storybook 9.1.0-alpha.3 → 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.
Files changed (70) hide show
  1. package/dist/actions/index.cjs +16 -16
  2. package/dist/actions/index.d.ts +1 -38
  3. package/dist/actions/index.js +12 -12
  4. package/dist/actions/preview.cjs +25 -25
  5. package/dist/actions/preview.d.ts +37 -547
  6. package/dist/actions/preview.js +18 -18
  7. package/dist/backgrounds/index.cjs +12 -144
  8. package/dist/backgrounds/index.d.ts +1 -591
  9. package/dist/backgrounds/index.js +0 -130
  10. package/dist/backgrounds/preview.cjs +63 -63
  11. package/dist/backgrounds/preview.d.ts +40 -542
  12. package/dist/backgrounds/preview.js +47 -47
  13. package/dist/bin/index.cjs +50 -50
  14. package/dist/bin/index.js +50 -50
  15. package/dist/cli/bin/index.cjs +1 -1
  16. package/dist/cli/bin/index.js +1 -1
  17. package/dist/common/index.cjs +732 -731
  18. package/dist/common/index.d.ts +2 -2
  19. package/dist/common/index.js +81 -79
  20. package/dist/component-testing/preview.cjs +12 -12
  21. package/dist/component-testing/preview.d.ts +2 -2
  22. package/dist/component-testing/preview.js +7 -7
  23. package/dist/controls/index.cjs +16 -16
  24. package/dist/controls/index.d.ts +1 -36
  25. package/dist/controls/preview.cjs +17 -17
  26. package/dist/controls/preview.d.ts +34 -546
  27. package/dist/controls/preview.js +3 -3
  28. package/dist/csf/index.cjs +1210 -95
  29. package/dist/csf/index.d.ts +59 -18
  30. package/dist/csf/index.js +1214 -90
  31. package/dist/csf-tools/index.cjs +2 -1
  32. package/dist/csf-tools/index.js +2 -2
  33. package/dist/highlight/index.cjs +15 -15
  34. package/dist/highlight/index.d.ts +1 -12
  35. package/dist/highlight/index.js +4 -4
  36. package/dist/highlight/preview.cjs +63 -63
  37. package/dist/highlight/preview.d.ts +11 -546
  38. package/dist/highlight/preview.js +11 -10
  39. package/dist/manager/globals-runtime.js +29776 -29777
  40. package/dist/manager-api/index.cjs +1 -1
  41. package/dist/manager-api/index.js +1 -1
  42. package/dist/measure/index.cjs +12 -472
  43. package/dist/measure/index.d.ts +1 -566
  44. package/dist/measure/index.js +0 -464
  45. package/dist/measure/preview.cjs +104 -104
  46. package/dist/measure/preview.d.ts +11 -546
  47. package/dist/measure/preview.js +105 -105
  48. package/dist/outline/index.cjs +12 -524
  49. package/dist/outline/index.d.ts +1 -566
  50. package/dist/outline/index.js +0 -500
  51. package/dist/outline/preview.cjs +32 -32
  52. package/dist/outline/preview.d.ts +11 -546
  53. package/dist/outline/preview.js +27 -27
  54. package/dist/preview/runtime.js +8259 -8266
  55. package/dist/preview-api/index.cjs +1228 -1261
  56. package/dist/preview-api/index.d.ts +6 -8
  57. package/dist/preview-api/index.js +927 -963
  58. package/dist/telemetry/index.cjs +1 -1
  59. package/dist/telemetry/index.js +1 -1
  60. package/dist/test/preview.cjs +42 -42
  61. package/dist/test/preview.d.ts +12 -550
  62. package/dist/test/preview.js +36 -36
  63. package/dist/types/index.d.ts +5 -3
  64. package/dist/viewport/index.cjs +17 -24
  65. package/dist/viewport/index.d.ts +9 -532
  66. package/dist/viewport/index.js +9 -16
  67. package/dist/viewport/preview.cjs +22 -22
  68. package/dist/viewport/preview.d.ts +45 -552
  69. package/dist/viewport/preview.js +8 -8
  70. package/package.json +1 -1
