baseline-kit 5.1.0 → 6.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.
package/dist/guide.d.ts CHANGED
@@ -58,6 +58,7 @@ type DebugColors = {
58
58
  };
59
59
  type ConfigSchema = {
60
60
  base: number;
61
+ domDiagnostics: boolean;
61
62
  baseline: {
62
63
  variant: BaselineVariant;
63
64
  debugging: DebuggingMode;
@@ -90,6 +91,7 @@ type PartialColors<T> = T extends {
90
91
  } : Partial<T>;
91
92
  type ConfigOverrides = {
92
93
  base?: number;
94
+ domDiagnostics?: boolean;
93
95
  baseline?: PartialColors<ConfigSchema['baseline']>;
94
96
  guide?: PartialColors<ConfigSchema['guide']>;
95
97
  spacer?: PartialColors<ConfigSchema['spacer']>;
@@ -116,7 +118,7 @@ type ConfigProps = ConfigOverrides & {
116
118
  /**
117
119
  * Configuration provider for baseline-kit components.
118
120
  */
119
- declare function Config({ children, base, baseline, guide, spacer, box, padder, }: ConfigProps): React.JSX.Element;
121
+ declare function Config({ children, base, domDiagnostics, baseline, guide, spacer, box, padder, }: ConfigProps): React.JSX.Element;
120
122
 
121
123
  /**
122
124
  * Common props shared across library components.
@@ -127,7 +129,16 @@ type ComponentsProps = {
127
129
  style?: React.CSSProperties;
128
130
  height?: React.CSSProperties['height'];
129
131
  width?: React.CSSProperties['width'];
130
- } & SpacingProps;
132
+ } & SpacingProps & React.AriaAttributes & {
133
+ id?: string;
134
+ title?: string;
135
+ role?: React.AriaRole;
136
+ tabIndex?: number;
137
+ lang?: string;
138
+ dir?: string;
139
+ hidden?: boolean;
140
+ [key: `data-${string}`]: string | number | boolean | undefined;
141
+ };
131
142
 
132
143
  type GuideProps = {
133
144
  align?: React.CSSProperties['justifyContent'];
package/dist/guide.mjs CHANGED
@@ -4,6 +4,7 @@ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
4
4
  //#region packages/core/src/config/defaults.ts
5
5
  var s = {
6
6
  base: 8,
7
+ domDiagnostics: !1,
7
8
  baseline: {
8
9
  variant: "line",
9
10
  debugging: "hidden",
@@ -50,20 +51,21 @@ var s = {
50
51
  "box",
51
52
  "padder"
52
53
  ], l = (e) => {
53
- let { parentConfig: t, base: n } = e, r = {};
54
+ let { parentConfig: t, base: n, domDiagnostics: r } = e, i = {};
54
55
  for (let n of c) {
55
- let i = e[n], a = t[n], o = {
56
+ let r = e[n], a = t[n], o = {
56
57
  ...a,
57
- ...i
58
+ ...r
58
59
  };
59
- i && "colors" in i && i.colors && "colors" in a && (o.colors = {
60
+ r && "colors" in r && r.colors && "colors" in a && (o.colors = {
60
61
  ...a.colors,
61
- ...i.colors
62
- }), r[n] = o;
62
+ ...r.colors
63
+ }), i[n] = o;
63
64
  }
64
65
  return {
65
66
  base: n ?? t.base,
66
- ...r
67
+ domDiagnostics: r ?? t.domDiagnostics ?? !1,
68
+ ...i
67
69
  };
68
70
  }, u = (e) => {
69
71
  let { base: t, baseline: n, guide: r, spacer: i, box: a, padder: o } = e;
@@ -86,26 +88,28 @@ var s = {
86
88
  }, d = "__baseline_kit_config_context__", f = globalThis, p = f[d] ?? (f[d] = e.createContext(s));
87
89
  p.displayName = "ConfigContext";
88
90
  var m = () => e.use(p);
89
- function h({ children: t, base: n, baseline: r, guide: i, spacer: o, box: s, padder: c }) {
90
- let u = m(), d = e.useMemo(() => l({
91
- parentConfig: u,
91
+ function h({ children: t, base: n, domDiagnostics: r, baseline: i, guide: o, spacer: s, box: c, padder: u }) {
92
+ let d = m(), f = e.useMemo(() => l({
93
+ parentConfig: d,
92
94
  base: n,
93
- baseline: r,
94
- guide: i,
95
- spacer: o,
96
- box: s,
97
- padder: c
95
+ domDiagnostics: r,
96
+ baseline: i,
97
+ guide: o,
98
+ spacer: s,
99
+ box: c,
100
+ padder: u
98
101
  }), [
99
- u,
102
+ d,
100
103
  n,
101
104
  r,
102
105
  i,
103
106
  o,
104
107
  s,
105
- c
108
+ c,
109
+ u
106
110
  ]);
107
111
  return /* @__PURE__ */ a(p, {
108
- value: d,
112
+ value: f,
109
113
  children: t
110
114
  });
111
115
  }
@@ -262,7 +266,17 @@ function j(e, t, n) {
262
266
  }
263
267
  //#endregion
264
268
  //#region packages/core/src/descriptors/guide.ts
265
- function M({ variant: e, base: t, gap: n, columns: r, columnWidth: i }) {
269
+ function M(e) {
270
+ let t = /* @__PURE__ */ new Set([
271
+ "--bkgd-cl",
272
+ "--bkgd-cp",
273
+ "--bkgd-ca",
274
+ "--bkgd-cf",
275
+ "--bkgd-line-color"
276
+ ]), n = e.style && Object.keys(e.style).some((e) => !t.has(e));
277
+ return !e.domDiagnostics && !e.className && !n && e.variant === "fixed" && e.columns === 4 && (e.columnWidth === void 0 || e.columnWidth === 60 || e.columnWidth === "60px") && e.gap === 0 && (e.align || "center") === "center";
278
+ }
279
+ function N({ variant: e, base: t, gap: n, columns: r, columnWidth: i }) {
266
280
  switch (e) {
267
281
  case "line": return {
268
282
  variant: "line",
@@ -295,7 +309,7 @@ function M({ variant: e, base: t, gap: n, columns: r, columnWidth: i }) {
295
309
  base: t
296
310
  };
297
311
  }
298
- var N = (e, t) => ({
312
+ var P = (e, t) => ({
299
313
  "--bkgd-w": "100%",
300
314
  "--bkgd-h": "100%",
301
315
  "--bkgd-mw": "none",
@@ -306,8 +320,8 @@ var N = (e, t) => ({
306
320
  "--bkgd-cl": t,
307
321
  "--bkgd-g": "0"
308
322
  });
309
- function P(e) {
310
- 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 = N(t, n.line), h = {
323
+ function F(e) {
324
+ 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 = P(t, n.line), h = {
311
325
  "--bkgd-cl": l ?? n.line,
312
326
  "--bkgd-cp": l ?? n.pattern,
313
327
  "--bkgd-ca": l ?? n.auto,
@@ -364,18 +378,21 @@ function P(e) {
364
378
  }
365
379
  //#endregion
366
380
  //#region packages/react/src/hooks/useConfig.ts
367
- function F(e) {
381
+ function I(e) {
368
382
  let t = m();
369
- return n(() => Object.assign({ base: t.base }, t[e]), [t, e]);
383
+ return n(() => Object.assign({
384
+ base: t.base,
385
+ domDiagnostics: t.domDiagnostics
386
+ }, t[e]), [t, e]);
370
387
  }
371
388
  //#endregion
372
389
  //#region packages/react/src/hooks/useDebug.ts
373
- function I(e, t) {
390
+ function L(e, t) {
374
391
  return n(() => T(e, t), [e, t]);
375
392
  }
376
393
  //#endregion
377
394
  //#region packages/dom/src/timing.ts
378
- var L = (e) => {
395
+ var R = (e) => {
379
396
  let t = null, n = null;
380
397
  return [(...r) => {
381
398
  n = r, t !== null && cancelAnimationFrame(t), t = requestAnimationFrame(() => {
@@ -387,7 +404,7 @@ var L = (e) => {
387
404
  };
388
405
  //#endregion
389
406
  //#region packages/dom/src/measure.ts
390
- function R(e, t) {
407
+ function z(e, t) {
391
408
  let n = {
392
409
  width: 0,
393
410
  height: 0
@@ -399,7 +416,7 @@ function R(e, t) {
399
416
  };
400
417
  (i.width !== n.width || i.height !== n.height) && (n = i, t(i));
401
418
  } catch {}
402
- }, [i, a] = L(r);
419
+ }, [i, a] = R(r);
403
420
  r();
404
421
  let o = new ResizeObserver(i);
405
422
  return o.observe(e), {
@@ -411,15 +428,15 @@ function R(e, t) {
411
428
  }
412
429
  //#endregion
413
430
  //#region packages/react/src/hooks/useMeasure.ts
414
- var z = {
431
+ var B = {
415
432
  width: 0,
416
433
  height: 0
417
434
  };
418
- function B(t) {
419
- let [n, r] = e.useState(z), i = e.useRef(null);
435
+ function V(t) {
436
+ let [n, r] = e.useState(B), i = e.useRef(null);
420
437
  e.useLayoutEffect(() => {
421
438
  if (typeof window > "u" || !t.current) return;
422
- let e = R(t.current, (e) => {
439
+ let e = z(t.current, (e) => {
423
440
  r((t) => t.width === e.width && t.height === e.height ? t : e);
424
441
  });
425
442
  return i.current = e, () => {
@@ -436,7 +453,7 @@ function B(t) {
436
453
  }
437
454
  //#endregion
438
455
  //#region packages/dom/src/viewport.ts
439
- function V() {
456
+ function H() {
440
457
  return typeof window > "u" ? {} : {
441
458
  viewportWidth: window.innerWidth,
442
459
  viewportHeight: window.innerHeight
@@ -444,13 +461,13 @@ function V() {
444
461
  }
445
462
  //#endregion
446
463
  //#region packages/react/src/hooks/useGuide.ts
447
- function H(t, n) {
448
- let { width: r } = B(t);
449
- return e.useMemo(() => j(r, n, V()), [n, r]);
464
+ function U(t, n) {
465
+ let { width: r } = V(t);
466
+ return e.useMemo(() => j(r, n, H()), [n, r]);
450
467
  }
451
468
  //#endregion
452
469
  //#region packages/react/src/hooks/useIsClient.ts
453
- function U() {
470
+ function W() {
454
471
  let [e, n] = r(!1);
455
472
  return t(() => {
456
473
  n(!0);
@@ -458,55 +475,68 @@ function U() {
458
475
  }
459
476
  //#endregion
460
477
  //#region packages/react/src/utils/ssr.tsx
461
- function W({ children: e, fallback: t = null }) {
462
- return U() ? /* @__PURE__ */ a(i, { children: e }) : /* @__PURE__ */ a(i, { children: t });
478
+ function G({ children: e, fallback: t = null }) {
479
+ return W() ? /* @__PURE__ */ a(i, { children: e }) : /* @__PURE__ */ a(i, { children: t });
463
480
  }
464
481
  //#endregion
465
482
  //#region packages/react/src/utils/merge.ts
466
- function G(...e) {
483
+ function K(...e) {
467
484
  return Object.assign({}, ...e.filter(Boolean));
468
485
  }
469
- var K = {
486
+ //#endregion
487
+ //#region packages/react/src/utils/dom.ts
488
+ function q(e, t) {
489
+ return Object.fromEntries(Object.entries(e).filter(([e, n]) => t[e] !== n));
490
+ }
491
+ var J = {
470
492
  gde: "gde_4PKz3",
471
493
  v: "v_yAvN0",
472
494
  h: "h_XcWcy",
473
495
  line: "line_UaLjW",
474
496
  cols: "cols_ibtT4",
475
497
  col: "col_QPSDI",
498
+ pattern: "pattern_8ihi5",
499
+ auto: "auto_xzTBc",
500
+ fixed: "fixed_g2rOO",
501
+ compactFixed: "compactFixed_C3AMS",
476
502
  ssr: "ssr_4UN4k"
477
- }, q = 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 }) {
478
- let g = F("guide"), _ = r ?? g.variant, v = typeof o == "number" ? o : 0, { isShown: y } = I(t, g.debugging);
479
- if (!y) return /* @__PURE__ */ a("div", {
480
- className: w(K.gde, K.h, e),
503
+ }, Y = 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 }) {
504
+ let g = I("guide"), v = r ?? g.variant, y = typeof o == "number" ? o : 0, { isShown: b } = L(t, g.debugging);
505
+ if (!b) return /* @__PURE__ */ a("div", {
506
+ className: w(J.gde, J.h, J[v], e),
481
507
  style: n,
482
- "data-testid": "guide",
483
- "data-variant": _,
508
+ "data-testid": g.domDiagnostics ? "guide" : void 0,
509
+ "data-variant": g.domDiagnostics ? v : void 0,
484
510
  "aria-hidden": "true",
485
511
  ...h,
486
512
  children: p
487
513
  });
488
- let b = /* @__PURE__ */ a("div", {
489
- className: w(K.gde, K.h, K.ssr, e),
490
- style: {
491
- width: c ?? "100%",
492
- height: s ?? "100%",
493
- maxWidth: d ?? "none",
494
- ...n
495
- },
496
- "data-testid": "guide",
497
- "data-variant": _,
514
+ let x = /* @__PURE__ */ a("div", {
515
+ className: w(J.gde, J.h, J.ssr, J[v], e),
516
+ style: K(q({
517
+ width: _(c ?? "100%"),
518
+ height: _(s ?? "100%"),
519
+ maxWidth: _(d ?? "none")
520
+ }, {
521
+ width: "100%",
522
+ height: "100%",
523
+ maxWidth: "none"
524
+ }), n),
525
+ "data-testid": g.domDiagnostics ? "guide" : void 0,
526
+ "data-variant": g.domDiagnostics ? v : void 0,
498
527
  "aria-hidden": "true",
528
+ ...h,
499
529
  children: p
500
530
  });
501
- return m ? b : /* @__PURE__ */ a(W, {
502
- fallback: b,
503
- children: /* @__PURE__ */ a(J, {
531
+ return m ? x : /* @__PURE__ */ a(G, {
532
+ fallback: x,
533
+ children: /* @__PURE__ */ a(X, {
504
534
  className: e,
505
535
  debugging: t,
506
536
  style: n,
507
- variant: _,
537
+ variant: v,
508
538
  align: i,
509
- gap: v,
539
+ gap: y,
510
540
  height: s,
511
541
  width: c,
512
542
  columns: l,
@@ -517,70 +547,94 @@ var K = {
517
547
  children: p
518
548
  })
519
549
  });
520
- }), J = 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 }) {
521
- let _ = F("guide"), { isShown: v } = I(n, _.debugging), y = e.useRef(null);
522
- B(y);
523
- let b = i ?? _.variant, x = typeof c == "number" ? c : 0, { template: S, columnsCount: C, calculatedGap: T } = H(y, e.useMemo(() => M({
524
- variant: b,
525
- base: _.base,
526
- gap: x,
527
- columns: d,
528
- columnWidth: f
550
+ }), X = e.memo(function({ className: t, debugging: n, style: r, variant: i, align: c = "center", gap: l, height: u, width: d, columns: f, columnWidth: p, maxWidth: m, color: h, children: g, ..._ }) {
551
+ let v = I("guide"), { isShown: y } = L(n, v.debugging), b = e.useRef(null);
552
+ V(b);
553
+ let x = i ?? v.variant, S = typeof l == "number" ? l : 0, { template: C, columnsCount: T, calculatedGap: E } = U(b, e.useMemo(() => N({
554
+ variant: x,
555
+ base: v.base,
556
+ gap: S,
557
+ columns: f,
558
+ columnWidth: p
529
559
  }), [
530
- b,
531
- _.base,
532
560
  x,
533
- d,
534
- f
535
- ])), E = e.useMemo(() => P({
536
- base: _.base,
537
- colors: _.colors,
538
- variant: b,
539
- align: s || "center",
540
- width: u,
541
- height: l,
542
- columnWidth: f,
543
- maxWidth: p,
544
- color: m,
545
- template: S,
546
- columnsCount: C,
547
- calculatedGap: T,
548
- isVisible: v
561
+ v.base,
562
+ S,
563
+ f,
564
+ p
565
+ ])), D = M({
566
+ variant: x,
567
+ columns: f,
568
+ columnWidth: p,
569
+ gap: S,
570
+ align: c,
571
+ domDiagnostics: v.domDiagnostics,
572
+ className: t,
573
+ style: r
574
+ }), O = e.useMemo(() => F({
575
+ base: v.base,
576
+ colors: v.colors,
577
+ variant: x,
578
+ align: c || "center",
579
+ width: d,
580
+ height: u,
581
+ columnWidth: p,
582
+ maxWidth: m,
583
+ color: h,
584
+ template: C,
585
+ columnsCount: T,
586
+ calculatedGap: E,
587
+ isVisible: y
549
588
  }), [
550
- _.base,
551
- _.colors,
552
- b,
553
- s,
589
+ v.base,
590
+ v.colors,
591
+ x,
592
+ c,
593
+ d,
554
594
  u,
555
- l,
556
- f,
557
595
  p,
558
596
  m,
559
- S,
597
+ h,
560
598
  C,
561
599
  T,
562
- v
563
- ]), D = e.useMemo(() => G(E.containerStyle, r), [E.containerStyle, r]);
600
+ E,
601
+ y
602
+ ]), k = e.useMemo(() => K(q(O.containerStyle, {
603
+ "--bkgd-w": "100%",
604
+ "--bkgd-h": "100%",
605
+ "--bkgd-mw": "none",
606
+ "--bkgd-cw": "60px",
607
+ "--bkgd-n": "12",
608
+ "--bkgd-b": "0",
609
+ "--bkgd-cl": s.guide.colors.line,
610
+ "--bkgd-cp": s.guide.colors.pattern,
611
+ "--bkgd-ca": s.guide.colors.auto,
612
+ "--bkgd-cf": s.guide.colors.fixed,
613
+ "--bkgd-g": "0px",
614
+ "--bkgd-j": "center",
615
+ "--bkgd-t": "none",
616
+ "--bkgd-line-color": "var(--bkgd-cl)"
617
+ }), r), [O.containerStyle, r]);
564
618
  return /* @__PURE__ */ o("div", {
565
- ref: y,
566
- "data-testid": "guide",
619
+ ref: b,
620
+ "data-testid": v.domDiagnostics ? "guide" : void 0,
567
621
  "aria-hidden": "true",
568
- className: w(...E.classTokens.map((e) => K[e]), t),
569
- "data-variant": i,
570
- style: D,
571
- ...g,
572
- children: [v && /* @__PURE__ */ a("div", {
573
- className: K.cols,
574
- "data-variant": i,
575
- children: !E.isLineVariant && Array.from({ length: E.columnsCount }, (e, t) => /* @__PURE__ */ a("div", {
576
- className: K.col,
577
- "data-column-index": t,
578
- "data-variant": i
622
+ className: w(...O.classTokens.map((e) => J[e]), !O.classTokens.includes(x) && J[x], t),
623
+ "data-variant": v.domDiagnostics ? x : void 0,
624
+ style: k,
625
+ ..._,
626
+ children: [y && /* @__PURE__ */ a("div", {
627
+ className: w(J.cols, J[x], D && J.compactFixed),
628
+ "data-variant": v.domDiagnostics ? x : void 0,
629
+ children: !O.isLineVariant && !D && Array.from({ length: O.columnsCount }, (e, t) => /* @__PURE__ */ a("div", {
630
+ className: w(J.col, J[x]),
631
+ "data-column-index": v.domDiagnostics ? t : void 0,
632
+ "data-variant": v.domDiagnostics ? x : void 0
579
633
  }, t))
580
- }), h]
634
+ }), g]
581
635
  });
582
636
  });
583
637
  //#endregion
584
- export { h as Config, q as Guide, u as createCSSVariables, l as mergeConfig };
638
+ export { h as Config, Y as Guide, u as createCSSVariables, l as mergeConfig };
585
639
 
586
640
  //# sourceMappingURL=guide.mjs.map