baseline-kit 3.0.1 → 5.0.0

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 (123) hide show
  1. package/README.md +99 -63
  2. package/dist/README.md +99 -63
  3. package/dist/baseline-kit.css +3 -21
  4. package/dist/core/src/config/defaults.d.ts +2 -0
  5. package/dist/core/src/config/index.d.ts +3 -0
  6. package/dist/core/src/config/merge.d.ts +21 -0
  7. package/dist/core/src/config/schema.d.ts +33 -0
  8. package/dist/core/src/descriptors/baseline.d.ts +26 -0
  9. package/dist/core/src/descriptors/box.d.ts +20 -0
  10. package/dist/core/src/descriptors/guide.d.ts +44 -0
  11. package/dist/core/src/descriptors/index.d.ts +5 -0
  12. package/dist/core/src/descriptors/padder.d.ts +19 -0
  13. package/dist/core/src/descriptors/spacer.d.ts +24 -0
  14. package/dist/core/src/index.d.ts +10 -0
  15. package/dist/core/src/types.d.ts +62 -0
  16. package/dist/core/src/utils/convert.d.ts +10 -0
  17. package/dist/core/src/utils/grid.d.ts +18 -0
  18. package/dist/{utils → core/src/utils}/index.d.ts +2 -9
  19. package/dist/core/src/utils/math.d.ts +9 -0
  20. package/dist/core/src/utils/merge.d.ts +28 -0
  21. package/dist/core/src/utils/normalize.d.ts +13 -0
  22. package/dist/core/src/utils/padding.d.ts +2 -0
  23. package/dist/core/src/utils/parse.d.ts +5 -0
  24. package/dist/core/src/utils/snapping.d.ts +2 -0
  25. package/dist/core/src/validation/guide.d.ts +3 -0
  26. package/dist/core/src/validation/index.d.ts +1 -0
  27. package/dist/core.cjs +1 -0
  28. package/dist/core.d.ts +344 -0
  29. package/dist/core.mjs +2 -0
  30. package/dist/dom/src/index.d.ts +11 -0
  31. package/dist/dom/src/measure.d.ts +18 -0
  32. package/dist/dom/src/observers.d.ts +5 -0
  33. package/dist/{utils → dom/src}/ssr.d.ts +0 -6
  34. package/dist/dom/src/timing.d.ts +2 -0
  35. package/dist/dom/src/viewport.d.ts +7 -0
  36. package/dist/dom/src/virtual.d.ts +23 -0
  37. package/dist/guide.cjs +2 -0
  38. package/dist/guide.cjs.map +1 -0
  39. package/dist/guide.css +2 -0
  40. package/dist/guide.d.ts +146 -0
  41. package/dist/guide.mjs +589 -0
  42. package/dist/guide.mjs.map +1 -0
  43. package/dist/index.cjs +2 -2
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.ts +197 -30
  46. package/dist/index.mjs +614 -1747
  47. package/dist/index.mjs.map +1 -1
  48. package/dist/react/src/components/Baseline/Baseline.d.ts +13 -0
  49. package/dist/react/src/components/Baseline/index.d.ts +1 -0
  50. package/dist/react/src/components/Box/Box.d.ts +26 -0
  51. package/dist/react/src/components/Box/index.d.ts +1 -0
  52. package/dist/react/src/components/Config/Config.d.ts +20 -0
  53. package/dist/react/src/components/Config/index.d.ts +2 -0
  54. package/dist/react/src/components/Guide/Guide.d.ts +16 -0
  55. package/dist/react/src/components/Guide/index.d.ts +1 -0
  56. package/dist/react/src/components/Padder/Padder.d.ts +20 -0
  57. package/dist/react/src/components/Padder/index.d.ts +1 -0
  58. package/dist/react/src/components/Spacer/Spacer.d.ts +14 -0
  59. package/dist/react/src/components/Spacer/index.d.ts +1 -0
  60. package/dist/{components → react/src/components}/index.d.ts +1 -5
  61. package/dist/react/src/components/types.d.ts +29 -0
  62. package/dist/react/src/guide.d.ts +10 -0
  63. package/dist/{hooks → react/src/hooks}/index.d.ts +2 -3
  64. package/dist/react/src/hooks/useBaseline.d.ts +26 -0
  65. package/dist/react/src/hooks/useConfig.d.ts +9 -0
  66. package/dist/react/src/hooks/useDebug.d.ts +6 -0
  67. package/dist/react/src/hooks/useGuide.d.ts +7 -0
  68. package/dist/{hooks → react/src/hooks}/useIsClient.d.ts +0 -2
  69. package/dist/react/src/hooks/useMeasure.d.ts +10 -0
  70. package/dist/react/src/hooks/useVirtual.d.ts +14 -0
  71. package/dist/react/src/index.d.ts +21 -0
  72. package/dist/react/src/utils/index.d.ts +9 -0
  73. package/dist/react/src/utils/merge.d.ts +10 -0
  74. package/dist/react/src/utils/ssr.d.ts +1 -0
  75. package/dist/reset.css +43 -0
  76. package/dist/src-CMjyHjX5.cjs +2 -0
  77. package/dist/src-CMjyHjX5.cjs.map +1 -0
  78. package/dist/src-QHaSfgVe.js +619 -0
  79. package/dist/src-QHaSfgVe.js.map +1 -0
  80. package/dist/styles.css +1 -1
  81. package/dist/theme/dark.css +0 -8
  82. package/dist/theme/default.css +0 -9
  83. package/dist/theme/tokens.css +1 -10
  84. package/dist/theme.css +0 -18
  85. package/package.json +82 -42
  86. package/dist/components/Baseline/Baseline.d.ts +0 -48
  87. package/dist/components/Baseline/index.d.ts +0 -6
  88. package/dist/components/Box/Box.d.ts +0 -73
  89. package/dist/components/Box/index.d.ts +0 -6
  90. package/dist/components/Config/Config.d.ts +0 -179
  91. package/dist/components/Config/defaults.d.ts +0 -25
  92. package/dist/components/Config/index.d.ts +0 -11
  93. package/dist/components/Guide/Guide.d.ts +0 -70
  94. package/dist/components/Guide/index.d.ts +0 -6
  95. package/dist/components/Guide/types.d.ts +0 -144
  96. package/dist/components/Guide/validation.d.ts +0 -82
  97. package/dist/components/Layout/Layout.d.ts +0 -73
  98. package/dist/components/Layout/index.d.ts +0 -10
  99. package/dist/components/Padder/Padder.d.ts +0 -67
  100. package/dist/components/Padder/index.d.ts +0 -10
  101. package/dist/components/Spacer/Spacer.d.ts +0 -48
  102. package/dist/components/Spacer/index.d.ts +0 -10
  103. package/dist/components/Stack/Stack.d.ts +0 -84
  104. package/dist/components/Stack/index.d.ts +0 -10
  105. package/dist/components/styles/index.d.ts +0 -11
  106. package/dist/components/types.d.ts +0 -102
  107. package/dist/hooks/useBaseline.d.ts +0 -55
  108. package/dist/hooks/useConfig.d.ts +0 -41
  109. package/dist/hooks/useDebug.d.ts +0 -49
  110. package/dist/hooks/useGuide.d.ts +0 -61
  111. package/dist/hooks/useMeasure.d.ts +0 -35
  112. package/dist/hooks/useVirtual.d.ts +0 -60
  113. package/dist/styles.d.ts +0 -6
  114. package/dist/theme.d.ts +0 -6
  115. package/dist/utils/convert.d.ts +0 -24
  116. package/dist/utils/grid.d.ts +0 -22
  117. package/dist/utils/math.d.ts +0 -48
  118. package/dist/utils/merge.d.ts +0 -117
  119. package/dist/utils/normalize.d.ts +0 -30
  120. package/dist/utils/padding.d.ts +0 -11
  121. package/dist/utils/parse.d.ts +0 -18
  122. package/dist/utils/snapping.d.ts +0 -28
  123. package/dist/utils/timing.d.ts +0 -45
