@storybook/csf 0.0.2-next.0 → 0.0.2-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +46 -30
  2. 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 AnyFramework = {
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
- declare type StoryContextForEnhancers<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryIdentifier & {
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 AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForEnhancers<TFramework, TArgs>) => TArgs;
117
- declare type ArgTypesEnhancer<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ((context: StoryContextForEnhancers<TFramework, TArgs>) => StrictArgTypes<TArgs>) & {
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 AnyFramework = AnyFramework, TArgs = Args> = StoryContextForEnhancers<TFramework, TArgs> & Required<StoryContextUpdate<TArgs>> & {
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 AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>;
132
- declare type StoryContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContextForLoaders<TFramework, TArgs> & {
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: HTMLElement;
143
+ canvasElement: TFramework['canvasElement'];
136
144
  };
137
145
  declare type StepLabel = string;
138
- declare type StepFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>) => Promise<void> | void;
139
- declare type PlayFunctionContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContext<TFramework, TArgs> & {
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 AnyFramework = AnyFramework, TArgs = Args> = (context: PlayFunctionContext<TFramework, TArgs>) => Promise<void> | void;
143
- declare type PartialStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TFramework['storyResult'];
144
- declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
145
- declare type ArgsStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (args: TArgs, context: StoryContext<TFramework, TArgs>) => (TFramework & {
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 AnyFramework = AnyFramework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
149
- declare type DecoratorFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
150
- declare type DecoratorApplicator<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (storyFn: LegacyStoryFn<TFramework, TArgs>, decorators: DecoratorFunction<TFramework, TArgs>[]) => LegacyStoryFn<TFramework, TArgs>;
151
- declare type StepRunner<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>, context: PlayFunctionContext<TFramework, TArgs>) => Promise<void>;
152
- declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = {
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 AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
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 AnyFramework = AnyFramework, TArgs = Args> extends BaseAnnotations<TFramework, TArgs> {
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 AnyFramework = AnyFramework, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TFramework, TArgs> & {
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 AnyFramework = AnyFramework, TArgs = Args> = StoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
287
- declare type LegacyStoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyAnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
288
- declare type AnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ArgsStoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
289
- declare type StoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
290
- declare type ArgsFromMeta<TFramework extends AnyFramework, Meta> = Meta 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 AnyFramework, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TFramework, infer TArgs> ? TArgs : unknown>;
296
- declare type LoaderArgs<TFramework extends AnyFramework, Loaders> = UnionToIntersection<Loaders extends LoaderFunction<TFramework, infer TArgs> ? TArgs : unknown>;
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/csf",
3
- "version": "0.0.2-next.0",
3
+ "version": "0.0.2-next.2",
4
4
  "description": "Component Story Format (CSF) utilities",
5
5
  "keywords": [
6
6
  "storybook",