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.
- package/assets/docs/addon-backgrounds.gif +0 -0
- package/assets/docs/highlight.png +0 -0
- package/dist/actions/decorator.js +46 -47
- package/dist/actions/index.cjs +28 -29
- package/dist/actions/index.d.ts +0 -3
- package/dist/actions/index.js +27 -28
- package/dist/actions/preview.cjs +22 -23
- package/dist/actions/preview.js +18 -19
- package/dist/backgrounds/index.cjs +148 -0
- package/dist/backgrounds/index.d.ts +91 -0
- package/dist/backgrounds/index.js +130 -0
- package/dist/backgrounds/preview.cjs +143 -0
- package/dist/backgrounds/preview.d.ts +54 -0
- package/dist/backgrounds/preview.js +127 -0
- package/dist/bin/index.cjs +62 -73
- package/dist/bin/index.js +57 -68
- package/dist/builder-manager/index.cjs +390 -380
- package/dist/builder-manager/index.js +489 -479
- package/dist/channels/index.cjs +1018 -948
- package/dist/channels/index.js +1194 -1161
- package/dist/cli/bin/index.cjs +225 -225
- package/dist/cli/bin/index.js +234 -234
- package/dist/cli/index.cjs +1860 -1873
- package/dist/cli/index.js +308 -321
- package/dist/common/index.cjs +2396 -2380
- package/dist/common/index.d.ts +0 -11
- package/dist/common/index.js +2604 -2588
- package/dist/components/index.cjs +6393 -12704
- package/dist/components/index.d.ts +1 -2
- package/dist/components/index.js +4665 -10778
- package/dist/core-events/index.cjs +72 -84
- package/dist/core-events/index.d.ts +2 -77
- package/dist/core-events/index.js +61 -73
- package/dist/core-server/index.cjs +13484 -13318
- package/dist/core-server/index.js +13652 -13486
- package/dist/core-server/presets/common-manager.js +9815 -12
- package/dist/core-server/presets/common-preset.cjs +2809 -3005
- package/dist/core-server/presets/common-preset.js +2891 -3087
- package/dist/docs-tools/index.cjs +626 -600
- package/dist/docs-tools/index.js +613 -587
- package/dist/highlight/index.cjs +27 -0
- package/dist/highlight/index.d.ts +17 -0
- package/dist/highlight/index.js +7 -0
- package/dist/highlight/preview.cjs +81 -0
- package/dist/highlight/preview.d.ts +54 -0
- package/dist/highlight/preview.js +67 -0
- package/dist/instrumenter/index.cjs +70 -60
- package/dist/instrumenter/index.d.ts +8 -7
- package/dist/instrumenter/index.js +98 -88
- package/dist/manager/globals-module-info.cjs +12 -22
- package/dist/manager/globals-module-info.js +2 -12
- package/dist/manager/globals-runtime.js +31295 -33999
- package/dist/manager/runtime.js +3419 -3522
- package/dist/manager-api/index.cjs +2521 -2445
- package/dist/manager-api/index.d.ts +7 -21
- package/dist/manager-api/index.js +2431 -2349
- package/dist/measure/index.cjs +474 -0
- package/dist/measure/index.d.ts +66 -0
- package/dist/measure/index.js +462 -0
- package/dist/measure/preview.cjs +464 -0
- package/dist/measure/preview.d.ts +59 -0
- package/dist/measure/preview.js +448 -0
- package/dist/outline/index.cjs +528 -0
- package/dist/outline/index.d.ts +66 -0
- package/dist/outline/index.js +500 -0
- package/dist/outline/preview.cjs +518 -0
- package/dist/outline/preview.d.ts +59 -0
- package/dist/outline/preview.js +486 -0
- package/dist/preview/runtime.js +20735 -17220
- package/dist/preview-api/index.cjs +1069 -1057
- package/dist/preview-api/index.d.ts +384 -157
- package/dist/preview-api/index.js +1123 -1109
- package/dist/server-errors.cjs +66 -67
- package/dist/server-errors.d.ts +0 -1
- package/dist/server-errors.js +68 -69
- package/dist/test/index.cjs +1547 -1546
- package/dist/test/index.js +2308 -2307
- package/dist/test/preview.cjs +1906 -1905
- package/dist/test/preview.js +1439 -1438
- package/dist/test/spy.cjs +65 -64
- package/dist/test/spy.js +59 -58
- package/dist/types/index.cjs +10 -10
- package/dist/types/index.d.ts +203 -243
- package/package.json +122 -17
- package/dist/actions/manager.js +0 -1195
- package/dist/component-testing/manager.js +0 -3126
- package/dist/controls/manager.js +0 -5593
- package/dist/viewport/manager.js +0 -400
- /package/dist/{component-testing/manager.css → core-server/presets/common-manager.css} +0 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var v = Object.defineProperty;
|
|
3
|
+
var ft = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var ct = Object.getOwnPropertyNames;
|
|
5
|
+
var mt = Object.prototype.hasOwnProperty;
|
|
6
|
+
var l = (e, t) => v(e, "name", { value: t, configurable: !0 });
|
|
7
|
+
var ut = (e, t) => {
|
|
8
|
+
for (var o in t)
|
|
9
|
+
v(e, o, { get: t[o], enumerable: !0 });
|
|
10
|
+
}, dt = (e, t, o, i) => {
|
|
11
|
+
if (t && typeof t == "object" || typeof t == "function")
|
|
12
|
+
for (let n of ct(t))
|
|
13
|
+
!mt.call(e, n) && n !== o && v(e, n, { get: () => t[n], enumerable: !(i = ft(t, n)) || i.enumerable });
|
|
14
|
+
return e;
|
|
15
|
+
};
|
|
16
|
+
var ht = (e) => dt(v({}, "__esModule", { value: !0 }), e);
|
|
17
|
+
|
|
18
|
+
// src/measure/preview.ts
|
|
19
|
+
var At = {};
|
|
20
|
+
ut(At, {
|
|
21
|
+
decorators: () => J,
|
|
22
|
+
default: () => Pt,
|
|
23
|
+
initialGlobals: () => tt
|
|
24
|
+
});
|
|
25
|
+
module.exports = ht(At);
|
|
26
|
+
var Q = require("storybook/preview-api");
|
|
27
|
+
|
|
28
|
+
// src/measure/constants.ts
|
|
29
|
+
var R = "storybook/measure-addon", Wt = `${R}/tool`, W = "measureEnabled", Ft = {
|
|
30
|
+
RESULT: `${R}/result`,
|
|
31
|
+
REQUEST: `${R}/request`,
|
|
32
|
+
CLEAR: `${R}/clear`
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// src/measure/withMeasure.ts
|
|
36
|
+
var A = require("storybook/preview-api");
|
|
37
|
+
|
|
38
|
+
// src/measure/box-model/canvas.ts
|
|
39
|
+
var y = require("@storybook/global");
|
|
40
|
+
|
|
41
|
+
// ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
42
|
+
var pt = process.env.NODE_ENV === "production", k = "Invariant failed";
|
|
43
|
+
function M(e, t) {
|
|
44
|
+
if (!e) {
|
|
45
|
+
if (pt)
|
|
46
|
+
throw new Error(k);
|
|
47
|
+
var o = typeof t == "function" ? t() : t, i = o ? "".concat(k, ": ").concat(o) : k;
|
|
48
|
+
throw new Error(i);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
l(M, "invariant");
|
|
52
|
+
|
|
53
|
+
// src/measure/box-model/canvas.ts
|
|
54
|
+
function F() {
|
|
55
|
+
let e = y.global.document.documentElement, t = Math.max(e.scrollHeight, e.offsetHeight);
|
|
56
|
+
return { width: Math.max(e.scrollWidth, e.offsetWidth), height: t };
|
|
57
|
+
}
|
|
58
|
+
l(F, "getDocumentWidthAndHeight");
|
|
59
|
+
function bt() {
|
|
60
|
+
let e = y.global.document.createElement("canvas");
|
|
61
|
+
e.id = "storybook-addon-measure";
|
|
62
|
+
let t = e.getContext("2d");
|
|
63
|
+
M(t != null);
|
|
64
|
+
let { width: o, height: i } = F();
|
|
65
|
+
return T(e, t, { width: o, height: i }), e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.zIndex = "214748364\
|
|
66
|
+
7", e.style.pointerEvents = "none", y.global.document.body.appendChild(e), { canvas: e, context: t, width: o, height: i };
|
|
67
|
+
}
|
|
68
|
+
l(bt, "createCanvas");
|
|
69
|
+
function T(e, t, { width: o, height: i }) {
|
|
70
|
+
e.style.width = `${o}px`, e.style.height = `${i}px`;
|
|
71
|
+
let n = y.global.window.devicePixelRatio;
|
|
72
|
+
e.width = Math.floor(o * n), e.height = Math.floor(i * n), t.scale(n, n);
|
|
73
|
+
}
|
|
74
|
+
l(T, "setCanvasWidthAndHeight");
|
|
75
|
+
var m = {};
|
|
76
|
+
function Y() {
|
|
77
|
+
m.canvas || (m = bt());
|
|
78
|
+
}
|
|
79
|
+
l(Y, "init");
|
|
80
|
+
function B() {
|
|
81
|
+
m.context && m.context.clearRect(0, 0, m.width ?? 0, m.height ?? 0);
|
|
82
|
+
}
|
|
83
|
+
l(B, "clear");
|
|
84
|
+
function z(e) {
|
|
85
|
+
B(), e(m.context);
|
|
86
|
+
}
|
|
87
|
+
l(z, "draw");
|
|
88
|
+
function X() {
|
|
89
|
+
M(m.canvas, "Canvas should exist in the state."), M(m.context, "Context should exist in the state."), T(m.canvas, m.context, { width: 0, height: 0 });
|
|
90
|
+
let { width: e, height: t } = F();
|
|
91
|
+
T(m.canvas, m.context, { width: e, height: t }), m.width = e, m.height = t;
|
|
92
|
+
}
|
|
93
|
+
l(X, "rescale");
|
|
94
|
+
function $() {
|
|
95
|
+
m.canvas && (B(), m.canvas.parentNode?.removeChild(m.canvas), m = {});
|
|
96
|
+
}
|
|
97
|
+
l($, "destroy");
|
|
98
|
+
|
|
99
|
+
// src/measure/box-model/visualizer.ts
|
|
100
|
+
var b = require("@storybook/global");
|
|
101
|
+
|
|
102
|
+
// src/measure/box-model/labels.ts
|
|
103
|
+
var w = {
|
|
104
|
+
margin: "#f6b26b",
|
|
105
|
+
border: "#ffe599",
|
|
106
|
+
padding: "#93c47d",
|
|
107
|
+
content: "#6fa8dc",
|
|
108
|
+
text: "#232020"
|
|
109
|
+
}, g = 6;
|
|
110
|
+
function N(e, { x: t, y: o, w: i, h: n, r }) {
|
|
111
|
+
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 +
|
|
112
|
+
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();
|
|
113
|
+
}
|
|
114
|
+
l(N, "roundedRect");
|
|
115
|
+
function gt(e, { padding: t, border: o, width: i, height: n, top: r, left: a }) {
|
|
116
|
+
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;
|
|
117
|
+
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 :
|
|
118
|
+
e === "center" && (c += s / 2, u += f / 2), { x: c, y: u };
|
|
119
|
+
}
|
|
120
|
+
l(gt, "positionCoordinate");
|
|
121
|
+
function wt(e, t, { margin: o, border: i, padding: n }, r, a) {
|
|
122
|
+
let s = /* @__PURE__ */ l((d) => 0, "shift"), f = 0, c = 0, u = a ? 1 : 0.5, h = a ? r * 2 : 0;
|
|
123
|
+
return e === "padding" ? s = /* @__PURE__ */ l((d) => n[d] * u + h, "shift") : e === "border" ? s = /* @__PURE__ */ l((d) => n[d] + i[d] *
|
|
124
|
+
u + h, "shift") : e === "margin" && (s = /* @__PURE__ */ l((d) => n[d] + i[d] + o[d] * u + h, "shift")), t === "top" ? c = -s("top") : t ===
|
|
125
|
+
"right" ? f = s("right") : t === "bottom" ? c = s("bottom") : t === "left" && (f = -s("left")), { offsetX: f, offsetY: c };
|
|
126
|
+
}
|
|
127
|
+
l(wt, "offset");
|
|
128
|
+
function Lt(e, t) {
|
|
129
|
+
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;
|
|
130
|
+
}
|
|
131
|
+
l(Lt, "collide");
|
|
132
|
+
function Et(e, t, o) {
|
|
133
|
+
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 ===
|
|
134
|
+
"left" && (t.x = o.x - o.w / 2 - g - t.w / 2), { x: t.x, y: t.y };
|
|
135
|
+
}
|
|
136
|
+
l(Et, "overlapAdjustment");
|
|
137
|
+
function O(e, t, { x: o, y: i, w: n, h: r }, a) {
|
|
138
|
+
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,
|
|
139
|
+
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 =
|
|
140
|
+
w.text, e.fillText(a, o, i), { x: o, y: i, w: n, h: r };
|
|
141
|
+
}
|
|
142
|
+
l(O, "textWithRect");
|
|
143
|
+
function I(e, t) {
|
|
144
|
+
e.font = "600 12px monospace", e.textBaseline = "middle", e.textAlign = "center";
|
|
145
|
+
let o = e.measureText(t), i = o.actualBoundingBoxAscent + o.actualBoundingBoxDescent, n = o.width + g * 2, r = i + g * 2;
|
|
146
|
+
return { w: n, h: r };
|
|
147
|
+
}
|
|
148
|
+
l(I, "configureText");
|
|
149
|
+
function yt(e, t, { type: o, position: i = "center", text: n }, r, a = !1) {
|
|
150
|
+
let { x: s, y: f } = gt(i, t), { offsetX: c, offsetY: u } = wt(o, i, t, g + 1, a);
|
|
151
|
+
s += c, f += u;
|
|
152
|
+
let { w: h, h: d } = I(e, n);
|
|
153
|
+
if (r && Lt({ x: s, y: f, w: h, h: d }, r)) {
|
|
154
|
+
let C = Et(i, { x: s, y: f, w: h, h: d }, r);
|
|
155
|
+
s = C.x, f = C.y;
|
|
156
|
+
}
|
|
157
|
+
return O(e, o, { x: s, y: f, w: h, h: d }, n);
|
|
158
|
+
}
|
|
159
|
+
l(yt, "drawLabel");
|
|
160
|
+
function St(e, { w: t, h: o }) {
|
|
161
|
+
let i = t * 0.5 + g, n = o * 0.5 + g;
|
|
162
|
+
return {
|
|
163
|
+
offsetX: (e.x === "left" ? -1 : 1) * i,
|
|
164
|
+
offsetY: (e.y === "top" ? -1 : 1) * n
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
l(St, "floatingOffset");
|
|
168
|
+
function Ct(e, t, { type: o, text: i }) {
|
|
169
|
+
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 } = St(n, {
|
|
170
|
+
w: f,
|
|
171
|
+
h: c
|
|
172
|
+
});
|
|
173
|
+
return a += u, s += h, O(e, o, { x: a, y: s, w: f, h: c }, i);
|
|
174
|
+
}
|
|
175
|
+
l(Ct, "drawFloatingLabel");
|
|
176
|
+
function S(e, t, o, i) {
|
|
177
|
+
let n = [];
|
|
178
|
+
o.forEach((r, a) => {
|
|
179
|
+
let s = i && r.position === "center" ? Ct(e, t, r) : yt(e, t, r, n[a - 1], i);
|
|
180
|
+
n[a] = s;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
l(S, "drawStack");
|
|
184
|
+
function _(e, t, o, i) {
|
|
185
|
+
let n = o.reduce((r, a) => (Object.prototype.hasOwnProperty.call(r, a.position) || (r[a.position] = []), r[a.position]?.push(a), r), {});
|
|
186
|
+
n.top && S(e, t, n.top, i), n.right && S(e, t, n.right, i), n.bottom && S(e, t, n.bottom, i), n.left && S(e, t, n.left, i), n.center && S(
|
|
187
|
+
e, t, n.center, i);
|
|
188
|
+
}
|
|
189
|
+
l(_, "labelStacks");
|
|
190
|
+
|
|
191
|
+
// src/measure/box-model/visualizer.ts
|
|
192
|
+
var x = {
|
|
193
|
+
margin: "#f6b26ba8",
|
|
194
|
+
border: "#ffe599a8",
|
|
195
|
+
padding: "#93c47d8c",
|
|
196
|
+
content: "#6fa8dca8"
|
|
197
|
+
}, q = 30;
|
|
198
|
+
function p(e) {
|
|
199
|
+
return parseInt(e.replace("px", ""), 10);
|
|
200
|
+
}
|
|
201
|
+
l(p, "pxToNumber");
|
|
202
|
+
function L(e) {
|
|
203
|
+
return Number.isInteger(e) ? e : e.toFixed(2);
|
|
204
|
+
}
|
|
205
|
+
l(L, "round");
|
|
206
|
+
function P(e) {
|
|
207
|
+
return e.filter((t) => t.text !== 0 && t.text !== "0");
|
|
208
|
+
}
|
|
209
|
+
l(P, "filterZeroValues");
|
|
210
|
+
function vt(e) {
|
|
211
|
+
let t = {
|
|
212
|
+
top: b.global.window.scrollY,
|
|
213
|
+
bottom: b.global.window.scrollY + b.global.window.innerHeight,
|
|
214
|
+
left: b.global.window.scrollX,
|
|
215
|
+
right: b.global.window.scrollX + b.global.window.innerWidth
|
|
216
|
+
}, o = {
|
|
217
|
+
top: Math.abs(t.top - e.top),
|
|
218
|
+
bottom: Math.abs(t.bottom - e.bottom),
|
|
219
|
+
left: Math.abs(t.left - e.left),
|
|
220
|
+
right: Math.abs(t.right - e.right)
|
|
221
|
+
};
|
|
222
|
+
return {
|
|
223
|
+
x: o.left > o.right ? "left" : "right",
|
|
224
|
+
y: o.top > o.bottom ? "top" : "bottom"
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
l(vt, "floatingAlignment");
|
|
228
|
+
function Rt(e) {
|
|
229
|
+
let t = b.global.getComputedStyle(e), { top: o, left: i, right: n, bottom: r, width: a, height: s } = e.getBoundingClientRect(), {
|
|
230
|
+
marginTop: f,
|
|
231
|
+
marginBottom: c,
|
|
232
|
+
marginLeft: u,
|
|
233
|
+
marginRight: h,
|
|
234
|
+
paddingTop: d,
|
|
235
|
+
paddingBottom: C,
|
|
236
|
+
paddingLeft: et,
|
|
237
|
+
paddingRight: ot,
|
|
238
|
+
borderBottomWidth: nt,
|
|
239
|
+
borderTopWidth: it,
|
|
240
|
+
borderLeftWidth: rt,
|
|
241
|
+
borderRightWidth: lt
|
|
242
|
+
} = t;
|
|
243
|
+
o = o + b.global.window.scrollY, i = i + b.global.window.scrollX, r = r + b.global.window.scrollY, n = n + b.global.window.scrollX;
|
|
244
|
+
let E = {
|
|
245
|
+
top: p(f),
|
|
246
|
+
bottom: p(c),
|
|
247
|
+
left: p(u),
|
|
248
|
+
right: p(h)
|
|
249
|
+
}, at = {
|
|
250
|
+
top: p(d),
|
|
251
|
+
bottom: p(C),
|
|
252
|
+
left: p(et),
|
|
253
|
+
right: p(ot)
|
|
254
|
+
}, st = {
|
|
255
|
+
top: p(it),
|
|
256
|
+
bottom: p(nt),
|
|
257
|
+
left: p(rt),
|
|
258
|
+
right: p(lt)
|
|
259
|
+
}, H = {
|
|
260
|
+
top: o - E.top,
|
|
261
|
+
bottom: r + E.bottom,
|
|
262
|
+
left: i - E.left,
|
|
263
|
+
right: n + E.right
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
margin: E,
|
|
267
|
+
padding: at,
|
|
268
|
+
border: st,
|
|
269
|
+
top: o,
|
|
270
|
+
left: i,
|
|
271
|
+
bottom: r,
|
|
272
|
+
right: n,
|
|
273
|
+
width: a,
|
|
274
|
+
height: s,
|
|
275
|
+
extremities: H,
|
|
276
|
+
floatingAlignment: vt(H)
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
l(Rt, "measureElement");
|
|
280
|
+
function Mt(e, { margin: t, width: o, height: i, top: n, left: r, bottom: a, right: s }) {
|
|
281
|
+
let f = i + t.bottom + t.top;
|
|
282
|
+
e.fillStyle = x.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(
|
|
283
|
+
r - t.left, n - t.top, t.left, f);
|
|
284
|
+
let c = [
|
|
285
|
+
{
|
|
286
|
+
type: "margin",
|
|
287
|
+
text: L(t.top),
|
|
288
|
+
position: "top"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
type: "margin",
|
|
292
|
+
text: L(t.right),
|
|
293
|
+
position: "right"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
type: "margin",
|
|
297
|
+
text: L(t.bottom),
|
|
298
|
+
position: "bottom"
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
type: "margin",
|
|
302
|
+
text: L(t.left),
|
|
303
|
+
position: "left"
|
|
304
|
+
}
|
|
305
|
+
];
|
|
306
|
+
return P(c);
|
|
307
|
+
}
|
|
308
|
+
l(Mt, "drawMargin");
|
|
309
|
+
function xt(e, { padding: t, border: o, width: i, height: n, top: r, left: a, bottom: s, right: f }) {
|
|
310
|
+
let c = i - o.left - o.right, u = n - t.top - t.bottom - o.top - o.bottom;
|
|
311
|
+
e.fillStyle = x.padding, e.fillRect(a + o.left, r + o.top, c, t.top), e.fillRect(
|
|
312
|
+
f - t.right - o.right,
|
|
313
|
+
r + t.top + o.top,
|
|
314
|
+
t.right,
|
|
315
|
+
u
|
|
316
|
+
), e.fillRect(
|
|
317
|
+
a + o.left,
|
|
318
|
+
s - t.bottom - o.bottom,
|
|
319
|
+
c,
|
|
320
|
+
t.bottom
|
|
321
|
+
), e.fillRect(a + o.left, r + t.top + o.top, t.left, u);
|
|
322
|
+
let h = [
|
|
323
|
+
{
|
|
324
|
+
type: "padding",
|
|
325
|
+
text: t.top,
|
|
326
|
+
position: "top"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
type: "padding",
|
|
330
|
+
text: t.right,
|
|
331
|
+
position: "right"
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
type: "padding",
|
|
335
|
+
text: t.bottom,
|
|
336
|
+
position: "bottom"
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
type: "padding",
|
|
340
|
+
text: t.left,
|
|
341
|
+
position: "left"
|
|
342
|
+
}
|
|
343
|
+
];
|
|
344
|
+
return P(h);
|
|
345
|
+
}
|
|
346
|
+
l(xt, "drawPadding");
|
|
347
|
+
function Dt(e, { border: t, width: o, height: i, top: n, left: r, bottom: a, right: s }) {
|
|
348
|
+
let f = i - t.top - t.bottom;
|
|
349
|
+
e.fillStyle = x.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(
|
|
350
|
+
s - t.right, n + t.top, t.right, f);
|
|
351
|
+
let c = [
|
|
352
|
+
{
|
|
353
|
+
type: "border",
|
|
354
|
+
text: t.top,
|
|
355
|
+
position: "top"
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
type: "border",
|
|
359
|
+
text: t.right,
|
|
360
|
+
position: "right"
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
type: "border",
|
|
364
|
+
text: t.bottom,
|
|
365
|
+
position: "bottom"
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
type: "border",
|
|
369
|
+
text: t.left,
|
|
370
|
+
position: "left"
|
|
371
|
+
}
|
|
372
|
+
];
|
|
373
|
+
return P(c);
|
|
374
|
+
}
|
|
375
|
+
l(Dt, "drawBorder");
|
|
376
|
+
function kt(e, { padding: t, border: o, width: i, height: n, top: r, left: a }) {
|
|
377
|
+
let s = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom;
|
|
378
|
+
return e.fillStyle = x.content, e.fillRect(
|
|
379
|
+
a + o.left + t.left,
|
|
380
|
+
r + o.top + t.top,
|
|
381
|
+
s,
|
|
382
|
+
f
|
|
383
|
+
), [
|
|
384
|
+
{
|
|
385
|
+
type: "content",
|
|
386
|
+
position: "center",
|
|
387
|
+
text: `${L(s)} x ${L(f)}`
|
|
388
|
+
}
|
|
389
|
+
];
|
|
390
|
+
}
|
|
391
|
+
l(kt, "drawContent");
|
|
392
|
+
function Tt(e) {
|
|
393
|
+
return (t) => {
|
|
394
|
+
if (e && t) {
|
|
395
|
+
let o = Rt(e), i = Mt(t, o), n = xt(t, o), r = Dt(t, o), a = kt(t, o), s = o.width <= q * 3 || o.height <= q;
|
|
396
|
+
_(
|
|
397
|
+
t,
|
|
398
|
+
o,
|
|
399
|
+
[...a, ...n, ...r, ...i],
|
|
400
|
+
s
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
l(Tt, "drawBoxModel");
|
|
406
|
+
function j(e) {
|
|
407
|
+
z(Tt(e));
|
|
408
|
+
}
|
|
409
|
+
l(j, "drawSelectedElement");
|
|
410
|
+
|
|
411
|
+
// src/measure/util.ts
|
|
412
|
+
var G = require("@storybook/global");
|
|
413
|
+
var V = /* @__PURE__ */ l((e, t) => {
|
|
414
|
+
let o = G.global.document.elementFromPoint(e, t), i = /* @__PURE__ */ l((r) => {
|
|
415
|
+
if (r && r.shadowRoot) {
|
|
416
|
+
let a = r.shadowRoot.elementFromPoint(e, t);
|
|
417
|
+
return r.isEqualNode(a) ? r : a.shadowRoot ? i(a) : a;
|
|
418
|
+
}
|
|
419
|
+
return r;
|
|
420
|
+
}, "crawlShadows");
|
|
421
|
+
return i(o) || o;
|
|
422
|
+
}, "deepElementFromPoint");
|
|
423
|
+
|
|
424
|
+
// src/measure/withMeasure.ts
|
|
425
|
+
var K, D = { x: 0, y: 0 };
|
|
426
|
+
function U(e, t) {
|
|
427
|
+
K = V(e, t), j(K);
|
|
428
|
+
}
|
|
429
|
+
l(U, "findAndDrawElement");
|
|
430
|
+
var Z = /* @__PURE__ */ l((e, t) => {
|
|
431
|
+
let { measureEnabled: o } = t.globals || {};
|
|
432
|
+
return (0, A.useEffect)(() => {
|
|
433
|
+
let i = /* @__PURE__ */ l((n) => {
|
|
434
|
+
window.requestAnimationFrame(() => {
|
|
435
|
+
n.stopPropagation(), D.x = n.clientX, D.y = n.clientY;
|
|
436
|
+
});
|
|
437
|
+
}, "onPointerMove");
|
|
438
|
+
return document.addEventListener("pointermove", i), () => {
|
|
439
|
+
document.removeEventListener("pointermove", i);
|
|
440
|
+
};
|
|
441
|
+
}, []), (0, A.useEffect)(() => {
|
|
442
|
+
let i = /* @__PURE__ */ l((r) => {
|
|
443
|
+
window.requestAnimationFrame(() => {
|
|
444
|
+
r.stopPropagation(), U(r.clientX, r.clientY);
|
|
445
|
+
});
|
|
446
|
+
}, "onPointerOver"), n = /* @__PURE__ */ l(() => {
|
|
447
|
+
window.requestAnimationFrame(() => {
|
|
448
|
+
X();
|
|
449
|
+
});
|
|
450
|
+
}, "onResize");
|
|
451
|
+
return t.viewMode === "story" && o && (document.addEventListener("pointerover", i), Y(), window.addEventListener("resize", n), U(D.x, D.
|
|
452
|
+
y)), () => {
|
|
453
|
+
window.removeEventListener("resize", n), $();
|
|
454
|
+
};
|
|
455
|
+
}, [o, t.viewMode]), e();
|
|
456
|
+
}, "withMeasure");
|
|
457
|
+
|
|
458
|
+
// src/measure/preview.ts
|
|
459
|
+
var J = [Z], tt = {
|
|
460
|
+
[W]: !1
|
|
461
|
+
}, Pt = /* @__PURE__ */ l(() => (0, Q.definePreview)({
|
|
462
|
+
decorators: J,
|
|
463
|
+
initialGlobals: tt
|
|
464
|
+
}), "default");
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as storybook_internal_csf from 'storybook/internal/csf';
|
|
2
|
+
import { Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, StoryIdentifier, StoryContext, PartialStoryFn, LegacyStoryFn } from 'storybook/internal/csf';
|
|
3
|
+
import { NormalizedProjectAnnotations, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn } from 'storybook/internal/types';
|
|
4
|
+
|
|
5
|
+
declare global {
|
|
6
|
+
interface SymbolConstructor {
|
|
7
|
+
readonly observable: symbol;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface Renderer extends Renderer$1 {
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type MaybePromise<T> = Promise<T> | T;
|
|
15
|
+
type TeardownRenderToCanvas = () => MaybePromise<void>;
|
|
16
|
+
type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
|
|
17
|
+
interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotations$1<TRenderer> {
|
|
18
|
+
addons?: ProjectAnnotations<TRenderer>[];
|
|
19
|
+
testingLibraryRender?: (...args: never[]) => {
|
|
20
|
+
unmount: () => void;
|
|
21
|
+
};
|
|
22
|
+
renderToCanvas?: RenderToCanvas<TRenderer>;
|
|
23
|
+
}
|
|
24
|
+
declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
|
|
25
|
+
showMain: () => void;
|
|
26
|
+
showError: (error: {
|
|
27
|
+
title: string;
|
|
28
|
+
description: string;
|
|
29
|
+
}) => void;
|
|
30
|
+
showException: (err: Error) => void;
|
|
31
|
+
forceRemount: boolean;
|
|
32
|
+
storyContext: StoryContext<TRenderer>;
|
|
33
|
+
storyFn: PartialStoryFn<TRenderer>;
|
|
34
|
+
unboundStoryFn: LegacyStoryFn<TRenderer>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
declare global {
|
|
38
|
+
var globalProjectAnnotations: NormalizedProjectAnnotations<any>;
|
|
39
|
+
var defaultProjectAnnotations: ProjectAnnotations$2<any>;
|
|
40
|
+
}
|
|
41
|
+
type WrappedStoryRef = {
|
|
42
|
+
__pw_type: 'jsx' | 'importRef';
|
|
43
|
+
};
|
|
44
|
+
type UnwrappedJSXStoryRef = {
|
|
45
|
+
__pw_type: 'jsx';
|
|
46
|
+
type: UnwrappedImportStoryRef;
|
|
47
|
+
};
|
|
48
|
+
type UnwrappedImportStoryRef = ComposedStoryFn;
|
|
49
|
+
declare global {
|
|
50
|
+
function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare const decorators: storybook_internal_csf.DecoratorFunction[];
|
|
54
|
+
declare const initialGlobals: {
|
|
55
|
+
measureEnabled: boolean;
|
|
56
|
+
};
|
|
57
|
+
declare const _default: () => ProjectAnnotations<Renderer>;
|
|
58
|
+
|
|
59
|
+
export { decorators, _default as default, initialGlobals };
|