asterui 0.12.22 → 0.12.24
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/Cascader.d.ts +55 -5
- package/dist/components/Tree.d.ts +78 -2
- package/dist/components/TreeSelect.d.ts +35 -2
- package/dist/index.d.ts +1 -1
- package/dist/index15.js +391 -137
- package/dist/index15.js.map +1 -1
- package/dist/index93.js +422 -194
- package/dist/index93.js.map +1 -1
- package/dist/index94.js +626 -263
- package/dist/index94.js.map +1 -1
- package/dist/index97.js +23 -23
- package/dist/index97.js.map +1 -1
- package/package.json +1 -1
package/dist/index94.js
CHANGED
|
@@ -1,298 +1,661 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as b, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Je, useId as Qe, useState as H, useRef as de, useMemo as se, useCallback as P, useEffect as ue } from "react";
|
|
3
|
+
function d(t, a, u) {
|
|
4
|
+
if (a === "title") {
|
|
5
|
+
const l = u?.label || "title";
|
|
6
|
+
return t[l];
|
|
7
|
+
}
|
|
8
|
+
if (a === "key") {
|
|
9
|
+
const l = u?.value || "key";
|
|
10
|
+
return t[l];
|
|
11
|
+
}
|
|
12
|
+
if (a === "children") {
|
|
13
|
+
const l = u?.children || "children";
|
|
14
|
+
return t[l];
|
|
15
|
+
}
|
|
9
16
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
function Ie(t, a = [], u) {
|
|
18
|
+
const l = [];
|
|
19
|
+
return t.forEach((h) => {
|
|
20
|
+
const p = d(h, "title", u), y = d(h, "children", u), w = [...a, p];
|
|
21
|
+
l.push({ node: h, path: w }), y && l.push(...Ie(y, w, u));
|
|
22
|
+
}), l;
|
|
23
|
+
}
|
|
24
|
+
function Xe(t, a) {
|
|
25
|
+
const u = [], l = (h) => {
|
|
26
|
+
h.forEach((p) => {
|
|
27
|
+
const y = d(p, "key", a), w = d(p, "children", a);
|
|
28
|
+
u.push(y), w && l(w);
|
|
14
29
|
});
|
|
15
30
|
};
|
|
16
|
-
return
|
|
31
|
+
return l(t), u;
|
|
17
32
|
}
|
|
18
|
-
function
|
|
19
|
-
for (const
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
function I(t, a, u) {
|
|
34
|
+
for (const l of t) {
|
|
35
|
+
const h = d(l, "key", u), p = d(l, "children", u);
|
|
36
|
+
if (h === a) return l;
|
|
37
|
+
if (p) {
|
|
38
|
+
const y = I(p, a, u);
|
|
39
|
+
if (y) return y;
|
|
24
40
|
}
|
|
25
41
|
}
|
|
26
42
|
return null;
|
|
27
43
|
}
|
|
28
|
-
function
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
44
|
+
function $e(t, a) {
|
|
45
|
+
const u = [], l = (h) => {
|
|
46
|
+
const p = d(h, "children", a);
|
|
47
|
+
p && p.forEach((y) => {
|
|
48
|
+
const w = d(y, "key", a);
|
|
49
|
+
u.push(w), l(y);
|
|
32
50
|
});
|
|
33
51
|
};
|
|
34
|
-
return
|
|
52
|
+
return l(t), u;
|
|
35
53
|
}
|
|
36
|
-
function
|
|
54
|
+
function fe(t, a, u, l = []) {
|
|
55
|
+
for (const h of t) {
|
|
56
|
+
const p = d(h, "key", u), y = d(h, "children", u);
|
|
57
|
+
if (p === a) return l;
|
|
58
|
+
if (y) {
|
|
59
|
+
const w = fe(y, a, u, [...l, p]);
|
|
60
|
+
if (w) return w;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function Ye({
|
|
37
66
|
node: t,
|
|
38
|
-
level:
|
|
67
|
+
level: a,
|
|
39
68
|
expanded: u,
|
|
40
|
-
selected:
|
|
41
|
-
checked:
|
|
42
|
-
indeterminate:
|
|
43
|
-
treeCheckable:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
69
|
+
selected: l,
|
|
70
|
+
checked: h,
|
|
71
|
+
indeterminate: p,
|
|
72
|
+
treeCheckable: y,
|
|
73
|
+
treeLine: w,
|
|
74
|
+
focused: O,
|
|
75
|
+
loading: E,
|
|
76
|
+
baseTestId: ie,
|
|
77
|
+
id: z,
|
|
78
|
+
fieldNames: V,
|
|
79
|
+
switcherIcon: B,
|
|
80
|
+
onToggle: S,
|
|
81
|
+
onSelect: Q,
|
|
82
|
+
onCheck: T,
|
|
83
|
+
renderChildren: U
|
|
48
84
|
}) {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
t.disabled || (
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
const C = d(t, "children", V), q = d(t, "title", V), M = d(t, "key", V), W = C && C.length > 0, L = t.isLeaf ?? !W, R = (k) => {
|
|
86
|
+
k.stopPropagation(), L || S(M);
|
|
87
|
+
}, X = () => {
|
|
88
|
+
t.disabled || (y ? T(M, t) : Q(M, t));
|
|
89
|
+
}, Y = (k) => {
|
|
90
|
+
k.stopPropagation(), t.disabled || T(M, t);
|
|
91
|
+
}, G = (k) => {
|
|
92
|
+
(k.key === "Enter" || k.key === " ") && (k.preventDefault(), X());
|
|
93
|
+
}, s = () => E ? /* @__PURE__ */ b("span", { className: "loading loading-spinner loading-xs" }) : B ? typeof B == "function" ? B({ expanded: u }) : B : /* @__PURE__ */ b(
|
|
94
|
+
"svg",
|
|
95
|
+
{
|
|
96
|
+
className: `w-3 h-3 transition-transform ${u ? "rotate-90" : ""}`,
|
|
97
|
+
fill: "none",
|
|
98
|
+
viewBox: "0 0 24 24",
|
|
99
|
+
stroke: "currentColor",
|
|
100
|
+
"aria-hidden": "true",
|
|
101
|
+
children: /* @__PURE__ */ b("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
return /* @__PURE__ */ F(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
className: "tree-select-node",
|
|
108
|
+
role: "treeitem",
|
|
109
|
+
id: z,
|
|
110
|
+
"aria-selected": l || h,
|
|
111
|
+
"aria-expanded": W ? u : void 0,
|
|
112
|
+
"data-testid": `${ie}-option-${M}`,
|
|
113
|
+
"data-state": l || h ? "selected" : "unselected",
|
|
114
|
+
"data-disabled": t.disabled || void 0,
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ F(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
className: [
|
|
120
|
+
"flex items-center py-1.5 px-2 cursor-pointer hover:bg-base-200 transition-colors outline-none",
|
|
121
|
+
(l || h) && "bg-primary/10 text-primary",
|
|
122
|
+
t.disabled && "opacity-50 cursor-not-allowed",
|
|
123
|
+
O && "ring-2 ring-primary ring-inset",
|
|
124
|
+
w && a > 0 && "border-l border-base-300 ml-2"
|
|
125
|
+
].filter(Boolean).join(" "),
|
|
126
|
+
style: { paddingLeft: `${a * 16 + 8}px` },
|
|
127
|
+
onClick: X,
|
|
128
|
+
onKeyDown: G,
|
|
129
|
+
tabIndex: -1,
|
|
130
|
+
children: [
|
|
131
|
+
/* @__PURE__ */ b(
|
|
132
|
+
"span",
|
|
78
133
|
{
|
|
79
|
-
className:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
134
|
+
className: [
|
|
135
|
+
"w-4 h-4 flex items-center justify-center flex-shrink-0 mr-1",
|
|
136
|
+
!L && "cursor-pointer"
|
|
137
|
+
].filter(Boolean).join(" "),
|
|
138
|
+
onClick: R,
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
children: !L && s()
|
|
84
141
|
}
|
|
85
|
-
)
|
|
142
|
+
),
|
|
143
|
+
y && /* @__PURE__ */ b("span", { className: "mr-2 flex-shrink-0", onClick: Y, children: /* @__PURE__ */ b(
|
|
144
|
+
"input",
|
|
145
|
+
{
|
|
146
|
+
type: "checkbox",
|
|
147
|
+
className: "checkbox checkbox-sm checkbox-primary",
|
|
148
|
+
checked: h,
|
|
149
|
+
ref: (k) => {
|
|
150
|
+
k && (k.indeterminate = p);
|
|
151
|
+
},
|
|
152
|
+
disabled: t.disabled,
|
|
153
|
+
onChange: X,
|
|
154
|
+
"aria-label": typeof q == "string" ? q : void 0,
|
|
155
|
+
tabIndex: -1
|
|
156
|
+
}
|
|
157
|
+
) }),
|
|
158
|
+
/* @__PURE__ */ b("span", { className: "flex-1 truncate select-none text-sm", children: q })
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
W && u && /* @__PURE__ */ b("div", { role: "group", children: U(C, a + 1) })
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const Ze = {
|
|
168
|
+
xs: "min-h-6 text-xs",
|
|
169
|
+
sm: "min-h-8 text-sm",
|
|
170
|
+
md: "min-h-10 text-base",
|
|
171
|
+
lg: "min-h-12 text-lg",
|
|
172
|
+
xl: "min-h-14 text-xl"
|
|
173
|
+
}, De = {
|
|
174
|
+
primary: "border-primary focus-within:border-primary",
|
|
175
|
+
secondary: "border-secondary focus-within:border-secondary",
|
|
176
|
+
accent: "border-accent focus-within:border-accent",
|
|
177
|
+
info: "border-info focus-within:border-info",
|
|
178
|
+
success: "border-success focus-within:border-success",
|
|
179
|
+
warning: "border-warning focus-within:border-warning",
|
|
180
|
+
error: "border-error focus-within:border-error"
|
|
181
|
+
}, Ne = {
|
|
182
|
+
error: "border-error focus-within:border-error",
|
|
183
|
+
warning: "border-warning focus-within:border-warning"
|
|
184
|
+
}, en = Je(
|
|
185
|
+
({
|
|
186
|
+
treeData: t,
|
|
187
|
+
value: a,
|
|
188
|
+
defaultValue: u = [],
|
|
189
|
+
onChange: l,
|
|
190
|
+
multiple: h = !1,
|
|
191
|
+
treeCheckable: p = !1,
|
|
192
|
+
treeCheckStrictly: y = !1,
|
|
193
|
+
showCheckedStrategy: w = "SHOW_ALL",
|
|
194
|
+
showSearch: O = !1,
|
|
195
|
+
searchValue: E,
|
|
196
|
+
onSearch: ie,
|
|
197
|
+
filterTreeNode: z,
|
|
198
|
+
placeholder: V = "Please select",
|
|
199
|
+
allowClear: B = !0,
|
|
200
|
+
disabled: S = !1,
|
|
201
|
+
treeDefaultExpandAll: Q = !1,
|
|
202
|
+
treeDefaultExpandedKeys: T = [],
|
|
203
|
+
treeExpandedKeys: U,
|
|
204
|
+
onTreeExpand: C,
|
|
205
|
+
size: q = "md",
|
|
206
|
+
color: M,
|
|
207
|
+
status: W,
|
|
208
|
+
maxTagCount: L,
|
|
209
|
+
maxTagPlaceholder: R,
|
|
210
|
+
labelInValue: X = !1,
|
|
211
|
+
treeLine: Y = !1,
|
|
212
|
+
loadData: G,
|
|
213
|
+
fieldNames: s,
|
|
214
|
+
open: k,
|
|
215
|
+
onDropdownVisibleChange: he,
|
|
216
|
+
suffixIcon: Ee,
|
|
217
|
+
switcherIcon: pe,
|
|
218
|
+
notFoundContent: Se = "No results found",
|
|
219
|
+
dropdownRender: be,
|
|
220
|
+
popupClassName: Me = "",
|
|
221
|
+
className: je = "",
|
|
222
|
+
"data-testid": Ae,
|
|
223
|
+
..._e
|
|
224
|
+
}, Z) => {
|
|
225
|
+
const K = Ae ?? "treeselect", D = Qe(), ge = `${D}-listbox`, [Be, Ce] = H(!1), [We, N] = H(""), [x, j] = H(null), [ye, ve] = H(/* @__PURE__ */ new Set()), oe = de(null), ce = de(null), ee = de(null), J = E ?? We, v = k ?? Be, xe = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], Re = xe(u), [He, ne] = H(Re), f = a !== void 0 ? xe(a) : He, Pe = se(() => Q ? Xe(t, s) : T, [t, Q, T, s]), [Fe, Oe] = H(Pe), $ = U ?? Fe, m = se(() => {
|
|
226
|
+
const e = [], r = (o) => {
|
|
227
|
+
o.forEach((n) => {
|
|
228
|
+
const i = d(n, "key", s), c = d(n, "children", s);
|
|
229
|
+
e.push({ key: i, node: n }), c && $.includes(i) && r(c);
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
return r(t), e;
|
|
233
|
+
}, [t, $, s]), A = P(
|
|
234
|
+
(e) => {
|
|
235
|
+
k === void 0 && Ce(e), he?.(e);
|
|
236
|
+
},
|
|
237
|
+
[k, he]
|
|
238
|
+
);
|
|
239
|
+
ue(() => {
|
|
240
|
+
const e = (r) => {
|
|
241
|
+
oe.current && !oe.current.contains(r.target) && (A(!1), E === void 0 && N(""));
|
|
242
|
+
};
|
|
243
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
244
|
+
}, [A, E]), ue(() => {
|
|
245
|
+
v && O && ce.current ? ce.current.focus() : v && ee.current && ee.current.focus();
|
|
246
|
+
}, [v, O]), ue(() => {
|
|
247
|
+
v && m.length > 0 ? f.length > 0 ? j(f[0]) : j(m[0].key) : v || j(null);
|
|
248
|
+
}, [v, m, f]);
|
|
249
|
+
const we = se(() => {
|
|
250
|
+
if (!J) return t;
|
|
251
|
+
const e = Ie(t, [], s), r = /* @__PURE__ */ new Set();
|
|
252
|
+
e.forEach(({ node: n }) => {
|
|
253
|
+
const i = d(n, "title", s), c = d(n, "key", s);
|
|
254
|
+
let g = !1;
|
|
255
|
+
z ? g = z(J, n) : g = (typeof i == "string" ? i : String(i)).toLowerCase().includes(J.toLowerCase()), g && r.add(c);
|
|
256
|
+
});
|
|
257
|
+
const o = (n) => n.map((i) => {
|
|
258
|
+
const c = d(i, "children", s), g = d(i, "key", s), _ = c && o(c).length > 0;
|
|
259
|
+
return r.has(g) || _ ? {
|
|
260
|
+
...i,
|
|
261
|
+
children: c ? o(c) : void 0
|
|
262
|
+
} : null;
|
|
263
|
+
}).filter(Boolean);
|
|
264
|
+
return o(t);
|
|
265
|
+
}, [t, J, z, s]), te = P(
|
|
266
|
+
async (e) => {
|
|
267
|
+
const r = I(t, e, s);
|
|
268
|
+
if (G && r) {
|
|
269
|
+
const n = d(r, "children", s);
|
|
270
|
+
if (!n || n.length === 0) {
|
|
271
|
+
ve((i) => new Set(i).add(e));
|
|
272
|
+
try {
|
|
273
|
+
await G(r);
|
|
274
|
+
} finally {
|
|
275
|
+
ve((i) => {
|
|
276
|
+
const c = new Set(i);
|
|
277
|
+
return c.delete(e), c;
|
|
278
|
+
});
|
|
86
279
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const o = $.includes(e) ? $.filter((n) => n !== e) : [...$, e];
|
|
283
|
+
U === void 0 && Oe(o), C?.(o);
|
|
284
|
+
},
|
|
285
|
+
[$, U, C, G, t, s]
|
|
286
|
+
), le = P(
|
|
287
|
+
(e, r) => {
|
|
288
|
+
let o;
|
|
289
|
+
h ? f.includes(e) ? o = f.filter((i) => i !== e) : o = [...f, e] : (o = [e], A(!1), E === void 0 && N("")), a === void 0 && ne(o);
|
|
290
|
+
const n = o.map((i) => {
|
|
291
|
+
const c = I(t, i, s);
|
|
292
|
+
return c ? d(c, "title", s) : i;
|
|
293
|
+
});
|
|
294
|
+
l?.(h ? o : o[0] || "", n);
|
|
295
|
+
},
|
|
296
|
+
[
|
|
297
|
+
f,
|
|
298
|
+
h,
|
|
299
|
+
a,
|
|
300
|
+
l,
|
|
301
|
+
t,
|
|
302
|
+
A,
|
|
303
|
+
E,
|
|
304
|
+
s
|
|
305
|
+
]
|
|
306
|
+
), ae = P(
|
|
307
|
+
(e, r) => {
|
|
308
|
+
const o = f.includes(e);
|
|
309
|
+
let n = [...f];
|
|
310
|
+
if (y)
|
|
311
|
+
o ? n = n.filter((c) => c !== e) : n.push(e);
|
|
312
|
+
else {
|
|
313
|
+
const c = $e(r, s);
|
|
314
|
+
o ? n = n.filter((g) => g !== e && !c.includes(g)) : (n.push(e), c.forEach((g) => {
|
|
315
|
+
n.includes(g) || n.push(g);
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
a === void 0 && ne(n);
|
|
319
|
+
const i = n.map((c) => {
|
|
320
|
+
const g = I(t, c, s);
|
|
321
|
+
return g ? d(g, "title", s) : c;
|
|
322
|
+
});
|
|
323
|
+
l?.(n, i);
|
|
324
|
+
},
|
|
325
|
+
[f, a, l, t, y, s]
|
|
326
|
+
), ze = (e) => {
|
|
327
|
+
e.stopPropagation();
|
|
328
|
+
const r = [];
|
|
329
|
+
a === void 0 && ne(r), l?.(h || p ? r : "", []);
|
|
330
|
+
}, Ve = (e, r) => {
|
|
331
|
+
r.stopPropagation();
|
|
332
|
+
const o = f.filter((i) => i !== e);
|
|
333
|
+
a === void 0 && ne(o);
|
|
334
|
+
const n = o.map((i) => {
|
|
335
|
+
const c = I(t, i, s);
|
|
336
|
+
return c ? d(c, "title", s) : i;
|
|
337
|
+
});
|
|
338
|
+
l?.(h || p ? o : o[0] || "", n);
|
|
339
|
+
}, Te = (e) => {
|
|
340
|
+
const r = e.target.value;
|
|
341
|
+
E === void 0 && N(r), ie?.(r);
|
|
342
|
+
}, Ue = (e) => {
|
|
343
|
+
if (!S)
|
|
344
|
+
switch (e.key) {
|
|
345
|
+
case "Enter":
|
|
346
|
+
case " ":
|
|
347
|
+
if (!v)
|
|
348
|
+
e.preventDefault(), A(!0);
|
|
349
|
+
else if (x) {
|
|
350
|
+
e.preventDefault();
|
|
351
|
+
const r = I(t, x, s);
|
|
352
|
+
r && !r.disabled && (p ? ae(x, r) : le(x, r));
|
|
100
353
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
value: i,
|
|
112
|
-
defaultValue: u = [],
|
|
113
|
-
onChange: c,
|
|
114
|
-
multiple: a = !1,
|
|
115
|
-
treeCheckable: m = !1,
|
|
116
|
-
showSearch: w = !1,
|
|
117
|
-
placeholder: M = "Please select",
|
|
118
|
-
allowClear: E = !0,
|
|
119
|
-
disabled: x = !1,
|
|
120
|
-
treeDefaultExpandAll: K = !1,
|
|
121
|
-
treeDefaultExpandedKeys: N = [],
|
|
122
|
-
treeExpandedKeys: p,
|
|
123
|
-
onTreeExpand: C,
|
|
124
|
-
size: B = "md",
|
|
125
|
-
className: P = "",
|
|
126
|
-
...f
|
|
127
|
-
}) {
|
|
128
|
-
const [y, T] = j(!1), [L, V] = j(""), W = G(null), Q = G(null), A = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], U = A(u), [X, S] = j(U), d = i !== void 0 ? A(i) : X, Y = z(() => K ? ie(t) : N, []), [Z, D] = j(Y), g = p ?? Z;
|
|
129
|
-
re(() => {
|
|
130
|
-
const e = (s) => {
|
|
131
|
-
W.current && !W.current.contains(s.target) && (T(!1), V(""));
|
|
132
|
-
};
|
|
133
|
-
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
134
|
-
}, []);
|
|
135
|
-
const I = z(() => {
|
|
136
|
-
if (!L) return t;
|
|
137
|
-
const e = J(t), s = /* @__PURE__ */ new Set();
|
|
138
|
-
e.forEach(({ node: r }) => {
|
|
139
|
-
(typeof r.title == "string" ? r.title : String(r.title)).toLowerCase().includes(L.toLowerCase()) && s.add(r.key);
|
|
140
|
-
});
|
|
141
|
-
const n = (r) => r.map((l) => {
|
|
142
|
-
const $ = l.children && n(l.children).length > 0;
|
|
143
|
-
return s.has(l.key) || $ ? {
|
|
144
|
-
...l,
|
|
145
|
-
children: l.children ? n(l.children) : void 0
|
|
146
|
-
} : null;
|
|
147
|
-
}).filter(Boolean);
|
|
148
|
-
return n(t);
|
|
149
|
-
}, [t, L]), O = b(
|
|
150
|
-
(e) => {
|
|
151
|
-
const s = g.includes(e) ? g.filter((n) => n !== e) : [...g, e];
|
|
152
|
-
p === void 0 && D(s), C?.(s);
|
|
153
|
-
},
|
|
154
|
-
[g, p, C]
|
|
155
|
-
), R = b(
|
|
156
|
-
(e, s) => {
|
|
157
|
-
let n;
|
|
158
|
-
a ? d.includes(e) ? n = d.filter((l) => l !== e) : n = [...d, e] : (n = [e], T(!1), V("")), i === void 0 && S(n);
|
|
159
|
-
const r = n.map((l) => k(t, l)?.title || l);
|
|
160
|
-
c?.(a ? n : n[0] || "", r);
|
|
161
|
-
},
|
|
162
|
-
[d, a, i, c, t]
|
|
163
|
-
), F = b(
|
|
164
|
-
(e, s) => {
|
|
165
|
-
const n = d.includes(e);
|
|
166
|
-
let r = [...d];
|
|
167
|
-
const l = H(s);
|
|
168
|
-
n ? r = r.filter((h) => h !== e && !l.includes(h)) : (r.push(e), l.forEach((h) => {
|
|
169
|
-
r.includes(h) || r.push(h);
|
|
170
|
-
})), i === void 0 && S(r);
|
|
171
|
-
const $ = r.map((h) => k(t, h)?.title || h);
|
|
172
|
-
c?.(r, $);
|
|
173
|
-
},
|
|
174
|
-
[d, i, c, t]
|
|
175
|
-
), ee = (e) => {
|
|
176
|
-
e.stopPropagation();
|
|
177
|
-
const s = [];
|
|
178
|
-
i === void 0 && S(s), c?.(a ? s : "", []);
|
|
179
|
-
}, te = (e, s) => {
|
|
180
|
-
s.stopPropagation();
|
|
181
|
-
const n = d.filter((l) => l !== e);
|
|
182
|
-
i === void 0 && S(n);
|
|
183
|
-
const r = n.map((l) => k(t, l)?.title || l);
|
|
184
|
-
c?.(a ? n : n[0] || "", r);
|
|
185
|
-
}, _ = b(
|
|
186
|
-
(e) => {
|
|
187
|
-
if (!e.children || e.children.length === 0)
|
|
188
|
-
return { checked: d.includes(e.key), indeterminate: !1 };
|
|
189
|
-
const s = H(e), n = s.filter((r) => d.includes(r));
|
|
190
|
-
return n.length === 0 ? { checked: d.includes(e.key), indeterminate: !1 } : n.length === s.length ? { checked: !0, indeterminate: !1 } : { checked: !1, indeterminate: !0 };
|
|
191
|
-
},
|
|
192
|
-
[d]
|
|
193
|
-
), q = b(
|
|
194
|
-
(e, s) => e.map((n) => {
|
|
195
|
-
const { checked: r, indeterminate: l } = _(n);
|
|
196
|
-
return /* @__PURE__ */ o(
|
|
197
|
-
le,
|
|
198
|
-
{
|
|
199
|
-
node: n,
|
|
200
|
-
level: s,
|
|
201
|
-
expanded: g.includes(n.key),
|
|
202
|
-
selected: d.includes(n.key),
|
|
203
|
-
checked: r,
|
|
204
|
-
indeterminate: l,
|
|
205
|
-
treeCheckable: m,
|
|
206
|
-
onToggle: O,
|
|
207
|
-
onSelect: R,
|
|
208
|
-
onCheck: F,
|
|
209
|
-
renderChildren: q
|
|
210
|
-
},
|
|
211
|
-
n.key
|
|
212
|
-
);
|
|
213
|
-
}),
|
|
214
|
-
[g, d, m, O, R, F, _]
|
|
215
|
-
), ne = z(() => d.length === 0 ? null : a || m ? d.map((s) => {
|
|
216
|
-
const n = k(t, s);
|
|
217
|
-
return /* @__PURE__ */ v(
|
|
218
|
-
"span",
|
|
219
|
-
{
|
|
220
|
-
className: "inline-flex items-center gap-1 px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1",
|
|
221
|
-
children: [
|
|
222
|
-
n?.title || s,
|
|
223
|
-
/* @__PURE__ */ o(
|
|
224
|
-
"button",
|
|
225
|
-
{
|
|
226
|
-
type: "button",
|
|
227
|
-
className: "hover:text-error",
|
|
228
|
-
onClick: (r) => te(s, r),
|
|
229
|
-
children: /* @__PURE__ */ o("svg", { className: "w-3 h-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ o("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
354
|
+
break;
|
|
355
|
+
case "Escape":
|
|
356
|
+
e.preventDefault(), A(!1), E === void 0 && N(""), ee.current?.focus();
|
|
357
|
+
break;
|
|
358
|
+
case "ArrowDown":
|
|
359
|
+
if (e.preventDefault(), !v)
|
|
360
|
+
A(!0);
|
|
361
|
+
else {
|
|
362
|
+
const r = m.findIndex((n) => n.key === x), o = r < m.length - 1 ? r + 1 : 0;
|
|
363
|
+
j(m[o]?.key || null);
|
|
230
364
|
}
|
|
231
|
-
|
|
232
|
-
|
|
365
|
+
break;
|
|
366
|
+
case "ArrowUp":
|
|
367
|
+
if (e.preventDefault(), v) {
|
|
368
|
+
const r = m.findIndex((n) => n.key === x), o = r > 0 ? r - 1 : m.length - 1;
|
|
369
|
+
j(m[o]?.key || null);
|
|
370
|
+
}
|
|
371
|
+
break;
|
|
372
|
+
case "ArrowRight":
|
|
373
|
+
if (v && x) {
|
|
374
|
+
e.preventDefault();
|
|
375
|
+
const r = I(t, x, s), o = r ? d(r, "children", s) : void 0;
|
|
376
|
+
o && o.length > 0 && !$.includes(x) && te(x);
|
|
377
|
+
}
|
|
378
|
+
break;
|
|
379
|
+
case "ArrowLeft":
|
|
380
|
+
if (v && x)
|
|
381
|
+
if (e.preventDefault(), $.includes(x))
|
|
382
|
+
te(x);
|
|
383
|
+
else {
|
|
384
|
+
const r = fe(t, x, s);
|
|
385
|
+
r && r.length > 0 && j(r[r.length - 1]);
|
|
386
|
+
}
|
|
387
|
+
break;
|
|
388
|
+
case "Home":
|
|
389
|
+
v && (e.preventDefault(), j(m[0]?.key || null));
|
|
390
|
+
break;
|
|
391
|
+
case "End":
|
|
392
|
+
v && (e.preventDefault(), j(m[m.length - 1]?.key || null));
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
}, ke = P(
|
|
396
|
+
(e) => {
|
|
397
|
+
const r = d(e, "key", s), o = d(e, "children", s);
|
|
398
|
+
if (y)
|
|
399
|
+
return { checked: f.includes(r), indeterminate: !1 };
|
|
400
|
+
if (!o || o.length === 0)
|
|
401
|
+
return { checked: f.includes(r), indeterminate: !1 };
|
|
402
|
+
const n = $e(e, s), i = n.filter((c) => f.includes(c));
|
|
403
|
+
return i.length === 0 ? { checked: f.includes(r), indeterminate: !1 } : i.length === n.length ? { checked: !0, indeterminate: !1 } : { checked: !1, indeterminate: !0 };
|
|
233
404
|
},
|
|
405
|
+
[f, y, s]
|
|
406
|
+
), me = P(
|
|
407
|
+
(e, r) => e.map((o) => {
|
|
408
|
+
const n = d(o, "key", s), { checked: i, indeterminate: c } = ke(o);
|
|
409
|
+
return /* @__PURE__ */ b(
|
|
410
|
+
Ye,
|
|
411
|
+
{
|
|
412
|
+
node: o,
|
|
413
|
+
level: r,
|
|
414
|
+
expanded: $.includes(n),
|
|
415
|
+
selected: f.includes(n),
|
|
416
|
+
checked: i,
|
|
417
|
+
indeterminate: c,
|
|
418
|
+
treeCheckable: p,
|
|
419
|
+
treeLine: Y,
|
|
420
|
+
focused: x === n,
|
|
421
|
+
loading: ye.has(n),
|
|
422
|
+
baseTestId: K,
|
|
423
|
+
id: `${D}-option-${n}`,
|
|
424
|
+
fieldNames: s,
|
|
425
|
+
switcherIcon: pe,
|
|
426
|
+
onToggle: te,
|
|
427
|
+
onSelect: le,
|
|
428
|
+
onCheck: ae,
|
|
429
|
+
renderChildren: me
|
|
430
|
+
},
|
|
431
|
+
n
|
|
432
|
+
);
|
|
433
|
+
}),
|
|
434
|
+
[
|
|
435
|
+
$,
|
|
436
|
+
f,
|
|
437
|
+
p,
|
|
438
|
+
Y,
|
|
439
|
+
x,
|
|
440
|
+
ye,
|
|
441
|
+
K,
|
|
442
|
+
D,
|
|
443
|
+
s,
|
|
444
|
+
pe,
|
|
445
|
+
te,
|
|
446
|
+
le,
|
|
447
|
+
ae,
|
|
448
|
+
ke
|
|
449
|
+
]
|
|
450
|
+
), qe = se(() => {
|
|
451
|
+
if (f.length === 0) return null;
|
|
452
|
+
let e = f;
|
|
453
|
+
if ((p || h) && w !== "SHOW_ALL" && (w === "SHOW_PARENT" ? e = f.filter((n) => {
|
|
454
|
+
const i = fe(t, n, s);
|
|
455
|
+
return i ? !i.some((c) => f.includes(c)) : !0;
|
|
456
|
+
}) : w === "SHOW_CHILD" && (e = f.filter((n) => {
|
|
457
|
+
const i = I(t, n, s);
|
|
458
|
+
if (!i) return !0;
|
|
459
|
+
const c = d(i, "children", s);
|
|
460
|
+
return !c || c.length === 0;
|
|
461
|
+
}))), h || p) {
|
|
462
|
+
let n = e, i = 0;
|
|
463
|
+
L !== void 0 && L !== "responsive" && e.length > L && (n = e.slice(0, L), i = e.length - L);
|
|
464
|
+
const c = n.map((g) => {
|
|
465
|
+
const _ = I(t, g, s), re = _ ? d(_, "title", s) : g;
|
|
466
|
+
return /* @__PURE__ */ F(
|
|
467
|
+
"span",
|
|
468
|
+
{
|
|
469
|
+
className: "inline-flex items-center gap-1 px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1",
|
|
470
|
+
"data-testid": `${K}-tag-${g}`,
|
|
471
|
+
children: [
|
|
472
|
+
re,
|
|
473
|
+
/* @__PURE__ */ b(
|
|
474
|
+
"button",
|
|
475
|
+
{
|
|
476
|
+
type: "button",
|
|
477
|
+
className: "hover:text-error",
|
|
478
|
+
onClick: (Ge) => Ve(g, Ge),
|
|
479
|
+
"aria-label": `Remove ${typeof re == "string" ? re : g}`,
|
|
480
|
+
children: /* @__PURE__ */ b(
|
|
481
|
+
"svg",
|
|
482
|
+
{
|
|
483
|
+
className: "w-3 h-3",
|
|
484
|
+
fill: "none",
|
|
485
|
+
viewBox: "0 0 24 24",
|
|
486
|
+
stroke: "currentColor",
|
|
487
|
+
"aria-hidden": "true",
|
|
488
|
+
children: /* @__PURE__ */ b(
|
|
489
|
+
"path",
|
|
490
|
+
{
|
|
491
|
+
strokeLinecap: "round",
|
|
492
|
+
strokeLinejoin: "round",
|
|
493
|
+
strokeWidth: 2,
|
|
494
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
495
|
+
}
|
|
496
|
+
)
|
|
497
|
+
}
|
|
498
|
+
)
|
|
499
|
+
}
|
|
500
|
+
)
|
|
501
|
+
]
|
|
502
|
+
},
|
|
503
|
+
g
|
|
504
|
+
);
|
|
505
|
+
});
|
|
506
|
+
if (i > 0) {
|
|
507
|
+
const g = e.slice(L), _ = typeof R == "function" ? R(g) : R || `+${i} more`;
|
|
508
|
+
c.push(
|
|
509
|
+
/* @__PURE__ */ b(
|
|
510
|
+
"span",
|
|
511
|
+
{
|
|
512
|
+
className: "inline-flex items-center px-2 py-0.5 bg-base-200 rounded text-sm mr-1 mb-1",
|
|
513
|
+
children: _
|
|
514
|
+
},
|
|
515
|
+
"__more__"
|
|
516
|
+
)
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
return c;
|
|
520
|
+
}
|
|
521
|
+
const r = I(t, f[0], s);
|
|
522
|
+
return r ? d(r, "title", s) : f[0];
|
|
523
|
+
}, [
|
|
524
|
+
f,
|
|
525
|
+
t,
|
|
526
|
+
h,
|
|
527
|
+
p,
|
|
528
|
+
w,
|
|
529
|
+
L,
|
|
530
|
+
R,
|
|
531
|
+
K,
|
|
234
532
|
s
|
|
235
|
-
)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
/* @__PURE__ */
|
|
533
|
+
]), Le = W ? Ne[W] : M ? De[M] : "", Ke = /* @__PURE__ */ b("div", { className: "py-1", role: "tree", "aria-label": "Tree options", children: we.length > 0 ? me(we, 0) : /* @__PURE__ */ b(
|
|
534
|
+
"div",
|
|
535
|
+
{
|
|
536
|
+
className: "px-4 py-2 text-base-content/50 text-sm text-center",
|
|
537
|
+
"data-testid": `${K}-empty`,
|
|
538
|
+
children: Se
|
|
539
|
+
}
|
|
540
|
+
) });
|
|
541
|
+
return /* @__PURE__ */ F(
|
|
244
542
|
"div",
|
|
245
543
|
{
|
|
246
|
-
|
|
247
|
-
"
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
544
|
+
ref: (e) => {
|
|
545
|
+
oe.current = e, typeof Z == "function" ? Z(e) : Z && (Z.current = e);
|
|
546
|
+
},
|
|
547
|
+
className: `relative ${je}`,
|
|
548
|
+
"data-testid": K,
|
|
549
|
+
"data-state": v ? "open" : "closed",
|
|
550
|
+
"data-disabled": S || void 0,
|
|
551
|
+
onKeyDown: Ue,
|
|
552
|
+
..._e,
|
|
253
553
|
children: [
|
|
254
|
-
/* @__PURE__ */
|
|
255
|
-
|
|
256
|
-
"button",
|
|
554
|
+
/* @__PURE__ */ F(
|
|
555
|
+
"div",
|
|
257
556
|
{
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
557
|
+
ref: ee,
|
|
558
|
+
role: "combobox",
|
|
559
|
+
"aria-expanded": v,
|
|
560
|
+
"aria-haspopup": "tree",
|
|
561
|
+
"aria-owns": v ? ge : void 0,
|
|
562
|
+
"aria-activedescendant": v && x ? `${D}-option-${x}` : void 0,
|
|
563
|
+
"aria-disabled": S,
|
|
564
|
+
tabIndex: S ? -1 : 0,
|
|
565
|
+
className: [
|
|
566
|
+
"input input-bordered flex items-center gap-2 cursor-pointer flex-wrap",
|
|
567
|
+
Ze[q],
|
|
568
|
+
Le,
|
|
569
|
+
S && "input-disabled opacity-50 cursor-not-allowed",
|
|
570
|
+
v && !Le && "input-primary"
|
|
571
|
+
].filter(Boolean).join(" "),
|
|
572
|
+
onClick: () => !S && A(!v),
|
|
573
|
+
"data-testid": `${K}-trigger`,
|
|
574
|
+
children: [
|
|
575
|
+
/* @__PURE__ */ b("div", { className: "flex-1 flex flex-wrap items-center gap-1 min-w-0", children: qe || /* @__PURE__ */ b("span", { className: "text-base-content/50", children: V }) }),
|
|
576
|
+
B && f.length > 0 && !S && /* @__PURE__ */ b(
|
|
577
|
+
"button",
|
|
578
|
+
{
|
|
579
|
+
type: "button",
|
|
580
|
+
className: "hover:text-error flex-shrink-0",
|
|
581
|
+
onClick: ze,
|
|
582
|
+
"aria-label": "Clear selection",
|
|
583
|
+
"data-testid": `${K}-clear`,
|
|
584
|
+
children: /* @__PURE__ */ b(
|
|
585
|
+
"svg",
|
|
586
|
+
{
|
|
587
|
+
className: "w-4 h-4",
|
|
588
|
+
fill: "none",
|
|
589
|
+
viewBox: "0 0 24 24",
|
|
590
|
+
stroke: "currentColor",
|
|
591
|
+
"aria-hidden": "true",
|
|
592
|
+
children: /* @__PURE__ */ b(
|
|
593
|
+
"path",
|
|
594
|
+
{
|
|
595
|
+
strokeLinecap: "round",
|
|
596
|
+
strokeLinejoin: "round",
|
|
597
|
+
strokeWidth: 2,
|
|
598
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
599
|
+
}
|
|
600
|
+
)
|
|
601
|
+
}
|
|
602
|
+
)
|
|
603
|
+
}
|
|
604
|
+
),
|
|
605
|
+
Ee || /* @__PURE__ */ b(
|
|
606
|
+
"svg",
|
|
607
|
+
{
|
|
608
|
+
className: `w-4 h-4 flex-shrink-0 transition-transform ${v ? "rotate-180" : ""}`,
|
|
609
|
+
fill: "none",
|
|
610
|
+
viewBox: "0 0 24 24",
|
|
611
|
+
stroke: "currentColor",
|
|
612
|
+
"aria-hidden": "true",
|
|
613
|
+
children: /* @__PURE__ */ b(
|
|
614
|
+
"path",
|
|
615
|
+
{
|
|
616
|
+
strokeLinecap: "round",
|
|
617
|
+
strokeLinejoin: "round",
|
|
618
|
+
strokeWidth: 2,
|
|
619
|
+
d: "M19 9l-7 7-7-7"
|
|
620
|
+
}
|
|
621
|
+
)
|
|
622
|
+
}
|
|
623
|
+
)
|
|
624
|
+
]
|
|
262
625
|
}
|
|
263
626
|
),
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
"
|
|
627
|
+
v && /* @__PURE__ */ F(
|
|
628
|
+
"div",
|
|
266
629
|
{
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
630
|
+
id: ge,
|
|
631
|
+
className: `absolute z-50 mt-1 w-full bg-base-100 border border-base-300 rounded-lg shadow-lg max-h-64 overflow-auto ${Me}`,
|
|
632
|
+
"data-testid": `${K}-dropdown`,
|
|
633
|
+
children: [
|
|
634
|
+
O && /* @__PURE__ */ b("div", { className: "p-2 border-b border-base-300", children: /* @__PURE__ */ b(
|
|
635
|
+
"input",
|
|
636
|
+
{
|
|
637
|
+
ref: ce,
|
|
638
|
+
type: "text",
|
|
639
|
+
className: "input input-bordered input-sm w-full",
|
|
640
|
+
placeholder: "Search...",
|
|
641
|
+
value: J,
|
|
642
|
+
onChange: Te,
|
|
643
|
+
onClick: (e) => e.stopPropagation(),
|
|
644
|
+
"aria-label": "Search tree options",
|
|
645
|
+
"data-testid": `${K}-search`
|
|
646
|
+
}
|
|
647
|
+
) }),
|
|
648
|
+
be ? be(Ke) : Ke
|
|
649
|
+
]
|
|
272
650
|
}
|
|
273
651
|
)
|
|
274
652
|
]
|
|
275
653
|
}
|
|
276
|
-
)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
{
|
|
281
|
-
ref: Q,
|
|
282
|
-
type: "text",
|
|
283
|
-
className: "input input-bordered input-sm w-full",
|
|
284
|
-
placeholder: "Search...",
|
|
285
|
-
value: L,
|
|
286
|
-
onChange: (e) => V(e.target.value),
|
|
287
|
-
onClick: (e) => e.stopPropagation(),
|
|
288
|
-
autoFocus: !0
|
|
289
|
-
}
|
|
290
|
-
) }),
|
|
291
|
-
/* @__PURE__ */ o("div", { className: "py-1", children: I.length > 0 ? q(I, 0) : /* @__PURE__ */ o("div", { className: "px-4 py-2 text-base-content/50 text-sm text-center", children: "No results found" }) })
|
|
292
|
-
] })
|
|
293
|
-
] });
|
|
294
|
-
}
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
);
|
|
657
|
+
en.displayName = "TreeSelect";
|
|
295
658
|
export {
|
|
296
|
-
|
|
659
|
+
en as TreeSelect
|
|
297
660
|
};
|
|
298
661
|
//# sourceMappingURL=index94.js.map
|