@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.
- package/LICENSE +27 -0
- package/README.md +3 -3
- package/dist/alert/index.d.ts +21 -0
- package/dist/alert/index.d.ts.map +1 -0
- package/dist/alert/index.js +49 -0
- package/dist/button/index.d.ts +2 -1
- package/dist/button/index.d.ts.map +1 -1
- package/dist/button/index.js +43 -12
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +86 -85
- package/dist/chart/donut.d.ts +4 -1
- package/dist/chart/donut.d.ts.map +1 -1
- package/dist/chart/donut.js +76 -66
- package/dist/chart/index.d.ts +8 -2
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.js +192 -182
- package/dist/chart/palette.d.ts +11 -0
- package/dist/chart/palette.d.ts.map +1 -0
- package/dist/chart/palette.js +9 -0
- package/dist/chart/tooltip.d.ts +6 -2
- package/dist/chart/tooltip.d.ts.map +1 -1
- package/dist/chart/tooltip.js +6 -6
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/checkbox/index.js +28 -44
- package/dist/chip/index.js +1 -1
- package/dist/code-block/index.js +1 -1
- package/dist/date-picker/index.d.ts.map +1 -1
- package/dist/date-picker/index.js +24 -38
- package/dist/disclosure/index.js +1 -1
- package/dist/editable-cell/index.js +1 -1
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +33 -32
- package/dist/header/index.d.ts +9 -1
- package/dist/header/index.d.ts.map +1 -1
- package/dist/header/index.js +17 -9
- package/dist/icons/arrow-left.d.ts +3 -0
- package/dist/icons/arrow-left.d.ts.map +1 -0
- package/dist/icons/arrow-right.d.ts +3 -0
- package/dist/icons/arrow-right.d.ts.map +1 -0
- package/dist/icons/bars.d.ts +3 -0
- package/dist/icons/bars.d.ts.map +1 -0
- package/dist/icons/calendar.d.ts +3 -0
- package/dist/icons/calendar.d.ts.map +1 -0
- package/dist/icons/chart-bar.d.ts +3 -0
- package/dist/icons/chart-bar.d.ts.map +1 -0
- package/dist/icons/chevron-down.d.ts.map +1 -1
- package/dist/icons/chevron-down.js +4 -2
- package/dist/icons/chevron-left.d.ts.map +1 -1
- package/dist/icons/chevron-left.js +4 -2
- package/dist/icons/chevron-right.d.ts.map +1 -1
- package/dist/icons/chevron-right.js +4 -2
- package/dist/icons/chevron-up.d.ts.map +1 -1
- package/dist/icons/chevron-up.js +4 -2
- package/dist/icons/ellipsis.d.ts +0 -1
- package/dist/icons/ellipsis.d.ts.map +1 -1
- package/dist/icons/flag.d.ts +3 -0
- package/dist/icons/flag.d.ts.map +1 -0
- package/dist/icons/list-bullet.d.ts +3 -0
- package/dist/icons/list-bullet.d.ts.map +1 -0
- package/dist/icons/lock.d.ts +3 -0
- package/dist/icons/lock.d.ts.map +1 -0
- package/dist/icons/logout.d.ts +3 -0
- package/dist/icons/logout.d.ts.map +1 -0
- package/dist/icons/micro/calendar.d.ts +3 -0
- package/dist/icons/micro/calendar.d.ts.map +1 -0
- package/dist/icons/micro/calendar.js +21 -0
- package/dist/icons/micro/check.d.ts +3 -0
- package/dist/icons/micro/check.d.ts.map +1 -0
- package/dist/icons/micro/check.js +21 -0
- package/dist/icons/micro/chevron-down.d.ts +3 -0
- package/dist/icons/micro/chevron-down.d.ts.map +1 -0
- package/dist/icons/micro/chevron-down.js +21 -0
- package/dist/icons/micro/chevron-right.d.ts +3 -0
- package/dist/icons/micro/chevron-right.d.ts.map +1 -0
- package/dist/icons/micro/chevron-right.js +21 -0
- package/dist/icons/micro/exclamation-triangle.d.ts +3 -0
- package/dist/icons/micro/exclamation-triangle.d.ts.map +1 -0
- package/dist/icons/micro/exclamation-triangle.js +21 -0
- package/dist/icons/micro/information-circle.d.ts +3 -0
- package/dist/icons/micro/information-circle.d.ts.map +1 -0
- package/dist/icons/micro/information-circle.js +21 -0
- package/dist/icons/micro/minus.d.ts +3 -0
- package/dist/icons/micro/minus.d.ts.map +1 -0
- package/dist/icons/micro/minus.js +17 -0
- package/dist/icons/micro/moon.d.ts +3 -0
- package/dist/icons/micro/moon.d.ts.map +1 -0
- package/dist/icons/micro/moon.js +17 -0
- package/dist/icons/micro/sun.d.ts +3 -0
- package/dist/icons/micro/sun.d.ts.map +1 -0
- package/dist/icons/micro/sun.js +17 -0
- package/dist/icons/micro/x-mark.d.ts +3 -0
- package/dist/icons/micro/x-mark.d.ts.map +1 -0
- package/dist/icons/micro/x-mark.js +17 -0
- package/dist/icons/search.d.ts.map +1 -1
- package/dist/icons/search.js +4 -2
- package/dist/icons/settings.d.ts +3 -0
- package/dist/icons/settings.d.ts.map +1 -0
- package/dist/icons/squares.d.ts +3 -0
- package/dist/icons/squares.d.ts.map +1 -0
- package/dist/icons/table.d.ts +3 -0
- package/dist/icons/table.d.ts.map +1 -0
- package/dist/icons/x-mark.d.ts.map +1 -1
- package/dist/icons/x-mark.js +4 -2
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/lib.js +56 -61
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +67 -60
- package/dist/month-picker/index.d.ts.map +1 -1
- package/dist/month-picker/index.js +55 -55
- package/dist/pills/index.d.ts +1 -1
- package/dist/pills/index.d.ts.map +1 -1
- package/dist/pills/index.js +6 -2
- package/dist/popover/index.js +12 -11
- package/dist/select/index.d.ts.map +1 -1
- package/dist/select/index.js +96 -102
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +1 -1
- package/dist/status-pill/index.d.ts +18 -0
- package/dist/status-pill/index.d.ts.map +1 -0
- package/dist/status-pill/index.js +25 -0
- package/dist/tab-bar/index.js +1 -1
- package/dist/table/index.js +1 -1
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +9 -5
- package/dist/theme-toggle/index.d.ts +2 -1
- package/dist/theme-toggle/index.d.ts.map +1 -1
- package/dist/theme-toggle/index.js +35 -32
- package/dist/theme.css +62 -1
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +119 -106
- package/dist/tree/index.d.ts +22 -3
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +76 -56
- package/dist/utils/date.d.ts +6 -4
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +18 -16
- package/dist/utils/field-chevron.d.ts.map +1 -1
- package/dist/utils/field-chevron.js +5 -14
- package/dist/utils/status-icons.d.ts +1 -1
- package/dist/utils/status-icons.d.ts.map +1 -1
- package/dist/utils/status-icons.js +11 -41
- package/dist/utils/styles.d.ts +9 -3
- package/dist/utils/styles.d.ts.map +1 -1
- package/dist/utils/styles.js +2 -2
- package/dist/utils/theme-wave.d.ts +24 -0
- package/dist/utils/theme-wave.d.ts.map +1 -0
- package/dist/utils/theme-wave.js +219 -0
- package/dist/utils/typeahead.d.ts +12 -0
- package/dist/utils/typeahead.d.ts.map +1 -0
- package/dist/utils/typeahead.js +19 -0
- package/dist/zen.css +1 -1
- package/package.json +2 -1
- package/dist/icons/ellipsis.js +0 -31
- package/dist/icons/index.d.ts +0 -9
- package/dist/icons/index.d.ts.map +0 -1
- package/dist/icons/status.d.ts +0 -2
- package/dist/icons/status.d.ts.map +0 -1
package/dist/toast/index.js
CHANGED
|
@@ -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
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
10
|
-
function
|
|
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,
|
|
13
|
-
|
|
14
|
-
let
|
|
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] =
|
|
18
|
-
|
|
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
|
-
|
|
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),
|
|
26
|
-
},
|
|
27
|
-
}, []),
|
|
28
|
-
let a =
|
|
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 :
|
|
44
|
+
timeout: i ?? (r ? 1e4 : g)
|
|
35
45
|
};
|
|
36
|
-
return
|
|
37
|
-
}, []),
|
|
38
|
-
let t =
|
|
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 >=
|
|
43
|
-
y:
|
|
44
|
-
scale:
|
|
45
|
-
height: !
|
|
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__ */
|
|
49
|
-
value:
|
|
50
|
-
children: [/* @__PURE__ */
|
|
51
|
-
value:
|
|
58
|
+
return /* @__PURE__ */ m(w.Provider, {
|
|
59
|
+
value: U,
|
|
60
|
+
children: [/* @__PURE__ */ p(T.Provider, {
|
|
61
|
+
value: A,
|
|
52
62
|
children: n
|
|
53
|
-
}), M &&
|
|
54
|
-
ref:
|
|
63
|
+
}), M && h(/* @__PURE__ */ p("section", {
|
|
64
|
+
ref: V,
|
|
55
65
|
popover: "manual",
|
|
56
|
-
|
|
57
|
-
"
|
|
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:
|
|
77
|
+
height: Y,
|
|
67
78
|
...r && { "--zen-toast-offset": r }
|
|
68
79
|
},
|
|
69
|
-
children: a.map((e, t) => /* @__PURE__ */
|
|
80
|
+
children: a.map((e, t) => /* @__PURE__ */ p(j, {
|
|
70
81
|
toast: e,
|
|
71
|
-
layout:
|
|
82
|
+
layout: X(e),
|
|
72
83
|
z: t + 1,
|
|
73
|
-
paused:
|
|
74
|
-
onDismiss:
|
|
84
|
+
paused: G,
|
|
85
|
+
onDismiss: H,
|
|
75
86
|
onHeight: F,
|
|
76
|
-
clocks:
|
|
77
|
-
entered:
|
|
87
|
+
clocks: f.current,
|
|
88
|
+
entered: S.current
|
|
78
89
|
}, e.id))
|
|
79
90
|
}), M)]
|
|
80
91
|
});
|
|
81
92
|
}
|
|
82
|
-
function
|
|
83
|
-
let n =
|
|
84
|
-
|
|
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
|
|
104
|
+
function O(e) {
|
|
94
105
|
if (e?.showPopover) try {
|
|
95
106
|
e.showPopover();
|
|
96
107
|
} catch {}
|
|
97
108
|
}
|
|
98
|
-
function
|
|
99
|
-
let e =
|
|
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
|
|
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
|
|
127
|
-
let
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}, [
|
|
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
|
|
135
|
-
|
|
136
|
-
let e =
|
|
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 = () =>
|
|
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
|
-
}, [
|
|
159
|
+
}, [s, t.id]), l(() => {
|
|
143
160
|
if (!t.timeout || i || t.leaving) return;
|
|
144
|
-
|
|
145
|
-
let e = setTimeout(() =>
|
|
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),
|
|
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
|
-
|
|
155
|
-
|
|
171
|
+
o,
|
|
172
|
+
T
|
|
156
173
|
]);
|
|
157
|
-
let
|
|
158
|
-
t.leaving || e.button !== 0 || e.target.closest("button") || (
|
|
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
|
-
},
|
|
165
|
-
if (!
|
|
166
|
-
let t =
|
|
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
|
-
},
|
|
169
|
-
let n =
|
|
170
|
-
n && (
|
|
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:
|
|
189
|
+
return /* @__PURE__ */ m(f, { children: [/* @__PURE__ */ m("div", {
|
|
190
|
+
ref: v,
|
|
174
191
|
role: t.tone === "error" ? "alert" : "status",
|
|
175
|
-
"aria-
|
|
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:
|
|
180
|
-
onPointerMove:
|
|
181
|
-
onPointerUp:
|
|
182
|
-
onPointerCancel:
|
|
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",
|
|
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__ */
|
|
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__ */
|
|
194
|
-
className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full",
|
|
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__ */
|
|
213
|
+
children: /* @__PURE__ */ p(_, { className: "size-4" })
|
|
197
214
|
}),
|
|
198
|
-
/* @__PURE__ */
|
|
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__ */
|
|
218
|
+
/* @__PURE__ */ p("div", {
|
|
202
219
|
className: "text-sm font-semibold",
|
|
203
220
|
children: t.title
|
|
204
221
|
}),
|
|
205
|
-
t.description && /* @__PURE__ */
|
|
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__ */
|
|
226
|
+
t.action && /* @__PURE__ */ p("button", {
|
|
210
227
|
type: "button",
|
|
211
228
|
onClick: () => {
|
|
212
|
-
t.action?.onClick(),
|
|
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__ */
|
|
236
|
+
/* @__PURE__ */ p("button", {
|
|
220
237
|
type: "button",
|
|
221
238
|
"aria-label": "Dismiss",
|
|
222
|
-
onClick: () =>
|
|
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__ */
|
|
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__ */
|
|
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",
|
|
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: `${-
|
|
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 {
|
|
261
|
+
export { E as default, k as useToast, D as useToastHost };
|
package/dist/tree/index.d.ts
CHANGED
|
@@ -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
|
|
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). */
|
package/dist/tree/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tree/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tree/index.tsx"],"names":[],"mappings":"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"}
|
package/dist/tree/index.js
CHANGED
|
@@ -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
|
|
5
|
-
import {
|
|
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
|
|
8
|
-
let [u, d] =
|
|
9
|
-
let e = [],
|
|
10
|
-
|
|
11
|
-
let
|
|
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:
|
|
14
|
-
key:
|
|
15
|
-
depth:
|
|
16
|
-
parentKey:
|
|
17
|
-
hasChildren:
|
|
18
|
-
expanded:
|
|
19
|
-
|
|
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
|
|
25
|
+
return i(t, 0, null), e;
|
|
23
26
|
}, [
|
|
24
27
|
t,
|
|
25
28
|
n,
|
|
26
|
-
|
|
29
|
+
r,
|
|
27
30
|
_
|
|
28
31
|
]), y = () => {
|
|
29
|
-
let e = [],
|
|
30
|
-
for (let
|
|
31
|
-
let t =
|
|
32
|
-
t?.length && (e.push(n(
|
|
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
|
|
36
|
-
}, b =
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
84
|
-
let
|
|
85
|
-
return /* @__PURE__ */
|
|
86
|
-
...
|
|
87
|
-
...
|
|
88
|
-
|
|
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
|
-
...
|
|
120
|
+
...u.style,
|
|
91
121
|
...a
|
|
92
122
|
}
|
|
93
123
|
});
|
|
94
124
|
}
|
|
95
|
-
function
|
|
96
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
107
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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
|
|
114
|
-
return /* @__PURE__ */
|
|
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",
|
|
120
|
-
...
|
|
121
|
-
children: /* @__PURE__ */
|
|
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 {
|
|
155
|
+
export { f as TreeCell, p as TreeLabel, d as TreeRow, m as TreeToggle, u as useTree };
|