@jc-times/business-ui 0.4.0 → 0.4.2

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 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。
@@ -344,3 +349,7 @@
344
349
 
345
350
  - Fix missing Chinese and substituted Latin text in PDFs with unembedded fonts. Both PDFium viewers use stable same-origin Noto fallback configuration; assets and OFL licenses ship with the package, with no external CDN requests.
346
351
  - Add desktop/mobile real PDF rendering coverage. Restoring `fontFallback: null` makes the same Chinese test fail with zero text pixels; explicit caller overrides remain supported.
352
+ ## 0.4.2 — 2026-09-29(patch)
353
+
354
+ - 日期及选项滚轮取消重复关闭叉号,使用公共内容高度 bottom-sheet、紧凑居中标题与统一底部操作。保留草稿、取消、一次确认和惯性未结束时禁止提交。
355
+ - UI 173 单测、类型/构建/摇树/矩阵通过;完整浏览器156通过、15跳过,唯一旧叉号断言修订后滚轮专项15通过、5跳过。真实微信手机惯性和读屏仍待验收。
@@ -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 o } from "react/jsx-runtime";
3
+ import { Fragment as i, jsx as a, jsxs as ee } from "react/jsx-runtime";
4
4
  //#region src/AsyncDirectoryPicker.tsx
5
- function s({ selectedItem: s, loadItems: ee, getKey: c, getText: l, getSelectionText: u = l, renderItem: d, onSelect: te, onQueryChange: f, ownerKey: p = "", label: m, placeholder: h = "输入关键词搜索", searchLabel: g, loadingTitle: _, emptyText: v, minimumCharacters: y = 0, minimumCharactersText: ne, debounceMs: b = 200, cacheSize: x = 50, cacheTtlMs: S = 3e5, refreshKey: C, loadOnFocus: re = !0, disabled: w = !1, busy: T = !1, className: E, inputProps: D }) {
6
- let O = s ? u(s) : "", [k, A] = r(O), [j, M] = r(O), [N, P] = r([]), [F, I] = r("idle"), [L, R] = r(!1), [z, B] = r(!1), [V, H] = r(!1), U = n(0), W = n(O);
7
- W.current = O;
8
- let [G, K] = r(""), q = n(null), J = n(0), Y = n(/* @__PURE__ */ new Map()), X = Number.isFinite(x) ? Math.max(0, Math.floor(x)) : 50, Z = n(X);
9
- Z.current = X, t(() => {
10
- for (; Y.current.size > X;) Y.current.delete(Y.current.keys().next().value);
11
- }, [X]), t(() => () => {
12
- J.current++, U.current++, q.current?.abort();
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
- J.current++, q.current?.abort(), q.current = null, Y.current.clear(), U.current++, H(!1);
15
- let e = s ? u(s) : "";
16
- A(e), M(e), P([]), I("idle"), K("");
17
- }, [p]), t(() => {
18
- J.current++, q.current?.abort(), Y.current.clear(), P([]), I("idle");
19
- }, [C, S]), t(() => {
20
- J.current++, q.current?.abort(), U.current++, H(!1);
21
- let e = s ? u(s) : "";
22
- A(e), M(e), P([]), I("idle"), K("");
23
- }, [s && c(s), s && u(s)]), t(() => {
24
- if (w || T || V || L || z || k === j || k.trim().length < y) return;
25
- let e = window.setTimeout(() => void Q(k), Math.max(0, b));
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
- k,
29
- j,
28
+ A,
29
+ M,
30
30
  w,
31
31
  T,
32
- V,
33
- L,
34
- z,
32
+ H,
33
+ R,
34
+ B,
35
+ _,
35
36
  y,
36
- b,
37
- C,
38
- S
37
+ S,
38
+ x
39
39
  ]);
40
- async function Q(e = k) {
40
+ async function $(e = A) {
41
41
  let t = e.trim();
42
- if (w || T || V || z || t.length < y) return;
43
- let n = ++J.current;
44
- q.current?.abort(), q.current = null;
45
- let r = t, i = X > 0 ? Y.current.get(r) : void 0;
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
- Y.current.delete(r), Y.current.set(r, i), P(i.items), I("success"), K("");
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
- q.current = a, I("loading"), K("");
51
+ J.current = a, L("loading"), q("");
52
52
  try {
53
- let e = await ee(t, a.signal);
54
- if (n !== J.current || a.signal.aborted) return;
55
- if (Z.current > 0) for (Y.current.delete(r), Y.current.set(r, {
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, S)
58
- }); Y.current.size > Z.current;) Y.current.delete(Y.current.keys().next().value);
59
- P(e), I("success");
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 !== J.current || a.signal.aborted) return;
62
- K(e instanceof Error ? e.message : "目录查询失败"), I("error");
61
+ if (n !== Y.current || a.signal.aborted) return;
62
+ q(e instanceof Error ? e.message : "目录查询失败"), L("error");
63
63
  } finally {
64
- n === J.current && (q.current = null);
64
+ n === Y.current && (J.current = null);
65
65
  }
66
66
  }
