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.
Files changed (32) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/HysDatePicker/HysDatePicker.vue.js +102 -48
  3. package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +2 -2
  4. package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +874 -532
  5. package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +2 -2
  6. package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +209 -168
  7. package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +102 -48
  8. package/dist/composables/datePicker.js +153 -94
  9. package/dist/composables/datePickerModel.js +156 -0
  10. package/dist/composables/datePickerPanels.js +78 -0
  11. package/dist/composables/datePickerRules.js +166 -0
  12. package/dist/composables/floatingPosition.js +32 -13
  13. package/dist/composables/useDatePicker.js +274 -381
  14. package/dist/composables/useFloating.js +21 -20
  15. package/dist/style.css +1 -1
  16. package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +6 -9
  17. package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +12 -0
  18. package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +6 -0
  19. package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +6 -9
  20. package/dist/types/components/HysIcon/HysIcon.vue.d.ts +1 -1
  21. package/dist/types/composables/datePicker.d.ts +14 -214
  22. package/dist/types/composables/datePickerModel.d.ts +63 -0
  23. package/dist/types/composables/datePickerPanels.d.ts +23 -0
  24. package/dist/types/composables/datePickerRules.d.ts +31 -0
  25. package/dist/types/composables/datePickerTypes.d.ts +277 -0
  26. package/dist/types/composables/floatingPosition.d.ts +1 -1
  27. package/dist/types/composables/useColorPicker.d.ts +1 -3
  28. package/dist/types/composables/useContextMenu.d.ts +1 -3
  29. package/dist/types/composables/useDatePicker.d.ts +20 -11
  30. package/dist/types/composables/useFloating.d.ts +2 -3
  31. package/dist/types/index.d.ts +1 -1
  32. package/package.json +1 -1
