@manik02/vue3-timepicker 0.1.2 → 0.2.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.
@@ -1,611 +1,867 @@
1
- import { defineComponent as X, ref as w, onMounted as O, watch as E, createElementBlock as D, openBlock as b, createElementVNode as K, Fragment as ce, renderList as de, normalizeClass as q, toDisplayString as pe, nextTick as Y, computed as y, onBeforeUnmount as ee, createCommentVNode as B, createVNode as W, createBlock as J, unref as T, normalizeStyle as R } from "vue";
2
- const ve = { class: "timepicker-dropdown" }, fe = ["tabindex", "onClick", "onMousemove"], C = /* @__PURE__ */ X({
1
+ import { defineComponent as ce, ref as E, onMounted as le, watch as D, createElementBlock as W, openBlock as K, createElementVNode as X, Fragment as Ae, renderList as xe, normalizeClass as re, toDisplayString as Ve, nextTick as ve, computed as h, onBeforeUnmount as pe, createCommentVNode as ae, createVNode as ue, createBlock as de, unref as H, normalizeStyle as oe } from "vue";
2
+ const Pe = { class: "timepicker-dropdown" }, Ie = ["tabindex", "onClick", "onMousemove"], ne = /* @__PURE__ */ ce({
3
3
  __name: "TimeColumn",
4
4
  props: {
5
5
  items: {},
6
6
  activeIndex: {}
7
7
  },
8
8
  emits: ["update:activeIndex", "select"],
9
- setup(s, { emit: r }) {
10
- const l = s, o = r, p = w(null);
11
- function a() {
12
- Y(() => {
13
- const v = p.value;
14
- if (!v) return;
15
- const g = v.querySelector(
9
+ setup(t, { emit: o }) {
10
+ const l = t, e = o, g = E(null);
11
+ function r() {
12
+ ve(() => {
13
+ const S = g.value;
14
+ if (!S) return;
15
+ const c = S.querySelector(
16
16
  ".timepicker-option--active"
17
17
  );
18
- if (g) {
19
- const h = v.clientHeight, x = g.offsetTop, m = g.offsetHeight;
20
- v.scrollTop = x - h / 2 + m / 2;
18
+ if (c) {
19
+ const V = S.clientHeight, M = c.offsetTop, A = c.offsetHeight;
20
+ S.scrollTop = M - V / 2 + A / 2;
21
21
  }
22
22
  });
23
23
  }
24
- O(a), E(() => l.activeIndex, a);
25
- function f(v) {
26
- o("update:activeIndex", v), o("select", l.items[v]?.value);
24
+ le(r), D(() => l.activeIndex, r);
25
+ function y(S) {
26
+ e("update:activeIndex", S), e("select", l.items[S]?.value);
27
27
  }
28
- const c = w(l.activeIndex ?? 0);
29
- return (v, g) => (b(), D("div", ve, [
30
- K("div", {
28
+ const x = E(l.activeIndex ?? 0);
29
+ return (S, c) => (K(), W("div", Pe, [
30
+ X("div", {
31
31
  ref_key: "menu",
32
- ref: p,
32
+ ref: g,
33
33
  class: "timepicker-dropdown__panel",
34
34
  role: "listbox",
35
35
  tabindex: "-1"
36
36
  }, [
37
- (b(!0), D(ce, null, de(v.items, (h, x) => (b(), D("div", {
38
- key: h.key,
39
- class: q(["timepicker-option", {
40
- "timepicker-option--active": x === v.activeIndex,
41
- "timepicker-option--disabled": h.disabled,
42
- "timepicker-option--focused": x === c.value
37
+ (K(!0), W(Ae, null, xe(S.items, (V, M) => (K(), W("div", {
38
+ key: V.key,
39
+ class: re(["timepicker-option", {
40
+ "timepicker-option--active": M === S.activeIndex,
41
+ "timepicker-option--disabled": V.disabled,
42
+ "timepicker-option--focused": M === x.value
43
43
  }]),
44
44
  role: "option",
45
- tabindex: h.disabled ? -1 : 0,
46
- onClick: (m) => !h.disabled && f(x),
47
- onMousemove: (m) => !h.disabled && (c.value = x)
48
- }, pe(h.text), 43, fe))), 128))
45
+ tabindex: V.disabled ? -1 : 0,
46
+ onClick: (A) => !V.disabled && y(M),
47
+ onMousemove: (A) => !V.disabled && (x.value = M)
48
+ }, Ve(V.text), 43, Ie))), 128))
49
49
  ], 512)
50
50
  ]));
51
51
  }
52
52
  });
53
- function se(s) {
54
- return /(a|A|p|P)/.test(s);
53
+ function he(t) {
54
+ return t.h * 3600 + t.m * 60 + t.s;
55
55
  }
56
- function he(s) {
57
- return /(p|P)/.test(s);
56
+ function ye(t) {
57
+ return /(a|A|p|P)/.test(t);
58
58
  }
59
- function Q(s) {
60
- return /k{1,2}/.test(s);
59
+ function we(t) {
60
+ return /(p|P)/.test(t);
61
61
  }
62
- function z(s, r) {
63
- if (!s) return { h: 0, m: 0, s: 0 };
64
- const l = s.match(/\d+/g) || [];
65
- let o = l[0] !== void 0 ? +l[0] : 0;
66
- const p = +l[1] || 0, a = +l[2] || 0;
67
- return { h: o, m: p, s: a };
62
+ function me(t) {
63
+ return /k{1,2}/.test(t);
68
64
  }
69
- function ge(s) {
70
- const r = s % 12;
71
- return r === 0 ? 12 : r;
65
+ function z(t, o) {
66
+ if (!t || typeof t != "string") return { h: 0, m: 0, s: 0 };
67
+ const l = t.match(/\d+/g) || [];
68
+ let e = l[0] !== void 0 ? +l[0] : 0;
69
+ const g = +l[1] || 0, r = +l[2] || 0;
70
+ return { h: e, m: g, s: r };
72
71
  }
73
- function te(s, r) {
74
- return r ? s % 12 + 12 : s % 12;
72
+ function De(t) {
73
+ const o = t % 12;
74
+ return o === 0 ? 12 : o;
75
75
  }
76
- function ke(s) {
77
- return /(s|ss)/.test(s);
76
+ function ge(t, o) {
77
+ return o ? t % 12 + 12 : t % 12;
78
78
  }
79
- function _(s, r) {
80
- let { h: l, m: o, s: p } = r;
81
- const a = se(s), f = l >= 12 ? "PM" : "AM";
82
- a && (l = ge(l));
83
- const c = l === 0 ? 24 : l, v = {
79
+ function Ee(t) {
80
+ return /(s|ss)/.test(t);
81
+ }
82
+ function Z(t, o) {
83
+ let { h: l, m: e, s: g } = o;
84
+ const r = ye(t), y = l >= 12 ? "PM" : "AM";
85
+ r && (l = De(l));
86
+ const x = l === 0 ? 24 : l, S = {
84
87
  HH: String(l).padStart(2, "0"),
85
88
  H: String(l),
86
89
  hh: String(l).padStart(2, "0"),
87
90
  h: String(l),
88
- kk: String(c).padStart(2, "0"),
89
- k: String(c),
90
- mm: String(o).padStart(2, "0"),
91
- m: String(o),
92
- ss: String(p).padStart(2, "0"),
93
- s: String(p),
94
- A: f,
95
- a: f.toLowerCase(),
96
- P: f,
97
- p: f.toLowerCase()
91
+ kk: String(x).padStart(2, "0"),
92
+ k: String(x),
93
+ mm: String(e).padStart(2, "0"),
94
+ m: String(e),
95
+ ss: String(g).padStart(2, "0"),
96
+ s: String(g),
97
+ A: y,
98
+ a: y.toLowerCase(),
99
+ P: y,
100
+ p: y.toLowerCase()
98
101
  };
99
- return s.replace(/HH|hh|kk|mm|ss|H|h|k|m|s|A|a|P|p/g, (g) => v[g] ?? g);
102
+ return t.replace(/HH|hh|kk|mm|ss|H|h|k|m|s|A|a|P|p/g, (c) => S[c] ?? c);
103
+ }
104
+ function O(t, o) {
105
+ return he(t) - he(o);
106
+ }
107
+ function He(t, o, l) {
108
+ return o && O(t, o) < 0 ? { ...o } : l && O(t, l) > 0 ? { ...l } : { ...t };
109
+ }
110
+ function Te(t, o, l) {
111
+ return !(o && O(t, o) < 0 || l && O(t, l) > 0);
112
+ }
113
+ function Se(t, o) {
114
+ return o.some(([l, e]) => O(t, l) >= 0 && O(t, e) <= 0);
100
115
  }
101
- const ne = /* @__PURE__ */ X({
116
+ const be = /* @__PURE__ */ ce({
102
117
  __name: "TimeSelection",
103
118
  props: {
104
119
  open: { type: Boolean },
105
120
  initTime: {},
106
121
  format: {},
122
+ minTime: {},
123
+ maxTime: {},
124
+ disabledRanges: {},
125
+ isTimeDisabled: { type: Function },
107
126
  hourStep: {},
108
127
  minuteStep: {},
109
128
  secondStep: {}
110
129
  },
111
130
  emits: ["update:initTime", "open", "close", "update:open"],
112
- setup(s, { emit: r }) {
113
- const l = y(() => se(a.format)), o = y(() => ke(a.format)), p = y(() => Q(a.format)), a = s, f = r, c = y({
114
- get: () => a.open ?? !1,
115
- set: (u) => {
116
- const k = a.open ?? !1;
117
- u !== k && (f("update:open", u), f(u ? "open" : "close"));
131
+ setup(t, { emit: o }) {
132
+ const l = h(() => ye(r.format)), e = h(() => Ee(r.format)), g = h(() => me(r.format)), r = t, y = o, x = h({
133
+ get: () => r.open ?? !1,
134
+ set: (n) => {
135
+ const p = r.open ?? !1;
136
+ n !== p && (y("update:open", n), y(n ? "open" : "close"));
118
137
  }
119
- }), v = w(null);
120
- function g(u) {
121
- if (!c.value) return;
122
- const k = u.target;
123
- v.value && !v.value.contains(k) && (c.value = !1);
124
- }
125
- O(() => document.addEventListener("mousedown", g)), ee(
126
- () => document.removeEventListener("mousedown", g)
138
+ }), S = E(null);
139
+ function c(n) {
140
+ if (!x.value) return;
141
+ const p = n.target;
142
+ S.value && !S.value.contains(p) && (x.value = !1);
143
+ }
144
+ le(() => document.addEventListener("mousedown", c)), pe(
145
+ () => document.removeEventListener("mousedown", c)
127
146
  );
128
- function h(u) {
129
- u.key === "Escape" && c.value && (c.value = !1);
130
- }
131
- O(() => document.addEventListener("keydown", h)), ee(() => document.removeEventListener("keydown", h));
132
- const x = w(Math.floor(a.initTime.h / a.hourStep) || 0), m = w(Math.floor(a.initTime.m / a.minuteStep) || 0), H = w(Math.floor(a.initTime.s / a.secondStep) || 0);
133
- E(
134
- () => a.initTime,
135
- (u) => {
136
- const k = Math.max(1, a.hourStep), M = Math.max(1, a.minuteStep), A = Math.max(1, a.secondStep);
137
- let I = u.h;
138
- l.value ? ($.value = u.h >= 12 ? 1 : 0, I = u.h % 12) : p.value && u.h === 0 && (I = 24), x.value = Math.floor(I / k), m.value = Math.floor(u.m / M), H.value = Math.floor(u.s / A);
147
+ function V(n) {
148
+ n.key === "Escape" && x.value && (x.value = !1);
149
+ }
150
+ le(() => document.addEventListener("keydown", V)), pe(() => document.removeEventListener("keydown", V));
151
+ const M = E(Math.floor(r.initTime.h / r.hourStep) || 0), A = E(Math.floor(r.initTime.m / r.minuteStep) || 0), L = E(Math.floor(r.initTime.s / r.secondStep) || 0);
152
+ D(
153
+ () => r.initTime,
154
+ (n) => {
155
+ const p = Math.max(1, r.hourStep), k = Math.max(1, r.minuteStep), T = Math.max(1, r.secondStep);
156
+ let w = n.h;
157
+ l.value ? (B.value = n.h >= 12 ? 1 : 0, w = n.h % 12) : g.value && n.h === 0 && (w = 24), M.value = Math.floor(w / p), A.value = Math.floor(n.m / k), L.value = Math.floor(n.s / T);
139
158
  }
140
159
  );
141
- function P(u, k) {
142
- const M = [];
143
- for (let A = 0; A < u; A += Math.max(1, k))
144
- M.push({ key: A, value: A, text: String(A).padStart(2, "0") });
145
- return M;
146
- }
147
- function N(u, k) {
148
- const M = Math.max(1, k), A = [];
149
- for (let I = 0; I < 12; I += M) {
150
- const me = I === 0 ? 12 : I, Z = u ? I === 0 ? 12 : I + 12 : I;
151
- A.push({ key: Z, value: Z, text: String(me).padStart(2, "0") });
160
+ function R(n, p) {
161
+ const k = [];
162
+ for (let T = 0; T < n; T += Math.max(1, p))
163
+ k.push({ key: T, value: T, text: String(T).padStart(2, "0") });
164
+ return k;
165
+ }
166
+ function q(n, p) {
167
+ const k = Math.max(1, p), T = [];
168
+ for (let w = 0; w < 12; w += k) {
169
+ const se = w === 0 ? 12 : w, fe = n ? w === 0 ? 12 : w + 12 : w;
170
+ T.push({ key: fe, value: fe, text: String(se).padStart(2, "0") });
152
171
  }
153
- return A;
172
+ return T;
154
173
  }
155
- function L(u) {
156
- const k = Math.max(1, u), M = [];
157
- for (let A = 0; A < 24; A += k) {
158
- const I = A === 0 ? 24 : A;
159
- M.push({ key: A, value: A, text: String(I).padStart(2, "0") });
174
+ function U(n) {
175
+ const p = Math.max(1, n), k = [];
176
+ for (let T = 0; T < 24; T += p) {
177
+ const w = T === 0 ? 24 : T;
178
+ k.push({ key: T, value: T, text: String(w).padStart(2, "0") });
160
179
  }
161
- return M;
180
+ return k;
162
181
  }
163
- const $ = w(he(a.format) ? 1 : 0), F = y(() => {
182
+ const B = E(we(r.format) ? 1 : 0), _ = h(() => {
164
183
  if (!l.value)
165
- return p.value ? L(a.hourStep) : P(24, a.hourStep);
166
- const u = $.value === 1;
167
- return N(u, a.hourStep);
168
- }), V = y(() => P(60, a.minuteStep)), e = y(() => P(60, a.secondStep)), t = y(() => /\s[ap]$/.test(a.format)), n = y(() => {
169
- const u = t.value ? "am" : "AM", k = t.value ? "pm" : "PM";
184
+ return g.value ? U(r.hourStep) : R(24, r.hourStep);
185
+ const n = B.value === 1;
186
+ return q(n, r.hourStep);
187
+ }), N = h(() => R(60, r.minuteStep)), s = h(() => R(60, r.secondStep)), u = h(() => /\s[ap]$/.test(r.format)), d = h(() => {
188
+ const n = u.value ? "am" : "AM", p = u.value ? "pm" : "PM";
170
189
  return [
171
- { key: "AM", value: "AM", text: u },
172
- { key: "PM", value: "PM", text: k }
190
+ { key: "AM", value: "AM", text: n },
191
+ { key: "PM", value: "PM", text: p }
173
192
  ];
174
- }), d = y(() => $.value === 1 ? "PM" : "AM"), i = y(() => {
175
- const u = Number(F.value[x.value]?.value ?? 0);
176
- return l.value ? d.value === "PM" ? te(u, !0) : te(u, !1) : p.value && u === 24 ? 0 : u;
177
- }), S = y(
178
- () => Number(V.value[m.value]?.value ?? 0)
179
- ), U = y(
180
- () => Number(e.value[H.value]?.value ?? 0)
193
+ }), v = h(
194
+ () => N.value.map((n) => Number(n.value ?? 0))
195
+ ), f = h(() => e.value ? s.value.map((n) => Number(n.value ?? 0)) : [0]);
196
+ function b(n) {
197
+ return Number(n.value ?? 0);
198
+ }
199
+ function C(n) {
200
+ const p = n.findIndex((k) => !k.disabled);
201
+ return p >= 0 ? p : 0;
202
+ }
203
+ function P(n) {
204
+ return !(!Te(n, r.minTime, r.maxTime) || Se(n, r.disabledRanges ?? []) || r.isTimeDisabled?.(n));
205
+ }
206
+ const Y = h(() => _.value.map((n) => {
207
+ const p = b(n), k = v.value.some(
208
+ (T) => f.value.some(
209
+ (w) => P({ h: p, m: T, s: w })
210
+ )
211
+ );
212
+ return {
213
+ ...n,
214
+ disabled: !k
215
+ };
216
+ })), $ = h(() => {
217
+ const n = Number(_.value[M.value]?.value ?? 0);
218
+ return N.value.map((p) => {
219
+ const k = Number(p.value ?? 0), T = f.value.some(
220
+ (w) => P({ h: n, m: k, s: w })
221
+ );
222
+ return {
223
+ ...p,
224
+ disabled: !T
225
+ };
226
+ });
227
+ }), ee = h(() => {
228
+ const n = Number(_.value[M.value]?.value ?? 0), p = Number(
229
+ N.value[A.value]?.value ?? 0
230
+ );
231
+ return s.value.map((k) => {
232
+ const T = Number(k.value ?? 0);
233
+ return {
234
+ ...k,
235
+ disabled: !P({
236
+ h: n,
237
+ m: p,
238
+ s: T
239
+ })
240
+ };
241
+ });
242
+ }), J = h(() => {
243
+ if (!l.value) return d.value;
244
+ const n = Number(N.value[A.value]?.value ?? 0), p = e.value ? Number(s.value[L.value]?.value ?? 0) : 0;
245
+ return d.value.map((k) => {
246
+ const T = k.value === "PM", w = q(T, r.hourStep).some(
247
+ (se) => P({
248
+ h: Number(se.value ?? 0),
249
+ m: n,
250
+ s: p
251
+ })
252
+ );
253
+ return {
254
+ ...k,
255
+ disabled: !w
256
+ };
257
+ });
258
+ }), te = h(() => B.value === 1 ? "PM" : "AM"), ie = h(() => {
259
+ const n = Number(_.value[M.value]?.value ?? 0);
260
+ return l.value ? te.value === "PM" ? ge(n, !0) : ge(n, !1) : g.value && n === 24 ? 0 : n;
261
+ }), G = h(
262
+ () => Number(N.value[A.value]?.value ?? 0)
263
+ ), a = h(
264
+ () => Number(s.value[L.value]?.value ?? 0)
181
265
  );
182
- function re(u) {
183
- !o.value && !l.value && G();
266
+ D(Y, (n) => {
267
+ n.length && (!n[M.value] || n[M.value].disabled) && (M.value = C(n));
268
+ }), D($, (n) => {
269
+ n.length && (!n[A.value] || n[A.value].disabled) && (A.value = C(n));
270
+ }), D(ee, (n) => {
271
+ !e.value || !n.length || (!n[L.value] || n[L.value].disabled) && (L.value = C(n));
272
+ }), D(J, (n) => {
273
+ !l.value || !n.length || (!n[B.value] || n[B.value].disabled) && (B.value = C(n));
274
+ });
275
+ function i(n) {
276
+ !e.value && !l.value && I();
184
277
  }
185
- function ie(u) {
186
- l.value || G();
278
+ function m(n) {
279
+ l.value || I();
187
280
  }
188
- function ue(u) {
189
- G();
281
+ function F(n) {
282
+ I();
190
283
  }
191
- function G() {
192
- c.value = !1;
284
+ function I() {
285
+ x.value = !1;
193
286
  }
194
- return E(
195
- [i, S, U],
196
- ([u, k, M]) => {
197
- f("update:initTime", { h: u, m: k, s: M });
287
+ return D(
288
+ [ie, G, a],
289
+ ([n, p, k]) => {
290
+ y("update:initTime", { h: n, m: p, s: k });
198
291
  },
199
292
  { immediate: !0 }
200
- ), (u, k) => c.value ? (b(), D("div", {
293
+ ), (n, p) => x.value ? (K(), W("div", {
201
294
  key: 0,
202
295
  class: "vtp-cols",
203
296
  ref_key: "root",
204
- ref: v
297
+ ref: S
205
298
  }, [
206
- W(C, {
207
- activeIndex: x.value,
208
- "onUpdate:activeIndex": k[0] || (k[0] = (M) => x.value = M),
209
- items: F.value,
299
+ ue(ne, {
300
+ activeIndex: M.value,
301
+ "onUpdate:activeIndex": p[0] || (p[0] = (k) => M.value = k),
302
+ items: Y.value,
210
303
  label: "Hours"
211
304
  }, null, 8, ["activeIndex", "items"]),
212
- W(C, {
213
- activeIndex: m.value,
214
- "onUpdate:activeIndex": k[1] || (k[1] = (M) => m.value = M),
215
- items: V.value,
305
+ ue(ne, {
306
+ activeIndex: A.value,
307
+ "onUpdate:activeIndex": p[1] || (p[1] = (k) => A.value = k),
308
+ items: $.value,
216
309
  label: "Minutes",
217
- onSelect: re
310
+ onSelect: i
218
311
  }, null, 8, ["activeIndex", "items"]),
219
- o.value ? (b(), J(C, {
312
+ e.value ? (K(), de(ne, {
220
313
  key: 0,
221
- activeIndex: H.value,
222
- "onUpdate:activeIndex": k[2] || (k[2] = (M) => H.value = M),
223
- items: e.value,
314
+ activeIndex: L.value,
315
+ "onUpdate:activeIndex": p[2] || (p[2] = (k) => L.value = k),
316
+ items: ee.value,
224
317
  label: "Seconds",
225
- onSelect: ie
226
- }, null, 8, ["activeIndex", "items"])) : B("", !0),
227
- l.value ? (b(), J(C, {
318
+ onSelect: m
319
+ }, null, 8, ["activeIndex", "items"])) : ae("", !0),
320
+ l.value ? (K(), de(ne, {
228
321
  key: 1,
229
- activeIndex: $.value,
230
- "onUpdate:activeIndex": k[3] || (k[3] = (M) => $.value = M),
231
- items: n.value,
322
+ activeIndex: B.value,
323
+ "onUpdate:activeIndex": p[3] || (p[3] = (k) => B.value = k),
324
+ items: J.value,
232
325
  label: "AM/PM",
233
- onSelect: ue
234
- }, null, 8, ["activeIndex", "items"])) : B("", !0)
235
- ], 512)) : B("", !0);
326
+ onSelect: F
327
+ }, null, 8, ["activeIndex", "items"])) : ae("", !0)
328
+ ], 512)) : ae("", !0);
236
329
  }
237
- }), le = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, oe = /^([01]\d|2[0-3]):([0-5]\d)(:([0-5]\d))?$/, j = typeof __DEV__ < "u" ? __DEV__ : typeof process < "u" && process.env && process.env.NODE_ENV !== "production", ye = {
330
+ });
331
+ function $e(t) {
332
+ return typeof t == "string" ? j.test(t) : Array.isArray(t) ? t.length === 2 && j.test(t[0] ?? "") && j.test(t[1] ?? "") : !1;
333
+ }
334
+ const Me = /^(HH|H|hh|h|kk|k):(mm|m)(?::(ss|s))?(?:\s*(A|a|P|p))?$/, j = /^([01]\d|2[0-3]):([0-5]\d)(:([0-5]\d))?$/, Q = typeof __DEV__ < "u" ? __DEV__ : typeof process < "u" && process.env && process.env.NODE_ENV !== "production", Le = {
238
335
  modelValue: {
239
336
  type: [String, Array],
240
337
  default: void 0,
241
- validator: (s) => {
242
- let r;
243
- return Array.isArray(s) ? r = s.length === 2 && s.every((l) => oe.test(l)) : r = s == null || oe.test(s), !r && j && console.error(
244
- `[VueTimepicker] \`modelValue\` is wrong. Received: ${s}`
245
- ), r;
338
+ validator: (t) => {
339
+ let o;
340
+ return Array.isArray(t) ? o = t.length === 2 && t.every((l) => j.test(l)) : o = t == null || j.test(t), !o && Q && console.error(
341
+ `[VueTimepicker] \`modelValue\` is wrong. Received: ${t}`
342
+ ), o;
246
343
  }
247
344
  },
248
345
  range: {
249
346
  type: Boolean,
250
347
  default: !1
251
348
  },
349
+ disabled: {
350
+ type: Boolean,
351
+ default: !1
352
+ },
252
353
  hourStep: { type: Number, default: 1 },
253
354
  minuteStep: { type: Number, default: 1 },
254
355
  secondStep: { type: Number, default: 1 },
356
+ minTime: {
357
+ type: String,
358
+ default: void 0,
359
+ validator: (t) => {
360
+ const o = t == null || j.test(t);
361
+ return !o && Q && console.error(`[VueTimepicker] \`minTime\` is wrong. Received: ${t}`), o;
362
+ }
363
+ },
364
+ maxTime: {
365
+ type: String,
366
+ default: void 0,
367
+ validator: (t) => {
368
+ const o = t == null || j.test(t);
369
+ return !o && Q && console.error(`[VueTimepicker] \`maxTime\` is wrong. Received: ${t}`), o;
370
+ }
371
+ },
372
+ disabledTimes: {
373
+ type: Array,
374
+ default: void 0,
375
+ validator: (t) => {
376
+ const o = t == null || t.every($e);
377
+ return !o && Q && console.error(
378
+ `[VueTimepicker] \`disabledTimes\` is wrong. Received: ${JSON.stringify(t)}`
379
+ ), o;
380
+ }
381
+ },
382
+ isTimeDisabled: {
383
+ type: Function,
384
+ default: void 0
385
+ },
255
386
  format: {
256
387
  type: String,
257
388
  default: "HH:mm",
258
- validator: (s) => {
259
- const r = le.test(s);
260
- return !r && j && console.error(
261
- `[VueTimepicker] \`format\` format is wrong. Received: ${s}`
262
- ), r;
389
+ validator: (t) => {
390
+ const o = Me.test(t);
391
+ return !o && Q && console.error(
392
+ `[VueTimepicker] \`format\` format is wrong. Received: ${t}`
393
+ ), o;
263
394
  }
264
395
  },
265
396
  size: {
266
397
  type: String,
267
398
  default: "md",
268
- validator: (s) => {
269
- const r = s === "sm" || s === "md" || s === "lg";
270
- return !r && j && console.error(`[VueTimepicker] \`size\` is wrong. Received: ${s}`), r;
399
+ validator: (t) => {
400
+ const o = t === "xs" || t === "sm" || t === "md" || t === "lg" || t === "xl";
401
+ return !o && Q && console.error(`[VueTimepicker] \`size\` is wrong. Received: ${t}`), o;
271
402
  }
272
403
  }
273
404
  };
274
- function Se(s) {
275
- const r = le.exec(s);
276
- if (!r) throw new Error(`[useTimeMask] Invalid format: ${s}`);
277
- const [, l, o, p, a] = r, f = [], c = !!a, v = /^k{1,2}$/.test(l);
278
- let g = 0, h = 23;
279
- return c ? (g = 1, h = 12) : v && (g = 1, h = 24), f.push({ token: l, min: g, max: h }), f.push({ token: o, min: 0, max: 59 }), p && f.push({ token: p, min: 0, max: 59 }), {
280
- digitGroups: f,
281
- hasAmPm: !!a,
282
- ampmLowercase: a === "a" || a === "p"
405
+ function Ne(t) {
406
+ const o = Me.exec(t);
407
+ if (!o) throw new Error(`[useTimeMask] Invalid format: ${t}`);
408
+ const [, l, e, g, r] = o, y = [], x = !!r, S = /^k{1,2}$/.test(l);
409
+ let c = 0, V = 23;
410
+ return x ? (c = 1, V = 12) : S && (c = 1, V = 24), y.push({ token: l, min: c, max: V }), y.push({ token: e, min: 0, max: 59 }), g && y.push({ token: g, min: 0, max: 59 }), {
411
+ digitGroups: y,
412
+ hasAmPm: !!r,
413
+ ampmLowercase: r === "a" || r === "p"
283
414
  };
284
415
  }
285
- function ae(s) {
286
- const r = y(() => Se(s.value)), l = y(() => r.value.digitGroups.length * 2), o = w([]), p = w("AM"), a = w("");
287
- function f() {
288
- const { digitGroups: e, hasAmPm: t } = r.value;
289
- let n = "", d = 0;
290
- for (let i = 0; i < e.length; i++) {
291
- for (let S = 0; S < 2; S++)
292
- d < o.value.length && (n += String(o.value[d]), d++);
293
- d === (i + 1) * 2 && i < e.length - 1 && (n += ":");
294
- }
295
- if (t && d >= l.value) {
296
- const i = r.value.ampmLowercase ? p.value.toLowerCase() : p.value;
297
- n += " " + i;
298
- }
299
- return n;
416
+ function ke(t) {
417
+ const o = h(() => Ne(t.value)), l = h(() => o.value.digitGroups.length * 2), e = E([]), g = E("AM"), r = E("");
418
+ function y() {
419
+ const { digitGroups: s, hasAmPm: u } = o.value;
420
+ let d = "", v = 0;
421
+ for (let f = 0; f < s.length; f++) {
422
+ for (let b = 0; b < 2; b++)
423
+ v < e.value.length && (d += String(e.value[v]), v++);
424
+ v === (f + 1) * 2 && f < s.length - 1 && (d += ":");
425
+ }
426
+ if (u && v >= l.value) {
427
+ const f = o.value.ampmLowercase ? g.value.toLowerCase() : g.value;
428
+ d += " " + f;
429
+ }
430
+ return d;
300
431
  }
301
- function c(e) {
302
- const t = e * 2;
303
- if (o.value.length < t + 2) return;
304
- const n = o.value[t] * 10 + o.value[t + 1], { min: d, max: i } = r.value.digitGroups[e], S = Math.max(d, Math.min(i, n));
305
- S !== n && (o.value[t] = Math.floor(S / 10), o.value[t + 1] = S % 10);
432
+ function x(s) {
433
+ const u = s * 2;
434
+ if (e.value.length < u + 2) return;
435
+ const d = e.value[u] * 10 + e.value[u + 1], { min: v, max: f } = o.value.digitGroups[s], b = Math.max(v, Math.min(f, d));
436
+ b !== d && (e.value[u] = Math.floor(b / 10), e.value[u + 1] = b % 10);
306
437
  }
307
- function v() {
308
- for (let e = 0; e < r.value.digitGroups.length; e++)
309
- c(e);
438
+ function S() {
439
+ for (let s = 0; s < o.value.digitGroups.length; s++)
440
+ x(s);
310
441
  }
311
- function g(e) {
312
- const t = f();
313
- let n = 0;
314
- for (let d = 0; d < Math.min(e, t.length); d++)
315
- /\d/.test(t[d]) && n++;
316
- return n;
442
+ function c(s) {
443
+ const u = y();
444
+ let d = 0;
445
+ for (let v = 0; v < Math.min(s, u.length); v++)
446
+ /\d/.test(u[v]) && d++;
447
+ return d;
317
448
  }
318
- function h(e) {
319
- return e + Math.floor(e / 2);
449
+ function V(s) {
450
+ return s + Math.floor(s / 2);
320
451
  }
321
- function x(e, t) {
322
- if (e >= l.value) return l.value;
323
- const n = [...o.value];
324
- n[e] = t, o.value = n;
325
- const d = Math.floor(e / 2);
326
- return c(d), Math.min(e + 1, l.value);
452
+ function M(s, u) {
453
+ if (s >= l.value) return l.value;
454
+ const d = [...e.value];
455
+ d[s] = u, e.value = d;
456
+ const v = Math.floor(s / 2);
457
+ return x(v), Math.min(s + 1, l.value);
327
458
  }
328
- function m(e, t) {
329
- const n = f();
330
- a.value = n, e.value = n;
331
- const d = t !== void 0 ? Math.min(h(t), n.length) : n.length;
332
- e.selectionStart = e.selectionEnd = d, Y(() => {
333
- document.activeElement === e && (e.selectionStart = e.selectionEnd = d);
459
+ function A(s, u) {
460
+ const d = y();
461
+ r.value = d, s.value = d;
462
+ const v = u !== void 0 ? Math.min(V(u), d.length) : d.length;
463
+ s.selectionStart = s.selectionEnd = v, ve(() => {
464
+ document.activeElement === s && (s.selectionStart = s.selectionEnd = v);
334
465
  });
335
466
  }
336
- function H(e) {
337
- const t = e.key, n = e.target;
467
+ function L(s) {
468
+ const u = s.key, d = s.target;
338
469
  if (["Tab", "Escape", "ArrowLeft", "ArrowRight", "Home", "End"].includes(
339
- t
340
- ) || e.metaKey || e.ctrlKey)
470
+ u
471
+ ) || s.metaKey || s.ctrlKey)
341
472
  return;
342
- e.preventDefault();
343
- const d = n.selectionStart ?? 0, i = g(d);
344
- if (t === "Backspace") {
345
- i > 0 && m(n, i - 1);
473
+ s.preventDefault();
474
+ const v = d.selectionStart ?? 0, f = c(v);
475
+ if (u === "Backspace") {
476
+ f > 0 && A(d, f - 1);
346
477
  return;
347
478
  }
348
- if (t !== "Delete") {
349
- if (r.value.hasAmPm) {
350
- const S = t.toLowerCase();
351
- if (S === "a") {
352
- p.value = "AM", m(n, i);
479
+ if (u !== "Delete") {
480
+ if (o.value.hasAmPm) {
481
+ const b = u.toLowerCase();
482
+ if (b === "a") {
483
+ g.value = "AM", A(d, f);
353
484
  return;
354
485
  }
355
- if (S === "p") {
356
- p.value = "PM", m(n, i);
486
+ if (b === "p") {
487
+ g.value = "PM", A(d, f);
357
488
  return;
358
489
  }
359
490
  }
360
- if (/^\d$/.test(t)) {
361
- const S = x(i, +t);
362
- m(n, S);
491
+ if (/^\d$/.test(u)) {
492
+ const b = M(f, +u);
493
+ A(d, b);
363
494
  return;
364
495
  }
365
496
  }
366
497
  }
367
- function P(e) {
368
- const t = e.target, n = t.value.replace(/\D/g, "").split("").map(Number).slice(0, l.value);
369
- o.value = n, v(), r.value.hasAmPm && (/p/i.test(t.value) ? p.value = "PM" : /a/i.test(t.value) && (p.value = "AM")), m(t);
498
+ function R(s) {
499
+ const u = s.target, d = u.value.replace(/\D/g, "").split("").map(Number).slice(0, l.value);
500
+ e.value = d, S(), o.value.hasAmPm && (/p/i.test(u.value) ? g.value = "PM" : /a/i.test(u.value) && (g.value = "AM")), A(u);
370
501
  }
371
- function N(e) {
372
- e.preventDefault();
373
- const t = e.clipboardData?.getData("text") ?? "", n = e.target, d = n.selectionStart ?? 0, i = t.replace(/\D/g, "").split("").map(Number);
374
- let S = g(d);
375
- for (const U of i) {
376
- if (S >= l.value) break;
377
- S = x(S, U);
378
- }
379
- r.value.hasAmPm && (/p\.?m\.?/i.test(t) ? p.value = "PM" : /a\.?m\.?/i.test(t) && (p.value = "AM")), m(n, S);
502
+ function q(s) {
503
+ s.preventDefault();
504
+ const u = s.clipboardData?.getData("text") ?? "", d = s.target, v = d.selectionStart ?? 0, f = u.replace(/\D/g, "").split("").map(Number);
505
+ let b = c(v);
506
+ for (const C of f) {
507
+ if (b >= l.value) break;
508
+ b = M(b, C);
509
+ }
510
+ o.value.hasAmPm && (/p\.?m\.?/i.test(u) ? g.value = "PM" : /a\.?m\.?/i.test(u) && (g.value = "AM")), A(d, b);
380
511
  }
381
- function L(e) {
382
- const { digitGroups: t, hasAmPm: n } = r.value, d = [];
383
- let i = e.h;
384
- n ? (p.value = e.h >= 12 ? "PM" : "AM", i = e.h % 12, i === 0 && (i = 12)) : Q(s.value) && (i = e.h === 0 ? 24 : e.h), d.push(Math.floor(i / 10), i % 10), d.push(Math.floor(e.m / 10), e.m % 10), t.length > 2 && d.push(Math.floor(e.s / 10), e.s % 10), o.value = d, a.value = f();
512
+ function U(s) {
513
+ const { digitGroups: u, hasAmPm: d } = o.value, v = [];
514
+ let f = s.h;
515
+ d ? (g.value = s.h >= 12 ? "PM" : "AM", f = s.h % 12, f === 0 && (f = 12)) : me(t.value) && (f = s.h === 0 ? 24 : s.h), v.push(Math.floor(f / 10), f % 10), v.push(Math.floor(s.m / 10), s.m % 10), u.length > 2 && v.push(Math.floor(s.s / 10), s.s % 10), e.value = v, r.value = y();
385
516
  }
386
- function $() {
387
- if (o.value.length < l.value) return null;
388
- const e = [];
389
- for (let i = 0; i < r.value.digitGroups.length; i++) {
390
- const S = i * 2;
391
- e.push(o.value[S] * 10 + o.value[S + 1]);
392
- }
393
- let t = e[0];
394
- const n = e[1], d = e[2] ?? 0;
395
- return r.value.hasAmPm && (t = p.value === "PM" ? t === 12 ? 12 : t + 12 : t === 12 ? 0 : t), Q(s.value) && t === 24 && (t = 0), { h: t, m: n, s: d };
517
+ function B() {
518
+ if (e.value.length < l.value) return null;
519
+ const s = [];
520
+ for (let f = 0; f < o.value.digitGroups.length; f++) {
521
+ const b = f * 2;
522
+ s.push(e.value[b] * 10 + e.value[b + 1]);
523
+ }
524
+ let u = s[0];
525
+ const d = s[1], v = s[2] ?? 0;
526
+ return o.value.hasAmPm && (u = g.value === "PM" ? u === 12 ? 12 : u + 12 : u === 12 ? 0 : u), me(t.value) && u === 24 && (u = 0), { h: u, m: d, s: v };
396
527
  }
397
- const F = y(
398
- () => o.value.length >= l.value
399
- ), V = y(() => r.value.ampmLowercase);
528
+ const _ = h(
529
+ () => e.value.length >= l.value
530
+ ), N = h(() => o.value.ampmLowercase);
400
531
  return {
401
- inputValue: a,
402
- handleKeydown: H,
403
- handleInput: P,
404
- handlePaste: N,
405
- setFromTime: L,
406
- getParsedTime: $,
407
- isComplete: F,
532
+ inputValue: r,
533
+ handleKeydown: L,
534
+ handleInput: R,
535
+ handlePaste: q,
536
+ setFromTime: U,
537
+ getParsedTime: B,
538
+ isComplete: _,
408
539
  totalDigits: l,
409
- displayPosToDigitIndex: g,
410
- ampm: p,
411
- ampmLowercase: V
540
+ displayPosToDigitIndex: c,
541
+ ampm: g,
542
+ ampmLowercase: N
412
543
  };
413
544
  }
414
- const Me = ["data-size"], xe = ["value", "placeholder"], Ae = ["value", "placeholder"], Pe = ["value", "placeholder"], we = /* @__PURE__ */ X({
545
+ const Be = ["data-size", "data-validation", "data-disabled"], Fe = ["value", "placeholder", "disabled"], _e = ["value", "placeholder", "disabled"], Re = ["value", "placeholder", "disabled"], Ke = /* @__PURE__ */ ce({
415
546
  __name: "TimePicker",
416
- props: ye,
417
- emits: ["update:modelValue", "open", "close", "error"],
418
- setup(s, { emit: r }) {
419
- const l = w(null), o = s, p = r, a = w(!1), f = w(!1);
420
- E(a, (e) => {
421
- e && (f.value = !1);
422
- }), E(f, (e) => {
423
- e && (a.value = !1);
424
- });
425
- const c = y({
547
+ props: Le,
548
+ emits: ["update:modelValue", "update:validationState", "validate", "open", "close", "error"],
549
+ setup(t, { emit: o }) {
550
+ const l = E(null), e = t, g = o, r = E(!1), y = E(!1), x = E("valid"), S = E("valid");
551
+ D(r, (a) => {
552
+ if (e.disabled && a) {
553
+ r.value = !1;
554
+ return;
555
+ }
556
+ a && (y.value = !1);
557
+ }), D(y, (a) => {
558
+ if (e.disabled && a) {
559
+ y.value = !1;
560
+ return;
561
+ }
562
+ a && (r.value = !1);
563
+ }), D(
564
+ () => e.disabled,
565
+ (a) => {
566
+ a && (r.value = !1, y.value = !1);
567
+ }
568
+ );
569
+ const c = h({
426
570
  get() {
427
- if (Array.isArray(o.modelValue)) {
428
- const [e, t] = o.modelValue;
429
- return [z(e, o.format), z(t, o.format)];
571
+ if (Array.isArray(e.modelValue)) {
572
+ const [a, i] = e.modelValue;
573
+ return [z(a, e.format), z(i, e.format)];
430
574
  } else
431
- return z(o.modelValue, o.format);
575
+ return z(e.modelValue, e.format);
432
576
  },
433
- set(e) {
434
- Array.isArray(e) ? p("update:modelValue", [
435
- _("HH:mm:ss", e[0]),
436
- _("HH:mm:ss", e[1])
437
- ]) : p("update:modelValue", _("HH:mm:ss", e));
577
+ set(a) {
578
+ Array.isArray(a) ? g("update:modelValue", [
579
+ Z("HH:mm:ss", a[0]),
580
+ Z("HH:mm:ss", a[1])
581
+ ]) : g("update:modelValue", Z("HH:mm:ss", a));
582
+ }
583
+ }), V = h(
584
+ () => e.minTime ? z(e.minTime) : null
585
+ ), M = h(
586
+ () => e.maxTime ? z(e.maxTime) : null
587
+ ), A = h(() => !V.value || !M.value ? !0 : O(V.value, M.value) <= 0), L = h(() => x.value === "out-of-range" || e.range && S.value === "out-of-range" ? "out-of-range" : x.value === "invalid" || e.range && S.value === "invalid" ? "invalid" : "valid"), R = h(() => (e.disabledTimes ?? []).map((i) => {
588
+ const m = Array.isArray(i) ? i : [i, i], F = z(m[0]), I = z(m[1]);
589
+ return O(F, I) <= 0 ? [F, I] : [I, F];
590
+ }));
591
+ function q(a) {
592
+ return !!(Se(a, R.value) || e.isTimeDisabled?.(a));
593
+ }
594
+ function U(a) {
595
+ return a === "first" ? Array.isArray(c.value) ? c.value[0] : c.value : Array.isArray(c.value) ? c.value[1] : c.value;
596
+ }
597
+ function B(a, i) {
598
+ if (a === "first") {
599
+ Array.isArray(c.value) ? c.value = [i, c.value[1]] : c.value = i;
600
+ return;
601
+ }
602
+ Array.isArray(c.value) && (c.value = [c.value[0], i]);
603
+ }
604
+ function _(a, i, m, F) {
605
+ if (a === "first" ? x.value = i : S.value = i, g("validate", {
606
+ target: a,
607
+ state: i,
608
+ reason: m,
609
+ value: F ? Z("HH:mm:ss", F) : null
610
+ }), i === "valid") {
611
+ l.value = null;
612
+ return;
613
+ }
614
+ if (i === "out-of-range") {
615
+ l.value = "OUT_OF_RANGE", g("error", {
616
+ code: "OUT_OF_RANGE",
617
+ message: "Time is outside min/max bounds and was clamped."
618
+ });
619
+ return;
438
620
  }
439
- }), v = y({
621
+ l.value = m ?? "BAD_TIME", g("error", {
622
+ code: m ?? "BAD_TIME",
623
+ message: m === "DISABLED" ? "Time is disabled by disabledTimes or isTimeDisabled." : "Time is invalid."
624
+ });
625
+ }
626
+ D(
627
+ L,
628
+ (a) => {
629
+ g("update:validationState", a);
630
+ },
631
+ { immediate: !0 }
632
+ );
633
+ const N = h(
634
+ () => A.value ? V.value : null
635
+ ), s = h(
636
+ () => A.value ? M.value : null
637
+ );
638
+ function u(a) {
639
+ return He(
640
+ a,
641
+ N.value,
642
+ s.value
643
+ );
644
+ }
645
+ function d(a, i, m) {
646
+ const F = !Te(
647
+ i,
648
+ N.value,
649
+ s.value
650
+ ), I = u(i);
651
+ return q(I) ? (m.emitValidation && _(a, "invalid", "DISABLED", I), !1) : (B(a, I), m.emitValidation && (F ? _(a, "out-of-range", "OUT_OF_RANGE", I) : _(a, "valid", void 0, I)), !0);
652
+ }
653
+ const v = h({
440
654
  get() {
441
655
  return Array.isArray(c.value) ? c.value[0] : c.value;
442
656
  },
443
- set(e) {
444
- Array.isArray(c.value) ? c.value = [e, c.value[1]] : c.value = e;
657
+ set(a) {
658
+ d("first", a, { emitValidation: !0 });
445
659
  }
446
- }), g = y({
660
+ }), f = h({
447
661
  get() {
448
662
  return Array.isArray(c.value) ? c.value[1] : c.value;
449
663
  },
450
- set(e) {
451
- Array.isArray(c.value) && (c.value = [c.value[0], e]);
664
+ set(a) {
665
+ Array.isArray(c.value) && d("second", a, { emitValidation: !0 });
452
666
  }
453
667
  });
454
- y(() => {
455
- if (!o.modelValue) return "—";
456
- const e = (t) => _(o.format, t);
457
- return o.range ? `${e(v.value)} → ${e(g.value)}` : e(v.value);
458
- }), E(
459
- () => o.range,
460
- (e) => {
461
- if (e) {
462
- if (!Array.isArray(o.modelValue))
668
+ h(() => {
669
+ if (!e.modelValue) return "—";
670
+ const a = (i) => Z(e.format, i);
671
+ return e.range ? `${a(v.value)} → ${a(f.value)}` : a(v.value);
672
+ }), D(
673
+ () => e.range,
674
+ (a) => {
675
+ if (a) {
676
+ if (!Array.isArray(e.modelValue))
463
677
  throw new RangeError(
464
- `Model value must be an array for range selection: ${o.modelValue}`
678
+ `Model value must be an array for range selection: ${e.modelValue}`
465
679
  );
466
- } else if (Array.isArray(o.modelValue))
680
+ } else if (Array.isArray(e.modelValue))
467
681
  throw new RangeError(
468
- `Model value must be a single string for single time selection: ${o.modelValue}`
682
+ `Model value must be a single string for single time selection: ${e.modelValue}`
469
683
  );
470
684
  },
471
685
  { immediate: !0 }
686
+ ), D(
687
+ () => [N.value, s.value, e.range],
688
+ () => {
689
+ d("first", U("first"), {
690
+ emitValidation: !0
691
+ }), e.range && d("second", U("second"), {
692
+ emitValidation: !0
693
+ });
694
+ },
695
+ { immediate: !0 }
696
+ ), D(
697
+ () => [R.value, e.isTimeDisabled, e.range],
698
+ () => {
699
+ d("first", U("first"), {
700
+ emitValidation: !0
701
+ }), e.range && d("second", U("second"), {
702
+ emitValidation: !0
703
+ });
704
+ },
705
+ { immediate: !0 }
472
706
  );
473
- const h = y(() => o.format ?? "HH:mm:ss"), x = y(() => {
474
- let e = h.value.length;
475
- return /[AaPp]$/.test(h.value) && (e += 1), `${Math.min(12, Math.max(4, e))}ch`;
476
- }), m = ae(h), H = m.inputValue, P = ae(h), N = P.inputValue;
477
- E(
478
- () => [v.value, h.value],
479
- ([e]) => {
480
- m.setFromTime(e);
707
+ const b = h(() => e.format ?? "HH:mm:ss"), C = h(() => {
708
+ let a = b.value.length;
709
+ return /[AaPp]$/.test(b.value) && (a += 1), `${Math.min(12, Math.max(4, a))}ch`;
710
+ }), P = ke(b), Y = P.inputValue, $ = ke(b), ee = $.inputValue;
711
+ D(
712
+ () => [v.value, b.value],
713
+ ([a]) => {
714
+ P.setFromTime(a);
481
715
  },
482
716
  { immediate: !0 }
483
- ), E(
484
- () => [g.value, h.value, o.range],
485
- ([e, , t]) => {
486
- if (!t) {
487
- P.setFromTime({ h: 0, m: 0, s: 0 });
717
+ ), D(
718
+ () => [f.value, b.value, e.range],
719
+ ([a, , i]) => {
720
+ if (!i) {
721
+ $.setFromTime({ h: 0, m: 0, s: 0 });
488
722
  return;
489
723
  }
490
- P.setFromTime(e);
724
+ $.setFromTime(a);
491
725
  },
492
726
  { immediate: !0 }
493
727
  );
494
- const L = w(null);
495
- function $(e) {
496
- if (e.key === "Enter") {
497
- e.preventDefault(), V("first");
728
+ const J = E(null);
729
+ function te(a) {
730
+ if (e.disabled) return;
731
+ if (a.key === "Enter") {
732
+ a.preventDefault(), G("first");
498
733
  return;
499
734
  }
500
- /^\d$/.test(e.key) && (a.value = !1, f.value = !1);
501
- const t = e.target, n = m.displayPosToDigitIndex(t.selectionStart ?? 0), d = /^\d$/.test(e.key) && n >= m.totalDigits.value - 1;
502
- if (m.handleKeydown(e), /^\d$/.test(e.key)) {
503
- const i = m.getParsedTime();
504
- i && (l.value = null, v.value = i);
735
+ /^\d$/.test(a.key) && (r.value = !1, y.value = !1);
736
+ const i = a.target, m = P.displayPosToDigitIndex(i.selectionStart ?? 0), F = /^\d$/.test(a.key) && m >= P.totalDigits.value - 1;
737
+ if (P.handleKeydown(a), /^\d$/.test(a.key)) {
738
+ const I = P.getParsedTime();
739
+ I && d("first", I, { emitValidation: !1 });
505
740
  }
506
- o.range && d && L.value && (V("first"), Y(() => {
507
- const i = L.value;
508
- i && (i.focus(), i.selectionStart = i.selectionEnd = 0);
741
+ e.range && F && J.value && (G("first"), ve(() => {
742
+ const I = J.value;
743
+ I && (I.focus(), I.selectionStart = I.selectionEnd = 0);
509
744
  }));
510
745
  }
511
- function F(e) {
512
- if (e.key === "Enter") {
513
- e.preventDefault(), V("second");
514
- return;
515
- }
516
- if (/^\d$/.test(e.key) && (a.value = !1, f.value = !1), P.handleKeydown(e), /^\d$/.test(e.key)) {
517
- const t = P.getParsedTime();
518
- t && (l.value = null, g.value = t);
746
+ function ie(a) {
747
+ if (!e.disabled) {
748
+ if (a.key === "Enter") {
749
+ a.preventDefault(), G("second");
750
+ return;
751
+ }
752
+ if (/^\d$/.test(a.key) && (r.value = !1, y.value = !1), $.handleKeydown(a), /^\d$/.test(a.key)) {
753
+ const i = $.getParsedTime();
754
+ i && d("second", i, { emitValidation: !1 });
755
+ }
519
756
  }
520
757
  }
521
- function V(e) {
522
- const n = (e === "first" ? m : P).getParsedTime();
523
- n && (l.value = null, e === "first" ? v.value = n : o.range && (g.value = n)), e === "first" ? m.setFromTime(v.value) : o.range && P.setFromTime(g.value);
758
+ function G(a) {
759
+ const m = (a === "first" ? P : $).getParsedTime();
760
+ m ? d(a, m, { emitValidation: !0 }) : _(a, "invalid", "BAD_TIME"), a === "first" ? P.setFromTime(v.value) : e.range && $.setFromTime(f.value);
524
761
  }
525
- return (e, t) => (b(), D("div", {
762
+ return (a, i) => (K(), W("div", {
526
763
  class: "timepicker-shell",
527
- "data-size": o.size
764
+ "data-size": e.size,
765
+ "data-validation": L.value,
766
+ "data-disabled": e.disabled ? "true" : "false"
528
767
  }, [
529
- o.range ? (b(), D("div", {
768
+ e.range ? (K(), W("div", {
530
769
  key: 1,
531
- class: q(["timepicker-shell__input", { "timepicker-shell__input--error": l.value }])
770
+ class: re(["timepicker-shell__input", {
771
+ "timepicker-shell__input--error": l.value,
772
+ "timepicker-shell__input--disabled": e.disabled
773
+ }])
532
774
  }, [
533
- K("input", {
775
+ X("input", {
534
776
  type: "text",
535
777
  class: "timepicker-field",
536
- value: T(H),
537
- placeholder: h.value,
538
- style: R({ width: x.value }),
539
- onFocus: t[4] || (t[4] = (n) => a.value = !0),
540
- onKeydown: $,
541
- onInput: t[5] || (t[5] = //@ts-ignore
542
- (...n) => T(m).handleInput && T(m).handleInput(...n)),
543
- onPaste: t[6] || (t[6] = //@ts-ignore
544
- (...n) => T(m).handlePaste && T(m).handlePaste(...n)),
545
- onBlur: t[7] || (t[7] = (n) => V("first"))
546
- }, null, 44, Ae),
547
- t[16] || (t[16] = K("span", { class: "timepicker-separator" }, "–", -1)),
548
- K("input", {
778
+ value: H(Y),
779
+ placeholder: b.value,
780
+ style: oe({ width: C.value }),
781
+ disabled: e.disabled,
782
+ onFocus: i[4] || (i[4] = (m) => !e.disabled && (r.value = !0)),
783
+ onKeydown: te,
784
+ onInput: i[5] || (i[5] = //@ts-ignore
785
+ (...m) => H(P).handleInput && H(P).handleInput(...m)),
786
+ onPaste: i[6] || (i[6] = //@ts-ignore
787
+ (...m) => H(P).handlePaste && H(P).handlePaste(...m)),
788
+ onBlur: i[7] || (i[7] = (m) => !e.disabled && G("first"))
789
+ }, null, 44, _e),
790
+ i[16] || (i[16] = X("span", { class: "timepicker-separator" }, "–", -1)),
791
+ X("input", {
549
792
  ref_key: "secondInputRef",
550
- ref: L,
793
+ ref: J,
551
794
  type: "text",
552
795
  class: "timepicker-field",
553
- value: T(N),
554
- placeholder: h.value,
555
- style: R({ width: x.value }),
556
- onFocus: t[8] || (t[8] = (n) => f.value = !0),
557
- onKeydown: F,
558
- onInput: t[9] || (t[9] = //@ts-ignore
559
- (...n) => T(P).handleInput && T(P).handleInput(...n)),
560
- onPaste: t[10] || (t[10] = //@ts-ignore
561
- (...n) => T(P).handlePaste && T(P).handlePaste(...n)),
562
- onBlur: t[11] || (t[11] = (n) => V("second"))
563
- }, null, 44, Pe)
564
- ], 2)) : (b(), D("div", {
796
+ value: H(ee),
797
+ placeholder: b.value,
798
+ style: oe({ width: C.value }),
799
+ disabled: e.disabled,
800
+ onFocus: i[8] || (i[8] = (m) => !e.disabled && (y.value = !0)),
801
+ onKeydown: ie,
802
+ onInput: i[9] || (i[9] = //@ts-ignore
803
+ (...m) => H($).handleInput && H($).handleInput(...m)),
804
+ onPaste: i[10] || (i[10] = //@ts-ignore
805
+ (...m) => H($).handlePaste && H($).handlePaste(...m)),
806
+ onBlur: i[11] || (i[11] = (m) => !e.disabled && G("second"))
807
+ }, null, 44, Re)
808
+ ], 2)) : (K(), W("div", {
565
809
  key: 0,
566
- class: q(["timepicker-shell__input", { "timepicker-shell__input--error": l.value }])
810
+ class: re(["timepicker-shell__input", {
811
+ "timepicker-shell__input--error": l.value,
812
+ "timepicker-shell__input--disabled": e.disabled
813
+ }])
567
814
  }, [
568
- K("input", {
815
+ X("input", {
569
816
  type: "text",
570
817
  class: "timepicker-field",
571
- value: T(H),
572
- placeholder: h.value,
573
- style: R({ width: x.value }),
574
- onFocus: t[0] || (t[0] = (n) => a.value = !0),
575
- onKeydown: $,
576
- onInput: t[1] || (t[1] = //@ts-ignore
577
- (...n) => T(m).handleInput && T(m).handleInput(...n)),
578
- onPaste: t[2] || (t[2] = //@ts-ignore
579
- (...n) => T(m).handlePaste && T(m).handlePaste(...n)),
580
- onBlur: t[3] || (t[3] = (n) => V("first"))
581
- }, null, 44, xe)
818
+ value: H(Y),
819
+ placeholder: b.value,
820
+ style: oe({ width: C.value }),
821
+ disabled: e.disabled,
822
+ onFocus: i[0] || (i[0] = (m) => !e.disabled && (r.value = !0)),
823
+ onKeydown: te,
824
+ onInput: i[1] || (i[1] = //@ts-ignore
825
+ (...m) => H(P).handleInput && H(P).handleInput(...m)),
826
+ onPaste: i[2] || (i[2] = //@ts-ignore
827
+ (...m) => H(P).handlePaste && H(P).handlePaste(...m)),
828
+ onBlur: i[3] || (i[3] = (m) => !e.disabled && G("first"))
829
+ }, null, 44, Fe)
582
830
  ], 2)),
583
- K("div", null, [
584
- W(ne, {
585
- open: a.value,
586
- "onUpdate:open": t[12] || (t[12] = (n) => a.value = n),
831
+ X("div", null, [
832
+ ue(be, {
833
+ open: r.value,
834
+ "onUpdate:open": i[12] || (i[12] = (m) => r.value = m),
587
835
  initTime: v.value,
588
- "onUpdate:initTime": t[13] || (t[13] = (n) => v.value = n),
589
- format: o.format,
590
- "hour-step": o.hourStep,
591
- "minute-step": o.minuteStep,
592
- "second-step": o.secondStep
593
- }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step"]),
594
- o.range ? (b(), J(ne, {
836
+ "onUpdate:initTime": i[13] || (i[13] = (m) => v.value = m),
837
+ format: e.format,
838
+ "hour-step": e.hourStep,
839
+ "minute-step": e.minuteStep,
840
+ "second-step": e.secondStep,
841
+ "min-time": N.value,
842
+ "max-time": s.value,
843
+ "disabled-ranges": R.value,
844
+ "is-time-disabled": e.isTimeDisabled
845
+ }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step", "min-time", "max-time", "disabled-ranges", "is-time-disabled"]),
846
+ e.range ? (K(), de(be, {
595
847
  key: 0,
596
- open: f.value,
597
- "onUpdate:open": t[14] || (t[14] = (n) => f.value = n),
598
- initTime: g.value,
599
- "onUpdate:initTime": t[15] || (t[15] = (n) => g.value = n),
600
- format: o.format,
601
- "hour-step": o.hourStep,
602
- "minute-step": o.minuteStep,
603
- "second-step": o.secondStep
604
- }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step"])) : B("", !0)
848
+ open: y.value,
849
+ "onUpdate:open": i[14] || (i[14] = (m) => y.value = m),
850
+ initTime: f.value,
851
+ "onUpdate:initTime": i[15] || (i[15] = (m) => f.value = m),
852
+ format: e.format,
853
+ "hour-step": e.hourStep,
854
+ "minute-step": e.minuteStep,
855
+ "second-step": e.secondStep,
856
+ "min-time": N.value,
857
+ "max-time": s.value,
858
+ "disabled-ranges": R.value,
859
+ "is-time-disabled": e.isTimeDisabled
860
+ }, null, 8, ["open", "initTime", "format", "hour-step", "minute-step", "second-step", "min-time", "max-time", "disabled-ranges", "is-time-disabled"])) : ae("", !0)
605
861
  ])
606
- ], 8, Me));
862
+ ], 8, Be));
607
863
  }
608
864
  });
609
865
  export {
610
- we as TimePicker
866
+ Ke as TimePicker
611
867
  };