asterui 0.12.23 → 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/package.json +1 -1
package/dist/index15.js
CHANGED
|
@@ -1,161 +1,415 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import { jsxs as x, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Je, useState as k, useCallback as R, useRef as q, useId as Qe, useMemo as G, useEffect as J } from "react";
|
|
3
|
+
function xe(L, b, N) {
|
|
4
|
+
return L[b] ?? L[N];
|
|
5
|
+
}
|
|
6
|
+
const Xe = Je(({
|
|
7
|
+
options: L,
|
|
5
8
|
value: b,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
defaultValue: N,
|
|
10
|
+
onChange: v,
|
|
11
|
+
placeholder: Q = "Please select",
|
|
12
|
+
disabled: y = !1,
|
|
13
|
+
allowClear: ke = !0,
|
|
14
|
+
expandTrigger: ye = "click",
|
|
15
|
+
changeOnSelect: I = !1,
|
|
16
|
+
displayRender: X,
|
|
17
|
+
size: Y = "md",
|
|
18
|
+
color: Z,
|
|
19
|
+
status: _,
|
|
20
|
+
showSearch: u = !1,
|
|
21
|
+
notFoundContent: je = "No results found",
|
|
22
|
+
loadData: ee,
|
|
23
|
+
fieldNames: K,
|
|
24
|
+
open: te,
|
|
25
|
+
onDropdownVisibleChange: ne,
|
|
26
|
+
popupClassName: $e = "",
|
|
27
|
+
dropdownRender: re,
|
|
28
|
+
multiple: w = !1,
|
|
29
|
+
maxTagCount: A,
|
|
30
|
+
className: Ce = "",
|
|
31
|
+
"aria-label": Le,
|
|
32
|
+
"data-testid": Ne,
|
|
33
|
+
...Pe
|
|
34
|
+
}, E) => {
|
|
35
|
+
const P = Ne ?? "cascader", W = te !== void 0, [Oe, De] = k(!1), i = W ? te : Oe, p = R((e) => {
|
|
36
|
+
W || De(e), ne?.(e);
|
|
37
|
+
}, [W, ne]), [j, O] = k(b ?? N ?? []), [f, D] = k(
|
|
38
|
+
b ? [b] : N ? [N] : []
|
|
39
|
+
), [se, $] = k([]), [d, h] = k({ column: 0, row: 0 }), [M, S] = k(""), [oe, ae] = k(/* @__PURE__ */ new Set()), V = q(null), le = q(null), Me = q(null), z = Qe(), Se = `${z}-input`, ie = `${z}-listbox`, ce = K?.label ?? "label", de = K?.value ?? "value", T = K?.children ?? "children", U = R((e) => ({
|
|
40
|
+
value: xe(e, de, "value"),
|
|
41
|
+
label: xe(e, ce, "label"),
|
|
42
|
+
disabled: e.disabled,
|
|
43
|
+
isLeaf: e.isLeaf,
|
|
44
|
+
children: e[T] ? e[T].map(U) : void 0
|
|
45
|
+
}), [ce, de, T]), m = G(
|
|
46
|
+
() => L.map((e) => U(e)),
|
|
47
|
+
[L, U]
|
|
48
|
+
);
|
|
49
|
+
J(() => {
|
|
50
|
+
b !== void 0 && (O(b), w && D([b]));
|
|
51
|
+
}, [b, w]), J(() => {
|
|
52
|
+
const e = (t) => {
|
|
53
|
+
V.current && !V.current.contains(t.target) && (p(!1), $([]), S(""));
|
|
22
54
|
};
|
|
23
|
-
if (
|
|
55
|
+
if (i)
|
|
24
56
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
25
|
-
}, [
|
|
26
|
-
const
|
|
27
|
-
if (e === 0) return
|
|
28
|
-
let
|
|
29
|
-
for (let
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
32
|
-
|
|
57
|
+
}, [i, p]);
|
|
58
|
+
const ue = R((e, t) => {
|
|
59
|
+
if (e === 0) return m;
|
|
60
|
+
let n = m;
|
|
61
|
+
for (let r = 0; r < e; r++) {
|
|
62
|
+
const s = n.find((o) => o.value === t[r]);
|
|
63
|
+
if (!s?.children) return [];
|
|
64
|
+
n = s.children;
|
|
65
|
+
}
|
|
66
|
+
return n;
|
|
67
|
+
}, [m]), B = R((e) => {
|
|
68
|
+
const t = [];
|
|
69
|
+
let n = m;
|
|
70
|
+
for (const r of e) {
|
|
71
|
+
const s = n.find((o) => o.value === r);
|
|
72
|
+
if (!s) break;
|
|
73
|
+
t.push(s), n = s.children || [];
|
|
33
74
|
}
|
|
34
75
|
return t;
|
|
35
|
-
}, [
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
76
|
+
}, [m]), fe = R(() => {
|
|
77
|
+
const e = [], t = (n, r, s) => {
|
|
78
|
+
for (const o of n) {
|
|
79
|
+
const a = [...r, o], g = [...s, o.value];
|
|
80
|
+
!o.children || o.children.length === 0 ? e.push({ path: a, values: g }) : (I && e.push({ path: a, values: g }), t(o.children, a, g));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return t(m, [], []), e;
|
|
84
|
+
}, [m, I]), c = G(() => {
|
|
85
|
+
if (!u || !M.trim()) return null;
|
|
86
|
+
const e = fe(), t = M.toLowerCase(), n = typeof u == "object" && u.filter ? u.filter : (r, s) => s.some(
|
|
87
|
+
(o) => String(o.label).toLowerCase().includes(r.toLowerCase())
|
|
88
|
+
);
|
|
89
|
+
return e.filter(({ path: r }) => n(t, r));
|
|
90
|
+
}, [u, M, fe]), C = i && se.length > 0 ? se : j, F = G(() => {
|
|
91
|
+
if (c) return [];
|
|
92
|
+
const e = [];
|
|
93
|
+
e.push(m);
|
|
94
|
+
for (let t = 0; t < C.length; t++) {
|
|
95
|
+
const n = ue(t + 1, C);
|
|
96
|
+
n.length > 0 && e.push(n);
|
|
42
97
|
}
|
|
43
|
-
return
|
|
44
|
-
}, [c]),
|
|
45
|
-
v.push(c);
|
|
46
|
-
for (let e = 0; e < h.length; e++) {
|
|
47
|
-
const s = z(e + 1, h);
|
|
48
|
-
s.length > 0 && v.push(s);
|
|
49
|
-
}
|
|
50
|
-
const K = (e, s) => {
|
|
98
|
+
return e;
|
|
99
|
+
}, [c, m, C, ue]), he = async (e, t) => {
|
|
51
100
|
if (e.disabled) return;
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
101
|
+
const n = [...C.slice(0, t), e.value], r = B(n);
|
|
102
|
+
if (ee && !e.children && !e.isLeaf) {
|
|
103
|
+
const s = e.value;
|
|
104
|
+
if (!oe.has(s)) {
|
|
105
|
+
ae((o) => new Set(o).add(s));
|
|
106
|
+
try {
|
|
107
|
+
await ee(r);
|
|
108
|
+
} finally {
|
|
109
|
+
ae((o) => {
|
|
110
|
+
const a = new Set(o);
|
|
111
|
+
return a.delete(s), a;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
$(n);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (e.children && e.children.length > 0)
|
|
119
|
+
$(n), I && (O(n), v?.(n, r));
|
|
120
|
+
else if (w) {
|
|
121
|
+
const s = n.join("/"), o = f.some((g) => g.join("/") === s);
|
|
122
|
+
let a;
|
|
123
|
+
o ? a = f.filter((g) => g.join("/") !== s) : a = [...f, n], D(a);
|
|
124
|
+
} else
|
|
125
|
+
O(n), p(!1), $([]), S(""), v?.(n, r);
|
|
126
|
+
}, be = (e, t) => {
|
|
127
|
+
if (w) {
|
|
128
|
+
const n = e.join("/"), r = f.some((o) => o.join("/") === n);
|
|
129
|
+
let s;
|
|
130
|
+
r ? s = f.filter((o) => o.join("/") !== n) : s = [...f, e], D(s);
|
|
131
|
+
} else
|
|
132
|
+
O(e), p(!1), S(""), v?.(e, t);
|
|
133
|
+
}, Fe = (e, t) => {
|
|
134
|
+
if (ye !== "hover" || e.disabled) return;
|
|
135
|
+
const n = [...C.slice(0, t), e.value];
|
|
136
|
+
$(n);
|
|
137
|
+
}, Re = (e) => {
|
|
138
|
+
e.stopPropagation(), w ? (D([]), v?.([], [])) : (O([]), v?.([], []));
|
|
139
|
+
}, Ae = (e, t) => {
|
|
140
|
+
t.stopPropagation();
|
|
141
|
+
const n = e.join("/"), r = f.filter((s) => s.join("/") !== n);
|
|
142
|
+
D(r), r.length > 0 ? v?.(r[r.length - 1], B(r[r.length - 1])) : v?.([], []);
|
|
143
|
+
}, Ee = (e) => {
|
|
144
|
+
if (!y)
|
|
62
145
|
switch (e.key) {
|
|
63
146
|
case "Enter":
|
|
147
|
+
if (e.preventDefault(), !i)
|
|
148
|
+
p(!0);
|
|
149
|
+
else if (c && c.length > 0) {
|
|
150
|
+
const { values: t, path: n } = c[d.row] || {};
|
|
151
|
+
t && be(t, n);
|
|
152
|
+
} else {
|
|
153
|
+
const t = F[d.column];
|
|
154
|
+
if (t) {
|
|
155
|
+
const n = t[d.row];
|
|
156
|
+
n && he(n, d.column);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
64
160
|
case " ":
|
|
65
|
-
e.preventDefault(),
|
|
161
|
+
u || (e.preventDefault(), p(!i));
|
|
66
162
|
break;
|
|
67
163
|
case "Escape":
|
|
68
|
-
e.preventDefault(),
|
|
164
|
+
e.preventDefault(), p(!1), $([]), S("");
|
|
165
|
+
break;
|
|
166
|
+
case "ArrowDown":
|
|
167
|
+
if (e.preventDefault(), !i)
|
|
168
|
+
p(!0);
|
|
169
|
+
else if (c)
|
|
170
|
+
h((t) => ({
|
|
171
|
+
...t,
|
|
172
|
+
row: Math.min(t.row + 1, c.length - 1)
|
|
173
|
+
}));
|
|
174
|
+
else {
|
|
175
|
+
const t = F[d.column];
|
|
176
|
+
t && h((n) => ({
|
|
177
|
+
...n,
|
|
178
|
+
row: Math.min(n.row + 1, t.length - 1)
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case "ArrowUp":
|
|
183
|
+
e.preventDefault(), h(c ? (t) => ({
|
|
184
|
+
...t,
|
|
185
|
+
row: Math.max(t.row - 1, 0)
|
|
186
|
+
}) : (t) => ({
|
|
187
|
+
...t,
|
|
188
|
+
row: Math.max(t.row - 1, 0)
|
|
189
|
+
}));
|
|
190
|
+
break;
|
|
191
|
+
case "ArrowRight":
|
|
192
|
+
e.preventDefault(), !c && d.column < F.length - 1 && h((t) => ({
|
|
193
|
+
column: t.column + 1,
|
|
194
|
+
row: 0
|
|
195
|
+
}));
|
|
196
|
+
break;
|
|
197
|
+
case "ArrowLeft":
|
|
198
|
+
e.preventDefault(), !c && d.column > 0 && h((t) => ({
|
|
199
|
+
column: t.column - 1,
|
|
200
|
+
row: 0
|
|
201
|
+
}));
|
|
202
|
+
break;
|
|
203
|
+
case "Home":
|
|
204
|
+
e.preventDefault(), h((t) => ({ ...t, row: 0 }));
|
|
205
|
+
break;
|
|
206
|
+
case "End":
|
|
207
|
+
if (e.preventDefault(), c)
|
|
208
|
+
h((t) => ({ ...t, row: c.length - 1 }));
|
|
209
|
+
else {
|
|
210
|
+
const t = F[d.column];
|
|
211
|
+
t && h((n) => ({ ...n, row: t.length - 1 }));
|
|
212
|
+
}
|
|
69
213
|
break;
|
|
70
214
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
215
|
+
};
|
|
216
|
+
J(() => {
|
|
217
|
+
i && h({ column: 0, row: 0 });
|
|
218
|
+
}, [i]);
|
|
219
|
+
const pe = B(j), me = pe.map((e) => e.label), ge = X ? X(me, pe) : me.join(" / "), ze = {
|
|
220
|
+
xs: "input-xs text-xs min-h-6",
|
|
221
|
+
sm: "input-sm text-sm min-h-8",
|
|
222
|
+
md: "input-md min-h-10",
|
|
223
|
+
lg: "input-lg text-lg min-h-12"
|
|
224
|
+
}, Be = {
|
|
77
225
|
xs: "text-xs",
|
|
78
226
|
sm: "text-sm",
|
|
79
227
|
md: "text-base",
|
|
80
228
|
lg: "text-lg"
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/* @__PURE__ */ n("span", { className: o.length === 0 ? "text-base-content/50" : "", children: o.length > 0 ? q : M }),
|
|
97
|
-
/* @__PURE__ */ m("div", { className: "flex items-center gap-1", children: [
|
|
98
|
-
S && o.length > 0 && !i && /* @__PURE__ */ n(
|
|
99
|
-
"button",
|
|
100
|
-
{
|
|
101
|
-
type: "button",
|
|
102
|
-
className: "btn btn-ghost btn-xs btn-circle",
|
|
103
|
-
onClick: R,
|
|
104
|
-
"aria-label": "Clear selection",
|
|
105
|
-
children: /* @__PURE__ */ n("svg", { className: "w-3 h-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
106
|
-
}
|
|
107
|
-
),
|
|
108
|
-
/* @__PURE__ */ n(
|
|
109
|
-
"svg",
|
|
110
|
-
{
|
|
111
|
-
className: `w-4 h-4 transition-transform ${r ? "rotate-180" : ""}`,
|
|
112
|
-
fill: "none",
|
|
113
|
-
viewBox: "0 0 24 24",
|
|
114
|
-
stroke: "currentColor",
|
|
115
|
-
children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
116
|
-
}
|
|
117
|
-
)
|
|
118
|
-
] })
|
|
119
|
-
]
|
|
120
|
-
}
|
|
121
|
-
),
|
|
122
|
-
r && /* @__PURE__ */ n(
|
|
123
|
-
"div",
|
|
124
|
-
{
|
|
125
|
-
id: N,
|
|
126
|
-
className: `absolute z-50 mt-1 bg-base-100 border border-base-300 rounded-lg shadow-lg flex ${G[C]}`,
|
|
127
|
-
children: v.map((e, s) => /* @__PURE__ */ n(
|
|
128
|
-
"ul",
|
|
229
|
+
}, He = {
|
|
230
|
+
primary: "border-primary focus:border-primary",
|
|
231
|
+
secondary: "border-secondary focus:border-secondary",
|
|
232
|
+
accent: "border-accent focus:border-accent",
|
|
233
|
+
info: "border-info focus:border-info",
|
|
234
|
+
success: "border-success focus:border-success",
|
|
235
|
+
warning: "border-warning focus:border-warning",
|
|
236
|
+
error: "border-error focus:border-error"
|
|
237
|
+
}, Ie = () => _ === "error" ? "input-error" : _ === "warning" ? "input-warning" : Z && i ? He[Z] : i ? "input-primary" : "", we = (e, t) => `${z}-option-${e}-${t}`, ve = (e) => `${z}-search-option-${e}`, Ke = () => {
|
|
238
|
+
const e = f, t = A === "responsive" || typeof A == "number" ? e.slice(0, typeof A == "number" ? A : 3) : e, n = e.length - t.length;
|
|
239
|
+
return /* @__PURE__ */ x("div", { className: "flex flex-wrap gap-1 flex-1", children: [
|
|
240
|
+
t.map((r) => {
|
|
241
|
+
const o = B(r).map((a) => a.label).join(" / ");
|
|
242
|
+
return /* @__PURE__ */ x(
|
|
243
|
+
"span",
|
|
129
244
|
{
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
"li",
|
|
245
|
+
className: "badge badge-sm gap-1",
|
|
246
|
+
children: [
|
|
247
|
+
o,
|
|
248
|
+
/* @__PURE__ */ l(
|
|
249
|
+
"button",
|
|
136
250
|
{
|
|
137
|
-
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
f && /* @__PURE__ */ n("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ n("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) })
|
|
146
|
-
]
|
|
147
|
-
},
|
|
148
|
-
t.value
|
|
149
|
-
);
|
|
150
|
-
})
|
|
251
|
+
type: "button",
|
|
252
|
+
className: "btn btn-ghost btn-xs btn-circle w-3 h-3 min-h-0",
|
|
253
|
+
onClick: (a) => Ae(r, a),
|
|
254
|
+
"aria-label": `Remove ${o}`,
|
|
255
|
+
children: /* @__PURE__ */ l("svg", { className: "w-2 h-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
256
|
+
}
|
|
257
|
+
)
|
|
258
|
+
]
|
|
151
259
|
},
|
|
152
|
-
|
|
153
|
-
)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
260
|
+
r.join("/")
|
|
261
|
+
);
|
|
262
|
+
}),
|
|
263
|
+
n > 0 && /* @__PURE__ */ x("span", { className: "badge badge-sm", children: [
|
|
264
|
+
"+",
|
|
265
|
+
n
|
|
266
|
+
] })
|
|
267
|
+
] });
|
|
268
|
+
}, We = () => {
|
|
269
|
+
if (!c) return null;
|
|
270
|
+
if (c.length === 0)
|
|
271
|
+
return /* @__PURE__ */ l("div", { className: "p-4 text-center text-base-content/50", children: je });
|
|
272
|
+
const e = typeof u == "object" && u.render ? u.render : null;
|
|
273
|
+
return /* @__PURE__ */ l("ul", { role: "listbox", className: "max-h-[200px] overflow-y-auto py-1", children: c.map(({ path: t, values: n }, r) => {
|
|
274
|
+
const s = w ? f.some((a) => a.join("/") === n.join("/")) : j.join("/") === n.join("/"), o = d.row === r;
|
|
275
|
+
return /* @__PURE__ */ l(
|
|
276
|
+
"li",
|
|
277
|
+
{
|
|
278
|
+
id: ve(r),
|
|
279
|
+
role: "option",
|
|
280
|
+
"aria-selected": s,
|
|
281
|
+
"data-testid": `${P}-search-option-${n.join("-")}`,
|
|
282
|
+
"data-state": s ? "selected" : void 0,
|
|
283
|
+
className: `px-3 py-2 cursor-pointer ${s ? "bg-primary text-primary-content" : o ? "bg-base-200" : "hover:bg-base-200"}`,
|
|
284
|
+
onClick: () => be(n, t),
|
|
285
|
+
children: e ? e(M, t) : t.map((a) => a.label).join(" / ")
|
|
286
|
+
},
|
|
287
|
+
n.join("/")
|
|
288
|
+
);
|
|
289
|
+
}) });
|
|
290
|
+
}, Ve = () => {
|
|
291
|
+
const e = c ? We() : /* @__PURE__ */ l("div", { className: "flex", children: F.map((t, n) => /* @__PURE__ */ l(
|
|
292
|
+
"ul",
|
|
293
|
+
{
|
|
294
|
+
role: "listbox",
|
|
295
|
+
"aria-label": `Level ${n + 1} options`,
|
|
296
|
+
className: `min-w-[120px] max-h-[200px] overflow-y-auto py-1 ${n > 0 ? "border-l border-base-300" : ""}`,
|
|
297
|
+
children: t.map((r, s) => {
|
|
298
|
+
const o = j[n] === r.value, a = C[n] === r.value, g = r.children && r.children.length > 0, Ue = oe.has(r.value), qe = d.column === n && d.row === s, Ge = we(n, s);
|
|
299
|
+
return /* @__PURE__ */ x(
|
|
300
|
+
"li",
|
|
301
|
+
{
|
|
302
|
+
id: Ge,
|
|
303
|
+
role: "option",
|
|
304
|
+
"aria-selected": o,
|
|
305
|
+
"aria-disabled": r.disabled,
|
|
306
|
+
"data-testid": `${P}-option-${r.value}`,
|
|
307
|
+
"data-state": o ? "selected" : a ? "hovered" : void 0,
|
|
308
|
+
"data-value": r.value,
|
|
309
|
+
className: `px-3 py-2 cursor-pointer flex items-center justify-between gap-2 ${r.disabled ? "text-base-content/30 cursor-not-allowed" : o ? "bg-primary text-primary-content" : qe || a ? "bg-base-200" : "hover:bg-base-200"}`,
|
|
310
|
+
onClick: () => he(r, n),
|
|
311
|
+
onMouseEnter: () => Fe(r, n),
|
|
312
|
+
children: [
|
|
313
|
+
/* @__PURE__ */ l("span", { children: r.label }),
|
|
314
|
+
Ue ? /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-xs" }) : g ? /* @__PURE__ */ l("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 5l7 7-7 7" }) }) : null
|
|
315
|
+
]
|
|
316
|
+
},
|
|
317
|
+
r.value
|
|
318
|
+
);
|
|
319
|
+
})
|
|
320
|
+
},
|
|
321
|
+
n
|
|
322
|
+
)) });
|
|
323
|
+
return re ? re(e) : e;
|
|
324
|
+
}, Te = () => {
|
|
325
|
+
if (i)
|
|
326
|
+
return c ? ve(d.row) : we(d.column, d.row);
|
|
327
|
+
}, H = w ? f.length > 0 : j.length > 0;
|
|
328
|
+
return /* @__PURE__ */ x(
|
|
329
|
+
"div",
|
|
330
|
+
{
|
|
331
|
+
ref: (e) => {
|
|
332
|
+
V.current = e, typeof E == "function" ? E(e) : E && (E.current = e);
|
|
333
|
+
},
|
|
334
|
+
className: `relative inline-block w-full ${Ce}`,
|
|
335
|
+
"data-testid": P,
|
|
336
|
+
"data-state": i ? "open" : "closed",
|
|
337
|
+
...Pe,
|
|
338
|
+
children: [
|
|
339
|
+
/* @__PURE__ */ x(
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
id: Se,
|
|
343
|
+
role: "combobox",
|
|
344
|
+
"aria-expanded": i,
|
|
345
|
+
"aria-haspopup": "listbox",
|
|
346
|
+
"aria-controls": ie,
|
|
347
|
+
"aria-activedescendant": Te(),
|
|
348
|
+
"aria-label": Le,
|
|
349
|
+
"aria-disabled": y,
|
|
350
|
+
tabIndex: y ? -1 : 0,
|
|
351
|
+
className: `input input-bordered w-full flex items-center justify-between cursor-pointer gap-1 ${ze[Y]} ${y ? "input-disabled cursor-not-allowed" : ""} ${Ie()}`,
|
|
352
|
+
onClick: () => {
|
|
353
|
+
y || (p(!i), u && !i && setTimeout(() => le.current?.focus(), 0));
|
|
354
|
+
},
|
|
355
|
+
onKeyDown: Ee,
|
|
356
|
+
children: [
|
|
357
|
+
w && f.length > 0 ? Ke() : u && i ? /* @__PURE__ */ l(
|
|
358
|
+
"input",
|
|
359
|
+
{
|
|
360
|
+
ref: le,
|
|
361
|
+
type: "text",
|
|
362
|
+
className: "flex-1 bg-transparent outline-none min-w-[50px]",
|
|
363
|
+
value: M,
|
|
364
|
+
onChange: (e) => S(e.target.value),
|
|
365
|
+
onClick: (e) => e.stopPropagation(),
|
|
366
|
+
placeholder: H ? String(ge) : Q,
|
|
367
|
+
"aria-label": "Search options"
|
|
368
|
+
}
|
|
369
|
+
) : /* @__PURE__ */ l("span", { className: `flex-1 truncate ${H ? "" : "text-base-content/50"}`, children: H ? ge : Q }),
|
|
370
|
+
/* @__PURE__ */ x("div", { className: "flex items-center gap-1 shrink-0", children: [
|
|
371
|
+
ke && H && !y && /* @__PURE__ */ l(
|
|
372
|
+
"button",
|
|
373
|
+
{
|
|
374
|
+
type: "button",
|
|
375
|
+
className: "btn btn-ghost btn-xs btn-circle",
|
|
376
|
+
onClick: Re,
|
|
377
|
+
"aria-label": "Clear selection",
|
|
378
|
+
"data-testid": `${P}-clear`,
|
|
379
|
+
children: /* @__PURE__ */ l("svg", { className: "w-3 h-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ l(
|
|
383
|
+
"svg",
|
|
384
|
+
{
|
|
385
|
+
className: `w-4 h-4 transition-transform ${i ? "rotate-180" : ""}`,
|
|
386
|
+
fill: "none",
|
|
387
|
+
viewBox: "0 0 24 24",
|
|
388
|
+
stroke: "currentColor",
|
|
389
|
+
"aria-hidden": "true",
|
|
390
|
+
children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" })
|
|
391
|
+
}
|
|
392
|
+
)
|
|
393
|
+
] })
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
),
|
|
397
|
+
i && /* @__PURE__ */ l(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
ref: Me,
|
|
401
|
+
id: ie,
|
|
402
|
+
className: `absolute z-50 mt-1 bg-base-100 border border-base-300 rounded-lg shadow-lg ${Be[Y]} ${$e}`,
|
|
403
|
+
"data-testid": `${P}-dropdown`,
|
|
404
|
+
children: Ve()
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
});
|
|
411
|
+
Xe.displayName = "Cascader";
|
|
158
412
|
export {
|
|
159
|
-
|
|
413
|
+
Xe as Cascader
|
|
160
414
|
};
|
|
161
415
|
//# sourceMappingURL=index15.js.map
|