@storybook/csf 0.0.2--canary.53.4879818.0 → 0.0.2--canary.54.75c3237.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +57 -57
- package/package.json +49 -10
package/dist/index.d.ts
CHANGED
@@ -51,9 +51,9 @@ interface StoryIdentifier {
|
|
51
51
|
story: StoryName;
|
52
52
|
tags: Tag[];
|
53
53
|
}
|
54
|
-
|
55
|
-
[name: string]:
|
56
|
-
}
|
54
|
+
interface Parameters {
|
55
|
+
[name: string]: unknown;
|
56
|
+
}
|
57
57
|
declare type ConditionalTest = {
|
58
58
|
truthy?: boolean;
|
59
59
|
} | {
|
@@ -99,30 +99,30 @@ declare type GlobalTypes = {
|
|
99
99
|
declare type StrictGlobalTypes = {
|
100
100
|
[name: string]: StrictInputType;
|
101
101
|
};
|
102
|
-
declare type
|
103
|
-
/** What
|
102
|
+
declare type Renderer = {
|
103
|
+
/** What is the type of the `component` annotation in this renderer? */
|
104
104
|
component: unknown;
|
105
|
-
/** What does the story function return in this
|
105
|
+
/** What does the story function return in this renderer? */
|
106
106
|
storyResult: unknown;
|
107
|
-
/** What type of element does this
|
107
|
+
/** What type of element does this renderer render to? */
|
108
108
|
canvasElement: unknown;
|
109
109
|
T?: unknown;
|
110
110
|
};
|
111
|
-
/** @deprecated - use `
|
112
|
-
declare type AnyFramework =
|
113
|
-
declare type StoryContextForEnhancers<
|
114
|
-
component?: (
|
111
|
+
/** @deprecated - use `Renderer` */
|
112
|
+
declare type AnyFramework = Renderer;
|
113
|
+
declare type StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryIdentifier & {
|
114
|
+
component?: (TRenderer & {
|
115
115
|
T: any;
|
116
116
|
})['component'];
|
117
|
-
subcomponents?: Record<string, (
|
117
|
+
subcomponents?: Record<string, (TRenderer & {
|
118
118
|
T: any;
|
119
119
|
})['component']>;
|
120
120
|
parameters: Parameters;
|
121
121
|
initialArgs: TArgs;
|
122
122
|
argTypes: StrictArgTypes<TArgs>;
|
123
123
|
};
|
124
|
-
declare type ArgsEnhancer<
|
125
|
-
declare type ArgTypesEnhancer<
|
124
|
+
declare type ArgsEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForEnhancers<TRenderer, TArgs>) => TArgs;
|
125
|
+
declare type ArgTypesEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = ((context: StoryContextForEnhancers<TRenderer, TArgs>) => StrictArgTypes<TArgs>) & {
|
126
126
|
secondPass?: boolean;
|
127
127
|
};
|
128
128
|
declare type StoryContextUpdate<TArgs = Args> = {
|
@@ -131,40 +131,40 @@ declare type StoryContextUpdate<TArgs = Args> = {
|
|
131
131
|
[key: string]: any;
|
132
132
|
};
|
133
133
|
declare type ViewMode = 'story' | 'docs';
|
134
|
-
declare type StoryContextForLoaders<
|
134
|
+
declare type StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForEnhancers<TRenderer, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
135
135
|
hooks: unknown;
|
136
136
|
viewMode: ViewMode;
|
137
|
-
originalStoryFn: StoryFn<
|
137
|
+
originalStoryFn: StoryFn<TRenderer>;
|
138
138
|
};
|
139
|
-
declare type LoaderFunction<
|
140
|
-
declare type StoryContext<
|
139
|
+
declare type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any>>;
|
140
|
+
declare type StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForLoaders<TRenderer, TArgs> & {
|
141
141
|
loaded: Record<string, any>;
|
142
142
|
abortSignal: AbortSignal;
|
143
|
-
canvasElement:
|
143
|
+
canvasElement: TRenderer['canvasElement'];
|
144
144
|
};
|
145
145
|
declare type StepLabel = string;
|
146
|
-
declare type StepFunction<
|
147
|
-
declare type PlayFunctionContext<
|
148
|
-
step: StepFunction<
|
146
|
+
declare type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>) => Promise<void> | void;
|
147
|
+
declare type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<TRenderer, TArgs> & {
|
148
|
+
step: StepFunction<TRenderer, TArgs>;
|
149
149
|
};
|
150
|
-
declare type PlayFunction<
|
151
|
-
declare type PartialStoryFn<
|
152
|
-
declare type LegacyStoryFn<
|
153
|
-
declare type ArgsStoryFn<
|
150
|
+
declare type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void> | void;
|
151
|
+
declare type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
152
|
+
declare type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
153
|
+
declare type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
154
154
|
T: TArgs;
|
155
155
|
})['storyResult'];
|
156
|
-
declare type StoryFn<
|
157
|
-
declare type DecoratorFunction<
|
158
|
-
declare type DecoratorApplicator<
|
159
|
-
declare type StepRunner<
|
160
|
-
declare type BaseAnnotations<
|
156
|
+
declare type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
157
|
+
declare type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
158
|
+
declare type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = Args> = (storyFn: LegacyStoryFn<TRenderer, TArgs>, decorators: DecoratorFunction<TRenderer, TArgs>[]) => LegacyStoryFn<TRenderer, TArgs>;
|
159
|
+
declare type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>, context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void>;
|
160
|
+
declare type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
|
161
161
|
/**
|
162
162
|
* Wrapper components or Storybook decorators that wrap a story.
|
163
163
|
*
|
164
164
|
* Decorators defined in Meta will be applied to every story variation.
|
165
165
|
* @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
|
166
166
|
*/
|
167
|
-
decorators?: DecoratorFunction<
|
167
|
+
decorators?: DecoratorFunction<TRenderer, TArgs>[];
|
168
168
|
/**
|
169
169
|
* Custom metadata for a story.
|
170
170
|
* @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters)
|
@@ -184,22 +184,22 @@ declare type BaseAnnotations<TFramework extends Framework = Framework, TArgs = A
|
|
184
184
|
* Asynchronous functions which provide data for a story.
|
185
185
|
* @see [Loaders](https://storybook.js.org/docs/react/writing-stories/loaders)
|
186
186
|
*/
|
187
|
-
loaders?: LoaderFunction<
|
187
|
+
loaders?: LoaderFunction<TRenderer, TArgs>[];
|
188
188
|
/**
|
189
|
-
* Define a custom render function for the story(ies). If not passed, a default render function by the
|
189
|
+
* Define a custom render function for the story(ies). If not passed, a default render function by the renderer will be used.
|
190
190
|
*/
|
191
|
-
render?: ArgsStoryFn<
|
191
|
+
render?: ArgsStoryFn<TRenderer, TArgs>;
|
192
192
|
};
|
193
|
-
declare type ProjectAnnotations<
|
194
|
-
argsEnhancers?: ArgsEnhancer<
|
195
|
-
argTypesEnhancers?: ArgTypesEnhancer<
|
193
|
+
declare type ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = BaseAnnotations<TRenderer, TArgs> & {
|
194
|
+
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
195
|
+
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
196
196
|
globals?: Globals;
|
197
197
|
globalTypes?: GlobalTypes;
|
198
|
-
applyDecorators?: DecoratorApplicator<
|
199
|
-
runStep?: StepRunner<
|
198
|
+
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
199
|
+
runStep?: StepRunner<TRenderer, TArgs>;
|
200
200
|
};
|
201
201
|
declare type StoryDescriptor$1 = string[] | RegExp;
|
202
|
-
interface ComponentAnnotations<
|
202
|
+
interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> extends BaseAnnotations<TRenderer, TArgs> {
|
203
203
|
/**
|
204
204
|
* Title of the component which will be presented in the navigation. **Should be unique.**
|
205
205
|
*
|
@@ -247,7 +247,7 @@ interface ComponentAnnotations<TFramework extends Framework = Framework, TArgs =
|
|
247
247
|
*
|
248
248
|
* Used by addons for automatic prop table generation and display of other component metadata.
|
249
249
|
*/
|
250
|
-
component?: (
|
250
|
+
component?: (TRenderer & {
|
251
251
|
T: Args extends TArgs ? any : TArgs;
|
252
252
|
})['component'];
|
253
253
|
/**
|
@@ -265,17 +265,17 @@ interface ComponentAnnotations<TFramework extends Framework = Framework, TArgs =
|
|
265
265
|
*
|
266
266
|
* By defining them each component will have its tab in the args table.
|
267
267
|
*/
|
268
|
-
subcomponents?: Record<string,
|
268
|
+
subcomponents?: Record<string, TRenderer['component']>;
|
269
269
|
/**
|
270
270
|
* Function that is executed after the story is rendered.
|
271
271
|
*/
|
272
|
-
play?: PlayFunction<
|
272
|
+
play?: PlayFunction<TRenderer, TArgs>;
|
273
273
|
/**
|
274
274
|
* Named tags for a story, used to filter stories in different contexts.
|
275
275
|
*/
|
276
276
|
tags?: Tag[];
|
277
277
|
}
|
278
|
-
declare type StoryAnnotations<
|
278
|
+
declare type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TRenderer, TArgs> & {
|
279
279
|
/**
|
280
280
|
* Override the display name in the UI (CSF v3)
|
281
281
|
*/
|
@@ -287,29 +287,29 @@ declare type StoryAnnotations<TFramework extends Framework = Framework, TArgs =
|
|
287
287
|
/**
|
288
288
|
* Function that is executed after the story is rendered.
|
289
289
|
*/
|
290
|
-
play?: PlayFunction<
|
290
|
+
play?: PlayFunction<TRenderer, TArgs>;
|
291
291
|
/**
|
292
292
|
* Named tags for a story, used to filter stories in different contexts.
|
293
293
|
*/
|
294
294
|
tags?: Tag[];
|
295
295
|
/** @deprecated */
|
296
|
-
story?: Omit<StoryAnnotations<
|
296
|
+
story?: Omit<StoryAnnotations<TRenderer, TArgs>, 'story'>;
|
297
297
|
} & ({} extends TRequiredArgs ? {
|
298
298
|
args?: TRequiredArgs;
|
299
299
|
} : {
|
300
300
|
args: TRequiredArgs;
|
301
301
|
});
|
302
|
-
declare type LegacyAnnotatedStoryFn<
|
303
|
-
declare type LegacyStoryAnnotationsOrFn<
|
304
|
-
declare type AnnotatedStoryFn<
|
305
|
-
declare type StoryAnnotationsOrFn<
|
306
|
-
declare type ArgsFromMeta<
|
307
|
-
render?: ArgsStoryFn<
|
302
|
+
declare type LegacyAnnotatedStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryFn<TRenderer, TArgs> & StoryAnnotations<TRenderer, TArgs>;
|
303
|
+
declare type LegacyStoryAnnotationsOrFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyAnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>;
|
304
|
+
declare type AnnotatedStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = ArgsStoryFn<TRenderer, TArgs> & StoryAnnotations<TRenderer, TArgs>;
|
305
|
+
declare type StoryAnnotationsOrFn<TRenderer extends Renderer = Renderer, TArgs = Args> = AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>;
|
306
|
+
declare type ArgsFromMeta<TRenderer extends Renderer, Meta> = Meta extends {
|
307
|
+
render?: ArgsStoryFn<TRenderer, infer RArgs>;
|
308
308
|
loaders?: (infer Loaders)[];
|
309
309
|
decorators?: (infer Decorators)[];
|
310
|
-
} ? Simplify<RArgs & DecoratorsArgs<
|
311
|
-
declare type DecoratorsArgs<
|
312
|
-
declare type LoaderArgs<
|
310
|
+
} ? Simplify<RArgs & DecoratorsArgs<TRenderer, Decorators> & LoaderArgs<TRenderer, Loaders>> : unknown;
|
311
|
+
declare type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
312
|
+
declare type LoaderArgs<TRenderer extends Renderer, Loaders> = UnionToIntersection<Loaders extends LoaderFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
313
313
|
|
314
314
|
/**
|
315
315
|
* Helper function to include/exclude an arg based on the value of other other args
|
@@ -352,4 +352,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
|
|
352
352
|
groups: string[];
|
353
353
|
};
|
354
354
|
|
355
|
-
export { AnnotatedStoryFn, AnyFramework, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, ComponentAnnotations, ComponentId, ComponentTitle, Conditional, DecoratorApplicator, DecoratorFunction,
|
355
|
+
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, Renderer, 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.
|
3
|
+
"version": "0.0.2--canary.54.75c3237.0",
|
4
4
|
"description": "Component Story Format (CSF) utilities",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -23,6 +23,12 @@
|
|
23
23
|
"*.js",
|
24
24
|
"*.d.ts"
|
25
25
|
],
|
26
|
+
"exports": {
|
27
|
+
".": {
|
28
|
+
"import": "./dist/index.mjs",
|
29
|
+
"require": "./dist/index.js"
|
30
|
+
}
|
31
|
+
},
|
26
32
|
"main": "dist/index.js",
|
27
33
|
"module": "dist/index.mjs",
|
28
34
|
"types": "dist/index.d.ts",
|
@@ -30,14 +36,29 @@
|
|
30
36
|
"build": "tsup ./src/index.ts --format esm,cjs --dts",
|
31
37
|
"check": "tsc",
|
32
38
|
"lint": "eslint src --ext .ts",
|
33
|
-
"test": "jest",
|
39
|
+
"test": "NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules jest",
|
34
40
|
"release": "yarn build && auto shipit"
|
35
41
|
},
|
36
42
|
"eslintConfig": {
|
37
43
|
"extends": [
|
38
44
|
"@storybook/eslint-config-storybook"
|
39
45
|
],
|
46
|
+
"parserOptions": {
|
47
|
+
"project": [
|
48
|
+
"./tsconfig.json"
|
49
|
+
]
|
50
|
+
},
|
51
|
+
"settings": {
|
52
|
+
"import/resolver": {
|
53
|
+
"typescript": {
|
54
|
+
"project": [
|
55
|
+
"./tsconfig.json"
|
56
|
+
]
|
57
|
+
}
|
58
|
+
}
|
59
|
+
},
|
40
60
|
"rules": {
|
61
|
+
"import/no-unresolved": "error",
|
41
62
|
"jest/expect-expect": [
|
42
63
|
"warn",
|
43
64
|
{
|
@@ -51,7 +72,21 @@
|
|
51
72
|
},
|
52
73
|
"prettier": "@storybook/linter-config/prettier.config",
|
53
74
|
"jest": {
|
54
|
-
"preset": "ts-jest",
|
75
|
+
"preset": "ts-jest/presets/default-esm",
|
76
|
+
"extensionsToTreatAsEsm": [
|
77
|
+
".ts"
|
78
|
+
],
|
79
|
+
"moduleNameMapper": {
|
80
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
81
|
+
},
|
82
|
+
"transform": {
|
83
|
+
"^.+\\.tsx?$": [
|
84
|
+
"ts-jest",
|
85
|
+
{
|
86
|
+
"useESM": true
|
87
|
+
}
|
88
|
+
]
|
89
|
+
},
|
55
90
|
"testEnvironment": "node",
|
56
91
|
"roots": [
|
57
92
|
"<rootDir>/src"
|
@@ -63,19 +98,23 @@
|
|
63
98
|
"type-fest": "^2.19.0"
|
64
99
|
},
|
65
100
|
"devDependencies": {
|
66
|
-
"@auto-it/released": "^10.37.
|
67
|
-
"@storybook/eslint-config-storybook": "^
|
101
|
+
"@auto-it/released": "^10.37.6",
|
102
|
+
"@storybook/eslint-config-storybook": "^3.1.2",
|
68
103
|
"@types/jest": "^29.2.0",
|
69
104
|
"@types/lodash": "^4.14.149",
|
70
105
|
"@types/node": "^18.11.0",
|
71
|
-
"@typescript-eslint/
|
72
|
-
"
|
106
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
107
|
+
"@typescript-eslint/parser": "^5.42.1",
|
108
|
+
"auto": "^10.37.6",
|
73
109
|
"common-tags": "^1.8.0",
|
74
|
-
"eslint": "^
|
75
|
-
"
|
110
|
+
"eslint": "^8.27.0",
|
111
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
112
|
+
"eslint-plugin-import": "^2.26.0",
|
113
|
+
"eslint-plugin-jest": "^27.1.4",
|
114
|
+
"jest": "^29.3.1",
|
76
115
|
"prettier": "^2.7.1",
|
77
116
|
"ts-jest": "^29.0.3",
|
78
|
-
"tsup": "^6.
|
117
|
+
"tsup": "^6.4.0",
|
79
118
|
"typescript": "^4.8.4"
|
80
119
|
},
|
81
120
|
"auto": {
|