@jc-times/business-ui 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,205 +1,275 @@
1
1
  import { useOverlayContainer as e } from "./OverlayContainer.js";
2
2
  import { FormField as t } from "./FormField.js";
3
- import { memo as n, useCallback as r, useEffect as i, useId as a, useMemo as o, useRef as s, useState as c } from "react";
4
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
- import { Check as ee, ChevronDown as te, ChevronRight as d, LoaderCircle as ne, X as re } from "lucide-react";
6
- import * as f from "@radix-ui/react-popover";
3
+ import { usePhoneWheel as n } from "./usePhoneWheel.js";
4
+ import { MobilePickerPanel as r } from "./MobilePickerPanel.js";
5
+ import { memo as i, useCallback as a, useEffect as o, useId as ee, useMemo as s, useRef as c, useState as l } from "react";
6
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
7
+ import { Check as te, ChevronDown as ne, ChevronRight as f, LoaderCircle as re, X as ie } from "lucide-react";
8
+ import * as p from "@radix-ui/react-popover";
7
9
  //#region src/TreeSelect.tsx
8
- var p = "\0tree-select-all";
9
- function ie({ items: n, value: d, defaultValue: ie = null, onValueChange: h, open: g, defaultOpen: _ = !1, onOpenChange: y, selectionMode: fe = "single", values: b, defaultValues: pe = [], onValuesChange: me, query: x, defaultQuery: he = "", onQueryChange: S, expandedIds: C, defaultExpandedIds: ge, onExpandedIdsChange: _e, label: w, placeholder: ve = "请选择", searchPlaceholder: ye = "输入关键词搜索", clearLabel: T = "清除选择", allLabel: be = "全部", emptyText: xe = "没有匹配项", loading: E = !1, loadingText: Se = "正在加载…", loadError: Ce, disabled: D = !1, required: O = !1, helpText: we, error: k, id: Te, name: Ee, formValueMode: De = "id", className: Oe = "", popoverClassName: ke = "", inputRef: A, inputProps: j }) {
10
- let Ae = e(), M = s(!1), je = a().replaceAll(":", ""), N = Te ?? `ui-tree-select-${je}`, Me = `${N}-tree`, P = s(null), Ne = s(null), F = o(() => oe(n), [n]), I = o(() => new Map(se(F).map((e) => [e.id, e])), [F]), [Pe, Fe] = c(ie), [Ie, Le] = c(pe), L = fe === "multiple", R = b ?? Ie, Re = o(() => new Set(R), [R]), [ze, Be] = c(_), [Ve, He] = c(he), [Ue, We] = c(() => new Set(ge ?? ce(F))), [z, B] = c(null), V = d === void 0 ? Pe : d, H = !D && (g === void 0 ? ze : g), U = x === void 0 ? Ve : x, W = C ?? Ue, G = o(() => U.trim() ? m(F, U) : F, [F, U]), K = !!U.trim(), q = o(() => le(G, W, K), [
10
+ var m = "\0tree-select-all";
11
+ function ae({ items: i, value: f, defaultValue: ae = null, onValueChange: g, open: _, defaultOpen: v = !1, onOpenChange: pe, selectionMode: me = "single", values: he, defaultValues: ge = [], onValuesChange: _e, query: b, defaultQuery: ve = "", onQueryChange: x, expandedIds: S, defaultExpandedIds: ye, onExpandedIdsChange: be, label: C, placeholder: xe = "请选择", searchPlaceholder: Se = "输入关键词搜索", clearLabel: w = "清除选择", allLabel: Ce = "全部", emptyText: we = "没有匹配项", loading: T = !1, loadingText: Te = "正在加载…", loadError: Ee, disabled: E = !1, required: D = !1, helpText: De, error: O, id: Oe, name: ke, formValueMode: Ae = "id", className: je = "", popoverClassName: Me = "", inputRef: k, inputProps: A, mobileMode: Ne = "dropdown" }) {
12
+ let j = n(Ne === "bottom-sheet"), Pe = c(null), Fe = e(), M = c(!1), Ie = ee().replaceAll(":", ""), N = Oe ?? `ui-tree-select-${Ie}`, P = `${N}-tree`, F = c(null), Le = c(null), I = s(() => se(i), [i]), L = s(() => new Map(y(I).map((e) => [e.id, e])), [I]), [Re, ze] = l(ae), [Be, Ve] = l(ge), R = me === "multiple", z = he ?? Be, He = s(() => new Set(z), [z]), [Ue, We] = l(v), [Ge, Ke] = l(ve), [qe, Je] = l(() => new Set(ye ?? ce(I))), [B, V] = l(null), H = f === void 0 ? Re : f, U = !E && (_ === void 0 ? Ue : _), W = b === void 0 ? Ge : b, G = S ?? qe, K = s(() => W.trim() ? h(I, W) : I, [I, W]), q = !!W.trim(), Ye = s(() => le(K, G, q), [
13
+ K,
11
14
  G,
12
- W,
13
- K
14
- ]), J = o(() => [{
15
- key: p,
15
+ q
16
+ ]), J = s(() => [{
17
+ key: m,
16
18
  disabled: !1
17
- }, ...q.map(({ node: e }) => ({
19
+ }, ...Ye.map(({ node: e }) => ({
18
20
  key: e.id,
19
21
  disabled: !!e.disabled
20
- }))], [q]), Ge = V === null ? void 0 : I.get(V), Y = z === null ? void 0 : v(N, z), Ke = H ? U : L ? R.map((e) => I.get(e)?.label ?? e).join("、") : Ge?.label ?? "", qe = de(j?.["aria-describedby"], we === void 0 ? void 0 : `${N}-help`, k === void 0 || k === "" ? void 0 : `${N}-error`);
21
- i(() => {
22
- H && (z !== null && J.some((e) => e.key === z && !e.disabled) || B(V && J.some((e) => e.key === V && !e.disabled) ? V : J.find((e) => !e.disabled)?.key ?? null));
22
+ }))], [Ye]), Xe = H === null ? void 0 : L.get(H), Y = B === null ? void 0 : ue(N, B), Ze = U ? W : R ? z.map((e) => L.get(e)?.label ?? e).join("、") : Xe?.label ?? "", Qe = fe(A?.["aria-describedby"], De === void 0 ? void 0 : `${N}-help`, O === void 0 || O === "" ? void 0 : `${N}-error`);
23
+ o(() => {
24
+ U && (B !== null && J.some((e) => e.key === B && !e.disabled) || V(H && J.some((e) => e.key === H && !e.disabled) ? H : J.find((e) => !e.disabled)?.key ?? null));
23
25
  }, [
24
- z,
25
- H,
26
+ B,
27
+ U,
26
28
  J,
27
- V
28
- ]), i(() => {
29
- H && Y !== void 0 && document.getElementById(Y)?.scrollIntoView?.({ block: "nearest" });
30
- }, [Y, H]), i(() => {
31
- P.current?.setCustomValidity(O && !(L ? R.length : V) ? "请选择选项" : "");
29
+ H
30
+ ]), o(() => {
31
+ U && Y !== void 0 && document.getElementById(Y)?.scrollIntoView?.({ block: "nearest" });
32
+ }, [Y, U]), o(() => {
33
+ F.current?.setCustomValidity(D && !(R ? z.length : H) ? "请选择选项" : "");
32
34
  }, [
33
- O,
34
- V,
35
- L,
36
- R
35
+ D,
36
+ H,
37
+ R,
38
+ z
37
39
  ]);
38
40
  function X(e) {
39
- g === void 0 && Be(e), y?.(e), e || (Z(""), B(null));
41
+ _ === void 0 && We(e), pe?.(e), e || (Z(""), V(null));
40
42
  }
41
43
  function Z(e) {
42
- x === void 0 && He(e), S?.(e);
44
+ b === void 0 && Ke(e), x?.(e);
43
45
  }
44
- function Je(e) {
45
- d === void 0 && Fe(e), h?.(e);
46
+ function $e(e) {
47
+ f === void 0 && ze(e), g?.(e);
46
48
  }
47
49
  function Q() {
48
- D || H || (Z(""), X(!0));
50
+ E || U || (Z(""), X(!0));
49
51
  }
50
- let $ = r((e) => {
51
- if (L) {
52
- let t = e === null ? [] : R.includes(e) ? R.filter((t) => t !== e) : [...R, e];
53
- b === void 0 && Le(t), me?.(t);
52
+ let $ = a((e) => {
53
+ if (R) {
54
+ let t = e === null ? [] : z.includes(e) ? z.filter((t) => t !== e) : [...z, e];
55
+ he === void 0 && Ve(t), _e?.(t);
54
56
  return;
55
57
  }
56
- d === void 0 && Fe(e), h?.(e), g === void 0 && Be(!1), y?.(!1), x === void 0 && He(""), S?.(""), B(null);
58
+ f === void 0 && ze(e), g?.(e), _ === void 0 && We(!1), pe?.(!1), b === void 0 && Ke(""), x?.(""), V(null);
57
59
  }, [
58
- d,
59
- h,
60
+ f,
60
61
  g,
61
- y,
62
+ _,
63
+ pe,
64
+ b,
62
65
  x,
63
- S,
64
- L,
65
66
  R,
66
- b,
67
- me
68
- ]), Ye = r((e) => {
69
- let t = new Set(W);
70
- t.has(e) ? t.delete(e) : t.add(e), C === void 0 && We(t), _e?.(t);
71
- }, [
72
- W,
73
- C,
67
+ z,
68
+ he,
74
69
  _e
70
+ ]), et = a((e) => {
71
+ let t = new Set(G);
72
+ t.has(e) ? t.delete(e) : t.add(e), S === void 0 && Je(t), be?.(t);
73
+ }, [
74
+ G,
75
+ S,
76
+ be
75
77
  ]);
76
- function Xe(e, t) {
78
+ function tt(e, t) {
77
79
  let n = J.filter((e) => !e.disabled);
78
80
  if (!n.length) return;
79
81
  if (t) {
80
- B(n[t === "start" ? 0 : n.length - 1].key);
82
+ V(n[t === "start" ? 0 : n.length - 1].key);
81
83
  return;
82
84
  }
83
- let r = n.findIndex((e) => e.key === z);
84
- B(n[((r < 0 ? e > 0 ? -1 : 0 : r) + e + n.length) % n.length].key);
85
+ let r = n.findIndex((e) => e.key === B);
86
+ V(n[((r < 0 ? e > 0 ? -1 : 0 : r) + e + n.length) % n.length].key);
85
87
  }
86
- function Ze(e) {
87
- if (j?.onKeyDown?.(e), e.defaultPrevented || M.current || e.nativeEvent.isComposing || e.keyCode === 229) return;
88
+ function nt(e) {
89
+ if (A?.onKeyDown?.(e), e.defaultPrevented || M.current || e.nativeEvent.isComposing || e.keyCode === 229) return;
90
+ if (j && !U && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown")) {
91
+ e.preventDefault(), Q();
92
+ return;
93
+ }
88
94
  if (e.key === "Tab") {
89
- H && X(!1);
95
+ U && !j && X(!1);
90
96
  return;
91
97
  }
92
- if (e.key === "Escape" && H) {
98
+ if (e.key === "Escape" && U) {
93
99
  e.preventDefault(), e.stopPropagation(), X(!1);
94
100
  return;
95
101
  }
96
- if (e.key === "Backspace" && !H && !L && V !== null) {
97
- e.preventDefault(), Je(null), Q();
102
+ if (e.key === "Backspace" && !U && !R && H !== null) {
103
+ e.preventDefault(), $e(null), Q();
98
104
  return;
99
105
  }
100
106
  if (e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Home" || e.key === "End") {
101
- e.preventDefault(), Q(), e.key === "Home" ? Xe(0, "start") : e.key === "End" ? Xe(0, "end") : Xe(e.key === "ArrowDown" ? 1 : -1);
107
+ e.preventDefault(), Q(), e.key === "Home" ? tt(0, "start") : e.key === "End" ? tt(0, "end") : tt(e.key === "ArrowDown" ? 1 : -1);
102
108
  return;
103
109
  }
104
- let t = q.find(({ node: e }) => e.id === z);
110
+ let t = Ye.find(({ node: e }) => e.id === B);
105
111
  if (e.key === "ArrowRight" && t) {
106
- e.preventDefault(), Q(), t.node.children.length && !W.has(t.node.id) && !K ? Ye(t.node.id) : t.node.children.length && B(t.node.children[0].id);
112
+ e.preventDefault(), Q(), t.node.children.length && !G.has(t.node.id) && !q ? et(t.node.id) : t.node.children.length && V(t.node.children[0].id);
107
113
  return;
108
114
  }
109
115
  if (e.key === "ArrowLeft" && t) {
110
- e.preventDefault(), t.node.children.length && W.has(t.node.id) && !K ? Ye(t.node.id) : t.parentId && B(t.parentId);
116
+ e.preventDefault(), t.node.children.length && G.has(t.node.id) && !q ? et(t.node.id) : t.parentId && V(t.parentId);
111
117
  return;
112
118
  }
113
- e.key === "Enter" && H && z !== null && (e.preventDefault(), z === p ? $(null) : t && !t.node.disabled && $(z));
119
+ e.key === "Enter" && U && B !== null && (e.preventDefault(), B === m ? $(null) : t && !t.node.disabled && $(B));
114
120
  }
115
- function Qe(e) {
116
- P.current = e, typeof A == "function" ? A(e) : A && (A.current = e);
121
+ function rt(e) {
122
+ F.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
117
123
  }
118
- return /* @__PURE__ */ u(t, {
124
+ let it = /* @__PURE__ */ d("div", {
125
+ id: P,
126
+ className: "ui-tree-select-tree",
127
+ role: "tree",
128
+ "aria-label": typeof C == "string" ? C : "树形选项",
129
+ "aria-busy": T || void 0,
130
+ "aria-multiselectable": R || void 0,
131
+ children: [/* @__PURE__ */ d("div", {
132
+ id: ue(N, m),
133
+ role: "treeitem",
134
+ "aria-level": 1,
135
+ "aria-posinset": 1,
136
+ "aria-setsize": K.length + 1,
137
+ "aria-selected": R ? !z.length : H === null,
138
+ className: de(B === m, R ? !z.length : H === null, !1),
139
+ onMouseDown: (e) => e.preventDefault(),
140
+ onClick: () => $(null),
141
+ children: [
142
+ /* @__PURE__ */ u("span", { className: "ui-tree-select-spacer" }),
143
+ /* @__PURE__ */ u("span", {
144
+ className: "ui-tree-select-label",
145
+ children: R ? w : Ce
146
+ }),
147
+ (R ? !z.length : H === null) && /* @__PURE__ */ u(te, {
148
+ size: 15,
149
+ "aria-hidden": "true"
150
+ })
151
+ ]
152
+ }), T ? /* @__PURE__ */ u("div", {
153
+ className: "ui-tree-select-status",
154
+ role: "status",
155
+ children: Te
156
+ }) : Ee === void 0 ? K.length ? ot(K, 1) : /* @__PURE__ */ u("div", {
157
+ className: "ui-tree-select-status",
158
+ children: we
159
+ }) : /* @__PURE__ */ u("div", {
160
+ className: "ui-tree-select-status ui-tree-select-error",
161
+ role: "alert",
162
+ children: Ee
163
+ })]
164
+ }), at = R && z.length > 0 && /* @__PURE__ */ d("div", {
165
+ className: "ui-multi-selection",
166
+ "aria-label": "已选节点",
167
+ children: [z.map((e) => /* @__PURE__ */ d("span", {
168
+ className: "ui-selection-tag",
169
+ children: [/* @__PURE__ */ u("span", {
170
+ className: "ui-selection-tag-label",
171
+ children: L.get(e)?.label ?? e
172
+ }), /* @__PURE__ */ u("button", {
173
+ type: "button",
174
+ disabled: E,
175
+ "aria-label": `移除 ${L.get(e)?.label ?? e}`,
176
+ onClick: () => $(e),
177
+ children: "×"
178
+ })]
179
+ }, e)), /* @__PURE__ */ u("button", {
180
+ type: "button",
181
+ className: "ui-selection-clear",
182
+ disabled: E,
183
+ onClick: () => $(null),
184
+ children: w
185
+ })]
186
+ });
187
+ return /* @__PURE__ */ d(t, {
119
188
  controlId: N,
120
- label: w,
121
- required: O,
122
- helpText: we,
123
- error: k,
124
- containerClassName: `ui-tree-select ${Oe}`.trim(),
125
- children: [/* @__PURE__ */ l(f.Root, {
126
- open: H,
189
+ label: C,
190
+ required: D,
191
+ helpText: De,
192
+ error: O,
193
+ containerClassName: `ui-tree-select ${je}`.trim(),
194
+ children: [/* @__PURE__ */ u(p.Root, {
195
+ open: !j && U,
127
196
  onOpenChange: X,
128
- children: /* @__PURE__ */ u("div", {
197
+ children: /* @__PURE__ */ d("div", {
129
198
  className: "ui-tree-select-root",
130
- ref: Ne,
199
+ ref: Le,
131
200
  children: [
132
- Ee && (L ? R : [V ?? ""]).map((e) => /* @__PURE__ */ l("input", {
201
+ ke && (R ? z : [H ?? ""]).map((e) => /* @__PURE__ */ u("input", {
133
202
  type: "hidden",
134
- name: Ee,
135
- value: De === "label" ? I.get(e)?.label ?? "" : e,
136
- disabled: D,
137
- form: j?.form
203
+ name: ke,
204
+ value: Ae === "label" ? L.get(e)?.label ?? "" : e,
205
+ disabled: E,
206
+ form: A?.form
138
207
  }, e)),
139
- /* @__PURE__ */ l(f.Anchor, {
208
+ /* @__PURE__ */ u(p.Anchor, {
140
209
  asChild: !0,
141
- children: /* @__PURE__ */ u("div", {
210
+ children: /* @__PURE__ */ d("div", {
142
211
  className: "ui-tree-select-control",
143
212
  children: [
144
- /* @__PURE__ */ l("input", {
145
- ...j,
146
- ref: Qe,
213
+ /* @__PURE__ */ u("input", {
214
+ ...A,
215
+ ref: rt,
147
216
  id: N,
148
217
  className: "ui-input ui-tree-select-input",
149
218
  role: "combobox",
150
219
  "aria-autocomplete": "list",
151
- "aria-haspopup": "tree",
152
- "aria-expanded": H,
153
- "aria-controls": H ? Me : void 0,
154
- "aria-activedescendant": H ? Y : void 0,
155
- "aria-describedby": qe,
156
- "aria-invalid": k ? !0 : j?.["aria-invalid"],
157
- "aria-required": O,
158
- disabled: D,
159
- placeholder: H ? ye : ve,
160
- value: Ke,
220
+ "aria-haspopup": j ? "dialog" : "tree",
221
+ "aria-expanded": U,
222
+ "aria-controls": !j && U ? P : void 0,
223
+ "aria-activedescendant": !j && U ? Y : void 0,
224
+ "aria-describedby": Qe,
225
+ "aria-invalid": O ? !0 : A?.["aria-invalid"],
226
+ "aria-required": D,
227
+ disabled: E,
228
+ inputMode: j ? "none" : A?.inputMode,
229
+ placeholder: !j && U ? Se : xe,
230
+ value: j ? R ? z.map((e) => L.get(e)?.label ?? e).join("、") : Xe?.label ?? "" : Ze,
161
231
  onCompositionStart: (e) => {
162
- M.current = !0, j?.onCompositionStart?.(e);
232
+ M.current = !0, A?.onCompositionStart?.(e);
163
233
  },
164
234
  onCompositionEnd: (e) => {
165
- M.current = !1, j?.onCompositionEnd?.(e);
235
+ M.current = !1, A?.onCompositionEnd?.(e);
166
236
  },
167
237
  onFocus: (e) => {
168
- j?.onFocus?.(e), e.defaultPrevented || Q();
238
+ A?.onFocus?.(e), !e.defaultPrevented && !j && Q();
169
239
  },
170
240
  onClick: Q,
171
241
  onChange: (e) => {
172
- H || X(!0), Z(e.target.value), B(null);
242
+ U || X(!0), Z(e.target.value), V(null);
173
243
  },
174
- onKeyDown: Ze
244
+ onKeyDown: nt
175
245
  }),
176
- Ge && !L && !D && /* @__PURE__ */ l("button", {
246
+ Xe && !R && !E && /* @__PURE__ */ u("button", {
177
247
  type: "button",
178
248
  tabIndex: -1,
179
249
  className: "ui-tree-select-clear",
180
- "aria-label": T,
250
+ "aria-label": w,
181
251
  onMouseDown: (e) => e.preventDefault(),
182
252
  onClick: () => {
183
- Je(null), Z(""), P.current?.focus();
253
+ $e(null), Z(""), F.current?.focus();
184
254
  },
185
- children: /* @__PURE__ */ l(re, {
255
+ children: /* @__PURE__ */ u(ie, {
186
256
  size: 15,
187
257
  "aria-hidden": "true"
188
258
  })
189
259
  }),
190
- /* @__PURE__ */ l("button", {
260
+ /* @__PURE__ */ u("button", {
191
261
  type: "button",
192
262
  tabIndex: -1,
193
263
  className: "ui-tree-select-trigger",
194
- "aria-label": H ? "收起选项" : "展开选项",
195
- disabled: D,
264
+ "aria-label": U ? "收起选项" : "展开选项",
265
+ disabled: E,
196
266
  onMouseDown: (e) => e.preventDefault(),
197
- onClick: () => H ? X(!1) : Q(),
198
- children: E ? /* @__PURE__ */ l(ne, {
267
+ onClick: () => U ? X(!1) : Q(),
268
+ children: T ? /* @__PURE__ */ u(re, {
199
269
  className: "spin",
200
270
  size: 16,
201
271
  "aria-hidden": "true"
202
- }) : /* @__PURE__ */ l(te, {
272
+ }) : /* @__PURE__ */ u(ne, {
203
273
  size: 16,
204
274
  "aria-hidden": "true"
205
275
  })
@@ -207,92 +277,67 @@ function ie({ items: n, value: d, defaultValue: ie = null, onValueChange: h, ope
207
277
  ]
208
278
  })
209
279
  }),
210
- /* @__PURE__ */ l(f.Portal, {
211
- container: Ae,
212
- children: /* @__PURE__ */ l(f.Content, {
213
- className: `ui-tree-select-popover ${ke}`.trim(),
280
+ /* @__PURE__ */ u(p.Portal, {
281
+ container: Fe,
282
+ children: /* @__PURE__ */ u(p.Content, {
283
+ className: `ui-tree-select-popover ${Me}`.trim(),
214
284
  sideOffset: 6,
215
285
  collisionPadding: 12,
216
286
  onOpenAutoFocus: (e) => e.preventDefault(),
217
287
  onCloseAutoFocus: (e) => e.preventDefault(),
218
288
  onInteractOutside: (e) => {
219
- Ne.current?.contains(e.target) && e.preventDefault();
289
+ Le.current?.contains(e.target) && e.preventDefault();
220
290
  },
221
- children: /* @__PURE__ */ u("div", {
222
- id: Me,
223
- className: "ui-tree-select-tree",
224
- role: "tree",
225
- "aria-label": typeof w == "string" ? w : "树形选项",
226
- "aria-busy": E || void 0,
227
- "aria-multiselectable": L || void 0,
228
- children: [/* @__PURE__ */ u("div", {
229
- id: v(N, p),
230
- role: "treeitem",
231
- "aria-level": 1,
232
- "aria-posinset": 1,
233
- "aria-setsize": G.length + 1,
234
- "aria-selected": L ? !R.length : V === null,
235
- className: ue(z === p, L ? !R.length : V === null, !1),
236
- onMouseDown: (e) => e.preventDefault(),
237
- onClick: () => $(null),
238
- children: [
239
- /* @__PURE__ */ l("span", { className: "ui-tree-select-spacer" }),
240
- /* @__PURE__ */ l("span", {
241
- className: "ui-tree-select-label",
242
- children: L ? T : be
243
- }),
244
- (L ? !R.length : V === null) && /* @__PURE__ */ l(ee, {
245
- size: 15,
246
- "aria-hidden": "true"
247
- })
248
- ]
249
- }), E ? /* @__PURE__ */ l("div", {
250
- className: "ui-tree-select-status",
251
- role: "status",
252
- children: Se
253
- }) : Ce === void 0 ? G.length ? $e(G, 1) : /* @__PURE__ */ l("div", {
254
- className: "ui-tree-select-status",
255
- children: xe
256
- }) : /* @__PURE__ */ l("div", {
257
- className: "ui-tree-select-status ui-tree-select-error",
258
- role: "alert",
259
- children: Ce
260
- })]
261
- })
291
+ children: it
262
292
  })
263
293
  })
264
294
  ]
265
295
  })
266
- }), L && R.length > 0 && /* @__PURE__ */ u("div", {
267
- className: "ui-multi-selection",
268
- "aria-label": "已选节点",
269
- children: [R.map((e) => /* @__PURE__ */ u("span", {
270
- className: "ui-selection-tag",
271
- children: [/* @__PURE__ */ l("span", {
272
- className: "ui-selection-tag-label",
273
- children: I.get(e)?.label ?? e
274
- }), /* @__PURE__ */ l("button", {
275
- type: "button",
276
- disabled: D,
277
- "aria-label": `移除 ${I.get(e)?.label ?? e}`,
278
- onClick: () => $(e),
279
- children: "×"
280
- })]
281
- }, e)), /* @__PURE__ */ l("button", {
282
- type: "button",
283
- className: "ui-selection-clear",
284
- disabled: D,
285
- onClick: () => $(null),
286
- children: T
287
- })]
288
- })]
296
+ }), j && U ? /* @__PURE__ */ d(r, {
297
+ title: C ?? "选择节点",
298
+ returnFocus: F,
299
+ initialFocus: Pe,
300
+ onClose: () => X(!1),
301
+ summary: R ? `已选 ${z.length} 项,即时生效` : void 0,
302
+ children: [
303
+ /* @__PURE__ */ u("input", {
304
+ ref: Pe,
305
+ className: "ui-input",
306
+ type: "search",
307
+ "aria-label": "搜索节点",
308
+ placeholder: Se,
309
+ value: W,
310
+ onChange: (e) => {
311
+ Z(e.target.value), V(null);
312
+ },
313
+ role: "combobox",
314
+ "aria-autocomplete": "list",
315
+ "aria-haspopup": "tree",
316
+ "aria-expanded": "true",
317
+ "aria-controls": P,
318
+ "aria-activedescendant": Y,
319
+ onKeyDown: nt,
320
+ onCompositionStart: (e) => {
321
+ M.current = !0, A?.onCompositionStart?.(e);
322
+ },
323
+ onCompositionEnd: (e) => {
324
+ M.current = !1, A?.onCompositionEnd?.(e);
325
+ }
326
+ }),
327
+ it,
328
+ /* @__PURE__ */ u("div", {
329
+ className: "ui-picker-sheet-selected",
330
+ children: at
331
+ })
332
+ ]
333
+ }) : at]
289
334
  });
290
- function $e(e, t) {
335
+ function ot(e, t) {
291
336
  return e.map((n, r) => {
292
- let i = K || W.has(n.id), a = n.children.length > 0, o = L ? Re.has(n.id) : V === n.id;
293
- return /* @__PURE__ */ u("div", {
337
+ let i = q || G.has(n.id), a = n.children.length > 0, o = R ? He.has(n.id) : H === n.id;
338
+ return /* @__PURE__ */ d("div", {
294
339
  className: "ui-tree-select-branch",
295
- children: [/* @__PURE__ */ l(ae, {
340
+ children: [/* @__PURE__ */ u(oe, {
296
341
  node: n,
297
342
  controlId: N,
298
343
  level: t,
@@ -300,21 +345,21 @@ function ie({ items: n, value: d, defaultValue: ie = null, onValueChange: h, ope
300
345
  size: e.length + +(t === 1),
301
346
  expanded: i,
302
347
  selected: o,
303
- active: z === n.id,
304
- activate: B,
348
+ active: B === n.id,
349
+ activate: V,
305
350
  commit: $,
306
- toggle: Ye
307
- }), i && a && /* @__PURE__ */ l("div", {
351
+ toggle: et
352
+ }), i && a && /* @__PURE__ */ u("div", {
308
353
  role: "group",
309
- children: $e(n.children, t + 1)
354
+ children: ot(n.children, t + 1)
310
355
  })]
311
356
  }, n.id);
312
357
  });
313
358
  }
314
359
  }
315
- var ae = n(function({ node: e, controlId: t, level: n, position: r, size: i, expanded: a, selected: o, active: s, activate: c, commit: ne, toggle: re }) {
316
- return /* @__PURE__ */ u("div", {
317
- id: v(t, e.id),
360
+ var oe = i(function({ node: e, controlId: t, level: n, position: r, size: i, expanded: a, selected: o, active: ee, activate: s, commit: c, toggle: l }) {
361
+ return /* @__PURE__ */ d("div", {
362
+ id: ue(t, e.id),
318
363
  role: "treeitem",
319
364
  "aria-level": n,
320
365
  "aria-posinset": r,
@@ -322,36 +367,36 @@ var ae = n(function({ node: e, controlId: t, level: n, position: r, size: i, exp
322
367
  "aria-expanded": e.children.length ? a : void 0,
323
368
  "aria-selected": o,
324
369
  "aria-disabled": e.disabled || void 0,
325
- className: ue(s, o, !!e.disabled),
370
+ className: de(ee, o, !!e.disabled),
326
371
  onMouseDown: (e) => e.preventDefault(),
327
- onMouseEnter: () => !e.disabled && c(e.id),
328
- onClick: () => !e.disabled && ne(e.id),
372
+ onMouseEnter: () => !e.disabled && s(e.id),
373
+ onClick: () => !e.disabled && c(e.id),
329
374
  children: [
330
- e.children.length ? /* @__PURE__ */ l("button", {
375
+ e.children.length ? /* @__PURE__ */ u("button", {
331
376
  type: "button",
332
377
  tabIndex: -1,
333
378
  className: "ui-tree-select-toggle",
334
379
  "aria-label": `${a ? "收起" : "展开"}${e.label}`,
335
380
  onClick: (t) => {
336
- t.stopPropagation(), re(e.id);
381
+ t.stopPropagation(), l(e.id);
337
382
  },
338
- children: l(a ? te : d, {
383
+ children: u(a ? ne : f, {
339
384
  size: 15,
340
385
  "aria-hidden": "true"
341
386
  })
342
- }) : /* @__PURE__ */ l("span", { className: "ui-tree-select-spacer" }),
343
- /* @__PURE__ */ l("span", {
387
+ }) : /* @__PURE__ */ u("span", { className: "ui-tree-select-spacer" }),
388
+ /* @__PURE__ */ u("span", {
344
389
  className: "ui-tree-select-label",
345
390
  children: e.label
346
391
  }),
347
- o && /* @__PURE__ */ l(ee, {
392
+ o && /* @__PURE__ */ u(te, {
348
393
  size: 15,
349
394
  "aria-hidden": "true"
350
395
  })
351
396
  ]
352
397
  });
353
398
  });
354
- function oe(e) {
399
+ function se(e) {
355
400
  let t = /* @__PURE__ */ new Map();
356
401
  for (let n of e) {
357
402
  let e = n.id.trim();
@@ -366,7 +411,7 @@ function oe(e) {
366
411
  let r = e.parentId && t.has(e.parentId) && e.parentId !== e.id ? e.parentId : null;
367
412
  n.set(e.id, r);
368
413
  }
369
- let r = h(n), i = new Map([...t].map(([e, t]) => [e, {
414
+ let r = g(n), i = new Map([...t].map(([e, t]) => [e, {
370
415
  ...t,
371
416
  children: []
372
417
  }])), a = [];
@@ -374,20 +419,20 @@ function oe(e) {
374
419
  let t = r.has(e.id) ? null : n.get(e.id), o = t ? i.get(t) : void 0;
375
420
  o ? o.children.push(e) : a.push(e);
376
421
  }
377
- return g(a), a;
422
+ return _(a), a;
378
423
  }
379
- function m(e, t) {
424
+ function h(e, t) {
380
425
  let n = t.trim().toLocaleLowerCase("zh-CN");
381
426
  return n ? e.flatMap((e) => {
382
- if (e.label.toLocaleLowerCase("zh-CN").includes(n)) return [_(e)];
383
- let t = m(e.children, n);
427
+ if (e.label.toLocaleLowerCase("zh-CN").includes(n)) return [v(e)];
428
+ let t = h(e.children, n);
384
429
  return t.length ? [{
385
430
  ...e,
386
431
  children: t
387
432
  }] : [];
388
- }) : e.map(_);
433
+ }) : e.map(v);
389
434
  }
390
- function h(e) {
435
+ function g(e) {
391
436
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
392
437
  for (let r of e.keys()) {
393
438
  if (t.has(r)) continue;
@@ -404,21 +449,21 @@ function h(e) {
404
449
  }
405
450
  return n;
406
451
  }
407
- function g(e) {
452
+ function _(e) {
408
453
  e.sort((e, t) => (e.order ?? 0) - (t.order ?? 0) || e.label.localeCompare(t.label, "zh-CN") || e.id.localeCompare(t.id));
409
- for (let t of e) g(t.children);
454
+ for (let t of e) _(t.children);
410
455
  }
411
- function _(e) {
456
+ function v(e) {
412
457
  return {
413
458
  ...e,
414
- children: e.children.map(_)
459
+ children: e.children.map(v)
415
460
  };
416
461
  }
417
- function se(e) {
418
- return e.flatMap((e) => [e, ...se(e.children)]);
462
+ function y(e) {
463
+ return e.flatMap((e) => [e, ...y(e.children)]);
419
464
  }
420
465
  function ce(e) {
421
- return se(e).filter((e) => e.children.length).map((e) => e.id);
466
+ return y(e).filter((e) => e.children.length).map((e) => e.id);
422
467
  }
423
468
  function le(e, t, n, r = 1, i = null) {
424
469
  return e.flatMap((a, o) => [{
@@ -429,10 +474,10 @@ function le(e, t, n, r = 1, i = null) {
429
474
  setSize: e.length
430
475
  }, ...a.children.length && (n || t.has(a.id)) ? le(a.children, t, n, r + 1, a.id) : []]);
431
476
  }
432
- function v(e, t) {
477
+ function ue(e, t) {
433
478
  return `${e}-item-${encodeURIComponent(t).replaceAll("%", "_")}`;
434
479
  }
435
- function ue(e, t, n) {
480
+ function de(e, t, n) {
436
481
  return [
437
482
  "ui-tree-select-item",
438
483
  e ? "active" : "",
@@ -440,8 +485,8 @@ function ue(e, t, n) {
440
485
  n ? "disabled" : ""
441
486
  ].filter(Boolean).join(" ");
442
487
  }
443
- function de(...e) {
488
+ function fe(...e) {
444
489
  return e.filter(Boolean).join(" ") || void 0;
445
490
  }
446
491
  //#endregion
447
- export { ie as TreeSelect, oe as buildTreeSelectTree, m as filterTreeSelectTree };
492
+ export { ae as TreeSelect, se as buildTreeSelectTree, h as filterTreeSelectTree };