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