67
- function $(e) {
68
- J.current++, q.current?.abort(), q.current = null, A(e), M(""), P([]), I("idle"), K(""), f?.(e);
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 ie(e) {
71
- J.current++, q.current?.abort(), q.current = null;
72
- let t = ++U.current, n = u(e);
73
- A(n), M(n), P([]), I("idle"), H(!0), K("");
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 te(e);
75
+ await u(e);
76
76
  } catch (e) {
77
- if (t !== U.current) return;
78
- A(W.current), M(W.current), K(e instanceof Error ? e.message : "选择保存失败");
77
+ if (t !== W.current) return;
78
+ j(G.current), N(G.current), q(e instanceof Error ? e.message : "选择保存失败");
79
79
  } finally {
80
- t === U.current && H(!1);
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?.onKeyDown?.(e), (e.key === "Backspace" || e.key === "Delete") && R(!0);
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?.onKeyUp?.(e), (e.key === "Backspace" || e.key === "Delete") && R(!1);
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__ */ o(i, { children: [/* @__PURE__ */ a(e, {
93
- query: k,
94
- onQueryChange: $,
95
- onSearch: () => void Q(),
96
- items: N,
97
- getKey: c,
98
- getText: l,
99
- renderItem: d,
100
- onSelect: ie,
101
- status: F,
102
- error: G,
103
- label: m,
104
- searchLabel: g,
105
- loadingTitle: _,
106
- emptyText: v,
107
- minimumCharacters: y,
108
- minimumCharactersText: ne,
109
- busy: T || V,
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: h,
115
- onFocus: ae,
116
- onKeyDown: oe,
117
- onKeyUp: se,
115
+ placeholder: m,
116
+ onFocus: oe,
117
+ onKeyDown: se,
118
+ onKeyUp: ce,
118
119
  onCompositionStart: (e) => {
119
- B(!0), D?.onCompositionStart?.(e);
120
+ V(!0), D?.onCompositionStart?.(e);
120
121
  },
121
122
  onCompositionEnd: (e) => {
122
- B(!1), D?.onCompositionEnd?.(e);
123
+ V(!1), D?.onCompositionEnd?.(e);
123
124
  },
124
125
  onBlur: (e) => {
125
- D?.onBlur?.(e), R(!1);
126
+ D?.onBlur?.(e), z(!1);
126
127
  }
127
128
  }
128
- }), G && F === "idle" && /* @__PURE__ */ a("div", {
129
+ }), K && I === "idle" && /* @__PURE__ */ a("div", {
129
130
  role: "alert",
130
- children: G
131
+ children: K
131
132
  })] });
132
133
  }
133
134
  //#endregion
