storybook 9.1.0-alpha.2 → 9.1.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.cjs +16 -16
- package/dist/actions/index.d.ts +1 -38
- package/dist/actions/index.js +12 -12
- package/dist/actions/preview.cjs +25 -25
- package/dist/actions/preview.d.ts +37 -547
- package/dist/actions/preview.js +18 -18
- package/dist/backgrounds/index.cjs +12 -144
- package/dist/backgrounds/index.d.ts +1 -591
- package/dist/backgrounds/index.js +0 -130
- package/dist/backgrounds/preview.cjs +63 -63
- package/dist/backgrounds/preview.d.ts +40 -542
- package/dist/backgrounds/preview.js +47 -47
- package/dist/bin/index.cjs +50 -50
- package/dist/bin/index.js +50 -50
- package/dist/builder-manager/index.cjs +379 -378
- package/dist/builder-manager/index.d.ts +567 -2
- package/dist/builder-manager/index.js +280 -279
- package/dist/cli/bin/index.cjs +1 -1
- package/dist/cli/bin/index.js +1 -1
- package/dist/common/index.cjs +87 -79
- package/dist/common/index.d.ts +2 -2
- package/dist/common/index.js +725 -716
- package/dist/component-testing/preview.cjs +12 -12
- package/dist/component-testing/preview.d.ts +2 -2
- package/dist/component-testing/preview.js +7 -7
- package/dist/components/index.cjs +1899 -1895
- package/dist/components/index.js +1343 -1339
- package/dist/controls/index.cjs +16 -16
- package/dist/controls/index.d.ts +1 -36
- package/dist/controls/preview.cjs +17 -17
- package/dist/controls/preview.d.ts +34 -546
- package/dist/controls/preview.js +3 -3
- package/dist/csf/index.cjs +1210 -95
- package/dist/csf/index.d.ts +59 -18
- package/dist/csf/index.js +1214 -90
- package/dist/csf-tools/index.cjs +2 -1
- package/dist/csf-tools/index.js +2 -2
- package/dist/highlight/index.cjs +15 -15
- package/dist/highlight/index.d.ts +1 -12
- package/dist/highlight/index.js +4 -4
- package/dist/highlight/preview.cjs +63 -63
- package/dist/highlight/preview.d.ts +11 -546
- package/dist/highlight/preview.js +11 -10
- package/dist/manager/globals-runtime.js +31934 -31888
- package/dist/manager-api/index.cjs +1 -1
- package/dist/manager-api/index.js +1 -1
- package/dist/measure/index.cjs +12 -472
- package/dist/measure/index.d.ts +1 -566
- package/dist/measure/index.js +0 -464
- package/dist/measure/preview.cjs +127 -127
- package/dist/measure/preview.d.ts +11 -546
- package/dist/measure/preview.js +117 -117
- package/dist/outline/index.cjs +12 -524
- package/dist/outline/index.d.ts +1 -566
- package/dist/outline/index.js +0 -500
- package/dist/outline/preview.cjs +32 -32
- package/dist/outline/preview.d.ts +11 -546
- package/dist/outline/preview.js +27 -27
- package/dist/preview/runtime.js +9415 -9379
- package/dist/preview-api/index.cjs +1228 -1261
- package/dist/preview-api/index.d.ts +6 -8
- package/dist/preview-api/index.js +927 -963
- package/dist/telemetry/index.cjs +1477 -1288
- package/dist/telemetry/index.js +1503 -1314
- package/dist/test/index.cjs +4437 -4394
- package/dist/test/index.js +3776 -3733
- package/dist/test/preview.cjs +42 -42
- package/dist/test/preview.d.ts +12 -550
- package/dist/test/preview.js +36 -36
- package/dist/types/index.d.ts +5 -3
- package/dist/viewport/index.cjs +17 -24
- package/dist/viewport/index.d.ts +9 -532
- package/dist/viewport/index.js +9 -16
- package/dist/viewport/preview.cjs +22 -22
- package/dist/viewport/preview.d.ts +45 -552
- package/dist/viewport/preview.js +8 -8
- package/package.json +1 -1
package/dist/csf/index.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
1
|
+
var Ge = Object.create;
|
|
2
|
+
var L = Object.defineProperty;
|
|
3
|
+
var Ve = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var qe = Object.getOwnPropertyNames;
|
|
5
|
+
var Ke = Object.getPrototypeOf, Ye = Object.prototype.hasOwnProperty;
|
|
6
|
+
var s = (e, r) => L(e, "name", { value: r, configurable: !0 });
|
|
7
|
+
var Je = (e, r) => () => (r || e((r = { exports: {} }).exports, r), r.exports);
|
|
8
|
+
var Xe = (e, r, t, o) => {
|
|
9
9
|
if (r && typeof r == "object" || typeof r == "function")
|
|
10
|
-
for (let
|
|
11
|
-
!
|
|
10
|
+
for (let a of qe(r))
|
|
11
|
+
!Ye.call(e, a) && a !== t && L(e, a, { get: () => r[a], enumerable: !(o = Ve(r, a)) || o.enumerable });
|
|
12
12
|
return e;
|
|
13
13
|
};
|
|
14
|
-
var
|
|
14
|
+
var Ze = (e, r, t) => (t = e != null ? Ge(Ke(e)) : {}, Xe(
|
|
15
15
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
16
16
|
// file that has been converted to a CommonJS file using a Babel-
|
|
17
17
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
18
18
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
19
|
-
r || !e || !e.__esModule ?
|
|
19
|
+
r || !e || !e.__esModule ? L(t, "default", { value: e, enumerable: !0 }) : t,
|
|
20
20
|
e
|
|
21
21
|
));
|
|
22
22
|
|
|
23
23
|
// ../node_modules/@ngard/tiny-isequal/index.js
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(
|
|
26
|
-
var e = Object.prototype.toString, r = Object.getPrototypeOf, t = Object.getOwnPropertySymbols ? function(
|
|
27
|
-
return Object.keys(
|
|
24
|
+
var fe = Je((W) => {
|
|
25
|
+
Object.defineProperty(W, "__esModule", { value: !0 }), W.isEqual = /* @__PURE__ */ function() {
|
|
26
|
+
var e = Object.prototype.toString, r = Object.getPrototypeOf, t = Object.getOwnPropertySymbols ? function(o) {
|
|
27
|
+
return Object.keys(o).concat(Object.getOwnPropertySymbols(o));
|
|
28
28
|
} : Object.keys;
|
|
29
|
-
return function(
|
|
30
|
-
return (/* @__PURE__ */
|
|
31
|
-
var c,
|
|
32
|
-
if (
|
|
33
|
-
if (
|
|
34
|
-
if (
|
|
35
|
-
if (
|
|
36
|
-
return !
|
|
29
|
+
return function(o, a) {
|
|
30
|
+
return (/* @__PURE__ */ s(function n(i, p, d) {
|
|
31
|
+
var c, m, f, y = e.call(i), h = e.call(p);
|
|
32
|
+
if (i === p) return !0;
|
|
33
|
+
if (i == null || p == null) return !1;
|
|
34
|
+
if (d.indexOf(i) > -1 && d.indexOf(p) > -1) return !0;
|
|
35
|
+
if (d.push(i, p), y != h || (c = t(i), m = t(p), c.length != m.length || c.some(function(S) {
|
|
36
|
+
return !n(i[S], p[S], d);
|
|
37
37
|
}))) return !1;
|
|
38
|
-
switch (
|
|
38
|
+
switch (y.slice(8, -1)) {
|
|
39
39
|
case "Symbol":
|
|
40
|
-
return
|
|
40
|
+
return i.valueOf() == p.valueOf();
|
|
41
41
|
case "Date":
|
|
42
42
|
case "Number":
|
|
43
|
-
return +
|
|
43
|
+
return +i == +p || +i != +i && +p != +p;
|
|
44
44
|
case "RegExp":
|
|
45
45
|
case "Function":
|
|
46
46
|
case "String":
|
|
47
47
|
case "Boolean":
|
|
48
|
-
return "" +
|
|
48
|
+
return "" + i == "" + p;
|
|
49
49
|
case "Set":
|
|
50
50
|
case "Map":
|
|
51
|
-
c =
|
|
51
|
+
c = i.entries(), m = p.entries();
|
|
52
52
|
do
|
|
53
|
-
if (!
|
|
54
|
-
while (!
|
|
53
|
+
if (!n((f = c.next()).value, m.next().value, d)) return !1;
|
|
54
|
+
while (!f.done);
|
|
55
55
|
return !0;
|
|
56
56
|
case "ArrayBuffer":
|
|
57
|
-
|
|
57
|
+
i = new Uint8Array(i), p = new Uint8Array(p);
|
|
58
58
|
case "DataView":
|
|
59
|
-
|
|
59
|
+
i = new Uint8Array(i.buffer), p = new Uint8Array(p.buffer);
|
|
60
60
|
case "Float32Array":
|
|
61
61
|
case "Float64Array":
|
|
62
62
|
case "Int8Array":
|
|
@@ -68,105 +68,1229 @@ var S = _((g) => {
|
|
|
68
68
|
case "Uint8ClampedArray":
|
|
69
69
|
case "Arguments":
|
|
70
70
|
case "Array":
|
|
71
|
-
if (
|
|
72
|
-
for (
|
|
71
|
+
if (i.length != p.length) return !1;
|
|
72
|
+
for (f = 0; f < i.length; f++) if ((f in i || f in p) && (f in i != f in p || !n(i[f], p[f], d))) return !1;
|
|
73
73
|
return !0;
|
|
74
74
|
case "Object":
|
|
75
|
-
return
|
|
75
|
+
return n(r(i), r(p), d);
|
|
76
76
|
default:
|
|
77
77
|
return !1;
|
|
78
78
|
}
|
|
79
|
-
}, "n"))(
|
|
79
|
+
}, "n"))(o, a, []);
|
|
80
80
|
};
|
|
81
81
|
}();
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
// src/csf/toStartCaseStr.ts
|
|
85
|
-
function
|
|
86
|
-
return e.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (r, t,
|
|
87
|
-
/([a-z])([A-Z])/g, (r, t,
|
|
88
|
-
${
|
|
85
|
+
function le(e) {
|
|
86
|
+
return e.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (r, t, o, a) => `${t} ${o}${a}`).replace(
|
|
87
|
+
/([a-z])([A-Z])/g, (r, t, o) => `${t} ${o}`).replace(/([a-z])([0-9])/gi, (r, t, o) => `${t} ${o}`).replace(/([0-9])([a-z])/gi, (r, t, o) => `${t}\
|
|
88
|
+
${o}`).replace(/(\s|^)(\w)/g, (r, t, o) => `${t}${o.toUpperCase()}`).replace(/ +/g, " ").trim();
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
s(le, "toStartCaseStr");
|
|
91
91
|
|
|
92
92
|
// src/csf/includeConditionalArg.ts
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
let { exists: t, eq:
|
|
96
|
-
if (
|
|
97
|
-
throw new Error(`Invalid conditional test ${JSON.stringify({ exists: t, eq:
|
|
98
|
-
if (typeof
|
|
99
|
-
return (0,
|
|
100
|
-
if (typeof
|
|
101
|
-
return !(0,
|
|
93
|
+
var G = Ze(fe(), 1);
|
|
94
|
+
var ue = /* @__PURE__ */ s((e) => e.map((r) => typeof r < "u").filter(Boolean).length, "count"), Qe = /* @__PURE__ */ s((e, r) => {
|
|
95
|
+
let { exists: t, eq: o, neq: a, truthy: n } = e;
|
|
96
|
+
if (ue([t, o, a, n]) > 1)
|
|
97
|
+
throw new Error(`Invalid conditional test ${JSON.stringify({ exists: t, eq: o, neq: a })}`);
|
|
98
|
+
if (typeof o < "u")
|
|
99
|
+
return (0, G.isEqual)(r, o);
|
|
100
|
+
if (typeof a < "u")
|
|
101
|
+
return !(0, G.isEqual)(r, a);
|
|
102
102
|
if (typeof t < "u") {
|
|
103
|
-
let
|
|
104
|
-
return t ?
|
|
103
|
+
let p = typeof r < "u";
|
|
104
|
+
return t ? p : !p;
|
|
105
105
|
}
|
|
106
|
-
return (typeof
|
|
107
|
-
}, "testValue"),
|
|
106
|
+
return (typeof n > "u" ? !0 : n) ? !!r : !r;
|
|
107
|
+
}, "testValue"), er = /* @__PURE__ */ s((e, r, t) => {
|
|
108
108
|
if (!e.if)
|
|
109
109
|
return !0;
|
|
110
|
-
let { arg:
|
|
111
|
-
if (
|
|
112
|
-
throw new Error(`Invalid conditional value ${JSON.stringify({ arg:
|
|
113
|
-
let
|
|
114
|
-
return
|
|
110
|
+
let { arg: o, global: a } = e.if;
|
|
111
|
+
if (ue([o, a]) !== 1)
|
|
112
|
+
throw new Error(`Invalid conditional value ${JSON.stringify({ arg: o, global: a })}`);
|
|
113
|
+
let n = o ? r[o] : t[a];
|
|
114
|
+
return Qe(e.if, n);
|
|
115
115
|
}, "includeConditionalArg");
|
|
116
116
|
|
|
117
117
|
// src/csf/csf-factories.ts
|
|
118
|
+
import { combineTags as kr } from "storybook/internal/csf";
|
|
119
|
+
|
|
120
|
+
// src/preview-api/modules/addons/main.ts
|
|
121
|
+
import { global as V } from "@storybook/global";
|
|
122
|
+
|
|
123
|
+
// src/preview-api/modules/addons/storybook-channel-mock.ts
|
|
124
|
+
import { Channel as rr } from "storybook/internal/channels";
|
|
125
|
+
function me() {
|
|
126
|
+
let e = {
|
|
127
|
+
setHandler: /* @__PURE__ */ s(() => {
|
|
128
|
+
}, "setHandler"),
|
|
129
|
+
send: /* @__PURE__ */ s(() => {
|
|
130
|
+
}, "send")
|
|
131
|
+
};
|
|
132
|
+
return new rr({ transport: e });
|
|
133
|
+
}
|
|
134
|
+
s(me, "mockChannel");
|
|
135
|
+
|
|
136
|
+
// src/preview-api/modules/addons/main.ts
|
|
137
|
+
var J = class J {
|
|
138
|
+
constructor() {
|
|
139
|
+
this.getChannel = /* @__PURE__ */ s(() => {
|
|
140
|
+
if (!this.channel) {
|
|
141
|
+
let r = me();
|
|
142
|
+
return this.setChannel(r), r;
|
|
143
|
+
}
|
|
144
|
+
return this.channel;
|
|
145
|
+
}, "getChannel");
|
|
146
|
+
this.ready = /* @__PURE__ */ s(() => this.promise, "ready");
|
|
147
|
+
this.hasChannel = /* @__PURE__ */ s(() => !!this.channel, "hasChannel");
|
|
148
|
+
this.setChannel = /* @__PURE__ */ s((r) => {
|
|
149
|
+
this.channel = r, this.resolve();
|
|
150
|
+
}, "setChannel");
|
|
151
|
+
this.promise = new Promise((r) => {
|
|
152
|
+
this.resolve = () => r(this.getChannel());
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
s(J, "AddonStore");
|
|
157
|
+
var K = J, q = "__STORYBOOK_ADDONS_PREVIEW";
|
|
158
|
+
function tr() {
|
|
159
|
+
return V[q] || (V[q] = new K()), V[q];
|
|
160
|
+
}
|
|
161
|
+
s(tr, "getAddonsStore");
|
|
162
|
+
var Y = tr();
|
|
163
|
+
|
|
164
|
+
// src/preview-api/modules/addons/hooks.ts
|
|
165
|
+
import { logger as qr } from "storybook/internal/client-logger";
|
|
166
|
+
import {
|
|
167
|
+
FORCE_RE_RENDER as Yr,
|
|
168
|
+
RESET_STORY_ARGS as Jr,
|
|
169
|
+
STORY_RENDERED as ye,
|
|
170
|
+
UPDATE_GLOBALS as Xr,
|
|
171
|
+
UPDATE_STORY_ARGS as Zr
|
|
172
|
+
} from "storybook/internal/core-events";
|
|
173
|
+
import { global as X } from "@storybook/global";
|
|
174
|
+
var Q = class Q {
|
|
175
|
+
constructor() {
|
|
176
|
+
this.hookListsMap = void 0;
|
|
177
|
+
this.mountedDecorators = void 0;
|
|
178
|
+
this.prevMountedDecorators = void 0;
|
|
179
|
+
this.currentHooks = void 0;
|
|
180
|
+
this.nextHookIndex = void 0;
|
|
181
|
+
this.currentPhase = void 0;
|
|
182
|
+
this.currentEffects = void 0;
|
|
183
|
+
this.prevEffects = void 0;
|
|
184
|
+
this.currentDecoratorName = void 0;
|
|
185
|
+
this.hasUpdates = void 0;
|
|
186
|
+
this.currentContext = void 0;
|
|
187
|
+
this.renderListener = /* @__PURE__ */ s((r) => {
|
|
188
|
+
r === this.currentContext?.id && (this.triggerEffects(), this.currentContext = null, this.removeRenderListeners());
|
|
189
|
+
}, "renderListener");
|
|
190
|
+
this.init();
|
|
191
|
+
}
|
|
192
|
+
init() {
|
|
193
|
+
this.hookListsMap = /* @__PURE__ */ new WeakMap(), this.mountedDecorators = /* @__PURE__ */ new Set(), this.prevMountedDecorators = /* @__PURE__ */ new Set(),
|
|
194
|
+
this.currentHooks = [], this.nextHookIndex = 0, this.currentPhase = "NONE", this.currentEffects = [], this.prevEffects = [], this.currentDecoratorName =
|
|
195
|
+
null, this.hasUpdates = !1, this.currentContext = null;
|
|
196
|
+
}
|
|
197
|
+
clean() {
|
|
198
|
+
this.prevEffects.forEach((r) => {
|
|
199
|
+
r.destroy && r.destroy();
|
|
200
|
+
}), this.init(), this.removeRenderListeners();
|
|
201
|
+
}
|
|
202
|
+
getNextHook() {
|
|
203
|
+
let r = this.currentHooks[this.nextHookIndex];
|
|
204
|
+
return this.nextHookIndex += 1, r;
|
|
205
|
+
}
|
|
206
|
+
triggerEffects() {
|
|
207
|
+
this.prevEffects.forEach((r) => {
|
|
208
|
+
!this.currentEffects.includes(r) && r.destroy && r.destroy();
|
|
209
|
+
}), this.currentEffects.forEach((r) => {
|
|
210
|
+
this.prevEffects.includes(r) || (r.destroy = r.create());
|
|
211
|
+
}), this.prevEffects = this.currentEffects, this.currentEffects = [];
|
|
212
|
+
}
|
|
213
|
+
addRenderListeners() {
|
|
214
|
+
this.removeRenderListeners(), Y.getChannel().on(ye, this.renderListener);
|
|
215
|
+
}
|
|
216
|
+
removeRenderListeners() {
|
|
217
|
+
Y.getChannel().removeListener(ye, this.renderListener);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
s(Q, "HooksContext");
|
|
221
|
+
var B = Q;
|
|
222
|
+
function ge(e) {
|
|
223
|
+
let r = /* @__PURE__ */ s((...t) => {
|
|
224
|
+
let { hooks: o } = typeof t[0] == "function" ? t[1] : t[0], a = o.currentPhase, n = o.currentHooks, i = o.nextHookIndex, p = o.currentDecoratorName;
|
|
225
|
+
o.currentDecoratorName = e.name, o.prevMountedDecorators.has(e) ? (o.currentPhase = "UPDATE", o.currentHooks = o.hookListsMap.get(e) || []) :
|
|
226
|
+
(o.currentPhase = "MOUNT", o.currentHooks = [], o.hookListsMap.set(e, o.currentHooks), o.prevMountedDecorators.add(e)), o.nextHookIndex =
|
|
227
|
+
0;
|
|
228
|
+
let d = X.STORYBOOK_HOOKS_CONTEXT;
|
|
229
|
+
X.STORYBOOK_HOOKS_CONTEXT = o;
|
|
230
|
+
let c = e(...t);
|
|
231
|
+
if (X.STORYBOOK_HOOKS_CONTEXT = d, o.currentPhase === "UPDATE" && o.getNextHook() != null)
|
|
232
|
+
throw new Error(
|
|
233
|
+
"Rendered fewer hooks than expected. This may be caused by an accidental early return statement."
|
|
234
|
+
);
|
|
235
|
+
return o.currentPhase = a, o.currentHooks = n, o.nextHookIndex = i, o.currentDecoratorName = p, c;
|
|
236
|
+
}, "hookified");
|
|
237
|
+
return r.originalFn = e, r;
|
|
238
|
+
}
|
|
239
|
+
s(ge, "hookify");
|
|
240
|
+
var Z = 0, or = 25, Te = /* @__PURE__ */ s((e) => (r, t) => {
|
|
241
|
+
let o = e(
|
|
242
|
+
ge(r),
|
|
243
|
+
t.map((a) => ge(a))
|
|
244
|
+
);
|
|
245
|
+
return (a) => {
|
|
246
|
+
let { hooks: n } = a;
|
|
247
|
+
n.prevMountedDecorators ??= /* @__PURE__ */ new Set(), n.mountedDecorators = /* @__PURE__ */ new Set([r, ...t]), n.currentContext = a, n.
|
|
248
|
+
hasUpdates = !1;
|
|
249
|
+
let i = o(a);
|
|
250
|
+
for (Z = 1; n.hasUpdates; )
|
|
251
|
+
if (n.hasUpdates = !1, n.currentEffects = [], i = o(a), Z += 1, Z > or)
|
|
252
|
+
throw new Error(
|
|
253
|
+
"Too many re-renders. Storybook limits the number of renders to prevent an infinite loop."
|
|
254
|
+
);
|
|
255
|
+
return n.addRenderListeners(), i;
|
|
256
|
+
};
|
|
257
|
+
}, "applyHooks");
|
|
258
|
+
|
|
259
|
+
// ../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
|
|
260
|
+
function I(e) {
|
|
261
|
+
if (!e || typeof e != "object")
|
|
262
|
+
return !1;
|
|
263
|
+
let r = Object.getPrototypeOf(e);
|
|
264
|
+
return r === null || r === Object.prototype || Object.getPrototypeOf(r) === null ? Object.prototype.toString.call(e) === "[object Object]" :
|
|
265
|
+
!1;
|
|
266
|
+
}
|
|
267
|
+
s(I, "isPlainObject");
|
|
268
|
+
|
|
269
|
+
// ../node_modules/es-toolkit/dist/object/mapValues.mjs
|
|
270
|
+
function w(e, r) {
|
|
271
|
+
let t = {}, o = Object.keys(e);
|
|
272
|
+
for (let a = 0; a < o.length; a++) {
|
|
273
|
+
let n = o[a], i = e[n];
|
|
274
|
+
t[n] = r(i, n, e);
|
|
275
|
+
}
|
|
276
|
+
return t;
|
|
277
|
+
}
|
|
278
|
+
s(w, "mapValues");
|
|
279
|
+
|
|
280
|
+
// ../node_modules/es-toolkit/dist/object/pickBy.mjs
|
|
281
|
+
function ee(e, r) {
|
|
282
|
+
let t = {}, o = Object.keys(e);
|
|
283
|
+
for (let a = 0; a < o.length; a++) {
|
|
284
|
+
let n = o[a], i = e[n];
|
|
285
|
+
r(i, n) && (t[n] = i);
|
|
286
|
+
}
|
|
287
|
+
return t;
|
|
288
|
+
}
|
|
289
|
+
s(ee, "pickBy");
|
|
290
|
+
|
|
291
|
+
// src/preview-api/modules/store/args.ts
|
|
292
|
+
import { once as gt } from "storybook/internal/client-logger";
|
|
293
|
+
|
|
294
|
+
// ../node_modules/ts-dedent/esm/index.js
|
|
118
295
|
function F(e) {
|
|
296
|
+
for (var r = [], t = 1; t < arguments.length; t++)
|
|
297
|
+
r[t - 1] = arguments[t];
|
|
298
|
+
var o = Array.from(typeof e == "string" ? [e] : e);
|
|
299
|
+
o[o.length - 1] = o[o.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
300
|
+
var a = o.reduce(function(p, d) {
|
|
301
|
+
var c = d.match(/\n([\t ]+|(?!\s).)/g);
|
|
302
|
+
return c ? p.concat(c.map(function(m) {
|
|
303
|
+
var f, y;
|
|
304
|
+
return (y = (f = m.match(/[\t ]/g)) === null || f === void 0 ? void 0 : f.length) !== null && y !== void 0 ? y : 0;
|
|
305
|
+
})) : p;
|
|
306
|
+
}, []);
|
|
307
|
+
if (a.length) {
|
|
308
|
+
var n = new RegExp(`
|
|
309
|
+
[ ]{` + Math.min.apply(Math, a) + "}", "g");
|
|
310
|
+
o = o.map(function(p) {
|
|
311
|
+
return p.replace(n, `
|
|
312
|
+
`);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
o[0] = o[0].replace(/^\r?\n/, "");
|
|
316
|
+
var i = o[0];
|
|
317
|
+
return r.forEach(function(p, d) {
|
|
318
|
+
var c = i.match(/(?:^|\n)( *)$/), m = c ? c[1] : "", f = p;
|
|
319
|
+
typeof p == "string" && p.includes(`
|
|
320
|
+
`) && (f = String(p).split(`
|
|
321
|
+
`).map(function(y, h) {
|
|
322
|
+
return h === 0 ? y : "" + m + y;
|
|
323
|
+
}).join(`
|
|
324
|
+
`)), i += f + o[d + 1];
|
|
325
|
+
}), i;
|
|
326
|
+
}
|
|
327
|
+
s(F, "dedent");
|
|
328
|
+
|
|
329
|
+
// src/preview-api/modules/store/args.ts
|
|
330
|
+
var xt = Symbol("incompatible");
|
|
331
|
+
var ht = Symbol("Deeply equal");
|
|
332
|
+
var re = "UNTARGETED";
|
|
333
|
+
function xe({
|
|
334
|
+
args: e,
|
|
335
|
+
argTypes: r
|
|
336
|
+
}) {
|
|
337
|
+
let t = {};
|
|
338
|
+
return Object.entries(e).forEach(([o, a]) => {
|
|
339
|
+
let { target: n = re } = r[o] || {};
|
|
340
|
+
t[n] = t[n] || {}, t[n][o] = a;
|
|
341
|
+
}), t;
|
|
342
|
+
}
|
|
343
|
+
s(xe, "groupArgsByTarget");
|
|
344
|
+
|
|
345
|
+
// src/preview-api/modules/store/csf/getValuesFromArgTypes.ts
|
|
346
|
+
var he = /* @__PURE__ */ s((e = {}) => Object.entries(e).reduce((r, [t, { defaultValue: o }]) => (typeof o < "u" && (r[t] = o), r), {}), "ge\
|
|
347
|
+
tValuesFromArgTypes");
|
|
348
|
+
|
|
349
|
+
// src/preview-api/modules/store/csf/normalizeInputTypes.ts
|
|
350
|
+
var nr = /* @__PURE__ */ s((e) => typeof e == "string" ? { name: e } : e, "normalizeType"), sr = /* @__PURE__ */ s((e) => typeof e == "strin\
|
|
351
|
+
g" ? { type: e } : e, "normalizeControl"), ar = /* @__PURE__ */ s((e, r) => {
|
|
352
|
+
let { type: t, control: o, ...a } = e, n = {
|
|
353
|
+
name: r,
|
|
354
|
+
...a
|
|
355
|
+
};
|
|
356
|
+
return t && (n.type = nr(t)), o ? n.control = sr(o) : o === !1 && (n.control = { disable: !0 }), n;
|
|
357
|
+
}, "normalizeInputType"), O = /* @__PURE__ */ s((e) => w(e, ar), "normalizeInputTypes");
|
|
358
|
+
|
|
359
|
+
// src/preview-api/modules/store/csf/normalizeStory.ts
|
|
360
|
+
import { deprecate as ir, logger as pr } from "storybook/internal/client-logger";
|
|
361
|
+
import { storyNameFromExport as cr, toId as dr } from "storybook/internal/csf";
|
|
362
|
+
|
|
363
|
+
// src/preview-api/modules/store/csf/normalizeArrays.ts
|
|
364
|
+
var l = /* @__PURE__ */ s((e) => Array.isArray(e) ? e : e ? [e] : [], "normalizeArrays");
|
|
365
|
+
|
|
366
|
+
// src/preview-api/modules/store/csf/normalizeStory.ts
|
|
367
|
+
var lr = F`
|
|
368
|
+
CSF .story annotations deprecated; annotate story functions directly:
|
|
369
|
+
- StoryFn.story.name => StoryFn.storyName
|
|
370
|
+
- StoryFn.story.(parameters|decorators) => StoryFn.(parameters|decorators)
|
|
371
|
+
See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations for details and codemod.
|
|
372
|
+
`;
|
|
373
|
+
function te(e, r, t) {
|
|
374
|
+
let o = r, a = typeof r == "function" ? r : null, { story: n } = o;
|
|
375
|
+
n && (pr.debug("deprecated story", n), ir(lr));
|
|
376
|
+
let i = cr(e), p = typeof o != "function" && o.name || o.storyName || n?.name || i, d = [
|
|
377
|
+
...l(o.decorators),
|
|
378
|
+
...l(n?.decorators)
|
|
379
|
+
], c = { ...n?.parameters, ...o.parameters }, m = { ...n?.args, ...o.args }, f = { ...n?.argTypes, ...o.argTypes }, y = [...l(o.loaders), ...l(
|
|
380
|
+
n?.loaders)], h = [
|
|
381
|
+
...l(o.beforeEach),
|
|
382
|
+
...l(n?.beforeEach)
|
|
383
|
+
], S = [
|
|
384
|
+
...l(o.afterEach),
|
|
385
|
+
...l(n?.afterEach)
|
|
386
|
+
], { render: k, play: E, tags: A = [], globals: b = {} } = o, u = c.__id || dr(t.id, i);
|
|
387
|
+
return {
|
|
388
|
+
moduleExport: r,
|
|
389
|
+
id: u,
|
|
390
|
+
name: p,
|
|
391
|
+
tags: A,
|
|
392
|
+
decorators: d,
|
|
393
|
+
parameters: c,
|
|
394
|
+
args: m,
|
|
395
|
+
argTypes: O(f),
|
|
396
|
+
loaders: y,
|
|
397
|
+
beforeEach: h,
|
|
398
|
+
afterEach: S,
|
|
399
|
+
globals: b,
|
|
400
|
+
...k && { render: k },
|
|
401
|
+
...a && { userStoryFn: a },
|
|
402
|
+
...E && { play: E }
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
s(te, "normalizeStory");
|
|
406
|
+
|
|
407
|
+
// src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts
|
|
408
|
+
import { sanitize as fr } from "storybook/internal/csf";
|
|
409
|
+
function Se(e, r = e.title, t) {
|
|
410
|
+
let { id: o, argTypes: a } = e;
|
|
411
|
+
return {
|
|
412
|
+
id: fr(o || r),
|
|
413
|
+
...e,
|
|
414
|
+
title: r,
|
|
415
|
+
...a && { argTypes: O(a) },
|
|
416
|
+
parameters: {
|
|
417
|
+
fileName: t,
|
|
418
|
+
...e.parameters
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
s(Se, "normalizeComponentAnnotations");
|
|
423
|
+
|
|
424
|
+
// src/preview-api/modules/store/csf/prepareStory.ts
|
|
425
|
+
import { combineTags as mr, includeConditionalArg as yr } from "storybook/internal/csf";
|
|
426
|
+
import { NoRenderFunctionError as gr } from "storybook/internal/preview-errors";
|
|
427
|
+
import { global as Tr } from "@storybook/global";
|
|
428
|
+
import { global as xr } from "@storybook/global";
|
|
429
|
+
|
|
430
|
+
// src/preview-api/modules/preview-web/render/mount-utils.ts
|
|
431
|
+
function Re(e) {
|
|
432
|
+
return e != null && ur(e).includes("mount");
|
|
433
|
+
}
|
|
434
|
+
s(Re, "mountDestructured");
|
|
435
|
+
function ur(e) {
|
|
436
|
+
let r = e.toString().match(/[^(]*\(([^)]*)/);
|
|
437
|
+
if (!r)
|
|
438
|
+
return [];
|
|
439
|
+
let t = Ae(r[1]);
|
|
440
|
+
if (!t.length)
|
|
441
|
+
return [];
|
|
442
|
+
let o = t[0];
|
|
443
|
+
return o.startsWith("{") && o.endsWith("}") ? Ae(o.slice(1, -1).replace(/\s/g, "")).map((n) => n.replace(/:.*|=.*/g, "")) : [];
|
|
444
|
+
}
|
|
445
|
+
s(ur, "getUsedProps");
|
|
446
|
+
function Ae(e) {
|
|
447
|
+
let r = [], t = [], o = 0;
|
|
448
|
+
for (let n = 0; n < e.length; n++)
|
|
449
|
+
if (e[n] === "{" || e[n] === "[")
|
|
450
|
+
t.push(e[n] === "{" ? "}" : "]");
|
|
451
|
+
else if (e[n] === t[t.length - 1])
|
|
452
|
+
t.pop();
|
|
453
|
+
else if (!t.length && e[n] === ",") {
|
|
454
|
+
let i = e.substring(o, n).trim();
|
|
455
|
+
i && r.push(i), o = n + 1;
|
|
456
|
+
}
|
|
457
|
+
let a = e.substring(o).trim();
|
|
458
|
+
return a && r.push(a), r;
|
|
459
|
+
}
|
|
460
|
+
s(Ae, "splitByComma");
|
|
461
|
+
|
|
462
|
+
// src/preview-api/modules/store/decorators.ts
|
|
463
|
+
function be(e, r, t) {
|
|
464
|
+
let o = t(e);
|
|
465
|
+
return (a) => r(o, a);
|
|
466
|
+
}
|
|
467
|
+
s(be, "decorateStory");
|
|
468
|
+
function Ce({
|
|
469
|
+
componentId: e,
|
|
470
|
+
title: r,
|
|
471
|
+
kind: t,
|
|
472
|
+
id: o,
|
|
473
|
+
name: a,
|
|
474
|
+
story: n,
|
|
475
|
+
parameters: i,
|
|
476
|
+
initialArgs: p,
|
|
477
|
+
argTypes: d,
|
|
478
|
+
...c
|
|
479
|
+
} = {}) {
|
|
480
|
+
return c;
|
|
481
|
+
}
|
|
482
|
+
s(Ce, "sanitizeStoryContextUpdate");
|
|
483
|
+
function oe(e, r) {
|
|
484
|
+
let t = {}, o = /* @__PURE__ */ s((n) => (i) => {
|
|
485
|
+
if (!t.value)
|
|
486
|
+
throw new Error("Decorated function called without init");
|
|
487
|
+
return t.value = {
|
|
488
|
+
...t.value,
|
|
489
|
+
...Ce(i)
|
|
490
|
+
}, n(t.value);
|
|
491
|
+
}, "bindWithContext"), a = r.reduce(
|
|
492
|
+
(n, i) => be(n, i, o),
|
|
493
|
+
e
|
|
494
|
+
);
|
|
495
|
+
return (n) => (t.value = n, a(n));
|
|
496
|
+
}
|
|
497
|
+
s(oe, "defaultDecorateStory");
|
|
498
|
+
|
|
499
|
+
// src/preview-api/modules/store/parameters.ts
|
|
500
|
+
var x = /* @__PURE__ */ s((...e) => {
|
|
501
|
+
let r = {}, t = e.filter(Boolean), o = t.reduce((a, n) => (Object.entries(n).forEach(([i, p]) => {
|
|
502
|
+
let d = a[i];
|
|
503
|
+
Array.isArray(p) || typeof d > "u" ? a[i] = p : I(p) && I(d) ? r[i] = !0 : typeof p < "u" && (a[i] = p);
|
|
504
|
+
}), a), {});
|
|
505
|
+
return Object.keys(r).forEach((a) => {
|
|
506
|
+
let n = t.filter(Boolean).map((i) => i[a]).filter((i) => typeof i < "u");
|
|
507
|
+
n.every((i) => I(i)) ? o[a] = x(...n) : o[a] = n[n.length - 1];
|
|
508
|
+
}), o;
|
|
509
|
+
}, "combineParameters");
|
|
510
|
+
|
|
511
|
+
// src/preview-api/modules/store/csf/prepareStory.ts
|
|
512
|
+
function ne(e, r, t) {
|
|
513
|
+
let { moduleExport: o, id: a, name: n } = e || {}, i = hr(
|
|
514
|
+
e,
|
|
515
|
+
r,
|
|
516
|
+
t
|
|
517
|
+
), p = /* @__PURE__ */ s(async (T) => {
|
|
518
|
+
let C = {};
|
|
519
|
+
for (let j of [
|
|
520
|
+
l(t.loaders),
|
|
521
|
+
l(r.loaders),
|
|
522
|
+
l(e.loaders)
|
|
523
|
+
]) {
|
|
524
|
+
if (T.abortSignal.aborted)
|
|
525
|
+
return C;
|
|
526
|
+
let z = await Promise.all(j.map((We) => We(T)));
|
|
527
|
+
Object.assign(C, ...z);
|
|
528
|
+
}
|
|
529
|
+
return C;
|
|
530
|
+
}, "applyLoaders"), d = /* @__PURE__ */ s(async (T) => {
|
|
531
|
+
let C = new Array();
|
|
532
|
+
for (let j of [
|
|
533
|
+
...l(t.beforeEach),
|
|
534
|
+
...l(r.beforeEach),
|
|
535
|
+
...l(e.beforeEach)
|
|
536
|
+
]) {
|
|
537
|
+
if (T.abortSignal.aborted)
|
|
538
|
+
return C;
|
|
539
|
+
let z = await j(T);
|
|
540
|
+
z && C.push(z);
|
|
541
|
+
}
|
|
542
|
+
return C;
|
|
543
|
+
}, "applyBeforeEach"), c = /* @__PURE__ */ s(async (T) => {
|
|
544
|
+
let C = [
|
|
545
|
+
...l(t.afterEach),
|
|
546
|
+
...l(r.afterEach),
|
|
547
|
+
...l(e.afterEach)
|
|
548
|
+
].reverse();
|
|
549
|
+
for (let j of C) {
|
|
550
|
+
if (T.abortSignal.aborted)
|
|
551
|
+
return;
|
|
552
|
+
await j(T);
|
|
553
|
+
}
|
|
554
|
+
}, "applyAfterEach"), m = /* @__PURE__ */ s((T) => T.originalStoryFn(T.args, T), "undecoratedStoryFn"), { applyDecorators: f = oe, runStep: y } = t,
|
|
555
|
+
h = [
|
|
556
|
+
...l(e?.decorators),
|
|
557
|
+
...l(r?.decorators),
|
|
558
|
+
...l(t?.decorators)
|
|
559
|
+
], S = e?.userStoryFn || e?.render || r.render || t.render, k = Te(f)(m, h), E = /* @__PURE__ */ s((T) => k(T), "unboundStoryFn"), A = e?.
|
|
560
|
+
play ?? r?.play, b = Re(A);
|
|
561
|
+
if (!S && !b)
|
|
562
|
+
throw new gr({ id: a });
|
|
563
|
+
let u = /* @__PURE__ */ s((T) => async () => (await T.renderToCanvas(), T.canvas), "defaultMount"), g = e.mount ?? r.mount ?? t.mount ?? u,
|
|
564
|
+
R = t.testingLibraryRender;
|
|
565
|
+
return {
|
|
566
|
+
storyGlobals: {},
|
|
567
|
+
...i,
|
|
568
|
+
moduleExport: o,
|
|
569
|
+
id: a,
|
|
570
|
+
name: n,
|
|
571
|
+
story: n,
|
|
572
|
+
originalStoryFn: S,
|
|
573
|
+
undecoratedStoryFn: m,
|
|
574
|
+
unboundStoryFn: E,
|
|
575
|
+
applyLoaders: p,
|
|
576
|
+
applyBeforeEach: d,
|
|
577
|
+
applyAfterEach: c,
|
|
578
|
+
playFunction: A,
|
|
579
|
+
runStep: y,
|
|
580
|
+
mount: g,
|
|
581
|
+
testingLibraryRender: R,
|
|
582
|
+
renderToCanvas: t.renderToCanvas,
|
|
583
|
+
usesMount: b
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
s(ne, "prepareStory");
|
|
587
|
+
function hr(e, r, t) {
|
|
588
|
+
let o = ["dev", "test"], a = xr.DOCS_OPTIONS?.autodocs === !0 ? ["autodocs"] : [], n = mr(
|
|
589
|
+
...o,
|
|
590
|
+
...a,
|
|
591
|
+
...t.tags ?? [],
|
|
592
|
+
...r.tags ?? [],
|
|
593
|
+
...e?.tags ?? []
|
|
594
|
+
), i = x(
|
|
595
|
+
t.parameters,
|
|
596
|
+
r.parameters,
|
|
597
|
+
e?.parameters
|
|
598
|
+
), { argTypesEnhancers: p = [], argsEnhancers: d = [] } = t, c = x(
|
|
599
|
+
t.argTypes,
|
|
600
|
+
r.argTypes,
|
|
601
|
+
e?.argTypes
|
|
602
|
+
);
|
|
603
|
+
if (e) {
|
|
604
|
+
let A = e?.userStoryFn || e?.render || r.render || t.render;
|
|
605
|
+
i.__isArgsStory = A && A.length > 0;
|
|
606
|
+
}
|
|
607
|
+
let m = {
|
|
608
|
+
...t.args,
|
|
609
|
+
...r.args,
|
|
610
|
+
...e?.args
|
|
611
|
+
}, f = {
|
|
612
|
+
...r.globals,
|
|
613
|
+
...e?.globals
|
|
614
|
+
}, y = {
|
|
615
|
+
componentId: r.id,
|
|
616
|
+
title: r.title,
|
|
617
|
+
kind: r.title,
|
|
618
|
+
// Back compat
|
|
619
|
+
id: e?.id || r.id,
|
|
620
|
+
// if there's no story name, we create a fake one since enhancers expect a name
|
|
621
|
+
name: e?.name || "__meta",
|
|
622
|
+
story: e?.name || "__meta",
|
|
623
|
+
// Back compat
|
|
624
|
+
component: r.component,
|
|
625
|
+
subcomponents: r.subcomponents,
|
|
626
|
+
tags: n,
|
|
627
|
+
parameters: i,
|
|
628
|
+
initialArgs: m,
|
|
629
|
+
argTypes: c,
|
|
630
|
+
storyGlobals: f
|
|
631
|
+
};
|
|
632
|
+
y.argTypes = p.reduce(
|
|
633
|
+
(A, b) => b({ ...y, argTypes: A }),
|
|
634
|
+
y.argTypes
|
|
635
|
+
);
|
|
636
|
+
let h = { ...m };
|
|
637
|
+
y.initialArgs = [...d].reduce(
|
|
638
|
+
(A, b) => ({
|
|
639
|
+
...A,
|
|
640
|
+
...b({
|
|
641
|
+
...y,
|
|
642
|
+
initialArgs: A
|
|
643
|
+
})
|
|
644
|
+
}),
|
|
645
|
+
h
|
|
646
|
+
);
|
|
647
|
+
let { name: S, story: k, ...E } = y;
|
|
648
|
+
return E;
|
|
649
|
+
}
|
|
650
|
+
s(hr, "preparePartialAnnotations");
|
|
651
|
+
function we(e) {
|
|
652
|
+
let { args: r } = e, t = {
|
|
653
|
+
...e,
|
|
654
|
+
allArgs: void 0,
|
|
655
|
+
argsByTarget: void 0
|
|
656
|
+
};
|
|
657
|
+
if (Tr.FEATURES?.argTypeTargetsV7) {
|
|
658
|
+
let n = xe(e);
|
|
659
|
+
t = {
|
|
660
|
+
...e,
|
|
661
|
+
allArgs: e.args,
|
|
662
|
+
argsByTarget: n,
|
|
663
|
+
args: n[re] || {}
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
let o = Object.entries(t.args).reduce((n, [i, p]) => {
|
|
667
|
+
if (!t.argTypes[i]?.mapping)
|
|
668
|
+
return n[i] = p, n;
|
|
669
|
+
let d = /* @__PURE__ */ s((c) => {
|
|
670
|
+
let m = t.argTypes[i].mapping;
|
|
671
|
+
return m && c in m ? m[c] : c;
|
|
672
|
+
}, "mappingFn");
|
|
673
|
+
return n[i] = Array.isArray(p) ? p.map(d) : d(p), n;
|
|
674
|
+
}, {}), a = Object.entries(o).reduce((n, [i, p]) => {
|
|
675
|
+
let d = t.argTypes[i] || {};
|
|
676
|
+
return yr(d, o, t.globals) && (n[i] = p), n;
|
|
677
|
+
}, {});
|
|
678
|
+
return { ...t, unmappedArgs: r, args: a };
|
|
679
|
+
}
|
|
680
|
+
s(we, "prepareContext");
|
|
681
|
+
|
|
682
|
+
// src/preview-api/modules/store/inferArgTypes.ts
|
|
683
|
+
import { logger as Sr } from "storybook/internal/client-logger";
|
|
684
|
+
var se = /* @__PURE__ */ s((e, r, t) => {
|
|
685
|
+
let o = typeof e;
|
|
686
|
+
switch (o) {
|
|
687
|
+
case "boolean":
|
|
688
|
+
case "string":
|
|
689
|
+
case "number":
|
|
690
|
+
case "function":
|
|
691
|
+
case "symbol":
|
|
692
|
+
return { name: o };
|
|
693
|
+
default:
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
return e ? t.has(e) ? (Sr.warn(F`
|
|
697
|
+
We've detected a cycle in arg '${r}'. Args should be JSON-serializable.
|
|
698
|
+
|
|
699
|
+
Consider using the mapping feature or fully custom args:
|
|
700
|
+
- Mapping: https://storybook.js.org/docs/writing-stories/args#mapping-to-complex-arg-values
|
|
701
|
+
- Custom args: https://storybook.js.org/docs/essentials/controls#fully-custom-args
|
|
702
|
+
`), { name: "other", value: "cyclic object" }) : (t.add(e), Array.isArray(e) ? { name: "array", value: e.length > 0 ? se(e[0], r, new Set(
|
|
703
|
+
t)) : { name: "other", value: "unknown" } } : { name: "object", value: w(e, (n) => se(n, r, new Set(t))) }) : { name: "object", value: {} };
|
|
704
|
+
}, "inferType"), ae = /* @__PURE__ */ s((e) => {
|
|
705
|
+
let { id: r, argTypes: t = {}, initialArgs: o = {} } = e, a = w(o, (i, p) => ({
|
|
706
|
+
name: p,
|
|
707
|
+
type: se(i, `${r}.${p}`, /* @__PURE__ */ new Set())
|
|
708
|
+
})), n = w(t, (i, p) => ({
|
|
709
|
+
name: p
|
|
710
|
+
}));
|
|
711
|
+
return x(a, n, t);
|
|
712
|
+
}, "inferArgTypes");
|
|
713
|
+
ae.secondPass = !0;
|
|
714
|
+
|
|
715
|
+
// src/preview-api/modules/store/inferControls.ts
|
|
716
|
+
import { logger as Ar } from "storybook/internal/client-logger";
|
|
717
|
+
|
|
718
|
+
// src/preview-api/modules/store/filterArgTypes.ts
|
|
719
|
+
var Ee = /* @__PURE__ */ s((e, r) => Array.isArray(r) ? r.includes(e) : e.match(r), "matches"), ie = /* @__PURE__ */ s((e, r, t) => !r && !t ?
|
|
720
|
+
e : e && ee(e, (o, a) => {
|
|
721
|
+
let n = o.name || a.toString();
|
|
722
|
+
return !!(!r || Ee(n, r)) && (!t || !Ee(n, t));
|
|
723
|
+
}), "filterArgTypes");
|
|
724
|
+
|
|
725
|
+
// src/preview-api/modules/store/inferControls.ts
|
|
726
|
+
var Rr = /* @__PURE__ */ s((e, r, t) => {
|
|
727
|
+
let { type: o, options: a } = e;
|
|
728
|
+
if (o) {
|
|
729
|
+
if (t.color && t.color.test(r)) {
|
|
730
|
+
let n = o.name;
|
|
731
|
+
if (n === "string")
|
|
732
|
+
return { control: { type: "color" } };
|
|
733
|
+
n !== "enum" && Ar.warn(
|
|
734
|
+
`Addon controls: Control of type color only supports string, received "${n}" instead`
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
if (t.date && t.date.test(r))
|
|
738
|
+
return { control: { type: "date" } };
|
|
739
|
+
switch (o.name) {
|
|
740
|
+
case "array":
|
|
741
|
+
return { control: { type: "object" } };
|
|
742
|
+
case "boolean":
|
|
743
|
+
return { control: { type: "boolean" } };
|
|
744
|
+
case "string":
|
|
745
|
+
return { control: { type: "text" } };
|
|
746
|
+
case "number":
|
|
747
|
+
return { control: { type: "number" } };
|
|
748
|
+
case "enum": {
|
|
749
|
+
let { value: n } = o;
|
|
750
|
+
return { control: { type: n?.length <= 5 ? "radio" : "select" }, options: n };
|
|
751
|
+
}
|
|
752
|
+
case "function":
|
|
753
|
+
case "symbol":
|
|
754
|
+
return null;
|
|
755
|
+
default:
|
|
756
|
+
return { control: { type: a ? "select" : "object" } };
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}, "inferControl"), U = /* @__PURE__ */ s((e) => {
|
|
760
|
+
let {
|
|
761
|
+
argTypes: r,
|
|
762
|
+
parameters: { __isArgsStory: t, controls: { include: o = null, exclude: a = null, matchers: n = {} } = {} }
|
|
763
|
+
} = e;
|
|
764
|
+
if (!t)
|
|
765
|
+
return r;
|
|
766
|
+
let i = ie(r, o, a), p = w(i, (d, c) => d?.type && Rr(d, c.toString(), n));
|
|
767
|
+
return x(p, i);
|
|
768
|
+
}, "inferControls");
|
|
769
|
+
U.secondPass = !0;
|
|
770
|
+
|
|
771
|
+
// src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts
|
|
772
|
+
function _({
|
|
773
|
+
argTypes: e,
|
|
774
|
+
globalTypes: r,
|
|
775
|
+
argTypesEnhancers: t,
|
|
776
|
+
decorators: o,
|
|
777
|
+
loaders: a,
|
|
778
|
+
beforeEach: n,
|
|
779
|
+
afterEach: i,
|
|
780
|
+
initialGlobals: p,
|
|
781
|
+
...d
|
|
782
|
+
}) {
|
|
783
|
+
return {
|
|
784
|
+
...e && { argTypes: O(e) },
|
|
785
|
+
...r && { globalTypes: O(r) },
|
|
786
|
+
decorators: l(o),
|
|
787
|
+
loaders: l(a),
|
|
788
|
+
beforeEach: l(n),
|
|
789
|
+
afterEach: l(i),
|
|
790
|
+
argTypesEnhancers: [
|
|
791
|
+
...t || [],
|
|
792
|
+
ae,
|
|
793
|
+
// There's an architectural decision to be made regarding embedded addons in core:
|
|
794
|
+
//
|
|
795
|
+
// Option 1: Keep embedded addons but ensure consistency by moving addon-specific code
|
|
796
|
+
// (like inferControls) to live alongside the addon code itself. This maintains the
|
|
797
|
+
// concept of core addons while improving code organization.
|
|
798
|
+
//
|
|
799
|
+
// Option 2: Fully integrate these addons into core, potentially moving UI components
|
|
800
|
+
// into the manager and treating them as core features rather than addons. This is a
|
|
801
|
+
// bigger architectural change requiring careful consideration.
|
|
802
|
+
//
|
|
803
|
+
// For now, we're keeping inferControls here as we need time to properly evaluate
|
|
804
|
+
// these options and their implications. Some features (like Angular's cleanArgsDecorator)
|
|
805
|
+
// currently rely on this behavior.
|
|
806
|
+
//
|
|
807
|
+
// TODO: Make an architectural decision on the handling of core addons
|
|
808
|
+
U
|
|
809
|
+
],
|
|
810
|
+
initialGlobals: p,
|
|
811
|
+
...d
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
s(_, "normalizeProjectAnnotations");
|
|
815
|
+
|
|
816
|
+
// src/preview-api/modules/store/csf/composeConfigs.ts
|
|
817
|
+
import { global as br } from "@storybook/global";
|
|
818
|
+
|
|
819
|
+
// src/preview-api/modules/store/csf/beforeAll.ts
|
|
820
|
+
var Pe = /* @__PURE__ */ s((e) => async () => {
|
|
821
|
+
let r = [];
|
|
822
|
+
for (let t of e) {
|
|
823
|
+
let o = await t();
|
|
824
|
+
o && r.unshift(o);
|
|
825
|
+
}
|
|
826
|
+
return async () => {
|
|
827
|
+
for (let t of r)
|
|
828
|
+
await t();
|
|
829
|
+
};
|
|
830
|
+
}, "composeBeforeAllHooks");
|
|
831
|
+
|
|
832
|
+
// src/preview-api/modules/store/csf/stepRunners.ts
|
|
833
|
+
function pe(e) {
|
|
834
|
+
return async (r, t, o) => {
|
|
835
|
+
await e.reduceRight(
|
|
836
|
+
(n, i) => async () => i(r, n, o),
|
|
837
|
+
async () => t(o)
|
|
838
|
+
)();
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
s(pe, "composeStepRunners");
|
|
842
|
+
|
|
843
|
+
// src/preview-api/modules/store/csf/composeConfigs.ts
|
|
844
|
+
function D(e, r) {
|
|
845
|
+
return e.map((t) => t.default?.[r] ?? t[r]).filter(Boolean);
|
|
846
|
+
}
|
|
847
|
+
s(D, "getField");
|
|
848
|
+
function P(e, r, t = {}) {
|
|
849
|
+
return D(e, r).reduce((o, a) => {
|
|
850
|
+
let n = l(a);
|
|
851
|
+
return t.reverseFileOrder ? [...n, ...o] : [...o, ...n];
|
|
852
|
+
}, []);
|
|
853
|
+
}
|
|
854
|
+
s(P, "getArrayField");
|
|
855
|
+
function H(e, r) {
|
|
856
|
+
return Object.assign({}, ...D(e, r));
|
|
857
|
+
}
|
|
858
|
+
s(H, "getObjectField");
|
|
859
|
+
function N(e, r) {
|
|
860
|
+
return D(e, r).pop();
|
|
861
|
+
}
|
|
862
|
+
s(N, "getSingletonField");
|
|
863
|
+
function M(e) {
|
|
864
|
+
let r = P(e, "argTypesEnhancers"), t = D(e, "runStep"), o = P(e, "beforeAll");
|
|
865
|
+
return {
|
|
866
|
+
parameters: x(...D(e, "parameters")),
|
|
867
|
+
decorators: P(e, "decorators", {
|
|
868
|
+
reverseFileOrder: !(br.FEATURES?.legacyDecoratorFileOrder ?? !1)
|
|
869
|
+
}),
|
|
870
|
+
args: H(e, "args"),
|
|
871
|
+
argsEnhancers: P(e, "argsEnhancers"),
|
|
872
|
+
argTypes: H(e, "argTypes"),
|
|
873
|
+
argTypesEnhancers: [
|
|
874
|
+
...r.filter((a) => !a.secondPass),
|
|
875
|
+
...r.filter((a) => a.secondPass)
|
|
876
|
+
],
|
|
877
|
+
initialGlobals: H(e, "initialGlobals"),
|
|
878
|
+
globalTypes: H(e, "globalTypes"),
|
|
879
|
+
loaders: P(e, "loaders"),
|
|
880
|
+
beforeAll: Pe(o),
|
|
881
|
+
beforeEach: P(e, "beforeEach"),
|
|
882
|
+
afterEach: P(e, "afterEach"),
|
|
883
|
+
render: N(e, "render"),
|
|
884
|
+
renderToCanvas: N(e, "renderToCanvas"),
|
|
885
|
+
applyDecorators: N(e, "applyDecorators"),
|
|
886
|
+
runStep: pe(t),
|
|
887
|
+
tags: P(e, "tags"),
|
|
888
|
+
mount: N(e, "mount"),
|
|
889
|
+
testingLibraryRender: N(e, "testingLibraryRender")
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
s(M, "composeConfigs");
|
|
893
|
+
|
|
894
|
+
// src/preview-api/modules/store/csf/portable-stories.ts
|
|
895
|
+
import { isExportStory as Lo } from "storybook/internal/csf";
|
|
896
|
+
import { getCoreAnnotations as Go } from "storybook/internal/csf";
|
|
897
|
+
import { MountMustBeDestructuredError as wr } from "storybook/internal/preview-errors";
|
|
898
|
+
|
|
899
|
+
// src/preview-api/modules/preview-web/render/animation-utils.ts
|
|
900
|
+
function ve() {
|
|
901
|
+
try {
|
|
902
|
+
return (
|
|
903
|
+
// @ts-expect-error this property exists in certain environments
|
|
904
|
+
!!globalThis.__vitest_browser__ || // @ts-expect-error this property exists in certain environments
|
|
905
|
+
!!globalThis.__playwright__binding__
|
|
906
|
+
);
|
|
907
|
+
} catch {
|
|
908
|
+
return !1;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
s(ve, "isTestEnvironment");
|
|
912
|
+
function ke(e = !0) {
|
|
913
|
+
if (!("document" in globalThis && "createElement" in globalThis.document))
|
|
914
|
+
return () => {
|
|
915
|
+
};
|
|
916
|
+
let r = document.createElement("style");
|
|
917
|
+
r.textContent = `*, *:before, *:after {
|
|
918
|
+
animation: none !important;
|
|
919
|
+
}`, document.head.appendChild(r);
|
|
920
|
+
let t = document.createElement("style");
|
|
921
|
+
return t.textContent = `*, *:before, *:after {
|
|
922
|
+
animation-delay: 0s !important;
|
|
923
|
+
animation-direction: ${e ? "reverse" : "normal"} !important;
|
|
924
|
+
animation-play-state: paused !important;
|
|
925
|
+
transition: none !important;
|
|
926
|
+
}`, document.head.appendChild(t), document.body.clientHeight, document.head.removeChild(r), () => {
|
|
927
|
+
t.parentNode?.removeChild(t);
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
s(ke, "pauseAnimations");
|
|
931
|
+
async function Oe(e) {
|
|
932
|
+
if (!("document" in globalThis && "getAnimations" in globalThis.document && "querySelectorAll" in globalThis.document))
|
|
933
|
+
return;
|
|
934
|
+
let r = !1;
|
|
935
|
+
await Promise.race([
|
|
936
|
+
// After 50ms, retrieve any running animations and wait for them to finish
|
|
937
|
+
// If new animations are created while waiting, we'll wait for them too
|
|
938
|
+
new Promise((t) => {
|
|
939
|
+
setTimeout(() => {
|
|
940
|
+
let o = [globalThis.document, ...Fe(globalThis.document)], a = /* @__PURE__ */ s(async () => {
|
|
941
|
+
if (r || e?.aborted)
|
|
942
|
+
return;
|
|
943
|
+
let n = o.flatMap((i) => i?.getAnimations?.() || []).filter((i) => i.playState === "running" && !Cr(i));
|
|
944
|
+
n.length > 0 && (await Promise.all(n.map((i) => i.finished)), await a());
|
|
945
|
+
}, "checkAnimationsFinished");
|
|
946
|
+
a().then(t);
|
|
947
|
+
}, 100);
|
|
948
|
+
}),
|
|
949
|
+
// If animations don't finish within the timeout, continue without waiting
|
|
950
|
+
new Promise(
|
|
951
|
+
(t) => setTimeout(() => {
|
|
952
|
+
r = !0, t(void 0);
|
|
953
|
+
}, 5e3)
|
|
954
|
+
)
|
|
955
|
+
]);
|
|
956
|
+
}
|
|
957
|
+
s(Oe, "waitForAnimations");
|
|
958
|
+
function Fe(e) {
|
|
959
|
+
return [e, ...e.querySelectorAll("*")].reduce((r, t) => ("shadowRoot" in t && t.shadowRoot && r.push(t.shadowRoot, ...Fe(t.shadowRoot)), r),
|
|
960
|
+
[]);
|
|
961
|
+
}
|
|
962
|
+
s(Fe, "getShadowRoots");
|
|
963
|
+
function Cr(e) {
|
|
964
|
+
if (e instanceof CSSAnimation && e.effect instanceof KeyframeEffect && e.effect.target) {
|
|
965
|
+
let r = getComputedStyle(e.effect.target, e.effect.pseudoElement), t = r.animationName?.split(", ").indexOf(e.animationName);
|
|
966
|
+
return r.animationIterationCount.split(", ")[t] === "infinite";
|
|
967
|
+
}
|
|
968
|
+
return !1;
|
|
969
|
+
}
|
|
970
|
+
s(Cr, "isInfiniteAnimation");
|
|
971
|
+
|
|
972
|
+
// src/preview-api/modules/store/reporter-api.ts
|
|
973
|
+
var ce = class ce {
|
|
974
|
+
constructor() {
|
|
975
|
+
this.reports = [];
|
|
976
|
+
}
|
|
977
|
+
async addReport(r) {
|
|
978
|
+
this.reports.push(r);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
s(ce, "ReporterAPI");
|
|
982
|
+
var $ = ce;
|
|
983
|
+
|
|
984
|
+
// src/preview-api/modules/store/csf/portable-stories.ts
|
|
985
|
+
var Er = "ComposedStory", Pr = "Unnamed Story";
|
|
986
|
+
var v = [];
|
|
987
|
+
function de(e, r, t, o, a) {
|
|
988
|
+
if (e === void 0)
|
|
989
|
+
throw new Error("Expected a story but received undefined.");
|
|
990
|
+
r.title = r.title ?? Er;
|
|
991
|
+
let n = Se(r), i = a || e.storyName || e.story?.name || e.name || Pr, p = te(
|
|
992
|
+
i,
|
|
993
|
+
e,
|
|
994
|
+
n
|
|
995
|
+
), d = _(
|
|
996
|
+
M([
|
|
997
|
+
o ?? globalThis.globalProjectAnnotations ?? {},
|
|
998
|
+
t ?? {}
|
|
999
|
+
])
|
|
1000
|
+
), c = ne(
|
|
1001
|
+
p,
|
|
1002
|
+
n,
|
|
1003
|
+
d
|
|
1004
|
+
), f = {
|
|
1005
|
+
...he(d.globalTypes),
|
|
1006
|
+
...d.initialGlobals,
|
|
1007
|
+
...c.storyGlobals
|
|
1008
|
+
}, y = new $(), h = /* @__PURE__ */ s(() => {
|
|
1009
|
+
let u = we({
|
|
1010
|
+
hooks: new B(),
|
|
1011
|
+
globals: f,
|
|
1012
|
+
args: { ...c.initialArgs },
|
|
1013
|
+
viewMode: "story",
|
|
1014
|
+
reporting: y,
|
|
1015
|
+
loaded: {},
|
|
1016
|
+
abortSignal: new AbortController().signal,
|
|
1017
|
+
step: /* @__PURE__ */ s((g, R) => c.runStep(g, R, u), "step"),
|
|
1018
|
+
canvasElement: null,
|
|
1019
|
+
canvas: {},
|
|
1020
|
+
userEvent: {},
|
|
1021
|
+
globalTypes: d.globalTypes,
|
|
1022
|
+
...c,
|
|
1023
|
+
context: null,
|
|
1024
|
+
mount: null
|
|
1025
|
+
});
|
|
1026
|
+
return u.parameters.__isPortableStory = !0, u.context = u, c.renderToCanvas && (u.renderToCanvas = async () => {
|
|
1027
|
+
let g = await c.renderToCanvas?.(
|
|
1028
|
+
{
|
|
1029
|
+
componentId: c.componentId,
|
|
1030
|
+
title: c.title,
|
|
1031
|
+
id: c.id,
|
|
1032
|
+
name: c.name,
|
|
1033
|
+
tags: c.tags,
|
|
1034
|
+
showMain: /* @__PURE__ */ s(() => {
|
|
1035
|
+
}, "showMain"),
|
|
1036
|
+
showError: /* @__PURE__ */ s((R) => {
|
|
1037
|
+
throw new Error(`${R.title}
|
|
1038
|
+
${R.description}`);
|
|
1039
|
+
}, "showError"),
|
|
1040
|
+
showException: /* @__PURE__ */ s((R) => {
|
|
1041
|
+
throw R;
|
|
1042
|
+
}, "showException"),
|
|
1043
|
+
forceRemount: !0,
|
|
1044
|
+
storyContext: u,
|
|
1045
|
+
storyFn: /* @__PURE__ */ s(() => c.unboundStoryFn(u), "storyFn"),
|
|
1046
|
+
unboundStoryFn: c.unboundStoryFn
|
|
1047
|
+
},
|
|
1048
|
+
u.canvasElement
|
|
1049
|
+
);
|
|
1050
|
+
g && v.push(g);
|
|
1051
|
+
}), u.mount = c.mount(u), u;
|
|
1052
|
+
}, "initializeContext"), S, k = /* @__PURE__ */ s(async (u) => {
|
|
1053
|
+
let g = h();
|
|
1054
|
+
return g.canvasElement ??= globalThis?.document?.body, S && (g.loaded = S.loaded), Object.assign(g, u), c.playFunction(g);
|
|
1055
|
+
}, "play"), E = /* @__PURE__ */ s((u) => {
|
|
1056
|
+
let g = h();
|
|
1057
|
+
return Object.assign(g, u), vr(c, g);
|
|
1058
|
+
}, "run"), A = c.playFunction ? k : void 0;
|
|
1059
|
+
return Object.assign(
|
|
1060
|
+
/* @__PURE__ */ s(function(g) {
|
|
1061
|
+
let R = h();
|
|
1062
|
+
return S && (R.loaded = S.loaded), R.args = {
|
|
1063
|
+
...R.initialArgs,
|
|
1064
|
+
...g
|
|
1065
|
+
}, c.unboundStoryFn(R);
|
|
1066
|
+
}, "storyFn"),
|
|
1067
|
+
{
|
|
1068
|
+
id: c.id,
|
|
1069
|
+
storyName: i,
|
|
1070
|
+
load: /* @__PURE__ */ s(async () => {
|
|
1071
|
+
for (let g of [...v].reverse())
|
|
1072
|
+
await g();
|
|
1073
|
+
v.length = 0;
|
|
1074
|
+
let u = h();
|
|
1075
|
+
u.loaded = await c.applyLoaders(u), v.push(...(await c.applyBeforeEach(u)).filter(Boolean)), S = u;
|
|
1076
|
+
}, "load"),
|
|
1077
|
+
globals: f,
|
|
1078
|
+
args: c.initialArgs,
|
|
1079
|
+
parameters: c.parameters,
|
|
1080
|
+
argTypes: c.argTypes,
|
|
1081
|
+
play: A,
|
|
1082
|
+
run: E,
|
|
1083
|
+
reporting: y,
|
|
1084
|
+
tags: c.tags
|
|
1085
|
+
}
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
s(de, "composeStory");
|
|
1089
|
+
async function vr(e, r) {
|
|
1090
|
+
for (let n of [...v].reverse())
|
|
1091
|
+
await n();
|
|
1092
|
+
if (v.length = 0, !r.canvasElement) {
|
|
1093
|
+
let n = document.createElement("div");
|
|
1094
|
+
globalThis?.document?.body?.appendChild(n), r.canvasElement = n, v.push(() => {
|
|
1095
|
+
globalThis?.document?.body?.contains(n) && globalThis?.document?.body?.removeChild(n);
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
if (r.loaded = await e.applyLoaders(r), r.abortSignal.aborted)
|
|
1099
|
+
return;
|
|
1100
|
+
v.push(...(await e.applyBeforeEach(r)).filter(Boolean));
|
|
1101
|
+
let t = e.playFunction, o = e.usesMount;
|
|
1102
|
+
if (o || await r.mount(), r.abortSignal.aborted)
|
|
1103
|
+
return;
|
|
1104
|
+
t && (o || (r.mount = async () => {
|
|
1105
|
+
throw new wr({ playFunction: t.toString() });
|
|
1106
|
+
}), await t(r));
|
|
1107
|
+
let a;
|
|
1108
|
+
ve() ? a = ke() : await Oe(r.abortSignal), await e.applyAfterEach(r), await a?.();
|
|
1109
|
+
}
|
|
1110
|
+
s(vr, "runStory");
|
|
1111
|
+
|
|
1112
|
+
// src/csf/core-annotations.ts
|
|
1113
|
+
import je from "storybook/internal/component-testing/preview";
|
|
1114
|
+
import Ie from "storybook/actions/preview";
|
|
1115
|
+
import _e from "storybook/backgrounds/preview";
|
|
1116
|
+
import Ne from "storybook/highlight/preview";
|
|
1117
|
+
import De from "storybook/measure/preview";
|
|
1118
|
+
import Me from "storybook/outline/preview";
|
|
1119
|
+
import ze from "storybook/test/preview";
|
|
1120
|
+
import Be from "storybook/viewport/preview";
|
|
1121
|
+
function Ue() {
|
|
1122
|
+
return [
|
|
1123
|
+
// @ts-expect-error CJS fallback
|
|
1124
|
+
(De.default ?? De)(),
|
|
1125
|
+
// @ts-expect-error CJS fallback
|
|
1126
|
+
(_e.default ?? _e)(),
|
|
1127
|
+
// @ts-expect-error CJS fallback
|
|
1128
|
+
(Ne.default ?? Ne)(),
|
|
1129
|
+
// @ts-expect-error CJS fallback
|
|
1130
|
+
(Me.default ?? Me)(),
|
|
1131
|
+
// @ts-expect-error CJS fallback
|
|
1132
|
+
(Be.default ?? Be)(),
|
|
1133
|
+
// @ts-expect-error CJS fallback
|
|
1134
|
+
(Ie.default ?? Ie)(),
|
|
1135
|
+
// @ts-expect-error CJS fallback
|
|
1136
|
+
(je.default ?? je)(),
|
|
1137
|
+
// @ts-expect-error CJS fallback
|
|
1138
|
+
(ze.default ?? ze)()
|
|
1139
|
+
];
|
|
1140
|
+
}
|
|
1141
|
+
s(Ue, "getCoreAnnotations");
|
|
1142
|
+
|
|
1143
|
+
// src/csf/csf-factories.ts
|
|
1144
|
+
function zn(e) {
|
|
1145
|
+
let r, t = {
|
|
1146
|
+
_tag: "Preview",
|
|
1147
|
+
input: e,
|
|
1148
|
+
get composed() {
|
|
1149
|
+
if (r)
|
|
1150
|
+
return r;
|
|
1151
|
+
let { addons: o, ...a } = e;
|
|
1152
|
+
return r = _(
|
|
1153
|
+
M([...Ue(), ...o ?? [], a])
|
|
1154
|
+
), r;
|
|
1155
|
+
},
|
|
1156
|
+
meta(o) {
|
|
1157
|
+
return Or(o, this);
|
|
1158
|
+
}
|
|
1159
|
+
};
|
|
1160
|
+
return globalThis.globalProjectAnnotations = t.composed, t;
|
|
1161
|
+
}
|
|
1162
|
+
s(zn, "definePreview");
|
|
1163
|
+
function Bn(e) {
|
|
1164
|
+
return e;
|
|
1165
|
+
}
|
|
1166
|
+
s(Bn, "definePreviewAddon");
|
|
1167
|
+
function Un(e) {
|
|
119
1168
|
return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Preview";
|
|
120
1169
|
}
|
|
121
|
-
|
|
122
|
-
function
|
|
1170
|
+
s(Un, "isPreview");
|
|
1171
|
+
function Hn(e) {
|
|
123
1172
|
return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Meta";
|
|
124
1173
|
}
|
|
125
|
-
|
|
126
|
-
function
|
|
1174
|
+
s(Hn, "isMeta");
|
|
1175
|
+
function Or(e, r) {
|
|
1176
|
+
return {
|
|
1177
|
+
_tag: "Meta",
|
|
1178
|
+
input: e,
|
|
1179
|
+
preview: r,
|
|
1180
|
+
get composed() {
|
|
1181
|
+
throw new Error("Not implemented");
|
|
1182
|
+
},
|
|
1183
|
+
// @ts-expect-error hard
|
|
1184
|
+
story(t = {}) {
|
|
1185
|
+
return He(typeof t == "function" ? { render: t } : t, this);
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
s(Or, "defineMeta");
|
|
1190
|
+
function $n(e) {
|
|
127
1191
|
return e != null && typeof e == "object" && "_tag" in e && e?._tag === "Story";
|
|
128
1192
|
}
|
|
129
|
-
|
|
1193
|
+
s($n, "isStory");
|
|
1194
|
+
function He(e, r) {
|
|
1195
|
+
let t, o = /* @__PURE__ */ s(() => (t || (t = de(
|
|
1196
|
+
e,
|
|
1197
|
+
r.input,
|
|
1198
|
+
void 0,
|
|
1199
|
+
r.preview.composed
|
|
1200
|
+
)), t), "compose");
|
|
1201
|
+
return {
|
|
1202
|
+
_tag: "Story",
|
|
1203
|
+
input: e,
|
|
1204
|
+
meta: r,
|
|
1205
|
+
__compose: o,
|
|
1206
|
+
get composed() {
|
|
1207
|
+
let a = o(), { args: n, argTypes: i, parameters: p, id: d, tags: c, globals: m, storyName: f } = a;
|
|
1208
|
+
return { args: n, argTypes: i, parameters: p, id: d, tags: c, name: f, globals: m };
|
|
1209
|
+
},
|
|
1210
|
+
get play() {
|
|
1211
|
+
return e.play ?? r.input?.play ?? (async () => {
|
|
1212
|
+
});
|
|
1213
|
+
},
|
|
1214
|
+
get run() {
|
|
1215
|
+
return o().run ?? (async () => {
|
|
1216
|
+
});
|
|
1217
|
+
},
|
|
1218
|
+
extend(a) {
|
|
1219
|
+
return He(
|
|
1220
|
+
{
|
|
1221
|
+
...this.input,
|
|
1222
|
+
...a,
|
|
1223
|
+
args: { ...this.input.args, ...a.args },
|
|
1224
|
+
argTypes: x(this.input.argTypes, a.argTypes),
|
|
1225
|
+
afterEach: [
|
|
1226
|
+
...l(this.input?.afterEach ?? []),
|
|
1227
|
+
...l(a.afterEach ?? [])
|
|
1228
|
+
],
|
|
1229
|
+
beforeEach: [
|
|
1230
|
+
...l(this.input?.beforeEach ?? []),
|
|
1231
|
+
...l(a.beforeEach ?? [])
|
|
1232
|
+
],
|
|
1233
|
+
decorators: [
|
|
1234
|
+
...l(this.input?.decorators ?? []),
|
|
1235
|
+
...l(a.decorators ?? [])
|
|
1236
|
+
],
|
|
1237
|
+
globals: { ...this.input.globals, ...a.globals },
|
|
1238
|
+
loaders: [
|
|
1239
|
+
...l(this.input?.loaders ?? []),
|
|
1240
|
+
...l(a.loaders ?? [])
|
|
1241
|
+
],
|
|
1242
|
+
parameters: x(this.input.parameters, a.parameters),
|
|
1243
|
+
tags: kr(...this.input.tags ?? [], ...a.tags ?? [])
|
|
1244
|
+
},
|
|
1245
|
+
this.meta
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1250
|
+
s(He, "defineStory");
|
|
130
1251
|
|
|
131
1252
|
// src/csf/index.ts
|
|
132
|
-
var
|
|
133
|
-
"-").replace(/^-+/, "").replace(/-+$/, ""), "sanitize"),
|
|
134
|
-
let t =
|
|
1253
|
+
var Fr = /* @__PURE__ */ s((e) => e.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, "-").replace(/-+/g,
|
|
1254
|
+
"-").replace(/^-+/, "").replace(/-+$/, ""), "sanitize"), $e = /* @__PURE__ */ s((e, r) => {
|
|
1255
|
+
let t = Fr(e);
|
|
135
1256
|
if (t === "")
|
|
136
1257
|
throw new Error(`Invalid ${r} '${e}', must include alphanumeric characters`);
|
|
137
1258
|
return t;
|
|
138
|
-
}, "sanitizeSafe"),
|
|
1259
|
+
}, "sanitizeSafe"), Vn = /* @__PURE__ */ s((e, r) => `${$e(e, "kind")}${r ? `--${$e(r, "name")}` : ""}`, "toId"), qn = /* @__PURE__ */ s((e) => le(
|
|
139
1260
|
e), "storyNameFromExport");
|
|
140
|
-
function
|
|
1261
|
+
function Le(e, r) {
|
|
141
1262
|
return Array.isArray(r) ? r.includes(e) : e.match(r);
|
|
142
1263
|
}
|
|
143
|
-
|
|
144
|
-
function
|
|
1264
|
+
s(Le, "matches");
|
|
1265
|
+
function Kn(e, { includeStories: r, excludeStories: t }) {
|
|
145
1266
|
return (
|
|
146
1267
|
// https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs
|
|
147
|
-
e !== "__esModule" && (!r ||
|
|
1268
|
+
e !== "__esModule" && (!r || Le(e, r)) && (!t || !Le(e, t))
|
|
148
1269
|
);
|
|
149
1270
|
}
|
|
150
|
-
|
|
151
|
-
var
|
|
152
|
-
let [
|
|
1271
|
+
s(Kn, "isExportStory");
|
|
1272
|
+
var Yn = /* @__PURE__ */ s((e, { rootSeparator: r, groupSeparator: t }) => {
|
|
1273
|
+
let [o, a] = e.split(r, 2), n = (a || e).split(t).filter((i) => !!i);
|
|
153
1274
|
return {
|
|
154
|
-
root:
|
|
155
|
-
groups:
|
|
1275
|
+
root: a ? o : null,
|
|
1276
|
+
groups: n
|
|
156
1277
|
};
|
|
157
|
-
}, "parseKind"),
|
|
158
|
-
let r = e.reduce((t,
|
|
1278
|
+
}, "parseKind"), Jn = /* @__PURE__ */ s((...e) => {
|
|
1279
|
+
let r = e.reduce((t, o) => (o.startsWith("!") ? t.delete(o.slice(1)) : t.add(o), t), /* @__PURE__ */ new Set());
|
|
159
1280
|
return Array.from(r);
|
|
160
1281
|
}, "combineTags");
|
|
161
1282
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
1283
|
+
Jn as combineTags,
|
|
1284
|
+
zn as definePreview,
|
|
1285
|
+
Bn as definePreviewAddon,
|
|
1286
|
+
Ue as getCoreAnnotations,
|
|
1287
|
+
er as includeConditionalArg,
|
|
1288
|
+
Kn as isExportStory,
|
|
1289
|
+
Hn as isMeta,
|
|
1290
|
+
Un as isPreview,
|
|
1291
|
+
$n as isStory,
|
|
1292
|
+
Yn as parseKind,
|
|
1293
|
+
Fr as sanitize,
|
|
1294
|
+
qn as storyNameFromExport,
|
|
1295
|
+
Vn as toId
|
|
172
1296
|
};
|