storybook 9.0.0-alpha.12 → 9.0.0-alpha.14

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 (89) hide show
  1. package/assets/docs/addon-backgrounds.gif +0 -0
  2. package/assets/docs/highlight.png +0 -0
  3. package/dist/actions/decorator.js +46 -47
  4. package/dist/actions/index.cjs +28 -29
  5. package/dist/actions/index.d.ts +0 -3
  6. package/dist/actions/index.js +27 -28
  7. package/dist/actions/preview.cjs +22 -23
  8. package/dist/actions/preview.js +18 -19
  9. package/dist/backgrounds/index.cjs +148 -0
  10. package/dist/backgrounds/index.d.ts +91 -0
  11. package/dist/backgrounds/index.js +130 -0
  12. package/dist/backgrounds/preview.cjs +143 -0
  13. package/dist/backgrounds/preview.d.ts +54 -0
  14. package/dist/backgrounds/preview.js +127 -0
  15. package/dist/bin/index.cjs +62 -73
  16. package/dist/bin/index.js +57 -68
  17. package/dist/builder-manager/index.cjs +390 -380
  18. package/dist/builder-manager/index.js +489 -479
  19. package/dist/channels/index.cjs +1018 -948
  20. package/dist/channels/index.js +1194 -1161
  21. package/dist/cli/bin/index.cjs +225 -225
  22. package/dist/cli/bin/index.js +234 -234
  23. package/dist/cli/index.cjs +1860 -1873
  24. package/dist/cli/index.js +308 -321
  25. package/dist/common/index.cjs +2396 -2380
  26. package/dist/common/index.d.ts +0 -11
  27. package/dist/common/index.js +2604 -2588
  28. package/dist/components/index.cjs +6393 -12704
  29. package/dist/components/index.d.ts +1 -2
  30. package/dist/components/index.js +4665 -10778
  31. package/dist/core-events/index.cjs +72 -84
  32. package/dist/core-events/index.d.ts +2 -77
  33. package/dist/core-events/index.js +61 -73
  34. package/dist/core-server/index.cjs +13484 -13318
  35. package/dist/core-server/index.js +13652 -13486
  36. package/dist/core-server/presets/common-manager.js +9815 -12
  37. package/dist/core-server/presets/common-preset.cjs +2809 -3005
  38. package/dist/core-server/presets/common-preset.js +2891 -3087
  39. package/dist/docs-tools/index.cjs +626 -600
  40. package/dist/docs-tools/index.js +613 -587
  41. package/dist/highlight/index.cjs +27 -0
  42. package/dist/highlight/index.d.ts +17 -0
  43. package/dist/highlight/index.js +7 -0
  44. package/dist/highlight/preview.cjs +81 -0
  45. package/dist/highlight/preview.d.ts +54 -0
  46. package/dist/highlight/preview.js +67 -0
  47. package/dist/instrumenter/index.cjs +70 -60
  48. package/dist/instrumenter/index.d.ts +8 -7
  49. package/dist/instrumenter/index.js +98 -88
  50. package/dist/manager/globals-module-info.cjs +12 -22
  51. package/dist/manager/globals-module-info.js +2 -12
  52. package/dist/manager/globals-runtime.js +31295 -33999
  53. package/dist/manager/runtime.js +3419 -3522
  54. package/dist/manager-api/index.cjs +2521 -2445
  55. package/dist/manager-api/index.d.ts +7 -21
  56. package/dist/manager-api/index.js +2431 -2349
  57. package/dist/measure/index.cjs +474 -0
  58. package/dist/measure/index.d.ts +66 -0
  59. package/dist/measure/index.js +462 -0
  60. package/dist/measure/preview.cjs +464 -0
  61. package/dist/measure/preview.d.ts +59 -0
  62. package/dist/measure/preview.js +448 -0
  63. package/dist/outline/index.cjs +528 -0
  64. package/dist/outline/index.d.ts +66 -0
  65. package/dist/outline/index.js +500 -0
  66. package/dist/outline/preview.cjs +518 -0
  67. package/dist/outline/preview.d.ts +59 -0
  68. package/dist/outline/preview.js +486 -0
  69. package/dist/preview/runtime.js +20735 -17220
  70. package/dist/preview-api/index.cjs +1069 -1057
  71. package/dist/preview-api/index.d.ts +384 -157
  72. package/dist/preview-api/index.js +1123 -1109
  73. package/dist/server-errors.cjs +66 -67
  74. package/dist/server-errors.d.ts +0 -1
  75. package/dist/server-errors.js +68 -69
  76. package/dist/test/index.cjs +1547 -1546
  77. package/dist/test/index.js +2308 -2307
  78. package/dist/test/preview.cjs +1906 -1905
  79. package/dist/test/preview.js +1439 -1438
  80. package/dist/test/spy.cjs +65 -64
  81. package/dist/test/spy.js +59 -58
  82. package/dist/types/index.cjs +10 -10
  83. package/dist/types/index.d.ts +203 -243
  84. package/package.json +122 -17
  85. package/dist/actions/manager.js +0 -1195
  86. package/dist/component-testing/manager.js +0 -3126
  87. package/dist/controls/manager.js +0 -5593
  88. package/dist/viewport/manager.js +0 -400
  89. /package/dist/{component-testing/manager.css → core-server/presets/common-manager.css} +0 -0
