@jc-times/business-ui 0.3.2 → 0.4.0

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 (52) hide show
  1. package/AGENTS.md +15 -0
  2. package/CHANGELOG.md +17 -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/Cascader.js +56 -51
  9. package/dist/DateInput.js +84 -66
  10. package/dist/DateWheelPicker.js +58 -0
  11. package/dist/ModalShell.js +84 -72
  12. package/dist/MultiSelect.js +5 -1
  13. package/dist/OptionWheelDialog.js +99 -0
  14. package/dist/Select.js +116 -61
  15. package/dist/StructuredAddressInput.js +72 -70
  16. package/dist/TreeSelect.js +4 -1
  17. package/dist/WheelCascader.js +123 -0
  18. package/dist/WheelDateInput.js +97 -0
  19. package/dist/business-ui.js +42 -39
  20. package/dist/date-wheel-model.js +27 -0
  21. package/dist/option-wheel-model.js +49 -0
  22. package/dist/styles.css +1 -1
  23. package/dist/types/AntDateWheelView.d.ts +9 -0
  24. package/dist/types/AntOptionWheelView.d.ts +8 -0
  25. package/dist/types/Cascader.d.ts +2 -0
  26. package/dist/types/DateInput.d.ts +4 -0
  27. package/dist/types/DateWheelPicker.d.ts +13 -0
  28. package/dist/types/ModalShell.d.ts +3 -1
  29. package/dist/types/OptionWheelDialog.d.ts +18 -0
  30. package/dist/types/Select.d.ts +4 -1
  31. package/dist/types/StructuredAddressInput.d.ts +3 -1
  32. package/dist/types/WheelCascader.d.ts +6 -0
  33. package/dist/types/WheelDateInput.d.ts +11 -0
  34. package/dist/types/date-wheel-model.d.ts +8 -0
  35. package/dist/types/index.d.ts +3 -0
  36. package/dist/types/option-wheel-model.d.ts +19 -0
  37. package/dist/types/usePhoneWheel.d.ts +2 -0
  38. package/dist/types/useSheetViewport.d.ts +3 -0
  39. package/dist/usePhoneWheel.js +16 -0
  40. package/dist/useSheetViewport.js +26 -0
  41. package/docs/agent-guide.md +13 -5
  42. package/docs/api.md +14 -0
  43. package/docs/cascader.md +2 -0
  44. package/docs/component-strategy.md +3 -0
  45. package/docs/date-wheel.md +25 -0
  46. package/docs/dependencies.md +2 -0
  47. package/docs/mobile-controls.md +54 -0
  48. package/docs/modal-shell-migration.md +25 -0
  49. package/docs/release.md +7 -0
  50. package/docs/viewport-qa.md +38 -0
  51. package/licenses/antd-mobile-MIT.txt +22 -0
  52. package/package.json +11 -2
