@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.
- package/CHANGELOG.md +5 -0
- package/dist/AsyncDirectoryPicker.js +89 -88
- package/dist/AsyncSearchPicker.js +136 -82
- package/dist/MobilePickerPanel.js +34 -0
- package/dist/TreeSelect.js +265 -220
- package/dist/styles.css +1 -1
- package/dist/types/AsyncDirectoryPicker.d.ts +2 -1
- package/dist/types/AsyncSearchPicker.d.ts +3 -1
- package/dist/types/MobilePickerPanel.d.ts +11 -0
- package/dist/types/TreeSelect.d.ts +2 -1
- package/docs/agent-guide.md +2 -0
- package/docs/api.md +2 -0
- package/docs/component-strategy.md +15 -0
- package/docs/mobile-controls.md +22 -2
- package/docs/release.md +1 -1
- package/docs/viewport-qa.md +14 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## 0.4.1 — 2026-09-28(patch,按用户指定)
|
|
2
|
+
|
|
3
|
+
- AsyncDirectoryPicker/AsyncSearchPicker、TreeSelect 新增可选手机 bottom-sheet 面板,复用 ModalShell/Radix Dialog;搜索与结果同屏、独立滚动、固定底栏、返回焦点与软键盘视口适配。默认桌面行为及树即时多选契约保留。
|
|
4
|
+
- 核对现有成熟内核;普通搜索继续使用 React Aria,树节点内核迁移作为独立候选,不采用上游明确不建议使用的 antd-mobile TreeSelect。
|
|
5
|
+
|
|
1
6
|
## 0.4.0 — 2026-09-28(minor)
|
|
2
7
|
|
|
3
8
|
- 修复滚轮控件外部 ref 转发在 React 18 类型定义下无法编译的问题,兼容 React 18/19。
|
|
@@ -1,134 +1,135 @@
|
|
|
1
1
|
import { AsyncSearchPicker as e } from "./AsyncSearchPicker.js";
|
|
2
2
|
import { useEffect as t, useRef as n, useState as r } from "react";
|
|
3
|
-
import { Fragment as i, jsx as a, jsxs as
|
|
3
|
+
import { Fragment as i, jsx as a, jsxs as ee } from "react/jsx-runtime";
|
|
4
4
|
//#region src/AsyncDirectoryPicker.tsx
|
|
5
|
-
function
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
let [
|
|
9
|
-
|
|
10
|
-
for (;
|
|
11
|
-
}, [
|
|
12
|
-
|
|
5
|
+
function o({ selectedItem: o, loadItems: te, getKey: s, getText: c, getSelectionText: l = c, renderItem: ne, onSelect: u, onQueryChange: d, ownerKey: f = "", label: p, placeholder: m = "输入关键词搜索", searchLabel: h, loadingTitle: g, emptyText: re, minimumCharacters: _ = 0, minimumCharactersText: v, debounceMs: y = 200, cacheSize: b = 50, cacheTtlMs: x = 3e5, refreshKey: S, loadOnFocus: C = !0, disabled: w = !1, busy: T = !1, className: E, inputProps: D, mobileMode: O }) {
|
|
6
|
+
let k = o ? l(o) : "", [A, j] = r(k), [M, N] = r(k), [P, F] = r([]), [I, L] = r("idle"), [R, z] = r(!1), [B, V] = r(!1), [H, U] = r(!1), W = n(0), G = n(k);
|
|
7
|
+
G.current = k;
|
|
8
|
+
let [K, q] = r(""), J = n(null), Y = n(0), X = n(/* @__PURE__ */ new Map()), Z = Number.isFinite(b) ? Math.max(0, Math.floor(b)) : 50, Q = n(Z);
|
|
9
|
+
Q.current = Z, t(() => {
|
|
10
|
+
for (; X.current.size > Z;) X.current.delete(X.current.keys().next().value);
|
|
11
|
+
}, [Z]), t(() => () => {
|
|
12
|
+
Y.current++, W.current++, J.current?.abort();
|
|
13
13
|
}, []), t(() => {
|
|
14
|
-
|
|
15
|
-
let e =
|
|
16
|
-
|
|
17
|
-
}, [
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
|
|
21
|
-
let e =
|
|
22
|
-
|
|
23
|
-
}, [
|
|
24
|
-
if (w || T ||
|
|
25
|
-
let e = window.setTimeout(() => void
|
|
14
|
+
Y.current++, J.current?.abort(), J.current = null, X.current.clear(), W.current++, U(!1);
|
|
15
|
+
let e = o ? l(o) : "";
|
|
16
|
+
j(e), N(e), F([]), L("idle"), q("");
|
|
17
|
+
}, [f]), t(() => {
|
|
18
|
+
Y.current++, J.current?.abort(), X.current.clear(), F([]), L("idle");
|
|
19
|
+
}, [S, x]), t(() => {
|
|
20
|
+
Y.current++, J.current?.abort(), W.current++, U(!1);
|
|
21
|
+
let e = o ? l(o) : "";
|
|
22
|
+
j(e), N(e), F([]), L("idle"), q("");
|
|
23
|
+
}, [o && s(o), o && l(o)]), t(() => {
|
|
24
|
+
if (w || T || H || R || B || A === M || A.trim().length < _) return;
|
|
25
|
+
let e = window.setTimeout(() => void $(A), Math.max(0, y));
|
|
26
26
|
return () => window.clearTimeout(e);
|
|
27
27
|
}, [
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
A,
|
|
29
|
+
M,
|
|
30
30
|
w,
|
|
31
31
|
T,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
H,
|
|
33
|
+
R,
|
|
34
|
+
B,
|
|
35
|
+
_,
|
|
35
36
|
y,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
S
|
|
37
|
+
S,
|
|
38
|
+
x
|
|
39
39
|
]);
|
|
40
|
-
async function
|
|
40
|
+
async function $(e = A) {
|
|
41
41
|
let t = e.trim();
|
|
42
|
-
if (w || T ||
|
|
43
|
-
let n = ++
|
|
44
|
-
|
|
45
|
-
let r = t, i =
|
|
42
|
+
if (w || T || H || B || t.length < _) return;
|
|
43
|
+
let n = ++Y.current;
|
|
44
|
+
J.current?.abort(), J.current = null;
|
|
45
|
+
let r = t, i = Z > 0 ? X.current.get(r) : void 0;
|
|
46
46
|
if (i && i.expires > Date.now()) {
|
|
47
|
-
|
|
47
|
+
X.current.delete(r), X.current.set(r, i), F(i.items), L("success"), q("");
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
let a = new AbortController();
|
|
51
|
-
|
|
51
|
+
J.current = a, L("loading"), q("");
|
|
52
52
|
try {
|
|
53
|
-
let e = await
|
|
54
|
-
if (n !==
|
|
55
|
-
if (
|
|
53
|
+
let e = await te(t, a.signal);
|
|
54
|
+
if (n !== Y.current || a.signal.aborted) return;
|
|
55
|
+
if (Q.current > 0) for (X.current.delete(r), X.current.set(r, {
|
|
56
56
|
items: e,
|
|
57
|
-
expires: Date.now() + Math.max(0,
|
|
58
|
-
});
|
|
59
|
-
|
|
57
|
+
expires: Date.now() + Math.max(0, x)
|
|
58
|
+
}); X.current.size > Q.current;) X.current.delete(X.current.keys().next().value);
|
|
59
|
+
F(e), L("success");
|
|
60
60
|
} catch (e) {
|
|
61
|
-
if (n !==
|
|
62
|
-
|
|
61
|
+
if (n !== Y.current || a.signal.aborted) return;
|
|
62
|
+
q(e instanceof Error ? e.message : "目录查询失败"), L("error");
|
|
63
63
|
} finally {
|
|
64
|
-
n ===
|
|
64
|
+
n === Y.current && (J.current = null);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
|
|
67
|
+
function ie(e) {
|
|
68
|
+
Y.current++, J.current?.abort(), J.current = null, j(e), N(""), F([]), L("idle"), q(""), d?.(e);
|
|
69
69
|
}
|
|
70
|
-
async function
|
|
71
|
-
|
|
72
|
-
let t = ++
|
|
73
|
-
|
|
70
|
+
async function ae(e) {
|
|
71
|
+
Y.current++, J.current?.abort(), J.current = null;
|
|
72
|
+
let t = ++W.current, n = l(e);
|
|
73
|
+
j(n), N(n), F([]), L("idle"), U(!0), q("");
|
|
74
74
|
try {
|
|
75
|
-
await
|
|
75
|
+
await u(e);
|
|
76
76
|
} catch (e) {
|
|
77
|
-
if (t !==
|
|
78
|
-
|
|
77
|
+
if (t !== W.current) return;
|
|
78
|
+
j(G.current), N(G.current), q(e instanceof Error ? e.message : "选择保存失败");
|
|
79
79
|
} finally {
|
|
80
|
-
t ===
|
|
80
|
+
t === W.current && U(!1);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
function ae(e) {
|
|
84
|
-
D?.onFocus?.(e), !e.defaultPrevented && re && !s && F === "idle" && !N.length && k.trim().length >= y && Q(k);
|
|
85
|
-
}
|
|
86
83
|
function oe(e) {
|
|
87
|
-
D?.
|
|
84
|
+
D?.onFocus?.(e), !e.defaultPrevented && C && !o && I === "idle" && !P.length && A.trim().length >= _ && $(A);
|
|
88
85
|
}
|
|
89
86
|
function se(e) {
|
|
90
|
-
D?.
|
|
87
|
+
D?.onKeyDown?.(e), (e.key === "Backspace" || e.key === "Delete") && z(!0);
|
|
88
|
+
}
|
|
89
|
+
function ce(e) {
|
|
90
|
+
D?.onKeyUp?.(e), (e.key === "Backspace" || e.key === "Delete") && z(!1);
|
|
91
91
|
}
|
|
92
|
-
return /* @__PURE__ */
|
|
93
|
-
query:
|
|
94
|
-
onQueryChange:
|
|
95
|
-
onSearch: () => void
|
|
96
|
-
items:
|
|
97
|
-
getKey:
|
|
98
|
-
getText:
|
|
99
|
-
renderItem:
|
|
100
|
-
onSelect:
|
|
101
|
-
status:
|
|
102
|
-
error:
|
|
103
|
-
label:
|
|
104
|
-
searchLabel:
|
|
105
|
-
loadingTitle:
|
|
106
|
-
emptyText:
|
|
107
|
-
minimumCharacters:
|
|
108
|
-
minimumCharactersText:
|
|
109
|
-
busy: T ||
|
|
92
|
+
return /* @__PURE__ */ ee(i, { children: [/* @__PURE__ */ a(e, {
|
|
93
|
+
query: A,
|
|
94
|
+
onQueryChange: ie,
|
|
95
|
+
onSearch: () => void $(),
|
|
96
|
+
items: P,
|
|
97
|
+
getKey: s,
|
|
98
|
+
getText: c,
|
|
99
|
+
renderItem: ne,
|
|
100
|
+
onSelect: ae,
|
|
101
|
+
status: I,
|
|
102
|
+
error: K,
|
|
103
|
+
label: p,
|
|
104
|
+
searchLabel: h,
|
|
105
|
+
loadingTitle: g,
|
|
106
|
+
emptyText: re,
|
|
107
|
+
minimumCharacters: _,
|
|
108
|
+
minimumCharactersText: v,
|
|
109
|
+
busy: T || H,
|
|
110
110
|
disabled: w,
|
|
111
111
|
className: E,
|
|
112
|
+
mobileMode: O,
|
|
112
113
|
inputProps: {
|
|
113
114
|
...D,
|
|
114
|
-
placeholder:
|
|
115
|
-
onFocus:
|
|
116
|
-
onKeyDown:
|
|
117
|
-
onKeyUp:
|
|
115
|
+
placeholder: m,
|
|
116
|
+
onFocus: oe,
|
|
117
|
+
onKeyDown: se,
|
|
118
|
+
onKeyUp: ce,
|
|
118
119
|
onCompositionStart: (e) => {
|
|
119
|
-
|
|
120
|
+
V(!0), D?.onCompositionStart?.(e);
|
|
120
121
|
},
|
|
121
122
|
onCompositionEnd: (e) => {
|
|
122
|
-
|
|
123
|
+
V(!1), D?.onCompositionEnd?.(e);
|
|
123
124
|
},
|
|
124
125
|
onBlur: (e) => {
|
|
125
|
-
D?.onBlur?.(e),
|
|
126
|
+
D?.onBlur?.(e), z(!1);
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
|
-
}),
|
|
129
|
+
}), K && I === "idle" && /* @__PURE__ */ a("div", {
|
|
129
130
|
role: "alert",
|
|
130
|
-
children:
|
|
131
|
+
children: K
|
|
131
132
|
})] });
|
|
132
133
|
}
|
|
133
134
|
//#endregion
|
|
134
|
-
export {
|
|
135
|
+
export { o as AsyncDirectoryPicker };
|
|
@@ -1,155 +1,209 @@
|
|
|
1
1
|
import { Button as e } from "./Button.js";
|
|
2
2
|
import { TextInput as t } from "./FormField.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { usePhoneWheel as n } from "./usePhoneWheel.js";
|
|
4
|
+
import { RecoverableAsyncState as r } from "./RecoverableAsyncState.js";
|
|
5
|
+
import { MobilePickerPanel as i } from "./MobilePickerPanel.js";
|
|
6
|
+
import { memo as a, useCallback as o, useEffect as s, useId as c, useRef as l, useState as u } from "react";
|
|
7
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
6
8
|
//#region src/AsyncSearchPicker.tsx
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}, [
|
|
9
|
+
function m({ query: a, onQueryChange: m, onSearch: g, items: _, getKey: v, getText: te, renderItem: y, onSelect: b, status: x = "idle", error: S, label: C, searchLabel: w = "查询", loadingTitle: ne = "正在查询", emptyText: re = "没有匹配项", minimumCharacters: T = 0, minimumCharactersText: ie = (e) => `请至少输入 ${e} 个字符`, busy: E = !1, disabled: D = !1, className: O = "", inputRef: k, inputProps: A, mobileMode: ae = "inline" }) {
|
|
10
|
+
let j = n(ae === "bottom-sheet"), [M, N] = u(!1), P = l(null), F = l(null);
|
|
11
|
+
s(() => {
|
|
12
|
+
(D || !j) && N(!1);
|
|
13
|
+
}, [D, j]);
|
|
14
|
+
let I = `ui-async-picker-${c().replaceAll(":", "")}`, [L, R] = u(-1), [z, B] = u(!1), V = l(/* @__PURE__ */ new Map()), H = l(null), [U, W] = u(320), G = D || E || x === "loading", K = a.trim().length < T, q = !z && x === "success" && !K, J = L >= 0 && L < _.length ? _[L] : void 0;
|
|
15
|
+
s(() => {
|
|
16
|
+
R(-1);
|
|
17
|
+
}, [a, _]), s(() => {
|
|
18
|
+
if (j) return;
|
|
12
19
|
let e = (e) => {
|
|
13
|
-
|
|
20
|
+
H.current?.contains(e.target) || (B(!0), R(-1));
|
|
14
21
|
};
|
|
15
22
|
return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
|
|
16
|
-
}, []),
|
|
17
|
-
if (!
|
|
23
|
+
}, [j]), s(() => {
|
|
24
|
+
if (j || !q || _.length === 0) return;
|
|
18
25
|
let e = window.visualViewport, t = 0, n = () => {
|
|
19
26
|
t && window.cancelAnimationFrame(t), t = window.requestAnimationFrame(() => {
|
|
20
27
|
t = 0;
|
|
21
|
-
let n =
|
|
28
|
+
let n = H.current?.querySelector(".ui-async-search-control");
|
|
22
29
|
if (!n) return;
|
|
23
30
|
let r = (e?.offsetTop ?? 0) + (e?.height ?? window.innerHeight), i = Math.floor(r - n.getBoundingClientRect().bottom - 12);
|
|
24
|
-
|
|
31
|
+
W(Math.max(96, Math.min(320, i)));
|
|
25
32
|
});
|
|
26
33
|
};
|
|
27
34
|
return n(), e?.addEventListener("resize", n), e?.addEventListener("scroll", n), window.addEventListener("resize", n), () => {
|
|
28
35
|
t && window.cancelAnimationFrame(t), e?.removeEventListener("resize", n), e?.removeEventListener("scroll", n), window.removeEventListener("resize", n);
|
|
29
36
|
};
|
|
30
|
-
}, [
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
}, [
|
|
38
|
+
_.length,
|
|
39
|
+
q,
|
|
40
|
+
j
|
|
41
|
+
]);
|
|
42
|
+
function Y() {
|
|
43
|
+
!G && !K && (B(!1), g(a));
|
|
33
44
|
}
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
function
|
|
38
|
-
if (!
|
|
39
|
-
let t = (e +
|
|
40
|
-
|
|
41
|
-
let n =
|
|
45
|
+
let X = o((e) => {
|
|
46
|
+
G || (b(e), B(!0), R(-1), N(!1));
|
|
47
|
+
}, [G, b]);
|
|
48
|
+
function Z(e) {
|
|
49
|
+
if (!_.length) return;
|
|
50
|
+
let t = (e + _.length) % _.length;
|
|
51
|
+
R(t);
|
|
52
|
+
let n = V.current.get(v(_[t]));
|
|
42
53
|
typeof n?.scrollIntoView == "function" && n.scrollIntoView({ block: "nearest" });
|
|
43
54
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
55
|
+
function oe(e) {
|
|
56
|
+
A?.onKeyDown?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing) && (e.key === "ArrowDown" && q && _.length ? (e.preventDefault(), Z(L + 1)) : e.key === "ArrowUp" && q && _.length ? (e.preventDefault(), Z(L <= 0 ? _.length - 1 : L - 1)) : e.key === "Enter" ? (e.preventDefault(), J && q ? X(J) : Y()) : (e.key === "Escape" || e.key === "Tab" && !j) && (B(!0), R(-1)));
|
|
46
57
|
}
|
|
47
|
-
|
|
48
|
-
ref:
|
|
49
|
-
className: `ui-async-search-picker ${
|
|
58
|
+
let Q = /* @__PURE__ */ p("div", {
|
|
59
|
+
ref: H,
|
|
60
|
+
className: `ui-async-search-picker ${O}`.trim(),
|
|
50
61
|
onBlur: (e) => {
|
|
51
|
-
e.currentTarget.contains(e.relatedTarget)
|
|
62
|
+
!j && !e.currentTarget.contains(e.relatedTarget) && (B(!0), R(-1));
|
|
52
63
|
},
|
|
53
64
|
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ p("div", {
|
|
55
66
|
className: "ui-async-search-control",
|
|
56
|
-
children: [/* @__PURE__ */
|
|
57
|
-
...
|
|
58
|
-
ref: j,
|
|
59
|
-
label:
|
|
60
|
-
value:
|
|
61
|
-
disabled:
|
|
67
|
+
children: [/* @__PURE__ */ f(t, {
|
|
68
|
+
...A,
|
|
69
|
+
ref: j ? F : k,
|
|
70
|
+
label: C,
|
|
71
|
+
value: a,
|
|
72
|
+
disabled: D || E,
|
|
73
|
+
id: j ? `${I}-search` : A?.id,
|
|
74
|
+
name: j ? void 0 : A?.name,
|
|
75
|
+
form: j ? void 0 : A?.form,
|
|
76
|
+
required: !j && A?.required,
|
|
62
77
|
onFocus: (e) => {
|
|
63
|
-
|
|
78
|
+
B(!1), A?.onFocus?.(e);
|
|
64
79
|
},
|
|
65
80
|
onChange: (e) => {
|
|
66
|
-
|
|
81
|
+
B(!1), m(e.target.value);
|
|
67
82
|
},
|
|
68
|
-
onKeyDown:
|
|
83
|
+
onKeyDown: oe,
|
|
69
84
|
role: "combobox",
|
|
70
85
|
"aria-autocomplete": "list",
|
|
71
|
-
"aria-expanded":
|
|
72
|
-
"aria-controls":
|
|
73
|
-
"aria-activedescendant":
|
|
74
|
-
}), /* @__PURE__ */
|
|
86
|
+
"aria-expanded": q && _.length > 0,
|
|
87
|
+
"aria-controls": q && _.length > 0 ? `${I}-list` : void 0,
|
|
88
|
+
"aria-activedescendant": q && J ? `${I}-${h(v(J))}` : void 0
|
|
89
|
+
}), /* @__PURE__ */ f(e, {
|
|
75
90
|
variant: "primary",
|
|
76
|
-
busy:
|
|
77
|
-
disabled:
|
|
78
|
-
onClick:
|
|
79
|
-
children:
|
|
91
|
+
busy: E || x === "loading",
|
|
92
|
+
disabled: D || K,
|
|
93
|
+
onClick: Y,
|
|
94
|
+
children: w
|
|
80
95
|
})]
|
|
81
96
|
}),
|
|
82
|
-
/* @__PURE__ */
|
|
97
|
+
/* @__PURE__ */ p("div", {
|
|
83
98
|
className: "ui-async-search-status",
|
|
84
99
|
"aria-live": "polite",
|
|
85
100
|
children: [
|
|
86
|
-
|
|
87
|
-
!
|
|
101
|
+
K ? ie(T) : null,
|
|
102
|
+
!z && !K && x === "loading" ? /* @__PURE__ */ f(r, {
|
|
88
103
|
compact: !0,
|
|
89
104
|
phase: "loading",
|
|
90
|
-
loadingTitle:
|
|
105
|
+
loadingTitle: ne,
|
|
91
106
|
errorTitle: ""
|
|
92
107
|
}) : null,
|
|
93
|
-
!
|
|
108
|
+
!z && !K && x === "error" ? /* @__PURE__ */ f(r, {
|
|
94
109
|
compact: !0,
|
|
95
110
|
phase: "error",
|
|
96
111
|
loadingTitle: "",
|
|
97
112
|
errorTitle: "查询失败",
|
|
98
|
-
detail:
|
|
99
|
-
onRetry:
|
|
113
|
+
detail: S,
|
|
114
|
+
onRetry: G ? void 0 : Y,
|
|
100
115
|
retryLabel: "重试"
|
|
101
116
|
}) : null,
|
|
102
|
-
|
|
117
|
+
q && _.length === 0 ? /* @__PURE__ */ f("div", {
|
|
103
118
|
className: "ui-async-search-empty",
|
|
104
|
-
children:
|
|
119
|
+
children: re
|
|
105
120
|
}) : null
|
|
106
121
|
]
|
|
107
122
|
}),
|
|
108
|
-
|
|
109
|
-
id: `${
|
|
123
|
+
q && _.length > 0 ? /* @__PURE__ */ f("div", {
|
|
124
|
+
id: `${I}-list`,
|
|
110
125
|
role: "listbox",
|
|
111
126
|
className: "ui-async-search-list",
|
|
112
|
-
style: { maxHeight:
|
|
113
|
-
children:
|
|
114
|
-
let n =
|
|
115
|
-
return /* @__PURE__ */
|
|
127
|
+
style: { maxHeight: U },
|
|
128
|
+
children: _.map((e, t) => {
|
|
129
|
+
let n = v(e);
|
|
130
|
+
return /* @__PURE__ */ f(ee, {
|
|
116
131
|
item: e,
|
|
117
132
|
index: t,
|
|
118
133
|
optionKey: n,
|
|
119
|
-
id: `${
|
|
120
|
-
selected:
|
|
121
|
-
refs:
|
|
122
|
-
activate:
|
|
123
|
-
select:
|
|
124
|
-
getText:
|
|
125
|
-
renderItem:
|
|
134
|
+
id: `${I}-${h(n)}`,
|
|
135
|
+
selected: L === t,
|
|
136
|
+
refs: V.current,
|
|
137
|
+
activate: R,
|
|
138
|
+
select: X,
|
|
139
|
+
getText: te,
|
|
140
|
+
renderItem: y
|
|
126
141
|
}, n);
|
|
127
142
|
})
|
|
128
143
|
}) : null
|
|
129
144
|
]
|
|
130
145
|
});
|
|
146
|
+
if (!j) return Q;
|
|
147
|
+
function se() {
|
|
148
|
+
N(!1), B(!0), R(-1);
|
|
149
|
+
}
|
|
150
|
+
function $() {
|
|
151
|
+
!D && !E && (B(!1), N(!0));
|
|
152
|
+
}
|
|
153
|
+
return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(t, {
|
|
154
|
+
...A,
|
|
155
|
+
ref: (e) => {
|
|
156
|
+
P.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
|
|
157
|
+
},
|
|
158
|
+
label: C,
|
|
159
|
+
value: a,
|
|
160
|
+
inputMode: "none",
|
|
161
|
+
disabled: D,
|
|
162
|
+
"aria-disabled": E || D || void 0,
|
|
163
|
+
readOnly: E || A?.readOnly,
|
|
164
|
+
className: `ui-mobile-picker-trigger ${O}`,
|
|
165
|
+
"aria-haspopup": "dialog",
|
|
166
|
+
"aria-expanded": M,
|
|
167
|
+
onFocus: void 0,
|
|
168
|
+
onBlur: void 0,
|
|
169
|
+
onChange: (e) => {
|
|
170
|
+
E || (m(e.target.value), $());
|
|
171
|
+
},
|
|
172
|
+
onClick: (e) => {
|
|
173
|
+
A?.onClick?.(e), e.defaultPrevented || $();
|
|
174
|
+
},
|
|
175
|
+
onKeyDown: (e) => {
|
|
176
|
+
A?.onKeyDown?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing || e.keyCode === 229) && (e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), $());
|
|
177
|
+
}
|
|
178
|
+
}), M && /* @__PURE__ */ f(i, {
|
|
179
|
+
title: C ?? "搜索选择",
|
|
180
|
+
returnFocus: P,
|
|
181
|
+
initialFocus: F,
|
|
182
|
+
onClose: se,
|
|
183
|
+
children: Q
|
|
184
|
+
})] });
|
|
131
185
|
}
|
|
132
|
-
function
|
|
186
|
+
function h(e) {
|
|
133
187
|
return e.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
134
188
|
}
|
|
135
|
-
function
|
|
136
|
-
let
|
|
137
|
-
e ?
|
|
138
|
-
}, [
|
|
139
|
-
return /* @__PURE__ */
|
|
140
|
-
ref:
|
|
189
|
+
function g({ item: e, index: t, optionKey: n, id: r, selected: i, refs: a, activate: s, select: c, getText: l, renderItem: u }) {
|
|
190
|
+
let d = o((e) => {
|
|
191
|
+
e ? a.set(n, e) : a.delete(n);
|
|
192
|
+
}, [a, n]);
|
|
193
|
+
return /* @__PURE__ */ f("button", {
|
|
194
|
+
ref: d,
|
|
141
195
|
id: r,
|
|
142
196
|
type: "button",
|
|
143
197
|
role: "option",
|
|
144
|
-
"aria-selected":
|
|
198
|
+
"aria-selected": i,
|
|
145
199
|
className: "ui-async-search-option",
|
|
146
200
|
tabIndex: -1,
|
|
147
201
|
onMouseEnter: () => s(t),
|
|
148
202
|
onClick: () => c(e),
|
|
149
|
-
"aria-label":
|
|
150
|
-
children:
|
|
203
|
+
"aria-label": l(e),
|
|
204
|
+
children: u(e)
|
|
151
205
|
});
|
|
152
206
|
}
|
|
153
|
-
var
|
|
207
|
+
var ee = a(g);
|
|
154
208
|
//#endregion
|
|
155
|
-
export {
|
|
209
|
+
export { m as AsyncSearchPicker };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Button as e } from "./Button.js";
|
|
2
|
+
import { useOverlayContainer as t } from "./OverlayContainer.js";
|
|
3
|
+
import { ModalShell as n } from "./ModalShell.js";
|
|
4
|
+
import { useId as r } from "react";
|
|
5
|
+
import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { createPortal as s } from "react-dom";
|
|
7
|
+
//#region src/MobilePickerPanel.tsx
|
|
8
|
+
function c({ title: c, children: l, onClose: u, returnFocus: d, initialFocus: f, summary: p }) {
|
|
9
|
+
let m = r(), h = t();
|
|
10
|
+
return s(/* @__PURE__ */ a(n, {
|
|
11
|
+
titleId: `${m}-title`,
|
|
12
|
+
title: c,
|
|
13
|
+
closeLabel: "关闭选择面板",
|
|
14
|
+
mobileMode: "bottom-sheet",
|
|
15
|
+
onClose: u,
|
|
16
|
+
returnFocus: d,
|
|
17
|
+
initialFocus: f,
|
|
18
|
+
backdropClassName: "ui-picker-sheet-backdrop",
|
|
19
|
+
panelClassName: "ui-picker-sheet",
|
|
20
|
+
contentClassName: "ui-picker-sheet-content",
|
|
21
|
+
footerClassName: "ui-picker-sheet-footer",
|
|
22
|
+
footer: /* @__PURE__ */ o(i, { children: [p && /* @__PURE__ */ a("span", {
|
|
23
|
+
className: "ui-picker-sheet-summary",
|
|
24
|
+
role: "status",
|
|
25
|
+
children: p
|
|
26
|
+
}), /* @__PURE__ */ a(e, {
|
|
27
|
+
onClick: u,
|
|
28
|
+
children: "完成"
|
|
29
|
+
})] }),
|
|
30
|
+
children: l
|
|
31
|
+
}), h ?? document.body);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { c as MobilePickerPanel };
|