diff --git a/docs/app/components/content/AIContentWidget.vue b/docs/app/components/content/AIContentWidget.vue new file mode 100644 index 0000000000..3ce6a78ad4 --- /dev/null +++ b/docs/app/components/content/AIContentWidget.vue @@ -0,0 +1,226 @@ + + + + + + + diff --git a/docs/app/components/content/ComponentCode.vue b/docs/app/components/content/ComponentCode.vue index 3cbbea09a7..9f6ab4a291 100644 --- a/docs/app/components/content/ComponentCode.vue +++ b/docs/app/components/content/ComponentCode.vue @@ -7,6 +7,7 @@ import { hash } from 'ohash' import { CalendarDate } from '@internationalized/date' import * as theme from '#build/ui' import { get, set } from '#ui/utils' +import type { AIContentWidgetProps } from './AIContentWidget.vue' interface Cast { get: (args: any) => any @@ -80,6 +81,10 @@ const props = defineProps<{ * Whether to add overflow-hidden to wrapper */ overflowHidden?: boolean + /** + * AI generation configuration - true to enable with defaults, object to customize + */ + ai?: AIContentWidgetProps['ai'] }>() const route = useRoute() @@ -300,6 +305,21 @@ ${props.slots?.default} return code }) +function handleAIGenerated(generatedContent: any) { + try { + // Apply generated content to component props + Object.entries(generatedContent).forEach(([key, value]) => { + if (value !== undefined && value !== null) { + setComponentProp(key, value) + } + }) + + console.log('Applied generated content:', generatedContent) + } catch (error) { + console.error('Error applying generated content:', error) + } +} + const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props: componentProps, slots: props.slots, external: props.external, externalTypes: props.externalTypes, collapse: props.collapse })}`, async () => { if (!props.prettier) { return parseMarkdown(code.value) @@ -322,7 +342,7 @@ const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props: