1 |
|
2 | import { AnyFramework, InputType, StoryContext as StoryContextForFramework, LegacyStoryFn as LegacyStoryFnForFramework, PartialStoryFn as PartialStoryFnForFramework, ArgsStoryFn as ArgsStoryFnForFramework, StoryFn as StoryFnForFramework, DecoratorFunction as DecoratorFunctionForFramework, LoaderFunction as LoaderFunctionForFramework, StoryId, StoryKind, StoryName, Args } from '@storybook/csf';
|
3 | import { Addon } from './index';
|
4 | export type { StoryId, StoryKind, StoryName, StoryIdentifier, ViewMode, Args, } from '@storybook/csf';
|
5 | export interface ArgType<TArg = unknown> extends InputType {
|
6 | defaultValue?: TArg;
|
7 | }
|
8 | export declare type ArgTypes<TArgs = Args> = {
|
9 | [key in keyof Partial<TArgs>]: ArgType<TArgs[key]>;
|
10 | } & {
|
11 | [key in string]: ArgType<unknown>;
|
12 | };
|
13 | export declare type Comparator<T> = ((a: T, b: T) => boolean) | ((a: T, b: T) => number);
|
14 | export declare type StorySortMethod = 'configure' | 'alphabetical';
|
15 | export interface StorySortObjectParameter {
|
16 | method?: StorySortMethod;
|
17 | order?: any[];
|
18 | locales?: string;
|
19 | includeNames?: boolean;
|
20 | }
|
21 | interface StoryIndexEntry {
|
22 | id: StoryId;
|
23 | name: StoryName;
|
24 | title: string;
|
25 | importPath: string;
|
26 | }
|
27 | export declare type StorySortComparator = Comparator<[StoryId, any, Parameters, Parameters]>;
|
28 | export declare type StorySortParameter = StorySortComparator | StorySortObjectParameter;
|
29 | export declare type StorySortComparatorV7 = Comparator<StoryIndexEntry>;
|
30 | export declare type StorySortParameterV7 = StorySortComparatorV7 | StorySortObjectParameter;
|
31 | export interface OptionsParameter extends Object {
|
32 | storySort?: StorySortParameter;
|
33 | theme?: {
|
34 | base: string;
|
35 | brandTitle?: string;
|
36 | };
|
37 | [key: string]: any;
|
38 | }
|
39 | export interface Parameters {
|
40 | fileName?: string;
|
41 | options?: OptionsParameter;
|
42 | /** The layout property defines basic styles added to the preview body where the story is rendered. If you pass 'none', no styles are applied. */
|
43 | layout?: 'centered' | 'fullscreen' | 'padded' | 'none';
|
44 | docsOnly?: boolean;
|
45 | [key: string]: any;
|
46 | }
|
47 | export declare type StoryContext = StoryContextForFramework<AnyFramework>;
|
48 | export declare type StoryContextUpdate = Partial<StoryContext>;
|
49 | declare type ReturnTypeFramework<ReturnType> = {
|
50 | component: any;
|
51 | storyResult: ReturnType;
|
52 | };
|
53 | export declare type PartialStoryFn<ReturnType = unknown> = PartialStoryFnForFramework<ReturnTypeFramework<ReturnType>>;
|
54 | export declare type LegacyStoryFn<ReturnType = unknown> = LegacyStoryFnForFramework<ReturnTypeFramework<ReturnType>>;
|
55 | export declare type ArgsStoryFn<ReturnType = unknown> = ArgsStoryFnForFramework<ReturnTypeFramework<ReturnType>>;
|
56 | export declare type StoryFn<ReturnType = unknown> = StoryFnForFramework<ReturnTypeFramework<ReturnType>>;
|
57 | export declare type DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunctionForFramework<ReturnTypeFramework<StoryFnReturnType>>;
|
58 | export declare type LoaderFunction = LoaderFunctionForFramework<ReturnTypeFramework<unknown>>;
|
59 | export declare enum types {
|
60 | TAB = "tab",
|
61 | PANEL = "panel",
|
62 | TOOL = "tool",
|
63 | TOOLEXTRA = "toolextra",
|
64 | PREVIEW = "preview",
|
65 | NOTES_ELEMENT = "notes-element"
|
66 | }
|
67 | export declare type Types = types | string;
|
68 | export declare function isSupportedType(type: Types): boolean;
|
69 | export interface WrapperSettings {
|
70 | options: object;
|
71 | parameters: {
|
72 | [key: string]: any;
|
73 | };
|
74 | }
|
75 | export declare type StoryWrapper = (storyFn: LegacyStoryFn, context: StoryContext, settings: WrapperSettings) => any;
|
76 | export declare type MakeDecoratorResult = (...args: any) => any;
|
77 | export interface AddStoryArgs<StoryFnReturnType = unknown> {
|
78 | id: StoryId;
|
79 | kind: StoryKind;
|
80 | name: StoryName;
|
81 | storyFn: StoryFn<StoryFnReturnType>;
|
82 | parameters: Parameters;
|
83 | }
|
84 | export interface ClientApiAddon<StoryFnReturnType = unknown> extends Addon {
|
85 | apply: (a: StoryApi<StoryFnReturnType>, b: any[]) => any;
|
86 | }
|
87 | export interface ClientApiAddons<StoryFnReturnType> {
|
88 | [key: string]: ClientApiAddon<StoryFnReturnType>;
|
89 | }
|
90 | export interface IStorybookStory {
|
91 | name: string;
|
92 | render: (context: any) => any;
|
93 | }
|
94 | export interface IStorybookSection {
|
95 | kind: string;
|
96 | stories: IStorybookStory[];
|
97 | }
|
98 | export declare type ClientApiReturnFn<StoryFnReturnType = unknown> = (...args: any[]) => StoryApi<StoryFnReturnType>;
|
99 | export interface StoryApi<StoryFnReturnType = unknown> {
|
100 | kind: StoryKind;
|
101 | add: (storyName: StoryName, storyFn: StoryFn<StoryFnReturnType>, parameters?: Parameters) => StoryApi<StoryFnReturnType>;
|
102 | addDecorator: (decorator: DecoratorFunction<StoryFnReturnType>) => StoryApi<StoryFnReturnType>;
|
103 | addLoader: (decorator: LoaderFunction) => StoryApi<StoryFnReturnType>;
|
104 | addParameters: (parameters: Parameters) => StoryApi<StoryFnReturnType>;
|
105 | [k: string]: string | ClientApiReturnFn<StoryFnReturnType>;
|
106 | }
|
107 | export interface ClientStoryApi<StoryFnReturnType = unknown> {
|
108 | storiesOf(kind: StoryKind, module: NodeModule): StoryApi<StoryFnReturnType>;
|
109 | addDecorator(decorator: DecoratorFunction<StoryFnReturnType>): StoryApi<StoryFnReturnType>;
|
110 | addParameters(parameter: Parameters): StoryApi<StoryFnReturnType>;
|
111 | }
|
112 | declare type LoadFn = () => any;
|
113 | declare type RequireContext = any;
|
114 | export declare type Loadable = RequireContext | [RequireContext] | LoadFn;
|
115 | export declare type BaseDecorators<StoryFnReturnType> = Array<(story: () => StoryFnReturnType, context: StoryContext) => StoryFnReturnType>;
|
116 | export interface BaseAnnotations<Args, StoryFnReturnType> {
|
117 | |
118 |
|
119 |
|
120 |
|
121 | args?: Partial<Args>;
|
122 | |
123 |
|
124 |
|
125 |
|
126 | argTypes?: ArgTypes<Args>;
|
127 | |
128 |
|
129 |
|
130 |
|
131 | parameters?: Parameters;
|
132 | |
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | decorators?: BaseDecorators<StoryFnReturnType>;
|
139 | |
140 |
|
141 |
|
142 | render?: (args: Args, context: StoryContext) => StoryFnReturnType;
|
143 | |
144 |
|
145 |
|
146 | play?: (context: StoryContext) => Promise<void> | void;
|
147 | }
|
148 | export interface Annotations<Args, StoryFnReturnType> extends BaseAnnotations<Args, StoryFnReturnType> {
|
149 | |
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | includeStories?: string[] | RegExp;
|
158 | |
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | excludeStories?: string[] | RegExp;
|
167 | }
|
168 | export interface BaseMeta<ComponentType> {
|
169 | |
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 | title?: string;
|
185 | |
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 | id?: string;
|
193 | |
194 |
|
195 |
|
196 |
|
197 |
|
198 | component?: ComponentType;
|
199 | |
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 | subcomponents?: Record<string, ComponentType>;
|
215 | }
|
216 | export declare type BaseStoryObject<Args, StoryFnReturnType> = {
|
217 | |
218 |
|
219 |
|
220 | storyName?: string;
|
221 | };
|
222 | export declare type BaseStoryFn<Args, StoryFnReturnType> = {
|
223 | (args: Args, context: StoryContext): StoryFnReturnType;
|
224 | } & BaseStoryObject<Args, StoryFnReturnType>;
|
225 | export declare type BaseStory<Args, StoryFnReturnType> = BaseStoryFn<Args, StoryFnReturnType> | BaseStoryObject<Args, StoryFnReturnType>;
|