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