@@ -0,0 +1,99 @@
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 { RecoverableAsyncState as r } from "./RecoverableAsyncState.js";
5
+ import { enabledWheelOptions as i, resolveWheelPath as a, wheelText as o } from "./option-wheel-model.js";
6
+ import { Component as s, Suspense as c, lazy as l, useId as u, useState as d } from "react";
7
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
8
+ import { createPortal as h } from "react-dom";
9
+ //#region src/OptionWheelDialog.tsx
10
+ var g = () => l(() => import("./AntOptionWheelView.js"));
11
+ function _({ options: r, value: s, title: l = "选择选项", returnFocus: _, portalContainer: b, allowClear: x, clearLabel: S = "清除", emptyText: C = "没有可选项", onClose: w, onConfirm: T }) {
12
+ let E = t(b), D = u(), [{ View: O, attempt: k }, A] = d(() => ({
13
+ View: g(),
14
+ attempt: 0
15
+ })), j = i(r), [M, N] = d(() => a(j, s).value), [P, F] = d(!0), I = a(j, M), L = M.length > 0 && JSON.stringify(I.value) === JSON.stringify(M);
16
+ function R() {
17
+ L && !P && T(M);
18
+ }
19
+ return h(/* @__PURE__ */ m(n, {
20
+ titleId: `${D}-title`,
21
+ title: l,
22
+ closeLabel: "关闭选择",
23
+ returnFocus: _,
24
+ onClose: w,
25
+ backdropClassName: "ui-date-wheel-backdrop",
26
+ panelClassName: "ui-date-wheel-panel",
27
+ contentClassName: "ui-date-wheel-content",
28
+ footerClassName: "ui-date-wheel-actions",
29
+ footer: /* @__PURE__ */ m(f, { children: [
30
+ /* @__PURE__ */ p(e, {
31
+ variant: "secondary",
32
+ onClick: w,
33
+ children: "取消"
34
+ }),
35
+ x && /* @__PURE__ */ p(e, {
36
+ variant: "secondary",
37
+ disabled: !s.length,
38
+ onClick: () => T([]),
39
+ children: S
40
+ }),
41
+ /* @__PURE__ */ p(e, {
42
+ variant: "primary",
43
+ disabled: !L || P,
44
+ onClick: R,
45
+ children: "确定选择"
46
+ })
47
+ ] }),
48
+ children: [j.length ? /* @__PURE__ */ p(v, {
49
+ onError: () => F(!0),
50
+ onRetry: () => {
51
+ F(!0), A({
52
+ View: g(),
53
+ attempt: k + 1
54
+ });
55
+ },
56
+ children: /* @__PURE__ */ p(c, {
57
+ fallback: /* @__PURE__ */ p(y, {}),
58
+ children: /* @__PURE__ */ p(O, {
59
+ columns: I.columns,
60
+ value: I.value,
61
+ onPendingChange: F,
62
+ onChange: (e) => N(a(j, e).value)
63
+ })
64
+ })
65
+ }, k) : /* @__PURE__ */ p("p", {
66
+ role: "status",
67
+ children: C
68
+ }), /* @__PURE__ */ p("p", {
69
+ className: "ui-date-wheel-summary ui-option-wheel-summary",
70
+ role: "status",
71
+ children: I.path.map(o).join(" / ")
72
+ })]
73
+ }), E ?? document.body);
74
+ }
75
+ var v = class extends s {
76
+ state = { failed: !1 };
77
+ static getDerivedStateFromError() {
78
+ return { failed: !0 };
79
+ }
80
+ componentDidCatch() {
81
+ this.props.onError();
82
+ }
83
+ render() {
84
+ return this.state.failed ? /* @__PURE__ */ p(r, {
85
+ phase: "error",
86
+ loadingTitle: "加载选择器",
87
+ errorTitle: "选择器加载失败",
88
+ onRetry: this.props.onRetry
89
+ }) : this.props.children;
90
+ }
91
+ };
92
+ function y() {
93
+ return /* @__PURE__ */ p("p", {
94
+ role: "status",
95
+ children: "正在加载选择器…"
96
+ });
97
+ }
98
+ //#endregion
99
+ export { _ as OptionWheelDialog };
package/dist/Select.js CHANGED
@@ -1,73 +1,128 @@
1
1
  import { useOverlayContainer as e } from "./OverlayContainer.js";
2
2
  import { FormField as t } from "./FormField.js";
3
- import { useId as n } from "react";
4
- import { jsx as r, jsxs as i } from "react/jsx-runtime";
5
- import { Check as a, ChevronDown as o, ChevronUp as s } from "lucide-react";
6
- import * as c from "@radix-ui/react-select";
3
+ import { usePhoneWheel as n } from "./usePhoneWheel.js";
4
+ import { wheelOptionsKey as r } from "./option-wheel-model.js";
5
+ import { OptionWheelDialog as i } from "./OptionWheelDialog.js";
6
+ import { useCallback as a, useEffect as o, useId as s, useRef as c, useState as l } from "react";
7
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
8
+ import { Check as f, ChevronDown as p, ChevronUp as m } from "lucide-react";
9
+ import * as h from "@radix-ui/react-select";
7
10
  //#region src/Select.tsx
