baseline-kit 3.0.2 → 5.1.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 (79) hide show
  1. package/CHANGELOG.md +235 -0
  2. package/README.md +226 -334
  3. package/dist/baseline-kit.css +7 -22
  4. package/dist/core.cjs +1 -0
  5. package/dist/core.d.ts +354 -0
  6. package/dist/core.mjs +2 -0
  7. package/dist/guide.cjs +2 -0
  8. package/dist/guide.cjs.map +1 -0
  9. package/dist/guide.css +2 -0
  10. package/dist/guide.d.ts +146 -0
  11. package/dist/guide.mjs +586 -0
  12. package/dist/guide.mjs.map +1 -0
  13. package/dist/index.cjs +2 -2
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.ts +204 -30
  16. package/dist/index.mjs +620 -1747
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/remix-server.d.ts +8 -0
  19. package/dist/remix-server.mjs +15 -0
  20. package/dist/remix-server.mjs.map +1 -0
  21. package/dist/remix.css +2 -0
  22. package/dist/remix.d.ts +177 -0
  23. package/dist/remix.mjs +989 -0
  24. package/dist/remix.mjs.map +1 -0
  25. package/dist/reset.css +43 -0
  26. package/dist/src-C-1u5WNS.cjs +2 -0
  27. package/dist/src-C-1u5WNS.cjs.map +1 -0
  28. package/dist/src-C3TICsw6.js +547 -0
  29. package/dist/src-C3TICsw6.js.map +1 -0
  30. package/dist/styles.css +1 -1
  31. package/dist/theme/dark.css +0 -8
  32. package/dist/theme/default.css +0 -10
  33. package/dist/theme/tokens.css +1 -11
  34. package/dist/theme.css +4 -19
  35. package/package.json +135 -46
  36. package/dist/README.md +0 -446
  37. package/dist/components/Baseline/Baseline.d.ts +0 -48
  38. package/dist/components/Baseline/index.d.ts +0 -6
  39. package/dist/components/Box/Box.d.ts +0 -73
  40. package/dist/components/Box/index.d.ts +0 -6
  41. package/dist/components/Config/Config.d.ts +0 -179
  42. package/dist/components/Config/defaults.d.ts +0 -25
  43. package/dist/components/Config/index.d.ts +0 -11
  44. package/dist/components/Guide/Guide.d.ts +0 -70
  45. package/dist/components/Guide/index.d.ts +0 -6
  46. package/dist/components/Guide/types.d.ts +0 -144
  47. package/dist/components/Guide/validation.d.ts +0 -82
  48. package/dist/components/Layout/Layout.d.ts +0 -73
  49. package/dist/components/Layout/index.d.ts +0 -10
  50. package/dist/components/Padder/Padder.d.ts +0 -67
  51. package/dist/components/Padder/index.d.ts +0 -10
  52. package/dist/components/Spacer/Spacer.d.ts +0 -48
  53. package/dist/components/Spacer/index.d.ts +0 -10
  54. package/dist/components/Stack/Stack.d.ts +0 -84
  55. package/dist/components/Stack/index.d.ts +0 -10
  56. package/dist/components/index.d.ts +0 -16
  57. package/dist/components/styles/index.d.ts +0 -11
  58. package/dist/components/types.d.ts +0 -102
  59. package/dist/hooks/index.d.ts +0 -11
  60. package/dist/hooks/useBaseline.d.ts +0 -55
  61. package/dist/hooks/useConfig.d.ts +0 -41
  62. package/dist/hooks/useDebug.d.ts +0 -49
  63. package/dist/hooks/useGuide.d.ts +0 -61
  64. package/dist/hooks/useIsClient.d.ts +0 -6
  65. package/dist/hooks/useMeasure.d.ts +0 -35
  66. package/dist/hooks/useVirtual.d.ts +0 -60
  67. package/dist/styles.d.ts +0 -6
  68. package/dist/theme.d.ts +0 -6
  69. package/dist/utils/convert.d.ts +0 -24
  70. package/dist/utils/grid.d.ts +0 -22
  71. package/dist/utils/index.d.ts +0 -15
  72. package/dist/utils/math.d.ts +0 -48
  73. package/dist/utils/merge.d.ts +0 -117
  74. package/dist/utils/normalize.d.ts +0 -30
  75. package/dist/utils/padding.d.ts +0 -11
  76. package/dist/utils/parse.d.ts +0 -18
  77. package/dist/utils/snapping.d.ts +0 -28
  78. package/dist/utils/ssr.d.ts +0 -26
  79. package/dist/utils/timing.d.ts +0 -45
