import type { AllowedComponentProps, Component, VNodeChild, VNodeProps } from 'vue'; type AnyComponent = (abstract new (...args: any[]) => any) | ((...args: any[]) => any); type ExtractInstanceProps = C extends abstract new (...args: any[]) => { $props: infer P; } ? P : C extends (props: infer P, ...rest: any[]) => any ? P : Record; /** * Extracts the public props of a Vue component, with Vue's built-in keys * (`key`, `ref`, `class`, `style`, …) stripped out so only the props the * component itself declares — including `modelValue` and `onUpdate:*` — remain. */ export type ComponentProps = Omit, keyof VNodeProps | keyof AllowedComponentProps>; export type EditorComponentVariantSlots = Record VNodeChild | string>; export interface EditorComponentVariant> { /** Short label shown above the rendered variant. */ label: string; /** Optional longer description. */ description?: string; /** Props passed to the component, fully typed. */ props: Partial; /** * Slot render functions, keyed by slot name. The default slot is `default`. * Each function may return any VNode-compatible value. */ slots?: EditorComponentVariantSlots; /** * Optional override for the entry-level `backgroundClass`. Useful when a * single variant needs a different stage background to remain legible. */ backgroundClass?: string; } export interface EditorComponentMeta { /** Discriminator — distinguishes from snippet entries. */ kind: 'component'; /** Unique identifier (used in URLs / sidebar). */ id: string; /** Display name. */ label: string; /** Optional category — used to group entries in the styleguide sidebar. */ category?: string; /** Optional description shown above the variants. */ description?: string; /** The component being documented. */ component: C; /** * Optional class applied to each variant's stage in place of the default * white background. Useful for components that need a themed background to * be legible (e.g. white-on-dark). */ backgroundClass?: string; /** One or more variants demonstrating different prop/slot combinations. */ variants: EditorComponentVariant>[]; } interface EditorSnippetVariantBase { /** Short label shown above the rendered variant. */ label: string; /** Optional longer description. */ description?: string; /** * Optional override for the entry-level `backgroundClass`. Useful when a * single variant needs a different stage background to remain legible. */ backgroundClass?: string; } interface EditorSnippetVariantRender extends EditorSnippetVariantBase { /** Render function returning the VNodes that demonstrate the snippet. */ render: () => VNodeChild | string; component?: never; } interface EditorSnippetVariantComponent extends EditorSnippetVariantBase { /** * Component that renders the snippet. Use when the example is large enough * that a `