@vavt/react-ui 1.0.0 → 1.0.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/README.md +50 -2
- package/dist/Card-BkZhLXQ5.cjs +1 -0
- package/dist/{Card-DlztNV-6.js → Card-DCLfLn1x.js} +13 -12
- package/dist/Cron-3D9GmlYf.cjs +1 -0
- package/dist/{Cron-Di7k2FTL.js → Cron-Go4yIqrd.js} +361 -353
- package/dist/{DatePicker-M-MwejjV.js → DatePicker-B-F5q_s_.js} +1 -1
- package/dist/{DatePicker-DAxv2h-d.cjs → DatePicker-CoHW85qm.cjs} +1 -1
- package/dist/{DateTimePicker-BcT3FtN-.js → DateTimePicker-BSBZZ7xV.js} +1 -1
- package/dist/{DateTimePicker-B3C3v99L.cjs → DateTimePicker-CAkdoY--.cjs} +1 -1
- package/dist/Divider-BXNZyvHY.js +48 -0
- package/dist/Divider-BnmUNmy2.cjs +1 -0
- package/dist/Drawer-C0toQ-fQ.js +112 -0
- package/dist/Drawer-D45miZ27.cjs +1 -0
- package/dist/Dropdown-BsXYVdt6.cjs +1 -0
- package/dist/Dropdown-DljKFnvO.js +319 -0
- package/dist/Empty-Dny96c3p.cjs +1 -0
- package/dist/Empty-MmxZitR8.js +40 -0
- package/dist/{MessageBox-CrIifoig.js → MessageBox-B4Qo1vs2.js} +1 -1
- package/dist/{MessageBox-Ddn-R2MS.cjs → MessageBox-CTJfdU29.cjs} +1 -1
- package/dist/Modal-i_Do8GsG.cjs +1 -0
- package/dist/Modal-otJ_9ldu.js +210 -0
- package/dist/{Pagination-B7a9v6BU.js → Pagination-CSI5IzQB.js} +32 -33
- package/dist/Pagination-ODU-i3gn.cjs +1 -0
- package/dist/Select-BRKxpX-_.cjs +1 -0
- package/dist/Select-QedbJ4pD.js +468 -0
- package/dist/{Table-C8cSyts5.js → Table-B9NTkptC.js} +1 -1
- package/dist/{Table-JoJ9vpu-.cjs → Table-Bqjey5fw.cjs} +1 -1
- package/dist/TimePicker-CHZsr_jj.js +207 -0
- package/dist/TimePicker-Cpmvn8tx.cjs +1 -0
- package/dist/Tooltip-Buk5F9f_.js +205 -0
- package/dist/Tooltip-CP8rpNYG.cjs +1 -0
- package/dist/Upload-DZC_bt6G.js +183 -0
- package/dist/Upload-bxJz2avf.cjs +1 -0
- package/dist/base.css +1 -1
- package/dist/cjs/Card.cjs +1 -1
- package/dist/cjs/Cron.cjs +1 -1
- package/dist/cjs/DatePicker.cjs +1 -1
- package/dist/cjs/DateTimePicker.cjs +1 -1
- package/dist/cjs/Divider.cjs +1 -1
- package/dist/cjs/Drawer.cjs +1 -1
- package/dist/cjs/Dropdown.cjs +1 -1
- package/dist/cjs/Empty.cjs +1 -0
- package/dist/cjs/MessageBox.cjs +1 -1
- package/dist/cjs/Modal.cjs +1 -1
- package/dist/cjs/Pagination.cjs +1 -1
- package/dist/cjs/Select.cjs +1 -1
- package/dist/cjs/Table.cjs +1 -1
- package/dist/cjs/TimePicker.cjs +1 -1
- package/dist/cjs/Tooltip.cjs +1 -1
- package/dist/cjs/Upload.cjs +1 -0
- package/dist/cjs/global.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/register.cjs +1 -1
- package/dist/content-DCGQZQp8.cjs +1 -0
- package/dist/content-Dllrr-7G.js +11 -0
- package/dist/css/Button.css +1 -1
- package/dist/css/DateTimePicker.css +1 -1
- package/dist/css/Empty.css +1 -0
- package/dist/css/Pagination.css +1 -1
- package/dist/css/Upload.css +1 -0
- package/dist/date-picker-BsiNrLZC.js +592 -0
- package/dist/date-picker-DNN0BiRA.cjs +1 -0
- package/dist/es/Card.mjs +1 -1
- package/dist/es/Cron.mjs +1 -1
- package/dist/es/DatePicker.mjs +1 -1
- package/dist/es/DateTimePicker.mjs +1 -1
- package/dist/es/Divider.mjs +1 -1
- package/dist/es/Drawer.mjs +1 -1
- package/dist/es/Dropdown.mjs +1 -1
- package/dist/es/Empty.mjs +3 -0
- package/dist/es/MessageBox.mjs +1 -1
- package/dist/es/Modal.mjs +1 -1
- package/dist/es/Pagination.mjs +1 -1
- package/dist/es/Select.mjs +1 -1
- package/dist/es/Table.mjs +1 -1
- package/dist/es/TimePicker.mjs +1 -1
- package/dist/es/Tooltip.mjs +1 -1
- package/dist/es/Upload.mjs +3 -0
- package/dist/es/global.mjs +1 -1
- package/dist/es/index.mjs +31 -29
- package/dist/es/register.mjs +1 -1
- package/dist/index.css +1 -1
- package/dist/layer-BgiUZy_t.cjs +1 -0
- package/dist/layer-DDm97-sb.js +53 -0
- package/dist/registry-BGNWNSiC.cjs +1 -0
- package/dist/registry-q6UdMOyj.js +83 -0
- package/dist/style/Empty.cjs +7 -0
- package/dist/style/Empty.mjs +7 -0
- package/dist/style/Pagination.cjs +1 -0
- package/dist/style/Pagination.mjs +1 -0
- package/dist/style/Upload.cjs +7 -0
- package/dist/style/Upload.mjs +7 -0
- package/dist/types/Cron/type.d.cts +2 -0
- package/dist/types/Cron/type.d.ts +2 -0
- package/dist/types/DatePicker/type.d.cts +2 -0
- package/dist/types/DatePicker/type.d.ts +2 -0
- package/dist/types/Dropdown/type.d.cts +2 -0
- package/dist/types/Dropdown/type.d.ts +2 -0
- package/dist/types/Empty/Empty.d.cts +3 -0
- package/dist/types/Empty/Empty.d.ts +3 -0
- package/dist/types/Empty/index.d.cts +5 -0
- package/dist/types/Empty/index.d.ts +5 -0
- package/dist/types/Empty/type.d.cts +24 -0
- package/dist/types/Empty/type.d.ts +24 -0
- package/dist/types/Select/type.d.cts +2 -0
- package/dist/types/Select/type.d.ts +2 -0
- package/dist/types/TimePicker/type.d.cts +2 -0
- package/dist/types/TimePicker/type.d.ts +2 -0
- package/dist/types/Tooltip/type.d.cts +2 -0
- package/dist/types/Tooltip/type.d.ts +2 -0
- package/dist/types/Upload/Upload.d.cts +3 -0
- package/dist/types/Upload/Upload.d.ts +3 -0
- package/dist/types/Upload/index.d.cts +5 -0
- package/dist/types/Upload/index.d.ts +5 -0
- package/dist/types/Upload/type.d.cts +62 -0
- package/dist/types/Upload/type.d.ts +62 -0
- package/dist/types/_shared/content.d.cts +13 -0
- package/dist/types/_shared/content.d.ts +13 -0
- package/dist/types/_shared/layer.d.cts +63 -0
- package/dist/types/_shared/layer.d.ts +63 -0
- package/dist/types/global.d.cts +4 -0
- package/dist/types/global.d.ts +4 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/registry.d.cts +2 -0
- package/dist/types/registry.d.ts +2 -0
- package/package.json +2 -4
- package/dist/Card-nILlh9c_.cjs +0 -1
- package/dist/Cron-CoO2Vnnm.cjs +0 -1
- package/dist/Divider-BfvQ6BVP.cjs +0 -1
- package/dist/Divider-vyftxh3F.js +0 -47
- package/dist/Drawer-D28QbyA3.js +0 -103
- package/dist/Drawer-OmMfdgKN.cjs +0 -1
- package/dist/Dropdown-CYx6RxVv.js +0 -311
- package/dist/Dropdown-swfND4yK.cjs +0 -1
- package/dist/Modal-B_VqN16m.js +0 -201
- package/dist/Modal-Dm48HmGu.cjs +0 -1
- package/dist/Pagination-mj-pO6ql.cjs +0 -1
- package/dist/Select-DQLup8Y-.cjs +0 -1
- package/dist/Select-DccM9YpB.js +0 -458
- package/dist/TimePicker-ClQCHa6M.js +0 -199
- package/dist/TimePicker-DNBo2Rn5.cjs +0 -1
- package/dist/Tooltip-CbPYYr6R.cjs +0 -1
- package/dist/Tooltip-Ds4Odm7K.js +0 -197
- package/dist/date-picker-DkRwNu2m.js +0 -584
- package/dist/date-picker-DyGLrw5H.cjs +0 -1
- package/dist/registry-CkiH1x-J.js +0 -79
- package/dist/registry-YCz7D-2R.cjs +0 -1
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
import { t as e } from "./effect-nifYL_rH.js";
|
|
2
|
+
import { n as t, t as n } from "./state-oH-YwB7_.js";
|
|
3
|
+
import { t as r } from "./client-pj_wzx28.js";
|
|
4
|
+
import { n as i } from "./refs-D5IYOBaf.js";
|
|
5
|
+
import { r as ee, t as a } from "./floating-DBAmeQIq.js";
|
|
6
|
+
import { t as o } from "./id-CHixuHb7.js";
|
|
7
|
+
import { n as s, r as te, t as ne } from "./layer-DDm97-sb.js";
|
|
8
|
+
import { t as re } from "./Transition-DiO4GsP3.js";
|
|
9
|
+
import { t as ie } from "./Input-CIB_TY2n.js";
|
|
10
|
+
import { _ as ae, a as oe, b as se, c, d as l, f as ce, g as u, h as le, i as ue, l as d, m as f, n as de, p, r as fe, s as m, t as pe, u as h, y as me } from "./time-wheel-BtvYZI6H.js";
|
|
11
|
+
import { t as he } from "./Dropdown-DljKFnvO.js";
|
|
12
|
+
import { CalendarDays as ge, ChevronLeft as _e, ChevronRight as ve, ChevronsLeft as ye, ChevronsRight as be, Clock3 as xe, X as Se } from "lucide-react";
|
|
13
|
+
import { forwardRef as Ce, useCallback as g, useEffect as we, useMemo as Te, useRef as Ee, useState as _ } from "react";
|
|
14
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
15
|
+
import { createPortal as De } from "react-dom";
|
|
16
|
+
//#region components/_shared/date-picker.tsx
|
|
17
|
+
var Oe = "data-vl-date-picker-popup-owner", ke = [
|
|
18
|
+
"日",
|
|
19
|
+
"一",
|
|
20
|
+
"二",
|
|
21
|
+
"三",
|
|
22
|
+
"四",
|
|
23
|
+
"五",
|
|
24
|
+
"六"
|
|
25
|
+
], b = [
|
|
26
|
+
"一月",
|
|
27
|
+
"二月",
|
|
28
|
+
"三月",
|
|
29
|
+
"四月",
|
|
30
|
+
"五月",
|
|
31
|
+
"六月",
|
|
32
|
+
"七月",
|
|
33
|
+
"八月",
|
|
34
|
+
"九月",
|
|
35
|
+
"十月",
|
|
36
|
+
"十一月",
|
|
37
|
+
"十二月"
|
|
38
|
+
], x = (e) => Array.isArray(e) && e.length === 2, S = (e, t) => se(e, t), Ae = (e, t) => {
|
|
39
|
+
if (x(e)) {
|
|
40
|
+
let n = S(e[0], t), r = S(e[1], t);
|
|
41
|
+
return n && r ? `${l(n, t)} ~ ${l(r, t)}` : "";
|
|
42
|
+
}
|
|
43
|
+
let n = S(e, t);
|
|
44
|
+
return n ? l(n, t) : "";
|
|
45
|
+
}, je = (e) => [e[0] ? d(e[0]) : null, e[1] ? d(e[1]) : null], Me = (e) => `${e.getFullYear()}年 ${b[e.getMonth()]}`, Ne = (e, t) => t ? d(e) : u(e), Pe = (e, t, n) => {
|
|
46
|
+
let r = (e) => {
|
|
47
|
+
let t = S(e, n);
|
|
48
|
+
return t ? t.getTime() : null;
|
|
49
|
+
};
|
|
50
|
+
return x(e) || x(t) ? !x(e) || !x(t) ? !1 : r(e[0]) === r(t[0]) && r(e[1]) === r(t[1]) : r(e) === r(t);
|
|
51
|
+
}, C = Ce((se, Ce) => {
|
|
52
|
+
let { componentName: b, withTime: C = !1, value: Fe, defaultValue: Ie, valueType: Le = "date", format: w = C ? "YYYY-MM-DD HH:mm:ss" : "YYYY-MM-DD", range: T = !1, shortcuts: Re = [], minDate: ze, maxDate: Be, disabledDate: Ve, minTime: He, maxTime: Ue, disabledTime: We, placeholder: Ge = T ? "请选择日期范围" : C ? "请选择日期时间" : "请选择日期", disabled: E = !1, clearable: Ke = !1, size: qe = "md", placement: D = "bottom-start", offset: Je = 8, zIndex: Ye, className: Xe, style: Ze, id: Qe, "aria-label": $e, "aria-labelledby": et, "aria-describedby": tt, onChange: nt, onClear: rt, onOpen: it, onClose: at, ...ot } = se, O = nt, st = Ee(null), k = Ee(null), A = Ee(null), ct = Ee(null), lt = r(), ut = te({
|
|
53
|
+
defaultZIndex: s.popover,
|
|
54
|
+
zIndex: Ye
|
|
55
|
+
}), dt = n(se, "value"), [j, M] = t({
|
|
56
|
+
value: Fe ?? null,
|
|
57
|
+
defaultValue: Ie ?? null,
|
|
58
|
+
controlled: dt
|
|
59
|
+
}), [N, ft] = _(!1), [pt, P] = _(() => {
|
|
60
|
+
let e = x(j) ? S(j[0], w) : S(j, w);
|
|
61
|
+
return ae(e ?? /* @__PURE__ */ new Date());
|
|
62
|
+
}), [F, mt] = _(null), [I, L] = _([null, null]), [R, z] = _("start"), [ht, gt] = _(!1), [B, _t] = _(null), [vt, yt] = _({}), [bt, xt] = _(D), [St, Ct] = _(!1), [wt, V] = _(null), Tt = o(`vl-${b}-control`, Qe), H = o(`vl-${b}-panel`), Et = Te(() => i(st, Ce), [Ce]), U = g(() => {
|
|
63
|
+
gt(!1), _t(null);
|
|
64
|
+
}, []), Dt = Te(() => T ? x(j) ? [S(j[0], w), S(j[1], w)] : [null, null] : Array.isArray(j) ? null : S(j, w), [
|
|
65
|
+
w,
|
|
66
|
+
T,
|
|
67
|
+
j
|
|
68
|
+
]), Ot = T ? Dt : null, W = T ? null : Dt, kt = Ae(j, w), At = pt, jt = c(pt, 1), G = S(ze, w), K = S(Be, w), Mt = He ? me(He) : null, Nt = Ue ? me(Ue) : null, Pt = Te(() => ({
|
|
69
|
+
minSeconds: Mt,
|
|
70
|
+
maxSeconds: Nt,
|
|
71
|
+
disabledTime: We
|
|
72
|
+
}), [
|
|
73
|
+
We,
|
|
74
|
+
Nt,
|
|
75
|
+
Mt
|
|
76
|
+
]), q = g((e) => {
|
|
77
|
+
let t = u(e);
|
|
78
|
+
return !!(G && h(t, u(G)) < 0 || K && h(t, u(K)) > 0 || Ve?.(t));
|
|
79
|
+
}, [
|
|
80
|
+
Ve,
|
|
81
|
+
K,
|
|
82
|
+
G
|
|
83
|
+
]), J = g((e) => ue(e, Pt), [Pt]), Ft = g((e, t, n) => de(e, t, n, Pt), [Pt]), It = g((e) => C && J(l(e, "HH:mm:ss")), [J, C]), Y = g((e) => {
|
|
84
|
+
if (!(e && (E || N)) && !(!e && !N)) {
|
|
85
|
+
if (e) {
|
|
86
|
+
let e = (T ? Ot?.[0] : W) ?? /* @__PURE__ */ new Date();
|
|
87
|
+
P(ae(e)), T ? L(je(Ot ?? [null, null])) : mt(W ? d(W) : null), z("start"), Ct(!1), yt({}), xt(D), V(null), U(), ft(!0), it?.();
|
|
88
|
+
} else V(null), U(), ft(!1), at?.();
|
|
89
|
+
}
|
|
90
|
+
}, [
|
|
91
|
+
E,
|
|
92
|
+
at,
|
|
93
|
+
it,
|
|
94
|
+
N,
|
|
95
|
+
D,
|
|
96
|
+
T,
|
|
97
|
+
U,
|
|
98
|
+
W,
|
|
99
|
+
Ot
|
|
100
|
+
]), Lt = g(() => {
|
|
101
|
+
if (!N || !k.current || !A.current) return;
|
|
102
|
+
let e = k.current.getBoundingClientRect(), t = a({
|
|
103
|
+
anchorRect: e,
|
|
104
|
+
floatingRect: A.current.getBoundingClientRect(),
|
|
105
|
+
placement: D,
|
|
106
|
+
offset: Je
|
|
107
|
+
});
|
|
108
|
+
xt(t.placement), yt({
|
|
109
|
+
left: `${Math.round(t.x)}px`,
|
|
110
|
+
top: `${Math.round(t.y)}px`
|
|
111
|
+
}), Ct(!0);
|
|
112
|
+
}, [
|
|
113
|
+
Je,
|
|
114
|
+
N,
|
|
115
|
+
D
|
|
116
|
+
]);
|
|
117
|
+
e(() => {
|
|
118
|
+
if (!N || !lt) return;
|
|
119
|
+
Lt();
|
|
120
|
+
let e = window.requestAnimationFrame(Lt);
|
|
121
|
+
return () => window.cancelAnimationFrame(e);
|
|
122
|
+
}, [
|
|
123
|
+
lt,
|
|
124
|
+
N,
|
|
125
|
+
Lt
|
|
126
|
+
]), e(() => {
|
|
127
|
+
if (!N || !wt) return;
|
|
128
|
+
let e = A.current?.querySelector(`[data-time="${wt.getTime()}"]:not(:disabled)`);
|
|
129
|
+
e && (e.focus(), V(null));
|
|
130
|
+
}, [
|
|
131
|
+
pt,
|
|
132
|
+
wt,
|
|
133
|
+
N
|
|
134
|
+
]);
|
|
135
|
+
let Rt = g((e) => e.some((e) => e instanceof HTMLElement && (e.getAttribute(Oe) === H || e.classList.contains("vl-dropdown__panel") && e.querySelector(`[${Oe}]`)?.getAttribute(Oe) === H)), [H]), zt = g(() => Y(!1), [Y]), Bt = g(() => {
|
|
136
|
+
ht || (Y(!1), k.current?.focus());
|
|
137
|
+
}, [Y, ht]);
|
|
138
|
+
ee({
|
|
139
|
+
active: N,
|
|
140
|
+
rootRef: st,
|
|
141
|
+
floatingRef: A,
|
|
142
|
+
isOwnedPopup: Rt,
|
|
143
|
+
onOutsideClick: zt,
|
|
144
|
+
onEscape: Bt,
|
|
145
|
+
onViewportChange: Lt
|
|
146
|
+
}), we(() => {
|
|
147
|
+
E && N && Y(!1);
|
|
148
|
+
}, [
|
|
149
|
+
E,
|
|
150
|
+
N,
|
|
151
|
+
Y
|
|
152
|
+
]);
|
|
153
|
+
let X = g((e) => Le === "string" ? l(e, w) : d(e), [w, Le]), Vt = g((e) => {
|
|
154
|
+
let t = Ne(e, C);
|
|
155
|
+
if (q(t) || C && J(l(t, "HH:mm:ss"))) return;
|
|
156
|
+
let n = X(t);
|
|
157
|
+
Pe(j, n, w) || (M(n), O?.(n)), Y(!1), k.current?.focus();
|
|
158
|
+
}, [
|
|
159
|
+
O,
|
|
160
|
+
w,
|
|
161
|
+
q,
|
|
162
|
+
J,
|
|
163
|
+
X,
|
|
164
|
+
j,
|
|
165
|
+
Y,
|
|
166
|
+
M,
|
|
167
|
+
C
|
|
168
|
+
]), Ht = g((e) => {
|
|
169
|
+
if (!e[0] || !e[1]) return;
|
|
170
|
+
let t = h(e[0], e[1]) <= 0 ? e : [e[1], e[0]], n = Ne(t[0], C), r = Ne(t[1], C);
|
|
171
|
+
if (q(n) || q(r) || C && (J(l(n, "HH:mm:ss")) || J(l(r, "HH:mm:ss")))) return;
|
|
172
|
+
let i = [X(n), X(r)];
|
|
173
|
+
Pe(j, i, w) || (M(i), O?.(i)), Y(!1), k.current?.focus();
|
|
174
|
+
}, [
|
|
175
|
+
O,
|
|
176
|
+
w,
|
|
177
|
+
q,
|
|
178
|
+
J,
|
|
179
|
+
X,
|
|
180
|
+
j,
|
|
181
|
+
Y,
|
|
182
|
+
M,
|
|
183
|
+
C
|
|
184
|
+
]), Ut = (e) => {
|
|
185
|
+
if (q(e)) return;
|
|
186
|
+
let t = T ? I[R === "start" ? 0 : 1] : F, n = u(e);
|
|
187
|
+
if (C) {
|
|
188
|
+
if (t) n = le(e, t.getHours(), t.getMinutes(), t.getSeconds());
|
|
189
|
+
else {
|
|
190
|
+
let t = Ft(0, 86399, 0);
|
|
191
|
+
n = t === null ? d(e) : le(e, Math.floor(t / 3600), Math.floor(t % 3600 / 60), t % 60);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (!T) {
|
|
195
|
+
mt(n), C || Vt(n);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
let [r, i] = I;
|
|
199
|
+
if (!r || i) {
|
|
200
|
+
L([n, null]), z("start");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
h(n, r) < 0 ? (L([n, r]), z("end")) : (L([r, n]), z("end"));
|
|
204
|
+
}, Z = g((e, t = !1) => {
|
|
205
|
+
if (e && B) {
|
|
206
|
+
if (T) {
|
|
207
|
+
let e = je(I);
|
|
208
|
+
e[R === "start" ? 0 : 1] = d(B), L(e);
|
|
209
|
+
} else mt(d(B));
|
|
210
|
+
}
|
|
211
|
+
U(), t && window.requestAnimationFrame(() => ct.current?.focus());
|
|
212
|
+
}, [
|
|
213
|
+
R,
|
|
214
|
+
I,
|
|
215
|
+
T,
|
|
216
|
+
U,
|
|
217
|
+
B
|
|
218
|
+
]), Wt = (e, t) => {
|
|
219
|
+
let n = B ? d(B) : /* @__PURE__ */ new Date(), r = {
|
|
220
|
+
hours: n.getHours(),
|
|
221
|
+
minutes: n.getMinutes(),
|
|
222
|
+
seconds: n.getSeconds()
|
|
223
|
+
}, { start: i, end: ee, preferred: a } = fe(e, t, r), o = Ft(i, ee, a);
|
|
224
|
+
if (o === null) return;
|
|
225
|
+
let s = le(n, Math.floor(o / 3600), Math.floor(o % 3600 / 60), o % 60);
|
|
226
|
+
_t(s);
|
|
227
|
+
}, Gt = (e) => {
|
|
228
|
+
let t = e.getValue(/* @__PURE__ */ new Date());
|
|
229
|
+
if (t === null) return;
|
|
230
|
+
if (T) {
|
|
231
|
+
if (!x(t)) return;
|
|
232
|
+
let e = S(t[0], w), n = S(t[1], w);
|
|
233
|
+
if (!e || !n || q(e) || q(n) || It(e) || It(n)) return;
|
|
234
|
+
L(h(e, n) <= 0 ? [e, n] : [n, e]), z("end");
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (x(t)) return;
|
|
238
|
+
let n = S(t, w);
|
|
239
|
+
!n || q(n) || It(n) || Vt(n);
|
|
240
|
+
}, Kt = (e) => {
|
|
241
|
+
e?.stopPropagation(), !E && (M(null), O?.(null), rt?.(), mt(null), L([null, null]));
|
|
242
|
+
}, Q = (e, t, n = !1) => {
|
|
243
|
+
let r = n ? u(e) : m(u(e), t);
|
|
244
|
+
for (let e = 0; e < 3660; e += 1) {
|
|
245
|
+
if (t < 0 && G && h(r, u(G)) < 0 || t > 0 && K && h(r, u(K)) > 0) return null;
|
|
246
|
+
if (!q(r)) return r;
|
|
247
|
+
r = m(r, t);
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
}, qt = (e) => {
|
|
251
|
+
if (!E) {
|
|
252
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
253
|
+
if (e.preventDefault(), N) Y(!1);
|
|
254
|
+
else {
|
|
255
|
+
let e = (T ? Ot?.[0] : W) ?? /* @__PURE__ */ new Date(), t = Q(e, 1, !0) ?? Q(e, -1, !0) ?? null;
|
|
256
|
+
Y(!0), t && V(t);
|
|
257
|
+
}
|
|
258
|
+
} else e.key === "Escape" && N && (e.preventDefault(), Y(!1));
|
|
259
|
+
}
|
|
260
|
+
}, Jt = (e) => {
|
|
261
|
+
!f(e, At) && !(T && f(e, jt)) && P(ae(e)), V(u(e));
|
|
262
|
+
}, Yt = (e, t) => {
|
|
263
|
+
let n = null;
|
|
264
|
+
if (e.key === "ArrowLeft") n = Q(t, -1);
|
|
265
|
+
else if (e.key === "ArrowRight") n = Q(t, 1);
|
|
266
|
+
else if (e.key === "ArrowUp") n = Q(t, -7);
|
|
267
|
+
else if (e.key === "ArrowDown") n = Q(t, 7);
|
|
268
|
+
else if (e.key === "Home" || e.key === "End") {
|
|
269
|
+
let r = e.key === "Home" ? m(t, -t.getDay()) : m(t, 6 - t.getDay()), i = e.key === "Home" ? 1 : -1;
|
|
270
|
+
for (let e = 0; e < 7; e += 1) {
|
|
271
|
+
let t = m(r, e * i);
|
|
272
|
+
if (!q(t)) {
|
|
273
|
+
n = t;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
n && (e.preventDefault(), Jt(n));
|
|
279
|
+
}, $ = T ? I[R === "start" ? 0 : 1] : F, Xt = g((e) => {
|
|
280
|
+
if (e) {
|
|
281
|
+
if (!$) return;
|
|
282
|
+
_t(d($)), gt(!0);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
Z(!1);
|
|
286
|
+
}, [$, Z]), Zt = B ?? $ ?? /* @__PURE__ */ new Date(), Qt = Zt.getHours(), $t = Zt.getMinutes(), en = Zt.getSeconds(), tn = $ ? l(Zt, "HH:mm:ss") : "", nn = T ? R === "start" ? "开始时间" : "结束时间" : "时间", rn = g((e, t) => oe(e, t, {
|
|
287
|
+
hours: Qt,
|
|
288
|
+
minutes: $t,
|
|
289
|
+
seconds: en
|
|
290
|
+
}, Ft), [
|
|
291
|
+
Ft,
|
|
292
|
+
Qt,
|
|
293
|
+
$t,
|
|
294
|
+
en
|
|
295
|
+
]), an = T ? !!(I[0] && I[1] && !q(I[0]) && !q(I[1]) && (!C || !J(l(I[0], "HH:mm:ss")) && !J(l(I[1], "HH:mm:ss")))) : !!(F && !q(F) && (!C || !J(l(F, "HH:mm:ss")))), on = !!kt, sn = [
|
|
296
|
+
`vl-${b}`,
|
|
297
|
+
`size-${qe}`,
|
|
298
|
+
N ? "is-open" : "",
|
|
299
|
+
E ? "is-disabled" : "",
|
|
300
|
+
T ? "is-range" : "",
|
|
301
|
+
C ? "has-time" : "",
|
|
302
|
+
Xe || ""
|
|
303
|
+
].filter(Boolean).join(" "), cn = (e) => {
|
|
304
|
+
let t = ce(e), n = T ? I[0] : null, r = T ? I[1] : null, i = T ? null : F ?? W, ee = (T ? [I[0], I[1]] : [i]).find((t) => t && f(t, e) && !q(t)) ?? t.find((t) => f(t, e) && !q(t));
|
|
305
|
+
return /* @__PURE__ */ y("section", {
|
|
306
|
+
className: `vl-${b}__calendar`,
|
|
307
|
+
"aria-label": Me(e),
|
|
308
|
+
children: [
|
|
309
|
+
T ? /* @__PURE__ */ v("div", {
|
|
310
|
+
className: `vl-${b}__month-title`,
|
|
311
|
+
children: Me(e)
|
|
312
|
+
}) : null,
|
|
313
|
+
/* @__PURE__ */ v("div", {
|
|
314
|
+
className: `vl-${b}__weekdays`,
|
|
315
|
+
role: "row",
|
|
316
|
+
children: ke.map((e) => /* @__PURE__ */ v("span", {
|
|
317
|
+
role: "columnheader",
|
|
318
|
+
children: e
|
|
319
|
+
}, e))
|
|
320
|
+
}),
|
|
321
|
+
/* @__PURE__ */ v("div", {
|
|
322
|
+
className: `vl-${b}__grid`,
|
|
323
|
+
role: "grid",
|
|
324
|
+
children: t.map((t) => {
|
|
325
|
+
let a = !f(t, e), o = a || q(t), s = !!(n && r && h(t, u(n)) >= 0 && h(t, u(r)) <= 0), te = [
|
|
326
|
+
`vl-${b}__day`,
|
|
327
|
+
a ? "is-other-month" : "",
|
|
328
|
+
p(t, /* @__PURE__ */ new Date()) ? "is-today" : "",
|
|
329
|
+
T && n && p(t, n) ? "is-range-start is-selected" : "",
|
|
330
|
+
T && r && p(t, r) ? "is-range-end is-selected" : "",
|
|
331
|
+
i && p(t, i) ? "is-selected" : "",
|
|
332
|
+
s ? "is-in-range" : "",
|
|
333
|
+
o ? "is-disabled" : ""
|
|
334
|
+
].filter(Boolean).join(" ");
|
|
335
|
+
return /* @__PURE__ */ v("button", {
|
|
336
|
+
type: "button",
|
|
337
|
+
className: te,
|
|
338
|
+
role: "gridcell",
|
|
339
|
+
"data-time": t.getTime(),
|
|
340
|
+
"aria-label": `${t.getFullYear()}年${t.getMonth() + 1}月${t.getDate()}日`,
|
|
341
|
+
"aria-selected": T ? s : !!(i && p(t, i)),
|
|
342
|
+
"aria-current": p(t, /* @__PURE__ */ new Date()) ? "date" : void 0,
|
|
343
|
+
"aria-hidden": a || void 0,
|
|
344
|
+
"aria-disabled": o || void 0,
|
|
345
|
+
disabled: o,
|
|
346
|
+
tabIndex: !o && ee && p(t, ee) ? 0 : -1,
|
|
347
|
+
onClick: () => Ut(t),
|
|
348
|
+
onKeyDown: (e) => Yt(e, t),
|
|
349
|
+
children: t.getDate()
|
|
350
|
+
}, t.toISOString());
|
|
351
|
+
})
|
|
352
|
+
})
|
|
353
|
+
]
|
|
354
|
+
});
|
|
355
|
+
}, ln = /* @__PURE__ */ v(re, {
|
|
356
|
+
show: N,
|
|
357
|
+
name: `vl-${b}`,
|
|
358
|
+
deferEffects: !lt,
|
|
359
|
+
children: /* @__PURE__ */ y("div", {
|
|
360
|
+
ref: A,
|
|
361
|
+
id: H,
|
|
362
|
+
className: `vl-${b}__panel is-${bt}${St ? " is-positioned" : ""}`,
|
|
363
|
+
style: {
|
|
364
|
+
...vt,
|
|
365
|
+
zIndex: ut.zIndex,
|
|
366
|
+
visibility: St ? "visible" : "hidden"
|
|
367
|
+
},
|
|
368
|
+
role: "dialog",
|
|
369
|
+
"aria-label": T ? "日期范围选择" : C ? "日期时间选择" : "日期选择",
|
|
370
|
+
children: [
|
|
371
|
+
/* @__PURE__ */ y("div", {
|
|
372
|
+
className: `vl-${b}__header`,
|
|
373
|
+
children: [
|
|
374
|
+
/* @__PURE__ */ y("div", {
|
|
375
|
+
className: `vl-${b}__header-actions`,
|
|
376
|
+
children: [/* @__PURE__ */ v("button", {
|
|
377
|
+
type: "button",
|
|
378
|
+
"aria-label": "上一年",
|
|
379
|
+
onClick: () => P((e) => c(e, -12)),
|
|
380
|
+
children: /* @__PURE__ */ v(ye, {
|
|
381
|
+
size: 16,
|
|
382
|
+
"aria-hidden": "true"
|
|
383
|
+
})
|
|
384
|
+
}), /* @__PURE__ */ v("button", {
|
|
385
|
+
type: "button",
|
|
386
|
+
"aria-label": "上一个月",
|
|
387
|
+
onClick: () => P((e) => c(e, -1)),
|
|
388
|
+
children: /* @__PURE__ */ v(_e, {
|
|
389
|
+
size: 16,
|
|
390
|
+
"aria-hidden": "true"
|
|
391
|
+
})
|
|
392
|
+
})]
|
|
393
|
+
}),
|
|
394
|
+
T ? null : /* @__PURE__ */ v("span", { children: Me(At) }),
|
|
395
|
+
/* @__PURE__ */ y("div", {
|
|
396
|
+
className: `vl-${b}__header-actions`,
|
|
397
|
+
children: [/* @__PURE__ */ v("button", {
|
|
398
|
+
type: "button",
|
|
399
|
+
"aria-label": "下一个月",
|
|
400
|
+
onClick: () => P((e) => c(e, 1)),
|
|
401
|
+
children: /* @__PURE__ */ v(ve, {
|
|
402
|
+
size: 16,
|
|
403
|
+
"aria-hidden": "true"
|
|
404
|
+
})
|
|
405
|
+
}), /* @__PURE__ */ v("button", {
|
|
406
|
+
type: "button",
|
|
407
|
+
"aria-label": "下一年",
|
|
408
|
+
onClick: () => P((e) => c(e, 12)),
|
|
409
|
+
children: /* @__PURE__ */ v(be, {
|
|
410
|
+
size: 16,
|
|
411
|
+
"aria-hidden": "true"
|
|
412
|
+
})
|
|
413
|
+
})]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
}),
|
|
417
|
+
/* @__PURE__ */ y("div", {
|
|
418
|
+
className: `vl-${b}__calendars`,
|
|
419
|
+
children: [cn(At), T ? cn(jt) : null]
|
|
420
|
+
}),
|
|
421
|
+
C ? /* @__PURE__ */ v("div", {
|
|
422
|
+
className: `vl-${b}__time`,
|
|
423
|
+
children: /* @__PURE__ */ y("div", {
|
|
424
|
+
className: `vl-${b}__time-toolbar`,
|
|
425
|
+
children: [
|
|
426
|
+
/* @__PURE__ */ v("span", {
|
|
427
|
+
className: `vl-${b}__time-title`,
|
|
428
|
+
children: "时间"
|
|
429
|
+
}),
|
|
430
|
+
T ? /* @__PURE__ */ y("div", {
|
|
431
|
+
className: `vl-${b}__time-range`,
|
|
432
|
+
children: [/* @__PURE__ */ v("button", {
|
|
433
|
+
type: "button",
|
|
434
|
+
className: R === "start" ? "is-active" : "",
|
|
435
|
+
"aria-pressed": R === "start",
|
|
436
|
+
disabled: !I[0],
|
|
437
|
+
onClick: () => {
|
|
438
|
+
Z(!1), z("start");
|
|
439
|
+
},
|
|
440
|
+
children: "开始时间"
|
|
441
|
+
}), /* @__PURE__ */ v("button", {
|
|
442
|
+
type: "button",
|
|
443
|
+
className: R === "end" ? "is-active" : "",
|
|
444
|
+
"aria-pressed": R === "end",
|
|
445
|
+
disabled: !I[1],
|
|
446
|
+
onClick: () => {
|
|
447
|
+
Z(!1), z("end");
|
|
448
|
+
},
|
|
449
|
+
children: "结束时间"
|
|
450
|
+
})]
|
|
451
|
+
}) : null,
|
|
452
|
+
/* @__PURE__ */ v(he, {
|
|
453
|
+
className: `vl-${b}__time-dropdown`,
|
|
454
|
+
open: ht,
|
|
455
|
+
disabled: !$,
|
|
456
|
+
trigger: "click",
|
|
457
|
+
placement: "bottom-end",
|
|
458
|
+
offset: 4,
|
|
459
|
+
closeOnContentClick: !1,
|
|
460
|
+
"aria-label": nn,
|
|
461
|
+
menuLabel: `${nn}选择器`,
|
|
462
|
+
triggerContent: /* @__PURE__ */ v(ie, {
|
|
463
|
+
ref: ct,
|
|
464
|
+
className: `vl-${b}__time-input`,
|
|
465
|
+
value: tn,
|
|
466
|
+
placeholder: "请先选择日期",
|
|
467
|
+
size: "sm",
|
|
468
|
+
suffixIcon: xe,
|
|
469
|
+
readOnly: !0,
|
|
470
|
+
disabled: !$
|
|
471
|
+
}),
|
|
472
|
+
onChange: Xt,
|
|
473
|
+
children: /* @__PURE__ */ y("div", {
|
|
474
|
+
className: `vl-${b}__time-popover`,
|
|
475
|
+
[Oe]: H,
|
|
476
|
+
children: [/* @__PURE__ */ v(pe, {
|
|
477
|
+
value: {
|
|
478
|
+
hours: Qt,
|
|
479
|
+
minutes: $t,
|
|
480
|
+
seconds: en
|
|
481
|
+
},
|
|
482
|
+
disabled: !$,
|
|
483
|
+
ariaLabel: nn,
|
|
484
|
+
visibleItemCount: 3,
|
|
485
|
+
itemHeight: 30,
|
|
486
|
+
isOptionDisabled: rn,
|
|
487
|
+
onChange: Wt
|
|
488
|
+
}), /* @__PURE__ */ y("div", {
|
|
489
|
+
className: `vl-${b}__footer`,
|
|
490
|
+
children: [/* @__PURE__ */ v("button", {
|
|
491
|
+
type: "button",
|
|
492
|
+
className: "is-cancel",
|
|
493
|
+
"aria-label": "取消时间",
|
|
494
|
+
onClick: () => Z(!1, !0),
|
|
495
|
+
children: "取消"
|
|
496
|
+
}), /* @__PURE__ */ v("button", {
|
|
497
|
+
type: "button",
|
|
498
|
+
className: "is-confirm",
|
|
499
|
+
"aria-label": "确定时间",
|
|
500
|
+
disabled: !B,
|
|
501
|
+
onClick: () => Z(!0, !0),
|
|
502
|
+
children: "确定"
|
|
503
|
+
})]
|
|
504
|
+
})]
|
|
505
|
+
})
|
|
506
|
+
})
|
|
507
|
+
]
|
|
508
|
+
})
|
|
509
|
+
}) : null,
|
|
510
|
+
Re.length ? /* @__PURE__ */ v("div", {
|
|
511
|
+
className: `vl-${b}__shortcuts`,
|
|
512
|
+
role: "group",
|
|
513
|
+
"aria-label": "快捷选择",
|
|
514
|
+
children: Re.map((e) => /* @__PURE__ */ v("button", {
|
|
515
|
+
type: "button",
|
|
516
|
+
onClick: () => Gt(e),
|
|
517
|
+
children: e.label
|
|
518
|
+
}, e.label))
|
|
519
|
+
}) : null,
|
|
520
|
+
T || C ? /* @__PURE__ */ y("div", {
|
|
521
|
+
className: `vl-${b}__footer`,
|
|
522
|
+
children: [/* @__PURE__ */ v("button", {
|
|
523
|
+
type: "button",
|
|
524
|
+
className: "is-cancel",
|
|
525
|
+
onClick: () => {
|
|
526
|
+
Y(!1), k.current?.focus();
|
|
527
|
+
},
|
|
528
|
+
children: "取消"
|
|
529
|
+
}), /* @__PURE__ */ v("button", {
|
|
530
|
+
type: "button",
|
|
531
|
+
className: "is-confirm",
|
|
532
|
+
disabled: !an,
|
|
533
|
+
onClick: () => {
|
|
534
|
+
T ? Ht(I) : F && Vt(F);
|
|
535
|
+
},
|
|
536
|
+
children: "确定"
|
|
537
|
+
})]
|
|
538
|
+
}) : null
|
|
539
|
+
]
|
|
540
|
+
})
|
|
541
|
+
});
|
|
542
|
+
return /* @__PURE__ */ v(ne, {
|
|
543
|
+
layer: ut.layer,
|
|
544
|
+
children: /* @__PURE__ */ y("div", {
|
|
545
|
+
ref: Et,
|
|
546
|
+
className: `vl-${b}-wrapper`,
|
|
547
|
+
style: Ze,
|
|
548
|
+
...ot,
|
|
549
|
+
children: [/* @__PURE__ */ y("div", {
|
|
550
|
+
ref: k,
|
|
551
|
+
id: Tt,
|
|
552
|
+
className: sn,
|
|
553
|
+
role: "combobox",
|
|
554
|
+
"aria-expanded": N,
|
|
555
|
+
"aria-controls": H,
|
|
556
|
+
"aria-haspopup": "dialog",
|
|
557
|
+
"aria-disabled": E || void 0,
|
|
558
|
+
"aria-label": $e ?? (et ? void 0 : Ge),
|
|
559
|
+
"aria-labelledby": et,
|
|
560
|
+
"aria-describedby": tt,
|
|
561
|
+
tabIndex: E ? -1 : 0,
|
|
562
|
+
onClick: () => Y(!N),
|
|
563
|
+
onKeyDown: qt,
|
|
564
|
+
children: [
|
|
565
|
+
/* @__PURE__ */ v("span", {
|
|
566
|
+
className: `vl-${b}__icon`,
|
|
567
|
+
"aria-hidden": "true",
|
|
568
|
+
children: /* @__PURE__ */ v(ge, { size: 16 })
|
|
569
|
+
}),
|
|
570
|
+
/* @__PURE__ */ v("span", {
|
|
571
|
+
className: `vl-${b}__value${kt ? "" : " is-placeholder"}`,
|
|
572
|
+
children: kt || Ge
|
|
573
|
+
}),
|
|
574
|
+
Ke && on && !E ? /* @__PURE__ */ v("button", {
|
|
575
|
+
type: "button",
|
|
576
|
+
className: `vl-${b}__clear`,
|
|
577
|
+
"aria-label": "清除已选",
|
|
578
|
+
onClick: Kt,
|
|
579
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
580
|
+
children: /* @__PURE__ */ v(Se, {
|
|
581
|
+
size: 16,
|
|
582
|
+
"aria-hidden": "true"
|
|
583
|
+
})
|
|
584
|
+
}) : null
|
|
585
|
+
]
|
|
586
|
+
}), lt ? De(ln, document.body) : ln]
|
|
587
|
+
})
|
|
588
|
+
});
|
|
589
|
+
});
|
|
590
|
+
C.displayName = "VlDatePickerCore";
|
|
591
|
+
//#endregion
|
|
592
|
+
export { C as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./effect-BpNxm_06.cjs"),t=require("./state-ZBA75xZ_.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./floating-DXRnx48N.cjs"),a=require("./id-CF0zOP1G.cjs"),o=require("./layer-BgiUZy_t.cjs"),s=require("./Transition-X_89ga-e.cjs"),c=require("./Input-CoDZggqc.cjs"),l=require("./time-wheel-BaCcA9nk.cjs"),ee=require("./Dropdown-BsXYVdt6.cjs");let u=require("lucide-react"),d=require("react"),f=require("react/jsx-runtime"),te=require("react-dom");var p=`data-vl-date-picker-popup-owner`,ne=[`日`,`一`,`二`,`三`,`四`,`五`,`六`],re=[`一月`,`二月`,`三月`,`四月`,`五月`,`六月`,`七月`,`八月`,`九月`,`十月`,`十一月`,`十二月`],m=e=>Array.isArray(e)&&e.length===2,h=(e,t)=>l.b(e,t),ie=(e,t)=>{if(m(e)){let n=h(e[0],t),r=h(e[1],t);return n&&r?`${l.d(n,t)} ~ ${l.d(r,t)}`:``}let n=h(e,t);return n?l.d(n,t):``},ae=e=>[e[0]?l.l(e[0]):null,e[1]?l.l(e[1]):null],oe=e=>`${e.getFullYear()}年 ${re[e.getMonth()]}`,se=(e,t)=>t?l.l(e):l.g(e),ce=(e,t,n)=>{let r=e=>{let t=h(e,n);return t?t.getTime():null};return m(e)||m(t)?!m(e)||!m(t)?!1:r(e[0])===r(t[0])&&r(e[1])===r(t[1]):r(e)===r(t)},g=(0,d.forwardRef)((re,g)=>{let{componentName:_,withTime:v=!1,value:le,defaultValue:ue,valueType:de=`date`,format:y=v?`YYYY-MM-DD HH:mm:ss`:`YYYY-MM-DD`,range:b=!1,shortcuts:fe=[],minDate:pe,maxDate:me,disabledDate:he,minTime:ge,maxTime:_e,disabledTime:ve,placeholder:ye=b?`请选择日期范围`:v?`请选择日期时间`:`请选择日期`,disabled:x=!1,clearable:be=!1,size:xe=`md`,placement:S=`bottom-start`,offset:Se=8,zIndex:Ce,className:we,style:Te,id:Ee,"aria-label":De,"aria-labelledby":Oe,"aria-describedby":ke,onChange:Ae,onClear:je,onOpen:Me,onClose:Ne,...Pe}=re,C=Ae,Fe=(0,d.useRef)(null),w=(0,d.useRef)(null),T=(0,d.useRef)(null),Ie=(0,d.useRef)(null),E=n.t(),Le=o.r({defaultZIndex:o.n.popover,zIndex:Ce}),Re=t.t(re,`value`),[D,O]=t.n({value:le??null,defaultValue:ue??null,controlled:Re}),[k,ze]=(0,d.useState)(!1),[Be,A]=(0,d.useState)(()=>{let e=m(D)?h(D[0],y):h(D,y);return l._(e??new Date)}),[j,M]=(0,d.useState)(null),[N,P]=(0,d.useState)([null,null]),[F,I]=(0,d.useState)(`start`),[Ve,He]=(0,d.useState)(!1),[L,Ue]=(0,d.useState)(null),[We,Ge]=(0,d.useState)({}),[Ke,qe]=(0,d.useState)(S),[Je,Ye]=(0,d.useState)(!1),[Xe,R]=(0,d.useState)(null),Ze=a.t(`vl-${_}-control`,Ee),z=a.t(`vl-${_}-panel`),Qe=(0,d.useMemo)(()=>r.n(Fe,g),[g]),B=(0,d.useCallback)(()=>{He(!1),Ue(null)},[]),$e=(0,d.useMemo)(()=>b?m(D)?[h(D[0],y),h(D[1],y)]:[null,null]:Array.isArray(D)?null:h(D,y),[y,b,D]),V=b?$e:null,H=b?null:$e,et=ie(D,y),tt=Be,nt=l.c(Be,1),U=h(pe,y),W=h(me,y),rt=ge?l.y(ge):null,it=_e?l.y(_e):null,G=(0,d.useMemo)(()=>({minSeconds:rt,maxSeconds:it,disabledTime:ve}),[ve,it,rt]),K=(0,d.useCallback)(e=>{let t=l.g(e);return!!(U&&l.u(t,l.g(U))<0||W&&l.u(t,l.g(W))>0||he?.(t))},[he,W,U]),q=(0,d.useCallback)(e=>l.i(e,G),[G]),at=(0,d.useCallback)((e,t,n)=>l.n(e,t,n,G),[G]),ot=(0,d.useCallback)(e=>v&&q(l.d(e,`HH:mm:ss`)),[q,v]),J=(0,d.useCallback)(e=>{if(!(e&&(x||k))&&!(!e&&!k)){if(e){let e=(b?V?.[0]:H)??new Date;A(l._(e)),b?P(ae(V??[null,null])):M(H?l.l(H):null),I(`start`),Ye(!1),Ge({}),qe(S),R(null),B(),ze(!0),Me?.()}else R(null),B(),ze(!1),Ne?.()}},[x,Ne,Me,k,S,b,B,H,V]),st=(0,d.useCallback)(()=>{if(!k||!w.current||!T.current)return;let e=w.current.getBoundingClientRect(),t=i.t({anchorRect:e,floatingRect:T.current.getBoundingClientRect(),placement:S,offset:Se});qe(t.placement),Ge({left:`${Math.round(t.x)}px`,top:`${Math.round(t.y)}px`}),Ye(!0)},[Se,k,S]);e.t(()=>{if(!k||!E)return;st();let e=window.requestAnimationFrame(st);return()=>window.cancelAnimationFrame(e)},[E,k,st]),e.t(()=>{if(!k||!Xe)return;let e=T.current?.querySelector(`[data-time="${Xe.getTime()}"]:not(:disabled)`);e&&(e.focus(),R(null))},[Be,Xe,k]);let ct=(0,d.useCallback)(e=>e.some(e=>e instanceof HTMLElement&&(e.getAttribute(p)===z||e.classList.contains(`vl-dropdown__panel`)&&e.querySelector(`[${p}]`)?.getAttribute(p)===z)),[z]),lt=(0,d.useCallback)(()=>J(!1),[J]),ut=(0,d.useCallback)(()=>{Ve||(J(!1),w.current?.focus())},[J,Ve]);i.r({active:k,rootRef:Fe,floatingRef:T,isOwnedPopup:ct,onOutsideClick:lt,onEscape:ut,onViewportChange:st}),(0,d.useEffect)(()=>{x&&k&&J(!1)},[x,k,J]);let Y=(0,d.useCallback)(e=>de===`string`?l.d(e,y):l.l(e),[y,de]),dt=(0,d.useCallback)(e=>{let t=se(e,v);if(K(t)||v&&q(l.d(t,`HH:mm:ss`)))return;let n=Y(t);ce(D,n,y)||(O(n),C?.(n)),J(!1),w.current?.focus()},[C,y,K,q,Y,D,J,O,v]),ft=(0,d.useCallback)(e=>{if(!e[0]||!e[1])return;let t=l.u(e[0],e[1])<=0?e:[e[1],e[0]],n=se(t[0],v),r=se(t[1],v);if(K(n)||K(r)||v&&(q(l.d(n,`HH:mm:ss`))||q(l.d(r,`HH:mm:ss`))))return;let i=[Y(n),Y(r)];ce(D,i,y)||(O(i),C?.(i)),J(!1),w.current?.focus()},[C,y,K,q,Y,D,J,O,v]),pt=e=>{if(K(e))return;let t=b?N[F===`start`?0:1]:j,n=l.g(e);if(v){if(t)n=l.h(e,t.getHours(),t.getMinutes(),t.getSeconds());else{let t=at(0,86399,0);n=t===null?l.l(e):l.h(e,Math.floor(t/3600),Math.floor(t%3600/60),t%60)}}if(!b){M(n),v||dt(n);return}let[r,i]=N;if(!r||i){P([n,null]),I(`start`);return}l.u(n,r)<0?(P([n,r]),I(`end`)):(P([r,n]),I(`end`))},X=(0,d.useCallback)((e,t=!1)=>{if(e&&L){if(b){let e=ae(N);e[F===`start`?0:1]=l.l(L),P(e)}else M(l.l(L))}B(),t&&window.requestAnimationFrame(()=>Ie.current?.focus())},[F,N,b,B,L]),mt=(e,t)=>{let n=L?l.l(L):new Date,r={hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds()},{start:i,end:a,preferred:o}=l.r(e,t,r),s=at(i,a,o);if(s===null)return;let c=l.h(n,Math.floor(s/3600),Math.floor(s%3600/60),s%60);Ue(c)},ht=e=>{let t=e.getValue(new Date);if(t===null)return;if(b){if(!m(t))return;let e=h(t[0],y),n=h(t[1],y);if(!e||!n||K(e)||K(n)||ot(e)||ot(n))return;P(l.u(e,n)<=0?[e,n]:[n,e]),I(`end`);return}if(m(t))return;let n=h(t,y);!n||K(n)||ot(n)||dt(n)},gt=e=>{e?.stopPropagation(),!x&&(O(null),C?.(null),je?.(),M(null),P([null,null]))},Z=(e,t,n=!1)=>{let r=n?l.g(e):l.s(l.g(e),t);for(let e=0;e<3660;e+=1){if(t<0&&U&&l.u(r,l.g(U))<0||t>0&&W&&l.u(r,l.g(W))>0)return null;if(!K(r))return r;r=l.s(r,t)}return null},_t=e=>{if(!x){if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),k)J(!1);else{let e=(b?V?.[0]:H)??new Date,t=Z(e,1,!0)??Z(e,-1,!0)??null;J(!0),t&&R(t)}}else e.key===`Escape`&&k&&(e.preventDefault(),J(!1))}},vt=e=>{!l.m(e,tt)&&!(b&&l.m(e,nt))&&A(l._(e)),R(l.g(e))},yt=(e,t)=>{let n=null;if(e.key===`ArrowLeft`)n=Z(t,-1);else if(e.key===`ArrowRight`)n=Z(t,1);else if(e.key===`ArrowUp`)n=Z(t,-7);else if(e.key===`ArrowDown`)n=Z(t,7);else if(e.key===`Home`||e.key===`End`){let r=e.key===`Home`?l.s(t,-t.getDay()):l.s(t,6-t.getDay()),i=e.key===`Home`?1:-1;for(let e=0;e<7;e+=1){let t=l.s(r,e*i);if(!K(t)){n=t;break}}}n&&(e.preventDefault(),vt(n))},Q=b?N[F===`start`?0:1]:j,bt=(0,d.useCallback)(e=>{if(e){if(!Q)return;Ue(l.l(Q)),He(!0);return}X(!1)},[Q,X]),$=L??Q??new Date,xt=$.getHours(),St=$.getMinutes(),Ct=$.getSeconds(),wt=Q?l.d($,`HH:mm:ss`):``,Tt=b?F===`start`?`开始时间`:`结束时间`:`时间`,Et=(0,d.useCallback)((e,t)=>l.a(e,t,{hours:xt,minutes:St,seconds:Ct},at),[at,xt,St,Ct]),Dt=b?!!(N[0]&&N[1]&&!K(N[0])&&!K(N[1])&&(!v||!q(l.d(N[0],`HH:mm:ss`))&&!q(l.d(N[1],`HH:mm:ss`)))):!!(j&&!K(j)&&(!v||!q(l.d(j,`HH:mm:ss`)))),Ot=!!et,kt=[`vl-${_}`,`size-${xe}`,k?`is-open`:``,x?`is-disabled`:``,b?`is-range`:``,v?`has-time`:``,we||``].filter(Boolean).join(` `),At=e=>{let t=l.f(e),n=b?N[0]:null,r=b?N[1]:null,i=b?null:j??H,a=(b?[N[0],N[1]]:[i]).find(t=>t&&l.m(t,e)&&!K(t))??t.find(t=>l.m(t,e)&&!K(t));return(0,f.jsxs)(`section`,{className:`vl-${_}__calendar`,"aria-label":oe(e),children:[b?(0,f.jsx)(`div`,{className:`vl-${_}__month-title`,children:oe(e)}):null,(0,f.jsx)(`div`,{className:`vl-${_}__weekdays`,role:`row`,children:ne.map(e=>(0,f.jsx)(`span`,{role:`columnheader`,children:e},e))}),(0,f.jsx)(`div`,{className:`vl-${_}__grid`,role:`grid`,children:t.map(t=>{let o=!l.m(t,e),s=o||K(t),c=!!(n&&r&&l.u(t,l.g(n))>=0&&l.u(t,l.g(r))<=0),ee=[`vl-${_}__day`,o?`is-other-month`:``,l.p(t,new Date)?`is-today`:``,b&&n&&l.p(t,n)?`is-range-start is-selected`:``,b&&r&&l.p(t,r)?`is-range-end is-selected`:``,i&&l.p(t,i)?`is-selected`:``,c?`is-in-range`:``,s?`is-disabled`:``].filter(Boolean).join(` `);return(0,f.jsx)(`button`,{type:`button`,className:ee,role:`gridcell`,"data-time":t.getTime(),"aria-label":`${t.getFullYear()}年${t.getMonth()+1}月${t.getDate()}日`,"aria-selected":b?c:!!(i&&l.p(t,i)),"aria-current":l.p(t,new Date)?`date`:void 0,"aria-hidden":o||void 0,"aria-disabled":s||void 0,disabled:s,tabIndex:!s&&a&&l.p(t,a)?0:-1,onClick:()=>pt(t),onKeyDown:e=>yt(e,t),children:t.getDate()},t.toISOString())})})]})},jt=(0,f.jsx)(s.t,{show:k,name:`vl-${_}`,deferEffects:!E,children:(0,f.jsxs)(`div`,{ref:T,id:z,className:`vl-${_}__panel is-${Ke}${Je?` is-positioned`:``}`,style:{...We,zIndex:Le.zIndex,visibility:Je?`visible`:`hidden`},role:`dialog`,"aria-label":b?`日期范围选择`:v?`日期时间选择`:`日期选择`,children:[(0,f.jsxs)(`div`,{className:`vl-${_}__header`,children:[(0,f.jsxs)(`div`,{className:`vl-${_}__header-actions`,children:[(0,f.jsx)(`button`,{type:`button`,"aria-label":`上一年`,onClick:()=>A(e=>l.c(e,-12)),children:(0,f.jsx)(u.ChevronsLeft,{size:16,"aria-hidden":`true`})}),(0,f.jsx)(`button`,{type:`button`,"aria-label":`上一个月`,onClick:()=>A(e=>l.c(e,-1)),children:(0,f.jsx)(u.ChevronLeft,{size:16,"aria-hidden":`true`})})]}),b?null:(0,f.jsx)(`span`,{children:oe(tt)}),(0,f.jsxs)(`div`,{className:`vl-${_}__header-actions`,children:[(0,f.jsx)(`button`,{type:`button`,"aria-label":`下一个月`,onClick:()=>A(e=>l.c(e,1)),children:(0,f.jsx)(u.ChevronRight,{size:16,"aria-hidden":`true`})}),(0,f.jsx)(`button`,{type:`button`,"aria-label":`下一年`,onClick:()=>A(e=>l.c(e,12)),children:(0,f.jsx)(u.ChevronsRight,{size:16,"aria-hidden":`true`})})]})]}),(0,f.jsxs)(`div`,{className:`vl-${_}__calendars`,children:[At(tt),b?At(nt):null]}),v?(0,f.jsx)(`div`,{className:`vl-${_}__time`,children:(0,f.jsxs)(`div`,{className:`vl-${_}__time-toolbar`,children:[(0,f.jsx)(`span`,{className:`vl-${_}__time-title`,children:`时间`}),b?(0,f.jsxs)(`div`,{className:`vl-${_}__time-range`,children:[(0,f.jsx)(`button`,{type:`button`,className:F===`start`?`is-active`:``,"aria-pressed":F===`start`,disabled:!N[0],onClick:()=>{X(!1),I(`start`)},children:`开始时间`}),(0,f.jsx)(`button`,{type:`button`,className:F===`end`?`is-active`:``,"aria-pressed":F===`end`,disabled:!N[1],onClick:()=>{X(!1),I(`end`)},children:`结束时间`})]}):null,(0,f.jsx)(ee.t,{className:`vl-${_}__time-dropdown`,open:Ve,disabled:!Q,trigger:`click`,placement:`bottom-end`,offset:4,closeOnContentClick:!1,"aria-label":Tt,menuLabel:`${Tt}选择器`,triggerContent:(0,f.jsx)(c.t,{ref:Ie,className:`vl-${_}__time-input`,value:wt,placeholder:`请先选择日期`,size:`sm`,suffixIcon:u.Clock3,readOnly:!0,disabled:!Q}),onChange:bt,children:(0,f.jsxs)(`div`,{className:`vl-${_}__time-popover`,[p]:z,children:[(0,f.jsx)(l.t,{value:{hours:xt,minutes:St,seconds:Ct},disabled:!Q,ariaLabel:Tt,visibleItemCount:3,itemHeight:30,isOptionDisabled:Et,onChange:mt}),(0,f.jsxs)(`div`,{className:`vl-${_}__footer`,children:[(0,f.jsx)(`button`,{type:`button`,className:`is-cancel`,"aria-label":`取消时间`,onClick:()=>X(!1,!0),children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`is-confirm`,"aria-label":`确定时间`,disabled:!L,onClick:()=>X(!0,!0),children:`确定`})]})]})})]})}):null,fe.length?(0,f.jsx)(`div`,{className:`vl-${_}__shortcuts`,role:`group`,"aria-label":`快捷选择`,children:fe.map(e=>(0,f.jsx)(`button`,{type:`button`,onClick:()=>ht(e),children:e.label},e.label))}):null,b||v?(0,f.jsxs)(`div`,{className:`vl-${_}__footer`,children:[(0,f.jsx)(`button`,{type:`button`,className:`is-cancel`,onClick:()=>{J(!1),w.current?.focus()},children:`取消`}),(0,f.jsx)(`button`,{type:`button`,className:`is-confirm`,disabled:!Dt,onClick:()=>{b?ft(N):j&&dt(j)},children:`确定`})]}):null]})});return(0,f.jsx)(o.t,{layer:Le.layer,children:(0,f.jsxs)(`div`,{ref:Qe,className:`vl-${_}-wrapper`,style:Te,...Pe,children:[(0,f.jsxs)(`div`,{ref:w,id:Ze,className:kt,role:`combobox`,"aria-expanded":k,"aria-controls":z,"aria-haspopup":`dialog`,"aria-disabled":x||void 0,"aria-label":De??(Oe?void 0:ye),"aria-labelledby":Oe,"aria-describedby":ke,tabIndex:x?-1:0,onClick:()=>J(!k),onKeyDown:_t,children:[(0,f.jsx)(`span`,{className:`vl-${_}__icon`,"aria-hidden":`true`,children:(0,f.jsx)(u.CalendarDays,{size:16})}),(0,f.jsx)(`span`,{className:`vl-${_}__value${et?``:` is-placeholder`}`,children:et||ye}),be&&Ot&&!x?(0,f.jsx)(`button`,{type:`button`,className:`vl-${_}__clear`,"aria-label":`清除已选`,onClick:gt,onMouseDown:e=>e.preventDefault(),children:(0,f.jsx)(u.X,{size:16,"aria-hidden":`true`})}):null]}),E?(0,te.createPortal)(jt,document.body):jt]})})});g.displayName=`VlDatePickerCore`,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return g}});
|
package/dist/es/Card.mjs
CHANGED
package/dist/es/Cron.mjs
CHANGED
package/dist/es/DatePicker.mjs
CHANGED
package/dist/es/Divider.mjs
CHANGED
package/dist/es/Drawer.mjs
CHANGED
package/dist/es/Dropdown.mjs
CHANGED
package/dist/es/MessageBox.mjs
CHANGED
package/dist/es/Modal.mjs
CHANGED
package/dist/es/Pagination.mjs
CHANGED