@@ -1,425 +1,318 @@
1
- import { ref as P, computed as c, shallowRef as Be, watch as Me } from "vue";
2
- import { useChoiceModel as Ge } from "./choiceModel.js";
3
- import { civilDay as Ie, calendarParts as Ve, calendarISO as qe } from "./calendar.js";
4
- import { dateUnit as ge, dateMultiple as Oe, datePattern as be, datePickerEnglish as _e, datePickerWords as ze, dateEqual as E, dateClone as U, datePoint as N, DATE_MIN as ee, DATE_MAX as ae, dateShift as j, dateNative as A, datePeriod as B, dateWeek as re, dateFormat as Pe, dateTimeSeconds as He } from "./datePicker.js";
5
- function Ke(u, f, G, o, Te) {
6
- const ve = P("string"), T = c(
7
- () => u.type === "datetime" || !!u.showTime && ge(u.type) === "date"
8
- ), s = c(() => ge(u.type)), w = c(() => !f.value && Oe(u.type)), m = c(
9
- () => Number.isFinite(u.firstDayOfWeek) ? (Math.trunc(u.firstDayOfWeek) % 7 + 7) % 7 : 1
10
- ), g = c(
11
- () => Number.isFinite(u.firstWeekContainsDate) ? Math.max(1, Math.min(7, Math.trunc(u.firstWeekContainsDate))) : 4
12
- ), I = c(
13
- () => u.valueFormat ?? be(u.type, T.value)
14
- ), ue = c(
15
- () => u.format ?? (s.value === "week" ? "GGGG-[W]WW" : be(u.type, T.value))
16
- ), le = c(() => {
17
- var e;
18
- return {
19
- ...ze,
20
- ...(e = u.locale) != null && e.startsWith("en") ? _e : {},
21
- ...u.messages
22
- };
23
- }), J = Ge(
24
- u,
25
- () => U(
26
- u.defaultValue ?? (f.value ? ["", ""] : w.value ? [] : "")
27
- ),
28
- E
29
- ), y = J.current, x = c(
30
- () => u.valueType ?? (y.value instanceof Date || Array.isArray(y.value) && y.value.some((e) => e instanceof Date) ? "date" : typeof y.value == "number" || Array.isArray(y.value) && y.value.some((e) => typeof e == "number") ? "timestamp" : ve.value)
31
- ), v = Be([]), W = P("start"), K = P(), S = P(""), q = P(
32
- u.defaultMode ?? (s.value === "week" ? "date" : s.value)
33
- ), L = P(q.value), O = P(0), Q = P(0), fe = c(() => N(/* @__PURE__ */ new Date())), de = c(() => {
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 e;
42
- return u.showConfirm ?? (T.value || w.value || f.value && !!((e = u.allowEmpty) != null && e.some(Boolean)));
35
+ var a;
36
+ return i.showConfirm ?? (D.value || B.value || s.value && !!((a = i.allowEmpty) != null && a.some(Boolean)));
43
37
  }
44
- );
45
- function R(e) {
46
- return N(e, I.value, m.value, g.value);
47
- }
48
- function _(e) {
49
- return R(e) ?? N(e, "YYYY-MM-DD") ?? N(e, "YYYY-MM-DD HH:mm:ss");
50
- }
51
- function F(e) {
52
- return {
53
- day: B(e.day, s.value, m.value)[0],
54
- second: T.value ? e.second : 0
55
- };
56
- }
57
- function M(e = y.value) {
58
- if (e == null || e === "" || u.clearValue !== void 0 && E(e, u.clearValue))
59
- return f.value ? [null, null] : [];
60
- if (f.value)
61
- return Array.from({ length: 2 }, (l, n) => {
62
- const t = Array.isArray(e) ? R(e[n]) : void 0;
63
- return t ? F(t) : null;
64
- });
65
- if (w.value) {
66
- const l = /* @__PURE__ */ new Set();
67
- return (Array.isArray(e) ? e : []).flatMap((n) => {
68
- const t = R(n);
69
- if (!t) return [];
70
- const r = F(t);
71
- return s.value === "week" && l.has(r.day) ? [] : (l.add(r.day), [r]);
72
- });
73
- }
74
- const a = R(e);
75
- return a ? [F(a)] : [];
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
- const z = c(() => M()), H = c(() => _(u.min)), X = c(() => _(u.max));
78
- function ce(e, a) {
79
- return {
78
+ function P(a) {
79
+ d("calendarChange", y(l.value), {
80
80
  range: a ? "end" : "start",
81
- from: v.value[0] ? new Date(v.value[0].day * 864e5) : null,
82
- iso: qe(e)
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 C(e, a, l = !1) {
195
- if (G.value || !J.isLive()) return !1;
196
- if (!l) {
197
- if ((f.value || w.value) && (!Array.isArray(e) || f.value && e.length !== 2))
198
- return k("shape");
199
- if ((Array.isArray(e) ? e : [e]).some((d) => d !== null && d !== "" && !R(d)))
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 n = M(e);
203
- if (!l && !Z(n)) return k("date");
204
- if (!l && x.value !== "string" && n.some((i) => i && !we(N(A(i)), i)))
205
- return k("time");
206
- S.value = "";
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: a,
209
- dates: n.map((i) => i ? A(i) : null),
210
- formatted: ye(n),
211
- ...s.value === "week" ? {
212
- weeks: n.map(
213
- (i) => i ? re(i.day, m.value, g.value) : null
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
- }, r = await J.commit(
217
- U(s.value === "week" && !l ? D(n) : e),
218
- (i) => o("update:modelValue", i),
219
- (i) => o("change", i, t),
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 r && (o("value-change", U(y.value), t), Te()), r;
114
+ return v && (d("value-change", X(j.value), t), ve()), v;
223
115
  }
224
- function he() {
225
- var a, l, n, t;
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 xe(e, a = 0) {
234
- if (!Number.isFinite(e) || e < ee || e > ae) return !1;
235
- const l = Ie(
236
- Ve(e).year,
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 Ce(e) {
263
- var n;
264
- if (G.value) return !1;
265
- const a = f.value && W.value === "end" ? 1 : 0;
266
- if (h(a) || !(s.value === "date" ? Y(e, a) : ne(
267
- ...B(e, s.value, m.value),
268
- a
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 l = F({
272
- day: e,
273
- second: T.value ? ((n = v.value[a]) == null ? void 0 : n.second) ?? Se(a) : 0
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 (w.value) {
276
- const t = v.value.filter((i) => !!i), r = t.findIndex((i) => i.day === l.day);
277
- if (r >= 0) t.splice(r, 1);
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 (u.maxDates && t.length >= u.maxDates)
280
- return k("limit");
281
- t.push(l);
142
+ if (i.maxDates && t.length >= i.maxDates)
143
+ return f("limit");
144
+ t.push(n);
282
145
  }
283
- v.value = t.sort((i, d) => i.day - d.day);
284
- } else if (f.value) {
285
- if (a === 0)
286
- v.value = [l, h(1) ? z.value[1] ?? null : null], W.value = h(1) ? "start" : "end";
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 = v.value[0], r = l;
289
- if (t && t.day > r.day) {
290
- if (h(0)) return k("order");
291
- [t, r] = [r, 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, r], W.value = h(0) ? "end" : "start";
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
- K.value = void 0;
296
- } else v.value = [l];
297
- if (S.value = "", o("calendarChange", D(v.value), {
298
- range: a ? "end" : "start",
299
- dates: v.value.map((t) => t ? A(t) : null)
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 ie() {
307
- const e = M(), a = f.value ? e.map((t, r) => h(r) ? t : null) : [], l = f.value && a.some(Boolean) ? D(a) : p(), n = await C(l, "clear", !0);
308
- return n && (v.value = M(), S.value = "", o("clear")), n;
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 Re() {
311
- if (!Z(v.value)) return k("draft");
312
- const e = D(v.value);
313
- return await C(e, "confirm") || E(e, y.value) ? (o("ok", U(y.value)), !0) : !1;
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 Fe(e) {
316
- return e == null || e === "" || Array.isArray(e) && e.every((l) => l == null || l === "") || E(e, p()) ? ie() : C(e, "api");
177
+ async function Ae(a) {
178
+ return W(a) || Array.isArray(a) && a.every(W) ? Q() : A(a, "api");
317
179
  }
318
- function Ye(e, a) {
319
- return G.value || h(e) || !v.value[e] || !Number.isInteger(a) || a < 0 || a > 86399 ? !1 : (v.value = v.value.map(
320
- (l, n) => n === e && l ? { ...l, second: a } : l
321
- ), S.value = "", o("calendarChange", D(v.value), {
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
- async function Ee(e, a = 0) {
327
- var r;
328
- if (G.value || h(a)) return !1;
329
- if (!e.trim()) {
330
- if (f.value && ((r = u.allowEmpty) != null && r[a])) {
331
- const i = M();
332
- return i[a] = null, v.value = i, C(D(i), "input");
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 ie();
203
+ return Q();
335
204
  }
336
- const l = [ue.value, ...u.inputFormats ?? []], n = l.map((i) => N(e, i, m.value, g.value)).find(Boolean);
337
- if (!n) return k("format");
338
- const t = f.value ? M() : [];
339
- if (f.value) t[a] = F(n);
340
- else {
341
- if (w.value) return k("multiple-input");
342
- t.push(F(n));
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
- return v.value = t, C(D(t), "input");
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 Ne(e) {
347
- var l;
348
- if (G.value) return !1;
349
- const a = (l = u.shortcuts) == null ? void 0 : l[e];
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 a.value == "function" ? a.value() : a.value, t = M(n);
353
- return Z(t) ? (v.value = t, W.value = "start", K.value = void 0, o("calendarChange", D(t), {
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 o("invalid", { reason: "shortcut", error: n }), !1;
243
+ return d("invalid", { reason: "shortcut", error: n }), !1;
359
244
  }
360
245
  }
361
- function we(e, a) {
362
- return !e && !a || !!e && !!a && e.day === a.day && e.second === a.second;
363
- }
364
- return Me(
365
- [() => u.type, () => u.showTime, () => u.valueFormat],
366
- he
367
- ), Me(
368
- y,
369
- (e) => {
370
- if (u.clearValue !== void 0 && E(e, u.clearValue))
371
- return;
372
- const a = Array.isArray(e) ? e : [e], l = a.find((n) => n != null && n !== "");
373
- l !== void 0 && (ve.value = l instanceof Date ? "date" : typeof l == "number" ? "timestamp" : "string");
374
- },
375
- { immediate: !0, flush: "sync" }
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: y,
378
- selected: z,
379
- draft: v,
380
- stage: W,
381
- preview: K,
382
- error: S,
383
- view: te,
384
- rightView: L,
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: m,
387
- weekContains: g,
388
- time: T,
389
- unit: s,
390
- multiple: w,
391
- pattern: I,
392
- displayPattern: ue,
393
- words: le,
394
- needsConfirm: se,
395
- today: fe,
396
- model: J,
397
- outputType: x,
398
- parse: R,
399
- boundary: _,
400
- points: M,
401
- available: Y,
402
- periodAvailable: ne,
403
- validTime: me,
404
- valid: Z,
405
- timeDisabled: oe,
406
- encode: D,
407
- describe: ye,
408
- empty: p,
409
- request: C,
410
- begin: he,
411
- setPanel: xe,
412
- setMode: We,
413
- choose: Ce,
414
- clear: ie,
415
- confirm: Re,
416
- setValue: Fe,
417
- setTime: Ye,
418
- input: Ee,
419
- pickShortcut: Ne,
420
- locked: h
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
- Ke as useDatePicker
317
+ Oe as useDatePicker
425
318
  };