@rinzai/zen 0.6.1 → 0.7.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 (159) 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/button/index.d.ts +2 -1
  7. package/dist/button/index.d.ts.map +1 -1
  8. package/dist/button/index.js +43 -12
  9. package/dist/calendar/index.d.ts.map +1 -1
  10. package/dist/calendar/index.js +86 -85
  11. package/dist/chart/donut.d.ts +4 -1
  12. package/dist/chart/donut.d.ts.map +1 -1
  13. package/dist/chart/donut.js +76 -66
  14. package/dist/chart/index.d.ts +8 -2
  15. package/dist/chart/index.d.ts.map +1 -1
  16. package/dist/chart/index.js +192 -182
  17. package/dist/chart/palette.d.ts +11 -0
  18. package/dist/chart/palette.d.ts.map +1 -0
  19. package/dist/chart/palette.js +9 -0
  20. package/dist/chart/tooltip.d.ts +6 -2
  21. package/dist/chart/tooltip.d.ts.map +1 -1
  22. package/dist/chart/tooltip.js +6 -6
  23. package/dist/checkbox/index.d.ts.map +1 -1
  24. package/dist/checkbox/index.js +28 -44
  25. package/dist/chip/index.js +1 -1
  26. package/dist/code-block/index.js +1 -1
  27. package/dist/date-picker/index.d.ts.map +1 -1
  28. package/dist/date-picker/index.js +24 -38
  29. package/dist/disclosure/index.js +1 -1
  30. package/dist/editable-cell/index.js +1 -1
  31. package/dist/field/index.d.ts +1 -1
  32. package/dist/field/index.d.ts.map +1 -1
  33. package/dist/field/index.js +33 -32
  34. package/dist/header/index.d.ts +9 -1
  35. package/dist/header/index.d.ts.map +1 -1
  36. package/dist/header/index.js +17 -9
  37. package/dist/icons/arrow-left.d.ts +3 -0
  38. package/dist/icons/arrow-left.d.ts.map +1 -0
  39. package/dist/icons/arrow-right.d.ts +3 -0
  40. package/dist/icons/arrow-right.d.ts.map +1 -0
  41. package/dist/icons/bars.d.ts +3 -0
  42. package/dist/icons/bars.d.ts.map +1 -0
  43. package/dist/icons/calendar.d.ts +3 -0
  44. package/dist/icons/calendar.d.ts.map +1 -0
  45. package/dist/icons/chart-bar.d.ts +3 -0
  46. package/dist/icons/chart-bar.d.ts.map +1 -0
  47. package/dist/icons/chevron-down.d.ts.map +1 -1
  48. package/dist/icons/chevron-down.js +4 -2
  49. package/dist/icons/chevron-left.d.ts.map +1 -1
  50. package/dist/icons/chevron-left.js +4 -2
  51. package/dist/icons/chevron-right.d.ts.map +1 -1
  52. package/dist/icons/chevron-right.js +4 -2
  53. package/dist/icons/chevron-up.d.ts.map +1 -1
  54. package/dist/icons/chevron-up.js +4 -2
  55. package/dist/icons/ellipsis.d.ts +0 -1
  56. package/dist/icons/ellipsis.d.ts.map +1 -1
  57. package/dist/icons/flag.d.ts +3 -0
  58. package/dist/icons/flag.d.ts.map +1 -0
  59. package/dist/icons/list-bullet.d.ts +3 -0
  60. package/dist/icons/list-bullet.d.ts.map +1 -0
  61. package/dist/icons/lock.d.ts +3 -0
  62. package/dist/icons/lock.d.ts.map +1 -0
  63. package/dist/icons/logout.d.ts +3 -0
  64. package/dist/icons/logout.d.ts.map +1 -0
  65. package/dist/icons/micro/calendar.d.ts +3 -0
  66. package/dist/icons/micro/calendar.d.ts.map +1 -0
  67. package/dist/icons/micro/calendar.js +21 -0
  68. package/dist/icons/micro/check.d.ts +3 -0
  69. package/dist/icons/micro/check.d.ts.map +1 -0
  70. package/dist/icons/micro/check.js +21 -0
  71. package/dist/icons/micro/chevron-down.d.ts +3 -0
  72. package/dist/icons/micro/chevron-down.d.ts.map +1 -0
  73. package/dist/icons/micro/chevron-down.js +21 -0
  74. package/dist/icons/micro/chevron-right.d.ts +3 -0
  75. package/dist/icons/micro/chevron-right.d.ts.map +1 -0
  76. package/dist/icons/micro/chevron-right.js +21 -0
  77. package/dist/icons/micro/exclamation-triangle.d.ts +3 -0
  78. package/dist/icons/micro/exclamation-triangle.d.ts.map +1 -0
  79. package/dist/icons/micro/exclamation-triangle.js +21 -0
  80. package/dist/icons/micro/information-circle.d.ts +3 -0
  81. package/dist/icons/micro/information-circle.d.ts.map +1 -0
  82. package/dist/icons/micro/information-circle.js +21 -0
  83. package/dist/icons/micro/minus.d.ts +3 -0
  84. package/dist/icons/micro/minus.d.ts.map +1 -0
  85. package/dist/icons/micro/minus.js +17 -0
  86. package/dist/icons/micro/moon.d.ts +3 -0
  87. package/dist/icons/micro/moon.d.ts.map +1 -0
  88. package/dist/icons/micro/moon.js +17 -0
  89. package/dist/icons/micro/sun.d.ts +3 -0
  90. package/dist/icons/micro/sun.d.ts.map +1 -0
  91. package/dist/icons/micro/sun.js +17 -0
  92. package/dist/icons/micro/x-mark.d.ts +3 -0
  93. package/dist/icons/micro/x-mark.d.ts.map +1 -0
  94. package/dist/icons/micro/x-mark.js +17 -0
  95. package/dist/icons/search.d.ts.map +1 -1
  96. package/dist/icons/search.js +4 -2
  97. package/dist/icons/settings.d.ts +3 -0
  98. package/dist/icons/settings.d.ts.map +1 -0
  99. package/dist/icons/squares.d.ts +3 -0
  100. package/dist/icons/squares.d.ts.map +1 -0
  101. package/dist/icons/table.d.ts +3 -0
  102. package/dist/icons/table.d.ts.map +1 -0
  103. package/dist/icons/x-mark.d.ts.map +1 -1
  104. package/dist/icons/x-mark.js +4 -2
  105. package/dist/index.d.ts +6 -4
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/lib.js +56 -61
  108. package/dist/menu/index.d.ts.map +1 -1
  109. package/dist/menu/index.js +67 -60
  110. package/dist/month-picker/index.d.ts.map +1 -1
  111. package/dist/month-picker/index.js +55 -55
  112. package/dist/pills/index.d.ts +1 -1
  113. package/dist/pills/index.d.ts.map +1 -1
  114. package/dist/pills/index.js +6 -2
  115. package/dist/popover/index.js +12 -11
  116. package/dist/select/index.d.ts.map +1 -1
  117. package/dist/select/index.js +96 -102
  118. package/dist/slider/index.d.ts.map +1 -1
  119. package/dist/slider/index.js +1 -1
  120. package/dist/status-pill/index.d.ts +18 -0
  121. package/dist/status-pill/index.d.ts.map +1 -0
  122. package/dist/status-pill/index.js +25 -0
  123. package/dist/tab-bar/index.js +1 -1
  124. package/dist/table/index.js +1 -1
  125. package/dist/tabs/index.d.ts.map +1 -1
  126. package/dist/tabs/index.js +9 -5
  127. package/dist/theme-toggle/index.d.ts +2 -1
  128. package/dist/theme-toggle/index.d.ts.map +1 -1
  129. package/dist/theme-toggle/index.js +35 -32
  130. package/dist/theme.css +62 -1
  131. package/dist/toast/index.d.ts.map +1 -1
  132. package/dist/toast/index.js +119 -106
  133. package/dist/tree/index.d.ts +22 -3
  134. package/dist/tree/index.d.ts.map +1 -1
  135. package/dist/tree/index.js +76 -56
  136. package/dist/utils/date.d.ts +6 -4
  137. package/dist/utils/date.d.ts.map +1 -1
  138. package/dist/utils/date.js +18 -16
  139. package/dist/utils/field-chevron.d.ts.map +1 -1
  140. package/dist/utils/field-chevron.js +5 -14
  141. package/dist/utils/status-icons.d.ts +1 -1
  142. package/dist/utils/status-icons.d.ts.map +1 -1
  143. package/dist/utils/status-icons.js +11 -41
  144. package/dist/utils/styles.d.ts +9 -3
  145. package/dist/utils/styles.d.ts.map +1 -1
  146. package/dist/utils/styles.js +2 -2
  147. package/dist/utils/theme-wave.d.ts +24 -0
  148. package/dist/utils/theme-wave.d.ts.map +1 -0
  149. package/dist/utils/theme-wave.js +219 -0
  150. package/dist/utils/typeahead.d.ts +12 -0
  151. package/dist/utils/typeahead.d.ts.map +1 -0
  152. package/dist/utils/typeahead.js +19 -0
  153. package/dist/zen.css +1 -1
  154. package/package.json +2 -1
  155. package/dist/icons/ellipsis.js +0 -31
  156. package/dist/icons/index.d.ts +0 -9
  157. package/dist/icons/index.d.ts.map +0 -1
  158. package/dist/icons/status.d.ts +0 -2
  159. package/dist/icons/status.d.ts.map +0 -1
