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,9 +1,15 @@
1
- import { calendarDate as C, calendarParts as u, civilDay as d, calendarISO as g, calendarDay as N, calendarShift as A } from "./calendar.js";
2
- const P = {
1
+ import { calendarDate as F, calendarParts as M, calendarISO as x, civilDay as u, calendarDay as Q, calendarShift as v } from "./calendar.js";
2
+ const I = {
3
3
  open: void 0,
4
4
  showConfirm: void 0,
5
5
  type: "date",
6
6
  clearable: !1,
7
+ allowClear: void 0,
8
+ automaticDropdown: void 0,
9
+ showWeekNumber: void 0,
10
+ use12Hours: void 0,
11
+ hideDisabledOptions: void 0,
12
+ teleported: void 0,
7
13
  editable: !1,
8
14
  bordered: !0,
9
15
  firstDayOfWeek: 1,
@@ -21,7 +27,7 @@ const P = {
21
27
  rangeValidation: "endpoints",
22
28
  validateEvent: !0,
23
29
  appendTo: "body"
24
- }, Q = {
30
+ }, q = {
25
31
  today: "今天",
26
32
  now: "此刻",
27
33
  clear: "清空",
@@ -46,7 +52,7 @@ const P = {
46
52
  second: "秒",
47
53
  empty: "选择日期",
48
54
  limit: "最多选择 {count} 项"
49
- }, b = {
55
+ }, z = {
50
56
  today: "Today",
51
57
  now: "Now",
52
58
  clear: "Clear",
@@ -71,117 +77,168 @@ const P = {
71
77
  second: "Second",
72
78
  empty: "Choose a date",
73
79
  limit: "Select up to {count} items"
74
- }, M = d(1, 0, 1), S = d(9999, 11, 31), D = (e) => e === "datetime" || !e ? "date" : e.replace(/s$/, ""), F = (e) => ["dates", "weeks", "months", "quarters", "years"].includes(e ?? "");
75
- function O(e, t = !1) {
76
- return t ? "YYYY-MM-DD HH:mm:ss" : D(e) === "year" ? "YYYY" : D(e) === "month" ? "YYYY-MM" : D(e) === "quarter" ? "YYYY-[Q]Q" : "YYYY-MM-DD";
80
+ }, W = u(1, 0, 1), p = u(9999, 11, 31), _ = (e) => !!(e != null && e.endsWith("range"));
81
+ function A(e) {
82
+ const t = e == null ? void 0 : e.replace(/range$/, "").replace(/s$/, "");
83
+ return t === "week" || t === "month" || t === "quarter" || t === "year" ? t : "date";
77
84
  }
78
- function $(e, t, i = 1) {
79
- const n = u(e);
85
+ const j = (e) => ["dates", "weeks", "months", "quarters", "years"].includes(e ?? "");
86
+ function R(e, t = !1) {
87
+ return t ? "YYYY-MM-DD HH:mm:ss" : A(e) === "year" ? "YYYY" : A(e) === "month" ? "YYYY-MM" : A(e) === "quarter" ? "YYYY-[Q]Q" : "YYYY-MM-DD";
88
+ }
89
+ function X(e, t, d = 1) {
90
+ const a = M(e);
80
91
  if (t === "year")
81
- return [d(n.year, 0, 1), d(n.year, 11, 31)];
92
+ return [u(a.year, 0, 1), u(a.year, 11, 31)];
82
93
  if (t === "quarter") {
83
- const r = Math.floor(n.month / 3) * 3;
84
- return [d(n.year, r, 1), d(n.year, r + 3, 0)];
94
+ const s = Math.floor(a.month / 3) * 3;
95
+ return [u(a.year, s, 1), u(a.year, s + 3, 0)];
85
96
  }
86
97
  if (t === "month")
87
- return [d(n.year, n.month, 1), d(n.year, n.month + 1, 0)];
98
+ return [u(a.year, a.month, 1), u(a.year, a.month + 1, 0)];
88
99
  if (t === "week") {
89
- const r = e - (n.weekday - i + 7) % 7;
90
- return [Math.max(M, r), Math.min(S, r + 6)];
100
+ const s = e - (a.weekday - d + 7) % 7;
101
+ return [Math.max(W, s), Math.min(p, s + 6)];
91
102
  }
92
103
  return [e, e];
93
104
  }
94
- function v(e) {
105
+ function K(e) {
106
+ if (e instanceof Date)
107
+ return Number.isFinite(e.getTime()) ? e.getHours() * 3600 + e.getMinutes() * 60 + e.getSeconds() : 0;
95
108
  const t = /^(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(e ?? "");
96
109
  return t && +t[1] < 24 && +t[2] < 60 && +(t[3] ?? 0) < 60 ? +t[1] * 3600 + +t[2] * 60 + +(t[3] ?? 0) : 0;
97
110
  }
98
- const G = /\[[^\]]*\]|YYYY|GGGG|MM|DD|HH|mm|ss|WW|Q/g;
99
- function W(e, t = 1, i = 4) {
100
- t = Number.isFinite(t) ? (Math.trunc(t) % 7 + 7) % 7 : 1, i = Number.isFinite(i) ? Math.max(1, Math.min(7, Math.trunc(i))) : 4;
101
- const n = (l) => {
102
- const h = d(l, 0, i);
103
- return h - (u(h).weekday - t + 7) % 7;
104
- }, r = e - (u(e).weekday - t + 7) % 7;
105
- let o = u(e).year;
106
- r < n(o) ? o-- : r >= n(o + 1) && o++;
107
- const m = Math.max(M, r), c = Math.min(S, r + 6);
111
+ const H = /\[[^\]]*\]|YYYY|GGGG|MMMM|MMM|MM|dddd|ddd|dd|DD|HH|hh|mm|ss|WW|M|D|H|h|m|s|Q|A|a/g, T = ["MMM", "MMMM", "dd", "ddd", "dddd"], S = /* @__PURE__ */ new Map();
112
+ function k(e) {
113
+ const t = S.get(e);
114
+ if (t) return t;
115
+ function d(s, r, i = !1) {
116
+ let c;
117
+ try {
118
+ c = new Intl.DateTimeFormat(e, s);
119
+ } catch {
120
+ c = new Intl.DateTimeFormat("en", s);
121
+ }
122
+ return Array.from(
123
+ { length: r },
124
+ (m, h) => c.format(new Date(2026, i ? h : 0, i ? 1 : 4 + h))
125
+ );
126
+ }
127
+ const a = {
128
+ MMM: d({ month: "short" }, 12, !0),
129
+ MMMM: d({ month: "long" }, 12, !0),
130
+ dd: d({ weekday: "narrow" }, 7),
131
+ ddd: d({ weekday: "short" }, 7),
132
+ dddd: d({ weekday: "long" }, 7)
133
+ };
134
+ return S.size >= 16 && S.clear(), S.set(e, a), a;
135
+ }
136
+ function P(e, t = 1, d = 4) {
137
+ t = Number.isFinite(t) ? (Math.trunc(t) % 7 + 7) % 7 : 1, d = Number.isFinite(d) ? Math.max(1, Math.min(7, Math.trunc(d))) : 4;
138
+ const a = (m) => {
139
+ const h = u(m, 0, d);
140
+ return h - (M(h).weekday - t + 7) % 7;
141
+ }, s = e - (M(e).weekday - t + 7) % 7;
142
+ let r = M(e).year;
143
+ s < a(r) ? r-- : s >= a(r + 1) && r++;
144
+ const i = Math.max(W, s), c = Math.min(p, s + 6);
108
145
  return {
109
- year: o,
110
- week: Math.floor((r - n(o)) / 7) + 1,
111
- start: g(m),
112
- end: g(c),
146
+ year: r,
147
+ week: Math.floor((s - a(r)) / 7) + 1,
148
+ start: x(i),
149
+ end: x(c),
113
150
  dates: Array.from(
114
- { length: Math.max(0, c - m + 1) },
115
- (l, h) => g(m + h)
151
+ { length: Math.max(0, c - i + 1) },
152
+ (m, h) => x(i + h)
116
153
  )
117
154
  };
118
155
  }
119
- function q(e, t, i = 1, n = 4) {
120
- const r = u(e.day), o = W(e.day, i, n), m = {
156
+ function L(e, t, d = 1, a = 4, s = "en") {
157
+ const r = M(e.day), i = P(e.day, d, a), c = Math.floor(e.second / 3600), m = Math.floor(e.second / 60) % 60, h = e.second % 60, Y = {
121
158
  YYYY: String(r.year).padStart(4, "0"),
122
- GGGG: String(o.year).padStart(4, "0"),
159
+ GGGG: String(i.year).padStart(4, "0"),
123
160
  MM: String(r.month + 1).padStart(2, "0"),
124
161
  DD: String(r.day).padStart(2, "0"),
125
162
  HH: String(Math.floor(e.second / 3600)).padStart(2, "0"),
126
163
  mm: String(Math.floor(e.second / 60) % 60).padStart(2, "0"),
127
164
  ss: String(e.second % 60).padStart(2, "0"),
128
- WW: String(o.week).padStart(2, "0"),
129
- Q: String(Math.floor(r.month / 3) + 1)
165
+ WW: String(i.week).padStart(2, "0"),
166
+ Q: String(Math.floor(r.month / 3) + 1),
167
+ M: String(r.month + 1),
168
+ D: String(r.day),
169
+ H: String(c),
170
+ h: String(c % 12 || 12),
171
+ hh: String(c % 12 || 12).padStart(2, "0"),
172
+ m: String(m),
173
+ s: String(h),
174
+ A: c < 12 ? "AM" : "PM",
175
+ a: c < 12 ? "am" : "pm"
130
176
  };
131
177
  return t.replace(
132
- G,
133
- (c) => c.startsWith("[") ? c.slice(1, -1) : m[c]
178
+ H,
179
+ (f) => f.startsWith("[") ? f.slice(1, -1) : T.includes(f) ? k(s)[f][f.startsWith("M") ? r.month : r.weekday] : Y[f]
134
180
  );
135
181
  }
136
- function E(e, t = "YYYY-MM-DD", i = 1, n = 4) {
182
+ function E(e, t = "YYYY-MM-DD", d = 1, a = 4, s = "en") {
137
183
  if (e instanceof Date || typeof e == "number") {
138
- const a = e instanceof Date ? e : new Date(e);
139
- if (!Number.isFinite(a.getTime())) return;
140
- const s = N(a);
141
- return s === void 0 ? void 0 : {
142
- day: s,
143
- second: a.getHours() * 3600 + a.getMinutes() * 60 + a.getSeconds()
184
+ const n = e instanceof Date ? e : new Date(e);
185
+ if (!Number.isFinite(n.getTime())) return;
186
+ const o = Q(n);
187
+ return o === void 0 ? void 0 : {
188
+ day: o,
189
+ second: n.getHours() * 3600 + n.getMinutes() * 60 + n.getSeconds()
144
190
  };
145
191
  }
146
192
  if (typeof e != "string" || !e.trim()) return;
147
193
  if (t === "x" || t === "X")
148
194
  return /^-?\d+(?:\.\d+)?$/.test(e) ? E(Number(e) * (t === "X" ? 1e3 : 1)) : void 0;
149
- const r = {}, o = [];
150
- let m = 0, c = "";
151
- for (const a of t.matchAll(G)) {
152
- c += w(t.slice(m, a.index));
153
- const s = a[0];
154
- s.startsWith("[") ? c += w(s.slice(1, -1)) : (o.push(s), c += s === "Q" ? "(\\d)" : s === "YYYY" || s === "GGGG" ? "(\\d{4})" : "(\\d{2})"), m = a.index + s.length;
195
+ const r = {}, i = [];
196
+ let c = 0, m = "";
197
+ for (const n of t.matchAll(H)) {
198
+ m += D(t.slice(c, n.index));
199
+ const o = n[0];
200
+ o.startsWith("[") ? m += D(o.slice(1, -1)) : (i.push(o), m += T.includes(o) ? "(" + k(s)[o].map(D).join("|") + ")" : o === "A" || o === "a" ? "(AM|PM|am|pm)" : o === "Q" ? "(\\d)" : o === "YYYY" || o === "GGGG" ? "(\\d{4})" : o.length === 1 ? "(\\d{1,2})" : "(\\d{2})"), c = n.index + o.length;
155
201
  }
156
- c += w(t.slice(m));
157
- const l = new RegExp("^" + c + "$").exec(e);
158
- if (!l || !o.some((a) => a === "YYYY" || a === "GGGG") || new Set(o).size !== o.length)
202
+ m += D(t.slice(c));
203
+ const h = new RegExp("^" + m + "$").exec(e.trim());
204
+ if (!h || !i.some((n) => n === "YYYY" || n === "GGGG") || new Set(i).size !== i.length)
159
205
  return;
160
- o.forEach((a, s) => r[a] = +l[s + 1]);
161
- const h = r.YYYY ?? r.GGGG, Y = r.MM ?? (r.Q ? (r.Q - 1) * 3 + 1 : 1), y = r.DD ?? 1, p = r.HH ?? 0, k = r.mm ?? 0, x = r.ss ?? 0;
162
- if (h < 1 || h > 9999 || Y < 1 || Y > 12 || y < 1 || y > 31 || p > 23 || k > 59 || x > 59 || r.Q !== void 0 && (r.Q < 1 || r.Q > 4))
206
+ i.forEach((n, o) => {
207
+ n === "MMM" || n === "MMMM" ? r[n] = k(s)[n].indexOf(h[o + 1]) + 1 : n.startsWith("d") || (r[n] = n === "A" || n === "a" ? +(h[o + 1].toLowerCase() === "pm") : +h[o + 1]);
208
+ });
209
+ const Y = r.hh ?? r.h, f = r.A ?? r.a;
210
+ if (Y !== void 0 && (Y < 1 || Y > 12)) return;
211
+ const y = r.YYYY ?? r.GGGG, g = r.MM ?? r.M ?? r.MMM ?? r.MMMM ?? (r.Q ? (r.Q - 1) * 3 + 1 : 1), w = r.DD ?? r.D ?? 1, G = Y === void 0 ? r.HH ?? r.H ?? 0 : Y % 12 + (f ?? 0) * 12, N = r.mm ?? r.m ?? 0, C = r.ss ?? r.s ?? 0;
212
+ if (y < 1 || y > 9999 || g < 1 || g > 12 || w < 1 || w > 31 || G > 23 || N > 59 || C > 59 || r.Q !== void 0 && (r.Q < 1 || r.Q > 4))
163
213
  return;
164
- let f = d(h, Y - 1, y);
214
+ let l = u(y, g - 1, w);
165
215
  if (r.WW !== void 0) {
166
216
  if (r.WW < 1 || r.WW > 53) return;
167
- const a = d(
168
- h,
217
+ const n = u(
218
+ y,
169
219
  0,
170
- Math.max(1, Math.min(7, Math.trunc(n)))
220
+ Math.max(1, Math.min(7, Math.trunc(a)))
171
221
  );
172
- f = a - (u(a).weekday - i + 7) % 7 + (r.WW - 1) * 7;
173
- const s = W(f, i, n);
174
- if (s.week !== r.WW || s.year !== h) return;
175
- } else if (u(f).month !== Y - 1 || u(f).day !== y)
222
+ l = n - (M(n).weekday - d + 7) % 7 + (r.WW - 1) * 7;
223
+ const o = P(l, d, a);
224
+ if (o.week !== r.WW || o.year !== y) return;
225
+ } else if (M(l).month !== g - 1 || M(l).day !== w)
176
226
  return;
177
- if (!(f < M || f > S))
178
- return { day: f, second: p * 3600 + k * 60 + x };
227
+ if (l < W || l > p) return;
228
+ const b = M(l).weekday;
229
+ if (!i.some(
230
+ (n, o) => n.startsWith("d") && k(s)[n][b] !== h[o + 1]
231
+ ))
232
+ return { day: l, second: G * 3600 + N * 60 + C };
233
+ }
234
+ function B(e, t) {
235
+ return E("2000-01-01 " + e.trim(), "YYYY-MM-DD " + t);
179
236
  }
180
- function w(e) {
237
+ function D(e) {
181
238
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
182
239
  }
183
- function I(e) {
184
- const t = C(e.day);
240
+ function U(e) {
241
+ const t = F(e.day);
185
242
  return t.setHours(
186
243
  Math.floor(e.second / 3600),
187
244
  Math.floor(e.second / 60) % 60,
@@ -189,39 +246,41 @@ function I(e) {
189
246
  0
190
247
  ), t;
191
248
  }
192
- function T(e, t) {
193
- return e instanceof Date && t instanceof Date ? e.getTime() === t.getTime() : Array.isArray(e) && Array.isArray(t) ? e.length === t.length && e.every((i, n) => T(i, t[n])) : Object.is(e, t);
249
+ function O(e, t) {
250
+ return e instanceof Date && t instanceof Date ? e.getTime() === t.getTime() : Array.isArray(e) && Array.isArray(t) ? e.length === t.length && e.every((d, a) => O(d, t[a])) : Object.is(e, t);
194
251
  }
195
- function z(e) {
252
+ function V(e) {
196
253
  return e instanceof Date ? new Date(e) : Array.isArray(e) ? e.map((t) => t instanceof Date ? new Date(t) : t) : e;
197
254
  }
198
- function X(e) {
255
+ function J(e) {
199
256
  try {
200
257
  return new Intl.DateTimeFormat(e, { month: "long" });
201
258
  } catch {
202
259
  return new Intl.DateTimeFormat("zh-CN", { month: "long" });
203
260
  }
204
261
  }
205
- function _(e, t) {
206
- return Math.max(M, Math.min(S, A(e, t)));
262
+ function Z(e, t) {
263
+ return Math.max(W, Math.min(p, v(e, t)));
207
264
  }
208
265
  export {
209
- S as DATE_MAX,
210
- M as DATE_MIN,
211
- z as dateClone,
212
- T as dateEqual,
213
- q as dateFormat,
214
- X as dateLocale,
215
- F as dateMultiple,
216
- I as dateNative,
217
- O as datePattern,
218
- $ as datePeriod,
219
- P as datePickerDefaults,
220
- b as datePickerEnglish,
221
- Q as datePickerWords,
266
+ p as DATE_MAX,
267
+ W as DATE_MIN,
268
+ B as dateClockPoint,
269
+ V as dateClone,
270
+ O as dateEqual,
271
+ L as dateFormat,
272
+ J as dateLocale,
273
+ j as dateMultiple,
274
+ U as dateNative,
275
+ R as datePattern,
276
+ X as datePeriod,
277
+ I as datePickerDefaults,
278
+ z as datePickerEnglish,
279
+ q as datePickerWords,
222
280
  E as datePoint,
223
- _ as dateShift,
224
- v as dateTimeSeconds,
225
- D as dateUnit,
226
- W as dateWeek
281
+ _ as dateRange,
282
+ Z as dateShift,
283
+ K as dateTimeSeconds,
284
+ A as dateUnit,
285
+ P as dateWeek
227
286
  };
@@ -0,0 +1,156 @@
1
+ import { ref as j, computed as n, watch as B } from "vue";
2
+ import { useChoiceModel as I } from "./choiceModel.js";
3
+ import { dateUnit as G, dateMultiple as J, datePattern as H, datePickerEnglish as K, datePickerWords as L, dateEqual as D, dateClone as Y, datePoint as g, dateNative as E, dateFormat as N, datePeriod as Q } from "./datePicker.js";
4
+ function p(t, i) {
5
+ const A = j("string"), M = n(
6
+ () => t.type === "datetime" || t.type === "datetimerange" || !!t.showTime && (t.picker ?? G(t.type)) === "date"
7
+ ), r = n(() => t.picker ?? G(t.type)), W = n(
8
+ () => i.value && r.value === "date" && t.defaultTime !== void 0
9
+ ), c = n(() => !i.value && J(t.type)), v = n(
10
+ () => Number.isFinite(t.firstDayOfWeek) ? (Math.trunc(t.firstDayOfWeek) % 7 + 7) % 7 : 1
11
+ ), C = n(
12
+ () => Number.isFinite(t.firstWeekContainsDate) ? Math.max(1, Math.min(7, Math.trunc(t.firstWeekContainsDate))) : 4
13
+ ), f = n(
14
+ () => t.valueFormat ?? H(r.value, M.value)
15
+ ), h = n(() => {
16
+ const e = t.format;
17
+ return (typeof e == "string" || typeof e == "function" ? e : e == null ? void 0 : e[0]) ?? (r.value === "week" ? "GGGG-[W]WW" : H(r.value, M.value));
18
+ }), S = n(() => {
19
+ var e;
20
+ return {
21
+ ...L,
22
+ ...(e = t.locale) != null && e.startsWith("en") ? K : {},
23
+ ...t.messages
24
+ };
25
+ }), b = I(
26
+ {
27
+ get modelValue() {
28
+ return t.modelValue === void 0 ? t.value : t.modelValue;
29
+ }
30
+ },
31
+ () => Y(
32
+ t.defaultValue ?? (i.value ? ["", ""] : c.value ? [] : "")
33
+ ),
34
+ D
35
+ ), u = b.current, o = n(
36
+ () => t.valueType ?? (m(u.value) ? A.value : u.value instanceof Date || Array.isArray(u.value) && u.value.some((e) => e instanceof Date) ? "date" : typeof u.value == "number" || Array.isArray(u.value) && u.value.some((e) => typeof e == "number") ? "timestamp" : A.value)
37
+ );
38
+ function y(e) {
39
+ return g(
40
+ e,
41
+ f.value,
42
+ v.value,
43
+ C.value,
44
+ t.locale
45
+ );
46
+ }
47
+ function P(e) {
48
+ return y(e) ?? g(e, "YYYY-MM-DD") ?? g(e, "YYYY-MM-DD HH:mm:ss") ?? g(e, "YYYY-MM-DD[T]HH:mm:ss");
49
+ }
50
+ function k(e) {
51
+ return {
52
+ day: Q(e.day, r.value, v.value)[0],
53
+ second: M.value || W.value ? e.second : 0
54
+ };
55
+ }
56
+ let T;
57
+ function m(e) {
58
+ var a;
59
+ return e == null || e === "" || ((a = t.emptyValues) == null ? void 0 : a.some((l) => D(e, l))) || t.clearValue !== void 0 && D(e, t.clearValue) || typeof t.valueOnClear != "function" && t.valueOnClear !== void 0 && D(e, t.valueOnClear) || T !== void 0 && D(e, T);
60
+ }
61
+ function w(e = u.value) {
62
+ if (m(e)) return i.value ? [null, null] : [];
63
+ if (i.value)
64
+ return Array.from({ length: 2 }, (l, d) => {
65
+ const s = Array.isArray(e) && !m(e[d]) ? y(e[d]) : void 0;
66
+ return s ? k(s) : null;
67
+ });
68
+ if (c.value) {
69
+ const l = /* @__PURE__ */ new Set();
70
+ return (Array.isArray(e) ? e : []).flatMap((d) => {
71
+ const s = m(d) ? void 0 : y(d);
72
+ if (!s) return [];
73
+ const V = k(s);
74
+ return r.value === "week" && l.has(V.day) ? [] : (l.add(V.day), [V]);
75
+ });
76
+ }
77
+ const a = y(e);
78
+ return a ? [k(a)] : [];
79
+ }
80
+ const x = n(() => w()), z = n(() => P(t.min)), q = n(() => P(t.max));
81
+ function O(e) {
82
+ const a = E(e);
83
+ return o.value === "date" ? a : o.value === "timestamp" ? a.getTime() : f.value === "x" ? String(a.getTime()) : f.value === "X" ? String(Math.floor(a.getTime() / 1e3)) : N(
84
+ e,
85
+ f.value,
86
+ v.value,
87
+ C.value,
88
+ t.locale
89
+ );
90
+ }
91
+ function U(e) {
92
+ return i.value || c.value ? e.map(
93
+ (a) => a ? O(a) : o.value === "string" ? "" : null
94
+ ) : e[0] ? O(e[0]) : F();
95
+ }
96
+ function F() {
97
+ if (t.valueOnClear !== void 0) {
98
+ const e = typeof t.valueOnClear == "function" ? t.valueOnClear() : t.valueOnClear;
99
+ return Y(e);
100
+ }
101
+ return t.clearValue !== void 0 ? Y(t.clearValue) : i.value ? o.value === "string" ? ["", ""] : [null, null] : c.value ? [] : o.value === "string" ? "" : null;
102
+ }
103
+ function X(e = x.value) {
104
+ return e.map(
105
+ (a) => a ? typeof h.value == "function" ? h.value(E(a)) : N(
106
+ a,
107
+ h.value,
108
+ v.value,
109
+ C.value,
110
+ t.locale
111
+ ) : ""
112
+ );
113
+ }
114
+ B(
115
+ u,
116
+ (e) => {
117
+ if (m(e)) return;
118
+ const a = Array.isArray(e) ? e : [e], l = a.find((d) => !m(d));
119
+ l !== void 0 && (A.value = l instanceof Date ? "date" : typeof l == "number" ? "timestamp" : "string");
120
+ },
121
+ { immediate: !0, flush: "sync" }
122
+ );
123
+ function _(e) {
124
+ T = Y(e);
125
+ }
126
+ return {
127
+ time: M,
128
+ rangeDefaultTime: W,
129
+ unit: r,
130
+ multiple: c,
131
+ first: v,
132
+ weekContains: C,
133
+ pattern: f,
134
+ displayPattern: h,
135
+ words: S,
136
+ model: b,
137
+ current: u,
138
+ outputType: o,
139
+ parse: y,
140
+ boundary: P,
141
+ normalize: k,
142
+ isEmpty: m,
143
+ points: w,
144
+ selected: x,
145
+ minPoint: z,
146
+ maxPoint: q,
147
+ encodePoint: O,
148
+ encode: U,
149
+ empty: F,
150
+ describe: X,
151
+ markClear: _
152
+ };
153
+ }
154
+ export {
155
+ p as useDatePickerModel
156
+ };
@@ -0,0 +1,78 @@
1
+ import { ref as y, computed as k } from "vue";
2
+ import { civilDay as j, calendarParts as E } from "./calendar.js";
3
+ import { dateShift as z, dateNative as A, DATE_MIN as T, DATE_MAX as _ } from "./datePicker.js";
4
+ function K({
5
+ props: l,
6
+ unit: t,
7
+ range: w,
8
+ time: M,
9
+ selected: V,
10
+ minPoint: F,
11
+ maxPoint: I,
12
+ boundary: f,
13
+ encodePoint: g,
14
+ emit: i
15
+ }) {
16
+ const r = y(
17
+ l.defaultMode ?? (t.value === "week" ? "date" : t.value)
18
+ ), c = y(r.value), s = y(0), o = y(0), P = k(() => {
19
+ var u, n, v, d;
20
+ const e = ((n = f(((u = l.panelValues) == null ? void 0 : u[0]) ?? l.panelValue)) == null ? void 0 : n.day) ?? s.value, a = (d = f((v = l.panelValues) == null ? void 0 : v[1])) == null ? void 0 : d.day;
21
+ return [
22
+ e,
23
+ a ?? (l.panelValue !== void 0 && !l.unlinkPanels ? h(e, 1) : o.value)
24
+ ];
25
+ }), D = k(() => t.value === "week" ? "date" : t.value), m = k(() => {
26
+ const e = l.mode ?? r.value;
27
+ return e === "time" && !M.value ? D.value : e;
28
+ });
29
+ function R(e) {
30
+ var d, q, B, C;
31
+ const a = l.defaultPickerValue, u = Array.isArray(a) ? a[0] : a, n = N(
32
+ ((d = V.value.find(Boolean)) == null ? void 0 : d.day) ?? ((q = f(u)) == null ? void 0 : q.day) ?? e
33
+ );
34
+ s.value = n;
35
+ const v = ((B = V.value[1]) == null ? void 0 : B.day) ?? (Array.isArray(a) ? (C = f(a[1])) == null ? void 0 : C.day : void 0);
36
+ o.value = (l.unlinkPanels || !V.value.some(Boolean) && Array.isArray(a)) && v !== void 0 ? N(v) : h(n, 1), r.value = l.defaultMode ?? (t.value === "week" ? "date" : t.value), c.value = r.value === "time" ? D.value : r.value;
37
+ }
38
+ function N(e) {
39
+ var a, u;
40
+ return Math.max(
41
+ ((a = F.value) == null ? void 0 : a.day) ?? T,
42
+ Math.min(((u = I.value) == null ? void 0 : u.day) ?? _, e)
43
+ );
44
+ }
45
+ function h(e, a) {
46
+ const u = t.value === "year" ? 144 : t.value === "month" || t.value === "quarter" ? 12 : 1;
47
+ return z(e, a * u);
48
+ }
49
+ function S(e, a = 0) {
50
+ if (!Number.isFinite(e) || e < T || e > _) return !1;
51
+ const u = j(
52
+ E(e).year,
53
+ E(e).month,
54
+ 1
55
+ ), n = [...P.value];
56
+ return n[a] = u, l.unlinkPanels || (n[1 - a] = h(u, a ? -1 : 1)), !l.panelValues && a === 0 ? (l.panelValue === void 0 && (s.value = u), i("update:panelValue", g({ day: u, second: 0 })), w.value && !l.unlinkPanels && (o.value = n[1])) : l.panelValues || (o.value = u, l.unlinkPanels || (l.panelValue === void 0 && (s.value = n[0]), i("update:panelValue", g({ day: n[0], second: 0 })))), w.value && i(
57
+ "update:panelValues",
58
+ n.map((v) => A({ day: v, second: 0 }))
59
+ ), i(
60
+ "panelChange",
61
+ A({ day: u, second: 0 }),
62
+ a ? c.value : m.value,
63
+ { index: a }
64
+ ), !0;
65
+ }
66
+ function X(e, a = 0) {
67
+ return !["date", "month", "quarter", "year", "decade", "time"].includes(e) || e === "time" && !M.value ? !1 : (a ? c.value = e : (l.mode === void 0 && (r.value = e), i("update:mode", e)), i(
68
+ "panelChange",
69
+ A({ day: P.value[a], second: 0 }),
70
+ e,
71
+ { index: a }
72
+ ), a ? !0 : m.value === e);
73
+ }
74
+ return { currentView: m, rightView: c, panels: P, resetPanels: R, setPanel: S, setMode: X };
75
+ }
76
+ export {
77
+ K as useDatePickerPanels
78
+ };