@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/Cascader.js
CHANGED
|
@@ -1,52 +1,57 @@
|
|
|
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 { WheelCascader as r } from "./WheelCascader.js";
|
|
5
|
+
import { useCallback as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronDown as d, ChevronRight as f, LoaderCircle as p, X as m } from "lucide-react";
|
|
8
|
+
import h from "@rc-component/cascader";
|
|
7
9
|
//#region src/Cascader.tsx
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
function g(e) {
|
|
11
|
+
return n(e.mobileMode === "wheel") && !e.multiple && !e.loadData && !e.changeOnSelect ? /* @__PURE__ */ l(r, { ...e }) : /* @__PURE__ */ l(_, { ...e });
|
|
12
|
+
}
|
|
13
|
+
function _(n) {
|
|
14
|
+
let r = o(), [g, _] = c(!1);
|
|
15
|
+
a(() => {
|
|
16
|
+
n.disabled && _(!1);
|
|
17
|
+
}, [n.disabled]);
|
|
18
|
+
let y = !n.disabled && (n.open ?? g), b = n.id ?? n.inputProps?.id ?? r, x = e(), { inputProps: S, inputRef: C, label: w, helpText: T, error: E } = n, D = s(null), O = i((e) => {
|
|
14
19
|
D.current = e, typeof C == "function" ? C(e) : C && (C.current = e);
|
|
15
20
|
}, [C]);
|
|
16
|
-
|
|
17
|
-
D.current?.setCustomValidity(
|
|
18
|
-
}, [
|
|
21
|
+
a(() => {
|
|
22
|
+
D.current?.setCustomValidity(n.required && !n.value.length ? "请选择一个选项" : "");
|
|
23
|
+
}, [n.required, n.value.length]);
|
|
19
24
|
let k = [
|
|
20
25
|
S?.["aria-describedby"],
|
|
21
26
|
T !== void 0 && `${b}-help`,
|
|
22
27
|
E && `${b}-error`
|
|
23
28
|
].filter(Boolean).join(" ") || void 0, A = {
|
|
24
29
|
id: b,
|
|
25
|
-
options:
|
|
30
|
+
options: n.options,
|
|
26
31
|
prefixCls: "ui-cascader",
|
|
27
|
-
className:
|
|
28
|
-
disabled:
|
|
32
|
+
className: n.className,
|
|
33
|
+
disabled: n.disabled,
|
|
29
34
|
open: y,
|
|
30
35
|
onPopupVisibleChange: (e) => {
|
|
31
|
-
|
|
36
|
+
_(e), n.onOpenChange?.(e);
|
|
32
37
|
},
|
|
33
38
|
onInputKeyDown: (e) => {
|
|
34
|
-
e.key === "Escape" && y && !e.nativeEvent.isComposing && (e.preventDefault(), e.stopPropagation(),
|
|
39
|
+
e.key === "Escape" && y && !e.nativeEvent.isComposing && (e.preventDefault(), e.stopPropagation(), _(!1), n.onOpenChange?.(!1));
|
|
35
40
|
},
|
|
36
41
|
showAction: [],
|
|
37
|
-
placeholder:
|
|
38
|
-
notFoundContent:
|
|
39
|
-
allowClear:
|
|
40
|
-
clearIcon: /* @__PURE__ */
|
|
41
|
-
label:
|
|
42
|
+
placeholder: n.placeholder ?? "请选择或搜索",
|
|
43
|
+
notFoundContent: n.emptyText ?? "没有匹配的选项",
|
|
44
|
+
allowClear: n.allowClear !== !1 && {
|
|
45
|
+
clearIcon: /* @__PURE__ */ l(m, { size: 14 }),
|
|
46
|
+
label: n.clearLabel ?? "清除选择"
|
|
42
47
|
},
|
|
43
|
-
suffix: /* @__PURE__ */
|
|
44
|
-
expandIcon: /* @__PURE__ */
|
|
45
|
-
loadingIcon: /* @__PURE__ */
|
|
46
|
-
changeOnSelect:
|
|
47
|
-
loadData:
|
|
48
|
-
showSearch:
|
|
49
|
-
filter: (e, t) =>
|
|
48
|
+
suffix: /* @__PURE__ */ l(d, { size: 16 }),
|
|
49
|
+
expandIcon: /* @__PURE__ */ l(f, { size: 14 }),
|
|
50
|
+
loadingIcon: /* @__PURE__ */ l(p, { size: 14 }),
|
|
51
|
+
changeOnSelect: n.changeOnSelect,
|
|
52
|
+
loadData: n.loadData,
|
|
53
|
+
showSearch: n.searchable ?? !n.loadData ? {
|
|
54
|
+
filter: (e, t) => v(t.map((e) => e.label).join("/")).includes(v(e)),
|
|
50
55
|
render: (e, t) => t.map((e) => e.label).join(" / "),
|
|
51
56
|
limit: 50
|
|
52
57
|
} : !1,
|
|
@@ -61,19 +66,19 @@ function m(m) {
|
|
|
61
66
|
shiftX: !0
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
|
-
components: { input: /* @__PURE__ */
|
|
69
|
+
components: { input: /* @__PURE__ */ l("input", {
|
|
65
70
|
...S,
|
|
66
71
|
ref: O,
|
|
67
72
|
id: b,
|
|
68
73
|
placeholder: "",
|
|
69
|
-
required:
|
|
70
|
-
"aria-required":
|
|
74
|
+
required: n.required && !n.value.length,
|
|
75
|
+
"aria-required": n.required || void 0,
|
|
71
76
|
"aria-invalid": E ? !0 : S?.["aria-invalid"],
|
|
72
77
|
"aria-describedby": k
|
|
73
78
|
}) },
|
|
74
|
-
tagRender: ({ label: e, closable: t, onClose: n }) => /* @__PURE__ */
|
|
79
|
+
tagRender: ({ label: e, closable: t, onClose: n }) => /* @__PURE__ */ u("span", {
|
|
75
80
|
className: "ui-cascader-tag",
|
|
76
|
-
children: [/* @__PURE__ */
|
|
81
|
+
children: [/* @__PURE__ */ l("span", { children: e }), t && /* @__PURE__ */ l("button", {
|
|
77
82
|
type: "button",
|
|
78
83
|
"aria-label": `移除 ${String(e)}`,
|
|
79
84
|
onMouseDown: (e) => {
|
|
@@ -82,37 +87,37 @@ function m(m) {
|
|
|
82
87
|
onClick: (e) => {
|
|
83
88
|
e.stopPropagation(), n();
|
|
84
89
|
},
|
|
85
|
-
children: /* @__PURE__ */
|
|
90
|
+
children: /* @__PURE__ */ l(m, { size: 12 })
|
|
86
91
|
})]
|
|
87
92
|
})
|
|
88
93
|
};
|
|
89
|
-
return /* @__PURE__ */
|
|
94
|
+
return /* @__PURE__ */ u(t, {
|
|
90
95
|
controlId: b,
|
|
91
96
|
label: w,
|
|
92
97
|
helpText: T,
|
|
93
98
|
error: E,
|
|
94
|
-
required:
|
|
95
|
-
children: [y && /* @__PURE__ */
|
|
99
|
+
required: n.required,
|
|
100
|
+
children: [y && /* @__PURE__ */ l("span", {
|
|
96
101
|
hidden: !0,
|
|
97
102
|
"data-ui-aria-overlay": ""
|
|
98
|
-
}),
|
|
103
|
+
}), n.multiple ? /* @__PURE__ */ l(h, {
|
|
99
104
|
...A,
|
|
100
105
|
checkable: !0,
|
|
101
|
-
checkStrictly:
|
|
102
|
-
maxTagCount:
|
|
103
|
-
value:
|
|
104
|
-
onChange: (e, t) =>
|
|
105
|
-
}) : /* @__PURE__ */
|
|
106
|
+
checkStrictly: n.checkStrictly ?? !0,
|
|
107
|
+
maxTagCount: n.maxTagCount ?? 3,
|
|
108
|
+
value: n.value,
|
|
109
|
+
onChange: (e, t) => n.onValueChange(e ?? [], t ?? [])
|
|
110
|
+
}) : /* @__PURE__ */ l(h, {
|
|
106
111
|
...A,
|
|
107
|
-
value:
|
|
108
|
-
onChange: (e, t) =>
|
|
112
|
+
value: n.value,
|
|
113
|
+
onChange: (e, t) => n.onValueChange(e ?? [], t ?? [])
|
|
109
114
|
})]
|
|
110
115
|
});
|
|
111
116
|
}
|
|
112
|
-
function
|
|
117
|
+
function v(e) {
|
|
113
118
|
return e.replace(/[\s/]+/gu, "").toLocaleLowerCase();
|
|
114
119
|
}
|
|
115
|
-
function
|
|
120
|
+
function y(e) {
|
|
116
121
|
let t = /* @__PURE__ */ new Map(), n = new Map(e.map((e) => [e.id, e.parentId]));
|
|
117
122
|
for (let n of e) {
|
|
118
123
|
if (!n.id || t.has(n.id)) throw Error("Cascader IDs must be nonempty and unique");
|
|
@@ -134,7 +139,7 @@ function g(e) {
|
|
|
134
139
|
}
|
|
135
140
|
return r;
|
|
136
141
|
}
|
|
137
|
-
function
|
|
142
|
+
function b(e) {
|
|
138
143
|
let t = /* @__PURE__ */ new Map();
|
|
139
144
|
function n(e, r) {
|
|
140
145
|
for (let i of e) {
|
|
@@ -146,4 +151,4 @@ function _(e) {
|
|
|
146
151
|
return n(e, []), t;
|
|
147
152
|
}
|
|
148
153
|
//#endregion
|
|
149
|
-
export {
|
|
154
|
+
export { g as Cascader, y as buildCascaderOptions, b as indexCascaderPaths };
|
package/dist/DateInput.js
CHANGED
|
@@ -1,38 +1,56 @@
|
|
|
1
1
|
import { useOverlayContainer as e } from "./OverlayContainer.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
2
|
+
import { WheelDateInput as t } from "./WheelDateInput.js";
|
|
3
|
+
import { forwardRef as n, useCallback as r, useEffect as i, useId as a, useRef as o, useState as s } from "react";
|
|
4
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
5
|
+
import { CalendarDays as ee, ChevronLeft as te, ChevronRight as ne, X as re } from "lucide-react";
|
|
6
|
+
import * as u from "@radix-ui/react-popover";
|
|
7
|
+
import { Button as d, Calendar as ie, CalendarCell as ae, CalendarGrid as oe, CalendarGridBody as se, CalendarGridHeader as ce, CalendarHeaderCell as le, Heading as ue, I18nProvider as de } from "react-aria-components";
|
|
8
|
+
import { CalendarDate as fe, getLocalTimeZone as f, parseDate as p, today as m } from "@internationalized/date";
|
|
8
9
|
//#region src/DateInput.tsx
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
var h = "jc-business-ui-date-input-open", g = "(hover: none) and (pointer: coarse)";
|
|
11
|
+
function _() {
|
|
12
|
+
return typeof navigator > "u" ? !1 : /iPhone|iPod|Android.+Mobile/i.test(navigator.userAgent);
|
|
13
|
+
}
|
|
14
|
+
var v = n(function({ mobileMode: e = "calendar", ...n }, r) {
|
|
15
|
+
let [a, o] = s(() => typeof window < "u" && !!window.matchMedia?.(g).matches);
|
|
16
|
+
return i(() => {
|
|
17
|
+
if (e !== "wheel" || !window.matchMedia) return;
|
|
18
|
+
let t = window.matchMedia(g), n = () => o(t.matches);
|
|
19
|
+
return n(), t.addEventListener("change", n), () => t.removeEventListener("change", n);
|
|
20
|
+
}, [e]), e === "wheel" && a && _() ? /* @__PURE__ */ c(t, {
|
|
21
|
+
...n,
|
|
22
|
+
ref: r
|
|
23
|
+
}) : /* @__PURE__ */ c(y, {
|
|
24
|
+
...n,
|
|
25
|
+
ref: r
|
|
26
|
+
});
|
|
27
|
+
}), y = n(function({ value: t, onValueChange: n, inputRef: p, inputClassName: g, className: _ = "", disabled: v, readOnly: y, required: C, inputMode: pe = "numeric", autoComplete: me = "off", onFocus: he, onBlur: ge, onKeyDown: _e, min: T, max: E, minDate: D, maxDate: ve, isDateUnavailable: O, onValidationError: ye, ...k }, A) {
|
|
28
|
+
let j = `ui-date-calendar-${a().replaceAll(":", "")}`, be = e(), M = o(null), N = o(!1), P = o(!1), F = o(!1), [I, L] = s(!1), [R, z] = s(() => b(t)), [B, V] = s(""), H = x(t), U = x(D ?? (T === void 0 ? "" : String(T))), W = x(ve ?? (E === void 0 ? "" : String(E))), [G, K] = s(() => H ?? m(f())), q = !!(v || y), xe = r((e) => {
|
|
29
|
+
M.current = e, w(p, e), w(A, e);
|
|
30
|
+
}, [p, A]);
|
|
31
|
+
i(() => {
|
|
32
|
+
z(b(t)), V(""), M.current?.setCustomValidity("");
|
|
33
|
+
}, [t]), i(() => {
|
|
16
34
|
q && L(!1);
|
|
17
|
-
}, [q]),
|
|
35
|
+
}, [q]), i(() => {
|
|
18
36
|
let e = (e) => {
|
|
19
37
|
e.detail !== j && L(!1);
|
|
20
38
|
};
|
|
21
|
-
return document.addEventListener(
|
|
39
|
+
return document.addEventListener(h, e), () => document.removeEventListener(h, e);
|
|
22
40
|
}, [j]);
|
|
23
41
|
function J(e) {
|
|
24
42
|
if (!(e && q)) {
|
|
25
43
|
if (e && !I) {
|
|
26
|
-
document.dispatchEvent(new CustomEvent(
|
|
27
|
-
let e = H ??
|
|
44
|
+
document.dispatchEvent(new CustomEvent(h, { detail: j }));
|
|
45
|
+
let e = H ?? m(f());
|
|
28
46
|
U && e.compare(U) < 0 && (e = U), W && e.compare(W) > 0 && (e = W), K(e);
|
|
29
47
|
}
|
|
30
48
|
L(e);
|
|
31
49
|
}
|
|
32
50
|
}
|
|
33
51
|
function Y(e) {
|
|
34
|
-
if (!e) return
|
|
35
|
-
let t =
|
|
52
|
+
if (!e) return C ? "请选择日期" : "";
|
|
53
|
+
let t = x(e);
|
|
36
54
|
return t ? U && t.compare(U) < 0 ? `日期不能早于 ${U}` : W && t.compare(W) > 0 ? `日期不能晚于 ${W}` : O?.(t.toString()) ? "该日期不可选择" : "" : "请输入有效日期(YYYY/MM/DD)";
|
|
37
55
|
}
|
|
38
56
|
function X(e) {
|
|
@@ -40,33 +58,33 @@ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChan
|
|
|
40
58
|
}
|
|
41
59
|
function Z() {
|
|
42
60
|
if (q) return;
|
|
43
|
-
let e = R.trim() ?
|
|
44
|
-
X(
|
|
61
|
+
let e = R.trim() ? S(R) : "", r = e === null ? "请输入有效日期(YYYY/MM/DD)" : Y(e);
|
|
62
|
+
X(r), !r && e !== null && (z(b(e)), e !== t && n(e));
|
|
45
63
|
}
|
|
46
64
|
function Q(e) {
|
|
47
65
|
if (q) return;
|
|
48
66
|
let t = Y(e);
|
|
49
|
-
X(t), !t && (F.current = !0,
|
|
67
|
+
X(t), !t && (F.current = !0, n(e), z(b(e)), L(!1));
|
|
50
68
|
}
|
|
51
|
-
let $ =
|
|
52
|
-
return /* @__PURE__ */
|
|
69
|
+
let $ = m(f()).toString();
|
|
70
|
+
return /* @__PURE__ */ l(u.Root, {
|
|
53
71
|
open: I && !q,
|
|
54
72
|
onOpenChange: J,
|
|
55
73
|
children: [
|
|
56
|
-
/* @__PURE__ */
|
|
74
|
+
/* @__PURE__ */ c(u.Anchor, {
|
|
57
75
|
asChild: !0,
|
|
58
|
-
children: /* @__PURE__ */
|
|
59
|
-
className: `ui-date-input${I ? " open" : ""}${
|
|
60
|
-
children: [/* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ l("span", {
|
|
77
|
+
className: `ui-date-input${I ? " open" : ""}${_ ? ` ${_}` : ""}`,
|
|
78
|
+
children: [/* @__PURE__ */ c("input", {
|
|
61
79
|
...k,
|
|
62
80
|
ref: xe,
|
|
63
|
-
className:
|
|
81
|
+
className: g,
|
|
64
82
|
type: "text",
|
|
65
83
|
inputMode: pe,
|
|
66
84
|
autoComplete: me,
|
|
67
|
-
disabled:
|
|
68
|
-
readOnly:
|
|
69
|
-
required:
|
|
85
|
+
disabled: v,
|
|
86
|
+
readOnly: y,
|
|
87
|
+
required: C,
|
|
70
88
|
value: R,
|
|
71
89
|
placeholder: k.placeholder ?? "YYYY/MM/DD",
|
|
72
90
|
"aria-haspopup": "dialog",
|
|
@@ -75,18 +93,18 @@ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChan
|
|
|
75
93
|
"aria-invalid": B ? !0 : k["aria-invalid"],
|
|
76
94
|
"aria-describedby": [k["aria-describedby"], B ? `${j}-error` : ""].filter(Boolean).join(" ") || void 0,
|
|
77
95
|
onFocus: (e) => {
|
|
78
|
-
|
|
96
|
+
he?.(e), !e.defaultPrevented && !N.current && J(!0);
|
|
79
97
|
},
|
|
80
98
|
onChange: (e) => {
|
|
81
99
|
z(e.target.value), B && X("");
|
|
82
100
|
},
|
|
83
101
|
onBlur: (e) => {
|
|
84
|
-
Z(),
|
|
102
|
+
Z(), ge?.(e);
|
|
85
103
|
},
|
|
86
104
|
onKeyDown: (e) => {
|
|
87
|
-
|
|
105
|
+
_e?.(e), !(e.defaultPrevented || e.nativeEvent.isComposing || e.keyCode === 229 || q) && (e.key === "ArrowDown" && (e.preventDefault(), P.current = !0, J(!0), I && document.getElementById(j)?.querySelector("[role=\"gridcell\"] [tabindex=\"0\"]")?.focus()), e.key === "Enter" && (e.preventDefault(), Z()));
|
|
88
106
|
}
|
|
89
|
-
}), /* @__PURE__ */
|
|
107
|
+
}), /* @__PURE__ */ c("button", {
|
|
90
108
|
type: "button",
|
|
91
109
|
className: "ui-date-trigger",
|
|
92
110
|
disabled: q,
|
|
@@ -96,22 +114,22 @@ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChan
|
|
|
96
114
|
onClick: () => {
|
|
97
115
|
P.current = !0, J(!I);
|
|
98
116
|
},
|
|
99
|
-
children: /* @__PURE__ */
|
|
117
|
+
children: /* @__PURE__ */ c(ee, {
|
|
100
118
|
size: 17,
|
|
101
119
|
"aria-hidden": "true"
|
|
102
120
|
})
|
|
103
121
|
})]
|
|
104
122
|
})
|
|
105
123
|
}),
|
|
106
|
-
B && /* @__PURE__ */
|
|
124
|
+
B && /* @__PURE__ */ c("span", {
|
|
107
125
|
id: `${j}-error`,
|
|
108
126
|
className: "ui-form-error",
|
|
109
127
|
role: "alert",
|
|
110
128
|
children: B
|
|
111
129
|
}),
|
|
112
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ c(u.Portal, {
|
|
113
131
|
container: be,
|
|
114
|
-
children: /* @__PURE__ */
|
|
132
|
+
children: /* @__PURE__ */ l(u.Content, {
|
|
115
133
|
id: j,
|
|
116
134
|
className: "ui-date-calendar",
|
|
117
135
|
"aria-label": "选择日期",
|
|
@@ -129,9 +147,9 @@ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChan
|
|
|
129
147
|
onInteractOutside: (e) => {
|
|
130
148
|
M.current?.parentElement?.contains(e.target) && e.preventDefault();
|
|
131
149
|
},
|
|
132
|
-
children: [/* @__PURE__ */
|
|
150
|
+
children: [/* @__PURE__ */ c(de, {
|
|
133
151
|
locale: "zh-CN",
|
|
134
|
-
children: /* @__PURE__ */
|
|
152
|
+
children: /* @__PURE__ */ l(ie, {
|
|
135
153
|
"aria-label": "选择日期",
|
|
136
154
|
value: H,
|
|
137
155
|
onChange: (e) => Q(e.toString()),
|
|
@@ -141,49 +159,49 @@ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChan
|
|
|
141
159
|
focusedValue: G,
|
|
142
160
|
onFocusChange: (e) => K(new fe(e.year, e.month, e.day)),
|
|
143
161
|
children: [
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
/* @__PURE__ */
|
|
162
|
+
/* @__PURE__ */ l("header", { children: [
|
|
163
|
+
/* @__PURE__ */ c(d, {
|
|
146
164
|
slot: "previous",
|
|
147
165
|
"aria-label": "上个月",
|
|
148
|
-
children: /* @__PURE__ */
|
|
166
|
+
children: /* @__PURE__ */ c(te, { size: 18 })
|
|
149
167
|
}),
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
/* @__PURE__ */
|
|
168
|
+
/* @__PURE__ */ c(ue, {}),
|
|
169
|
+
/* @__PURE__ */ c(d, {
|
|
152
170
|
slot: "next",
|
|
153
171
|
"aria-label": "下个月",
|
|
154
|
-
children: /* @__PURE__ */
|
|
172
|
+
children: /* @__PURE__ */ c(ne, { size: 18 })
|
|
155
173
|
})
|
|
156
174
|
] }),
|
|
157
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ l("label", {
|
|
158
176
|
className: "ui-date-month-jump",
|
|
159
|
-
children: ["跳转年月", /* @__PURE__ */
|
|
177
|
+
children: ["跳转年月", /* @__PURE__ */ c("input", {
|
|
160
178
|
type: "month",
|
|
161
179
|
"aria-label": "跳转年月",
|
|
162
180
|
value: `${G.year.toString().padStart(4, "0")}-${String(G.month).padStart(2, "0")}`,
|
|
163
181
|
min: U?.toString().slice(0, 7),
|
|
164
182
|
max: W?.toString().slice(0, 7),
|
|
165
183
|
onChange: (e) => {
|
|
166
|
-
let t =
|
|
184
|
+
let t = x(`${e.target.value}-01`);
|
|
167
185
|
t && K(U && t.compare(U) < 0 ? U : W && t.compare(W) > 0 ? W : t);
|
|
168
186
|
}
|
|
169
187
|
})]
|
|
170
188
|
}),
|
|
171
|
-
/* @__PURE__ */
|
|
189
|
+
/* @__PURE__ */ l(oe, {
|
|
172
190
|
className: "ui-aria-calendar-grid",
|
|
173
|
-
children: [/* @__PURE__ */
|
|
191
|
+
children: [/* @__PURE__ */ c(ce, { children: (e) => /* @__PURE__ */ c(le, { children: e }) }), /* @__PURE__ */ c(se, { children: (e) => /* @__PURE__ */ c(ae, {
|
|
174
192
|
date: e,
|
|
175
193
|
"data-date": e.toString()
|
|
176
194
|
}) })]
|
|
177
195
|
})
|
|
178
196
|
]
|
|
179
197
|
})
|
|
180
|
-
}), /* @__PURE__ */
|
|
198
|
+
}), /* @__PURE__ */ l("footer", { children: [/* @__PURE__ */ l("button", {
|
|
181
199
|
type: "button",
|
|
182
200
|
className: "ui-date-clear",
|
|
183
|
-
disabled: !t ||
|
|
201
|
+
disabled: !t || C,
|
|
184
202
|
onClick: () => Q(""),
|
|
185
|
-
children: [/* @__PURE__ */
|
|
186
|
-
}), /* @__PURE__ */
|
|
203
|
+
children: [/* @__PURE__ */ c(re, { size: 14 }), "清除"]
|
|
204
|
+
}), /* @__PURE__ */ c("button", {
|
|
187
205
|
type: "button",
|
|
188
206
|
className: "ui-date-today",
|
|
189
207
|
disabled: !!Y($),
|
|
@@ -195,29 +213,29 @@ var m = "jc-business-ui-date-input-open", h = t(function({ value: t, onValueChan
|
|
|
195
213
|
]
|
|
196
214
|
});
|
|
197
215
|
});
|
|
198
|
-
function
|
|
216
|
+
function b(e) {
|
|
199
217
|
return /^\d{4}-\d{2}-\d{2}$/.test(e) ? e.replaceAll("-", "/") : e;
|
|
200
218
|
}
|
|
201
|
-
function
|
|
202
|
-
let t =
|
|
203
|
-
return t ?
|
|
219
|
+
function x(e) {
|
|
220
|
+
let t = S(e);
|
|
221
|
+
return t ? p(t) : null;
|
|
204
222
|
}
|
|
205
|
-
function
|
|
223
|
+
function S(e) {
|
|
206
224
|
let t = e.trim().match(/^(\d{4})[/.\-](\d{1,2})[/.\-](\d{1,2})$/);
|
|
207
225
|
if (!t || Number(t[1]) < 1) return null;
|
|
208
226
|
let n = `${t[1]}-${t[2].padStart(2, "0")}-${t[3].padStart(2, "0")}`;
|
|
209
227
|
try {
|
|
210
|
-
return
|
|
228
|
+
return p(n).toString();
|
|
211
229
|
} catch {
|
|
212
230
|
return null;
|
|
213
231
|
}
|
|
214
232
|
}
|
|
215
|
-
function
|
|
233
|
+
function C(e, t) {
|
|
216
234
|
let n = new Date(e, t, 1), r = new Date(e, t, 1 - n.getDay());
|
|
217
235
|
return Array.from({ length: 42 }, (e, t) => ({ date: new Date(r.getFullYear(), r.getMonth(), r.getDate() + t) }));
|
|
218
236
|
}
|
|
219
|
-
function
|
|
237
|
+
function w(e, t) {
|
|
220
238
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
221
239
|
}
|
|
222
240
|
//#endregion
|
|
223
|
-
export {
|
|
241
|
+
export { v as DateInput, C as calendarDays, S as parseDate };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { RecoverableAsyncState as e } from "./RecoverableAsyncState.js";
|
|
2
|
+
import { initialWheelDate as t, wheelBounds as n } from "./date-wheel-model.js";
|
|
3
|
+
import { Component as r, Suspense as i, lazy as a, useEffect as o, useState as s } from "react";
|
|
4
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
5
|
+
//#region src/DateWheelPicker.tsx
|
|
6
|
+
var l = () => a(() => import("./AntDateWheelView.js"));
|
|
7
|
+
function u(e) {
|
|
8
|
+
let [{ View: r, attempt: a }, o] = s(() => ({
|
|
9
|
+
View: l(),
|
|
10
|
+
attempt: 0
|
|
11
|
+
})), u = n(e.minDate, e.maxDate);
|
|
12
|
+
return u ? /* @__PURE__ */ c(d, {
|
|
13
|
+
onError: () => e.onPendingChange?.(!0),
|
|
14
|
+
onRetry: () => o({
|
|
15
|
+
View: l(),
|
|
16
|
+
attempt: a + 1
|
|
17
|
+
}),
|
|
18
|
+
children: /* @__PURE__ */ c(i, {
|
|
19
|
+
fallback: /* @__PURE__ */ c(f, { onPendingChange: e.onPendingChange }),
|
|
20
|
+
children: /* @__PURE__ */ c(r, {
|
|
21
|
+
...e,
|
|
22
|
+
date: t(e.value, e.minDate, e.maxDate),
|
|
23
|
+
bounds: u
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}, a) : /* @__PURE__ */ c("p", {
|
|
27
|
+
role: "alert",
|
|
28
|
+
className: "ui-form-error",
|
|
29
|
+
children: "日期范围无效"
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
var d = class extends r {
|
|
33
|
+
state = { failed: !1 };
|
|
34
|
+
static getDerivedStateFromError() {
|
|
35
|
+
return { failed: !0 };
|
|
36
|
+
}
|
|
37
|
+
componentDidCatch() {
|
|
38
|
+
this.props.onError();
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
return this.state.failed ? /* @__PURE__ */ c(e, {
|
|
42
|
+
phase: "error",
|
|
43
|
+
loadingTitle: "加载日期选择器",
|
|
44
|
+
errorTitle: "日期选择器加载失败",
|
|
45
|
+
onRetry: this.props.onRetry
|
|
46
|
+
}) : this.props.children;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
function f({ onPendingChange: e }) {
|
|
50
|
+
return o(() => {
|
|
51
|
+
e?.(!0);
|
|
52
|
+
}, [e]), /* @__PURE__ */ c("p", {
|
|
53
|
+
role: "status",
|
|
54
|
+
children: "正在加载日期选择器…"
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { u as DateWheelPicker };
|