asterui 0.12.59 → 0.12.61

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.
@@ -1,6 +1,7 @@
1
- import { jsx as g, jsxs as z } from "react/jsx-runtime";
2
- import sn, { forwardRef as on, useId as cn, useState as F, useRef as be, useMemo as oe, useCallback as T, useEffect as ge } from "react";
3
- const ln = "checkbox", an = "checkbox-sm", dn = "checkbox-primary", un = "loading", fn = "loading-spinner", hn = "loading-xs", Oe = "input", pn = "input-sm", bn = "input-disabled", gn = "SHOW_ALL", vn = "SHOW_PARENT", yn = "SHOW_CHILD";
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 Pe(r, u = [], p) {
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(...Pe(v, k, p));
23
+ l.push({ node: f, path: k }), v && l.push(...Be(v, k, p));
23
24
  }), l;
24
25
  }
25
- function xn(r, u) {
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 S(r, u, p) {
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 = S(b, u, p);
40
+ const v = $(b, u, p);
40
41
  if (v) return v;
41
42
  }
42
43
  }
43
44
  return null;
44
45
  }
45
- function Me(r, u) {
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 ve(r, u, p, l = []) {
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 = ve(v, u, p, [...l, b]);
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 wn({
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: C,
76
- focused: H,
77
- loading: ce,
78
- baseTestId: V,
79
- id: le,
80
- fieldNames: U,
81
- switcherIcon: L,
82
- onToggle: Q,
83
- onSelect: Y,
84
- onCheck: M,
85
- renderChildren: Z
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 X = d(r, "children", U), P = d(r, "title", U), W = d(r, "key", U), D = r.icon, q = X && X.length > 0, E = r.isLeaf ?? !q, B = (m) => {
88
- m.stopPropagation(), E || Q(W);
89
- }, $ = () => {
90
- r.disabled || (v ? M(W, r) : Y(W, r));
91
- }, _ = (m) => {
92
- m.stopPropagation(), r.disabled || M(W, r);
93
- }, G = (m) => {
94
- (m.key === "Enter" || m.key === " ") && (m.preventDefault(), $());
95
- }, N = () => ce ? /* @__PURE__ */ g("span", { className: `${un} ${fn} ${hn}` }) : L ? typeof L == "function" ? L({ expanded: p }) : L : /* @__PURE__ */ g(
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__ */ z(
107
+ return /* @__PURE__ */ C(
107
108
  "div",
108
109
  {
109
110
  className: "tree-select-node",
110
111
  role: "treeitem",
111
- id: le,
112
+ id: ae,
112
113
  "aria-selected": l || f,
113
- "aria-expanded": q ? p : void 0,
114
- "data-testid": `${V}-option-${W}`,
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__ */ z(
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
- H && "ring-2 ring-primary ring-inset",
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: G,
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
- !E && "cursor-pointer"
139
+ !K && "cursor-pointer"
139
140
  ].filter(Boolean).join(" "),
140
- onClick: B,
141
+ onClick: R,
141
142
  "aria-hidden": "true",
142
- children: !E && N()
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: `${ln} ${an} ${dn}`,
150
+ className: `${bn} ${gn} ${vn}`,
150
151
  checked: f,
151
- ref: (m) => {
152
- m && (m.indeterminate = b);
152
+ ref: (L) => {
153
+ L && (L.indeterminate = b);
153
154
  },
154
155
  disabled: r.disabled,
155
- onChange: $,
156
- "aria-label": typeof P == "string" ? P : void 0,
156
+ onChange: m,
157
+ "aria-label": typeof B == "string" ? B : void 0,
157
158
  tabIndex: -1
158
159
  }
159
160
  ) }),
160
- C && D && /* @__PURE__ */ g("span", { className: "mr-1.5 flex-shrink-0 flex items-center", children: D }),
161
- /* @__PURE__ */ g("span", { className: "flex-1 truncate select-none text-sm", children: P })
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
- q && p && /* @__PURE__ */ g("div", { role: "group", children: Z(X, u + 1) })
166
+ G && p && /* @__PURE__ */ g("div", { role: "group", children: D(q, u + 1) })
166
167
  ]
167
168
  }
168
169
  );
169
170
  }
170
- const kn = {
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
- }, Ln = {
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
- }, $n = {
186
+ }, Hn = {
186
187
  error: "border-error focus-within:border-error",
187
188
  warning: "border-warning focus-within:border-warning"
188
- }, mn = {
189
+ }, Wn = {
189
190
  outlined: "border border-base-300",
190
191
  filled: "bg-base-200 border-transparent",
191
192
  borderless: "border-transparent"
192
- }, Be = on(
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: C = !1,
203
- searchValue: H,
204
- onSearch: ce,
205
- filterTreeNode: V,
206
- placeholder: le = "Please select",
207
- allowClear: U = !0,
208
- disabled: L = !1,
209
- treeDefaultExpandAll: Q = !1,
210
- treeDefaultExpandedKeys: Y = [],
211
- treeExpandedKeys: M,
212
- onTreeExpand: Z,
213
- size: X = "md",
214
- color: P,
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: D = "outlined",
217
- ghost: q = !1,
218
- maxTagCount: E,
219
- maxTagPlaceholder: B,
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: G,
223
- treeLine: N = !1,
224
- treeIcon: m = !1,
225
- loadData: ae,
223
+ tagRender: J,
224
+ treeLine: ee = !1,
225
+ treeIcon: L = !1,
226
+ loadData: de,
226
227
  fieldNames: i,
227
- open: de,
228
- onDropdownVisibleChange: ye,
229
- suffixIcon: Re,
230
- switcherIcon: xe,
231
- notFoundContent: Fe = "No results found",
232
- dropdownRender: we,
233
- popupClassName: Te = "",
234
- className: ze = "",
235
- "data-testid": Ce,
236
- ...Ve
237
- }, ee) => {
238
- const I = Ce ?? "treeselect", ne = cn(), ke = `${ne}-listbox`, [Ue, Xe] = F(!1), [qe, te] = F(""), [x, j] = F(null), [Le, $e] = F(/* @__PURE__ */ new Set()), ue = be(null), fe = be(null), re = be(null), J = H ?? qe, y = de ?? Ue, me = (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], Ge = me(p), [Je, se] = F(Ge), h = u !== void 0 ? me(u) : Je, Qe = oe(() => Q ? xn(r, i) : Y, [r, Q, Y, i]), [Ye, Ze] = F(Qe), A = M ?? Ye, K = oe(() => {
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 && A.includes(o) && n(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, A, i]), O = T(
247
+ }, [r, I, i]), O = z(
247
248
  (e) => {
248
- de === void 0 && Xe(e), ye?.(e);
249
+ ue === void 0 && Ze(e), xe?.(e);
249
250
  },
250
- [de, ye]
251
+ [ue, xe]
251
252
  );
252
- ge(() => {
253
+ ve(() => {
253
254
  const e = (n) => {
254
- ue.current && !ue.current.contains(n.target) && (O(!1), H === void 0 && te(""));
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, H]), ge(() => {
258
- y && C && fe.current ? fe.current.focus() : y && re.current && re.current.focus();
259
- }, [y, C]), ge(() => {
260
- y && K.length > 0 ? h.length > 0 ? j(h[0]) : j(K[0].key) : y || j(null);
261
- }, [y, K, h]);
262
- const Se = oe(() => {
263
- if (!J) return r;
264
- const e = Pe(r, [], i), n = /* @__PURE__ */ new Set();
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
- V ? a = V(J, t) : a = (typeof o == "string" ? o : String(o)).toLowerCase().includes(J.toLowerCase()), a && n.add(s);
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, J, V, i]), ie = T(
279
+ }, [r, Q, U, i]), oe = z(
279
280
  async (e) => {
280
- const n = S(r, e, i);
281
- if (ae && n) {
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 ae(n);
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 = A.includes(e) ? A.filter((t) => t !== e) : [...A, e];
296
- M === void 0 && Ze(c), Z?.(c);
296
+ const c = I.includes(e) ? I.filter((t) => t !== e) : [...I, e];
297
+ P === void 0 && rn(c), D?.(c);
297
298
  },
298
- [A, M, Z, ae, r, i]
299
- ), he = T(
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 ($ !== void 0 && h.length >= $)
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), H === void 0 && te("");
312
- u === void 0 && se(c);
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 = S(r, o, i);
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 = S(r, s, i);
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
- H,
342
+ A,
342
343
  i,
343
344
  _
344
345
  ]
345
- ), pe = T(
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 ($ !== void 0 && h.length >= $)
354
+ if (m !== void 0 && h.length >= m)
354
355
  return;
355
356
  t.push(e);
356
357
  }
357
358
  else {
358
- const s = Me(n, i);
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 ($ !== void 0 && t.length + a.length > $) {
364
- const w = $ - t.length;
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((R) => t.push(R));
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 && se(t);
374
+ u === void 0 && ie(t);
374
375
  const o = t.map((s) => {
375
- const a = S(r, s, i);
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 = S(r, a, i);
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
- ), De = (e) => {
391
+ [h, u, l, r, v, i, m, _]
392
+ ), sn = (e) => {
392
393
  e.stopPropagation();
393
394
  const n = [];
394
- u === void 0 && se(n), _ ? l?.(f || b ? [] : { value: "", label: "" }, []) : l?.(f || b ? n : "", []);
395
- }, Ke = (e, n) => {
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 && se(c);
399
+ u === void 0 && ie(c);
399
400
  const t = c.map((o) => {
400
- const s = S(r, o, i);
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 = S(r, s, i);
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
- }, Ne = (e) => {
418
+ }, on = (e) => {
418
419
  const n = e.target.value;
419
- H === void 0 && te(n), ce?.(n);
420
- }, en = (e) => {
421
- if (!L)
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 = S(r, x, i);
430
- n && !n.disabled && (b ? pe(x, n) : he(x, n));
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), H === void 0 && te(""), re.current?.focus();
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 = K.findIndex((t) => t.key === x), c = n < K.length - 1 ? n + 1 : 0;
441
- j(K[c]?.key || null);
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 = K.findIndex((t) => t.key === x), c = n > 0 ? n - 1 : K.length - 1;
447
- j(K[c]?.key || null);
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 = S(r, x, i), c = n ? d(n, "children", i) : void 0;
454
- c && c.length > 0 && !A.includes(x) && ie(x);
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(), A.includes(x))
460
- ie(x);
460
+ if (e.preventDefault(), I.includes(x))
461
+ oe(x);
461
462
  else {
462
- const n = ve(r, x, i);
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(K[0]?.key || null));
468
+ y && (e.preventDefault(), j(S[0]?.key || null));
468
469
  break;
469
470
  case "End":
470
- y && (e.preventDefault(), j(K[K.length - 1]?.key || null));
471
+ y && (e.preventDefault(), j(S[S.length - 1]?.key || null));
471
472
  break;
472
473
  }
473
- }, Ee = T(
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 = Me(e, i), o = t.filter((s) => h.includes(s));
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
- ), Ie = T(
485
+ ), Ae = z(
485
486
  (e, n) => e.map((c) => {
486
- const t = d(c, "key", i), { checked: o, indeterminate: s } = Ee(c);
487
+ const t = d(c, "key", i), { checked: o, indeterminate: s } = Ie(c);
487
488
  return /* @__PURE__ */ g(
488
- wn,
489
+ En,
489
490
  {
490
491
  node: c,
491
492
  level: n,
492
- expanded: A.includes(t),
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: N,
498
- treeIcon: m,
498
+ treeLine: ee,
499
+ treeIcon: L,
499
500
  focused: x === t,
500
501
  loading: Le.has(t),
501
- baseTestId: I,
502
- id: `${ne}-option-${t}`,
502
+ baseTestId: E,
503
+ id: `${te}-option-${t}`,
503
504
  fieldNames: i,
504
- switcherIcon: xe,
505
- onToggle: ie,
506
- onSelect: he,
507
- onCheck: pe,
508
- renderChildren: Ie
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
- A,
515
+ I,
515
516
  h,
516
517
  b,
517
- N,
518
- m,
518
+ ee,
519
+ L,
519
520
  x,
520
521
  Le,
521
- I,
522
- ne,
522
+ E,
523
+ te,
523
524
  i,
524
- xe,
525
- ie,
526
- he,
525
+ we,
526
+ oe,
527
527
  pe,
528
- Ee
528
+ be,
529
+ Ie
529
530
  ]
530
- ), nn = oe(() => {
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 = ve(r, t, i);
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 = S(r, t, i);
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
- E !== void 0 && E !== "responsive" && e.length > E && (t = e.slice(0, E), o = e.length - E);
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 = S(r, a, i), R = w ? d(w, "title", i) : a, We = R, _e = !L, rn = () => {
546
- Ke(a, { stopPropagation: () => {
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 G ? /* @__PURE__ */ g(sn.Fragment, { children: G({ label: We, value: a, closable: _e, onClose: rn }) }, a) : /* @__PURE__ */ z(
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": `${I}-tag-${a}`,
554
+ "data-testid": `${E}-tag-${a}`,
554
555
  children: [
555
- We,
556
- _e && /* @__PURE__ */ g(
556
+ _e,
557
+ je && /* @__PURE__ */ g(
557
558
  "button",
558
559
  {
559
560
  type: "button",
560
561
  className: "hover:text-error",
561
- onClick: (je) => Ke(a, je),
562
- "aria-label": `Remove ${typeof R == "string" ? R : a}`,
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(E), w = typeof B == "function" ? B(a) : B || `+${o} more`;
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 = S(r, h[0], i);
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
- L,
617
- G
618
- ]), Ae = W ? $n[W] : P ? Ln[P] : "", tn = q ? "bg-transparent border-transparent" : mn[D], He = /* @__PURE__ */ g("div", { className: "py-1", role: "tree", "aria-label": "Tree options", children: Se.length > 0 ? Ie(Se, 0) : /* @__PURE__ */ g(
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": `${I}-empty`,
623
- children: Fe
623
+ "data-testid": `${E}-empty`,
624
+ children: Qe
624
625
  }
625
626
  ) });
626
- return /* @__PURE__ */ z(
627
+ return /* @__PURE__ */ C(
627
628
  "div",
628
629
  {
629
630
  ref: (e) => {
630
- ue.current = e, typeof ee == "function" ? ee(e) : ee && (ee.current = e);
631
+ fe.current = e, typeof ne == "function" ? ne(e) : ne && (ne.current = e);
631
632
  },
632
- className: `relative ${ze}`,
633
- "data-testid": I,
633
+ className: `relative ${Ce}`,
634
+ "data-testid": E,
634
635
  "data-state": y ? "open" : "closed",
635
- "data-disabled": L || void 0,
636
- onKeyDown: en,
637
- ...Ve,
636
+ "data-disabled": H || void 0,
637
+ onKeyDown: cn,
638
+ ...Ue,
638
639
  children: [
639
- /* @__PURE__ */ z(
640
+ /* @__PURE__ */ C(
640
641
  "div",
641
642
  {
642
- ref: re,
643
+ ref: se,
643
644
  role: "combobox",
644
645
  "aria-expanded": y,
645
646
  "aria-haspopup": "tree",
646
- "aria-owns": y ? ke : void 0,
647
- "aria-activedescendant": y && x ? `${ne}-option-${x}` : void 0,
648
- "aria-disabled": L,
649
- tabIndex: L ? -1 : 0,
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
- Oe,
652
+ Me,
652
653
  "flex items-center gap-2 cursor-pointer flex-wrap",
653
- kn[X],
654
- tn,
655
- Ae,
656
- L && `${bn} opacity-50 cursor-not-allowed`,
657
- y && !Ae && "border-primary"
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: () => !L && O(!y),
660
- "data-testid": `${I}-trigger`,
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: nn || /* @__PURE__ */ g("span", { className: "text-base-content/50", children: le }) }),
663
- U && h.length > 0 && !L && /* @__PURE__ */ g(
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: De,
669
+ onClick: sn,
669
670
  "aria-label": "Clear selection",
670
- "data-testid": `${I}-clear`,
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
- Re || /* @__PURE__ */ g(
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__ */ z(
715
+ y && /* @__PURE__ */ C(
715
716
  "div",
716
717
  {
717
- id: ke,
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 ${Te}`,
719
- "data-testid": `${I}-dropdown`,
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
- C && /* @__PURE__ */ g("div", { className: "p-2 border-b border-base-300", children: /* @__PURE__ */ g(
722
+ V && /* @__PURE__ */ g("div", { className: "p-2 border-b border-base-300", children: /* @__PURE__ */ g(
722
723
  "input",
723
724
  {
724
- ref: fe,
725
+ ref: he,
725
726
  type: "text",
726
- className: `${Oe} ${pn} w-full`,
727
+ className: `${Me} ${kn} w-full`,
727
728
  placeholder: "Search...",
728
- value: J,
729
- onChange: Ne,
729
+ value: Q,
730
+ onChange: on,
730
731
  onClick: (e) => e.stopPropagation(),
731
732
  "aria-label": "Search tree options",
732
- "data-testid": `${I}-search`
733
+ "data-testid": `${E}-search`
733
734
  }
734
735
  ) }),
735
- we ? we(He) : He
736
+ ke ? ke(We) : We
736
737
  ]
737
738
  }
738
739
  )
@@ -741,15 +742,15 @@ const kn = {
741
742
  );
742
743
  }
743
744
  );
744
- Be.displayName = "TreeSelect";
745
- const En = Object.assign(Be, {
746
- SHOW_ALL: gn,
747
- SHOW_PARENT: vn,
748
- SHOW_CHILD: yn
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
- Be as TreeSelect,
752
- En as TreeSelectComponent,
753
- En as default
752
+ Re as TreeSelect,
753
+ Mn as TreeSelectComponent,
754
+ Mn as default
754
755
  };
755
756
  //# sourceMappingURL=TreeSelect.js.map