@storybook/csf 0.0.2--canary.60.011a95e.0 → 0.0.2--canary.62.d7abc02.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +56 -56
- package/dist/index.js +91 -29
- package/dist/index.mjs +105 -14
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
@@ -4,42 +4,42 @@ 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;
|
@@ -57,7 +57,7 @@ interface Parameters {
|
|
57
57
|
interface StrictParameters {
|
58
58
|
[name: string]: unknown;
|
59
59
|
}
|
60
|
-
|
60
|
+
type ConditionalTest = {
|
61
61
|
truthy?: boolean;
|
62
62
|
} | {
|
63
63
|
exists: boolean;
|
@@ -66,12 +66,12 @@ declare type ConditionalTest = {
|
|
66
66
|
} | {
|
67
67
|
neq: any;
|
68
68
|
};
|
69
|
-
|
69
|
+
type ConditionalValue = {
|
70
70
|
arg: string;
|
71
71
|
} | {
|
72
72
|
global: string;
|
73
73
|
};
|
74
|
-
|
74
|
+
type Conditional = ConditionalValue & ConditionalTest;
|
75
75
|
interface InputType {
|
76
76
|
name?: string;
|
77
77
|
description?: string;
|
@@ -90,22 +90,22 @@ interface Args {
|
|
90
90
|
interface StrictArgs {
|
91
91
|
[name: string]: unknown;
|
92
92
|
}
|
93
|
-
|
93
|
+
type ArgTypes<TArgs = Args> = {
|
94
94
|
[name in keyof TArgs]: InputType;
|
95
95
|
};
|
96
|
-
|
96
|
+
type StrictArgTypes<TArgs = Args> = {
|
97
97
|
[name in keyof TArgs]: StrictInputType;
|
98
98
|
};
|
99
|
-
|
99
|
+
type Globals = {
|
100
100
|
[name: string]: any;
|
101
101
|
};
|
102
|
-
|
102
|
+
type GlobalTypes = {
|
103
103
|
[name: string]: InputType;
|
104
104
|
};
|
105
|
-
|
105
|
+
type StrictGlobalTypes = {
|
106
106
|
[name: string]: StrictInputType;
|
107
107
|
};
|
108
|
-
|
108
|
+
type Renderer = {
|
109
109
|
/** What is the type of the `component` annotation in this renderer? */
|
110
110
|
component: unknown;
|
111
111
|
/** What does the story function return in this renderer? */
|
@@ -115,8 +115,8 @@ declare type Renderer = {
|
|
115
115
|
T?: unknown;
|
116
116
|
};
|
117
117
|
/** @deprecated - use `Renderer` */
|
118
|
-
|
119
|
-
|
118
|
+
type AnyFramework = Renderer;
|
119
|
+
type StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryIdentifier & {
|
120
120
|
component?: (TRenderer & {
|
121
121
|
T: any;
|
122
122
|
})['component'];
|
@@ -127,43 +127,43 @@ declare type StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TAr
|
|
127
127
|
initialArgs: TArgs;
|
128
128
|
argTypes: StrictArgTypes<TArgs>;
|
129
129
|
};
|
130
|
-
|
131
|
-
|
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>) & {
|
132
132
|
secondPass?: boolean;
|
133
133
|
};
|
134
|
-
|
134
|
+
type StoryContextUpdate<TArgs = Args> = {
|
135
135
|
args?: TArgs;
|
136
136
|
globals?: Globals;
|
137
137
|
[key: string]: any;
|
138
138
|
};
|
139
|
-
|
140
|
-
|
139
|
+
type ViewMode = 'story' | 'docs';
|
140
|
+
type StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContextForEnhancers<TRenderer, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
141
141
|
hooks: unknown;
|
142
142
|
viewMode: ViewMode;
|
143
143
|
originalStoryFn: StoryFn<TRenderer>;
|
144
144
|
};
|
145
|
-
|
146
|
-
|
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> & {
|
147
147
|
loaded: Record<string, any>;
|
148
148
|
abortSignal: AbortSignal;
|
149
149
|
canvasElement: TRenderer['canvasElement'];
|
150
150
|
};
|
151
|
-
|
152
|
-
|
153
|
-
|
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
154
|
step: StepFunction<TRenderer, TArgs>;
|
155
155
|
};
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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 & {
|
160
160
|
T: TArgs;
|
161
161
|
})['storyResult'];
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
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> = {
|
167
167
|
/**
|
168
168
|
* Wrapper components or Storybook decorators that wrap a story.
|
169
169
|
*
|
@@ -196,7 +196,7 @@ declare type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args
|
|
196
196
|
*/
|
197
197
|
render?: ArgsStoryFn<TRenderer, TArgs>;
|
198
198
|
};
|
199
|
-
|
199
|
+
type ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = BaseAnnotations<TRenderer, TArgs> & {
|
200
200
|
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
201
201
|
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
202
202
|
globals?: Globals;
|
@@ -204,7 +204,7 @@ declare type ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs = A
|
|
204
204
|
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
205
205
|
runStep?: StepRunner<TRenderer, TArgs>;
|
206
206
|
};
|
207
|
-
|
207
|
+
type StoryDescriptor$1 = string[] | RegExp;
|
208
208
|
interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> extends BaseAnnotations<TRenderer, TArgs> {
|
209
209
|
/**
|
210
210
|
* Title of the component which will be presented in the navigation. **Should be unique.**
|
@@ -281,7 +281,7 @@ interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Ar
|
|
281
281
|
*/
|
282
282
|
tags?: Tag[];
|
283
283
|
}
|
284
|
-
|
284
|
+
type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TRenderer, TArgs> & {
|
285
285
|
/**
|
286
286
|
* Override the display name in the UI (CSF v3)
|
287
287
|
*/
|
@@ -305,23 +305,23 @@ declare type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Arg
|
|
305
305
|
} : {
|
306
306
|
args: TRequiredArgs;
|
307
307
|
});
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
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
313
|
render?: ArgsStoryFn<TRenderer, infer RArgs>;
|
314
314
|
loaders?: (infer Loaders)[];
|
315
315
|
decorators?: (infer Decorators)[];
|
316
316
|
} ? Simplify<RemoveIndexSignature<RArgs & DecoratorsArgs<TRenderer, Decorators> & LoaderArgs<TRenderer, Loaders>>> : unknown;
|
317
|
-
|
318
|
-
|
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>;
|
319
319
|
|
320
320
|
/**
|
321
321
|
* Helper function to include/exclude an arg based on the value of other other args
|
322
322
|
* aka "conditional args"
|
323
323
|
*/
|
324
|
-
declare const includeConditionalArg: (argType: InputType, args: Args, globals: Globals) =>
|
324
|
+
declare const includeConditionalArg: (argType: InputType, args: Args, globals: Globals) => any;
|
325
325
|
|
326
326
|
/**
|
327
327
|
* Remove punctuation and illegal characters from a story ID.
|
@@ -337,7 +337,7 @@ declare const toId: (kind: string, name?: string) => string;
|
|
337
337
|
* Transform a CSF named export into a readable story name
|
338
338
|
*/
|
339
339
|
declare const storyNameFromExport: (key: string) => string;
|
340
|
-
|
340
|
+
type StoryDescriptor = string[] | RegExp;
|
341
341
|
interface IncludeExcludeOptions {
|
342
342
|
includeStories?: StoryDescriptor;
|
343
343
|
excludeStories?: StoryDescriptor;
|
package/dist/index.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
|
1
|
+
'use strict';
|
2
|
+
|
2
3
|
var __create = Object.create;
|
3
4
|
var __defProp = Object.defineProperty;
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
7
|
var __getProtoOf = Object.getPrototypeOf;
|
7
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
-
var
|
9
|
-
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
11
11
|
};
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
@@ -21,23 +21,87 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
21
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
22
22
|
mod
|
23
23
|
));
|
24
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
25
24
|
|
26
|
-
//
|
27
|
-
var
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
// node_modules/@ngard/tiny-isequal/index.js
|
26
|
+
var require_tiny_isequal = __commonJS({
|
27
|
+
"node_modules/@ngard/tiny-isequal/index.js"(exports) {
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true }), exports.isEqual = function() {
|
29
|
+
var e = Object.prototype.toString, r = Object.getPrototypeOf, t = Object.getOwnPropertySymbols ? function(e2) {
|
30
|
+
return Object.keys(e2).concat(Object.getOwnPropertySymbols(e2));
|
31
|
+
} : Object.keys;
|
32
|
+
return function(n, a) {
|
33
|
+
return function n2(a2, c, u) {
|
34
|
+
var i, s, l, o = e.call(a2), f = e.call(c);
|
35
|
+
if (a2 === c)
|
36
|
+
return true;
|
37
|
+
if (null == a2 || null == c)
|
38
|
+
return false;
|
39
|
+
if (u.indexOf(a2) > -1 && u.indexOf(c) > -1)
|
40
|
+
return true;
|
41
|
+
if (u.push(a2, c), o != f)
|
42
|
+
return false;
|
43
|
+
if (i = t(a2), s = t(c), i.length != s.length || i.some(function(e2) {
|
44
|
+
return !n2(a2[e2], c[e2], u);
|
45
|
+
}))
|
46
|
+
return false;
|
47
|
+
switch (o.slice(8, -1)) {
|
48
|
+
case "Symbol":
|
49
|
+
return a2.valueOf() == c.valueOf();
|
50
|
+
case "Date":
|
51
|
+
case "Number":
|
52
|
+
return +a2 == +c || +a2 != +a2 && +c != +c;
|
53
|
+
case "RegExp":
|
54
|
+
case "Function":
|
55
|
+
case "String":
|
56
|
+
case "Boolean":
|
57
|
+
return "" + a2 == "" + c;
|
58
|
+
case "Set":
|
59
|
+
case "Map":
|
60
|
+
i = a2.entries(), s = c.entries();
|
61
|
+
do {
|
62
|
+
if (!n2((l = i.next()).value, s.next().value, u))
|
63
|
+
return false;
|
64
|
+
} while (!l.done);
|
65
|
+
return true;
|
66
|
+
case "ArrayBuffer":
|
67
|
+
a2 = new Uint8Array(a2), c = new Uint8Array(c);
|
68
|
+
case "DataView":
|
69
|
+
a2 = new Uint8Array(a2.buffer), c = new Uint8Array(c.buffer);
|
70
|
+
case "Float32Array":
|
71
|
+
case "Float64Array":
|
72
|
+
case "Int8Array":
|
73
|
+
case "Int16Array":
|
74
|
+
case "Int32Array":
|
75
|
+
case "Uint8Array":
|
76
|
+
case "Uint16Array":
|
77
|
+
case "Uint32Array":
|
78
|
+
case "Uint8ClampedArray":
|
79
|
+
case "Arguments":
|
80
|
+
case "Array":
|
81
|
+
if (a2.length != c.length)
|
82
|
+
return false;
|
83
|
+
for (l = 0; l < a2.length; l++)
|
84
|
+
if ((l in a2 || l in c) && (l in a2 != l in c || !n2(a2[l], c[l], u)))
|
85
|
+
return false;
|
86
|
+
return true;
|
87
|
+
case "Object":
|
88
|
+
return n2(r(a2), r(c), u);
|
89
|
+
default:
|
90
|
+
return false;
|
91
|
+
}
|
92
|
+
}(n, a, []);
|
93
|
+
};
|
94
|
+
}();
|
95
|
+
}
|
35
96
|
});
|
36
|
-
|
37
|
-
|
97
|
+
|
98
|
+
// src/toStartCaseStr.ts
|
99
|
+
function toStartCaseStr(str) {
|
100
|
+
return str.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, (str2, $1, $2) => `${$1} ${$2}`).replace(/([a-z])([0-9])/gi, (str2, $1, $2) => `${$1} ${$2}`).replace(/(\s|^)(\w)/g, (str2, $1, $2) => $1 + $2.toUpperCase());
|
101
|
+
}
|
38
102
|
|
39
103
|
// src/includeConditionalArg.ts
|
40
|
-
var
|
104
|
+
var import_tiny_isequal = __toESM(require_tiny_isequal());
|
41
105
|
var count = (vals) => vals.map((v) => typeof v !== "undefined").filter(Boolean).length;
|
42
106
|
var testValue = (cond, value) => {
|
43
107
|
const { exists, eq, neq, truthy } = cond;
|
@@ -45,10 +109,10 @@ var testValue = (cond, value) => {
|
|
45
109
|
throw new Error(`Invalid conditional test ${JSON.stringify({ exists, eq, neq })}`);
|
46
110
|
}
|
47
111
|
if (typeof eq !== "undefined") {
|
48
|
-
return (0,
|
112
|
+
return (0, import_tiny_isequal.isEqual)(value, eq);
|
49
113
|
}
|
50
114
|
if (typeof neq !== "undefined") {
|
51
|
-
return !(0,
|
115
|
+
return !(0, import_tiny_isequal.isEqual)(value, neq);
|
52
116
|
}
|
53
117
|
if (typeof exists !== "undefined") {
|
54
118
|
const valueExists = typeof value !== "undefined";
|
@@ -80,7 +144,7 @@ var sanitizeSafe = (string, part) => {
|
|
80
144
|
return sanitized;
|
81
145
|
};
|
82
146
|
var toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`;
|
83
|
-
var storyNameFromExport = (key) => (
|
147
|
+
var storyNameFromExport = (key) => toStartCaseStr(key);
|
84
148
|
function matches(storyKey, arrayOrRegex) {
|
85
149
|
if (Array.isArray(arrayOrRegex)) {
|
86
150
|
return arrayOrRegex.includes(storyKey);
|
@@ -98,12 +162,10 @@ var parseKind = (kind, { rootSeparator, groupSeparator }) => {
|
|
98
162
|
groups
|
99
163
|
};
|
100
164
|
};
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
toId
|
109
|
-
});
|
165
|
+
|
166
|
+
exports.includeConditionalArg = includeConditionalArg;
|
167
|
+
exports.isExportStory = isExportStory;
|
168
|
+
exports.parseKind = parseKind;
|
169
|
+
exports.sanitize = sanitize;
|
170
|
+
exports.storyNameFromExport = storyNameFromExport;
|
171
|
+
exports.toId = toId;
|
package/dist/index.mjs
CHANGED
@@ -1,8 +1,105 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
8
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
19
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
20
|
+
mod
|
21
|
+
));
|
22
|
+
|
23
|
+
// node_modules/@ngard/tiny-isequal/index.js
|
24
|
+
var require_tiny_isequal = __commonJS({
|
25
|
+
"node_modules/@ngard/tiny-isequal/index.js"(exports) {
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true }), exports.isEqual = function() {
|
27
|
+
var e = Object.prototype.toString, r = Object.getPrototypeOf, t = Object.getOwnPropertySymbols ? function(e2) {
|
28
|
+
return Object.keys(e2).concat(Object.getOwnPropertySymbols(e2));
|
29
|
+
} : Object.keys;
|
30
|
+
return function(n, a) {
|
31
|
+
return function n2(a2, c, u) {
|
32
|
+
var i, s, l, o = e.call(a2), f = e.call(c);
|
33
|
+
if (a2 === c)
|
34
|
+
return true;
|
35
|
+
if (null == a2 || null == c)
|
36
|
+
return false;
|
37
|
+
if (u.indexOf(a2) > -1 && u.indexOf(c) > -1)
|
38
|
+
return true;
|
39
|
+
if (u.push(a2, c), o != f)
|
40
|
+
return false;
|
41
|
+
if (i = t(a2), s = t(c), i.length != s.length || i.some(function(e2) {
|
42
|
+
return !n2(a2[e2], c[e2], u);
|
43
|
+
}))
|
44
|
+
return false;
|
45
|
+
switch (o.slice(8, -1)) {
|
46
|
+
case "Symbol":
|
47
|
+
return a2.valueOf() == c.valueOf();
|
48
|
+
case "Date":
|
49
|
+
case "Number":
|
50
|
+
return +a2 == +c || +a2 != +a2 && +c != +c;
|
51
|
+
case "RegExp":
|
52
|
+
case "Function":
|
53
|
+
case "String":
|
54
|
+
case "Boolean":
|
55
|
+
return "" + a2 == "" + c;
|
56
|
+
case "Set":
|
57
|
+
case "Map":
|
58
|
+
i = a2.entries(), s = c.entries();
|
59
|
+
do {
|
60
|
+
if (!n2((l = i.next()).value, s.next().value, u))
|
61
|
+
return false;
|
62
|
+
} while (!l.done);
|
63
|
+
return true;
|
64
|
+
case "ArrayBuffer":
|
65
|
+
a2 = new Uint8Array(a2), c = new Uint8Array(c);
|
66
|
+
case "DataView":
|
67
|
+
a2 = new Uint8Array(a2.buffer), c = new Uint8Array(c.buffer);
|
68
|
+
case "Float32Array":
|
69
|
+
case "Float64Array":
|
70
|
+
case "Int8Array":
|
71
|
+
case "Int16Array":
|
72
|
+
case "Int32Array":
|
73
|
+
case "Uint8Array":
|
74
|
+
case "Uint16Array":
|
75
|
+
case "Uint32Array":
|
76
|
+
case "Uint8ClampedArray":
|
77
|
+
case "Arguments":
|
78
|
+
case "Array":
|
79
|
+
if (a2.length != c.length)
|
80
|
+
return false;
|
81
|
+
for (l = 0; l < a2.length; l++)
|
82
|
+
if ((l in a2 || l in c) && (l in a2 != l in c || !n2(a2[l], c[l], u)))
|
83
|
+
return false;
|
84
|
+
return true;
|
85
|
+
case "Object":
|
86
|
+
return n2(r(a2), r(c), u);
|
87
|
+
default:
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
}(n, a, []);
|
91
|
+
};
|
92
|
+
}();
|
93
|
+
}
|
94
|
+
});
|
95
|
+
|
96
|
+
// src/toStartCaseStr.ts
|
97
|
+
function toStartCaseStr(str) {
|
98
|
+
return str.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, (str2, $1, $2) => `${$1} ${$2}`).replace(/([a-z])([0-9])/gi, (str2, $1, $2) => `${$1} ${$2}`).replace(/(\s|^)(\w)/g, (str2, $1, $2) => $1 + $2.toUpperCase());
|
99
|
+
}
|
3
100
|
|
4
101
|
// src/includeConditionalArg.ts
|
5
|
-
|
102
|
+
var import_tiny_isequal = __toESM(require_tiny_isequal());
|
6
103
|
var count = (vals) => vals.map((v) => typeof v !== "undefined").filter(Boolean).length;
|
7
104
|
var testValue = (cond, value) => {
|
8
105
|
const { exists, eq, neq, truthy } = cond;
|
@@ -10,10 +107,10 @@ var testValue = (cond, value) => {
|
|
10
107
|
throw new Error(`Invalid conditional test ${JSON.stringify({ exists, eq, neq })}`);
|
11
108
|
}
|
12
109
|
if (typeof eq !== "undefined") {
|
13
|
-
return isEqual(value, eq);
|
110
|
+
return (0, import_tiny_isequal.isEqual)(value, eq);
|
14
111
|
}
|
15
112
|
if (typeof neq !== "undefined") {
|
16
|
-
return !isEqual(value, neq);
|
113
|
+
return !(0, import_tiny_isequal.isEqual)(value, neq);
|
17
114
|
}
|
18
115
|
if (typeof exists !== "undefined") {
|
19
116
|
const valueExists = typeof value !== "undefined";
|
@@ -45,7 +142,7 @@ var sanitizeSafe = (string, part) => {
|
|
45
142
|
return sanitized;
|
46
143
|
};
|
47
144
|
var toId = (kind, name) => `${sanitizeSafe(kind, "kind")}${name ? `--${sanitizeSafe(name, "name")}` : ""}`;
|
48
|
-
var storyNameFromExport = (key) =>
|
145
|
+
var storyNameFromExport = (key) => toStartCaseStr(key);
|
49
146
|
function matches(storyKey, arrayOrRegex) {
|
50
147
|
if (Array.isArray(arrayOrRegex)) {
|
51
148
|
return arrayOrRegex.includes(storyKey);
|
@@ -63,11 +160,5 @@ var parseKind = (kind, { rootSeparator, groupSeparator }) => {
|
|
63
160
|
groups
|
64
161
|
};
|
65
162
|
};
|
66
|
-
|
67
|
-
|
68
|
-
isExportStory,
|
69
|
-
parseKind,
|
70
|
-
sanitize,
|
71
|
-
storyNameFromExport,
|
72
|
-
toId
|
73
|
-
};
|
163
|
+
|
164
|
+
export { 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.62.d7abc02.0",
|
4
4
|
"description": "Component Story Format (CSF) utilities",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -33,7 +33,7 @@
|
|
33
33
|
"module": "dist/index.mjs",
|
34
34
|
"types": "dist/index.d.ts",
|
35
35
|
"scripts": {
|
36
|
-
"build": "tsup ./src/index.ts --format esm,cjs --dts",
|
36
|
+
"build": "tsup ./src/index.ts --format esm,cjs --dts --treeshake",
|
37
37
|
"check": "tsc",
|
38
38
|
"lint": "eslint src --ext .ts",
|
39
39
|
"test": "NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules jest",
|
@@ -93,15 +93,14 @@
|
|
93
93
|
]
|
94
94
|
},
|
95
95
|
"dependencies": {
|
96
|
-
"expect-type": "^0.14.2",
|
97
|
-
"lodash": "^4.17.15",
|
98
96
|
"type-fest": "^2.19.0"
|
99
97
|
},
|
100
98
|
"devDependencies": {
|
99
|
+
"expect-type": "^0.14.2",
|
101
100
|
"@auto-it/released": "^10.37.6",
|
101
|
+
"@ngard/tiny-isequal": "^1.1.0",
|
102
102
|
"@storybook/eslint-config-storybook": "^3.1.2",
|
103
103
|
"@types/jest": "^29.2.0",
|
104
|
-
"@types/lodash": "^4.14.149",
|
105
104
|
"@types/node": "^18.11.0",
|
106
105
|
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
107
106
|
"@typescript-eslint/parser": "^5.42.1",
|