@@ -2,86 +2,97 @@
2
2
  import { cx as e } from "../utils/cx.js";
3
3
  import { useGraphicsMode as t } from "../utils/graphics.js";
4
4
  import { AlertIcon as n, CheckIcon as r, InfoIcon as i } from "../utils/status-icons.js";
5
- import { createContext as a, useCallback as o, useContext as s, useEffect as c, useRef as l, useState as u } from "react";
6
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
7
- import { createPortal as p } from "react-dom";
5
+ import a from "../icons/micro/x-mark.js";
6
+ import { createContext as o, useCallback as s, useContext as c, useEffect as l, useRef as u, useState as d } from "react";
7
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { createPortal as h } from "react-dom";
8
9
  //#region packages/toast/index.tsx
9
- var m = 5e3, h = 3, g = 300, _ = 14, v = .05, y = 10, b = 60, x = .45, S = a(null), C = a(null);
10
- function w({ children: n, offset: r, viewportClassName: i }) {
10
+ var g = 5e3, _ = 3, v = 300, y = 14, b = .05, x = 10, S = 60, C = .45, w = o(null), T = o(null);
11
+ function E({ children: n, offset: r, viewportClassName: i }) {
11
12
  t();
12
- let [a, s] = u([]), b = l(0), x = l(/* @__PURE__ */ new Map()), w = l(/* @__PURE__ */ new Set()), [T, D] = u([]), [O, A] = u(!1);
13
- c(() => A(!0), []);
14
- let j = o((e) => (D((t) => [...t, e]), () => D((t) => t.filter((t) => t !== e))), []), M = T.at(-1) ?? (O ? document.body : null), [N, P] = u({}), F = o((e, t) => P((n) => n[e] === t ? n : {
13
+ let [a, o] = d([]), c = u(0), f = u(/* @__PURE__ */ new Map()), S = u(/* @__PURE__ */ new Set()), [C, E] = d([]), [D, k] = d(!1);
14
+ l(() => k(!0), []);
15
+ let A = s((e) => (E((t) => [...t, e]), () => E((t) => t.filter((t) => t !== e))), []), M = C.at(-1) ?? (D ? document.body : null), [N, P] = d({}), F = s((e, t) => P((n) => n[e] === t ? n : {
15
16
  ...n,
16
17
  [e]: t
17
- }), []), [I, L] = u(!1), [R, z] = u(!1), B = o((e, t = "fade") => {
18
- s((n) => n.map((n) => n.id === e ? {
18
+ }), []), [I, L] = d(!1), [R, z] = d(!1), B = u(null), V = s((e) => {
19
+ B.current = e, O(e);
20
+ }, []);
21
+ l(() => {
22
+ let e = (e) => {
23
+ e.key === "F8" && B.current?.querySelector(".zen__toast:not([inert])") && (e.preventDefault(), B.current.focus());
24
+ };
25
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
26
+ }, []);
27
+ let H = s((e, t = "fade") => {
28
+ o((n) => n.map((n) => n.id === e ? {
19
29
  ...n,
20
30
  leaving: t
21
31
  } : n)), setTimeout(() => {
22
- s((t) => {
32
+ o((t) => {
23
33
  let n = t.filter((t) => t.id !== e);
24
34
  return n.length || L(!1), n;
25
- }), P(({ [e]: t, ...n }) => n), x.current.delete(e), w.current.delete(e);
26
- }, g);
27
- }, []), V = o((e, { description: t, tone: n = "info", action: r, timeout: i } = {}) => {
28
- let a = b.current++, o = {
35
+ }), P(({ [e]: t, ...n }) => n), f.current.delete(e), S.current.delete(e);
36
+ }, v);
37
+ }, []), U = s((e, { description: t, tone: n = "info", action: r, timeout: i } = {}) => {
38
+ let a = c.current++, s = {
29
39
  id: a,
30
40
  title: e,
31
41
  description: t,
32
42
  tone: n,
33
43
  action: r,
34
- timeout: i ?? (r ? 1e4 : m)
44
+ timeout: i ?? (r ? 1e4 : g)
35
45
  };
36
- return s((e) => [...e, o]), a;
37
- }, []), H = a.filter((e) => !e.leaving), U = (I || R) && H.length > 0, W = H.at(-1), G = W ? N[W.id] : void 0, K = H.slice(-3), q = U ? K.reduce((e, t) => e + (N[t.id] ?? 0), 0) + y * (K.length - 1) : (G ?? 0) + _ * (K.length - 1), J = (e) => {
38
- let t = H.filter((t) => t.id > e.id), n = t.length;
46
+ return o((e) => [...e, s]), a;
47
+ }, []), W = a.filter((e) => !e.leaving), G = (I || R) && W.length > 0, K = W.at(-1), q = K ? N[K.id] : void 0, J = W.slice(-3), Y = G ? J.reduce((e, t) => e + (N[t.id] ?? 0), 0) + x * (J.length - 1) : (q ?? 0) + y * (J.length - 1), X = (e) => {
48
+ let t = W.filter((t) => t.id > e.id), n = t.length;
39
49
  return {
40
50
  index: n,
41
51
  front: n === 0,
42
- hidden: n >= h,
43
- y: U ? -(t.reduce((e, t) => e + (N[t.id] ?? 0), 0) + y * n) : -14 * Math.min(n, 2),
44
- scale: U ? 1 : 1 - v * Math.min(n, 2),
45
- height: !U && n > 0 ? G : void 0
52
+ hidden: n >= _,
53
+ y: G ? -(t.reduce((e, t) => e + (N[t.id] ?? 0), 0) + x * n) : -14 * Math.min(n, 2),
54
+ scale: G ? 1 : 1 - b * Math.min(n, 2),
55
+ height: !G && n > 0 ? q : void 0
46
56
  };
47
57
  };
48
- return /* @__PURE__ */ f(S.Provider, {
49
- value: V,
50
- children: [/* @__PURE__ */ d(C.Provider, {
51
- value: j,
58
+ return /* @__PURE__ */ m(w.Provider, {
59
+ value: U,
60
+ children: [/* @__PURE__ */ p(T.Provider, {
61
+ value: A,
52
62
  children: n
53
- }), M && p(/* @__PURE__ */ d("section", {
54
- ref: E,
63
+ }), M && h(/* @__PURE__ */ p("section", {
64
+ ref: V,
55
65
  popover: "manual",
56
- "aria-label": "Notifications",
57
- "data-expanded": U || void 0,
66
+ tabIndex: -1,
67
+ "aria-label": "Notifications (F8)",
68
+ "data-expanded": G || void 0,
58
69
  onMouseEnter: () => L(!0),
59
70
  onMouseLeave: () => L(!1),
60
71
  onFocus: () => z(!0),
61
72
  onBlur: (e) => {
62
73
  e.currentTarget.contains(e.relatedTarget) || z(!1);
63
74
  },
64
- className: e("zen__toast-viewport fixed top-auto right-4 bottom-[calc(var(--zen-toast-offset,1rem)+env(safe-area-inset-bottom))] left-auto z-50 m-0 w-[calc(100vw-2rem)] overflow-visible border-0 bg-transparent p-0 text-inherit md:bottom-5 md:w-[24rem]", "transition-[height] duration-300 ease-[cubic-bezier(0.2,0.8,0.2,1)]", i),
75
+ className: e("zen__toast-viewport fixed top-auto right-4 bottom-[calc(var(--zen-toast-offset,1rem)+env(safe-area-inset-bottom))] left-auto z-50 m-0 w-[calc(100vw-2rem)] overflow-visible border-0 bg-transparent p-0 text-inherit outline-hidden md:bottom-5 md:w-[24rem]", "transition-[height] duration-300 ease-[cubic-bezier(0.2,0.8,0.2,1)]", i),
65
76
  style: {
66
- height: q,
77
+ height: Y,
67
78
  ...r && { "--zen-toast-offset": r }
68
79
  },
69
- children: a.map((e, t) => /* @__PURE__ */ d(k, {
80
+ children: a.map((e, t) => /* @__PURE__ */ p(j, {
70
81
  toast: e,
71
- layout: J(e),
82
+ layout: X(e),
72
83
  z: t + 1,
73
- paused: U,
74
- onDismiss: B,
84
+ paused: G,
85
+ onDismiss: H,
75
86
  onHeight: F,
76
- clocks: x.current,
77
- entered: w.current
87
+ clocks: f.current,
88
+ entered: S.current
78
89
  }, e.id))
79
90
  }), M)]
80
91
  });
81
92
  }
82
- function T(e, t) {
83
- let n = s(C);
84
- c(() => {
93
+ function D(e, t) {
94
+ let n = c(T);
95
+ l(() => {
85
96
  let r = e.current;
86
97
  if (n && t && r) return n(r);
87
98
  }, [
@@ -90,17 +101,17 @@ function T(e, t) {
90
101
  e
91
102
  ]);
92
103
  }
93
- function E(e) {
104
+ function O(e) {
94
105
  if (e?.showPopover) try {
95
106
  e.showPopover();
96
107
  } catch {}
97
108
  }
98
- function D() {
99
- let e = s(S);
109
+ function k() {
110
+ let e = c(w);
100
111
  if (!e) throw Error("useToast() needs a <ToastProvider> above it");
101
112
  return e;
102
113
  }
103
- var O = {
114
+ var A = {
104
115
  success: {
105
116
  icon: r,
106
117
  ring: "border-primary/30",
@@ -123,126 +134,128 @@ var O = {
123
134
  glow: "shadow-[var(--toast-shadow)]"
124
135
  }
125
136
  };
126
- function k({ toast: t, layout: n, z: r, paused: i, onDismiss: a, onHeight: o, clocks: s, entered: p }) {
127
- let m = O[t.tone] ?? O.info, h = m.icon, g = l(null), _ = l(null), [v] = u(() => !p.has(t.id));
128
- c(() => {
129
- g.current?.isConnected && p.add(t.id);
130
- }, [p, t.id]), s.has(t.id) || s.set(t.id, {
137
+ function j({ toast: t, layout: n, z: r, paused: i, onDismiss: o, onHeight: s, clocks: c, entered: h }) {
138
+ let g = A[t.tone] ?? A.info, _ = g.icon, v = u(null), y = u(null), [b] = d(() => !h.has(t.id));
139
+ l(() => {
140
+ v.current?.isConnected && h.add(t.id);
141
+ }, [h, t.id]);
142
+ let [x, w] = d(!1);
143
+ l(() => {
144
+ if (!b) return;
145
+ let e = requestAnimationFrame(() => e = requestAnimationFrame(() => w(!0)));
146
+ return () => cancelAnimationFrame(e);
147
+ }, [b]), c.has(t.id) || c.set(t.id, {
131
148
  spent: 0,
132
149
  since: null
133
150
  });
134
- let y = s.get(t.id), [S] = u(() => y.spent + (y.since === null ? 0 : Date.now() - y.since));
135
- c(() => {
136
- let e = _.current;
151
+ let T = c.get(t.id), [E] = d(() => T.spent + (T.since === null ? 0 : Date.now() - T.since));
152
+ l(() => {
153
+ let e = y.current;
137
154
  if (!e) return;
138
- let n = () => o(t.id, e.offsetHeight);
155
+ let n = () => s(t.id, e.offsetHeight);
139
156
  n();
140
157
  let r = new ResizeObserver(n);
141
158
  return r.observe(e), () => r.disconnect();
142
- }, [o, t.id]), c(() => {
159
+ }, [s, t.id]), l(() => {
143
160
  if (!t.timeout || i || t.leaving) return;
144
- y.since = Date.now();
145
- let e = setTimeout(() => a(t.id), Math.max(0, t.timeout - y.spent));
161
+ T.since = Date.now();
162
+ let e = setTimeout(() => o(t.id), Math.max(0, t.timeout - T.spent));
146
163
  return () => {
147
- clearTimeout(e), y.since !== null && (y.spent += Date.now() - y.since), y.since = null;
164
+ clearTimeout(e), T.since !== null && (T.spent += Date.now() - T.since), T.since = null;
148
165
  };
149
166
  }, [
150
167
  i,
151
168
  t.id,
152
169
  t.timeout,
153
170
  t.leaving,
154
- a,
155
- y
171
+ o,
172
+ T
156
173
  ]);
157
- let C = l(null), w = (e) => {
158
- t.leaving || e.button !== 0 || e.target.closest("button") || (C.current = {
174
+ let D = u(null), O = (e) => {
175
+ t.leaving || e.button !== 0 || e.target.closest("button") || (D.current = {
159
176
  x: e.clientX,
160
177
  dx: 0,
161
178
  t: e.timeStamp,
162
179
  speed: 0
163
180
  }, e.currentTarget.setPointerCapture(e.pointerId), e.currentTarget.dataset.swiping = "");
164
- }, T = (e) => {
165
- if (!C.current) return;
166
- let t = C.current, n = e.clientX - t.x;
181
+ }, k = (e) => {
182
+ if (!D.current) return;
183
+ let t = D.current, n = e.clientX - t.x;
167
184
  t.speed = (n - t.dx) / Math.max(1, e.timeStamp - t.t), t.dx = n, t.t = e.timeStamp, e.currentTarget.style.setProperty("--zen-swipe", `${n > 0 ? n : n / 6}px`);
168
- }, E = (e) => {
169
- let n = C.current;
170
- n && (C.current = null, delete e.currentTarget.dataset.swiping, n.dx > b || n.dx > 0 && n.speed > x ? a(t.id, "swipe") : e.currentTarget.style.setProperty("--zen-swipe", "0px"));
185
+ }, j = (e) => {
186
+ let n = D.current;
187
+ n && (D.current = null, delete e.currentTarget.dataset.swiping, n.dx > S || n.dx > 0 && n.speed > C ? o(t.id, "swipe") : e.currentTarget.style.setProperty("--zen-swipe", "0px"));
171
188
  };
172
- return /* @__PURE__ */ f("div", {
173
- ref: g,
189
+ return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("div", {
190
+ ref: v,
174
191
  role: t.tone === "error" ? "alert" : "status",
175
- "aria-atomic": "true",
192
+ "aria-live": "off",
176
193
  "data-front": n.front || void 0,
177
194
  "data-behind": !n.front && n.height !== void 0 || void 0,
178
195
  inert: n.hidden || !!t.leaving,
179
- onPointerDown: w,
180
- onPointerMove: T,
181
- onPointerUp: E,
182
- onPointerCancel: E,
183
- className: e("zen__toast group glass glass-blur glow-edge text-card-foreground absolute! inset-x-0 bottom-0 origin-bottom touch-pan-y overflow-hidden rounded-2xl border select-none", "transition-[transform,translate,opacity,height] duration-400 ease-[cubic-bezier(0.2,0.8,0.2,1)] data-swiping:transition-none", v && "starting:translate-y-full starting:opacity-0", n.hidden && "opacity-0", t.leaving === "fade" && "translate-y-[35%] opacity-0", t.leaving === "swipe" && "translate-x-full opacity-0", m.ring, m.glow),
196
+ onPointerDown: O,
197
+ onPointerMove: k,
198
+ onPointerUp: j,
199
+ onPointerCancel: j,
200
+ className: e("zen__toast group glass glass-blur glow-edge text-card-foreground absolute! inset-x-0 bottom-0 origin-bottom touch-pan-y overflow-hidden rounded-2xl border select-none", "transition-[transform,translate,opacity,height] duration-400 ease-[cubic-bezier(0.2,0.8,0.2,1)] data-swiping:transition-none", b && "starting:translate-y-full starting:opacity-0", n.hidden && "opacity-0", t.leaving === "fade" && "translate-y-[35%] opacity-0", t.leaving === "swipe" && "translate-x-full opacity-0", g.ring, g.glow),
184
201
  style: {
185
202
  zIndex: r,
186
203
  height: n.height,
187
204
  transform: `translateX(var(--zen-swipe, 0px)) translateY(${n.y}px) scale(${n.scale})`
188
205
  },
189
- children: [/* @__PURE__ */ f("div", {
190
- ref: _,
206
+ children: [/* @__PURE__ */ m("div", {
207
+ ref: y,
191
208
  className: "flex items-start gap-3 p-3.5 pr-10 transition-opacity duration-300 group-data-behind:opacity-0",
192
209
  children: [
193
- /* @__PURE__ */ d("span", {
194
- className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full", m.badge),
210
+ /* @__PURE__ */ p("span", {
211
+ className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full", g.badge),
195
212
  "aria-hidden": !0,
196
- children: /* @__PURE__ */ d(h, { className: "size-4" })
213
+ children: /* @__PURE__ */ p(_, { className: "size-4" })
197
214
  }),
198
- /* @__PURE__ */ f("div", {
215
+ /* @__PURE__ */ m("div", {
199
216
  className: "flex min-w-0 flex-1 flex-col gap-0.5 pt-0.5",
200
217
  children: [
201
- /* @__PURE__ */ d("div", {
218
+ /* @__PURE__ */ p("div", {
202
219
  className: "text-sm font-semibold",
203
220
  children: t.title
204
221
  }),
205
- t.description && /* @__PURE__ */ d("div", {
222
+ t.description && /* @__PURE__ */ p("div", {
206
223
  className: "text-muted-foreground text-sm leading-5",
207
224
  children: t.description
208
225
  }),
209
- t.action && /* @__PURE__ */ d("button", {
226
+ t.action && /* @__PURE__ */ p("button", {
210
227
  type: "button",
211
228
  onClick: () => {
212
- t.action?.onClick(), a(t.id);
229
+ t.action?.onClick(), o(t.id);
213
230
  },
214
- className: "border-tint/10 bg-tint/[0.06] hover:bg-tint/[0.12] focus-visible:ring-ring/50 mt-2 self-start rounded-lg border px-3 py-1 text-xs font-medium outline-hidden transition-colors focus-visible:ring-2",
231
+ className: "border-tint/10 bg-tint/[0.06] hover:bg-tint/[0.12] focus-visible:ring-ring/50 mt-2 cursor-pointer self-start rounded-lg border px-3 py-1 text-xs font-medium outline-hidden transition-colors focus-visible:ring-2",
215
232
  children: t.action.label
216
233
  })
217
234
  ]
218
235
  }),
219
- /* @__PURE__ */ d("button", {
236
+ /* @__PURE__ */ p("button", {
220
237
  type: "button",
221
238
  "aria-label": "Dismiss",
222
- onClick: () => a(t.id),
223
- className: "text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-visible:ring-ring/50 absolute top-2.5 right-2.5 grid size-7 place-items-center rounded-lg outline-hidden transition-colors focus-visible:ring-2",
224
- children: /* @__PURE__ */ d("svg", {
225
- viewBox: "0 0 16 16",
226
- fill: "none",
227
- stroke: "currentColor",
228
- strokeWidth: "1.8",
229
- strokeLinecap: "round",
230
- className: "size-3.5",
231
- "aria-hidden": !0,
232
- children: /* @__PURE__ */ d("path", { d: "m4 4 8 8M12 4l-8 8" })
233
- })
239
+ onClick: () => o(t.id),
240
+ className: "text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-visible:ring-ring/50 absolute top-2.5 right-2.5 grid size-7 cursor-pointer place-items-center rounded-lg outline-hidden transition-colors focus-visible:ring-2",
241
+ children: /* @__PURE__ */ p(a, { className: "size-3.5" })
234
242
  })
235
243
  ]
236
- }), t.timeout > 0 && /* @__PURE__ */ d("span", {
244
+ }), t.timeout > 0 && /* @__PURE__ */ p("span", {
237
245
  "aria-hidden": !0,
238
- className: e("zen__toast-timer absolute bottom-0 left-0 h-0.5 w-full origin-left opacity-60 transition-opacity group-data-behind:opacity-0", m.bar),
246
+ className: e("zen__toast-timer absolute bottom-0 left-0 h-0.5 w-full origin-left opacity-60 transition-opacity group-data-behind:opacity-0", g.bar),
239
247
  style: {
240
248
  animationDuration: `${t.timeout}ms`,
241
- animationDelay: `${-S}ms`,
249
+ animationDelay: `${-E}ms`,
242
250
  animationPlayState: i ? "paused" : void 0
243
251
  }
244
252
  })]
245
- });
253
+ }), /* @__PURE__ */ p("span", {
254
+ className: "sr-only",
255
+ "aria-live": t.tone === "error" ? "assertive" : "polite",
256
+ "aria-atomic": "true",
257
+ children: x && [t.title, t.description].filter(Boolean).join(". ")
258
+ })] });
246
259
  }
247
260
  //#endregion
248
- export { w as default, D as useToast, T as useToastHost };
261
+ export { E as default, k as useToast, D as useToastHost };
@@ -1,5 +1,5 @@
1
1
  import { TableCellProps } from '../table';
2
- import { ComponentProps, CSSProperties, ReactNode } from 'react';
2
+ import { ComponentProps, CSSProperties, FocusEvent, KeyboardEvent, ReactNode } from 'react';
3
3
  /** One visible row of a tree. */
4
4
  export interface TreeRowData<T> {
5
5
  item: T;
@@ -9,11 +9,19 @@ export interface TreeRowData<T> {
9
9
  parentKey: string | null;
10
10
  hasChildren: boolean;
11
11
  expanded: boolean;
12
+ /** Its place among its siblings (1-based), and how many siblings there are. */
13
+ position: number;
14
+ siblings: number;
12
15
  }
13
16
  /**
14
17
  * Headless tree for tables and lists: turns nested items into the rows that
15
18
  * are visible (children of collapsed rows are skipped), and expands/collapses
16
19
  * them. With the Tree* parts, children grow in and shrink away smoothly.
20
+ *
21
+ * Put `tree.tableProps` on the Table: it's then a tree grid (WAI-ARIA), one tab
22
+ * stop whose rows the keyboard moves between. Up and Down go row to row, Home
23
+ * and End to the first and last, Right opens a row (or goes to its first
24
+ * child), Left closes it (or goes to its parent).
17
25
  */
18
26
  export declare function useTree<T>({ items, getKey, getChildren, defaultExpanded, rowHeight }: UseTreeOptions<T>): {
19
27
  rows: TreeRowData<T>[];
@@ -25,10 +33,20 @@ export declare function useTree<T>({ items, getKey, getChildren, defaultExpanded
25
33
  expandAll: () => void;
26
34
  /** Closes every row. */
27
35
  collapseAll: () => void;
36
+ /** For the Table: a tree grid. */
37
+ tableProps: {
38
+ role: "treegrid";
39
+ };
28
40
  rowProps: (row: TreeRowData<T>) => {
29
41
  'aria-level': number;
30
42
  'aria-expanded': boolean | undefined;
43
+ 'aria-posinset': number;
44
+ 'aria-setsize': number;
31
45
  'data-depth': number;
46
+ 'data-tree-key': string;
47
+ tabIndex: number;
48
+ onFocus: (e: FocusEvent<HTMLElement>) => void;
49
+ onKeyDown: (e: KeyboardEvent<HTMLElement>) => void;
32
50
  className: string;
33
51
  style: CSSProperties;
34
52
  onAnimationEnd: (e: {
@@ -38,12 +56,13 @@ export declare function useTree<T>({ items, getKey, getChildren, defaultExpanded
38
56
  toggleProps: (row: TreeRowData<T>) => {
39
57
  expanded: boolean;
40
58
  onToggle: () => void;
59
+ tabIndex: number;
41
60
  };
42
61
  rowHeight: number;
43
62
  };
44
63
  export type Tree<T> = ReturnType<typeof useTree<T>>;
45
- /** A table row wired to useTree: tree semantics (aria-level, aria-expanded) and the open/close animation. */
46
- export declare function TreeRow<T>({ row, tree, className, style, ...rest }: TreeRowProps<T>): import('react').JSX.Element;
64
+ /** A table row wired to useTree: tree semantics, the keyboard and the open/close animation. */
65
+ export declare function TreeRow<T>({ row, tree, className, style, onFocus, onKeyDown, ...rest }: TreeRowProps<T>): import('react').JSX.Element;
47
66
  /** A cell in a TreeRow: its content sits in a box whose height animates as groups open and close. */
48
67
  export declare function TreeCell({ numeric, className, children, ...rest }: TableCellProps): import('react').JSX.Element;
49
68
  /** The first column's content: indented by depth, with the row's toggle (or a spacer, so labels line up). */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tree/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAY,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,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,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACxB"}
@@ -1,39 +1,42 @@
1
1
  "use client";
2
2
  import { cx as e } from "../utils/cx.js";
3
3
  import { TableCell as t, TableRow as n } from "../table/index.js";
4
- import { useCallback as r, useMemo as i, useRef as a, useState as o } from "react";
5
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
4
+ import r from "../icons/micro/chevron-right.js";
5
+ import { useCallback as i, useMemo as a, useRef as o, useState as s } from "react";
6
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
6
7
  //#region packages/tree/index.tsx
7
- function l({ items: t, getKey: n, getChildren: s, defaultExpanded: c = !0, rowHeight: l = 36 }) {
8
- let [u, d] = o(() => /* @__PURE__ */ new Set()), [f, p] = o(null), [m, h] = o(null), g = a(null), _ = r((e) => u.has(e) !== c, [u, c]), v = i(() => {
9
- let e = [], r = (t, i, a) => {
10
- for (let o of t) {
11
- let t = n(o), c = s(o), l = !!c?.length, u = l && _(t);
8
+ function u({ items: t, getKey: n, getChildren: r, defaultExpanded: c = !0, rowHeight: l = 36 }) {
9
+ let [u, d] = s(() => /* @__PURE__ */ new Set()), [f, p] = s(null), [m, h] = s(null), g = o(null), _ = i((e) => u.has(e) !== c, [u, c]), v = a(() => {
10
+ let e = [], i = (t, a, o) => {
11
+ t.forEach((s, c) => {
12
+ let l = n(s), u = r(s), d = !!u?.length, f = d && _(l);
12
13
  e.push({
13
- item: o,
14
- key: t,
15
- depth: i,
16
- parentKey: a,
17
- hasChildren: l,
18
- expanded: u
19
- }), u && r(c, i + 1, t);
20
- }
14
+ item: s,
15
+ key: l,
16
+ depth: a,
17
+ parentKey: o,
18
+ hasChildren: d,
19
+ expanded: f,
20
+ position: c + 1,
21
+ siblings: t.length
22
+ }), f && i(u, a + 1, l);
23
+ });
21
24
  };
22
- return r(t, 0, null), e;
25
+ return i(t, 0, null), e;
23
26
  }, [
24
27
  t,
25
28
  n,
26
- s,
29
+ r,
27
30
  _
28
31
  ]), y = () => {
29
- let e = [], r = (t) => {
30
- for (let i of t) {
31
- let t = s(i);
32
- t?.length && (e.push(n(i)), r(t));
32
+ let e = [], i = (t) => {
33
+ for (let a of t) {
34
+ let t = r(a);
35
+ t?.length && (e.push(n(a)), i(t));
33
36
  }
34
37
  };
35
- return r(t), e;
36
- }, b = r((e, t) => d((n) => {
38
+ return i(t), e;
39
+ }, b = i((e, t) => d((n) => {
37
40
  let r = new Set(n);
38
41
  return t === c ? r.delete(e) : r.add(e), r;
39
42
  }), [c]), x = () => typeof window < "u" && (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || document.documentElement.classList.contains("reduce-motion")), S = (e) => {
@@ -54,6 +57,17 @@ function l({ items: t, getKey: n, getChildren: s, defaultExpanded: c = !0, rowHe
54
57
  };
55
58
  g.current = t, setTimeout(t, 500);
56
59
  }
60
+ }, [C, w] = s(null), T = v.some((e) => e.key === C) ? C : v[0]?.key ?? null, E = (e) => e.expanded && m !== e.key, D = (e, t) => {
61
+ if (t.target !== t.currentTarget) return;
62
+ let n = v.indexOf(e), r;
63
+ if (t.key === "ArrowDown") r = v[n + 1];
64
+ else if (t.key === "ArrowUp") r = v[n - 1];
65
+ else if (t.key === "Home") r = v[0];
66
+ else if (t.key === "End") r = v.at(-1);
67
+ else if (t.key === "ArrowRight" && e.hasChildren) E(e) ? r = v[n + 1] : S(e.key);
68
+ else if (t.key === "ArrowLeft") E(e) ? S(e.key) : r = v.find((t) => t.key === e.parentKey);
69
+ else return;
70
+ t.preventDefault(), r && t.currentTarget.closest("[role=\"treegrid\"], table")?.querySelector(`[data-tree-key="${CSS.escape(r.key)}"]`)?.focus();
57
71
  };
58
72
  return {
59
73
  rows: v,
@@ -63,73 +77,79 @@ function l({ items: t, getKey: n, getChildren: s, defaultExpanded: c = !0, rowHe
63
77
  collapse: (e) => b(e, !1),
64
78
  expandAll: () => d(c ? /* @__PURE__ */ new Set() : new Set(y())),
65
79
  collapseAll: () => d(c ? new Set(y()) : /* @__PURE__ */ new Set()),
80
+ tableProps: { role: "treegrid" },
66
81
  rowProps: (t) => ({
67
82
  "aria-level": t.depth + 1,
68
- "aria-expanded": t.hasChildren ? t.expanded : void 0,
83
+ "aria-expanded": t.hasChildren ? E(t) : void 0,
84
+ "aria-posinset": t.position,
85
+ "aria-setsize": t.siblings,
69
86
  "data-depth": t.depth,
70
- className: e(f && t.parentKey === f.key && "zen__tree-row-enter", m && t.parentKey === m && "zen__tree-row-exit"),
87
+ "data-tree-key": t.key,
88
+ tabIndex: t.key === T ? 0 : -1,
89
+ onFocus: (e) => {
90
+ e.target === e.currentTarget && w(t.key);
91
+ },
92
+ onKeyDown: (e) => D(t, e),
93
+ className: e("outline-hidden focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring/60", f && t.parentKey === f.key && "zen__tree-row-enter", m && t.parentKey === m && "zen__tree-row-exit"),
71
94
  style: { "--row-h": `${l - 1}px` },
72
95
  onAnimationEnd: (e) => {
73
96
  e.animationName === "zen-row-close" && m && t.parentKey === m && g.current?.();
74
97
  }
75
98
  }),
76
99
  toggleProps: (e) => ({
77
- expanded: e.expanded && m !== e.key,
78
- onToggle: () => S(e.key)
100
+ expanded: E(e),
101
+ onToggle: () => S(e.key),
102
+ tabIndex: -1
79
103
  }),
80
104
  rowHeight: l
81
105
  };
82
106
  }
83
- function u({ row: t, tree: r, className: i, style: a, ...o }) {
84
- let c = r.rowProps(t);
85
- return /* @__PURE__ */ s(n, {
86
- ...o,
87
- ...c,
88
- className: e(c.className, i),
107
+ function d({ row: t, tree: r, className: i, style: a, onFocus: o, onKeyDown: s, ...l }) {
108
+ let u = r.rowProps(t);
109
+ return /* @__PURE__ */ c(n, {
110
+ ...l,
111
+ ...u,
112
+ onFocus: (e) => {
113
+ o?.(e), u.onFocus(e);
114
+ },
115
+ onKeyDown: (e) => {
116
+ s?.(e), e.defaultPrevented || u.onKeyDown(e);
117
+ },
118
+ className: e(u.className, i),
89
119
  style: {
90
- ...c.style,
120
+ ...u.style,
91
121
  ...a
92
122
  }
93
123
  });
94
124
  }
95
- function d({ numeric: n, className: r, children: i, ...a }) {
96
- return /* @__PURE__ */ s(t, {
125
+ function f({ numeric: n, className: r, children: i, ...a }) {
126
+ return /* @__PURE__ */ c(t, {
97
127
  numeric: n,
98
128
  className: e("py-0 whitespace-nowrap", r),
99
129
  ...a,
100
- children: /* @__PURE__ */ s("div", {
130
+ children: /* @__PURE__ */ c("div", {
101
131
  className: e("zen__tree-cell flex h-[var(--row-h)] items-center", n && "justify-end"),
102
132
  children: i
103
133
  })
104
134
  });
105
135
  }
106
- function f({ row: t, tree: n, indent: r = 20, children: i, className: a }) {
107
- return /* @__PURE__ */ c("div", {
136
+ function p({ row: t, tree: n, indent: r = 20, children: i, className: a }) {
137
+ return /* @__PURE__ */ l("div", {
108
138
  className: e("flex min-w-0 flex-1 items-center gap-1", a),
109
139
  style: { paddingLeft: t.depth * r },
110
- children: [t.hasChildren ? /* @__PURE__ */ s(p, { ...n.toggleProps(t) }) : /* @__PURE__ */ s("span", { className: "-ml-1 w-6 shrink-0" }), i]
140
+ children: [t.hasChildren ? /* @__PURE__ */ c(m, { ...n.toggleProps(t) }) : /* @__PURE__ */ c("span", { className: "-ml-1 w-6 shrink-0" }), i]
111
141
  });
112
142
  }
113
- function p({ expanded: t, onToggle: n, className: r, ...i }) {
114
- return /* @__PURE__ */ s("button", {
143
+ function m({ expanded: t, onToggle: n, className: i, ...a }) {
144
+ return /* @__PURE__ */ c("button", {
115
145
  type: "button",
116
146
  onClick: n,
117
147
  "aria-label": t ? "Collapse" : "Expand",
118
148
  "aria-expanded": t,
119
- className: e("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground focus-visible:ring-ring/50 -ml-1 grid size-6 shrink-0 place-items-center rounded-md outline-hidden transition-colors focus-visible:ring-2", r),
120
- ...i,
121
- children: /* @__PURE__ */ s("svg", {
122
- viewBox: "0 0 16 16",
123
- fill: "none",
124
- stroke: "currentColor",
125
- strokeWidth: "2",
126
- strokeLinecap: "round",
127
- strokeLinejoin: "round",
128
- "aria-hidden": !0,
129
- className: e("size-4 transition-transform duration-200 ease-out", t && "rotate-90"),
130
- children: /* @__PURE__ */ s("path", { d: "m6 3.5 4.5 4.5L6 12.5" })
131
- })
149
+ className: e("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground focus-visible:ring-ring/50 -ml-1 grid size-6 shrink-0 cursor-pointer place-items-center rounded-md outline-hidden transition-colors focus-visible:ring-2", i),
150
+ ...a,
151
+ children: /* @__PURE__ */ c(r, { className: e("size-4 transition-transform duration-200 ease-out", t && "rotate-90") })
132
152
  });
133
153
  }
134
154
  //#endregion
135
- export { d as TreeCell, f as TreeLabel, u as TreeRow, p as TreeToggle, l as useTree };
155
+ export { f as TreeCell, p as TreeLabel, d as TreeRow, m as TreeToggle, u as useTree };