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