@manik02/vue3-timepicker 0.4.3 → 0.4.4

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.
@@ -1,5 +1,5 @@
1
- import { defineComponent as Se, ref as L, onMounted as ge, onBeforeUnmount as be, createElementBlock as X, openBlock as G, normalizeClass as oe, createElementVNode as ae, Fragment as we, renderList as Ne, toDisplayString as He, nextTick as xe, computed as c, watch as F, createCommentVNode as ne, createVNode as ye, createBlock as ke, normalizeStyle as ue, unref as O } from "vue";
2
- const Le = ["tabindex", "onClick", "onMousemove"], de = /* @__PURE__ */ Se({
1
+ import { defineComponent as Ae, ref as $, onMounted as ye, onBeforeUnmount as ke, createElementBlock as X, openBlock as G, normalizeClass as oe, createElementVNode as ae, Fragment as Ee, renderList as Re, toDisplayString as Ce, nextTick as Ie, computed as c, watch as F, createCommentVNode as te, createVNode as Te, createBlock as Se, normalizeStyle as de, unref as O } from "vue";
2
+ const Fe = ["tabindex", "onClick", "onMousemove"], ce = /* @__PURE__ */ Ae({
3
3
  __name: "TimeColumn",
4
4
  props: {
5
5
  items: {},
@@ -7,153 +7,150 @@ const Le = ["tabindex", "onClick", "onMousemove"], de = /* @__PURE__ */ Se({
7
7
  },
8
8
  emits: ["update:activeIndex", "select"],
9
9
  setup(e, { emit: n }) {
10
- const s = e, t = n, p = L(null), b = L(!1);
11
- let l = null;
12
- function E(f) {
13
- const A = Array.from(f.querySelectorAll(".timepicker-option"));
14
- if (!A.length) return 0;
15
- const S = f.scrollTop + f.clientHeight / 2;
16
- let D = 0, $ = Number.POSITIVE_INFINITY;
17
- for (let I = 0; I < A.length; I++) {
18
- const K = A[I], r = K.offsetTop + K.offsetHeight / 2, u = Math.abs(r - S);
19
- u < $ && ($ = u, D = I);
10
+ const s = e, t = n, v = $(null), y = $(!1);
11
+ let d = null;
12
+ function D(p) {
13
+ const S = Array.from(p.querySelectorAll(".timepicker-option"));
14
+ if (!S.length) return 0;
15
+ const A = p.scrollTop + p.clientHeight / 2;
16
+ let M = 0, B = Number.POSITIVE_INFINITY;
17
+ for (let P = 0; P < S.length; P++) {
18
+ const U = S[P], r = U.offsetTop + U.offsetHeight / 2, u = Math.abs(r - A);
19
+ u < B && (B = u, M = P);
20
20
  }
21
- return D;
21
+ return M;
22
22
  }
23
- function N(f) {
23
+ function E(p) {
24
24
  if (!s.items.length) return 0;
25
- if (!s.items[f]?.disabled) return f;
26
- for (let A = 1; A < s.items.length; A++) {
27
- const S = f - A, D = f + A;
28
- if (S >= 0 && !s.items[S]?.disabled) return S;
29
- if (D < s.items.length && !s.items[D]?.disabled) return D;
25
+ if (!s.items[p]?.disabled) return p;
26
+ for (let S = 1; S < s.items.length; S++) {
27
+ const A = p - S, M = p + S;
28
+ if (A >= 0 && !s.items[A]?.disabled) return A;
29
+ if (M < s.items.length && !s.items[M]?.disabled) return M;
30
30
  }
31
- return f;
31
+ return p;
32
32
  }
33
33
  function w() {
34
- xe(() => {
35
- const f = p.value;
36
- if (!f) return;
37
- const A = f.querySelector(
34
+ Ie(() => {
35
+ const p = v.value;
36
+ if (!p) return;
37
+ const S = p.querySelector(
38
38
  ".timepicker-option--active"
39
39
  );
40
- if (A) {
41
- const S = f.clientHeight, D = A.offsetTop, $ = A.offsetHeight, I = D - S / 2 + $ / 2;
42
- b.value = !0, f.scrollTo({ top: I, behavior: "auto" }), l && clearTimeout(l), l = setTimeout(() => {
43
- b.value = !1;
40
+ if (S) {
41
+ const A = p.clientHeight, M = S.offsetTop, B = S.offsetHeight, P = M - A / 2 + B / 2;
42
+ y.value = !0, p.scrollTo({ top: P, behavior: "auto" }), d && clearTimeout(d), d = setTimeout(() => {
43
+ y.value = !1;
44
44
  }, 70);
45
45
  }
46
46
  });
47
47
  }
48
48
  function _() {
49
- const f = p.value;
50
- if (!f || b.value) return;
51
- const A = E(f), S = N(A);
52
- s.items[S]?.disabled || (H.value = S);
49
+ const p = v.value;
50
+ if (!p || y.value) return;
51
+ const S = D(p), A = E(S);
52
+ s.items[A]?.disabled || (N.value = A);
53
53
  }
54
- ge(w), be(() => {
55
- l && clearTimeout(l);
54
+ ye(w), ke(() => {
55
+ d && clearTimeout(d);
56
56
  });
57
- function k(f) {
58
- t("update:activeIndex", f), t("select", s.items[f]?.value);
57
+ function T(p) {
58
+ t("update:activeIndex", p), t("select", s.items[p]?.value);
59
59
  }
60
- function M(f) {
61
- k(f);
60
+ function I(p) {
61
+ T(p);
62
62
  }
63
- const H = L(s.activeIndex ?? 0);
64
- return (f, A) => (G(), X("div", {
63
+ const N = $(s.activeIndex ?? 0);
64
+ return (p, S) => (G(), X("div", {
65
65
  class: oe(["timepicker-dropdown", {
66
- "timepicker-dropdown--short": f.items.length <= 3
66
+ "timepicker-dropdown--short": p.items.length <= 3
67
67
  }])
68
68
  }, [
69
69
  ae("div", {
70
70
  ref_key: "menu",
71
- ref: p,
71
+ ref: v,
72
72
  class: "timepicker-dropdown__panel",
73
73
  role: "listbox",
74
74
  tabindex: "-1",
75
75
  onScroll: _
76
76
  }, [
77
- (G(!0), X(we, null, Ne(f.items, (S, D) => (G(), X("div", {
78
- key: S.key,
77
+ (G(!0), X(Ee, null, Re(p.items, (A, M) => (G(), X("div", {
78
+ key: A.key,
79
79
  class: oe(["timepicker-option", {
80
- "timepicker-option--active": D === f.activeIndex,
81
- "timepicker-option--disabled": S.disabled,
82
- "timepicker-option--focused": D === H.value
80
+ "timepicker-option--active": M === p.activeIndex,
81
+ "timepicker-option--disabled": A.disabled,
82
+ "timepicker-option--focused": M === N.value
83
83
  }]),
84
84
  role: "option",
85
- tabindex: S.disabled ? -1 : 0,
86
- onClick: ($) => !S.disabled && M(D),
87
- onMousemove: ($) => !S.disabled && (H.value = D)
88
- }, He(S.text), 43, Le))), 128))
85
+ tabindex: A.disabled ? -1 : 0,
86
+ onClick: (B) => !A.disabled && I(M),
87
+ onMousemove: (B) => !A.disabled && (N.value = M)
88
+ }, Ce(A.text), 43, Fe))), 128))
89
89
  ], 544)
90
90
  ], 2));
91
91
  }
92
92
  });
93
- function Ae(e) {
93
+ function Me(e) {
94
94
  return e.h * 3600 + e.m * 60 + e.s;
95
95
  }
96
- function Pe(e) {
96
+ function Ne(e) {
97
97
  return /(a|A|p|P)/.test(e);
98
98
  }
99
- function Re(e) {
100
- return /(p|P)/.test(e);
101
- }
102
- function Te(e) {
99
+ function xe(e) {
103
100
  return /k{1,2}/.test(e);
104
101
  }
105
102
  function Y(e, n) {
106
103
  if (!e || typeof e != "string") return { h: 0, m: 0, s: 0 };
107
104
  const s = e.match(/\d+/g) || [];
108
105
  let t = s[0] !== void 0 ? +s[0] : 0;
109
- const p = +s[1] || 0, b = +s[2] || 0;
110
- return { h: t, m: p, s: b };
106
+ const v = +s[1] || 0, y = +s[2] || 0;
107
+ return { h: t, m: v, s: y };
111
108
  }
112
- function Ce(e) {
109
+ function Be(e) {
113
110
  const n = e % 12;
114
111
  return n === 0 ? 12 : n;
115
112
  }
116
- function Ie(e, n) {
113
+ function Ve(e, n) {
117
114
  return n ? e % 12 + 12 : e % 12;
118
115
  }
119
- function Fe(e) {
116
+ function _e(e) {
120
117
  return /(s|ss)/.test(e);
121
118
  }
122
- function ce(e, n) {
123
- let { h: s, m: t, s: p } = n;
124
- const b = Pe(e), l = s >= 12 ? "PM" : "AM";
125
- b && (s = Ce(s));
126
- const E = s === 0 ? 24 : s, N = {
119
+ function me(e, n) {
120
+ let { h: s, m: t, s: v } = n;
121
+ const y = Ne(e), d = s >= 12 ? "PM" : "AM";
122
+ y && (s = Be(s));
123
+ const D = s === 0 ? 24 : s, E = {
127
124
  HH: String(s).padStart(2, "0"),
128
125
  H: String(s),
129
126
  hh: String(s).padStart(2, "0"),
130
127
  h: String(s),
131
- kk: String(E).padStart(2, "0"),
132
- k: String(E),
128
+ kk: String(D).padStart(2, "0"),
129
+ k: String(D),
133
130
  mm: String(t).padStart(2, "0"),
134
131
  m: String(t),
135
- ss: String(p).padStart(2, "0"),
136
- s: String(p),
137
- A: l,
138
- a: l.toLowerCase(),
139
- P: l,
140
- p: l.toLowerCase()
132
+ ss: String(v).padStart(2, "0"),
133
+ s: String(v),
134
+ A: d,
135
+ a: d.toLowerCase(),
136
+ P: d,
137
+ p: d.toLowerCase()
141
138
  };
142
- return e.replace(/HH|hh|kk|mm|ss|H|h|k|m|s|A|a|P|p/g, (w) => N[w] ?? w);
139
+ return e.replace(/HH|hh|kk|mm|ss|H|h|k|m|s|A|a|P|p/g, (w) => E[w] ?? w);
143
140
  }
144
- function q(e, n) {
145
- return Ae(e) - Ae(n);
141
+ function j(e, n) {
142
+ return Me(e) - Me(n);
146
143
  }
147
- function Be(e, n, s) {
148
- return n && q(e, n) < 0 ? { ...n } : s && q(e, s) > 0 ? { ...s } : { ...e };
144
+ function We(e, n, s) {
145
+ return n && j(e, n) < 0 ? { ...n } : s && j(e, s) > 0 ? { ...s } : { ...e };
149
146
  }
150
- function De(e, n, s) {
151
- return !(n && q(e, n) < 0 || s && q(e, s) > 0);
147
+ function $e(e, n, s) {
148
+ return !(n && j(e, n) < 0 || s && j(e, s) > 0);
152
149
  }
153
- function $e(e, n) {
154
- return n.some(([s, t]) => q(e, s) >= 0 && q(e, t) <= 0);
150
+ function He(e, n) {
151
+ return n.some(([s, t]) => j(e, s) >= 0 && j(e, t) <= 0);
155
152
  }
156
- const Me = /* @__PURE__ */ Se({
153
+ const we = /* @__PURE__ */ Ae({
157
154
  __name: "TimeSelection",
158
155
  props: {
159
156
  open: { type: Boolean },
@@ -172,232 +169,236 @@ const Me = /* @__PURE__ */ Se({
172
169
  function s(a) {
173
170
  return Math.max(1, a ?? 1);
174
171
  }
175
- const t = c(() => Pe(l.format)), p = c(() => Fe(l.format)), b = c(() => Te(l.format)), l = e, E = n, N = c({
176
- get: () => l.open ?? !1,
172
+ const t = c(() => Ne(d.format)), v = c(() => _e(d.format)), y = c(() => xe(d.format)), d = e, D = n, E = c({
173
+ get: () => d.open ?? !1,
177
174
  set: (a) => {
178
- const d = l.open ?? !1;
179
- a !== d && (E("update:open", a), E(a ? "open" : "close"));
175
+ const l = d.open ?? !1;
176
+ a !== l && (D("update:open", a), D(a ? "open" : "close"));
180
177
  }
181
- }), w = L(null);
178
+ }), w = $(null);
182
179
  function _(a) {
183
- if (!N.value) return;
184
- const d = a.target;
185
- w.value && !w.value.contains(d) && (N.value = !1);
180
+ if (!E.value) return;
181
+ const l = a.target;
182
+ w.value && !w.value.contains(l) && (E.value = !1);
186
183
  }
187
- ge(() => document.addEventListener("mousedown", _)), be(
184
+ ye(() => document.addEventListener("mousedown", _)), ke(
188
185
  () => document.removeEventListener("mousedown", _)
189
186
  );
190
- function k(a) {
191
- a.key === "Escape" && N.value && (N.value = !1);
187
+ function T(a) {
188
+ a.key === "Escape" && E.value && (E.value = !1);
189
+ }
190
+ ye(() => document.addEventListener("keydown", T)), ke(() => document.removeEventListener("keydown", T));
191
+ const I = $(0), N = $(0), p = $(0), S = $(0);
192
+ function A(a) {
193
+ const l = s(d.hourStep), g = s(d.minuteStep), k = s(d.secondStep);
194
+ let V = a.h;
195
+ t.value ? (S.value = a.h >= 12 ? 1 : 0, V = a.h % 12) : y.value && a.h === 0 && (V = 24), I.value = Math.floor(V / l), N.value = Math.floor(a.m / g), p.value = Math.floor(a.s / k);
192
196
  }
193
- ge(() => document.addEventListener("keydown", k)), be(() => document.removeEventListener("keydown", k));
194
- const M = L(Math.floor(l.initTime.h / l.hourStep) || 0), H = L(Math.floor(l.initTime.m / l.minuteStep) || 0), f = L(Math.floor(l.initTime.s / l.secondStep) || 0);
195
197
  F(
196
- () => l.initTime,
198
+ () => d.initTime,
197
199
  (a) => {
198
- const d = s(l.hourStep), h = s(l.minuteStep), T = s(l.secondStep);
199
- let V = a.h;
200
- t.value ? ($.value = a.h >= 12 ? 1 : 0, V = a.h % 12) : b.value && a.h === 0 && (V = 24), M.value = Math.floor(V / d), H.value = Math.floor(a.m / h), f.value = Math.floor(a.s / T);
201
- }
200
+ A(a);
201
+ },
202
+ { immediate: !0 }
202
203
  );
203
- function A(a, d) {
204
- const h = [];
205
- for (let T = 0; T < a; T += s(d))
206
- h.push({ key: T, value: T, text: String(T).padStart(2, "0") });
207
- return h;
204
+ function M(a, l) {
205
+ const g = [];
206
+ for (let k = 0; k < a; k += s(l))
207
+ g.push({ key: k, value: k, text: String(k).padStart(2, "0") });
208
+ return g;
208
209
  }
209
- function S(a, d) {
210
- const h = s(d), T = [];
211
- for (let V = 0; V < 12; V += h) {
212
- const ie = V === 0 ? 12 : V, j = a ? V === 0 ? 12 : V + 12 : V;
213
- T.push({ key: j, value: j, text: String(ie).padStart(2, "0") });
210
+ function B(a, l) {
211
+ const g = s(l), k = [];
212
+ for (let V = 0; V < 12; V += g) {
213
+ const ie = V === 0 ? 12 : V, J = a ? V === 0 ? 12 : V + 12 : V;
214
+ k.push({ key: J, value: J, text: String(ie).padStart(2, "0") });
214
215
  }
215
- return T;
216
+ return k;
216
217
  }
217
- function D(a) {
218
- const d = s(a), h = [];
219
- for (let T = 0; T < 24; T += d) {
220
- const V = T === 0 ? 24 : T;
221
- h.push({ key: T, value: T, text: String(V).padStart(2, "0") });
218
+ function P(a) {
219
+ const l = s(a), g = [];
220
+ for (let k = 0; k < 24; k += l) {
221
+ const V = k === 0 ? 24 : k;
222
+ g.push({ key: k, value: k, text: String(V).padStart(2, "0") });
222
223
  }
223
- return h;
224
+ return g;
224
225
  }
225
- const $ = L(Re(l.format) ? 1 : 0), I = c(() => {
226
+ const U = c(() => {
226
227
  if (!t.value)
227
- return b.value ? D(l.hourStep) : A(24, l.hourStep);
228
- const a = $.value === 1;
229
- return S(a, l.hourStep);
230
- }), K = c(() => A(60, l.minuteStep)), r = c(() => A(60, l.secondStep)), u = c(() => /\s[ap]$/.test(l.format)), m = c(() => {
231
- const a = u.value ? "am" : "AM", d = u.value ? "pm" : "PM";
228
+ return y.value ? P(d.hourStep) : M(24, d.hourStep);
229
+ const a = S.value === 1;
230
+ return B(a, d.hourStep);
231
+ }), r = c(() => M(60, d.minuteStep)), u = c(() => M(60, d.secondStep)), m = c(() => /\s[ap]$/.test(d.format)), b = c(() => {
232
+ const a = m.value ? "am" : "AM", l = m.value ? "pm" : "PM";
232
233
  return [
233
234
  { key: "AM", value: "AM", text: a },
234
- { key: "PM", value: "PM", text: d }
235
+ { key: "PM", value: "PM", text: l }
235
236
  ];
236
- }), y = c(
237
- () => K.value.map((a) => Number(a.value ?? 0))
238
- ), v = c(() => p.value ? r.value.map((a) => Number(a.value ?? 0)) : [0]);
239
- function x(a) {
237
+ }), h = c(
238
+ () => r.value.map((a) => Number(a.value ?? 0))
239
+ ), x = c(() => v.value ? u.value.map((a) => Number(a.value ?? 0)) : [0]);
240
+ function z(a) {
240
241
  return Number(a.value ?? 0);
241
242
  }
242
- function z(a) {
243
- const d = a.findIndex((h) => !h.disabled);
244
- return d >= 0 ? d : 0;
243
+ function pe(a) {
244
+ const l = a.findIndex((g) => !g.disabled);
245
+ return l >= 0 ? l : 0;
245
246
  }
246
- function J(a) {
247
- return !(!De(a, l.minTime, l.maxTime) || $e(a, l.disabledRanges ?? []) || l.isTimeDisabled?.(a));
247
+ function K(a) {
248
+ return !(!$e(a, d.minTime, d.maxTime) || He(a, d.disabledRanges ?? []) || d.isTimeDisabled?.(a));
248
249
  }
249
- const U = c(() => I.value.map((a) => {
250
- const d = x(a), h = y.value.some(
251
- (T) => v.value.some(
252
- (V) => J({ h: d, m: T, s: V })
250
+ const Z = c(() => U.value.map((a) => {
251
+ const l = z(a), g = h.value.some(
252
+ (k) => x.value.some(
253
+ (V) => K({ h: l, m: k, s: V })
253
254
  )
254
255
  );
255
256
  return {
256
257
  ...a,
257
- disabled: !h
258
+ disabled: !g
258
259
  };
259
- })), Z = c(() => {
260
- const a = Number(I.value[M.value]?.value ?? 0);
261
- return K.value.map((d) => {
262
- const h = Number(d.value ?? 0), T = v.value.some(
263
- (V) => J({ h: a, m: h, s: V })
260
+ })), re = c(() => {
261
+ const a = Number(U.value[I.value]?.value ?? 0);
262
+ return r.value.map((l) => {
263
+ const g = Number(l.value ?? 0), k = x.value.some(
264
+ (V) => K({ h: a, m: g, s: V })
264
265
  );
265
266
  return {
266
- ...d,
267
- disabled: !T
267
+ ...l,
268
+ disabled: !k
268
269
  };
269
270
  });
270
- }), re = c(() => {
271
- const a = Number(I.value[M.value]?.value ?? 0), d = Number(
272
- K.value[H.value]?.value ?? 0
271
+ }), se = c(() => {
272
+ const a = Number(U.value[I.value]?.value ?? 0), l = Number(
273
+ r.value[N.value]?.value ?? 0
273
274
  );
274
- return r.value.map((h) => {
275
- const T = Number(h.value ?? 0);
275
+ return u.value.map((g) => {
276
+ const k = Number(g.value ?? 0);
276
277
  return {
277
- ...h,
278
- disabled: !J({
278
+ ...g,
279
+ disabled: !K({
279
280
  h: a,
280
- m: d,
281
- s: T
281
+ m: l,
282
+ s: k
282
283
  })
283
284
  };
284
285
  });
285
- }), se = c(() => {
286
- if (!t.value) return m.value;
287
- const a = Number(K.value[H.value]?.value ?? 0), d = p.value ? Number(r.value[f.value]?.value ?? 0) : 0;
288
- return m.value.map((h) => {
289
- const T = h.value === "PM", V = S(T, l.hourStep).some(
290
- (ie) => J({
286
+ }), ue = c(() => {
287
+ if (!t.value) return b.value;
288
+ const a = Number(r.value[N.value]?.value ?? 0), l = v.value ? Number(u.value[p.value]?.value ?? 0) : 0;
289
+ return b.value.map((g) => {
290
+ const k = g.value === "PM", V = B(k, d.hourStep).some(
291
+ (ie) => K({
291
292
  h: Number(ie.value ?? 0),
292
293
  m: a,
293
- s: d
294
+ s: l
294
295
  })
295
296
  );
296
297
  return {
297
- ...h,
298
+ ...g,
298
299
  disabled: !V
299
300
  };
300
301
  });
301
- }), fe = c(() => $.value === 1 ? "PM" : "AM"), pe = c(() => {
302
- const a = Number(I.value[M.value]?.value ?? 0);
303
- return t.value ? fe.value === "PM" ? Ie(a, !0) : Ie(a, !1) : b.value && a === 24 ? 0 : a;
304
- }), ee = c(
305
- () => Number(K.value[H.value]?.value ?? 0)
306
- ), ve = c(
307
- () => Number(r.value[f.value]?.value ?? 0)
302
+ }), ve = c(() => S.value === 1 ? "PM" : "AM"), ee = c(() => {
303
+ const a = Number(U.value[I.value]?.value ?? 0);
304
+ return t.value ? ve.value === "PM" ? Ve(a, !0) : Ve(a, !1) : y.value && a === 24 ? 0 : a;
305
+ }), he = c(
306
+ () => Number(r.value[N.value]?.value ?? 0)
307
+ ), ge = c(
308
+ () => Number(u.value[p.value]?.value ?? 0)
308
309
  );
309
- function te(a, d, h) {
310
- a.length && (!a[d] || a[d].disabled) && h(z(a));
310
+ function q(a, l, g) {
311
+ a.length && (!a[l] || a[l].disabled) && g(pe(a));
311
312
  }
312
- F(U, (a) => {
313
- te(a, M.value, (d) => {
314
- M.value = d;
315
- });
316
- }), F(Z, (a) => {
317
- te(a, H.value, (d) => {
318
- H.value = d;
313
+ F(Z, (a) => {
314
+ q(a, I.value, (l) => {
315
+ I.value = l;
319
316
  });
320
317
  }), F(re, (a) => {
321
- !p.value || !a.length || te(a, f.value, (d) => {
322
- f.value = d;
318
+ q(a, N.value, (l) => {
319
+ N.value = l;
323
320
  });
324
321
  }), F(se, (a) => {
325
- !t.value || !a.length || te(a, $.value, (d) => {
326
- $.value = d;
322
+ !v.value || !a.length || q(a, p.value, (l) => {
323
+ p.value = l;
324
+ });
325
+ }), F(ue, (a) => {
326
+ !t.value || !a.length || q(a, S.value, (l) => {
327
+ S.value = l;
327
328
  });
328
329
  });
329
- function le(a) {
330
- !p.value && !t.value && C();
331
- }
332
330
  function R(a) {
333
- t.value || C();
331
+ !v.value && !t.value && ne();
332
+ }
333
+ function be(a) {
334
+ t.value || ne();
334
335
  }
335
- function he(a) {
336
- C();
336
+ function W(a) {
337
+ ne();
337
338
  }
338
- function C() {
339
- N.value = !1;
339
+ function ne() {
340
+ E.value = !1;
340
341
  }
341
342
  return F(
342
- [pe, ee, ve],
343
- ([a, d, h]) => {
344
- E("update:initTime", { h: a, m: d, s: h });
343
+ [ee, he, ge],
344
+ ([a, l, g]) => {
345
+ D("update:initTime", { h: a, m: l, s: g });
345
346
  },
346
347
  { immediate: !0 }
347
- ), (a, d) => N.value ? (G(), X("div", {
348
+ ), (a, l) => E.value ? (G(), X("div", {
348
349
  key: 0,
349
350
  class: "vtp-cols",
350
351
  ref_key: "root",
351
352
  ref: w
352
353
  }, [
353
- ye(de, {
354
- activeIndex: M.value,
355
- "onUpdate:activeIndex": d[0] || (d[0] = (h) => M.value = h),
356
- items: U.value,
354
+ Te(ce, {
355
+ activeIndex: I.value,
356
+ "onUpdate:activeIndex": l[0] || (l[0] = (g) => I.value = g),
357
+ items: Z.value,
357
358
  label: "Hours"
358
359
  }, null, 8, ["activeIndex", "items"]),
359
- ye(de, {
360
- activeIndex: H.value,
361
- "onUpdate:activeIndex": d[1] || (d[1] = (h) => H.value = h),
362
- items: Z.value,
360
+ Te(ce, {
361
+ activeIndex: N.value,
362
+ "onUpdate:activeIndex": l[1] || (l[1] = (g) => N.value = g),
363
+ items: re.value,
363
364
  label: "Minutes",
364
- onSelect: le
365
+ onSelect: R
365
366
  }, null, 8, ["activeIndex", "items"]),
366
- p.value ? (G(), ke(de, {
367
+ v.value ? (G(), Se(ce, {
367
368
  key: 0,
368
- activeIndex: f.value,
369
- "onUpdate:activeIndex": d[2] || (d[2] = (h) => f.value = h),
370
- items: re.value,
369
+ activeIndex: p.value,
370
+ "onUpdate:activeIndex": l[2] || (l[2] = (g) => p.value = g),
371
+ items: se.value,
371
372
  label: "Seconds",
372
- onSelect: R
373
- }, null, 8, ["activeIndex", "items"])) : ne("", !0),
374
- t.value ? (G(), ke(de, {
373
+ onSelect: be
374
+ }, null, 8, ["activeIndex", "items"])) : te("", !0),
375
+ t.value ? (G(), Se(ce, {
375
376
  key: 1,
376
- activeIndex: $.value,
377
- "onUpdate:activeIndex": d[3] || (d[3] = (h) => $.value = h),
378
- items: se.value,
377
+ activeIndex: S.value,
378
+ "onUpdate:activeIndex": l[3] || (l[3] = (g) => S.value = g),
379
+ items: ue.value,
379
380
  label: "AM/PM",
380
- onSelect: he
381
- }, null, 8, ["activeIndex", "items"])) : ne("", !0)
382
- ], 512)) : ne("", !0);
381
+ onSelect: W
382
+ }, null, 8, ["activeIndex", "items"])) : te("", !0)
383
+ ], 512)) : te("", !0);
383
384
  }
384
385
  });
385
- function _e(e) {
386
+ function Ke(e) {
386
387
  return typeof e == "string" ? Q.test(e) : Array.isArray(e) ? e.length === 2 && Q.test(e[0] ?? "") && Q.test(e[1] ?? "") : !1;
387
388
  }
388
- function me(e) {
389
+ function fe(e) {
389
390
  return e == null || typeof e == "string" || typeof e == "number";
390
391
  }
391
- function We(e) {
392
+ function Ue(e) {
392
393
  return e == null || typeof e == "string" || Array.isArray(e) || typeof e == "object" && e !== null;
393
394
  }
394
- const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]\d|2[0-3]):([0-5]\d)(:([0-5]\d))?$/, B = typeof __DEV__ < "u" ? __DEV__ : typeof process < "u" && process.env && process.env.NODE_ENV !== "production", Ke = {
395
+ const Le = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]\d|2[0-3]):([0-5]\d)(:([0-5]\d))?$/, C = typeof __DEV__ < "u" ? __DEV__ : typeof process < "u" && process.env && process.env.NODE_ENV !== "production", Oe = {
395
396
  modelValue: {
396
397
  type: [String, Array],
397
398
  default: void 0,
398
399
  validator: (e) => {
399
400
  let n;
400
- return Array.isArray(e) ? n = e.length === 2 && e.every((s) => Q.test(s)) : n = e == null || Q.test(e), !n && B && console.error(
401
+ return Array.isArray(e) ? n = e.length === 2 && e.every((s) => Q.test(s)) : n = e == null || Q.test(e), !n && C && console.error(
401
402
  `[VueTimepicker] \`modelValue\` is wrong. Received: ${e}`
402
403
  ), n;
403
404
  }
@@ -422,7 +423,7 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
422
423
  default: void 0,
423
424
  validator: (e) => {
424
425
  const n = e == null || Q.test(e);
425
- return !n && B && console.error(`[VueTimepicker] \`minTime\` is wrong. Received: ${e}`), n;
426
+ return !n && C && console.error(`[VueTimepicker] \`minTime\` is wrong. Received: ${e}`), n;
426
427
  }
427
428
  },
428
429
  maxTime: {
@@ -430,15 +431,15 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
430
431
  default: void 0,
431
432
  validator: (e) => {
432
433
  const n = e == null || Q.test(e);
433
- return !n && B && console.error(`[VueTimepicker] \`maxTime\` is wrong. Received: ${e}`), n;
434
+ return !n && C && console.error(`[VueTimepicker] \`maxTime\` is wrong. Received: ${e}`), n;
434
435
  }
435
436
  },
436
437
  disabledTimes: {
437
438
  type: Array,
438
439
  default: void 0,
439
440
  validator: (e) => {
440
- const n = e == null || e.every(_e);
441
- return !n && B && console.error(
441
+ const n = e == null || e.every(Ke);
442
+ return !n && C && console.error(
442
443
  `[VueTimepicker] \`disabledTimes\` is wrong. Received: ${JSON.stringify(e)}`
443
444
  ), n;
444
445
  }
@@ -451,8 +452,8 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
451
452
  type: String,
452
453
  default: "HH:mm",
453
454
  validator: (e) => {
454
- const n = Ee.test(e);
455
- return !n && B && console.error(
455
+ const n = Le.test(e);
456
+ return !n && C && console.error(
456
457
  `[VueTimepicker] \`format\` format is wrong. Received: ${e}`
457
458
  ), n;
458
459
  }
@@ -466,7 +467,7 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
466
467
  default: void 0,
467
468
  validator: (e) => {
468
469
  const n = e == null || typeof e == "string";
469
- return !n && B && console.error(
470
+ return !n && C && console.error(
470
471
  `[VueTimepicker] \`id\` must be a string. Received: ${e}`
471
472
  ), n;
472
473
  }
@@ -476,7 +477,7 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
476
477
  default: void 0,
477
478
  validator: (e) => {
478
479
  const n = e == null || typeof e == "string";
479
- return !n && B && console.error(
480
+ return !n && C && console.error(
480
481
  `[VueTimepicker] \`name\` must be a string. Received: ${e}`
481
482
  ), n;
482
483
  }
@@ -486,7 +487,7 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
486
487
  default: 0,
487
488
  validator: (e) => {
488
489
  const n = Number.isInteger(e);
489
- return !n && B && console.error(
490
+ return !n && C && console.error(
490
491
  `[VueTimepicker] \`tabindex\` must be an integer. Received: ${e}`
491
492
  ), n;
492
493
  }
@@ -496,7 +497,7 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
496
497
  default: "off",
497
498
  validator: (e) => {
498
499
  const n = typeof e == "string";
499
- return !n && B && console.error(
500
+ return !n && C && console.error(
500
501
  `[VueTimepicker] \`autocomplete\` must be a string. Received: ${e}`
501
502
  ), n;
502
503
  }
@@ -505,8 +506,8 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
505
506
  type: [String, Array, Object],
506
507
  default: void 0,
507
508
  validator: (e) => {
508
- const n = We(e);
509
- return !n && B && console.error(
509
+ const n = Ue(e);
510
+ return !n && C && console.error(
510
511
  `[VueTimepicker] \`inputClass\` must be a string, array, or object. Received: ${e}`
511
512
  ), n;
512
513
  }
@@ -515,8 +516,8 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
515
516
  type: [String, Number],
516
517
  default: void 0,
517
518
  validator: (e) => {
518
- const n = me(e);
519
- return !n && B && console.error(
519
+ const n = fe(e);
520
+ return !n && C && console.error(
520
521
  `[VueTimepicker] \`inputWidth\` must be a string or number. Received: ${e}`
521
522
  ), n;
522
523
  }
@@ -525,8 +526,8 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
525
526
  type: [String, Number],
526
527
  default: void 0,
527
528
  validator: (e) => {
528
- const n = me(e);
529
- return !n && B && console.error(
529
+ const n = fe(e);
530
+ return !n && C && console.error(
530
531
  `[VueTimepicker] \`componentWidth\` must be a string or number. Received: ${e}`
531
532
  ), n;
532
533
  }
@@ -535,8 +536,8 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
535
536
  type: [String, Number],
536
537
  default: void 0,
537
538
  validator: (e) => {
538
- const n = me(e);
539
- return !n && B && console.error(
539
+ const n = fe(e);
540
+ return !n && C && console.error(
540
541
  `[VueTimepicker] \`minInputWidth\` must be a string or number. Received: ${e}`
541
542
  ), n;
542
543
  }
@@ -545,8 +546,8 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
545
546
  type: [String, Number],
546
547
  default: void 0,
547
548
  validator: (e) => {
548
- const n = me(e);
549
- return !n && B && console.error(
549
+ const n = fe(e);
550
+ return !n && C && console.error(
550
551
  `[VueTimepicker] \`maxInputWidth\` must be a string or number. Received: ${e}`
551
552
  ), n;
552
553
  }
@@ -556,173 +557,180 @@ const Ee = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, Q = /^([01]
556
557
  default: "md",
557
558
  validator: (e) => {
558
559
  const n = e === "xs" || e === "sm" || e === "md" || e === "lg" || e === "xl";
559
- return !n && B && console.error(`[VueTimepicker] \`size\` is wrong. Received: ${e}`), n;
560
+ return !n && C && console.error(`[VueTimepicker] \`size\` is wrong. Received: ${e}`), n;
560
561
  }
561
562
  }
562
563
  };
563
- function Ue(e) {
564
- const n = Ee.exec(e);
564
+ function Pe(e) {
565
+ const n = Le.exec(e);
565
566
  if (!n) throw new Error(`[useTimeMask] Invalid format: ${e}`);
566
- const [, s, t, p, b] = n, l = [], E = !!b, N = /^k{1,2}$/.test(s);
567
+ const [, s, t, v, y] = n, d = [], D = !!y, E = /^k{1,2}$/.test(s);
567
568
  let w = 0, _ = 23;
568
- return E ? (w = 1, _ = 12) : N && (w = 1, _ = 24), l.push({ token: s, min: w, max: _ }), l.push({ token: t, min: 0, max: 59 }), p && l.push({ token: p, min: 0, max: 59 }), {
569
- digitGroups: l,
570
- hasAmPm: !!b,
571
- ampmLowercase: b === "a" || b === "p"
569
+ return D ? (w = 1, _ = 12) : E && (w = 1, _ = 24), d.push({ token: s, min: w, max: _ }), d.push({ token: t, min: 0, max: 59 }), v && d.push({ token: v, min: 0, max: 59 }), {
570
+ digitGroups: d,
571
+ hasAmPm: !!y,
572
+ ampmLowercase: y === "a" || y === "p"
572
573
  };
573
574
  }
574
- function Ve(e) {
575
- const n = c(() => Ue(e.value)), s = c(() => n.value.digitGroups.length * 2), t = L([]), p = L("AM"), b = L("");
576
- function l() {
575
+ function Ge(e) {
576
+ try {
577
+ return Pe(e);
578
+ } catch {
579
+ return Pe("HH:mm");
580
+ }
581
+ }
582
+ function De(e) {
583
+ const n = c(() => Ge(e.value)), s = c(() => n.value.digitGroups.length * 2), t = $([]), v = $("AM"), y = $("");
584
+ function d() {
577
585
  const { digitGroups: r, hasAmPm: u } = n.value;
578
- let m = "", y = 0;
579
- for (let v = 0; v < r.length; v++) {
586
+ let m = "", b = 0;
587
+ for (let h = 0; h < r.length; h++) {
580
588
  for (let x = 0; x < 2; x++)
581
- y < t.value.length && (m += String(t.value[y]), y++);
582
- y === (v + 1) * 2 && v < r.length - 1 && (m += ":");
589
+ b < t.value.length && (m += String(t.value[b]), b++);
590
+ b === (h + 1) * 2 && h < r.length - 1 && (m += ":");
583
591
  }
584
- if (u && y >= s.value) {
585
- const v = n.value.ampmLowercase ? p.value.toLowerCase() : p.value;
586
- m += " " + v;
592
+ if (u && b >= s.value) {
593
+ const h = n.value.ampmLowercase ? v.value.toLowerCase() : v.value;
594
+ m += " " + h;
587
595
  }
588
596
  return m;
589
597
  }
590
- function E(r) {
598
+ function D(r) {
591
599
  const u = r * 2;
592
600
  if (t.value.length < u + 2) return;
593
- const m = t.value[u] * 10 + t.value[u + 1], { min: y, max: v } = n.value.digitGroups[r], x = Math.max(y, Math.min(v, m));
601
+ const m = t.value[u] * 10 + t.value[u + 1], { min: b, max: h } = n.value.digitGroups[r], x = Math.max(b, Math.min(h, m));
594
602
  x !== m && (t.value[u] = Math.floor(x / 10), t.value[u + 1] = x % 10);
595
603
  }
596
- function N() {
604
+ function E() {
597
605
  for (let r = 0; r < n.value.digitGroups.length; r++)
598
- E(r);
606
+ D(r);
599
607
  }
600
608
  function w(r) {
601
- const u = l();
609
+ const u = d();
602
610
  let m = 0;
603
- for (let y = 0; y < Math.min(r, u.length); y++)
604
- /\d/.test(u[y]) && m++;
611
+ for (let b = 0; b < Math.min(r, u.length); b++)
612
+ /\d/.test(u[b]) && m++;
605
613
  return m;
606
614
  }
607
615
  function _(r) {
608
616
  return r + Math.floor(r / 2);
609
617
  }
610
- function k(r, u) {
618
+ function T(r, u) {
611
619
  if (r >= s.value) return s.value;
612
620
  const m = [...t.value];
613
621
  m[r] = u, t.value = m;
614
- const y = Math.floor(r / 2);
615
- return E(y), Math.min(r + 1, s.value);
622
+ const b = Math.floor(r / 2);
623
+ return D(b), Math.min(r + 1, s.value);
616
624
  }
617
- function M(r, u) {
618
- const m = l();
619
- b.value = m, r.value = m;
620
- const y = u !== void 0 ? Math.min(_(u), m.length) : m.length;
621
- r.selectionStart = r.selectionEnd = y, xe(() => {
622
- document.activeElement === r && (r.selectionStart = r.selectionEnd = y);
625
+ function I(r, u) {
626
+ const m = d();
627
+ y.value = m, r.value = m;
628
+ const b = u !== void 0 ? Math.min(_(u), m.length) : m.length;
629
+ r.selectionStart = r.selectionEnd = b, Ie(() => {
630
+ document.activeElement === r && (r.selectionStart = r.selectionEnd = b);
623
631
  });
624
632
  }
625
- function H(r) {
633
+ function N(r) {
626
634
  const u = r.key, m = r.target;
627
635
  if (["Tab", "Escape", "ArrowLeft", "ArrowRight", "Home", "End"].includes(
628
636
  u
629
637
  ) || r.metaKey || r.ctrlKey)
630
638
  return;
631
639
  r.preventDefault();
632
- const y = m.selectionStart ?? 0, v = w(y);
640
+ const b = m.selectionStart ?? 0, h = w(b);
633
641
  if (u === "Backspace") {
634
- v > 0 && M(m, v - 1);
642
+ h > 0 && I(m, h - 1);
635
643
  return;
636
644
  }
637
645
  if (u !== "Delete") {
638
646
  if (n.value.hasAmPm) {
639
647
  const x = u.toLowerCase();
640
648
  if (x === "a") {
641
- p.value = "AM", M(m, v);
649
+ v.value = "AM", I(m, h);
642
650
  return;
643
651
  }
644
652
  if (x === "p") {
645
- p.value = "PM", M(m, v);
653
+ v.value = "PM", I(m, h);
646
654
  return;
647
655
  }
648
656
  }
649
657
  if (/^\d$/.test(u)) {
650
- const x = k(v, +u);
651
- M(m, x);
658
+ const x = T(h, +u);
659
+ I(m, x);
652
660
  return;
653
661
  }
654
662
  }
655
663
  }
656
- function f(r) {
664
+ function p(r) {
657
665
  const u = r.target, m = u.value.replace(/\D/g, "").split("").map(Number).slice(0, s.value);
658
- t.value = m, N(), n.value.hasAmPm && (/p/i.test(u.value) ? p.value = "PM" : /a/i.test(u.value) && (p.value = "AM")), M(u);
666
+ t.value = m, E(), n.value.hasAmPm && (/p/i.test(u.value) ? v.value = "PM" : /a/i.test(u.value) && (v.value = "AM")), I(u);
659
667
  }
660
- function A(r) {
668
+ function S(r) {
661
669
  r.preventDefault();
662
- const u = r.clipboardData?.getData("text") ?? "", m = r.target, y = m.selectionStart ?? 0, v = u.replace(/\D/g, "").split("").map(Number);
663
- let x = w(y);
664
- for (const z of v) {
670
+ const u = r.clipboardData?.getData("text") ?? "", m = r.target, b = m.selectionStart ?? 0, h = u.replace(/\D/g, "").split("").map(Number);
671
+ let x = w(b);
672
+ for (const z of h) {
665
673
  if (x >= s.value) break;
666
- x = k(x, z);
674
+ x = T(x, z);
667
675
  }
668
- n.value.hasAmPm && (/p\.?m\.?/i.test(u) ? p.value = "PM" : /a\.?m\.?/i.test(u) && (p.value = "AM")), M(m, x);
676
+ n.value.hasAmPm && (/p\.?m\.?/i.test(u) ? v.value = "PM" : /a\.?m\.?/i.test(u) && (v.value = "AM")), I(m, x);
669
677
  }
670
- function S(r) {
671
- const { digitGroups: u, hasAmPm: m } = n.value, y = [];
672
- let v = r.h;
673
- m ? (p.value = r.h >= 12 ? "PM" : "AM", v = r.h % 12, v === 0 && (v = 12)) : Te(e.value) && (v = r.h === 0 ? 24 : r.h), y.push(Math.floor(v / 10), v % 10), y.push(Math.floor(r.m / 10), r.m % 10), u.length > 2 && y.push(Math.floor(r.s / 10), r.s % 10), t.value = y, b.value = l();
678
+ function A(r) {
679
+ const { digitGroups: u, hasAmPm: m } = n.value, b = [];
680
+ let h = r.h;
681
+ m ? (v.value = r.h >= 12 ? "PM" : "AM", h = r.h % 12, h === 0 && (h = 12)) : xe(e.value) && (h = r.h === 0 ? 24 : r.h), b.push(Math.floor(h / 10), h % 10), b.push(Math.floor(r.m / 10), r.m % 10), u.length > 2 && b.push(Math.floor(r.s / 10), r.s % 10), t.value = b, y.value = d();
674
682
  }
675
- function D() {
676
- t.value = [], b.value = "", p.value = "AM";
683
+ function M() {
684
+ t.value = [], y.value = "", v.value = "AM";
677
685
  }
678
- function $() {
686
+ function B() {
679
687
  if (t.value.length < s.value) return null;
680
688
  const r = [];
681
- for (let v = 0; v < n.value.digitGroups.length; v++) {
682
- const x = v * 2;
689
+ for (let h = 0; h < n.value.digitGroups.length; h++) {
690
+ const x = h * 2;
683
691
  r.push(t.value[x] * 10 + t.value[x + 1]);
684
692
  }
685
693
  let u = r[0];
686
- const m = r[1], y = r[2] ?? 0;
687
- return n.value.hasAmPm && (u = p.value === "PM" ? u === 12 ? 12 : u + 12 : u === 12 ? 0 : u), Te(e.value) && u === 24 && (u = 0), { h: u, m, s: y };
694
+ const m = r[1], b = r[2] ?? 0;
695
+ return n.value.hasAmPm && (u = v.value === "PM" ? u === 12 ? 12 : u + 12 : u === 12 ? 0 : u), xe(e.value) && u === 24 && (u = 0), { h: u, m, s: b };
688
696
  }
689
- const I = c(
697
+ const P = c(
690
698
  () => t.value.length >= s.value
691
- ), K = c(() => n.value.ampmLowercase);
699
+ ), U = c(() => n.value.ampmLowercase);
692
700
  return {
693
- inputValue: b,
694
- handleKeydown: H,
695
- handleInput: f,
696
- handlePaste: A,
697
- setFromTime: S,
698
- clear: D,
699
- getParsedTime: $,
700
- isComplete: I,
701
+ inputValue: y,
702
+ handleKeydown: N,
703
+ handleInput: p,
704
+ handlePaste: S,
705
+ setFromTime: A,
706
+ clear: M,
707
+ getParsedTime: B,
708
+ isComplete: P,
701
709
  totalDigits: s,
702
710
  displayPosToDigitIndex: w,
703
- ampm: p,
704
- ampmLowercase: K
711
+ ampm: v,
712
+ ampmLowercase: U
705
713
  };
706
714
  }
707
- const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name", "tabindex", "autocomplete", "value", "placeholder", "disabled"], ze = ["id", "name", "tabindex", "autocomplete", "value", "placeholder", "disabled"], qe = /* @__PURE__ */ Se({
715
+ const ze = ["data-size", "data-validation", "data-disabled"], je = ["id", "name", "tabindex", "autocomplete", "value", "placeholder", "disabled"], qe = ["id", "name", "tabindex", "autocomplete", "value", "placeholder", "disabled"], Ye = /* @__PURE__ */ Ae({
708
716
  __name: "TimePicker",
709
- props: Ke,
717
+ props: Oe,
710
718
  emits: ["update:modelValue", "update:validationState", "validate", "open", "close", "error"],
711
719
  setup(e, { emit: n }) {
712
- const s = L(null), t = e, p = n, b = L(!1), l = L(!1), E = L("valid"), N = L("valid");
720
+ const s = $(null), t = e, v = n, y = $(!1), d = $(!1), D = $("valid"), E = $("valid");
713
721
  function w() {
714
- b.value = !1, l.value = !1;
722
+ y.value = !1, d.value = !1;
715
723
  }
716
724
  function _(i, o) {
717
725
  if (t.disabled && o) {
718
726
  w();
719
727
  return;
720
728
  }
721
- o && (i === "first" ? l.value = !1 : b.value = !1);
729
+ o && (i === "first" ? d.value = !1 : y.value = !1);
722
730
  }
723
- F(b, (i) => {
731
+ F(y, (i) => {
724
732
  _("first", i);
725
- }), F(l, (i) => {
733
+ }), F(d, (i) => {
726
734
  _("second", i);
727
735
  }), F(
728
736
  () => t.disabled,
@@ -735,7 +743,7 @@ const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name"
735
743
  i && w();
736
744
  }
737
745
  );
738
- const k = c({
746
+ const T = c({
739
747
  get() {
740
748
  if (Array.isArray(t.modelValue)) {
741
749
  const [i, o] = t.modelValue;
@@ -744,98 +752,98 @@ const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name"
744
752
  return Y(t.modelValue, t.format);
745
753
  },
746
754
  set(i) {
747
- Array.isArray(i) ? p("update:modelValue", [
748
- ce("HH:mm:ss", i[0]),
749
- ce("HH:mm:ss", i[1])
750
- ]) : p("update:modelValue", ce("HH:mm:ss", i));
755
+ Array.isArray(i) ? v("update:modelValue", [
756
+ me("HH:mm:ss", i[0]),
757
+ me("HH:mm:ss", i[1])
758
+ ]) : v("update:modelValue", me("HH:mm:ss", i));
751
759
  }
752
- }), M = c(
760
+ }), I = c(
753
761
  () => t.minTime ? Y(t.minTime) : null
754
- ), H = c(
762
+ ), N = c(
755
763
  () => t.maxTime ? Y(t.maxTime) : null
756
- ), f = c(() => !M.value || !H.value ? !0 : q(M.value, H.value) <= 0), A = c(() => E.value === "out-of-range" || t.range && N.value === "out-of-range" ? "out-of-range" : E.value === "invalid" || t.range && N.value === "invalid" ? "invalid" : "valid"), S = c(() => (t.disabledTimes ?? []).map((o) => {
757
- const g = Array.isArray(o) ? o : [o, o], W = Y(g[0]), P = Y(g[1]);
758
- return q(W, P) <= 0 ? [W, P] : [P, W];
764
+ ), p = c(() => !I.value || !N.value ? !0 : j(I.value, N.value) <= 0), S = c(() => D.value === "out-of-range" || t.range && E.value === "out-of-range" ? "out-of-range" : D.value === "invalid" || t.range && E.value === "invalid" ? "invalid" : "valid"), A = c(() => (t.disabledTimes ?? []).map((o) => {
765
+ const f = Array.isArray(o) ? o : [o, o], H = Y(f[0]), L = Y(f[1]);
766
+ return j(H, L) <= 0 ? [H, L] : [L, H];
759
767
  }));
760
- function D(i) {
761
- return !!($e(i, S.value) || t.isTimeDisabled?.(i));
768
+ function M(i) {
769
+ return !!(He(i, A.value) || t.isTimeDisabled?.(i));
762
770
  }
763
- function $(i) {
764
- return i === "first" ? Array.isArray(k.value) ? k.value[0] : k.value : Array.isArray(k.value) ? k.value[1] : k.value;
771
+ function B(i) {
772
+ return i === "first" ? Array.isArray(T.value) ? T.value[0] : T.value : Array.isArray(T.value) ? T.value[1] : T.value;
765
773
  }
766
- function I(i) {
774
+ function P(i) {
767
775
  const o = t.modelValue;
768
776
  return Array.isArray(o) ? i === "first" ? !!o[0] : !!o[1] : i === "second" ? !1 : typeof o == "string" && o.length > 0;
769
777
  }
770
- function K(i, o) {
778
+ function U(i, o) {
771
779
  if (i === "first") {
772
- Array.isArray(k.value) ? k.value = [o, k.value[1]] : k.value = o;
780
+ Array.isArray(T.value) ? T.value = [o, T.value[1]] : T.value = o;
773
781
  return;
774
782
  }
775
- Array.isArray(k.value) && (k.value = [k.value[0], o]);
783
+ Array.isArray(T.value) && (T.value = [T.value[0], o]);
776
784
  }
777
- function r(i, o, g, W) {
778
- if (i === "first" ? E.value = o : N.value = o, p("validate", {
785
+ function r(i, o, f, H) {
786
+ if (i === "first" ? D.value = o : E.value = o, v("validate", {
779
787
  target: i,
780
788
  state: o,
781
- reason: g,
782
- value: W ? ce("HH:mm:ss", W) : null
789
+ reason: f,
790
+ value: H ? me("HH:mm:ss", H) : null
783
791
  }), o === "valid") {
784
792
  s.value = null;
785
793
  return;
786
794
  }
787
795
  if (o === "out-of-range") {
788
- s.value = "OUT_OF_RANGE", p("error", {
796
+ s.value = "OUT_OF_RANGE", v("error", {
789
797
  code: "OUT_OF_RANGE",
790
798
  message: "Time is outside min/max bounds and was clamped."
791
799
  });
792
800
  return;
793
801
  }
794
- s.value = g ?? "BAD_TIME", p("error", {
795
- code: g ?? "BAD_TIME",
796
- message: g === "DISABLED" ? "Time is disabled by disabledTimes or isTimeDisabled." : "Time is invalid."
802
+ s.value = f ?? "BAD_TIME", v("error", {
803
+ code: f ?? "BAD_TIME",
804
+ message: f === "DISABLED" ? "Time is disabled by disabledTimes or isTimeDisabled." : "Time is invalid."
797
805
  });
798
806
  }
799
807
  F(
800
- A,
808
+ S,
801
809
  (i) => {
802
- p("update:validationState", i);
810
+ v("update:validationState", i);
803
811
  },
804
812
  { immediate: !0 }
805
813
  );
806
814
  const u = c(
807
- () => f.value ? M.value : null
815
+ () => p.value ? I.value : null
808
816
  ), m = c(
809
- () => f.value ? H.value : null
817
+ () => p.value ? N.value : null
810
818
  );
811
- function y(i) {
812
- return Be(
819
+ function b(i) {
820
+ return We(
813
821
  i,
814
822
  u.value,
815
823
  m.value
816
824
  );
817
825
  }
818
- function v(i, o, g) {
819
- const W = !De(
826
+ function h(i, o, f) {
827
+ const H = !$e(
820
828
  o,
821
829
  u.value,
822
830
  m.value
823
- ), P = y(o);
824
- return D(P) ? (g.emitValidation && r(i, "invalid", "DISABLED", P), !1) : (K(i, P), g.emitValidation && (W ? r(i, "out-of-range", "OUT_OF_RANGE", P) : r(i, "valid", void 0, P)), !0);
831
+ ), L = b(o);
832
+ return M(L) ? (f.emitValidation && r(i, "invalid", "DISABLED", L), !1) : (U(i, L), f.emitValidation && (H ? r(i, "out-of-range", "OUT_OF_RANGE", L) : r(i, "valid", void 0, L)), !0);
825
833
  }
826
834
  const x = c({
827
835
  get() {
828
- return Array.isArray(k.value) ? k.value[0] : k.value;
836
+ return Array.isArray(T.value) ? T.value[0] : T.value;
829
837
  },
830
838
  set(i) {
831
- !I("first") && !b.value || v("first", i, { emitValidation: !0 });
839
+ !P("first") && !y.value || h("first", i, { emitValidation: !0 });
832
840
  }
833
841
  }), z = c({
834
842
  get() {
835
- return Array.isArray(k.value) ? k.value[1] : k.value;
843
+ return Array.isArray(T.value) ? T.value[1] : T.value;
836
844
  },
837
845
  set(i) {
838
- !I("second") && !l.value || Array.isArray(k.value) && v("second", i, { emitValidation: !0 });
846
+ !P("second") && !d.value || Array.isArray(T.value) && h("second", i, { emitValidation: !0 });
839
847
  }
840
848
  });
841
849
  F(
@@ -853,25 +861,27 @@ const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name"
853
861
  },
854
862
  { immediate: !0 }
855
863
  );
856
- function J() {
857
- I("first") && v("first", $("first"), {
864
+ function pe() {
865
+ P("first") && h("first", B("first"), {
858
866
  emitValidation: !0
859
- }), t.range && I("second") && v("second", $("second"), {
867
+ }), t.range && P("second") && h("second", B("second"), {
860
868
  emitValidation: !0
861
869
  });
862
870
  }
863
871
  F(
864
- () => [u.value, m.value, t.range],
865
- J,
866
- { immediate: !0 }
867
- ), F(
868
- () => [S.value, t.isTimeDisabled, t.range],
869
- J,
872
+ () => [
873
+ u.value,
874
+ m.value,
875
+ A.value,
876
+ t.isTimeDisabled,
877
+ t.range
878
+ ],
879
+ pe,
870
880
  { immediate: !0 }
871
881
  );
872
- const U = c(() => t.format ?? "HH:mm:ss"), Z = c(() => t.placeholder ?? "Select time"), re = c(() => t.id), se = c(
882
+ const K = c(() => t.format ?? "HH:mm:ss"), Z = c(() => t.placeholder ?? "Select time"), re = c(() => t.id), se = c(
873
883
  () => t.range && t.id ? `${t.id}-end` : void 0
874
- ), fe = c(() => t.name), pe = c(
884
+ ), ue = c(() => t.name), ve = c(
875
885
  () => t.range && t.name ? `${t.name}-end` : void 0
876
886
  );
877
887
  function ee(i) {
@@ -880,26 +890,26 @@ const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name"
880
890
  const o = i.trim();
881
891
  return o.length > 0 ? o : void 0;
882
892
  }
883
- const ve = c(() => {
893
+ const he = c(() => {
884
894
  let i = Math.max(
885
- U.value.length,
895
+ K.value.length,
886
896
  Z.value.length
887
897
  );
888
- return /[AaPp]$/.test(U.value) && (i = Math.max(i, U.value.length + 1)), `${Math.min(20, Math.max(6, i))}ch`;
889
- }), te = c(() => {
890
- const i = {}, o = ee(t.componentWidth), g = ee(t.inputWidth), W = ee(t.minInputWidth), P = ee(t.maxInputWidth);
891
- return o && (i["--vtp-component-width"] = o), g && (i["--vtp-input-width"] = g), W && (i["--vtp-input-min-width"] = W), P && (i["--vtp-input-max-width"] = P), i;
892
- }), le = c(() => ({
893
- width: `var(--vtp-input-width, ${ve.value})`,
898
+ return /[AaPp]$/.test(K.value) && (i = Math.max(i, K.value.length + 1)), `${Math.min(20, Math.max(6, i))}ch`;
899
+ }), ge = c(() => {
900
+ const i = {}, o = ee(t.componentWidth), f = ee(t.inputWidth), H = ee(t.minInputWidth), L = ee(t.maxInputWidth);
901
+ return o && (i["--vtp-component-width"] = o), f && (i["--vtp-input-width"] = f), H && (i["--vtp-input-min-width"] = H), L && (i["--vtp-input-max-width"] = L), i;
902
+ }), q = c(() => ({
903
+ width: `var(--vtp-input-width, ${he.value})`,
894
904
  minWidth: "var(--vtp-input-min-width, 0)",
895
905
  maxWidth: "var(--vtp-input-max-width, none)"
896
- })), R = Ve(U), he = R.inputValue, C = Ve(U), a = C.inputValue, d = L(null), h = L(null), T = c(() => ({
897
- left: `${(t.range && l.value ? h.value : d.value)?.offsetLeft ?? 0}px`
906
+ })), R = De(K), be = R.inputValue, W = De(K), ne = W.inputValue, a = $(null), l = $(null), g = c(() => ({
907
+ left: `${(t.range && d.value ? l.value : a.value)?.offsetLeft ?? 0}px`
898
908
  }));
899
909
  F(
900
- () => [x.value, U.value],
910
+ () => [x.value, K.value],
901
911
  ([i]) => {
902
- if (!I("first")) {
912
+ if (!P("first")) {
903
913
  R.clear();
904
914
  return;
905
915
  }
@@ -907,55 +917,47 @@ const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name"
907
917
  },
908
918
  { immediate: !0 }
909
919
  ), F(
910
- () => [z.value, U.value, t.range],
920
+ () => [z.value, K.value, t.range],
911
921
  ([i, , o]) => {
912
- if (!o || !I("second")) {
913
- C.clear();
922
+ if (!o || !P("second")) {
923
+ W.clear();
914
924
  return;
915
925
  }
916
- C.setFromTime(i);
926
+ W.setFromTime(i);
917
927
  },
918
928
  { immediate: !0 }
919
929
  );
920
- function V(i) {
921
- if (t.disabled) return;
922
- if (i.key === "Enter") {
923
- i.preventDefault(), j("first");
924
- return;
925
- }
926
- /^\d$/.test(i.key) && (b.value = !1, l.value = !1);
927
- const o = i.target, g = R.displayPosToDigitIndex(o.selectionStart ?? 0), W = /^\d$/.test(i.key) && g >= R.totalDigits.value - 1;
928
- if (R.handleKeydown(i), /^\d$/.test(i.key)) {
929
- const P = R.getParsedTime();
930
- P && v("first", P, { emitValidation: !1 });
930
+ function k(i, o, f) {
931
+ if (t.disabled) return !1;
932
+ if (o.key === "Enter")
933
+ return o.preventDefault(), J(i), !1;
934
+ const H = /^\d$/.test(o.key);
935
+ if (H && (y.value = !1, d.value = !1), f.handleKeydown(o), H) {
936
+ const L = f.getParsedTime();
937
+ L && h(i, L, { emitValidation: !1 });
931
938
  }
932
- t.range && W && h.value && (j("first"), xe(() => {
933
- const P = h.value;
934
- P && (P.focus(), P.selectionStart = P.selectionEnd = 0);
939
+ return H;
940
+ }
941
+ function V(i) {
942
+ const o = i.target, f = R.displayPosToDigitIndex(o.selectionStart ?? 0), H = /^\d$/.test(i.key) && f >= R.totalDigits.value - 1;
943
+ k("first", i, R) && t.range && H && l.value && (J("first"), Ie(() => {
944
+ const le = l.value;
945
+ le && (le.focus(), le.selectionStart = le.selectionEnd = 0);
935
946
  }));
936
947
  }
937
948
  function ie(i) {
938
- if (!t.disabled) {
939
- if (i.key === "Enter") {
940
- i.preventDefault(), j("second");
941
- return;
942
- }
943
- if (/^\d$/.test(i.key) && (b.value = !1, l.value = !1), C.handleKeydown(i), /^\d$/.test(i.key)) {
944
- const o = C.getParsedTime();
945
- o && v("second", o, { emitValidation: !1 });
946
- }
947
- }
949
+ k("second", i, W);
948
950
  }
949
- function j(i) {
950
- const o = i === "first" ? R : C, g = o.getParsedTime();
951
- g ? v(i, g, { emitValidation: !0 }) : o.inputValue.value.trim() ? r(i, "invalid", "BAD_TIME") : !t.range && i === "first" && (p("update:modelValue", null), r("first", "valid")), i === "first" ? I("first") ? R.setFromTime(x.value) : R.clear() : t.range && (I("second") ? C.setFromTime(z.value) : C.clear());
951
+ function J(i) {
952
+ const o = i === "first" ? R : W, f = o.getParsedTime();
953
+ f ? h(i, f, { emitValidation: !0 }) : o.inputValue.value.trim() ? r(i, "invalid", "BAD_TIME") : !t.range && i === "first" && (v("update:modelValue", null), r("first", "valid")), i === "first" ? P("first") ? R.setFromTime(x.value) : R.clear() : t.range && (P("second") ? W.setFromTime(z.value) : W.clear());
952
954
  }
953
955
  return (i, o) => (G(), X("div", {
954
956
  class: "timepicker-shell",
955
957
  "data-size": t.size,
956
- "data-validation": A.value,
958
+ "data-validation": S.value,
957
959
  "data-disabled": t.disabled ? "true" : "false",
958
- style: ue(te.value)
960
+ style: de(ge.value)
959
961
  }, [
960
962
  ae("div", {
961
963
  class: oe(["timepicker-shell__input", {
@@ -965,88 +967,88 @@ const Oe = ["data-size", "data-validation", "data-disabled"], Ge = ["id", "name"
965
967
  }, [
966
968
  ae("input", {
967
969
  ref_key: "firstInputRef",
968
- ref: d,
970
+ ref: a,
969
971
  type: "text",
970
972
  class: oe(["timepicker-field", t.inputClass]),
971
973
  id: re.value,
972
- name: fe.value,
974
+ name: ue.value,
973
975
  tabindex: t.tabindex,
974
976
  autocomplete: t.autocomplete,
975
- value: O(he),
977
+ value: O(be),
976
978
  placeholder: Z.value,
977
- style: ue(le.value),
979
+ style: de(q.value),
978
980
  disabled: t.disabled,
979
- onFocus: o[0] || (o[0] = (g) => !t.disabled && !t.hideDropdown && (b.value = !0)),
981
+ onFocus: o[0] || (o[0] = (f) => !t.disabled && !t.hideDropdown && (y.value = !0)),
980
982
  onKeydown: V,
981
983
  onInput: o[1] || (o[1] = //@ts-ignore
982
- (...g) => O(R).handleInput && O(R).handleInput(...g)),
984
+ (...f) => O(R).handleInput && O(R).handleInput(...f)),
983
985
  onPaste: o[2] || (o[2] = //@ts-ignore
984
- (...g) => O(R).handlePaste && O(R).handlePaste(...g)),
985
- onBlur: o[3] || (o[3] = (g) => !t.disabled && j("first"))
986
- }, null, 46, Ge),
987
- t.range ? (G(), X(we, { key: 0 }, [
986
+ (...f) => O(R).handlePaste && O(R).handlePaste(...f)),
987
+ onBlur: o[3] || (o[3] = (f) => !t.disabled && J("first"))
988
+ }, null, 46, je),
989
+ t.range ? (G(), X(Ee, { key: 0 }, [
988
990
  o[12] || (o[12] = ae("span", { class: "timepicker-separator" }, "–", -1)),
989
991
  ae("input", {
990
992
  ref_key: "secondInputRef",
991
- ref: h,
993
+ ref: l,
992
994
  type: "text",
993
995
  class: oe(["timepicker-field", t.inputClass]),
994
996
  id: se.value,
995
- name: pe.value,
997
+ name: ve.value,
996
998
  tabindex: t.tabindex,
997
999
  autocomplete: t.autocomplete,
998
- value: O(a),
1000
+ value: O(ne),
999
1001
  placeholder: Z.value,
1000
- style: ue(le.value),
1002
+ style: de(q.value),
1001
1003
  disabled: t.disabled,
1002
- onFocus: o[4] || (o[4] = (g) => !t.disabled && !t.hideDropdown && (l.value = !0)),
1004
+ onFocus: o[4] || (o[4] = (f) => !t.disabled && !t.hideDropdown && (d.value = !0)),
1003
1005
  onKeydown: ie,
1004
1006
  onInput: o[5] || (o[5] = //@ts-ignore
1005
- (...g) => O(C).handleInput && O(C).handleInput(...g)),
1007
+ (...f) => O(W).handleInput && O(W).handleInput(...f)),
1006
1008
  onPaste: o[6] || (o[6] = //@ts-ignore
1007
- (...g) => O(C).handlePaste && O(C).handlePaste(...g)),
1008
- onBlur: o[7] || (o[7] = (g) => !t.disabled && j("second"))
1009
- }, null, 46, ze)
1010
- ], 64)) : ne("", !0)
1009
+ (...f) => O(W).handlePaste && O(W).handlePaste(...f)),
1010
+ onBlur: o[7] || (o[7] = (f) => !t.disabled && J("second"))
1011
+ }, null, 46, qe)
1012
+ ], 64)) : te("", !0)
1011
1013
  ], 2),
1012
- t.hideDropdown ? ne("", !0) : (G(), X("div", {
1014
+ t.hideDropdown ? te("", !0) : (G(), X("div", {
1013
1015
  key: 0,
1014
1016
  class: "timepicker-popovers",
1015
- style: ue(T.value)
1017
+ style: de(g.value)
1016
1018
  }, [
1017
- ye(Me, {
1018
- open: b.value,
1019
- "onUpdate:open": o[8] || (o[8] = (g) => b.value = g),
1019
+ Te(we, {
1020
+ open: y.value,
1021
+ "onUpdate:open": o[8] || (o[8] = (f) => y.value = f),
1020
1022
  initTime: x.value,
1021
- "onUpdate:initTime": o[9] || (o[9] = (g) => x.value = g),
1023
+ "onUpdate:initTime": o[9] || (o[9] = (f) => x.value = f),
1022
1024
  format: t.format,
1023
1025
  "hour-step": t.hourStep,
1024
1026
  "minute-step": t.minuteStep,
1025
1027
  "second-step": t.secondStep,
1026
1028
  "min-time": u.value,
1027
1029
  "max-time": m.value,
1028
- "disabled-ranges": S.value,
1030
+ "disabled-ranges": A.value,
1029
1031
  "is-time-disabled": t.isTimeDisabled
1030
1032
  }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step", "min-time", "max-time", "disabled-ranges", "is-time-disabled"]),
1031
- t.range ? (G(), ke(Me, {
1033
+ t.range ? (G(), Se(we, {
1032
1034
  key: 0,
1033
- open: l.value,
1034
- "onUpdate:open": o[10] || (o[10] = (g) => l.value = g),
1035
+ open: d.value,
1036
+ "onUpdate:open": o[10] || (o[10] = (f) => d.value = f),
1035
1037
  initTime: z.value,
1036
- "onUpdate:initTime": o[11] || (o[11] = (g) => z.value = g),
1038
+ "onUpdate:initTime": o[11] || (o[11] = (f) => z.value = f),
1037
1039
  format: t.format,
1038
1040
  "hour-step": t.hourStep,
1039
1041
  "minute-step": t.minuteStep,
1040
1042
  "second-step": t.secondStep,
1041
1043
  "min-time": u.value,
1042
1044
  "max-time": m.value,
1043
- "disabled-ranges": S.value,
1045
+ "disabled-ranges": A.value,
1044
1046
  "is-time-disabled": t.isTimeDisabled
1045
- }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step", "min-time", "max-time", "disabled-ranges", "is-time-disabled"])) : ne("", !0)
1047
+ }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step", "min-time", "max-time", "disabled-ranges", "is-time-disabled"])) : te("", !0)
1046
1048
  ], 4))
1047
- ], 12, Oe));
1049
+ ], 12, ze));
1048
1050
  }
1049
1051
  });
1050
1052
  export {
1051
- qe as TimePicker
1053
+ Ye as TimePicker
1052
1054
  };