storybook 9.1.0-alpha.0 → 9.1.0-alpha.10
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.
- package/assets/browser/favicon-wrapper.svg +46 -0
- package/assets/browser/favicon.svg +1 -1
- package/dist/actions/index.cjs +16 -16
- package/dist/actions/index.d.ts +1 -38
- package/dist/actions/index.js +12 -12
- package/dist/bin/index.cjs +62 -69
- package/dist/bin/index.js +43 -50
- package/dist/builder-manager/index.cjs +379 -378
- package/dist/builder-manager/index.d.ts +567 -2
- package/dist/builder-manager/index.js +280 -279
- package/dist/cli/bin/index.cjs +945 -945
- package/dist/cli/bin/index.js +673 -672
- package/dist/cli/index.cjs +14965 -14973
- package/dist/cli/index.d.ts +713 -15
- package/dist/cli/index.js +13488 -13495
- package/dist/common/index.cjs +11211 -11103
- package/dist/common/index.d.ts +351 -72
- package/dist/common/index.js +18491 -18379
- package/dist/components/index.cjs +4606 -4425
- package/dist/components/index.d.ts +11 -12
- package/dist/components/index.js +3020 -2834
- package/dist/controls/index.cjs +16 -16
- package/dist/controls/index.d.ts +1 -36
- package/dist/core-server/index.cjs +6690 -6624
- package/dist/core-server/index.d.ts +14 -2
- package/dist/core-server/index.js +6088 -6023
- package/dist/core-server/presets/common-manager.js +3582 -3475
- package/dist/core-server/presets/common-preset.cjs +85015 -5213
- package/dist/core-server/presets/common-preset.js +85107 -5291
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.cjs +28728 -0
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +28729 -0
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.cjs +29339 -0
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +29340 -0
- package/dist/csf/index.cjs +3019 -104
- package/dist/csf/index.d.ts +301 -18
- package/dist/csf/index.js +3031 -98
- package/dist/csf-tools/index.cjs +489 -488
- package/dist/csf-tools/index.js +311 -309
- package/dist/highlight/index.cjs +15 -15
- package/dist/highlight/index.d.ts +1 -12
- package/dist/highlight/index.js +4 -4
- package/dist/instrumenter/index.cjs +1308 -1239
- package/dist/instrumenter/index.d.ts +25 -3
- package/dist/instrumenter/index.js +1345 -1280
- package/dist/manager/globals-module-info.cjs +1 -1
- package/dist/manager/globals-module-info.js +1 -1
- package/dist/manager/globals-runtime.js +42257 -44665
- package/dist/manager/runtime.js +3715 -3536
- package/dist/manager-api/index.cjs +74 -74
- package/dist/manager-api/index.d.ts +4 -1
- package/dist/manager-api/index.js +142 -142
- package/dist/node-logger/index.cjs +8520 -994
- package/dist/node-logger/index.d.ts +395 -2
- package/dist/node-logger/index.js +8535 -995
- package/dist/preview/runtime.js +13701 -16331
- package/dist/preview-api/index.cjs +1434 -1458
- package/dist/preview-api/index.d.ts +13 -10
- package/dist/preview-api/index.js +950 -976
- package/dist/server-errors.cjs +201 -242
- package/dist/server-errors.d.ts +1 -12
- package/dist/server-errors.js +182 -223
- package/dist/telemetry/index.cjs +1919 -1638
- package/dist/telemetry/index.d.ts +4 -2
- package/dist/telemetry/index.js +1972 -1690
- package/dist/test/index.cjs +9184 -9816
- package/dist/test/index.d.ts +8 -1
- package/dist/test/index.js +8390 -9029
- package/dist/types/index.d.ts +19 -17
- package/dist/viewport/index.cjs +17 -24
- package/dist/viewport/index.d.ts +9 -532
- package/dist/viewport/index.js +9 -16
- package/package.json +18 -187
- package/templates/mocker-runtime.template.js +89 -0
- package/dist/actions/preview.cjs +0 -159
- package/dist/actions/preview.d.ts +0 -555
- package/dist/actions/preview.js +0 -149
- package/dist/backgrounds/index.cjs +0 -148
- package/dist/backgrounds/index.d.ts +0 -592
- package/dist/backgrounds/index.js +0 -130
- package/dist/backgrounds/preview.cjs +0 -143
- package/dist/backgrounds/preview.d.ts +0 -555
- package/dist/backgrounds/preview.js +0 -127
- package/dist/component-testing/index.cjs +0 -23
- package/dist/component-testing/index.d.ts +0 -3
- package/dist/component-testing/index.js +0 -5
- package/dist/component-testing/preview.cjs +0 -40
- package/dist/component-testing/preview.d.ts +0 -5
- package/dist/component-testing/preview.js +0 -25
- package/dist/controls/preview.cjs +0 -26
- package/dist/controls/preview.d.ts +0 -555
- package/dist/controls/preview.js +0 -9
- package/dist/highlight/preview.cjs +0 -590
- package/dist/highlight/preview.d.ts +0 -555
- package/dist/highlight/preview.js +0 -574
- package/dist/measure/index.cjs +0 -476
- package/dist/measure/index.d.ts +0 -567
- package/dist/measure/index.js +0 -464
- package/dist/measure/preview.cjs +0 -466
- package/dist/measure/preview.d.ts +0 -560
- package/dist/measure/preview.js +0 -450
- package/dist/outline/index.cjs +0 -528
- package/dist/outline/index.d.ts +0 -567
- package/dist/outline/index.js +0 -500
- package/dist/outline/preview.cjs +0 -518
- package/dist/outline/preview.d.ts +0 -560
- package/dist/outline/preview.js +0 -486
- package/dist/test/preview.cjs +0 -73
- package/dist/test/preview.d.ts +0 -555
- package/dist/test/preview.js +0 -66
- package/dist/viewport/preview.cjs +0 -35
- package/dist/viewport/preview.d.ts +0 -569
- package/dist/viewport/preview.js +0 -19
package/dist/measure/index.js
DELETED
|
@@ -1,464 +0,0 @@
|
|
|
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
|
-
};
|