@storybook/csf 0.0.2-next.1 → 0.0.2-next.10
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +95 -83
- package/dist/index.js +8 -107
- package/dist/index.mjs +2 -72
- package/package.json +67 -24
package/dist/index.d.ts
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
import { Simplify, UnionToIntersection } from 'type-fest';
|
1
|
+
import { Simplify, RemoveIndexSignature, UnionToIntersection } from 'type-fest';
|
2
2
|
|
3
3
|
interface SBBaseType {
|
4
4
|
required?: boolean;
|
5
5
|
raw?: string;
|
6
6
|
}
|
7
|
-
|
7
|
+
type SBScalarType = SBBaseType & {
|
8
8
|
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
9
9
|
};
|
10
|
-
|
10
|
+
type SBArrayType = SBBaseType & {
|
11
11
|
name: 'array';
|
12
12
|
value: SBType;
|
13
13
|
};
|
14
|
-
|
14
|
+
type SBObjectType = SBBaseType & {
|
15
15
|
name: 'object';
|
16
16
|
value: Record<string, SBType>;
|
17
17
|
};
|
18
|
-
|
18
|
+
type SBEnumType = SBBaseType & {
|
19
19
|
name: 'enum';
|
20
20
|
value: (string | number)[];
|
21
21
|
};
|
22
|
-
|
22
|
+
type SBIntersectionType = SBBaseType & {
|
23
23
|
name: 'intersection';
|
24
24
|
value: SBType[];
|
25
25
|
};
|
26
|
-
|
26
|
+
type SBUnionType = SBBaseType & {
|
27
27
|
name: 'union';
|
28
28
|
value: SBType[];
|
29
29
|
};
|
30
|
-
|
30
|
+
type SBOtherType = SBBaseType & {
|
31
31
|
name: 'other';
|
32
32
|
value: string;
|
33
33
|
};
|
34
|
-
|
34
|
+
type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
type StoryId = string;
|
37
|
+
type ComponentId = string;
|
38
|
+
type ComponentTitle = string;
|
39
|
+
type StoryName = string;
|
40
40
|
/** @deprecated */
|
41
|
-
|
42
|
-
|
41
|
+
type StoryKind = ComponentTitle;
|
42
|
+
type Tag = string;
|
43
43
|
interface StoryIdentifier {
|
44
44
|
componentId: ComponentId;
|
45
45
|
title: ComponentTitle;
|
@@ -51,10 +51,13 @@ interface StoryIdentifier {
|
|
51
51
|
story: StoryName;
|
52
52
|
tags: Tag[];
|
53
53
|
}
|
54
|
-
|
54
|
+
interface Parameters {
|
55
55
|
[name: string]: any;
|
56
|
-
}
|
57
|
-
|
56
|
+
}
|
57
|
+
interface StrictParameters {
|
58
|
+
[name: string]: unknown;
|
59
|
+
}
|
60
|
+
type ConditionalTest = {
|
58
61
|
truthy?: boolean;
|
59
62
|
} | {
|
60
63
|
exists: boolean;
|
@@ -63,12 +66,12 @@ declare type ConditionalTest = {
|
|
63
66
|
} | {
|
64
67
|
neq: any;
|
65
68
|
};
|
66
|
-
|
69
|
+
type ConditionalValue = {
|
67
70
|
arg: string;
|
68
71
|
} | {
|
69
72
|
global: string;
|
70
73
|
};
|
71
|
-
|
74
|
+
type Conditional = ConditionalValue & ConditionalTest;
|
72
75
|
interface InputType {
|
73
76
|
name?: string;
|
74
77
|
description?: string;
|
@@ -81,84 +84,93 @@ interface StrictInputType extends InputType {
|
|
81
84
|
name: string;
|
82
85
|
type?: SBType;
|
83
86
|
}
|
84
|
-
|
87
|
+
interface Args {
|
85
88
|
[name: string]: any;
|
86
|
-
}
|
87
|
-
|
89
|
+
}
|
90
|
+
interface StrictArgs {
|
91
|
+
[name: string]: unknown;
|
92
|
+
}
|
93
|
+
type ArgTypes<TArgs = Args> = {
|
88
94
|
[name in keyof TArgs]: InputType;
|
89
95
|
};
|
90
|
-
|
96
|
+
type StrictArgTypes<TArgs = Args> = {
|
91
97
|
[name in keyof TArgs]: StrictInputType;
|
92
98
|
};
|
93
|
-
|
99
|
+
type Globals = {
|
94
100
|
[name: string]: any;
|
95
101
|
};
|
96
|
-
|
102
|
+
type GlobalTypes = {
|
97
103
|
[name: string]: InputType;
|
98
104
|
};
|
99
|
-
|
105
|
+
type StrictGlobalTypes = {
|
100
106
|
[name: string]: StrictInputType;
|
101
107
|
};
|
102
|
-
|
108
|
+
type Renderer = {
|
109
|
+
/** What is the type of the `component` annotation in this renderer? */
|
103
110
|
component: unknown;
|
111
|
+
/** What does the story function return in this renderer? */
|
104
112
|
storyResult: unknown;
|
113
|
+
/** What type of element does this renderer render to? */
|
114
|
+
canvasElement: unknown;
|
105
115
|
T?: unknown;
|
106
116
|
};
|
107
|
-
|
108
|
-
|
117
|
+
/** @deprecated - use `Renderer` */
|
118
|
+
type AnyFramework = Renderer;
|
119
|
+
type StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryIdentifier & {
|
120
|
+
component?: (TRenderer & {
|
109
121
|
T: any;
|
110
122
|
})['component'];
|
111
|
-
subcomponents?: Record<string, (
|
123
|
+
subcomponents?: Record<string, (TRenderer & {
|
112
124
|
T: any;
|
113
125
|
})['component']>;
|
114
126
|
parameters: Parameters;
|
115
127
|
initialArgs: TArgs;
|
116
128
|
argTypes: StrictArgTypes<TArgs>;
|
117
129
|
};
|
118
|
-
|
119
|
-
|
130
|
+
type ArgsEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForEnhancers<TRenderer, TArgs>) => TArgs;
|
131
|
+
type ArgTypesEnhancer<TRenderer extends Renderer = Renderer, TArgs = Args> = ((context: StoryContextForEnhancers<TRenderer, TArgs>) => StrictArgTypes<TArgs>) & {
|
120
132
|
secondPass?: boolean;
|
121
133
|
};
|
122
|
-
|
134
|
+
type StoryContextUpdate<TArgs = Args> = {
|
123
135
|
args?: TArgs;
|
124
136
|
globals?: Globals;
|
125
137
|
[key: string]: any;
|
126
138
|
};
|
127
|
-
|
128
|
-
|
139
|
+
type ViewMode = 'story' | 'docs';
|
140
|
+
type StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForEnhancers<TRenderer, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
129
141
|
hooks: unknown;
|
130
142
|
viewMode: ViewMode;
|
131
|
-
originalStoryFn: StoryFn<
|
143
|
+
originalStoryFn: StoryFn<TRenderer>;
|
132
144
|
};
|
133
|
-
|
134
|
-
|
145
|
+
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any>>;
|
146
|
+
type StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForLoaders<TRenderer, TArgs> & {
|
135
147
|
loaded: Record<string, any>;
|
136
148
|
abortSignal: AbortSignal;
|
137
|
-
canvasElement:
|
149
|
+
canvasElement: TRenderer['canvasElement'];
|
138
150
|
};
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
step: StepFunction<
|
151
|
+
type StepLabel = string;
|
152
|
+
type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>) => Promise<void> | void;
|
153
|
+
type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<TRenderer, TArgs> & {
|
154
|
+
step: StepFunction<TRenderer, TArgs>;
|
143
155
|
};
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
156
|
+
type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void> | void;
|
157
|
+
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
158
|
+
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
159
|
+
type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: TArgs, context: StoryContext<TRenderer, TArgs>) => (TRenderer & {
|
148
160
|
T: TArgs;
|
149
161
|
})['storyResult'];
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
162
|
+
type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
163
|
+
type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
164
|
+
type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = Args> = (storyFn: LegacyStoryFn<TRenderer, TArgs>, decorators: DecoratorFunction<TRenderer, TArgs>[]) => LegacyStoryFn<TRenderer, TArgs>;
|
165
|
+
type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>, context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void>;
|
166
|
+
type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
|
155
167
|
/**
|
156
168
|
* Wrapper components or Storybook decorators that wrap a story.
|
157
169
|
*
|
158
170
|
* Decorators defined in Meta will be applied to every story variation.
|
159
171
|
* @see [Decorators](https://storybook.js.org/docs/addons/introduction/#1-decorators)
|
160
172
|
*/
|
161
|
-
decorators?: DecoratorFunction<
|
173
|
+
decorators?: DecoratorFunction<TRenderer, TArgs>[];
|
162
174
|
/**
|
163
175
|
* Custom metadata for a story.
|
164
176
|
* @see [Parameters](https://storybook.js.org/docs/basics/writing-stories/#parameters)
|
@@ -178,22 +190,22 @@ declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TAr
|
|
178
190
|
* Asynchronous functions which provide data for a story.
|
179
191
|
* @see [Loaders](https://storybook.js.org/docs/react/writing-stories/loaders)
|
180
192
|
*/
|
181
|
-
loaders?: LoaderFunction<
|
193
|
+
loaders?: LoaderFunction<TRenderer, TArgs>[];
|
182
194
|
/**
|
183
|
-
* Define a custom render function for the story(ies). If not passed, a default render function by the
|
195
|
+
* Define a custom render function for the story(ies). If not passed, a default render function by the renderer will be used.
|
184
196
|
*/
|
185
|
-
render?: ArgsStoryFn<
|
197
|
+
render?: ArgsStoryFn<TRenderer, TArgs>;
|
186
198
|
};
|
187
|
-
|
188
|
-
argsEnhancers?: ArgsEnhancer<
|
189
|
-
argTypesEnhancers?: ArgTypesEnhancer<
|
199
|
+
type ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = BaseAnnotations<TRenderer, TArgs> & {
|
200
|
+
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
201
|
+
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
190
202
|
globals?: Globals;
|
191
203
|
globalTypes?: GlobalTypes;
|
192
|
-
applyDecorators?: DecoratorApplicator<
|
193
|
-
runStep?: StepRunner<
|
204
|
+
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
205
|
+
runStep?: StepRunner<TRenderer, TArgs>;
|
194
206
|
};
|
195
|
-
|
196
|
-
interface ComponentAnnotations<
|
207
|
+
type StoryDescriptor$1 = string[] | RegExp;
|
208
|
+
interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> extends BaseAnnotations<TRenderer, TArgs> {
|
197
209
|
/**
|
198
210
|
* Title of the component which will be presented in the navigation. **Should be unique.**
|
199
211
|
*
|
@@ -241,8 +253,8 @@ interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, T
|
|
241
253
|
*
|
242
254
|
* Used by addons for automatic prop table generation and display of other component metadata.
|
243
255
|
*/
|
244
|
-
component?: (
|
245
|
-
T:
|
256
|
+
component?: (TRenderer & {
|
257
|
+
T: Record<string, unknown> extends Required<TArgs> ? any : TArgs;
|
246
258
|
})['component'];
|
247
259
|
/**
|
248
260
|
* Auxiliary subcomponents that are part of the stories.
|
@@ -259,17 +271,17 @@ interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, T
|
|
259
271
|
*
|
260
272
|
* By defining them each component will have its tab in the args table.
|
261
273
|
*/
|
262
|
-
subcomponents?: Record<string,
|
274
|
+
subcomponents?: Record<string, TRenderer['component']>;
|
263
275
|
/**
|
264
276
|
* Function that is executed after the story is rendered.
|
265
277
|
*/
|
266
|
-
play?: PlayFunction<
|
278
|
+
play?: PlayFunction<TRenderer, TArgs>;
|
267
279
|
/**
|
268
280
|
* Named tags for a story, used to filter stories in different contexts.
|
269
281
|
*/
|
270
282
|
tags?: Tag[];
|
271
283
|
}
|
272
|
-
|
284
|
+
type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TRenderer, TArgs> & {
|
273
285
|
/**
|
274
286
|
* Override the display name in the UI (CSF v3)
|
275
287
|
*/
|
@@ -281,35 +293,35 @@ declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TA
|
|
281
293
|
/**
|
282
294
|
* Function that is executed after the story is rendered.
|
283
295
|
*/
|
284
|
-
play?: PlayFunction<
|
296
|
+
play?: PlayFunction<TRenderer, TArgs>;
|
285
297
|
/**
|
286
298
|
* Named tags for a story, used to filter stories in different contexts.
|
287
299
|
*/
|
288
300
|
tags?: Tag[];
|
289
301
|
/** @deprecated */
|
290
|
-
story?: Omit<StoryAnnotations<
|
302
|
+
story?: Omit<StoryAnnotations<TRenderer, TArgs>, 'story'>;
|
291
303
|
} & ({} extends TRequiredArgs ? {
|
292
304
|
args?: TRequiredArgs;
|
293
305
|
} : {
|
294
306
|
args: TRequiredArgs;
|
295
307
|
});
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
render?: ArgsStoryFn<
|
308
|
+
type LegacyAnnotatedStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryFn<TRenderer, TArgs> & StoryAnnotations<TRenderer, TArgs>;
|
309
|
+
type LegacyStoryAnnotationsOrFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyAnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>;
|
310
|
+
type AnnotatedStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = ArgsStoryFn<TRenderer, TArgs> & StoryAnnotations<TRenderer, TArgs>;
|
311
|
+
type StoryAnnotationsOrFn<TRenderer extends Renderer = Renderer, TArgs = Args> = AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>;
|
312
|
+
type ArgsFromMeta<TRenderer extends Renderer, Meta> = Meta extends {
|
313
|
+
render?: ArgsStoryFn<TRenderer, infer RArgs>;
|
302
314
|
loaders?: (infer Loaders)[];
|
303
315
|
decorators?: (infer Decorators)[];
|
304
|
-
} ? Simplify<RArgs & DecoratorsArgs<
|
305
|
-
|
306
|
-
|
316
|
+
} ? Simplify<RemoveIndexSignature<RArgs & DecoratorsArgs<TRenderer, Decorators> & LoaderArgs<TRenderer, Loaders>>> : unknown;
|
317
|
+
type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
318
|
+
type LoaderArgs<TRenderer extends Renderer, Loaders> = UnionToIntersection<Loaders extends LoaderFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
307
319
|
|
308
320
|
/**
|
309
321
|
* Helper function to include/exclude an arg based on the value of other other args
|
310
322
|
* aka "conditional args"
|
311
323
|
*/
|
312
|
-
declare const includeConditionalArg: (argType: InputType, args: Args, globals: Globals) =>
|
324
|
+
declare const includeConditionalArg: (argType: InputType, args: Args, globals: Globals) => any;
|
313
325
|
|
314
326
|
/**
|
315
327
|
* Remove punctuation and illegal characters from a story ID.
|
@@ -325,7 +337,7 @@ declare const toId: (kind: string, name?: string) => string;
|
|
325
337
|
* Transform a CSF named export into a readable story name
|
326
338
|
*/
|
327
339
|
declare const storyNameFromExport: (key: string) => string;
|
328
|
-
|
340
|
+
type StoryDescriptor = string[] | RegExp;
|
329
341
|
interface IncludeExcludeOptions {
|
330
342
|
includeStories?: StoryDescriptor;
|
331
343
|
excludeStories?: StoryDescriptor;
|
@@ -346,4 +358,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
|
|
346
358
|
groups: string[];
|
347
359
|
};
|
348
360
|
|
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 };
|
361
|
+
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, StrictArgs, StrictGlobalTypes, StrictInputType, StrictParameters, Tag, ViewMode, includeConditionalArg, isExportStory, parseKind, sanitize, storyNameFromExport, toId };
|
package/dist/index.js
CHANGED
@@ -1,109 +1,10 @@
|
|
1
|
-
|
2
|
-
var __create = Object.create;
|
3
|
-
var __defProp = Object.defineProperty;
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var __export = (target, all) => {
|
9
|
-
for (var name in all)
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
-
};
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
-
for (let key of __getOwnPropNames(from))
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
-
}
|
18
|
-
return to;
|
19
|
-
};
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
|
-
mod
|
23
|
-
));
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
1
|
+
'use strict';
|
25
2
|
|
26
|
-
|
27
|
-
var src_exports = {};
|
28
|
-
__export(src_exports, {
|
29
|
-
includeConditionalArg: () => includeConditionalArg,
|
30
|
-
isExportStory: () => isExportStory,
|
31
|
-
parseKind: () => parseKind,
|
32
|
-
sanitize: () => sanitize,
|
33
|
-
storyNameFromExport: () => storyNameFromExport,
|
34
|
-
toId: () => toId
|
35
|
-
});
|
36
|
-
module.exports = __toCommonJS(src_exports);
|
37
|
-
var import_startCase = __toESM(require("lodash/startCase"));
|
3
|
+
var B=Object.create;var R=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var I=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var E=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of C(e))!w.call(r,a)&&a!==t&&R(r,a,{get:()=>e[a],enumerable:!(n=b(e,a))||n.enumerable});return r};var P=(r,e,t)=>(t=r!=null?B(h(r)):{},E(e||!r||!r.__esModule?R(t,"default",{value:r,enumerable:!0}):t,r));var x=I(T=>{Object.defineProperty(T,"__esModule",{value:!0}),T.isEqual=function(){var r=Object.prototype.toString,e=Object.getPrototypeOf,t=Object.getOwnPropertySymbols?function(n){return Object.keys(n).concat(Object.getOwnPropertySymbols(n))}:Object.keys;return function(n,a){return function i(o,s,d){var y,g,p,A=r.call(o),F=r.call(s);if(o===s)return !0;if(o==null||s==null)return !1;if(d.indexOf(o)>-1&&d.indexOf(s)>-1)return !0;if(d.push(o,s),A!=F||(y=t(o),g=t(s),y.length!=g.length||y.some(function(l){return !i(o[l],s[l],d)})))return !1;switch(A.slice(8,-1)){case"Symbol":return o.valueOf()==s.valueOf();case"Date":case"Number":return +o==+s||+o!=+o&&+s!=+s;case"RegExp":case"Function":case"String":case"Boolean":return ""+o==""+s;case"Set":case"Map":y=o.entries(),g=s.entries();do if(!i((p=y.next()).value,g.next().value,d))return !1;while(!p.done);return !0;case"ArrayBuffer":o=new Uint8Array(o),s=new Uint8Array(s);case"DataView":o=new Uint8Array(o.buffer),s=new Uint8Array(s.buffer);case"Float32Array":case"Float64Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Uint8Array":case"Uint16Array":case"Uint32Array":case"Uint8ClampedArray":case"Arguments":case"Array":if(o.length!=s.length)return !1;for(p=0;p<o.length;p++)if((p in o||p in s)&&(p in o!=p in s||!i(o[p],s[p],d)))return !1;return !0;case"Object":return i(e(o),e(s),d);default:return !1}}(n,a,[])}}();});function u(r){return r.replace(/_/g," ").replace(/-/g," ").replace(/\./g," ").replace(/([^\n])([A-Z])([a-z])/g,(e,t,n,a)=>`${t} ${n}${a}`).replace(/([a-z])([A-Z])/g,(e,t,n)=>`${t} ${n}`).replace(/([a-z])([0-9])/gi,(e,t,n)=>`${t} ${n}`).replace(/([0-9])([a-z])/gi,(e,t,n)=>`${t} ${n}`).replace(/(\s|^)(\w)/g,(e,t,n)=>`${t}${n.toUpperCase()}`).replace(/ +/g," ").trim()}var c=P(x()),S=r=>r.map(e=>typeof e<"u").filter(Boolean).length,O=(r,e)=>{let{exists:t,eq:n,neq:a,truthy:i}=r;if(S([t,n,a,i])>1)throw new Error(`Invalid conditional test ${JSON.stringify({exists:t,eq:n,neq:a})}`);if(typeof n<"u")return (0, c.isEqual)(e,n);if(typeof a<"u")return !(0, c.isEqual)(e,a);if(typeof t<"u"){let s=typeof e<"u";return t?s:!s}return (typeof i>"u"?!0:i)?!!e:!e},v=(r,e,t)=>{if(!r.if)return !0;let{arg:n,global:a}=r.if;if(S([n,a])!==1)throw new Error(`Invalid conditional value ${JSON.stringify({arg:n,global:a})}`);let i=n?e[n]:t[a];return O(r.if,i)};var L=r=>r.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,"-").replace(/-+/g,"-").replace(/^-+/,"").replace(/-+$/,""),m=(r,e)=>{let t=L(r);if(t==="")throw new Error(`Invalid ${e} '${r}', must include alphanumeric characters`);return t},N=(r,e)=>`${m(r,"kind")}${e?`--${m(e,"name")}`:""}`,M=r=>u(r);function f(r,e){return Array.isArray(e)?e.includes(r):r.match(e)}function G(r,{includeStories:e,excludeStories:t}){return r!=="__esModule"&&(!e||f(r,e))&&(!t||!f(r,t))}var z=(r,{rootSeparator:e,groupSeparator:t})=>{let[n,a]=r.split(e,2),i=(a||r).split(t).filter(o=>!!o);return {root:a?n:null,groups:i}};
|
38
4
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
throw new Error(`Invalid conditional test ${JSON.stringify({ exists, eq, neq })}`);
|
46
|
-
}
|
47
|
-
if (typeof eq !== "undefined") {
|
48
|
-
return (0, import_isEqual.default)(value, eq);
|
49
|
-
}
|
50
|
-
if (typeof neq !== "undefined") {
|
51
|
-
return !(0, import_isEqual.default)(value, neq);
|
52
|
-
}
|
53
|
-
if (typeof exists !== "undefined") {
|
54
|
-
const valueExists = typeof value !== "undefined";
|
55
|
-
return exists ? valueExists : !valueExists;
|
56
|
-
}
|
57
|
-
const shouldBeTruthy = typeof truthy === "undefined" ? true : truthy;
|
58
|
-
return shouldBeTruthy ? !!value : !value;
|
59
|
-
};
|
60
|
-
var includeConditionalArg = (argType, args, globals) => {
|
61
|
-
if (!argType.if)
|
62
|
-
return true;
|
63
|
-
const { arg, global } = argType.if;
|
64
|
-
if (count([arg, global]) !== 1) {
|
65
|
-
throw new Error(`Invalid conditional value ${JSON.stringify({ arg, global })}`);
|
66
|
-
}
|
67
|
-
const value = arg ? args[arg] : globals[global];
|
68
|
-
return testValue(argType.if, value);
|
69
|
-
};
|
70
|
-
|
71
|
-
// src/index.ts
|
72
|
-
var sanitize = (string) => {
|
73
|
-
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
74
|
-
};
|
75
|
-
var sanitizeSafe = (string, part) => {
|
76
|
-
const sanitized = sanitize(string);
|
77
|
-
if (sanitized === "") {
|
78
|
-
throw new Error(`Invalid ${part} '${string}', must include alphanumeric characters`);
|
79
|
-
}
|
80
|
-
return sanitized;
|
81
|
-
};
|
82
|
-
var toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`;
|
83
|
-
var storyNameFromExport = (key) => (0, import_startCase.default)(key);
|
84
|
-
function matches(storyKey, arrayOrRegex) {
|
85
|
-
if (Array.isArray(arrayOrRegex)) {
|
86
|
-
return arrayOrRegex.includes(storyKey);
|
87
|
-
}
|
88
|
-
return storyKey.match(arrayOrRegex);
|
89
|
-
}
|
90
|
-
function isExportStory(key, { includeStories, excludeStories }) {
|
91
|
-
return key !== "__esModule" && (!includeStories || matches(key, includeStories)) && (!excludeStories || !matches(key, excludeStories));
|
92
|
-
}
|
93
|
-
var parseKind = (kind, { rootSeparator, groupSeparator }) => {
|
94
|
-
const [root, remainder] = kind.split(rootSeparator, 2);
|
95
|
-
const groups = (remainder || kind).split(groupSeparator).filter((i) => !!i);
|
96
|
-
return {
|
97
|
-
root: remainder ? root : null,
|
98
|
-
groups
|
99
|
-
};
|
100
|
-
};
|
101
|
-
// Annotate the CommonJS export names for ESM import in node:
|
102
|
-
0 && (module.exports = {
|
103
|
-
includeConditionalArg,
|
104
|
-
isExportStory,
|
105
|
-
parseKind,
|
106
|
-
sanitize,
|
107
|
-
storyNameFromExport,
|
108
|
-
toId
|
109
|
-
});
|
5
|
+
exports.includeConditionalArg = v;
|
6
|
+
exports.isExportStory = G;
|
7
|
+
exports.parseKind = z;
|
8
|
+
exports.sanitize = L;
|
9
|
+
exports.storyNameFromExport = M;
|
10
|
+
exports.toId = N;
|
package/dist/index.mjs
CHANGED
@@ -1,73 +1,3 @@
|
|
1
|
-
|
2
|
-
import startCase from "lodash/startCase";
|
1
|
+
var B=Object.create;var R=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var I=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var E=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of C(e))!w.call(r,a)&&a!==t&&R(r,a,{get:()=>e[a],enumerable:!(n=b(e,a))||n.enumerable});return r};var P=(r,e,t)=>(t=r!=null?B(h(r)):{},E(e||!r||!r.__esModule?R(t,"default",{value:r,enumerable:!0}):t,r));var x=I(T=>{Object.defineProperty(T,"__esModule",{value:!0}),T.isEqual=function(){var r=Object.prototype.toString,e=Object.getPrototypeOf,t=Object.getOwnPropertySymbols?function(n){return Object.keys(n).concat(Object.getOwnPropertySymbols(n))}:Object.keys;return function(n,a){return function i(o,s,d){var y,g,p,A=r.call(o),F=r.call(s);if(o===s)return !0;if(o==null||s==null)return !1;if(d.indexOf(o)>-1&&d.indexOf(s)>-1)return !0;if(d.push(o,s),A!=F||(y=t(o),g=t(s),y.length!=g.length||y.some(function(l){return !i(o[l],s[l],d)})))return !1;switch(A.slice(8,-1)){case"Symbol":return o.valueOf()==s.valueOf();case"Date":case"Number":return +o==+s||+o!=+o&&+s!=+s;case"RegExp":case"Function":case"String":case"Boolean":return ""+o==""+s;case"Set":case"Map":y=o.entries(),g=s.entries();do if(!i((p=y.next()).value,g.next().value,d))return !1;while(!p.done);return !0;case"ArrayBuffer":o=new Uint8Array(o),s=new Uint8Array(s);case"DataView":o=new Uint8Array(o.buffer),s=new Uint8Array(s.buffer);case"Float32Array":case"Float64Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Uint8Array":case"Uint16Array":case"Uint32Array":case"Uint8ClampedArray":case"Arguments":case"Array":if(o.length!=s.length)return !1;for(p=0;p<o.length;p++)if((p in o||p in s)&&(p in o!=p in s||!i(o[p],s[p],d)))return !1;return !0;case"Object":return i(e(o),e(s),d);default:return !1}}(n,a,[])}}();});function u(r){return r.replace(/_/g," ").replace(/-/g," ").replace(/\./g," ").replace(/([^\n])([A-Z])([a-z])/g,(e,t,n,a)=>`${t} ${n}${a}`).replace(/([a-z])([A-Z])/g,(e,t,n)=>`${t} ${n}`).replace(/([a-z])([0-9])/gi,(e,t,n)=>`${t} ${n}`).replace(/([0-9])([a-z])/gi,(e,t,n)=>`${t} ${n}`).replace(/(\s|^)(\w)/g,(e,t,n)=>`${t}${n.toUpperCase()}`).replace(/ +/g," ").trim()}var c=P(x()),S=r=>r.map(e=>typeof e<"u").filter(Boolean).length,O=(r,e)=>{let{exists:t,eq:n,neq:a,truthy:i}=r;if(S([t,n,a,i])>1)throw new Error(`Invalid conditional test ${JSON.stringify({exists:t,eq:n,neq:a})}`);if(typeof n<"u")return (0, c.isEqual)(e,n);if(typeof a<"u")return !(0, c.isEqual)(e,a);if(typeof t<"u"){let s=typeof e<"u";return t?s:!s}return (typeof i>"u"?!0:i)?!!e:!e},v=(r,e,t)=>{if(!r.if)return !0;let{arg:n,global:a}=r.if;if(S([n,a])!==1)throw new Error(`Invalid conditional value ${JSON.stringify({arg:n,global:a})}`);let i=n?e[n]:t[a];return O(r.if,i)};var L=r=>r.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,"-").replace(/-+/g,"-").replace(/^-+/,"").replace(/-+$/,""),m=(r,e)=>{let t=L(r);if(t==="")throw new Error(`Invalid ${e} '${r}', must include alphanumeric characters`);return t},N=(r,e)=>`${m(r,"kind")}${e?`--${m(e,"name")}`:""}`,M=r=>u(r);function f(r,e){return Array.isArray(e)?e.includes(r):r.match(e)}function G(r,{includeStories:e,excludeStories:t}){return r!=="__esModule"&&(!e||f(r,e))&&(!t||!f(r,t))}var z=(r,{rootSeparator:e,groupSeparator:t})=>{let[n,a]=r.split(e,2),i=(a||r).split(t).filter(o=>!!o);return {root:a?n:null,groups:i}};
|
3
2
|
|
4
|
-
|
5
|
-
import isEqual from "lodash/isEqual";
|
6
|
-
var count = (vals) => vals.map((v) => typeof v !== "undefined").filter(Boolean).length;
|
7
|
-
var testValue = (cond, value) => {
|
8
|
-
const { exists, eq, neq, truthy } = cond;
|
9
|
-
if (count([exists, eq, neq, truthy]) > 1) {
|
10
|
-
throw new Error(`Invalid conditional test ${JSON.stringify({ exists, eq, neq })}`);
|
11
|
-
}
|
12
|
-
if (typeof eq !== "undefined") {
|
13
|
-
return isEqual(value, eq);
|
14
|
-
}
|
15
|
-
if (typeof neq !== "undefined") {
|
16
|
-
return !isEqual(value, neq);
|
17
|
-
}
|
18
|
-
if (typeof exists !== "undefined") {
|
19
|
-
const valueExists = typeof value !== "undefined";
|
20
|
-
return exists ? valueExists : !valueExists;
|
21
|
-
}
|
22
|
-
const shouldBeTruthy = typeof truthy === "undefined" ? true : truthy;
|
23
|
-
return shouldBeTruthy ? !!value : !value;
|
24
|
-
};
|
25
|
-
var includeConditionalArg = (argType, args, globals) => {
|
26
|
-
if (!argType.if)
|
27
|
-
return true;
|
28
|
-
const { arg, global } = argType.if;
|
29
|
-
if (count([arg, global]) !== 1) {
|
30
|
-
throw new Error(`Invalid conditional value ${JSON.stringify({ arg, global })}`);
|
31
|
-
}
|
32
|
-
const value = arg ? args[arg] : globals[global];
|
33
|
-
return testValue(argType.if, value);
|
34
|
-
};
|
35
|
-
|
36
|
-
// src/index.ts
|
37
|
-
var sanitize = (string) => {
|
38
|
-
return string.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
|
39
|
-
};
|
40
|
-
var sanitizeSafe = (string, part) => {
|
41
|
-
const sanitized = sanitize(string);
|
42
|
-
if (sanitized === "") {
|
43
|
-
throw new Error(`Invalid ${part} '${string}', must include alphanumeric characters`);
|
44
|
-
}
|
45
|
-
return sanitized;
|
46
|
-
};
|
47
|
-
var toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`;
|
48
|
-
var storyNameFromExport = (key) => startCase(key);
|
49
|
-
function matches(storyKey, arrayOrRegex) {
|
50
|
-
if (Array.isArray(arrayOrRegex)) {
|
51
|
-
return arrayOrRegex.includes(storyKey);
|
52
|
-
}
|
53
|
-
return storyKey.match(arrayOrRegex);
|
54
|
-
}
|
55
|
-
function isExportStory(key, { includeStories, excludeStories }) {
|
56
|
-
return key !== "__esModule" && (!includeStories || matches(key, includeStories)) && (!excludeStories || !matches(key, excludeStories));
|
57
|
-
}
|
58
|
-
var parseKind = (kind, { rootSeparator, groupSeparator }) => {
|
59
|
-
const [root, remainder] = kind.split(rootSeparator, 2);
|
60
|
-
const groups = (remainder || kind).split(groupSeparator).filter((i) => !!i);
|
61
|
-
return {
|
62
|
-
root: remainder ? root : null,
|
63
|
-
groups
|
64
|
-
};
|
65
|
-
};
|
66
|
-
export {
|
67
|
-
includeConditionalArg,
|
68
|
-
isExportStory,
|
69
|
-
parseKind,
|
70
|
-
sanitize,
|
71
|
-
storyNameFromExport,
|
72
|
-
toId
|
73
|
-
};
|
3
|
+
export { v as includeConditionalArg, G as isExportStory, z as parseKind, L as sanitize, M as storyNameFromExport, N as toId };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/csf",
|
3
|
-
"version": "0.0.2-next.
|
3
|
+
"version": "0.0.2-next.10",
|
4
4
|
"description": "Component Story Format (CSF) utilities",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -17,27 +17,52 @@
|
|
17
17
|
"url": "https://github.com/ComponentDriven/csf.git"
|
18
18
|
},
|
19
19
|
"license": "MIT",
|
20
|
+
"exports": {
|
21
|
+
".": {
|
22
|
+
"import": "./dist/index.mjs",
|
23
|
+
"require": "./dist/index.js",
|
24
|
+
"browser": "./dist/index.mjs",
|
25
|
+
"node": "./dist/index.js",
|
26
|
+
"types": "./dist/index.d.ts"
|
27
|
+
}
|
28
|
+
},
|
29
|
+
"main": "dist/index.js",
|
30
|
+
"module": "dist/index.mjs",
|
31
|
+
"types": "dist/index.d.ts",
|
20
32
|
"files": [
|
21
33
|
"dist/**/*",
|
22
34
|
"README.md",
|
23
35
|
"*.js",
|
24
36
|
"*.d.ts"
|
25
37
|
],
|
26
|
-
"main": "dist/index.js",
|
27
|
-
"module": "dist/index.mjs",
|
28
|
-
"types": "dist/index.d.ts",
|
29
38
|
"scripts": {
|
30
|
-
"build": "tsup ./src/index.ts --format esm,cjs --dts",
|
39
|
+
"build": "tsup ./src/index.ts --format esm,cjs --dts --treeshake --minify",
|
31
40
|
"check": "tsc",
|
32
41
|
"lint": "eslint src --ext .ts",
|
33
|
-
"
|
34
|
-
"
|
42
|
+
"release": "yarn build && auto shipit",
|
43
|
+
"test": "NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules jest"
|
35
44
|
},
|
45
|
+
"prettier": "@storybook/linter-config/prettier.config",
|
36
46
|
"eslintConfig": {
|
47
|
+
"parserOptions": {
|
48
|
+
"project": [
|
49
|
+
"./tsconfig.json"
|
50
|
+
]
|
51
|
+
},
|
52
|
+
"settings": {
|
53
|
+
"import/resolver": {
|
54
|
+
"typescript": {
|
55
|
+
"project": [
|
56
|
+
"./tsconfig.json"
|
57
|
+
]
|
58
|
+
}
|
59
|
+
}
|
60
|
+
},
|
37
61
|
"extends": [
|
38
62
|
"@storybook/eslint-config-storybook"
|
39
63
|
],
|
40
64
|
"rules": {
|
65
|
+
"import/no-unresolved": "error",
|
41
66
|
"jest/expect-expect": [
|
42
67
|
"warn",
|
43
68
|
{
|
@@ -49,42 +74,60 @@
|
|
49
74
|
]
|
50
75
|
}
|
51
76
|
},
|
52
|
-
"prettier": "@storybook/linter-config/prettier.config",
|
53
77
|
"jest": {
|
54
|
-
"
|
55
|
-
|
78
|
+
"extensionsToTreatAsEsm": [
|
79
|
+
".ts"
|
80
|
+
],
|
81
|
+
"moduleNameMapper": {
|
82
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
83
|
+
},
|
84
|
+
"preset": "ts-jest/presets/default-esm",
|
56
85
|
"roots": [
|
57
86
|
"<rootDir>/src"
|
58
|
-
]
|
87
|
+
],
|
88
|
+
"testEnvironment": "node",
|
89
|
+
"transform": {
|
90
|
+
"^.+\\.tsx?$": [
|
91
|
+
"ts-jest",
|
92
|
+
{
|
93
|
+
"useESM": true
|
94
|
+
}
|
95
|
+
]
|
96
|
+
}
|
59
97
|
},
|
60
98
|
"dependencies": {
|
61
|
-
"expect-type": "^0.14.2",
|
62
|
-
"lodash": "^4.17.15",
|
63
99
|
"type-fest": "^2.19.0"
|
64
100
|
},
|
65
101
|
"devDependencies": {
|
66
|
-
"@auto-it/released": "^10.37.
|
67
|
-
"@
|
102
|
+
"@auto-it/released": "^10.37.6",
|
103
|
+
"@ngard/tiny-isequal": "^1.1.0",
|
104
|
+
"@storybook/eslint-config-storybook": "^3.1.2",
|
68
105
|
"@types/jest": "^29.2.0",
|
69
|
-
"@types/lodash": "^4.14.149",
|
70
106
|
"@types/node": "^18.11.0",
|
71
|
-
"@typescript-eslint/
|
72
|
-
"
|
107
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
108
|
+
"@typescript-eslint/parser": "^5.42.1",
|
109
|
+
"auto": "^10.37.6",
|
73
110
|
"common-tags": "^1.8.0",
|
74
|
-
"eslint": "^
|
75
|
-
"
|
111
|
+
"eslint": "^8.27.0",
|
112
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
113
|
+
"eslint-plugin-import": "^2.26.0",
|
114
|
+
"eslint-plugin-jest": "^27.1.4",
|
115
|
+
"expect-type": "^0.14.2",
|
116
|
+
"jest": "^29.3.1",
|
117
|
+
"lodash": "^4.17.21",
|
118
|
+
"@types/lodash": "^4.14.191",
|
76
119
|
"prettier": "^2.7.1",
|
77
120
|
"ts-jest": "^29.0.3",
|
78
|
-
"tsup": "^6.
|
121
|
+
"tsup": "^6.4.0",
|
79
122
|
"typescript": "^4.8.4"
|
80
123
|
},
|
124
|
+
"publishConfig": {
|
125
|
+
"access": "public"
|
126
|
+
},
|
81
127
|
"auto": {
|
82
128
|
"plugins": [
|
83
129
|
"npm",
|
84
130
|
"released"
|
85
131
|
]
|
86
|
-
},
|
87
|
-
"publishConfig": {
|
88
|
-
"access": "public"
|
89
132
|
}
|
90
133
|
}
|