storybook 9.0.0-alpha.9 → 9.0.0-beta.1

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 (140) hide show
  1. package/assets/docs/addon-backgrounds.gif +0 -0
  2. package/assets/docs/addon-controls-args-annotated.png +0 -0
  3. package/assets/docs/addon-controls-args-background-color.png +0 -0
  4. package/assets/docs/addon-controls-args-background-string.png +0 -0
  5. package/assets/docs/addon-controls-args-docs.png +0 -0
  6. package/assets/docs/addon-controls-args-logging.png +0 -0
  7. package/assets/docs/addon-controls-args-no-annotation.png +0 -0
  8. package/assets/docs/addon-controls-args-reflow-slider.png +0 -0
  9. package/assets/docs/addon-controls-args-reflow.png +0 -0
  10. package/assets/docs/addon-controls-args-template.png +0 -0
  11. package/assets/docs/addon-controls-expanded.png +0 -0
  12. package/assets/docs/addon-controls-hero.gif +0 -0
  13. package/assets/docs/addon-controls-install.png +0 -0
  14. package/assets/docs/hero.gif +0 -0
  15. package/assets/docs/highlight.png +0 -0
  16. package/assets/docs/viewport.png +0 -0
  17. package/assets/server/base-preview-head.html +1 -3
  18. package/bin/index.cjs +2 -2
  19. package/dist/actions/decorator.js +67 -72
  20. package/dist/actions/index.cjs +27 -31
  21. package/dist/actions/index.d.ts +0 -3
  22. package/dist/actions/index.js +27 -31
  23. package/dist/actions/preview.cjs +23 -27
  24. package/dist/actions/preview.d.ts +0 -1
  25. package/dist/actions/preview.js +19 -23
  26. package/dist/babel/index.cjs +822 -816
  27. package/dist/babel/index.js +822 -816
  28. package/dist/backgrounds/index.cjs +148 -0
  29. package/dist/backgrounds/index.d.ts +91 -0
  30. package/dist/backgrounds/index.js +130 -0
  31. package/dist/backgrounds/preview.cjs +143 -0
  32. package/dist/backgrounds/preview.d.ts +54 -0
  33. package/dist/backgrounds/preview.js +127 -0
  34. package/dist/bin/index.cjs +73 -92
  35. package/dist/bin/index.js +66 -85
  36. package/dist/builder-manager/index.cjs +316 -296
  37. package/dist/builder-manager/index.js +567 -547
  38. package/dist/channels/index.cjs +1020 -950
  39. package/dist/channels/index.js +1256 -1201
  40. package/dist/cli/bin/index.cjs +198 -198
  41. package/dist/cli/bin/index.js +204 -204
  42. package/dist/cli/index.cjs +61735 -7589
  43. package/dist/cli/index.d.ts +24 -20
  44. package/dist/cli/index.js +61776 -7630
  45. package/dist/common/index.cjs +16133 -9095
  46. package/dist/common/index.d.ts +32 -24
  47. package/dist/common/index.js +16227 -9183
  48. package/dist/component-testing/index.cjs +23 -0
  49. package/dist/component-testing/index.d.ts +3 -0
  50. package/dist/component-testing/index.js +5 -0
  51. package/dist/component-testing/preview.cjs +40 -0
  52. package/dist/component-testing/preview.d.ts +5 -0
  53. package/dist/component-testing/preview.js +25 -0
  54. package/dist/components/index.cjs +6479 -13005
  55. package/dist/components/index.d.ts +8 -257
  56. package/dist/components/index.js +6160 -18689
  57. package/dist/controls/decorator.d.ts +5 -0
  58. package/dist/controls/decorator.js +8 -0
  59. package/dist/controls/index.cjs +26 -0
  60. package/dist/controls/index.d.ts +39 -0
  61. package/dist/controls/index.js +6 -0
  62. package/dist/controls/preview.cjs +26 -0
  63. package/dist/controls/preview.d.ts +54 -0
  64. package/dist/controls/preview.js +9 -0
  65. package/dist/core-events/index.cjs +91 -106
  66. package/dist/core-events/index.d.ts +2 -80
  67. package/dist/core-events/index.js +79 -94
  68. package/dist/core-server/index.cjs +12409 -12231
  69. package/dist/core-server/index.d.ts +32 -23
  70. package/dist/core-server/index.js +12567 -12389
  71. package/dist/core-server/presets/common-manager.css +170 -0
  72. package/dist/core-server/presets/common-manager.js +12153 -12
  73. package/dist/core-server/presets/common-preset.cjs +3004 -3151
  74. package/dist/core-server/presets/common-preset.js +2833 -2981
  75. package/dist/csf/index.d.ts +1 -3
  76. package/dist/csf-tools/index.cjs +412 -403
  77. package/dist/csf-tools/index.d.ts +0 -4
  78. package/dist/csf-tools/index.js +410 -401
  79. package/dist/docs-tools/index.cjs +2569 -575
  80. package/dist/docs-tools/index.js +2565 -564
  81. package/dist/highlight/index.cjs +27 -0
  82. package/dist/highlight/index.d.ts +61 -0
  83. package/dist/highlight/index.js +7 -0
  84. package/dist/highlight/preview.cjs +535 -0
  85. package/dist/highlight/preview.d.ts +54 -0
  86. package/dist/highlight/preview.js +519 -0
  87. package/dist/instrumenter/index.cjs +1411 -1758
  88. package/dist/instrumenter/index.d.ts +8 -7
  89. package/dist/instrumenter/index.js +1325 -1663
  90. package/dist/manager/globals-module-info.cjs +22 -33
  91. package/dist/manager/globals-module-info.js +7 -18
  92. package/dist/manager/globals-runtime.js +45452 -49541
  93. package/dist/manager/runtime.js +4392 -3774
  94. package/dist/manager-api/index.cjs +2622 -2529
  95. package/dist/manager-api/index.d.ts +109 -114
  96. package/dist/manager-api/index.js +2603 -2475
  97. package/dist/manager-errors.js +41 -37
  98. package/dist/measure/index.cjs +476 -0
  99. package/dist/measure/index.d.ts +66 -0
  100. package/dist/measure/index.js +464 -0
  101. package/dist/measure/preview.cjs +466 -0
  102. package/dist/measure/preview.d.ts +59 -0
  103. package/dist/measure/preview.js +450 -0
  104. package/dist/outline/index.cjs +528 -0
  105. package/dist/outline/index.d.ts +66 -0
  106. package/dist/outline/index.js +500 -0
  107. package/dist/outline/preview.cjs +518 -0
  108. package/dist/outline/preview.d.ts +59 -0
  109. package/dist/outline/preview.js +486 -0
  110. package/dist/preview/runtime.js +41973 -38159
  111. package/dist/preview-api/index.cjs +1204 -1293
  112. package/dist/preview-api/index.d.ts +126 -178
  113. package/dist/preview-api/index.js +1614 -1685
  114. package/dist/preview-errors.cjs +65 -51
  115. package/dist/preview-errors.d.ts +6 -2
  116. package/dist/preview-errors.js +176 -142
  117. package/dist/server-errors.cjs +160 -113
  118. package/dist/server-errors.d.ts +12 -2
  119. package/dist/server-errors.js +157 -110
  120. package/dist/telemetry/index.cjs +374 -370
  121. package/dist/telemetry/index.d.ts +1 -1
  122. package/dist/telemetry/index.js +460 -456
  123. package/dist/test/index.cjs +1553 -1552
  124. package/dist/test/index.js +9603 -9514
  125. package/dist/test/preview.cjs +1906 -1905
  126. package/dist/test/preview.d.ts +0 -6
  127. package/dist/test/preview.js +3664 -3603
  128. package/dist/test/spy.cjs +65 -64
  129. package/dist/test/spy.js +59 -58
  130. package/dist/types/index.cjs +11 -12
  131. package/dist/types/index.d.ts +601 -334
  132. package/dist/types/index.js +1 -2
  133. package/dist/viewport/index.cjs +310 -0
  134. package/dist/viewport/index.d.ts +320 -0
  135. package/dist/viewport/index.js +290 -0
  136. package/dist/viewport/preview.cjs +35 -0
  137. package/dist/viewport/preview.d.ts +68 -0
  138. package/dist/viewport/preview.js +19 -0
  139. package/package.json +207 -12
  140. package/dist/actions/manager.js +0 -1196
