storybook 9.0.0-alpha.2 → 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.
Files changed (162) 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/assets/server/base-preview-head.html +1 -3
  19. package/bin/index.cjs +2 -2
  20. package/dist/actions/decorator.d.ts +6 -0
  21. package/dist/actions/decorator.js +134 -0
  22. package/dist/actions/index.cjs +123 -0
  23. package/dist/actions/index.d.ts +102 -0
  24. package/dist/actions/index.js +108 -0
  25. package/dist/actions/preview.cjs +161 -0
  26. package/dist/actions/preview.d.ts +54 -0
  27. package/dist/actions/preview.js +152 -0
  28. package/dist/babel/index.cjs +822 -816
  29. package/dist/babel/index.js +822 -816
  30. package/dist/backgrounds/index.cjs +148 -0
  31. package/dist/backgrounds/index.d.ts +91 -0
  32. package/dist/backgrounds/index.js +130 -0
  33. package/dist/backgrounds/preview.cjs +143 -0
  34. package/dist/backgrounds/preview.d.ts +54 -0
  35. package/dist/backgrounds/preview.js +127 -0
  36. package/dist/bin/index.cjs +49 -70
  37. package/dist/bin/index.js +49 -70
  38. package/dist/builder-manager/index.cjs +319 -326
  39. package/dist/builder-manager/index.js +576 -583
  40. package/dist/channels/index.cjs +1026 -981
  41. package/dist/channels/index.js +1258 -1207
  42. package/dist/cli/bin/index.cjs +483 -483
  43. package/dist/cli/bin/index.js +495 -495
  44. package/dist/cli/index.cjs +61735 -7590
  45. package/dist/cli/index.d.ts +25 -21
  46. package/dist/cli/index.js +61776 -7631
  47. package/dist/client-logger/index.cjs +56 -88
  48. package/dist/client-logger/index.js +41 -47
  49. package/dist/common/index.cjs +16137 -9085
  50. package/dist/common/index.d.ts +35 -30
  51. package/dist/common/index.js +16230 -9172
  52. package/dist/component-testing/index.cjs +23 -0
  53. package/dist/component-testing/index.d.ts +3 -0
  54. package/dist/component-testing/index.js +5 -0
  55. package/dist/component-testing/preview.cjs +40 -0
  56. package/dist/component-testing/preview.d.ts +5 -0
  57. package/dist/component-testing/preview.js +25 -0
  58. package/dist/components/index.cjs +16268 -24926
  59. package/dist/components/index.d.ts +98 -347
  60. package/dist/components/index.js +5905 -19177
  61. package/dist/controls/decorator.d.ts +5 -0
  62. package/dist/controls/decorator.js +8 -0
  63. package/dist/controls/index.cjs +26 -0
  64. package/dist/controls/index.d.ts +39 -0
  65. package/dist/controls/index.js +6 -0
  66. package/dist/controls/preview.cjs +26 -0
  67. package/dist/controls/preview.d.ts +54 -0
  68. package/dist/controls/preview.js +9 -0
  69. package/dist/core-events/index.cjs +91 -106
  70. package/dist/core-events/index.d.ts +139 -104
  71. package/dist/core-events/index.js +79 -94
  72. package/dist/core-server/index.cjs +13898 -13409
  73. package/dist/core-server/index.d.ts +270 -3
  74. package/dist/core-server/index.js +13981 -13497
  75. package/dist/core-server/presets/common-manager.css +170 -0
  76. package/dist/core-server/presets/common-manager.js +12149 -17
  77. package/dist/core-server/presets/common-preset.cjs +3009 -3155
  78. package/dist/core-server/presets/common-preset.js +2862 -3009
  79. package/dist/csf/index.cjs +76 -120
  80. package/dist/csf/index.d.ts +2 -6
  81. package/dist/csf/index.js +69 -113
  82. package/dist/csf-tools/index.cjs +412 -403
  83. package/dist/csf-tools/index.d.ts +0 -4
  84. package/dist/csf-tools/index.js +410 -401
  85. package/dist/docs-tools/index.cjs +2569 -575
  86. package/dist/docs-tools/index.d.ts +2 -2
  87. package/dist/docs-tools/index.js +2565 -564
  88. package/dist/highlight/index.cjs +27 -0
  89. package/dist/highlight/index.d.ts +61 -0
  90. package/dist/highlight/index.js +7 -0
  91. package/dist/highlight/preview.cjs +535 -0
  92. package/dist/highlight/preview.d.ts +54 -0
  93. package/dist/highlight/preview.js +519 -0
  94. package/dist/instrumenter/index.cjs +2207 -2342
  95. package/dist/instrumenter/index.d.ts +8 -7
  96. package/dist/instrumenter/index.js +2430 -2603
  97. package/dist/manager/globals-module-info.cjs +291 -151
  98. package/dist/manager/globals-module-info.d.ts +1 -1
  99. package/dist/manager/globals-module-info.js +275 -135
  100. package/dist/manager/globals-runtime.js +60263 -28383
  101. package/dist/manager/globals.cjs +23 -19
  102. package/dist/manager/globals.d.ts +8 -5
  103. package/dist/manager/globals.js +10 -6
  104. package/dist/manager/runtime.js +4625 -3921
  105. package/dist/manager-api/index.cjs +4228 -3833
  106. package/dist/manager-api/index.d.ts +398 -102
  107. package/dist/manager-api/index.js +3500 -3084
  108. package/dist/manager-errors.d.ts +25 -1
  109. package/dist/manager-errors.js +50 -30
  110. package/dist/measure/index.cjs +476 -0
  111. package/dist/measure/index.d.ts +66 -0
  112. package/dist/measure/index.js +464 -0
  113. package/dist/measure/preview.cjs +466 -0
  114. package/dist/measure/preview.d.ts +59 -0
  115. package/dist/measure/preview.js +450 -0
  116. package/dist/outline/index.cjs +528 -0
  117. package/dist/outline/index.d.ts +66 -0
  118. package/dist/outline/index.js +500 -0
  119. package/dist/outline/preview.cjs +518 -0
  120. package/dist/outline/preview.d.ts +59 -0
  121. package/dist/outline/preview.js +486 -0
  122. package/dist/preview/globals.cjs +21 -17
  123. package/dist/preview/globals.d.ts +4 -1
  124. package/dist/preview/globals.js +6 -2
  125. package/dist/preview/runtime.js +46311 -6614
  126. package/dist/preview-api/index.cjs +1363 -1899
  127. package/dist/preview-api/index.d.ts +81 -395
  128. package/dist/preview-api/index.js +1711 -2169
  129. package/dist/preview-errors.cjs +119 -88
  130. package/dist/preview-errors.d.ts +30 -2
  131. package/dist/preview-errors.js +192 -142
  132. package/dist/router/index.cjs +847 -871
  133. package/dist/router/index.js +193 -199
  134. package/dist/server-errors.cjs +188 -124
  135. package/dist/server-errors.d.ts +36 -2
  136. package/dist/server-errors.js +188 -124
  137. package/dist/telemetry/index.cjs +1056 -1979
  138. package/dist/telemetry/index.d.ts +26 -5
  139. package/dist/telemetry/index.js +1091 -2010
  140. package/dist/test/index.cjs +35686 -0
  141. package/dist/test/index.d.ts +186 -0
  142. package/dist/test/index.js +33840 -0
  143. package/dist/test/preview.cjs +15870 -0
  144. package/dist/test/preview.d.ts +48 -0
  145. package/dist/test/preview.js +14501 -0
  146. package/dist/test/spy.cjs +258 -0
  147. package/dist/test/spy.d.ts +66 -0
  148. package/dist/test/spy.js +240 -0
  149. package/dist/theming/create.cjs +79 -2269
  150. package/dist/theming/create.js +67 -841
  151. package/dist/theming/index.cjs +1065 -3232
  152. package/dist/theming/index.js +951 -1719
  153. package/dist/types/index.cjs +11 -12
  154. package/dist/types/index.d.ts +684 -163
  155. package/dist/types/index.js +1 -2
  156. package/dist/viewport/index.cjs +310 -0
  157. package/dist/viewport/index.d.ts +320 -0
  158. package/dist/viewport/index.js +290 -0
  159. package/dist/viewport/preview.cjs +35 -0
  160. package/dist/viewport/preview.d.ts +68 -0
  161. package/dist/viewport/preview.js +19 -0
  162. package/package.json +359 -12
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var I = Object.defineProperty;
3
+ var G = Object.getOwnPropertyDescriptor;
4
+ var _ = Object.getOwnPropertyNames;
5
+ var n = Object.prototype.hasOwnProperty;
6
+ var L = (o, t) => {
7
+ for (var H in t)
8
+ I(o, H, { get: t[H], enumerable: !0 });
9
+ }, T = (o, t, H, s) => {
10
+ if (t && typeof t == "object" || typeof t == "function")
11
+ for (let e of _(t))
12
+ !n.call(o, e) && e !== H && I(o, e, { get: () => t[e], enumerable: !(s = G(t, e)) || s.enumerable });
13
+ return o;
14
+ };
15
+ var c = (o) => T(I({}, "__esModule", { value: !0 }), o);
16
+
17
+ // src/highlight/index.ts
18
+ var x = {};
19
+ L(x, {
20
+ HIGHLIGHT: () => i,
21
+ RESET_HIGHLIGHT: () => p,
22
+ SCROLL_INTO_VIEW: () => E
23
+ });
24
+ module.exports = c(x);
25
+
26
+ // src/highlight/constants.ts
27
+ var r = "storybook/highlight", i = `${r}/add`, l = `${r}/remove`, p = `${r}/reset`, E = `${r}/scroll-into-view`;
@@ -0,0 +1,61 @@
1
+ declare const HIGHLIGHT = "storybook/highlight/add";
2
+ declare const RESET_HIGHLIGHT = "storybook/highlight/reset";
3
+ declare const SCROLL_INTO_VIEW = "storybook/highlight/scroll-into-view";
4
+
5
+ interface HighlightParameters {
6
+ /**
7
+ * Highlight configuration
8
+ *
9
+ * @see https://storybook.js.org/docs/essentials/highlight#parameters
10
+ */
11
+ highlight: {
12
+ /** Remove the addon panel and disable the addon's behavior */
13
+ disable?: boolean;
14
+ };
15
+ }
16
+ interface HighlightOptions {
17
+ /** Unique identifier for the highlight, required if you want to remove the highlight later */
18
+ id?: string;
19
+ /** HTML selectors of the elements */
20
+ selectors: string[];
21
+ /** Priority of the highlight, higher takes precedence, defaults to 0 */
22
+ priority?: number;
23
+ /** Whether the highlight is selectable (reveals the element's HTML) */
24
+ selectable?: boolean;
25
+ /** CSS styles to apply to the highlight */
26
+ styles: Record<string, string>;
27
+ /** CSS styles to apply to the highlight when it is hovered */
28
+ hoverStyles?: Record<string, string>;
29
+ /** CSS styles to apply to the highlight when it is focused or selected */
30
+ focusStyles?: Record<string, string>;
31
+ /** Keyframes required for animations */
32
+ keyframes?: string;
33
+ /** Menu items to show when the highlight is selected (implies selectable: true) */
34
+ menu?: {
35
+ /** Unique identifier for the menu item */
36
+ id: string;
37
+ /** Title of the menu item */
38
+ title: string;
39
+ /** Description of the menu item */
40
+ description?: string;
41
+ /** Name for a channel event to trigger when the menu item is clicked */
42
+ clickEvent?: string;
43
+ /** HTML selectors for which this menu item should show (subset of `selectors`) */
44
+ selectors?: string[];
45
+ }[];
46
+ }
47
+ interface ClickEventDetails {
48
+ top: number;
49
+ left: number;
50
+ width: number;
51
+ height: number;
52
+ selectors: string[];
53
+ element: {
54
+ attributes: Record<string, string>;
55
+ localName: string;
56
+ tagName: string;
57
+ outerHTML: string;
58
+ };
59
+ }
60
+
61
+ export { type ClickEventDetails, HIGHLIGHT, type HighlightOptions, type HighlightParameters, RESET_HIGHLIGHT, SCROLL_INTO_VIEW };
@@ -0,0 +1,7 @@
1
+ // src/highlight/constants.ts
2
+ var t = "storybook/highlight", o = `${t}/add`, r = `${t}/remove`, e = `${t}/reset`, H = `${t}/scroll-into-view`;
3
+ export {
4
+ o as HIGHLIGHT,
5
+ e as RESET_HIGHLIGHT,
6
+ H as SCROLL_INTO_VIEW
7
+ };
@@ -0,0 +1,535 @@
1
+ "use strict";
2
+ var F = Object.defineProperty;
3
+ var ae = Object.getOwnPropertyDescriptor;
4
+ var de = Object.getOwnPropertyNames;
5
+ var pe = Object.prototype.hasOwnProperty;
6
+ var l = (t, e) => F(t, "name", { value: e, configurable: !0 });
7
+ var ge = (t, e) => {
8
+ for (var c in e)
9
+ F(t, c, { get: e[c], enumerable: !0 });
10
+ }, ue = (t, e, c, a) => {
11
+ if (e && typeof e == "object" || typeof e == "function")
12
+ for (let i of de(e))
13
+ !pe.call(t, i) && i !== c && F(t, i, { get: () => e[i], enumerable: !(a = ae(e, i)) || a.enumerable });
14
+ return t;
15
+ };
16
+ var me = (t) => ue(F({}, "__esModule", { value: !0 }), t);
17
+
18
+ // src/highlight/preview.ts
19
+ var xe = {};
20
+ ge(xe, {
21
+ default: () => we
22
+ });
23
+ module.exports = me(xe);
24
+ var $ = require("storybook/preview-api");
25
+
26
+ // src/highlight/useHighlights.ts
27
+ var Z = require("storybook/internal/core-events");
28
+
29
+ // src/highlight/constants.ts
30
+ var _ = "storybook/highlight", X = `${_}/add`, oe = `${_}/remove`, P = `${_}/reset`, Y = `${_}/scroll-into-view`, V = 2147483647;
31
+
32
+ // src/highlight/utils.ts
33
+ var fe = "svg,path,rect,circle,line,polyline,polygon,ellipse,text".split(","), y = /* @__PURE__ */ l((t, e, c) => {
34
+ let a = fe.includes(t) ? document.createElementNS("http://www.w3.org/2000/svg", t) : document.createElement(t);
35
+ return Object.entries(e).forEach(([i, g]) => {
36
+ /[A-Z]/.test(i) ? (i === "onClick" && (a.addEventListener("click", g), a.addEventListener("keydown", (p) => {
37
+ (p.key === "Enter" || p.key === " ") && (p.preventDefault(), g());
38
+ })), i === "onMouseEnter" && a.addEventListener("mouseenter", g), i === "onMouseLeave" && a.addEventListener("mouseleave", g)) : a.setAttribute(
39
+ i, g);
40
+ }), c?.forEach((i) => {
41
+ if (!(i == null || i === !1))
42
+ try {
43
+ a.appendChild(i);
44
+ } catch {
45
+ a.appendChild(document.createTextNode(String(i)));
46
+ }
47
+ }), a;
48
+ }, "createElement"), ne = /* @__PURE__ */ l((t) => {
49
+ if ("elements" in t) {
50
+ let { elements: e, color: c, style: a } = t;
51
+ return {
52
+ selectors: e,
53
+ styles: {
54
+ outline: `2px ${a} ${c}`,
55
+ outlineOffset: "2px",
56
+ boxShadow: "0 0 0 6px rgba(255,255,255,0.6)"
57
+ }
58
+ };
59
+ }
60
+ return t;
61
+ }, "convertLegacy"), he = /* @__PURE__ */ l((t) => t instanceof Function, "isFunction"), A = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(),
62
+ I = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ l((t) => {
63
+ let e = Symbol();
64
+ return O.set(e, []), A.set(e, t), { get: /* @__PURE__ */ l(() => A.get(e), "get"), set: /* @__PURE__ */ l((p) => {
65
+ let u = A.get(e), m = he(p) ? p(u) : p;
66
+ m !== u && (A.set(e, m), O.get(e)?.forEach((x) => {
67
+ I.get(x)?.(), I.set(x, x(m));
68
+ }));
69
+ }, "set"), subscribe: /* @__PURE__ */ l((p) => (O.get(e)?.push(p), () => {
70
+ let u = O.get(e);
71
+ u && O.set(
72
+ e,
73
+ u.filter((m) => m !== p)
74
+ );
75
+ }), "subscribe"), teardown: /* @__PURE__ */ l(() => {
76
+ O.get(e)?.forEach((p) => {
77
+ I.get(p)?.(), I.delete(p);
78
+ }), O.delete(e), A.delete(e);
79
+ }, "teardown") };
80
+ }, "useStore"), q = /* @__PURE__ */ l((t) => {
81
+ let e = document.getElementById("storybook-root"), c = /* @__PURE__ */ new Map();
82
+ for (let a of t) {
83
+ let { priority: i = 0, selectable: g = !!a.menu } = a;
84
+ for (let p of a.selectors)
85
+ for (let u of e?.querySelectorAll(p) || []) {
86
+ let m = c.get(u);
87
+ (!m || m.priority < i) && c.set(u, {
88
+ ...a,
89
+ priority: i,
90
+ selectors: (m?.selectors || []).concat(p),
91
+ selectable: g
92
+ });
93
+ }
94
+ }
95
+ return c;
96
+ }, "mapElements"), se = /* @__PURE__ */ l((t) => Array.from(t.entries()).map(([e, { selectors: c, styles: a, hoverStyles: i, focusStyles: g,
97
+ selectable: p, menu: u }]) => {
98
+ let { top: m, left: x, width: E, height: M } = e.getBoundingClientRect(), { position: v } = getComputedStyle(e);
99
+ return {
100
+ element: e,
101
+ selectors: c,
102
+ selectable: p,
103
+ styles: a,
104
+ hoverStyles: i,
105
+ focusStyles: g,
106
+ menu: u,
107
+ top: v === "fixed" ? m : m + window.scrollY,
108
+ left: v === "fixed" ? x : x + window.scrollX,
109
+ width: E,
110
+ height: M
111
+ };
112
+ }).sort((e, c) => c.width * c.height - e.width * e.height), "mapBoxes"), z = /* @__PURE__ */ l((t, e) => {
113
+ let c = t.getBoundingClientRect(), { x: a, y: i } = e;
114
+ return c?.top && c?.left && a >= c.left && a <= c.left + c.width && i >= c.top && i <= c.top + c.height;
115
+ }, "isOverMenu"), j = /* @__PURE__ */ l((t, e, c) => {
116
+ if (!c)
117
+ return !1;
118
+ let { left: a, top: i, width: g, height: p } = t;
119
+ (p === 0 || g === 0) && (a -= 10, i -= 10, g += 20, p += 20), e.style.position === "fixed" && (a += window.scrollX, i += window.scrollY);
120
+ let { x: u, y: m } = c;
121
+ return u >= a && u <= a + g && m >= i && m <= i + p;
122
+ }, "isTargeted"), ie = /* @__PURE__ */ l((t, e, c = {}) => {
123
+ let { x: a, y: i } = e, { margin: g = 5, topOffset: p = 0, centered: u = !1 } = c, { scrollX: m, scrollY: x, innerHeight: E, innerWidth: M } = window,
124
+ v = Math.min(
125
+ t.style.position === "fixed" ? i - x : i,
126
+ E - t.clientHeight - g - p + x
127
+ ), w = u ? t.clientWidth / 2 : 0, H = t.style.position === "fixed" ? Math.max(Math.min(a - m, M - w - g), w + g) : Math.max(
128
+ Math.min(a, M - w - g + m),
129
+ w + g + m
130
+ );
131
+ Object.assign(t.style, {
132
+ ...H !== a && { left: `${H}px` },
133
+ ...v !== i && { top: `${v}px` }
134
+ });
135
+ }, "keepInViewport"), W = /* @__PURE__ */ l((t) => {
136
+ window.HTMLElement.prototype.hasOwnProperty("showPopover") && t.showPopover();
137
+ }, "showPopover"), re = /* @__PURE__ */ l((t) => {
138
+ window.HTMLElement.prototype.hasOwnProperty("showPopover") && t.hidePopover();
139
+ }, "hidePopover"), le = /* @__PURE__ */ l((t) => ({
140
+ top: t.top,
141
+ left: t.left,
142
+ width: t.width,
143
+ height: t.height,
144
+ selectors: t.selectors,
145
+ element: {
146
+ attributes: Object.fromEntries(
147
+ Array.from(t.element.attributes).map((e) => [e.name, e.value])
148
+ ),
149
+ localName: t.element.localName,
150
+ tagName: t.element.tagName,
151
+ outerHTML: t.element.outerHTML
152
+ }
153
+ }), "getEventDetails");
154
+
155
+ // src/highlight/useHighlights.ts
156
+ var be = /* @__PURE__ */ l(() => y(
157
+ "svg",
158
+ { width: "14", height: "14", viewBox: "0 0 14 14", xmlns: "http://www.w3.org/2000/svg" },
159
+ [
160
+ y("path", {
161
+ fillRule: "evenodd",
162
+ clipRule: "evenodd",
163
+ d: "M9.10355 10.1464C9.29882 10.3417 9.29882 10.6583 9.10355 10.8536C8.90829 11.0488 8.59171 11.0488 8.39645 10.8536L4.89645 7.35355C4\
164
+ .70118 7.15829 4.70118 6.84171 4.89645 6.64645L8.39645 3.14645C8.59171 2.95118 8.90829 2.95118 9.10355 3.14645C9.29882 3.34171 9.29882 3.658\
165
+ 29 9.10355 3.85355L5.95711 7L9.10355 10.1464Z",
166
+ fill: "currentColor"
167
+ })
168
+ ]
169
+ ), "chevronLeft"), ye = /* @__PURE__ */ l(() => y(
170
+ "svg",
171
+ { width: "14", height: "14", viewBox: "0 0 14 14", xmlns: "http://www.w3.org/2000/svg" },
172
+ [
173
+ y("path", {
174
+ fillRule: "evenodd",
175
+ clipRule: "evenodd",
176
+ d: "M4.89645 10.1464C4.70118 10.3417 4.70118 10.6583 4.89645 10.8536C5.09171 11.0488 5.40829 11.0488 5.60355 10.8536L9.10355 7.35355C9\
177
+ .29882 7.15829 9.29882 6.84171 9.10355 6.64645L5.60355 3.14645C5.40829 2.95118 5.09171 2.95118 4.89645 3.14645C4.70118 3.34171 4.70118 3.658\
178
+ 29 4.89645 3.85355L8.04289 7L4.89645 10.1464Z",
179
+ fill: "currentColor"
180
+ })
181
+ ]
182
+ ), "chevronRight"), ce = /* @__PURE__ */ l(({
183
+ channel: t,
184
+ menuId: e = "storybook-highlights-menu",
185
+ rootId: c = "storybook-highlights-root",
186
+ storybookRootId: a = "storybook-root"
187
+ }) => {
188
+ globalThis.__STORYBOOK_HIGHLIGHT_TEARDOWN?.();
189
+ let { document: i } = globalThis, g = T([]), p = T(/* @__PURE__ */ new Map()), u = T([]), m = T(), x = T(), E = T([]), M = T([]), v = T(),
190
+ w = T(), H = i.getElementById(c);
191
+ g.subscribe(() => {
192
+ H || (H = y("div", { id: c }), i.body.appendChild(H));
193
+ }), g.subscribe((o) => {
194
+ let n = i.getElementById(a);
195
+ if (!n)
196
+ return;
197
+ p.set(q(o));
198
+ let s = new MutationObserver(() => p.set(q(o)));
199
+ return s.observe(n, { subtree: !0, childList: !0 }), () => {
200
+ s.disconnect();
201
+ };
202
+ }), p.subscribe((o) => {
203
+ let n = /* @__PURE__ */ l(() => requestAnimationFrame(() => u.set(se(o))), "updateBoxes"), s = new ResizeObserver(n);
204
+ s.observe(i.body), Array.from(o.keys()).forEach((r) => s.observe(r));
205
+ let d = Array.from(i.body.querySelectorAll("*")).filter((r) => {
206
+ let { overflow: f, overflowX: h, overflowY: b } = window.getComputedStyle(r);
207
+ return ["auto", "scroll"].some((L) => [f, h, b].includes(L));
208
+ });
209
+ return d.forEach((r) => r.addEventListener("scroll", n)), () => {
210
+ s.disconnect(), d.forEach((r) => r.removeEventListener("scroll", n));
211
+ };
212
+ }), p.subscribe((o) => {
213
+ let n = Array.from(o.keys()).filter(({ style: d }) => d.position === "sticky"), s = /* @__PURE__ */ l(() => requestAnimationFrame(() => {
214
+ u.set(
215
+ (d) => d.map((r) => {
216
+ if (n.includes(r.element)) {
217
+ let { top: f, left: h } = r.element.getBoundingClientRect();
218
+ return { ...r, top: f + window.scrollY, left: h + window.scrollX };
219
+ }
220
+ return r;
221
+ })
222
+ );
223
+ }), "updateBoxes");
224
+ return i.addEventListener("scroll", s), () => i.removeEventListener("scroll", s);
225
+ }), p.subscribe((o) => {
226
+ E.set((n) => n.filter(({ element: s }) => o.has(s)));
227
+ }), E.subscribe((o) => {
228
+ o.length ? (w.set((n) => o.some((s) => s.element === n?.element) ? n : void 0), v.set((n) => o.some((s) => s.element === n?.element) ? n :
229
+ void 0)) : (w.set(void 0), v.set(void 0), m.set(void 0));
230
+ });
231
+ let k = new Map(/* @__PURE__ */ new Map());
232
+ g.subscribe((o) => {
233
+ o.forEach(({ keyframes: n }) => {
234
+ if (n) {
235
+ let s = k.get(n);
236
+ s || (s = i.createElement("style"), s.setAttribute("data-highlight", "keyframes"), k.set(n, s), i.head.appendChild(s)), s.innerHTML =
237
+ n;
238
+ }
239
+ }), k.forEach((n, s) => {
240
+ o.some((d) => d.keyframes === s) || (n.remove(), k.delete(s));
241
+ });
242
+ });
243
+ let C = new Map(/* @__PURE__ */ new Map());
244
+ u.subscribe((o) => {
245
+ o.forEach((n) => {
246
+ let s = C.get(n.element);
247
+ if (H && !s) {
248
+ let d = {
249
+ popover: "manual",
250
+ "data-highlight-dimensions": `w${n.width.toFixed(0)}h${n.height.toFixed(0)}`,
251
+ "data-highlight-coordinates": `x${n.left.toFixed(0)}y${n.top.toFixed(0)}`
252
+ };
253
+ s = H.appendChild(y("div", d)), C.set(n.element, s);
254
+ }
255
+ }), C.forEach((n, s) => {
256
+ o.some(({ element: d }) => d === s) || (n.remove(), C.delete(s));
257
+ });
258
+ }), u.subscribe((o) => {
259
+ let n = o.filter((d) => d.selectable);
260
+ if (!n.length)
261
+ return;
262
+ let s = /* @__PURE__ */ l((d) => {
263
+ requestAnimationFrame(() => {
264
+ let r = i.getElementById(e), f = { x: d.pageX, y: d.pageY };
265
+ if (r && !z(r, f)) {
266
+ let h = n.filter((b) => {
267
+ let L = C.get(b.element);
268
+ return j(b, L, f);
269
+ });
270
+ m.set(h.length ? f : void 0), E.set(h);
271
+ }
272
+ });
273
+ }, "onClick");
274
+ return i.addEventListener("click", s), () => i.removeEventListener("click", s);
275
+ });
276
+ let K = /* @__PURE__ */ l(() => {
277
+ let o = i.getElementById(e), n = x.get();
278
+ !n || o && z(o, n) || M.set((s) => {
279
+ let d = u.get().filter((b) => {
280
+ let L = C.get(b.element);
281
+ return j(b, L, n);
282
+ }), r = s.filter((b) => d.includes(b)), f = d.filter((b) => !s.includes(b)), h = s.length - r.length;
283
+ return f.length || h ? [...r, ...f] : s;
284
+ });
285
+ }, "updateHovered");
286
+ x.subscribe(K), u.subscribe(K);
287
+ let B = /* @__PURE__ */ l(() => {
288
+ let o = w.get(), n = o ? [o] : E.get(), s = n.length === 1 ? n[0] : v.get(), d = m.get() !== void 0;
289
+ u.get().forEach((r) => {
290
+ let f = C.get(r.element);
291
+ if (f) {
292
+ let h = s === r, b = d ? s ? h : n.includes(r) : M.get()?.includes(r);
293
+ Object.assign(f.style, {
294
+ animation: "none",
295
+ background: "transparent",
296
+ border: "none",
297
+ boxSizing: "border-box",
298
+ outline: "none",
299
+ outlineOffset: "0px",
300
+ ...r.styles,
301
+ ...b ? r.hoverStyles : {},
302
+ ...h ? r.focusStyles : {},
303
+ position: getComputedStyle(r.element).position === "fixed" ? "fixed" : "absolute",
304
+ zIndex: V - 10,
305
+ top: `${r.top}px`,
306
+ left: `${r.left}px`,
307
+ width: `${r.width}px`,
308
+ height: `${r.height}px`,
309
+ margin: 0,
310
+ padding: 0,
311
+ cursor: r.selectable ? "pointer" : "default",
312
+ pointerEvents: r.selectable ? "auto" : "none"
313
+ }), W(f);
314
+ }
315
+ });
316
+ }, "updateBoxStyles");
317
+ u.subscribe(B), E.subscribe(B), M.subscribe(B), v.subscribe(B), w.subscribe(B);
318
+ let J = /* @__PURE__ */ l(() => {
319
+ if (!H)
320
+ return;
321
+ let o = i.getElementById(e);
322
+ if (o)
323
+ o.innerHTML = "";
324
+ else {
325
+ let r = { id: e, popover: "manual" };
326
+ o = H.appendChild(y("div", r)), H.appendChild(
327
+ y("style", {}, [
328
+ `
329
+ #${e} {
330
+ position: absolute;
331
+ z-index: ${V};
332
+ width: 300px;
333
+ padding: 0px;
334
+ margin: 15px 0 0 0;
335
+ transform: translateX(-50%);
336
+ font-family: "Nunito Sans", -apple-system, ".SFNSText-Regular", "San Francisco", BlinkMacSystemFont, "Segoe UI", "Helvetica Ne\
337
+ ue", Helvetica, Arial, sans-serif;
338
+ font-size: 12px;
339
+ background: white;
340
+ border: none;
341
+ border-radius: 6px;
342
+ box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.05), 0 5px 15px 0 rgba(0, 0, 0, 0.1);
343
+ color: #2E3438;
344
+ }
345
+ #${e} ul {
346
+ list-style: none;
347
+ padding: 4px 0;
348
+ margin: 0;
349
+ max-height: 300px;
350
+ overflow-y: auto;
351
+ }
352
+ #${e} li {
353
+ padding: 0 4px;
354
+ margin: 0;
355
+ }
356
+ #${e} li > * {
357
+ display: flex;
358
+ padding: 8px;
359
+ margin: 0;
360
+ align-items: center;
361
+ gap: 8px;
362
+ border-radius: 4px;
363
+ }
364
+ #${e} button {
365
+ width: 100%;
366
+ border: 0;
367
+ background: transparent;
368
+ color: inherit;
369
+ text-align: left;
370
+ font-family: inherit;
371
+ font-size: inherit;
372
+ }
373
+ #${e} button:focus {
374
+ outline-color: #029CFD;
375
+ }
376
+ #${e} button:hover {
377
+ background: rgba(2, 156, 253, 0.07);
378
+ color: #029CFD;
379
+ cursor: pointer;
380
+ }
381
+ #${e} li code {
382
+ white-space: nowrap;
383
+ overflow: hidden;
384
+ text-overflow: ellipsis;
385
+ line-height: 16px;
386
+ font-size: 11px;
387
+ }
388
+ #${e} li svg {
389
+ display: none;
390
+ flex-shrink: 0;
391
+ margin: 1px;
392
+ color: #73828C;
393
+ }
394
+ #${e} li > button:hover svg, #${e} li > button:focus svg {
395
+ color: #029CFD;
396
+ }
397
+ #${e} li.selectable svg, #${e} li.selected svg {
398
+ display: block;
399
+ }
400
+ #${e} .menu-list {
401
+ border-top: 1px solid rgba(38, 85, 115, 0.15);
402
+ }
403
+ #${e} .menu-list li:not(:last-child) {
404
+ padding-bottom: 4px;
405
+ margin-bottom: 4px;
406
+ border-bottom: 1px solid rgba(38, 85, 115, 0.15);
407
+ }
408
+ #${e} .menu-list li div {
409
+ display: flex;
410
+ flex-direction: column;
411
+ align-items: flex-start;
412
+ gap: 0;
413
+ }
414
+ #${e} .menu-list li small {
415
+ color: #5C6870;
416
+ font-size: 11px;
417
+ }
418
+ `
419
+ ])
420
+ );
421
+ }
422
+ let n = w.get(), s = n ? [n] : E.get();
423
+ if (s.length && (o.style.position = getComputedStyle(s[0].element).position === "fixed" ? "fixed" : "absolute", o.appendChild(
424
+ y(
425
+ "ul",
426
+ { class: "element-list" },
427
+ s.map((r) => {
428
+ let f = r.menu?.filter(
429
+ (S) => !S.selectors || S.selectors.some((R) => r.selectors.includes(R))
430
+ ), h = s.length > 1 && !!f?.length, b = h ? {
431
+ class: "selectable",
432
+ onClick: /* @__PURE__ */ l(() => w.set(r), "onClick"),
433
+ onMouseEnter: /* @__PURE__ */ l(() => v.set(r), "onMouseEnter"),
434
+ onMouseLeave: /* @__PURE__ */ l(() => v.set(void 0), "onMouseLeave")
435
+ } : n ? { class: "selected", onClick: /* @__PURE__ */ l(() => w.set(void 0), "onClick") } : {}, L = h || n;
436
+ return y("li", b, [
437
+ y(L ? "button" : "div", L ? { type: "button" } : {}, [
438
+ n ? be() : null,
439
+ y("code", {}, [r.element.outerHTML]),
440
+ h ? ye() : null
441
+ ])
442
+ ]);
443
+ })
444
+ )
445
+ )), w.get() || E.get().length === 1) {
446
+ let r = w.get() || E.get()[0], f = r.menu?.filter(
447
+ (h) => !h.selectors || h.selectors.some((b) => r.selectors.includes(b))
448
+ );
449
+ f?.length && o.appendChild(
450
+ y(
451
+ "ul",
452
+ { class: "menu-list" },
453
+ f.map(({ id: h, title: b, description: L, clickEvent: S }) => {
454
+ let R = S && (() => t.emit(S, h, le(r)));
455
+ return y("li", {}, [
456
+ y(
457
+ R ? "button" : "div",
458
+ R ? { type: "button", onClick: R } : {},
459
+ [
460
+ y("div", {}, [
461
+ y("strong", {}, [b]),
462
+ L && y("small", {}, [L])
463
+ ])
464
+ ]
465
+ )
466
+ ]);
467
+ })
468
+ )
469
+ );
470
+ }
471
+ let d = m.get();
472
+ d ? (Object.assign(o.style, {
473
+ display: "block",
474
+ left: `${o.style.position === "fixed" ? d.x - window.scrollX : d.x}px`,
475
+ top: `${o.style.position === "fixed" ? d.y - window.scrollY : d.y}px`
476
+ }), W(o), requestAnimationFrame(() => ie(o, d, { topOffset: 15, centered: !0 }))) : (re(o), Object.assign(o.style, { display: "none" }));
477
+ }, "renderMenu");
478
+ E.subscribe(J), w.subscribe(J);
479
+ let U = /* @__PURE__ */ l((o) => {
480
+ let n = ne(o);
481
+ n.selectors?.length && g.set((s) => [...s, n]);
482
+ }, "addHighlight"), N = /* @__PURE__ */ l((o) => {
483
+ g.set((n) => n.filter((s) => s.id !== o));
484
+ }, "removeHighlight"), D = /* @__PURE__ */ l(() => {
485
+ g.set([]);
486
+ }, "clearHighlights"), G, Q = /* @__PURE__ */ l((o, n) => {
487
+ let s = "scrollIntoView-highlight";
488
+ clearTimeout(G), N(s);
489
+ let d = i.querySelector(o);
490
+ if (!d) {
491
+ console.warn(`Cannot scroll into view: ${o} not found`);
492
+ return;
493
+ }
494
+ d.scrollIntoView({ behavior: "smooth", block: "center", ...n });
495
+ let r = `kf-${Math.random().toString(36).substring(2, 15)}`;
496
+ g.set((f) => [
497
+ ...f,
498
+ {
499
+ id: s,
500
+ priority: 1e3,
501
+ selectors: [o],
502
+ selectable: !1,
503
+ styles: {
504
+ outline: "2px solid #1EA7FD",
505
+ outlineOffset: "2px",
506
+ animation: `${r} 3s linear forwards`
507
+ },
508
+ keyframes: `@keyframes ${r} {
509
+ 0% { outline: 2px solid #1EA7FD; }
510
+ 20% { outline: 2px solid #1EA7FD00; }
511
+ 40% { outline: 2px solid #1EA7FD; }
512
+ 60% { outline: 2px solid #1EA7FD00; }
513
+ 80% { outline: 2px solid #1EA7FD; }
514
+ 100% { outline: 2px solid #1EA7FD00; }
515
+ }`
516
+ }
517
+ ]), G = setTimeout(() => N(s), 3500);
518
+ }, "scrollIntoView"), ee = /* @__PURE__ */ l((o) => {
519
+ requestAnimationFrame(() => x.set({ x: o.pageX, y: o.pageY }));
520
+ }, "onMouseMove");
521
+ i.body.addEventListener("mousemove", ee), t.on(X, U), t.on(oe, N), t.on(P, D), t.on(Z.STORY_CHANGED, D), t.on(Y, Q);
522
+ let te = /* @__PURE__ */ l(() => {
523
+ clearTimeout(G), i.body.removeEventListener("mousemove", ee), t.off(X, U), t.off(P, D), t.off(Z.STORY_CHANGED, D), t.off(Y, Q), g.teardown(),
524
+ p.teardown(), u.teardown(), E.teardown(), m.teardown(), x.teardown(), M.teardown(), v.teardown(), w.teardown(), k.forEach((o) => o.remove()),
525
+ C.forEach((o) => o.remove()), i.getElementById(e)?.remove(), i.getElementById(c)?.remove();
526
+ }, "teardown");
527
+ return globalThis.__STORYBOOK_HIGHLIGHT_TEARDOWN = te, te;
528
+ }, "useHighlights");
529
+
530
+ // src/highlight/preview.ts
531
+ $.addons && $.addons.ready && $.addons.ready().then(() => {
532
+ let t = $.addons.getChannel();
533
+ ce({ channel: t });
534
+ });
535
+ var we = /* @__PURE__ */ l(() => (0, $.definePreview)({}), "default");
@@ -0,0 +1,54 @@
1
+ import { Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, StoryIdentifier, StoryContext, PartialStoryFn, LegacyStoryFn } from 'storybook/internal/csf';
2
+ import { NormalizedProjectAnnotations, ProjectAnnotations as ProjectAnnotations$2, ComposedStoryFn } from 'storybook/internal/types';
3
+
4
+ declare global {
5
+ interface SymbolConstructor {
6
+ readonly observable: symbol;
7
+ }
8
+ }
9
+
10
+ interface Renderer extends Renderer$1 {
11
+ }
12
+
13
+ type MaybePromise<T> = Promise<T> | T;
14
+ type TeardownRenderToCanvas = () => MaybePromise<void>;
15
+ type RenderToCanvas<TRenderer extends Renderer> = (context: RenderContext<TRenderer>, element: TRenderer['canvasElement']) => MaybePromise<void | TeardownRenderToCanvas>;
16
+ interface ProjectAnnotations<TRenderer extends Renderer> extends ProjectAnnotations$1<TRenderer> {
17
+ addons?: ProjectAnnotations<TRenderer>[];
18
+ testingLibraryRender?: (...args: never[]) => {
19
+ unmount: () => void;
20
+ };
21
+ renderToCanvas?: RenderToCanvas<TRenderer>;
22
+ }
23
+ declare type RenderContext<TRenderer extends Renderer = Renderer> = StoryIdentifier & {
24
+ showMain: () => void;
25
+ showError: (error: {
26
+ title: string;
27
+ description: string;
28
+ }) => void;
29
+ showException: (err: Error) => void;
30
+ forceRemount: boolean;
31
+ storyContext: StoryContext<TRenderer>;
32
+ storyFn: PartialStoryFn<TRenderer>;
33
+ unboundStoryFn: LegacyStoryFn<TRenderer>;
34
+ };
35
+
36
+ declare global {
37
+ var globalProjectAnnotations: NormalizedProjectAnnotations<any>;
38
+ var defaultProjectAnnotations: ProjectAnnotations$2<any>;
39
+ }
40
+ type WrappedStoryRef = {
41
+ __pw_type: 'jsx' | 'importRef';
42
+ };
43
+ type UnwrappedJSXStoryRef = {
44
+ __pw_type: 'jsx';
45
+ type: UnwrappedImportStoryRef;
46
+ };
47
+ type UnwrappedImportStoryRef = ComposedStoryFn;
48
+ declare global {
49
+ function __pwUnwrapObject(storyRef: WrappedStoryRef): Promise<UnwrappedJSXStoryRef | UnwrappedImportStoryRef>;
50
+ }
51
+
52
+ declare const _default: () => ProjectAnnotations<Renderer>;
53
+
54
+ export { _default as default };