@@ -2,7 +2,7 @@ var it = Object.defineProperty;
2
2
  var r = (e, t) => it(e, "name", { value: t, configurable: !0 });
3
3
 
4
4
  // src/measure/preview.ts
5
- import { definePreview as St } from "storybook/preview-api";
5
+ import { definePreviewAddon as St } from "storybook/internal/csf";
6
6
 
7
7
  // src/measure/constants.ts
8
8
  var C = "storybook/measure-addon", Mt = `${C}/tool`, P = "measureEnabled", xt = {
@@ -91,19 +91,19 @@ function X(e, { x: t, y: o, w: i, h: n, r: l }) {
91
91
  i, o + n, l), e.arcTo(t + i, o + n, t, o + n, l), e.arcTo(t, o + n, t, o, l), e.arcTo(t, o, t + i, o, l), e.closePath();
92
92
  }
93
93
  r(X, "roundedRect");
94
- function at(e, { padding: t, border: o, width: i, height: n, top: l, left: a }) {
95
- let s = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom, c = a + o.left + t.left, u = l + o.top + t.top;
96
- return e === "top" ? c += s / 2 : e === "right" ? (c += s, u += f / 2) : e === "bottom" ? (c += s / 2, u += f) : e === "left" ? u += f / 2 :
97
- e === "center" && (c += s / 2, u += f / 2), { x: c, y: u };
98
- }
99
- r(at, "positionCoordinate");
100
- function st(e, t, { margin: o, border: i, padding: n }, l, a) {
101
- let s = /* @__PURE__ */ r((h) => 0, "shift"), f = 0, c = 0, u = a ? 1 : 0.5, p = a ? l * 2 : 0;
102
- return e === "padding" ? s = /* @__PURE__ */ r((h) => n[h] * u + p, "shift") : e === "border" ? s = /* @__PURE__ */ r((h) => n[h] + i[h] *
103
- u + p, "shift") : e === "margin" && (s = /* @__PURE__ */ r((h) => n[h] + i[h] + o[h] * u + p, "shift")), t === "top" ? c = -s("top") : t ===
104
- "right" ? f = s("right") : t === "bottom" ? c = s("bottom") : t === "left" && (f = -s("left")), { offsetX: f, offsetY: c };
105
- }
106
- r(st, "offset");
94
+ function st(e, { padding: t, border: o, width: i, height: n, top: l, left: s }) {
95
+ let a = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom, c = s + o.left + t.left, p = l + o.top + t.top;
96
+ return e === "top" ? c += a / 2 : e === "right" ? (c += a, p += f / 2) : e === "bottom" ? (c += a / 2, p += f) : e === "left" ? p += f / 2 :
97
+ e === "center" && (c += a / 2, p += f / 2), { x: c, y: p };
98
+ }
99
+ r(st, "positionCoordinate");
100
+ function at(e, t, { margin: o, border: i, padding: n }, l, s) {
101
+ let a = /* @__PURE__ */ r((u) => 0, "shift"), f = 0, c = 0, p = s ? 1 : 0.5, d = s ? l * 2 : 0;
102
+ return e === "padding" ? a = /* @__PURE__ */ r((u) => n[u] * p + d, "shift") : e === "border" ? a = /* @__PURE__ */ r((u) => n[u] + i[u] *
103
+ p + d, "shift") : e === "margin" && (a = /* @__PURE__ */ r((u) => n[u] + i[u] + o[u] * p + d, "shift")), t === "top" ? c = -a("top") : t ===
104
+ "right" ? f = a("right") : t === "bottom" ? c = a("bottom") : t === "left" && (f = -a("left")), { offsetX: f, offsetY: c };
105
+ }
106
+ r(at, "offset");
107
107
  function ft(e, t) {
108
108
  return Math.abs(e.x - t.x) < Math.abs(e.w + t.w) / 2 && Math.abs(e.y - t.y) < Math.abs(e.h + t.h) / 2;
109
109
  }