@@ -0,0 +1,464 @@
1
+ var H = Object.defineProperty;
2
+ var l = (e, t) => H(e, "name", { value: t, configurable: !0 });
3
+ var st = (e, t) => {
4
+ for (var o in t)
5
+ H(e, o, { get: t[o], enumerable: !0 });
6
+ };
7
+
8
+ // src/measure/index.ts
9
+ import { definePreview as Tt } from "storybook/preview-api";
10
+
11
+ // src/measure/preview.ts
12
+ var P = {};
13
+ st(P, {
14
+ decorators: () => Q,
15
+ default: () => xt,
16
+ initialGlobals: () => J
17
+ });
18
+ import { definePreview as Mt } from "storybook/preview-api";
19
+
20
+ // src/measure/constants.ts
21
+ var C = "storybook/measure-addon", kt = `${C}/tool`, F = "measureEnabled", Pt = {
22
+ RESULT: `${C}/result`,
23
+ REQUEST: `${C}/request`,
24
+ CLEAR: `${C}/clear`
25
+ };
26
+
27
+ // src/measure/withMeasure.ts
28
+ import { useEffect as U } from "storybook/preview-api";
29
+
30
+ // src/measure/box-model/canvas.ts
31
+ import { global as R } from "@storybook/global";
32
+
33
+ // ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
34
+ var ft = !1, T = "Invariant failed";
35
+ function v(e, t) {
36
+ if (!e) {
37
+ if (ft)
38
+ throw new Error(T);
39
+ var o = typeof t == "function" ? t() : t, i = o ? "".concat(T, ": ").concat(o) : T;
40
+ throw new Error(i);
41
+ }
42
+ }
43
+ l(v, "invariant");
44
+
45
+ // src/measure/box-model/canvas.ts
46
+ function W() {
47
+ let e = R.document.documentElement, t = Math.max(e.scrollHeight, e.offsetHeight);
48
+ return { width: Math.max(e.scrollWidth, e.offsetWidth), height: t };
49
+ }
50
+ l(W, "getDocumentWidthAndHeight");
51
+ function ct() {
52
+ let e = R.document.createElement("canvas");
53
+ e.id = "storybook-addon-measure";
54
+ let t = e.getContext("2d");
55
+ v(t != null);
56
+ let { width: o, height: i } = W();
57
+ return D(e, t, { width: o, height: i }), e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.zIndex = "214748364\
58
+ 7", e.style.pointerEvents = "none", R.document.body.appendChild(e), { canvas: e, context: t, width: o, height: i };
59
+ }
60
+ l(ct, "createCanvas");
61
+ function D(e, t, { width: o, height: i }) {
62
+ e.style.width = `${o}px`, e.style.height = `${i}px`;
63
+ let n = R.window.devicePixelRatio;
64
+ e.width = Math.floor(o * n), e.height = Math.floor(i * n), t.scale(n, n);
65
+ }
66
+ l(D, "setCanvasWidthAndHeight");
67
+ var m = {};
68
+ function Y() {
69
+ m.canvas || (m = ct());
70
+ }
71
+ l(Y, "init");
72
+ function B() {
73
+ m.context && m.context.clearRect(0, 0, m.width ?? 0, m.height ?? 0);
74
+ }
75
+ l(B, "clear");
76
+ function z(e) {
77
+ B(), e(m.context);
78
+ }
79
+ l(z, "draw");
80
+ function X() {
81
+ v(m.canvas, "Canvas should exist in the state."), v(m.context, "Context should exist in the state."), D(m.canvas, m.context, { width: 0, height: 0 });
82
+ let { width: e, height: t } = W();
83
+ D(m.canvas, m.context, { width: e, height: t }), m.width = e, m.height = t;
84
+ }
85
+ l(X, "rescale");
86
+ function $() {
87
+ m.canvas && (B(), m.canvas.parentNode?.removeChild(m.canvas), m = {});
88
+ }
89
+ l($, "destroy");
90
+
91
+ // src/measure/box-model/visualizer.ts
92
+ import { global as b } from "@storybook/global";
93
+
94
+ // src/measure/box-model/labels.ts
95
+ var w = {
96
+ margin: "#f6b26b",
97
+ border: "#ffe599",
98
+ padding: "#93c47d",
99
+ content: "#6fa8dc",
100
+ text: "#232020"
101
+ }, g = 6;
102
+ function N(e, { x: t, y: o, w: i, h: n, r }) {
103
+ t = t - i / 2, o = o - n / 2, i < 2 * r && (r = i / 2), n < 2 * r && (r = n / 2), e.beginPath(), e.moveTo(t + r, o), e.arcTo(t + i, o, t +
104
+ i, o + n, r), e.arcTo(t + i, o + n, t, o + n, r), e.arcTo(t, o + n, t, o, r), e.arcTo(t, o, t + i, o, r), e.closePath();
105
+ }
106
+ l(N, "roundedRect");
107
+ function mt(e, { padding: t, border: o, width: i, height: n, top: r, left: a }) {
108
+ 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 = r + o.top + t.top;
109
+ 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 :
110
+ e === "center" && (c += s / 2, u += f / 2), { x: c, y: u };
111
+ }
112
+ l(mt, "positionCoordinate");
113
+ function ut(e, t, { margin: o, border: i, padding: n }, r, a) {
114
+ let s = /* @__PURE__ */ l((d) => 0, "shift"), f = 0, c = 0, u = a ? 1 : 0.5, h = a ? r * 2 : 0;
115
+ return e === "padding" ? s = /* @__PURE__ */ l((d) => n[d] * u + h, "shift") : e === "border" ? s = /* @__PURE__ */ l((d) => n[d] + i[d] *
116
+ u + h, "shift") : e === "margin" && (s = /* @__PURE__ */ l((d) => n[d] + i[d] + o[d] * u + h, "shift")), t === "top" ? c = -s("top") : t ===
117
+ "right" ? f = s("right") : t === "bottom" ? c = s("bottom") : t === "left" && (f = -s("left")), { offsetX: f, offsetY: c };
118
+ }
119
+ l(ut, "offset");
120
+ function dt(e, t) {
121
+ 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;
122
+ }
123
+ l(dt, "collide");
124
+ function ht(e, t, o) {
125
+ return e === "top" ? t.y = o.y - o.h - g : e === "right" ? t.x = o.x + o.w / 2 + g + t.w / 2 : e === "bottom" ? t.y = o.y + o.h + g : e ===
126
+ "left" && (t.x = o.x - o.w / 2 - g - t.w / 2), { x: t.x, y: t.y };
127
+ }
128
+ l(ht, "overlapAdjustment");
129
+ function O(e, t, { x: o, y: i, w: n, h: r }, a) {
130
+ return N(e, { x: o, y: i, w: n, h: r, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle = w.text,
131
+ e.fillText(a, o, i), N(e, { x: o, y: i, w: n, h: r, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle =
132
+ w.text, e.fillText(a, o, i), { x: o, y: i, w: n, h: r };
133
+ }
134
+ l(O, "textWithRect");
135
+ function I(e, t) {
136
+ e.font = "600 12px monospace", e.textBaseline = "middle", e.textAlign = "center";
137
+ let o = e.measureText(t), i = o.actualBoundingBoxAscent + o.actualBoundingBoxDescent, n = o.width + g * 2, r = i + g * 2;
138
+ return { w: n, h: r };
139
+ }
140
+ l(I, "configureText");
141
+ function pt(e, t, { type: o, position: i = "center", text: n }, r, a = !1) {
142
+ let { x: s, y: f } = mt(i, t), { offsetX: c, offsetY: u } = ut(o, i, t, g + 1, a);
143
+ s += c, f += u;
144
+ let { w: h, h: d } = I(e, n);
145
+ if (r && dt({ x: s, y: f, w: h, h: d }, r)) {
146
+ let S = ht(i, { x: s, y: f, w: h, h: d }, r);
147
+ s = S.x, f = S.y;
148
+ }
149
+ return O(e, o, { x: s, y: f, w: h, h: d }, n);
150
+ }
151
+ l(pt, "drawLabel");
152
+ function bt(e, { w: t, h: o }) {
153
+ let i = t * 0.5 + g, n = o * 0.5 + g;
154
+ return {
155
+ offsetX: (e.x === "left" ? -1 : 1) * i,
156
+ offsetY: (e.y === "top" ? -1 : 1) * n
157
+ };
158
+ }
159
+ l(bt, "floatingOffset");
160
+ function gt(e, t, { type: o, text: i }) {
161
+ let { floatingAlignment: n, extremities: r } = t, a = r[n.x], s = r[n.y], { w: f, h: c } = I(e, i), { offsetX: u, offsetY: h } = bt(n, {
162
+ w: f,
163
+ h: c
164
+ });
165
+ return a += u, s += h, O(e, o, { x: a, y: s, w: f, h: c }, i);
166
+ }
167
+ l(gt, "drawFloatingLabel");
168
+ function y(e, t, o, i) {
169
+ let n = [];
170
+ o.forEach((r, a) => {
171
+ let s = i && r.position === "center" ? gt(e, t, r) : pt(e, t, r, n[a - 1], i);
172
+ n[a] = s;
173
+ });
174
+ }
175
+ l(y, "drawStack");
176
+ function _(e, t, o, i) {
177
+ let n = o.reduce((r, a) => (Object.prototype.hasOwnProperty.call(r, a.position) || (r[a.position] = []), r[a.position]?.push(a), r), {});
178
+ 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(
179
+ e, t, n.center, i);
180
+ }
181
+ l(_, "labelStacks");
182
+
183
+ // src/measure/box-model/visualizer.ts
184
+ var M = {
185
+ margin: "#f6b26ba8",
186
+ border: "#ffe599a8",
187
+ padding: "#93c47d8c",
188
+ content: "#6fa8dca8"
189
+ }, q = 30;
190
+ function p(e) {
191
+ return parseInt(e.replace("px", ""), 10);
192
+ }
193
+ l(p, "pxToNumber");
194
+ function L(e) {
195
+ return Number.isInteger(e) ? e : e.toFixed(2);
196
+ }
197
+ l(L, "round");
198
+ function k(e) {
199
+ return e.filter((t) => t.text !== 0 && t.text !== "0");
200
+ }
201
+ l(k, "filterZeroValues");
202
+ function wt(e) {
203
+ let t = {
204
+ top: b.window.scrollY,
205
+ bottom: b.window.scrollY + b.window.innerHeight,
206
+ left: b.window.scrollX,
207
+ right: b.window.scrollX + b.window.innerWidth
208
+ }, o = {
209
+ top: Math.abs(t.top - e.top),
210
+ bottom: Math.abs(t.bottom - e.bottom),
211
+ left: Math.abs(t.left - e.left),
212
+ right: Math.abs(t.right - e.right)
213
+ };
214
+ return {
215
+ x: o.left > o.right ? "left" : "right",
216
+ y: o.top > o.bottom ? "top" : "bottom"
217
+ };
218
+ }
219
+ l(wt, "floatingAlignment");
220
+ function Lt(e) {
221
+ let t = b.getComputedStyle(e), { top: o, left: i, right: n, bottom: r, width: a, height: s } = e.getBoundingClientRect(), {
222
+ marginTop: f,
223
+ marginBottom: c,
224
+ marginLeft: u,
225
+ marginRight: h,
226
+ paddingTop: d,
227
+ paddingBottom: S,
228
+ paddingLeft: tt,
229
+ paddingRight: et,
230
+ borderBottomWidth: ot,
231
+ borderTopWidth: nt,
232
+ borderLeftWidth: it,
233
+ borderRightWidth: rt
234
+ } = t;
235
+ o = o + b.window.scrollY, i = i + b.window.scrollX, r = r + b.window.scrollY, n = n + b.window.scrollX;
236
+ let E = {
237
+ top: p(f),
238
+ bottom: p(c),
239
+ left: p(u),
240
+ right: p(h)
241
+ }, lt = {
242
+ top: p(d),
243
+ bottom: p(S),
244
+ left: p(tt),
245
+ right: p(et)
246
+ }, at = {
247
+ top: p(nt),
248
+ bottom: p(ot),
249
+ left: p(it),
250
+ right: p(rt)
251
+ }, A = {
252
+ top: o - E.top,
253
+ bottom: r + E.bottom,
254
+ left: i - E.left,
255
+ right: n + E.right
256
+ };
257
+ return {
258
+ margin: E,
259
+ padding: lt,
260
+ border: at,
261
+ top: o,
262
+ left: i,
263
+ bottom: r,
264
+ right: n,
265
+ width: a,
266
+ height: s,
267
+ extremities: A,
268
+ floatingAlignment: wt(A)
269
+ };
270
+ }
271
+ l(Lt, "measureElement");
272
+ function Et(e, { margin: t, width: o, height: i, top: n, left: r, bottom: a, right: s }) {
273
+ let f = i + t.bottom + t.top;
274
+ e.fillStyle = M.margin, e.fillRect(r, n - t.top, o, t.top), e.fillRect(s, n - t.top, t.right, f), e.fillRect(r, a, o, t.bottom), e.fillRect(
275
+ r - t.left, n - t.top, t.left, f);
276
+ let c = [
277
+ {
278
+ type: "margin",
279
+ text: L(t.top),
280
+ position: "top"
281
+ },
282
+ {
283
+ type: "margin",
284
+ text: L(t.right),
285
+ position: "right"
286
+ },
287
+ {
288
+ type: "margin",
289
+ text: L(t.bottom),
290
+ position: "bottom"
291
+ },
292
+ {
293
+ type: "margin",
294
+ text: L(t.left),
295
+ position: "left"
296
+ }
297
+ ];
298
+ return k(c);
299
+ }
300
+ l(Et, "drawMargin");
301
+ function yt(e, { padding: t, border: o, width: i, height: n, top: r, left: a, bottom: s, right: f }) {
302
+ let c = i - o.left - o.right, u = n - t.top - t.bottom - o.top - o.bottom;
303
+ e.fillStyle = M.padding, e.fillRect(a + o.left, r + o.top, c, t.top), e.fillRect(
304
+ f - t.right - o.right,
305
+ r + t.top + o.top,
306
+ t.right,
307
+ u
308
+ ), e.fillRect(
309
+ a + o.left,
310
+ s - t.bottom - o.bottom,
311
+ c,
312
+ t.bottom
313
+ ), e.fillRect(a + o.left, r + t.top + o.top, t.left, u);
314
+ let h = [
315
+ {
316
+ type: "padding",
317
+ text: t.top,
318
+ position: "top"
319
+ },
320
+ {
321
+ type: "padding",
322
+ text: t.right,
323
+ position: "right"
324
+ },
325
+ {
326
+ type: "padding",
327
+ text: t.bottom,
328
+ position: "bottom"
329
+ },
330
+ {
331
+ type: "padding",
332
+ text: t.left,
333
+ position: "left"
334
+ }
335
+ ];
336
+ return k(h);
337
+ }
338
+ l(yt, "drawPadding");
339
+ function St(e, { border: t, width: o, height: i, top: n, left: r, bottom: a, right: s }) {
340
+ let f = i - t.top - t.bottom;
341
+ e.fillStyle = M.border, e.fillRect(r, n, o, t.top), e.fillRect(r, a - t.bottom, o, t.bottom), e.fillRect(r, n + t.top, t.left, f), e.fillRect(
342
+ s - t.right, n + t.top, t.right, f);
343
+ let c = [
344
+ {
345
+ type: "border",
346
+ text: t.top,
347
+ position: "top"
348
+ },
349
+ {
350
+ type: "border",
351
+ text: t.right,
352
+ position: "right"
353
+ },
354
+ {
355
+ type: "border",
356
+ text: t.bottom,
357
+ position: "bottom"
358
+ },
359
+ {
360
+ type: "border",
361
+ text: t.left,
362
+ position: "left"
363
+ }
364
+ ];
365
+ return k(c);
366
+ }
367
+ l(St, "drawBorder");
368
+ function Ct(e, { padding: t, border: o, width: i, height: n, top: r, left: a }) {
369
+ let s = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom;
370
+ return e.fillStyle = M.content, e.fillRect(
371
+ a + o.left + t.left,
372
+ r + o.top + t.top,
373
+ s,
374
+ f
375
+ ), [
376
+ {
377
+ type: "content",
378
+ position: "center",
379
+ text: `${L(s)} x ${L(f)}`
380
+ }
381
+ ];
382
+ }
383
+ l(Ct, "drawContent");
384
+ function vt(e) {
385
+ return (t) => {
386
+ if (e && t) {
387
+ let o = Lt(e), i = Et(t, o), n = yt(t, o), r = St(t, o), a = Ct(t, o), s = o.width <= q * 3 || o.height <= q;
388
+ _(
389
+ t,
390
+ o,
391
+ [...a, ...n, ...r, ...i],
392
+ s
393
+ );
394
+ }
395
+ };
396
+ }
397
+ l(vt, "drawBoxModel");
398
+ function j(e) {
399
+ z(vt(e));
400
+ }
401
+ l(j, "drawSelectedElement");
402
+
403
+ // src/measure/util.ts
404
+ import { global as Rt } from "@storybook/global";
405
+ var G = /* @__PURE__ */ l((e, t) => {
406
+ let o = Rt.document.elementFromPoint(e, t), i = /* @__PURE__ */ l((r) => {
407
+ if (r && r.shadowRoot) {
408
+ let a = r.shadowRoot.elementFromPoint(e, t);
409
+ return r.isEqualNode(a) ? r : a.shadowRoot ? i(a) : a;
410
+ }
411
+ return r;
412
+ }, "crawlShadows");
413
+ return i(o) || o;
414
+ }, "deepElementFromPoint");
415
+
416
+ // src/measure/withMeasure.ts
417
+ var V, x = { x: 0, y: 0 };
418
+ function K(e, t) {
419
+ V = G(e, t), j(V);
420
+ }
421
+ l(K, "findAndDrawElement");
422
+ var Z = /* @__PURE__ */ l((e, t) => {
423
+ let { measureEnabled: o } = t.globals || {};
424
+ return U(() => {
425
+ if (typeof globalThis.document > "u")
426
+ return;
427
+ let i = /* @__PURE__ */ l((n) => {
428
+ window.requestAnimationFrame(() => {
429
+ n.stopPropagation(), x.x = n.clientX, x.y = n.clientY;
430
+ });
431
+ }, "onPointerMove");
432
+ return globalThis.document.addEventListener("pointermove", i), () => {
433
+ globalThis.document.removeEventListener("pointermove", i);
434
+ };
435
+ }, []), U(() => {
436
+ let i = /* @__PURE__ */ l((r) => {
437
+ window.requestAnimationFrame(() => {
438
+ r.stopPropagation(), K(r.clientX, r.clientY);
439
+ });
440
+ }, "onPointerOver"), n = /* @__PURE__ */ l(() => {
441
+ window.requestAnimationFrame(() => {
442
+ X();
443
+ });
444
+ }, "onResize");
445
+ return t.viewMode === "story" && o && (globalThis.document.addEventListener("pointerover", i), Y(), globalThis.window.addEventListener("\
446
+ resize", n), K(x.x, x.y)), () => {
447
+ globalThis.window.removeEventListener("resize", n), $();
448
+ };
449
+ }, [o, t.viewMode]), e();
450
+ }, "withMeasure");
451
+
452
+ // src/measure/preview.ts
453
+ var Q = globalThis.FEATURES?.measure ? [Z] : [], J = {
454
+ [F]: !1
455
+ }, xt = /* @__PURE__ */ l(() => Mt({
456
+ decorators: Q,
457
+ initialGlobals: J
458
+ }), "default");
459
+
460
+ // src/measure/index.ts
461
+ var le = /* @__PURE__ */ l(() => Tt(P), "default");
462
+ export {
463
+ le as default
464
+ };