@storybook/csf 0.0.2-next.0 → 0.0.2-next.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +46 -30
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -39,6 +39,7 @@ declare type ComponentTitle = string;
|
|
39
39
|
declare type StoryName = string;
|
40
40
|
/** @deprecated */
|
41
41
|
declare type StoryKind = ComponentTitle;
|
42
|
+
declare type Tag = string;
|
42
43
|
interface StoryIdentifier {
|
43
44
|
componentId: ComponentId;
|
44
45
|
title: ComponentTitle;
|
@@ -48,6 +49,7 @@ interface StoryIdentifier {
|
|
48
49
|
name: StoryName;
|
49
50
|
/** @deprecated */
|
50
51
|
story: StoryName;
|
52
|
+
tags: Tag[];
|
51
53
|
}
|
52
54
|
declare type Parameters = {
|
53
55
|
[name: string]: any;
|
@@ -97,12 +99,18 @@ declare type GlobalTypes = {
|
|
97
99
|
declare type StrictGlobalTypes = {
|
98
100
|
[name: string]: StrictInputType;
|
99
101
|
};
|
100
|
-
declare type
|
102
|
+
declare type Framework = {
|
103
|
+
/** What does is the type of the `component` annotation in this framework? */
|
101
104
|
component: unknown;
|
105
|
+
/** What does the story function return in this framework? */
|
102
106
|
storyResult: unknown;
|
107
|
+
/** What type of element does this framework render to? */
|
108
|
+
canvasElement: unknown;
|
103
109
|
T?: unknown;
|
104
110
|
};
|
105
|
-
|
111
|
+
/** @deprecated - use `Framework` */
|
112
|
+
declare type AnyFramework = Framework;
|
113
|
+
declare type StoryContextForEnhancers<TFramework extends Framework = Framework, TArgs = Args> = StoryIdentifier & {
|
106
114
|
component?: (TFramework & {
|
107
115
|
T: any;
|
108
116
|
})['component'];
|
@@ -113,8 +121,8 @@ declare type StoryContextForEnhancers<TFramework extends AnyFramework = AnyFrame
|
|
113
121
|
initialArgs: TArgs;
|
114
122
|
argTypes: StrictArgTypes<TArgs>;
|
115
123
|
};
|
116
|
-
declare type ArgsEnhancer<TFramework extends
|
117
|
-
declare type ArgTypesEnhancer<TFramework extends
|
124
|
+
declare type ArgsEnhancer<TFramework extends Framework = Framework, TArgs = Args> = (context: StoryContextForEnhancers<TFramework, TArgs>) => TArgs;
|
125
|
+
declare type ArgTypesEnhancer<TFramework extends Framework = Framework, TArgs = Args> = ((context: StoryContextForEnhancers<TFramework, TArgs>) => StrictArgTypes<TArgs>) & {
|
118
126
|
secondPass?: boolean;
|
119
127
|
};
|
120
128
|
declare type StoryContextUpdate<TArgs = Args> = {
|
@@ -123,33 +131,33 @@ declare type StoryContextUpdate<TArgs = Args> = {
|
|
123
131
|
[key: string]: any;
|
124
132
|
};
|
125
133
|
declare type ViewMode = 'story' | 'docs';
|
126
|
-
declare type StoryContextForLoaders<TFramework extends
|
134
|
+
declare type StoryContextForLoaders<TFramework extends Framework = Framework, TArgs = Args> = StoryContextForEnhancers<TFramework, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
127
135
|
hooks: unknown;
|
128
136
|
viewMode: ViewMode;
|
129
137
|
originalStoryFn: StoryFn<TFramework>;
|
130
138
|
};
|
131
|
-
declare type LoaderFunction<TFramework extends
|
132
|
-
declare type StoryContext<TFramework extends
|
139
|
+
declare type LoaderFunction<TFramework extends Framework = Framework, TArgs = Args> = (context: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>;
|
140
|
+
declare type StoryContext<TFramework extends Framework = Framework, TArgs = Args> = StoryContextForLoaders<TFramework, TArgs> & {
|
133
141
|
loaded: Record<string, any>;
|
134
142
|
abortSignal: AbortSignal;
|
135
|
-
canvasElement:
|
143
|
+
canvasElement: TFramework['canvasElement'];
|
136
144
|
};
|
137
145
|
declare type StepLabel = string;
|
138
|
-
declare type StepFunction<TFramework extends
|
139
|
-
declare type PlayFunctionContext<TFramework extends
|
146
|
+
declare type StepFunction<TFramework extends Framework = Framework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>) => Promise<void> | void;
|
147
|
+
declare type PlayFunctionContext<TFramework extends Framework = Framework, TArgs = Args> = StoryContext<TFramework, TArgs> & {
|
140
148
|
step: StepFunction<TFramework, TArgs>;
|
141
149
|
};
|
142
|
-
declare type PlayFunction<TFramework extends
|
143
|
-
declare type PartialStoryFn<TFramework extends
|
144
|
-
declare type LegacyStoryFn<TFramework extends
|
145
|
-
declare type ArgsStoryFn<TFramework extends
|
150
|
+
declare type PlayFunction<TFramework extends Framework = Framework, TArgs = Args> = (context: PlayFunctionContext<TFramework, TArgs>) => Promise<void> | void;
|
151
|
+
declare type PartialStoryFn<TFramework extends Framework = Framework, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TFramework['storyResult'];
|
152
|
+
declare type LegacyStoryFn<TFramework extends Framework = Framework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
153
|
+
declare type ArgsStoryFn<TFramework extends Framework = Framework, TArgs = Args> = (args: TArgs, context: StoryContext<TFramework, TArgs>) => (TFramework & {
|
146
154
|
T: TArgs;
|
147
155
|
})['storyResult'];
|
148
|
-
declare type StoryFn<TFramework extends
|
149
|
-
declare type DecoratorFunction<TFramework extends
|
150
|
-
declare type DecoratorApplicator<TFramework extends
|
151
|
-
declare type StepRunner<TFramework extends
|
152
|
-
declare type BaseAnnotations<TFramework extends
|
156
|
+
declare type StoryFn<TFramework extends Framework = Framework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
|
157
|
+
declare type DecoratorFunction<TFramework extends Framework = Framework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
158
|
+
declare type DecoratorApplicator<TFramework extends Framework = Framework, TArgs = Args> = (storyFn: LegacyStoryFn<TFramework, TArgs>, decorators: DecoratorFunction<TFramework, TArgs>[]) => LegacyStoryFn<TFramework, TArgs>;
|
159
|
+
declare type StepRunner<TFramework extends Framework = Framework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>, context: PlayFunctionContext<TFramework, TArgs>) => Promise<void>;
|
160
|
+
declare type BaseAnnotations<TFramework extends Framework = Framework, TArgs = Args> = {
|
153
161
|
/**
|
154
162
|
* Wrapper components or Storybook decorators that wrap a story.
|
155
163
|
*
|
@@ -182,7 +190,7 @@ declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TAr
|
|
182
190
|
*/
|
183
191
|
render?: ArgsStoryFn<TFramework, TArgs>;
|
184
192
|
};
|
185
|
-
declare type ProjectAnnotations<TFramework extends
|
193
|
+
declare type ProjectAnnotations<TFramework extends Framework = Framework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
186
194
|
argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
|
187
195
|
argTypesEnhancers?: ArgTypesEnhancer<TFramework, Args>[];
|
188
196
|
globals?: Globals;
|
@@ -191,7 +199,7 @@ declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework,
|
|
191
199
|
runStep?: StepRunner<TFramework, TArgs>;
|
192
200
|
};
|
193
201
|
declare type StoryDescriptor$1 = string[] | RegExp;
|
194
|
-
interface ComponentAnnotations<TFramework extends
|
202
|
+
interface ComponentAnnotations<TFramework extends Framework = Framework, TArgs = Args> extends BaseAnnotations<TFramework, TArgs> {
|
195
203
|
/**
|
196
204
|
* Title of the component which will be presented in the navigation. **Should be unique.**
|
197
205
|
*
|
@@ -262,8 +270,12 @@ interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, T
|
|
262
270
|
* Function that is executed after the story is rendered.
|
263
271
|
*/
|
264
272
|
play?: PlayFunction<TFramework, TArgs>;
|
273
|
+
/**
|
274
|
+
* Named tags for a story, used to filter stories in different contexts.
|
275
|
+
*/
|
276
|
+
tags?: Tag[];
|
265
277
|
}
|
266
|
-
declare type StoryAnnotations<TFramework extends
|
278
|
+
declare type StoryAnnotations<TFramework extends Framework = Framework, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TFramework, TArgs> & {
|
267
279
|
/**
|
268
280
|
* Override the display name in the UI (CSF v3)
|
269
281
|
*/
|
@@ -276,6 +288,10 @@ declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TA
|
|
276
288
|
* Function that is executed after the story is rendered.
|
277
289
|
*/
|
278
290
|
play?: PlayFunction<TFramework, TArgs>;
|
291
|
+
/**
|
292
|
+
* Named tags for a story, used to filter stories in different contexts.
|
293
|
+
*/
|
294
|
+
tags?: Tag[];
|
279
295
|
/** @deprecated */
|
280
296
|
story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>;
|
281
297
|
} & ({} extends TRequiredArgs ? {
|
@@ -283,17 +299,17 @@ declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TA
|
|
283
299
|
} : {
|
284
300
|
args: TRequiredArgs;
|
285
301
|
});
|
286
|
-
declare type LegacyAnnotatedStoryFn<TFramework extends
|
287
|
-
declare type LegacyStoryAnnotationsOrFn<TFramework extends
|
288
|
-
declare type AnnotatedStoryFn<TFramework extends
|
289
|
-
declare type StoryAnnotationsOrFn<TFramework extends
|
290
|
-
declare type ArgsFromMeta<TFramework extends
|
302
|
+
declare type LegacyAnnotatedStoryFn<TFramework extends Framework = Framework, TArgs = Args> = StoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
|
303
|
+
declare type LegacyStoryAnnotationsOrFn<TFramework extends Framework = Framework, TArgs = Args> = LegacyAnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
|
304
|
+
declare type AnnotatedStoryFn<TFramework extends Framework = Framework, TArgs = Args> = ArgsStoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
|
305
|
+
declare type StoryAnnotationsOrFn<TFramework extends Framework = Framework, TArgs = Args> = AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
|
306
|
+
declare type ArgsFromMeta<TFramework extends Framework, Meta> = Meta extends {
|
291
307
|
render?: ArgsStoryFn<TFramework, infer RArgs>;
|
292
308
|
loaders?: (infer Loaders)[];
|
293
309
|
decorators?: (infer Decorators)[];
|
294
310
|
} ? Simplify<RArgs & DecoratorsArgs<TFramework, Decorators> & LoaderArgs<TFramework, Loaders>> : unknown;
|
295
|
-
declare type DecoratorsArgs<TFramework extends
|
296
|
-
declare type LoaderArgs<TFramework extends
|
311
|
+
declare type DecoratorsArgs<TFramework extends Framework, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TFramework, infer TArgs> ? TArgs : unknown>;
|
312
|
+
declare type LoaderArgs<TFramework extends Framework, Loaders> = UnionToIntersection<Loaders extends LoaderFunction<TFramework, infer TArgs> ? TArgs : unknown>;
|
297
313
|
|
298
314
|
/**
|
299
315
|
* Helper function to include/exclude an arg based on the value of other other args
|
@@ -336,4 +352,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
|
|
336
352
|
groups: string[];
|
337
353
|
};
|
338
354
|
|
339
|
-
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, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryKind, StoryName, StrictArgTypes, StrictGlobalTypes, StrictInputType, ViewMode, includeConditionalArg, isExportStory, parseKind, sanitize, storyNameFromExport, toId };
|
355
|
+
export { AnnotatedStoryFn, AnyFramework, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, ComponentAnnotations, ComponentId, ComponentTitle, Conditional, DecoratorApplicator, DecoratorFunction, Framework, GlobalTypes, Globals, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoaderFunction, Parameters, PartialStoryFn, PlayFunction, PlayFunctionContext, ProjectAnnotations, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryKind, StoryName, StrictArgTypes, StrictGlobalTypes, StrictInputType, Tag, ViewMode, includeConditionalArg, isExportStory, parseKind, sanitize, storyNameFromExport, toId };
|