@rinzai/zen 0.6.1 → 0.7.1

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 (161) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +3 -3
  3. package/dist/alert/index.d.ts +21 -0
  4. package/dist/alert/index.d.ts.map +1 -0
  5. package/dist/alert/index.js +49 -0
  6. package/dist/avatar/index.d.ts.map +1 -1
  7. package/dist/avatar/index.js +25 -22
  8. package/dist/button/index.d.ts +2 -1
  9. package/dist/button/index.d.ts.map +1 -1
  10. package/dist/button/index.js +43 -12
  11. package/dist/calendar/index.d.ts.map +1 -1
  12. package/dist/calendar/index.js +86 -85
  13. package/dist/chart/donut.d.ts +4 -1
  14. package/dist/chart/donut.d.ts.map +1 -1
  15. package/dist/chart/donut.js +76 -66
  16. package/dist/chart/index.d.ts +8 -2
  17. package/dist/chart/index.d.ts.map +1 -1
  18. package/dist/chart/index.js +192 -182
  19. package/dist/chart/palette.d.ts +14 -0
  20. package/dist/chart/palette.d.ts.map +1 -0
  21. package/dist/chart/palette.js +9 -0
  22. package/dist/chart/tooltip.d.ts +6 -2
  23. package/dist/chart/tooltip.d.ts.map +1 -1
  24. package/dist/chart/tooltip.js +6 -6
  25. package/dist/checkbox/index.d.ts.map +1 -1
  26. package/dist/checkbox/index.js +28 -44
  27. package/dist/chip/index.js +1 -1
  28. package/dist/code-block/index.js +1 -1
  29. package/dist/date-picker/index.d.ts.map +1 -1
  30. package/dist/date-picker/index.js +24 -38
  31. package/dist/disclosure/index.js +1 -1
  32. package/dist/editable-cell/index.js +1 -1
  33. package/dist/field/index.d.ts +1 -1
  34. package/dist/field/index.d.ts.map +1 -1
  35. package/dist/field/index.js +33 -32
  36. package/dist/header/index.d.ts +9 -1
  37. package/dist/header/index.d.ts.map +1 -1
  38. package/dist/header/index.js +17 -9
  39. package/dist/icons/arrow-left.d.ts +3 -0
  40. package/dist/icons/arrow-left.d.ts.map +1 -0
  41. package/dist/icons/arrow-right.d.ts +3 -0
  42. package/dist/icons/arrow-right.d.ts.map +1 -0
  43. package/dist/icons/bars.d.ts +3 -0
  44. package/dist/icons/bars.d.ts.map +1 -0
  45. package/dist/icons/calendar.d.ts +3 -0
  46. package/dist/icons/calendar.d.ts.map +1 -0
  47. package/dist/icons/chart-bar.d.ts +3 -0
  48. package/dist/icons/chart-bar.d.ts.map +1 -0
  49. package/dist/icons/chevron-down.d.ts.map +1 -1
  50. package/dist/icons/chevron-down.js +4 -2
  51. package/dist/icons/chevron-left.d.ts.map +1 -1
  52. package/dist/icons/chevron-left.js +4 -2
  53. package/dist/icons/chevron-right.d.ts.map +1 -1
  54. package/dist/icons/chevron-right.js +4 -2
  55. package/dist/icons/chevron-up.d.ts.map +1 -1
  56. package/dist/icons/chevron-up.js +4 -2
  57. package/dist/icons/ellipsis.d.ts +0 -1
  58. package/dist/icons/ellipsis.d.ts.map +1 -1
  59. package/dist/icons/flag.d.ts +3 -0
  60. package/dist/icons/flag.d.ts.map +1 -0
  61. package/dist/icons/list-bullet.d.ts +3 -0
  62. package/dist/icons/list-bullet.d.ts.map +1 -0
  63. package/dist/icons/lock.d.ts +3 -0
  64. package/dist/icons/lock.d.ts.map +1 -0
  65. package/dist/icons/logout.d.ts +3 -0
  66. package/dist/icons/logout.d.ts.map +1 -0
  67. package/dist/icons/micro/calendar.d.ts +3 -0
  68. package/dist/icons/micro/calendar.d.ts.map +1 -0
  69. package/dist/icons/micro/calendar.js +21 -0
  70. package/dist/icons/micro/check.d.ts +3 -0
  71. package/dist/icons/micro/check.d.ts.map +1 -0
  72. package/dist/icons/micro/check.js +21 -0
  73. package/dist/icons/micro/chevron-down.d.ts +3 -0
  74. package/dist/icons/micro/chevron-down.d.ts.map +1 -0
  75. package/dist/icons/micro/chevron-down.js +21 -0
  76. package/dist/icons/micro/chevron-right.d.ts +3 -0
  77. package/dist/icons/micro/chevron-right.d.ts.map +1 -0
  78. package/dist/icons/micro/chevron-right.js +21 -0
  79. package/dist/icons/micro/exclamation-triangle.d.ts +3 -0
  80. package/dist/icons/micro/exclamation-triangle.d.ts.map +1 -0
  81. package/dist/icons/micro/exclamation-triangle.js +21 -0
  82. package/dist/icons/micro/information-circle.d.ts +3 -0
  83. package/dist/icons/micro/information-circle.d.ts.map +1 -0
  84. package/dist/icons/micro/information-circle.js +21 -0
  85. package/dist/icons/micro/minus.d.ts +3 -0
  86. package/dist/icons/micro/minus.d.ts.map +1 -0
  87. package/dist/icons/micro/minus.js +17 -0
  88. package/dist/icons/micro/moon.d.ts +3 -0
  89. package/dist/icons/micro/moon.d.ts.map +1 -0
  90. package/dist/icons/micro/moon.js +17 -0
  91. package/dist/icons/micro/sun.d.ts +3 -0
  92. package/dist/icons/micro/sun.d.ts.map +1 -0
  93. package/dist/icons/micro/sun.js +17 -0
  94. package/dist/icons/micro/x-mark.d.ts +3 -0
  95. package/dist/icons/micro/x-mark.d.ts.map +1 -0
  96. package/dist/icons/micro/x-mark.js +17 -0
  97. package/dist/icons/search.d.ts.map +1 -1
  98. package/dist/icons/search.js +4 -2
  99. package/dist/icons/settings.d.ts +3 -0
  100. package/dist/icons/settings.d.ts.map +1 -0
  101. package/dist/icons/squares.d.ts +3 -0
  102. package/dist/icons/squares.d.ts.map +1 -0
  103. package/dist/icons/table.d.ts +3 -0
  104. package/dist/icons/table.d.ts.map +1 -0
  105. package/dist/icons/x-mark.d.ts.map +1 -1
  106. package/dist/icons/x-mark.js +4 -2
  107. package/dist/index.d.ts +7 -5
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/lib.js +57 -61
  110. package/dist/menu/index.d.ts.map +1 -1
  111. package/dist/menu/index.js +67 -60
  112. package/dist/month-picker/index.d.ts.map +1 -1
  113. package/dist/month-picker/index.js +55 -55
  114. package/dist/pills/index.d.ts +1 -1
  115. package/dist/pills/index.d.ts.map +1 -1
  116. package/dist/pills/index.js +6 -2
  117. package/dist/popover/index.js +12 -11
  118. package/dist/select/index.d.ts.map +1 -1
  119. package/dist/select/index.js +96 -102
  120. package/dist/slider/index.d.ts.map +1 -1
  121. package/dist/slider/index.js +1 -1
  122. package/dist/status-pill/index.d.ts +18 -0
  123. package/dist/status-pill/index.d.ts.map +1 -0
  124. package/dist/status-pill/index.js +25 -0
  125. package/dist/tab-bar/index.js +1 -1
  126. package/dist/table/index.js +1 -1
  127. package/dist/tabs/index.d.ts.map +1 -1
  128. package/dist/tabs/index.js +9 -5
  129. package/dist/theme-toggle/index.d.ts +26 -4
  130. package/dist/theme-toggle/index.d.ts.map +1 -1
  131. package/dist/theme-toggle/index.js +42 -35
  132. package/dist/theme.css +67 -1
  133. package/dist/toast/index.d.ts.map +1 -1
  134. package/dist/toast/index.js +119 -106
  135. package/dist/tree/index.d.ts +22 -3
  136. package/dist/tree/index.d.ts.map +1 -1
  137. package/dist/tree/index.js +76 -56
  138. package/dist/utils/date.d.ts +6 -4
  139. package/dist/utils/date.d.ts.map +1 -1
  140. package/dist/utils/date.js +18 -16
  141. package/dist/utils/field-chevron.d.ts.map +1 -1
  142. package/dist/utils/field-chevron.js +5 -14
  143. package/dist/utils/status-icons.d.ts +1 -1
  144. package/dist/utils/status-icons.d.ts.map +1 -1
  145. package/dist/utils/status-icons.js +11 -41
  146. package/dist/utils/styles.d.ts +9 -3
  147. package/dist/utils/styles.d.ts.map +1 -1
  148. package/dist/utils/styles.js +2 -2
  149. package/dist/utils/theme-wave.d.ts +26 -0
  150. package/dist/utils/theme-wave.d.ts.map +1 -0
  151. package/dist/utils/theme-wave.js +239 -0
  152. package/dist/utils/typeahead.d.ts +12 -0
  153. package/dist/utils/typeahead.d.ts.map +1 -0
  154. package/dist/utils/typeahead.js +19 -0
  155. package/dist/zen.css +1 -1
  156. package/package.json +2 -1
  157. package/dist/icons/ellipsis.js +0 -31
  158. package/dist/icons/index.d.ts +0 -9
  159. package/dist/icons/index.d.ts.map +0 -1
  160. package/dist/icons/status.d.ts +0 -2
  161. package/dist/icons/status.d.ts.map +0 -1
