@jc-times/business-ui 0.3.1 → 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.
- package/AGENTS.md +15 -0
- package/CHANGELOG.md +23 -0
- package/README.md +2 -0
- package/THIRD_PARTY_NOTICES.md +8 -0
- package/assets/pdf-fonts/NotoSans-Bold.ttf +0 -0
- package/assets/pdf-fonts/NotoSans-BoldItalic.ttf +0 -0
- package/assets/pdf-fonts/NotoSans-Italic.ttf +0 -0
- package/assets/pdf-fonts/NotoSans-Regular.ttf +0 -0
- package/assets/pdf-fonts/NotoSansHans-Regular.otf +0 -0
- package/assets/pdf-fonts/OFL-CJK.txt +92 -0
- package/assets/pdf-fonts/OFL-Latin.txt +94 -0
- package/assets/pdf-fonts/README.md +11 -0
- package/bin/business-ui-gate.mjs +2 -2
- package/dist/AntDateWheelView.js +131 -0
- package/dist/AntOptionWheelView.js +76 -0
- package/dist/Cascader.js +56 -51
- package/dist/DateInput.js +84 -66
- package/dist/DateWheelPicker.js +58 -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 +4 -1
- 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/document-viewer-v2/DocumentViewerV2.js +49 -48
- package/dist/document-viewer-v2/HeadlessPdfViewer.js +128 -124
- package/dist/document-viewer-v2/pdf-font-fallback.js +35 -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/Cascader.d.ts +2 -0
- package/dist/types/DateInput.d.ts +4 -0
- package/dist/types/DateWheelPicker.d.ts +13 -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/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/document-viewer-v2/pdf-font-fallback.d.ts +2 -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 +14 -0
- package/docs/cascader.md +2 -0
- package/docs/component-strategy.md +3 -0
- package/docs/date-wheel.md +25 -0
- package/docs/dependencies.md +2 -0
- package/docs/document-viewer-v2.md +2 -2
- package/docs/mobile-controls.md +54 -0
- package/docs/modal-shell-migration.md +25 -0
- package/docs/release.md +7 -0
- package/docs/viewport-qa.md +38 -0
- package/licenses/antd-mobile-MIT.txt +22 -0
- package/package.json +17 -4
package/dist/ModalShell.js
CHANGED
|
@@ -1,105 +1,117 @@
|
|
|
1
1
|
import { Button as e } from "./Button.js";
|
|
2
2
|
import { OverlayContainerContext as t } from "./OverlayContainer.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
3
|
+
import { useSheetViewport as n } from "./useSheetViewport.js";
|
|
4
|
+
import { Children as r, Fragment as i, isValidElement as a, useCallback as o, useEffect as s, useRef as c, useState as l } from "react";
|
|
5
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
|
+
import { X as f } from "lucide-react";
|
|
7
|
+
import * as p from "@radix-ui/react-dialog";
|
|
7
8
|
//#region src/ModalShell.tsx
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
var m = Symbol("ui-modal-nested-escape");
|
|
10
|
+
function h({ backdropClassName: e = "", panelClassName: r = "", titleId: i, eyebrow: a, title: f, description: h, closeLabel: y, onClose: S, closeDisabled: C = !1, showCloseButton: w = !0, closeIconSize: T = 20, closeOnBackdrop: E = !1, rootRef: D, closeOnEscape: O = !0, initialFocus: k, returnFocus: A, role: j = "dialog", describedBy: M, children: N, footer: P, contentClassName: F = "", contentProps: I, footerClassName: L = "", mobileMode: R = "fullscreen" }) {
|
|
11
|
+
let z = n(R === "bottom-sheet"), B = c(null), [V, H] = l(null), U = c(typeof document > "u" ? null : document.activeElement), W = o((e) => {
|
|
12
|
+
B.current = e, b(D, e);
|
|
13
|
+
}, [D]), G = c(!1), { ref: K, ...q } = I ?? {};
|
|
14
|
+
function J() {
|
|
15
|
+
return [...document.querySelectorAll("[role='dialog'][aria-modal='true'],[role='alertdialog'][aria-modal='true']")].at(-1) === B.current;
|
|
14
16
|
}
|
|
15
|
-
function
|
|
16
|
-
!
|
|
17
|
+
function Y() {
|
|
18
|
+
!C && J() && S();
|
|
17
19
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}, [
|
|
21
|
-
function
|
|
22
|
-
|
|
20
|
+
s(() => {
|
|
21
|
+
_() && P === void 0 && !G.current && g(N) && (G.current = !0, console.warn("[business-ui] ModalShell 的直接 <footer> child 会位于可滚动正文区。固定底栏请改用 footer 属性,并用 footerClassName 定制样式;组件不会自动搬运 children。"));
|
|
22
|
+
}, [N, P]);
|
|
23
|
+
function X(e) {
|
|
24
|
+
E && e.target === e.currentTarget && Y(), e.target.closest("button,a[href],input,select,textarea,[tabindex]") || e.preventDefault();
|
|
23
25
|
}
|
|
24
|
-
return /* @__PURE__ */
|
|
26
|
+
return /* @__PURE__ */ u(p.Root, {
|
|
25
27
|
open: !0,
|
|
26
28
|
onOpenChange: (e) => {
|
|
27
|
-
e ||
|
|
29
|
+
e || Y();
|
|
28
30
|
},
|
|
29
|
-
children: /* @__PURE__ */
|
|
31
|
+
children: /* @__PURE__ */ u(p.Overlay, {
|
|
30
32
|
asChild: !0,
|
|
31
|
-
children: /* @__PURE__ */
|
|
33
|
+
children: /* @__PURE__ */ u(p.Content, {
|
|
32
34
|
asChild: !0,
|
|
33
35
|
onEscapeKeyDown: (e) => {
|
|
34
|
-
(
|
|
36
|
+
if (!J()) {
|
|
37
|
+
e[m] = !0, e.preventDefault();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
(C || !O || B.current?.querySelector("[data-ui-aria-overlay]")) && e.preventDefault();
|
|
35
41
|
},
|
|
36
42
|
onInteractOutside: (e) => e.preventDefault(),
|
|
37
43
|
onOpenAutoFocus: (e) => {
|
|
38
|
-
let t =
|
|
44
|
+
let t = x(k);
|
|
39
45
|
t && !t.hasAttribute("disabled") && (e.preventDefault(), t.focus());
|
|
40
46
|
},
|
|
41
47
|
onCloseAutoFocus: (e) => {
|
|
42
|
-
if (e.preventDefault(),
|
|
43
|
-
let e =
|
|
48
|
+
if (e.preventDefault(), A !== !1) {
|
|
49
|
+
let e = x(A) ?? U.current;
|
|
44
50
|
e?.isConnected && e.focus();
|
|
45
51
|
}
|
|
46
52
|
},
|
|
47
|
-
children: /* @__PURE__ */
|
|
48
|
-
ref:
|
|
53
|
+
children: /* @__PURE__ */ u("div", {
|
|
54
|
+
ref: W,
|
|
49
55
|
"data-ui-focus-managed": "radix",
|
|
56
|
+
"data-mobile-mode": R,
|
|
57
|
+
style: z,
|
|
50
58
|
className: `ui-modal-backdrop ${e}`.trim(),
|
|
51
|
-
role:
|
|
59
|
+
role: j,
|
|
52
60
|
"aria-modal": "true",
|
|
53
|
-
"aria-labelledby":
|
|
54
|
-
"aria-describedby":
|
|
55
|
-
onMouseDown:
|
|
61
|
+
"aria-labelledby": i,
|
|
62
|
+
"aria-describedby": M ?? (h === void 0 ? void 0 : `${i}-description`),
|
|
63
|
+
onMouseDown: X,
|
|
56
64
|
tabIndex: -1,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
65
|
+
onKeyDown: (e) => {
|
|
66
|
+
let t = e.nativeEvent[m];
|
|
67
|
+
e.key === "Escape" && (!e.defaultPrevented || t) && J() && O && !C && !B.current?.querySelector("[data-ui-aria-overlay]") && (e.preventDefault(), e.stopPropagation(), Y());
|
|
68
|
+
},
|
|
69
|
+
children: /* @__PURE__ */ d(t.Provider, {
|
|
70
|
+
value: V,
|
|
71
|
+
children: [/* @__PURE__ */ d("section", {
|
|
72
|
+
className: `ui-modal ${r}`.trim(),
|
|
61
73
|
children: [
|
|
62
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ d("header", {
|
|
63
75
|
className: "ui-modal-header",
|
|
64
|
-
children: [/* @__PURE__ */
|
|
65
|
-
|
|
76
|
+
children: [/* @__PURE__ */ d("div", { children: [
|
|
77
|
+
a === void 0 ? null : /* @__PURE__ */ u("span", {
|
|
66
78
|
className: "ui-modal-eyebrow",
|
|
67
|
-
children:
|
|
79
|
+
children: a
|
|
68
80
|
}),
|
|
69
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ u(p.Title, {
|
|
70
82
|
asChild: !0,
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
id:
|
|
73
|
-
children:
|
|
83
|
+
children: /* @__PURE__ */ u("h2", {
|
|
84
|
+
id: i,
|
|
85
|
+
children: f
|
|
74
86
|
})
|
|
75
87
|
}),
|
|
76
|
-
|
|
88
|
+
h === void 0 ? null : /* @__PURE__ */ u(p.Description, {
|
|
77
89
|
asChild: !0,
|
|
78
|
-
children: /* @__PURE__ */
|
|
79
|
-
id: `${
|
|
80
|
-
children:
|
|
90
|
+
children: /* @__PURE__ */ u("p", {
|
|
91
|
+
id: `${i}-description`,
|
|
92
|
+
children: h
|
|
81
93
|
})
|
|
82
94
|
})
|
|
83
|
-
] }),
|
|
84
|
-
label:
|
|
85
|
-
disabled:
|
|
86
|
-
size:
|
|
87
|
-
onClose:
|
|
95
|
+
] }), w && /* @__PURE__ */ u(v, {
|
|
96
|
+
label: y,
|
|
97
|
+
disabled: C,
|
|
98
|
+
size: T,
|
|
99
|
+
onClose: Y
|
|
88
100
|
})]
|
|
89
101
|
}),
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
...
|
|
92
|
-
ref:
|
|
93
|
-
className: `ui-modal-content ${
|
|
94
|
-
children:
|
|
102
|
+
/* @__PURE__ */ u("div", {
|
|
103
|
+
...q,
|
|
104
|
+
ref: K,
|
|
105
|
+
className: `ui-modal-content ${F}`.trim(),
|
|
106
|
+
children: N
|
|
95
107
|
}),
|
|
96
|
-
|
|
97
|
-
className: `ui-modal-footer ${
|
|
98
|
-
children:
|
|
108
|
+
P === void 0 ? null : /* @__PURE__ */ u("footer", {
|
|
109
|
+
className: `ui-modal-footer ${L}`.trim(),
|
|
110
|
+
children: P
|
|
99
111
|
})
|
|
100
112
|
]
|
|
101
|
-
}), /* @__PURE__ */
|
|
102
|
-
ref:
|
|
113
|
+
}), /* @__PURE__ */ u("div", {
|
|
114
|
+
ref: H,
|
|
103
115
|
className: "ui-overlay-container"
|
|
104
116
|
})]
|
|
105
117
|
})
|
|
@@ -108,32 +120,32 @@ function p({ backdropClassName: e = "", panelClassName: n = "", titleId: r, eyeb
|
|
|
108
120
|
})
|
|
109
121
|
});
|
|
110
122
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
123
|
+
function g(e) {
|
|
124
|
+
return r.toArray(e).some((e) => a(e) ? e.type === "footer" || e.type === i && g(e.props.children) : !1);
|
|
113
125
|
}
|
|
114
|
-
function
|
|
126
|
+
function _() {
|
|
115
127
|
return typeof process < "u" && process.env.NODE_ENV !== "production";
|
|
116
128
|
}
|
|
117
|
-
function
|
|
118
|
-
return /* @__PURE__ */
|
|
129
|
+
function v({ label: t, disabled: n, size: r, onClose: i }) {
|
|
130
|
+
return /* @__PURE__ */ u(e, {
|
|
119
131
|
className: "ui-modal-close",
|
|
120
132
|
variant: "ghost",
|
|
121
133
|
iconOnly: !0,
|
|
122
134
|
"aria-label": t,
|
|
123
135
|
onClick: i,
|
|
124
136
|
disabled: n,
|
|
125
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ u(f, {
|
|
126
138
|
size: r,
|
|
127
139
|
"aria-hidden": "true"
|
|
128
140
|
})
|
|
129
141
|
});
|
|
130
142
|
}
|
|
131
|
-
var
|
|
132
|
-
function
|
|
143
|
+
var y = h;
|
|
144
|
+
function b(e, t) {
|
|
133
145
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
134
146
|
}
|
|
135
|
-
function
|
|
147
|
+
function x(e) {
|
|
136
148
|
return e && "current" in e ? e.current : e || null;
|
|
137
149
|
}
|
|
138
150
|
//#endregion
|
|
139
|
-
export {
|
|
151
|
+
export { y as Dialog, h as ModalShell };
|
package/dist/MultiSelect.js
CHANGED
|
@@ -43,6 +43,7 @@ function x({ values: x, defaultValues: S = y, onValuesChange: C, name: w, select
|
|
|
43
43
|
selectionMode: "multiple",
|
|
44
44
|
value: Z,
|
|
45
45
|
onChange: (e) => Q(e.map(String)),
|
|
46
|
+
allowsCustomValue: !0,
|
|
46
47
|
inputValue: j,
|
|
47
48
|
defaultInputValue: M,
|
|
48
49
|
onInputChange: N,
|
|
@@ -87,7 +88,10 @@ function x({ values: x, defaultValues: S = y, onValuesChange: C, name: w, select
|
|
|
87
88
|
id: e.id,
|
|
88
89
|
textValue: e.label,
|
|
89
90
|
className: "ui-selection-tag",
|
|
90
|
-
children: [
|
|
91
|
+
children: [/* @__PURE__ */ r("span", {
|
|
92
|
+
className: "ui-selection-tag-label",
|
|
93
|
+
children: e.label
|
|
94
|
+
}), /* @__PURE__ */ r(c, {
|
|
91
95
|
slot: "remove",
|
|
92
96
|
"aria-label": `移除 ${e.label}`,
|
|
93
97
|
children: "×"
|
|
@@ -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 {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
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
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
|
58
|
-
controlId:
|
|
59
|
-
label:
|
|
60
|
-
required:
|
|
61
|
-
helpText:
|
|
62
|
-
error:
|
|
63
|
-
children:
|
|
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
|
|
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
|
|
124
|
+
function v(...e) {
|
|
70
125
|
return e.filter(Boolean).join(" ") || void 0;
|
|
71
126
|
}
|
|
72
127
|
//#endregion
|
|
73
|
-
export {
|
|
128
|
+
export { g as Select };
|