@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.
- package/README.md +118 -11
- package/dist/TimePicker/TimePicker.vue.d.ts +73 -7
- package/dist/TimePicker/TimeSelection.vue.d.ts +4 -0
- package/dist/TimePicker/types.d.ts +36 -3
- package/dist/helpers.d.ts +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/stories/TimePicker.stories.d.ts +677 -0
- package/dist/vue-timepicker.css +1 -1
- package/dist/vue-timepicker.js +679 -423
- package/dist/vue-timepicker.umd.cjs +1 -1
- package/package.json +9 -1
package/dist/vue-timepicker.js
CHANGED
|
@@ -1,611 +1,867 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
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(
|
|
10
|
-
const l =
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
15
|
-
const
|
|
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 (
|
|
19
|
-
const
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
function
|
|
26
|
-
|
|
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
|
|
29
|
-
return (
|
|
30
|
-
|
|
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:
|
|
32
|
+
ref: g,
|
|
33
33
|
class: "timepicker-dropdown__panel",
|
|
34
34
|
role: "listbox",
|
|
35
35
|
tabindex: "-1"
|
|
36
36
|
}, [
|
|
37
|
-
(
|
|
38
|
-
key:
|
|
39
|
-
class:
|
|
40
|
-
"timepicker-option--active":
|
|
41
|
-
"timepicker-option--disabled":
|
|
42
|
-
"timepicker-option--focused":
|
|
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:
|
|
46
|
-
onClick: (
|
|
47
|
-
onMousemove: (
|
|
48
|
-
},
|
|
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
|
|
54
|
-
return
|
|
53
|
+
function he(t) {
|
|
54
|
+
return t.h * 3600 + t.m * 60 + t.s;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
57
|
-
return /(p|P)/.test(
|
|
56
|
+
function ye(t) {
|
|
57
|
+
return /(a|A|p|P)/.test(t);
|
|
58
58
|
}
|
|
59
|
-
function
|
|
60
|
-
return /
|
|
59
|
+
function we(t) {
|
|
60
|
+
return /(p|P)/.test(t);
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
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
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
74
|
-
|
|
72
|
+
function De(t) {
|
|
73
|
+
const o = t % 12;
|
|
74
|
+
return o === 0 ? 12 : o;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return
|
|
76
|
+
function ge(t, o) {
|
|
77
|
+
return o ? t % 12 + 12 : t % 12;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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(
|
|
89
|
-
k: String(
|
|
90
|
-
mm: String(
|
|
91
|
-
m: String(
|
|
92
|
-
ss: String(
|
|
93
|
-
s: String(
|
|
94
|
-
A:
|
|
95
|
-
a:
|
|
96
|
-
P:
|
|
97
|
-
p:
|
|
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
|
|
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
|
|
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(
|
|
113
|
-
const l =
|
|
114
|
-
get: () =>
|
|
115
|
-
set: (
|
|
116
|
-
const
|
|
117
|
-
|
|
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
|
-
}),
|
|
120
|
-
function
|
|
121
|
-
if (!
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
() => document.removeEventListener("mousedown",
|
|
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
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
() =>
|
|
135
|
-
(
|
|
136
|
-
const
|
|
137
|
-
let
|
|
138
|
-
l.value ? (
|
|
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
|
|
142
|
-
const
|
|
143
|
-
for (let
|
|
144
|
-
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
function
|
|
148
|
-
const
|
|
149
|
-
for (let
|
|
150
|
-
const
|
|
151
|
-
|
|
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
|
|
172
|
+
return T;
|
|
154
173
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
157
|
-
for (let
|
|
158
|
-
const
|
|
159
|
-
|
|
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
|
|
180
|
+
return k;
|
|
162
181
|
}
|
|
163
|
-
const
|
|
182
|
+
const B = E(we(r.format) ? 1 : 0), _ = h(() => {
|
|
164
183
|
if (!l.value)
|
|
165
|
-
return
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
}),
|
|
169
|
-
const
|
|
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:
|
|
172
|
-
{ key: "PM", value: "PM", text:
|
|
190
|
+
{ key: "AM", value: "AM", text: n },
|
|
191
|
+
{ key: "PM", value: "PM", text: p }
|
|
173
192
|
];
|
|
174
|
-
}),
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
183
|
-
|
|
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
|
|
186
|
-
l.value ||
|
|
278
|
+
function m(n) {
|
|
279
|
+
l.value || I();
|
|
187
280
|
}
|
|
188
|
-
function
|
|
189
|
-
|
|
281
|
+
function F(n) {
|
|
282
|
+
I();
|
|
190
283
|
}
|
|
191
|
-
function
|
|
192
|
-
|
|
284
|
+
function I() {
|
|
285
|
+
x.value = !1;
|
|
193
286
|
}
|
|
194
|
-
return
|
|
195
|
-
[
|
|
196
|
-
([
|
|
197
|
-
|
|
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
|
-
), (
|
|
293
|
+
), (n, p) => x.value ? (K(), W("div", {
|
|
201
294
|
key: 0,
|
|
202
295
|
class: "vtp-cols",
|
|
203
296
|
ref_key: "root",
|
|
204
|
-
ref:
|
|
297
|
+
ref: S
|
|
205
298
|
}, [
|
|
206
|
-
|
|
207
|
-
activeIndex:
|
|
208
|
-
"onUpdate:activeIndex":
|
|
209
|
-
items:
|
|
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
|
-
|
|
213
|
-
activeIndex:
|
|
214
|
-
"onUpdate:activeIndex":
|
|
215
|
-
items:
|
|
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:
|
|
310
|
+
onSelect: i
|
|
218
311
|
}, null, 8, ["activeIndex", "items"]),
|
|
219
|
-
|
|
312
|
+
e.value ? (K(), de(ne, {
|
|
220
313
|
key: 0,
|
|
221
|
-
activeIndex:
|
|
222
|
-
"onUpdate:activeIndex":
|
|
223
|
-
items:
|
|
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:
|
|
226
|
-
}, null, 8, ["activeIndex", "items"])) :
|
|
227
|
-
l.value ? (
|
|
318
|
+
onSelect: m
|
|
319
|
+
}, null, 8, ["activeIndex", "items"])) : ae("", !0),
|
|
320
|
+
l.value ? (K(), de(ne, {
|
|
228
321
|
key: 1,
|
|
229
|
-
activeIndex:
|
|
230
|
-
"onUpdate:activeIndex":
|
|
231
|
-
items:
|
|
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:
|
|
234
|
-
}, null, 8, ["activeIndex", "items"])) :
|
|
235
|
-
], 512)) :
|
|
326
|
+
onSelect: F
|
|
327
|
+
}, null, 8, ["activeIndex", "items"])) : ae("", !0)
|
|
328
|
+
], 512)) : ae("", !0);
|
|
236
329
|
}
|
|
237
|
-
})
|
|
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: (
|
|
242
|
-
let
|
|
243
|
-
return Array.isArray(
|
|
244
|
-
`[VueTimepicker] \`modelValue\` is wrong. Received: ${
|
|
245
|
-
),
|
|
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: (
|
|
259
|
-
const
|
|
260
|
-
return !
|
|
261
|
-
`[VueTimepicker] \`format\` format is wrong. Received: ${
|
|
262
|
-
),
|
|
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: (
|
|
269
|
-
const
|
|
270
|
-
return !
|
|
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
|
|
275
|
-
const
|
|
276
|
-
if (!
|
|
277
|
-
const [, l,
|
|
278
|
-
let
|
|
279
|
-
return
|
|
280
|
-
digitGroups:
|
|
281
|
-
hasAmPm: !!
|
|
282
|
-
ampmLowercase:
|
|
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
|
|
286
|
-
const
|
|
287
|
-
function
|
|
288
|
-
const { digitGroups:
|
|
289
|
-
let
|
|
290
|
-
for (let
|
|
291
|
-
for (let
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
if (
|
|
296
|
-
const
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
return
|
|
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
|
|
302
|
-
const
|
|
303
|
-
if (
|
|
304
|
-
const
|
|
305
|
-
|
|
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
|
|
308
|
-
for (let
|
|
309
|
-
|
|
438
|
+
function S() {
|
|
439
|
+
for (let s = 0; s < o.value.digitGroups.length; s++)
|
|
440
|
+
x(s);
|
|
310
441
|
}
|
|
311
|
-
function
|
|
312
|
-
const
|
|
313
|
-
let
|
|
314
|
-
for (let
|
|
315
|
-
/\d/.test(
|
|
316
|
-
return
|
|
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
|
|
319
|
-
return
|
|
449
|
+
function V(s) {
|
|
450
|
+
return s + Math.floor(s / 2);
|
|
320
451
|
}
|
|
321
|
-
function
|
|
322
|
-
if (
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
const
|
|
326
|
-
return
|
|
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
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
document.activeElement ===
|
|
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
|
|
337
|
-
const
|
|
467
|
+
function L(s) {
|
|
468
|
+
const u = s.key, d = s.target;
|
|
338
469
|
if (["Tab", "Escape", "ArrowLeft", "ArrowRight", "Home", "End"].includes(
|
|
339
|
-
|
|
340
|
-
) ||
|
|
470
|
+
u
|
|
471
|
+
) || s.metaKey || s.ctrlKey)
|
|
341
472
|
return;
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
|
|
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 (
|
|
349
|
-
if (
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
|
|
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 (
|
|
356
|
-
|
|
486
|
+
if (b === "p") {
|
|
487
|
+
g.value = "PM", A(d, f);
|
|
357
488
|
return;
|
|
358
489
|
}
|
|
359
490
|
}
|
|
360
|
-
if (/^\d$/.test(
|
|
361
|
-
const
|
|
362
|
-
|
|
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
|
|
368
|
-
const
|
|
369
|
-
|
|
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
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
let
|
|
375
|
-
for (const
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
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
|
|
382
|
-
const { digitGroups:
|
|
383
|
-
let
|
|
384
|
-
|
|
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 (
|
|
388
|
-
const
|
|
389
|
-
for (let
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
let
|
|
394
|
-
const
|
|
395
|
-
return
|
|
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
|
|
398
|
-
() =>
|
|
399
|
-
),
|
|
528
|
+
const _ = h(
|
|
529
|
+
() => e.value.length >= l.value
|
|
530
|
+
), N = h(() => o.value.ampmLowercase);
|
|
400
531
|
return {
|
|
401
|
-
inputValue:
|
|
402
|
-
handleKeydown:
|
|
403
|
-
handleInput:
|
|
404
|
-
handlePaste:
|
|
405
|
-
setFromTime:
|
|
406
|
-
getParsedTime:
|
|
407
|
-
isComplete:
|
|
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:
|
|
410
|
-
ampm:
|
|
411
|
-
ampmLowercase:
|
|
540
|
+
displayPosToDigitIndex: c,
|
|
541
|
+
ampm: g,
|
|
542
|
+
ampmLowercase: N
|
|
412
543
|
};
|
|
413
544
|
}
|
|
414
|
-
const
|
|
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:
|
|
417
|
-
emits: ["update:modelValue", "open", "close", "error"],
|
|
418
|
-
setup(
|
|
419
|
-
const l =
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
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(
|
|
428
|
-
const [
|
|
429
|
-
return [z(
|
|
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(
|
|
575
|
+
return z(e.modelValue, e.format);
|
|
432
576
|
},
|
|
433
|
-
set(
|
|
434
|
-
Array.isArray(
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
]) :
|
|
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
|
-
|
|
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(
|
|
444
|
-
|
|
657
|
+
set(a) {
|
|
658
|
+
d("first", a, { emitValidation: !0 });
|
|
445
659
|
}
|
|
446
|
-
}),
|
|
660
|
+
}), f = h({
|
|
447
661
|
get() {
|
|
448
662
|
return Array.isArray(c.value) ? c.value[1] : c.value;
|
|
449
663
|
},
|
|
450
|
-
set(
|
|
451
|
-
Array.isArray(c.value) && (
|
|
664
|
+
set(a) {
|
|
665
|
+
Array.isArray(c.value) && d("second", a, { emitValidation: !0 });
|
|
452
666
|
}
|
|
453
667
|
});
|
|
454
|
-
|
|
455
|
-
if (!
|
|
456
|
-
const
|
|
457
|
-
return
|
|
458
|
-
}),
|
|
459
|
-
() =>
|
|
460
|
-
(
|
|
461
|
-
if (
|
|
462
|
-
if (!Array.isArray(
|
|
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: ${
|
|
678
|
+
`Model value must be an array for range selection: ${e.modelValue}`
|
|
465
679
|
);
|
|
466
|
-
} else if (Array.isArray(
|
|
680
|
+
} else if (Array.isArray(e.modelValue))
|
|
467
681
|
throw new RangeError(
|
|
468
|
-
`Model value must be a single string for single time selection: ${
|
|
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
|
|
474
|
-
let
|
|
475
|
-
return /[AaPp]$/.test(
|
|
476
|
-
}),
|
|
477
|
-
|
|
478
|
-
() => [v.value,
|
|
479
|
-
([
|
|
480
|
-
|
|
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
|
-
),
|
|
484
|
-
() => [
|
|
485
|
-
([
|
|
486
|
-
if (!
|
|
487
|
-
|
|
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
|
-
|
|
724
|
+
$.setFromTime(a);
|
|
491
725
|
},
|
|
492
726
|
{ immediate: !0 }
|
|
493
727
|
);
|
|
494
|
-
const
|
|
495
|
-
function
|
|
496
|
-
if (e.
|
|
497
|
-
|
|
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(
|
|
501
|
-
const
|
|
502
|
-
if (
|
|
503
|
-
const
|
|
504
|
-
|
|
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
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
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
|
|
512
|
-
if (e.
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
|
522
|
-
const
|
|
523
|
-
|
|
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 (
|
|
762
|
+
return (a, i) => (K(), W("div", {
|
|
526
763
|
class: "timepicker-shell",
|
|
527
|
-
"data-size":
|
|
764
|
+
"data-size": e.size,
|
|
765
|
+
"data-validation": L.value,
|
|
766
|
+
"data-disabled": e.disabled ? "true" : "false"
|
|
528
767
|
}, [
|
|
529
|
-
|
|
768
|
+
e.range ? (K(), W("div", {
|
|
530
769
|
key: 1,
|
|
531
|
-
class:
|
|
770
|
+
class: re(["timepicker-shell__input", {
|
|
771
|
+
"timepicker-shell__input--error": l.value,
|
|
772
|
+
"timepicker-shell__input--disabled": e.disabled
|
|
773
|
+
}])
|
|
532
774
|
}, [
|
|
533
|
-
|
|
775
|
+
X("input", {
|
|
534
776
|
type: "text",
|
|
535
777
|
class: "timepicker-field",
|
|
536
|
-
value:
|
|
537
|
-
placeholder:
|
|
538
|
-
style:
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
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:
|
|
793
|
+
ref: J,
|
|
551
794
|
type: "text",
|
|
552
795
|
class: "timepicker-field",
|
|
553
|
-
value:
|
|
554
|
-
placeholder:
|
|
555
|
-
style:
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
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:
|
|
810
|
+
class: re(["timepicker-shell__input", {
|
|
811
|
+
"timepicker-shell__input--error": l.value,
|
|
812
|
+
"timepicker-shell__input--disabled": e.disabled
|
|
813
|
+
}])
|
|
567
814
|
}, [
|
|
568
|
-
|
|
815
|
+
X("input", {
|
|
569
816
|
type: "text",
|
|
570
817
|
class: "timepicker-field",
|
|
571
|
-
value:
|
|
572
|
-
placeholder:
|
|
573
|
-
style:
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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
|
-
|
|
584
|
-
|
|
585
|
-
open:
|
|
586
|
-
"onUpdate:open":
|
|
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":
|
|
589
|
-
format:
|
|
590
|
-
"hour-step":
|
|
591
|
-
"minute-step":
|
|
592
|
-
"second-step":
|
|
593
|
-
|
|
594
|
-
|
|
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:
|
|
597
|
-
"onUpdate:open":
|
|
598
|
-
initTime:
|
|
599
|
-
"onUpdate:initTime":
|
|
600
|
-
format:
|
|
601
|
-
"hour-step":
|
|
602
|
-
"minute-step":
|
|
603
|
-
"second-step":
|
|
604
|
-
|
|
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,
|
|
862
|
+
], 8, Be));
|
|
607
863
|
}
|
|
608
864
|
});
|
|
609
865
|
export {
|
|
610
|
-
|
|
866
|
+
Ke as TimePicker
|
|
611
867
|
};
|