@@ -1,150 +1,144 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { useAnchoredPopup as t } from "../utils/useAnchoredPopup.js";
4
- import { POPUP as n, TRIGGER as r } from "../utils/styles.js";
5
- import { CheckIcon as i } from "../utils/status-icons.js";
6
- import { useFieldProps as a } from "../field/index.js";
7
- import { FieldChevron as o } from "../utils/field-chevron.js";
8
- import { Children as s, Fragment as c, createContext as l, isValidElement as u, useCallback as d, useContext as f, useEffect as p, useId as m, useLayoutEffect as h, useRef as g, useState as _ } from "react";
9
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
3
+ import { useTypeahead as t } from "../utils/typeahead.js";
4
+ import { useAnchoredPopup as n } from "../utils/useAnchoredPopup.js";
5
+ import { POPUP as r, TRIGGER as i } from "../utils/styles.js";
6
+ import { CheckIcon as a } from "../utils/status-icons.js";
7
+ import { useFieldProps as o } from "../field/index.js";
8
+ import { FieldChevron as s } from "../utils/field-chevron.js";
9
+ import { Children as c, Fragment as l, createContext as u, isValidElement as d, useCallback as f, useContext as p, useEffect as m, useId as h, useLayoutEffect as g, useRef as _, useState as v } from "react";
10
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
10
11
  //#region packages/select/index.tsx
