import type { JSX } from './components'; import type { NovaCategoryId } from './nova-categories'; type Optional = Partial> & Omit; /** * See https://github.com/Sidnioulz/storybook-addon-tag-badges for customizing * the Badges. Any changes requires additional styles in the blazor storybook * at blazor/BlazingStory/BlazingStory/Internals/Components/SideBar/NavigationTree/TagBadges.razor.scss * Make sure to reflect any changes in the documentation as well. docs/feature-flags.md * Also update the storybook manager.ts file in the respective packages: * - packages/angular/.storybook/manager.ts * - packages/react/.storybook/manager.ts * - packages/vue/.storybook/manager.ts * - packages/native/.storybook/manager.ts */ export type NovaBadge = 'new' | 'beta' | 'deprecated' | 'danger'; export type NovaTemplate = string; export type NovaComponent = keyof JSX.IntrinsicElements; /** * One authored control of an interactive playground story. Values are spliced * into the story template at every data-storybook-args position — the same * place story args land today — so a prop hard-coded after that marker on an * element wins over the control (normal spread semantics). Interactive * stories should therefore not hard-code controlled props. */ export type NovaStoryControl = { /** Component prop this control binds to. */ prop: Extract; /** Interaction-panel label, defaults to the prop name. */ label?: string; /** Initial value; falls back to the story's args entry, else unset. */ defaultValue?: string | number | boolean; } & ( | { /** Free-text input. */ control: 'text'; } | { /** Checkbox toggle. */ control: 'boolean'; } | { /** Numeric input. */ control: 'number'; /** Smallest accepted value. */ min?: number; /** Largest accepted value. */ max?: number; /** Input stepping. */ step?: number; } | { /** Fixed-option dropdown. */ control: 'select'; /** Selectable values in display order. */ options: ReadonlyArray; } ); export type NovaDocs = T extends NovaTemplate ? Omit, 'component'> : NovaDocsGeneric; /** * Generic Interface for the NovaDocs object */ export interface NovaDocsGeneric { /** * Will not render the component in storybook, useful for composed components */ skip?: boolean; /** * Add a badge to the sidebar in storybook group */ badge?: NovaBadge; /** * Parent grouping name for organizing related components together. * When set, creates a hierarchy under components: "components/parent-component/sub-component" * Use the parent component name (e.g., 'nv-breadcrumbs') to group child components. * Example: parentGroup: 'nv-breadcrumbs' creates "components/nv-breadcrumbs/nv-breadcrumb" */ parentGroup?: string; /** * Playground sidebar category. Author it on family roots and standalone * components only; family members inherit it from their memberOf root. * Storybook ignores this field. */ category?: NovaCategoryId; /** * Playground display name for the sidebar entry and page heading, e.g. * 'Sidebar'. Defaults to a title-cased tag when omitted. Storybook ignores * this field. */ displayName?: string; /** * Marks this component as a member of a component family; the value is the * family root's tag (e.g. 'nv-sidebar' on nv-sidebarheader.docs.tsx). * Members get no playground sidebar entry of their own — they become * toggleable sections of the root's page. Storybook ignores this field and * keeps using parentGroup for its title hierarchy. */ memberOf?: NovaComponent; /** * Tag name of the component */ component: T extends NovaTemplate ? undefined : NovaComponent; /** * List of components that will be rendered inside the component's docs, * required for correct imports */ subcomponents?: Array; /** * List of components that will be used for composition. Will render * additional docs tabs with props etc. for them. */ composedComponents?: Array; /** * Each item will be rendered as a story in each storybook. */ stories?: Array< { /** * Name of the story */ name: string; /** API members demonstrated by this story; inferred from its name/template when omitted. */ api?: { /** Native properties demonstrated by this story. */ props?: Array>; /** Native event names, resolved to each framework's public event API. */ events?: string[]; /** Slot names; use `default` for the unnamed slot. */ slots?: string[]; /** Public component methods exercised by this story. */ methods?: Array>; }; /** * Add a badge to the sidebar in individual story */ badge?: NovaBadge; /** * Props to pass to the component */ args?: T extends NovaTemplate ? undefined : Partial; /** * Template to render the component with the args passed in the story args * object above (optional) */ template: JSX.Element; /** * Skips rendering the source code for the story, useful for very long * lists of elements that demo the component, and improves performance */ disableSource?: boolean; /** * Derives interaction-panel controls from the component's own prop * metadata, so a story does not have to restate props it already * documents. Props with non-primitive types, an `@icon` tag, a * deprecation, or a value hard-coded on the args element are skipped. * Storybook ignores this field. */ showControls?: T extends NovaTemplate ? undefined : boolean; /** * Props to leave out of the derived controls, for knobs that would only * add noise. Requires `showControls`. Storybook ignores this field. */ hiddenControls?: T extends NovaTemplate ? undefined : Array>; /** * Authored interaction-panel controls. On their own they mark the story * as the playground's interactive story; alongside `showControls` they * replace a derived control of the same prop and append the rest. * Storybook ignores this field. */ controls?: T extends NovaTemplate ? undefined : Array>; } & StoryDescription >; } type StoryDescription = T extends NovaTemplate ? { /** * Description of the story, required for template stories */ description: string; } : { /** * Description of the story, leave blank to automatically infer from prop * descriptions */ description?: string; /** * If the description is not provided, infer it from the prop descriptions * from another component (for example child components that are described * in the parent story, see nv-dialog as an example) */ descriptionSource?: NovaComponent; };