import { Simplify, RemoveIndexSignature, UnionToIntersection } from 'type-fest'; interface SBBaseType { required?: boolean; raw?: string; } type SBScalarType = SBBaseType & { name: 'boolean' | 'string' | 'number' | 'function' | 'symbol'; }; type SBArrayType = SBBaseType & { name: 'array'; value: SBType; }; type SBObjectType = SBBaseType & { name: 'object'; value: Record; }; type SBEnumType = SBBaseType & { name: 'enum'; value: (string | number)[]; }; type SBIntersectionType = SBBaseType & { name: 'intersection'; value: SBType[]; }; type SBUnionType = SBBaseType & { name: 'union'; value: SBType[]; }; type SBOtherType = SBBaseType & { name: 'other'; value: string; }; type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType; type StoryId = string; type ComponentId = string; type ComponentTitle = string; type StoryName = string; /** @deprecated */ type StoryKind = ComponentTitle; type Tag = string; interface StoryIdentifier { componentId: ComponentId; title: ComponentTitle; /** @deprecated */ kind: ComponentTitle; id: StoryId; name: StoryName; /** @deprecated */ story: StoryName; tags: Tag[]; } interface Parameters { [name: string]: any; } interface StrictParameters { [name: string]: unknown; } type ConditionalTest = { truthy?: boolean; } | { exists: boolean; } | { eq: any; } | { neq: any; }; type ConditionalValue = { arg: string; } | { global: string; }; type Conditional = ConditionalValue & ConditionalTest; interface InputType { name?: string; description?: string; defaultValue?: any; type?: SBType | SBScalarType['name']; if?: Conditional; [key: string]: any; } interface StrictInputType extends InputType { name: string; type?: SBType; } interface Args { [name: string]: any; } interface StrictArgs { [name: string]: unknown; } type ArgTypes = { [name in keyof TArgs]: InputType; }; type StrictArgTypes = { [name in keyof TArgs]: StrictInputType; }; interface Globals { [name: string]: any; } interface GlobalTypes { [name: string]: InputType; } interface StrictGlobalTypes { [name: string]: StrictInputType; } type Renderer = { /** What is the type of the `component` annotation in this renderer? */ component: unknown; /** What does the story function return in this renderer? */ storyResult: unknown; /** What type of element does this renderer render to? */ canvasElement: unknown; T?: unknown; }; /** @deprecated - use `Renderer` */ type AnyFramework = Renderer; interface StoryContextForEnhancers extends StoryIdentifier { component?: (TRenderer & { T: any; })['component']; subcomponents?: Record; parameters: Parameters; initialArgs: TArgs; argTypes: StrictArgTypes; } type ArgsEnhancer = (context: StoryContextForEnhancers) => TArgs; type ArgTypesEnhancer = ((context: StoryContextForEnhancers) => StrictArgTypes) & { secondPass?: boolean; }; interface StoryContextUpdate { args?: TArgs; globals?: Globals; [key: string]: any; } type ViewMode = 'story' | 'docs'; interface StoryContextForLoaders extends StoryContextForEnhancers, Required> { hooks: unknown; viewMode: ViewMode; originalStoryFn: StoryFn; } type LoaderFunction = (context: StoryContextForLoaders) => Promise | void> | Record | void; interface StoryContext extends StoryContextForLoaders { loaded: Record; abortSignal: AbortSignal; canvasElement: TRenderer['canvasElement']; } type StepLabel = string; type StepFunction = (label: StepLabel, play: PlayFunction) => Promise | void; type PlayFunctionContext = StoryContext & { step: StepFunction; }; type PlayFunction = (context: PlayFunctionContext) => Promise | void; type PartialStoryFn = (update?: StoryContextUpdate>) => TRenderer['storyResult']; type LegacyStoryFn = (context: StoryContext) => TRenderer['storyResult']; type ArgsStoryFn = (args: TArgs, context: StoryContext) => (TRenderer & { T: TArgs; })['storyResult']; type StoryFn = LegacyStoryFn | ArgsStoryFn; type DecoratorFunction = (fn: PartialStoryFn, c: StoryContext) => TRenderer['storyResult']; type DecoratorApplicator = (storyFn: LegacyStoryFn, decorators: DecoratorFunction[]) => LegacyStoryFn; type StepRunner = (label: StepLabel, play: PlayFunction, context: PlayFunctionContext) => Promise; type BaseAnnotations = { /** * Wrapper components or Storybook decorators that wrap a story. * * Decorators defined in Meta will be applied to every story variation. * @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators) */ decorators?: DecoratorFunction>[] | DecoratorFunction>; /** * Custom metadata for a story. * @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters) */ parameters?: Parameters; /** * Dynamic data that are provided (and possibly updated by) Storybook and its addons. * @see [Arg story inputs](https://storybook.js.org/docs/react/api/csf#args-story-inputs) */ args?: Partial; /** * ArgTypes encode basic metadata for args, such as `name`, `description`, `defaultValue` for an arg. These get automatically filled in by Storybook Docs. * @see [Control annotations](https://github.com/storybookjs/storybook/blob/91e9dee33faa8eff0b342a366845de7100415367/addons/controls/README.md#control-annotations) */ argTypes?: Partial>; /** * Asynchronous functions which provide data for a story. * @see [Loaders](https://storybook.js.org/docs/react/writing-stories/loaders) */ loaders?: LoaderFunction[] | LoaderFunction; /** * Define a custom render function for the story(ies). If not passed, a default render function by the renderer will be used. */ render?: ArgsStoryFn; }; type ProjectAnnotations = BaseAnnotations & { argsEnhancers?: ArgsEnhancer[]; argTypesEnhancers?: ArgTypesEnhancer[]; globals?: Globals; globalTypes?: GlobalTypes; applyDecorators?: DecoratorApplicator; runStep?: StepRunner; }; type StoryDescriptor$1 = string[] | RegExp; interface ComponentAnnotations extends BaseAnnotations { /** * Title of the component which will be presented in the navigation. **Should be unique.** * * Components can be organized in a nested structure using "/" as a separator. * * Since CSF 3.0 this property is optional -- it can be inferred from the filesystem path * * @example * export default { * ... * title: 'Design System/Atoms/Button' * } * * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy) */ title?: ComponentTitle; /** * Id of the component (prefix of the story id) which is used for URLs. * * By default is inferred from sanitizing the title * * @see [Story Hierarchy](https://storybook.js.org/docs/basics/writing-stories/#story-hierarchy) */ id?: ComponentId; /** * Used to only include certain named exports as stories. Useful when you want to have non-story exports such as mock data or ignore a few stories. * @example * includeStories: ['SimpleStory', 'ComplexStory'] * includeStories: /.*Story$/ * * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports) */ includeStories?: StoryDescriptor$1; /** * Used to exclude certain named exports. Useful when you want to have non-story exports such as mock data or ignore a few stories. * @example * excludeStories: ['simpleData', 'complexData'] * excludeStories: /.*Data$/ * * @see [Non-story exports](https://storybook.js.org/docs/formats/component-story-format/#non-story-exports) */ excludeStories?: StoryDescriptor$1; /** * The primary component for your story. * * Used by addons for automatic prop table generation and display of other component metadata. */ component?: (TRenderer & { T: Record extends Required ? any : TArgs; })['component']; /** * Auxiliary subcomponents that are part of the stories. * * Used by addons for automatic prop table generation and display of other component metadata. * * @example * import { Button, ButtonGroup } from './components'; * * export default { * ... * subcomponents: { Button, ButtonGroup } * } * * By defining them each component will have its tab in the args table. */ subcomponents?: Record; /** * Function that is executed after the story is rendered. */ play?: PlayFunction; /** * Named tags for a story, used to filter stories in different contexts. */ tags?: Tag[]; } type StoryAnnotations> = BaseAnnotations & { /** * Override the display name in the UI (CSF v3) */ name?: StoryName; /** * Override the display name in the UI (CSF v2) */ storyName?: StoryName; /** * Function that is executed after the story is rendered. */ play?: PlayFunction; /** * Named tags for a story, used to filter stories in different contexts. */ tags?: Tag[]; /** @deprecated */ story?: Omit, 'story'>; } & ({} extends TRequiredArgs ? { args?: TRequiredArgs; } : { args: TRequiredArgs; }); type LegacyAnnotatedStoryFn = StoryFn & StoryAnnotations; type LegacyStoryAnnotationsOrFn = LegacyAnnotatedStoryFn | StoryAnnotations; type AnnotatedStoryFn = ArgsStoryFn & StoryAnnotations; type StoryAnnotationsOrFn = AnnotatedStoryFn | StoryAnnotations; type ArgsFromMeta = Meta extends { render?: ArgsStoryFn; loaders?: (infer Loaders)[] | infer Loaders; decorators?: (infer Decorators)[] | infer Decorators; } ? Simplify & LoaderArgs>> : unknown; type DecoratorsArgs = UnionToIntersection ? TArgs : unknown>; type LoaderArgs = UnionToIntersection ? TArgs : unknown>; /** * Helper function to include/exclude an arg based on the value of other other args * aka "conditional args" */ declare const includeConditionalArg: (argType: InputType, args: Args, globals: Globals) => any; /** * Remove punctuation and illegal characters from a story ID. * * See https://gist.github.com/davidjrice/9d2af51100e41c6c4b4a */ declare const sanitize: (string: string) => string; /** * Generate a storybook ID from a component/kind and story name. */ declare const toId: (kind: string, name?: string) => string; /** * Transform a CSF named export into a readable story name */ declare const storyNameFromExport: (key: string) => string; type StoryDescriptor = string[] | RegExp; interface IncludeExcludeOptions { includeStories?: StoryDescriptor; excludeStories?: StoryDescriptor; } /** * Does a named export match CSF inclusion/exclusion options? */ declare function isExportStory(key: string, { includeStories, excludeStories }: IncludeExcludeOptions): boolean | null; interface SeparatorOptions { rootSeparator: string | RegExp; groupSeparator: string | RegExp; } /** * Parse out the component/kind name from a path, using the given separator config. */ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: SeparatorOptions) => { root: string | null; groups: string[]; }; export { AnnotatedStoryFn, AnyFramework, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, ComponentAnnotations, ComponentId, ComponentTitle, Conditional, DecoratorApplicator, DecoratorFunction, GlobalTypes, Globals, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoaderFunction, Parameters, PartialStoryFn, PlayFunction, PlayFunctionContext, ProjectAnnotations, Renderer, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryKind, StoryName, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, StrictParameters, Tag, ViewMode, includeConditionalArg, isExportStory, parseKind, sanitize, storyNameFromExport, toId };