11
- var x = l(null);
12
- function S({ value: i, onChange: s, placeholder: c = "Select…", disabled: l = !1, name: u, id: f, className: h, listClassName: S, children: w, style: T, onKeyDown: E, ...D }) {
13
- let O = g(null), k = m(), A = f ?? k, j = a({
14
- ...D,
15
- id: f
16
- }), [M, N] = _(null), P = g({
17
- text: "",
18
- at: 0
19
- }), [F, I] = _(/* @__PURE__ */ new Map()), L = () => Array.from(O.current?.querySelectorAll("[role=\"option\"]") ?? []).map((e) => ({
12
+ var S = u(null);
13
+ function C({ value: a, onChange: c, placeholder: l = "Select…", disabled: u = !1, name: d, id: p, className: g, listClassName: C, children: T, style: E, onKeyDown: D, ...O }) {
14
+ let k = _(null), A = h(), j = p ?? A, M = o({
15
+ ...O,
16
+ id: p
17
+ }), [N, P] = v(null), F = t(), [I, L] = v(/* @__PURE__ */ new Map()), R = () => Array.from(k.current?.querySelectorAll("[role=\"option\"]") ?? []).map((e) => ({
20
18
  value: e.dataset.value,
21
19
  label: e.dataset.label ?? "",
22
20
  disabled: e.getAttribute("aria-disabled") === "true"
23
- })), R = t({
21
+ })), z = n({
24
22
  matchWidth: !0,
25
23
  onOpenChange: (e) => {
26
24
  if (!e) return;
27
- let t = L();
28
- N(t.find((e) => e.value === i)?.value ?? t.find((e) => !e.disabled)?.value ?? null);
25
+ let t = R();
26
+ P(t.find((e) => e.value === a)?.value ?? t.find((e) => !e.disabled)?.value ?? null);
29
27
  }
30
28
  });
31
- p(() => {
32
- R.open && O.current?.focus();
33
- }, [R.open]);
34
- let z = (e) => {
35
- L().find((t) => t.value === e)?.disabled || (s(e), R.setOpen(!1));
36
- }, B = d((e, t) => (I((n) => n.get(e) === t ? n : new Map(n).set(e, t)), () => I((t) => {
29
+ m(() => {
30
+ z.open && k.current?.focus();
31
+ }, [z.open]);
32
+ let B = (e) => {
33
+ R().find((t) => t.value === e)?.disabled || (c(e), z.setOpen(!1));
34
+ }, V = f((e, t) => (L((n) => n.get(e) === t ? n : new Map(n).set(e, t)), () => L((t) => {
37
35
  let n = new Map(t);
38
36
  return n.delete(e), n;
39
- })), []), V = new Map(F);
40
- C(w, V);
41
- let H = i === null ? void 0 : V.get(i), U = (e, t, n = L()) => {
37
+ })), []), H = new Map(I);
38
+ w(T, H);
39
+ let U = a === null ? void 0 : H.get(a), W = (e, t, n = R()) => {
42
40
  let r = e === null ? t === 1 ? -1 : n.length : n.findIndex((t) => t.value === e);
43
41
  for (let e = 1; e <= n.length; e++) {
44
42
  let i = (r + t * e + n.length * 2) % n.length;
45
43
  if (!n[i].disabled) return n[i].value;
46
44
  }
47
45
  return e;
48
- }, W = (e) => {
46
+ }, G = (e) => {
49
47
  let t = {
50
- ArrowDown: () => N((e) => U(e, 1)),
51
- ArrowUp: () => N((e) => U(e, -1)),
52
- Home: () => N(U(null, 1)),
53
- End: () => N(U(null, -1)),
54
- Enter: () => M !== null && z(M),
55
- " ": () => M !== null && z(M),
56
- Tab: () => R.setOpen(!1)
48
+ ArrowDown: () => P((e) => W(e, 1)),
49
+ ArrowUp: () => P((e) => W(e, -1)),
50
+ Home: () => P(W(null, 1)),
51
+ End: () => P(W(null, -1)),
52
+ Enter: () => N !== null && B(N),
53
+ " ": () => N !== null && B(N),
54
+ Tab: () => z.setOpen(!1)
57
55
  };
58
56
  if (t[e.key]) {
59
57
  e.key !== "Tab" && e.preventDefault(), t[e.key]();
60
58
  return;
61
59
  }
62
- if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
63
- let t = Date.now(), n = (t - P.current.at < 700 ? P.current.text : "") + e.key.toLowerCase();
64
- P.current = {
65
- text: n,
66
- at: t
67
- };
68
- let r = L().find((e) => !e.disabled && e.label.toLowerCase().startsWith(n));
69
- r && N(r.value);
60
+ let n = F(e);
61
+ if (n) {
62
+ let e = R().find((e) => !e.disabled && e.label.toLowerCase().startsWith(n));
63
+ e && P(e.value);
70
64
  }
71
- }, G = (e) => `${R.id}-option-${e}`;
72
- return /* @__PURE__ */ b(v, { children: [
73
- /* @__PURE__ */ b("button", {
65
+ }, K = (e) => `${z.id}-option-${e}`;
66
+ return /* @__PURE__ */ x(y, { children: [
67
+ /* @__PURE__ */ x("button", {
74
68
  type: "button",
75
- ...D,
76
- ...j,
77
- id: A,
78
- disabled: l,
69
+ ...O,
70
+ ...M,
71
+ id: j,
72
+ disabled: u,
79
73
  "aria-haspopup": "listbox",
80
- ...R.triggerProps,
74
+ ...z.triggerProps,
81
75
  style: {
82
- ...R.triggerProps.style,
83
- ...T
76
+ ...z.triggerProps.style,
77
+ ...E
84
78
  },
85
79
  onKeyDown: (e) => {
86
- E?.(e), ["ArrowDown", "ArrowUp"].includes(e.key) && !R.open && (e.preventDefault(), R.setOpen(!0));
80
+ D?.(e), ["ArrowDown", "ArrowUp"].includes(e.key) && !z.open && (e.preventDefault(), z.setOpen(!0));
87
81
  },
88
- className: e("zen__select group", r, "w-full", R.open && "border-glow/60 [--glow-border-color:transparent] shadow-[0_0_0_3px_oklch(var(--glow)/0.16),0_0_24px_-6px_oklch(var(--glow)/0.6)]", h),
89
- children: [/* @__PURE__ */ y("span", {
90
- className: e("truncate", H === void 0 && "text-muted-foreground"),
91
- children: H ?? c
92
- }), /* @__PURE__ */ y(o, { open: R.open })]
82
+ className: e("zen__select group", i, "w-full", z.open && "border-glow/60 [--glow-border-color:transparent] shadow-[0_0_0_3px_oklch(var(--glow)/0.16),0_0_24px_-6px_oklch(var(--glow)/0.6)]", g),
83
+ children: [/* @__PURE__ */ b("span", {
84
+ className: e("truncate", U === void 0 && "text-muted-foreground"),
85
+ children: U ?? l
86
+ }), /* @__PURE__ */ b(s, { open: z.open })]
93
87
  }),
94
- u && /* @__PURE__ */ y("input", {
88
+ d && /* @__PURE__ */ b("input", {
95
89
  type: "hidden",
96
- name: u,
97
- value: i ?? ""
90
+ name: d,
91
+ value: a ?? ""
98
92
  }),
99
- /* @__PURE__ */ y("div", {
100
- ...R.popupProps,
101
- className: e("zen__popover", n, "overflow-visible py-1", S),
102
- children: /* @__PURE__ */ y("div", {
103
- ref: O,
93
+ /* @__PURE__ */ b("div", {
94
+ ...z.popupProps,
95
+ className: e("zen__popover", r, "overflow-visible py-1", C),
96
+ children: /* @__PURE__ */ b("div", {
97
+ ref: k,
104
98
  role: "listbox",
105
99
  tabIndex: -1,
106
- "aria-label": D["aria-label"],
107
- "aria-labelledby": D["aria-label"] ? void 0 : A,
108
- "aria-activedescendant": M === null ? void 0 : G(M),
109
- onKeyDown: W,
100
+ "aria-label": O["aria-label"],
101
+ "aria-labelledby": O["aria-label"] ? void 0 : j,
102
+ "aria-activedescendant": N === null ? void 0 : K(N),
103
+ onKeyDown: G,
110
104
  className: "max-h-72 overflow-y-auto outline-hidden",
111
- children: /* @__PURE__ */ y(x.Provider, {
105
+ children: /* @__PURE__ */ b(S.Provider, {
112
106
  value: {
113
- value: i,
114
- active: M,
115
- setActive: N,
116
- choose: z,
117
- optionId: G,
118
- register: B
107
+ value: a,
108
+ active: N,
109
+ setActive: P,
110
+ choose: B,
111
+ optionId: K,
112
+ register: V
119
113
  },
120
- children: w
114
+ children: T
121
115
  })
122
116
  })
123
117
  })
124
118
  ] });
125
119
  }
126
- function C(e, t) {
127
- s.forEach(e, (e) => {
128
- if (!u(e)) return;
120
+ function w(e, t) {
121
+ c.forEach(e, (e) => {
122
+ if (!d(e)) return;
129
123
  let n = e;
130
- if (n.type === T && n.props.value !== void 0) {
131
- let e = n.props.label ?? w(n.props.children);
124
+ if (n.type === E && n.props.value !== void 0) {
125
+ let e = n.props.label ?? T(n.props.children);
132
126
  e && t.set(n.props.value, e);
133
- } else (n.type === E || n.type === c) && C(n.props.children, t);
127
+ } else (n.type === D || n.type === l) && w(n.props.children, t);
134
128
  });
135
129
  }
136
- var w = (e) => typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(w).join("") : "";
137
- function T({ value: t, label: n, disabled: r, className: a, children: o }) {
138
- let s = f(x);
130
+ var T = (e) => typeof e == "string" || typeof e == "number" ? String(e) : Array.isArray(e) ? e.map(T).join("") : "";
131
+ function E({ value: t, label: n, disabled: r, className: i, children: o }) {
132
+ let s = p(S);
139
133
  if (!s) throw Error("SelectItem must be inside a Select");
140
- let c = g(null), l = n ?? w(o), u = s.register;
141
- h(() => u(t, l || c.current?.textContent?.trim() || ""), [
134
+ let c = _(null), l = n ?? T(o), u = s.register;
135
+ g(() => u(t, l || c.current?.textContent?.trim() || ""), [
142
136
  u,
143
137
  t,
144
138
  l
145
139
  ]);
146
140
  let d = s.value === t;
147
- return /* @__PURE__ */ b("div", {
141
+ return /* @__PURE__ */ x("div", {
148
142
  ref: c,
149
143
  id: s.optionId(t),
150
144
  role: "option",
@@ -155,33 +149,33 @@ function T({ value: t, label: n, disabled: r, className: a, children: o }) {
155
149
  "data-highlighted": s.active === t || void 0,
156
150
  onMouseMove: () => !r && s.setActive(t),
157
151
  onClick: () => s.choose(t),
158
- className: e("grid cursor-pointer grid-cols-[1rem_1fr] items-center gap-2 px-3 py-2 text-sm outline-hidden select-none", "data-highlighted:bg-muted aria-disabled:cursor-not-allowed aria-disabled:opacity-50", a),
159
- children: [/* @__PURE__ */ y("span", {
152
+ className: e("grid cursor-pointer grid-cols-[1rem_1fr] items-center gap-2 px-3 py-2 text-sm outline-hidden select-none", "data-highlighted:bg-muted aria-disabled:cursor-not-allowed aria-disabled:opacity-50", i),
153
+ children: [/* @__PURE__ */ b("span", {
160
154
  className: "text-primary col-start-1",
161
155
  "aria-hidden": !0,
162
- children: d && /* @__PURE__ */ y(i, {})
163
- }), /* @__PURE__ */ y("span", {
156
+ children: d && /* @__PURE__ */ b(a, {})
157
+ }), /* @__PURE__ */ b("span", {
164
158
  className: "col-start-2 truncate",
165
159
  children: o
166
160
  })]
167
161
  });
168
162
  }
169
- function E({ label: e, children: t }) {
170
- return /* @__PURE__ */ b("div", {
163
+ function D({ label: e, children: t }) {
164
+ return /* @__PURE__ */ x("div", {
171
165
  role: "group",
172
166
  "aria-label": typeof e == "string" ? e : void 0,
173
- children: [/* @__PURE__ */ y("div", {
167
+ children: [/* @__PURE__ */ b("div", {
174
168
  "aria-hidden": !0,
175
169
  className: "text-muted-foreground px-3 pt-2 pb-1 text-xs font-medium",
176
170
  children: e
177
171
  }), t]
178
172
  });
179
173
  }
180
- function D() {
181
- return /* @__PURE__ */ y("div", {
174
+ function O() {
175
+ return /* @__PURE__ */ b("div", {
182
176
  role: "separator",
183
177
  className: "bg-tint/[0.07] mx-2 my-1 h-px"
184
178
  });
185
179
  }
186
180
  //#endregion
187
- export { E as SelectGroup, T as SelectItem, D as SelectSeparator, S as default };
181
+ export { D as SelectGroup, E as SelectItem, O as SelectSeparator, C as default };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/slider/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAoC,MAAM,OAAO,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC3B,KAAK,EACL,GAAO,EACP,GAAS,EACT,IAAQ,EACR,aAAa,EACb,aAAa,EACb,eAAe,EACf,UAAU,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACV,EAAE,WAAW,+BAiDb;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CACrC,cAAc,CAAC,OAAO,CAAC,EACvB,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,cAAc,CAC1E;IACG,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iDAAiD;IACjD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACzC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/slider/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAoC,MAAM,OAAO,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAC3B,KAAK,EACL,GAAO,EACP,GAAS,EACT,IAAQ,EACR,aAAa,EACb,aAAa,EACb,eAAe,EACf,UAAU,EACV,SAAS,EACT,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACV,EAAE,WAAW,+BAkDb;AAED,MAAM,WAAW,WAAY,SAAQ,IAAI,CACrC,cAAc,CAAC,OAAO,CAAC,EACvB,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,UAAU,GAAG,cAAc,CAC1E;IACG,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,iDAAiD;IACjD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACzC"}
@@ -26,7 +26,7 @@ function i({ value: i, min: a = 0, max: o = 100, step: s = 1, onValueChange: c,
26
26
  "--zen-track": y,
27
27
  "--zen-thumb": d ?? "oklch(var(--primary))"
28
28
  },
29
- className: e("zen__slider h-5 w-full cursor-pointer appearance-none bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50", "[&::-webkit-slider-runnable-track]:h-2.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:[background:var(--zen-track)]", "[&::-moz-range-track]:h-2.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:[background:var(--zen-track)]", "[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-white [&::-webkit-slider-thumb]:shadow-[0_0_0_1px_oklch(0_0_0/0.3),0_0_16px_oklch(var(--glow)/0.8)] [&::-webkit-slider-thumb]:[background:var(--zen-thumb)]", "[&::-moz-range-thumb]:size-5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-white [&::-moz-range-thumb]:shadow-[0_0_0_1px_oklch(0_0_0/0.3),0_0_16px_oklch(var(--glow)/0.8)] [&::-moz-range-thumb]:[background:var(--zen-thumb)]", "focus-visible:[&::-webkit-slider-thumb]:ring-ring/40 focus-visible:[&::-webkit-slider-thumb]:ring-4", p),
29
+ className: e("zen__slider h-5 w-full cursor-pointer appearance-none bg-transparent outline-hidden disabled:cursor-not-allowed disabled:opacity-50", "[&::-webkit-slider-runnable-track]:h-2.5 [&::-webkit-slider-runnable-track]:rounded-full [&::-webkit-slider-runnable-track]:[background:var(--zen-track)]", "[&::-moz-range-track]:h-2.5 [&::-moz-range-track]:rounded-full [&::-moz-range-track]:[background:var(--zen-track)]", "[&::-webkit-slider-thumb]:-mt-[5px] [&::-webkit-slider-thumb]:size-5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:border-2 [&::-webkit-slider-thumb]:border-white [&::-webkit-slider-thumb]:shadow-[0_0_0_1px_oklch(0_0_0/0.3),0_0_16px_oklch(var(--glow)/0.8)] [&::-webkit-slider-thumb]:[background:var(--zen-thumb)]", "[&::-moz-range-thumb]:size-5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-2 [&::-moz-range-thumb]:border-white [&::-moz-range-thumb]:shadow-[0_0_0_1px_oklch(0_0_0/0.3),0_0_16px_oklch(var(--glow)/0.8)] [&::-moz-range-thumb]:[background:var(--zen-thumb)]", "focus-visible:[&::-webkit-slider-thumb]:ring-ring/40 focus-visible:[&::-webkit-slider-thumb]:ring-4", "focus-visible:[&::-moz-range-thumb]:ring-ring/40 focus-visible:[&::-moz-range-thumb]:ring-4", p),
30
30
  ...h
31
31
  });
32
32
  }
@@ -0,0 +1,18 @@
1
+ import { ComponentProps } from 'react';
2
+ /**
3
+ * A small rounded status that changes in place, e.g. an app's "Saving…",
4
+ * "Saved", "Not saved · Retry": an icon (a Spinner, a Check) and a few words.
5
+ * `quiet` fades it back once the news is old (a save a few seconds ago).
6
+ * Changes are read out politely (role="status"). For an action inside it,
7
+ * such as Retry, use StatusPillAction. For a fixed label or count, use Badge.
8
+ */
9
+ export default function StatusPill({ tone, quiet, className, ...rest }: StatusPillProps): import('react').JSX.Element;
10
+ /** A text button inside a StatusPill, e.g. Retry, in the pill's colour. */
11
+ export declare function StatusPillAction({ className, type, ...rest }: ComponentProps<'button'>): import('react').JSX.Element;
12
+ export interface StatusPillProps extends ComponentProps<'span'> {
13
+ /** `positive` in the accent colour (done), `negative` in red (failed); `default` is muted (in progress). */
14
+ tone?: 'default' | 'positive' | 'negative';
15
+ /** Faded back into the page: the news is old. */
16
+ quiet?: boolean;
17
+ }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/status-pill/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAQvC;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,IAAgB,EAAE,KAAa,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,eAAe,+BAa1G;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,IAAe,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,CAAC,QAAQ,CAAC,+BAWjG;AAED,MAAM,WAAW,eAAgB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAC3D,4GAA4G;IAC5G,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;IAC3C,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { cx as e } from "../utils/cx.js";
3
+ import { jsx as t } from "react/jsx-runtime";
4
+ //#region packages/status-pill/index.tsx
5
+ var n = {
6
+ default: "border-tint/10 bg-tint/[0.05] text-muted-foreground",
7
+ positive: "border-primary/35 bg-primary/12 text-primary",
8
+ negative: "border-destructive/40 bg-destructive/15 text-destructive"
9
+ };
10
+ function r({ tone: r = "default", quiet: i = !1, className: a, ...o }) {
11
+ return /* @__PURE__ */ t("span", {
12
+ role: "status",
13
+ ...o,
14
+ className: e("zen__status-pill inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium whitespace-nowrap [&_svg]:size-3.5 [&_svg]:shrink-0", "transition-[color,background-color,border-color,opacity] duration-300", i ? "text-muted-foreground border-transparent bg-transparent opacity-80" : n[r], a)
15
+ });
16
+ }
17
+ function i({ className: n, type: r = "button", ...i }) {
18
+ return /* @__PURE__ */ t("button", {
19
+ type: r,
20
+ ...i,
21
+ className: e("ml-0.5 cursor-pointer rounded-full underline underline-offset-2 outline-hidden focus-visible:ring-2 focus-visible:ring-current/50", n)
22
+ });
23
+ }
24
+ //#endregion
25
+ export { i as StatusPillAction, r as default };
@@ -15,7 +15,7 @@ function a({ hideFrom: t = "md", className: i, children: a, ...o }) {
15
15
  })
16
16
  });
17
17
  }
18
- var o = e("flex flex-col items-center gap-1 py-2.5 text-[0.7rem] outline-hidden transition-colors duration-200 focus-visible:bg-tint/5", "text-muted-foreground aria-[current=page]:text-primary [&_svg]:size-5 aria-[current=page]:[&_svg]:drop-shadow-[0_0_8px_oklch(var(--glow)/0.8)]");
18
+ var o = e("flex flex-col items-center gap-1 py-2.5 text-[0.7rem] outline-hidden transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-inset", "text-muted-foreground aria-[current=page]:text-primary [&_svg]:size-5 aria-[current=page]:[&_svg]:drop-shadow-[0_0_8px_oklch(var(--glow)/0.8)]");
19
19
  function s({ icon: n, active: a, asChild: s, className: c, children: l, ...u }) {
20
20
  let d = {
21
21
  ...u,
@@ -71,7 +71,7 @@ function g({ numeric: r, sticky: i, sortDirection: a, onSort: o, scope: s = "col
71
71
  children: o ? /* @__PURE__ */ l("button", {
72
72
  type: "button",
73
73
  onClick: o,
74
- className: e("hover:text-foreground inline-flex items-center gap-1 align-middle leading-5 tracking-wider uppercase", r && "flex-row-reverse"),
74
+ className: e("hover:text-foreground inline-flex cursor-pointer items-center gap-1 align-middle leading-5 tracking-wider uppercase", r && "flex-row-reverse"),
75
75
  children: [d, /* @__PURE__ */ c("span", {
76
76
  "aria-hidden": !0,
77
77
  className: "inline-flex w-3",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tabs/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAqE,MAAM,OAAO,CAAC;AAgB1G,6GAA6G;AAC7G,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,YAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAetG;AAID;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,OAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,+BAiC5F;AA4BD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,+BA0BnE;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,sCAapE;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,KAAK,CAAC;IACvD,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACrE,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,KAAK,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tabs/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAqE,MAAM,OAAO,CAAC;AAgB1G,6GAA6G;AAC7G,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAAE,KAAK,EAAE,YAAiB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,+BAetG;AAID;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,OAAqB,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,+BAiC5F;AAiCD,wBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,QAAQ,+BA0BnE;AAED,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,aAAa,sCAgBpE;AAED,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,OAAO,CAAC;AAEnD,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,KAAK,CAAC;IACvD,OAAO,CAAC,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACrE,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,KAAK,EAAE,MAAM,CAAC;CACjB"}
@@ -72,14 +72,18 @@ function _({ ref: t, className: r, children: i, ...a }) {
72
72
  },
73
73
  className: e("border-border relative flex gap-1 border-b", r),
74
74
  ...a,
75
- children: [i, s && /* @__PURE__ */ u("span", {
75
+ children: [i, s ? /* @__PURE__ */ u("span", {
76
76
  "aria-hidden": !0,
77
- className: "bg-primary absolute bottom-[-1px] left-0 h-0.5 transition-[translate,width] duration-150 ease-in-out",
77
+ className: "zen__tab-bar bg-primary absolute bottom-[-1px] left-0 h-0.5 transition-[translate,width] duration-150 ease-in-out",
78
78
  style: {
79
79
  width: s.w,
80
80
  translate: `${s.x}px 0`
81
81
  }
82
- })]
82
+ }, "measured") : /* @__PURE__ */ u("span", {
83
+ "aria-hidden": !0,
84
+ "data-pending": !0,
85
+ className: "zen__tab-bar hidden"
86
+ }, "pending")]
83
87
  });
84
88
  }
85
89
  function v({ value: n, className: r, onClick: i, ...a }) {
@@ -95,7 +99,7 @@ function v({ value: n, className: r, onClick: i, ...a }) {
95
99
  onClick: (e) => {
96
100
  c(n), i?.(e);
97
101
  },
98
- className: e(d === "pills" ? t : "focus-visible:ring-ring text-muted-foreground hover:text-foreground data-active:text-foreground px-3 py-2 text-sm whitespace-nowrap outline-hidden select-none focus-visible:ring-1", r),
102
+ className: e(d === "pills" ? t : "focus-visible:ring-ring text-muted-foreground hover:text-foreground data-active:text-foreground cursor-pointer px-3 py-2 text-sm whitespace-nowrap outline-hidden select-none focus-visible:ring-1 disabled:cursor-not-allowed", r),
99
103
  ...a
100
104
  });
101
105
  }
@@ -106,7 +110,7 @@ function y({ value: t, className: n, ...r }) {
106
110
  id: a("panel", t),
107
111
  "aria-labelledby": a("tab", t),
108
112
  tabIndex: 0,
109
- className: e("outline-hidden", n),
113
+ className: e("focus-visible:outline-ring/50 outline-hidden focus-visible:outline-2 focus-visible:outline-offset-4", n),
110
114
  ...r
111
115
  }) : null;
112
116
  }
@@ -1,3 +1,5 @@
1
+ import { Appearance } from '../utils/theme';
2
+ import { RefObject } from 'react';
1
3
  /** The inline script ThemeScript renders (for frameworks that take a raw string). */
2
4
  export declare const themeScript: (storageKey?: string) => string;
3
5
  /**
@@ -8,12 +10,32 @@ export declare function ThemeScript({ storageKey }: {
8
10
  storageKey?: string;
9
11
  }): import('react').JSX.Element;
10
12
  /**
11
- * Switches <html> between the dark and light themes and remembers the choice
12
- * (localStorage). Add ThemeScript to <head> to apply it on the next visit.
13
+ * Switches between the dark and light themes; the new theme spreads from the
14
+ * button like a drop of water (themeWave).
15
+ *
16
+ * On its own, it switches <html>'s class and remembers the choice (localStorage):
17
+ * add ThemeScript to <head> to apply it on the next visit. Give it `value` and
18
+ * `onChange` and the theme is yours: it shows `value` and leaves applying and
19
+ * storing the choice to `onChange` (in your state, a database, a cookie…).
20
+ * With `target` too, it switches the theme of one element (a panel, a preview),
21
+ * and the water stays inside it.
13
22
  */
14
- export default function ThemeToggle({ storageKey, className }: ThemeToggleProps): import('react').JSX.Element;
23
+ export default function ThemeToggle({ value, onChange, target, storageKey, className }: ThemeToggleProps): import('react').JSX.Element;
15
24
  export interface ThemeToggleProps {
16
- /** localStorage key for the choice. Use the same one in ThemeScript. */
25
+ /**
26
+ * The theme, when you keep it: the toggle shows it, and `onChange` must apply
27
+ * the new one (by the end of a synchronous render and its effects). Without it,
28
+ * the toggle switches <html>'s class itself.
29
+ */
30
+ value?: Appearance;
31
+ /** Called with the theme switched to. */
32
+ onChange?: (theme: Appearance) => void;
33
+ /**
34
+ * The element whose theme `onChange` switches, when it's not the page (a panel
35
+ * with its own .dark or .light): the wave plays inside it. Needs `value`.
36
+ */
37
+ target?: RefObject<HTMLElement | null>;
38
+ /** localStorage key for the choice, when the toggle keeps it. Use the same one in ThemeScript. */
17
39
  storageKey?: string;
18
40
  className?: string;
19
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/theme-toggle/index.tsx"],"names":[],"mappings":"AAKA,qFAAqF;AACrF,eAAO,MAAM,WAAW,GAAI,mBAAoB,WAC4I,CAAC;AAE7L;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,UAAoB,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,+BAE5E;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,UAAoB,EAAE,SAAS,EAAE,EAAE,gBAAgB,+BA6CxF;AAED,MAAM,WAAW,gBAAgB;IAC7B,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/theme-toggle/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,KAAK,SAAS,EAAwB,MAAM,OAAO,CAAC;AAG7D,qFAAqF;AACrF,eAAO,MAAM,WAAW,GAAI,mBAAoB,WAC4I,CAAC;AAE7L;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAAE,UAAoB,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,+BAE5E;AAiBD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAoB,EAAE,SAAS,EAAE,EAAE,gBAAgB,+BA4CjH;AAED,MAAM,WAAW,gBAAgB;IAC7B;;;;OAIG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC,kGAAkG;IAClG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -1,43 +1,50 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
- import { useEffect as t, useState as n } from "react";
4
- import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
3
+ import t from "../icons/micro/moon.js";
4
+ import n from "../icons/micro/sun.js";
5
+ import { prepareThemeWave as r, themeWave as i } from "../utils/theme-wave.js";
6
+ import { useSyncExternalStore as a } from "react";
7
+ import { jsx as o } from "react/jsx-runtime";
8
+ import { flushSync as s } from "react-dom";
5
9
  //#region packages/theme-toggle/index.tsx
6
- var o = (e = "theme") => `try{var t=localStorage.getItem(${JSON.stringify(e)}),r=document.documentElement;if(t==='light'||t==='dark'){r.classList.remove('light','dark');r.classList.add(t)}}catch(e){}`;
7
- function s({ storageKey: e = "theme" }) {
8
- return /* @__PURE__ */ i("script", { dangerouslySetInnerHTML: { __html: o(e) } });
10
+ var c = (e = "theme") => `try{var t=localStorage.getItem(${JSON.stringify(e)}),r=document.documentElement;if(t==='light'||t==='dark'){r.classList.remove('light','dark');r.classList.add(t)}}catch(e){}`;
11
+ function l({ storageKey: e = "theme" }) {
12
+ return /* @__PURE__ */ o("script", { dangerouslySetInnerHTML: { __html: c(e) } });
9
13
  }
10
- function c({ storageKey: o = "theme", className: s }) {
11
- let [c, l] = n("dark");
12
- t(() => l(document.documentElement.classList.contains("light") ? "light" : "dark"), []);
13
- let u = c === "dark" ? "light" : "dark";
14
- return /* @__PURE__ */ i("button", {
14
+ var u = /* @__PURE__ */ new Set();
15
+ function d(e) {
16
+ u.add(e);
17
+ let t = new MutationObserver(e);
18
+ return t.observe(document.documentElement, {
19
+ attributes: !0,
20
+ attributeFilter: ["class"]
21
+ }), () => {
22
+ u.delete(e), t.disconnect();
23
+ };
24
+ }
25
+ var f = () => document.documentElement.classList.contains("light") ? "light" : "dark";
26
+ function p({ value: c, onChange: l, target: p, storageKey: m = "theme", className: h }) {
27
+ let g = a(d, f, () => "dark"), _ = c ?? g, v = _ === "dark" ? "light" : "dark";
28
+ return /* @__PURE__ */ o("button", {
15
29
  type: "button",
16
- "aria-label": `Switch to ${u} theme`,
17
- onClick: () => {
18
- let e = document.documentElement;
19
- e.classList.remove("dark", "light"), e.classList.add(u);
20
- try {
21
- localStorage.setItem(o, u);
22
- } catch {}
23
- l(u);
24
- },
25
- className: e("zen__theme-toggle text-muted-foreground hover:bg-tint/[0.06] hover:text-foreground focus-visible:ring-ring/50 grid size-9 place-items-center rounded-lg outline-hidden focus-visible:ring-2", s),
26
- children: /* @__PURE__ */ i("svg", {
27
- viewBox: "0 0 16 16",
28
- fill: "none",
29
- stroke: "currentColor",
30
- strokeWidth: "1.5",
31
- strokeLinecap: "round",
32
- className: "size-4",
33
- "aria-hidden": !0,
34
- children: c === "dark" ? /* @__PURE__ */ i("path", { d: "M13.5 9.5A5.5 5.5 0 0 1 6.5 2.5a5.5 5.5 0 1 0 7 7Z" }) : /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("circle", {
35
- cx: "8",
36
- cy: "8",
37
- r: "3"
38
- }), /* @__PURE__ */ i("path", { d: "M8 1v1.5M8 13.5V15M1 8h1.5M13.5 8H15M3.05 3.05l1.06 1.06M11.89 11.89l1.06 1.06M3.05 12.95l1.06-1.06M11.89 4.11l1.06-1.06" })] })
39
- })
30
+ "aria-label": `Switch to ${v} theme`,
31
+ onPointerEnter: r,
32
+ onFocus: r,
33
+ onClick: (e) => i(() => {
34
+ if (c === void 0) {
35
+ let e = document.documentElement;
36
+ e.classList.remove("dark", "light"), e.classList.add(v);
37
+ try {
38
+ localStorage.setItem(m, v);
39
+ } catch {}
40
+ }
41
+ s(() => {
42
+ l?.(v), u.forEach((e) => e());
43
+ });
44
+ }, e.currentTarget, p?.current),
45
+ className: e("zen__theme-toggle text-muted-foreground hover:bg-tint/[0.06] hover:text-foreground focus-visible:ring-ring/50 grid size-9 cursor-pointer place-items-center rounded-lg outline-hidden focus-visible:ring-2", h),
46
+ children: o(_ === "dark" ? t : n, { className: "size-4" })
40
47
  });
41
48
  }
42
49
  //#endregion
43
- export { s as ThemeScript, c as default, o as themeScript };
50
+ export { l as ThemeScript, p as default, c as themeScript };