@storybook/csf 0.0.2-next.1 → 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 +36 -30
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -99,12 +99,18 @@ declare type GlobalTypes = {
|
|
99
99
|
declare type StrictGlobalTypes = {
|
100
100
|
[name: string]: StrictInputType;
|
101
101
|
};
|
102
|
-
declare type
|
102
|
+
declare type Framework = {
|
103
|
+
/** What does is the type of the `component` annotation in this framework? */
|
103
104
|
component: unknown;
|
105
|
+
/** What does the story function return in this framework? */
|
104
106
|
storyResult: unknown;
|
107
|
+
/** What type of element does this framework render to? */
|
108
|
+
canvasElement: unknown;
|
105
109
|
T?: unknown;
|
106
110
|
};
|
107
|
-
|
111
|
+
/** @deprecated - use `Framework` */
|
112
|
+
declare type AnyFramework = Framework;
|
113
|
+
declare type StoryContextForEnhancers<TFramework extends Framework = Framework, TArgs = Args> = StoryIdentifier & {
|
108
114
|
component?: (TFramework & {
|
109
115
|
T: any;
|
110
116
|
})['component'];
|
@@ -115,8 +121,8 @@ declare type StoryContextForEnhancers<TFramework extends AnyFramework = AnyFrame
|
|
115
121
|
initialArgs: TArgs;
|
116
122
|
argTypes: StrictArgTypes<TArgs>;
|
117
123
|
};
|
118
|
-
declare type ArgsEnhancer<TFramework extends
|
119
|
-
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>) & {
|
120
126
|
secondPass?: boolean;
|
121
127
|
};
|
122
128
|
declare type StoryContextUpdate<TArgs = Args> = {
|
@@ -125,33 +131,33 @@ declare type StoryContextUpdate<TArgs = Args> = {
|
|
125
131
|
[key: string]: any;
|
126
132
|
};
|
127
133
|
declare type ViewMode = 'story' | 'docs';
|
128
|
-
declare type StoryContextForLoaders<TFramework extends
|
134
|
+
declare type StoryContextForLoaders<TFramework extends Framework = Framework, TArgs = Args> = StoryContextForEnhancers<TFramework, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
129
135
|
hooks: unknown;
|
130
136
|
viewMode: ViewMode;
|
131
137
|
originalStoryFn: StoryFn<TFramework>;
|
132
138
|
};
|
133
|
-
declare type LoaderFunction<TFramework extends
|
134
|
-
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> & {
|
135
141
|
loaded: Record<string, any>;
|
136
142
|
abortSignal: AbortSignal;
|
137
|
-
canvasElement:
|
143
|
+
canvasElement: TFramework['canvasElement'];
|
138
144
|
};
|
139
145
|
declare type StepLabel = string;
|
140
|
-
declare type StepFunction<TFramework extends
|
141
|
-
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> & {
|
142
148
|
step: StepFunction<TFramework, TArgs>;
|
143
149
|
};
|
144
|
-
declare type PlayFunction<TFramework extends
|
145
|
-
declare type PartialStoryFn<TFramework extends
|
146
|
-
declare type LegacyStoryFn<TFramework extends
|
147
|
-
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 & {
|
148
154
|
T: TArgs;
|
149
155
|
})['storyResult'];
|
150
|
-
declare type StoryFn<TFramework extends
|
151
|
-
declare type DecoratorFunction<TFramework extends
|
152
|
-
declare type DecoratorApplicator<TFramework extends
|
153
|
-
declare type StepRunner<TFramework extends
|
154
|
-
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> = {
|
155
161
|
/**
|
156
162
|
* Wrapper components or Storybook decorators that wrap a story.
|
157
163
|
*
|
@@ -184,7 +190,7 @@ declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TAr
|
|
184
190
|
*/
|
185
191
|
render?: ArgsStoryFn<TFramework, TArgs>;
|
186
192
|
};
|
187
|
-
declare type ProjectAnnotations<TFramework extends
|
193
|
+
declare type ProjectAnnotations<TFramework extends Framework = Framework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
188
194
|
argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
|
189
195
|
argTypesEnhancers?: ArgTypesEnhancer<TFramework, Args>[];
|
190
196
|
globals?: Globals;
|
@@ -193,7 +199,7 @@ declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework,
|
|
193
199
|
runStep?: StepRunner<TFramework, TArgs>;
|
194
200
|
};
|
195
201
|
declare type StoryDescriptor$1 = string[] | RegExp;
|
196
|
-
interface ComponentAnnotations<TFramework extends
|
202
|
+
interface ComponentAnnotations<TFramework extends Framework = Framework, TArgs = Args> extends BaseAnnotations<TFramework, TArgs> {
|
197
203
|
/**
|
198
204
|
* Title of the component which will be presented in the navigation. **Should be unique.**
|
199
205
|
*
|
@@ -269,7 +275,7 @@ interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, T
|
|
269
275
|
*/
|
270
276
|
tags?: Tag[];
|
271
277
|
}
|
272
|
-
declare type StoryAnnotations<TFramework extends
|
278
|
+
declare type StoryAnnotations<TFramework extends Framework = Framework, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TFramework, TArgs> & {
|
273
279
|
/**
|
274
280
|
* Override the display name in the UI (CSF v3)
|
275
281
|
*/
|
@@ -293,17 +299,17 @@ declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TA
|
|
293
299
|
} : {
|
294
300
|
args: TRequiredArgs;
|
295
301
|
});
|
296
|
-
declare type LegacyAnnotatedStoryFn<TFramework extends
|
297
|
-
declare type LegacyStoryAnnotationsOrFn<TFramework extends
|
298
|
-
declare type AnnotatedStoryFn<TFramework extends
|
299
|
-
declare type StoryAnnotationsOrFn<TFramework extends
|
300
|
-
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 {
|
301
307
|
render?: ArgsStoryFn<TFramework, infer RArgs>;
|
302
308
|
loaders?: (infer Loaders)[];
|
303
309
|
decorators?: (infer Decorators)[];
|
304
310
|
} ? Simplify<RArgs & DecoratorsArgs<TFramework, Decorators> & LoaderArgs<TFramework, Loaders>> : unknown;
|
305
|
-
declare type DecoratorsArgs<TFramework extends
|
306
|
-
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>;
|
307
313
|
|
308
314
|
/**
|
309
315
|
* Helper function to include/exclude an arg based on the value of other other args
|
@@ -346,4 +352,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
|
|
346
352
|
groups: string[];
|
347
353
|
};
|
348
354
|
|
349
|
-
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, Tag, 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 };
|