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/guide.mjs ADDED
@@ -0,0 +1,589 @@
1
+ import * as e from "react";
2
+ import { useEffect as t, useMemo as n, useState as r } from "react";
3
+ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ //#region packages/core/src/config/defaults.ts
5
+ var s = {
6
+ base: 8,
7
+ baseline: {
8
+ variant: "line",
9
+ debugging: "hidden",
10
+ colors: {
11
+ line: "var(--bk-baseline-color-line-theme)",
12
+ flat: "var(--bk-baseline-color-flat-theme)"
13
+ }
14
+ },
15
+ guide: {
16
+ variant: "line",
17
+ debugging: "hidden",
18
+ colors: {
19
+ line: "var(--bk-guide-color-line-theme)",
20
+ pattern: "var(--bk-guide-color-pattern-theme)",
21
+ auto: "var(--bk-guide-color-auto-theme)",
22
+ fixed: "var(--bk-guide-color-fixed-theme)"
23
+ }
24
+ },
25
+ spacer: {
26
+ variant: "line",
27
+ debugging: "hidden",
28
+ colors: {
29
+ line: "var(--bk-spacer-color-line-theme)",
30
+ flat: "var(--bk-spacer-color-flat-theme)",
31
+ text: "var(--bk-spacer-color-text-theme)"
32
+ }
33
+ },
34
+ box: {
35
+ debugging: "hidden",
36
+ colors: {
37
+ line: "var(--bk-box-color-line-theme)",
38
+ flat: "var(--bk-box-color-flat-theme)",
39
+ text: "var(--bk-box-color-text-theme)"
40
+ }
41
+ },
42
+ padder: {
43
+ debugging: "hidden",
44
+ color: "var(--bk-padder-color-theme)"
45
+ }
46
+ }, c = [
47
+ "baseline",
48
+ "guide",
49
+ "spacer",
50
+ "box",
51
+ "padder"
52
+ ], l = (e) => {
53
+ let { parentConfig: t, base: n } = e, r = {};
54
+ for (let n of c) r[n] = {
55
+ ...t[n],
56
+ ...e[n]
57
+ };
58
+ return {
59
+ base: n ?? t.base,
60
+ ...r
61
+ };
62
+ }, u = (e) => {
63
+ let { base: t, baseline: n, guide: r, spacer: i, box: a, padder: o } = e;
64
+ return {
65
+ "--bk-base": `${t}px`,
66
+ "--bkbl-cl": n.colors.line,
67
+ "--bkbl-cf": n.colors.flat,
68
+ "--bkgd-cl": r.colors.line,
69
+ "--bkgd-cp": r.colors.pattern,
70
+ "--bkgd-ca": r.colors.auto,
71
+ "--bkgd-cf": r.colors.fixed,
72
+ "--bksp-cl": i.colors.line,
73
+ "--bksp-cf": i.colors.flat,
74
+ "--bksp-ct": i.colors.text,
75
+ "--bkbx-cl": a.colors.line,
76
+ "--bkbx-cf": a.colors.flat,
77
+ "--bkbx-ct": a.colors.text,
78
+ "--bkpd-c": o.color
79
+ };
80
+ }, d = e.createContext(s);
81
+ d.displayName = "ConfigContext";
82
+ var f = () => e.use(d);
83
+ function p({ children: t, base: n, baseline: r, guide: i, spacer: o, box: s, padder: c }) {
84
+ let u = f();
85
+ return /* @__PURE__ */ a(d, {
86
+ value: e.useMemo(() => l({
87
+ parentConfig: u,
88
+ base: n,
89
+ baseline: r,
90
+ guide: i,
91
+ spacer: o,
92
+ box: s,
93
+ padder: c
94
+ }), [
95
+ u,
96
+ n,
97
+ r,
98
+ i,
99
+ o,
100
+ s,
101
+ c
102
+ ]),
103
+ children: t
104
+ });
105
+ }
106
+ //#endregion
107
+ //#region packages/core/src/utils/parse.ts
108
+ function m(e) {
109
+ let t = e.trim().match(/^([+-]?[\d.]+)([a-zA-Z%]+)$/);
110
+ return t ? {
111
+ value: parseFloat(t[1]),
112
+ unit: t[2]
113
+ } : null;
114
+ }
115
+ function h(e, t) {
116
+ return e === void 0 && t !== void 0 ? `${t}px` : e === "auto" || typeof e == "string" && /^(auto|100%|0|.*(fr|vh|vw|vmin|vmax|rem))$/.test(e) ? String(e) : typeof e == "number" ? `${e}px` : e ?? "";
117
+ }
118
+ //#endregion
119
+ //#region packages/core/src/utils/convert.ts
120
+ var g = {
121
+ parentSize: 0,
122
+ viewportWidth: 1920,
123
+ viewportHeight: 1080,
124
+ rootFontSize: 16,
125
+ parentFontSize: 16
126
+ }, _ = {
127
+ px: 1,
128
+ in: 96,
129
+ cm: 37.8,
130
+ mm: 3.78,
131
+ pt: 1.33,
132
+ pc: 16
133
+ }, v = {
134
+ em: (e) => e.parentFontSize,
135
+ rem: (e) => e.rootFontSize,
136
+ vh: (e) => e.viewportHeight / 100,
137
+ vw: (e) => e.viewportWidth / 100,
138
+ vmin: (e) => Math.min(e.viewportWidth, e.viewportHeight) / 100,
139
+ vmax: (e) => Math.max(e.viewportWidth, e.viewportHeight) / 100,
140
+ "%": (e) => e.parentSize / 100
141
+ };
142
+ function y(e, t) {
143
+ if (typeof e == "number") return e;
144
+ if (typeof e != "string") return null;
145
+ let n = m(e);
146
+ if (!n) return null;
147
+ let { value: r, unit: i } = n;
148
+ if (i in _) return r * _[i];
149
+ if (i === "auto") return null;
150
+ let a = v[i];
151
+ return a ? r * a({
152
+ ...g,
153
+ ...t
154
+ }) : null;
155
+ }
156
+ //#endregion
157
+ //#region packages/core/src/utils/math.ts
158
+ function b(e, t, n) {
159
+ return Math.min(Math.max(e, t), n);
160
+ }
161
+ //#endregion
162
+ //#region packages/core/src/utils/normalize.ts
163
+ function x(e, t = {}) {
164
+ let { base: n = 8, round: r = !0, clamp: i, context: a } = t;
165
+ if (e === "auto") return n;
166
+ let o = null;
167
+ if (typeof e == "number" ? o = e : typeof e == "string" && (o = y(e, a) ?? n), o === null && (o = n), n <= 0) return o;
168
+ let s = r ? Math.round(o / n) * n : o;
169
+ return i === void 0 ? s : b(s, i.min ?? -Infinity, i.max ?? Infinity);
170
+ }
171
+ //#endregion
172
+ //#region packages/core/src/utils/merge.ts
173
+ var S = (...e) => e.filter(Boolean).join(" ").trim();
174
+ function C(e, t) {
175
+ let n = e ?? t;
176
+ return {
177
+ isShown: n === "visible",
178
+ isHidden: n === "hidden",
179
+ isNone: n === "none",
180
+ debugging: n
181
+ };
182
+ }
183
+ function w(e, t, n) {
184
+ let r = typeof e == "string" ? e : e.key, i = typeof e == "string" ? t : e.value, a = typeof e == "string" ? n : e.defaultStyles, o = typeof e == "object" ? e.skipDimensions : void 0;
185
+ return o && (o.fitContent?.includes(r) && i === "fit-content" || o.auto?.includes(r) && i === "auto" || o.fullSize?.includes(r) && (i === "100%" || i === "100vh" || i === "100vw")) || i === a[r] ? {} : { [r]: i };
186
+ }
187
+ //#endregion
188
+ //#region packages/core/src/validation/guide.ts
189
+ var T = /^\d*\.?\d+(?:fr|px|%|em|rem|vh|vw|vmin|vmax|pt|pc|in|cm|mm)$/, E = (e) => typeof e == "number" ? Number.isFinite(e) && e >= 0 : typeof e == "string" ? e === "auto" || e === "100%" || T.test(e) : !1, D = (e) => Array.isArray(e) && e.length > 0 && e.every(E), O = {
190
+ template: "none",
191
+ columnsCount: 0,
192
+ calculatedGap: 0,
193
+ isValid: !1
194
+ };
195
+ function k(e, t, n) {
196
+ let r = t.variant ?? "line", i = t.base ?? 8, a = x(t.gap ?? 0, {
197
+ base: i,
198
+ context: n
199
+ });
200
+ if (!e) return O;
201
+ switch (r) {
202
+ case "line": {
203
+ let t = a === 0 ? 0 : a - 1, n = t + 1, r = t === 0 ? Math.max(1, Math.floor(e) + 1) : Math.max(1, Math.floor((e + 1) / n) + 1);
204
+ return {
205
+ template: `repeat(${r}, 1px)`,
206
+ columnsCount: r,
207
+ calculatedGap: a > 0 ? a - 1 : a,
208
+ isValid: !0
209
+ };
210
+ }
211
+ case "pattern": {
212
+ if (!t.columns || !Array.isArray(t.columns) || !D(t.columns)) return O;
213
+ let e = t.columns.map((e) => typeof e == "number" ? `${e}px` : e);
214
+ return e.some((e) => e === "0" || e === "0px") ? O : {
215
+ template: e.join(" "),
216
+ columnsCount: e.length,
217
+ calculatedGap: a,
218
+ isValid: !0
219
+ };
220
+ }
221
+ case "fixed": {
222
+ let e = typeof t.columns == "number" ? t.columns : 0;
223
+ return e < 1 ? O : {
224
+ template: `repeat(${e}, ${t.columnWidth ? h(t.columnWidth) : "1fr"})`,
225
+ columnsCount: e,
226
+ calculatedGap: a,
227
+ isValid: !0
228
+ };
229
+ }
230
+ case "auto": {
231
+ let r = t.columnWidth ?? "auto";
232
+ if (r === "auto") return {
233
+ template: "repeat(auto-fill, minmax(0, 1fr))",
234
+ columnsCount: 1,
235
+ calculatedGap: a,
236
+ isValid: !0
237
+ };
238
+ let i = typeof r == "number" ? `${r}px` : r.toString(), o = y(i, n) ?? 0, s = o > 0 ? Math.max(1, Math.floor((e + a) / (o + a))) : 1;
239
+ return {
240
+ template: `repeat(auto-fill, ${i})`,
241
+ columnsCount: s,
242
+ calculatedGap: a,
243
+ isValid: !0
244
+ };
245
+ }
246
+ default: {
247
+ let t = Math.max(1, Math.floor(e / (a + 1)) + 1);
248
+ return {
249
+ template: `repeat(${t}, 1px)`,
250
+ columnsCount: t,
251
+ calculatedGap: a,
252
+ isValid: !0
253
+ };
254
+ }
255
+ }
256
+ }
257
+ //#endregion
258
+ //#region packages/core/src/descriptors/guide.ts
259
+ function A({ variant: e, base: t, gap: n, columns: r, columnWidth: i }) {
260
+ switch (e) {
261
+ case "line": return {
262
+ variant: "line",
263
+ gap: n,
264
+ base: t
265
+ };
266
+ case "pattern":
267
+ if (r && Array.isArray(r)) return {
268
+ variant: "pattern",
269
+ columns: r,
270
+ gap: n,
271
+ base: t
272
+ };
273
+ break;
274
+ case "fixed":
275
+ if (r !== void 0) {
276
+ let e = typeof r == "number" ? r : parseInt(String(r), 10);
277
+ return {
278
+ variant: "fixed",
279
+ columns: isNaN(e) ? 12 : e,
280
+ columnWidth: i || "60px",
281
+ gap: n,
282
+ base: t
283
+ };
284
+ }
285
+ break;
286
+ }
287
+ return {
288
+ variant: "auto",
289
+ columnWidth: i || "1fr",
290
+ gap: n,
291
+ base: t
292
+ };
293
+ }
294
+ var j = (e, t) => ({
295
+ "--bkgd-w": "100%",
296
+ "--bkgd-h": "100%",
297
+ "--bkgd-mw": "none",
298
+ "--bkgd-cw": "60px",
299
+ "--bkgd-gw": "24px",
300
+ "--bkgd-n": "12",
301
+ "--bkgd-b": `${e}px`,
302
+ "--bkgd-cl": t,
303
+ "--bkgd-g": "0"
304
+ });
305
+ function M(e) {
306
+ let { base: t, colors: n, variant: r, align: i, width: a, height: o, columnWidth: s, maxWidth: c, color: l, template: u, columnsCount: d, calculatedGap: f, isVisible: p } = e, m = j(t, n.line), g = ["--bkgd-w", "--bkgd-h"], _ = h(a ?? "100%"), v = h(o ?? "100%"), y = {
307
+ ...w({
308
+ key: "--bkgd-w",
309
+ value: _,
310
+ defaultStyles: m,
311
+ skipDimensions: { fullSize: g }
312
+ }),
313
+ ...w({
314
+ key: "--bkgd-h",
315
+ value: v,
316
+ defaultStyles: m,
317
+ skipDimensions: { fullSize: g }
318
+ }),
319
+ ...w({
320
+ key: "--bkgd-mw",
321
+ value: h(c || "none"),
322
+ defaultStyles: m
323
+ }),
324
+ ...w({
325
+ key: "--bkgd-cw",
326
+ value: h(s || "60px"),
327
+ defaultStyles: m
328
+ }),
329
+ ...w({
330
+ key: "--bkgd-n",
331
+ value: `${d}`,
332
+ defaultStyles: m
333
+ }),
334
+ ...w({
335
+ key: "--bkgd-b",
336
+ value: "0",
337
+ defaultStyles: m
338
+ }),
339
+ ...w({
340
+ key: "--bkgd-cl",
341
+ value: l ?? n.line,
342
+ defaultStyles: m
343
+ }),
344
+ ...w({
345
+ key: "--bkgd-g",
346
+ value: `${f}px`,
347
+ defaultStyles: m
348
+ }),
349
+ ...w({
350
+ key: "--bkgd-j",
351
+ value: i || "center",
352
+ defaultStyles: m
353
+ }),
354
+ ...u && u !== "none" ? { "--bkgd-t": u } : {}
355
+ }, b = (r && r in n ? n[r] : void 0) ?? n.line, x = r === "line", S = ["gde", p ? "v" : "h"];
356
+ return x && S.push("line"), x && (y["--bkgd-line-color"] = l ?? n.line, y["--bkgd-line-period"] = `${f + 1}px`), {
357
+ containerStyle: y,
358
+ columnColor: b,
359
+ columnsCount: d,
360
+ calculatedGap: f,
361
+ template: u,
362
+ isVisible: p,
363
+ isLineVariant: x,
364
+ classTokens: S
365
+ };
366
+ }
367
+ //#endregion
368
+ //#region packages/react/src/hooks/useConfig.ts
369
+ function N(e) {
370
+ let t = f();
371
+ return n(() => Object.assign({ base: t.base }, t[e]), [t, e]);
372
+ }
373
+ //#endregion
374
+ //#region packages/react/src/hooks/useDebug.ts
375
+ function P(e, t) {
376
+ return n(() => C(e, t), [e, t]);
377
+ }
378
+ //#endregion
379
+ //#region packages/dom/src/timing.ts
380
+ var F = (e) => {
381
+ let t = null, n = null;
382
+ return [(...r) => {
383
+ n = r, t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
384
+ e(...n), t = null, n = null;
385
+ });
386
+ }, () => {
387
+ t !== null && (cancelAnimationFrame(t), t = null, n = null);
388
+ }];
389
+ };
390
+ //#endregion
391
+ //#region packages/dom/src/measure.ts
392
+ function I(e, t) {
393
+ let n = {
394
+ width: 0,
395
+ height: 0
396
+ }, r = () => {
397
+ try {
398
+ let r = e.getBoundingClientRect(), i = {
399
+ width: Math.round(r.width),
400
+ height: Math.round(r.height)
401
+ };
402
+ (i.width !== n.width || i.height !== n.height) && (n = i, t(i));
403
+ } catch {}
404
+ }, [i, a] = F(r);
405
+ r();
406
+ let o = new ResizeObserver(i);
407
+ return o.observe(e), {
408
+ refresh: i,
409
+ disconnect() {
410
+ o.disconnect(), a();
411
+ }
412
+ };
413
+ }
414
+ //#endregion
415
+ //#region packages/react/src/hooks/useMeasure.ts
416
+ var L = {
417
+ width: 0,
418
+ height: 0
419
+ };
420
+ function R(t) {
421
+ let [n, r] = e.useState(L), i = e.useRef(null);
422
+ e.useLayoutEffect(() => {
423
+ if (typeof window > "u" || !t.current) return;
424
+ let e = I(t.current, (e) => {
425
+ r((t) => t.width === e.width && t.height === e.height ? t : e);
426
+ });
427
+ return i.current = e, () => {
428
+ e.disconnect(), i.current = null;
429
+ };
430
+ }, [t]);
431
+ let a = e.useCallback(() => {
432
+ i.current?.refresh();
433
+ }, []);
434
+ return {
435
+ ...n,
436
+ refresh: a
437
+ };
438
+ }
439
+ //#endregion
440
+ //#region packages/dom/src/viewport.ts
441
+ function z() {
442
+ return typeof window > "u" ? {} : {
443
+ viewportWidth: window.innerWidth,
444
+ viewportHeight: window.innerHeight
445
+ };
446
+ }
447
+ //#endregion
448
+ //#region packages/react/src/hooks/useGuide.ts
449
+ function B(t, n) {
450
+ let { width: r } = R(t);
451
+ return e.useMemo(() => k(r, n, z()), [n, r]);
452
+ }
453
+ //#endregion
454
+ //#region packages/react/src/hooks/useIsClient.ts
455
+ function V() {
456
+ let [e, n] = r(!1);
457
+ return t(() => {
458
+ n(!0);
459
+ }, []), e;
460
+ }
461
+ //#endregion
462
+ //#region packages/react/src/utils/ssr.tsx
463
+ function H({ children: e, fallback: t = null }) {
464
+ return V() ? /* @__PURE__ */ a(i, { children: e }) : /* @__PURE__ */ a(i, { children: t });
465
+ }
466
+ //#endregion
467
+ //#region packages/react/src/utils/merge.ts
468
+ function U(...e) {
469
+ return Object.assign({}, ...e.filter(Boolean));
470
+ }
471
+ var W = {
472
+ gde: "gde_4PKz3",
473
+ v: "v_yAvN0",
474
+ h: "h_XcWcy",
475
+ line: "line_UaLjW",
476
+ cols: "cols_ibtT4",
477
+ col: "col_QPSDI",
478
+ ssr: "ssr_4UN4k"
479
+ }, G = e.memo(function({ className: e, debugging: t, style: n, variant: r, align: i = "center", gap: o, height: s, width: c, columns: l, columnWidth: u, maxWidth: d, color: f, children: p, ssrMode: m = !1, ...h }) {
480
+ let g = N("guide"), _ = r ?? g.variant, v = typeof o == "number" ? o : 0, { isShown: y } = P(t, g.debugging);
481
+ if (!y) return /* @__PURE__ */ a("div", {
482
+ className: S(W.gde, W.h, e),
483
+ style: n,
484
+ "data-testid": "guide",
485
+ "data-variant": _,
486
+ "aria-hidden": "true",
487
+ ...h,
488
+ children: p
489
+ });
490
+ let b = /* @__PURE__ */ a("div", {
491
+ className: S(W.gde, W.h, W.ssr, e),
492
+ style: {
493
+ width: c ?? "100%",
494
+ height: s ?? "100%",
495
+ maxWidth: d ?? "none",
496
+ ...n
497
+ },
498
+ "data-testid": "guide",
499
+ "data-variant": _,
500
+ "aria-hidden": "true",
501
+ children: p
502
+ });
503
+ return m ? b : /* @__PURE__ */ a(H, {
504
+ fallback: b,
505
+ children: /* @__PURE__ */ a(K, {
506
+ className: e,
507
+ debugging: t,
508
+ style: n,
509
+ variant: _,
510
+ align: i,
511
+ gap: v,
512
+ height: s,
513
+ width: c,
514
+ columns: l,
515
+ columnWidth: u,
516
+ maxWidth: d,
517
+ color: f,
518
+ ...h,
519
+ children: p
520
+ })
521
+ });
522
+ }), K = e.memo(function({ className: t, debugging: n, style: r, variant: i, align: s = "center", gap: c, height: l, width: u, columns: d, columnWidth: f, maxWidth: p, color: m, children: h, ...g }) {
523
+ let _ = N("guide"), { isShown: v } = P(n, _.debugging), y = e.useRef(null);
524
+ R(y);
525
+ let b = i ?? _.variant, x = typeof c == "number" ? c : 0, { template: C, columnsCount: w, calculatedGap: T } = B(y, e.useMemo(() => A({
526
+ variant: b,
527
+ base: _.base,
528
+ gap: x,
529
+ columns: d,
530
+ columnWidth: f
531
+ }), [
532
+ b,
533
+ _.base,
534
+ x,
535
+ d,
536
+ f
537
+ ])), E = e.useMemo(() => M({
538
+ base: _.base,
539
+ colors: _.colors,
540
+ variant: b,
541
+ align: s || "center",
542
+ width: u,
543
+ height: l,
544
+ columnWidth: f,
545
+ maxWidth: p,
546
+ color: m,
547
+ template: C,
548
+ columnsCount: w,
549
+ calculatedGap: T,
550
+ isVisible: v
551
+ }), [
552
+ _.base,
553
+ _.colors,
554
+ b,
555
+ s,
556
+ u,
557
+ l,
558
+ f,
559
+ p,
560
+ m,
561
+ C,
562
+ w,
563
+ T,
564
+ v
565
+ ]), D = e.useMemo(() => U(E.containerStyle, r), [E.containerStyle, r]);
566
+ return /* @__PURE__ */ o("div", {
567
+ ref: y,
568
+ "data-testid": "guide",
569
+ "aria-hidden": "true",
570
+ className: S(...E.classTokens.map((e) => W[e]), t),
571
+ "data-variant": i,
572
+ style: D,
573
+ ...g,
574
+ children: [v && /* @__PURE__ */ a("div", {
575
+ className: W.cols,
576
+ "data-variant": i,
577
+ children: !E.isLineVariant && Array.from({ length: E.columnsCount }, (e, t) => /* @__PURE__ */ a("div", {
578
+ className: W.col,
579
+ "data-column-index": t,
580
+ "data-variant": i,
581
+ style: { backgroundColor: E.columnColor }
582
+ }, t))
583
+ }), h]
584
+ });
585
+ });
586
+ //#endregion
587
+ export { p as Config, G as Guide, u as createCSSVariables, l as mergeConfig };
588
+
589
+ //# sourceMappingURL=guide.mjs.map