8
- function l({ value: l, defaultValue: f, onValueChange: p, options: m, label: h, placeholder: g = "请选择", helpText: _, error: v, required: y, disabled: b, name: x, id: S, className: C = "", triggerRef: w, triggerProps: T, portalContainer: E, placement: D }) {
9
- let O = n(), k = S ?? O, A = e(E), j = /* @__PURE__ */ i(c.Root, {
10
- value: l,
11
- defaultValue: f,
12
- onValueChange: p,
13
- disabled: b,
14
- name: x,
15
- required: y,
16
- children: [/* @__PURE__ */ i(c.Trigger, {
17
- ...T,
18
- ref: w,
19
- id: k,
20
- className: `ui-select-trigger ${C}`.trim(),
21
- "aria-invalid": v ? !0 : T?.["aria-invalid"],
22
- "aria-describedby": d(T?.["aria-describedby"], u(k, _, v)),
23
- children: [/* @__PURE__ */ r(c.Value, { placeholder: g }), /* @__PURE__ */ r(c.Icon, { children: /* @__PURE__ */ r(o, { size: 16 }) })]
24
- }), /* @__PURE__ */ r(c.Portal, {
25
- container: A,
26
- children: /* @__PURE__ */ i(c.Content, {
27
- className: "ui-select-content",
28
- position: "popper",
29
- sideOffset: 6,
30
- collisionPadding: 10,
31
- ...D,
32
- children: [
33
- /* @__PURE__ */ r(c.ScrollUpButton, {
34
- className: "ui-select-scroll",
35
- children: /* @__PURE__ */ r(s, { size: 16 })
36
- }),
37
- /* @__PURE__ */ r(c.Viewport, {
38
- className: "ui-select-viewport",
39
- children: m.map((e) => /* @__PURE__ */ i(c.Item, {
40
- value: e.value,
41
- disabled: e.disabled,
42
- className: "ui-select-item",
43
- children: [/* @__PURE__ */ r(c.ItemText, { children: e.label }), /* @__PURE__ */ r(c.ItemIndicator, {
44
- className: "ui-select-indicator",
45
- children: /* @__PURE__ */ r(a, { size: 15 })
46
- })]
47
- }, e.value))
48
- }),
49
- /* @__PURE__ */ r(c.ScrollDownButton, {
50
- className: "ui-select-scroll",
51
- children: /* @__PURE__ */ r(o, { size: 16 })
52
- })
53
- ]
11
+ function g({ value: g, defaultValue: y, onValueChange: b, options: x, label: S, placeholder: C = "请选择", helpText: w, error: T, required: E, disabled: D, name: O, id: k, className: A = "", triggerRef: j, triggerProps: M, portalContainer: N, placement: P, mobileMode: F = "dropdown" }) {
12
+ let I = s(), L = k ?? I, R = e(N), z = n(F === "wheel"), [B, V] = l(y ?? ""), H = g ?? B, U = c(null), W = a((e) => {
13
+ U.current = e, typeof j == "function" ? j(e) : j && (j.current = e);
14
+ }, [j]), G = z ? JSON.stringify([H, r(x)]) : "", [K, q] = l(null), [J, Y] = l(!1), X = z && !D && K === G;
15
+ o(() => {
16
+ q(null);
17
+ }, [
18
+ G,
19
+ z,
20
+ D
21
+ ]), o(() => {
22
+ Y(!1);
23
+ }, [z, D]);
24
+ function Z(e) {
25
+ g === void 0 && V(e), b?.(e);
26
+ }
27
+ let Q = /* @__PURE__ */ d(h.Root, {
28
+ value: H,
29
+ onValueChange: Z,
30
+ open: !z && !D && J,
31
+ onOpenChange: (e) => {
32
+ z ? e && !D && q(G) : Y(e);
33
+ },
34
+ disabled: D,
35
+ name: O,
36
+ required: E,
37
+ children: [
38
+ /* @__PURE__ */ d(h.Trigger, {
39
+ ...M,
40
+ ref: W,
41
+ id: L,
42
+ className: `ui-select-trigger ${A}`.trim(),
43
+ ...z ? {
44
+ "aria-haspopup": "dialog",
45
+ "aria-expanded": X,
46
+ "aria-controls": void 0
47
+ } : {},
48
+ onKeyDown: (e) => {
49
+ M?.onKeyDown?.(e), z && !e.defaultPrevented && ([
50
+ "Enter",
51
+ " ",
52
+ "ArrowDown",
53
+ "ArrowUp"
54
+ ].includes(e.key) ? (e.preventDefault(), D || q(G)) : e.key.length === 1 && e.preventDefault());
55
+ },
56
+ "aria-invalid": T ? !0 : M?.["aria-invalid"],
57
+ "aria-describedby": v(M?.["aria-describedby"], _(L, w, T)),
58
+ children: [/* @__PURE__ */ u("span", {
59
+ className: "ui-select-value",
60
+ children: /* @__PURE__ */ u(h.Value, { placeholder: C })
61
+ }), /* @__PURE__ */ u(h.Icon, {
62
+ className: "ui-select-icon",
63
+ children: /* @__PURE__ */ u(p, { size: 16 })
64
+ })]
65
+ }),
66
+ /* @__PURE__ */ u(h.Portal, {
67
+ container: R,
68
+ children: /* @__PURE__ */ d(h.Content, {
69
+ className: "ui-select-content",
70
+ position: "popper",
71
+ sideOffset: 6,
72
+ collisionPadding: 10,
73
+ ...P,
74
+ children: [
75
+ /* @__PURE__ */ u(h.ScrollUpButton, {
76
+ className: "ui-select-scroll",
77
+ children: /* @__PURE__ */ u(m, { size: 16 })
78
+ }),
79
+ /* @__PURE__ */ u(h.Viewport, {
80
+ className: "ui-select-viewport",
81
+ children: x.map((e) => /* @__PURE__ */ d(h.Item, {
82
+ value: e.value,
83
+ disabled: e.disabled,
84
+ className: "ui-select-item",
85
+ children: [/* @__PURE__ */ u(h.ItemText, { children: e.label }), /* @__PURE__ */ u(h.ItemIndicator, {
86
+ className: "ui-select-indicator",
87
+ children: /* @__PURE__ */ u(f, { size: 15 })
88
+ })]
89
+ }, e.value))
90
+ }),
91
+ /* @__PURE__ */ u(h.ScrollDownButton, {
92
+ className: "ui-select-scroll",
93
+ children: /* @__PURE__ */ u(p, { size: 16 })
94
+ })
95
+ ]
96
+ })
97
+ }),
98
+ X && /* @__PURE__ */ u(i, {
99
+ options: x,
100
+ value: H ? [H] : [],
101
+ title: S ?? "选择选项",
102
+ portalContainer: N,
103
+ returnFocus: U,
104
+ onClose: () => q(null),
105
+ onConfirm: (e) => {
106
+ let t = x.find((t) => t.value === e[0] && !t.disabled);
107
+ !D && t && (H !== t.value && Z(t.value), q(null));
108
+ }
54
109
  })
55
- })]
110
+ ]
56
111
  });
57
- return h === void 0 && _ === void 0 && !v ? j : /* @__PURE__ */ r(t, {
58
- controlId: k,
59
- label: h,
60
- required: y,
61
- helpText: _,
62
- error: v,
63
- children: j
112
+ return S === void 0 && w === void 0 && !T ? Q : /* @__PURE__ */ u(t, {
113
+ controlId: L,
114
+ label: S,
115
+ required: E,
116
+ helpText: w,
117
+ error: T,
118
+ children: Q
64
119
  });
65
120
  }
66
- function u(e, t, n) {
121
+ function _(e, t, n) {
67
122
  return [t === void 0 ? "" : `${e}-help`, n === void 0 || n === "" ? "" : `${e}-error`].filter(Boolean).join(" ") || void 0;
68
123
  }
69
- function d(...e) {
124
+ function v(...e) {
70
125
  return e.filter(Boolean).join(" ") || void 0;
71
126
  }
72
127
  //#endregion
73
- export { l as Select };
128
+ export { g as Select };
@@ -1,10 +1,11 @@
1
- import { Select as e } from "./Select.js";
2
- import { Cascader as t } from "./Cascader.js";
3
- import { useId as n, useMemo as r, useRef as i } from "react";
4
- import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
1
+ import { usePhoneWheel as e } from "./usePhoneWheel.js";
2
+ import { Select as t } from "./Select.js";
3
+ import { Cascader as n } from "./Cascader.js";
4
+ import { useId as r, useMemo as i, useRef as a } from "react";
5
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
5
6
  //#region src/StructuredAddressInput.tsx
6
- function c({ regions: c, value: l, onValueChange: u, label: d = "地址", required: f = !1, disabled: m = !1, annotation: h, dataVersion: g, className: _ = "", structuredModeLabel: v = "结构化地址", freeformModeLabel: y = "海外或非标准地址", showModeSelector: b = !1, regionLabel: x = "所在地区", detailLabel: S = "详细地址", freeformLabel: C = "完整地址", searchPlaceholder: w = "请选择或搜索地区", emptyText: T = "没有匹配的地区", maxLength: E = 500, regionInputRef: D, detailInputRef: O, freeformInputRef: k, regionInputProps: A, detailInputProps: j, freeformInputProps: M }) {
7
- let N = n().replaceAll(":", ""), P = A?.id ?? `ui-address-${N}-region`, F = i(null), I = r(() => {
7
+ function l({ regions: l, value: u, onValueChange: d, label: f = "地址", required: p = !1, disabled: h = !1, annotation: g, dataVersion: _, className: v = "", structuredModeLabel: y = "结构化地址", freeformModeLabel: b = "海外或非标准地址", showModeSelector: x = !1, regionLabel: S = "所在地区", detailLabel: C = "详细地址", freeformLabel: w = "完整地址", searchPlaceholder: T = "请选择或搜索地区", emptyText: E = "没有匹配的地区", maxLength: D = 500, regionInputRef: O, detailInputRef: k, freeformInputRef: A, regionInputProps: j, detailInputProps: M, freeformInputProps: N, mobileMode: P = "dropdown" }) {
8
+ let F = r().replaceAll(":", ""), I = e(P === "wheel"), L = j?.id ?? `ui-address-${F}-region`, R = a(null), z = i(() => {
8
9
  function e(t) {
9
10
  return t.map((t) => ({
10
11
  value: t.id,
@@ -13,105 +14,106 @@ function c({ regions: c, value: l, onValueChange: u, label: d = "地址", requir
13
14
  children: t.children ? e(t.children) : void 0
14
15
  }));
15
16
  }
16
- return e(c);
17
- }, [c]);
18
- function L(e) {
19
- u({
20
- ...l,
21
- ...b ? {} : { mode: "structured" },
17
+ return e(l);
18
+ }, [l]);
19
+ function B(e) {
20
+ d({
21
+ ...u,
22
+ ...x ? {} : { mode: "structured" },
22
23
  ...e
23
24
  });
24
25
  }
25
- return /* @__PURE__ */ s("fieldset", {
26
- className: `ui-structured-address ${_}`.trim(),
27
- disabled: m,
26
+ return /* @__PURE__ */ c("fieldset", {
27
+ className: `ui-structured-address ${v}`.trim(),
28
+ disabled: h,
28
29
  children: [
29
- /* @__PURE__ */ s("legend", { children: [
30
- f && /* @__PURE__ */ o("span", {
30
+ /* @__PURE__ */ c("legend", { children: [
31
+ p && /* @__PURE__ */ s("span", {
31
32
  className: "ui-required-mark",
32
33
  "aria-hidden": "true",
33
34
  children: "*"
34
35
  }),
35
- d,
36
- h !== void 0 && /* @__PURE__ */ o("span", {
36
+ f,
37
+ g !== void 0 && /* @__PURE__ */ s("span", {
37
38
  className: "ui-structured-address-annotation",
38
- children: h
39
+ children: g
39
40
  })
40
41
  ] }),
41
- b && /* @__PURE__ */ o("div", {
42
+ x && /* @__PURE__ */ s("div", {
42
43
  className: "ui-structured-address-mode",
43
- children: /* @__PURE__ */ o(e, {
44
+ children: /* @__PURE__ */ s(t, {
44
45
  label: "地址类型",
45
- value: l.mode,
46
- disabled: m,
47
- onValueChange: (e) => L({ mode: e }),
46
+ value: u.mode,
47
+ disabled: h,
48
+ onValueChange: (e) => B({ mode: e }),
48
49
  options: [{
49
50
  value: "structured",
50
- label: v
51
+ label: y
51
52
  }, {
52
53
  value: "freeform",
53
- label: y
54
+ label: b
54
55
  }]
55
56
  })
56
57
  }),
57
- b && l.mode === "freeform" ? /* @__PURE__ */ s("label", {
58
+ x && u.mode === "freeform" ? /* @__PURE__ */ c("label", {
58
59
  className: "ui-structured-address-full",
59
- children: [/* @__PURE__ */ o("span", { children: C }), /* @__PURE__ */ o("input", {
60
- ...M,
61
- ref: k,
60
+ children: [/* @__PURE__ */ s("span", { children: w }), /* @__PURE__ */ s("input", {
61
+ ...N,
62
+ ref: A,
62
63
  className: "ui-input",
63
64
  autoComplete: "street-address",
64
- maxLength: E,
65
- required: f,
66
- value: l.freeform,
67
- onChange: (e) => L({ freeform: e.target.value })
65
+ maxLength: D,
66
+ required: p,
67
+ value: u.freeform,
68
+ onChange: (e) => B({ freeform: e.target.value })
68
69
  })]
69
- }) : /* @__PURE__ */ s(a, { children: [
70
- /* @__PURE__ */ o("div", {
70
+ }) : /* @__PURE__ */ c(o, { children: [
71
+ /* @__PURE__ */ s("div", {
71
72
  className: "ui-structured-address-region",
72
- children: /* @__PURE__ */ o(t, {
73
- options: I,
74
- value: l.regionIds,
75
- label: x,
76
- id: P,
77
- disabled: m,
78
- required: f,
79
- placeholder: w,
80
- emptyText: T,
81
- inputProps: A,
82
- inputRef: D,
83
- changeOnSelect: !0,
73
+ children: /* @__PURE__ */ s(n, {
74
+ options: z,
75
+ value: u.regionIds,
76
+ label: S,
77
+ id: L,
78
+ disabled: h,
79
+ required: p,
80
+ placeholder: T,
81
+ emptyText: E,
82
+ inputProps: j,
83
+ inputRef: O,
84
+ changeOnSelect: !I,
85
+ mobileMode: P,
84
86
  onValueChange: (e, t) => {
85
- L({ regionIds: e });
87
+ B({ regionIds: e });
86
88
  let n = t.at(-1);
87
- n && !n.children?.length && queueMicrotask(() => F.current?.focus());
89
+ !I && n && !n.children?.length && queueMicrotask(() => R.current?.focus());
88
90
  }
89
91
  })
90
92
  }),
91
- /* @__PURE__ */ s("label", {
93
+ /* @__PURE__ */ c("label", {
92
94
  className: "ui-structured-address-detail",
93
- children: [/* @__PURE__ */ o("span", { children: S }), /* @__PURE__ */ o("input", {
94
- ...j,
95
+ children: [/* @__PURE__ */ s("span", { children: C }), /* @__PURE__ */ s("input", {
96
+ ...M,
95
97
  ref: (e) => {
96
- F.current = e, p(O, e);
98
+ R.current = e, m(k, e);
97
99
  },
98
100
  className: "ui-input",
99
101
  autoComplete: "street-address",
100
- maxLength: E,
101
- required: f,
102
- value: l.detail,
103
- onChange: (e) => L({ detail: e.target.value })
102
+ maxLength: D,
103
+ required: p,
104
+ value: u.detail,
105
+ onChange: (e) => B({ detail: e.target.value })
104
106
  })]
105
107
  }),
106
- g !== void 0 && /* @__PURE__ */ o("small", {
108
+ _ !== void 0 && /* @__PURE__ */ s("small", {
107
109
  className: "ui-structured-address-version",
108
- children: g
110
+ children: _
109
111
  })
110
112
  ] })
111
113
  ]
112
114
  });
113
115
  }
114
- function l(e) {
116
+ function u(e) {
115
117
  let t = [];
116
118
  function n(e, r, i) {
117
119
  for (let a of e) {
@@ -125,16 +127,16 @@ function l(e) {
125
127
  }
126
128
  return n(e, [], []), t;
127
129
  }
128
- function u(e, t, n = 20) {
129
- let r = f(t);
130
+ function d(e, t, n = 20) {
131
+ let r = p(t);
130
132
  if (!r) return [];
131
133
  let i = (e) => {
132
- let t = f(e.labels.at(-1) ?? "");
134
+ let t = p(e.labels.at(-1) ?? "");
133
135
  return t === r ? 0 : t.includes(r) ? 1 : 2;
134
136
  };
135
- return l(e).filter((e) => f(e.labels.join("/")).includes(r)).sort((e, t) => i(e) - i(t) || e.labels.join("/").localeCompare(t.labels.join("/"), "zh-CN")).slice(0, n);
137
+ return u(e).filter((e) => p(e.labels.join("/")).includes(r)).sort((e, t) => i(e) - i(t) || e.labels.join("/").localeCompare(t.labels.join("/"), "zh-CN")).slice(0, n);
136
138
  }
137
- function d(e, t) {
139
+ function f(e, t) {
138
140
  if (!t.length) return;
139
141
  let n = e, r = [], i = [], a;
140
142
  for (let e of t) {
@@ -147,11 +149,11 @@ function d(e, t) {
147
149
  leaf: a
148
150
  } : void 0;
149
151
  }
150
- function f(e) {
152
+ function p(e) {
151
153
  return e.replace(/[\s/]+/gu, "").toLocaleLowerCase();
152
154
  }
153
- function p(e, t) {
155
+ function m(e, t) {
154
156
  typeof e == "function" ? e(t) : e && (e.current = t);
155
157
  }
156
158
  //#endregion
157
- export { c as StructuredAddressInput, d as findAddressRegionPath, l as flattenAddressRegions, u as searchAddressRegions };
159
+ export { l as StructuredAddressInput, f as findAddressRegionPath, u as flattenAddressRegions, d as searchAddressRegions };
@@ -268,7 +268,10 @@ function ie({ items: n, value: d, defaultValue: ie = null, onValueChange: h, ope
268
268
  "aria-label": "已选节点",
269
269
  children: [R.map((e) => /* @__PURE__ */ u("span", {
270
270
  className: "ui-selection-tag",
271
- children: [I.get(e)?.label ?? e, /* @__PURE__ */ l("button", {
271
+ children: [/* @__PURE__ */ l("span", {
272
+ className: "ui-selection-tag-label",
273
+ children: I.get(e)?.label ?? e
274
+ }), /* @__PURE__ */ l("button", {
272
275
  type: "button",
273
276
  disabled: D,
274
277
  "aria-label": `移除 ${I.get(e)?.label ?? e}`,
@@ -0,0 +1,123 @@
1
+ import { FormField as e } from "./FormField.js";
2
+ import { enabledWheelOptions as t, resolveWheelPath as n, wheelOptionsKey as r } from "./option-wheel-model.js";
3
+ import { OptionWheelDialog as i } from "./OptionWheelDialog.js";
4
+ import { useCallback as a, useEffect as o, useId as s, useRef as c, useState as l } from "react";
5
+ import { jsx as u, jsxs as d } from "react/jsx-runtime";
6
+ //#region src/WheelCascader.tsx
7
+ function f(f) {
8
+ let p = s(), m = f.id ?? f.inputProps?.id ?? p, h = c(null), g = a((e) => {
9
+ h.current = e, typeof f.inputRef == "function" ? f.inputRef(e) : f.inputRef && (f.inputRef.current = e);
10
+ }, [f.inputRef]), [_, v] = l(!1), [y, b] = l();
11
+ o(() => {
12
+ (f.value.length || !f.required) && b(void 0);
13
+ }, [f.value.length, f.required]);
14
+ let x = f.error ?? y, S = JSON.stringify([
15
+ f.value,
16
+ r(f.options),
17
+ !!f.disabled,
18
+ !!f.inputProps?.readOnly
19
+ ]), [C, w] = l(S), T = C !== S, E = f.open ?? _, [D, O] = l(!1), k = E && !f.disabled && !f.inputProps?.readOnly && !T && !D;
20
+ function A() {
21
+ v(!1), f.onOpenChange?.(!1);
22
+ }
23
+ o(() => {
24
+ T && (w(S), E && (O(!0), A()));
25
+ }, [
26
+ S,
27
+ T,
28
+ E
29
+ ]), o(() => {
30
+ E || O(!1);
31
+ }, [E]);
32
+ function j() {
33
+ f.disabled || f.inputProps?.readOnly || (w(S), O(!1), v(!0), f.onOpenChange?.(!0));
34
+ }
35
+ let M = [], N = f.options;
36
+ for (let e of f.value) {
37
+ let t = N.find((t) => t.value === e);
38
+ if (!t) break;
39
+ M.push(t), N = t.children ?? [];
40
+ }
41
+ let { onClick: P, onKeyDown: F, ...I } = f.inputProps ?? {}, L = [
42
+ I["aria-describedby"],
43
+ f.helpText !== void 0 && `${m}-help`,
44
+ x && `${m}-error`
45
+ ].filter(Boolean).join(" ") || void 0;
46
+ function R(e) {
47
+ if (f.disabled || f.inputProps?.readOnly || T) return;
48
+ if (!e.length) {
49
+ if (f.required || f.allowClear === !1) return;
50
+ f.onValueChange([], []), A();
51
+ return;
52
+ }
53
+ let r = n(t(f.options), e);
54
+ if (JSON.stringify(r.value) !== JSON.stringify(e)) return;
55
+ let i = [], a = f.options;
56
+ for (let t of e) {
57
+ let e = a.find((e) => e.value === t);
58
+ i.push(e), a = e.children ?? [];
59
+ }
60
+ JSON.stringify(f.value) !== JSON.stringify(e) && f.onValueChange(e, i), A();
61
+ }
62
+ return /* @__PURE__ */ d(e, {
63
+ controlId: m,
64
+ label: f.label,
65
+ helpText: f.helpText,
66
+ error: x,
67
+ required: f.required,
68
+ children: [
69
+ f.required && /* @__PURE__ */ u("input", {
70
+ className: "ui-wheel-validation",
71
+ tabIndex: -1,
72
+ "aria-hidden": "true",
73
+ required: !0,
74
+ disabled: f.disabled,
75
+ value: f.value.length ? "selected" : "",
76
+ onChange: () => {},
77
+ onInvalid: (e) => {
78
+ e.preventDefault(), b("请选择一个选项"), h.current?.focus();
79
+ }
80
+ }),
81
+ /* @__PURE__ */ u("input", {
82
+ ...I,
83
+ id: m,
84
+ ref: g,
85
+ type: "text",
86
+ readOnly: !0,
87
+ inputMode: "none",
88
+ disabled: f.disabled,
89
+ className: `ui-input ui-wheel-cascader ${f.className ?? ""}`,
90
+ value: M.map((e) => e.label).join(" / "),
91
+ placeholder: f.placeholder ?? "请选择",
92
+ "aria-haspopup": "dialog",
93
+ "aria-expanded": k,
94
+ "aria-required": f.required || void 0,
95
+ "aria-invalid": x ? !0 : I["aria-invalid"],
96
+ "aria-describedby": L,
97
+ onClick: (e) => {
98
+ P?.(e), e.defaultPrevented || j();
99
+ },
100
+ onKeyDown: (e) => {
101
+ F?.(e), !e.defaultPrevented && [
102
+ "Enter",
103
+ " ",
104
+ "ArrowDown"
105
+ ].includes(e.key) && (e.preventDefault(), j());
106
+ }
107
+ }),
108
+ k && /* @__PURE__ */ u(i, {
109
+ options: f.options,
110
+ value: f.value,
111
+ title: f.label ?? "选择选项",
112
+ returnFocus: h,
113
+ clearLabel: f.clearLabel,
114
+ emptyText: f.emptyText,
115
+ allowClear: !f.required && f.allowClear !== !1,
116
+ onClose: A,
117
+ onConfirm: R
118
+ })
119
+ ]
120
+ });
121
+ }
122
+ //#endregion
123
+ export { f as WheelCascader };