storybook 9.0.0-alpha.2 → 9.0.0-alpha.20

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.
Files changed (159) hide show
  1. package/README.md +1 -1
  2. package/assets/docs/addon-backgrounds.gif +0 -0
  3. package/assets/docs/addon-controls-args-annotated.png +0 -0
  4. package/assets/docs/addon-controls-args-background-color.png +0 -0
  5. package/assets/docs/addon-controls-args-background-string.png +0 -0
  6. package/assets/docs/addon-controls-args-docs.png +0 -0
  7. package/assets/docs/addon-controls-args-logging.png +0 -0
  8. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  9. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  10. package/assets/docs/addon-controls-args-reflow.png +0 -0
  11. package/assets/docs/addon-controls-args-template.png +0 -0
  12. package/assets/docs/addon-controls-expanded.png +0 -0
  13. package/assets/docs/addon-controls-hero.gif +0 -0
  14. package/assets/docs/addon-controls-install.png +0 -0
  15. package/assets/docs/hero.gif +0 -0
  16. package/assets/docs/highlight.png +0 -0
  17. package/assets/docs/viewport.png +0 -0
  18. package/bin/index.cjs +2 -2
  19. package/dist/actions/decorator.d.ts +6 -0
  20. package/dist/actions/decorator.js +138 -0
  21. package/dist/actions/index.cjs +126 -0
  22. package/dist/actions/index.d.ts +102 -0
  23. package/dist/actions/index.js +111 -0
  24. package/dist/actions/preview.cjs +164 -0
  25. package/dist/actions/preview.d.ts +54 -0
  26. package/dist/actions/preview.js +155 -0
  27. package/dist/backgrounds/index.cjs +148 -0
  28. package/dist/backgrounds/index.d.ts +91 -0
  29. package/dist/backgrounds/index.js +130 -0
  30. package/dist/backgrounds/preview.cjs +143 -0
  31. package/dist/backgrounds/preview.d.ts +54 -0
  32. package/dist/backgrounds/preview.js +127 -0
  33. package/dist/bin/index.cjs +66 -89
  34. package/dist/bin/index.js +62 -85
  35. package/dist/builder-manager/index.cjs +523 -540
  36. package/dist/builder-manager/index.js +544 -561
  37. package/dist/channels/index.cjs +1026 -981
  38. package/dist/channels/index.js +1194 -1165
  39. package/dist/cli/bin/index.cjs +483 -483
  40. package/dist/cli/bin/index.js +495 -495
  41. package/dist/cli/index.cjs +2279 -2295
  42. package/dist/cli/index.d.ts +4 -8
  43. package/dist/cli/index.js +740 -756
  44. package/dist/client-logger/index.cjs +56 -88
  45. package/dist/client-logger/index.js +41 -47
  46. package/dist/common/index.cjs +2496 -2480
  47. package/dist/common/index.d.ts +5 -29
  48. package/dist/common/index.js +2679 -2663
  49. package/dist/component-testing/index.cjs +23 -0
  50. package/dist/component-testing/index.d.ts +3 -0
  51. package/dist/component-testing/index.js +5 -0
  52. package/dist/component-testing/preview.cjs +40 -0
  53. package/dist/component-testing/preview.d.ts +5 -0
  54. package/dist/component-testing/preview.js +25 -0
  55. package/dist/components/index.cjs +11709 -20418
  56. package/dist/components/index.d.ts +94 -346
  57. package/dist/components/index.js +5827 -19157
  58. package/dist/controls/decorator.d.ts +5 -0
  59. package/dist/controls/decorator.js +8 -0
  60. package/dist/controls/index.cjs +26 -0
  61. package/dist/controls/index.d.ts +39 -0
  62. package/dist/controls/index.js +6 -0
  63. package/dist/controls/preview.cjs +26 -0
  64. package/dist/controls/preview.d.ts +54 -0
  65. package/dist/controls/preview.js +9 -0
  66. package/dist/core-events/index.cjs +91 -106
  67. package/dist/core-events/index.d.ts +139 -104
  68. package/dist/core-events/index.js +79 -94
  69. package/dist/core-server/index.cjs +14413 -13924
  70. package/dist/core-server/index.d.ts +270 -3
  71. package/dist/core-server/index.js +14003 -13519
  72. package/dist/core-server/presets/common-manager.css +170 -0
  73. package/dist/core-server/presets/common-manager.js +12099 -17
  74. package/dist/core-server/presets/common-preset.cjs +2760 -2914
  75. package/dist/core-server/presets/common-preset.js +2852 -3007
  76. package/dist/csf/index.cjs +76 -120
  77. package/dist/csf/index.d.ts +2 -6
  78. package/dist/csf/index.js +69 -113
  79. package/dist/csf-tools/index.cjs +412 -403
  80. package/dist/csf-tools/index.d.ts +0 -4
  81. package/dist/csf-tools/index.js +410 -401
  82. package/dist/docs-tools/index.cjs +2569 -575
  83. package/dist/docs-tools/index.d.ts +2 -2
  84. package/dist/docs-tools/index.js +2557 -564
  85. package/dist/highlight/index.cjs +27 -0
  86. package/dist/highlight/index.d.ts +17 -0
  87. package/dist/highlight/index.js +7 -0
  88. package/dist/highlight/preview.cjs +81 -0
  89. package/dist/highlight/preview.d.ts +54 -0
  90. package/dist/highlight/preview.js +67 -0
  91. package/dist/instrumenter/index.cjs +2207 -2342
  92. package/dist/instrumenter/index.d.ts +8 -7
  93. package/dist/instrumenter/index.js +2438 -2620
  94. package/dist/manager/globals-module-info.cjs +290 -151
  95. package/dist/manager/globals-module-info.d.ts +1 -1
  96. package/dist/manager/globals-module-info.js +274 -135
  97. package/dist/manager/globals-runtime.js +60016 -28331
  98. package/dist/manager/globals.cjs +23 -19
  99. package/dist/manager/globals.d.ts +8 -5
  100. package/dist/manager/globals.js +10 -6
  101. package/dist/manager/runtime.js +4645 -3946
  102. package/dist/manager-api/index.cjs +4228 -3833
  103. package/dist/manager-api/index.d.ts +398 -102
  104. package/dist/manager-api/index.js +3676 -3291
  105. package/dist/manager-errors.d.ts +25 -1
  106. package/dist/manager-errors.js +42 -26
  107. package/dist/measure/index.cjs +474 -0
  108. package/dist/measure/index.d.ts +66 -0
  109. package/dist/measure/index.js +462 -0
  110. package/dist/measure/preview.cjs +464 -0
  111. package/dist/measure/preview.d.ts +59 -0
  112. package/dist/measure/preview.js +448 -0
  113. package/dist/outline/index.cjs +528 -0
  114. package/dist/outline/index.d.ts +66 -0
  115. package/dist/outline/index.js +500 -0
  116. package/dist/outline/preview.cjs +518 -0
  117. package/dist/outline/preview.d.ts +59 -0
  118. package/dist/outline/preview.js +486 -0
  119. package/dist/preview/globals.cjs +21 -17
  120. package/dist/preview/globals.d.ts +4 -1
  121. package/dist/preview/globals.js +6 -2
  122. package/dist/preview/runtime.js +45697 -6618
  123. package/dist/preview-api/index.cjs +1363 -1898
  124. package/dist/preview-api/index.d.ts +449 -498
  125. package/dist/preview-api/index.js +1622 -2095
  126. package/dist/preview-errors.cjs +99 -82
  127. package/dist/preview-errors.d.ts +25 -1
  128. package/dist/preview-errors.js +110 -94
  129. package/dist/router/index.cjs +847 -871
  130. package/dist/router/index.js +193 -199
  131. package/dist/server-errors.cjs +156 -125
  132. package/dist/server-errors.d.ts +28 -2
  133. package/dist/server-errors.js +150 -119
  134. package/dist/telemetry/index.cjs +1050 -1977
  135. package/dist/telemetry/index.d.ts +26 -5
  136. package/dist/telemetry/index.js +1085 -2008
  137. package/dist/test/index.cjs +35686 -0
  138. package/dist/test/index.d.ts +186 -0
  139. package/dist/test/index.js +33752 -0
  140. package/dist/test/preview.cjs +15870 -0
  141. package/dist/test/preview.d.ts +54 -0
  142. package/dist/test/preview.js +14441 -0
  143. package/dist/test/spy.cjs +258 -0
  144. package/dist/test/spy.d.ts +66 -0
  145. package/dist/test/spy.js +240 -0
  146. package/dist/theming/create.cjs +79 -2269
  147. package/dist/theming/create.js +67 -841
  148. package/dist/theming/index.cjs +1065 -3232
  149. package/dist/theming/index.js +951 -1719
  150. package/dist/types/index.cjs +11 -12
  151. package/dist/types/index.d.ts +612 -157
  152. package/dist/types/index.js +1 -2
  153. package/dist/viewport/index.cjs +310 -0
  154. package/dist/viewport/index.d.ts +320 -0
  155. package/dist/viewport/index.js +290 -0
  156. package/dist/viewport/preview.cjs +35 -0
  157. package/dist/viewport/preview.d.ts +68 -0
  158. package/dist/viewport/preview.js +19 -0
  159. 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/internal/manager-api';
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
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 < 18) {
5
- console.error('To run Storybook you need to have Node.js 18 or higher');
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,6 @@
1
+ import { Renderer, PartialStoryFn } from 'storybook/internal/types';
2
+
3
+ /** @deprecated Will be removed in Storybook v10 */
4
+ declare const withActions: <T extends Renderer>(storyFn: PartialStoryFn<T>) => T['storyResult'];
5
+
6
+ export { withActions };
@@ -0,0 +1,138 @@
1
+ var j = Object.defineProperty;
2
+ var r = (e, o) => j(e, "name", { value: o, configurable: !0 });
3
+
4
+ // src/actions/decorator.ts
5
+ import { global as F } from "@storybook/global";
6
+ import { makeDecorator as M, useEffect as C } from "storybook/preview-api";
7
+
8
+ // src/actions/constants.ts
9
+ var h = "actions", y = "storybook/actions", L = `${y}/panel`, g = `${y}/action-event`, W = `${y}/action-clear`;
10
+
11
+ // src/actions/runtime/action.ts
12
+ import { ImplicitActionsDuringRendering as S } from "storybook/internal/preview-errors";
13
+ import { global as E } from "@storybook/global";
14
+ import { addons as I } from "storybook/preview-api";
15
+ import { v4 as P } from "uuid";
16
+
17
+ // src/actions/runtime/configureActions.ts
18
+ var a = {
19
+ depth: 10,
20
+ clearOnStoryChange: !0,
21
+ limit: 50
22
+ };
23
+
24
+ // src/actions/runtime/action.ts
25
+ var A = /* @__PURE__ */ r((e, o) => {
26
+ let t = Object.getPrototypeOf(e);
27
+ return !t || o(t) ? t : A(t, o);
28
+ }, "findProto"), x = /* @__PURE__ */ r((e) => !!(typeof e == "object" && e && A(e, (o) => /^Synthetic(?:Base)?Event$/.test(o.constructor.name)) &&
29
+ typeof e.persist == "function"), "isReactSyntheticEvent"), k = /* @__PURE__ */ r((e) => {
30
+ if (x(e)) {
31
+ let o = Object.create(
32
+ e.constructor.prototype,
33
+ Object.getOwnPropertyDescriptors(e)
34
+ );
35
+ o.persist();
36
+ let t = Object.getOwnPropertyDescriptor(o, "view"), n = t?.value;
37
+ return typeof n == "object" && n?.constructor.name === "Window" && Object.defineProperty(o, "view", {
38
+ ...t,
39
+ value: Object.create(n.constructor.prototype)
40
+ }), o;
41
+ }
42
+ return e;
43
+ }, "serializeArg"), T = /* @__PURE__ */ r(() => typeof crypto == "object" && typeof crypto.getRandomValues == "function" ? P() : (
44
+ // pseudo random id, example response lo1e7zm4832bkr7yfl7
45
+ Date.now().toString(36) + Math.random().toString(36).substring(2)
46
+ ), "generateId");
47
+ function O(e, o = {}) {
48
+ let t = {
49
+ ...a,
50
+ ...o
51
+ }, n = /* @__PURE__ */ r(function(...i) {
52
+ if (o.implicit) {
53
+ let u = ("__STORYBOOK_PREVIEW__" in E ? (
54
+ // eslint-disable-next-line no-underscore-dangle
55
+ E.__STORYBOOK_PREVIEW__
56
+ ) : void 0)?.storyRenders.find(
57
+ (c) => c.phase === "playing" || c.phase === "rendering"
58
+ );
59
+ if (u) {
60
+ let c = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, d = new S({
61
+ phase: u.phase,
62
+ name: e,
63
+ deprecated: c
64
+ });
65
+ if (c)
66
+ console.warn(d);
67
+ else
68
+ throw d;
69
+ }
70
+ }
71
+ let m = I.getChannel(), p = T(), l = 5, f = i.map(k), R = i.length > 1 ? f : f[0], D = {
72
+ id: p,
73
+ count: 0,
74
+ data: { name: e, args: R },
75
+ options: {
76
+ ...t,
77
+ maxDepth: l + (t.depth || 3)
78
+ }
79
+ };
80
+ m.emit(g, D);
81
+ }, "actionHandler");
82
+ return n.isAction = !0, n.implicit = o.implicit, n;
83
+ }
84
+ r(O, "action");
85
+
86
+ // src/actions/runtime/actions.ts
87
+ var b = /* @__PURE__ */ r((...e) => {
88
+ let o = a, t = e;
89
+ t.length === 1 && Array.isArray(t[0]) && ([t] = t), t.length !== 1 && typeof t[t.length - 1] != "string" && (o = {
90
+ ...a,
91
+ ...t.pop()
92
+ });
93
+ let n = t[0];
94
+ (t.length !== 1 || typeof n == "string") && (n = {}, t.forEach((i) => {
95
+ n[i] = i;
96
+ }));
97
+ let s = {};
98
+ return Object.keys(n).forEach((i) => {
99
+ s[i] = O(n[i], o);
100
+ }), s;
101
+ }, "actions");
102
+
103
+ // src/actions/decorator.ts
104
+ var { document: v, Element: w } = F, N = /^(\S+)\s*(.*)$/, V = w != null && !w.prototype.matches, Y = V ? "msMatchesSelector" : "matches", _ = /* @__PURE__ */ r(
105
+ (e, o) => {
106
+ if (e[Y](o))
107
+ return !0;
108
+ let t = e.parentElement;
109
+ return t ? _(t, o) : !1;
110
+ }, "hasMatchInAncestry"), $ = /* @__PURE__ */ r((e, ...o) => {
111
+ let t = e(...o);
112
+ return Object.entries(t).map(([n, s]) => {
113
+ let [i, m, p] = n.match(N) || [];
114
+ return {
115
+ eventName: m,
116
+ handler: /* @__PURE__ */ r((l) => {
117
+ (!p || _(l.target, p)) && s(l);
118
+ }, "handler")
119
+ };
120
+ });
121
+ }, "createHandlers"), B = /* @__PURE__ */ r((e, ...o) => {
122
+ let t = v && v.getElementById("storybook-root");
123
+ C(() => {
124
+ if (t != null) {
125
+ let n = $(e, ...o);
126
+ return n.forEach(({ eventName: s, handler: i }) => t.addEventListener(s, i)), () => n.forEach(({ eventName: s, handler: i }) => t.removeEventListener(
127
+ s, i));
128
+ }
129
+ }, [t, e, o]);
130
+ }, "applyEventHandlers"), mt = M({
131
+ name: "withActions",
132
+ parameterName: h,
133
+ skipIfNoParametersOrOptions: !0,
134
+ wrapper: /* @__PURE__ */ r((e, o, { parameters: t }) => (t?.handles && B(b, ...t.handles), e(o)), "wrapper")
135
+ });
136
+ export {
137
+ mt as withActions
138
+ };
@@ -0,0 +1,126 @@
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 ? (
79
+ // eslint-disable-next-line no-underscore-dangle
80
+ f.global.__STORYBOOK_PREVIEW__
81
+ ) : void 0)?.storyRenders.find(
82
+ (p) => p.phase === "playing" || p.phase === "rendering"
83
+ );
84
+ if (d) {
85
+ let p = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, g = new A.ImplicitActionsDuringRendering({
86
+ phase: d.phase,
87
+ name: t,
88
+ deprecated: p
89
+ });
90
+ if (p)
91
+ console.warn(g);
92
+ else
93
+ throw g;
94
+ }
95
+ }
96
+ let E = O.addons.getChannel(), v = $(), w = 5, u = c.map(Y), _ = c.length > 1 ? u : u[0], D = {
97
+ id: v,
98
+ count: 0,
99
+ data: { name: t, args: _ },
100
+ options: {
101
+ ...n,
102
+ maxDepth: w + (n.depth || 3)
103
+ }
104
+ };
105
+ E.emit(y, D);
106
+ }, "actionHandler");
107
+ return e.isAction = !0, e.implicit = o.implicit, e;
108
+ }
109
+ r(l, "action");
110
+
111
+ // src/actions/runtime/actions.ts
112
+ var B = /* @__PURE__ */ r((...t) => {
113
+ let o = s, n = t;
114
+ n.length === 1 && Array.isArray(n[0]) && ([n] = n), n.length !== 1 && typeof n[n.length - 1] != "string" && (o = {
115
+ ...s,
116
+ ...n.pop()
117
+ });
118
+ let e = n[0];
119
+ (n.length !== 1 || typeof e == "string") && (e = {}, n.forEach((c) => {
120
+ e[c] = c;
121
+ }));
122
+ let i = {};
123
+ return Object.keys(e).forEach((c) => {
124
+ i[c] = l(e[c], o);
125
+ }), i;
126
+ }, "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,111 @@
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 ? (
52
+ // eslint-disable-next-line no-underscore-dangle
53
+ u.__STORYBOOK_PREVIEW__
54
+ ) : void 0)?.storyRenders.find(
55
+ (s) => s.phase === "playing" || s.phase === "rendering"
56
+ );
57
+ if (y) {
58
+ let s = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, f = new w({
59
+ phase: y.phase,
60
+ name: o,
61
+ deprecated: s
62
+ });
63
+ if (s)
64
+ console.warn(f);
65
+ else
66
+ throw f;
67
+ }
68
+ }
69
+ let A = _.getChannel(), O = j(), h = 5, m = i.map(R), b = i.length > 1 ? m : m[0], E = {
70
+ id: O,
71
+ count: 0,
72
+ data: { name: o, args: b },
73
+ options: {
74
+ ...t,
75
+ maxDepth: h + (t.depth || 3)
76
+ }
77
+ };
78
+ A.emit(l, E);
79
+ }, "actionHandler");
80
+ return e.isAction = !0, e.implicit = n.implicit, e;
81
+ }
82
+ r(g, "action");
83
+
84
+ // src/actions/runtime/actions.ts
85
+ var G = /* @__PURE__ */ r((...o) => {
86
+ let n = c, t = o;
87
+ t.length === 1 && Array.isArray(t[0]) && ([t] = t), t.length !== 1 && typeof t[t.length - 1] != "string" && (n = {
88
+ ...c,
89
+ ...t.pop()
90
+ });
91
+ let e = t[0];
92
+ (t.length !== 1 || typeof e == "string") && (e = {}, t.forEach((i) => {
93
+ e[i] = i;
94
+ }));
95
+ let p = {};
96
+ return Object.keys(e).forEach((i) => {
97
+ p[i] = g(e[i], n);
98
+ }), p;
99
+ }, "actions");
100
+ export {
101
+ a as ADDON_ID,
102
+ k as CLEAR_ID,
103
+ C as CYCLIC_KEY,
104
+ l as EVENT_ID,
105
+ T as PANEL_ID,
106
+ S as PARAM_KEY,
107
+ g as action,
108
+ G as actions,
109
+ c as config,
110
+ V as configureActions
111
+ };