package/dist/index.mjs CHANGED
@@ -1,1763 +1,636 @@
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-C3TICsw6.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 = "__baseline_kit_config_context__", C = globalThis, w = C[S] ?? (C[S] = p.createContext(a));
7
+ w.displayName = "ConfigContext";
8
+ var T = () => p.use(w);
9
+ function E({ children: t, base: n, baseline: r, guide: i, spacer: a, box: o, padder: s }) {
10
+ let c = T(), l = p.useMemo(() => e({
11
+ parentConfig: c,
12
+ base: n,
13
+ baseline: r,
14
+ guide: i,
15
+ spacer: a,
16
+ box: o,
17
+ padder: s
18
+ }), [
19
+ c,
20
+ n,
21
+ r,
22
+ i,
23
+ a,
24
+ o,
25
+ s
26
+ ]);
27
+ return /* @__PURE__ */ b(w, {
28
+ value: l,
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 D = (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 O(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] = D(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 k = {
71
+ width: 0,
72
+ height: 0
73
+ };
74
+ function A(e) {
75
+ let [t, n] = p.useState(k), r = p.useRef(null);
76
+ p.useLayoutEffect(() => {
77
+ if (typeof window > "u" || !e.current) return;
78
+ let t = O(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 j(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] = D(() => {
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 M({ 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
+ o((t) => t.start === 0 && t.end === e ? t : {
133
+ start: 0,
134
+ end: e
135
+ });
136
+ let r = j(n.current, {
137
+ totalItems: e,
138
+ itemHeight: t,
139
+ buffer: i
140
+ }, s);
141
+ return () => r.disconnect();
142
+ }, [
143
+ n,
144
+ e,
145
+ t,
146
+ i,
147
+ s
148
+ ]), a;
359
149
  }
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;
150
+ //#endregion
151
+ //#region packages/react/src/hooks/useBaseline.ts
152
+ function N(e, { base: t = 8, snapping: n = "none", spacing: i = {} } = {}) {
153
+ if (t < 1) throw Error("Base must be >= 1 for baseline alignment.");
154
+ let { height: a } = A(e), s = p.useRef(null);
155
+ return p.useMemo(() => {
156
+ let e = r({ padding: i }), c = a % t === 0;
157
+ if (n === "none") return {
158
+ padding: e,
159
+ isAligned: c,
160
+ height: a
161
+ };
162
+ if (s.current) return {
163
+ padding: s.current,
164
+ isAligned: c,
165
+ height: a
166
+ };
167
+ if (a === 0) return {
168
+ padding: e,
169
+ isAligned: c,
170
+ height: a
171
+ };
172
+ let l = o(a, t, e, n);
173
+ return s.current = l, {
174
+ padding: l,
175
+ isAligned: c,
176
+ height: a
177
+ };
178
+ }, [
179
+ t,
180
+ n,
181
+ i,
182
+ a
183
+ ]);
373
184
  }
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
- }
185
+ //#endregion
186
+ //#region packages/dom/src/viewport.ts
187
+ function P() {
188
+ return typeof window > "u" ? {} : {
189
+ viewportWidth: window.innerWidth,
190
+ viewportHeight: window.innerHeight
191
+ };
383
192
  }
384
- function J(t, e, n) {
385
- return !t || xt ? e : n;
193
+ //#endregion
194
+ //#region packages/react/src/hooks/useGuide.ts
195
+ function F(e, t) {
196
+ let { width: n } = A(e);
197
+ return p.useMemo(() => d(n, t, P()), [t, n]);
386
198
  }
387
- function wt({ children: t, fallback: e = null }) {
388
- return jt() ? /* @__PURE__ */ y(K, { children: t }) : /* @__PURE__ */ y(K, { children: e });
199
+ //#endregion
200
+ //#region packages/react/src/hooks/useConfig.ts
201
+ function I(e) {
202
+ let t = T();
203
+ return _(() => Object.assign({ base: t.base }, t[e]), [t, e]);
389
204
  }
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 };
205
+ //#endregion
206
+ //#region packages/react/src/hooks/useDebug.ts
207
+ function L(e, t) {
208
+ return _(() => l(e, t), [e, t]);
416
209
  }
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;
210
+ //#endregion
211
+ //#region packages/react/src/hooks/useIsClient.ts
212
+ function R() {
213
+ let [e, t] = v(!1);
214
+ return h(() => {
215
+ t(!0);
216
+ }, []), e;
456
217
  }
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]);
218
+ //#endregion
219
+ //#region packages/react/src/utils/ssr.tsx
220
+ function z({ children: e, fallback: t = null }) {
221
+ return R() ? /* @__PURE__ */ b(y, { children: e }) : /* @__PURE__ */ b(y, { children: t });
463
222
  }
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]);
223
+ //#endregion
224
+ //#region packages/react/src/utils/merge.ts
225
+ function B(...e) {
226
+ return Object.assign({}, ...e.filter(Boolean));
489
227
  }
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]);
228
+ function V(...e) {
229
+ return (t) => {
230
+ e.forEach((e) => {
231
+ e && (typeof e == "function" ? e(t) : Object.assign(e, { current: t }));
232
+ });
233
+ };
1518
234
  }
1519
- function T(t) {
1520
- const e = gt();
1521
- return Q(() => Object.assign(
1522
- { base: e.base },
1523
- e[t]
1524
- ), [e, t]);
235
+ var H = {
236
+ bas: "bas_4Emvv",
237
+ v: "v_lNfeX",
238
+ h: "h_PbNDU",
239
+ row: "row_J1Wva",
240
+ ssr: "ssr_PQAP-"
241
+ }, U = p.memo(function({ className: e, debugging: t, style: r, variant: a, height: o, width: s, base: c, color: l, ...u }) {
242
+ let d = I("baseline"), { isShown: f } = L(t, d.debugging), m = p.useRef(null), { width: h, height: g } = A(m), _ = c || d.base, v = p.useMemo(() => i({
243
+ base: _,
244
+ colors: d.colors,
245
+ variant: a ?? d.variant,
246
+ width: s,
247
+ height: o,
248
+ color: l,
249
+ containerWidth: h,
250
+ containerHeight: g,
251
+ spacing: u,
252
+ isVisible: f
253
+ }), [
254
+ _,
255
+ d.colors,
256
+ d.variant,
257
+ a,
258
+ s,
259
+ o,
260
+ l,
261
+ h,
262
+ g,
263
+ u,
264
+ f
265
+ ]), { start: y, end: x } = M({
266
+ totalLines: v.rowCount,
267
+ lineHeight: _,
268
+ containerRef: m,
269
+ buffer: 160
270
+ }), S = p.useMemo(() => B(v.containerStyle, r), [v.containerStyle, r]);
271
+ return /* @__PURE__ */ b("div", {
272
+ ref: m,
273
+ "data-testid": "baseline",
274
+ "aria-hidden": "true",
275
+ className: n(...v.classTokens.map((e) => H[e]), e),
276
+ style: S,
277
+ ...u,
278
+ children: f && Array.from({ length: x - y }, (e, t) => {
279
+ let n = t + y;
280
+ return /* @__PURE__ */ b("div", {
281
+ className: H.row,
282
+ "data-row-index": n,
283
+ style: v.getRowStyle(n)
284
+ }, n);
285
+ })
286
+ });
287
+ }), W = p.memo(function({ className: e, debugging: t, style: r, variant: i, height: a, width: o, base: s, color: c, ssrMode: l = !1, ...u }) {
288
+ let d = I("baseline"), f = i ?? d.variant, p = s ?? d.base, { isShown: m } = L(t, d.debugging);
289
+ if (!m) return /* @__PURE__ */ b("div", {
290
+ className: n(H.bas, H.h, e),
291
+ style: r,
292
+ "data-testid": "baseline",
293
+ "aria-hidden": "true",
294
+ ...u
295
+ });
296
+ let h = /* @__PURE__ */ b("div", {
297
+ className: n(H.bas, H.h, H.ssr, e),
298
+ style: {
299
+ width: o ?? "100%",
300
+ height: a ?? "100%",
301
+ ...r
302
+ },
303
+ "data-testid": "baseline",
304
+ "aria-hidden": "true"
305
+ });
306
+ return l ? h : /* @__PURE__ */ b(z, {
307
+ fallback: h,
308
+ children: /* @__PURE__ */ b(U, {
309
+ className: e,
310
+ debugging: t,
311
+ style: r,
312
+ variant: f,
313
+ height: a,
314
+ width: o,
315
+ base: p,
316
+ color: c,
317
+ ...u
318
+ })
319
+ });
320
+ }), G = {
321
+ gde: "gde_4PKz3",
322
+ v: "v_yAvN0",
323
+ h: "h_XcWcy",
324
+ line: "line_UaLjW",
325
+ cols: "cols_ibtT4",
326
+ col: "col_QPSDI",
327
+ ssr: "ssr_4UN4k"
328
+ }, ee = 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 }) {
329
+ let g = I("guide"), _ = i ?? g.variant, v = typeof o == "number" ? o : 0, { isShown: y } = L(t, g.debugging);
330
+ if (!y) return /* @__PURE__ */ b("div", {
331
+ className: n(G.gde, G.h, e),
332
+ style: r,
333
+ "data-testid": "guide",
334
+ "data-variant": _,
335
+ "aria-hidden": "true",
336
+ ...h,
337
+ children: p
338
+ });
339
+ let x = /* @__PURE__ */ b("div", {
340
+ className: n(G.gde, G.h, G.ssr, e),
341
+ style: {
342
+ width: c ?? "100%",
343
+ height: s ?? "100%",
344
+ maxWidth: d ?? "none",
345
+ ...r
346
+ },
347
+ "data-testid": "guide",
348
+ "data-variant": _,
349
+ "aria-hidden": "true",
350
+ children: p
351
+ });
352
+ return m ? x : /* @__PURE__ */ b(z, {
353
+ fallback: x,
354
+ children: /* @__PURE__ */ b(te, {
355
+ className: e,
356
+ debugging: t,
357
+ style: r,
358
+ variant: _,
359
+ align: a,
360
+ gap: v,
361
+ height: s,
362
+ width: c,
363
+ columns: l,
364
+ columnWidth: u,
365
+ maxWidth: d,
366
+ color: f,
367
+ ...h,
368
+ children: p
369
+ })
370
+ });
371
+ }), te = 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, ..._ }) {
372
+ let v = I("guide"), { isShown: y } = L(r, v.debugging), S = p.useRef(null);
373
+ A(S);
374
+ let C = a ?? v.variant, w = typeof s == "number" ? s : 0, { template: T, columnsCount: E, calculatedGap: D } = F(S, p.useMemo(() => t({
375
+ variant: C,
376
+ base: v.base,
377
+ gap: w,
378
+ columns: d,
379
+ columnWidth: f
380
+ }), [
381
+ C,
382
+ v.base,
383
+ w,
384
+ d,
385
+ f
386
+ ])), O = p.useMemo(() => c({
387
+ base: v.base,
388
+ colors: v.colors,
389
+ variant: C,
390
+ align: o || "center",
391
+ width: u,
392
+ height: l,
393
+ columnWidth: f,
394
+ maxWidth: m,
395
+ color: h,
396
+ template: T,
397
+ columnsCount: E,
398
+ calculatedGap: D,
399
+ isVisible: y
400
+ }), [
401
+ v.base,
402
+ v.colors,
403
+ C,
404
+ o,
405
+ u,
406
+ l,
407
+ f,
408
+ m,
409
+ h,
410
+ T,
411
+ E,
412
+ D,
413
+ y
414
+ ]), k = p.useMemo(() => B(O.containerStyle, i), [O.containerStyle, i]);
415
+ return /* @__PURE__ */ x("div", {
416
+ ref: S,
417
+ "data-testid": "guide",
418
+ "aria-hidden": "true",
419
+ className: n(...O.classTokens.map((e) => G[e]), e),
420
+ "data-variant": a,
421
+ style: k,
422
+ ..._,
423
+ children: [y && /* @__PURE__ */ b("div", {
424
+ className: G.cols,
425
+ "data-variant": a,
426
+ children: !O.isLineVariant && Array.from({ length: O.columnsCount }, (e, t) => /* @__PURE__ */ b("div", {
427
+ className: G.col,
428
+ "data-column-index": t,
429
+ "data-variant": a
430
+ }, t))
431
+ }), g]
432
+ });
433
+ }), K = typeof window > "u";
434
+ function ne(e, t) {
435
+ if (K) return t;
436
+ try {
437
+ return e();
438
+ } catch {
439
+ return t;
440
+ }
1525
441
  }
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]);
442
+ function q(e, t, n) {
443
+ return !e || K ? t : n;
1536
444
  }
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
445
+ var J = {
446
+ spr: "spr_syfhf",
447
+ line: "line_nzGsp",
448
+ flat: "flat_XJWHt",
449
+ indicator: "indicator_inw1x"
450
+ }, 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 }) {
451
+ let h = p.useRef(null), g = I("spacer"), { isShown: _ } = L(i, g.debugging), v = a ?? g.variant, S = o ?? g.base, C = R(), w = p.useMemo(() => s({
452
+ base: S,
453
+ colors: g.colors,
454
+ width: t,
455
+ height: e,
456
+ color: c,
457
+ variant: v,
458
+ isVisible: _
459
+ }), [
460
+ S,
461
+ g.colors,
462
+ t,
463
+ e,
464
+ c,
465
+ v,
466
+ _
467
+ ]), T = q(C && !f, !1, _ && r !== void 0), E = p.useMemo(() => {
468
+ if (!T) return null;
469
+ let e = w.normWidth, t = w.normHeight;
470
+ return /* @__PURE__ */ x(y, { children: [t !== 0 && /* @__PURE__ */ b("span", {
471
+ className: J.indicator,
472
+ "aria-hidden": "true",
473
+ children: r(t, "height")
474
+ }, "height"), e !== 0 && /* @__PURE__ */ b("span", {
475
+ className: J.indicator,
476
+ "aria-hidden": "true",
477
+ children: r(e, "width")
478
+ }, "width")] });
479
+ }, [
480
+ T,
481
+ r,
482
+ w.normWidth,
483
+ w.normHeight
484
+ ]), D = p.useMemo(() => B(w.style, u), [w.style, u]);
485
+ return /* @__PURE__ */ x("div", {
486
+ ref: h,
487
+ "data-testid": "spacer",
488
+ className: n(...w.classTokens.map((e) => J[e]), l),
489
+ "data-variant": v,
490
+ "data-height": typeof w.normHeight == "number" ? `${w.normHeight}px` : w.normHeight,
491
+ style: D,
492
+ ...m,
493
+ children: [E, d]
494
+ });
495
+ }), X = {
496
+ pad: "pad_NizuS",
497
+ content: "content_xFX0U",
498
+ v: "v_dowAz"
499
+ }, re = (e, t, n) => {
500
+ let r = e || "line", i = t || "none", a = (e, t) => /* @__PURE__ */ b(Y, {
501
+ variant: r,
502
+ debugging: t === 0 || e === 0 ? "none" : i,
503
+ indicatorNode: n,
504
+ height: t === "100%" ? void 0 : t,
505
+ width: e === "100%" ? void 0 : e
506
+ });
507
+ return a.displayName = "PadderSpacer", a;
508
+ }, Z = { gridColumn: "1 / -1" }, Q = { gridRow: "2 / 3" }, ie = {
509
+ gridRow: "2 / 3",
510
+ gridColumn: "2 / 3"
511
+ }, $ = p.memo(p.forwardRef(function({ children: e, className: t, debugging: i, height: a, indicatorNode: o, style: s, width: c, ssrMode: l = !1, ...u }, d) {
512
+ let m = I("padder"), { variant: h } = I("spacer"), g = p.useMemo(() => r(u), [u]), { isShown: _, isNone: v, debugging: S } = L(i, m.debugging), C = !v, w = R(), T = p.useRef(null), E = N(T, {
513
+ base: m.base,
514
+ snapping: "height",
515
+ spacing: g
516
+ }), D = { padding: {
517
+ top: g.top || 0,
518
+ right: g.right || 0,
519
+ bottom: g.bottom || 0,
520
+ left: g.left || 0
521
+ } }, { padding: O } = q(w && !l, D, E), k = V(d, T), A = p.useMemo(() => f({
522
+ base: m.base,
523
+ color: m.color,
524
+ width: c,
525
+ height: a,
526
+ padding: O,
527
+ enableSpacers: C,
528
+ isVisible: _
529
+ }), [
530
+ m.base,
531
+ m.color,
532
+ c,
533
+ a,
534
+ O,
535
+ C,
536
+ _
537
+ ]), j = p.useMemo(() => B(A.containerStyle, s), [A.containerStyle, s]), M = p.useMemo(() => re(h, S, o), [
538
+ h,
539
+ S,
540
+ o
541
+ ]);
542
+ return C ? /* @__PURE__ */ x("div", {
543
+ ref: k,
544
+ "data-testid": "padder",
545
+ className: n(...A.classTokens.map((e) => X[e]), t),
546
+ style: j,
547
+ children: [
548
+ /* @__PURE__ */ x(y, { children: [O.top >= 0 && /* @__PURE__ */ b("div", {
549
+ style: Z,
550
+ children: M("100%", O.top)
551
+ }), O.left >= 0 && /* @__PURE__ */ b("div", {
552
+ style: Q,
553
+ children: M(O.left, "100%")
554
+ })] }),
555
+ /* @__PURE__ */ b("div", {
556
+ "data-testid": "padder-content",
557
+ className: X.content,
558
+ style: ie,
559
+ children: e
560
+ }),
561
+ /* @__PURE__ */ x(y, { children: [O.right >= 0 && /* @__PURE__ */ b("div", {
562
+ style: Q,
563
+ children: M(O.right, "100%")
564
+ }), O.bottom >= 0 && /* @__PURE__ */ b("div", {
565
+ style: Z,
566
+ children: M("100%", O.bottom)
567
+ })] })
568
+ ]
569
+ }) : /* @__PURE__ */ b("div", {
570
+ ref: k,
571
+ "data-testid": "padder",
572
+ className: n(...A.classTokens.map((e) => X[e]), t),
573
+ style: j,
574
+ children: e
575
+ });
576
+ })), ae = {
577
+ box: "box_sPqFs",
578
+ v: "v_ZrZ5j"
579
+ }, oe = 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) {
580
+ let _ = I("box"), { isShown: v, debugging: y } = L(i, _.debugging), x = R(), S = p.useRef(null), { top: C, bottom: w, left: T, right: D } = r(h), O = N(S, {
581
+ base: _.base,
582
+ snapping: t,
583
+ spacing: {
584
+ top: C,
585
+ bottom: w,
586
+ left: T,
587
+ right: D
588
+ }
589
+ }), { padding: k } = q(x && !m, { padding: {
590
+ top: C || 0,
591
+ right: D || 0,
592
+ bottom: w || 0,
593
+ left: T || 0
594
+ } }, O), A = p.useMemo(() => u({
595
+ base: _.base,
596
+ lineColor: _.colors.line,
597
+ width: l,
598
+ height: d,
599
+ span: c,
600
+ colSpan: o,
601
+ rowSpan: s,
602
+ isVisible: v
603
+ }), [
604
+ _.base,
605
+ _.colors.line,
606
+ l,
607
+ d,
608
+ c,
609
+ o,
610
+ s,
611
+ v
612
+ ]), j = p.useMemo(() => B(A.boxStyle, f), [A.boxStyle, f]);
613
+ return /* @__PURE__ */ b("div", {
614
+ ref: V(g, S),
615
+ "data-testid": "box",
616
+ className: n(...A.classTokens.map((e) => ae[e]), a),
617
+ style: B(j, A.gridSpanStyle),
618
+ children: /* @__PURE__ */ b(E, {
619
+ base: 1,
620
+ spacer: { variant: "flat" },
621
+ children: /* @__PURE__ */ b($, {
622
+ block: [k.top, k.bottom],
623
+ inline: [k.left, k.right],
624
+ width: "fit-content",
625
+ height: d,
626
+ debugging: y,
627
+ ssrMode: !0,
628
+ children: e
629
+ })
630
+ })
631
+ });
632
+ }));
633
+ //#endregion
634
+ export { W as Baseline, oe as Box, E as Config, ee as Guide, $ as Padder, Y as Spacer, K as isSSR, ne as safeClientValue };
635
+
636
+ //# sourceMappingURL=index.mjs.map