@@ -1,400 +0,0 @@
1
- var q = Object.defineProperty;
2
- var n = (e, t) => q(e, "name", { value: t, configurable: !0 });
3
-
4
- // src/viewport/manager.tsx
5
- import * as F from "react";
6
- import { addons as O, types as c0 } from "storybook/manager-api";
7
-
8
- // src/viewport/components/Tool.tsx
9
- import o, { Fragment as J, useCallback as Q, useEffect as $, useState as K } from "react";
10
- import { IconButton as e0, TooltipLinkList as t0, WithTooltip as a0 } from "storybook/internal/components";
11
-
12
- // ../node_modules/@storybook/icons/dist/index.mjs
13
- import * as l from "react";
14
- var H = /* @__PURE__ */ l.forwardRef(({ color: e = "currentColor", size: t = 14, ...a }, r) => /* @__PURE__ */ l.createElement(
15
- "svg",
16
- {
17
- width: t,
18
- height: t,
19
- viewBox: "0 0 14 14",
20
- fill: "none",
21
- xmlns: "http://www.w3.org/2000/svg",
22
- ref: r,
23
- ...a
24
- },
25
- /* @__PURE__ */ l.createElement(
26
- "path",
27
- {
28
- d: "M1.5 1.004a.5.5 0 100 1H12v10.5a.5.5 0 001 0v-10.5a1 1 0 00-1-1H1.5z",
29
- fill: e
30
- }
31
- ),
32
- /* @__PURE__ */ l.createElement(
33
- "path",
34
- {
35
- d: "M1 3.504a.5.5 0 01.5-.5H10a1 1 0 011 1v8.5a.5.5 0 01-1 0v-8.5H1.5a.5.5 0 01-.5-.5z",
36
- fill: e
37
- }
38
- ),
39
- /* @__PURE__ */ l.createElement(
40
- "path",
41
- {
42
- fillRule: "evenodd",
43
- clipRule: "evenodd",
44
- d: "M1.5 5.004a.5.5 0 00-.5.5v7a.5.5 0 00.5.5h7a.5.5 0 00.5-.5v-7a.5.5 0 00-.5-.5h-7zm.5 1v6h6v-6H2z",
45
- fill: e
46
- }
47
- )
48
- ));
49
- var C = /* @__PURE__ */ l.forwardRef(({ color: e = "currentColor", size: t = 14, ...a }, r) => /* @__PURE__ */ l.createElement(
50
- "svg",
51
- {
52
- width: t,
53
- height: t,
54
- viewBox: "0 0 14 14",
55
- fill: "none",
56
- xmlns: "http://www.w3.org/2000/svg",
57
- ref: r,
58
- ...a
59
- },
60
- /* @__PURE__ */ l.createElement(
61
- "path",
62
- {
63
- fillRule: "evenodd",
64
- clipRule: "evenodd",
65
- d: "M.5 13.004a.5.5 0 01-.5-.5v-11a.5.5 0 01.5-.5h13a.5.5 0 01.5.5v11a.5.5 0 01-.5.5H.5zm.5-1v-8h12v8H1zm1-9.5a.5.5 0 11-1 0 .5.5 0 01\
66
- 1 0zm2 0a.5.5 0 11-1 0 .5.5 0 011 0zm2 0a.5.5 0 11-1 0 .5.5 0 011 0z",
67
- fill: e
68
- }
69
- )
70
- )), L = /* @__PURE__ */ l.forwardRef(({ color: e = "currentColor", size: t = 14, ...a }, r) => /* @__PURE__ */ l.createElement(
71
- "svg",
72
- {
73
- width: t,
74
- height: t,
75
- viewBox: "0 0 14 15",
76
- fill: "none",
77
- xmlns: "http://www.w3.org/2000/svg",
78
- ref: r,
79
- ...a
80
- },
81
- /* @__PURE__ */ l.createElement(
82
- "path",
83
- {
84
- fillRule: "evenodd",
85
- clipRule: "evenodd",
86
- d: "M3.5.004a1.5 1.5 0 00-1.5 1.5v11a1.5 1.5 0 001.5 1.5h7a1.5 1.5 0 001.5-1.5v-11a1.5 1.5 0 00-1.5-1.5h-7zm0 1h7a.5.5 0 01.5.5v9.5H3v\
87
- -9.5a.5.5 0 01.5-.5zm2.5 11a.5.5 0 000 1h2a.5.5 0 000-1H6z",
88
- fill: e
89
- }
90
- )
91
- )), A = /* @__PURE__ */ l.forwardRef(({ color: e = "currentColor", size: t = 14, ...a }, r) => /* @__PURE__ */ l.createElement(
92
- "svg",
93
- {
94
- width: t,
95
- height: t,
96
- viewBox: "0 0 14 15",
97
- fill: "none",
98
- xmlns: "http://www.w3.org/2000/svg",
99
- ref: r,
100
- ...a
101
- },
102
- /* @__PURE__ */ l.createElement(
103
- "path",
104
- {
105
- fillRule: "evenodd",
106
- clipRule: "evenodd",
107
- d: "M3 1.504a1.5 1.5 0 011.5-1.5h5a1.5 1.5 0 011.5 1.5v11a1.5 1.5 0 01-1.5 1.5h-5a1.5 1.5 0 01-1.5-1.5v-11zm1 10.5v-10h6v10H4z",
108
- fill: e
109
- }
110
- )
111
- ));
112
- var V = /* @__PURE__ */ l.forwardRef(({ color: e = "currentColor", size: t = 14, ...a }, r) => /* @__PURE__ */ l.createElement(
113
- "svg",
114
- {
115
- width: t,
116
- height: t,
117
- viewBox: "0 0 14 14",
118
- fill: "none",
119
- xmlns: "http://www.w3.org/2000/svg",
120
- ref: r,
121
- ...a
122
- },
123
- /* @__PURE__ */ l.createElement(
124
- "path",
125
- {
126
- d: "M10.646 2.646a.5.5 0 01.708 0l1.5 1.5a.5.5 0 010 .708l-1.5 1.5a.5.5 0 01-.708-.708L11.293 5H1.5a.5.5 0 010-1h9.793l-.647-.646a.5.5\
127
- 0 010-.708zM3.354 8.354L2.707 9H12.5a.5.5 0 010 1H2.707l.647.646a.5.5 0 01-.708.708l-1.5-1.5a.5.5 0 010-.708l1.5-1.5a.5.5 0 11.708.708z",
128
- fill: e
129
- }
130
- )
131
- ));
132
- var B = /* @__PURE__ */ l.forwardRef(({ color: e = "currentColor", size: t = 14, ...a }, r) => /* @__PURE__ */ l.createElement(
133
- "svg",
134
- {
135
- width: t,
136
- height: t,
137
- viewBox: "0 0 14 14",
138
- fill: "none",
139
- xmlns: "http://www.w3.org/2000/svg",
140
- ref: r,
141
- ...a
142
- },
143
- /* @__PURE__ */ l.createElement(
144
- "path",
145
- {
146
- d: "M7.092.5H7a6.5 6.5 0 106.41 7.583.5.5 0 10-.986-.166A5.495 5.495 0 017 12.5a5.5 5.5 0 010-11h.006a5.5 5.5 0 014.894 3H10a.5.5 0 00\
147
- 0 1h3a.5.5 0 00.5-.5V2a.5.5 0 00-1 0v1.535A6.495 6.495 0 007.092.5z",
148
- fill: e
149
- }
150
- )
151
- ));
152
-
153
- // src/viewport/components/Tool.tsx
154
- import { useGlobals as l0, useParameter as r0 } from "storybook/manager-api";
155
- import { Global as n0 } from "storybook/theming";
156
-
157
- // src/viewport/constants.ts
158
- var i = "storybook/viewport", d = "viewport", v0 = `${i}/panel`, y = `${i}/tool`;
159
-
160
- // src/viewport/defaults.ts
161
- var b = {
162
- mobile1: {
163
- name: "Small mobile",
164
- styles: {
165
- height: "568px",
166
- width: "320px"
167
- },
168
- type: "mobile"
169
- },
170
- mobile2: {
171
- name: "Large mobile",
172
- styles: {
173
- height: "896px",
174
- width: "414px"
175
- },
176
- type: "mobile"
177
- },
178
- tablet: {
179
- name: "Tablet",
180
- styles: {
181
- height: "1112px",
182
- width: "834px"
183
- },
184
- type: "tablet"
185
- },
186
- desktop: {
187
- name: "Desktop",
188
- styles: {
189
- height: "1024px",
190
- width: "1280px"
191
- },
192
- type: "desktop"
193
- }
194
- };
195
-
196
- // src/viewport/responsiveViewport.tsx
197
- var m = {
198
- name: "Reset viewport",
199
- styles: {
200
- height: "100%",
201
- width: "100%"
202
- },
203
- type: "desktop"
204
- };
205
-
206
- // src/viewport/preview.ts
207
- import { definePreview as m0 } from "storybook/preview-api";
208
- var P = {
209
- [d]: { value: void 0, isRotated: !1 }
210
- };
211
-
212
- // src/viewport/shortcuts.ts
213
- var S = /* @__PURE__ */ n((e, t) => e.indexOf(t), "getCurrentViewportIndex"), X = /* @__PURE__ */ n((e, t) => {
214
- let a = S(e, t);
215
- return a === e.length - 1 ? e[0] : e[a + 1];
216
- }, "getNextViewport"), Z = /* @__PURE__ */ n((e, t) => {
217
- let a = S(e, t);
218
- return a < 1 ? e[e.length - 1] : e[a - 1];
219
- }, "getPreviousViewport"), _ = /* @__PURE__ */ n(async (e, t, a, r) => {
220
- await e.setAddonShortcut(i, {
221
- label: "Previous viewport",
222
- defaultShortcut: ["alt", "shift", "V"],
223
- actionName: "previous",
224
- action: /* @__PURE__ */ n(() => {
225
- a({
226
- viewport: Z(r, t)
227
- });
228
- }, "action")
229
- }), await e.setAddonShortcut(i, {
230
- label: "Next viewport",
231
- defaultShortcut: ["alt", "V"],
232
- actionName: "next",
233
- action: /* @__PURE__ */ n(() => {
234
- a({
235
- viewport: X(r, t)
236
- });
237
- }, "action")
238
- }), await e.setAddonShortcut(i, {
239
- label: "Reset viewport",
240
- defaultShortcut: ["alt", "control", "V"],
241
- actionName: "reset",
242
- action: /* @__PURE__ */ n(() => {
243
- a(P);
244
- }, "action")
245
- });
246
- }, "registerShortcuts");
247
-
248
- // src/viewport/utils.tsx
249
- import M, { Fragment as j } from "react";
250
- import { IconButton as Y } from "storybook/internal/components";
251
- import { styled as z } from "storybook/theming";
252
- var k = z.div({
253
- display: "inline-flex",
254
- alignItems: "center"
255
- }), I = z.div(({ theme: e }) => ({
256
- display: "inline-block",
257
- textDecoration: "none",
258
- padding: 10,
259
- fontWeight: e.typography.weight.bold,
260
- fontSize: e.typography.size.s2 - 1,
261
- lineHeight: "1",
262
- height: 40,
263
- border: "none",
264
- borderTop: "3px solid transparent",
265
- borderBottom: "3px solid transparent",
266
- background: "transparent"
267
- })), D = z(Y)(() => ({
268
- display: "inline-flex",
269
- alignItems: "center"
270
- })), T = z.div(({ theme: e }) => ({
271
- fontSize: e.typography.size.s2 - 1,
272
- marginLeft: 10
273
- })), G = {
274
- desktop: /* @__PURE__ */ M.createElement(C, null),
275
- mobile: /* @__PURE__ */ M.createElement(A, null),
276
- tablet: /* @__PURE__ */ M.createElement(L, null),
277
- other: /* @__PURE__ */ M.createElement(j, null)
278
- };
279
-
280
- // src/viewport/components/Tool.tsx
281
- var U = /* @__PURE__ */ n(({ api: e }) => {
282
- let t = r0(d), [a, r, g] = l0(), [u, s] = K(!1), { options: h = b, disable: E } = t || {}, v = a?.[d] || {}, w = typeof v == "string" ? v :
283
- v.value, f = typeof v == "string" ? !1 : v.isRotated, c = h[w] || m, R = u || c !== m, p = d in g, x = Object.keys(h).length;
284
- if ($(() => {
285
- _(e, w, r, Object.keys(h));
286
- }, [h, w, r, e]), c.styles === null || !h || x < 1)
287
- return null;
288
- if (typeof c.styles == "function")
289
- return console.warn(
290
- "Addon Viewport no longer supports dynamic styles using a function, use css calc() instead"
291
- ), null;
292
- let N = f ? c.styles.height : c.styles.width, W = f ? c.styles.width : c.styles.height;
293
- return E ? null : /* @__PURE__ */ o.createElement(
294
- o0,
295
- {
296
- item: c,
297
- updateGlobals: r,
298
- viewportMap: h,
299
- viewportName: w,
300
- isRotated: f,
301
- setIsTooltipVisible: s,
302
- isLocked: p,
303
- isActive: R,
304
- width: N,
305
- height: W
306
- }
307
- );
308
- }, "ViewportTool"), o0 = o.memo(/* @__PURE__ */ n(function(t) {
309
- let {
310
- item: a,
311
- viewportMap: r,
312
- viewportName: g,
313
- isRotated: u,
314
- updateGlobals: s,
315
- setIsTooltipVisible: h,
316
- isLocked: E,
317
- isActive: v,
318
- width: w,
319
- height: f
320
- } = t, c = Q(
321
- (R) => s({ [d]: R }),
322
- [s]
323
- );
324
- return /* @__PURE__ */ o.createElement(J, null, /* @__PURE__ */ o.createElement(
325
- a0,
326
- {
327
- placement: "bottom",
328
- tooltip: ({ onHide: R }) => /* @__PURE__ */ o.createElement(
329
- t0,
330
- {
331
- links: [
332
- ...length > 0 && a !== m ? [
333
- {
334
- id: "reset",
335
- title: "Reset viewport",
336
- icon: /* @__PURE__ */ o.createElement(B, null),
337
- onClick: /* @__PURE__ */ n(() => {
338
- c({ value: void 0, isRotated: !1 }), R();
339
- }, "onClick")
340
- }
341
- ] : [],
342
- ...Object.entries(r).map(([p, x]) => ({
343
- id: p,
344
- title: x.name,
345
- icon: G[x.type],
346
- active: p === g,
347
- onClick: /* @__PURE__ */ n(() => {
348
- c({ value: p, isRotated: !1 }), R();
349
- }, "onClick")
350
- }))
351
- ].flat()
352
- }
353
- ),
354
- closeOnOutsideClick: !0,
355
- onVisibleChange: h
356
- },
357
- /* @__PURE__ */ o.createElement(
358
- D,
359
- {
360
- disabled: E,
361
- key: "viewport",
362
- title: "Change the size of the preview",
363
- active: v,
364
- onDoubleClick: () => {
365
- c({ value: void 0, isRotated: !1 });
366
- }
367
- },
368
- /* @__PURE__ */ o.createElement(H, null),
369
- a !== m ? /* @__PURE__ */ o.createElement(T, null, a.name, " ", u ? "(L)" : "(P)") : null
370
- )
371
- ), /* @__PURE__ */ o.createElement(
372
- n0,
373
- {
374
- styles: {
375
- 'iframe[data-is-storybook="true"]': { width: w, height: f }
376
- }
377
- }
378
- ), a !== m ? /* @__PURE__ */ o.createElement(k, null, /* @__PURE__ */ o.createElement(I, { title: "Viewport width" }, w.replace("px", "")),
379
- E ? "/" : /* @__PURE__ */ o.createElement(
380
- e0,
381
- {
382
- key: "viewport-rotate",
383
- title: "Rotate viewport",
384
- onClick: () => {
385
- c({ value: g, isRotated: !u });
386
- }
387
- },
388
- /* @__PURE__ */ o.createElement(V, null)
389
- ), /* @__PURE__ */ o.createElement(I, { title: "Viewport height" }, f.replace("px", ""))) : null);
390
- }, "PureTool"));
391
-
392
- // src/viewport/manager.tsx
393
- O.register(i, (e) => {
394
- O.add(y, {
395
- title: "viewport / media-queries",
396
- type: c0.TOOL,
397
- match: /* @__PURE__ */ n(({ viewMode: t, tabId: a }) => t === "story" && !a, "match"),
398
- render: /* @__PURE__ */ n(() => /* @__PURE__ */ F.createElement(U, { api: e }), "render")
399
- });
400
- });