@jc-times/business-ui 0.3.2 → 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.
Files changed (59) hide show
  1. package/AGENTS.md +15 -0
  2. package/CHANGELOG.md +22 -0
  3. package/README.md +2 -0
  4. package/THIRD_PARTY_NOTICES.md +3 -0
  5. package/bin/business-ui-gate.mjs +2 -2
  6. package/dist/AntDateWheelView.js +131 -0
  7. package/dist/AntOptionWheelView.js +76 -0
  8. package/dist/AsyncDirectoryPicker.js +89 -88
  9. package/dist/AsyncSearchPicker.js +136 -82
  10. package/dist/Cascader.js +56 -51
  11. package/dist/DateInput.js +84 -66
  12. package/dist/DateWheelPicker.js +58 -0
  13. package/dist/MobilePickerPanel.js +34 -0
  14. package/dist/ModalShell.js +84 -72
  15. package/dist/MultiSelect.js +5 -1
  16. package/dist/OptionWheelDialog.js +99 -0
  17. package/dist/Select.js +116 -61
  18. package/dist/StructuredAddressInput.js +72 -70
  19. package/dist/TreeSelect.js +265 -217
  20. package/dist/WheelCascader.js +123 -0
  21. package/dist/WheelDateInput.js +97 -0
  22. package/dist/business-ui.js +42 -39
  23. package/dist/date-wheel-model.js +27 -0
  24. package/dist/option-wheel-model.js +49 -0
  25. package/dist/styles.css +1 -1
  26. package/dist/types/AntDateWheelView.d.ts +9 -0
  27. package/dist/types/AntOptionWheelView.d.ts +8 -0
  28. package/dist/types/AsyncDirectoryPicker.d.ts +2 -1
  29. package/dist/types/AsyncSearchPicker.d.ts +3 -1
  30. package/dist/types/Cascader.d.ts +2 -0
  31. package/dist/types/DateInput.d.ts +4 -0
  32. package/dist/types/DateWheelPicker.d.ts +13 -0
  33. package/dist/types/MobilePickerPanel.d.ts +11 -0
  34. package/dist/types/ModalShell.d.ts +3 -1
  35. package/dist/types/OptionWheelDialog.d.ts +18 -0
  36. package/dist/types/Select.d.ts +4 -1
  37. package/dist/types/StructuredAddressInput.d.ts +3 -1
  38. package/dist/types/TreeSelect.d.ts +2 -1
  39. package/dist/types/WheelCascader.d.ts +6 -0
  40. package/dist/types/WheelDateInput.d.ts +11 -0
  41. package/dist/types/date-wheel-model.d.ts +8 -0
  42. package/dist/types/index.d.ts +3 -0
  43. package/dist/types/option-wheel-model.d.ts +19 -0
  44. package/dist/types/usePhoneWheel.d.ts +2 -0
  45. package/dist/types/useSheetViewport.d.ts +3 -0
  46. package/dist/usePhoneWheel.js +16 -0
  47. package/dist/useSheetViewport.js +26 -0
  48. package/docs/agent-guide.md +15 -5
  49. package/docs/api.md +16 -0
  50. package/docs/cascader.md +2 -0
  51. package/docs/component-strategy.md +18 -0
  52. package/docs/date-wheel.md +25 -0
  53. package/docs/dependencies.md +2 -0
  54. package/docs/mobile-controls.md +74 -0
  55. package/docs/modal-shell-migration.md +25 -0
  56. package/docs/release.md +8 -1
  57. package/docs/viewport-qa.md +52 -0
  58. package/licenses/antd-mobile-MIT.txt +22 -0
  59. package/package.json +11 -2
@@ -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,89 +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: [I.get(e)?.label ?? e, /* @__PURE__ */ l("button", {
272
- type: "button",
273
- disabled: D,
274
- "aria-label": `移除 ${I.get(e)?.label ?? e}`,
275
- onClick: () => $(e),
276
- children: "×"
277
- })]
278
- }, e)), /* @__PURE__ */ l("button", {
279
- type: "button",
280
- className: "ui-selection-clear",
281
- disabled: D,
282
- onClick: () => $(null),
283
- children: T
284
- })]
285
- })]
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]
286
334
  });
