@rinzai/zen 0.15.0 → 0.16.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 (78) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/animated-number/index.js +14 -14
  3. package/dist/breadcrumbs/index.js +14 -14
  4. package/dist/calendar/index.js +29 -29
  5. package/dist/calendar-heatmap/index.js +12 -12
  6. package/dist/canvas/index.js +19 -19
  7. package/dist/carousel/index.js +24 -24
  8. package/dist/chart/index.js +7 -7
  9. package/dist/code-block/index.js +5 -5
  10. package/dist/collapse/index.js +6 -6
  11. package/dist/color-picker/index.js +10 -10
  12. package/dist/combobox/index.js +61 -61
  13. package/dist/command-palette/index.js +5 -5
  14. package/dist/confirm-dialog/index.js +4 -4
  15. package/dist/date-picker/index.js +15 -15
  16. package/dist/dialog/index.d.ts.map +1 -1
  17. package/dist/dialog/index.js +45 -65
  18. package/dist/docs/README.md +4 -4
  19. package/dist/docs/locale-provider.md +1 -1
  20. package/dist/docs/menu.md +54 -1
  21. package/dist/docs/seek-bar.md +30 -1
  22. package/dist/docs/sortable.md +63 -1
  23. package/dist/docs/tooltip.md +45 -3
  24. package/dist/filter-bar/index.js +6 -6
  25. package/dist/header/index.js +6 -6
  26. package/dist/icon-picker/index.js +5 -5
  27. package/dist/keypad/index.js +5 -5
  28. package/dist/lib.js +7 -7
  29. package/dist/load-more/index.js +5 -5
  30. package/dist/menu/index.d.ts +7 -1
  31. package/dist/menu/index.d.ts.map +1 -1
  32. package/dist/menu/index.js +217 -174
  33. package/dist/money-input/index.js +54 -54
  34. package/dist/month-picker/index.js +11 -11
  35. package/dist/number-field/index.js +5 -5
  36. package/dist/pagination/index.js +12 -12
  37. package/dist/range-slider/index.js +11 -11
  38. package/dist/repeat-picker/index.js +5 -5
  39. package/dist/resizable/index.js +22 -22
  40. package/dist/seek-bar/index.d.ts +3 -1
  41. package/dist/seek-bar/index.d.ts.map +1 -1
  42. package/dist/seek-bar/index.js +41 -40
  43. package/dist/select/index.js +21 -21
  44. package/dist/sortable/index.d.ts +13 -1
  45. package/dist/sortable/index.d.ts.map +1 -1
  46. package/dist/sortable/index.js +74 -55
  47. package/dist/sortable/shared.js +14 -14
  48. package/dist/sortable/tree.js +17 -17
  49. package/dist/sparkline/index.js +4 -4
  50. package/dist/stepper/index.js +13 -13
  51. package/dist/table/index.js +26 -26
  52. package/dist/table/selection.js +9 -9
  53. package/dist/table-of-contents/index.js +11 -11
  54. package/dist/tag-input/index.js +5 -5
  55. package/dist/theme-toggle/index.js +4 -4
  56. package/dist/theme.css +103 -0
  57. package/dist/time-field/index.js +21 -21
  58. package/dist/toast/index.d.ts.map +1 -1
  59. package/dist/toast/index.js +41 -41
  60. package/dist/tooltip/index.d.ts +9 -3
  61. package/dist/tooltip/index.d.ts.map +1 -1
  62. package/dist/tooltip/index.js +19 -16
  63. package/dist/tree/index.js +34 -34
  64. package/dist/trend/index.js +5 -5
  65. package/dist/utils/messages.d.ts +1 -0
  66. package/dist/utils/messages.d.ts.map +1 -1
  67. package/dist/utils/messages.js +1 -0
  68. package/dist/utils/swipe.d.ts +7 -0
  69. package/dist/utils/swipe.d.ts.map +1 -1
  70. package/dist/utils/swipe.js +45 -25
  71. package/dist/utils/useAnchoredPopup.d.ts +2 -1
  72. package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
  73. package/dist/utils/useAnchoredPopup.js +9 -5
  74. package/dist/utils/useVirtualList.d.ts +6 -1
  75. package/dist/utils/useVirtualList.d.ts.map +1 -1
  76. package/dist/utils/useVirtualList.js +12 -12
  77. package/dist/zen.css +1 -1
  78. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.16.0
