@storybook/csf 0.0.2--canary.5b59926.0 → 0.0.2--canary.795e486.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/index.d.ts +44 -34
  2. 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 AnyFramework = {
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
- 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 & {
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 AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForEnhancers<TFramework, TArgs>) => TArgs;
119
- 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>) & {
120
126
  secondPass?: boolean;
121
127
  };
122
128
  declare type StoryContextUpdate<TArgs = Args> = {
@@ -125,37 +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 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>> & {
129
135
  hooks: unknown;
130
136
  viewMode: ViewMode;
131
137
  originalStoryFn: StoryFn<TFramework>;
132
138
  };
133
- declare type LoaderFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>;
134
- 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> & {
135
141
  loaded: Record<string, any>;
136
142
  abortSignal: AbortSignal;
137
- canvasElement: HTMLElement;
143
+ canvasElement: TFramework['canvasElement'];
138
144
  };
139
145
  declare type StepLabel = string;
140
- declare type StepFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>) => Promise<void> | void;
141
- 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> & {
142
148
  step: StepFunction<TFramework, TArgs>;
143
149
  };
144
- declare type PlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: PlayFunctionContext<TFramework, TArgs>) => Promise<void> | void;
145
- declare type PartialStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TFramework['storyResult'];
146
- declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
147
- 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 & {
148
154
  T: TArgs;
149
155
  })['storyResult'];
150
- declare type StoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
151
- declare type DecoratorFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
152
- declare type DecoratorApplicator<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (storyFn: LegacyStoryFn<TFramework, TArgs>, decorators: DecoratorFunction<TFramework, TArgs>[]) => LegacyStoryFn<TFramework, TArgs>;
153
- declare type StepRunner<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>, context: PlayFunctionContext<TFramework, TArgs>) => Promise<void>;
154
- declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = {
155
- /**
156
- * Named tags for a story, used to filter stories in different contexts.
157
- */
158
- tags?: Tag[];
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> = {
159
161
  /**
160
162
  * Wrapper components or Storybook decorators that wrap a story.
161
163
  *
@@ -188,7 +190,7 @@ declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TAr
188
190
  */
189
191
  render?: ArgsStoryFn<TFramework, TArgs>;
190
192
  };
191
- 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> & {
192
194
  argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
193
195
  argTypesEnhancers?: ArgTypesEnhancer<TFramework, Args>[];
194
196
  globals?: Globals;
@@ -197,7 +199,7 @@ declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework,
197
199
  runStep?: StepRunner<TFramework, TArgs>;
198
200
  };
199
201
  declare type StoryDescriptor$1 = string[] | RegExp;
200
- 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> {
201
203
  /**
202
204
  * Title of the component which will be presented in the navigation. **Should be unique.**
203
205
  *
@@ -268,8 +270,12 @@ interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, T
268
270
  * Function that is executed after the story is rendered.
269
271
  */
270
272
  play?: PlayFunction<TFramework, TArgs>;
273
+ /**
274
+ * Named tags for a story, used to filter stories in different contexts.
275
+ */
276
+ tags?: Tag[];
271
277
  }
272
- 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> & {
273
279
  /**
274
280
  * Override the display name in the UI (CSF v3)
275
281
  */
@@ -282,6 +288,10 @@ declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TA
282
288
  * Function that is executed after the story is rendered.
283
289
  */
284
290
  play?: PlayFunction<TFramework, TArgs>;
291
+ /**
292
+ * Named tags for a story, used to filter stories in different contexts.
293
+ */
294
+ tags?: Tag[];
285
295
  /** @deprecated */
286
296
  story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>;
287
297
  } & ({} extends TRequiredArgs ? {
@@ -289,17 +299,17 @@ declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TA
289
299
  } : {
290
300
  args: TRequiredArgs;
291
301
  });
292
- declare type LegacyAnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
293
- declare type LegacyStoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyAnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
294
- declare type AnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ArgsStoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
295
- declare type StoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
296
- 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 {
297
307
  render?: ArgsStoryFn<TFramework, infer RArgs>;
298
308
  loaders?: (infer Loaders)[];
299
309
  decorators?: (infer Decorators)[];
300
310
  } ? Simplify<RArgs & DecoratorsArgs<TFramework, Decorators> & LoaderArgs<TFramework, Loaders>> : unknown;
301
- declare type DecoratorsArgs<TFramework extends AnyFramework, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TFramework, infer TArgs> ? TArgs : unknown>;
302
- 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>;
303
313
 
304
314
  /**
305
315
  * Helper function to include/exclude an arg based on the value of other other args
@@ -342,4 +352,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
342
352
  groups: string[];
343
353
  };
344
354
 
345
- 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/csf",
3
- "version": "0.0.2--canary.5b59926.0",
3
+ "version": "0.0.2--canary.795e486.0",
4
4
  "description": "Component Story Format (CSF) utilities",
5
5
  "keywords": [
6
6
  "storybook",