@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.
- package/AGENTS.md +15 -0
- package/CHANGELOG.md +22 -0
- package/README.md +2 -0
- package/THIRD_PARTY_NOTICES.md +3 -0
- package/bin/business-ui-gate.mjs +2 -2
- package/dist/AntDateWheelView.js +131 -0
- package/dist/AntOptionWheelView.js +76 -0
- package/dist/AsyncDirectoryPicker.js +89 -88
- package/dist/AsyncSearchPicker.js +136 -82
- package/dist/Cascader.js +56 -51
- package/dist/DateInput.js +84 -66
- package/dist/DateWheelPicker.js +58 -0
- package/dist/MobilePickerPanel.js +34 -0
- package/dist/ModalShell.js +84 -72
- package/dist/MultiSelect.js +5 -1
- package/dist/OptionWheelDialog.js +99 -0
- package/dist/Select.js +116 -61
- package/dist/StructuredAddressInput.js +72 -70
- package/dist/TreeSelect.js +265 -217
- package/dist/WheelCascader.js +123 -0
- package/dist/WheelDateInput.js +97 -0
- package/dist/business-ui.js +42 -39
- package/dist/date-wheel-model.js +27 -0
- package/dist/option-wheel-model.js +49 -0
- package/dist/styles.css +1 -1
- package/dist/types/AntDateWheelView.d.ts +9 -0
- package/dist/types/AntOptionWheelView.d.ts +8 -0
- package/dist/types/AsyncDirectoryPicker.d.ts +2 -1
- package/dist/types/AsyncSearchPicker.d.ts +3 -1
- package/dist/types/Cascader.d.ts +2 -0
- package/dist/types/DateInput.d.ts +4 -0
- package/dist/types/DateWheelPicker.d.ts +13 -0
- package/dist/types/MobilePickerPanel.d.ts +11 -0
- package/dist/types/ModalShell.d.ts +3 -1
- package/dist/types/OptionWheelDialog.d.ts +18 -0
- package/dist/types/Select.d.ts +4 -1
- package/dist/types/StructuredAddressInput.d.ts +3 -1
- package/dist/types/TreeSelect.d.ts +2 -1
- package/dist/types/WheelCascader.d.ts +6 -0
- package/dist/types/WheelDateInput.d.ts +11 -0
- package/dist/types/date-wheel-model.d.ts +8 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/option-wheel-model.d.ts +19 -0
- package/dist/types/usePhoneWheel.d.ts +2 -0
- package/dist/types/useSheetViewport.d.ts +3 -0
- package/dist/usePhoneWheel.js +16 -0
- package/dist/useSheetViewport.js +26 -0
- package/docs/agent-guide.md +15 -5
- package/docs/api.md +16 -0
- package/docs/cascader.md +2 -0
- package/docs/component-strategy.md +18 -0
- package/docs/date-wheel.md +25 -0
- package/docs/dependencies.md +2 -0
- package/docs/mobile-controls.md +74 -0
- package/docs/modal-shell-migration.md +25 -0
- package/docs/release.md +8 -1
- package/docs/viewport-qa.md +52 -0
- package/licenses/antd-mobile-MIT.txt +22 -0
- package/package.json +11 -2
package/dist/TreeSelect.js
CHANGED
|
@@ -1,205 +1,275 @@
|
|
|
1
1
|
import { useOverlayContainer as e } from "./OverlayContainer.js";
|
|
2
2
|
import { FormField as t } from "./FormField.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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
|
|
9
|
-
function
|
|
10
|
-
let
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
key: p,
|
|
15
|
+
q
|
|
16
|
+
]), J = s(() => [{
|
|
17
|
+
key: m,
|
|
16
18
|
disabled: !1
|
|
17
|
-
}, ...
|
|
19
|
+
}, ...Ye.map(({ node: e }) => ({
|
|
18
20
|
key: e.id,
|
|
19
21
|
disabled: !!e.disabled
|
|
20
|
-
}))], [
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
+
B,
|
|
27
|
+
U,
|
|
26
28
|
J,
|
|
27
|
-
|
|
28
|
-
]),
|
|
29
|
-
|
|
30
|
-
}, [Y,
|
|
31
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
D,
|
|
36
|
+
H,
|
|
37
|
+
R,
|
|
38
|
+
z
|
|
37
39
|
]);
|
|
38
40
|
function X(e) {
|
|
39
|
-
|
|
41
|
+
_ === void 0 && We(e), pe?.(e), e || (Z(""), V(null));
|
|
40
42
|
}
|
|
41
43
|
function Z(e) {
|
|
42
|
-
|
|
44
|
+
b === void 0 && Ke(e), x?.(e);
|
|
43
45
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
+
function $e(e) {
|
|
47
|
+
f === void 0 && ze(e), g?.(e);
|
|
46
48
|
}
|
|
47
49
|
function Q() {
|
|
48
|
-
|
|
50
|
+
E || U || (Z(""), X(!0));
|
|
49
51
|
}
|
|
50
|
-
let $ =
|
|
51
|
-
if (
|
|
52
|
-
let t = e === null ? [] :
|
|
53
|
-
|
|
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
|
-
|
|
58
|
+
f === void 0 && ze(e), g?.(e), _ === void 0 && We(!1), pe?.(!1), b === void 0 && Ke(""), x?.(""), V(null);
|
|
57
59
|
}, [
|
|
58
|
-
|
|
59
|
-
h,
|
|
60
|
+
f,
|
|
60
61
|
g,
|
|
61
|
-
|
|
62
|
+
_,
|
|
63
|
+
pe,
|
|
64
|
+
b,
|
|
62
65
|
x,
|
|
63
|
-
S,
|
|
64
|
-
L,
|
|
65
66
|
R,
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
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
|
-
|
|
82
|
+
V(n[t === "start" ? 0 : n.length - 1].key);
|
|
81
83
|
return;
|
|
82
84
|
}
|
|
83
|
-
let r = n.findIndex((e) => e.key ===
|
|
84
|
-
|
|
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
|
|
87
|
-
if (
|
|
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
|
-
|
|
95
|
+
U && !j && X(!1);
|
|
90
96
|
return;
|
|
91
97
|
}
|
|
92
|
-
if (e.key === "Escape" &&
|
|
98
|
+
if (e.key === "Escape" && U) {
|
|
93
99
|
e.preventDefault(), e.stopPropagation(), X(!1);
|
|
94
100
|
return;
|
|
95
101
|
}
|
|
96
|
-
if (e.key === "Backspace" && !
|
|
97
|
-
e.preventDefault(),
|
|
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" ?
|
|
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 =
|
|
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 && !
|
|
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 &&
|
|
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" &&
|
|
119
|
+
e.key === "Enter" && U && B !== null && (e.preventDefault(), B === m ? $(null) : t && !t.node.disabled && $(B));
|
|
114
120
|
}
|
|
115
|
-
function
|
|
116
|
-
|
|
121
|
+
function rt(e) {
|
|
122
|
+
F.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
|
|
117
123
|
}
|
|
118
|
-
|
|
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:
|
|
121
|
-
required:
|
|
122
|
-
helpText:
|
|
123
|
-
error:
|
|
124
|
-
containerClassName: `ui-tree-select ${
|
|
125
|
-
children: [/* @__PURE__ */
|
|
126
|
-
open:
|
|
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__ */
|
|
197
|
+
children: /* @__PURE__ */ d("div", {
|
|
129
198
|
className: "ui-tree-select-root",
|
|
130
|
-
ref:
|
|
199
|
+
ref: Le,
|
|
131
200
|
children: [
|
|
132
|
-
|
|
201
|
+
ke && (R ? z : [H ?? ""]).map((e) => /* @__PURE__ */ u("input", {
|
|
133
202
|
type: "hidden",
|
|
134
|
-
name:
|
|
135
|
-
value:
|
|
136
|
-
disabled:
|
|
137
|
-
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__ */
|
|
208
|
+
/* @__PURE__ */ u(p.Anchor, {
|
|
140
209
|
asChild: !0,
|
|
141
|
-
children: /* @__PURE__ */
|
|
210
|
+
children: /* @__PURE__ */ d("div", {
|
|
142
211
|
className: "ui-tree-select-control",
|
|
143
212
|
children: [
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
...
|
|
146
|
-
ref:
|
|
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":
|
|
153
|
-
"aria-controls":
|
|
154
|
-
"aria-activedescendant":
|
|
155
|
-
"aria-describedby":
|
|
156
|
-
"aria-invalid":
|
|
157
|
-
"aria-required":
|
|
158
|
-
disabled:
|
|
159
|
-
|
|
160
|
-
|
|
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,
|
|
232
|
+
M.current = !0, A?.onCompositionStart?.(e);
|
|
163
233
|
},
|
|
164
234
|
onCompositionEnd: (e) => {
|
|
165
|
-
M.current = !1,
|
|
235
|
+
M.current = !1, A?.onCompositionEnd?.(e);
|
|
166
236
|
},
|
|
167
237
|
onFocus: (e) => {
|
|
168
|
-
|
|
238
|
+
A?.onFocus?.(e), !e.defaultPrevented && !j && Q();
|
|
169
239
|
},
|
|
170
240
|
onClick: Q,
|
|
171
241
|
onChange: (e) => {
|
|
172
|
-
|
|
242
|
+
U || X(!0), Z(e.target.value), V(null);
|
|
173
243
|
},
|
|
174
|
-
onKeyDown:
|
|
244
|
+
onKeyDown: nt
|
|
175
245
|
}),
|
|
176
|
-
|
|
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":
|
|
250
|
+
"aria-label": w,
|
|
181
251
|
onMouseDown: (e) => e.preventDefault(),
|
|
182
252
|
onClick: () => {
|
|
183
|
-
|
|
253
|
+
$e(null), Z(""), F.current?.focus();
|
|
184
254
|
},
|
|
185
|
-
children: /* @__PURE__ */
|
|
255
|
+
children: /* @__PURE__ */ u(ie, {
|
|
186
256
|
size: 15,
|
|
187
257
|
"aria-hidden": "true"
|
|
188
258
|
})
|
|
189
259
|
}),
|
|
190
|
-
/* @__PURE__ */
|
|
260
|
+
/* @__PURE__ */ u("button", {
|
|
191
261
|
type: "button",
|
|
192
262
|
tabIndex: -1,
|
|
193
263
|
className: "ui-tree-select-trigger",
|
|
194
|
-
"aria-label":
|
|
195
|
-
disabled:
|
|
264
|
+
"aria-label": U ? "收起选项" : "展开选项",
|
|
265
|
+
disabled: E,
|
|
196
266
|
onMouseDown: (e) => e.preventDefault(),
|
|
197
|
-
onClick: () =>
|
|
198
|
-
children:
|
|
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__ */
|
|
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__ */
|
|
211
|
-
container:
|
|
212
|
-
children: /* @__PURE__ */
|
|
213
|
-
className: `ui-tree-select-popover ${
|
|
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
|
-
|
|
289
|
+
Le.current?.contains(e.target) && e.preventDefault();
|
|
220
290
|
},
|
|
221
|
-
children:
|
|
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
|
-
}),
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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
|
|
335
|
+
function ot(e, t) {
|
|
288
336
|
return e.map((n, r) => {
|
|
289
|
-
let i =
|
|
290
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
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:
|
|
301
|
-
activate:
|
|
348
|
+
active: B === n.id,
|
|
349
|
+
activate: V,
|
|
302
350
|
commit: $,
|
|
303
|
-
toggle:
|
|
304
|
-
}), i && a && /* @__PURE__ */
|
|
351
|
+
toggle: et
|
|
352
|
+
}), i && a && /* @__PURE__ */ u("div", {
|
|
305
353
|
role: "group",
|
|
306
|
-
children:
|
|
354
|
+
children: ot(n.children, t + 1)
|
|
307
355
|
})]
|
|
308
356
|
}, n.id);
|
|
309
357
|
});
|
|
310
358
|
}
|
|
311
359
|
}
|
|
312
|
-
var
|
|
313
|
-
return /* @__PURE__ */
|
|
314
|
-
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:
|
|
370
|
+
className: de(ee, o, !!e.disabled),
|
|
323
371
|
onMouseDown: (e) => e.preventDefault(),
|
|
324
|
-
onMouseEnter: () => !e.disabled &&
|
|
325
|
-
onClick: () => !e.disabled &&
|
|
372
|
+
onMouseEnter: () => !e.disabled && s(e.id),
|
|
373
|
+
onClick: () => !e.disabled && c(e.id),
|
|
326
374
|
children: [
|
|
327
|
-
e.children.length ? /* @__PURE__ */
|
|
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(),
|
|
381
|
+
t.stopPropagation(), l(e.id);
|
|
334
382
|
},
|
|
335
|
-
children:
|
|
383
|
+
children: u(a ? ne : f, {
|
|
336
384
|
size: 15,
|
|
337
385
|
"aria-hidden": "true"
|
|
338
386
|
})
|
|
339
|
-
}) : /* @__PURE__ */
|
|
340
|
-
/* @__PURE__ */
|
|
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__ */
|
|
392
|
+
o && /* @__PURE__ */ u(te, {
|
|
345
393
|
size: 15,
|
|
346
394
|
"aria-hidden": "true"
|
|
347
395
|
})
|
|
348
396
|
]
|
|
349
397
|
});
|
|
350
398
|
});
|
|
351
|
-
function
|
|
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 =
|
|
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
|
|
422
|
+
return _(a), a;
|
|
375
423
|
}
|
|
376
|
-
function
|
|
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 [
|
|
380
|
-
let t =
|
|
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
|
|
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
|
|
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)
|
|
454
|
+
for (let t of e) _(t.children);
|
|
407
455
|
}
|
|
408
|
-
function
|
|
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
|
|
415
|
-
return e.flatMap((e) => [e, ...
|
|
462
|
+
function y(e) {
|
|
463
|
+
return e.flatMap((e) => [e, ...y(e.children)]);
|
|
416
464
|
}
|
|
417
465
|
function ce(e) {
|
|
418
|
-
return
|
|
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
|
|
477
|
+
function ue(e, t) {
|
|
430
478
|
return `${e}-item-${encodeURIComponent(t).replaceAll("%", "_")}`;
|
|
431
479
|
}
|
|
432
|
-
function
|
|
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
|
|
488
|
+
function fe(...e) {
|
|
441
489
|
return e.filter(Boolean).join(" ") || void 0;
|
|
442
490
|
}
|
|
443
491
|
//#endregion
|
|
444
|
-
export {
|
|
492
|
+
export { ae as TreeSelect, se as buildTreeSelectTree, h as filterTreeSelectTree };
|