package/dist/index.mjs CHANGED
@@ -1,1763 +1,630 @@
1
- import { jsx as y, Fragment as K, jsxs as Z } from "react/jsx-runtime";
2
- import * as l from "react";
3
- import { useState as mt, useEffect as St, useMemo as Q, useCallback as ot, useLayoutEffect as ht } from "react";
4
- const Ct = {
5
- /** Color for single-line guides */
6
- line: "var(--bk-guide-color-line-theme)",
7
- /** Color for pattern-based guides */
8
- pattern: "var(--bk-guide-color-pattern-theme)",
9
- /** Color for auto-calculated guides */
10
- auto: "var(--bk-guide-color-auto-theme)",
11
- /** Color for fixed-column guides */
12
- fixed: "var(--bk-guide-color-fixed-theme)"
13
- }, Mt = {
14
- /** Color for line variant */
15
- line: "var(--bk-baseline-color-line-theme)",
16
- /** Color for flat/block variant */
17
- flat: "var(--bk-baseline-color-flat-theme)"
18
- }, $t = {
19
- /** Color for line-style spacers */
20
- line: "var(--bk-spacer-color-line-theme)",
21
- /** Color for flat/block spacers */
22
- flat: "var(--bk-spacer-color-flat-theme)",
23
- /** Color for measurement indicators */
24
- text: "var(--bk-spacer-color-text-theme)"
25
- }, Rt = {
26
- /** Border color for debug outline */
27
- line: "var(--bk-box-color-line-theme)",
28
- /** Background color for debug mode */
29
- flat: "var(--bk-box-color-flat-theme)",
30
- /** Color for measurement indicators */
31
- text: "var(--bk-box-color-text-theme)"
32
- }, Et = {
33
- /** Border color for debug outline */
34
- line: "var(--bk-stack-color-line-theme)",
35
- /** Background color for debug mode */
36
- flat: "var(--bk-stack-color-flat-theme)",
37
- /** Color for measurement indicators */
38
- text: "var(--bk-stack-color-text-theme)"
39
- }, Vt = {
40
- /** Border color for debug outline */
41
- line: "var(--bk-layout-color-line-theme)",
42
- /** Background color for debug mode */
43
- flat: "var(--bk-layout-color-flat-theme)",
44
- /** Color for measurement indicators */
45
- text: "var(--bk-layout-color-text-theme)"
46
- }, Gt = "var(--bk-padder-color-theme)", Ot = {
47
- /** Base unit for spacing calculations (in pixels) */
48
- base: 8,
49
- /** Baseline grid configuration */
50
- baseline: {
51
- variant: "line",
52
- debugging: "hidden",
53
- colors: Mt
54
- },
55
- /** Guide overlay configuration */
56
- guide: {
57
- variant: "line",
58
- debugging: "hidden",
59
- colors: Ct
60
- },
61
- /** Spacer component configuration */
62
- spacer: {
63
- variant: "line",
64
- debugging: "hidden",
65
- colors: $t
66
- },
67
- /** Box component configuration */
68
- box: {
69
- debugging: "hidden",
70
- colors: Rt
71
- },
72
- /** Stack/Flex component configuration */
73
- stack: {
74
- debugging: "hidden",
75
- colors: Et
76
- },
77
- /** Layout component configuration */
78
- layout: {
79
- debugging: "hidden",
80
- colors: Vt
81
- },
82
- /** Padder component configuration */
83
- padder: {
84
- debugging: "hidden",
85
- color: Gt
86
- }
87
- }, rt = l.createContext(Ot);
88
- rt.displayName = "ConfigContext";
89
- const gt = () => l.use(rt), Dt = (t) => {
90
- const {
91
- parentConfig: e,
92
- base: n,
93
- baseline: s,
94
- guide: o,
95
- spacer: r,
96
- box: i,
97
- stack: a,
98
- layout: c,
99
- padder: d
100
- } = t;
101
- return {
102
- base: n ?? e.base,
103
- baseline: { ...e.baseline, ...s },
104
- guide: { ...e.guide, ...o },
105
- spacer: { ...e.spacer, ...r },
106
- box: { ...e.box, ...i },
107
- stack: { ...e.stack, ...a },
108
- layout: { ...e.layout, ...c },
109
- padder: { ...e.padder, ...d }
110
- };
111
- };
112
- function it({
113
- children: t,
114
- base: e,
115
- stack: n,
116
- baseline: s,
117
- guide: o,
118
- layout: r,
119
- spacer: i,
120
- box: a,
121
- padder: c
122
- }) {
123
- const d = gt(), f = l.useMemo(() => Dt({
124
- parentConfig: d,
125
- base: e,
126
- baseline: s,
127
- guide: o,
128
- spacer: i,
129
- box: a,
130
- stack: n,
131
- layout: r,
132
- padder: c
133
- }), [d, e, s, o, i, a, n, r, c]);
134
- return /* @__PURE__ */ y(rt, { value: f, children: t });
135
- }
136
- function _t(t) {
137
- const e = t.trim().match(/^([+-]?[\d.]+)([a-zA-Z%]+)$/);
138
- if (!e) return null;
139
- const n = parseFloat(e[1]), s = e[2];
140
- return { value: n, unit: s };
141
- }
142
- function O(t, e) {
143
- return t === void 0 && e !== void 0 ? `${e}px` : t === "auto" || typeof t == "string" && /^(auto|100%|0|.*(fr|vh|vw|vmin|vmax|rem))$/.test(t) ? String(t) : typeof t == "number" ? `${t}px` : t ?? "";
144
- }
145
- const At = {
146
- parentSize: 0,
147
- viewportWidth: typeof window < "u" ? window.innerWidth : 1920,
148
- viewportHeight: typeof window < "u" ? window.innerHeight : 1080,
149
- rootFontSize: 16,
150
- parentFontSize: 16
151
- }, lt = {
152
- px: 1,
153
- in: 96,
154
- // 1in = 96px
155
- cm: 37.8,
156
- // 1cm = 37.8px
157
- mm: 3.78,
158
- // 1mm = 3.78px
159
- pt: 1.33,
160
- // 1pt = 1.33px
161
- pc: 16
162
- // 1pc = 16px
163
- }, It = [
164
- "em",
165
- "rem",
166
- "vh",
167
- "vw",
168
- "vmin",
169
- "vmax",
170
- "%"
171
- ];
172
- function pt(t, e) {
173
- if (typeof t == "number") return t;
174
- if (typeof t != "string") return null;
175
- const n = _t(t);
176
- if (!n) return null;
177
- const { value: s, unit: o } = n;
178
- if (o in lt)
179
- return s * lt[o];
180
- if (o === "auto") return null;
181
- if (It.includes(o)) {
182
- const r = { ...At, ...e };
183
- switch (o) {
184
- case "em":
185
- return s * r.parentFontSize;
186
- case "rem":
187
- return s * r.rootFontSize;
188
- case "vh":
189
- return s / 100 * r.viewportHeight;
190
- case "vw":
191
- return s / 100 * r.viewportWidth;
192
- case "vmin":
193
- return s / 100 * Math.min(r.viewportWidth, r.viewportHeight);
194
- case "vmax":
195
- return s / 100 * Math.max(r.viewportWidth, r.viewportHeight);
196
- case "%":
197
- return s / 100 * r.parentSize;
198
- default:
199
- return null;
200
- }
201
- }
202
- return null;
203
- }
204
- function Lt(t, e, n) {
205
- return Math.min(Math.max(t, e), n);
206
- }
207
- function Nt(t) {
208
- const { height: e, top: n, bottom: s, base: o } = t, r = (e ?? 0) - (n + s);
209
- return Math.max(1, Math.floor(r / o));
210
- }
211
- function st(t, e = {}) {
212
- const {
213
- base: n = 8,
214
- round: s = !0,
215
- clamp: o,
216
- suppressWarnings: r = !1
217
- } = e;
218
- if (t === "auto") return n;
219
- let i = null;
220
- if (typeof t == "number")
221
- i = t;
222
- else if (typeof t == "string") {
223
- const d = pt(t);
224
- d === null ? (r || console.error(
225
- `Failed to convert "${t}" to pixels. Falling back to base ${n}.`
226
- ), i = n) : i = d;
227
- }
228
- i === null && (i = n);
229
- const a = s ? Math.round(i / n) * n : i, c = o !== void 0 ? Lt(
230
- a,
231
- o.min ?? -1 / 0,
232
- o.max ?? 1 / 0
233
- ) : a;
234
- return !r && c !== i && console.warn(`Normalized ${i} to ${c} to match base ${n}px.`), c;
235
- }
236
- function kt(t, e, n) {
237
- if (!t || t[0] === void 0 && t[1] === void 0)
238
- return e;
239
- const s = t[0] !== void 0 ? st(t[0], n) : e[0], o = t[1] !== void 0 ? st(t[1], n) : e[1];
240
- return [s, o];
1
+ import { O as e, a as t, f as n, h as r, i, k as a, m as o, n as s, o as c, p as l, r as u, s as d, t as f } from "./src-QHaSfgVe.js";
2
+ import * as p from "react";
3
+ import { useCallback as m, useEffect as h, useLayoutEffect as g, useMemo as _, useState as v } from "react";
4
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
5
+ //#region packages/react/src/components/Config/Config.tsx
6
+ var S = p.createContext(a);
7
+ S.displayName = "ConfigContext";
8
+ var C = () => p.use(S);
9
+ function w({ children: t, base: n, baseline: r, guide: i, spacer: a, box: o, padder: s }) {
10
+ let c = C();
11
+ return /* @__PURE__ */ b(S, {
12
+ value: p.useMemo(() => e({
13
+ parentConfig: c,
14
+ base: n,
15
+ baseline: r,
16
+ guide: i,
17
+ spacer: a,
18
+ box: o,
19
+ padder: s
20
+ }), [
21
+ c,
22
+ n,
23
+ r,
24
+ i,
25
+ a,
26
+ o,
27
+ s
28
+ ]),
29
+ children: t
30
+ });
241
31
  }
242
- function Y(t) {
243
- if ("padding" in t && t.padding != null)
244
- return Bt(t.padding);
245
- const e = "block" in t && t.block != null ? Wt(t.block) : { top: 0, bottom: 0 }, n = "inline" in t && t.inline != null ? zt(t.inline) : { left: 0, right: 0 };
246
- return {
247
- top: e.top,
248
- right: n.right,
249
- bottom: e.bottom,
250
- left: n.left
251
- };
252
- }
253
- function Bt(t) {
254
- if (typeof t == "number")
255
- return { top: t, right: t, bottom: t, left: t };
256
- if (Array.isArray(t)) {
257
- if (t.length === 2) {
258
- const [e, n] = t;
259
- return { top: e, right: n, bottom: e, left: n };
260
- }
261
- if (t.length >= 4) {
262
- const [e, n, s, o] = t;
263
- return {
264
- top: e ?? 0,
265
- right: n ?? 0,
266
- bottom: s ?? 0,
267
- left: o ?? 0
268
- };
269
- }
270
- }
271
- if (typeof t == "object" && !Array.isArray(t)) {
272
- const e = t.top ?? 0, n = t.bottom ?? 0, s = t.left ?? 0, o = t.right ?? 0;
273
- return { top: e, right: o, bottom: n, left: s };
274
- }
275
- return { top: 0, right: 0, bottom: 0, left: 0 };
276
- }
277
- function Wt(t) {
278
- if (typeof t == "number")
279
- return { top: t, bottom: t };
280
- if (Array.isArray(t)) {
281
- const [e, n] = t;
282
- return {
283
- top: e ?? 0,
284
- bottom: n ?? 0
285
- };
286
- }
287
- return typeof t == "object" ? {
288
- top: t.start ?? 0,
289
- bottom: t.end ?? 0
290
- } : { top: 0, bottom: 0 };
291
- }
292
- function zt(t) {
293
- if (typeof t == "number")
294
- return { left: t, right: t };
295
- if (Array.isArray(t)) {
296
- const [e, n] = t;
297
- return {
298
- left: e ?? 0,
299
- right: n ?? 0
300
- };
301
- }
302
- return typeof t == "object" ? {
303
- left: t.start ?? 0,
304
- right: t.end ?? 0
305
- } : { left: 0, right: 0 };
306
- }
307
- function Ht(t, e, n, s) {
308
- const o = Y({ padding: n });
309
- if (s === "none")
310
- return o;
311
- if (s === "height") {
312
- const r = t % e;
313
- r !== 0 && (o.bottom += e - r);
314
- }
315
- if (s === "clamp") {
316
- o.top = o.top % e;
317
- const r = t % e;
318
- r !== 0 && (o.bottom += e - r), o.bottom = o.bottom % e;
319
- }
320
- return o;
32
+ //#endregion
33
+ //#region packages/dom/src/timing.ts
34
+ var T = (e) => {
35
+ let t = null, n = null;
36
+ return [(...r) => {
37
+ n = r, t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
38
+ e(...n), t = null, n = null;
39
+ });
40
+ }, () => {
41
+ t !== null && (cancelAnimationFrame(t), t = null, n = null);
42
+ }];
43
+ };
44
+ //#endregion
45
+ //#region packages/dom/src/measure.ts
46
+ function E(e, t) {
47
+ let n = {
48
+ width: 0,
49
+ height: 0
50
+ }, r = () => {
51
+ try {
52
+ let r = e.getBoundingClientRect(), i = {
53
+ width: Math.round(r.width),
54
+ height: Math.round(r.height)
55
+ };
56
+ (i.width !== n.width || i.height !== n.height) && (n = i, t(i));
57
+ } catch {}
58
+ }, [i, a] = T(r);
59
+ r();
60
+ let o = new ResizeObserver(i);
61
+ return o.observe(e), {
62
+ refresh: i,
63
+ disconnect() {
64
+ o.disconnect(), a();
65
+ }
66
+ };
321
67
  }