134
- export { s as AsyncDirectoryPicker };
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 { RecoverableAsyncState as n } from "./RecoverableAsyncState.js";
4
- import { memo as r, useCallback as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
5
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
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 d({ query: r, onQueryChange: d, onSearch: p, items: h, getKey: g, getText: _, renderItem: v, onSelect: y, status: b = "idle", error: x, label: S, searchLabel: C = "查询", loadingTitle: w = "正在查询", emptyText: T = "没有匹配项", minimumCharacters: E = 0, minimumCharactersText: D = (e) => `请至少输入 ${e} 个字符`, busy: O = !1, disabled: k = !1, className: A = "", inputRef: j, inputProps: M }) {
8
- let N = `ui-async-picker-${o().replaceAll(":", "")}`, [P, F] = c(-1), [I, L] = c(!1), R = s(/* @__PURE__ */ new Map()), z = s(null), [B, V] = c(320), H = k || O || b === "loading", U = r.trim().length < E, W = !I && b === "success" && !U, G = P >= 0 && P < h.length ? h[P] : void 0;
9
- a(() => {
10
- F(-1);
11
- }, [r, h]), a(() => {
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
- z.current?.contains(e.target) || (L(!0), F(-1));
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
- }, []), a(() => {
17
- if (!W || h.length === 0) return;
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 = z.current?.querySelector(".ui-async-search-control");
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
- V(Math.max(96, Math.min(320, i)));
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
- }, [h.length, W]);
31
- function K() {
32
- !H && !U && (L(!1), p(r));
37
+ }, [
38
+ _.length,
39
+ q,
40
+ j
41
+ ]);
42
+ function Y() {
43
+ !G && !K && (B(!1), g(a));
33
44
  }
34
- let q = i((e) => {
35
- H || (y(e), L(!0), F(-1));
36
- }, [H, y]);
37
- function J(e) {
38
- if (!h.length) return;
39
- let t = (e + h.length) % h.length;
40
- F(t);
41
- let n = R.current.get(g(h[t]));
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 Y(e) {
45
- M?.onKeyDown?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing) && (e.key === "ArrowDown" && W && h.length ? (e.preventDefault(), J(P + 1)) : e.key === "ArrowUp" && W && h.length ? (e.preventDefault(), J(P <= 0 ? h.length - 1 : P - 1)) : e.key === "Enter" ? (e.preventDefault(), G && W ? q(G) : K()) : (e.key === "Escape" || e.key === "Tab") && (L(!0), F(-1)));
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
- return /* @__PURE__ */ u("div", {
48
- ref: z,
49
- className: `ui-async-search-picker ${A}`.trim(),
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) || (L(!0), F(-1));
62
+ !j && !e.currentTarget.contains(e.relatedTarget) && (B(!0), R(-1));
52
63
  },
53
64
  children: [
54
- /* @__PURE__ */ u("div", {
65
+ /* @__PURE__ */ p("div", {
55
66
  className: "ui-async-search-control",
56
- children: [/* @__PURE__ */ l(t, {
57
- ...M,
58
- ref: j,
59
- label: S,
60
- value: r,
61
- disabled: k || O,
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
- L(!1), M?.onFocus?.(e);
78
+ B(!1), A?.onFocus?.(e);
64
79
  },
65
80
  onChange: (e) => {
66
- L(!1), d(e.target.value);
81
+ B(!1), m(e.target.value);
67
82
  },
68
- onKeyDown: Y,
83
+ onKeyDown: oe,
69
84
  role: "combobox",
70
85
  "aria-autocomplete": "list",
71
- "aria-expanded": W && h.length > 0,
72
- "aria-controls": W && h.length > 0 ? `${N}-list` : void 0,
73
- "aria-activedescendant": W && G ? `${N}-${f(g(G))}` : void 0
74
- }), /* @__PURE__ */ l(e, {
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: O || b === "loading",
77
- disabled: k || U,
78
- onClick: K,
79
- children: C
91
+ busy: E || x === "loading",
92
+ disabled: D || K,
93
+ onClick: Y,
94
+ children: w
80
95
  })]
81
96
  }),
82
- /* @__PURE__ */ u("div", {
97
+ /* @__PURE__ */ p("div", {
83
98
  className: "ui-async-search-status",
84
99
  "aria-live": "polite",
85
100
  children: [
86
- U ? D(E) : null,
87
- !I && !U && b === "loading" ? /* @__PURE__ */ l(n, {
101
+ K ? ie(T) : null,
102
+ !z && !K && x === "loading" ? /* @__PURE__ */ f(r, {
88
103
  compact: !0,
89
104
  phase: "loading",
90
- loadingTitle: w,
105
+ loadingTitle: ne,
91
106
  errorTitle: ""
92
107
  }) : null,
93
- !I && !U && b === "error" ? /* @__PURE__ */ l(n, {
108
+ !z && !K && x === "error" ? /* @__PURE__ */ f(r, {
94
109
  compact: !0,
95
110
  phase: "error",
96
111
  loadingTitle: "",
97
112
  errorTitle: "查询失败",
98
- detail: x,
99
- onRetry: H ? void 0 : K,
113
+ detail: S,
114
+ onRetry: G ? void 0 : Y,
100
115
  retryLabel: "重试"
101
116
  }) : null,
102
- W && h.length === 0 ? /* @__PURE__ */ l("div", {
117
+ q && _.length === 0 ? /* @__PURE__ */ f("div", {
103
118
  className: "ui-async-search-empty",
104
- children: T
119
+ children: re
105
120
  }) : null
106
121
  ]
107
122
  }),
108
- W && h.length > 0 ? /* @__PURE__ */ l("div", {
109
- id: `${N}-list`,
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: B },
113
- children: h.map((e, t) => {
114
- let n = g(e);
115
- return /* @__PURE__ */ l(m, {
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: `${N}-${f(n)}`,
120
- selected: P === t,
121
- refs: R.current,
122
- activate: F,
123
- select: q,
124
- getText: _,
125
- renderItem: v
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 f(e) {
186
+ function h(e) {
133
187
  return e.replace(/[^a-zA-Z0-9_-]/g, "-");
134
188
  }
135
- function p({ item: e, index: t, optionKey: n, id: r, selected: a, refs: o, activate: s, select: c, getText: u, renderItem: d }) {
136
- let f = i((e) => {
137
- e ? o.set(n, e) : o.delete(n);
138
- }, [o, n]);
139
- return /* @__PURE__ */ l("button", {
140
- ref: f,
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": a,
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": u(e),
150
- children: d(e)
203
+ "aria-label": l(e),
204
+ children: u(e)
151
205
  });
152
206
  }
153
- var m = r(p);
207
+ var ee = a(g);
154
208
  //#endregion
155
- export { d as AsyncSearchPicker };
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 };
@@ -21,6 +21,8 @@ function _({ options: r, value: s, title: l = "选择选项", returnFocus: _, po
21
21
  title: l,
22
22
  closeLabel: "关闭选择",
23
23
  returnFocus: _,
24
+ mobileMode: "bottom-sheet",
25
+ showCloseButton: !1,
24
26
  onClose: w,
25
27
  backdropClassName: "ui-date-wheel-backdrop",
26
28
  panelClassName: "ui-date-wheel-panel",