287
- function $e(e, t) {
335
+ function ot(e, t) {
288
336
  return e.map((n, r) => {
289
- let i = K || W.has(n.id), a = n.children.length > 0, o = L ? Re.has(n.id) : V === n.id;
290
- 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", {
291
339
  className: "ui-tree-select-branch",
292
- children: [/* @__PURE__ */ l(ae, {
340
+ children: [/* @__PURE__ */ u(oe, {
293
341
  node: n,
294
342
  controlId: N,
295
343
  level: t,
@@ -297,21 +345,21 @@ function ie({ items: n, value: d, defaultValue: ie = null, onValueChange: h, ope
297
345
  size: e.length + +(t === 1),
298
346
  expanded: i,
299
347
  selected: o,
300
- active: z === n.id,
301
- activate: B,
348
+ active: B === n.id,
349
+ activate: V,
302
350
  commit: $,
303
- toggle: Ye
304
- }), i && a && /* @__PURE__ */ l("div", {
351
+ toggle: et
352
+ }), i && a && /* @__PURE__ */ u("div", {
305
353
  role: "group",
306
- children: $e(n.children, t + 1)
354
+ children: ot(n.children, t + 1)
307
355
  })]
308
356
  }, n.id);
309
357
  });
310
358
  }
311
359
  }
312
- 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 }) {
313
- return /* @__PURE__ */ u("div", {
314
- 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),
315
363
  role: "treeitem",
316
364
  "aria-level": n,
317
365
  "aria-posinset": r,
@@ -319,36 +367,36 @@ var ae = n(function({ node: e, controlId: t, level: n, position: r, size: i, exp
319
367
  "aria-expanded": e.children.length ? a : void 0,
320
368
  "aria-selected": o,
321
369
  "aria-disabled": e.disabled || void 0,
322
- className: ue(s, o, !!e.disabled),
370
+ className: de(ee, o, !!e.disabled),
323
371
  onMouseDown: (e) => e.preventDefault(),
324
- onMouseEnter: () => !e.disabled && c(e.id),
325
- onClick: () => !e.disabled && ne(e.id),
372
+ onMouseEnter: () => !e.disabled && s(e.id),
373
+ onClick: () => !e.disabled && c(e.id),
326
374
  children: [
327
- e.children.length ? /* @__PURE__ */ l("button", {
375
+ e.children.length ? /* @__PURE__ */ u("button", {
328
376
  type: "button",
329
377
  tabIndex: -1,
330
378
  className: "ui-tree-select-toggle",
331
379
  "aria-label": `${a ? "收起" : "展开"}${e.label}`,
332
380
  onClick: (t) => {
333
- t.stopPropagation(), re(e.id);
381
+ t.stopPropagation(), l(e.id);
334
382
  },
335
- children: l(a ? te : d, {
383
+ children: u(a ? ne : f, {
336
384
  size: 15,
337
385
  "aria-hidden": "true"
338
386
  })
339
- }) : /* @__PURE__ */ l("span", { className: "ui-tree-select-spacer" }),
340
- /* @__PURE__ */ l("span", {
387
+ }) : /* @__PURE__ */ u("span", { className: "ui-tree-select-spacer" }),
388
+ /* @__PURE__ */ u("span", {
341
389
  className: "ui-tree-select-label",
342
390
  children: e.label
343
391
  }),
344
- o && /* @__PURE__ */ l(ee, {
392
+ o && /* @__PURE__ */ u(te, {
345
393
  size: 15,
346
394
  "aria-hidden": "true"
347
395
  })
348
396
  ]
349
397
  });
350
398
  });
351
- function oe(e) {
399
+ function se(e) {
352
400
  let t = /* @__PURE__ */ new Map();
353
401
  for (let n of e) {
354
402
  let e = n.id.trim();
@@ -363,7 +411,7 @@ function oe(e) {
363
411
  let r = e.parentId && t.has(e.parentId) && e.parentId !== e.id ? e.parentId : null;
364
412
  n.set(e.id, r);
365
413
  }
366
- 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, {
367
415
  ...t,
368
416
  children: []
369
417
  }])), a = [];
@@ -371,20 +419,20 @@ function oe(e) {
371
419
  let t = r.has(e.id) ? null : n.get(e.id), o = t ? i.get(t) : void 0;
372
420
  o ? o.children.push(e) : a.push(e);
373
421
  }
374
- return g(a), a;
422
+ return _(a), a;
375
423
  }
376
- function m(e, t) {
424
+ function h(e, t) {
377
425
  let n = t.trim().toLocaleLowerCase("zh-CN");
378
426
  return n ? e.flatMap((e) => {
379
- if (e.label.toLocaleLowerCase("zh-CN").includes(n)) return [_(e)];
380
- 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);
381
429
  return t.length ? [{
382
430
  ...e,
383
431
  children: t
384
432
  }] : [];
385
- }) : e.map(_);
433
+ }) : e.map(v);
386
434
  }
387
- function h(e) {
435
+ function g(e) {
388
436
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
389
437
  for (let r of e.keys()) {
390
438
  if (t.has(r)) continue;
@@ -401,21 +449,21 @@ function h(e) {
401
449
  }
402
450
  return n;
403
451
  }
404
- function g(e) {
452
+ function _(e) {
405
453
  e.sort((e, t) => (e.order ?? 0) - (t.order ?? 0) || e.label.localeCompare(t.label, "zh-CN") || e.id.localeCompare(t.id));
406
- for (let t of e) g(t.children);
454
+ for (let t of e) _(t.children);
407
455
  }
408
- function _(e) {
456
+ function v(e) {
409
457
  return {
410
458
  ...e,
411
- children: e.children.map(_)
459
+ children: e.children.map(v)
412
460
  };
413
461
  }
414
- function se(e) {
415
- return e.flatMap((e) => [e, ...se(e.children)]);
462
+ function y(e) {
463
+ return e.flatMap((e) => [e, ...y(e.children)]);
416
464
  }
417
465
  function ce(e) {
418
- 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);
419
467
  }
420
468
  function le(e, t, n, r = 1, i = null) {
421
469
  return e.flatMap((a, o) => [{
@@ -426,10 +474,10 @@ function le(e, t, n, r = 1, i = null) {
426
474
  setSize: e.length
427
475
  }, ...a.children.length && (n || t.has(a.id)) ? le(a.children, t, n, r + 1, a.id) : []]);
428
476
  }
429
- function v(e, t) {
477
+ function ue(e, t) {
430
478
  return `${e}-item-${encodeURIComponent(t).replaceAll("%", "_")}`;
431
479
  }
432
- function ue(e, t, n) {
480
+ function de(e, t, n) {
433
481
  return [
434
482
  "ui-tree-select-item",
435
483
  e ? "active" : "",
@@ -437,8 +485,8 @@ function ue(e, t, n) {
437
485
  n ? "disabled" : ""
438
486
  ].filter(Boolean).join(" ");
439
487
  }
440
- function de(...e) {
488
+ function fe(...e) {
441
489
  return e.filter(Boolean).join(" ") || void 0;
442
490
  }
443
491
  //#endregion
444
- export { ie as TreeSelect, oe as buildTreeSelectTree, m as filterTreeSelectTree };
492
+ export { ae as TreeSelect, se as buildTreeSelectTree, h as filterTreeSelectTree };