4
+
5
+ ### Added to existing components
6
+
7
+ - **MenuContent**: `sheet` makes the menu a bottom sheet on phones (below `md`), as music apps show a song's menu: across the bottom of the screen over a scrim, with a grip, swiped down or tapped outside to close. Its submenus slide in over it, with a row at the top that goes back (the arrow back and Escape still do), and open only when chosen, not on hover. Wider screens keep the popover.
8
+ - **SortableList**: works with a virtualized list. Give it `itemHeight` and render only the rows in view (from `useVirtualList`), each at its place in `value`; a drag works from `value`, not the rows on screen, and rows that come into view as it scrolls the list take their places. `onLiftedChange` says which item is picked up (by its handle or from the keyboard), to keep its row rendered. An item moved with the keyboard is scrolled into view.
9
+ - **useVirtualList**: `keep` renders a row even when it's out of view, such as the one being dragged, with the rows between.
10
+ - **SeekBar**: `times="below"` puts the time played and the length under the ends of the bar, as on a phone's Now Playing screen.
11
+ - **TooltipContent**: `side="beside"` puts the tooltip after its trigger (before it if there's no room) instead of below, centred on it, as for the icons of a collapsed sidebar, where a tooltip below would cover the next icon. `align` lines up its top or bottom with the trigger's instead.
12
+ - **Anchored popups** (`anchoredStyle`): beside the trigger, `align` now chooses top (start, as before), middle (center) or bottom (end).
13
+
14
+ ### Fixes
15
+
16
+ - **ToastProvider**: once its toasts were gone, the empty toast area kept its last height (the height it was given went negative, which browsers ignore) and caught clicks meant for what was under it, such as a player bar's controls. It now shrinks to nothing.
17
+
3
18
  ## 0.15.0
4
19
 
5
20
  ### New components
@@ -1,14 +1,14 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { useLocale as t } from "../locale-provider/index.js";
2
+ import { useLocale as e } from "../locale-provider/index.js";
3
+ import { cx as t } from "../utils/cx.js";
4
4
  import { formatMoney as n } from "../utils/money.js";
5
5
  import { reducedMotion as r } from "../utils/motion.js";
6
6
  import { useEffect as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
7
7
  import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
8
  //#region packages/animated-number/index.tsx
9
9
  var u = typeof window > "u" ? i : a, d = (e) => 1 - (1 - e) ** 3;
10
- function f({ value: t, format: n = String, duration: a = 650, fromZero: f = !0, roll: p = !1, className: h }) {
11
- let [g, _] = s(f ? 0 : t), v = o(f ? 0 : t), [y, b] = s(!f);
10
+ function f({ value: e, format: n = String, duration: a = 650, fromZero: f = !0, roll: p = !1, className: h }) {
11
+ let [g, _] = s(f ? 0 : e), v = o(f ? 0 : e), [y, b] = s(!f);
12
12
  if (i(() => {
13
13
  if (!p || y) return;
14
14
  let e = requestAnimationFrame(() => b(!0));
@@ -16,22 +16,22 @@ function f({ value: t, format: n = String, duration: a = 650, fromZero: f = !0,
16
16
  }, [p, y]), u(() => {
17
17
  if (p) return;
18
18
  if (r() || a <= 0) {
19
- v.current = t, _(t);
19
+ v.current = e, _(e);
20
20
  return;
21
21
  }
22
- let e = v.current, n = performance.now(), i = requestAnimationFrame(function r(o) {
23
- let s = Math.min(1, (o - n) / a), c = Math.round(e + (t - e) * d(s));
22
+ let t = v.current, n = performance.now(), i = requestAnimationFrame(function r(o) {
23
+ let s = Math.min(1, (o - n) / a), c = Math.round(t + (e - t) * d(s));
24
24
  v.current = c, _(c), s < 1 && (i = requestAnimationFrame(r));
25
25
  });
26
26
  return () => cancelAnimationFrame(i);
27
27
  }, [
28
- t,
28
+ e,
29
29
  a,
30
30
  p
31
31
  ]), p) {
32
- let r = n(t);
32
+ let r = n(e);
33
33
  return /* @__PURE__ */ l("span", {
34
- className: e("zen__animated-number inline-flex items-start tabular-nums", h),
34
+ className: t("zen__animated-number inline-flex items-start tabular-nums", h),
35
35
  children: [/* @__PURE__ */ c("span", {
36
36
  className: "sr-only",
37
37
  children: r
@@ -46,7 +46,7 @@ function f({ value: t, format: n = String, duration: a = 650, fromZero: f = !0,
46
46
  });
47
47
  }
48
48
  return /* @__PURE__ */ c("span", {
49
- className: e("zen__animated-number tabular-nums", h),
49
+ className: t("zen__animated-number tabular-nums", h),
50
50
  children: n(g)
51
51
  });
52
52
  }
@@ -75,10 +75,10 @@ function m({ digit: e, duration: t }) {
75
75
  })
76
76
  });
77
77
  }
78
- function h({ value: e, currency: r, locale: i, showDecimals: a = !1, ...o }) {
79
- let s = t(i);
78
+ function h({ value: t, currency: r, locale: i, showDecimals: a = !1, ...o }) {
79
+ let s = e(i);
80
80
  return /* @__PURE__ */ c(f, {
81
- value: e,
81
+ value: t,
82
82
  format: (e) => n(e, r, s, { showDecimals: a }),
83
83
  ...o
84
84
  });
@@ -1,37 +1,37 @@
1
1
  "use client";
2
- import e from "../icons/micro/chevron-right.js";
3
- import { cx as t } from "../utils/cx.js";
4
- import { Slot as n } from "../utils/slot.js";
5
- import { useMessages as r } from "../locale-provider/index.js";
2
+ import { useMessages as e } from "../locale-provider/index.js";
3
+ import t from "../icons/micro/chevron-right.js";
4
+ import { cx as n } from "../utils/cx.js";
5
+ import { Slot as r } from "../utils/slot.js";
6
6
  import { Children as i, Fragment as a, isValidElement as o } from "react";
7
7
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
8
8
  //#region packages/breadcrumbs/index.tsx
9
- function l({ className: n, children: l, "aria-label": u, ...d }) {
10
- let f = r(), p = u ?? f.breadcrumb, m = i.toArray(l).filter(o);
9
+ function l({ className: r, children: l, "aria-label": u, ...d }) {
10
+ let f = e(), p = u ?? f.breadcrumb, m = i.toArray(l).filter(o);
11
11
  return /* @__PURE__ */ s("nav", {
12
12
  "aria-label": p,
13
- className: t("zen__breadcrumbs", n),
13
+ className: n("zen__breadcrumbs", r),
14
14
  ...d,
15
15
  children: /* @__PURE__ */ s("ol", {
16
16
  className: "text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm",
17
- children: m.map((t, n) => /* @__PURE__ */ c(a, { children: [n > 0 && /* @__PURE__ */ s("li", {
17
+ children: m.map((e, n) => /* @__PURE__ */ c(a, { children: [n > 0 && /* @__PURE__ */ s("li", {
18
18
  "aria-hidden": !0,
19
19
  className: "text-muted-foreground/60 flex",
20
- children: /* @__PURE__ */ s(e, { className: "size-3.5 rtl:-scale-x-100" })
20
+ children: /* @__PURE__ */ s(t, { className: "size-3.5 rtl:-scale-x-100" })
21
21
  }), /* @__PURE__ */ s("li", {
22
22
  className: "flex min-w-0",
23
- children: t
24
- })] }, t.key ?? n))
23
+ children: e
24
+ })] }, e.key ?? n))
25
25
  })
26
26
  });
27
27
  }
28
- function u({ current: e, asChild: r, className: i, ...a }) {
29
- let o = t("truncate rounded-sm outline-hidden transition-colors focus-ring", e ? "text-foreground font-medium" : "hover:text-foreground touch-target", i);
28
+ function u({ current: e, asChild: t, className: i, ...a }) {
29
+ let o = n("truncate rounded-sm outline-hidden transition-colors focus-ring", e ? "text-foreground font-medium" : "hover:text-foreground touch-target", i);
30
30
  return e ? /* @__PURE__ */ s("span", {
31
31
  "aria-current": "page",
32
32
  className: o,
33
33
  ...a
34
- }) : s(r ? n : "a", {
34
+ }) : s(t ? r : "a", {
35
35
  className: o,
36
36
  ...a
37
37
  });
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { readingKey as t } from "../utils/direction.js";
4
- import { useControllable as n } from "../utils/useControllable.js";
5
- import { useLocale as r, useMessages as i } from "../locale-provider/index.js";
2
+ import { useLocale as e, useMessages as t } from "../locale-provider/index.js";
3
+ import { cx as n } from "../utils/cx.js";
4
+ import { readingKey as r } from "../utils/direction.js";
5
+ import { useControllable as i } from "../utils/useControllable.js";
6
6
  import { PICKER_MONTH as a, PICKER_NAV as o } from "../utils/styles.js";
7
7
  import s from "../icons/chevron-left.js";
8
8
  import c from "../icons/chevron-right.js";
@@ -13,7 +13,7 @@ import { useEffect as ae, useId as oe, useRef as _, useState as v } from "react"
13
13
  import { jsx as y, jsxs as b } from "react/jsx-runtime";
14
14
  //#region packages/calendar/index.tsx
15
15
  function se(se) {
16
- let { locale: le, min: x, max: S, isDisabled: ue, weekStartsOn: de, months: C = 1, defaultMonth: fe, className: w, autoFocus: pe, mode: T, value: me, defaultValue: he = null, onValueChange: ge, ...E } = se, D = r(le), _e = new Intl.NumberFormat(D), O = i(), k = de ?? re(D), [A, j] = n(me, he, ge), M = T === "range" ? A : null, N = T === "range" ? null : A, P = N ?? M?.start ?? null, F = ne(), I = ie() ? F : null, [L, R] = v(() => fe ?? (P ?? F).slice(0, 7)), [z, B] = v(() => P ?? F), [V, H] = v(null), [U, W] = v("days"), [G, K] = v(() => Number(L.slice(0, 4))), q = _(null), J = _(pe ?? !1), ve = oe(), ye = l(L, C - 1), be = (e) => e.slice(0, 7) >= L && e.slice(0, 7) <= ye, xe = (e) => !!x && e < x || !!S && e > S || !!ue?.(e), Y = be(z) ? z : m(z, f(z.slice(0, 7), L));
16
+ let { locale: le, min: x, max: S, isDisabled: ue, weekStartsOn: de, months: C = 1, defaultMonth: fe, className: w, autoFocus: pe, mode: T, value: me, defaultValue: he = null, onValueChange: ge, ...E } = se, D = e(le), _e = new Intl.NumberFormat(D), O = t(), k = de ?? re(D), [A, j] = i(me, he, ge), M = T === "range" ? A : null, N = T === "range" ? null : A, P = N ?? M?.start ?? null, F = ne(), I = ie() ? F : null, [L, R] = v(() => fe ?? (P ?? F).slice(0, 7)), [z, B] = v(() => P ?? F), [V, H] = v(null), [U, W] = v("days"), [G, K] = v(() => Number(L.slice(0, 4))), q = _(null), J = _(pe ?? !1), ve = oe(), ye = l(L, C - 1), be = (e) => e.slice(0, 7) >= L && e.slice(0, 7) <= ye, xe = (e) => !!x && e < x || !!S && e > S || !!ue?.(e), Y = be(z) ? z : m(z, f(z.slice(0, 7), L));
17
17
  ae(() => {
18
18
  J.current && (J.current = !1, q.current?.querySelector(`[data-date="${Y}"]`)?.focus());
19
19
  }, [Y, U]);
@@ -36,16 +36,16 @@ function se(se) {
36
36
  } else j(e);
37
37
  }
38
38
  }, we = (e) => {
39
- let n = Y, r = (h(n) - k + 7) % 7, i = {
40
- ArrowLeft: p(n, -1),
41
- ArrowRight: p(n, 1),
42
- ArrowUp: p(n, -7),
43
- ArrowDown: p(n, 7),
44
- Home: p(n, -r),
45
- End: p(n, 6 - r),
46
- PageUp: m(n, e.shiftKey ? -12 : -1),
47
- PageDown: m(n, e.shiftKey ? 12 : 1)
48
- }[t(e.key, e.currentTarget)];
39
+ let t = Y, n = (h(t) - k + 7) % 7, i = {
40
+ ArrowLeft: p(t, -1),
41
+ ArrowRight: p(t, 1),
42
+ ArrowUp: p(t, -7),
43
+ ArrowDown: p(t, 7),
44
+ Home: p(t, -n),
45
+ End: p(t, 6 - n),
46
+ PageUp: m(t, e.shiftKey ? -12 : -1),
47
+ PageDown: m(t, e.shiftKey ? 12 : 1)
48
+ }[r(e.key, e.currentTarget)];
49
49
  i && (e.preventDefault(), Se(i));
50
50
  }, X = M && M.end === null ? M.start : null, Te = X && V ? V < X ? [V, X] : [X, V] : null, [Z, Q] = M?.end ? [M.start, M.end] : Te ?? [null, null], Ee = (e) => {
51
51
  R((t) => l(t, e));
@@ -80,16 +80,16 @@ function se(se) {
80
80
  ]
81
81
  });
82
82
  if (U === "months") {
83
- let t = d(D);
83
+ let e = d(D);
84
84
  return /* @__PURE__ */ b("div", {
85
- className: e("zen__calendar w-fit", w),
85
+ className: n("zen__calendar w-fit", w),
86
86
  ...E,
87
87
  children: [$, /* @__PURE__ */ y("div", {
88
88
  className: "grid w-64 grid-cols-3 gap-1",
89
89
  role: "group",
90
90
  "aria-labelledby": ve,
91
- children: t.map((t, n) => {
92
- let r = `${G}-${String(n + 1).padStart(2, "0")}`, i = !!x && r < x.slice(0, 7) || !!S && r > S.slice(0, 7);
91
+ children: e.map((e, t) => {
92
+ let r = `${G}-${String(t + 1).padStart(2, "0")}`, i = !!x && r < x.slice(0, 7) || !!S && r > S.slice(0, 7);
93
93
  return /* @__PURE__ */ y("button", {
94
94
  type: "button",
95
95
  disabled: i,
@@ -98,8 +98,8 @@ function se(se) {
98
98
  onClick: () => {
99
99
  R(r), J.current = !0, B(m(z, f(z.slice(0, 7), r))), W("days");
100
100
  },
101
- className: e(a, r === L && "bg-primary text-primary-foreground hover:bg-primary"),
102
- children: t
101
+ className: n(a, r === L && "bg-primary text-primary-foreground hover:bg-primary"),
102
+ children: e
103
103
  }, r);
104
104
  })
105
105
  })]
@@ -107,15 +107,15 @@ function se(se) {
107
107
  }
108
108
  let De = g(D, "narrow"), Oe = g(D, "long"), ke = Array.from({ length: 7 }, (e, t) => (k + t) % 7);
109
109
  return /* @__PURE__ */ b("div", {
110
- className: e("zen__calendar w-fit", w),
110
+ className: n("zen__calendar w-fit", w),
111
111
  ...E,
112
112
  children: [$, /* @__PURE__ */ y("div", {
113
113
  ref: q,
114
114
  className: "flex gap-4",
115
115
  onKeyDown: we,
116
116
  onMouseLeave: () => H(null),
117
- children: Array.from({ length: C }, (t, n) => {
118
- let r = l(L, n), i = `${r}-01`, a = `${r}-${ee(r)}`, o = p(i, -((h(i) - k + 7) % 7));
117
+ children: Array.from({ length: C }, (e, t) => {
118
+ let r = l(L, t), i = `${r}-01`, a = `${r}-${ee(r)}`, o = p(i, -((h(i) - k + 7) % 7));
119
119
  return /* @__PURE__ */ b("table", {
120
120
  role: "grid",
121
121
  "aria-label": u(r, D, "long"),
@@ -131,14 +131,14 @@ function se(se) {
131
131
  className: "text-muted-foreground size-9 text-xs font-medium",
132
132
  children: De[e]
133
133
  }, e)) }) }),
134
- /* @__PURE__ */ y("tbody", { children: Array.from({ length: 6 }, (t, n) => /* @__PURE__ */ y("tr", { children: Array.from({ length: 7 }, (t, s) => {
135
- let c = p(o, n * 7 + s), l = c.slice(0, 7) === r;
134
+ /* @__PURE__ */ y("tbody", { children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */ y("tr", { children: Array.from({ length: 7 }, (e, s) => {
135
+ let c = p(o, t * 7 + s), l = c.slice(0, 7) === r;
136
136
  if (!l && C > 1) return /* @__PURE__ */ y("td", { role: "gridcell" }, c);
137
137
  let u = c === Z, d = c === Q, f = !!Z && !!Q && c > Z && c < Q, m = c === N || c === M?.start || c === M?.end, h = xe(c);
138
138
  return /* @__PURE__ */ y("td", {
139
139
  role: "gridcell",
140
140
  "aria-selected": m || f || void 0,
141
- className: e("p-0", (f || (u || d) && Z !== Q) && "bg-primary/15", u && "rounded-s-lg", d && "rounded-e-lg", f && (s === 0 || C > 1 && c === i) && "rounded-s-lg", f && (s === 6 || C > 1 && c === a) && "rounded-e-lg"),
141
+ className: n("p-0", (f || (u || d) && Z !== Q) && "bg-primary/15", u && "rounded-s-lg", d && "rounded-e-lg", f && (s === 0 || C > 1 && c === i) && "rounded-s-lg", f && (s === 6 || C > 1 && c === a) && "rounded-e-lg"),
142
142
  children: /* @__PURE__ */ y("button", {
143
143
  type: "button",
144
144
  "data-date": c,
@@ -152,11 +152,11 @@ function se(se) {
152
152
  B(c), X && H(c);
153
153
  },
154
154
  onMouseEnter: () => X && H(c),
155
- className: e(ce, !l && "text-muted-foreground", h && "cursor-not-allowed opacity-35", m ? "bg-primary text-primary-foreground shadow-[0_0_20px_-4px_oklch(var(--glow)/calc(0.8*var(--glow-k)))]" : !h && "hover:bg-tint/[0.08]", c === I && "after:bg-primary after:absolute after:bottom-1 after:left-1/2 after:size-1 after:-translate-x-1/2 after:rounded-full", c === I && m && "after:bg-primary-foreground"),
155
+ className: n(ce, !l && "text-muted-foreground", h && "cursor-not-allowed opacity-35", m ? "bg-primary text-primary-foreground shadow-[0_0_20px_-4px_oklch(var(--glow)/calc(0.8*var(--glow-k)))]" : !h && "hover:bg-tint/[0.08]", c === I && "after:bg-primary after:absolute after:bottom-1 after:left-1/2 after:size-1 after:-translate-x-1/2 after:rounded-full", c === I && m && "after:bg-primary-foreground"),
156
156
  children: _e.format(Number(c.slice(8)))
157
157
  })
158
158
  }, c);
159
- }) }, n)) })
159
+ }) }, t)) })
160
160
  ]
161
161
  }, r);
162
162
  })
@@ -1,28 +1,28 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { useLocale as t } from "../locale-provider/index.js";
2
+ import { useLocale as e } from "../locale-provider/index.js";
3
+ import { cx as t } from "../utils/cx.js";
4
4
  import { formatMonth as n } from "../utils/month.js";
5
5
  import { dayOfWeek as r, daysInMonth as i, formatDate as a, weekStart as o, weekdayNames as s } from "../utils/date.js";
6
6
  import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
7
7
  //#region packages/calendar-heatmap/index.tsx
8
8
  function d({ month: d, values: f, locale: p, format: m = String, weekStartsOn: h, onSelectedChange: g, selected: _, label: v, className: y, ...b }) {
9
- let x = t(p), S = new Intl.NumberFormat(x), C = h ?? o(x), w = i(d), T = Array.from({ length: w }, (e, t) => `${d}-${String(t + 1).padStart(2, "0")}`), E = (r(T[0]) - C + 7) % 7, D = [...Array(E).fill(null), ...T];
9
+ let x = e(p), S = new Intl.NumberFormat(x), C = h ?? o(x), w = i(d), T = Array.from({ length: w }, (e, t) => `${d}-${String(t + 1).padStart(2, "0")}`), E = (r(T[0]) - C + 7) % 7, D = [...Array(E).fill(null), ...T];
10
10
  for (; D.length % 7;) D.push(null);
11
11
  let O = Array.from({ length: D.length / 7 }, (e, t) => D.slice(t * 7, t * 7 + 7)), k = s(x, "narrow"), A = s(x, "long"), j = Array.from({ length: 7 }, (e, t) => (C + t) % 7), M = Math.max(0, ...T.map((e) => f[e] ?? 0));
12
12
  return /* @__PURE__ */ u("table", {
13
13
  "aria-label": v ?? n(d, x, "long"),
14
14
  ...b,
15
- className: e("zen__calendar-heatmap w-full table-fixed border-separate border-spacing-1", y),
15
+ className: t("zen__calendar-heatmap w-full table-fixed border-separate border-spacing-1", y),
16
16
  children: [/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: j.map((e) => /* @__PURE__ */ l("th", {
17
17
  scope: "col",
18
18
  abbr: A[e],
19
19
  className: "text-muted-foreground pb-1 text-xs font-normal",
20
20
  children: k[e]
21
- }, e)) }) }), /* @__PURE__ */ l("tbody", { children: O.map((t, n) => /* @__PURE__ */ l("tr", { children: t.map((t, n) => {
22
- if (!t) return /* @__PURE__ */ l("td", {}, n);
23
- let r = f[t], i = M > 0 && r ? Math.sqrt(r / M) : 0, o = `${a(t, x, "day")}: ${m(r || 0)}`, s = e("relative grid aspect-square w-full place-items-center rounded-md text-[0.65rem] tabular-nums transition-[box-shadow]", i ? i > .6 ? "text-primary-foreground" : "text-foreground/80" : "bg-tint/[0.04] text-muted-foreground", t === _ && "ring-ring ring-2"), d = i ? { background: `oklch(var(--primary) / ${+(.14 + .81 * i).toFixed(2)})` } : void 0, p = /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("span", {
21
+ }, e)) }) }), /* @__PURE__ */ l("tbody", { children: O.map((e, n) => /* @__PURE__ */ l("tr", { children: e.map((e, n) => {
22
+ if (!e) return /* @__PURE__ */ l("td", {}, n);
23
+ let r = f[e], i = M > 0 && r ? Math.sqrt(r / M) : 0, o = `${a(e, x, "day")}: ${m(r || 0)}`, s = t("relative grid aspect-square w-full place-items-center rounded-md text-[0.65rem] tabular-nums transition-[box-shadow]", i ? i > .6 ? "text-primary-foreground" : "text-foreground/80" : "bg-tint/[0.04] text-muted-foreground", e === _ && "ring-ring ring-2"), d = i ? { background: `oklch(var(--primary) / ${+(.14 + .81 * i).toFixed(2)})` } : void 0, p = /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("span", {
24
24
  "aria-hidden": !0,
25
- children: S.format(Number(t.slice(8)))
25
+ children: S.format(Number(e.slice(8)))
26
26
  }), /* @__PURE__ */ l("span", {
27
27
  className: "sr-only",
28
28
  children: o
@@ -32,9 +32,9 @@ function d({ month: d, values: f, locale: p, format: m = String, weekStartsOn: h
32
32
  className: "p-0",
33
33
  children: g ? /* @__PURE__ */ l("button", {
34
34
  type: "button",
35
- "aria-pressed": t === _,
36
- onClick: () => g(t),
37
- className: e(s, " cursor-pointer outline-hidden hover:shadow-[0_0_0_1px_oklch(var(--tint)/0.3)] focus-ring"),
35
+ "aria-pressed": e === _,
36
+ onClick: () => g(e),
37
+ className: t(s, " cursor-pointer outline-hidden hover:shadow-[0_0_0_1px_oklch(var(--tint)/0.3)] focus-ring"),
38
38
  style: d,
39
39
  children: p
40
40
  }) : /* @__PURE__ */ l("span", {
@@ -42,7 +42,7 @@ function d({ month: d, values: f, locale: p, format: m = String, weekStartsOn: h
42
42
  style: d,
43
43
  children: p
44
44
  })
45
- }, t);
45
+ }, e);
46
46
  }) }, n)) })]
47
47
  });
48
48
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { useMergedRefs as t } from "../utils/refs.js";
4
- import { useMessages as n } from "../locale-provider/index.js";
2
+ import { useMessages as e } from "../locale-provider/index.js";
3
+ import { cx as t } from "../utils/cx.js";
4
+ import { useMergedRefs as n } from "../utils/refs.js";
5
5
  import { boundsOf as r, intersects as i, moveRect as a, resizeRect as o } from "./geometry.js";
6
6
  import { createContext as s, useContext as c, useEffect as l, useId as u, useLayoutEffect as d, useRef as f, useState as p } from "react";
7
7
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
@@ -31,7 +31,7 @@ var g = typeof window > "u" ? l : d, _ = 3, ee = "input, textarea, select, butto
31
31
  ArrowDown: [0, 1]
32
32
  }, x = (e, t) => e.x === t.x && e.y === t.y && e.w === t.w && e.h === t.h, S = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]), C = s(null);
33
33
  function w({ width: s, height: c, scale: l = 1, items: d, onItemsChange: v, onItemsChangeEnd: y, selected: w = [], onSelectedChange: T, minSize: E = 8, snap: D = !1, grid: O, className: te, style: ne, children: re, onPointerDown: ie, ref: ae, ...k }) {
34
- let A = n(), j = f(null), oe = t(j, ae), M = f(!1), [N, se] = p(null), [ce, P] = p([]), [F, I] = p(null), [L, R] = p(null), [le, z] = p(!1), [B, V] = p(""), H = u();
34
+ let A = e(), j = f(null), oe = n(j, ae), M = f(!1), [N, se] = p(null), [ce, P] = p([]), [F, I] = p(null), [L, R] = p(null), [le, z] = p(!1), [B, V] = p(""), H = u();
35
35
  g(() => {
36
36
  let e = j.current;
37
37
  if (l !== "fit" || !e) return;
@@ -190,7 +190,7 @@ function w({ width: s, height: c, scale: l = 1, items: d, onItemsChange: v, onIt
190
190
  height: c * U
191
191
  }
192
192
  },
193
- className: e("zen__canvas bg-tint/[0.03] relative shrink-0 overflow-hidden rounded-lg shadow-[inset_0_0_0_1px_oklch(var(--tint)/0.08)] select-none", te),
193
+ className: t("zen__canvas bg-tint/[0.03] relative shrink-0 overflow-hidden rounded-lg shadow-[inset_0_0_0_1px_oklch(var(--tint)/0.08)] select-none", te),
194
194
  children: [/* @__PURE__ */ m("div", {
195
195
  style: {
196
196
  width: s,
@@ -198,7 +198,7 @@ function w({ width: s, height: c, scale: l = 1, items: d, onItemsChange: v, onIt
198
198
  scale: String(U),
199
199
  "--canvas-scale": U
200
200
  },
201
- className: e("absolute top-0 left-0 origin-top-left", l === "fit" && N === null && "invisible"),
201
+ className: t("absolute top-0 left-0 origin-top-left", l === "fit" && N === null && "invisible"),
202
202
  children: re
203
203
  }), /* @__PURE__ */ h("div", {
204
204
  "aria-hidden": !0,
@@ -260,30 +260,30 @@ function w({ width: s, height: c, scale: l = 1, items: d, onItemsChange: v, onIt
260
260
  ]
261
261
  });
262
262
  }
263
- function T({ id: t, label: n, className: r, style: i, children: a, ...o }) {
263
+ function T({ id: e, label: n, className: r, style: i, children: a, ...o }) {
264
264
  let s = c(C);
265
265
  if (!s) throw Error("<CanvasItem> must be inside <Canvas>");
266
- let l = s.item(t);
266
+ let l = s.item(e);
267
267
  if (!l) return null;
268
- let u = s.selected.includes(t), d = u && s.selected.length === 1;
268
+ let u = s.selected.includes(e), d = u && s.selected.length === 1;
269
269
  return /* @__PURE__ */ h("div", {
270
270
  role: "group",
271
271
  "aria-roledescription": l.locked ? "locked item" : "movable item",
272
272
  "aria-label": n,
273
273
  "aria-describedby": l.locked ? void 0 : s.hintId,
274
274
  tabIndex: 0,
275
- "data-canvas-id": t,
275
+ "data-canvas-id": e,
276
276
  "data-selected": u || void 0,
277
277
  "data-locked": l.locked || void 0,
278
278
  ...o,
279
- onFocus: (e) => {
280
- o.onFocus?.(e), e.target === e.currentTarget && s.focus(t);
279
+ onFocus: (t) => {
280
+ o.onFocus?.(t), t.target === t.currentTarget && s.focus(e);
281
281
  },
282
- onPointerDown: (e) => {
283
- o.onPointerDown?.(e), s.grab(e, t, n);
282
+ onPointerDown: (t) => {
283
+ o.onPointerDown?.(t), s.grab(t, e, n);
284
284
  },
285
- onKeyDown: (e) => {
286
- o.onKeyDown?.(e), s.key(e, t, n);
285
+ onKeyDown: (t) => {
286
+ o.onKeyDown?.(t), s.key(t, e, n);
287
287
  },
288
288
  style: {
289
289
  ...i,
@@ -292,12 +292,12 @@ function T({ id: t, label: n, className: r, style: i, children: a, ...o }) {
292
292
  width: l.w,
293
293
  height: l.h
294
294
  },
295
- className: e("zen__canvas-item absolute cursor-move touch-none outline-hidden data-locked:cursor-default data-locked:touch-auto", "[outline-offset:calc(1px/var(--canvas-scale))]", "not-data-selected:hover:outline-solid not-data-selected:hover:outline-[length:calc(1px/var(--canvas-scale))] not-data-selected:hover:outline-[color:oklch(var(--tint)/0.35)]", "data-selected:outline-solid data-selected:outline-[length:calc(2px/var(--canvas-scale))] data-selected:outline-[color:oklch(var(--primary)/0.8)]", "focus-visible:outline-solid focus-visible:outline-[length:calc(2px/var(--canvas-scale))] focus-visible:outline-[color:oklch(var(--ring)/0.7)]", r),
295
+ className: t("zen__canvas-item absolute cursor-move touch-none outline-hidden data-locked:cursor-default data-locked:touch-auto", "[outline-offset:calc(1px/var(--canvas-scale))]", "not-data-selected:hover:outline-solid not-data-selected:hover:outline-[length:calc(1px/var(--canvas-scale))] not-data-selected:hover:outline-[color:oklch(var(--tint)/0.35)]", "data-selected:outline-solid data-selected:outline-[length:calc(2px/var(--canvas-scale))] data-selected:outline-[color:oklch(var(--primary)/0.8)]", "focus-visible:outline-solid focus-visible:outline-[length:calc(2px/var(--canvas-scale))] focus-visible:outline-[color:oklch(var(--ring)/0.7)]", r),
296
296
  children: [a, d && !l.locked && v.map((r) => /* @__PURE__ */ m("span", {
297
297
  "aria-hidden": !0,
298
298
  "data-handle": r,
299
- onPointerDown: (e) => s.grab(e, t, n, r),
300
- className: e("bg-foreground absolute z-10 size-[calc(10px/var(--canvas-scale))] -translate-1/2 rounded-full border-[length:calc(2px/var(--canvas-scale))] border-[color:oklch(var(--primary))] shadow-[0_0_8px_oklch(var(--glow)/0.6)]", "after:absolute after:-inset-[calc(6px/var(--canvas-scale))] pointer-coarse:after:-inset-[calc(14px/var(--canvas-scale))]", y[r])
299
+ onPointerDown: (t) => s.grab(t, e, n, r),
300
+ className: t("bg-foreground absolute z-10 size-[calc(10px/var(--canvas-scale))] -translate-1/2 rounded-full border-[length:calc(2px/var(--canvas-scale))] border-[color:oklch(var(--primary))] shadow-[0_0_8px_oklch(var(--glow)/0.6)]", "after:absolute after:-inset-[calc(6px/var(--canvas-scale))] pointer-coarse:after:-inset-[calc(14px/var(--canvas-scale))]", y[r])
301
301
  }, r))]
302
302
  });
303
303
  }
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { useMergedRefs as t } from "../utils/refs.js";
4
- import { useMessages as n } from "../locale-provider/index.js";
2
+ import { useMessages as e } from "../locale-provider/index.js";
3
+ import { cx as t } from "../utils/cx.js";
4
+ import { useMergedRefs as n } from "../utils/refs.js";
5
5
  import { reducedMotion as r } from "../utils/motion.js";
6
6
  import i from "../icons/chevron-left.js";
7
7
  import a from "../icons/chevron-right.js";
@@ -18,8 +18,8 @@ function _(e, t) {
18
18
  let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
19
19
  return (getComputedStyle(t).direction === "rtl" ? r.right - n.right : n.left - r.left) + Math.abs(t.scrollLeft);
20
20
  }
21
- function v({ className: t, children: i, ...a }) {
22
- let o = n(), c = d(null), [l, u] = f({
21
+ function v({ className: n, children: i, ...a }) {
22
+ let o = e(), c = d(null), [l, u] = f({
23
23
  index: 0,
24
24
  stops: 1,
25
25
  count: 0
@@ -70,23 +70,23 @@ function v({ className: t, children: i, ...a }) {
70
70
  children: /* @__PURE__ */ p("section", {
71
71
  "aria-roledescription": o.carousel,
72
72
  ...a,
73
- className: e("zen__carousel relative", t),
73
+ className: t("zen__carousel relative", n),
74
74
  children: i
75
75
  })
76
76
  });
77
77
  }
78
- function y({ ref: n, className: r, ...i }) {
79
- let { contentRef: a } = g("CarouselContent"), o = t(a, n);
78
+ function y({ ref: e, className: r, ...i }) {
79
+ let { contentRef: a } = g("CarouselContent"), o = n(a, e);
80
80
  return /* @__PURE__ */ p("div", {
81
81
  tabIndex: 0,
82
82
  "aria-live": "polite",
83
83
  ...i,
84
84
  ref: o,
85
- className: e("flex snap-x snap-mandatory gap-4 overflow-x-auto overscroll-x-contain rounded-xl", "focus-ring [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", r)
85
+ className: t("flex snap-x snap-mandatory gap-4 overflow-x-auto overscroll-x-contain rounded-xl", "focus-ring [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", r)
86
86
  });
87
87
  }
88
88
  function b({ ref: r, className: i, ...a }) {
89
- let o = n(), { count: s } = g("CarouselItem"), c = d(null), l = t(c, r), [u, h] = f(0);
89
+ let o = e(), { count: s } = g("CarouselItem"), c = d(null), l = n(c, r), [u, h] = f(0);
90
90
  return m(() => {
91
91
  let e = c.current;
92
92
  e?.parentElement && h(Array.prototype.indexOf.call(e.parentElement.children, e) + 1);
@@ -96,18 +96,18 @@ function b({ ref: r, className: i, ...a }) {
96
96
  "aria-label": u && s ? o.slideOf(u, s) : void 0,
97
97
  ...a,
98
98
  ref: l,
99
- className: e("min-w-0 shrink-0 grow-0 basis-full snap-start", i)
99
+ className: t("min-w-0 shrink-0 grow-0 basis-full snap-start", i)
100
100
  });
101
101
  }
102
102
  var x = "glass glass-blur text-foreground grid size-9 shrink-0 cursor-pointer place-items-center rounded-full transition-opacity focus-ring hover:bg-tint/[0.08] aria-disabled:cursor-not-allowed aria-disabled:opacity-0 aria-disabled:focus-visible:opacity-40";
103
- function S({ className: t, onClick: r, ...a }) {
104
- let o = n(), { index: s, scrollTo: c } = g("CarouselPrevious"), l = s === 0;
103
+ function S({ className: n, onClick: r, ...a }) {
104
+ let o = e(), { index: s, scrollTo: c } = g("CarouselPrevious"), l = s === 0;
105
105
  return /* @__PURE__ */ p("button", {
106
106
  type: "button",
107
107
  "aria-label": o.previousSlide,
108
108
  ...a,
109
109
  "aria-disabled": l || void 0,
110
- className: e(x, t),
110
+ className: t(x, n),
111
111
  onClick: (e) => {
112
112
  r?.(e), !l && !e.defaultPrevented && c(s - 1);
113
113
  },
@@ -117,14 +117,14 @@ function S({ className: t, onClick: r, ...a }) {
117
117
  })
118
118
  });
119
119
  }
120
- function C({ className: t, onClick: r, ...i }) {
121
- let o = n(), { index: s, stops: c, scrollTo: l } = g("CarouselNext"), u = s >= c - 1;
120
+ function C({ className: n, onClick: r, ...i }) {
121
+ let o = e(), { index: s, stops: c, scrollTo: l } = g("CarouselNext"), u = s >= c - 1;
122
122
  return /* @__PURE__ */ p("button", {
123
123
  type: "button",
124
124
  "aria-label": o.nextSlide,
125
125
  ...i,
126
126
  "aria-disabled": u || void 0,
127
- className: e(x, t),
127
+ className: t(x, n),
128
128
  onClick: (e) => {
129
129
  r?.(e), !u && !e.defaultPrevented && l(s + 1);
130
130
  },
@@ -134,12 +134,12 @@ function C({ className: t, onClick: r, ...i }) {
134
134
  })
135
135
  });
136
136
  }
137
- function w({ className: t, ...r }) {
138
- let i = n(), { index: a, stops: o, scrollTo: s } = g("CarouselDots");
137
+ function w({ className: n, ...r }) {
138
+ let i = e(), { index: a, stops: o, scrollTo: s } = g("CarouselDots");
139
139
  return o < 2 ? null : /* @__PURE__ */ p("div", {
140
140
  ...r,
141
- className: e("flex justify-center gap-0.5", t),
142
- children: Array.from({ length: o }, (t, n) => /* @__PURE__ */ p("button", {
141
+ className: t("flex justify-center gap-0.5", n),
142
+ children: Array.from({ length: o }, (e, n) => /* @__PURE__ */ p("button", {
143
143
  type: "button",
144
144
  "aria-label": i.goToSlide(n + 1),
145
145
  "aria-current": n === a || void 0,
@@ -147,15 +147,15 @@ function w({ className: t, ...r }) {
147
147
  className: "group cursor-pointer rounded-full p-1 outline-hidden",
148
148
  children: /* @__PURE__ */ p("span", {
149
149
  "aria-hidden": !0,
150
- className: e("block h-1.5 rounded-full transition-[width,background-color,box-shadow] duration-300", "group-focus-visible:ring-2 group-focus-visible:ring-ring/50", n === a ? "bg-primary w-5 shadow-[0_0_10px_oklch(var(--glow)/calc(0.7*var(--glow-k)))]" : "bg-tint/25 group-hover:bg-tint/40 w-1.5")
150
+ className: t("block h-1.5 rounded-full transition-[width,background-color,box-shadow] duration-300", "group-focus-visible:ring-2 group-focus-visible:ring-ring/50", n === a ? "bg-primary w-5 shadow-[0_0_10px_oklch(var(--glow)/calc(0.7*var(--glow-k)))]" : "bg-tint/25 group-hover:bg-tint/40 w-1.5")
151
151
  })
152
152
  }, n))
153
153
  });
154
154
  }
155
- function T({ className: t, ...n }) {
155
+ function T({ className: e, ...n }) {
156
156
  return /* @__PURE__ */ p("div", {
157
157
  ...n,
158
- className: e("mt-3 flex items-center justify-between gap-3", t)
158
+ className: t("mt-3 flex items-center justify-between gap-3", e)
159
159
  });
160
160
  }
161
161
  //#endregion
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { cx as e } from "../utils/cx.js";
3
- import { useMessages as t } from "../locale-provider/index.js";
2
+ import { useMessages as e } from "../locale-provider/index.js";
3
+ import { cx as t } from "../utils/cx.js";
4
4
  import { useSeen as n } from "../utils/useSeen.js";
5
5
  import { paletteColor as r } from "./palette.js";
6
6
  import { ChartTooltipCard as i, Key as a } from "./tooltip.js";
@@ -19,7 +19,7 @@ var g = () => null, _ = () => null, v = () => null, ne = () => null, y = /* @__P
19
19
  bottom: 26
20
20
  }, x = 11;
21
21
  function S({ data: a, x: o, label: s, summary: c, height: g = 240, formatX: _ = String, formatY: v = O, formatTooltipX: S, renderTooltip: D, legend: j, palette: M = "chart", className: N, children: P, ...F }) {
22
- let I = t(), L = l().replace(/[^\w-]/g, ""), R = d(null), z = E(R), B = n(R), [V, H] = f(null), [oe, U] = f(null), W = u(() => {
22
+ let I = e(), L = l().replace(/[^\w-]/g, ""), R = d(null), z = E(R), B = n(R), [V, H] = f(null), [oe, U] = f(null), W = u(() => {
23
23
  let e = ee.toArray(P).filter(te), t = e.filter((e) => y.has(e.type)).length, n = [], i = [];
24
24
  for (let a of e) {
25
25
  a.type === ne && i.push(a.props);
@@ -223,7 +223,7 @@ function S({ data: a, x: o, label: s, summary: c, height: g = 240, formatX: _ =
223
223
  return /* @__PURE__ */ h("figure", {
224
224
  "aria-label": s,
225
225
  ...F,
226
- className: e("zen__chart m-0 flex flex-col gap-3", N),
226
+ className: t("zen__chart m-0 flex flex-col gap-3", N),
227
227
  children: [
228
228
  ve && /* @__PURE__ */ m(w, { series: G }),
229
229
  /* @__PURE__ */ h("div", {
@@ -304,12 +304,12 @@ function C(e, t) {
304
304
  let n = e[t];
305
305
  return typeof n == "number" && Number.isFinite(n) ? n : null;
306
306
  }
307
- function w({ series: e }) {
308
- let n = t(), r = e.filter((t, n) => t.dimLabel && e.findIndex((e) => e.dimLabel === t.dimLabel) === n);
307
+ function w({ series: t }) {
308
+ let n = e(), r = t.filter((e, n) => e.dimLabel && t.findIndex((t) => t.dimLabel === e.dimLabel) === n);
309
309
  return /* @__PURE__ */ h("ul", {
310
310
  className: "text-muted-foreground flex flex-wrap gap-x-4 gap-y-1 text-xs",
311
311
  "aria-label": n.legend,
312
- children: [e.map((e) => /* @__PURE__ */ h("li", {
312
+ children: [t.map((e) => /* @__PURE__ */ h("li", {
313
313
  className: "flex items-center gap-1.5",
314
314
  children: [/* @__PURE__ */ m(a, {
315
315
  color: e.color,