hys-ui 0.7.0 → 0.8.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/CHANGELOG.md +6 -0
- package/dist/components/HysDatePicker/HysDatePicker.vue.js +102 -48
- package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +2 -2
- package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +874 -532
- package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +2 -2
- package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +209 -168
- package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +102 -48
- package/dist/composables/datePicker.js +153 -94
- package/dist/composables/datePickerModel.js +156 -0
- package/dist/composables/datePickerPanels.js +78 -0
- package/dist/composables/datePickerRules.js +166 -0
- package/dist/composables/floatingPosition.js +32 -13
- package/dist/composables/useDatePicker.js +274 -381
- package/dist/composables/useFloating.js +21 -20
- package/dist/style.css +1 -1
- package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +6 -9
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +12 -0
- package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +6 -0
- package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +6 -9
- package/dist/types/components/HysIcon/HysIcon.vue.d.ts +1 -1
- package/dist/types/composables/datePicker.d.ts +14 -214
- package/dist/types/composables/datePickerModel.d.ts +63 -0
- package/dist/types/composables/datePickerPanels.d.ts +23 -0
- package/dist/types/composables/datePickerRules.d.ts +31 -0
- package/dist/types/composables/datePickerTypes.d.ts +277 -0
- package/dist/types/composables/floatingPosition.d.ts +1 -1
- package/dist/types/composables/useColorPicker.d.ts +1 -3
- package/dist/types/composables/useContextMenu.d.ts +1 -3
- package/dist/types/composables/useDatePicker.d.ts +20 -11
- package/dist/types/composables/useFloating.d.ts +2 -3
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,425 +1,318 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
),
|
|
34
|
-
var e;
|
|
35
|
-
return [
|
|
36
|
-
u.panelValue === void 0 ? O.value : ((e = _(u.panelValue)) == null ? void 0 : e.day) ?? O.value,
|
|
37
|
-
Q.value
|
|
38
|
-
];
|
|
39
|
-
}), te = c(() => u.mode ?? q.value), se = c(
|
|
1
|
+
import { shallowRef as le, ref as U, computed as re, watch as Ce } from "vue";
|
|
2
|
+
import { useDatePickerRules as Ee } from "./datePickerRules.js";
|
|
3
|
+
import { useDatePickerModel as Se } from "./datePickerModel.js";
|
|
4
|
+
import { useDatePickerPanels as je } from "./datePickerPanels.js";
|
|
5
|
+
import { datePoint as q, dateTimeSeconds as qe, datePeriod as ne, dateNative as N, dateClockPoint as Fe, dateEqual as ie, dateClone as X, dateWeek as Ie } from "./datePicker.js";
|
|
6
|
+
function Oe(i, s, V, d, ve) {
|
|
7
|
+
const {
|
|
8
|
+
time: D,
|
|
9
|
+
rangeDefaultTime: R,
|
|
10
|
+
unit: m,
|
|
11
|
+
multiple: B,
|
|
12
|
+
first: T,
|
|
13
|
+
weekContains: S,
|
|
14
|
+
pattern: Y,
|
|
15
|
+
displayPattern: Z,
|
|
16
|
+
words: z,
|
|
17
|
+
model: L,
|
|
18
|
+
current: j,
|
|
19
|
+
outputType: _,
|
|
20
|
+
parse: $,
|
|
21
|
+
boundary: p,
|
|
22
|
+
normalize: O,
|
|
23
|
+
isEmpty: W,
|
|
24
|
+
points: C,
|
|
25
|
+
selected: F,
|
|
26
|
+
minPoint: g,
|
|
27
|
+
maxPoint: x,
|
|
28
|
+
encodePoint: se,
|
|
29
|
+
encode: y,
|
|
30
|
+
empty: ee,
|
|
31
|
+
describe: G,
|
|
32
|
+
markClear: oe
|
|
33
|
+
} = Se(i, s), l = le([]), h = U("start"), I = U(), c = U(""), H = le(q(/* @__PURE__ */ new Date())), E = re(
|
|
40
34
|
() => {
|
|
41
|
-
var
|
|
42
|
-
return
|
|
35
|
+
var a;
|
|
36
|
+
return i.showConfirm ?? (D.value || B.value || s.value && !!((a = i.allowEmpty) != null && a.some(Boolean)));
|
|
43
37
|
}
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
38
|
+
), { currentView: fe, rightView: ce, panels: de, resetPanels: me, setPanel: ae, setMode: ye } = je({
|
|
39
|
+
props: i,
|
|
40
|
+
unit: m,
|
|
41
|
+
range: s,
|
|
42
|
+
time: D,
|
|
43
|
+
selected: F,
|
|
44
|
+
minPoint: g,
|
|
45
|
+
maxPoint: x,
|
|
46
|
+
boundary: p,
|
|
47
|
+
encodePoint: se,
|
|
48
|
+
emit: d
|
|
49
|
+
}), {
|
|
50
|
+
context: he,
|
|
51
|
+
locked: o,
|
|
52
|
+
available: M,
|
|
53
|
+
periodAvailable: J,
|
|
54
|
+
timeDisabled: we,
|
|
55
|
+
validTime: K,
|
|
56
|
+
valid: w,
|
|
57
|
+
samePoint: Pe
|
|
58
|
+
} = Ee({
|
|
59
|
+
props: i,
|
|
60
|
+
range: s,
|
|
61
|
+
multiple: B,
|
|
62
|
+
time: D,
|
|
63
|
+
unit: m,
|
|
64
|
+
first: T,
|
|
65
|
+
weekContains: S,
|
|
66
|
+
selected: F,
|
|
67
|
+
draft: l,
|
|
68
|
+
stage: h,
|
|
69
|
+
minPoint: g,
|
|
70
|
+
maxPoint: x
|
|
71
|
+
});
|
|
72
|
+
function f(a) {
|
|
73
|
+
return c.value = a === "limit" ? z.value.limit.replace("{count}", String(i.maxDates)) : z.value.invalid, d("invalid", {
|
|
74
|
+
reason: a,
|
|
75
|
+
dates: l.value.map((e) => e ? N(e) : null)
|
|
76
|
+
}), !1;
|
|
76
77
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return {
|
|
78
|
+
function P(a) {
|
|
79
|
+
d("calendarChange", y(l.value), {
|
|
80
80
|
range: a ? "end" : "start",
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
function h(e) {
|
|
86
|
-
return Array.isArray(u.disabled) && !!u.disabled[e];
|
|
87
|
-
}
|
|
88
|
-
function Y(e, a = 0, l = !0) {
|
|
89
|
-
var n;
|
|
90
|
-
if (!Number.isFinite(e) || e < ee || e > ae || H.value && e < H.value.day || X.value && e > X.value.day || (n = u.disabledDate) != null && n.call(u, new Date(e * 864e5), ce(e, a)))
|
|
91
|
-
return !1;
|
|
92
|
-
if (f.value && l && a === 1 && v.value[0]) {
|
|
93
|
-
const t = s.value === "week" ? Math.abs(
|
|
94
|
-
B(e, "week", m.value)[0] - B(v.value[0].day, "week", m.value)[0]
|
|
95
|
-
) + 7 : Math.abs(e - v.value[0].day) + 1;
|
|
96
|
-
if (u.minRangeDays && t < u.minRangeDays || u.maxRangeDays && t > u.maxRangeDays)
|
|
97
|
-
return !1;
|
|
98
|
-
}
|
|
99
|
-
return !0;
|
|
100
|
-
}
|
|
101
|
-
function ne(e, a, l = W.value === "end" ? 1 : 0, n = !0) {
|
|
102
|
-
var i, d, b;
|
|
103
|
-
if (s.value === "week" && a - e <= 6) {
|
|
104
|
-
if ((i = u.disabledWeek) != null && i.call(u, re(e, m.value, g.value)))
|
|
105
|
-
return !1;
|
|
106
|
-
if (u.weekValidation === "full") {
|
|
107
|
-
if (a - e !== 6) return !1;
|
|
108
|
-
for (let V = e; V <= a; V++)
|
|
109
|
-
if (!Y(V, l, n)) return !1;
|
|
110
|
-
return !0;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const t = Math.max(e, ((d = H.value) == null ? void 0 : d.day) ?? ee), r = Math.min(a, ((b = X.value) == null ? void 0 : b.day) ?? ae);
|
|
114
|
-
for (let V = t; V <= r; V++)
|
|
115
|
-
if (Y(V, l, n)) return !0;
|
|
116
|
-
return !1;
|
|
117
|
-
}
|
|
118
|
-
function oe(e, a) {
|
|
119
|
-
var l;
|
|
120
|
-
return ((l = u.disabledTime) == null ? void 0 : l.call(u, A(e), ce(e.day, a))) ?? {};
|
|
121
|
-
}
|
|
122
|
-
function me(e, a) {
|
|
123
|
-
var De, ke, Ae;
|
|
124
|
-
const l = oe(e, a), n = Math.floor(e.second / 3600), t = Math.floor(e.second / 60) % 60, r = e.second % 60;
|
|
125
|
-
if ((De = l.hours) != null && De.includes(n) || (ke = l.minutes) != null && ke.call(l, n).includes(t) || (Ae = l.seconds) != null && Ae.call(l, n, t).includes(r))
|
|
126
|
-
return !1;
|
|
127
|
-
const i = e.day * 86400 + e.second, d = H.value, b = X.value, V = typeof u.max == "string" && !/[T :]/.test(u.max) ? 86399 : (b == null ? void 0 : b.second) ?? 0;
|
|
128
|
-
return !(d && i < d.day * 86400 + d.second || b && i > b.day * 86400 + V);
|
|
129
|
-
}
|
|
130
|
-
function Z(e, a = !0) {
|
|
131
|
-
var l;
|
|
132
|
-
if (f.value) {
|
|
133
|
-
if (e.length !== 2 || e.some((r, i) => {
|
|
134
|
-
var d;
|
|
135
|
-
return !r && !((d = u.allowEmpty) != null && d[i]);
|
|
136
|
-
})) return !1;
|
|
137
|
-
const [n, t] = e;
|
|
138
|
-
if (n && t && n.day * 86400 + n.second > t.day * 86400 + t.second)
|
|
139
|
-
return !1;
|
|
140
|
-
if (n && t) {
|
|
141
|
-
const r = s.value === "week" ? B(t.day, "week", m.value)[1] : t.day, i = r - n.day + 1;
|
|
142
|
-
if (u.minRangeDays && i < u.minRangeDays || u.maxRangeDays && i > u.maxRangeDays)
|
|
143
|
-
return !1;
|
|
144
|
-
if (u.rangeValidation === "continuous") {
|
|
145
|
-
if (t.day > j(n.day, 1200)) return !1;
|
|
146
|
-
for (let d = n.day; d <= r; d++)
|
|
147
|
-
if (!Y(d, d === n.day ? 0 : 1, !1) || s.value === "week" && (d - n.day) % 7 === 0 && ((l = u.disabledWeek) != null && l.call(
|
|
148
|
-
u,
|
|
149
|
-
re(d, m.value, g.value)
|
|
150
|
-
)))
|
|
151
|
-
return !1;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (a && e.some((r, i) => h(i) && !we(r, z.value[i])))
|
|
155
|
-
return !1;
|
|
156
|
-
} else if (!e.length || !w.value && e.length !== 1 || u.maxDates && e.length > u.maxDates)
|
|
157
|
-
return !1;
|
|
158
|
-
return e.every(
|
|
159
|
-
(n, t) => !n || (s.value === "date" ? Y(n.day, f.value ? t : 0, !1) : ne(
|
|
160
|
-
...B(n.day, s.value, m.value),
|
|
161
|
-
f.value ? t : 0,
|
|
162
|
-
!1
|
|
163
|
-
)) && (!T.value || me(n, f.value ? t : 0))
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
function $(e) {
|
|
167
|
-
const a = A(e);
|
|
168
|
-
return x.value === "date" ? a : x.value === "timestamp" ? a.getTime() : I.value === "x" ? String(a.getTime()) : I.value === "X" ? String(Math.floor(a.getTime() / 1e3)) : Pe(e, I.value, m.value, g.value);
|
|
169
|
-
}
|
|
170
|
-
function D(e) {
|
|
171
|
-
return f.value || w.value ? e.map(
|
|
172
|
-
(a) => a ? $(a) : x.value === "string" ? "" : null
|
|
173
|
-
) : e[0] ? $(e[0]) : p();
|
|
174
|
-
}
|
|
175
|
-
function p() {
|
|
176
|
-
return u.clearValue !== void 0 ? U(u.clearValue) : f.value ? x.value === "string" ? ["", ""] : [null, null] : w.value ? [] : x.value === "string" ? "" : null;
|
|
177
|
-
}
|
|
178
|
-
function ye(e = z.value) {
|
|
179
|
-
return e.map(
|
|
180
|
-
(a) => a ? Pe(
|
|
181
|
-
a,
|
|
182
|
-
ue.value,
|
|
183
|
-
m.value,
|
|
184
|
-
g.value
|
|
185
|
-
) : ""
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
function k(e) {
|
|
189
|
-
return S.value = e === "limit" ? le.value.limit.replace("{count}", String(u.maxDates)) : le.value.invalid, o("invalid", {
|
|
190
|
-
reason: e,
|
|
191
|
-
dates: v.value.map((a) => a ? A(a) : null)
|
|
192
|
-
}), !1;
|
|
81
|
+
dates: l.value.map((e) => e ? N(e) : null),
|
|
82
|
+
formatted: G(l.value)
|
|
83
|
+
});
|
|
193
84
|
}
|
|
194
|
-
async function
|
|
195
|
-
if (
|
|
196
|
-
if (!
|
|
197
|
-
if ((
|
|
198
|
-
return
|
|
199
|
-
if ((Array.isArray(
|
|
200
|
-
return k("format");
|
|
85
|
+
async function A(a, e, n = !1) {
|
|
86
|
+
if (V.value || !L.isLive()) return !1;
|
|
87
|
+
if (!n) {
|
|
88
|
+
if ((s.value || B.value) && (!Array.isArray(a) || s.value && a.length !== 2))
|
|
89
|
+
return f("shape");
|
|
90
|
+
if ((Array.isArray(a) ? a : [a]).some((k) => !W(k) && !$(k))) return f("format");
|
|
201
91
|
}
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
204
|
-
if (!
|
|
205
|
-
return
|
|
206
|
-
|
|
92
|
+
const r = C(a);
|
|
93
|
+
if (!n && !w(r)) return f("date");
|
|
94
|
+
if (!n && _.value !== "string" && r.some((u) => u && !Pe(q(N(u)), u)))
|
|
95
|
+
return f("time");
|
|
96
|
+
c.value = "";
|
|
207
97
|
const t = {
|
|
208
|
-
source:
|
|
209
|
-
dates:
|
|
210
|
-
formatted:
|
|
211
|
-
...
|
|
212
|
-
weeks:
|
|
213
|
-
(
|
|
98
|
+
source: e,
|
|
99
|
+
dates: r.map((u) => u ? N(u) : null),
|
|
100
|
+
formatted: G(r),
|
|
101
|
+
...m.value === "week" ? {
|
|
102
|
+
weeks: r.map(
|
|
103
|
+
(u) => u ? Ie(u.day, T.value, S.value) : null
|
|
214
104
|
)
|
|
215
105
|
} : {}
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
(
|
|
219
|
-
|
|
106
|
+
}, v = await L.commit(
|
|
107
|
+
X(m.value === "week" && !n ? y(r) : a),
|
|
108
|
+
(u) => {
|
|
109
|
+
d("update:modelValue", u), d("update:value", u);
|
|
110
|
+
},
|
|
111
|
+
(u) => d("change", u, t),
|
|
220
112
|
!0
|
|
221
113
|
);
|
|
222
|
-
return
|
|
114
|
+
return v && (d("value-change", X(j.value), t), ve()), v;
|
|
223
115
|
}
|
|
224
|
-
function
|
|
225
|
-
|
|
226
|
-
S.value = "", v.value = M(), f.value && v.value.length !== 2 && (v.value = [null, null]), W.value = f.value && h(0) && !h(1) ? "end" : "start", K.value = void 0;
|
|
227
|
-
let e = ((a = z.value.find(Boolean)) == null ? void 0 : a.day) ?? ((l = _(u.defaultPickerValue)) == null ? void 0 : l.day) ?? fe.value.day;
|
|
228
|
-
e = Math.max(
|
|
229
|
-
((n = H.value) == null ? void 0 : n.day) ?? ee,
|
|
230
|
-
Math.min(((t = X.value) == null ? void 0 : t.day) ?? ae, e)
|
|
231
|
-
), O.value = e, Q.value = j(e, 1), q.value = u.defaultMode ?? (s.value === "week" ? "date" : s.value), L.value = q.value;
|
|
116
|
+
function te() {
|
|
117
|
+
H.value = q(/* @__PURE__ */ new Date()), c.value = "", l.value = C(), s.value && l.value.length !== 2 && (l.value = [null, null]), h.value = s.value && o(0) && !o(1) ? "end" : "start", I.value = void 0, me(H.value.day);
|
|
232
118
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
Ve(e).month,
|
|
238
|
-
1
|
|
119
|
+
function b(a) {
|
|
120
|
+
const e = i.defaultTime ?? (typeof i.showTime == "object" ? i.showTime.defaultValue : void 0);
|
|
121
|
+
return qe(
|
|
122
|
+
Array.isArray(e) ? e[a] : e
|
|
239
123
|
);
|
|
240
|
-
return a === 0 ? (u.panelValue === void 0 && (O.value = l), o("update:panelValue", $({ day: l, second: 0 })), f.value && !u.unlinkPanels && (Q.value = j(l, 1))) : (Q.value = l, u.unlinkPanels || (u.panelValue === void 0 && (O.value = j(l, -1)), o(
|
|
241
|
-
"update:panelValue",
|
|
242
|
-
$({ day: j(l, -1), second: 0 })
|
|
243
|
-
))), o(
|
|
244
|
-
"panelChange",
|
|
245
|
-
A({ day: l, second: 0 }),
|
|
246
|
-
a ? L.value : te.value,
|
|
247
|
-
{ index: a }
|
|
248
|
-
), !0;
|
|
249
|
-
}
|
|
250
|
-
function We(e, a = 0) {
|
|
251
|
-
return ["date", "month", "quarter", "year"].includes(e) ? (a ? L.value = e : (u.mode === void 0 && (q.value = e), o("update:mode", e)), o(
|
|
252
|
-
"panelChange",
|
|
253
|
-
A({ day: de.value[a], second: 0 }),
|
|
254
|
-
e,
|
|
255
|
-
{ index: a }
|
|
256
|
-
), a ? !0 : te.value === e) : !1;
|
|
257
|
-
}
|
|
258
|
-
function Se(e) {
|
|
259
|
-
const a = Array.isArray(u.defaultTime) ? u.defaultTime[e] : u.defaultTime;
|
|
260
|
-
return He(a);
|
|
261
124
|
}
|
|
262
|
-
async function
|
|
263
|
-
var
|
|
264
|
-
if (
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
...
|
|
268
|
-
|
|
125
|
+
async function ke(a) {
|
|
126
|
+
var r;
|
|
127
|
+
if (V.value) return !1;
|
|
128
|
+
const e = s.value && h.value === "end" ? 1 : 0;
|
|
129
|
+
if (o(e) || !(m.value === "date" ? M(a, e) : J(
|
|
130
|
+
...ne(a, m.value, T.value),
|
|
131
|
+
e
|
|
269
132
|
)))
|
|
270
133
|
return !1;
|
|
271
|
-
const
|
|
272
|
-
day:
|
|
273
|
-
second:
|
|
134
|
+
const n = O({
|
|
135
|
+
day: a,
|
|
136
|
+
second: D.value ? ((r = l.value[e]) == null ? void 0 : r.second) ?? b(e) : R.value ? b(e) : 0
|
|
274
137
|
});
|
|
275
|
-
if (
|
|
276
|
-
const t =
|
|
277
|
-
if (
|
|
138
|
+
if (B.value) {
|
|
139
|
+
const t = l.value.filter((u) => !!u), v = t.findIndex((u) => u.day === n.day);
|
|
140
|
+
if (v >= 0) t.splice(v, 1);
|
|
278
141
|
else {
|
|
279
|
-
if (
|
|
280
|
-
return
|
|
281
|
-
t.push(
|
|
142
|
+
if (i.maxDates && t.length >= i.maxDates)
|
|
143
|
+
return f("limit");
|
|
144
|
+
t.push(n);
|
|
282
145
|
}
|
|
283
|
-
|
|
284
|
-
} else if (
|
|
285
|
-
if (
|
|
286
|
-
|
|
146
|
+
l.value = t.sort((u, k) => u.day - k.day);
|
|
147
|
+
} else if (s.value) {
|
|
148
|
+
if (e === 0)
|
|
149
|
+
l.value = [n, o(1) ? F.value[1] ?? null : null], h.value = o(1) ? "start" : "end";
|
|
287
150
|
else {
|
|
288
|
-
let t =
|
|
289
|
-
if (t && t.day >
|
|
290
|
-
if (
|
|
291
|
-
[t,
|
|
151
|
+
let t = l.value[0], v = n;
|
|
152
|
+
if (t && t.day > v.day) {
|
|
153
|
+
if (o(0)) return f("order");
|
|
154
|
+
[t, v] = [v, t];
|
|
292
155
|
}
|
|
293
|
-
v.value = [t ?? null,
|
|
156
|
+
R.value && !D.value && (t && !o(0) && (t = { ...t, second: b(0) }), v = { ...v, second: b(1) }), l.value = [t ?? null, v], h.value = o(0) ? "end" : "start";
|
|
294
157
|
}
|
|
295
|
-
|
|
296
|
-
} else
|
|
297
|
-
if (
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}), !se.value && (!f.value || v.value.every(Boolean))) {
|
|
301
|
-
const t = D(v.value);
|
|
302
|
-
return await C(t, "date") || E(t, y.value);
|
|
158
|
+
I.value = void 0;
|
|
159
|
+
} else l.value = [n];
|
|
160
|
+
if (c.value = "", P(e), !E.value && (!s.value || l.value.every(Boolean))) {
|
|
161
|
+
const t = y(l.value);
|
|
162
|
+
return await A(t, "date") || ie(t, j.value);
|
|
303
163
|
}
|
|
304
164
|
return !1;
|
|
305
165
|
}
|
|
306
|
-
async function
|
|
307
|
-
const
|
|
308
|
-
|
|
166
|
+
async function Q() {
|
|
167
|
+
const a = C(), e = s.value ? a.map((t, v) => o(v) ? t : null) : [], n = s.value && e.some(Boolean) ? y(e) : ee();
|
|
168
|
+
e.some(Boolean) || oe(n);
|
|
169
|
+
const r = await A(n, "clear", !0);
|
|
170
|
+
return r && (l.value = C(), c.value = "", d("clear")), r;
|
|
309
171
|
}
|
|
310
|
-
async function
|
|
311
|
-
if (!
|
|
312
|
-
const
|
|
313
|
-
return await
|
|
172
|
+
async function De() {
|
|
173
|
+
if (!w(l.value)) return f("draft");
|
|
174
|
+
const a = y(l.value);
|
|
175
|
+
return await A(a, "confirm") || ie(a, j.value) ? (d("ok", X(j.value)), !0) : !1;
|
|
314
176
|
}
|
|
315
|
-
async function
|
|
316
|
-
return
|
|
177
|
+
async function Ae(a) {
|
|
178
|
+
return W(a) || Array.isArray(a) && a.every(W) ? Q() : A(a, "api");
|
|
317
179
|
}
|
|
318
|
-
function
|
|
319
|
-
return
|
|
320
|
-
(
|
|
321
|
-
),
|
|
322
|
-
range: e ? "end" : "start",
|
|
323
|
-
dates: v.value.map((l) => l ? A(l) : null)
|
|
324
|
-
}), !0);
|
|
180
|
+
function Te(a, e) {
|
|
181
|
+
return V.value || o(a) || !l.value[a] || !Number.isInteger(e) || e < 0 || e > 86399 ? !1 : (l.value = l.value.map(
|
|
182
|
+
(n, r) => r === a && n ? { ...n, second: e } : n
|
|
183
|
+
), c.value = "", P(a), !0);
|
|
325
184
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
if (!
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
185
|
+
function be(a, e, n, r) {
|
|
186
|
+
if (V.value || o(a)) return !1;
|
|
187
|
+
const t = l.value[a], v = r === "date" ? q(e, n, T.value, S.value, i.locale) : Fe(e, n);
|
|
188
|
+
if (!v || r === "time" && !t) return f("format");
|
|
189
|
+
const u = r === "date" ? { day: v.day, second: (t == null ? void 0 : t.second) ?? b(a) } : { day: t.day, second: v.second };
|
|
190
|
+
if (!M(u.day, a, !1) || r === "time" && !K(u, a))
|
|
191
|
+
return f("draft");
|
|
192
|
+
const k = [...l.value];
|
|
193
|
+
return k[a] = u, l.value = k, c.value = "", r === "date" && (ae(u.day, a), s.value && (h.value = a === 0 && !o(1) ? "end" : "start")), P(a), !E.value && w(k) && A(y(k), "time"), !0;
|
|
194
|
+
}
|
|
195
|
+
async function Ve(a, e = 0) {
|
|
196
|
+
var v;
|
|
197
|
+
if (V.value || o(e)) return !1;
|
|
198
|
+
if (!a.trim()) {
|
|
199
|
+
if (s.value && ((v = i.allowEmpty) != null && v[e])) {
|
|
200
|
+
const u = [...l.value];
|
|
201
|
+
return u[e] = null, l.value = u, c.value = "", P(e), E.value || !w(u) ? !0 : A(y(u), "input");
|
|
333
202
|
}
|
|
334
|
-
return
|
|
203
|
+
return Q();
|
|
335
204
|
}
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
205
|
+
const n = [
|
|
206
|
+
...Array.isArray(i.format) ? i.format : [Z.value],
|
|
207
|
+
...i.inputFormats ?? [],
|
|
208
|
+
Y.value
|
|
209
|
+
].filter((u) => typeof u == "string"), r = n.map(
|
|
210
|
+
(u) => q(a, u, T.value, S.value, i.locale)
|
|
211
|
+
).find(Boolean);
|
|
212
|
+
if (!r) return f("format");
|
|
213
|
+
const t = s.value ? [...l.value] : [];
|
|
214
|
+
if (s.value) {
|
|
215
|
+
if (R.value && !D.value && (r.second = b(e)), !(m.value === "date" ? M(r.day, e, !1) : J(
|
|
216
|
+
...ne(r.day, m.value, T.value),
|
|
217
|
+
e,
|
|
218
|
+
!1
|
|
219
|
+
)) || D.value && !K(r, e))
|
|
220
|
+
return f("date");
|
|
221
|
+
t[e] = O(r);
|
|
222
|
+
} else {
|
|
223
|
+
if (B.value) return f("multiple-input");
|
|
224
|
+
t.push(O(r));
|
|
343
225
|
}
|
|
344
|
-
|
|
226
|
+
if (l.value = t, s.value) {
|
|
227
|
+
if (c.value = "", h.value = e === 0 && !o(1) ? "end" : "start", !t.every(Boolean) && !w(t))
|
|
228
|
+
return P(e), !0;
|
|
229
|
+
if (!w(t)) return f("date");
|
|
230
|
+
if (P(e), E.value) return !0;
|
|
231
|
+
} else if (E.value)
|
|
232
|
+
return w(t) ? (c.value = "", P(0), !0) : f("date");
|
|
233
|
+
return A(y(t), "input");
|
|
345
234
|
}
|
|
346
|
-
function
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
if (!a || a.disabled) return !1;
|
|
235
|
+
function Be(a) {
|
|
236
|
+
if (V.value) return !1;
|
|
237
|
+
const e = ue.value[a];
|
|
238
|
+
if (!e || e.disabled) return !1;
|
|
351
239
|
try {
|
|
352
|
-
const n = typeof
|
|
353
|
-
return
|
|
354
|
-
range: "start",
|
|
355
|
-
dates: t.map((r) => r ? A(r) : null)
|
|
356
|
-
}), !0) : k("shortcut");
|
|
240
|
+
const n = typeof e.value == "function" ? e.value() : e.value, r = C(n);
|
|
241
|
+
return w(r) ? (l.value = r, h.value = "start", I.value = void 0, P(0), !0) : f("shortcut");
|
|
357
242
|
} catch (n) {
|
|
358
|
-
return
|
|
243
|
+
return d("invalid", { reason: "shortcut", error: n }), !1;
|
|
359
244
|
}
|
|
360
245
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
246
|
+
const ue = re(() => [
|
|
247
|
+
...i.shortcuts ?? [],
|
|
248
|
+
...i.presets ?? [],
|
|
249
|
+
...Object.entries(i.ranges ?? {}).map(([a, e]) => ({
|
|
250
|
+
label: a,
|
|
251
|
+
value: e,
|
|
252
|
+
disabled: !1
|
|
253
|
+
}))
|
|
254
|
+
]);
|
|
255
|
+
return Ce(
|
|
256
|
+
[
|
|
257
|
+
() => i.type,
|
|
258
|
+
() => i.picker,
|
|
259
|
+
() => i.showTime,
|
|
260
|
+
() => i.valueFormat,
|
|
261
|
+
s
|
|
262
|
+
],
|
|
263
|
+
te
|
|
376
264
|
), {
|
|
377
|
-
current:
|
|
378
|
-
selected:
|
|
379
|
-
draft:
|
|
380
|
-
stage:
|
|
381
|
-
preview:
|
|
382
|
-
error:
|
|
383
|
-
view:
|
|
384
|
-
rightView:
|
|
265
|
+
current: j,
|
|
266
|
+
selected: F,
|
|
267
|
+
draft: l,
|
|
268
|
+
stage: h,
|
|
269
|
+
preview: I,
|
|
270
|
+
error: c,
|
|
271
|
+
view: fe,
|
|
272
|
+
rightView: ce,
|
|
385
273
|
panels: de,
|
|
386
|
-
first:
|
|
387
|
-
weekContains:
|
|
388
|
-
time:
|
|
389
|
-
unit:
|
|
390
|
-
multiple:
|
|
391
|
-
pattern:
|
|
392
|
-
displayPattern:
|
|
393
|
-
words:
|
|
394
|
-
needsConfirm:
|
|
395
|
-
today:
|
|
396
|
-
model:
|
|
397
|
-
outputType:
|
|
398
|
-
parse:
|
|
399
|
-
boundary:
|
|
400
|
-
points:
|
|
401
|
-
available:
|
|
402
|
-
periodAvailable:
|
|
403
|
-
validTime:
|
|
404
|
-
valid:
|
|
405
|
-
timeDisabled:
|
|
406
|
-
encode:
|
|
407
|
-
describe:
|
|
408
|
-
empty:
|
|
409
|
-
request:
|
|
410
|
-
begin:
|
|
411
|
-
setPanel:
|
|
412
|
-
setMode:
|
|
413
|
-
choose:
|
|
414
|
-
clear:
|
|
415
|
-
confirm:
|
|
416
|
-
setValue:
|
|
417
|
-
setTime:
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
274
|
+
first: T,
|
|
275
|
+
weekContains: S,
|
|
276
|
+
time: D,
|
|
277
|
+
unit: m,
|
|
278
|
+
multiple: B,
|
|
279
|
+
pattern: Y,
|
|
280
|
+
displayPattern: Z,
|
|
281
|
+
words: z,
|
|
282
|
+
needsConfirm: E,
|
|
283
|
+
today: H,
|
|
284
|
+
model: L,
|
|
285
|
+
outputType: _,
|
|
286
|
+
parse: $,
|
|
287
|
+
boundary: p,
|
|
288
|
+
points: C,
|
|
289
|
+
available: M,
|
|
290
|
+
periodAvailable: J,
|
|
291
|
+
validTime: K,
|
|
292
|
+
valid: w,
|
|
293
|
+
timeDisabled: we,
|
|
294
|
+
encode: y,
|
|
295
|
+
describe: G,
|
|
296
|
+
empty: ee,
|
|
297
|
+
request: A,
|
|
298
|
+
begin: te,
|
|
299
|
+
setPanel: ae,
|
|
300
|
+
setMode: ye,
|
|
301
|
+
choose: ke,
|
|
302
|
+
clear: Q,
|
|
303
|
+
confirm: De,
|
|
304
|
+
setValue: Ae,
|
|
305
|
+
setTime: Te,
|
|
306
|
+
editDraft: be,
|
|
307
|
+
emitDraft: P,
|
|
308
|
+
input: Ve,
|
|
309
|
+
pickShortcut: Be,
|
|
310
|
+
shortcuts: ue,
|
|
311
|
+
context: he,
|
|
312
|
+
defaultSecond: b,
|
|
313
|
+
locked: o
|
|
421
314
|
};
|
|
422
315
|
}
|
|
423
316
|
export {
|
|
424
|
-
|
|
317
|
+
Oe as useDatePicker
|
|
425
318
|
};
|