storybook 9.0.0-alpha.20 → 9.0.0-alpha.21
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/server/base-preview-head.html +1 -3
- package/dist/actions/decorator.js +34 -38
- package/dist/actions/index.cjs +1 -4
- package/dist/actions/index.js +1 -4
- package/dist/actions/preview.cjs +1 -4
- package/dist/actions/preview.js +1 -4
- package/dist/babel/index.cjs +822 -816
- package/dist/babel/index.js +822 -816
- package/dist/backgrounds/index.cjs +16 -16
- package/dist/backgrounds/index.js +14 -14
- package/dist/backgrounds/preview.cjs +34 -34
- package/dist/backgrounds/preview.js +29 -29
- package/dist/bin/index.cjs +67 -65
- package/dist/bin/index.js +61 -59
- package/dist/builder-manager/index.cjs +482 -472
- package/dist/builder-manager/index.js +283 -273
- package/dist/channels/index.js +941 -919
- package/dist/cli/bin/index.cjs +1 -1
- package/dist/cli/bin/index.js +1 -1
- package/dist/cli/index.cjs +61752 -7591
- package/dist/cli/index.d.ts +22 -14
- package/dist/cli/index.js +61775 -7614
- package/dist/common/index.cjs +16015 -8979
- package/dist/common/index.d.ts +30 -1
- package/dist/common/index.js +16105 -9063
- package/dist/components/index.cjs +3694 -3643
- package/dist/components/index.d.ts +5 -2
- package/dist/components/index.js +2352 -2294
- package/dist/core-server/index.cjs +3540 -3540
- package/dist/core-server/index.js +730 -730
- package/dist/core-server/presets/common-manager.js +2642 -2592
- package/dist/core-server/presets/common-preset.cjs +723 -715
- package/dist/core-server/presets/common-preset.js +10 -2
- package/dist/docs-tools/index.js +640 -632
- package/dist/highlight/index.cjs +16 -16
- package/dist/highlight/index.d.ts +45 -1
- package/dist/highlight/index.js +2 -2
- package/dist/highlight/preview.cjs +522 -68
- package/dist/highlight/preview.js +508 -56
- package/dist/instrumenter/index.js +1179 -1170
- package/dist/manager/globals-module-info.cjs +1 -0
- package/dist/manager/globals-module-info.js +1 -0
- package/dist/manager/globals-runtime.js +19385 -19190
- package/dist/manager/runtime.js +2084 -2079
- package/dist/manager-api/index.cjs +352 -352
- package/dist/manager-api/index.js +1694 -1663
- package/dist/manager-errors.js +41 -37
- package/dist/measure/index.cjs +99 -97
- package/dist/measure/index.js +95 -93
- package/dist/measure/preview.cjs +127 -125
- package/dist/measure/preview.js +125 -123
- package/dist/outline/index.cjs +41 -41
- package/dist/outline/index.js +12 -12
- package/dist/outline/preview.cjs +23 -23
- package/dist/outline/preview.js +7 -7
- package/dist/preview/runtime.js +13577 -12959
- package/dist/preview-api/index.cjs +0 -1
- package/dist/preview-api/index.d.ts +120 -385
- package/dist/preview-api/index.js +827 -812
- package/dist/preview-errors.cjs +65 -51
- package/dist/preview-errors.d.ts +6 -2
- package/dist/preview-errors.js +176 -142
- package/dist/server-errors.cjs +105 -72
- package/dist/server-errors.d.ts +9 -1
- package/dist/server-errors.js +87 -54
- package/dist/telemetry/index.cjs +374 -370
- package/dist/telemetry/index.js +460 -456
- package/dist/test/index.js +9831 -9743
- package/dist/test/preview.d.ts +0 -6
- package/dist/test/preview.js +3628 -3568
- package/dist/types/index.d.ts +72 -6
- package/package.json +1 -1
package/dist/measure/preview.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var it = Object.defineProperty;
|
|
2
|
-
var
|
|
2
|
+
var r = (e, t) => it(e, "name", { value: t, configurable: !0 });
|
|
3
3
|
|
|
4
4
|
// src/measure/preview.ts
|
|
5
5
|
import { definePreview as St } from "storybook/preview-api";
|
|
@@ -18,62 +18,62 @@ import { useEffect as j } from "storybook/preview-api";
|
|
|
18
18
|
import { global as R } from "@storybook/global";
|
|
19
19
|
|
|
20
20
|
// ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js
|
|
21
|
-
var
|
|
21
|
+
var lt = !1, T = "Invariant failed";
|
|
22
22
|
function v(e, t) {
|
|
23
23
|
if (!e) {
|
|
24
|
-
if (
|
|
25
|
-
throw new Error(
|
|
26
|
-
var o = typeof t == "function" ? t() : t, i = o ? "".concat(
|
|
24
|
+
if (lt)
|
|
25
|
+
throw new Error(T);
|
|
26
|
+
var o = typeof t == "function" ? t() : t, i = o ? "".concat(T, ": ").concat(o) : T;
|
|
27
27
|
throw new Error(i);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
r(v, "invariant");
|
|
31
31
|
|
|
32
32
|
// src/measure/box-model/canvas.ts
|
|
33
33
|
function H() {
|
|
34
34
|
let e = R.document.documentElement, t = Math.max(e.scrollHeight, e.offsetHeight);
|
|
35
35
|
return { width: Math.max(e.scrollWidth, e.offsetWidth), height: t };
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
function
|
|
37
|
+
r(H, "getDocumentWidthAndHeight");
|
|
38
|
+
function rt() {
|
|
39
39
|
let e = R.document.createElement("canvas");
|
|
40
40
|
e.id = "storybook-addon-measure";
|
|
41
41
|
let t = e.getContext("2d");
|
|
42
42
|
v(t != null);
|
|
43
43
|
let { width: o, height: i } = H();
|
|
44
|
-
return
|
|
44
|
+
return D(e, t, { width: o, height: i }), e.style.position = "absolute", e.style.left = "0", e.style.top = "0", e.style.zIndex = "214748364\
|
|
45
45
|
7", e.style.pointerEvents = "none", R.document.body.appendChild(e), { canvas: e, context: t, width: o, height: i };
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
function
|
|
47
|
+
r(rt, "createCanvas");
|
|
48
|
+
function D(e, t, { width: o, height: i }) {
|
|
49
49
|
e.style.width = `${o}px`, e.style.height = `${i}px`;
|
|
50
50
|
let n = R.window.devicePixelRatio;
|
|
51
51
|
e.width = Math.floor(o * n), e.height = Math.floor(i * n), t.scale(n, n);
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
r(D, "setCanvasWidthAndHeight");
|
|
54
54
|
var m = {};
|
|
55
|
-
function W() {
|
|
56
|
-
m.canvas || (m = lt());
|
|
57
|
-
}
|
|
58
|
-
l(W, "init");
|
|
59
55
|
function F() {
|
|
56
|
+
m.canvas || (m = rt());
|
|
57
|
+
}
|
|
58
|
+
r(F, "init");
|
|
59
|
+
function W() {
|
|
60
60
|
m.context && m.context.clearRect(0, 0, m.width ?? 0, m.height ?? 0);
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
r(W, "clear");
|
|
63
63
|
function Y(e) {
|
|
64
|
-
|
|
64
|
+
W(), e(m.context);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
r(Y, "draw");
|
|
67
67
|
function B() {
|
|
68
|
-
v(m.canvas, "Canvas should exist in the state."), v(m.context, "Context should exist in the state."),
|
|
68
|
+
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 });
|
|
69
69
|
let { width: e, height: t } = H();
|
|
70
|
-
|
|
70
|
+
D(m.canvas, m.context, { width: e, height: t }), m.width = e, m.height = t;
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
r(B, "rescale");
|
|
73
73
|
function z() {
|
|
74
|
-
m.canvas && (
|
|
74
|
+
m.canvas && (W(), m.canvas.parentNode?.removeChild(m.canvas), m = {});
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
r(z, "destroy");
|
|
77
77
|
|
|
78
78
|
// src/measure/box-model/visualizer.ts
|
|
79
79
|
import { global as b } from "@storybook/global";
|
|
@@ -86,56 +86,56 @@ var w = {
|
|
|
86
86
|
content: "#6fa8dc",
|
|
87
87
|
text: "#232020"
|
|
88
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 *
|
|
91
|
-
i, o + n,
|
|
89
|
+
function X(e, { x: t, y: o, w: i, h: n, r: l }) {
|
|
90
|
+
t = t - i / 2, o = o - n / 2, i < 2 * l && (l = i / 2), n < 2 * l && (l = n / 2), e.beginPath(), e.moveTo(t + l, o), e.arcTo(t + i, o, t +
|
|
91
|
+
i, o + n, l), e.arcTo(t + i, o + n, t, o + n, l), e.arcTo(t, o + n, t, o, l), e.arcTo(t, o, t + i, o, l), e.closePath();
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
function at(e, { padding: t, border: o, width: i, height: n, top:
|
|
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 =
|
|
93
|
+
r(X, "roundedRect");
|
|
94
|
+
function at(e, { padding: t, border: o, width: i, height: n, top: l, left: a }) {
|
|
95
|
+
let s = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom, c = a + o.left + t.left, u = l + o.top + t.top;
|
|
96
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
97
|
e === "center" && (c += s / 2, u += f / 2), { x: c, y: u };
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
function st(e, t, { margin: o, border: i, padding: n },
|
|
101
|
-
let s = /* @__PURE__ */
|
|
102
|
-
return e === "padding" ? s = /* @__PURE__ */
|
|
103
|
-
u +
|
|
99
|
+
r(at, "positionCoordinate");
|
|
100
|
+
function st(e, t, { margin: o, border: i, padding: n }, l, a) {
|
|
101
|
+
let s = /* @__PURE__ */ r((h) => 0, "shift"), f = 0, c = 0, u = a ? 1 : 0.5, d = a ? l * 2 : 0;
|
|
102
|
+
return e === "padding" ? s = /* @__PURE__ */ r((h) => n[h] * u + d, "shift") : e === "border" ? s = /* @__PURE__ */ r((h) => n[h] + i[h] *
|
|
103
|
+
u + d, "shift") : e === "margin" && (s = /* @__PURE__ */ r((h) => n[h] + i[h] + o[h] * u + d, "shift")), t === "top" ? c = -s("top") : t ===
|
|
104
104
|
"right" ? f = s("right") : t === "bottom" ? c = s("bottom") : t === "left" && (f = -s("left")), { offsetX: f, offsetY: c };
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
r(st, "offset");
|
|
107
107
|
function ft(e, t) {
|
|
108
108
|
return Math.abs(e.x - t.x) < Math.abs(e.w + t.w) / 2 && Math.abs(e.y - t.y) < Math.abs(e.h + t.h) / 2;
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
r(ft, "collide");
|
|
111
111
|
function ct(e, t, o) {
|
|
112
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
113
|
"left" && (t.x = o.x - o.w / 2 - g - t.w / 2), { x: t.x, y: t.y };
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
function $(e, t, { x: o, y: i, w: n, h:
|
|
117
|
-
return X(e, { x: o, y: i, w: n, h:
|
|
118
|
-
e.fillText(a, o, i), X(e, { x: o, y: i, w: n, h:
|
|
119
|
-
w.text, e.fillText(a, o, i), { x: o, y: i, w: n, h:
|
|
115
|
+
r(ct, "overlapAdjustment");
|
|
116
|
+
function $(e, t, { x: o, y: i, w: n, h: l }, a) {
|
|
117
|
+
return X(e, { x: o, y: i, w: n, h: l, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle = w.text,
|
|
118
|
+
e.fillText(a, o, i), X(e, { x: o, y: i, w: n, h: l, r: 3 }), e.fillStyle = `${w[t]}dd`, e.fill(), e.strokeStyle = w[t], e.stroke(), e.fillStyle =
|
|
119
|
+
w.text, e.fillText(a, o, i), { x: o, y: i, w: n, h: l };
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
r($, "textWithRect");
|
|
122
122
|
function N(e, t) {
|
|
123
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,
|
|
125
|
-
return { w: n, h:
|
|
124
|
+
let o = e.measureText(t), i = o.actualBoundingBoxAscent + o.actualBoundingBoxDescent, n = o.width + g * 2, l = i + g * 2;
|
|
125
|
+
return { w: n, h: l };
|
|
126
126
|
}
|
|
127
|
-
|
|
128
|
-
function mt(e, t, { type: o, position: i = "center", text: n },
|
|
127
|
+
r(N, "configureText");
|
|
128
|
+
function mt(e, t, { type: o, position: i = "center", text: n }, l, a = !1) {
|
|
129
129
|
let { x: s, y: f } = at(i, t), { offsetX: c, offsetY: u } = st(o, i, t, g + 1, a);
|
|
130
130
|
s += c, f += u;
|
|
131
|
-
let { w:
|
|
132
|
-
if (
|
|
133
|
-
let S = ct(i, { x: s, y: f, w:
|
|
131
|
+
let { w: d, h } = N(e, n);
|
|
132
|
+
if (l && ft({ x: s, y: f, w: d, h }, l)) {
|
|
133
|
+
let S = ct(i, { x: s, y: f, w: d, h }, l);
|
|
134
134
|
s = S.x, f = S.y;
|
|
135
135
|
}
|
|
136
|
-
return $(e, o, { x: s, y: f, w:
|
|
136
|
+
return $(e, o, { x: s, y: f, w: d, h }, n);
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
r(mt, "drawLabel");
|
|
139
139
|
function ut(e, { w: t, h: o }) {
|
|
140
140
|
let i = t * 0.5 + g, n = o * 0.5 + g;
|
|
141
141
|
return {
|
|
@@ -143,29 +143,29 @@ function ut(e, { w: t, h: o }) {
|
|
|
143
143
|
offsetY: (e.y === "top" ? -1 : 1) * n
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
function
|
|
148
|
-
let { floatingAlignment: n, extremities:
|
|
146
|
+
r(ut, "floatingOffset");
|
|
147
|
+
function ht(e, t, { type: o, text: i }) {
|
|
148
|
+
let { floatingAlignment: n, extremities: l } = t, a = l[n.x], s = l[n.y], { w: f, h: c } = N(e, i), { offsetX: u, offsetY: d } = ut(n, {
|
|
149
149
|
w: f,
|
|
150
150
|
h: c
|
|
151
151
|
});
|
|
152
|
-
return a += u, s +=
|
|
152
|
+
return a += u, s += d, $(e, o, { x: a, y: s, w: f, h: c }, i);
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
r(ht, "drawFloatingLabel");
|
|
155
155
|
function y(e, t, o, i) {
|
|
156
156
|
let n = [];
|
|
157
|
-
o.forEach((
|
|
158
|
-
let s = i &&
|
|
157
|
+
o.forEach((l, a) => {
|
|
158
|
+
let s = i && l.position === "center" ? ht(e, t, l) : mt(e, t, l, n[a - 1], i);
|
|
159
159
|
n[a] = s;
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
|
|
162
|
+
r(y, "drawStack");
|
|
163
163
|
function O(e, t, o, i) {
|
|
164
|
-
let n = o.reduce((
|
|
164
|
+
let n = o.reduce((l, a) => (Object.prototype.hasOwnProperty.call(l, a.position) || (l[a.position] = []), l[a.position]?.push(a), l), {});
|
|
165
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
166
|
e, t, n.center, i);
|
|
167
167
|
}
|
|
168
|
-
|
|
168
|
+
r(O, "labelStacks");
|
|
169
169
|
|
|
170
170
|
// src/measure/box-model/visualizer.ts
|
|
171
171
|
var M = {
|
|
@@ -177,16 +177,16 @@ var M = {
|
|
|
177
177
|
function p(e) {
|
|
178
178
|
return parseInt(e.replace("px", ""), 10);
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
r(p, "pxToNumber");
|
|
181
181
|
function L(e) {
|
|
182
182
|
return Number.isInteger(e) ? e : e.toFixed(2);
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
function
|
|
184
|
+
r(L, "round");
|
|
185
|
+
function k(e) {
|
|
186
186
|
return e.filter((t) => t.text !== 0 && t.text !== "0");
|
|
187
187
|
}
|
|
188
|
-
|
|
189
|
-
function
|
|
188
|
+
r(k, "filterZeroValues");
|
|
189
|
+
function dt(e) {
|
|
190
190
|
let t = {
|
|
191
191
|
top: b.window.scrollY,
|
|
192
192
|
bottom: b.window.scrollY + b.window.innerHeight,
|
|
@@ -203,32 +203,32 @@ function ht(e) {
|
|
|
203
203
|
y: o.top > o.bottom ? "top" : "bottom"
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
r(dt, "floatingAlignment");
|
|
207
207
|
function pt(e) {
|
|
208
|
-
let t = b.getComputedStyle(e), { top: o, left: i, right: n, bottom:
|
|
208
|
+
let t = b.getComputedStyle(e), { top: o, left: i, right: n, bottom: l, width: a, height: s } = e.getBoundingClientRect(), {
|
|
209
209
|
marginTop: f,
|
|
210
210
|
marginBottom: c,
|
|
211
211
|
marginLeft: u,
|
|
212
|
-
marginRight:
|
|
213
|
-
paddingTop:
|
|
212
|
+
marginRight: d,
|
|
213
|
+
paddingTop: h,
|
|
214
214
|
paddingBottom: S,
|
|
215
|
-
paddingLeft:
|
|
215
|
+
paddingLeft: K,
|
|
216
216
|
paddingRight: Z,
|
|
217
217
|
borderBottomWidth: Q,
|
|
218
218
|
borderTopWidth: J,
|
|
219
219
|
borderLeftWidth: tt,
|
|
220
220
|
borderRightWidth: et
|
|
221
221
|
} = t;
|
|
222
|
-
o = o + b.window.scrollY, i = i + b.window.scrollX,
|
|
222
|
+
o = o + b.window.scrollY, i = i + b.window.scrollX, l = l + b.window.scrollY, n = n + b.window.scrollX;
|
|
223
223
|
let E = {
|
|
224
224
|
top: p(f),
|
|
225
225
|
bottom: p(c),
|
|
226
226
|
left: p(u),
|
|
227
|
-
right: p(
|
|
227
|
+
right: p(d)
|
|
228
228
|
}, ot = {
|
|
229
|
-
top: p(
|
|
229
|
+
top: p(h),
|
|
230
230
|
bottom: p(S),
|
|
231
|
-
left: p(
|
|
231
|
+
left: p(K),
|
|
232
232
|
right: p(Z)
|
|
233
233
|
}, nt = {
|
|
234
234
|
top: p(J),
|
|
@@ -237,7 +237,7 @@ function pt(e) {
|
|
|
237
237
|
right: p(et)
|
|
238
238
|
}, P = {
|
|
239
239
|
top: o - E.top,
|
|
240
|
-
bottom:
|
|
240
|
+
bottom: l + E.bottom,
|
|
241
241
|
left: i - E.left,
|
|
242
242
|
right: n + E.right
|
|
243
243
|
};
|
|
@@ -247,19 +247,19 @@ function pt(e) {
|
|
|
247
247
|
border: nt,
|
|
248
248
|
top: o,
|
|
249
249
|
left: i,
|
|
250
|
-
bottom:
|
|
250
|
+
bottom: l,
|
|
251
251
|
right: n,
|
|
252
252
|
width: a,
|
|
253
253
|
height: s,
|
|
254
254
|
extremities: P,
|
|
255
|
-
floatingAlignment:
|
|
255
|
+
floatingAlignment: dt(P)
|
|
256
256
|
};
|
|
257
257
|
}
|
|
258
|
-
|
|
259
|
-
function bt(e, { margin: t, width: o, height: i, top: n, left:
|
|
258
|
+
r(pt, "measureElement");
|
|
259
|
+
function bt(e, { margin: t, width: o, height: i, top: n, left: l, bottom: a, right: s }) {
|
|
260
260
|
let f = i + t.bottom + t.top;
|
|
261
|
-
e.fillStyle = M.margin, e.fillRect(
|
|
262
|
-
|
|
261
|
+
e.fillStyle = M.margin, e.fillRect(l, n - t.top, o, t.top), e.fillRect(s, n - t.top, t.right, f), e.fillRect(l, a, o, t.bottom), e.fillRect(
|
|
262
|
+
l - t.left, n - t.top, t.left, f);
|
|
263
263
|
let c = [
|
|
264
264
|
{
|
|
265
265
|
type: "margin",
|
|
@@ -282,14 +282,14 @@ function bt(e, { margin: t, width: o, height: i, top: n, left: r, bottom: a, rig
|
|
|
282
282
|
position: "left"
|
|
283
283
|
}
|
|
284
284
|
];
|
|
285
|
-
return
|
|
285
|
+
return k(c);
|
|
286
286
|
}
|
|
287
|
-
|
|
288
|
-
function gt(e, { padding: t, border: o, width: i, height: n, top:
|
|
287
|
+
r(bt, "drawMargin");
|
|
288
|
+
function gt(e, { padding: t, border: o, width: i, height: n, top: l, left: a, bottom: s, right: f }) {
|
|
289
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,
|
|
290
|
+
e.fillStyle = M.padding, e.fillRect(a + o.left, l + o.top, c, t.top), e.fillRect(
|
|
291
291
|
f - t.right - o.right,
|
|
292
|
-
|
|
292
|
+
l + t.top + o.top,
|
|
293
293
|
t.right,
|
|
294
294
|
u
|
|
295
295
|
), e.fillRect(
|
|
@@ -297,8 +297,8 @@ function gt(e, { padding: t, border: o, width: i, height: n, top: r, left: a, bo
|
|
|
297
297
|
s - t.bottom - o.bottom,
|
|
298
298
|
c,
|
|
299
299
|
t.bottom
|
|
300
|
-
), e.fillRect(a + o.left,
|
|
301
|
-
let
|
|
300
|
+
), e.fillRect(a + o.left, l + t.top + o.top, t.left, u);
|
|
301
|
+
let d = [
|
|
302
302
|
{
|
|
303
303
|
type: "padding",
|
|
304
304
|
text: t.top,
|
|
@@ -320,12 +320,12 @@ function gt(e, { padding: t, border: o, width: i, height: n, top: r, left: a, bo
|
|
|
320
320
|
position: "left"
|
|
321
321
|
}
|
|
322
322
|
];
|
|
323
|
-
return
|
|
323
|
+
return k(d);
|
|
324
324
|
}
|
|
325
|
-
|
|
326
|
-
function wt(e, { border: t, width: o, height: i, top: n, left:
|
|
325
|
+
r(gt, "drawPadding");
|
|
326
|
+
function wt(e, { border: t, width: o, height: i, top: n, left: l, bottom: a, right: s }) {
|
|
327
327
|
let f = i - t.top - t.bottom;
|
|
328
|
-
e.fillStyle = M.border, e.fillRect(
|
|
328
|
+
e.fillStyle = M.border, e.fillRect(l, n, o, t.top), e.fillRect(l, a - t.bottom, o, t.bottom), e.fillRect(l, n + t.top, t.left, f), e.fillRect(
|
|
329
329
|
s - t.right, n + t.top, t.right, f);
|
|
330
330
|
let c = [
|
|
331
331
|
{
|
|
@@ -349,14 +349,14 @@ function wt(e, { border: t, width: o, height: i, top: n, left: r, bottom: a, rig
|
|
|
349
349
|
position: "left"
|
|
350
350
|
}
|
|
351
351
|
];
|
|
352
|
-
return
|
|
352
|
+
return k(c);
|
|
353
353
|
}
|
|
354
|
-
|
|
355
|
-
function Lt(e, { padding: t, border: o, width: i, height: n, top:
|
|
354
|
+
r(wt, "drawBorder");
|
|
355
|
+
function Lt(e, { padding: t, border: o, width: i, height: n, top: l, left: a }) {
|
|
356
356
|
let s = i - o.left - o.right - t.left - t.right, f = n - t.top - t.bottom - o.top - o.bottom;
|
|
357
357
|
return e.fillStyle = M.content, e.fillRect(
|
|
358
358
|
a + o.left + t.left,
|
|
359
|
-
|
|
359
|
+
l + o.top + t.top,
|
|
360
360
|
s,
|
|
361
361
|
f
|
|
362
362
|
), [
|
|
@@ -367,77 +367,79 @@ function Lt(e, { padding: t, border: o, width: i, height: n, top: r, left: a })
|
|
|
367
367
|
}
|
|
368
368
|
];
|
|
369
369
|
}
|
|
370
|
-
|
|
370
|
+
r(Lt, "drawContent");
|
|
371
371
|
function Et(e) {
|
|
372
372
|
return (t) => {
|
|
373
373
|
if (e && t) {
|
|
374
|
-
let o = pt(e), i = bt(t, o), n = gt(t, o),
|
|
374
|
+
let o = pt(e), i = bt(t, o), n = gt(t, o), l = wt(t, o), a = Lt(t, o), s = o.width <= I * 3 || o.height <= I;
|
|
375
375
|
O(
|
|
376
376
|
t,
|
|
377
377
|
o,
|
|
378
|
-
[...a, ...n, ...
|
|
378
|
+
[...a, ...n, ...l, ...i],
|
|
379
379
|
s
|
|
380
380
|
);
|
|
381
381
|
}
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
|
-
|
|
384
|
+
r(Et, "drawBoxModel");
|
|
385
385
|
function _(e) {
|
|
386
386
|
Y(Et(e));
|
|
387
387
|
}
|
|
388
|
-
|
|
388
|
+
r(_, "drawSelectedElement");
|
|
389
389
|
|
|
390
390
|
// src/measure/util.ts
|
|
391
391
|
import { global as yt } from "@storybook/global";
|
|
392
|
-
var q = /* @__PURE__ */
|
|
393
|
-
let o = yt.document.elementFromPoint(e, t), i = /* @__PURE__ */
|
|
394
|
-
if (
|
|
395
|
-
let a =
|
|
396
|
-
return
|
|
392
|
+
var q = /* @__PURE__ */ r((e, t) => {
|
|
393
|
+
let o = yt.document.elementFromPoint(e, t), i = /* @__PURE__ */ r((l) => {
|
|
394
|
+
if (l && l.shadowRoot) {
|
|
395
|
+
let a = l.shadowRoot.elementFromPoint(e, t);
|
|
396
|
+
return l.isEqualNode(a) ? l : a.shadowRoot ? i(a) : a;
|
|
397
397
|
}
|
|
398
|
-
return
|
|
398
|
+
return l;
|
|
399
399
|
}, "crawlShadows");
|
|
400
400
|
return i(o) || o;
|
|
401
401
|
}, "deepElementFromPoint");
|
|
402
402
|
|
|
403
403
|
// src/measure/withMeasure.ts
|
|
404
404
|
var G, x = { x: 0, y: 0 };
|
|
405
|
-
function
|
|
405
|
+
function U(e, t) {
|
|
406
406
|
G = q(e, t), _(G);
|
|
407
407
|
}
|
|
408
|
-
|
|
409
|
-
var
|
|
408
|
+
r(U, "findAndDrawElement");
|
|
409
|
+
var V = /* @__PURE__ */ r((e, t) => {
|
|
410
410
|
let { measureEnabled: o } = t.globals || {};
|
|
411
411
|
return j(() => {
|
|
412
|
-
|
|
412
|
+
if (typeof globalThis.document > "u")
|
|
413
|
+
return;
|
|
414
|
+
let i = /* @__PURE__ */ r((n) => {
|
|
413
415
|
window.requestAnimationFrame(() => {
|
|
414
416
|
n.stopPropagation(), x.x = n.clientX, x.y = n.clientY;
|
|
415
417
|
});
|
|
416
418
|
}, "onPointerMove");
|
|
417
|
-
return document.addEventListener("pointermove", i), () => {
|
|
418
|
-
document.removeEventListener("pointermove", i);
|
|
419
|
+
return globalThis.document.addEventListener("pointermove", i), () => {
|
|
420
|
+
globalThis.document.removeEventListener("pointermove", i);
|
|
419
421
|
};
|
|
420
422
|
}, []), j(() => {
|
|
421
|
-
let i = /* @__PURE__ */
|
|
423
|
+
let i = /* @__PURE__ */ r((l) => {
|
|
422
424
|
window.requestAnimationFrame(() => {
|
|
423
|
-
|
|
425
|
+
l.stopPropagation(), U(l.clientX, l.clientY);
|
|
424
426
|
});
|
|
425
|
-
}, "onPointerOver"), n = /* @__PURE__ */
|
|
427
|
+
}, "onPointerOver"), n = /* @__PURE__ */ r(() => {
|
|
426
428
|
window.requestAnimationFrame(() => {
|
|
427
429
|
B();
|
|
428
430
|
});
|
|
429
431
|
}, "onResize");
|
|
430
|
-
return t.viewMode === "story" && o && (document.addEventListener("pointerover", i),
|
|
431
|
-
|
|
432
|
-
window.removeEventListener("resize", n), z();
|
|
432
|
+
return t.viewMode === "story" && o && (globalThis.document.addEventListener("pointerover", i), F(), globalThis.window.addEventListener("\
|
|
433
|
+
resize", n), U(x.x, x.y)), () => {
|
|
434
|
+
globalThis.window.removeEventListener("resize", n), z();
|
|
433
435
|
};
|
|
434
436
|
}, [o, t.viewMode]), e();
|
|
435
437
|
}, "withMeasure");
|
|
436
438
|
|
|
437
439
|
// src/measure/preview.ts
|
|
438
|
-
var Ct = [
|
|
440
|
+
var Ct = globalThis.FEATURES?.measure ? [V] : [], vt = {
|
|
439
441
|
[A]: !1
|
|
440
|
-
}, te = /* @__PURE__ */
|
|
442
|
+
}, te = /* @__PURE__ */ r(() => St({
|
|
441
443
|
decorators: Ct,
|
|
442
444
|
initialGlobals: vt
|
|
443
445
|
}), "default");
|
package/dist/outline/index.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var _ = Object.create;
|
|
3
3
|
var e = Object.defineProperty;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var j = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var C = Object.getOwnPropertyNames;
|
|
6
|
+
var L = Object.getPrototypeOf, F = Object.prototype.hasOwnProperty;
|
|
7
7
|
var p = (i, t) => e(i, "name", { value: t, configurable: !0 });
|
|
8
|
-
var
|
|
8
|
+
var H = (i, t) => () => (t || i((t = { exports: {} }).exports, t), t.exports), E = (i, t) => {
|
|
9
9
|
for (var n in t)
|
|
10
10
|
e(i, n, { get: t[n], enumerable: !0 });
|
|
11
|
-
},
|
|
11
|
+
}, S = (i, t, n, o) => {
|
|
12
12
|
if (t && typeof t == "object" || typeof t == "function")
|
|
13
|
-
for (let a of
|
|
14
|
-
!
|
|
13
|
+
for (let a of C(t))
|
|
14
|
+
!F.call(i, a) && a !== n && e(i, a, { get: () => t[a], enumerable: !(o = j(t, a)) || o.enumerable });
|
|
15
15
|
return i;
|
|
16
16
|
};
|
|
17
|
-
var
|
|
17
|
+
var K = (i, t, n) => (n = i != null ? _(L(i)) : {}, S(
|
|
18
18
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
19
|
// file that has been converted to a CommonJS file using a Babel-
|
|
20
20
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
21
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
22
|
t || !i || !i.__esModule ? e(n, "default", { value: i, enumerable: !0 }) : n,
|
|
23
23
|
i
|
|
24
|
-
)),
|
|
24
|
+
)), Y = (i) => S(e({}, "__esModule", { value: !0 }), i);
|
|
25
25
|
|
|
26
26
|
// ../node_modules/ts-dedent/dist/index.js
|
|
27
|
-
var k =
|
|
27
|
+
var k = H((s) => {
|
|
28
28
|
"use strict";
|
|
29
|
-
Object.defineProperty(
|
|
30
|
-
|
|
29
|
+
Object.defineProperty(s, "__esModule", { value: !0 });
|
|
30
|
+
s.dedent = void 0;
|
|
31
31
|
function M(i) {
|
|
32
32
|
for (var t = [], n = 1; n < arguments.length; n++)
|
|
33
33
|
t[n - 1] = arguments[n];
|
|
@@ -35,67 +35,67 @@ var k = T(($) => {
|
|
|
35
35
|
o[o.length - 1] = o[o.length - 1].replace(/\r?\n([\t ]*)$/, "");
|
|
36
36
|
var a = o.reduce(function(d, g) {
|
|
37
37
|
var r = g.match(/\n([\t ]+|(?!\s).)/g);
|
|
38
|
-
return r ? d.concat(r.map(function(
|
|
38
|
+
return r ? d.concat(r.map(function(h) {
|
|
39
39
|
var u, m;
|
|
40
|
-
return (m = (u =
|
|
40
|
+
return (m = (u = h.match(/[\t ]/g)) === null || u === void 0 ? void 0 : u.length) !== null && m !== void 0 ? m : 0;
|
|
41
41
|
})) : d;
|
|
42
42
|
}, []);
|
|
43
43
|
if (a.length) {
|
|
44
|
-
var
|
|
44
|
+
var $ = new RegExp(`
|
|
45
45
|
[ ]{` + Math.min.apply(Math, a) + "}", "g");
|
|
46
46
|
o = o.map(function(d) {
|
|
47
|
-
return d.replace(
|
|
47
|
+
return d.replace($, `
|
|
48
48
|
`);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
o[0] = o[0].replace(/^\r?\n/, "");
|
|
52
52
|
var l = o[0];
|
|
53
53
|
return t.forEach(function(d, g) {
|
|
54
|
-
var r = l.match(/(?:^|\n)( *)$/),
|
|
54
|
+
var r = l.match(/(?:^|\n)( *)$/), h = r ? r[1] : "", u = d;
|
|
55
55
|
typeof d == "string" && d.includes(`
|
|
56
56
|
`) && (u = String(d).split(`
|
|
57
|
-
`).map(function(m,
|
|
58
|
-
return
|
|
57
|
+
`).map(function(m, T) {
|
|
58
|
+
return T === 0 ? m : "" + h + m;
|
|
59
59
|
}).join(`
|
|
60
60
|
`)), l += u + o[g + 1];
|
|
61
61
|
}), l;
|
|
62
62
|
}
|
|
63
63
|
p(M, "dedent");
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
s.dedent = M;
|
|
65
|
+
s.default = M;
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
// src/outline/index.ts
|
|
69
69
|
var N = {};
|
|
70
|
-
|
|
70
|
+
E(N, {
|
|
71
71
|
default: () => G
|
|
72
72
|
});
|
|
73
|
-
module.exports =
|
|
74
|
-
var
|
|
73
|
+
module.exports = Y(N);
|
|
74
|
+
var R = require("storybook/preview-api");
|
|
75
75
|
|
|
76
76
|
// src/outline/preview.ts
|
|
77
77
|
var A = {};
|
|
78
|
-
|
|
78
|
+
E(A, {
|
|
79
79
|
decorators: () => D,
|
|
80
|
-
default: () =>
|
|
80
|
+
default: () => B,
|
|
81
81
|
initialGlobals: () => I
|
|
82
82
|
});
|
|
83
83
|
var P = require("storybook/preview-api");
|
|
84
84
|
|
|
85
85
|
// src/outline/constants.ts
|
|
86
|
-
var
|
|
86
|
+
var f = "outline";
|
|
87
87
|
|
|
88
88
|
// src/outline/withOutline.ts
|
|
89
89
|
var b = require("storybook/preview-api");
|
|
90
90
|
|
|
91
91
|
// src/outline/helpers.ts
|
|
92
92
|
var x = require("@storybook/global");
|
|
93
|
-
var
|
|
94
|
-
(Array.isArray(i) ? i : [i]).forEach(
|
|
95
|
-
}, "clearStyles"),
|
|
93
|
+
var y = /* @__PURE__ */ p((i) => {
|
|
94
|
+
(Array.isArray(i) ? i : [i]).forEach(q);
|
|
95
|
+
}, "clearStyles"), q = /* @__PURE__ */ p((i) => {
|
|
96
96
|
let t = typeof i == "string" ? i : i.join(""), n = x.global.document.getElementById(t);
|
|
97
97
|
n && n.parentElement && n.parentElement.removeChild(n);
|
|
98
|
-
}, "clearStyle"),
|
|
98
|
+
}, "clearStyle"), c = /* @__PURE__ */ p((i, t) => {
|
|
99
99
|
let n = x.global.document.getElementById(i);
|
|
100
100
|
if (n)
|
|
101
101
|
n.innerHTML !== t && (n.innerHTML = t);
|
|
@@ -106,7 +106,7 @@ var h = /* @__PURE__ */ p((i) => {
|
|
|
106
106
|
}, "addOutlineStyles");
|
|
107
107
|
|
|
108
108
|
// src/outline/outlineCSS.ts
|
|
109
|
-
var w =
|
|
109
|
+
var w = K(k(), 1);
|
|
110
110
|
function v(i) {
|
|
111
111
|
return w.dedent`
|
|
112
112
|
${i} body {
|
|
@@ -509,20 +509,20 @@ p(v, "outlineCSS");
|
|
|
509
509
|
|
|
510
510
|
// src/outline/withOutline.ts
|
|
511
511
|
var O = /* @__PURE__ */ p((i, t) => {
|
|
512
|
-
let n = t.globals || {}, o = [!0, "true"].includes(n[
|
|
512
|
+
let n = t.globals || {}, o = [!0, "true"].includes(n[f]), a = t.viewMode === "docs", $ = (0, b.useMemo)(() => v(a ? '[data-story-block="tr\
|
|
513
513
|
ue"]' : ".sb-show-main"), [t]);
|
|
514
514
|
return (0, b.useEffect)(() => {
|
|
515
515
|
let l = a ? `addon-outline-docs-${t.id}` : "addon-outline";
|
|
516
|
-
return o ?
|
|
517
|
-
|
|
516
|
+
return o ? c(l, $) : y(l), () => {
|
|
517
|
+
y(l);
|
|
518
518
|
};
|
|
519
|
-
}, [o,
|
|
519
|
+
}, [o, $, t]), i();
|
|
520
520
|
}, "withOutline");
|
|
521
521
|
|
|
522
522
|
// src/outline/preview.ts
|
|
523
|
-
var D = [O], I = {
|
|
524
|
-
[
|
|
525
|
-
},
|
|
523
|
+
var D = globalThis.FEATURES?.outline ? [O] : [], I = {
|
|
524
|
+
[f]: !1
|
|
525
|
+
}, B = /* @__PURE__ */ p(() => (0, P.definePreview)({ decorators: D, initialGlobals: I }), "default");
|
|
526
526
|
|
|
527
527
|
// src/outline/index.ts
|
|
528
|
-
var G = /* @__PURE__ */ p(() => (0,
|
|
528
|
+
var G = /* @__PURE__ */ p(() => (0, R.definePreview)(A), "default");
|