storybook 9.0.0-alpha.2 → 9.0.0-alpha.21
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/README.md +1 -1
- package/assets/docs/addon-backgrounds.gif +0 -0
- package/assets/docs/addon-controls-args-annotated.png +0 -0
- package/assets/docs/addon-controls-args-background-color.png +0 -0
- package/assets/docs/addon-controls-args-background-string.png +0 -0
- package/assets/docs/addon-controls-args-docs.png +0 -0
- package/assets/docs/addon-controls-args-logging.png +0 -0
- package/assets/docs/addon-controls-args-no-annotation.png +0 -0
- package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
- package/assets/docs/addon-controls-args-reflow.png +0 -0
- package/assets/docs/addon-controls-args-template.png +0 -0
- package/assets/docs/addon-controls-expanded.png +0 -0
- package/assets/docs/addon-controls-hero.gif +0 -0
- package/assets/docs/addon-controls-install.png +0 -0
- package/assets/docs/hero.gif +0 -0
- package/assets/docs/highlight.png +0 -0
- package/assets/docs/viewport.png +0 -0
- package/assets/server/base-preview-head.html +1 -3
- package/bin/index.cjs +2 -2
- package/dist/actions/decorator.d.ts +6 -0
- package/dist/actions/decorator.js +134 -0
- package/dist/actions/index.cjs +123 -0
- package/dist/actions/index.d.ts +102 -0
- package/dist/actions/index.js +108 -0
- package/dist/actions/preview.cjs +161 -0
- package/dist/actions/preview.d.ts +54 -0
- package/dist/actions/preview.js +152 -0
- package/dist/babel/index.cjs +822 -816
- package/dist/babel/index.js +822 -816
- package/dist/backgrounds/index.cjs +148 -0
- package/dist/backgrounds/index.d.ts +91 -0
- package/dist/backgrounds/index.js +130 -0
- package/dist/backgrounds/preview.cjs +143 -0
- package/dist/backgrounds/preview.d.ts +54 -0
- package/dist/backgrounds/preview.js +127 -0
- package/dist/bin/index.cjs +49 -70
- package/dist/bin/index.js +49 -70
- package/dist/builder-manager/index.cjs +319 -326
- package/dist/builder-manager/index.js +576 -583
- package/dist/channels/index.cjs +1026 -981
- package/dist/channels/index.js +1258 -1207
- package/dist/cli/bin/index.cjs +483 -483
- package/dist/cli/bin/index.js +495 -495
- package/dist/cli/index.cjs +61735 -7590
- package/dist/cli/index.d.ts +25 -21
- package/dist/cli/index.js +61776 -7631
- package/dist/client-logger/index.cjs +56 -88
- package/dist/client-logger/index.js +41 -47
- package/dist/common/index.cjs +16137 -9085
- package/dist/common/index.d.ts +35 -30
- package/dist/common/index.js +16230 -9172
- package/dist/component-testing/index.cjs +23 -0
- package/dist/component-testing/index.d.ts +3 -0
- package/dist/component-testing/index.js +5 -0
- package/dist/component-testing/preview.cjs +40 -0
- package/dist/component-testing/preview.d.ts +5 -0
- package/dist/component-testing/preview.js +25 -0
- package/dist/components/index.cjs +16268 -24926
- package/dist/components/index.d.ts +98 -347
- package/dist/components/index.js +5905 -19177
- package/dist/controls/decorator.d.ts +5 -0
- package/dist/controls/decorator.js +8 -0
- package/dist/controls/index.cjs +26 -0
- package/dist/controls/index.d.ts +39 -0
- package/dist/controls/index.js +6 -0
- package/dist/controls/preview.cjs +26 -0
- package/dist/controls/preview.d.ts +54 -0
- package/dist/controls/preview.js +9 -0
- package/dist/core-events/index.cjs +91 -106
- package/dist/core-events/index.d.ts +139 -104
- package/dist/core-events/index.js +79 -94
- package/dist/core-server/index.cjs +13898 -13409
- package/dist/core-server/index.d.ts +270 -3
- package/dist/core-server/index.js +13981 -13497
- package/dist/core-server/presets/common-manager.css +170 -0
- package/dist/core-server/presets/common-manager.js +12149 -17
- package/dist/core-server/presets/common-preset.cjs +3009 -3155
- package/dist/core-server/presets/common-preset.js +2862 -3009
- package/dist/csf/index.cjs +76 -120
- package/dist/csf/index.d.ts +2 -6
- package/dist/csf/index.js +69 -113
- package/dist/csf-tools/index.cjs +412 -403
- package/dist/csf-tools/index.d.ts +0 -4
- package/dist/csf-tools/index.js +410 -401
- package/dist/docs-tools/index.cjs +2569 -575
- package/dist/docs-tools/index.d.ts +2 -2
- package/dist/docs-tools/index.js +2565 -564
- package/dist/highlight/index.cjs +27 -0
- package/dist/highlight/index.d.ts +61 -0
- package/dist/highlight/index.js +7 -0
- package/dist/highlight/preview.cjs +535 -0
- package/dist/highlight/preview.d.ts +54 -0
- package/dist/highlight/preview.js +519 -0
- package/dist/instrumenter/index.cjs +2207 -2342
- package/dist/instrumenter/index.d.ts +8 -7
- package/dist/instrumenter/index.js +2430 -2603
- package/dist/manager/globals-module-info.cjs +291 -151
- package/dist/manager/globals-module-info.d.ts +1 -1
- package/dist/manager/globals-module-info.js +275 -135
- package/dist/manager/globals-runtime.js +60263 -28383
- package/dist/manager/globals.cjs +23 -19
- package/dist/manager/globals.d.ts +8 -5
- package/dist/manager/globals.js +10 -6
- package/dist/manager/runtime.js +4625 -3921
- package/dist/manager-api/index.cjs +4228 -3833
- package/dist/manager-api/index.d.ts +398 -102
- package/dist/manager-api/index.js +3500 -3084
- package/dist/manager-errors.d.ts +25 -1
- package/dist/manager-errors.js +50 -30
- package/dist/measure/index.cjs +476 -0
- package/dist/measure/index.d.ts +66 -0
- package/dist/measure/index.js +464 -0
- package/dist/measure/preview.cjs +466 -0
- package/dist/measure/preview.d.ts +59 -0
- package/dist/measure/preview.js +450 -0
- package/dist/outline/index.cjs +528 -0
- package/dist/outline/index.d.ts +66 -0
- package/dist/outline/index.js +500 -0
- package/dist/outline/preview.cjs +518 -0
- package/dist/outline/preview.d.ts +59 -0
- package/dist/outline/preview.js +486 -0
- package/dist/preview/globals.cjs +21 -17
- package/dist/preview/globals.d.ts +4 -1
- package/dist/preview/globals.js +6 -2
- package/dist/preview/runtime.js +46311 -6614
- package/dist/preview-api/index.cjs +1363 -1899
- package/dist/preview-api/index.d.ts +81 -395
- package/dist/preview-api/index.js +1711 -2169
- package/dist/preview-errors.cjs +119 -88
- package/dist/preview-errors.d.ts +30 -2
- package/dist/preview-errors.js +192 -142
- package/dist/router/index.cjs +847 -871
- package/dist/router/index.js +193 -199
- package/dist/server-errors.cjs +188 -124
- package/dist/server-errors.d.ts +36 -2
- package/dist/server-errors.js +188 -124
- package/dist/telemetry/index.cjs +1056 -1979
- package/dist/telemetry/index.d.ts +26 -5
- package/dist/telemetry/index.js +1091 -2010
- package/dist/test/index.cjs +35686 -0
- package/dist/test/index.d.ts +186 -0
- package/dist/test/index.js +33840 -0
- package/dist/test/preview.cjs +15870 -0
- package/dist/test/preview.d.ts +48 -0
- package/dist/test/preview.js +14501 -0
- package/dist/test/spy.cjs +258 -0
- package/dist/test/spy.d.ts +66 -0
- package/dist/test/spy.js +240 -0
- package/dist/theming/create.cjs +79 -2269
- package/dist/theming/create.js +67 -841
- package/dist/theming/index.cjs +1065 -3232
- package/dist/theming/index.js +951 -1719
- package/dist/types/index.cjs +11 -12
- package/dist/types/index.d.ts +684 -163
- package/dist/types/index.js +1 -2
- package/dist/viewport/index.cjs +310 -0
- package/dist/viewport/index.d.ts +320 -0
- package/dist/viewport/index.js +290 -0
- package/dist/viewport/preview.cjs +35 -0
- package/dist/viewport/preview.d.ts +68 -0
- package/dist/viewport/preview.js +19 -0
- package/package.json +359 -12
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Even though this is where all of the code is located, it is NOT to be the entry
|
|
|
20
20
|
Consumers of the code should import like so:
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
import { addons } from 'storybook/
|
|
23
|
+
import { addons } from 'storybook/manager-api';
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
Importing from `@storybook/core` is explicitly NOT supported; it WILL break in a future version of storybook, very likely in a non-major version bump.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<base target="_parent" />
|
|
2
2
|
|
|
3
3
|
<style>
|
|
4
|
-
/* While we aren't showing the main block yet, but still preparing, we want everything the user
|
|
5
|
-
has rendered, which may or may not be in #storybook-root, to be display none */
|
|
4
|
+
/* While we aren't showing the main block yet, but still preparing, we want everything the user has rendered, which may or may not be in #storybook-root, to be display none */
|
|
6
5
|
.sb-show-preparing-story:not(.sb-show-main) > :not(.sb-preparing-story) {
|
|
7
6
|
display: none;
|
|
8
7
|
}
|
|
@@ -437,7 +436,6 @@
|
|
|
437
436
|
|
|
438
437
|
<script>
|
|
439
438
|
/* globals window */
|
|
440
|
-
/* eslint-disable no-underscore-dangle */
|
|
441
439
|
try {
|
|
442
440
|
if (window.top !== window) {
|
|
443
441
|
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.top.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
package/bin/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const majorNodeVersion = parseInt(process.versions.node, 10);
|
|
4
|
-
if (majorNodeVersion <
|
|
5
|
-
console.error('To run Storybook you need to have Node.js
|
|
4
|
+
if (majorNodeVersion < 20) {
|
|
5
|
+
console.error('To run Storybook you need to have Node.js 20 or higher');
|
|
6
6
|
process.exit(1);
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var r = (e, o) => R(e, "name", { value: o, configurable: !0 });
|
|
3
|
+
|
|
4
|
+
// src/actions/decorator.ts
|
|
5
|
+
import { makeDecorator as T, useEffect as k } from "storybook/preview-api";
|
|
6
|
+
|
|
7
|
+
// src/actions/constants.ts
|
|
8
|
+
var h = "actions", y = "storybook/actions", B = `${y}/panel`, g = `${y}/action-event`, H = `${y}/action-clear`;
|
|
9
|
+
|
|
10
|
+
// src/actions/runtime/action.ts
|
|
11
|
+
import { ImplicitActionsDuringRendering as D } from "storybook/internal/preview-errors";
|
|
12
|
+
import { global as E } from "@storybook/global";
|
|
13
|
+
import { addons as j } from "storybook/preview-api";
|
|
14
|
+
import { v4 as S } from "uuid";
|
|
15
|
+
|
|
16
|
+
// src/actions/runtime/configureActions.ts
|
|
17
|
+
var a = {
|
|
18
|
+
depth: 10,
|
|
19
|
+
clearOnStoryChange: !0,
|
|
20
|
+
limit: 50
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/actions/runtime/action.ts
|
|
24
|
+
var A = /* @__PURE__ */ r((e, o) => {
|
|
25
|
+
let t = Object.getPrototypeOf(e);
|
|
26
|
+
return !t || o(t) ? t : A(t, o);
|
|
27
|
+
}, "findProto"), I = /* @__PURE__ */ r((e) => !!(typeof e == "object" && e && A(e, (o) => /^Synthetic(?:Base)?Event$/.test(o.constructor.name)) &&
|
|
28
|
+
typeof e.persist == "function"), "isReactSyntheticEvent"), P = /* @__PURE__ */ r((e) => {
|
|
29
|
+
if (I(e)) {
|
|
30
|
+
let o = Object.create(
|
|
31
|
+
e.constructor.prototype,
|
|
32
|
+
Object.getOwnPropertyDescriptors(e)
|
|
33
|
+
);
|
|
34
|
+
o.persist();
|
|
35
|
+
let t = Object.getOwnPropertyDescriptor(o, "view"), n = t?.value;
|
|
36
|
+
return typeof n == "object" && n?.constructor.name === "Window" && Object.defineProperty(o, "view", {
|
|
37
|
+
...t,
|
|
38
|
+
value: Object.create(n.constructor.prototype)
|
|
39
|
+
}), o;
|
|
40
|
+
}
|
|
41
|
+
return e;
|
|
42
|
+
}, "serializeArg"), x = /* @__PURE__ */ r(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? S() : (
|
|
43
|
+
// pseudo random id, example response lo1e7zm4832bkr7yfl7
|
|
44
|
+
Date.now().toString(36) + Math.random().toString(36).substring(2)
|
|
45
|
+
), "generateId");
|
|
46
|
+
function O(e, o = {}) {
|
|
47
|
+
let t = {
|
|
48
|
+
...a,
|
|
49
|
+
...o
|
|
50
|
+
}, n = /* @__PURE__ */ r(function(...i) {
|
|
51
|
+
if (o.implicit) {
|
|
52
|
+
let d = ("__STORYBOOK_PREVIEW__" in E ? E.__STORYBOOK_PREVIEW__ : void 0)?.storyRenders.find(
|
|
53
|
+
(c) => c.phase === "playing" || c.phase === "rendering"
|
|
54
|
+
);
|
|
55
|
+
if (d) {
|
|
56
|
+
let c = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, u = new D({
|
|
57
|
+
phase: d.phase,
|
|
58
|
+
name: e,
|
|
59
|
+
deprecated: c
|
|
60
|
+
});
|
|
61
|
+
if (c)
|
|
62
|
+
console.warn(u);
|
|
63
|
+
else
|
|
64
|
+
throw u;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let m = j.getChannel(), p = x(), l = 5, f = i.map(P), w = i.length > 1 ? f : f[0], _ = {
|
|
68
|
+
id: p,
|
|
69
|
+
count: 0,
|
|
70
|
+
data: { name: e, args: w },
|
|
71
|
+
options: {
|
|
72
|
+
...t,
|
|
73
|
+
maxDepth: l + (t.depth || 3)
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
m.emit(g, _);
|
|
77
|
+
}, "actionHandler");
|
|
78
|
+
return n.isAction = !0, n.implicit = o.implicit, n;
|
|
79
|
+
}
|
|
80
|
+
r(O, "action");
|
|
81
|
+
|
|
82
|
+
// src/actions/runtime/actions.ts
|
|
83
|
+
var b = /* @__PURE__ */ r((...e) => {
|
|
84
|
+
let o = a, t = e;
|
|
85
|
+
t.length === 1 && Array.isArray(t[0]) && ([t] = t), t.length !== 1 && typeof t[t.length - 1] != "string" && (o = {
|
|
86
|
+
...a,
|
|
87
|
+
...t.pop()
|
|
88
|
+
});
|
|
89
|
+
let n = t[0];
|
|
90
|
+
(t.length !== 1 || typeof n == "string") && (n = {}, t.forEach((i) => {
|
|
91
|
+
n[i] = i;
|
|
92
|
+
}));
|
|
93
|
+
let s = {};
|
|
94
|
+
return Object.keys(n).forEach((i) => {
|
|
95
|
+
s[i] = O(n[i], o);
|
|
96
|
+
}), s;
|
|
97
|
+
}, "actions");
|
|
98
|
+
|
|
99
|
+
// src/actions/decorator.ts
|
|
100
|
+
var F = /^(\S+)\s*(.*)$/, M = Element != null && !Element.prototype.matches, C = M ? "msMatchesSelector" : "matches", v = /* @__PURE__ */ r(
|
|
101
|
+
(e, o) => {
|
|
102
|
+
if (e[C](o))
|
|
103
|
+
return !0;
|
|
104
|
+
let t = e.parentElement;
|
|
105
|
+
return t ? v(t, o) : !1;
|
|
106
|
+
}, "hasMatchInAncestry"), N = /* @__PURE__ */ r((e, ...o) => {
|
|
107
|
+
let t = e(...o);
|
|
108
|
+
return Object.entries(t).map(([n, s]) => {
|
|
109
|
+
let [i, m, p] = n.match(F) || [];
|
|
110
|
+
return {
|
|
111
|
+
eventName: m,
|
|
112
|
+
handler: /* @__PURE__ */ r((l) => {
|
|
113
|
+
(!p || v(l.target, p)) && s(l);
|
|
114
|
+
}, "handler")
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
}, "createHandlers"), V = /* @__PURE__ */ r((e, ...o) => {
|
|
118
|
+
let t = typeof globalThis.document < "u" && globalThis.document.getElementById("storybook-root");
|
|
119
|
+
k(() => {
|
|
120
|
+
if (t) {
|
|
121
|
+
let n = N(e, ...o);
|
|
122
|
+
return n.forEach(({ eventName: s, handler: i }) => t.addEventListener(s, i)), () => n.forEach(({ eventName: s, handler: i }) => t.removeEventListener(
|
|
123
|
+
s, i));
|
|
124
|
+
}
|
|
125
|
+
}, [t, e, o]);
|
|
126
|
+
}, "applyEventHandlers"), ct = T({
|
|
127
|
+
name: "withActions",
|
|
128
|
+
parameterName: h,
|
|
129
|
+
skipIfNoParametersOrOptions: !0,
|
|
130
|
+
wrapper: /* @__PURE__ */ r((e, o, { parameters: t }) => (t?.handles && V(b, ...t.handles), e(o)), "wrapper")
|
|
131
|
+
});
|
|
132
|
+
export {
|
|
133
|
+
ct as withActions
|
|
134
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var a = Object.defineProperty;
|
|
3
|
+
var x = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var R = Object.getOwnPropertyNames;
|
|
5
|
+
var j = Object.prototype.hasOwnProperty;
|
|
6
|
+
var r = (t, o) => a(t, "name", { value: o, configurable: !0 });
|
|
7
|
+
var I = (t, o) => {
|
|
8
|
+
for (var n in o)
|
|
9
|
+
a(t, n, { get: o[n], enumerable: !0 });
|
|
10
|
+
}, P = (t, o, n, e) => {
|
|
11
|
+
if (o && typeof o == "object" || typeof o == "function")
|
|
12
|
+
for (let i of R(o))
|
|
13
|
+
!j.call(t, i) && i !== n && a(t, i, { get: () => o[i], enumerable: !(e = x(o, i)) || e.enumerable });
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
var S = (t) => P(a({}, "__esModule", { value: !0 }), t);
|
|
17
|
+
|
|
18
|
+
// src/actions/index.ts
|
|
19
|
+
var K = {};
|
|
20
|
+
I(K, {
|
|
21
|
+
ADDON_ID: () => m,
|
|
22
|
+
CLEAR_ID: () => C,
|
|
23
|
+
CYCLIC_KEY: () => F,
|
|
24
|
+
EVENT_ID: () => y,
|
|
25
|
+
PANEL_ID: () => k,
|
|
26
|
+
PARAM_KEY: () => T,
|
|
27
|
+
action: () => l,
|
|
28
|
+
actions: () => B,
|
|
29
|
+
config: () => s,
|
|
30
|
+
configureActions: () => V
|
|
31
|
+
});
|
|
32
|
+
module.exports = S(K);
|
|
33
|
+
|
|
34
|
+
// src/actions/constants.ts
|
|
35
|
+
var T = "actions", m = "storybook/actions", k = `${m}/panel`, y = `${m}/action-event`, C = `${m}/action-clear`, F = "$___storybook.isCyclic";
|
|
36
|
+
|
|
37
|
+
// src/actions/runtime/action.ts
|
|
38
|
+
var A = require("storybook/internal/preview-errors"), f = require("@storybook/global"), O = require("storybook/preview-api"), h = require("uuid");
|
|
39
|
+
|
|
40
|
+
// src/actions/runtime/configureActions.ts
|
|
41
|
+
var s = {
|
|
42
|
+
depth: 10,
|
|
43
|
+
clearOnStoryChange: !0,
|
|
44
|
+
limit: 50
|
|
45
|
+
}, V = /* @__PURE__ */ r((t = {}) => {
|
|
46
|
+
Object.assign(s, t);
|
|
47
|
+
}, "configureActions");
|
|
48
|
+
|
|
49
|
+
// src/actions/runtime/action.ts
|
|
50
|
+
var b = /* @__PURE__ */ r((t, o) => {
|
|
51
|
+
let n = Object.getPrototypeOf(t);
|
|
52
|
+
return !n || o(n) ? n : b(n, o);
|
|
53
|
+
}, "findProto"), W = /* @__PURE__ */ r((t) => !!(typeof t == "object" && t && b(t, (o) => /^Synthetic(?:Base)?Event$/.test(o.constructor.name)) &&
|
|
54
|
+
typeof t.persist == "function"), "isReactSyntheticEvent"), Y = /* @__PURE__ */ r((t) => {
|
|
55
|
+
if (W(t)) {
|
|
56
|
+
let o = Object.create(
|
|
57
|
+
t.constructor.prototype,
|
|
58
|
+
Object.getOwnPropertyDescriptors(t)
|
|
59
|
+
);
|
|
60
|
+
o.persist();
|
|
61
|
+
let n = Object.getOwnPropertyDescriptor(o, "view"), e = n?.value;
|
|
62
|
+
return typeof e == "object" && e?.constructor.name === "Window" && Object.defineProperty(o, "view", {
|
|
63
|
+
...n,
|
|
64
|
+
value: Object.create(e.constructor.prototype)
|
|
65
|
+
}), o;
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
}, "serializeArg"), $ = /* @__PURE__ */ r(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? (0, h.v4)() : (
|
|
69
|
+
// pseudo random id, example response lo1e7zm4832bkr7yfl7
|
|
70
|
+
Date.now().toString(36) + Math.random().toString(36).substring(2)
|
|
71
|
+
), "generateId");
|
|
72
|
+
function l(t, o = {}) {
|
|
73
|
+
let n = {
|
|
74
|
+
...s,
|
|
75
|
+
...o
|
|
76
|
+
}, e = /* @__PURE__ */ r(function(...c) {
|
|
77
|
+
if (o.implicit) {
|
|
78
|
+
let d = ("__STORYBOOK_PREVIEW__" in f.global ? f.global.__STORYBOOK_PREVIEW__ : void 0)?.storyRenders.find(
|
|
79
|
+
(p) => p.phase === "playing" || p.phase === "rendering"
|
|
80
|
+
);
|
|
81
|
+
if (d) {
|
|
82
|
+
let p = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, g = new A.ImplicitActionsDuringRendering({
|
|
83
|
+
phase: d.phase,
|
|
84
|
+
name: t,
|
|
85
|
+
deprecated: p
|
|
86
|
+
});
|
|
87
|
+
if (p)
|
|
88
|
+
console.warn(g);
|
|
89
|
+
else
|
|
90
|
+
throw g;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
let E = O.addons.getChannel(), v = $(), w = 5, u = c.map(Y), _ = c.length > 1 ? u : u[0], D = {
|
|
94
|
+
id: v,
|
|
95
|
+
count: 0,
|
|
96
|
+
data: { name: t, args: _ },
|
|
97
|
+
options: {
|
|
98
|
+
...n,
|
|
99
|
+
maxDepth: w + (n.depth || 3)
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
E.emit(y, D);
|
|
103
|
+
}, "actionHandler");
|
|
104
|
+
return e.isAction = !0, e.implicit = o.implicit, e;
|
|
105
|
+
}
|
|
106
|
+
r(l, "action");
|
|
107
|
+
|
|
108
|
+
// src/actions/runtime/actions.ts
|
|
109
|
+
var B = /* @__PURE__ */ r((...t) => {
|
|
110
|
+
let o = s, n = t;
|
|
111
|
+
n.length === 1 && Array.isArray(n[0]) && ([n] = n), n.length !== 1 && typeof n[n.length - 1] != "string" && (o = {
|
|
112
|
+
...s,
|
|
113
|
+
...n.pop()
|
|
114
|
+
});
|
|
115
|
+
let e = n[0];
|
|
116
|
+
(n.length !== 1 || typeof e == "string") && (e = {}, n.forEach((c) => {
|
|
117
|
+
e[c] = c;
|
|
118
|
+
}));
|
|
119
|
+
let i = {};
|
|
120
|
+
return Object.keys(e).forEach((c) => {
|
|
121
|
+
i[c] = l(e[c], o);
|
|
122
|
+
}), i;
|
|
123
|
+
}, "actions");
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
declare const PARAM_KEY = "actions";
|
|
2
|
+
declare const ADDON_ID = "storybook/actions";
|
|
3
|
+
declare const PANEL_ID = "storybook/actions/panel";
|
|
4
|
+
declare const EVENT_ID = "storybook/actions/action-event";
|
|
5
|
+
declare const CLEAR_ID = "storybook/actions/action-clear";
|
|
6
|
+
declare const CYCLIC_KEY = "$___storybook.isCyclic";
|
|
7
|
+
|
|
8
|
+
interface Options$1 {
|
|
9
|
+
allowRegExp: boolean;
|
|
10
|
+
allowSymbol: boolean;
|
|
11
|
+
allowDate: boolean;
|
|
12
|
+
allowUndefined: boolean;
|
|
13
|
+
allowError: boolean;
|
|
14
|
+
maxDepth: number;
|
|
15
|
+
space: number | undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Options {
|
|
19
|
+
depth: number;
|
|
20
|
+
clearOnStoryChange: boolean;
|
|
21
|
+
limit: number;
|
|
22
|
+
implicit: boolean;
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
type ActionOptions = Partial<Options> & Partial<Options$1>;
|
|
26
|
+
|
|
27
|
+
interface ActionDisplay {
|
|
28
|
+
id: string;
|
|
29
|
+
data: {
|
|
30
|
+
name: string;
|
|
31
|
+
args: any[];
|
|
32
|
+
};
|
|
33
|
+
count: number;
|
|
34
|
+
options: ActionOptions;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type HandlerFunction = (...args: any[]) => void;
|
|
38
|
+
|
|
39
|
+
type ActionsMap<T extends string = string> = Record<T, HandlerFunction>;
|
|
40
|
+
|
|
41
|
+
interface ActionsFunction {
|
|
42
|
+
<T extends string>(handlerMap: Record<T, string>, options?: ActionOptions): ActionsMap<T>;
|
|
43
|
+
<T extends string>(...handlers: T[]): ActionsMap<T>;
|
|
44
|
+
<T extends string>(handler1: T, options?: ActionOptions): ActionsMap<T>;
|
|
45
|
+
<T extends string>(handler1: T, handler2: T, options?: ActionOptions): ActionsMap<T>;
|
|
46
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, options?: ActionOptions): ActionsMap<T>;
|
|
47
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, options?: ActionOptions): ActionsMap<T>;
|
|
48
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, options?: ActionOptions): ActionsMap<T>;
|
|
49
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, options?: ActionOptions): ActionsMap<T>;
|
|
50
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, options?: ActionOptions): ActionsMap<T>;
|
|
51
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, options?: ActionOptions): ActionsMap<T>;
|
|
52
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, handler9: T, options?: ActionOptions): ActionsMap<T>;
|
|
53
|
+
<T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, handler9: T, handler10: T, options?: ActionOptions): ActionsMap<T>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
type DecoratorFunction = (args: any[]) => any[];
|
|
57
|
+
|
|
58
|
+
declare function action(name: string, options?: ActionOptions): HandlerFunction;
|
|
59
|
+
|
|
60
|
+
declare const actions: ActionsFunction;
|
|
61
|
+
|
|
62
|
+
declare const config: ActionOptions;
|
|
63
|
+
declare const configureActions: (options?: ActionOptions) => void;
|
|
64
|
+
|
|
65
|
+
interface ActionsParameters {
|
|
66
|
+
/**
|
|
67
|
+
* Actions configuration
|
|
68
|
+
*
|
|
69
|
+
* @see https://storybook.js.org/docs/essentials/actions#parameters
|
|
70
|
+
*/
|
|
71
|
+
actions: {
|
|
72
|
+
/**
|
|
73
|
+
* Create actions for each arg that matches the regex. (**NOT recommended, see below**)
|
|
74
|
+
*
|
|
75
|
+
* This is quite useful when your component has dozens (or hundreds) of methods and you do not
|
|
76
|
+
* want to manually apply the fn utility for each of those methods. However, this is not the
|
|
77
|
+
* recommended way of writing actions. That's because automatically inferred args are not
|
|
78
|
+
* available as spies in your play function. If you use argTypesRegex and your stories have play
|
|
79
|
+
* functions, you will need to also define args with the fn utility to test them in your play
|
|
80
|
+
* function.
|
|
81
|
+
*
|
|
82
|
+
* @example `argTypesRegex: '^on.*'`
|
|
83
|
+
*/
|
|
84
|
+
argTypesRegex?: string;
|
|
85
|
+
/** Remove the addon panel and disable the addon's behavior */
|
|
86
|
+
disable?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Binds a standard HTML event handler to the outermost HTML element rendered by your component
|
|
89
|
+
* and triggers an action when the event is called for a given selector. The format is
|
|
90
|
+
* `<eventname> <selector>`. The selector is optional; it defaults to all elements.
|
|
91
|
+
*
|
|
92
|
+
* **To enable this feature, you must use the `withActions` decorator.**
|
|
93
|
+
*
|
|
94
|
+
* @example `handles: ['mouseover', 'click .btn']`
|
|
95
|
+
*
|
|
96
|
+
* @see https://storybook.js.org/docs/essentials/actions#action-event-handlers
|
|
97
|
+
*/
|
|
98
|
+
handles?: string[];
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { ADDON_ID, type ActionDisplay, type ActionOptions, type ActionsFunction, type ActionsMap, type ActionsParameters, CLEAR_ID, CYCLIC_KEY, type DecoratorFunction, EVENT_ID, type HandlerFunction, PANEL_ID, PARAM_KEY, action, actions, config, configureActions };
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var v = Object.defineProperty;
|
|
2
|
+
var r = (o, n) => v(o, "name", { value: n, configurable: !0 });
|
|
3
|
+
|
|
4
|
+
// src/actions/constants.ts
|
|
5
|
+
var S = "actions", a = "storybook/actions", T = `${a}/panel`, l = `${a}/action-event`, k = `${a}/action-clear`, C = "$___storybook.isCyclic";
|
|
6
|
+
|
|
7
|
+
// src/actions/runtime/action.ts
|
|
8
|
+
import { ImplicitActionsDuringRendering as w } from "storybook/internal/preview-errors";
|
|
9
|
+
import { global as u } from "@storybook/global";
|
|
10
|
+
import { addons as _ } from "storybook/preview-api";
|
|
11
|
+
import { v4 as D } from "uuid";
|
|
12
|
+
|
|
13
|
+
// src/actions/runtime/configureActions.ts
|
|
14
|
+
var c = {
|
|
15
|
+
depth: 10,
|
|
16
|
+
clearOnStoryChange: !0,
|
|
17
|
+
limit: 50
|
|
18
|
+
}, V = /* @__PURE__ */ r((o = {}) => {
|
|
19
|
+
Object.assign(c, o);
|
|
20
|
+
}, "configureActions");
|
|
21
|
+
|
|
22
|
+
// src/actions/runtime/action.ts
|
|
23
|
+
var d = /* @__PURE__ */ r((o, n) => {
|
|
24
|
+
let t = Object.getPrototypeOf(o);
|
|
25
|
+
return !t || n(t) ? t : d(t, n);
|
|
26
|
+
}, "findProto"), x = /* @__PURE__ */ r((o) => !!(typeof o == "object" && o && d(o, (n) => /^Synthetic(?:Base)?Event$/.test(n.constructor.name)) &&
|
|
27
|
+
typeof o.persist == "function"), "isReactSyntheticEvent"), R = /* @__PURE__ */ r((o) => {
|
|
28
|
+
if (x(o)) {
|
|
29
|
+
let n = Object.create(
|
|
30
|
+
o.constructor.prototype,
|
|
31
|
+
Object.getOwnPropertyDescriptors(o)
|
|
32
|
+
);
|
|
33
|
+
n.persist();
|
|
34
|
+
let t = Object.getOwnPropertyDescriptor(n, "view"), e = t?.value;
|
|
35
|
+
return typeof e == "object" && e?.constructor.name === "Window" && Object.defineProperty(n, "view", {
|
|
36
|
+
...t,
|
|
37
|
+
value: Object.create(e.constructor.prototype)
|
|
38
|
+
}), n;
|
|
39
|
+
}
|
|
40
|
+
return o;
|
|
41
|
+
}, "serializeArg"), j = /* @__PURE__ */ r(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? D() : (
|
|
42
|
+
// pseudo random id, example response lo1e7zm4832bkr7yfl7
|
|
43
|
+
Date.now().toString(36) + Math.random().toString(36).substring(2)
|
|
44
|
+
), "generateId");
|
|
45
|
+
function g(o, n = {}) {
|
|
46
|
+
let t = {
|
|
47
|
+
...c,
|
|
48
|
+
...n
|
|
49
|
+
}, e = /* @__PURE__ */ r(function(...i) {
|
|
50
|
+
if (n.implicit) {
|
|
51
|
+
let y = ("__STORYBOOK_PREVIEW__" in u ? u.__STORYBOOK_PREVIEW__ : void 0)?.storyRenders.find(
|
|
52
|
+
(s) => s.phase === "playing" || s.phase === "rendering"
|
|
53
|
+
);
|
|
54
|
+
if (y) {
|
|
55
|
+
let s = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, f = new w({
|
|
56
|
+
phase: y.phase,
|
|
57
|
+
name: o,
|
|
58
|
+
deprecated: s
|
|
59
|
+
});
|
|
60
|
+
if (s)
|
|
61
|
+
console.warn(f);
|
|
62
|
+
else
|
|
63
|
+
throw f;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let A = _.getChannel(), O = j(), h = 5, m = i.map(R), b = i.length > 1 ? m : m[0], E = {
|
|
67
|
+
id: O,
|
|
68
|
+
count: 0,
|
|
69
|
+
data: { name: o, args: b },
|
|
70
|
+
options: {
|
|
71
|
+
...t,
|
|
72
|
+
maxDepth: h + (t.depth || 3)
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
A.emit(l, E);
|
|
76
|
+
}, "actionHandler");
|
|
77
|
+
return e.isAction = !0, e.implicit = n.implicit, e;
|
|
78
|
+
}
|
|
79
|
+
r(g, "action");
|
|
80
|
+
|
|
81
|
+
// src/actions/runtime/actions.ts
|
|
82
|
+
var G = /* @__PURE__ */ r((...o) => {
|
|
83
|
+
let n = c, t = o;
|
|
84
|
+
t.length === 1 && Array.isArray(t[0]) && ([t] = t), t.length !== 1 && typeof t[t.length - 1] != "string" && (n = {
|
|
85
|
+
...c,
|
|
86
|
+
...t.pop()
|
|
87
|
+
});
|
|
88
|
+
let e = t[0];
|
|
89
|
+
(t.length !== 1 || typeof e == "string") && (e = {}, t.forEach((i) => {
|
|
90
|
+
e[i] = i;
|
|
91
|
+
}));
|
|
92
|
+
let p = {};
|
|
93
|
+
return Object.keys(e).forEach((i) => {
|
|
94
|
+
p[i] = g(e[i], n);
|
|
95
|
+
}), p;
|
|
96
|
+
}, "actions");
|
|
97
|
+
export {
|
|
98
|
+
a as ADDON_ID,
|
|
99
|
+
k as CLEAR_ID,
|
|
100
|
+
C as CYCLIC_KEY,
|
|
101
|
+
l as EVENT_ID,
|
|
102
|
+
T as PANEL_ID,
|
|
103
|
+
S as PARAM_KEY,
|
|
104
|
+
g as action,
|
|
105
|
+
G as actions,
|
|
106
|
+
c as config,
|
|
107
|
+
V as configureActions
|
|
108
|
+
};
|