@@ -113,10 +113,10 @@ function ct(e, t, o) {
113
113
  "left" && (t.x = o.x - o.w / 2 - b - t.w / 2), { x: t.x, y: t.y };
114
114
  }
115
115
  r(ct, "overlapAdjustment");
116
- function $(e, t, { x: o, y: i, w: n, h: l }, a) {
116
+ function $(e, t, { x: o, y: i, w: n, h: l }, s) {
117
117
  return X(e, { x: o, y: i, w: n, h: l, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle = w.text,
118
- e.fillText(a, o, i), X(e, { x: o, y: i, w: n, h: l, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle =
119
- w.text, e.fillText(a, o, i), { x: o, y: i, w: n, h: l };
118
+ e.fillText(s, o, i), X(e, { x: o, y: i, w: n, h: l, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle =
119
+ w.text, e.fillText(s, o, i), { x: o, y: i, w: n, h: l };
120
120
  }
121
121
  r($, "textWithRect");
122
122
  function N(e, t) {
@@ -125,44 +125,44 @@ function N(e, t) {
125
125
  return { w: n, h: l };
126
126
  }
127
127
  r(N, "configureText");
128
- function mt(e, t, { type: o, position: i = "center", text: n }, l, a = !1) {
129
- let { x: s, y: f } = at(i, t), { offsetX: c, offsetY: u } = st(o, i, t, b + 1, a);
130
- s += c, f += u;
131
- let { w: p, h } = N(e, n);
132
- if (l && ft({ x: s, y: f, w: p, h }, l)) {
133
- let S = ct(i, { x: s, y: f, w: p, h }, l);
134
- s = S.x, f = S.y;
128
+ function mt(e, t, { type: o, position: i = "center", text: n }, l, s = !1) {
129
+ let { x: a, y: f } = st(i, t), { offsetX: c, offsetY: p } = at(o, i, t, b + 1, s);
130
+ a += c, f += p;
131
+ let { w: d, h: u } = N(e, n);
132
+ if (l && ft({ x: a, y: f, w: d, h: u }, l)) {
133
+ let S = ct(i, { x: a, y: f, w: d, h: u }, l);
134
+ a = S.x, f = S.y;
135
135
  }
136
- return $(e, o, { x: s, y: f, w: p, h }, n);
136
+ return $(e, o, { x: a, y: f, w: d, h: u }, n);
137
137
  }
138
138
  r(mt, "drawLabel");
139
- function ut(e, { w: t, h: o }) {
139
+ function pt(e, { w: t, h: o }) {
140
140
  let i = t * 0.5 + b, n = o * 0.5 + b;
141
141
  return {
142
142
  offsetX: (e.x === "left" ? -1 : 1) * i,
143
143
  offsetY: (e.y === "top" ? -1 : 1) * n
144
144
  };
145
145
  }
146
- r(ut, "floatingOffset");
147
- function ht(e, t, { type: o, text: i }) {
148
- let { floatingAlignment: n, extremities: l } = t, a = l[n.x], s = l[n.y], { w: f, h: c } = N(e, i), { offsetX: u, offsetY: p } = ut(n, {
146
+ r(pt, "floatingOffset");
147
+ function ut(e, t, { type: o, text: i }) {
148
+ let { floatingAlignment: n, extremities: l } = t, s = l[n.x], a = l[n.y], { w: f, h: c } = N(e, i), { offsetX: p, offsetY: d } = pt(n, {
149
149
  w: f,
150
150
  h: c
151
151
  });
152
- return a += u, s += p, $(e, o, { x: a, y: s, w: f, h: c }, i);
152
+ return s += p, a += d, $(e, o, { x: s, y: a, w: f, h: c }, i);
153
153
  }
154
- r(ht, "drawFloatingLabel");
155
- function y(e, t, o, i) {
154
+ r(ut, "drawFloatingLabel");
155
+ function E(e, t, o, i) {
156
156
  let n = [];
157
- o.forEach((l, a) => {
158
- let s = i && l.position === "center" ? ht(e, t, l) : mt(e, t, l, n[a - 1], i);
159
- n[a] = s;
157
+ o.forEach((l, s) => {
158
+ let a = i && l.position === "center" ? ut(e, t, l) : mt(e, t, l, n[s - 1], i);
159
+ n[s] = a;
160
160
  });
161
161
  }
162
- r(y, "drawStack");
162
+ r(E, "drawStack");
163
163
  function O(e, t, o, i) {
164
- let n = o.reduce((l, a) => (Object.prototype.hasOwnProperty.call(l, a.position) || (l[a.position] = []), l[a.position]?.push(a), l), {});
165
- n.top && y(e, t, n.top, i), n.right && y(e, t, n.right, i), n.bottom && y(e, t, n.bottom, i), n.left && y(e, t, n.left, i), n.center && y(
164
+ let n = o.reduce((l, s) => (Object.prototype.hasOwnProperty.call(l, s.position) || (l[s.position] = []), l[s.position]?.push(s), l), {});
165
+ n.top && E(e, t, n.top, i), n.right && E(e, t, n.right, i), n.bottom && E(e, t, n.bottom, i), n.left && E(e, t, n.left, i), n.center && E(
166
166
  e, t, n.center, i);
167
167
  }
168
168
  r(O, "labelStacks");
@@ -174,19 +174,19 @@ var M = {
174
174
  padding: "#93c47d8c",
175
175
  content: "#6fa8dca8"
176
176
  }, I = 30;
177
- function d(e) {
177
+ function h(e) {
178
178
  return parseInt(e.replace("px", ""), 10);
179
179
  }
180
- r(d, "pxToNumber");
181
- function L(e) {
180
+ r(h, "pxToNumber");
181
+ function y(e) {
182
182
  return Number.isInteger(e) ? e : e.toFixed(2);
183
183
  }
184
- r(L, "round");
184
+ r(y, "round");
185
185
  function k(e) {
186
186
  return e.filter((t) => t.text !== 0 && t.text !== "0");
187
187
  }
188
188
  r(k, "filterZeroValues");
189
- function pt(e) {
189
+ function dt(e) {
190
190
  let t = {
191
191
  top: g.window.scrollY,
192
192
  bottom: g.window.scrollY + g.window.innerHeight,
@@ -203,14 +203,14 @@ function pt(e) {
203
203
  y: o.top > o.bottom ? "top" : "bottom"
204
204
  };
205
205
  }
206
- r(pt, "floatingAlignment");
207
- function dt(e) {
208
- let t = g.getComputedStyle(e), { top: o, left: i, right: n, bottom: l, width: a, height: s } = e.getBoundingClientRect(), {
206
+ r(dt, "floatingAlignment");
207
+ function ht(e) {
208
+ let t = g.getComputedStyle(e), { top: o, left: i, right: n, bottom: l, width: s, height: a } = e.getBoundingClientRect(), {
209
209
  marginTop: f,
210
210
  marginBottom: c,
211
- marginLeft: u,
212
- marginRight: p,
213
- paddingTop: h,
211
+ marginLeft: p,
212
+ marginRight: d,
213
+ paddingTop: u,
214
214
  paddingBottom: S,
215
215
  paddingLeft: K,
216
216
  paddingRight: Z,
@@ -220,85 +220,85 @@ function dt(e) {
220
220
  borderRightWidth: et
221
221
  } = t;
222
222
  o = o + g.window.scrollY, i = i + g.window.scrollX, l = l + g.window.scrollY, n = n + g.window.scrollX;
223
- let E = {
224
- top: d(f),
225
- bottom: d(c),
226
- left: d(u),
227
- right: d(p)
223
+ let L = {
224
+ top: h(f),
225
+ bottom: h(c),
226
+ left: h(p),
227
+ right: h(d)
228
228
  }, ot = {
229
- top: d(h),
230
- bottom: d(S),
231
- left: d(K),
232
- right: d(Z)
229
+ top: h(u),
230
+ bottom: h(S),
231
+ left: h(K),
232
+ right: h(Z)
233
233
  }, nt = {
234
- top: d(J),
235
- bottom: d(Q),
236
- left: d(tt),
237
- right: d(et)
234
+ top: h(J),
235
+ bottom: h(Q),
236
+ left: h(tt),
237
+ right: h(et)
238
238
  }, A = {
239
- top: o - E.top,
240
- bottom: l + E.bottom,
241
- left: i - E.left,
242
- right: n + E.right
239
+ top: o - L.top,
240
+ bottom: l + L.bottom,
241
+ left: i - L.left,
242
+ right: n + L.right
243
243
  };
244
244
  return {
245
- margin: E,
245
+ margin: L,
246
246
  padding: ot,
247
247
  border: nt,
248
248
  top: o,
249
249
  left: i,
250
250
  bottom: l,
251
251
  right: n,
252
- width: a,
253
- height: s,
252
+ width: s,
253
+ height: a,
254
254
  extremities: A,
255
- floatingAlignment: pt(A)
255
+ floatingAlignment: dt(A)
256
256
  };
257
257
  }
258
- r(dt, "measureElement");
259
- function gt(e, { margin: t, width: o, height: i, top: n, left: l, bottom: a, right: s }) {
258
+ r(ht, "measureElement");
259
+ function gt(e, { margin: t, width: o, height: i, top: n, left: l, bottom: s, right: a }) {
260
260
  let f = i + t.bottom + t.top;
261
- e.fillStyle = M.margin, e.fillRect(l, n - t.top, o, t.top), e.fillRect(s, n - t.top, t.right, f), e.fillRect(l, a, o, t.bottom), e.fillRect(
261
+ e.fillStyle = M.margin, e.fillRect(l, n - t.top, o, t.top), e.fillRect(a, n - t.top, t.right, f), e.fillRect(l, s, o, t.bottom), e.fillRect(
262
262
  l - t.left, n - t.top, t.left, f);
263
263
  let c = [
264
264
  {
265
265
  type: "margin",
266
- text: L(t.top),
266
+ text: y(t.top),
267
267
  position: "top"
268
268
  },
269
269
  {
270
270
  type: "margin",
271
- text: L(t.right),
271
+ text: y(t.right),
272
272
  position: "right"
273
273
  },
274
274
  {
275
275
  type: "margin",
276
- text: L(t.bottom),
276
+ text: y(t.bottom),
277
277
  position: "bottom"
278
278
  },
279
279
  {
280
280
  type: "margin",
281
- text: L(t.left),
281
+ text: y(t.left),
282
282
  position: "left"
283
283
  }
284
284
  ];
285
285
  return k(c);
286
286
  }
287
287
  r(gt, "drawMargin");
288
- function bt(e, { padding: t, border: o, width: i, height: n, top: l, left: a, bottom: s, right: f }) {
289
- let c = i - o.left - o.right, u = n - t.top - t.bottom - o.top - o.bottom;
290
- e.fillStyle = M.padding, e.fillRect(a + o.left, l + o.top, c, t.top), e.fillRect(
288
+ function bt(e, { padding: t, border: o, width: i, height: n, top: l, left: s, bottom: a, right: f }) {
289
+ let c = i - o.left - o.right, p = n - t.top - t.bottom - o.top - o.bottom;
290
+ e.fillStyle = M.padding, e.fillRect(s + o.left, l + o.top, c, t.top), e.fillRect(
291
291
  f - t.right - o.right,
292
292
  l + t.top + o.top,
293
293
  t.right,
294
- u
294
+ p
295
295
  ), e.fillRect(
296
- a + o.left,
297
- s - t.bottom - o.bottom,
296
+ s + o.left,
297
+ a - t.bottom - o.bottom,
298
298
  c,
299
299
  t.bottom
300
- ), e.fillRect(a + o.left, l + t.top + o.top, t.left, u);
301
- let p = [
300
+ ), e.fillRect(s + o.left, l + t.top + o.top, t.left, p);
301
+ let d = [
302
302
  {
303
303
  type: "padding",
304
304
  text: t.top,
@@ -320,13 +320,13 @@ function bt(e, { padding: t, border: o, width: i, height: n, top: l, left: a, bo
320
320
  position: "left"
321
321
  }
322
322
  ];
323
- return k(p);
323
+ return k(d);
324
324
  }
325
325
  r(bt, "drawPadding");
326
- function wt(e, { border: t, width: o, height: i, top: n, left: l, bottom: a, right: s }) {
326
+ function wt(e, { border: t, width: o, height: i, top: n, left: l, bottom: s, right: a }) {
327
327
  let f = i - t.top - t.bottom;
328
- e.fillStyle = M.border, e.fillRect(l, n, o, t.top), e.fillRect(l, a - t.bottom, o, t.bottom), e.fillRect(l, n + t.top, t.left, f), e.fillRect(
329
- s - t.right, n + t.top, t.right, f);
328
+ e.fillStyle = M.border, e.fillRect(l, n, o, t.top), e.fillRect(l, s - t.bottom, o, t.bottom), e.fillRect(l, n + t.top, t.left, f), e.fillRect(
329
+ a - t.right, n + t.top, t.right, f);
330
330
  let c = [
331
331
  {
332
332
  type: "border",
@@ -352,48 +352,48 @@ function wt(e, { border: t, width: o, height: i, top: n, left: l, bottom: a, rig
352
352
  return k(c);
353
353
  }
354
354
  r(wt, "drawBorder");
355
- function Lt(e, { padding: t, border: o, width: i, height: n, top: l, left: a }) {
356
- let s = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom;
355
+ function yt(e, { padding: t, border: o, width: i, height: n, top: l, left: s }) {
356
+ let a = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom;
357
357
  return e.fillStyle = M.content, e.fillRect(
358
- a + o.left + t.left,
358
+ s + o.left + t.left,
359
359
  l + o.top + t.top,
360
- s,
360
+ a,
361
361
  f
362
362
  ), [
363
363
  {
364
364
  type: "content",
365
365
  position: "center",
366
- text: `${L(s)} x ${L(f)}`
366
+ text: `${y(a)} x ${y(f)}`
367
367
  }
368
368
  ];
369
369
  }
370
- r(Lt, "drawContent");
371
- function Et(e) {
370
+ r(yt, "drawContent");
371
+ function Lt(e) {
372
372
  return (t) => {
373
373
  if (e && t) {
374
- let o = dt(e), i = gt(t, o), n = bt(t, o), l = wt(t, o), a = Lt(t, o), s = o.width <= I * 3 || o.height <= I;
374
+ let o = ht(e), i = gt(t, o), n = bt(t, o), l = wt(t, o), s = yt(t, o), a = o.width <= I * 3 || o.height <= I;
375
375
  O(
376
376
  t,
377
377
  o,
378
- [...a, ...n, ...l, ...i],
379
- s
378
+ [...s, ...n, ...l, ...i],
379
+ a
380
380
  );
381
381
  }
382
382
  };
383
383
  }
384
- r(Et, "drawBoxModel");
384
+ r(Lt, "drawBoxModel");
385
385
  function _(e) {
386
- Y(Et(e));
386
+ Y(Lt(e));
387
387
  }
388
388
  r(_, "drawSelectedElement");
389
389
 
390
390
  // src/measure/util.ts
391
- import { global as yt } from "@storybook/global";
391
+ import { global as Et } from "@storybook/global";
392
392
  var q = /* @__PURE__ */ r((e, t) => {
393
- let o = yt.document.elementFromPoint(e, t), i = /* @__PURE__ */ r((l) => {
393
+ let o = Et.document.elementFromPoint(e, t), i = /* @__PURE__ */ r((l) => {
394
394
  if (l && l.shadowRoot) {
395
- let a = l.shadowRoot.elementFromPoint(e, t);
396
- return l.isEqualNode(a) ? l : a.shadowRoot ? i(a) : a;
395
+ let s = l.shadowRoot.elementFromPoint(e, t);
396
+ return l.isEqualNode(s) ? l : s.shadowRoot ? i(s) : s;
397
397
  }
398
398
  return l;
399
399
  }, "crawlShadows");