@tetrascience-npm/tetrascience-react-ui 1.0.0-beta.162.1 → 1.0.0-beta.164.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.
- package/dist/components/ui/tree.d.ts +46 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +227 -225
- package/dist/index.scoped.css +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/ui/table.cjs +1 -1
- package/dist/ui/table.cjs.map +1 -1
- package/dist/ui/table.js +3 -1
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tree.cjs +1 -1
- package/dist/ui/tree.cjs.map +1 -1
- package/dist/ui/tree.js +282 -218
- package/dist/ui/tree.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/tree.js
CHANGED
|
@@ -1,53 +1,58 @@
|
|
|
1
|
-
import { jsx as i, jsxs as
|
|
1
|
+
import { jsx as i, jsxs as O, Fragment as ie } from "react/jsx-runtime";
|
|
2
2
|
import { useControllableState as J } from "@radix-ui/react-use-controllable-state";
|
|
3
|
-
import { cva as
|
|
4
|
-
import { ChevronRightIcon as
|
|
5
|
-
import * as
|
|
6
|
-
import { TooltipProvider as
|
|
7
|
-
import { cn as
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
const r =
|
|
3
|
+
import { cva as de } from "class-variance-authority";
|
|
4
|
+
import { ChevronRightIcon as ce } from "lucide-react";
|
|
5
|
+
import * as a from "react";
|
|
6
|
+
import { TooltipProvider as ue, Tooltip as fe, TooltipTrigger as me, TooltipContent as pe } from "./tooltip.js";
|
|
7
|
+
import { cn as I } from "../lib/utils.js";
|
|
8
|
+
const te = a.createContext(null), re = a.createContext(null);
|
|
9
|
+
function ne(e) {
|
|
10
|
+
const r = a.useContext(te);
|
|
11
11
|
if (!r)
|
|
12
12
|
throw new Error(`\`${e}\` must be rendered inside a \`Tree\`.`);
|
|
13
13
|
return r;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const j = a.createContext(1), ae = a.createContext({
|
|
16
16
|
posinset: 1,
|
|
17
17
|
setsize: 1,
|
|
18
18
|
lastBranchPos: 0
|
|
19
|
-
}),
|
|
19
|
+
}), G = a.createContext(null), ge = [];
|
|
20
20
|
function Y(e) {
|
|
21
|
-
const r =
|
|
21
|
+
const r = a.useContext(G);
|
|
22
22
|
if (!r)
|
|
23
23
|
throw new Error(`\`${e}\` must be rendered inside a \`TreeItem\`.`);
|
|
24
24
|
return r;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function Me() {
|
|
27
27
|
return Y("useTreeItem");
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
function Q(e) {
|
|
30
|
+
return e.type === Re || e.type === Pe;
|
|
31
|
+
}
|
|
32
|
+
function he(e) {
|
|
33
|
+
return a.useMemo(() => {
|
|
34
|
+
const r = a.Children.toArray(e), t = r.filter(
|
|
35
|
+
(l) => a.isValidElement(l) && !Q(l)
|
|
36
|
+
), s = t.length, o = (l) => l.props?.hasChildren === !0, d = t.reduce((l, f, p) => o(f) ? p + 1 : l, 0);
|
|
37
|
+
let c = 0;
|
|
38
|
+
return r.map((l, f) => !a.isValidElement(l) || Q(l) ? l : (c += 1, /* @__PURE__ */ i(ae.Provider, { value: { posinset: c, setsize: s, lastBranchPos: d }, children: l }, l.key ?? f)));
|
|
34
39
|
}, [e]);
|
|
35
40
|
}
|
|
36
|
-
const
|
|
37
|
-
function
|
|
38
|
-
return e ? [...e.querySelectorAll(
|
|
41
|
+
const z = '[role="treeitem"][data-tree-item-id]';
|
|
42
|
+
function A(e) {
|
|
43
|
+
return e ? [...e.querySelectorAll(z)] : [];
|
|
39
44
|
}
|
|
40
|
-
const
|
|
41
|
-
function
|
|
42
|
-
return
|
|
45
|
+
const xe = '[role="group"], [role="tree"]';
|
|
46
|
+
function U(e, r) {
|
|
47
|
+
return A(e).find((t) => t.dataset.treeItemId === r);
|
|
43
48
|
}
|
|
44
|
-
function
|
|
45
|
-
return e.parentElement?.closest(
|
|
49
|
+
function Z(e) {
|
|
50
|
+
return e.parentElement?.closest(xe) ?? null;
|
|
46
51
|
}
|
|
47
|
-
function
|
|
52
|
+
function be(e) {
|
|
48
53
|
const r = [];
|
|
49
|
-
for (let t = e.parentElement?.closest(
|
|
50
|
-
t.dataset.treeItemId && r.unshift(t.dataset.treeItemId), t = t.parentElement?.closest(
|
|
54
|
+
for (let t = e.parentElement?.closest(z); t; )
|
|
55
|
+
t.dataset.treeItemId && r.unshift(t.dataset.treeItemId), t = t.parentElement?.closest(z);
|
|
51
56
|
return r;
|
|
52
57
|
}
|
|
53
58
|
function oe(e) {
|
|
@@ -57,53 +62,53 @@ function oe(e) {
|
|
|
57
62
|
for (const t of e.childNodes) r += oe(t);
|
|
58
63
|
return r;
|
|
59
64
|
}
|
|
60
|
-
function
|
|
65
|
+
function ve(e) {
|
|
61
66
|
const r = e.getAttribute("aria-labelledby"), t = r ? e.ownerDocument.getElementById(r) : null;
|
|
62
67
|
return (t ? oe(t) : "").trim().toLowerCase();
|
|
63
68
|
}
|
|
64
|
-
function
|
|
65
|
-
const s =
|
|
69
|
+
function Ie(e, r, t) {
|
|
70
|
+
const s = U(e, r);
|
|
66
71
|
if (s) return s;
|
|
67
|
-
for (let
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
72
|
+
for (let o = t.length - 1; o >= 0; o -= 1) {
|
|
73
|
+
const d = U(e, t[o]);
|
|
74
|
+
if (d) return d;
|
|
70
75
|
}
|
|
71
|
-
return
|
|
76
|
+
return A(e)[0];
|
|
72
77
|
}
|
|
73
|
-
function
|
|
78
|
+
function Te(e, r) {
|
|
74
79
|
const t = e?.dataset.treeItemId;
|
|
75
80
|
!e || !t || (r(t), e.focus());
|
|
76
81
|
}
|
|
77
|
-
const
|
|
82
|
+
const ye = 600, Ce = 800;
|
|
78
83
|
function K({ event: e, setFocusedId: r }, t) {
|
|
79
|
-
e.preventDefault(),
|
|
84
|
+
e.preventDefault(), Te(t, r);
|
|
80
85
|
}
|
|
81
|
-
function
|
|
82
|
-
const t =
|
|
86
|
+
function ee(e, r) {
|
|
87
|
+
const t = A(e.root);
|
|
83
88
|
K(e, t[t.indexOf(e.current) + r]);
|
|
84
89
|
}
|
|
85
|
-
const
|
|
86
|
-
ArrowDown: (e) =>
|
|
87
|
-
ArrowUp: (e) =>
|
|
90
|
+
const we = {
|
|
91
|
+
ArrowDown: (e) => ee(e, 1),
|
|
92
|
+
ArrowUp: (e) => ee(e, -1),
|
|
88
93
|
ArrowRight: (e) => {
|
|
89
|
-
const { event: r, current: t, id: s, hasChildren:
|
|
90
|
-
if (
|
|
91
|
-
r.preventDefault(),
|
|
94
|
+
const { event: r, current: t, id: s, hasChildren: o, expanded: d, setExpanded: c } = e;
|
|
95
|
+
if (o && !d) {
|
|
96
|
+
r.preventDefault(), c(s, !0);
|
|
92
97
|
return;
|
|
93
98
|
}
|
|
94
|
-
|
|
99
|
+
d && K(e, t.querySelector(z));
|
|
95
100
|
},
|
|
96
101
|
ArrowLeft: (e) => {
|
|
97
|
-
const { event: r, current: t, id: s, expanded:
|
|
98
|
-
if (
|
|
99
|
-
r.preventDefault(),
|
|
102
|
+
const { event: r, current: t, id: s, expanded: o, setExpanded: d } = e;
|
|
103
|
+
if (o) {
|
|
104
|
+
r.preventDefault(), d(s, !1);
|
|
100
105
|
return;
|
|
101
106
|
}
|
|
102
|
-
K(e, t.parentElement?.closest(
|
|
107
|
+
K(e, t.parentElement?.closest(z));
|
|
103
108
|
},
|
|
104
|
-
Home: (e) => K(e,
|
|
109
|
+
Home: (e) => K(e, A(e.root)[0]),
|
|
105
110
|
End: (e) => {
|
|
106
|
-
const r =
|
|
111
|
+
const r = A(e.root);
|
|
107
112
|
K(e, r[r.length - 1]);
|
|
108
113
|
},
|
|
109
114
|
Enter: (e) => {
|
|
@@ -111,151 +116,151 @@ const ye = {
|
|
|
111
116
|
},
|
|
112
117
|
/** Expands every collapsed branch among the focused node's siblings, the node itself included. */
|
|
113
118
|
"*": (e) => {
|
|
114
|
-
const { event: r, root: t, current: s, expandIds:
|
|
119
|
+
const { event: r, root: t, current: s, expandIds: o } = e;
|
|
115
120
|
r.preventDefault();
|
|
116
|
-
const
|
|
117
|
-
|
|
121
|
+
const d = Z(s) ?? t, c = A(d).filter((l) => Z(l) === d).filter((l) => l.dataset.treeHasChildren === "true" && l.getAttribute("aria-expanded") !== "true").map((l) => l.dataset.treeItemId).filter((l) => !!l);
|
|
122
|
+
c.length && o(c);
|
|
118
123
|
}
|
|
119
124
|
};
|
|
120
|
-
function
|
|
125
|
+
function Ee(e) {
|
|
121
126
|
return e.key.length === 1 && e.key !== " ";
|
|
122
127
|
}
|
|
123
|
-
function
|
|
124
|
-
const { event: r, root: t, current: s, typeahead:
|
|
125
|
-
r.preventDefault(), clearTimeout(
|
|
126
|
-
const { buffer:
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
},
|
|
130
|
-
const p =
|
|
128
|
+
function ke(e) {
|
|
129
|
+
const { event: r, root: t, current: s, typeahead: o, setTypeaheadMatch: d } = e;
|
|
130
|
+
r.preventDefault(), clearTimeout(o.timer), clearTimeout(o.fadeTimer), o.buffer += r.key.toLowerCase();
|
|
131
|
+
const { buffer: c } = o, f = c.length > 1 && [...c].every((x) => x === c[0]) ? c[0] : c;
|
|
132
|
+
d({ query: f, fading: !1 }), o.timer = setTimeout(() => {
|
|
133
|
+
o.buffer = "", d({ query: f, fading: !0 }), o.fadeTimer = setTimeout(() => d(null), Ce);
|
|
134
|
+
}, ye);
|
|
135
|
+
const p = A(t), T = p.indexOf(s);
|
|
131
136
|
for (let x = 1; x <= p.length; x += 1) {
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
K(e,
|
|
137
|
+
const y = p[(T + x) % p.length];
|
|
138
|
+
if (ve(y).startsWith(f)) {
|
|
139
|
+
K(e, y);
|
|
135
140
|
return;
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
}
|
|
139
|
-
function
|
|
144
|
+
function Fe({
|
|
140
145
|
className: e,
|
|
141
146
|
children: r,
|
|
142
147
|
expandedIds: t,
|
|
143
148
|
defaultExpandedIds: s,
|
|
144
|
-
onExpandedChange:
|
|
145
|
-
selectedId:
|
|
146
|
-
defaultSelectedId:
|
|
149
|
+
onExpandedChange: o,
|
|
150
|
+
selectedId: d,
|
|
151
|
+
defaultSelectedId: c = null,
|
|
147
152
|
onSelectedChange: l,
|
|
148
|
-
onActivate:
|
|
153
|
+
onActivate: f,
|
|
149
154
|
expandOnSelect: p = !0,
|
|
150
155
|
guides: T = "hover",
|
|
151
156
|
onFocus: x,
|
|
152
|
-
onBlur:
|
|
153
|
-
...
|
|
157
|
+
onBlur: y,
|
|
158
|
+
...D
|
|
154
159
|
}) {
|
|
155
|
-
const R =
|
|
160
|
+
const R = a.useRef(null), [C, E] = J({
|
|
156
161
|
prop: t,
|
|
157
162
|
defaultProp: s ?? /* @__PURE__ */ new Set(),
|
|
158
|
-
onChange:
|
|
159
|
-
}), [
|
|
160
|
-
prop:
|
|
161
|
-
defaultProp:
|
|
163
|
+
onChange: o
|
|
164
|
+
}), [w, b] = J({
|
|
165
|
+
prop: d,
|
|
166
|
+
defaultProp: c,
|
|
162
167
|
onChange: (n) => {
|
|
163
168
|
n != null && l?.(n);
|
|
164
169
|
}
|
|
165
|
-
}), [
|
|
166
|
-
|
|
170
|
+
}), [g, L] = a.useState(null), [k, S] = a.useState(null), [m, N] = a.useState(null), B = a.useRef([]), _ = a.useRef(!1), $ = a.useRef({ buffer: "", timer: void 0, fadeTimer: void 0 });
|
|
171
|
+
a.useEffect(
|
|
167
172
|
() => () => {
|
|
168
|
-
clearTimeout(
|
|
173
|
+
clearTimeout($.current.timer), clearTimeout($.current.fadeTimer);
|
|
169
174
|
},
|
|
170
175
|
[]
|
|
171
176
|
);
|
|
172
|
-
const
|
|
173
|
-
(n,
|
|
174
|
-
E((
|
|
175
|
-
const
|
|
176
|
-
return
|
|
177
|
+
const P = a.useCallback(
|
|
178
|
+
(n, h) => {
|
|
179
|
+
E((u) => {
|
|
180
|
+
const v = new Set(u);
|
|
181
|
+
return h ? v.add(n) : v.delete(n), v;
|
|
177
182
|
});
|
|
178
183
|
},
|
|
179
184
|
[E]
|
|
180
|
-
),
|
|
185
|
+
), M = a.useCallback(
|
|
181
186
|
(n) => {
|
|
182
|
-
E((
|
|
183
|
-
const
|
|
184
|
-
for (const
|
|
185
|
-
return
|
|
187
|
+
E((h) => {
|
|
188
|
+
const u = new Set(h);
|
|
189
|
+
for (const v of n) u.add(v);
|
|
190
|
+
return u;
|
|
186
191
|
});
|
|
187
192
|
},
|
|
188
193
|
[E]
|
|
189
|
-
), H =
|
|
190
|
-
(n,
|
|
191
|
-
b(n), p &&
|
|
194
|
+
), H = a.useCallback(
|
|
195
|
+
(n, h, u) => {
|
|
196
|
+
b(n), p && h && P(n, !u), f?.(n);
|
|
192
197
|
},
|
|
193
|
-
[b, p,
|
|
194
|
-
), F =
|
|
198
|
+
[b, p, P, f]
|
|
199
|
+
), F = a.useCallback(
|
|
195
200
|
(n) => {
|
|
196
|
-
const
|
|
197
|
-
if (!
|
|
198
|
-
const
|
|
199
|
-
|
|
201
|
+
const h = R.current, u = n.target?.closest(z), v = u?.dataset.treeItemId;
|
|
202
|
+
if (!h || !u || !v || !h.contains(u) || u !== n.currentTarget || n.ctrlKey || n.metaKey || n.altKey) return;
|
|
203
|
+
const W = we[n.key] ?? (Ee(n) ? ke : void 0);
|
|
204
|
+
W && W({
|
|
200
205
|
event: n,
|
|
201
|
-
root:
|
|
202
|
-
current:
|
|
203
|
-
id:
|
|
204
|
-
hasChildren:
|
|
205
|
-
expanded:
|
|
206
|
-
disabled:
|
|
207
|
-
setExpanded:
|
|
208
|
-
expandIds:
|
|
206
|
+
root: h,
|
|
207
|
+
current: u,
|
|
208
|
+
id: v,
|
|
209
|
+
hasChildren: u.dataset.treeHasChildren === "true",
|
|
210
|
+
expanded: u.getAttribute("aria-expanded") === "true",
|
|
211
|
+
disabled: u.getAttribute("aria-disabled") === "true",
|
|
212
|
+
setExpanded: P,
|
|
213
|
+
expandIds: M,
|
|
209
214
|
setFocusedId: L,
|
|
210
215
|
activate: H,
|
|
211
|
-
typeahead:
|
|
212
|
-
setTypeaheadMatch:
|
|
216
|
+
typeahead: $.current,
|
|
217
|
+
setTypeaheadMatch: N
|
|
213
218
|
});
|
|
214
219
|
},
|
|
215
|
-
[
|
|
216
|
-
),
|
|
220
|
+
[P, M, H]
|
|
221
|
+
), q = a.useCallback(() => {
|
|
217
222
|
const n = R.current;
|
|
218
223
|
if (!n) return;
|
|
219
|
-
if (
|
|
220
|
-
const X =
|
|
221
|
-
X !==
|
|
224
|
+
if (g == null) {
|
|
225
|
+
const X = w != null && !U(n, w) ? A(n)[0]?.dataset.treeItemId ?? null : null;
|
|
226
|
+
X !== k && S(X);
|
|
222
227
|
return;
|
|
223
228
|
}
|
|
224
|
-
const
|
|
225
|
-
if (!
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
_.current && (!n.contains(
|
|
229
|
-
}, [
|
|
230
|
-
|
|
231
|
-
const V =
|
|
229
|
+
const h = Ie(n, g, B.current), u = h?.dataset.treeItemId;
|
|
230
|
+
if (!h || !u) return;
|
|
231
|
+
u === g ? B.current = be(h) : L(u);
|
|
232
|
+
const v = n.ownerDocument.activeElement;
|
|
233
|
+
_.current && (!n.contains(v) || v === n) && h.focus();
|
|
234
|
+
}, [g, w, k]);
|
|
235
|
+
a.useLayoutEffect(q);
|
|
236
|
+
const V = a.useMemo(
|
|
232
237
|
() => ({
|
|
233
|
-
expandedIds:
|
|
234
|
-
setExpanded:
|
|
235
|
-
expandIds:
|
|
236
|
-
selectedId:
|
|
238
|
+
expandedIds: C ?? /* @__PURE__ */ new Set(),
|
|
239
|
+
setExpanded: P,
|
|
240
|
+
expandIds: M,
|
|
241
|
+
selectedId: w ?? null,
|
|
237
242
|
activateItem: H,
|
|
238
|
-
focusedId:
|
|
243
|
+
focusedId: g,
|
|
239
244
|
setFocusedId: L,
|
|
240
|
-
entryId:
|
|
245
|
+
entryId: k,
|
|
241
246
|
expandOnSelect: p,
|
|
242
247
|
guides: T,
|
|
243
248
|
onItemKeyDown: F
|
|
244
249
|
}),
|
|
245
250
|
[
|
|
246
|
-
y,
|
|
247
|
-
A,
|
|
248
|
-
z,
|
|
249
251
|
C,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
+
P,
|
|
253
|
+
M,
|
|
252
254
|
w,
|
|
255
|
+
H,
|
|
256
|
+
g,
|
|
257
|
+
k,
|
|
253
258
|
p,
|
|
254
259
|
T,
|
|
255
260
|
F
|
|
256
261
|
]
|
|
257
262
|
);
|
|
258
|
-
return /* @__PURE__ */ i(
|
|
263
|
+
return /* @__PURE__ */ i(te.Provider, { value: V, children: /* @__PURE__ */ i(re.Provider, { value: m, children: /* @__PURE__ */ i(j.Provider, { value: 1, children: /* @__PURE__ */ i(
|
|
259
264
|
"div",
|
|
260
265
|
{
|
|
261
266
|
ref: R,
|
|
@@ -267,80 +272,80 @@ function _e({
|
|
|
267
272
|
x?.(n), _.current = !0;
|
|
268
273
|
},
|
|
269
274
|
onBlur: (n) => {
|
|
270
|
-
|
|
275
|
+
y?.(n), n.currentTarget.contains(n.relatedTarget) || (_.current = !1);
|
|
271
276
|
},
|
|
272
|
-
className:
|
|
277
|
+
className: I(
|
|
273
278
|
"group/tree text-foreground flex w-full flex-col text-sm",
|
|
274
279
|
"[--tree-indent:1.25rem] [--tree-guide-color:color-mix(in_oklch,var(--muted-foreground)_40%,var(--background))]",
|
|
275
280
|
e
|
|
276
281
|
),
|
|
277
|
-
...
|
|
278
|
-
children: /* @__PURE__ */ i(
|
|
282
|
+
...D,
|
|
283
|
+
children: /* @__PURE__ */ i(ue, { delayDuration: 500, children: /* @__PURE__ */ i(se, { children: r }) })
|
|
279
284
|
}
|
|
280
285
|
) }) }) });
|
|
281
286
|
}
|
|
282
|
-
function
|
|
283
|
-
return
|
|
287
|
+
function se({ children: e }) {
|
|
288
|
+
return he(e);
|
|
284
289
|
}
|
|
285
|
-
function
|
|
290
|
+
function Ke({
|
|
286
291
|
className: e,
|
|
287
292
|
children: r,
|
|
288
293
|
id: t,
|
|
289
294
|
hasChildren: s = !1,
|
|
290
|
-
disabled:
|
|
291
|
-
onClick:
|
|
292
|
-
onFocus:
|
|
295
|
+
disabled: o = !1,
|
|
296
|
+
onClick: d,
|
|
297
|
+
onFocus: c,
|
|
293
298
|
onKeyDown: l,
|
|
294
|
-
style:
|
|
299
|
+
style: f,
|
|
295
300
|
...p
|
|
296
301
|
}) {
|
|
297
|
-
const { expandedIds: T, setExpanded: x, selectedId:
|
|
298
|
-
s && x(t, !
|
|
299
|
-
}, [s, x, t,
|
|
300
|
-
|
|
301
|
-
}, [
|
|
302
|
-
() => b > 1 &&
|
|
303
|
-
[F, b,
|
|
304
|
-
), V =
|
|
302
|
+
const { expandedIds: T, setExpanded: x, selectedId: y, activateItem: D, focusedId: R, setFocusedId: C, entryId: E, onItemKeyDown: w } = ne("TreeItem"), b = a.useContext(j), { posinset: g, setsize: L, lastBranchPos: k } = a.useContext(ae), S = `${a.useId()}-label`, m = s && T.has(t), N = y === t, B = a.useCallback(() => {
|
|
303
|
+
s && x(t, !m);
|
|
304
|
+
}, [s, x, t, m]), _ = a.useCallback(() => {
|
|
305
|
+
o || (C(t), D(t, s, m));
|
|
306
|
+
}, [o, C, t, D, s, m]), $ = b === 1 && g === 1, P = y == null ? $ : y === t, M = R ? R === t : E ? E === t : P, F = a.useContext(G)?.trunkLevels ?? ge, q = a.useMemo(
|
|
307
|
+
() => b > 1 && g < k ? [...F, b - 1] : F,
|
|
308
|
+
[F, b, g, k]
|
|
309
|
+
), V = a.useMemo(
|
|
305
310
|
() => ({
|
|
306
311
|
id: t,
|
|
307
312
|
labelId: S,
|
|
308
313
|
level: b,
|
|
309
|
-
expanded:
|
|
314
|
+
expanded: m,
|
|
310
315
|
hasChildren: s,
|
|
311
|
-
selected:
|
|
312
|
-
disabled:
|
|
313
|
-
trunkLevels:
|
|
314
|
-
toggle:
|
|
316
|
+
selected: N,
|
|
317
|
+
disabled: o,
|
|
318
|
+
trunkLevels: q,
|
|
319
|
+
toggle: B,
|
|
315
320
|
select: _
|
|
316
321
|
}),
|
|
317
|
-
[t, S, b,
|
|
322
|
+
[t, S, b, m, s, N, o, q, B, _]
|
|
318
323
|
);
|
|
319
|
-
return /* @__PURE__ */ i(
|
|
324
|
+
return /* @__PURE__ */ i(G.Provider, { value: V, children: /* @__PURE__ */ i(
|
|
320
325
|
"div",
|
|
321
326
|
{
|
|
322
327
|
...p,
|
|
323
328
|
"data-slot": "tree-item",
|
|
324
329
|
"data-tree-item-id": t,
|
|
325
330
|
"data-tree-has-children": s,
|
|
326
|
-
"data-state":
|
|
331
|
+
"data-state": m ? "expanded" : "collapsed",
|
|
327
332
|
role: "treeitem",
|
|
328
333
|
"aria-labelledby": S,
|
|
329
|
-
"aria-expanded": s ?
|
|
334
|
+
"aria-expanded": s ? m : void 0,
|
|
330
335
|
"aria-level": b,
|
|
331
|
-
"aria-posinset":
|
|
336
|
+
"aria-posinset": g,
|
|
332
337
|
"aria-setsize": L,
|
|
333
|
-
"aria-selected":
|
|
334
|
-
"aria-disabled":
|
|
335
|
-
tabIndex:
|
|
338
|
+
"aria-selected": N,
|
|
339
|
+
"aria-disabled": o || void 0,
|
|
340
|
+
tabIndex: M ? 0 : -1,
|
|
336
341
|
onKeyDown: (n) => {
|
|
337
|
-
l?.(n), !n.defaultPrevented &&
|
|
342
|
+
l?.(n), !n.defaultPrevented && w(n);
|
|
338
343
|
},
|
|
339
344
|
onClick: (n) => {
|
|
340
|
-
|
|
345
|
+
d?.(n), !n.defaultPrevented && n.target.closest(z) === n.currentTarget && _();
|
|
341
346
|
},
|
|
342
347
|
onFocus: (n) => {
|
|
343
|
-
|
|
348
|
+
c?.(n), n.target === n.currentTarget && C(t);
|
|
344
349
|
},
|
|
345
350
|
style: {
|
|
346
351
|
// Inherited by the label, which draws the elbow from the same two values.
|
|
@@ -351,9 +356,9 @@ function Me({
|
|
|
351
356
|
// Shared by the elbow's corner and by where the same-column trunk picks up, so the two
|
|
352
357
|
// meet exactly instead of overlapping or leaving a gap.
|
|
353
358
|
"--tree-elbow-radius": "0.5rem",
|
|
354
|
-
...
|
|
359
|
+
...f
|
|
355
360
|
},
|
|
356
|
-
className:
|
|
361
|
+
className: I(
|
|
357
362
|
"relative outline-none",
|
|
358
363
|
// Direct-child selectors, deliberately not `group-*/tree-item`: tree items nest, and a
|
|
359
364
|
// group variant matches *any* ancestor, so a focused or selected parent painted its focus
|
|
@@ -366,7 +371,7 @@ function Me({
|
|
|
366
371
|
}
|
|
367
372
|
) });
|
|
368
373
|
}
|
|
369
|
-
const
|
|
374
|
+
const le = de(
|
|
370
375
|
"flex w-full min-w-0 cursor-default items-center gap-1.5 rounded-md pr-2 text-left transition-colors select-none",
|
|
371
376
|
{
|
|
372
377
|
variants: {
|
|
@@ -381,27 +386,27 @@ const we = le(
|
|
|
381
386
|
}
|
|
382
387
|
}
|
|
383
388
|
);
|
|
384
|
-
function
|
|
385
|
-
const { labelId: l, level:
|
|
386
|
-
const
|
|
387
|
-
|
|
389
|
+
function Oe({ className: e, children: r, size: t, style: s, icon: o, trailing: d, ...c }) {
|
|
390
|
+
const { labelId: l, level: f, expanded: p, hasChildren: T, selected: x, disabled: y, trunkLevels: D, toggle: R } = Y("TreeItemLabel"), { guides: C } = ne("TreeItemLabel"), E = a.useContext(re), w = C !== "none" && f > 1 && T, b = C !== "none" && (w || D.length > 0), g = a.useRef(null), [L, k] = a.useState(!1), S = (m) => {
|
|
391
|
+
const N = g.current;
|
|
392
|
+
k(m && !!N && N.scrollWidth > N.clientWidth);
|
|
388
393
|
};
|
|
389
|
-
return /* @__PURE__ */
|
|
394
|
+
return /* @__PURE__ */ O(
|
|
390
395
|
"div",
|
|
391
396
|
{
|
|
392
|
-
...
|
|
397
|
+
...c,
|
|
393
398
|
id: l,
|
|
394
399
|
"data-slot": "tree-item-label",
|
|
395
|
-
style: { paddingInlineStart: `calc(var(--tree-indent) * ${
|
|
396
|
-
className:
|
|
397
|
-
|
|
400
|
+
style: { paddingInlineStart: `calc(var(--tree-indent) * ${f - 1} + 0.25rem)`, ...s },
|
|
401
|
+
className: I(
|
|
402
|
+
le({ size: t }),
|
|
398
403
|
"relative border border-transparent",
|
|
399
404
|
// Only selection paints a background — an open folder is already marked by its rotated
|
|
400
405
|
// chevron, open-folder icon and the connectors running down from it.
|
|
401
406
|
x ? "bg-accent text-accent-foreground font-medium" : "hover:bg-muted",
|
|
402
407
|
// From this node's own state, not an ancestor selector: `aria-disabled` is per-node, so a
|
|
403
408
|
// disabled folder must not dim the contents underneath it.
|
|
404
|
-
|
|
409
|
+
y && "pointer-events-none opacity-50",
|
|
405
410
|
e
|
|
406
411
|
),
|
|
407
412
|
children: [
|
|
@@ -418,29 +423,29 @@ function ze({ className: e, children: r, size: t, style: s, icon: a, trailing: c
|
|
|
418
423
|
// *padding* box. The label carries `border border-transparent` for its focus ring while the
|
|
419
424
|
// `TreeItem` carries none, so one `--tree-guide-left` landed 1px apart on the two elements
|
|
420
425
|
// and the elbow/trunk overlap read as a 2px line. Both now share this container.
|
|
421
|
-
/* @__PURE__ */
|
|
426
|
+
/* @__PURE__ */ O(
|
|
422
427
|
"span",
|
|
423
428
|
{
|
|
424
429
|
"data-slot": "tree-item-guides",
|
|
425
430
|
"aria-hidden": "true",
|
|
426
|
-
className:
|
|
431
|
+
className: I(
|
|
427
432
|
"pointer-events-none absolute inset-0",
|
|
428
433
|
// The fade lives on the container, not on each line. Opacity on the parent renders the
|
|
429
434
|
// whole layer into one buffer and composites it once, so a seam between two segments
|
|
430
435
|
// can never double-expose mid-transition.
|
|
431
|
-
|
|
436
|
+
C === "hover" && "opacity-0 transition-opacity group-hover/tree:opacity-100 motion-reduce:transition-none"
|
|
432
437
|
),
|
|
433
438
|
children: [
|
|
434
|
-
|
|
439
|
+
D.map((m) => /* @__PURE__ */ i(
|
|
435
440
|
"span",
|
|
436
441
|
{
|
|
437
442
|
"data-slot": "tree-item-guide-trunk",
|
|
438
|
-
style: { left: `calc(var(--tree-indent) * ${
|
|
443
|
+
style: { left: `calc(var(--tree-indent) * ${m - 1} + 0.6875rem)` },
|
|
439
444
|
className: "absolute top-[-0.4375rem] bottom-0 w-0 border-l border-[var(--tree-guide-color)]"
|
|
440
445
|
},
|
|
441
|
-
|
|
446
|
+
m
|
|
442
447
|
)),
|
|
443
|
-
|
|
448
|
+
w ? (
|
|
444
449
|
// Down the guide line, then a rounded turn right, stopping just short of this row's
|
|
445
450
|
// chevron. Starts half a chevron above the row so the line emerges from under the
|
|
446
451
|
// parent's chevron instead of leaving a half-row gap.
|
|
@@ -448,7 +453,7 @@ function ze({ className: e, children: r, size: t, style: s, icon: a, trailing: c
|
|
|
448
453
|
"span",
|
|
449
454
|
{
|
|
450
455
|
"data-slot": "tree-item-guide-elbow",
|
|
451
|
-
className:
|
|
456
|
+
className: I(
|
|
452
457
|
"absolute top-[-0.4375rem] left-[var(--tree-guide-left)] border-[var(--tree-guide-color)]",
|
|
453
458
|
"h-[calc(50%+0.4375rem)] w-[var(--tree-elbow-run)] border-b border-l",
|
|
454
459
|
"rounded-bl-[var(--tree-elbow-radius)]"
|
|
@@ -470,54 +475,54 @@ function ze({ className: e, children: r, size: t, style: s, icon: a, trailing: c
|
|
|
470
475
|
{
|
|
471
476
|
"data-slot": "tree-item-indicator",
|
|
472
477
|
"aria-hidden": "true",
|
|
473
|
-
onClick: (
|
|
474
|
-
|
|
478
|
+
onClick: (m) => {
|
|
479
|
+
m.stopPropagation(), R();
|
|
475
480
|
},
|
|
476
481
|
className: "flex size-3.5 shrink-0 items-center justify-center text-muted-foreground",
|
|
477
|
-
children: /* @__PURE__ */ i(
|
|
482
|
+
children: /* @__PURE__ */ i(ce, { className: I("size-3.5 transition-transform", p && "rotate-90") })
|
|
478
483
|
}
|
|
479
484
|
)
|
|
480
485
|
) : /* @__PURE__ */ i("span", { "data-slot": "tree-item-indicator-spacer", "aria-hidden": "true", className: "size-3.5 shrink-0" }),
|
|
481
|
-
|
|
486
|
+
o ? /* @__PURE__ */ i(
|
|
482
487
|
"span",
|
|
483
488
|
{
|
|
484
489
|
"data-slot": "tree-item-icon",
|
|
485
490
|
"aria-hidden": "true",
|
|
486
|
-
className:
|
|
491
|
+
className: I(
|
|
487
492
|
"flex size-4 shrink-0 items-center justify-center [&_svg]:size-4 [&_svg]:shrink-0",
|
|
488
493
|
x ? "text-accent-foreground" : "text-muted-foreground"
|
|
489
494
|
),
|
|
490
|
-
children:
|
|
495
|
+
children: o
|
|
491
496
|
}
|
|
492
497
|
) : null,
|
|
493
|
-
/* @__PURE__ */
|
|
494
|
-
/* @__PURE__ */ i(
|
|
498
|
+
/* @__PURE__ */ O(fe, { open: L, onOpenChange: S, children: [
|
|
499
|
+
/* @__PURE__ */ i(me, { asChild: !0, children: /* @__PURE__ */ i(
|
|
495
500
|
"span",
|
|
496
501
|
{
|
|
497
|
-
ref:
|
|
502
|
+
ref: g,
|
|
498
503
|
"data-slot": "tree-item-text",
|
|
499
504
|
className: "-mx-1 min-w-0 flex-1 truncate px-1",
|
|
500
|
-
children: /* @__PURE__ */ i(
|
|
505
|
+
children: /* @__PURE__ */ i(Ne, { match: E, children: r })
|
|
501
506
|
}
|
|
502
507
|
) }),
|
|
503
|
-
/* @__PURE__ */ i(
|
|
508
|
+
/* @__PURE__ */ i(pe, { children: r })
|
|
504
509
|
] }),
|
|
505
|
-
|
|
510
|
+
d ? /* @__PURE__ */ i("span", { "data-slot": "tree-item-trailing", className: "ml-auto flex shrink-0 items-center gap-1 [&_svg]:size-3.5", children: d }) : null
|
|
506
511
|
]
|
|
507
512
|
}
|
|
508
513
|
);
|
|
509
514
|
}
|
|
510
|
-
function
|
|
515
|
+
function Ne({ match: e, children: r }) {
|
|
511
516
|
if (!e || typeof r != "string" || !r.toLowerCase().startsWith(e.query))
|
|
512
517
|
return r;
|
|
513
518
|
const { query: t, fading: s } = e;
|
|
514
|
-
return /* @__PURE__ */
|
|
519
|
+
return /* @__PURE__ */ O(ie, { children: [
|
|
515
520
|
/* @__PURE__ */ i(
|
|
516
521
|
"span",
|
|
517
522
|
{
|
|
518
523
|
"data-slot": "tree-item-typeahead-match",
|
|
519
524
|
"data-state": s ? "fading" : "active",
|
|
520
|
-
className:
|
|
525
|
+
className: I(
|
|
521
526
|
// The SW-2445 selected-state tokens: a primary tint that reads as "this is the match" on
|
|
522
527
|
// a resting, hovered or selected row, in both themes. Plain spans, not `<mark>`, so the
|
|
523
528
|
// label's accessible name is unchanged.
|
|
@@ -536,16 +541,75 @@ function ke({ match: e, children: r }) {
|
|
|
536
541
|
r.slice(t.length)
|
|
537
542
|
] });
|
|
538
543
|
}
|
|
539
|
-
function
|
|
540
|
-
const { expanded: s, level:
|
|
541
|
-
return s ? /* @__PURE__ */ i(
|
|
544
|
+
function Be({ className: e, children: r, ...t }) {
|
|
545
|
+
const { expanded: s, level: o } = Y("TreeItemGroup");
|
|
546
|
+
return s ? /* @__PURE__ */ i(j.Provider, { value: o + 1, children: /* @__PURE__ */ i("div", { ...t, "data-slot": "tree-item-group", role: "group", className: I("flex flex-col", e), children: /* @__PURE__ */ i(se, { children: r }) }) }) : null;
|
|
547
|
+
}
|
|
548
|
+
function Re({ className: e, children: r, style: t, ...s }) {
|
|
549
|
+
const o = a.useContext(j);
|
|
550
|
+
return /* @__PURE__ */ O(
|
|
551
|
+
"div",
|
|
552
|
+
{
|
|
553
|
+
...s,
|
|
554
|
+
"data-slot": "tree-empty",
|
|
555
|
+
role: "treeitem",
|
|
556
|
+
"aria-selected": "false",
|
|
557
|
+
tabIndex: -1,
|
|
558
|
+
style: { paddingInlineStart: `calc(var(--tree-indent) * ${o - 1} + 0.25rem)`, ...t },
|
|
559
|
+
className: I(
|
|
560
|
+
"text-muted-foreground flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md border border-transparent pr-2 text-left text-sm [&_svg]:size-4 [&_svg]:shrink-0",
|
|
561
|
+
e
|
|
562
|
+
),
|
|
563
|
+
children: [
|
|
564
|
+
/* @__PURE__ */ i("span", { "data-slot": "tree-item-indicator-spacer", "aria-hidden": "true", className: "size-3.5 shrink-0" }),
|
|
565
|
+
r
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
function Pe({ className: e, children: r = "Load more", icon: t, size: s, style: o, onClick: d, ...c }) {
|
|
571
|
+
const l = a.useContext(j);
|
|
572
|
+
return /* @__PURE__ */ i("div", { "data-slot": "tree-load-more", role: "treeitem", "aria-selected": "false", className: "flex w-full", children: /* @__PURE__ */ O(
|
|
573
|
+
"button",
|
|
574
|
+
{
|
|
575
|
+
...c,
|
|
576
|
+
type: "button",
|
|
577
|
+
onClick: (f) => {
|
|
578
|
+
f.stopPropagation(), d?.(f);
|
|
579
|
+
},
|
|
580
|
+
style: { paddingInlineStart: `calc(var(--tree-indent) * ${l - 1} + 0.25rem)`, ...o },
|
|
581
|
+
className: I(
|
|
582
|
+
le({ size: s }),
|
|
583
|
+
"text-muted-foreground border border-transparent outline-none",
|
|
584
|
+
"hover:bg-muted hover:text-foreground",
|
|
585
|
+
"focus-visible:border-ring focus-visible:shadow-focus",
|
|
586
|
+
"active:bg-accent active:text-accent-foreground",
|
|
587
|
+
e
|
|
588
|
+
),
|
|
589
|
+
children: [
|
|
590
|
+
/* @__PURE__ */ i("span", { "data-slot": "tree-item-indicator-spacer", "aria-hidden": "true", className: "size-3.5 shrink-0" }),
|
|
591
|
+
t ? /* @__PURE__ */ i(
|
|
592
|
+
"span",
|
|
593
|
+
{
|
|
594
|
+
"data-slot": "tree-item-icon",
|
|
595
|
+
"aria-hidden": "true",
|
|
596
|
+
className: "flex size-4 shrink-0 items-center justify-center [&_svg]:size-4 [&_svg]:shrink-0",
|
|
597
|
+
children: t
|
|
598
|
+
}
|
|
599
|
+
) : null,
|
|
600
|
+
/* @__PURE__ */ i("span", { className: "min-w-0 flex-1 truncate", children: r })
|
|
601
|
+
]
|
|
602
|
+
}
|
|
603
|
+
) });
|
|
542
604
|
}
|
|
543
605
|
export {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
606
|
+
Fe as Tree,
|
|
607
|
+
Re as TreeEmpty,
|
|
608
|
+
Ke as TreeItem,
|
|
609
|
+
Be as TreeItemGroup,
|
|
610
|
+
Oe as TreeItemLabel,
|
|
611
|
+
Pe as TreeLoadMore,
|
|
612
|
+
le as treeItemLabelVariants,
|
|
613
|
+
Me as useTreeItem
|
|
550
614
|
};
|
|
551
615
|
//# sourceMappingURL=tree.js.map
|