322
- const Tt = (t, e, n) => {
323
- const s = {};
324
- return t !== void 0 ? (s.gridColumn = `span ${t}`, s.gridRow = `span ${t}`) : (e !== void 0 && (s.gridColumn = `span ${e}`), n !== void 0 && (s.gridRow = `span ${n}`)), s;
325
- }, z = (...t) => t.filter(Boolean).join(" ").trim(), q = (...t) => Object.assign(
326
- {},
327
- ...t.filter((e) => e !== void 0)
328
- );
329
- function Ft(t, e) {
330
- if (t)
331
- if (typeof t == "function")
332
- t(e);
333
- else
334
- try {
335
- Object.assign(t, { current: e });
336
- } catch (n) {
337
- console.error("Error assigning ref:", n);
338
- }
68
+ //#endregion
69
+ //#region packages/react/src/hooks/useMeasure.ts
70
+ var D = {
71
+ width: 0,
72
+ height: 0
73
+ };
74
+ function O(e) {
75
+ let [t, n] = p.useState(D), r = p.useRef(null);
76
+ p.useLayoutEffect(() => {
77
+ if (typeof window > "u" || !e.current) return;
78
+ let t = E(e.current, (e) => {
79
+ n((t) => t.width === e.width && t.height === e.height ? t : e);
80
+ });
81
+ return r.current = t, () => {
82
+ t.disconnect(), r.current = null;
83
+ };
84
+ }, [e]);
85
+ let i = p.useCallback(() => {
86
+ r.current?.refresh();
87
+ }, []);
88
+ return {
89
+ ...t,
90
+ refresh: i
91
+ };
339
92
  }
340
- function yt(...t) {
341
- return (e) => {
342
- t.forEach((n) => {
343
- Ft(n, e);
344
- });
345
- };
93
+ //#endregion
94
+ //#region packages/dom/src/virtual.ts
95
+ function k(e, t, n) {
96
+ let { totalItems: r, itemHeight: i, buffer: a = 0 } = t;
97
+ if (!Number.isFinite(i) || i <= 0) throw Error("createVirtualTracker requires itemHeight to be greater than 0");
98
+ if (!Number.isFinite(r) || r < 0) throw Error("createVirtualTracker requires totalItems to be 0 or greater");
99
+ let o = () => {
100
+ let t = e.getBoundingClientRect().top + window.scrollY, n = Math.max(0, window.scrollY - t - a), o = n + window.innerHeight + a * 2;
101
+ return {
102
+ start: Math.max(0, Math.floor(n / i)),
103
+ end: Math.min(r, Math.ceil(o / i))
104
+ };
105
+ }, s = {
106
+ start: 0,
107
+ end: r
108
+ }, [c, l] = T(() => {
109
+ let e = o();
110
+ (e.start !== s.start || e.end !== s.end) && (s = e, n(e));
111
+ }), u = { passive: !0 };
112
+ window.addEventListener("scroll", c, u), window.addEventListener("resize", c, u);
113
+ let d = new IntersectionObserver(c, { threshold: 0 });
114
+ return d.observe(e), c(), {
115
+ refresh: c,
116
+ disconnect() {
117
+ window.removeEventListener("scroll", c, u), window.removeEventListener("resize", c, u), d.disconnect(), l();
118
+ }
119
+ };
346
120
  }
347
- function k(t, e, n) {
348
- var a, c, d;
349
- const s = typeof t == "string" ? t : t.key, o = typeof t == "string" ? e : t.value, r = typeof t == "string" ? n : t.defaultStyles, i = typeof t == "object" ? t.skipDimensions : void 0;
350
- if (i) {
351
- if ((a = i.fitContent) != null && a.includes(s) && o === "fit-content")
352
- return {};
353
- if ((c = i.auto) != null && c.includes(s) && o === "auto")
354
- return {};
355
- if ((d = i.fullSize) != null && d.includes(s) && (o === "100%" || o === "100vh" || o === "100vw"))
356
- return {};
357
- }
358
- return o !== r[s] ? { [s]: o } : {};
121
+ //#endregion
122
+ //#region packages/react/src/hooks/useVirtual.ts
123
+ function A({ totalLines: e, lineHeight: t, containerRef: n, buffer: r = 0 }) {
124
+ let i = typeof r == "number" ? r : parseInt(r, 10) || 0, [a, o] = v({
125
+ start: 0,
126
+ end: e
127
+ }), s = m((e) => {
128
+ o((t) => t.start === e.start && t.end === e.end ? t : e);
129
+ }, []);
130
+ return g(() => {
131
+ if (!n.current) return;
132
+ let r = k(n.current, {
133
+ totalItems: e,
134
+ itemHeight: t,
135
+ buffer: i
136
+ }, s);
137
+ return () => r.disconnect();
138
+ }, [
139
+ n,
140
+ e,
141
+ t,
142
+ i,
143
+ s
144
+ ]), a;
359
145
  }
360
- const vt = (t) => {
361
- let e = null, n = null;
362
- return (...o) => {
363
- n = o, e !== null && cancelAnimationFrame(e), e = requestAnimationFrame(() => {
364
- t(...n), e = null, n = null;
365
- });
366
- };
367
- };
368
- function jt() {
369
- const [t, e] = mt(!1);
370
- return St(() => {
371
- e(!0);
372
- }, []), t;
146
+ //#endregion
147
+ //#region packages/react/src/hooks/useBaseline.ts
148
+ function j(e, { base: t = 8, snapping: n = "none", spacing: i = {} } = {}) {
149
+ if (t < 1) throw Error("Base must be >= 1 for baseline alignment.");
150
+ let { height: a } = O(e), s = p.useRef(null);
151
+ return p.useMemo(() => {
152
+ let e = r({ padding: i }), c = a % t === 0;
153
+ if (n === "none") return {
154
+ padding: e,
155
+ isAligned: c,
156
+ height: a
157
+ };
158
+ if (s.current) return {
159
+ padding: s.current,
160
+ isAligned: c,
161
+ height: a
162
+ };
163
+ if (a === 0) return {
164
+ padding: e,
165
+ isAligned: c,
166
+ height: a
167
+ };
168
+ let l = o(a, t, e, n);
169
+ return s.current = l, {
170
+ padding: l,
171
+ isAligned: c,
172
+ height: a
173
+ };
174
+ }, [
175
+ t,
176
+ n,
177
+ i,
178
+ a
179
+ ]);
373
180
  }
374
- const xt = typeof window > "u";
375
- function Be(t, e) {
376
- if (xt)
377
- return e;
378
- try {
379
- return t();
380
- } catch {
381
- return e;
382
- }
181
+ //#endregion
182
+ //#region packages/dom/src/viewport.ts
183
+ function M() {
184
+ return typeof window > "u" ? {} : {
185
+ viewportWidth: window.innerWidth,
186
+ viewportHeight: window.innerHeight
187
+ };
383
188
  }
384
- function J(t, e, n) {
385
- return !t || xt ? e : n;
189
+ //#endregion
190
+ //#region packages/react/src/hooks/useGuide.ts
191
+ function N(e, t) {
192
+ let { width: n } = O(e);
193
+ return p.useMemo(() => d(n, t, M()), [t, n]);
386
194
  }
387
- function wt({ children: t, fallback: e = null }) {
388
- return jt() ? /* @__PURE__ */ y(K, { children: t }) : /* @__PURE__ */ y(K, { children: e });
195
+ //#endregion
196
+ //#region packages/react/src/hooks/useConfig.ts
197
+ function P(e) {
198
+ let t = C();
199
+ return _(() => Object.assign({ base: t.base }, t[e]), [t, e]);
389
200
  }
390
- function P(t) {
391
- const [e, n] = l.useState({ width: 0, height: 0 }), s = l.useCallback(() => {
392
- if (t.current)
393
- try {
394
- const r = t.current.getBoundingClientRect(), i = {
395
- width: r ? Math.round(r.width) : 0,
396
- height: r ? Math.round(r.height) : 0
397
- };
398
- n(
399
- (a) => a.width === i.width && a.height === i.height ? a : i
400
- );
401
- } catch {
402
- n({ width: 0, height: 0 });
403
- }
404
- }, [t]), o = l.useMemo(() => vt(s), [s]);
405
- return l.useLayoutEffect(() => {
406
- typeof window > "u" || s();
407
- }, [s]), l.useLayoutEffect(() => {
408
- if (typeof window > "u" || !t.current) return;
409
- const r = new ResizeObserver(() => {
410
- o();
411
- });
412
- return r.observe(t.current), () => {
413
- r.disconnect();
414
- };
415
- }, [t, o]), { ...e, refresh: o };
201
+ //#endregion
202
+ //#region packages/react/src/hooks/useDebug.ts
203
+ function F(e, t) {
204
+ return _(() => l(e, t), [e, t]);
416
205
  }
417
- function Ut({
418
- totalLines: t,
419
- lineHeight: e,
420
- containerRef: n,
421
- buffer: s = 0
422
- }) {
423
- const o = Q(
424
- () => typeof s == "number" ? s : parseInt(s, 10) || 0,
425
- [s]
426
- ), r = ot(() => {
427
- const f = n.current;
428
- if (!f) return { start: 0, end: t };
429
- if (f.closest(".block"))
430
- return { start: 0, end: t };
431
- const M = f.getBoundingClientRect().top + window.scrollY, v = Math.max(0, window.scrollY - M - o), b = v + window.innerHeight + o * 2, w = Math.max(0, Math.floor(v / e)), g = Math.min(t, Math.ceil(b / e));
432
- return { start: w, end: g };
433
- }, [t, e, n, o]), [i, a] = mt(r);
434
- qt(["scroll", "resize"], () => {
435
- d();
436
- });
437
- const c = ot(() => {
438
- a((f) => {
439
- const u = r();
440
- return f.start !== u.start || f.end !== u.end ? u : f;
441
- });
442
- }, [r]), d = Q(
443
- () => vt(c),
444
- [c]
445
- );
446
- return ht(() => {
447
- const f = n.current;
448
- if (!f) return;
449
- const u = new IntersectionObserver(d, {
450
- threshold: 0
451
- });
452
- return u.observe(f), d(), () => {
453
- u.disconnect();
454
- };
455
- }, [n, r, d]), i;
206
+ //#endregion
207
+ //#region packages/react/src/hooks/useIsClient.ts
208
+ function I() {
209
+ let [e, t] = v(!1);
210
+ return h(() => {
211
+ t(!0);
212
+ }, []), e;
456
213
  }
457
- function qt(t, e) {
458
- const n = ot(e, [e]);
459
- ht(() => {
460
- const s = () => n();
461
- return t.forEach((o) => window.addEventListener(o, s)), () => t.forEach((o) => window.removeEventListener(o, s));
462
- }, [t, n]);
214
+ //#endregion
215
+ //#region packages/react/src/utils/ssr.tsx
216
+ function L({ children: e, fallback: t = null }) {
217
+ return I() ? /* @__PURE__ */ b(y, { children: e }) : /* @__PURE__ */ b(y, { children: t });
463
218
  }
464
- function tt(t, {
465
- base: e = 8,
466
- snapping: n = "none",
467
- spacing: s = {},
468
- warnOnMisalignment: o = !1
469
- } = {}) {
470
- if (e < 1)
471
- throw new Error("Base must be >= 1 for baseline alignment.");
472
- const { height: r } = P(t), i = l.useRef(!1), a = l.useRef(!1);
473
- return l.useMemo(() => {
474
- const c = Y({ padding: s }), d = r % e === 0;
475
- if (!d && o && process.env.NODE_ENV === "development" && (a.current || (console.warn(
476
- `[useBaseline] Element height (${r}px) is not aligned with base (${e}px).`
477
- ), a.current = !0)), n === "none")
478
- return { padding: c, isAligned: d, height: r };
479
- if (i.current)
480
- return { padding: c, isAligned: d, height: r };
481
- const f = Ht(
482
- r,
483
- e,
484
- c,
485
- n
486
- );
487
- return i.current = !0, { padding: f, isAligned: d, height: r };
488
- }, [e, n, s, o, r]);
219
+ //#endregion
220
+ //#region packages/react/src/utils/merge.ts
221
+ function R(...e) {
222
+ return Object.assign({}, ...e.filter(Boolean));
489
223
  }
490
- const Xt = "spr_zbcF6", Yt = "line_qHW69", Zt = "flat_gqixr", ct = {
491
- spr: Xt,
492
- line: Yt,
493
- flat: Zt
494
- }, Kt = (t, e, n, s) => ({
495
- "--bksw": "100%",
496
- "--bksh": "100%",
497
- "--bksb": `${t}px`,
498
- "--bksct": e,
499
- "--bkscf": n,
500
- "--bkscl": s
501
- }), Jt = (t, e, n, s) => {
502
- if (!t || !e) return null;
503
- const o = typeof n == "number" ? n : 0, r = typeof s == "number" ? s : 0;
504
- return /* @__PURE__ */ Z(K, { children: [
505
- r !== 0 && /* @__PURE__ */ y("span", { children: e(r, "height") }, "height"),
506
- o !== 0 && /* @__PURE__ */ y("span", { children: e(o, "width") }, "width")
507
- ] });
508
- }, Qt = l.memo(function({
509
- height: e,
510
- width: n,
511
- indicatorNode: s,
512
- debugging: o,
513
- variant: r,
514
- base: i,
515
- color: a,
516
- className: c,
517
- style: d,
518
- children: f,
519
- ssrMode: u = !1,
520
- ...M
521
- }) {
522
- const v = l.useRef(null), b = T("spacer"), { isShown: w } = j(o, b.debugging), g = r ?? b.variant, h = i ?? b.base, [D, S] = l.useState(!1);
523
- l.useEffect(() => {
524
- S(!0);
525
- }, []);
526
- const [x, $] = l.useMemo(() => kt([n, e], [0, 0], {
527
- base: h,
528
- suppressWarnings: !0
529
- }), [n, e, h]), I = J(
530
- D && !u,
531
- !1,
532
- // Don't show measurements during SSR
533
- w && s !== void 0
534
- ), m = l.useMemo(() => I ? Jt(w, s, x, $) : null, [I, w, s, x, $]), G = l.useMemo(
535
- () => Kt(
536
- h,
537
- b.colors.text,
538
- b.colors.flat,
539
- b.colors.line
540
- ),
541
- [h, b.colors]
542
- ), A = l.useMemo(() => {
543
- const p = O($ || "100%"), B = O(x || "100%"), _ = `${h}px`, V = ["--bksw", "--bksh"], L = {
544
- ...k({
545
- key: "--bksh",
546
- value: p,
547
- defaultStyles: G,
548
- skipDimensions: { fullSize: V }
549
- }),
550
- ...k({
551
- key: "--bksw",
552
- value: B,
553
- defaultStyles: G,
554
- skipDimensions: { fullSize: V }
555
- }),
556
- // Explicitly set --bksb to ensure it is always applied
557
- "--bksb": _,
558
- ...k({
559
- key: "--bksct",
560
- value: a ?? b.colors.text,
561
- defaultStyles: G
562
- }),
563
- ...k({
564
- key: "--bkscl",
565
- value: a ?? b.colors.line,
566
- defaultStyles: G
567
- }),
568
- ...k({
569
- key: "--bkscf",
570
- value: a ?? b.colors.flat,
571
- defaultStyles: G
572
- })
573
- };
574
- return q(L, d);
575
- }, [
576
- x,
577
- $,
578
- a,
579
- h,
580
- b.colors,
581
- G,
582
- d
583
- ]);
584
- return /* @__PURE__ */ Z(
585
- "div",
586
- {
587
- ref: v,
588
- "data-testid": "spacer",
589
- className: z(
590
- ct.spr,
591
- w && ct[g],
592
- c
593
- ),
594
- "data-variant": g,
595
- "data-height": typeof $ == "number" ? `${$}px` : $,
596
- style: A,
597
- ...M,
598
- children: [
599
- m,
600
- f
601
- ]
602
- }
603
- );
604
- }), Pt = "pad_w2-sL", te = "v_lhGBy", nt = {
605
- pad: Pt,
606
- v: te
607
- }, ee = (t, e, n, s) => {
608
- const o = {};
609
- return t !== "fit-content" && (o["--bkpw"] = O(t || "fit-content")), e !== "fit-content" && (o["--bkph"] = O(e || "fit-content")), o["--bkpb"] = `${n}px`, o["--bkpc"] = s, o;
610
- }, ne = (t, e) => {
611
- const { top: n, right: s, bottom: o, left: r } = e, i = {};
612
- return t || ((n > 0 || o > 0) && (i.paddingBlock = `${n}px ${o}px`), (r > 0 || s > 0) && (i.paddingInline = `${r}px ${s}px`)), i;
613
- }, oe = (t, e, n) => {
614
- const s = t || "line", o = e || "none", r = (i, a) => /* @__PURE__ */ y(
615
- Qt,
616
- {
617
- variant: s,
618
- debugging: a === 0 || i === 0 ? "none" : o,
619
- indicatorNode: n,
620
- height: a !== "100%" ? a : void 0,
621
- width: i !== "100%" ? i : void 0
622
- }
623
- );
624
- return r.displayName = "PadderSpacer", r;
625
- }, at = l.memo(
626
- l.forwardRef(function({
627
- children: e,
628
- className: n,
629
- debugging: s,
630
- height: o,
631
- indicatorNode: r,
632
- style: i,
633
- width: a,
634
- ssrMode: c = !1,
635
- ...d
636
- }, f) {
637
- const u = T("padder"), { variant: M } = T("spacer"), v = l.useMemo(
638
- () => Y(d),
639
- [d]
640
- ), { isShown: b, isNone: w, debugging: g } = j(
641
- s,
642
- u.debugging
643
- ), h = !w, [D, S] = l.useState(!1);
644
- l.useEffect(() => {
645
- S(!0);
646
- }, []);
647
- const x = l.useRef(null), $ = tt(x, {
648
- base: u.base,
649
- snapping: "height",
650
- spacing: v,
651
- warnOnMisalignment: !w
652
- }), I = {
653
- padding: {
654
- top: v.top || 0,
655
- right: v.right || 0,
656
- bottom: v.bottom || 0,
657
- left: v.left || 0
658
- }
659
- }, { padding: m } = J(
660
- D && !c,
661
- I,
662
- $
663
- ), G = yt(f, x), A = l.useMemo(() => {
664
- const B = ee(
665
- a,
666
- o,
667
- u.base,
668
- u.color
669
- ), _ = ne(h, {
670
- top: m.top,
671
- right: m.right,
672
- bottom: m.bottom,
673
- left: m.left
674
- });
675
- return q(
676
- { ...B, ..._ },
677
- i
678
- );
679
- }, [
680
- a,
681
- o,
682
- u.base,
683
- u.color,
684
- h,
685
- m.top,
686
- m.right,
687
- m.bottom,
688
- m.left,
689
- i
690
- ]), p = l.useMemo(
691
- () => oe(M, g, r),
692
- [M, g, r]
693
- );
694
- return h ? /* @__PURE__ */ Z(
695
- "div",
696
- {
697
- ref: G,
698
- "data-testid": "padder",
699
- className: z(nt.pad, b && nt.v, n),
700
- style: A,
701
- children: [
702
- /* @__PURE__ */ Z(K, { children: [
703
- m.top >= 0 && /* @__PURE__ */ y("div", { style: { gridColumn: "1 / -1" }, children: p("100%", m.top) }),
704
- m.left >= 0 && /* @__PURE__ */ y("div", { style: { gridRow: "2 / 3" }, children: p(m.left, "100%") })
705
- ] }),
706
- /* @__PURE__ */ y("div", { style: { gridRow: "2 / 3", gridColumn: "2 / 3" }, children: e }),
707
- /* @__PURE__ */ Z(K, { children: [
708
- m.right >= 0 && /* @__PURE__ */ y("div", { style: { gridRow: "2 / 3" }, children: p(m.right, "100%") }),
709
- m.bottom >= 0 && /* @__PURE__ */ y("div", { style: { gridColumn: "1 / -1" }, children: p("100%", m.bottom) })
710
- ] })
711
- ]
712
- }
713
- ) : /* @__PURE__ */ y(
714
- "div",
715
- {
716
- ref: G,
717
- "data-testid": "padder",
718
- className: z(nt.pad, n),
719
- style: A,
720
- children: e
721
- }
722
- );
723
- })
724
- ), se = "lay_5cMu5", re = "v_dprVE", ut = {
725
- lay: se,
726
- v: re
727
- }, ie = (t) => ({
728
- "--bklw": "auto",
729
- "--bklh": "auto",
730
- "--bklcl": t.line,
731
- "--bklcf": t.flat,
732
- "--bklci": t.text
733
- }), dt = (t) => typeof t == "number" ? `repeat(${t}, 1fr)` : typeof t == "string" ? t : Array.isArray(t) ? t.map((e) => typeof e == "number" ? `${e}px` : e).join(" ") : "repeat(auto-fill, minmax(100px, 1fr))", ae = (t, e, n) => {
734
- const s = {};
735
- return t !== void 0 && (s.gap = O(t)), e !== void 0 && (s.rowGap = O(e)), n !== void 0 && (s.columnGap = O(n)), s;
736
- }, We = l.memo(function({
737
- alignContent: e,
738
- alignItems: n,
739
- children: s,
740
- className: o,
741
- columns: r = "repeat(auto-fill, minmax(100px, 1fr))",
742
- columnGap: i,
743
- debugging: a,
744
- gap: c,
745
- height: d,
746
- indicatorNode: f,
747
- justifyContent: u,
748
- justifyItems: M,
749
- rowGap: v,
750
- rows: b,
751
- style: w,
752
- variant: g,
753
- width: h,
754
- ssrMode: D = !1,
755
- ...S
756
- }) {
757
- const x = T("layout"), { isShown: $, debugging: I } = j(a, x.debugging), [m, G] = l.useState(!1);
758
- l.useEffect(() => {
759
- G(!0);
760
- }, []);
761
- const A = l.useRef(null), p = l.useMemo(
762
- () => Y(S),
763
- [S]
764
- ), B = tt(A, {
765
- base: x.base,
766
- snapping: "height",
767
- spacing: p,
768
- warnOnMisalignment: !0
769
- }), _ = {
770
- padding: {
771
- top: p.top || 0,
772
- right: p.right || 0,
773
- bottom: p.bottom || 0,
774
- left: p.left || 0
775
- }
776
- }, { padding: V } = J(
777
- m && !D,
778
- _,
779
- B
780
- ), L = l.useMemo(
781
- () => dt(r),
782
- [r]
783
- ), C = l.useMemo(
784
- () => b ? dt(b) : "auto",
785
- [b]
786
- ), E = l.useMemo(
787
- () => ie(x.colors),
788
- [x.colors]
789
- ), R = l.useMemo(
790
- () => ae(c, v, i),
791
- [c, v, i]
792
- ), N = l.useMemo(() => {
793
- const W = O(h || "auto"), X = O(d || "auto"), U = ["--bklw", "--bklh"];
794
- return q(
795
- {
796
- // Theme overrides
797
- ...k({
798
- key: "--bklw",
799
- value: W,
800
- defaultStyles: E,
801
- skipDimensions: { auto: U }
802
- }),
803
- ...k({
804
- key: "--bklh",
805
- value: X,
806
- defaultStyles: E,
807
- skipDimensions: { auto: U }
808
- }),
809
- ...k({
810
- key: "--bklcl",
811
- value: x.colors.line,
812
- defaultStyles: E
813
- }),
814
- ...k({
815
- key: "--bklcf",
816
- value: x.colors.flat,
817
- defaultStyles: E
818
- }),
819
- ...k({
820
- key: "--bklci",
821
- value: x.colors.text,
822
- defaultStyles: E
823
- }),
824
- // Grid properties - only inject if different from defaults
825
- ...L !== "repeat(auto-fill, minmax(100px, 1fr))" && {
826
- "--bklgtc": L
827
- },
828
- ...C !== "auto" && { "--bklgtr": C },
829
- ...M && { "--bklji": M },
830
- ...n && { "--bklai": n },
831
- ...u && { "--bkljc": u },
832
- ...e && { "--bklac": e },
833
- // Include gap styles
834
- ...R
835
- },
836
- w
837
- );
838
- }, [
839
- L,
840
- C,
841
- M,
842
- n,
843
- u,
844
- e,
845
- h,
846
- d,
847
- x.colors,
848
- E,
849
- w,
850
- R
851
- ]);
852
- return /* @__PURE__ */ y(it, { spacer: { variant: g ?? "line" }, children: /* @__PURE__ */ y(
853
- at,
854
- {
855
- ref: A,
856
- className: $ ? ut.v : "",
857
- block: [V.top, V.bottom],
858
- ...f ? { indicatorNode: f } : {},
859
- inline: [V.left, V.right],
860
- debugging: I,
861
- width: h,
862
- height: d,
863
- ssrMode: D,
864
- children: /* @__PURE__ */ y(
865
- "div",
866
- {
867
- "data-testid": "layout",
868
- className: z(o, ut.lay),
869
- style: N,
870
- ...S && Object.keys(S).length > 0 ? Object.fromEntries(
871
- Object.entries(S).filter(
872
- ([W]) => W !== "ssrMode"
873
- )
874
- ) : {},
875
- children: s
876
- }
877
- )
878
- }
879
- ) });
880
- }), le = "box_rDCRX", ce = "v_0MMHD", ft = {
881
- box: le,
882
- v: ce
883
- }, ue = (t, e) => ({
884
- "--bkboxw": "auto",
885
- "--bkboxh": "auto",
886
- "--bkboxc": e,
887
- "--bkboxb": `${t}px`
888
- }), de = ({
889
- width: t,
890
- height: e,
891
- base: n,
892
- lineColor: s,
893
- defaultStyles: o
894
- }) => {
895
- const r = O(t || "fit-content"), i = O(e || "fit-content"), a = ["--bkboxw", "--bkboxh"];
896
- return {
897
- ...k({
898
- key: "--bkboxw",
899
- value: r,
900
- defaultStyles: o,
901
- skipDimensions: { fitContent: a }
902
- }),
903
- ...k({
904
- key: "--bkboxh",
905
- value: i,
906
- defaultStyles: o,
907
- skipDimensions: { fitContent: a }
908
- }),
909
- ...k({
910
- key: "--bkboxb",
911
- value: `${n}px`,
912
- defaultStyles: o
913
- }),
914
- ...k({
915
- key: "--bkboxc",
916
- value: s,
917
- defaultStyles: o
918
- })
919
- };
920
- }, ze = l.memo(
921
- l.forwardRef(function({
922
- children: e,
923
- snapping: n = "clamp",
924
- debugging: s,
925
- className: o,
926
- colSpan: r,
927
- rowSpan: i,
928
- span: a,
929
- width: c,
930
- height: d,
931
- style: f,
932
- ssrMode: u = !1,
933
- ...M
934
- }, v) {
935
- const b = T("box"), { isShown: w, debugging: g } = j(s, b.debugging), [h, D] = l.useState(!1);
936
- l.useEffect(() => {
937
- D(!0);
938
- }, []);
939
- const S = l.useRef(null), { top: x, bottom: $, left: I, right: m } = Y(M), G = tt(S, {
940
- base: b.base,
941
- snapping: n,
942
- spacing: { top: x, bottom: $, left: I, right: m },
943
- warnOnMisalignment: g !== "none"
944
- }), A = {
945
- padding: {
946
- top: x || 0,
947
- right: m || 0,
948
- bottom: $ || 0,
949
- left: I || 0
950
- }
951
- }, { padding: p } = J(
952
- h && !u,
953
- A,
954
- G
955
- ), B = l.useMemo(
956
- () => Tt(a, r, i),
957
- [r, i, a]
958
- ), _ = l.useMemo(
959
- () => ue(b.base, b.colors.line),
960
- [b.base, b.colors.line]
961
- ), V = l.useMemo(() => {
962
- const L = de({
963
- width: c,
964
- height: d,
965
- base: b.base,
966
- lineColor: b.colors.line,
967
- defaultStyles: _
968
- });
969
- return q(L, f);
970
- }, [
971
- b.base,
972
- b.colors.line,
973
- c,
974
- d,
975
- _,
976
- f
977
- ]);
978
- return /* @__PURE__ */ y(
979
- "div",
980
- {
981
- ref: yt(v, S),
982
- "data-testid": "box",
983
- className: z(ft.box, w && ft.v, o),
984
- style: q(V, B),
985
- children: /* @__PURE__ */ y(it, { base: 1, spacer: { variant: "flat" }, children: /* @__PURE__ */ y(
986
- at,
987
- {
988
- block: [p.top, p.bottom],
989
- inline: [p.left, p.right],
990
- width: "fit-content",
991
- height: d,
992
- debugging: g,
993
- ssrMode: u,
994
- children: e
995
- }
996
- ) })
997
- }
998
- );
999
- })
1000
- ), fe = "stk_l-58l", be = "v_-k3qw", bt = {
1001
- stk: fe,
1002
- v: be
1003
- }, me = {
1004
- x: "row",
1005
- y: "column",
1006
- "-x": "row-reverse",
1007
- "-y": "column-reverse"
1008
- }, he = (t) => ({
1009
- "--bkkw": "auto",
1010
- "--bkkh": "auto",
1011
- "--bkkcl": t.line,
1012
- "--bkkcf": t.flat,
1013
- "--bkkci": t.text
1014
- }), ge = (t, e, n) => ({
1015
- rowGap: n !== void 0 ? n : t,
1016
- columnGap: n !== void 0 ? n : e
1017
- }), He = l.memo(function({
1018
- align: e = "flex-start",
1019
- children: n,
1020
- className: s,
1021
- columnGap: o,
1022
- debugging: r,
1023
- direction: i = "row",
1024
- gap: a,
1025
- height: c,
1026
- indicatorNode: d,
1027
- justify: f = "flex-start",
1028
- rowGap: u,
1029
- style: M,
1030
- variant: v,
1031
- width: b,
1032
- ssrMode: w = !1,
1033
- ...g
1034
- }) {
1035
- const h = T("stack"), { isShown: D, debugging: S } = j(r, h.debugging), [x, $] = l.useState(!1);
1036
- l.useEffect(() => {
1037
- $(!0);
1038
- }, []);
1039
- const I = l.useRef(null), { top: m, right: G, bottom: A, left: p } = Y({
1040
- ...g
1041
- }), B = tt(I, {
1042
- base: h.base,
1043
- snapping: "height",
1044
- spacing: { top: m, right: G, bottom: A, left: p },
1045
- warnOnMisalignment: S !== "none"
1046
- }), _ = {
1047
- padding: {
1048
- top: m || 0,
1049
- right: G || 0,
1050
- bottom: A || 0,
1051
- left: p || 0
1052
- }
1053
- }, { padding: V } = J(
1054
- x && !w,
1055
- _,
1056
- B
1057
- ), L = l.useMemo(() => {
1058
- const N = u !== void 0 ? Number(u) : void 0, W = o !== void 0 ? Number(o) : void 0, X = a !== void 0 ? Number(a) : void 0;
1059
- return ge(
1060
- N,
1061
- W,
1062
- X
1063
- );
1064
- }, [u, o, a]), C = l.useMemo(
1065
- () => he(h.colors),
1066
- [h.colors]
1067
- ), E = l.useMemo(() => {
1068
- const N = O(b || "auto"), W = O(c || "auto"), X = me[i] || i, U = ["--bkkw", "--bkkh"], et = {
1069
- ...k({
1070
- key: "--bkkw",
1071
- value: N,
1072
- defaultStyles: C,
1073
- skipDimensions: { auto: U }
1074
- }),
1075
- ...k({
1076
- key: "--bkkh",
1077
- value: W,
1078
- defaultStyles: C,
1079
- skipDimensions: { auto: U }
1080
- }),
1081
- ...k({
1082
- key: "--bkkcl",
1083
- value: h.colors.line,
1084
- defaultStyles: C
1085
- }),
1086
- ...k({
1087
- key: "--bkkcf",
1088
- value: h.colors.flat,
1089
- defaultStyles: C
1090
- }),
1091
- ...k({
1092
- key: "--bkkci",
1093
- value: h.colors.text,
1094
- defaultStyles: C
1095
- })
1096
- };
1097
- return q({
1098
- flexDirection: X,
1099
- justifyContent: f,
1100
- alignItems: e,
1101
- width: b,
1102
- height: c
1103
- }, L, et, M);
1104
- }, [
1105
- i,
1106
- f,
1107
- e,
1108
- b,
1109
- c,
1110
- h.colors.line,
1111
- h.colors.flat,
1112
- h.colors.text,
1113
- C,
1114
- L,
1115
- M
1116
- ]), R = S === "none" ? {
1117
- ...E,
1118
- paddingBlock: `${V.top}px ${V.bottom}px`,
1119
- paddingInline: `${V.left}px ${V.right}px`
1120
- } : E;
1121
- return /* @__PURE__ */ y(it, { spacer: { variant: v ?? "line" }, children: /* @__PURE__ */ y(
1122
- at,
1123
- {
1124
- ref: I,
1125
- block: [V.top, V.bottom],
1126
- inline: [V.left, V.right],
1127
- debugging: S,
1128
- indicatorNode: d,
1129
- width: b,
1130
- height: c,
1131
- ssrMode: w,
1132
- children: /* @__PURE__ */ y(
1133
- "div",
1134
- {
1135
- "data-testid": "stack",
1136
- className: z(s, bt.stk, D && bt.v),
1137
- style: R,
1138
- ...g,
1139
- children: n
1140
- }
1141
- )
1142
- }
1143
- ) });
1144
- }), pe = "gde_-Naxo", ke = "line_-VS-e", ye = "cols_8lD6D", ve = "col_rlbsL", xe = "ssr_VGvpO", H = {
1145
- gde: pe,
1146
- line: ke,
1147
- cols: ye,
1148
- col: ve,
1149
- ssr: xe
1150
- }, we = (t) => {
1151
- const { variant: e, base: n, gap: s, columns: o, columnWidth: r } = t;
1152
- switch (e) {
1153
- case "line":
1154
- return {
1155
- variant: "line",
1156
- gap: s,
1157
- base: n
1158
- };
1159
- case "pattern":
1160
- if (o && Array.isArray(o))
1161
- return {
1162
- variant: "pattern",
1163
- columns: o,
1164
- gap: s,
1165
- base: n
1166
- };
1167
- break;
1168
- case "fixed":
1169
- if (o !== void 0) {
1170
- const i = typeof o == "number" ? o : parseInt(String(o), 10);
1171
- return {
1172
- variant: "fixed",
1173
- columns: isNaN(i) ? 12 : i,
1174
- columnWidth: r || "60px",
1175
- gap: s,
1176
- base: n
1177
- };
1178
- }
1179
- break;
1180
- }
1181
- return {
1182
- variant: "auto",
1183
- columnWidth: r || "1fr",
1184
- gap: s,
1185
- base: n
1186
- };
1187
- }, Se = (t, e) => ({
1188
- "--bkgw": "auto",
1189
- "--bkgh": "auto",
1190
- "--bkgmw": "none",
1191
- "--bkgcw": "60px",
1192
- "--bkggw": "24px",
1193
- "--bkgc": "12",
1194
- "--bkgb": `${t}px`,
1195
- "--bkgcl": e,
1196
- "--bkgg": "0"
1197
- }), Te = l.memo(function({
1198
- className: e,
1199
- debugging: n,
1200
- style: s,
1201
- variant: o,
1202
- align: r = "center",
1203
- gap: i,
1204
- height: a,
1205
- width: c,
1206
- columns: d,
1207
- columnWidth: f,
1208
- maxWidth: u,
1209
- color: M,
1210
- children: v,
1211
- ssrMode: b = !1,
1212
- ...w
1213
- }) {
1214
- const g = T("guide"), h = o ?? g.variant, D = typeof i == "number" ? i : 0, { isShown: S } = j(n, g.debugging);
1215
- if (!S)
1216
- return /* @__PURE__ */ y(
1217
- "div",
1218
- {
1219
- className: z(H.g, H.h, e),
1220
- style: s,
1221
- "data-testid": "guide",
1222
- "data-variant": h,
1223
- ...w,
1224
- children: v
1225
- }
1226
- );
1227
- const x = /* @__PURE__ */ y(
1228
- "div",
1229
- {
1230
- className: z(H.g, H.h, H.ssr, e),
1231
- style: {
1232
- width: c || "100%",
1233
- height: a || "100%",
1234
- maxWidth: u || "none",
1235
- ...s
1236
- },
1237
- "data-testid": "guide",
1238
- "data-variant": h,
1239
- children: v
1240
- }
1241
- );
1242
- return /* @__PURE__ */ y(wt, { fallback: x, children: /* @__PURE__ */ y(
1243
- Ce,
1244
- {
1245
- className: e,
1246
- debugging: n,
1247
- style: s,
1248
- variant: h,
1249
- align: r,
1250
- gap: D,
1251
- height: a,
1252
- width: c,
1253
- columns: d,
1254
- columnWidth: f,
1255
- maxWidth: u,
1256
- color: M,
1257
- ssrMode: b,
1258
- ...w,
1259
- children: v
1260
- }
1261
- ) });
1262
- }), Ce = l.memo(function({
1263
- className: e,
1264
- debugging: n,
1265
- style: s,
1266
- variant: o,
1267
- align: r = "center",
1268
- gap: i,
1269
- height: a,
1270
- width: c,
1271
- columns: d,
1272
- columnWidth: f,
1273
- maxWidth: u,
1274
- color: M,
1275
- children: v,
1276
- ssrMode: b = !1,
1277
- ...w
1278
- }) {
1279
- const g = T("guide"), { isShown: h } = j(n, g.debugging), D = l.useRef(null), {
1280
- width: S,
1281
- height: x,
1282
- refresh: $
1283
- // Keep the refresh function available for dynamic updates
1284
- } = P(D);
1285
- l.useEffect(() => {
1286
- const R = () => {
1287
- $();
1288
- };
1289
- return window.addEventListener("resize", R), () => {
1290
- window.removeEventListener("resize", R);
1291
- };
1292
- }, [$]);
1293
- const I = l.useMemo(() => {
1294
- const R = o, N = typeof i == "number" ? i : 0;
1295
- return we({
1296
- variant: R,
1297
- base: g.base,
1298
- gap: N,
1299
- columns: d,
1300
- columnWidth: f
1301
- });
1302
- }, [o, g.base, i, d, f]), { template: m, columnsCount: G, calculatedGap: A } = Ee(
1303
- D,
1304
- I
1305
- ), p = l.useMemo(
1306
- () => Se(g.base, g.colors.line),
1307
- [g.base, g.colors.line]
1308
- ), B = l.useMemo(() => {
1309
- const R = O(c || S || "auto"), N = O(a || x || "auto"), W = O(u || "none"), X = O(f || "60px"), U = ["--bkgw", "--bkgh"], et = {
1310
- ...k({
1311
- key: "--bkgw",
1312
- value: R,
1313
- defaultStyles: p,
1314
- skipDimensions: { auto: U }
1315
- }),
1316
- ...k({
1317
- key: "--bkgh",
1318
- value: N,
1319
- defaultStyles: p,
1320
- skipDimensions: { auto: U }
1321
- }),
1322
- ...k({
1323
- key: "--bkgmw",
1324
- value: W,
1325
- defaultStyles: p
1326
- }),
1327
- ...k({
1328
- key: "--bkgcw",
1329
- value: X,
1330
- defaultStyles: p
1331
- }),
1332
- ...k({
1333
- key: "--bkgc",
1334
- value: `${G}`,
1335
- defaultStyles: p
1336
- }),
1337
- ...k({
1338
- key: "--bkgb",
1339
- value: "0",
1340
- defaultStyles: p
1341
- }),
1342
- ...k({
1343
- key: "--bkgcl",
1344
- value: M ?? g.colors.line,
1345
- defaultStyles: p
1346
- }),
1347
- ...k({
1348
- key: "--bkgg",
1349
- value: `${A}px`,
1350
- defaultStyles: p
1351
- }),
1352
- ...k({
1353
- key: "--bkgj",
1354
- value: r || "center",
1355
- defaultStyles: p
1356
- }),
1357
- ...m && m !== "none" ? { "--bkgt": m } : {},
1358
- // Add grid template if available
1359
- ...m && m !== "none" ? { gridTemplateColumns: m } : {}
1360
- };
1361
- return q(et, s);
1362
- }, [
1363
- c,
1364
- a,
1365
- u,
1366
- f,
1367
- G,
1368
- M,
1369
- m,
1370
- A,
1371
- S,
1372
- x,
1373
- g.colors.line,
1374
- p,
1375
- s,
1376
- r
1377
- ]), _ = () => {
1378
- const R = typeof i == "number" ? i : 0, N = R === 0 ? 0 : R - 1, W = N + 1;
1379
- return { finalGap: N, actualGapWithLine: W };
1380
- }, { finalGap: V, actualGapWithLine: L } = _(), C = typeof c == "number" ? c : S || 1024;
1381
- let E;
1382
- return V === 0 ? E = Math.floor(C) + 1 : o === "line" ? E = Math.max(
1383
- 1,
1384
- Math.floor((C + 1) / L) + 1
1385
- ) : E = Math.max(
1386
- 1,
1387
- Math.floor(C / L) + 1
1388
- ), /* @__PURE__ */ Z(
1389
- "div",
1390
- {
1391
- ref: D,
1392
- "data-testid": "guide",
1393
- className: z(
1394
- H.gde,
1395
- e,
1396
- h ? H.v : H.h,
1397
- o === "line" && H.line
1398
- ),
1399
- "data-variant": o,
1400
- style: B,
1401
- ...w,
1402
- children: [
1403
- h && /* @__PURE__ */ y("div", { className: H.cols, "data-variant": o, children: Array.from({ length: E }, (R, N) => {
1404
- const W = g.colors[o] ?? g.colors.line;
1405
- return /* @__PURE__ */ y(
1406
- "div",
1407
- {
1408
- className: H.col,
1409
- "data-column-index": N,
1410
- "data-variant": o,
1411
- style: { backgroundColor: W }
1412
- },
1413
- N
1414
- );
1415
- }) }),
1416
- v
1417
- ]
1418
- }
1419
- );
1420
- }), Me = /^\d*\.?\d+(?:fr|px|%|em|rem|vh|vw|vmin|vmax|pt|pc|in|cm|mm)$/, $e = (t) => typeof t == "number" ? Number.isFinite(t) && t >= 0 : typeof t != "string" ? !1 : t === "auto" || t === "100%" || Me.test(t), Re = (t) => Array.isArray(t) && t.length > 0 && t.every($e);
1421
- function Ee(t, e) {
1422
- const { width: n } = P(t), s = l.useRef(!1);
1423
- return l.useMemo(() => {
1424
- const o = e.variant ?? "line", r = e.base ?? 8, i = st(e.gap ?? 0, { base: r });
1425
- if (!n)
1426
- return {
1427
- template: "none",
1428
- columnsCount: 0,
1429
- calculatedGap: 0,
1430
- isValid: !1
1431
- };
1432
- try {
1433
- switch (o) {
1434
- case "line": {
1435
- const a = i === 0 ? 0 : i - 1, c = a + 1;
1436
- let d;
1437
- return a === 0 ? d = Math.max(1, Math.floor(n) + 1) : d = Math.max(
1438
- 1,
1439
- Math.floor((n + 1) / c) + 1
1440
- ), {
1441
- template: `repeat(${d}, 1px)`,
1442
- columnsCount: d,
1443
- calculatedGap: i > 0 ? i - 1 : i,
1444
- isValid: !0
1445
- };
1446
- }
1447
- case "pattern": {
1448
- if (!e.columns || !Array.isArray(e.columns))
1449
- throw new Error("Missing or invalid pattern columns");
1450
- if (!Re(e.columns))
1451
- throw new Error('Invalid "pattern" columns array');
1452
- const a = e.columns.map(
1453
- (c) => typeof c == "number" ? `${c}px` : c
1454
- );
1455
- return a.some((c) => c === "0" || c === "0px") ? {
1456
- template: "none",
1457
- columnsCount: 0,
1458
- calculatedGap: 0,
1459
- isValid: !1
1460
- } : {
1461
- template: a.join(" "),
1462
- columnsCount: a.length,
1463
- calculatedGap: i,
1464
- isValid: !0
1465
- };
1466
- }
1467
- case "fixed": {
1468
- const a = typeof e.columns == "number" ? e.columns : 0;
1469
- if (a < 1)
1470
- throw new Error(`Invalid columns count: ${a}`);
1471
- const c = e.columnWidth ? O(e.columnWidth) : "1fr";
1472
- return {
1473
- template: `repeat(${a}, ${c})`,
1474
- columnsCount: a,
1475
- calculatedGap: i,
1476
- isValid: !0
1477
- };
1478
- }
1479
- case "auto": {
1480
- const a = e.columnWidth ?? "auto";
1481
- if (a === "auto")
1482
- return {
1483
- template: "repeat(auto-fill, minmax(0, 1fr))",
1484
- columnsCount: 1,
1485
- calculatedGap: i,
1486
- isValid: !0
1487
- };
1488
- const c = typeof a == "number" ? `${a}px` : a.toString(), d = pt(c) ?? 0, f = d > 0 ? Math.max(1, Math.floor((n + i) / (d + i))) : 1;
1489
- return {
1490
- template: `repeat(auto-fill, ${c})`,
1491
- columnsCount: f,
1492
- calculatedGap: i,
1493
- isValid: !0
1494
- };
1495
- }
1496
- default: {
1497
- s.current || (console.warn(
1498
- `[useGuide] Unknown variant "${o}". Falling back to "line".`
1499
- ), s.current = !0);
1500
- const a = Math.max(1, Math.floor(n / (i + 1)) + 1);
1501
- return {
1502
- template: `repeat(${a}, 1px)`,
1503
- columnsCount: a,
1504
- calculatedGap: i,
1505
- isValid: !0
1506
- };
1507
- }
1508
- }
1509
- } catch (a) {
1510
- return console.warn("Error in useGuide:", a), {
1511
- template: "none",
1512
- columnsCount: 0,
1513
- calculatedGap: 0,
1514
- isValid: !1
1515
- };
1516
- }
1517
- }, [e, n]);
224
+ function z(...e) {
225
+ return (t) => {
226
+ e.forEach((e) => {
227
+ e && (typeof e == "function" ? e(t) : Object.assign(e, { current: t }));
228
+ });
229
+ };
1518
230
  }
1519
- function T(t) {
1520
- const e = gt();
1521
- return Q(() => Object.assign(
1522
- { base: e.base },
1523
- e[t]
1524
- ), [e, t]);
231
+ var B = {
232
+ bas: "bas_4Emvv",
233
+ v: "v_lNfeX",
234
+ h: "h_PbNDU",
235
+ row: "row_J1Wva",
236
+ ssr: "ssr_PQAP-"
237
+ }, V = p.memo(function({ className: e, debugging: t, style: r, variant: a, height: o, width: s, base: c, color: l, ...u }) {
238
+ let d = P("baseline"), { isShown: f } = F(t, d.debugging), m = p.useRef(null), { width: h, height: g } = O(m), _ = c || d.base, v = p.useMemo(() => i({
239
+ base: _,
240
+ colors: d.colors,
241
+ variant: a ?? d.variant,
242
+ width: s,
243
+ height: o,
244
+ color: l,
245
+ containerWidth: h,
246
+ containerHeight: g,
247
+ spacing: u,
248
+ isVisible: f
249
+ }), [
250
+ _,
251
+ d.colors,
252
+ d.variant,
253
+ a,
254
+ s,
255
+ o,
256
+ l,
257
+ h,
258
+ g,
259
+ u,
260
+ f
261
+ ]), { start: y, end: x } = A({
262
+ totalLines: v.rowCount,
263
+ lineHeight: _,
264
+ containerRef: m,
265
+ buffer: 160
266
+ }), S = p.useMemo(() => R(v.containerStyle, r), [v.containerStyle, r]);
267
+ return /* @__PURE__ */ b("div", {
268
+ ref: m,
269
+ "data-testid": "baseline",
270
+ "aria-hidden": "true",
271
+ className: n(...v.classTokens.map((e) => B[e]), e),
272
+ style: S,
273
+ ...u,
274
+ children: f && Array.from({ length: x - y }, (e, t) => {
275
+ let n = t + y;
276
+ return /* @__PURE__ */ b("div", {
277
+ className: B.row,
278
+ "data-row-index": n,
279
+ style: v.getRowStyle(n)
280
+ }, n);
281
+ })
282
+ });
283
+ }), H = p.memo(function({ className: e, debugging: t, style: r, variant: i, height: a, width: o, base: s, color: c, ssrMode: l = !1, ...u }) {
284
+ let d = P("baseline"), f = i ?? d.variant, p = s ?? d.base, { isShown: m } = F(t, d.debugging);
285
+ if (!m) return /* @__PURE__ */ b("div", {
286
+ className: n(B.bas, B.h, e),
287
+ style: r,
288
+ "data-testid": "baseline",
289
+ "aria-hidden": "true",
290
+ ...u
291
+ });
292
+ let h = /* @__PURE__ */ b("div", {
293
+ className: n(B.bas, B.h, B.ssr, e),
294
+ style: {
295
+ width: o ?? "100%",
296
+ height: a ?? "100%",
297
+ ...r
298
+ },
299
+ "data-testid": "baseline",
300
+ "aria-hidden": "true"
301
+ });
302
+ return l ? h : /* @__PURE__ */ b(L, {
303
+ fallback: h,
304
+ children: /* @__PURE__ */ b(V, {
305
+ className: e,
306
+ debugging: t,
307
+ style: r,
308
+ variant: f,
309
+ height: a,
310
+ width: o,
311
+ base: p,
312
+ color: c,
313
+ ...u
314
+ })
315
+ });
316
+ }), U = {
317
+ gde: "gde_4PKz3",
318
+ v: "v_yAvN0",
319
+ h: "h_XcWcy",
320
+ line: "line_UaLjW",
321
+ cols: "cols_ibtT4",
322
+ col: "col_QPSDI",
323
+ ssr: "ssr_4UN4k"
324
+ }, W = p.memo(function({ className: e, debugging: t, style: r, variant: i, align: a = "center", gap: o, height: s, width: c, columns: l, columnWidth: u, maxWidth: d, color: f, children: p, ssrMode: m = !1, ...h }) {
325
+ let g = P("guide"), _ = i ?? g.variant, v = typeof o == "number" ? o : 0, { isShown: y } = F(t, g.debugging);
326
+ if (!y) return /* @__PURE__ */ b("div", {
327
+ className: n(U.gde, U.h, e),
328
+ style: r,
329
+ "data-testid": "guide",
330
+ "data-variant": _,
331
+ "aria-hidden": "true",
332
+ ...h,
333
+ children: p
334
+ });
335
+ let x = /* @__PURE__ */ b("div", {
336
+ className: n(U.gde, U.h, U.ssr, e),
337
+ style: {
338
+ width: c ?? "100%",
339
+ height: s ?? "100%",
340
+ maxWidth: d ?? "none",
341
+ ...r
342
+ },
343
+ "data-testid": "guide",
344
+ "data-variant": _,
345
+ "aria-hidden": "true",
346
+ children: p
347
+ });
348
+ return m ? x : /* @__PURE__ */ b(L, {
349
+ fallback: x,
350
+ children: /* @__PURE__ */ b(G, {
351
+ className: e,
352
+ debugging: t,
353
+ style: r,
354
+ variant: _,
355
+ align: a,
356
+ gap: v,
357
+ height: s,
358
+ width: c,
359
+ columns: l,
360
+ columnWidth: u,
361
+ maxWidth: d,
362
+ color: f,
363
+ ...h,
364
+ children: p
365
+ })
366
+ });
367
+ }), G = p.memo(function({ className: e, debugging: r, style: i, variant: a, align: o = "center", gap: s, height: l, width: u, columns: d, columnWidth: f, maxWidth: m, color: h, children: g, ..._ }) {
368
+ let v = P("guide"), { isShown: y } = F(r, v.debugging), S = p.useRef(null);
369
+ O(S);
370
+ let C = a ?? v.variant, w = typeof s == "number" ? s : 0, { template: T, columnsCount: E, calculatedGap: D } = N(S, p.useMemo(() => t({
371
+ variant: C,
372
+ base: v.base,
373
+ gap: w,
374
+ columns: d,
375
+ columnWidth: f
376
+ }), [
377
+ C,
378
+ v.base,
379
+ w,
380
+ d,
381
+ f
382
+ ])), k = p.useMemo(() => c({
383
+ base: v.base,
384
+ colors: v.colors,
385
+ variant: C,
386
+ align: o || "center",
387
+ width: u,
388
+ height: l,
389
+ columnWidth: f,
390
+ maxWidth: m,
391
+ color: h,
392
+ template: T,
393
+ columnsCount: E,
394
+ calculatedGap: D,
395
+ isVisible: y
396
+ }), [
397
+ v.base,
398
+ v.colors,
399
+ C,
400
+ o,
401
+ u,
402
+ l,
403
+ f,
404
+ m,
405
+ h,
406
+ T,
407
+ E,
408
+ D,
409
+ y
410
+ ]), A = p.useMemo(() => R(k.containerStyle, i), [k.containerStyle, i]);
411
+ return /* @__PURE__ */ x("div", {
412
+ ref: S,
413
+ "data-testid": "guide",
414
+ "aria-hidden": "true",
415
+ className: n(...k.classTokens.map((e) => U[e]), e),
416
+ "data-variant": a,
417
+ style: A,
418
+ ..._,
419
+ children: [y && /* @__PURE__ */ b("div", {
420
+ className: U.cols,
421
+ "data-variant": a,
422
+ children: !k.isLineVariant && Array.from({ length: k.columnsCount }, (e, t) => /* @__PURE__ */ b("div", {
423
+ className: U.col,
424
+ "data-column-index": t,
425
+ "data-variant": a,
426
+ style: { backgroundColor: k.columnColor }
427
+ }, t))
428
+ }), g]
429
+ });
430
+ }), K = typeof window > "u";
431
+ function q(e, t) {
432
+ if (K) return t;
433
+ try {
434
+ return e();
435
+ } catch {
436
+ return t;
437
+ }
1525
438
  }
1526
- function j(t, e) {
1527
- return Q(() => {
1528
- const n = t ?? e;
1529
- return {
1530
- isShown: n === "visible",
1531
- isHidden: n === "hidden",
1532
- isNone: n === "none",
1533
- debugging: n
1534
- };
1535
- }, [t, e]);
439
+ function J(e, t, n) {
440
+ return !e || K ? t : n;
1536
441
  }
1537
- const Ve = "bas_e-SXr", Ge = "row_q-FZb", Oe = "ssr_W1N5g", F = {
1538
- bas: Ve,
1539
- row: Ge,
1540
- ssr: Oe
1541
- }, De = (t, e, n) => ({
1542
- "--bkbw": "100%",
1543
- "--bkbh": "100%",
1544
- "--bkbb": `${t}px`,
1545
- "--bkbcl": e,
1546
- "--bkbcf": n
1547
- }), _e = (t) => {
1548
- const { index: e, base: n, variant: s, chosenColor: o, lineColor: r, flatColor: i } = t;
1549
- return {
1550
- "--bkrt": e === 0 ? "0px" : `${e * n}px`,
1551
- "--bkrh": s === "line" ? "1px" : `${n}px`,
1552
- "--bkbc": o || (s === "line" ? r : i)
1553
- };
1554
- }, Ae = l.memo(function({
1555
- className: e,
1556
- debugging: n,
1557
- style: s,
1558
- variant: o,
1559
- height: r,
1560
- width: i,
1561
- base: a,
1562
- color: c,
1563
- ssrMode: d = !1,
1564
- ...f
1565
- }) {
1566
- const u = T("baseline"), { isShown: M } = j(n, u.debugging), v = l.useRef(null), {
1567
- width: b,
1568
- height: w,
1569
- refresh: g
1570
- } = P(v);
1571
- l.useEffect(() => {
1572
- const C = () => {
1573
- g();
1574
- };
1575
- return window.addEventListener("resize", C), () => {
1576
- window.removeEventListener("resize", C);
1577
- };
1578
- }, [g]);
1579
- const [h, D] = l.useMemo(() => kt(
1580
- [i, r],
1581
- [b, w]
1582
- ), [i, r, b, w]), { top: S, right: x, bottom: $, left: I } = l.useMemo(
1583
- () => Y(f),
1584
- [f]
1585
- ), m = l.useMemo(() => {
1586
- const C = [S, x, $, I].map((E) => E ? `${E}px` : "0").join(" ");
1587
- return C !== "0 0 0 0" ? C : void 0;
1588
- }, [S, x, $, I]), G = l.useMemo(() => {
1589
- const C = a || u.base;
1590
- return Nt({
1591
- height: D,
1592
- top: S,
1593
- bottom: $,
1594
- base: C
1595
- });
1596
- }, [D, S, $, a, u.base]), { start: A, end: p } = Ut({
1597
- totalLines: G,
1598
- lineHeight: a || u.base,
1599
- containerRef: v,
1600
- buffer: 160
1601
- }), B = c || (o === "line" ? u.colors.line : u.colors.flat), _ = l.useMemo(
1602
- () => De(
1603
- a || u.base,
1604
- u.colors.line,
1605
- u.colors.flat
1606
- ),
1607
- [a, u.colors.line, u.colors.flat, u.base]
1608
- ), V = l.useMemo(() => {
1609
- const C = O(i || "100%"), E = O(r || "100%"), R = ["--bkbw", "--bkbh"];
1610
- return q(
1611
- {
1612
- ...k({
1613
- key: "--bkbw",
1614
- value: C,
1615
- defaultStyles: _,
1616
- skipDimensions: { fullSize: R }
1617
- }),
1618
- ...k({
1619
- key: "--bkbh",
1620
- value: E,
1621
- defaultStyles: _,
1622
- skipDimensions: { fullSize: R }
1623
- }),
1624
- ...k({
1625
- key: "--bkbb",
1626
- value: `${a}px`,
1627
- defaultStyles: _
1628
- }),
1629
- ...k({
1630
- key: "--bkbcl",
1631
- value: c || u.colors.line,
1632
- defaultStyles: _
1633
- }),
1634
- ...k({
1635
- key: "--bkbcf",
1636
- value: c || u.colors.flat,
1637
- defaultStyles: _
1638
- }),
1639
- ...m && { padding: m }
1640
- },
1641
- s
1642
- );
1643
- }, [
1644
- i,
1645
- r,
1646
- a,
1647
- c,
1648
- u.colors.line,
1649
- u.colors.flat,
1650
- m,
1651
- _,
1652
- s
1653
- ]), L = l.useCallback(
1654
- (C) => {
1655
- const E = o, R = a || u.base;
1656
- return _e({
1657
- index: C,
1658
- base: R,
1659
- variant: E,
1660
- chosenColor: B,
1661
- lineColor: u.colors.line,
1662
- flatColor: u.colors.flat
1663
- });
1664
- },
1665
- [
1666
- a,
1667
- o,
1668
- B,
1669
- u.colors.line,
1670
- u.colors.flat,
1671
- u.base
1672
- ]
1673
- );
1674
- return /* @__PURE__ */ y(
1675
- "div",
1676
- {
1677
- ref: v,
1678
- "data-testid": "baseline",
1679
- className: z(
1680
- F.bas,
1681
- M ? F.v : F.h,
1682
- e
1683
- ),
1684
- style: V,
1685
- ...f,
1686
- children: M && Array.from({ length: p - A }, (C, E) => {
1687
- const R = E + A;
1688
- return /* @__PURE__ */ y(
1689
- "div",
1690
- {
1691
- className: F.row,
1692
- "data-row-index": R,
1693
- style: L(R)
1694
- },
1695
- R
1696
- );
1697
- })
1698
- }
1699
- );
1700
- }), Fe = l.memo(function({
1701
- className: e,
1702
- debugging: n,
1703
- style: s,
1704
- variant: o,
1705
- height: r,
1706
- width: i,
1707
- base: a,
1708
- color: c,
1709
- ssrMode: d = !1,
1710
- ...f
1711
- }) {
1712
- const u = T("baseline"), M = o ?? u.variant, v = a ?? u.base, { isShown: b } = j(n, u.debugging);
1713
- if (!b)
1714
- return /* @__PURE__ */ y(
1715
- "div",
1716
- {
1717
- className: z(F.b, F.h, e),
1718
- style: s,
1719
- "data-testid": "baseline",
1720
- ...f
1721
- }
1722
- );
1723
- const w = /* @__PURE__ */ y(
1724
- "div",
1725
- {
1726
- className: z(F.b, F.h, F.ssr, e),
1727
- style: {
1728
- width: i || "100%",
1729
- height: r || "100%",
1730
- ...s
1731
- },
1732
- "data-testid": "baseline"
1733
- }
1734
- );
1735
- return /* @__PURE__ */ y(wt, { fallback: w, children: /* @__PURE__ */ y(
1736
- Ae,
1737
- {
1738
- className: e,
1739
- debugging: n,
1740
- style: s,
1741
- variant: M,
1742
- height: r,
1743
- width: i,
1744
- base: v,
1745
- color: c,
1746
- ssrMode: d,
1747
- ...f
1748
- }
1749
- ) });
1750
- });
1751
- export {
1752
- Fe as Baseline,
1753
- ze as Box,
1754
- it as Config,
1755
- Te as Guide,
1756
- We as Layout,
1757
- at as Padder,
1758
- Qt as Spacer,
1759
- He as Stack,
1760
- xt as isSSR,
1761
- Be as safeClientValue
1762
- };
1763
- //# sourceMappingURL=index.mjs.map
442
+ var ee = {
443
+ spr: "spr_syfhf",
444
+ line: "line_nzGsp",
445
+ flat: "flat_XJWHt"
446
+ }, Y = p.memo(function({ height: e, width: t, indicatorNode: r, debugging: i, variant: a, base: o, color: c, className: l, style: u, children: d, ssrMode: f = !1, ...m }) {
447
+ let h = p.useRef(null), g = P("spacer"), { isShown: _ } = F(i, g.debugging), v = a ?? g.variant, S = o ?? g.base, C = I(), w = p.useMemo(() => s({
448
+ base: S,
449
+ colors: g.colors,
450
+ width: t,
451
+ height: e,
452
+ color: c,
453
+ variant: v,
454
+ isVisible: _
455
+ }), [
456
+ S,
457
+ g.colors,
458
+ t,
459
+ e,
460
+ c,
461
+ v,
462
+ _
463
+ ]), T = J(C && !f, !1, _ && r !== void 0), E = p.useMemo(() => {
464
+ if (!T) return null;
465
+ let e = w.normWidth, t = w.normHeight;
466
+ return /* @__PURE__ */ x(y, { children: [t !== 0 && /* @__PURE__ */ b("span", {
467
+ "aria-hidden": "true",
468
+ children: r(t, "height")
469
+ }, "height"), e !== 0 && /* @__PURE__ */ b("span", {
470
+ "aria-hidden": "true",
471
+ children: r(e, "width")
472
+ }, "width")] });
473
+ }, [
474
+ T,
475
+ r,
476
+ w.normWidth,
477
+ w.normHeight
478
+ ]), D = p.useMemo(() => R(w.style, u), [w.style, u]);
479
+ return /* @__PURE__ */ x("div", {
480
+ ref: h,
481
+ "data-testid": "spacer",
482
+ className: n(...w.classTokens.map((e) => ee[e]), l),
483
+ "data-variant": v,
484
+ "data-height": typeof w.normHeight == "number" ? `${w.normHeight}px` : w.normHeight,
485
+ style: D,
486
+ ...m,
487
+ children: [E, d]
488
+ });
489
+ }), X = {
490
+ pad: "pad_NizuS",
491
+ lay: "lay_ZdQLz",
492
+ line: "line_7S7iI",
493
+ stk: "stk_X79YA",
494
+ v: "v_dowAz"
495
+ }, te = (e, t, n) => {
496
+ let r = e || "line", i = t || "none", a = (e, t) => /* @__PURE__ */ b(Y, {
497
+ variant: r,
498
+ debugging: t === 0 || e === 0 ? "none" : i,
499
+ indicatorNode: n,
500
+ height: t === "100%" ? void 0 : t,
501
+ width: e === "100%" ? void 0 : e
502
+ });
503
+ return a.displayName = "PadderSpacer", a;
504
+ }, Z = { gridColumn: "1 / -1" }, Q = { gridRow: "2 / 3" }, ne = {
505
+ gridRow: "2 / 3",
506
+ gridColumn: "2 / 3"
507
+ }, $ = p.memo(p.forwardRef(function({ children: e, className: t, debugging: i, height: a, indicatorNode: o, style: s, width: c, ssrMode: l = !1, ...u }, d) {
508
+ let m = P("padder"), { variant: h } = P("spacer"), g = p.useMemo(() => r(u), [u]), { isShown: _, isNone: v, debugging: S } = F(i, m.debugging), C = !v, w = I(), T = p.useRef(null), E = j(T, {
509
+ base: m.base,
510
+ snapping: "height",
511
+ spacing: g
512
+ }), D = { padding: {
513
+ top: g.top || 0,
514
+ right: g.right || 0,
515
+ bottom: g.bottom || 0,
516
+ left: g.left || 0
517
+ } }, { padding: O } = J(w && !l, D, E), k = z(d, T), A = p.useMemo(() => f({
518
+ base: m.base,
519
+ color: m.color,
520
+ width: c,
521
+ height: a,
522
+ padding: O,
523
+ enableSpacers: C,
524
+ isVisible: _
525
+ }), [
526
+ m.base,
527
+ m.color,
528
+ c,
529
+ a,
530
+ O,
531
+ C,
532
+ _
533
+ ]), M = p.useMemo(() => R(A.containerStyle, s), [A.containerStyle, s]), N = p.useMemo(() => te(h, S, o), [
534
+ h,
535
+ S,
536
+ o
537
+ ]);
538
+ return C ? /* @__PURE__ */ x("div", {
539
+ ref: k,
540
+ "data-testid": "padder",
541
+ className: n(...A.classTokens.map((e) => X[e]), t),
542
+ style: M,
543
+ children: [
544
+ /* @__PURE__ */ x(y, { children: [O.top >= 0 && /* @__PURE__ */ b("div", {
545
+ style: Z,
546
+ children: N("100%", O.top)
547
+ }), O.left >= 0 && /* @__PURE__ */ b("div", {
548
+ style: Q,
549
+ children: N(O.left, "100%")
550
+ })] }),
551
+ /* @__PURE__ */ b("div", {
552
+ style: ne,
553
+ children: e
554
+ }),
555
+ /* @__PURE__ */ x(y, { children: [O.right >= 0 && /* @__PURE__ */ b("div", {
556
+ style: Q,
557
+ children: N(O.right, "100%")
558
+ }), O.bottom >= 0 && /* @__PURE__ */ b("div", {
559
+ style: Z,
560
+ children: N("100%", O.bottom)
561
+ })] })
562
+ ]
563
+ }) : /* @__PURE__ */ b("div", {
564
+ ref: k,
565
+ "data-testid": "padder",
566
+ className: n(...A.classTokens.map((e) => X[e]), t),
567
+ style: M,
568
+ children: e
569
+ });
570
+ })), re = {
571
+ box: "box_sPqFs",
572
+ v: "v_ZrZ5j"
573
+ }, ie = p.memo(p.forwardRef(function({ children: e, snapping: t = "clamp", debugging: i, className: a, colSpan: o, rowSpan: s, span: c, width: l, height: d, style: f, ssrMode: m = !1, ...h }, g) {
574
+ let _ = P("box"), { isShown: v, debugging: y } = F(i, _.debugging), x = I(), S = p.useRef(null), { top: C, bottom: T, left: E, right: D } = r(h), O = j(S, {
575
+ base: _.base,
576
+ snapping: t,
577
+ spacing: {
578
+ top: C,
579
+ bottom: T,
580
+ left: E,
581
+ right: D
582
+ }
583
+ }), { padding: k } = J(x && !m, { padding: {
584
+ top: C || 0,
585
+ right: D || 0,
586
+ bottom: T || 0,
587
+ left: E || 0
588
+ } }, O), A = p.useMemo(() => u({
589
+ base: _.base,
590
+ lineColor: _.colors.line,
591
+ width: l,
592
+ height: d,
593
+ span: c,
594
+ colSpan: o,
595
+ rowSpan: s,
596
+ isVisible: v
597
+ }), [
598
+ _.base,
599
+ _.colors.line,
600
+ l,
601
+ d,
602
+ c,
603
+ o,
604
+ s,
605
+ v
606
+ ]), M = p.useMemo(() => R(A.boxStyle, f), [A.boxStyle, f]);
607
+ return /* @__PURE__ */ b("div", {
608
+ ref: z(g, S),
609
+ "data-testid": "box",
610
+ className: n(...A.classTokens.map((e) => re[e]), a),
611
+ style: R(M, A.gridSpanStyle),
612
+ children: /* @__PURE__ */ b(w, {
613
+ base: 1,
614
+ spacer: { variant: "flat" },
615
+ children: /* @__PURE__ */ b($, {
616
+ block: [k.top, k.bottom],
617
+ inline: [k.left, k.right],
618
+ width: "fit-content",
619
+ height: d,
620
+ debugging: y,
621
+ ssrMode: m,
622
+ children: e
623
+ })
624
+ })
625
+ });
626
+ }));
627
+ //#endregion
628
+ export { H as Baseline, ie as Box, w as Config, W as Guide, $ as Padder, Y as Spacer, K as isSSR, q as safeClientValue };
629
+
630
+ //# sourceMappingURL=index.mjs.map