courthive-components 6.10.2 → 6.10.3
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/dist/courthive-components.es.js +10 -10
- package/dist/courthive-components.umd.js +50 -50
- package/dist/dist-D160D4O-.mjs +3374 -0
- package/dist/range-CbB5sPGX.mjs +452 -0
- package/package.json +6 -6
- package/dist/dist-DtcVkd_L.mjs +0 -2852
- package/dist/range-BLOZcKzY.mjs +0 -430
package/dist/dist-DtcVkd_L.mjs
DELETED
|
@@ -1,2852 +0,0 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/timepicker-ui@4.4.0/node_modules/timepicker-ui/dist/index.js
|
|
2
|
-
var e = () => typeof window > "u", t = () => typeof document < "u", n = class {
|
|
3
|
-
_degreesHours = null;
|
|
4
|
-
_degreesMinutes = null;
|
|
5
|
-
_options;
|
|
6
|
-
_isMobileView = !1;
|
|
7
|
-
_isTouchMouseMove = !1;
|
|
8
|
-
_disabledTime = null;
|
|
9
|
-
_cloned = null;
|
|
10
|
-
_isModalRemove = !0;
|
|
11
|
-
_isOpen = !1;
|
|
12
|
-
_isInitialized = !1;
|
|
13
|
-
_eventHandlersRegistered = !1;
|
|
14
|
-
_isDestroyed = !1;
|
|
15
|
-
element;
|
|
16
|
-
instanceId;
|
|
17
|
-
customId;
|
|
18
|
-
constructor(e, t, n, r) {
|
|
19
|
-
this.element = e, this.instanceId = n, this.customId = r, this._options = t;
|
|
20
|
-
}
|
|
21
|
-
get degreesHours() {
|
|
22
|
-
return this._degreesHours;
|
|
23
|
-
}
|
|
24
|
-
get degreesMinutes() {
|
|
25
|
-
return this._degreesMinutes;
|
|
26
|
-
}
|
|
27
|
-
get options() {
|
|
28
|
-
return this._options;
|
|
29
|
-
}
|
|
30
|
-
get isMobileView() {
|
|
31
|
-
return this._isMobileView;
|
|
32
|
-
}
|
|
33
|
-
get isTouchMouseMove() {
|
|
34
|
-
return this._isTouchMouseMove;
|
|
35
|
-
}
|
|
36
|
-
get disabledTime() {
|
|
37
|
-
return this._disabledTime;
|
|
38
|
-
}
|
|
39
|
-
get cloned() {
|
|
40
|
-
return this._cloned;
|
|
41
|
-
}
|
|
42
|
-
get isModalRemove() {
|
|
43
|
-
return this._isModalRemove;
|
|
44
|
-
}
|
|
45
|
-
get isOpen() {
|
|
46
|
-
return this._isOpen;
|
|
47
|
-
}
|
|
48
|
-
get isInitialized() {
|
|
49
|
-
return this._isInitialized;
|
|
50
|
-
}
|
|
51
|
-
get eventHandlersRegistered() {
|
|
52
|
-
return this._eventHandlersRegistered;
|
|
53
|
-
}
|
|
54
|
-
get isDestroyed() {
|
|
55
|
-
return this._isDestroyed;
|
|
56
|
-
}
|
|
57
|
-
setDegreesHours(e) {
|
|
58
|
-
this._degreesHours = e;
|
|
59
|
-
}
|
|
60
|
-
setDegreesMinutes(e) {
|
|
61
|
-
this._degreesMinutes = e;
|
|
62
|
-
}
|
|
63
|
-
setOptions(e) {
|
|
64
|
-
this._options = e;
|
|
65
|
-
}
|
|
66
|
-
setIsMobileView(e) {
|
|
67
|
-
this._isMobileView = e;
|
|
68
|
-
}
|
|
69
|
-
setIsTouchMouseMove(e) {
|
|
70
|
-
this._isTouchMouseMove = e;
|
|
71
|
-
}
|
|
72
|
-
setDisabledTime(e) {
|
|
73
|
-
this._disabledTime = e;
|
|
74
|
-
}
|
|
75
|
-
setCloned(e) {
|
|
76
|
-
this._cloned = e;
|
|
77
|
-
}
|
|
78
|
-
setIsModalRemove(e) {
|
|
79
|
-
this._isModalRemove = e;
|
|
80
|
-
}
|
|
81
|
-
setIsOpen(e) {
|
|
82
|
-
this._isOpen = e;
|
|
83
|
-
}
|
|
84
|
-
setIsInitialized(e) {
|
|
85
|
-
this._isInitialized = e;
|
|
86
|
-
}
|
|
87
|
-
setEventHandlersRegistered(e) {
|
|
88
|
-
this._eventHandlersRegistered = e;
|
|
89
|
-
}
|
|
90
|
-
setIsDestroyed(e) {
|
|
91
|
-
this._isDestroyed = e;
|
|
92
|
-
}
|
|
93
|
-
updateOptions(e) {
|
|
94
|
-
this._options = {
|
|
95
|
-
...this._options,
|
|
96
|
-
clock: {
|
|
97
|
-
...this._options.clock,
|
|
98
|
-
...e.clock || {}
|
|
99
|
-
},
|
|
100
|
-
ui: {
|
|
101
|
-
...this._options.ui,
|
|
102
|
-
...e.ui || {}
|
|
103
|
-
},
|
|
104
|
-
labels: {
|
|
105
|
-
...this._options.labels,
|
|
106
|
-
...e.labels || {}
|
|
107
|
-
},
|
|
108
|
-
behavior: {
|
|
109
|
-
...this._options.behavior,
|
|
110
|
-
...e.behavior || {}
|
|
111
|
-
},
|
|
112
|
-
callbacks: {
|
|
113
|
-
...this._options.callbacks,
|
|
114
|
-
...e.callbacks || {}
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
reset() {
|
|
119
|
-
this._degreesHours = null, this._degreesMinutes = null, this._isTouchMouseMove = !1, this._disabledTime = null, this._cloned = null, this._isModalRemove = !0, this._isOpen = !1, this._isInitialized = !1, this._isDestroyed = !0, this._eventHandlersRegistered = !1;
|
|
120
|
-
}
|
|
121
|
-
q(e) {
|
|
122
|
-
return this.getModalElement()?.querySelector(e) ?? null;
|
|
123
|
-
}
|
|
124
|
-
qMobile(e, t) {
|
|
125
|
-
return this._isMobileView ? this.q(e) : this.q(t);
|
|
126
|
-
}
|
|
127
|
-
getModalElement() {
|
|
128
|
-
return t() === !1 ? null : document.querySelector(`[data-owner-id="${this.instanceId}"]`);
|
|
129
|
-
}
|
|
130
|
-
getInput() {
|
|
131
|
-
return this.element?.querySelector("input");
|
|
132
|
-
}
|
|
133
|
-
getClockFace() {
|
|
134
|
-
return this.qMobile(".tp-ui-clock-face.mobile", ".tp-ui-clock-face:not(.mobile)");
|
|
135
|
-
}
|
|
136
|
-
getClockHand() {
|
|
137
|
-
return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-clock-hand", ".tp-ui-clock-hand:not(.mobile)");
|
|
138
|
-
}
|
|
139
|
-
getCircle() {
|
|
140
|
-
return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-circle-hand", ".tp-ui-circle-hand:not(.mobile)");
|
|
141
|
-
}
|
|
142
|
-
getTipsWrapper() {
|
|
143
|
-
return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper", ".tp-ui-tips-wrapper:not(.mobile)");
|
|
144
|
-
}
|
|
145
|
-
getTipsWrapperFor24h() {
|
|
146
|
-
return this.qMobile(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h", ".tp-ui-tips-wrapper-24h:not(.mobile)");
|
|
147
|
-
}
|
|
148
|
-
getMinutes() {
|
|
149
|
-
return this.q(".tp-ui-minutes");
|
|
150
|
-
}
|
|
151
|
-
getHour() {
|
|
152
|
-
return this.q(".tp-ui-hour");
|
|
153
|
-
}
|
|
154
|
-
getAM() {
|
|
155
|
-
return this.q(".tp-ui-am");
|
|
156
|
-
}
|
|
157
|
-
getPM() {
|
|
158
|
-
return this.q(".tp-ui-pm");
|
|
159
|
-
}
|
|
160
|
-
getHourText() {
|
|
161
|
-
return this.q(".tp-ui-hour-text");
|
|
162
|
-
}
|
|
163
|
-
getMinutesText() {
|
|
164
|
-
return this.q(".tp-ui-minute-text");
|
|
165
|
-
}
|
|
166
|
-
getHeader() {
|
|
167
|
-
return this.q(".tp-ui-header");
|
|
168
|
-
}
|
|
169
|
-
getInputWrappers() {
|
|
170
|
-
return this.getModalElement()?.querySelectorAll(".tp-ui-input-wrapper") || null;
|
|
171
|
-
}
|
|
172
|
-
getDots() {
|
|
173
|
-
return this.q(".tp-ui-dots");
|
|
174
|
-
}
|
|
175
|
-
getMinutesTips() {
|
|
176
|
-
return this.q(".tp-ui-minutes-time");
|
|
177
|
-
}
|
|
178
|
-
getHourTips() {
|
|
179
|
-
return this.q(".tp-ui-hour-time-12");
|
|
180
|
-
}
|
|
181
|
-
getAllValueTips() {
|
|
182
|
-
let e = this.getModalElement();
|
|
183
|
-
return e ? [...e.querySelectorAll(".tp-ui-value-tips"), ...e.querySelectorAll(".tp-ui-value-tips-24h")] : [];
|
|
184
|
-
}
|
|
185
|
-
getOpenElementData() {
|
|
186
|
-
let e = this.element?.querySelectorAll("[data-open]");
|
|
187
|
-
if (e?.length > 0) {
|
|
188
|
-
let t = [];
|
|
189
|
-
return e.forEach(({ dataset: e }) => t.push(e.open ?? "")), [...new Set(t)];
|
|
190
|
-
}
|
|
191
|
-
return null;
|
|
192
|
-
}
|
|
193
|
-
getOpenElement() {
|
|
194
|
-
let e = this.getInput(), t = this.getOpenElementData();
|
|
195
|
-
return t === null ? (e?.setAttribute("data-open", "tp-ui-input"), [e]) : t.map((e) => this.element?.querySelectorAll(`[data-open='${e}']`))[0] ?? "";
|
|
196
|
-
}
|
|
197
|
-
getCancelButton() {
|
|
198
|
-
return this.q(".tp-ui-cancel-btn");
|
|
199
|
-
}
|
|
200
|
-
getOkButton() {
|
|
201
|
-
return this.q(".tp-ui-ok-btn");
|
|
202
|
-
}
|
|
203
|
-
getActiveTypeMode() {
|
|
204
|
-
return this.q(".tp-ui-type-mode.active");
|
|
205
|
-
}
|
|
206
|
-
getKeyboardClockIcon() {
|
|
207
|
-
return this.q(".tp-ui-keyboard-icon-wrapper");
|
|
208
|
-
}
|
|
209
|
-
getFooter() {
|
|
210
|
-
return this.q(".tp-ui-footer");
|
|
211
|
-
}
|
|
212
|
-
getWrapper() {
|
|
213
|
-
return this.q(".tp-ui-wrapper");
|
|
214
|
-
}
|
|
215
|
-
}, r = {
|
|
216
|
-
DEFAULT_DELAY: 300,
|
|
217
|
-
MODAL_ANIMATION: 150,
|
|
218
|
-
SCROLLBAR_RESTORE: 400,
|
|
219
|
-
MODAL_REMOVE: 300,
|
|
220
|
-
CLOCK_ANIMATION: 600,
|
|
221
|
-
TIPS_ANIMATION: 401,
|
|
222
|
-
MOBILE_TOGGLE: 450,
|
|
223
|
-
CLOCK_SCALE_DELAY: 150,
|
|
224
|
-
WRAPPER_TRANSITION: 400,
|
|
225
|
-
DROPDOWN_CLICK_DELAY: 10
|
|
226
|
-
}, i = class {
|
|
227
|
-
core;
|
|
228
|
-
emitter;
|
|
229
|
-
timeouts = [];
|
|
230
|
-
constructor(e, t) {
|
|
231
|
-
this.core = e, this.emitter = t, this.setupEventListeners();
|
|
232
|
-
}
|
|
233
|
-
setupEventListeners() {
|
|
234
|
-
this.emitter.on("animation:clock", () => {
|
|
235
|
-
this.handleAnimationSwitchTipsMode();
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
runWithAnimation(e, t = r.MODAL_ANIMATION) {
|
|
239
|
-
if (this.core.options.ui.animation) {
|
|
240
|
-
let n = setTimeout(e, t);
|
|
241
|
-
this.timeouts.push(n);
|
|
242
|
-
} else e();
|
|
243
|
-
}
|
|
244
|
-
clearAllTimeouts() {
|
|
245
|
-
this.timeouts.forEach(clearTimeout), this.timeouts = [];
|
|
246
|
-
}
|
|
247
|
-
setAnimationToOpen() {
|
|
248
|
-
this.clearAllTimeouts(), this.core.getModalElement()?.classList.add("opacity"), this.runWithAnimation(() => {
|
|
249
|
-
this.core.getModalElement()?.classList.add("show");
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
removeAnimationToClose() {
|
|
253
|
-
this.clearAllTimeouts(), this.core.getModalElement() && this.runWithAnimation(() => {
|
|
254
|
-
let e = this.core.getModalElement();
|
|
255
|
-
e?.classList.remove("show"), e?.classList.remove("opacity");
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
handleAnimationClock() {
|
|
259
|
-
this.core.options.ui.animation && this.runWithAnimation(() => {
|
|
260
|
-
this.core.getClockFace()?.classList.add("tp-ui-clock-animation");
|
|
261
|
-
let e = setTimeout(() => {
|
|
262
|
-
this.core.getClockFace()?.classList.remove("tp-ui-clock-animation");
|
|
263
|
-
}, r.CLOCK_ANIMATION);
|
|
264
|
-
this.timeouts.push(e);
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
handleAnimationSwitchTipsMode() {
|
|
268
|
-
let e = this.core.getClockHand();
|
|
269
|
-
if (!e) return;
|
|
270
|
-
this.emitter.emit("animation:start", {}), e.classList.add("tp-ui-tips-animation");
|
|
271
|
-
let t = setTimeout(() => {
|
|
272
|
-
this.core.getClockHand()?.classList.remove("tp-ui-tips-animation"), this.emitter.emit("animation:end", {});
|
|
273
|
-
}, r.TIPS_ANIMATION);
|
|
274
|
-
this.timeouts.push(t);
|
|
275
|
-
}
|
|
276
|
-
destroy() {
|
|
277
|
-
this.clearAllTimeouts();
|
|
278
|
-
}
|
|
279
|
-
}, a = () => {
|
|
280
|
-
if (t() === !1) return 0;
|
|
281
|
-
let e = document.createElement("div");
|
|
282
|
-
e.className = "tp-ui-measure", document.body.appendChild(e);
|
|
283
|
-
let n = e.getBoundingClientRect().width - e.clientWidth;
|
|
284
|
-
return document.body.removeChild(e), n;
|
|
285
|
-
}, o = (e, t) => e ? e.classList.contains(t) : !1, s = (e, t) => Array.from({ length: Number(t) - Number(e) + 1 }, (t, n) => Number(e) + n), c = (e, t) => Array.from({ length: Number(t) - Number(e) + 1 }, (e, n) => Number(t) - n).reverse(), l = (e = "") => {
|
|
286
|
-
let t = e.replace(/(AM|PM|am|pm)/, (e) => ` ${e}`), n = /* @__PURE__ */ new Date(`September 20, 2000 ${t}`);
|
|
287
|
-
return `${n.getHours().toString().padStart(2, "0")}:${n.getMinutes().toString().padStart(2, "0")}`;
|
|
288
|
-
}, u = (e) => {
|
|
289
|
-
let [t, n] = e.split(":");
|
|
290
|
-
return `${t.padStart(2, "0")}:${n.padStart(2, "0")}`;
|
|
291
|
-
}, d = (e, t) => {
|
|
292
|
-
if (e.length < 2) return !1;
|
|
293
|
-
let n = e.map((e) => {
|
|
294
|
-
let [n, r] = e.trim().split("-"), i, a;
|
|
295
|
-
if (t === "12h") {
|
|
296
|
-
if (!/\s?(AM|PM|am|pm)\s?$/.test(n.trim()) || !/\s?(AM|PM|am|pm)\s?$/.test(r.trim())) throw Error(`Invalid 12h format: "${e}"`);
|
|
297
|
-
i = l(n.trim()), a = l(r.trim());
|
|
298
|
-
} else {
|
|
299
|
-
if (/\s?(AM|PM|am|pm)\s?/.test(n.trim()) || /\s?(AM|PM|am|pm)\s?/.test(r.trim())) throw Error(`Invalid 24h format: "${e}"`);
|
|
300
|
-
i = u(n.trim()), a = u(r.trim());
|
|
301
|
-
}
|
|
302
|
-
return {
|
|
303
|
-
start: i,
|
|
304
|
-
end: a,
|
|
305
|
-
original: e
|
|
306
|
-
};
|
|
307
|
-
});
|
|
308
|
-
for (let e = 0; e < n.length; e++) for (let t = e + 1; t < n.length; t++) {
|
|
309
|
-
let r = n[e], i = n[t];
|
|
310
|
-
if (r.start <= i.end && r.end >= i.start || i.start <= r.end && i.end >= r.start) throw Error(`Overlapping intervals: "${r.original}" and "${i.original}"`);
|
|
311
|
-
}
|
|
312
|
-
return !1;
|
|
313
|
-
}, f = () => typeof window < "u" && window.crypto && typeof window.crypto.randomUUID == "function" ? window.crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
|
|
314
|
-
let t = Math.random() * 16 | 0;
|
|
315
|
-
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
316
|
-
}), p = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e3e3e3\"><path d=\"M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z\"/></svg>", m = "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"#e3e3e3\"><path d=\"m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z\"/></svg>", h = new class {
|
|
317
|
-
plugins = /* @__PURE__ */ new Map();
|
|
318
|
-
register(e) {
|
|
319
|
-
this.plugins.has(e.name) || this.plugins.set(e.name, e);
|
|
320
|
-
}
|
|
321
|
-
getAll() {
|
|
322
|
-
return Array.from(this.plugins.values());
|
|
323
|
-
}
|
|
324
|
-
has(e) {
|
|
325
|
-
return this.plugins.has(e);
|
|
326
|
-
}
|
|
327
|
-
get(e) {
|
|
328
|
-
return this.plugins.get(e);
|
|
329
|
-
}
|
|
330
|
-
getTemplateProvider(e) {
|
|
331
|
-
return this.plugins.get(e)?.templateProvider;
|
|
332
|
-
}
|
|
333
|
-
getClearHandler(e) {
|
|
334
|
-
return this.plugins.get(e)?.clearHandler;
|
|
335
|
-
}
|
|
336
|
-
}(), g = [
|
|
337
|
-
"00",
|
|
338
|
-
"13",
|
|
339
|
-
"14",
|
|
340
|
-
"15",
|
|
341
|
-
"16",
|
|
342
|
-
"17",
|
|
343
|
-
"18",
|
|
344
|
-
"19",
|
|
345
|
-
"20",
|
|
346
|
-
"21",
|
|
347
|
-
"22",
|
|
348
|
-
"23"
|
|
349
|
-
], _ = [
|
|
350
|
-
"12",
|
|
351
|
-
"1",
|
|
352
|
-
"2",
|
|
353
|
-
"3",
|
|
354
|
-
"4",
|
|
355
|
-
"5",
|
|
356
|
-
"6",
|
|
357
|
-
"7",
|
|
358
|
-
"8",
|
|
359
|
-
"9",
|
|
360
|
-
"10",
|
|
361
|
-
"11"
|
|
362
|
-
], v = [
|
|
363
|
-
"00",
|
|
364
|
-
"05",
|
|
365
|
-
"10",
|
|
366
|
-
"15",
|
|
367
|
-
"20",
|
|
368
|
-
"25",
|
|
369
|
-
"30",
|
|
370
|
-
"35",
|
|
371
|
-
"40",
|
|
372
|
-
"45",
|
|
373
|
-
"50",
|
|
374
|
-
"55"
|
|
375
|
-
], y = (e, t, n) => {
|
|
376
|
-
let { timezone: { enabled: r, label: i } } = e;
|
|
377
|
-
return !r || !h.has("timezone") ? "" : `<div class="tp-ui-timezone ${t}">
|
|
378
|
-
<span class="tp-ui-timezone-label" id="tp-tz-label-${n}">${i}</span>
|
|
379
|
-
<div class="tp-ui-timezone-dropdown" role="combobox" aria-expanded="false" aria-haspopup="listbox" aria-labelledby="tp-tz-label-${n}" tabindex="0" data-tz-id="${n}">
|
|
380
|
-
<div class="tp-ui-timezone-selected" data-placeholder="${i}...">${i}...</div>
|
|
381
|
-
<svg class="tp-ui-timezone-arrow" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>
|
|
382
|
-
<div class="tp-ui-timezone-menu" role="listbox" aria-labelledby="tp-tz-label-${n}"></div>
|
|
383
|
-
</div>
|
|
384
|
-
</div>`;
|
|
385
|
-
}, b = (e) => {
|
|
386
|
-
let { range: { enabled: t, fromLabel: n, toLabel: r }, labels: { rangeSelectionLabel: i } } = e;
|
|
387
|
-
return !t || !h.has("range") ? "" : `<div class="tp-ui-range-header" role="tablist" aria-label="${i}"><button type="button" class="tp-ui-range-tab tp-ui-range-from active" role="tab" tabindex="0" aria-selected="true"><span class="tp-ui-range-tab-label">${n}</span><span class="tp-ui-range-tab-value tp-ui-range-from-time">--:--</span></button><button type="button" class="tp-ui-range-tab tp-ui-range-to" role="tab" tabindex="-1" aria-selected="false"><span class="tp-ui-range-tab-label">${r}</span><span class="tp-ui-range-tab-value tp-ui-range-to-time">--:--</span></button></div>`;
|
|
388
|
-
}, x = (e, t) => {
|
|
389
|
-
let { ui: { clearButton: n }, labels: { clear: r } } = e;
|
|
390
|
-
return n ? `<div class="tp-ui-clear-btn ${t} disabled" data-md3-ripple tabindex="0" role="button" aria-label="${r}" aria-disabled="true">${r}</div>` : "";
|
|
391
|
-
}, ee = (e, t, n) => {
|
|
392
|
-
if (e.isWheelMode) {
|
|
393
|
-
let t = h.getTemplateProvider("wheel");
|
|
394
|
-
return t ? `<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}">${t(n, e.instanceId)}</div>` : `<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"></div>`;
|
|
395
|
-
}
|
|
396
|
-
let { labels: { clockLabel: r } } = n;
|
|
397
|
-
return `<div class="tp-ui-mobile-clock-wrapper ${e.mobileClass}"><div class="tp-ui-body ${e.mobileClass}"><div class="tp-ui-clock-face ${e.mobileClass}" role="group" aria-label="${r}"><div class="tp-ui-dot ${e.mobileClass}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${e.mobileClass}" aria-hidden="true"><div class="tp-ui-circle-hand ${e.mobileClass}"></div></div><div class="tp-ui-tips-wrapper ${e.mobileClass}" aria-hidden="true"></div>${e.clockType === "24h" ? `<div class="tp-ui-tips-wrapper-24h ${e.mobileClass}" aria-hidden="true"></div>` : ""}</div></div></div>`;
|
|
398
|
-
}, te = (e, t) => {
|
|
399
|
-
let { labels: { time: n, mobileTime: r, timeLabel: i, am: a, pm: o, mobileMinute: s, mobileHour: c, hourLabel: l, minuteLabel: u, periodLabel: d }, ui: { editable: f } } = e, { mobileClass: p, clockType: m, instanceId: h } = t, g = p ? r : n, _ = m === "12h", v = _ ? "1" : "0", y = _ ? "12" : "23", b = _ ? "12" : "0", x = m === "24h" ? "" : `<div class="tp-ui-wrapper-type-time ${p}" role="group" aria-label="${d}"><div class="tp-ui-type-mode tp-ui-am ${p ? "mobile" : "tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${a}" aria-pressed="false" data-type="AM">${a}</div><div class="tp-ui-type-mode tp-ui-pm ${p ? "mobile" : "tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${o}" aria-pressed="false" data-type="PM">${o}</div></div>`;
|
|
400
|
-
return `<div class="tp-ui-select-time ${p}" id="tp-ui-label-${h}">${g}</div><div class="tp-ui-header ${p}"><div class="tp-ui-wrapper-time ${p} ${m === "24h" ? "tp-ui-wrapper-time-24h" : ""}" role="group" aria-label="${i}"><div class="tp-ui-input-wrapper ${p}"><div class="tp-ui-input-ripple-wrapper ${p}" data-md3-ripple><input name="hour" ${!f && !p ? "readonly" : ""} class="tp-ui-hour ${p}" tabindex="0" type="number" min="${v}" max="${y}" aria-label="${p ? c : l}" role="spinbutton" aria-valuemin="${v}" aria-valuemax="${y}" aria-valuenow="${b}" aria-valuetext="${b}"></div><div class="tp-ui-hour-text ${p}">${c}</div></div><div class="tp-ui-dots ${p}" aria-hidden="true"><span></span><span></span></div><div class="tp-ui-input-wrapper ${p}"><div class="tp-ui-input-ripple-wrapper ${p}" data-md3-ripple><input name="minutes" ${!f && !p ? "readonly" : ""} class="tp-ui-minutes ${p}" tabindex="0" type="number" min="0" max="59" aria-label="${p ? s : u}" role="spinbutton" aria-valuemin="0" aria-valuemax="59" aria-valuenow="0" aria-valuetext="00"></div><div class="tp-ui-minute-text ${p}">${s}</div></div></div>${x}</div>`;
|
|
401
|
-
}, ne = (e, t) => {
|
|
402
|
-
let { ui: { enableSwitchIcon: n, iconTemplate: r, iconTemplateMobile: i }, labels: { cancel: a, ok: o, switchToKeyboardLabel: s, switchToClockLabel: c, toggleLabel: l } } = e, u = `<button aria-label="${s}" type="button" class="tp-ui-keyboard-icon">${r || p}</button>`, d = i || `<button aria-label="${c}" type="button" class="tp-ui-keyboard-icon">${i || m}</button>`, f = n ? `<div class="tp-ui-keyboard-icon-wrapper ${t}" tabindex="0" role="button" aria-pressed="false" aria-label="${l}" data-view="desktop">${t ? d : u}</div>` : "", h = x(e, t);
|
|
403
|
-
return `<div class="tp-ui-footer ${t}" ${t ? "data-view=\"mobile\"" : ""}>${f}<div class="tp-ui-wrapper-btn ${t}">${h}<div class="tp-ui-cancel-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-label="${a}">${a}</div><div class="tp-ui-ok-btn ${t}" data-md3-ripple tabindex="0" role="button" aria-label="${o}">${o}</div></div></div>`;
|
|
404
|
-
}, re = (e, t) => {
|
|
405
|
-
let { ui: { mode: n, animation: r, theme: i, mobile: a }, clock: { incrementMinutes: o } } = e, s = a ? "mobile" : "", c = n === "compact-wheel" && h.has("wheel"), l = (n === "wheel" || c) && h.has("wheel"), u = !!e.range?.enabled && h.has("range"), d = !!e.timezone?.enabled && h.has("timezone"), f = {
|
|
406
|
-
mobileClass: s,
|
|
407
|
-
clockType: e.clock.type || "12h",
|
|
408
|
-
instanceId: t,
|
|
409
|
-
isWheelMode: l,
|
|
410
|
-
isCompactWheel: c,
|
|
411
|
-
isRangeMode: u
|
|
412
|
-
}, p = b(e), m = y(e, s, t), g = c ? "" : te(e, f), _ = ee(f, o ?? 1, e), v = c && e.wheel?.hideFooter === !0 ? "" : ne(e, s), x;
|
|
413
|
-
return x = c ? " tp-ui-compact-wheel-mode" : l ? " tp-ui-wheel-mode" : "", `<div class="tp-ui-modal normalize ${s}${u ? " tp-ui-range-mode" : ""}${d ? " tp-ui-tz-mode" : ""}${x}" data-theme="${i}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${t}" data-owner-id="${t}" style='transition:${r ? "opacity 0.15s linear" : "none"}'><div class="tp-ui-wrapper ${s}" tabindex="0">${p}${g}${m}${_}${v}</div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`;
|
|
414
|
-
}, S = 0, C = "", w = "";
|
|
415
|
-
function ie() {
|
|
416
|
-
S === 0 && (C = document.body.style.overflowY, w = document.body.style.paddingRight, document.body.style.paddingRight = `${a()}px`, document.body.style.overflowY = "hidden"), S += 1;
|
|
417
|
-
}
|
|
418
|
-
function ae() {
|
|
419
|
-
S !== 0 && (--S, S === 0 && (document.body.style.overflowY = C, document.body.style.paddingRight = w, C = "", w = ""));
|
|
420
|
-
}
|
|
421
|
-
var oe = class {
|
|
422
|
-
core;
|
|
423
|
-
emitter;
|
|
424
|
-
timeouts = [];
|
|
425
|
-
scrollLocked = !1;
|
|
426
|
-
constructor(e, t) {
|
|
427
|
-
this.core = e, this.emitter = t;
|
|
428
|
-
}
|
|
429
|
-
runWithTimeout(e, t = r.DEFAULT_DELAY) {
|
|
430
|
-
let n = setTimeout(e, t);
|
|
431
|
-
this.timeouts.push(n);
|
|
432
|
-
}
|
|
433
|
-
clearAllTimeouts() {
|
|
434
|
-
this.timeouts.forEach(clearTimeout), this.timeouts = [];
|
|
435
|
-
}
|
|
436
|
-
isPopoverMode() {
|
|
437
|
-
return this.core.options.ui.mode === "compact-wheel" && !!this.core.options.wheel?.placement;
|
|
438
|
-
}
|
|
439
|
-
clearExistingModal() {
|
|
440
|
-
if (t() === !1) return;
|
|
441
|
-
let e = this.core.getModalElement();
|
|
442
|
-
e && e.remove();
|
|
443
|
-
}
|
|
444
|
-
setModalTemplate() {
|
|
445
|
-
if (t() === !1) return;
|
|
446
|
-
this.clearExistingModal();
|
|
447
|
-
let e = re(this.core.options, this.core.instanceId);
|
|
448
|
-
if (this.core.options.ui.inline?.enabled) {
|
|
449
|
-
let t = document.getElementById(this.core.options.ui.inline.containerId);
|
|
450
|
-
if (!t) return;
|
|
451
|
-
t.innerHTML = "", t.insertAdjacentHTML("beforeend", e);
|
|
452
|
-
let n = t.querySelector(".tp-ui-modal");
|
|
453
|
-
if (n) {
|
|
454
|
-
n.classList.add("tp-ui--inline");
|
|
455
|
-
let { showButtons: e } = this.core.options.ui.inline;
|
|
456
|
-
(e === !1 || e === void 0) && n.querySelectorAll(".tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile").forEach((e) => e.style.display = "none");
|
|
457
|
-
}
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
let { appendModalSelector: n } = this.core.options.ui;
|
|
461
|
-
n ? document.querySelector(n)?.insertAdjacentHTML("beforeend", e) : document.body.insertAdjacentHTML("beforeend", e);
|
|
462
|
-
}
|
|
463
|
-
lockScroll() {
|
|
464
|
-
t() !== !1 && (this.core.options.ui.inline?.enabled || this.isPopoverMode() || this.core.options.ui.enableScrollbar || this.scrollLocked || (this.scrollLocked = !0, ie()));
|
|
465
|
-
}
|
|
466
|
-
unlockScroll() {
|
|
467
|
-
t() !== !1 && this.scrollLocked && (this.scrollLocked = !1, ae());
|
|
468
|
-
}
|
|
469
|
-
setScrollbarOrNot() {
|
|
470
|
-
t() !== !1 && (this.core.options.ui.inline?.enabled || this.isPopoverMode() || (this.core.options.ui.enableScrollbar ? this.runWithTimeout(() => {
|
|
471
|
-
e() || this.runWithTimeout(() => {
|
|
472
|
-
this.unlockScroll();
|
|
473
|
-
}, r.SCROLLBAR_RESTORE);
|
|
474
|
-
}, 400) : this.lockScroll()));
|
|
475
|
-
}
|
|
476
|
-
removeBackdrop() {
|
|
477
|
-
if (this.core.options.ui.inline?.enabled || this.core.options.ui.backdrop) return;
|
|
478
|
-
let e = this.core.getModalElement(), t = this.core.getOpenElement();
|
|
479
|
-
e?.classList.add("removed"), t.forEach((e) => e?.classList.add("disabled"));
|
|
480
|
-
}
|
|
481
|
-
setNormalizeClass() {
|
|
482
|
-
let e = this.core.getModalElement();
|
|
483
|
-
e && (e.classList.add("tp-ui-normalize"), e.querySelectorAll(":scope > div").forEach((e) => e.classList.add("tp-ui-normalize")));
|
|
484
|
-
}
|
|
485
|
-
setShowClassToBackdrop() {
|
|
486
|
-
if (this.core.options.ui.inline?.enabled || this.isPopoverMode()) {
|
|
487
|
-
this.core.getModalElement()?.classList.add("show"), this.setInitialFocus();
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
this.core.options.ui.backdrop && this.runWithTimeout(() => {
|
|
491
|
-
this.core.getModalElement()?.classList.add("show"), this.setInitialFocus();
|
|
492
|
-
}, r.MODAL_ANIMATION);
|
|
493
|
-
}
|
|
494
|
-
setInitialFocus() {
|
|
495
|
-
if (!this.core.options.behavior.focusTrap) return;
|
|
496
|
-
let e = this.core.getWrapper();
|
|
497
|
-
e && typeof requestAnimationFrame < "u" && requestAnimationFrame(() => {
|
|
498
|
-
e.focus();
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
setFlexEndToFooterIfNoKeyboardIcon() {
|
|
502
|
-
let e = this.core.getFooter();
|
|
503
|
-
!this.core.options.ui.enableSwitchIcon && e && (e.style.justifyContent = "flex-end");
|
|
504
|
-
}
|
|
505
|
-
destroy() {
|
|
506
|
-
this.clearAllTimeouts(), this.unlockScroll(), this.clearExistingModal();
|
|
507
|
-
}
|
|
508
|
-
}, T = (e, t, n, r) => {
|
|
509
|
-
let i = {
|
|
510
|
-
hour: "12",
|
|
511
|
-
minutes: "00",
|
|
512
|
-
type: t === "24h" ? void 0 : "PM"
|
|
513
|
-
};
|
|
514
|
-
if (!e) return i;
|
|
515
|
-
let a = e.value.trim();
|
|
516
|
-
if (!n && !a) return i;
|
|
517
|
-
if (typeof n == "boolean" && n) {
|
|
518
|
-
let [e, n] = (/* @__PURE__ */ new Date()).toLocaleTimeString().split(":"), r = e.padStart(2, "0");
|
|
519
|
-
if (/[a-z]/i.test(n) && t === "12h") {
|
|
520
|
-
let [e, t] = n.split(" ");
|
|
521
|
-
return {
|
|
522
|
-
hour: r,
|
|
523
|
-
minutes: e,
|
|
524
|
-
type: t
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
return {
|
|
528
|
-
hour: r,
|
|
529
|
-
minutes: n,
|
|
530
|
-
type: void 0
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
if (typeof n == "object") {
|
|
534
|
-
let { time: e, locales: i, preventClockType: a } = n, o = e ?? /* @__PURE__ */ new Date();
|
|
535
|
-
if (a && r) {
|
|
536
|
-
let [e, t] = new Date(o).toLocaleTimeString().split(":");
|
|
537
|
-
if (/[a-z]/i.test(t)) {
|
|
538
|
-
let [n, r] = t.split(" ");
|
|
539
|
-
return {
|
|
540
|
-
hour: e,
|
|
541
|
-
minutes: n,
|
|
542
|
-
type: r
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
return {
|
|
546
|
-
hour: e.padStart(2, "0"),
|
|
547
|
-
minutes: t,
|
|
548
|
-
type: void 0
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
let [s, c] = new Date(o).toLocaleTimeString(i || "en-US", {
|
|
552
|
-
hour: "2-digit",
|
|
553
|
-
minute: "2-digit",
|
|
554
|
-
hour12: t === "12h"
|
|
555
|
-
}).split(":");
|
|
556
|
-
if (t === "12h" && /[a-z]/i.test(c)) {
|
|
557
|
-
let e = c.trim().split(" ");
|
|
558
|
-
return {
|
|
559
|
-
hour: s,
|
|
560
|
-
minutes: e[0],
|
|
561
|
-
type: e[1] || "AM"
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
return {
|
|
565
|
-
hour: s,
|
|
566
|
-
minutes: c.replace(/\D/g, ""),
|
|
567
|
-
type: void 0
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
let [o, s] = a.split(" "), [c = "", l = ""] = o.split(":"), u = c.replace(/\D/g, ""), d = l.replace(/\D/g, ""), f = {
|
|
571
|
-
hour: u.padStart(2, "0"),
|
|
572
|
-
minutes: d.padStart(2, "0"),
|
|
573
|
-
type: t === "12h" ? s : void 0
|
|
574
|
-
};
|
|
575
|
-
if (u.length > 2 || d.length > 2) return {
|
|
576
|
-
...f,
|
|
577
|
-
error: "Invalid input: too many digits.",
|
|
578
|
-
currentHour: c,
|
|
579
|
-
currentMin: l
|
|
580
|
-
};
|
|
581
|
-
if (/[a-z]/i.test(o)) return {
|
|
582
|
-
...f,
|
|
583
|
-
error: "Input contains invalid letters."
|
|
584
|
-
};
|
|
585
|
-
if (a.includes(" ") && (!s || a.length > 8 || s !== "AM" && s !== "PM")) return {
|
|
586
|
-
...f,
|
|
587
|
-
error: "Invalid AM/PM format or length.",
|
|
588
|
-
currentLength: a.length,
|
|
589
|
-
currentType: s
|
|
590
|
-
};
|
|
591
|
-
let p = Number(u), m = Number(d);
|
|
592
|
-
if (t === "12h") {
|
|
593
|
-
if (p < 1 || p > 12 || m < 0 || m > 59 || s !== "AM" && s !== "PM") return {
|
|
594
|
-
...f,
|
|
595
|
-
error: "Invalid 12h time.",
|
|
596
|
-
currentHour: p,
|
|
597
|
-
currentMin: m,
|
|
598
|
-
currentType: s
|
|
599
|
-
};
|
|
600
|
-
} else if (p < 0 || p > 23 || m < 0 || m > 59) return {
|
|
601
|
-
...f,
|
|
602
|
-
error: "Invalid 24h time.",
|
|
603
|
-
currentHour: p,
|
|
604
|
-
currentMin: m
|
|
605
|
-
};
|
|
606
|
-
return f;
|
|
607
|
-
}, E = (e, t, n) => {
|
|
608
|
-
let r = Number(e);
|
|
609
|
-
if (Number.isNaN(r)) return !1;
|
|
610
|
-
switch (t) {
|
|
611
|
-
case "hour": return n === "24h" ? r >= 0 && r <= 23 : r > 0 && r <= 12;
|
|
612
|
-
case "minutes": return r >= 0 && r <= 59;
|
|
613
|
-
default: return;
|
|
614
|
-
}
|
|
615
|
-
}, D = "tp-ui", se = "mousedown mouseup mousemove mouseleave mouseover touchstart touchmove touchend", O = "active", ce = class {
|
|
616
|
-
core;
|
|
617
|
-
emitter;
|
|
618
|
-
constructor(e, t) {
|
|
619
|
-
this.core = e, this.emitter = t;
|
|
620
|
-
}
|
|
621
|
-
isCurrentTimeEnabled(e) {
|
|
622
|
-
let t = this.core.options.clock.currentTime;
|
|
623
|
-
return typeof t == "boolean" ? t : !!t?.[e];
|
|
624
|
-
}
|
|
625
|
-
preventClockTypeByCurrentTime() {
|
|
626
|
-
if (!this.isCurrentTimeEnabled("preventClockType")) return;
|
|
627
|
-
let e = this.core.getInput();
|
|
628
|
-
if (!e) return;
|
|
629
|
-
let { currentTime: t, clockType: n } = {
|
|
630
|
-
currentTime: this.core.options.clock.currentTime,
|
|
631
|
-
clockType: this.core.options.clock.type
|
|
632
|
-
}, { type: r } = T(e, n, t, !0);
|
|
633
|
-
this.core.updateOptions({ clock: { type: r ? "12h" : "24h" } });
|
|
634
|
-
}
|
|
635
|
-
updateInputValueWithCurrentTimeOnStart() {
|
|
636
|
-
if (!this.isCurrentTimeEnabled("updateInput")) return;
|
|
637
|
-
let e = this.core.getInput();
|
|
638
|
-
if (!e) return;
|
|
639
|
-
let { hour: t, minutes: n, type: r } = T(e, this.core.options.clock.type, this.core.options.clock.currentTime);
|
|
640
|
-
e.value = r ? `${t}:${n} ${r}` : `${t}:${n}`;
|
|
641
|
-
}
|
|
642
|
-
getInputValueOnOpenAndSet() {
|
|
643
|
-
let e = this.core.getInput();
|
|
644
|
-
if (!e) return;
|
|
645
|
-
let t = T(e, this.core.options.clock.type, this.core.options.clock.currentTime), n = this.core.getHour(), r = this.core.getMinutes(), i = this.core.getActiveTypeMode(), a = this.core.getAM();
|
|
646
|
-
if (t === void 0) {
|
|
647
|
-
n && (n.value = "12"), r && (r.value = "00");
|
|
648
|
-
let e = {
|
|
649
|
-
hour: n?.value || "12",
|
|
650
|
-
minutes: r?.value || "00",
|
|
651
|
-
type: i?.dataset.type,
|
|
652
|
-
degreesHours: this.core.degreesHours,
|
|
653
|
-
degreesMinutes: this.core.degreesMinutes
|
|
654
|
-
};
|
|
655
|
-
this.emitter.emit("open", e);
|
|
656
|
-
let t = this.core.options.range?.enabled === !0;
|
|
657
|
-
this.core.options.clock.type !== "24h" && a && !t && a.classList.add(O);
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
let [o, s, c] = e.value.split(":").join(" ").split(" ");
|
|
661
|
-
e.value.length === 0 && (o = t.hour, s = t.minutes, c = t.type), this.core.options.clock.type !== "24h" && !c && (c = t.type || "AM"), n && (n.value = o.padStart(2, "0")), r && (r.value = s.padStart(2, "0"));
|
|
662
|
-
let l = this.core.getModalElement()?.querySelector(`[data-type='${c}']`);
|
|
663
|
-
this.core.options.clock.type !== "24h" && l && l.classList.add(O);
|
|
664
|
-
let u = {
|
|
665
|
-
...t,
|
|
666
|
-
type: i?.dataset.type,
|
|
667
|
-
degreesHours: this.core.degreesHours,
|
|
668
|
-
degreesMinutes: this.core.degreesMinutes
|
|
669
|
-
};
|
|
670
|
-
this.emitter.emit("open", u);
|
|
671
|
-
}
|
|
672
|
-
getInputValue(e, t, n) {
|
|
673
|
-
return T(e, t, n);
|
|
674
|
-
}
|
|
675
|
-
destroy() {}
|
|
676
|
-
}, le = class {
|
|
677
|
-
core;
|
|
678
|
-
emitter;
|
|
679
|
-
isAnimating = !1;
|
|
680
|
-
constructor(e, t) {
|
|
681
|
-
this.core = e, this.emitter = t, this.setupEventListeners();
|
|
682
|
-
}
|
|
683
|
-
setupEventListeners() {
|
|
684
|
-
this.emitter.on("switch:view", () => {
|
|
685
|
-
this.toggleMobileClockFace();
|
|
686
|
-
});
|
|
687
|
-
}
|
|
688
|
-
checkMobileOption() {
|
|
689
|
-
this.core.setIsMobileView(!!this.core.options.ui.mobile), this.core.options.ui.mobile && this.core.updateOptions({ ui: { editable: !0 } });
|
|
690
|
-
}
|
|
691
|
-
toggleMobileClockFace() {
|
|
692
|
-
if (this.isAnimating) return;
|
|
693
|
-
let e = this.core.getModalElement();
|
|
694
|
-
if (!e) return;
|
|
695
|
-
let t = e.querySelector(".tp-ui-wrapper"), n = this.core.getKeyboardClockIcon(), r = e.querySelector(".tp-ui-mobile-clock-wrapper"), i = e.querySelectorAll("*"), a = e.querySelector(".tp-ui-select-time"), o = this.core.getHour(), s = this.core.getMinutes(), c = this.core.getClockFace();
|
|
696
|
-
if (!t) return;
|
|
697
|
-
let l = t.classList.contains("expanded"), u = this.core.isMobileView;
|
|
698
|
-
l ? this.collapseClockFace(t, r, i, n, a, o, s, c, u) : this.expandClockFace(t, r, i, n, a, o, s, c);
|
|
699
|
-
}
|
|
700
|
-
collapseClockFace(e, t, n, r, i, a, o, s, c) {
|
|
701
|
-
if (this.isAnimating = !0, typeof requestAnimationFrame < "u") {
|
|
702
|
-
let l = typeof window < "u" && window.matchMedia("(orientation: landscape) and (min-width: 320px) and (max-width: 825px)").matches;
|
|
703
|
-
requestAnimationFrame(() => {
|
|
704
|
-
l && e instanceof HTMLElement ? this.collapseLandscape(e, t, n, r, i, a, o, s, c) : this.collapsePortrait(e, t, n, r, i, a, o, s, c);
|
|
705
|
-
});
|
|
706
|
-
} else this.switchView(i, r, a, o, !0), this.isAnimating = !1;
|
|
707
|
-
r?.setAttribute("aria-label", "Show clock face"), r?.setAttribute("aria-pressed", "false");
|
|
708
|
-
}
|
|
709
|
-
collapseLandscape(e, t, n, i, a, o, s, c, l) {
|
|
710
|
-
c?.classList.remove("scale-in");
|
|
711
|
-
let u = this.core.getModalElement(), d = this.getMobileLandscapeHeight(u);
|
|
712
|
-
e.style.width = "328px", e.style.height = d, t instanceof HTMLElement && (t.style.height = "0", t.style.opacity = "0", t.style.transform = "scale(0)"), setTimeout(() => {
|
|
713
|
-
this.applyMobileClasses(e, t, n, a, l), e.classList.add("mobile"), t && t.classList.add("mobile"), this.switchView(a, i, o, s, !0), requestAnimationFrame(() => {
|
|
714
|
-
e.style.width = "", e.style.height = "", t instanceof HTMLElement && (t.style.height = "", t.style.opacity = "", t.style.transform = ""), this.isAnimating = !1;
|
|
715
|
-
});
|
|
716
|
-
}, r.WRAPPER_TRANSITION);
|
|
717
|
-
}
|
|
718
|
-
collapsePortrait(e, t, n, i, a, o, s, c, l) {
|
|
719
|
-
l ? c?.classList.remove("scale-in") : c?.classList.add("scale-in"), t?.classList.remove("expanded"), l && t?.classList.add("mobile"), requestAnimationFrame(() => {
|
|
720
|
-
this.applyMobileClasses(e, t, n, a, l), this.switchView(a, i, o, s, !0), setTimeout(() => {
|
|
721
|
-
this.isAnimating = !1;
|
|
722
|
-
}, r.MOBILE_TOGGLE);
|
|
723
|
-
});
|
|
724
|
-
}
|
|
725
|
-
applyMobileClasses(e, t, n, r, i) {
|
|
726
|
-
e.classList.remove("expanded"), t?.classList.remove("expanded"), i && (e.classList.add("mobile"), t?.classList.add("mobile")), n.forEach((n) => {
|
|
727
|
-
n !== t && n !== e && n !== r && (n.classList.remove("expanded"), i && n.classList.add("mobile"));
|
|
728
|
-
}), r && (r.classList.remove("expanded"), i && r.classList.add("mobile"));
|
|
729
|
-
}
|
|
730
|
-
expandClockFace(e, t, n, i, a, o, s, c) {
|
|
731
|
-
this.isAnimating = !0, s?.classList.contains("active") && s ? this.emitter.emit("select:minute", { minutes: s.value }) : o && this.emitter.emit("select:hour", { hour: o.value }), n.forEach((n) => {
|
|
732
|
-
n !== t && n !== e && n !== a && (n.classList.remove("mobile"), n.classList.add("expanded"));
|
|
733
|
-
}), a && (a.classList.remove("mobile"), a.classList.add("expanded")), this.switchView(a, i, o, s, !1), typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => {
|
|
734
|
-
e.classList.remove("mobile"), e.classList.add("expanded"), requestAnimationFrame(() => {
|
|
735
|
-
t && (t.classList.remove("mobile"), t.classList.add("expanded")), c && c.classList.remove("scale-in"), setTimeout(() => {
|
|
736
|
-
c && c.classList.add("scale-in");
|
|
737
|
-
}, r.CLOCK_SCALE_DELAY), setTimeout(() => {
|
|
738
|
-
this.isAnimating = !1;
|
|
739
|
-
}, r.MOBILE_TOGGLE);
|
|
740
|
-
});
|
|
741
|
-
}) : this.isAnimating = !1, i?.setAttribute("aria-label", "Hide clock face"), i?.setAttribute("aria-pressed", "true");
|
|
742
|
-
}
|
|
743
|
-
switchView(e, t, n, r, i) {
|
|
744
|
-
let a = this.core.getModalElement(), o = a?.querySelector(".tp-ui-hour-text"), s = a?.querySelector(".tp-ui-minute-text"), c = t?.querySelector(".tp-ui-keyboard-icon"), l = this.core.getInputWrappers(), u = this.core.getHeader(), d = a?.querySelector(".tp-ui-wrapper-type-time"), f = a?.querySelector(".tp-ui-am"), h = a?.querySelector(".tp-ui-pm"), g = a?.querySelectorAll(".tp-ui-input-ripple-wrapper"), { iconTemplate: _, iconTemplateMobile: v } = this.core.options.ui, { time: y, mobileTime: b } = this.core.options.labels;
|
|
745
|
-
i ? (e?.classList.add("mobile"), t?.classList.add("mobile"), n?.classList.add("mobile"), n?.removeAttribute("readonly"), r?.classList.add("mobile"), r?.removeAttribute("readonly"), o?.classList.add("mobile"), s?.classList.add("mobile"), u?.classList.add("mobile"), d?.classList.add("mobile"), f?.classList.add("mobile"), f?.classList.remove("tp-ui-ripple"), h?.classList.add("mobile"), h?.classList.remove("tp-ui-ripple"), l?.forEach((e) => {
|
|
746
|
-
e.classList.add("mobile");
|
|
747
|
-
}), g?.forEach((e) => {
|
|
748
|
-
e.classList.add("mobile");
|
|
749
|
-
}), e && b && (e.textContent = b), c && (c.innerHTML = v || m), this.updateClockFaceAccessibility(!0)) : (e?.classList.remove("mobile"), t?.classList.remove("mobile"), n?.classList.remove("mobile"), r?.classList.remove("mobile"), this.core.options.ui.editable || (n?.setAttribute("readonly", ""), r?.setAttribute("readonly", "")), o?.classList.remove("mobile"), s?.classList.remove("mobile"), u?.classList.remove("mobile"), d?.classList.remove("mobile"), f?.classList.remove("mobile"), f?.classList.add("tp-ui-ripple"), h?.classList.remove("mobile"), h?.classList.add("tp-ui-ripple"), l?.forEach((e) => {
|
|
750
|
-
e.classList.remove("mobile");
|
|
751
|
-
}), g?.forEach((e) => {
|
|
752
|
-
e.classList.remove("mobile");
|
|
753
|
-
}), e && y && (e.textContent = y), c && (c.innerHTML = _ || p), this.updateClockFaceAccessibility(!1));
|
|
754
|
-
}
|
|
755
|
-
updateClockFaceAccessibility(e) {
|
|
756
|
-
let t = this.core.getClockFace();
|
|
757
|
-
if (!t) return;
|
|
758
|
-
let n = t.querySelector(".tp-ui-tips-wrapper"), r = t.querySelector(".tp-ui-tips-wrapper-24h"), i = t.querySelectorAll(".tp-ui-tip");
|
|
759
|
-
e ? (t.setAttribute("aria-hidden", "true"), n?.setAttribute("aria-hidden", "true"), r?.setAttribute("aria-hidden", "true"), i.forEach((e) => {
|
|
760
|
-
e.setAttribute("tabindex", "-1"), e.setAttribute("aria-hidden", "true");
|
|
761
|
-
})) : (t.removeAttribute("aria-hidden"), n?.removeAttribute("aria-hidden"), r?.removeAttribute("aria-hidden"), i.forEach((e) => {
|
|
762
|
-
e.setAttribute("tabindex", "0"), e.removeAttribute("aria-hidden");
|
|
763
|
-
}));
|
|
764
|
-
}
|
|
765
|
-
getMobileLandscapeHeight(e) {
|
|
766
|
-
return e?.classList.contains("tp-ui-tz-mode") ? "326px" : e?.classList.contains("tp-ui-range-mode") ? "287px" : "258px";
|
|
767
|
-
}
|
|
768
|
-
destroy() {}
|
|
769
|
-
}, ue = (e) => {
|
|
770
|
-
if (!e) return;
|
|
771
|
-
let { disabledTime: t, type: n } = e.clock;
|
|
772
|
-
if (!t || !Object.keys(t).length) return;
|
|
773
|
-
let { hours: r, minutes: i, interval: a } = t;
|
|
774
|
-
if (a) {
|
|
775
|
-
delete t.hours, delete t.minutes;
|
|
776
|
-
let e = Array.isArray(a) ? a : [a];
|
|
777
|
-
if (!n) throw Error("clockType required for interval");
|
|
778
|
-
return d(e, n), { value: e.map((e) => {
|
|
779
|
-
let [t, r] = e.trim().split("-"), { hour: i, minutes: a, type: o } = T({ value: t.trim() }, n), { hour: l, minutes: u, type: d } = T({ value: r.trim() }, n), f = s(i, l).map((e) => Number(e) === 0 ? "00" : String(Number(e))), p = [], m = Number(a), h = Number(u);
|
|
780
|
-
if (d === o) return m > 0 && h <= 0 ? (p.push(f[0], f[f.length - 1]), f = f.slice(1, -1)) : h < 59 && h > 0 && m <= 0 ? (p.push(void 0, f[f.length - 1]), f = f.slice(0, -1)) : h > 0 && m > 0 ? (p.push(f[0], f[f.length - 1]), f = f.slice(1, -1)) : h === 0 && m === 0 && (p.push(void 0, f[f.length - 1]), f.pop()), {
|
|
781
|
-
removedStartedHour: p[0] !== void 0 && Number(p[0]) <= 9 ? `0${p[0]}` : p[0],
|
|
782
|
-
removedEndHour: p[1] !== void 0 && Number(p[1]) <= 9 ? `0${p[1]}` : p[1],
|
|
783
|
-
rangeArrHour: f,
|
|
784
|
-
startMinutes: s(a, 59).map((e) => Number(e) <= 9 ? `0${e}` : `${e}`),
|
|
785
|
-
endMinutes: c(0, u).map((e) => Number(e) <= 9 ? `0${e}` : `${e}`),
|
|
786
|
-
startType: o,
|
|
787
|
-
endType: d
|
|
788
|
-
};
|
|
789
|
-
{
|
|
790
|
-
let e = s(i, 12).map(String), t = c(1, l).map(String), n = [], r = [];
|
|
791
|
-
return m > 0 && h <= 0 ? (r.push(t[t.length - 1]), n.push(e[0]), t.pop(), e.shift()) : h < 59 && h > 0 && m <= 0 ? (n.push(e[0]), r.push(t[t.length - 1]), t.pop()) : h > 0 && m > 0 ? (r.push(t[t.length - 1]), n.push(e[0]), t.pop(), e.shift()) : h === 0 && m === 0 && (r.push(t[t.length - 1]), n.push(e[0]), t.pop()), {
|
|
792
|
-
startType: o,
|
|
793
|
-
endType: d,
|
|
794
|
-
amHours: e,
|
|
795
|
-
pmHours: t,
|
|
796
|
-
removedAmHour: n[0] && Number(n[0]) <= 9 ? `0${n[0]}` : n[0],
|
|
797
|
-
removedPmHour: r[0] && Number(r[0]) <= 9 ? `0${r[0]}` : r[0],
|
|
798
|
-
startMinutes: Number(a) === 0 ? [] : s(a, 59).map((e) => Number(e) <= 9 ? `0${e}` : `${e}`),
|
|
799
|
-
endMinutes: c(0, u).map((e) => Number(e) <= 9 ? `0${e}` : `${e}`)
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
}).reduce((e, t) => (Object.entries(t).forEach(([t, n]) => {
|
|
803
|
-
e[t] = Array.isArray(n) ? Array.isArray(e[t]) ? [...e[t], ...n] : [...n] : n;
|
|
804
|
-
}), e), {
|
|
805
|
-
isInterval: !0,
|
|
806
|
-
clockType: n,
|
|
807
|
-
intervals: e
|
|
808
|
-
}) };
|
|
809
|
-
}
|
|
810
|
-
return r?.forEach((e) => {
|
|
811
|
-
if (n === "12h" && Number(e) > 12) throw Error("The disabled hours value has to be less than 13");
|
|
812
|
-
if (n === "24h" && Number(e) > 23) throw Error("The disabled hours value has to be less than 24");
|
|
813
|
-
}), i?.forEach((e) => {
|
|
814
|
-
if (Number(e) > 59) throw Error("The disabled minutes value has to be less than 60");
|
|
815
|
-
}), { value: {
|
|
816
|
-
hours: r?.map((e) => e === "00" || Number(e) === 0 ? `0${Number(e)}` : `${Number(e)}`),
|
|
817
|
-
minutes: i?.map((e) => Number(e) <= 9 ? `0${e}` : `${e}`)
|
|
818
|
-
} };
|
|
819
|
-
}, k = (e, t, n, r) => {
|
|
820
|
-
if (e) {
|
|
821
|
-
if (Array.isArray(e) && e.length > 0) return !e.map((e) => E(e, t, n)).some((e) => e === !1);
|
|
822
|
-
if (typeof e == "string" || typeof e == "number") {
|
|
823
|
-
let i = E(e, t, n), a = r?.map(Number).includes(Number(e));
|
|
824
|
-
return !(!i || a);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}, de = class {
|
|
828
|
-
core;
|
|
829
|
-
constructor(e) {
|
|
830
|
-
this.core = e;
|
|
831
|
-
}
|
|
832
|
-
getDisableTime() {
|
|
833
|
-
let e = ue(this.core.options);
|
|
834
|
-
this.core.setDisabledTime(e || null);
|
|
835
|
-
}
|
|
836
|
-
destroy() {}
|
|
837
|
-
}, fe = class {
|
|
838
|
-
inputValueHandler;
|
|
839
|
-
mobileViewHandler;
|
|
840
|
-
disabledTimeHandler;
|
|
841
|
-
core;
|
|
842
|
-
constructor(e, t) {
|
|
843
|
-
this.core = e, this.inputValueHandler = new ce(e, t), this.mobileViewHandler = new le(e, t), this.disabledTimeHandler = new de(e);
|
|
844
|
-
}
|
|
845
|
-
preventClockTypeByCurrentTime() {
|
|
846
|
-
this.inputValueHandler.preventClockTypeByCurrentTime();
|
|
847
|
-
}
|
|
848
|
-
updateInputValueWithCurrentTimeOnStart() {
|
|
849
|
-
this.inputValueHandler.updateInputValueWithCurrentTimeOnStart();
|
|
850
|
-
}
|
|
851
|
-
getInputValueOnOpenAndSet() {
|
|
852
|
-
this.inputValueHandler.getInputValueOnOpenAndSet();
|
|
853
|
-
}
|
|
854
|
-
getInputValue(e, t, n) {
|
|
855
|
-
return this.inputValueHandler.getInputValue(e, t, n);
|
|
856
|
-
}
|
|
857
|
-
checkMobileOption() {
|
|
858
|
-
this.mobileViewHandler.checkMobileOption();
|
|
859
|
-
}
|
|
860
|
-
toggleMobileClockFace() {
|
|
861
|
-
this.mobileViewHandler.toggleMobileClockFace();
|
|
862
|
-
}
|
|
863
|
-
updateClockFaceAccessibility(e) {
|
|
864
|
-
this.mobileViewHandler.updateClockFaceAccessibility(e);
|
|
865
|
-
}
|
|
866
|
-
getDisableTime() {
|
|
867
|
-
this.disabledTimeHandler.getDisableTime();
|
|
868
|
-
}
|
|
869
|
-
destroy() {
|
|
870
|
-
this.inputValueHandler.destroy(), this.mobileViewHandler.destroy(), this.disabledTimeHandler.destroy();
|
|
871
|
-
}
|
|
872
|
-
}, pe = class {
|
|
873
|
-
core;
|
|
874
|
-
emitter;
|
|
875
|
-
constructor(e, t) {
|
|
876
|
-
this.core = e, this.emitter = t;
|
|
877
|
-
}
|
|
878
|
-
setTheme() {
|
|
879
|
-
let e = this.core.getModalElement();
|
|
880
|
-
if (!e) return;
|
|
881
|
-
let { theme: t } = this.core.options.ui;
|
|
882
|
-
t && e.setAttribute("data-theme", t);
|
|
883
|
-
}
|
|
884
|
-
setInputClassToInputElement() {
|
|
885
|
-
let e = this.core.getInput();
|
|
886
|
-
e && (o(e, "tp-ui-input") || e.classList.add("tp-ui-input"));
|
|
887
|
-
}
|
|
888
|
-
setDataOpenToInputIfDoesntExistInWrapper() {
|
|
889
|
-
let e = this.core.getOpenElementData(), t = this.core.getInput();
|
|
890
|
-
e === null && t && t.setAttribute("data-open", "tp-ui-input");
|
|
891
|
-
}
|
|
892
|
-
setClassTopOpenElement() {
|
|
893
|
-
let e = this.core.getOpenElement();
|
|
894
|
-
for (let t of e) t && t.classList.add("tp-ui-open-element");
|
|
895
|
-
}
|
|
896
|
-
setTimepickerClassToElement() {
|
|
897
|
-
let e = this.core.element;
|
|
898
|
-
if (!e) return;
|
|
899
|
-
e.classList.add(D);
|
|
900
|
-
let t = this.core.options.ui.cssClass;
|
|
901
|
-
t && t !== D && e.classList.add(t);
|
|
902
|
-
}
|
|
903
|
-
destroy() {
|
|
904
|
-
let e = this.core.getModalElement();
|
|
905
|
-
e && e.removeAttribute("data-theme");
|
|
906
|
-
}
|
|
907
|
-
}, A = class e extends Error {
|
|
908
|
-
constructor(t, n) {
|
|
909
|
-
super(`[TimepickerUI] ${t}`), this.code = n, this.name = "TimepickerError", Object.setPrototypeOf(this, e.prototype);
|
|
910
|
-
}
|
|
911
|
-
}, j = {
|
|
912
|
-
ELEMENT_NOT_FOUND: "ELEMENT_NOT_FOUND",
|
|
913
|
-
INVALID_PARAMETER: "INVALID_PARAMETER",
|
|
914
|
-
NO_INPUT_ELEMENT: "NO_INPUT_ELEMENT",
|
|
915
|
-
INSTANCE_DESTROYED: "INSTANCE_DESTROYED",
|
|
916
|
-
NOT_INITIALIZED: "NOT_INITIALIZED",
|
|
917
|
-
INVALID_TIME_FORMAT: "INVALID_TIME_FORMAT",
|
|
918
|
-
INLINE_CONFIG_ERROR: "INLINE_CONFIG_ERROR",
|
|
919
|
-
CONTAINER_NOT_FOUND: "CONTAINER_NOT_FOUND",
|
|
920
|
-
SSR_ENVIRONMENT: "SSR_ENVIRONMENT"
|
|
921
|
-
}, M = (e, t) => {
|
|
922
|
-
if (!e) return;
|
|
923
|
-
let n = e.querySelector(".timepicker-announcer");
|
|
924
|
-
n && (n.textContent = "", setTimeout(() => {
|
|
925
|
-
n.textContent = t;
|
|
926
|
-
}, 100));
|
|
927
|
-
}, N = (e, t) => {
|
|
928
|
-
e && e.setAttribute("aria-pressed", String(t));
|
|
929
|
-
}, P = (e) => e.getAttribute("aria-disabled") === "true" || e.classList.contains("disabled"), F = (e, t) => {
|
|
930
|
-
if (!e) return () => {};
|
|
931
|
-
let n = (n) => {
|
|
932
|
-
P(e) || t(n);
|
|
933
|
-
}, r = (n) => {
|
|
934
|
-
n.key !== "Enter" && n.key !== " " && n.key !== "Spacebar" || ((n.key === " " || n.key === "Spacebar") && n.preventDefault(), !P(e) && t(n));
|
|
935
|
-
};
|
|
936
|
-
return e.addEventListener("click", n), e.addEventListener("keydown", r), () => {
|
|
937
|
-
e.removeEventListener("click", n), e.removeEventListener("keydown", r);
|
|
938
|
-
};
|
|
939
|
-
}, me = () => typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia("(prefers-reduced-motion: reduce)").matches, he = class {
|
|
940
|
-
core;
|
|
941
|
-
emitter;
|
|
942
|
-
constructor(e, t) {
|
|
943
|
-
this.core = e, this.emitter = t;
|
|
944
|
-
}
|
|
945
|
-
setErrorHandler() {
|
|
946
|
-
let e = this.core.getInput();
|
|
947
|
-
if (!e) return !0;
|
|
948
|
-
let { error: n, currentHour: r, currentMin: i, currentType: a, currentLength: o } = T(e, this.core.options.clock.type);
|
|
949
|
-
if (this.removeErrorHandler(), n) {
|
|
950
|
-
if (t() === !1) return !1;
|
|
951
|
-
let s = this.core.options.labels.invalidTimeFormat ?? "Invalid time format", c = document.createElement("div");
|
|
952
|
-
c.classList.add("tp-ui-invalid-text"), c.setAttribute("role", "alert");
|
|
953
|
-
let l = document.createElement("b");
|
|
954
|
-
l.textContent = s, c.appendChild(l), e.classList.add("tp-ui-invalid-format"), e.nextElementSibling?.classList.contains("tp-ui-invalid-text") || e.after(c), M(this.core.getModalElement(), s);
|
|
955
|
-
let u = {
|
|
956
|
-
error: n,
|
|
957
|
-
rejectedHour: void 0,
|
|
958
|
-
rejectedMinute: void 0,
|
|
959
|
-
inputHour: r,
|
|
960
|
-
inputMinute: i,
|
|
961
|
-
inputType: a,
|
|
962
|
-
inputLength: o
|
|
963
|
-
};
|
|
964
|
-
return this.emitter.emit("error", u), !1;
|
|
965
|
-
}
|
|
966
|
-
return !0;
|
|
967
|
-
}
|
|
968
|
-
removeErrorHandler() {
|
|
969
|
-
let e = this.core.getInput();
|
|
970
|
-
if (!e) return;
|
|
971
|
-
e.classList.remove("tp-ui-invalid-format");
|
|
972
|
-
let t = e.nextElementSibling;
|
|
973
|
-
t?.classList.contains("tp-ui-invalid-text") && t.remove();
|
|
974
|
-
}
|
|
975
|
-
checkDisabledValuesOnStart() {
|
|
976
|
-
if (!this.core.options.clock.disabledTime) return;
|
|
977
|
-
let { disabledTime: e, type: t } = this.core.options.clock;
|
|
978
|
-
if (e.interval) {
|
|
979
|
-
if (!t) throw new A("clockType is required when using disabledTime.interval", j.INVALID_PARAMETER);
|
|
980
|
-
let n = Array.isArray(e.interval) ? e.interval : [e.interval];
|
|
981
|
-
try {
|
|
982
|
-
d(n, t);
|
|
983
|
-
} catch (e) {
|
|
984
|
-
throw new A(`Invalid disabledTime.interval: ${e.message}`, j.INVALID_PARAMETER);
|
|
985
|
-
}
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
let { hours: n, minutes: r } = e, i = !n || k(n, "hour", t), a = !r || k(r, "minutes", t);
|
|
989
|
-
if (!i || !a) throw new A("Invalid hours or minutes in disabledTime option", j.INVALID_PARAMETER);
|
|
990
|
-
}
|
|
991
|
-
destroy() {
|
|
992
|
-
this.removeErrorHandler();
|
|
993
|
-
}
|
|
994
|
-
}, ge = class {
|
|
995
|
-
core;
|
|
996
|
-
emitter;
|
|
997
|
-
cleanupHandlers = [];
|
|
998
|
-
constructor(e, t) {
|
|
999
|
-
this.core = e, this.emitter = t;
|
|
1000
|
-
}
|
|
1001
|
-
handleOpenOnClick() {
|
|
1002
|
-
let e = this.core.getOpenElement();
|
|
1003
|
-
if (!e) return;
|
|
1004
|
-
let t = () => {
|
|
1005
|
-
this.core.isDestroyed || this.emitter.emit("show", {});
|
|
1006
|
-
};
|
|
1007
|
-
e.forEach((e) => {
|
|
1008
|
-
this.cleanupHandlers.push(F(e, t));
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
handleCancelButton() {
|
|
1012
|
-
let e = this.core.getCancelButton();
|
|
1013
|
-
e && this.cleanupHandlers.push(F(e, () => {
|
|
1014
|
-
this.core.isDestroyed || this.emitter.emit("cancel", {});
|
|
1015
|
-
}));
|
|
1016
|
-
}
|
|
1017
|
-
handleOkButton() {
|
|
1018
|
-
let e = this.core.getOkButton();
|
|
1019
|
-
e && this.cleanupHandlers.push(F(e, () => {
|
|
1020
|
-
if (this.core.isDestroyed || e.getAttribute("aria-disabled") === "true") return;
|
|
1021
|
-
let t = this.core.getHour(), n = this.core.getMinutes();
|
|
1022
|
-
if (t && n) {
|
|
1023
|
-
let e = this.core.getActiveTypeMode();
|
|
1024
|
-
this.emitter.emit("confirm", {
|
|
1025
|
-
hour: t.value,
|
|
1026
|
-
minutes: n.value,
|
|
1027
|
-
type: e?.textContent || void 0
|
|
1028
|
-
});
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
let r = this.core.getModalElement();
|
|
1032
|
-
if (r) {
|
|
1033
|
-
let e = r.querySelector(".tp-ui-wheel-hours .tp-ui-wheel-item.is-center"), t = r.querySelector(".tp-ui-wheel-minutes .tp-ui-wheel-item.is-center"), n = r.querySelector(".tp-ui-wheel-ampm .tp-ui-wheel-item.is-center");
|
|
1034
|
-
this.emitter.emit("confirm", {
|
|
1035
|
-
hour: e?.getAttribute("data-value") ?? void 0,
|
|
1036
|
-
minutes: t?.getAttribute("data-value") ?? void 0,
|
|
1037
|
-
type: n?.getAttribute("data-value") ?? void 0
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
}));
|
|
1041
|
-
}
|
|
1042
|
-
handleAmClick() {
|
|
1043
|
-
let e = this.core.getAM();
|
|
1044
|
-
e && this.cleanupHandlers.push(F(e, () => {
|
|
1045
|
-
if (this.core.isDestroyed) return;
|
|
1046
|
-
let t = this.core.getPM();
|
|
1047
|
-
e.classList.add("active"), t?.classList.remove("active"), N(e, !0), N(t, !1), M(this.core.getModalElement(), this.core.options.labels.announceAmSelected ?? "AM selected"), this.emitter.emit("select:am", {});
|
|
1048
|
-
let n = this.core.getHour(), r = this.core.getMinutes();
|
|
1049
|
-
this.emitter.emit("update", {
|
|
1050
|
-
hour: n?.value,
|
|
1051
|
-
minutes: r?.value,
|
|
1052
|
-
type: "AM"
|
|
1053
|
-
});
|
|
1054
|
-
}));
|
|
1055
|
-
}
|
|
1056
|
-
handlePmClick() {
|
|
1057
|
-
let e = this.core.getPM();
|
|
1058
|
-
e && this.cleanupHandlers.push(F(e, () => {
|
|
1059
|
-
if (this.core.isDestroyed) return;
|
|
1060
|
-
let t = this.core.getAM();
|
|
1061
|
-
e.classList.add("active"), t?.classList.remove("active"), N(e, !0), N(t, !1), M(this.core.getModalElement(), this.core.options.labels.announcePmSelected ?? "PM selected"), this.emitter.emit("select:pm", {});
|
|
1062
|
-
let n = this.core.getHour(), r = this.core.getMinutes();
|
|
1063
|
-
this.emitter.emit("update", {
|
|
1064
|
-
hour: n?.value,
|
|
1065
|
-
minutes: r?.value,
|
|
1066
|
-
type: "PM"
|
|
1067
|
-
});
|
|
1068
|
-
}));
|
|
1069
|
-
}
|
|
1070
|
-
handleSwitchViewButton() {
|
|
1071
|
-
let e = this.core.getKeyboardClockIcon();
|
|
1072
|
-
e && this.cleanupHandlers.push(F(e, () => {
|
|
1073
|
-
this.core.isDestroyed || this.emitter.emit("switch:view", {});
|
|
1074
|
-
}));
|
|
1075
|
-
}
|
|
1076
|
-
destroy() {
|
|
1077
|
-
this.cleanupHandlers.forEach((e) => e()), this.cleanupHandlers = [];
|
|
1078
|
-
}
|
|
1079
|
-
}, I = (e, t, n) => Math.max(t, Math.min(n, e)), _e = (e, t) => {
|
|
1080
|
-
if (e === "") return "";
|
|
1081
|
-
let n = parseInt(e, 10);
|
|
1082
|
-
return Number.isNaN(n) ? "" : I(n, +!!t, t ? 12 : 23).toString().padStart(2, "0");
|
|
1083
|
-
}, ve = (e) => {
|
|
1084
|
-
if (e === "") return "";
|
|
1085
|
-
let t = parseInt(e, 10);
|
|
1086
|
-
return Number.isNaN(t) ? "" : I(t, 0, 59).toString().padStart(2, "0");
|
|
1087
|
-
}, ye = class {
|
|
1088
|
-
core;
|
|
1089
|
-
emitter;
|
|
1090
|
-
cleanupHandlers = [];
|
|
1091
|
-
constructor(e, t) {
|
|
1092
|
-
this.core = e, this.emitter = t;
|
|
1093
|
-
}
|
|
1094
|
-
handleHourEvents() {
|
|
1095
|
-
let e = this.core.getHour();
|
|
1096
|
-
if (!e) return;
|
|
1097
|
-
let t = () => {
|
|
1098
|
-
if (this.core.isDestroyed) return;
|
|
1099
|
-
e.classList.add("active");
|
|
1100
|
-
let t = this.core.getMinutes();
|
|
1101
|
-
t?.classList.remove("active"), this.emitter.emit("select:hour", { hour: e.value });
|
|
1102
|
-
let n = this.core.getActiveTypeMode();
|
|
1103
|
-
this.emitter.emit("update", {
|
|
1104
|
-
hour: e.value,
|
|
1105
|
-
minutes: t?.value,
|
|
1106
|
-
type: n?.textContent || void 0
|
|
1107
|
-
});
|
|
1108
|
-
};
|
|
1109
|
-
e.addEventListener("click", t), this.cleanupHandlers.push(() => e.removeEventListener("click", t));
|
|
1110
|
-
let n = e.value, r = () => {
|
|
1111
|
-
if (this.core.isDestroyed || e.hasAttribute("readonly")) return;
|
|
1112
|
-
let t = this.core.options.clock.type === "12h", r = _e(e.value, t);
|
|
1113
|
-
if (e.value = r, e.setAttribute("aria-valuenow", r), e.value !== n) {
|
|
1114
|
-
n = e.value, this.emitter.emit("animation:clock", {}), this.emitter.emit("select:hour", { hour: e.value });
|
|
1115
|
-
let t = this.core.getMinutes(), r = this.core.getActiveTypeMode();
|
|
1116
|
-
this.emitter.emit("update", {
|
|
1117
|
-
hour: e.value,
|
|
1118
|
-
minutes: t?.value,
|
|
1119
|
-
type: r?.textContent || void 0
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
};
|
|
1123
|
-
e.addEventListener("blur", r), this.cleanupHandlers.push(() => e.removeEventListener("blur", r));
|
|
1124
|
-
}
|
|
1125
|
-
handleMinutesEvents() {
|
|
1126
|
-
let e = this.core.getMinutes();
|
|
1127
|
-
if (!e) return;
|
|
1128
|
-
let t = () => {
|
|
1129
|
-
if (this.core.isDestroyed) return;
|
|
1130
|
-
e.classList.add("active");
|
|
1131
|
-
let t = this.core.getHour();
|
|
1132
|
-
t?.classList.remove("active"), this.emitter.emit("select:minute", { minutes: e.value });
|
|
1133
|
-
let n = this.core.getActiveTypeMode();
|
|
1134
|
-
this.emitter.emit("update", {
|
|
1135
|
-
hour: t?.value,
|
|
1136
|
-
minutes: e.value,
|
|
1137
|
-
type: n?.textContent || void 0
|
|
1138
|
-
});
|
|
1139
|
-
};
|
|
1140
|
-
e.addEventListener("click", t), this.cleanupHandlers.push(() => e.removeEventListener("click", t));
|
|
1141
|
-
let n = e.value, r = () => {
|
|
1142
|
-
if (this.core.isDestroyed || e.hasAttribute("readonly")) return;
|
|
1143
|
-
let t = ve(e.value);
|
|
1144
|
-
if (e.value = t, e.setAttribute("aria-valuenow", t), e.value !== n) {
|
|
1145
|
-
n = e.value, this.emitter.emit("animation:clock", {}), this.emitter.emit("select:minute", { minutes: e.value });
|
|
1146
|
-
let t = this.core.getHour(), r = this.core.getActiveTypeMode();
|
|
1147
|
-
this.emitter.emit("update", {
|
|
1148
|
-
hour: t?.value,
|
|
1149
|
-
minutes: e.value,
|
|
1150
|
-
type: r?.textContent || void 0
|
|
1151
|
-
});
|
|
1152
|
-
}
|
|
1153
|
-
};
|
|
1154
|
-
e.addEventListener("blur", r), this.cleanupHandlers.push(() => e.removeEventListener("blur", r));
|
|
1155
|
-
}
|
|
1156
|
-
destroy() {
|
|
1157
|
-
this.cleanupHandlers.forEach((e) => e()), this.cleanupHandlers = [];
|
|
1158
|
-
}
|
|
1159
|
-
}, be = class {
|
|
1160
|
-
core;
|
|
1161
|
-
emitter;
|
|
1162
|
-
cleanupHandlers = [];
|
|
1163
|
-
constructor(e, t) {
|
|
1164
|
-
this.core = e, this.emitter = t;
|
|
1165
|
-
}
|
|
1166
|
-
handleOpenOnEnterFocus() {
|
|
1167
|
-
let e = this.core.getInput();
|
|
1168
|
-
if (!e) return;
|
|
1169
|
-
let t = (e) => {
|
|
1170
|
-
e.key === "Enter" && !this.core.isDestroyed && !this.core.isOpen && this.emitter.emit("show", {});
|
|
1171
|
-
};
|
|
1172
|
-
e.addEventListener("keydown", t), this.cleanupHandlers.push(() => e.removeEventListener("keydown", t));
|
|
1173
|
-
}
|
|
1174
|
-
handleEscClick() {
|
|
1175
|
-
if (t() === !1) return;
|
|
1176
|
-
let e = (e) => {
|
|
1177
|
-
this.core.isDestroyed || this.core.isOpen && e.key === "Escape" && this.emitter.emit("cancel", {});
|
|
1178
|
-
};
|
|
1179
|
-
document.addEventListener("keydown", e), this.cleanupHandlers.push(() => document.removeEventListener("keydown", e));
|
|
1180
|
-
}
|
|
1181
|
-
handleKeyboardInput() {
|
|
1182
|
-
let e = this.core.getHour(), t = this.core.getMinutes(), n = [
|
|
1183
|
-
"ArrowUp",
|
|
1184
|
-
"ArrowDown",
|
|
1185
|
-
"Home",
|
|
1186
|
-
"End",
|
|
1187
|
-
"PageUp",
|
|
1188
|
-
"PageDown"
|
|
1189
|
-
];
|
|
1190
|
-
if (e) {
|
|
1191
|
-
let t = (t) => {
|
|
1192
|
-
if (this.core.isDestroyed || !n.includes(t.key)) return;
|
|
1193
|
-
t.preventDefault();
|
|
1194
|
-
let r = parseInt(e.value) || 0, i = parseInt(e.getAttribute("max") || "23"), a = +(this.core.options.clock.type === "12h"), o = this.computeSpinValue(t.key, r, a, i, 3);
|
|
1195
|
-
e.value = o.toString().padStart(2, "0"), e.setAttribute("aria-valuenow", e.value), e.setAttribute("aria-valuetext", e.value), M(this.core.getModalElement(), `${this.core.options.labels.announceHour ?? "Hour"}: ${e.value}`), this.emitter.emit("animation:clock", {}), this.emitter.emit("select:hour", { hour: e.value });
|
|
1196
|
-
let s = this.core.getMinutes(), c = this.core.getActiveTypeMode();
|
|
1197
|
-
this.emitter.emit("update", {
|
|
1198
|
-
hour: e.value,
|
|
1199
|
-
minutes: s?.value,
|
|
1200
|
-
type: c?.textContent || void 0
|
|
1201
|
-
});
|
|
1202
|
-
};
|
|
1203
|
-
e.addEventListener("keydown", t), this.cleanupHandlers.push(() => e.removeEventListener("keydown", t));
|
|
1204
|
-
}
|
|
1205
|
-
if (t) {
|
|
1206
|
-
let e = (e) => {
|
|
1207
|
-
if (this.core.isDestroyed || !n.includes(e.key)) return;
|
|
1208
|
-
e.preventDefault();
|
|
1209
|
-
let r = parseInt(t.value) || 0, i = this.computeSpinValue(e.key, r, 0, 59, 5);
|
|
1210
|
-
t.value = i.toString().padStart(2, "0"), t.setAttribute("aria-valuenow", t.value), t.setAttribute("aria-valuetext", t.value), M(this.core.getModalElement(), `${this.core.options.labels.announceMinute ?? "Minutes"}: ${t.value}`), this.emitter.emit("animation:clock", {}), this.emitter.emit("select:minute", { minutes: t.value });
|
|
1211
|
-
let a = this.core.getHour(), o = this.core.getActiveTypeMode();
|
|
1212
|
-
this.emitter.emit("update", {
|
|
1213
|
-
hour: a?.value,
|
|
1214
|
-
minutes: t.value,
|
|
1215
|
-
type: o?.textContent || void 0
|
|
1216
|
-
});
|
|
1217
|
-
};
|
|
1218
|
-
t.addEventListener("keydown", e), this.cleanupHandlers.push(() => t.removeEventListener("keydown", e));
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
computeSpinValue(e, t, n, r, i) {
|
|
1222
|
-
switch (e) {
|
|
1223
|
-
case "ArrowUp": return t >= r ? n : t + 1;
|
|
1224
|
-
case "ArrowDown": return t <= n ? r : t - 1;
|
|
1225
|
-
case "Home": return n;
|
|
1226
|
-
case "End": return r;
|
|
1227
|
-
case "PageUp": return Math.min(r, t + i);
|
|
1228
|
-
case "PageDown": return Math.max(n, t - i);
|
|
1229
|
-
default: return t;
|
|
1230
|
-
}
|
|
1231
|
-
}
|
|
1232
|
-
focusTrapHandler() {
|
|
1233
|
-
if (t() === !1) return;
|
|
1234
|
-
let e = this.core.getWrapper();
|
|
1235
|
-
if (!e) return;
|
|
1236
|
-
let n = (t) => {
|
|
1237
|
-
if (this.core.isDestroyed || t.key !== "Tab") return;
|
|
1238
|
-
let n = e.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex=\"-1\"])"), r = [];
|
|
1239
|
-
if (n.forEach((e) => {
|
|
1240
|
-
e.getAttribute("aria-disabled") !== "true" && (e.hasAttribute("disabled") || e.hidden || e.getAttribute("aria-hidden") !== "true" && (e.offsetParent === null && e.getClientRects().length === 0 || r.push(e)));
|
|
1241
|
-
}), r.length === 0) return;
|
|
1242
|
-
let i = r[0], a = r[r.length - 1];
|
|
1243
|
-
t.shiftKey && document.activeElement === i ? (a?.focus(), t.preventDefault()) : !t.shiftKey && document.activeElement === a && (i?.focus(), t.preventDefault());
|
|
1244
|
-
};
|
|
1245
|
-
e.addEventListener("keydown", n), this.cleanupHandlers.push(() => e.removeEventListener("keydown", n));
|
|
1246
|
-
}
|
|
1247
|
-
destroy() {
|
|
1248
|
-
this.cleanupHandlers.forEach((e) => e()), this.cleanupHandlers = [];
|
|
1249
|
-
}
|
|
1250
|
-
}, xe = class {
|
|
1251
|
-
core;
|
|
1252
|
-
emitter;
|
|
1253
|
-
cleanupHandlers = [];
|
|
1254
|
-
constructor(e, t) {
|
|
1255
|
-
this.core = e, this.emitter = t;
|
|
1256
|
-
}
|
|
1257
|
-
handleBackdropClick() {
|
|
1258
|
-
let e = this.core.getModalElement();
|
|
1259
|
-
if (!e) return;
|
|
1260
|
-
let t = (t) => {
|
|
1261
|
-
this.core.isDestroyed || t.target === e && this.emitter.emit("cancel", {});
|
|
1262
|
-
};
|
|
1263
|
-
e.addEventListener("click", t), this.cleanupHandlers.push(() => e.removeEventListener("click", t));
|
|
1264
|
-
}
|
|
1265
|
-
handleMoveHand() {
|
|
1266
|
-
if (t() === !1) return;
|
|
1267
|
-
let e = (e) => {
|
|
1268
|
-
this.core.isDestroyed || e.preventDefault();
|
|
1269
|
-
};
|
|
1270
|
-
document.addEventListener("mousedown", e, !1), document.addEventListener("touchstart", e, { passive: !1 }), this.cleanupHandlers.push(() => {
|
|
1271
|
-
document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
destroy() {
|
|
1275
|
-
this.cleanupHandlers.forEach((e) => e()), this.cleanupHandlers = [];
|
|
1276
|
-
}
|
|
1277
|
-
}, Se = class {
|
|
1278
|
-
buttonHandlers;
|
|
1279
|
-
inputHandlers;
|
|
1280
|
-
keyboardHandlers;
|
|
1281
|
-
modalHandlers;
|
|
1282
|
-
constructor(e, t) {
|
|
1283
|
-
this.buttonHandlers = new ge(e, t), this.inputHandlers = new ye(e, t), this.keyboardHandlers = new be(e, t), this.modalHandlers = new xe(e, t);
|
|
1284
|
-
}
|
|
1285
|
-
handleOpenOnClick() {
|
|
1286
|
-
this.buttonHandlers.handleOpenOnClick();
|
|
1287
|
-
}
|
|
1288
|
-
handleOpenOnEnterFocus() {
|
|
1289
|
-
this.keyboardHandlers.handleOpenOnEnterFocus();
|
|
1290
|
-
}
|
|
1291
|
-
handleCancelButton() {
|
|
1292
|
-
this.buttonHandlers.handleCancelButton();
|
|
1293
|
-
}
|
|
1294
|
-
handleOkButton() {
|
|
1295
|
-
this.buttonHandlers.handleOkButton();
|
|
1296
|
-
}
|
|
1297
|
-
handleBackdropClick() {
|
|
1298
|
-
this.modalHandlers.handleBackdropClick();
|
|
1299
|
-
}
|
|
1300
|
-
handleEscClick() {
|
|
1301
|
-
this.keyboardHandlers.handleEscClick();
|
|
1302
|
-
}
|
|
1303
|
-
handleAmClick() {
|
|
1304
|
-
this.buttonHandlers.handleAmClick();
|
|
1305
|
-
}
|
|
1306
|
-
handlePmClick() {
|
|
1307
|
-
this.buttonHandlers.handlePmClick();
|
|
1308
|
-
}
|
|
1309
|
-
handleHourEvents() {
|
|
1310
|
-
this.inputHandlers.handleHourEvents();
|
|
1311
|
-
}
|
|
1312
|
-
handleMinutesEvents() {
|
|
1313
|
-
this.inputHandlers.handleMinutesEvents();
|
|
1314
|
-
}
|
|
1315
|
-
handleKeyboardInput() {
|
|
1316
|
-
this.keyboardHandlers.handleKeyboardInput();
|
|
1317
|
-
}
|
|
1318
|
-
focusTrapHandler() {
|
|
1319
|
-
this.keyboardHandlers.focusTrapHandler();
|
|
1320
|
-
}
|
|
1321
|
-
handleMoveHand() {
|
|
1322
|
-
this.modalHandlers.handleMoveHand();
|
|
1323
|
-
}
|
|
1324
|
-
handleSwitchViewButton() {
|
|
1325
|
-
this.buttonHandlers.handleSwitchViewButton();
|
|
1326
|
-
}
|
|
1327
|
-
destroy() {
|
|
1328
|
-
this.buttonHandlers.destroy(), this.inputHandlers.destroy(), this.keyboardHandlers.destroy(), this.modalHandlers.destroy();
|
|
1329
|
-
}
|
|
1330
|
-
}, Ce = class {
|
|
1331
|
-
emitter;
|
|
1332
|
-
getClockSystem;
|
|
1333
|
-
setHoursToClock;
|
|
1334
|
-
setMinutesToClock;
|
|
1335
|
-
updateAmPm;
|
|
1336
|
-
convertDisabledTime;
|
|
1337
|
-
constructor(e, t, n, r, i, a) {
|
|
1338
|
-
this.emitter = e, this.getClockSystem = t, this.setHoursToClock = n, this.setMinutesToClock = r, this.updateAmPm = i, this.convertDisabledTime = a;
|
|
1339
|
-
}
|
|
1340
|
-
setup() {
|
|
1341
|
-
this.emitter.on("select:hour", ({ hour: e }) => {
|
|
1342
|
-
this.emitter.emit("animation:clock", {}), this.setHoursToClock(e || null);
|
|
1343
|
-
}), this.emitter.on("select:minute", ({ minutes: e }) => {
|
|
1344
|
-
this.emitter.emit("animation:clock", {}), this.setMinutesToClock(e || null);
|
|
1345
|
-
}), this.emitter.on("select:am", () => {
|
|
1346
|
-
this.updateAmPm();
|
|
1347
|
-
}), this.emitter.on("select:pm", () => {
|
|
1348
|
-
this.updateAmPm();
|
|
1349
|
-
}), this.emitter.on("animation:start", () => {
|
|
1350
|
-
this.getClockSystem()?.blockInteractions();
|
|
1351
|
-
}), this.emitter.on("animation:end", () => {
|
|
1352
|
-
this.getClockSystem()?.unblockInteractions();
|
|
1353
|
-
}), this.emitter.on("range:switch", (e) => {
|
|
1354
|
-
this.refreshDisabledTimeForRange(e.disabledTime);
|
|
1355
|
-
});
|
|
1356
|
-
}
|
|
1357
|
-
refreshDisabledTimeForRange(e) {
|
|
1358
|
-
let t = this.getClockSystem();
|
|
1359
|
-
if (!t) return;
|
|
1360
|
-
let n = this.convertDisabledTime(), r = n;
|
|
1361
|
-
if (e) {
|
|
1362
|
-
let t = [...n?.hours || [], ...e.hours || []], i = [...n?.minutes || [], ...e.minutes || []];
|
|
1363
|
-
r = {
|
|
1364
|
-
...n,
|
|
1365
|
-
hours: t.length > 0 ? t : void 0,
|
|
1366
|
-
minutes: i.length > 0 ? i : void 0,
|
|
1367
|
-
rangeFromType: e.fromType,
|
|
1368
|
-
rangeFromHour: e.fromHour
|
|
1369
|
-
};
|
|
1370
|
-
}
|
|
1371
|
-
t.updateDisabledTime(r);
|
|
1372
|
-
}
|
|
1373
|
-
}, we = /^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i, Te = /^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/;
|
|
1374
|
-
function Ee(e) {
|
|
1375
|
-
let t = e.match(we);
|
|
1376
|
-
return t ? {
|
|
1377
|
-
hour: t[1],
|
|
1378
|
-
minutes: t[2],
|
|
1379
|
-
type: t[3].toUpperCase()
|
|
1380
|
-
} : null;
|
|
1381
|
-
}
|
|
1382
|
-
function De(e) {
|
|
1383
|
-
let t = e.match(Te);
|
|
1384
|
-
return t ? {
|
|
1385
|
-
hour: t[1],
|
|
1386
|
-
minutes: t[2]
|
|
1387
|
-
} : null;
|
|
1388
|
-
}
|
|
1389
|
-
function L(e, t) {
|
|
1390
|
-
let n = parseInt(e.hour, 10), r = parseInt(e.minutes, 10);
|
|
1391
|
-
if (Number.isNaN(n) || Number.isNaN(r)) return 0;
|
|
1392
|
-
if (t === "12h" && e.type) {
|
|
1393
|
-
let t = e.type.toUpperCase();
|
|
1394
|
-
t === "PM" && n !== 12 && (n += 12), t === "AM" && n === 12 && (n = 0);
|
|
1395
|
-
}
|
|
1396
|
-
return n * 60 + r;
|
|
1397
|
-
}
|
|
1398
|
-
function R(e, t) {
|
|
1399
|
-
if (t === "12h") {
|
|
1400
|
-
let t = e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);
|
|
1401
|
-
return t ? L({
|
|
1402
|
-
hour: t[1],
|
|
1403
|
-
minutes: t[2],
|
|
1404
|
-
type: t[3]
|
|
1405
|
-
}, "12h") : 0;
|
|
1406
|
-
}
|
|
1407
|
-
let [n, r] = e.split(":");
|
|
1408
|
-
return L({
|
|
1409
|
-
hour: n ?? "0",
|
|
1410
|
-
minutes: r ?? "0"
|
|
1411
|
-
}, "24h");
|
|
1412
|
-
}
|
|
1413
|
-
var z = class {
|
|
1414
|
-
static angleToIndex(e, t, n) {
|
|
1415
|
-
let r = Math.round(e / 30) % 12;
|
|
1416
|
-
if (t === "24h") {
|
|
1417
|
-
if (n) {
|
|
1418
|
-
let e = r + 12;
|
|
1419
|
-
return e === 12 ? 0 : e;
|
|
1420
|
-
}
|
|
1421
|
-
return r === 0 ? 12 : r;
|
|
1422
|
-
}
|
|
1423
|
-
return r === 0 ? 12 : r;
|
|
1424
|
-
}
|
|
1425
|
-
static indexToValue(e, t) {
|
|
1426
|
-
if (t === "24h") return e.toString().padStart(2, "0");
|
|
1427
|
-
let n = e;
|
|
1428
|
-
return n === 0 && (n = 12), n > 12 && (n -= 12), n.toString().padStart(2, "0");
|
|
1429
|
-
}
|
|
1430
|
-
static indexToAngle(e, t) {
|
|
1431
|
-
return t === "24h" ? e >= 12 ? (e - 12) % 12 * 30 : e % 12 * 30 : (e === 0 ? 12 : e) % 12 * 30;
|
|
1432
|
-
}
|
|
1433
|
-
static isDisabled(e, t, n) {
|
|
1434
|
-
return n ? n.isInterval && n.intervals && n.clockType ? this.isDisabledByInterval(e, t, n) : n.rangeFromType !== void 0 && n.rangeFromHour !== void 0 ? this.isDisabledForRange12h(e, t, n) : n.hours ? n.hours.some((t) => String(t) === e || Number(t) === Number(e) || t === e) : !1 : !1;
|
|
1435
|
-
}
|
|
1436
|
-
static isDisabledForRange12h(e, t, n) {
|
|
1437
|
-
let r = n.rangeFromType, i = n.rangeFromHour, a = parseInt(e, 10);
|
|
1438
|
-
return r === null || i === void 0 ? !1 : t === "AM" && r === "PM" ? !0 : t === "AM" && r === "AM" ? i === 12 ? !1 : a === 12 || a < i : t === "PM" && r === "AM" ? !1 : t === "PM" && r === "PM" ? i === 12 ? !1 : a === 12 || a < i : !1;
|
|
1439
|
-
}
|
|
1440
|
-
static isDisabledByInterval(e, t, n) {
|
|
1441
|
-
if (!n.intervals) return !1;
|
|
1442
|
-
for (let r = 0; r < 60; r++) {
|
|
1443
|
-
let i = r.toString().padStart(2, "0");
|
|
1444
|
-
if (!this.isTimeInIntervals(e, i, t, n.intervals, n.clockType)) return !1;
|
|
1445
|
-
}
|
|
1446
|
-
return !0;
|
|
1447
|
-
}
|
|
1448
|
-
static isTimeInIntervals(e, t, n, r, i) {
|
|
1449
|
-
let a = R(i === "12h" ? `${e}:${t} ${n}` : `${e}:${t}`, i);
|
|
1450
|
-
for (let e of r) {
|
|
1451
|
-
let [t, n] = e.split("-").map((e) => e.trim()), r = R(t, i), o = R(n, i);
|
|
1452
|
-
if (a >= r && a <= o) return !0;
|
|
1453
|
-
}
|
|
1454
|
-
return !1;
|
|
1455
|
-
}
|
|
1456
|
-
static findNearestValid(e, t, n, r) {
|
|
1457
|
-
let i = t === "24h" ? 23 : 12;
|
|
1458
|
-
for (let a = 0; a <= i; a++) {
|
|
1459
|
-
let o = a === 0 ? [e] : [e + a, e - a];
|
|
1460
|
-
for (let e of o) {
|
|
1461
|
-
let a = e;
|
|
1462
|
-
a < 0 && (a += i + 1), a > i && (a %= i + 1);
|
|
1463
|
-
let o = this.indexToValue(a, t);
|
|
1464
|
-
if (!this.isDisabled(o, n, r)) return a;
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
return e;
|
|
1468
|
-
}
|
|
1469
|
-
}, B = class {
|
|
1470
|
-
static angleToIndex(e) {
|
|
1471
|
-
return Math.round(e / 6) % 60;
|
|
1472
|
-
}
|
|
1473
|
-
static indexToValue(e) {
|
|
1474
|
-
return e.toString().padStart(2, "0");
|
|
1475
|
-
}
|
|
1476
|
-
static indexToAngle(e) {
|
|
1477
|
-
return e % 60 * 6;
|
|
1478
|
-
}
|
|
1479
|
-
static isDisabled(e, t, n, r, i) {
|
|
1480
|
-
return r ? r.isInterval && r.intervals ? this.isDisabledByInterval(e, t, n, r, i) : r.rangeFromType !== void 0 && r.rangeFromHour !== void 0 ? this.isDisabledForRange12h(e, t, n, r) : r.rangeFromHour !== void 0 && parseInt(t, 10) !== r.rangeFromHour ? !1 : r.minutes ? r.minutes.some((t) => String(t) === e || Number(t) === Number(e) || t === e) : !1 : !1;
|
|
1481
|
-
}
|
|
1482
|
-
static isDisabledForRange12h(e, t, n, r) {
|
|
1483
|
-
let i = r.rangeFromType, a = r.rangeFromHour, o = parseInt(t, 10), s = parseInt(e, 10);
|
|
1484
|
-
if (i === null || a === void 0) return !1;
|
|
1485
|
-
let c = r.minutes || [], l = c.length > 0 ? parseInt(c[c.length - 1], 10) + 1 : 0;
|
|
1486
|
-
return n === "AM" && i === "PM" ? !0 : n === "PM" && i === "AM" ? !1 : o === a || o === 12 && a === 12 || n === i && o === a ? s < l : !1;
|
|
1487
|
-
}
|
|
1488
|
-
static isDisabledByInterval(e, t, n, r, i) {
|
|
1489
|
-
if (!r.intervals) return !1;
|
|
1490
|
-
let a = R(i === "12h" ? `${t}:${e} ${n}` : `${t}:${e}`, i);
|
|
1491
|
-
for (let e of r.intervals) {
|
|
1492
|
-
let [t, n] = e.split("-").map((e) => e.trim()), r = R(t, i), o = R(n, i);
|
|
1493
|
-
if (a >= r && a <= o) return !0;
|
|
1494
|
-
}
|
|
1495
|
-
return !1;
|
|
1496
|
-
}
|
|
1497
|
-
static findNearestValid(e, t, n, r, i) {
|
|
1498
|
-
for (let a = 0; a < 60; a++) {
|
|
1499
|
-
let o = a === 0 ? [e] : [e + a, e - a];
|
|
1500
|
-
for (let e of o) {
|
|
1501
|
-
let a = e;
|
|
1502
|
-
a < 0 && (a += 60), a >= 60 && (a %= 60);
|
|
1503
|
-
let o = this.indexToValue(a);
|
|
1504
|
-
if (!this.isDisabled(o, t, n, r, i)) return a;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
return e;
|
|
1508
|
-
}
|
|
1509
|
-
}, V = class {
|
|
1510
|
-
static normalizeAngle(e) {
|
|
1511
|
-
let t = e % 360;
|
|
1512
|
-
return t < 0 && (t += 360), t;
|
|
1513
|
-
}
|
|
1514
|
-
static calculateRawAngle(e, t) {
|
|
1515
|
-
let n = e.x - t.x, r = e.y - t.y, i = Math.atan2(r, n) * 180 / Math.PI + 90;
|
|
1516
|
-
return this.normalizeAngle(i);
|
|
1517
|
-
}
|
|
1518
|
-
static snapToIncrement(e, t) {
|
|
1519
|
-
let n = Math.round(e / t) * t;
|
|
1520
|
-
return this.normalizeAngle(n);
|
|
1521
|
-
}
|
|
1522
|
-
static calculateDistance(e, t) {
|
|
1523
|
-
let n = e.x - t.x, r = e.y - t.y;
|
|
1524
|
-
return Math.sqrt(n * n + r * r);
|
|
1525
|
-
}
|
|
1526
|
-
static isInnerCircle(e, t) {
|
|
1527
|
-
return e < t * .75;
|
|
1528
|
-
}
|
|
1529
|
-
static calculateShortestPath(e, t) {
|
|
1530
|
-
let n = this.normalizeAngle(e), r = this.normalizeAngle(t) - n, i = r >= 0 ? r : r + 360, a = r <= 0 ? r : r - 360;
|
|
1531
|
-
return e + (Math.abs(i) < Math.abs(a) ? i : a);
|
|
1532
|
-
}
|
|
1533
|
-
}, Oe = class {
|
|
1534
|
-
config;
|
|
1535
|
-
currentAngle = 0;
|
|
1536
|
-
tipsCache = /* @__PURE__ */ new Map();
|
|
1537
|
-
cachedDimensions = /* @__PURE__ */ new Map();
|
|
1538
|
-
constructor(e) {
|
|
1539
|
-
this.config = e;
|
|
1540
|
-
}
|
|
1541
|
-
getCachedDimensions(e) {
|
|
1542
|
-
let t = this.cachedDimensions.get(e);
|
|
1543
|
-
if (!t) {
|
|
1544
|
-
let n = (e.offsetWidth - 32) / 2;
|
|
1545
|
-
t = {
|
|
1546
|
-
width: n,
|
|
1547
|
-
height: (e.offsetHeight - 32) / 2,
|
|
1548
|
-
radius: n - 9
|
|
1549
|
-
}, this.cachedDimensions.set(e, t);
|
|
1550
|
-
}
|
|
1551
|
-
return t;
|
|
1552
|
-
}
|
|
1553
|
-
setHandAngle(e) {
|
|
1554
|
-
let t = V.calculateShortestPath(this.currentAngle, e);
|
|
1555
|
-
Math.abs(this.currentAngle - t) < .01 || (this.currentAngle = t, this.config.clockHand.style.transform = `rotateZ(${t}deg)`);
|
|
1556
|
-
}
|
|
1557
|
-
animateToAngle(e) {
|
|
1558
|
-
let t = V.calculateShortestPath(this.currentAngle, e);
|
|
1559
|
-
if (this.currentAngle = t, me()) {
|
|
1560
|
-
this.config.clockHand.style.transform = `rotateZ(${t}deg)`;
|
|
1561
|
-
return;
|
|
1562
|
-
}
|
|
1563
|
-
this.config.tipsWrapper.classList.add("tp-ui-tips-animation"), this.config.clockHand.style.transform = `rotateZ(${t}deg)`, setTimeout(() => {
|
|
1564
|
-
this.config.tipsWrapper.classList.remove("tp-ui-tips-animation");
|
|
1565
|
-
}, 401);
|
|
1566
|
-
}
|
|
1567
|
-
setActiveValue(e) {
|
|
1568
|
-
let t = [this.config.tipsWrapper];
|
|
1569
|
-
this.config.tipsWrapperFor24h && t.push(this.config.tipsWrapperFor24h), t.forEach((t) => {
|
|
1570
|
-
t.querySelectorAll(".tp-ui-value-tips, .tp-ui-value-tips-24h").forEach((t) => {
|
|
1571
|
-
let n = t;
|
|
1572
|
-
n.textContent === e || Number(n.textContent) === Number(e) ? n.classList.add("active") : n.classList.remove("active");
|
|
1573
|
-
});
|
|
1574
|
-
});
|
|
1575
|
-
}
|
|
1576
|
-
renderTips(e, n, r, i, a, o = !0, s, c = "", l = "12") {
|
|
1577
|
-
if (t() === !1) return;
|
|
1578
|
-
let u = s || this.config.tipsWrapper;
|
|
1579
|
-
o && (u.innerHTML = "", this.tipsCache.clear());
|
|
1580
|
-
let { width: d, height: f, radius: p } = this.getCachedDimensions(u), m = document.createDocumentFragment(), h = `${n}-${this.config.theme || "default"}`;
|
|
1581
|
-
e.forEach((t, o) => {
|
|
1582
|
-
let s = `${h}-${t}`, u = this.tipsCache.get(s);
|
|
1583
|
-
u || (u = this.createTip(t, n, a), this.tipsCache.set(s, u));
|
|
1584
|
-
let { wrapper: g, tip: _ } = u;
|
|
1585
|
-
this.updateTipState(g, _, t, r, i, a, c, l);
|
|
1586
|
-
let v = o * (360 / e.length) * (Math.PI / 180);
|
|
1587
|
-
g.style.left = `${d + Math.sin(v) * p}px`, g.style.bottom = `${f + Math.cos(v) * p}px`, m.appendChild(g);
|
|
1588
|
-
}), u.appendChild(m);
|
|
1589
|
-
}
|
|
1590
|
-
createTip(e, n, r) {
|
|
1591
|
-
if (t() === !1) {
|
|
1592
|
-
let e = {};
|
|
1593
|
-
return {
|
|
1594
|
-
wrapper: e,
|
|
1595
|
-
tip: e
|
|
1596
|
-
};
|
|
1597
|
-
}
|
|
1598
|
-
let i = document.createElement("span"), a = document.createElement("span");
|
|
1599
|
-
a.textContent = e, a.tabIndex = -1;
|
|
1600
|
-
let o = r === "24h" && n.includes("24") ? "tp-ui-value-tips-24h" : "tp-ui-value-tips";
|
|
1601
|
-
return a.classList.add(o), i.classList.add(n), i.appendChild(a), {
|
|
1602
|
-
wrapper: i,
|
|
1603
|
-
tip: a
|
|
1604
|
-
};
|
|
1605
|
-
}
|
|
1606
|
-
updateTipState(e, t, n, r, i, a, o, s) {
|
|
1607
|
-
e.classList.remove("tp-ui-tips-disabled"), t.classList.remove("tp-ui-tips-disabled"), t.tabIndex = -1, this.checkIfDisabled(n, r, i, a, o, s) && (e.classList.add("tp-ui-tips-disabled"), t.classList.add("tp-ui-tips-disabled"));
|
|
1608
|
-
}
|
|
1609
|
-
checkIfDisabled(e, t, n, r, i, a) {
|
|
1610
|
-
return n ? t === "hours" ? z.isDisabled(e, i, n) : t === "minutes" && B.isDisabled(e, a, i, n, r) : !1;
|
|
1611
|
-
}
|
|
1612
|
-
setCircleSize(e) {
|
|
1613
|
-
e ? this.config.circle.classList.remove("small-circle") : this.config.circle.classList.add("small-circle");
|
|
1614
|
-
}
|
|
1615
|
-
setCircle24hMode(e) {
|
|
1616
|
-
e ? (this.config.circle.classList.add("tp-ui-circle-hand-24h"), this.config.clockHand.classList.add("tp-ui-clock-hand-24h")) : (this.config.circle.classList.remove("tp-ui-circle-hand-24h"), this.config.clockHand.classList.remove("tp-ui-clock-hand-24h"));
|
|
1617
|
-
}
|
|
1618
|
-
destroy() {
|
|
1619
|
-
this.tipsCache.clear(), this.cachedDimensions.clear(), this.config.tipsWrapper.innerHTML = "";
|
|
1620
|
-
}
|
|
1621
|
-
}, H = class {
|
|
1622
|
-
static processPointerInput(e) {
|
|
1623
|
-
let t = V.calculateRawAngle(e.pointerPosition, e.clockCenter);
|
|
1624
|
-
return e.mode === "hours" ? this.processHours(t, e) : this.processMinutes(t, e);
|
|
1625
|
-
}
|
|
1626
|
-
static processHours(e, t) {
|
|
1627
|
-
let n = t.smoothHourSnap ?? !0, r;
|
|
1628
|
-
if (n) r = e;
|
|
1629
|
-
else {
|
|
1630
|
-
let n = t.incrementHours * 30;
|
|
1631
|
-
r = V.snapToIncrement(e, n);
|
|
1632
|
-
}
|
|
1633
|
-
let i = V.calculateDistance(t.pointerPosition, t.clockCenter), a = t.clockType === "24h" && V.isInnerCircle(i, t.clockRadius), o = z.angleToIndex(r, t.clockType, a), s = z.indexToValue(o, t.clockType), c = z.isDisabled(s, t.amPm, t.disabledTime);
|
|
1634
|
-
c && (o = z.findNearestValid(o, t.clockType, t.amPm, t.disabledTime));
|
|
1635
|
-
let l = z.indexToValue(o, t.clockType), u;
|
|
1636
|
-
return u = n ? e : z.indexToAngle(o, t.clockType), {
|
|
1637
|
-
angle: u,
|
|
1638
|
-
value: l,
|
|
1639
|
-
index: o,
|
|
1640
|
-
isValid: !c,
|
|
1641
|
-
isInnerCircle: t.clockType === "24h" ? a : void 0
|
|
1642
|
-
};
|
|
1643
|
-
}
|
|
1644
|
-
static processMinutes(e, t) {
|
|
1645
|
-
let n = t.incrementMinutes * 6, r = V.snapToIncrement(e, n), i = B.angleToIndex(r), a = B.indexToValue(i), o = t.currentHour || "00", s = B.isDisabled(a, o, t.amPm, t.disabledTime, t.clockType);
|
|
1646
|
-
s && (i = B.findNearestValid(i, o, t.amPm, t.disabledTime, t.clockType));
|
|
1647
|
-
let c = B.indexToValue(i);
|
|
1648
|
-
return {
|
|
1649
|
-
angle: B.indexToAngle(i),
|
|
1650
|
-
value: c,
|
|
1651
|
-
index: i,
|
|
1652
|
-
isValid: !s
|
|
1653
|
-
};
|
|
1654
|
-
}
|
|
1655
|
-
static valueToAngle(e, t, n) {
|
|
1656
|
-
let r = parseInt(e, 10);
|
|
1657
|
-
return t === "hours" ? z.indexToAngle(r, n) : B.indexToAngle(r);
|
|
1658
|
-
}
|
|
1659
|
-
}, ke = class {
|
|
1660
|
-
state;
|
|
1661
|
-
renderer;
|
|
1662
|
-
clockType;
|
|
1663
|
-
disabledTime;
|
|
1664
|
-
incrementHours;
|
|
1665
|
-
incrementMinutes;
|
|
1666
|
-
smoothHourSnap;
|
|
1667
|
-
isDragging = !1;
|
|
1668
|
-
callbacks;
|
|
1669
|
-
lastProcessedX = null;
|
|
1670
|
-
lastProcessedY = null;
|
|
1671
|
-
constructor(e, t, n, r, i = 1, a = 1, o = !0, s = {}) {
|
|
1672
|
-
this.renderer = e, this.state = { ...t }, this.clockType = n, this.disabledTime = r, this.incrementHours = i, this.incrementMinutes = a, this.smoothHourSnap = o, this.callbacks = s;
|
|
1673
|
-
}
|
|
1674
|
-
handlePointerMove(e, t, n) {
|
|
1675
|
-
if (this.isDragging = !0, this.lastProcessedX === e.x && this.lastProcessedY === e.y) return;
|
|
1676
|
-
this.lastProcessedX = e.x, this.lastProcessedY = e.y;
|
|
1677
|
-
let r = {
|
|
1678
|
-
pointerPosition: e,
|
|
1679
|
-
clockCenter: t,
|
|
1680
|
-
clockRadius: n,
|
|
1681
|
-
mode: this.state.mode,
|
|
1682
|
-
clockType: this.clockType,
|
|
1683
|
-
amPm: this.state.amPm,
|
|
1684
|
-
disabledTime: this.disabledTime,
|
|
1685
|
-
incrementHours: this.incrementHours,
|
|
1686
|
-
incrementMinutes: this.incrementMinutes,
|
|
1687
|
-
smoothHourSnap: this.smoothHourSnap,
|
|
1688
|
-
currentHour: this.state.hour
|
|
1689
|
-
}, i = H.processPointerInput(r);
|
|
1690
|
-
if (i.isValid) {
|
|
1691
|
-
if (this.state.mode === "hours") {
|
|
1692
|
-
let e = this.state.hour;
|
|
1693
|
-
this.state.hour = i.value, this.state.hourAngle = i.angle, this.clockType === "24h" && i.isInnerCircle !== void 0 && (this.renderer.setCircleSize(!0), this.renderer.setCircle24hMode(i.isInnerCircle)), this.callbacks.onHourChange && e !== i.value && this.callbacks.onHourChange(i.value);
|
|
1694
|
-
} else {
|
|
1695
|
-
let e = this.state.minute;
|
|
1696
|
-
this.state.minute = i.value, this.state.minuteAngle = i.angle, this.renderer.setCircleSize(!0), this.renderer.setCircle24hMode(!1), this.callbacks.onMinuteChange && e !== i.value && this.callbacks.onMinuteChange(i.value);
|
|
1697
|
-
}
|
|
1698
|
-
this.renderer.setHandAngle(i.angle), this.renderer.setActiveValue(i.value);
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
handlePointerUp() {
|
|
1702
|
-
this.isDragging = !1, this.lastProcessedX = null, this.lastProcessedY = null;
|
|
1703
|
-
}
|
|
1704
|
-
snapToNearestHour() {
|
|
1705
|
-
if (this.state.mode !== "hours") return;
|
|
1706
|
-
let e = H.valueToAngle(this.state.hour, "hours", this.clockType);
|
|
1707
|
-
this.state.hourAngle = e, this.renderer.animateToAngle(e);
|
|
1708
|
-
}
|
|
1709
|
-
switchMode(e) {
|
|
1710
|
-
this.state.mode = e;
|
|
1711
|
-
let t = e === "hours" ? this.state.hourAngle : this.state.minuteAngle, n = e === "hours" ? this.state.hour : this.state.minute;
|
|
1712
|
-
if (e === "hours" && this.clockType === "24h") {
|
|
1713
|
-
let e = parseInt(n, 10), t = e === 0 || e >= 13;
|
|
1714
|
-
this.renderer.setCircleSize(!0), this.renderer.setCircle24hMode(t);
|
|
1715
|
-
} else this.renderer.setCircleSize(!0), this.renderer.setCircle24hMode(!1);
|
|
1716
|
-
this.renderer.setHandAngle(t), this.renderer.setActiveValue(n);
|
|
1717
|
-
}
|
|
1718
|
-
setValue(e, t) {
|
|
1719
|
-
let n = H.valueToAngle(t, e, this.clockType);
|
|
1720
|
-
if (e === "hours") {
|
|
1721
|
-
if (this.state.hour = t, this.state.hourAngle = n, this.clockType === "24h") {
|
|
1722
|
-
let e = parseInt(t, 10), n = e === 0 || e >= 13;
|
|
1723
|
-
this.renderer.setCircleSize(!0), this.renderer.setCircle24hMode(n);
|
|
1724
|
-
} else this.renderer.setCircle24hMode(!1);
|
|
1725
|
-
} else this.state.minute = t, this.state.minuteAngle = n, this.renderer.setCircleSize(!0), this.renderer.setCircle24hMode(!1);
|
|
1726
|
-
this.state.mode === e && (this.renderer.setHandAngle(n), this.renderer.setActiveValue(t));
|
|
1727
|
-
}
|
|
1728
|
-
setAmPm(e) {
|
|
1729
|
-
this.state.amPm = e;
|
|
1730
|
-
}
|
|
1731
|
-
getState() {
|
|
1732
|
-
return { ...this.state };
|
|
1733
|
-
}
|
|
1734
|
-
getHour() {
|
|
1735
|
-
return this.state.hour;
|
|
1736
|
-
}
|
|
1737
|
-
getMinute() {
|
|
1738
|
-
return this.state.minute;
|
|
1739
|
-
}
|
|
1740
|
-
getAmPm() {
|
|
1741
|
-
return this.state.amPm;
|
|
1742
|
-
}
|
|
1743
|
-
updateDisabledTime(e) {
|
|
1744
|
-
this.disabledTime = e;
|
|
1745
|
-
}
|
|
1746
|
-
destroy() {
|
|
1747
|
-
this.renderer.destroy();
|
|
1748
|
-
}
|
|
1749
|
-
}, Ae = class {
|
|
1750
|
-
controller;
|
|
1751
|
-
clockFace;
|
|
1752
|
-
isActive = !1;
|
|
1753
|
-
isBlocked = !1;
|
|
1754
|
-
config;
|
|
1755
|
-
cachedRect = null;
|
|
1756
|
-
cachedCenter = null;
|
|
1757
|
-
cachedRadius = null;
|
|
1758
|
-
rafId = null;
|
|
1759
|
-
constructor(e, t, n = {}) {
|
|
1760
|
-
this.controller = e, this.clockFace = t, this.config = n;
|
|
1761
|
-
}
|
|
1762
|
-
attach() {
|
|
1763
|
-
this.clockFace.addEventListener("mousedown", this.handlePointerDown), this.clockFace.addEventListener("touchstart", this.handlePointerDown, { passive: !1 });
|
|
1764
|
-
}
|
|
1765
|
-
detach() {
|
|
1766
|
-
this.clockFace.removeEventListener("mousedown", this.handlePointerDown), this.clockFace.removeEventListener("touchstart", this.handlePointerDown), this.removeGlobalListeners();
|
|
1767
|
-
}
|
|
1768
|
-
block() {
|
|
1769
|
-
this.isBlocked = !0;
|
|
1770
|
-
}
|
|
1771
|
-
unblock() {
|
|
1772
|
-
this.isBlocked = !1;
|
|
1773
|
-
}
|
|
1774
|
-
handlePointerDown = (t) => {
|
|
1775
|
-
if (e() || this.isBlocked) return;
|
|
1776
|
-
let n = t.target;
|
|
1777
|
-
n && n.classList && n.classList.contains("tp-ui-tips-disabled") || (t.preventDefault(), this.isActive = !0, this.cachedRect = this.clockFace.getBoundingClientRect(), this.cachedCenter = this.getClockCenter(), this.cachedRadius = this.getClockRadius(), this.processPointerEvent(t), document.addEventListener("mousemove", this.handlePointerMove), document.addEventListener("touchmove", this.handlePointerMove, { passive: !1 }), document.addEventListener("mouseup", this.handlePointerUp), document.addEventListener("touchend", this.handlePointerUp));
|
|
1778
|
-
};
|
|
1779
|
-
handlePointerMove = (e) => {
|
|
1780
|
-
if (!this.isActive || this.isBlocked) return;
|
|
1781
|
-
let t = this.getTargetElement(e);
|
|
1782
|
-
t && t.classList && t.classList.contains("tp-ui-tips-disabled") || (e.preventDefault(), this.rafId === null && (this.rafId = requestAnimationFrame(() => {
|
|
1783
|
-
this.rafId = null, this.processPointerEvent(e);
|
|
1784
|
-
})));
|
|
1785
|
-
};
|
|
1786
|
-
handlePointerUp = () => {
|
|
1787
|
-
if (!this.isActive) return;
|
|
1788
|
-
this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null), this.isActive = !1, this.cachedRect = null, this.cachedCenter = null, this.cachedRadius = null, this.controller.handlePointerUp();
|
|
1789
|
-
let { autoSwitchToMinutes: e, isMobileView: t, smoothHourSnap: n, hourElement: r, minutesElement: i } = this.config;
|
|
1790
|
-
n && r?.classList.contains("active") && this.controller.snapToNearestHour(), this.removeGlobalListeners(), e && r?.classList.contains("active") && !t ? (r.classList.remove("active"), i?.classList.add("active"), i?.click(), i?.focus(), r.blur()) : i?.classList.contains("active") && this.config.onMinuteCommit && this.config.onMinuteCommit();
|
|
1791
|
-
};
|
|
1792
|
-
processPointerEvent(e) {
|
|
1793
|
-
let t = this.getPointerPosition(e), n = this.cachedCenter || this.getClockCenter(), r = this.cachedRadius || this.getClockRadius();
|
|
1794
|
-
this.controller.handlePointerMove(t, n, r);
|
|
1795
|
-
}
|
|
1796
|
-
getPointerPosition(e) {
|
|
1797
|
-
let t = this.cachedRect || this.clockFace.getBoundingClientRect();
|
|
1798
|
-
if ("touches" in e) {
|
|
1799
|
-
let n = e.touches[0] || e.changedTouches[0];
|
|
1800
|
-
return {
|
|
1801
|
-
x: n.clientX - t.left,
|
|
1802
|
-
y: n.clientY - t.top
|
|
1803
|
-
};
|
|
1804
|
-
}
|
|
1805
|
-
return {
|
|
1806
|
-
x: e.clientX - t.left,
|
|
1807
|
-
y: e.clientY - t.top
|
|
1808
|
-
};
|
|
1809
|
-
}
|
|
1810
|
-
getTargetElement(t) {
|
|
1811
|
-
if ("touches" in t) {
|
|
1812
|
-
let n = t.touches[0] || t.changedTouches[0];
|
|
1813
|
-
if (n && !e()) return document.elementFromPoint(n.clientX, n.clientY);
|
|
1814
|
-
}
|
|
1815
|
-
return t.target;
|
|
1816
|
-
}
|
|
1817
|
-
getClockCenter() {
|
|
1818
|
-
let e = this.clockFace.offsetWidth, t = this.clockFace.offsetHeight;
|
|
1819
|
-
return {
|
|
1820
|
-
x: e / 2,
|
|
1821
|
-
y: t / 2
|
|
1822
|
-
};
|
|
1823
|
-
}
|
|
1824
|
-
getClockRadius() {
|
|
1825
|
-
return this.clockFace.offsetWidth / 2;
|
|
1826
|
-
}
|
|
1827
|
-
removeGlobalListeners() {
|
|
1828
|
-
t() !== !1 && (document.removeEventListener("mousemove", this.handlePointerMove), document.removeEventListener("touchmove", this.handlePointerMove), document.removeEventListener("mouseup", this.handlePointerUp), document.removeEventListener("touchend", this.handlePointerUp));
|
|
1829
|
-
}
|
|
1830
|
-
}, je = class {
|
|
1831
|
-
renderer;
|
|
1832
|
-
controller;
|
|
1833
|
-
dragHandlers;
|
|
1834
|
-
clockType;
|
|
1835
|
-
disabledTime;
|
|
1836
|
-
tipsWrapper;
|
|
1837
|
-
tipsWrapperFor24h;
|
|
1838
|
-
constructor(e) {
|
|
1839
|
-
this.clockType = e.clockType, this.disabledTime = e.disabledTime, this.tipsWrapper = e.tipsWrapper, this.tipsWrapperFor24h = e.tipsWrapperFor24h;
|
|
1840
|
-
let t = {
|
|
1841
|
-
clockFace: e.clockFace,
|
|
1842
|
-
tipsWrapper: e.tipsWrapper,
|
|
1843
|
-
tipsWrapperFor24h: e.tipsWrapperFor24h,
|
|
1844
|
-
clockHand: e.clockHand,
|
|
1845
|
-
circle: e.circle,
|
|
1846
|
-
theme: e.theme
|
|
1847
|
-
};
|
|
1848
|
-
this.renderer = new Oe(t);
|
|
1849
|
-
let n = {
|
|
1850
|
-
hour: e.initialHour,
|
|
1851
|
-
minute: e.initialMinute,
|
|
1852
|
-
amPm: e.initialAmPm,
|
|
1853
|
-
hourAngle: this.calculateInitialAngle("hours", e.initialHour),
|
|
1854
|
-
minuteAngle: this.calculateInitialAngle("minutes", e.initialMinute),
|
|
1855
|
-
mode: "hours"
|
|
1856
|
-
}, r = {
|
|
1857
|
-
onHourChange: e.onHourChange,
|
|
1858
|
-
onMinuteChange: e.onMinuteChange
|
|
1859
|
-
};
|
|
1860
|
-
this.controller = new ke(this.renderer, n, e.clockType, e.disabledTime, e.incrementHours || 1, e.incrementMinutes || 1, e.smoothHourSnap ?? !0, r), this.dragHandlers = new Ae(this.controller, e.clockFace, e.dragConfig || {});
|
|
1861
|
-
}
|
|
1862
|
-
initialize() {
|
|
1863
|
-
this.dragHandlers.attach(), this.switchToHours();
|
|
1864
|
-
}
|
|
1865
|
-
switchToHours() {
|
|
1866
|
-
this.controller.switchMode("hours"), this.clockType === "24h" && this.tipsWrapperFor24h && this.tipsWrapperFor24h.classList.remove("none"), this.renderHourTips();
|
|
1867
|
-
let e = this.controller.getState();
|
|
1868
|
-
this.renderer.setActiveValue(e.hour);
|
|
1869
|
-
}
|
|
1870
|
-
switchToMinutes() {
|
|
1871
|
-
this.controller.switchMode("minutes"), this.tipsWrapperFor24h && this.tipsWrapperFor24h.classList.add("none"), this.renderMinuteTips();
|
|
1872
|
-
let e = this.controller.getState();
|
|
1873
|
-
this.renderer.setActiveValue(e.minute);
|
|
1874
|
-
}
|
|
1875
|
-
setHour(e) {
|
|
1876
|
-
this.controller.setValue("hours", e);
|
|
1877
|
-
}
|
|
1878
|
-
setMinute(e) {
|
|
1879
|
-
this.controller.setValue("minutes", e);
|
|
1880
|
-
}
|
|
1881
|
-
setAmPm(e) {
|
|
1882
|
-
this.controller.setAmPm(e);
|
|
1883
|
-
let t = this.controller.getState();
|
|
1884
|
-
t.mode === "hours" ? (this.renderHourTips(), this.renderer.setHandAngle(t.hourAngle), this.renderer.setActiveValue(t.hour)) : (this.renderMinuteTips(), this.renderer.setHandAngle(t.minuteAngle), this.renderer.setActiveValue(t.minute));
|
|
1885
|
-
}
|
|
1886
|
-
getHour() {
|
|
1887
|
-
return this.controller.getHour();
|
|
1888
|
-
}
|
|
1889
|
-
getMinute() {
|
|
1890
|
-
return this.controller.getMinute();
|
|
1891
|
-
}
|
|
1892
|
-
getAmPm() {
|
|
1893
|
-
return this.controller.getAmPm();
|
|
1894
|
-
}
|
|
1895
|
-
updateDisabledTime(e) {
|
|
1896
|
-
this.disabledTime = e, this.controller.updateDisabledTime(e), this.controller.getState().mode === "hours" ? this.renderHourTips() : this.renderMinuteTips();
|
|
1897
|
-
}
|
|
1898
|
-
renderHourTips() {
|
|
1899
|
-
let e = this.controller.getState().amPm;
|
|
1900
|
-
this.clockType === "24h" ? (this.renderer.renderTips(_, "tp-ui-hour-time-12", "hours", this.disabledTime, this.clockType, !0, this.tipsWrapper, e), this.tipsWrapperFor24h && this.renderer.renderTips(g, "tp-ui-hour-time-24", "hours", this.disabledTime, this.clockType, !0, this.tipsWrapperFor24h, e)) : this.renderer.renderTips(_, "tp-ui-hour-time-12", "hours", this.disabledTime, this.clockType, !0, void 0, e);
|
|
1901
|
-
}
|
|
1902
|
-
renderMinuteTips() {
|
|
1903
|
-
let e = this.controller.getState(), t = e.amPm, n = e.hour;
|
|
1904
|
-
this.renderer.renderTips(v, "tp-ui-minutes-time", "minutes", this.disabledTime, this.clockType, !0, void 0, t, n);
|
|
1905
|
-
}
|
|
1906
|
-
calculateInitialAngle(e, t) {
|
|
1907
|
-
let n = parseInt(t, 10);
|
|
1908
|
-
return e === "hours" ? n % 12 * 30 : n * 6;
|
|
1909
|
-
}
|
|
1910
|
-
destroy() {
|
|
1911
|
-
this.dragHandlers.detach(), this.controller.destroy();
|
|
1912
|
-
}
|
|
1913
|
-
blockInteractions() {
|
|
1914
|
-
this.dragHandlers.block();
|
|
1915
|
-
}
|
|
1916
|
-
unblockInteractions() {
|
|
1917
|
-
this.dragHandlers.unblock();
|
|
1918
|
-
}
|
|
1919
|
-
}, Me = class {
|
|
1920
|
-
core;
|
|
1921
|
-
emitter;
|
|
1922
|
-
clockSystem = null;
|
|
1923
|
-
constructor(e, t) {
|
|
1924
|
-
this.core = e, this.emitter = t;
|
|
1925
|
-
}
|
|
1926
|
-
getClockSystem() {
|
|
1927
|
-
return this.clockSystem;
|
|
1928
|
-
}
|
|
1929
|
-
initialize() {
|
|
1930
|
-
let e = this.core.getClockFace(), t = this.core.getClockHand(), n = this.core.getCircle();
|
|
1931
|
-
if (!e || !t || !n) return;
|
|
1932
|
-
let r = this.core.options.clock.type === "24h", i = this.core.getTipsWrapper();
|
|
1933
|
-
if (!i) return;
|
|
1934
|
-
let a = this.core.getHour(), o = this.core.getMinutes(), s = {
|
|
1935
|
-
clockFace: e,
|
|
1936
|
-
tipsWrapper: i,
|
|
1937
|
-
tipsWrapperFor24h: r && this.core.getTipsWrapperFor24h() || void 0,
|
|
1938
|
-
clockHand: t,
|
|
1939
|
-
circle: n,
|
|
1940
|
-
clockType: this.core.options.clock.type || "12h",
|
|
1941
|
-
disabledTime: this.convertDisabledTime(),
|
|
1942
|
-
initialHour: a?.value || "12",
|
|
1943
|
-
initialMinute: o?.value || "00",
|
|
1944
|
-
initialAmPm: this.getAmPmValue(),
|
|
1945
|
-
theme: this.core.options.ui.theme,
|
|
1946
|
-
incrementHours: this.core.options.clock.incrementHours || 1,
|
|
1947
|
-
incrementMinutes: this.core.options.clock.incrementMinutes || 1,
|
|
1948
|
-
smoothHourSnap: this.core.options.clock.smoothHourSnap ?? !0,
|
|
1949
|
-
timepicker: null,
|
|
1950
|
-
dragConfig: {
|
|
1951
|
-
autoSwitchToMinutes: this.core.options.clock.autoSwitchToMinutes,
|
|
1952
|
-
isMobileView: this.core.isMobileView,
|
|
1953
|
-
smoothHourSnap: this.core.options.clock.smoothHourSnap ?? !0,
|
|
1954
|
-
hourElement: a,
|
|
1955
|
-
minutesElement: o,
|
|
1956
|
-
onMinuteCommit: () => {
|
|
1957
|
-
let e = this.core.getMinutes(), t = this.core.getHour(), n = this.core.getActiveTypeMode();
|
|
1958
|
-
this.emitter.emit("range:minute:commit", {
|
|
1959
|
-
hour: t?.value ?? "12",
|
|
1960
|
-
minutes: e?.value ?? "00",
|
|
1961
|
-
type: n?.textContent ?? void 0
|
|
1962
|
-
});
|
|
1963
|
-
}
|
|
1964
|
-
},
|
|
1965
|
-
onHourChange: (e) => {
|
|
1966
|
-
let t = this.core.getHour();
|
|
1967
|
-
t && (t.value = e, t.setAttribute("aria-valuenow", e)), M(this.core.getModalElement(), `Hour: ${e}`);
|
|
1968
|
-
let n = this.core.getMinutes(), r = this.core.getActiveTypeMode();
|
|
1969
|
-
this.emitter.emit("update", {
|
|
1970
|
-
hour: e,
|
|
1971
|
-
minutes: n?.value,
|
|
1972
|
-
type: r?.textContent || void 0
|
|
1973
|
-
});
|
|
1974
|
-
},
|
|
1975
|
-
onMinuteChange: (e) => {
|
|
1976
|
-
let t = this.core.getMinutes();
|
|
1977
|
-
t && (t.value = e, t.setAttribute("aria-valuenow", e)), M(this.core.getModalElement(), `Minutes: ${e}`);
|
|
1978
|
-
let n = this.core.getHour(), r = this.core.getActiveTypeMode();
|
|
1979
|
-
this.emitter.emit("update", {
|
|
1980
|
-
hour: n?.value,
|
|
1981
|
-
minutes: e,
|
|
1982
|
-
type: r?.textContent || void 0
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
};
|
|
1986
|
-
this.clockSystem = new je(s), this.clockSystem.initialize();
|
|
1987
|
-
}
|
|
1988
|
-
convertDisabledTime() {
|
|
1989
|
-
let e = this.core.disabledTime?.value;
|
|
1990
|
-
if (!e) return null;
|
|
1991
|
-
let t;
|
|
1992
|
-
return e.intervals && (t = Array.isArray(e.intervals) ? e.intervals : [e.intervals]), {
|
|
1993
|
-
hours: e.hours,
|
|
1994
|
-
minutes: e.minutes,
|
|
1995
|
-
isInterval: e.isInterval,
|
|
1996
|
-
intervals: t,
|
|
1997
|
-
clockType: e.clockType
|
|
1998
|
-
};
|
|
1999
|
-
}
|
|
2000
|
-
getAmPmValue() {
|
|
2001
|
-
if (this.core.options.clock.type === "24h") return "";
|
|
2002
|
-
let e = this.core.getActiveTypeMode();
|
|
2003
|
-
if (e) {
|
|
2004
|
-
let t = e.textContent?.trim();
|
|
2005
|
-
if (t === "AM" || t === "PM") return t;
|
|
2006
|
-
}
|
|
2007
|
-
let t = this.core.getAM();
|
|
2008
|
-
return this.core.options.range?.enabled === !0 ? t?.classList.contains("active") ? "AM" : "" : t?.classList.contains("active") ? "AM" : "PM";
|
|
2009
|
-
}
|
|
2010
|
-
destroy() {
|
|
2011
|
-
this.clockSystem &&= (this.clockSystem.destroy(), null);
|
|
2012
|
-
}
|
|
2013
|
-
}, Ne = class {
|
|
2014
|
-
core;
|
|
2015
|
-
constructor(e) {
|
|
2016
|
-
this.core = e;
|
|
2017
|
-
}
|
|
2018
|
-
removeCircleClockClasses24h() {
|
|
2019
|
-
let e = this.core.getCircle(), t = this.core.getClockHand();
|
|
2020
|
-
e?.classList.remove("tp-ui-circle-hand-24h"), t?.classList.remove("tp-ui-clock-hand-24h");
|
|
2021
|
-
}
|
|
2022
|
-
setCircleClockClasses24h() {
|
|
2023
|
-
let e = this.core.getCircle(), t = this.core.getClockHand();
|
|
2024
|
-
e && e.classList.add("tp-ui-circle-hand-24h"), t && t.classList.add("tp-ui-clock-hand-24h");
|
|
2025
|
-
}
|
|
2026
|
-
setOnStartCSSClassesIfClockType24h() {
|
|
2027
|
-
if (this.core.options.clock.type === "24h") {
|
|
2028
|
-
let e = this.core.getInput();
|
|
2029
|
-
if (!e) return;
|
|
2030
|
-
let t;
|
|
2031
|
-
e.value.length > 0 && (t = e.value.split(":")[0]), t && (Number(t) > 12 || Number(t) === 0) && this.setCircleClockClasses24h();
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2034
|
-
setBgColorToCircleWithMinutesTips() {
|
|
2035
|
-
let e = this.core.getMinutes(), t = this.core.getCircle();
|
|
2036
|
-
if (e && t && e.value && v.includes(e.value)) {
|
|
2037
|
-
let e = getComputedStyle(t).getPropertyValue("--timepicker-primary").trim();
|
|
2038
|
-
e && (t.style.backgroundColor = e), t.classList.remove("small-circle");
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
removeBgColorToCirleWithMinutesTips() {
|
|
2042
|
-
let e = this.core.getMinutes(), t = this.core.getCircle();
|
|
2043
|
-
!e || !t || e.value && v.includes(e.value) || (t.style.backgroundColor = "", t.classList.add("small-circle"));
|
|
2044
|
-
}
|
|
2045
|
-
setClassActiveToHourOnOpen() {
|
|
2046
|
-
this.core.options.ui.mobile || this.core.isMobileView || this.core.getHour()?.classList.add(O);
|
|
2047
|
-
}
|
|
2048
|
-
toggleClassActiveToValueTips(e, t) {
|
|
2049
|
-
if (e) return;
|
|
2050
|
-
let n = this.core.getAllValueTips();
|
|
2051
|
-
if (!n) return;
|
|
2052
|
-
let r = n.find((e) => Number(e.innerText) === Number(t));
|
|
2053
|
-
n.forEach((e) => {
|
|
2054
|
-
e.classList.remove(O), e.setAttribute("aria-selected", "false");
|
|
2055
|
-
}), r !== void 0 && (r.classList.add(O), r.setAttribute("aria-selected", "true"));
|
|
2056
|
-
}
|
|
2057
|
-
}, Pe = class {
|
|
2058
|
-
getClockSystem;
|
|
2059
|
-
styleHandler;
|
|
2060
|
-
getAmPmValue;
|
|
2061
|
-
clockType;
|
|
2062
|
-
constructor(e, t, n, r) {
|
|
2063
|
-
this.getClockSystem = e, this.styleHandler = t, this.getAmPmValue = n, this.clockType = r;
|
|
2064
|
-
}
|
|
2065
|
-
setMinutesToClock(e) {
|
|
2066
|
-
let t = this.getClockSystem();
|
|
2067
|
-
t && (this.styleHandler.removeBgColorToCirleWithMinutesTips(), e && t.setMinute(e), t.switchToMinutes());
|
|
2068
|
-
}
|
|
2069
|
-
setHoursToClock(e) {
|
|
2070
|
-
let t = this.getClockSystem();
|
|
2071
|
-
t && (e && t.setHour(e), t.switchToHours());
|
|
2072
|
-
}
|
|
2073
|
-
setTransformToCircleWithSwitchesHour(e) {
|
|
2074
|
-
let t = this.getClockSystem();
|
|
2075
|
-
!t || !e || t.setHour(e);
|
|
2076
|
-
}
|
|
2077
|
-
setTransformToCircleWithSwitchesMinutes(e) {
|
|
2078
|
-
let t = this.getClockSystem();
|
|
2079
|
-
!t || !e || t.setMinute(e);
|
|
2080
|
-
}
|
|
2081
|
-
updateAmPm() {
|
|
2082
|
-
let e = this.getClockSystem();
|
|
2083
|
-
if (!e || this.clockType === "24h") return;
|
|
2084
|
-
let t = this.getAmPmValue();
|
|
2085
|
-
t !== "" && e.setAmPm(t);
|
|
2086
|
-
}
|
|
2087
|
-
}, Fe = class {
|
|
2088
|
-
systemInitializer;
|
|
2089
|
-
styleHandler;
|
|
2090
|
-
timeHandler;
|
|
2091
|
-
eventHandler;
|
|
2092
|
-
constructor(e, t) {
|
|
2093
|
-
this.systemInitializer = new Me(e, t), this.styleHandler = new Ne(e);
|
|
2094
|
-
let n = e.options.clock.type || "12h";
|
|
2095
|
-
this.timeHandler = new Pe(() => this.systemInitializer.getClockSystem(), this.styleHandler, () => this.systemInitializer.getAmPmValue(), n), this.eventHandler = new Ce(t, () => this.systemInitializer.getClockSystem(), (e) => this.timeHandler.setHoursToClock(e), (e) => this.timeHandler.setMinutesToClock(e), () => this.timeHandler.updateAmPm(), () => this.systemInitializer.convertDisabledTime()), this.eventHandler.setup();
|
|
2096
|
-
}
|
|
2097
|
-
initializeClockSystem() {
|
|
2098
|
-
this.systemInitializer.initialize();
|
|
2099
|
-
}
|
|
2100
|
-
destroyClockSystem() {
|
|
2101
|
-
this.systemInitializer.destroy();
|
|
2102
|
-
}
|
|
2103
|
-
removeCircleClockClasses24h() {
|
|
2104
|
-
this.styleHandler.removeCircleClockClasses24h();
|
|
2105
|
-
}
|
|
2106
|
-
setCircleClockClasses24h() {
|
|
2107
|
-
this.styleHandler.setCircleClockClasses24h();
|
|
2108
|
-
}
|
|
2109
|
-
setOnStartCSSClassesIfClockType24h() {
|
|
2110
|
-
this.styleHandler.setOnStartCSSClassesIfClockType24h();
|
|
2111
|
-
}
|
|
2112
|
-
setBgColorToCircleWithMinutesTips = () => {
|
|
2113
|
-
this.styleHandler.setBgColorToCircleWithMinutesTips();
|
|
2114
|
-
};
|
|
2115
|
-
removeBgColorToCirleWithMinutesTips = () => {
|
|
2116
|
-
this.styleHandler.removeBgColorToCirleWithMinutesTips();
|
|
2117
|
-
};
|
|
2118
|
-
setClassActiveToHourOnOpen = () => {
|
|
2119
|
-
this.styleHandler.setClassActiveToHourOnOpen();
|
|
2120
|
-
};
|
|
2121
|
-
setMinutesToClock = (e) => {
|
|
2122
|
-
this.timeHandler.setMinutesToClock(e);
|
|
2123
|
-
};
|
|
2124
|
-
setHoursToClock = (e) => {
|
|
2125
|
-
this.timeHandler.setHoursToClock(e);
|
|
2126
|
-
};
|
|
2127
|
-
setTransformToCircleWithSwitchesHour = (e) => {
|
|
2128
|
-
this.timeHandler.setTransformToCircleWithSwitchesHour(e);
|
|
2129
|
-
};
|
|
2130
|
-
setTransformToCircleWithSwitchesMinutes = (e) => {
|
|
2131
|
-
this.timeHandler.setTransformToCircleWithSwitchesMinutes(e);
|
|
2132
|
-
};
|
|
2133
|
-
updateAmPm = () => {
|
|
2134
|
-
this.timeHandler.updateAmPm();
|
|
2135
|
-
};
|
|
2136
|
-
toggleClassActiveToValueTips = (e) => {
|
|
2137
|
-
let t = this.systemInitializer.getClockSystem() !== null;
|
|
2138
|
-
this.styleHandler.toggleClassActiveToValueTips(t, e);
|
|
2139
|
-
};
|
|
2140
|
-
destroy() {
|
|
2141
|
-
this.destroyClockSystem();
|
|
2142
|
-
}
|
|
2143
|
-
};
|
|
2144
|
-
function U(e, t, n, r) {
|
|
2145
|
-
e.on(n, r), t.push(() => e.off(n, r));
|
|
2146
|
-
}
|
|
2147
|
-
var Ie = class {
|
|
2148
|
-
core;
|
|
2149
|
-
emitter;
|
|
2150
|
-
cleanupHandlers = [];
|
|
2151
|
-
wasCleared = !1;
|
|
2152
|
-
constructor(e, t) {
|
|
2153
|
-
this.core = e, this.emitter = t;
|
|
2154
|
-
}
|
|
2155
|
-
init() {
|
|
2156
|
-
if (!this.core.options.ui.clearButton) return;
|
|
2157
|
-
let e = this.getClearButton();
|
|
2158
|
-
e && (this.cleanupHandlers.push(F(e, () => {
|
|
2159
|
-
this.core.isDestroyed || this.handleClearClick();
|
|
2160
|
-
})), this.setupInternalEventListeners());
|
|
2161
|
-
}
|
|
2162
|
-
setupInternalEventListeners() {
|
|
2163
|
-
U(this.emitter, this.cleanupHandlers, "update", () => {
|
|
2164
|
-
this.updateClearButtonState();
|
|
2165
|
-
}), U(this.emitter, this.cleanupHandlers, "open", () => {
|
|
2166
|
-
this.updateClearButtonState();
|
|
2167
|
-
}), U(this.emitter, this.cleanupHandlers, "select:hour", () => {
|
|
2168
|
-
this.updateClearButtonState(), this.reenableConfirmIfCleared();
|
|
2169
|
-
}), U(this.emitter, this.cleanupHandlers, "select:minute", () => {
|
|
2170
|
-
this.updateClearButtonState(), this.reenableConfirmIfCleared();
|
|
2171
|
-
});
|
|
2172
|
-
}
|
|
2173
|
-
handleClearClick() {
|
|
2174
|
-
let e = this.core.getInput()?.value || null;
|
|
2175
|
-
this.clearTimeValue(), this.resetClockToNeutral(), this.disableConfirmButton(), this.wasCleared = !0, M(this.core.getModalElement(), "Time cleared"), this.emitter.emit("clear", { previousValue: e }), this.emitter.emit("update", {
|
|
2176
|
-
hour: void 0,
|
|
2177
|
-
minutes: void 0,
|
|
2178
|
-
type: void 0
|
|
2179
|
-
});
|
|
2180
|
-
let { callbacks: t } = this.core.options;
|
|
2181
|
-
t.onClear && t.onClear({ previousValue: e });
|
|
2182
|
-
}
|
|
2183
|
-
clearTimeValue() {
|
|
2184
|
-
let e = this.core.options.clearBehavior?.clearInput !== !1, t = this.core.getInput();
|
|
2185
|
-
t && e && (t.value = ""), this.core.setDegreesHours(null), this.core.setDegreesMinutes(null);
|
|
2186
|
-
let n = h.getClearHandler("range");
|
|
2187
|
-
n && n(this.core, this.emitter);
|
|
2188
|
-
let r = h.getClearHandler("timezone");
|
|
2189
|
-
r && r(this.core, this.emitter);
|
|
2190
|
-
}
|
|
2191
|
-
resetClockToNeutral() {
|
|
2192
|
-
let e = this.core.options.clock.type, t = e === "12h" ? "PM" : void 0, n = this.core.getHour(), r = this.core.getMinutes();
|
|
2193
|
-
n && (n.value = "12", n.removeAttribute("aria-valuenow")), r && (r.value = "00", r.removeAttribute("aria-valuenow"));
|
|
2194
|
-
let i = this.core.getClockHand();
|
|
2195
|
-
if (i) {
|
|
2196
|
-
let e = i.style.transition;
|
|
2197
|
-
i.style.transition = "none", i.style.transform = "rotateZ(0deg)", i.offsetHeight, requestAnimationFrame(() => {
|
|
2198
|
-
i.style.transition = e;
|
|
2199
|
-
});
|
|
2200
|
-
}
|
|
2201
|
-
if (this.removeActiveStates(), n && n.click(), e === "12h" && t) {
|
|
2202
|
-
let e = this.core.getAM(), t = this.core.getPM();
|
|
2203
|
-
e?.classList.remove("active"), t?.classList.remove("active"), e?.setAttribute("aria-pressed", "false"), t?.setAttribute("aria-pressed", "false"), t?.classList.add("active"), t?.setAttribute("aria-pressed", "true");
|
|
2204
|
-
}
|
|
2205
|
-
this.emitter.emit("animation:clock", {});
|
|
2206
|
-
}
|
|
2207
|
-
removeActiveStates() {
|
|
2208
|
-
this.core.getAllValueTips().forEach((e) => {
|
|
2209
|
-
e.classList.remove("active"), e.removeAttribute("aria-selected");
|
|
2210
|
-
});
|
|
2211
|
-
let e = this.core.getHour(), t = this.core.getMinutes();
|
|
2212
|
-
e?.removeAttribute("aria-valuenow"), t?.removeAttribute("aria-valuenow");
|
|
2213
|
-
}
|
|
2214
|
-
disableConfirmButton() {
|
|
2215
|
-
let e = this.core.getOkButton();
|
|
2216
|
-
e && (e.classList.add("disabled"), e.setAttribute("aria-disabled", "true"));
|
|
2217
|
-
}
|
|
2218
|
-
updateClearButtonState() {
|
|
2219
|
-
let e = this.getClearButton();
|
|
2220
|
-
if (!e) return;
|
|
2221
|
-
let t = this.core.getInput(), n = t?.value && t.value.trim() !== "", r = this.core.getHour(), i = this.core.getMinutes(), a = this.core.getActiveTypeMode(), o = this.core.options.clock.type, s = r?.value || "", c = i?.value || "", l = a?.textContent || "", u = n || !(o === "12h" ? s === "12" && c === "00" && l === "PM" : s === "12" && c === "00");
|
|
2222
|
-
e.classList.toggle("disabled", !u), e.setAttribute("aria-disabled", String(!u));
|
|
2223
|
-
}
|
|
2224
|
-
reenableConfirmIfCleared() {
|
|
2225
|
-
if (!this.wasCleared) return;
|
|
2226
|
-
let e = this.core.getOkButton();
|
|
2227
|
-
e && (e.classList.remove("disabled"), e.setAttribute("aria-disabled", "false"), this.wasCleared = !1);
|
|
2228
|
-
}
|
|
2229
|
-
getClearButton() {
|
|
2230
|
-
return this.core.getModalElement()?.querySelector(".tp-ui-clear-btn") || null;
|
|
2231
|
-
}
|
|
2232
|
-
destroy() {
|
|
2233
|
-
this.cleanupHandlers.forEach((e) => e()), this.cleanupHandlers = [];
|
|
2234
|
-
}
|
|
2235
|
-
}, Le = class {
|
|
2236
|
-
animation;
|
|
2237
|
-
modal;
|
|
2238
|
-
config;
|
|
2239
|
-
theme;
|
|
2240
|
-
validation;
|
|
2241
|
-
events;
|
|
2242
|
-
clock;
|
|
2243
|
-
clearButton;
|
|
2244
|
-
plugins = /* @__PURE__ */ new Map();
|
|
2245
|
-
constructor(e, t) {
|
|
2246
|
-
this.animation = new i(e, t), this.modal = new oe(e, t), this.config = new fe(e, t), this.theme = new pe(e, t), this.validation = new he(e, t), this.events = new Se(e, t), this.clock = new Fe(e, t), this.clearButton = new Ie(e, t), h.getAll().forEach((n) => {
|
|
2247
|
-
let r = n.factory(e, t);
|
|
2248
|
-
this.plugins.set(n.name, r);
|
|
2249
|
-
});
|
|
2250
|
-
}
|
|
2251
|
-
getPlugin(e) {
|
|
2252
|
-
return this.plugins.get(e);
|
|
2253
|
-
}
|
|
2254
|
-
destroy() {
|
|
2255
|
-
this.animation.destroy(), this.modal.destroy(), this.config.destroy(), this.theme.destroy(), this.validation.destroy(), this.events.destroy(), this.clock.destroy(), this.clearButton.destroy(), this.plugins.forEach((e) => e.destroy()), this.plugins.clear();
|
|
2256
|
-
}
|
|
2257
|
-
}, W = "is-rippling", G = "ripple-hold", K = null;
|
|
2258
|
-
function Re(e) {
|
|
2259
|
-
let t = e.target, n = t.hasAttribute("data-md3-ripple") ? t : t.closest("[data-md3-ripple]");
|
|
2260
|
-
if (!n || e.button !== 0 && e.pointerType === "mouse") return;
|
|
2261
|
-
let r = n.getBoundingClientRect(), i = Math.max(r.width, r.height) * 2, a = e.clientX - r.left, o = e.clientY - r.top;
|
|
2262
|
-
n.style.setProperty("--ripple-size", `${i}px`), n.style.setProperty("--ripple-x", `${a}px`), n.style.setProperty("--ripple-y", `${o}px`), n.classList.remove(W, G), n.offsetWidth, n.classList.add(W, G), n._rippleHold = !0, K = n;
|
|
2263
|
-
}
|
|
2264
|
-
function q(e) {
|
|
2265
|
-
let t = e.target, n = (t.hasAttribute("data-md3-ripple") ? t : t.closest("[data-md3-ripple]")) || K;
|
|
2266
|
-
n && (n._rippleHold = !1, n.classList.remove(G), setTimeout(() => {
|
|
2267
|
-
n.classList.remove(W), K === n && (K = null);
|
|
2268
|
-
}, 1e3));
|
|
2269
|
-
}
|
|
2270
|
-
function ze(e) {
|
|
2271
|
-
let t = e.currentTarget;
|
|
2272
|
-
!t || !t._rippleHold || (t._rippleHold = !1, t.classList.remove(G), setTimeout(() => {
|
|
2273
|
-
t.classList.remove(W), K === t && (K = null);
|
|
2274
|
-
}, 1e3));
|
|
2275
|
-
}
|
|
2276
|
-
function Be(e) {
|
|
2277
|
-
if (t() === !1) return;
|
|
2278
|
-
let n = e || document;
|
|
2279
|
-
n.addEventListener("pointerdown", Re), n.addEventListener("pointerup", q), n.addEventListener("pointercancel", q), n.querySelectorAll("[data-md3-ripple]").forEach((e) => {
|
|
2280
|
-
e.addEventListener("mouseleave", ze);
|
|
2281
|
-
});
|
|
2282
|
-
}
|
|
2283
|
-
var Ve = (e, t) => {
|
|
2284
|
-
let n;
|
|
2285
|
-
return (...r) => {
|
|
2286
|
-
clearTimeout(n), n = setTimeout(() => {
|
|
2287
|
-
e(...r);
|
|
2288
|
-
}, t);
|
|
2289
|
-
};
|
|
2290
|
-
};
|
|
2291
|
-
function J(e) {
|
|
2292
|
-
let t = e.ui.mode;
|
|
2293
|
-
return t === "wheel" || t === "compact-wheel";
|
|
2294
|
-
}
|
|
2295
|
-
function Y(e) {
|
|
2296
|
-
return e.ui.mode === "compact-wheel";
|
|
2297
|
-
}
|
|
2298
|
-
function X(e) {
|
|
2299
|
-
return Y(e) && !!e.wheel?.placement;
|
|
2300
|
-
}
|
|
2301
|
-
var He = [
|
|
2302
|
-
["onOpen", "open"],
|
|
2303
|
-
["onCancel", "cancel"],
|
|
2304
|
-
["onConfirm", "confirm"],
|
|
2305
|
-
["onUpdate", "update"],
|
|
2306
|
-
["onSelectHour", "select:hour"],
|
|
2307
|
-
["onSelectMinute", "select:minute"],
|
|
2308
|
-
["onSelectAM", "select:am"],
|
|
2309
|
-
["onSelectPM", "select:pm"],
|
|
2310
|
-
["onError", "error"],
|
|
2311
|
-
["onTimezoneChange", "timezone:change"],
|
|
2312
|
-
["onRangeConfirm", "range:confirm"],
|
|
2313
|
-
["onRangeSwitch", "range:switch"],
|
|
2314
|
-
["onRangeValidation", "range:validation"],
|
|
2315
|
-
["onClear", "clear"]
|
|
2316
|
-
], Ue = [
|
|
2317
|
-
{
|
|
2318
|
-
needed: (e) => e.ui.mode === "wheel" || e.ui.mode === "compact-wheel",
|
|
2319
|
-
name: "wheel",
|
|
2320
|
-
message: "WheelPlugin is not registered. Import and register it: PluginRegistry.register(WheelPlugin)"
|
|
2321
|
-
},
|
|
2322
|
-
{
|
|
2323
|
-
needed: (e) => !!e.range?.enabled,
|
|
2324
|
-
name: "range",
|
|
2325
|
-
message: "RangePlugin is not registered. Import and register it: PluginRegistry.register(RangePlugin)"
|
|
2326
|
-
},
|
|
2327
|
-
{
|
|
2328
|
-
needed: (e) => !!e.timezone?.enabled,
|
|
2329
|
-
name: "timezone",
|
|
2330
|
-
message: "TimezonePlugin is not registered. Import and register it: PluginRegistry.register(TimezonePlugin)"
|
|
2331
|
-
}
|
|
2332
|
-
];
|
|
2333
|
-
function We(e, t) {
|
|
2334
|
-
let { callbacks: n } = e.options;
|
|
2335
|
-
for (let [e, r] of He) {
|
|
2336
|
-
let i = n[e];
|
|
2337
|
-
i && t.on(r, i);
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
function Ge(e, t) {
|
|
2341
|
-
for (let n of Ue) n.needed(e.options) && !h.has(n.name) && t.emit("error", { error: n.message });
|
|
2342
|
-
}
|
|
2343
|
-
var Ke = class e {
|
|
2344
|
-
static EXPANDED_EXCLUDED = [
|
|
2345
|
-
"tp-ui-select-time",
|
|
2346
|
-
"tp-ui-mobile-clock-wrapper",
|
|
2347
|
-
"tp-ui-wrapper"
|
|
2348
|
-
];
|
|
2349
|
-
core;
|
|
2350
|
-
managers;
|
|
2351
|
-
emitter;
|
|
2352
|
-
eventsClickMobileHandler = () => {};
|
|
2353
|
-
mutliEventsMoveHandler = () => {};
|
|
2354
|
-
unmountTimeouts = [];
|
|
2355
|
-
constructor(e, t, n) {
|
|
2356
|
-
this.core = e, this.managers = t, this.emitter = n;
|
|
2357
|
-
}
|
|
2358
|
-
init() {
|
|
2359
|
-
if (!this.core.isDestroyed && !this.core.isInitialized) {
|
|
2360
|
-
try {
|
|
2361
|
-
this.managers.config.updateInputValueWithCurrentTimeOnStart(), this.managers.validation.checkDisabledValuesOnStart();
|
|
2362
|
-
} catch {
|
|
2363
|
-
this.core.setIsDestroyed(!0);
|
|
2364
|
-
return;
|
|
2365
|
-
}
|
|
2366
|
-
this.managers.theme.setTimepickerClassToElement(), this.managers.theme.setInputClassToInputElement(), this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(), this.managers.theme.setClassTopOpenElement(), this.managers.config.getDisableTime(), this.core.options.ui.inline?.enabled || this.managers.events.handleOpenOnClick(), this.managers.events.handleOpenOnEnterFocus(), We(this.core, this.emitter), this.core.setIsInitialized(!0);
|
|
2367
|
-
}
|
|
2368
|
-
}
|
|
2369
|
-
mount() {
|
|
2370
|
-
this.core.isDestroyed || this.core.isOpen || (this.core.isInitialized || this.init(), this.eventsBundle());
|
|
2371
|
-
}
|
|
2372
|
-
unmount(e) {
|
|
2373
|
-
let t = Ve((...e) => {
|
|
2374
|
-
if (e.length > 2) return;
|
|
2375
|
-
let [t] = e.filter((e) => typeof e == "boolean"), [n] = e.filter((e) => typeof e == "function");
|
|
2376
|
-
this.core.setIsMobileView(!!this.core.options.ui.mobile);
|
|
2377
|
-
let i = this.core.getModalElement();
|
|
2378
|
-
t && i && this.core.getOkButton()?.click(), this.core.setIsTouchMouseMove(!1), this.core.setIsOpen(!1), this.removeEventListeners(), X(this.core.options) && this.managers.getPlugin("wheel")?.detachPopover?.(), i && this.managers.animation.removeAnimationToClose(), this.core.getOpenElement().forEach((e) => e?.classList.remove("disabled"));
|
|
2379
|
-
let a = setTimeout(() => {
|
|
2380
|
-
this.managers.modal.unlockScroll();
|
|
2381
|
-
}, r.SCROLLBAR_RESTORE);
|
|
2382
|
-
this.unmountTimeouts.push(a);
|
|
2383
|
-
let o = setTimeout(() => {
|
|
2384
|
-
let e = this.core.getInput();
|
|
2385
|
-
this.core.options.behavior.focusInputAfterClose && e?.focus();
|
|
2386
|
-
let t = this.core.getModalElement();
|
|
2387
|
-
t && t.remove(), this.core.setIsModalRemove(!0);
|
|
2388
|
-
}, r.MODAL_REMOVE);
|
|
2389
|
-
this.unmountTimeouts.push(o), n && n();
|
|
2390
|
-
}, this.core.options.behavior.delayHandler || r.DEFAULT_DELAY);
|
|
2391
|
-
e ? t(e) : t();
|
|
2392
|
-
}
|
|
2393
|
-
destroy(e) {
|
|
2394
|
-
if (this.core.isDestroyed) return;
|
|
2395
|
-
this.clearUnmountTimeouts();
|
|
2396
|
-
let { keepInputValue: t = !1, callback: n } = typeof e == "function" ? { callback: e } : e || {}, r = this.core.getInput(), i = t ? r?.value : null;
|
|
2397
|
-
this.removeEventListeners(), this.core.getModalElement()?.remove(), this.core.getOpenElement()?.forEach((e) => {
|
|
2398
|
-
e && e.classList.remove("disabled", "active", "tp-ui-open-element");
|
|
2399
|
-
}), r && (r.classList.remove("tp-ui-invalid-format", "invalid-value", "error", "active", "tp-ui-input"), r.removeAttribute("data-open"), r.removeAttribute("data-owner-id"), t && i && (r.value = i));
|
|
2400
|
-
let a = this.core.element;
|
|
2401
|
-
a && (a.classList.remove("error", "active", "disabled"), a.removeAttribute("data-owner-id"), a.removeAttribute("data-open"), this.core.options.ui.cssClass && a.classList.remove(this.core.options.ui.cssClass)), a?.querySelectorAll(".tp-ui-invalid-text")?.forEach((e) => e.remove()), this.mutliEventsMoveHandler = () => {}, this.eventsClickMobileHandler = () => {}, this.core.reset(), this.managers.destroy(), this.emitter.clear(), this.managers.modal.unlockScroll(), n && n();
|
|
2402
|
-
}
|
|
2403
|
-
eventsBundle() {
|
|
2404
|
-
if (this.core.isDestroyed || !this.core.isModalRemove) return;
|
|
2405
|
-
this.clearUnmountTimeouts(), this.core.setIsOpen(!0), this.core.setIsModalRemove(!1), this.setupValidation(), this.disableOpenElements(), this.setupModal(), this.applyExpandedState(), this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(), this.applyThemeDeferred(), this.managers.animation.setAnimationToOpen(), this.managers.config.getInputValueOnOpenAndSet();
|
|
2406
|
-
let e = J(this.core.options) && h.has("wheel");
|
|
2407
|
-
Ge(this.core, this.emitter), this.initClockOrWheel(e), this.initOptionalPlugins(e), this.bindEventHandlers(e), this.finalizeModal(e), X(this.core.options) && this.managers.getPlugin("wheel")?.attachPopover?.(), this.managers.modal.setShowClassToBackdrop();
|
|
2408
|
-
}
|
|
2409
|
-
setupValidation() {
|
|
2410
|
-
this.managers.validation.setErrorHandler(), this.managers.validation.removeErrorHandler();
|
|
2411
|
-
}
|
|
2412
|
-
disableOpenElements() {
|
|
2413
|
-
this.core.options.ui.inline?.enabled || (this.core.getOpenElement().forEach((e) => e?.classList.add("disabled")), X(this.core.options) || this.core.getInput()?.blur());
|
|
2414
|
-
}
|
|
2415
|
-
setupModal() {
|
|
2416
|
-
this.managers.modal.setScrollbarOrNot(), this.managers.modal.setModalTemplate(), this.managers.modal.setNormalizeClass(), this.managers.modal.removeBackdrop();
|
|
2417
|
-
}
|
|
2418
|
-
applyExpandedState() {
|
|
2419
|
-
if (this.core.isMobileView) {
|
|
2420
|
-
this.managers.config.updateClockFaceAccessibility(!0);
|
|
2421
|
-
return;
|
|
2422
|
-
}
|
|
2423
|
-
let t = this.core.getModalElement();
|
|
2424
|
-
t && (t.querySelector(".tp-ui-mobile-clock-wrapper")?.classList.add("expanded"), t.querySelector(".tp-ui-wrapper")?.classList.add("expanded"), t.querySelectorAll("*").forEach((t) => {
|
|
2425
|
-
e.EXPANDED_EXCLUDED.some((e) => t.classList.contains(e)) || t.classList.add("expanded");
|
|
2426
|
-
}));
|
|
2427
|
-
}
|
|
2428
|
-
applyThemeDeferred() {
|
|
2429
|
-
let e = setTimeout(() => {
|
|
2430
|
-
this.managers.theme.setTheme();
|
|
2431
|
-
let e = this.core.getWrapper();
|
|
2432
|
-
e && this.core.options.ui.cssClass && e.classList.add(this.core.options.ui.cssClass);
|
|
2433
|
-
}, 0);
|
|
2434
|
-
this.unmountTimeouts.push(e);
|
|
2435
|
-
}
|
|
2436
|
-
initClockOrWheel(e) {
|
|
2437
|
-
if (e) {
|
|
2438
|
-
let e = this.managers.getPlugin("wheel");
|
|
2439
|
-
e && e.init();
|
|
2440
|
-
} else this.managers.clock.initializeClockSystem(), this.managers.clock.setOnStartCSSClassesIfClockType24h(), this.managers.clock.setClassActiveToHourOnOpen();
|
|
2441
|
-
}
|
|
2442
|
-
initOptionalPlugins(e) {
|
|
2443
|
-
let t = this.managers.getPlugin("timezone");
|
|
2444
|
-
t && t.init();
|
|
2445
|
-
let n = this.managers.getPlugin("range");
|
|
2446
|
-
n && !e && n.init();
|
|
2447
|
-
}
|
|
2448
|
-
bindEventHandlers(e) {
|
|
2449
|
-
this.managers.events.handleCancelButton(), this.managers.events.handleOkButton(), this.managers.clearButton.init(), e || (this.managers.events.handleHourEvents(), this.managers.events.handleMinutesEvents()), this.managers.events.handleKeyboardInput(), this.core.options.ui.enableSwitchIcon && !e && this.managers.events.handleSwitchViewButton(), this.core.options.clock.type !== "24h" && !Y(this.core.options) && (this.managers.events.handleAmClick(), this.managers.events.handlePmClick()), this.core.options.behavior.focusTrap && this.managers.events.focusTrapHandler(), this.core.options.ui.inline?.enabled || (this.managers.events.handleEscClick(), X(this.core.options) || e && this.core.options.wheel?.ignoreOutsideClick || this.managers.events.handleBackdropClick());
|
|
2450
|
-
}
|
|
2451
|
-
finalizeModal(e) {
|
|
2452
|
-
let t = this.core.getModalElement();
|
|
2453
|
-
if (t && Be(t), !e) {
|
|
2454
|
-
let e = this.core.getClockFace();
|
|
2455
|
-
e && typeof requestAnimationFrame < "u" && requestAnimationFrame(() => {
|
|
2456
|
-
requestAnimationFrame(() => {
|
|
2457
|
-
e?.classList.add("scale-in");
|
|
2458
|
-
});
|
|
2459
|
-
});
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
clearUnmountTimeouts() {
|
|
2463
|
-
this.unmountTimeouts.forEach(clearTimeout), this.unmountTimeouts = [];
|
|
2464
|
-
}
|
|
2465
|
-
removeEventListeners() {
|
|
2466
|
-
t() !== !1 && (se.split(" ").forEach((e) => {
|
|
2467
|
-
document.removeEventListener(e, this.mutliEventsMoveHandler, !1);
|
|
2468
|
-
}), document.removeEventListener("mousedown", this.eventsClickMobileHandler));
|
|
2469
|
-
}
|
|
2470
|
-
}, Z = class {
|
|
2471
|
-
events = /* @__PURE__ */ new Map();
|
|
2472
|
-
on(e, t) {
|
|
2473
|
-
this.events.has(e) || this.events.set(e, /* @__PURE__ */ new Set()), this.events.get(e).add(t);
|
|
2474
|
-
}
|
|
2475
|
-
once(e, t) {
|
|
2476
|
-
let n = (r) => {
|
|
2477
|
-
t(r), this.events.get(e)?.delete(n);
|
|
2478
|
-
};
|
|
2479
|
-
n.__originalHandler = t, this.on(e, n);
|
|
2480
|
-
}
|
|
2481
|
-
off(e, t) {
|
|
2482
|
-
if (!t) {
|
|
2483
|
-
this.events.delete(e);
|
|
2484
|
-
return;
|
|
2485
|
-
}
|
|
2486
|
-
let n = this.events.get(e);
|
|
2487
|
-
n && n.forEach((e) => {
|
|
2488
|
-
(e === t || e.__originalHandler === t) && n.delete(e);
|
|
2489
|
-
});
|
|
2490
|
-
}
|
|
2491
|
-
emit(e, t) {
|
|
2492
|
-
let n = this.events.get(e);
|
|
2493
|
-
n && [...n].forEach((e) => {
|
|
2494
|
-
e(t);
|
|
2495
|
-
});
|
|
2496
|
-
}
|
|
2497
|
-
clear() {
|
|
2498
|
-
this.events.clear();
|
|
2499
|
-
}
|
|
2500
|
-
hasListeners(e) {
|
|
2501
|
-
return (this.events.get(e)?.size ?? 0) > 0;
|
|
2502
|
-
}
|
|
2503
|
-
}, Q = {
|
|
2504
|
-
clock: {
|
|
2505
|
-
type: "12h",
|
|
2506
|
-
incrementHours: 1,
|
|
2507
|
-
incrementMinutes: 1,
|
|
2508
|
-
autoSwitchToMinutes: !0,
|
|
2509
|
-
disabledTime: void 0,
|
|
2510
|
-
currentTime: void 0
|
|
2511
|
-
},
|
|
2512
|
-
ui: {
|
|
2513
|
-
mode: "clock",
|
|
2514
|
-
theme: "basic",
|
|
2515
|
-
animation: !0,
|
|
2516
|
-
backdrop: !0,
|
|
2517
|
-
mobile: !1,
|
|
2518
|
-
enableSwitchIcon: !1,
|
|
2519
|
-
editable: !1,
|
|
2520
|
-
enableScrollbar: !1,
|
|
2521
|
-
cssClass: void 0,
|
|
2522
|
-
appendModalSelector: "",
|
|
2523
|
-
iconTemplate: "",
|
|
2524
|
-
iconTemplateMobile: "",
|
|
2525
|
-
inline: void 0,
|
|
2526
|
-
clearButton: !1
|
|
2527
|
-
},
|
|
2528
|
-
labels: {
|
|
2529
|
-
am: "AM",
|
|
2530
|
-
pm: "PM",
|
|
2531
|
-
ok: "OK",
|
|
2532
|
-
cancel: "Cancel",
|
|
2533
|
-
time: "Select time",
|
|
2534
|
-
mobileTime: "Enter Time",
|
|
2535
|
-
mobileHour: "Hour",
|
|
2536
|
-
mobileMinute: "Minute",
|
|
2537
|
-
clear: "Clear",
|
|
2538
|
-
hourLabel: "Hour",
|
|
2539
|
-
minuteLabel: "Minute",
|
|
2540
|
-
clockLabel: "Clock",
|
|
2541
|
-
periodLabel: "Period",
|
|
2542
|
-
timeLabel: "Time",
|
|
2543
|
-
format24Label: "24-hour",
|
|
2544
|
-
rangeSelectionLabel: "Range selection",
|
|
2545
|
-
switchToKeyboardLabel: "Switch to keyboard input",
|
|
2546
|
-
switchToClockLabel: "Switch to clock",
|
|
2547
|
-
toggleLabel: "Toggle",
|
|
2548
|
-
timezoneSelectorLabel: "Timezone",
|
|
2549
|
-
announceHour: "Hour",
|
|
2550
|
-
announceMinute: "Minutes",
|
|
2551
|
-
announceAmSelected: "AM selected",
|
|
2552
|
-
announcePmSelected: "PM selected",
|
|
2553
|
-
invalidTimeFormat: "Invalid time format"
|
|
2554
|
-
},
|
|
2555
|
-
behavior: {
|
|
2556
|
-
focusInputAfterClose: !1,
|
|
2557
|
-
focusTrap: !0,
|
|
2558
|
-
delayHandler: 300,
|
|
2559
|
-
id: void 0
|
|
2560
|
-
},
|
|
2561
|
-
callbacks: {
|
|
2562
|
-
onOpen: void 0,
|
|
2563
|
-
onCancel: void 0,
|
|
2564
|
-
onConfirm: void 0,
|
|
2565
|
-
onUpdate: void 0,
|
|
2566
|
-
onSelectHour: void 0,
|
|
2567
|
-
onSelectMinute: void 0,
|
|
2568
|
-
onSelectAM: void 0,
|
|
2569
|
-
onSelectPM: void 0,
|
|
2570
|
-
onError: void 0,
|
|
2571
|
-
onTimezoneChange: void 0,
|
|
2572
|
-
onRangeConfirm: void 0,
|
|
2573
|
-
onRangeSwitch: void 0,
|
|
2574
|
-
onRangeValidation: void 0,
|
|
2575
|
-
onClear: void 0
|
|
2576
|
-
},
|
|
2577
|
-
timezone: {
|
|
2578
|
-
enabled: !1,
|
|
2579
|
-
default: void 0,
|
|
2580
|
-
whitelist: void 0,
|
|
2581
|
-
label: "Timezone"
|
|
2582
|
-
},
|
|
2583
|
-
range: {
|
|
2584
|
-
enabled: !1,
|
|
2585
|
-
minDuration: void 0,
|
|
2586
|
-
maxDuration: void 0,
|
|
2587
|
-
fromLabel: "From",
|
|
2588
|
-
toLabel: "To"
|
|
2589
|
-
},
|
|
2590
|
-
wheel: {
|
|
2591
|
-
placement: void 0,
|
|
2592
|
-
hideFooter: void 0,
|
|
2593
|
-
commitOnScroll: void 0,
|
|
2594
|
-
hideDisabled: void 0,
|
|
2595
|
-
ignoreOutsideClick: void 0
|
|
2596
|
-
},
|
|
2597
|
-
clearBehavior: { clearInput: !0 }
|
|
2598
|
-
};
|
|
2599
|
-
function qe(e = {}) {
|
|
2600
|
-
let t = {
|
|
2601
|
-
clock: {
|
|
2602
|
-
...Q.clock,
|
|
2603
|
-
...e.clock
|
|
2604
|
-
},
|
|
2605
|
-
ui: {
|
|
2606
|
-
...Q.ui,
|
|
2607
|
-
...e.ui
|
|
2608
|
-
},
|
|
2609
|
-
labels: {
|
|
2610
|
-
...Q.labels,
|
|
2611
|
-
...e.labels
|
|
2612
|
-
},
|
|
2613
|
-
behavior: {
|
|
2614
|
-
...Q.behavior,
|
|
2615
|
-
...e.behavior
|
|
2616
|
-
},
|
|
2617
|
-
callbacks: {
|
|
2618
|
-
...Q.callbacks,
|
|
2619
|
-
...e.callbacks
|
|
2620
|
-
},
|
|
2621
|
-
timezone: {
|
|
2622
|
-
...Q.timezone,
|
|
2623
|
-
...e.timezone
|
|
2624
|
-
},
|
|
2625
|
-
range: {
|
|
2626
|
-
...Q.range,
|
|
2627
|
-
...e.range
|
|
2628
|
-
},
|
|
2629
|
-
wheel: {
|
|
2630
|
-
...Q.wheel,
|
|
2631
|
-
...e.wheel
|
|
2632
|
-
},
|
|
2633
|
-
clearBehavior: {
|
|
2634
|
-
...Q.clearBehavior,
|
|
2635
|
-
...e.clearBehavior
|
|
2636
|
-
}
|
|
2637
|
-
}, n = t.ui.mode;
|
|
2638
|
-
return (n === "wheel" || n === "compact-wheel") && (t.wheel = {
|
|
2639
|
-
placement: n === "compact-wheel" ? "auto" : void 0,
|
|
2640
|
-
hideFooter: void 0,
|
|
2641
|
-
commitOnScroll: void 0,
|
|
2642
|
-
ignoreOutsideClick: void 0,
|
|
2643
|
-
...t.wheel
|
|
2644
|
-
}), t;
|
|
2645
|
-
}
|
|
2646
|
-
var Je = (e) => e.replace(/[^0-9:APMapm\s]/g, "");
|
|
2647
|
-
function Ye(e, t) {
|
|
2648
|
-
if (e.options.clock.type === "24h") {
|
|
2649
|
-
let e = De(t);
|
|
2650
|
-
if (!e) throw Error("Invalid 24h format. Expected HH:MM");
|
|
2651
|
-
return {
|
|
2652
|
-
hourValue: e.hour.padStart(2, "0"),
|
|
2653
|
-
minutesValue: e.minutes,
|
|
2654
|
-
typeValue: "AM"
|
|
2655
|
-
};
|
|
2656
|
-
}
|
|
2657
|
-
let n = Ee(t);
|
|
2658
|
-
if (!n) throw Error("Invalid 12h format. Expected HH:MM AM/PM");
|
|
2659
|
-
return {
|
|
2660
|
-
hourValue: n.hour,
|
|
2661
|
-
minutesValue: n.minutes,
|
|
2662
|
-
typeValue: n.type
|
|
2663
|
-
};
|
|
2664
|
-
}
|
|
2665
|
-
function Xe(e, t) {
|
|
2666
|
-
let n = e.getHour(), r = e.getMinutes();
|
|
2667
|
-
n && (n.value = t.hourValue, n.setAttribute("aria-valuenow", t.hourValue), e.setDegreesHours(Number(t.hourValue) * 30)), r && (r.value = t.minutesValue, r.setAttribute("aria-valuenow", t.minutesValue), e.setDegreesMinutes(Number(t.minutesValue) * 6));
|
|
2668
|
-
}
|
|
2669
|
-
function Ze(e, t) {
|
|
2670
|
-
if (e.options.clock.type === "24h") return;
|
|
2671
|
-
let n = e.getAM(), r = e.getPM();
|
|
2672
|
-
!n || !r || (t === "AM" ? (n.classList.add("active"), r.classList.remove("active")) : (r.classList.add("active"), n.classList.remove("active")));
|
|
2673
|
-
}
|
|
2674
|
-
function Qe(e, t, n) {
|
|
2675
|
-
if (J(e.options)) t.getPlugin("wheel")?.scrollToValue?.(n.hourValue, n.minutesValue, n.typeValue);
|
|
2676
|
-
else {
|
|
2677
|
-
let t = e.getClockHand();
|
|
2678
|
-
t && (t.style.transform = `rotateZ(${e.degreesHours || 0}deg)`);
|
|
2679
|
-
}
|
|
2680
|
-
}
|
|
2681
|
-
var $ = /* @__PURE__ */ new Map(), $e = class {
|
|
2682
|
-
core;
|
|
2683
|
-
managers;
|
|
2684
|
-
lifecycle;
|
|
2685
|
-
emitter;
|
|
2686
|
-
constructor(t, r) {
|
|
2687
|
-
if (e()) throw Error("TimepickerUI requires browser environment");
|
|
2688
|
-
let i = this.resolveInputElement(t);
|
|
2689
|
-
if (!i) throw Error("Input element not found");
|
|
2690
|
-
let a = r?.behavior?.id, o = a || `tp-ui-${f()}`, s = this.createWrapperElement(i), c = qe(r || {});
|
|
2691
|
-
if (c.ui.inline?.enabled && typeof r?.behavior?.focusTrap > "u" && (c.behavior.focusTrap = !1), c.ui.inline?.enabled) {
|
|
2692
|
-
if (!c.ui.inline.containerId) throw Error("inline.containerId is required when inline mode is enabled");
|
|
2693
|
-
if (!e() && !document.getElementById(c.ui.inline.containerId)) throw Error(`Container element with id "${c.ui.inline.containerId}" not found`);
|
|
2694
|
-
}
|
|
2695
|
-
this.emitter = new Z(), this.core = new n(s, c, o, a);
|
|
2696
|
-
let l = this.core.getInput();
|
|
2697
|
-
if (l) {
|
|
2698
|
-
let e = T(l, c.clock.type), t = Number(e.hour) * 30, n = Number(e.minutes) * 6;
|
|
2699
|
-
this.core.setDegreesHours(t), this.core.setDegreesMinutes(n);
|
|
2700
|
-
}
|
|
2701
|
-
this.managers = new Le(this.core, this.emitter), this.lifecycle = new Ke(this.core, this.managers, this.emitter), this.managers.config.checkMobileOption(), this.managers.config.preventClockTypeByCurrentTime(), this.setupInternalEventListeners(), $.set(this.core.instanceId, this);
|
|
2702
|
-
}
|
|
2703
|
-
setupInternalEventListeners() {
|
|
2704
|
-
this.emitter.on("show", () => {
|
|
2705
|
-
this.core.isDestroyed || this.lifecycle.mount();
|
|
2706
|
-
}), this.emitter.on("cancel", () => {
|
|
2707
|
-
this.core.isDestroyed || this.lifecycle.unmount();
|
|
2708
|
-
}), this.emitter.on("confirm", (e) => {
|
|
2709
|
-
if (!this.core.isDestroyed) {
|
|
2710
|
-
if (this.core.options.range?.enabled) return;
|
|
2711
|
-
let t = this.core.getInput();
|
|
2712
|
-
if (t && e.hour && e.minutes) {
|
|
2713
|
-
let n = e.type ? ` ${e.type}` : "";
|
|
2714
|
-
t.value = `${e.hour}:${e.minutes}${n}`;
|
|
2715
|
-
}
|
|
2716
|
-
e.autoCommit || this.lifecycle.unmount();
|
|
2717
|
-
}
|
|
2718
|
-
}), this.emitter.on("range:confirm", (e) => {
|
|
2719
|
-
if (this.core.isDestroyed) return;
|
|
2720
|
-
let t = this.core.getInput();
|
|
2721
|
-
t && (t.value = `${e.from} - ${e.to}`), this.lifecycle.unmount();
|
|
2722
|
-
});
|
|
2723
|
-
}
|
|
2724
|
-
create() {
|
|
2725
|
-
this.lifecycle.init(), this.core.options.ui.inline?.enabled && this.lifecycle.mount();
|
|
2726
|
-
}
|
|
2727
|
-
open(e) {
|
|
2728
|
-
this.lifecycle.mount(), e && e();
|
|
2729
|
-
}
|
|
2730
|
-
close(e, t) {
|
|
2731
|
-
this.lifecycle.unmount(e ? t : void 0), !e && t && t();
|
|
2732
|
-
}
|
|
2733
|
-
destroy(e) {
|
|
2734
|
-
$.delete(this.core.instanceId), this.lifecycle.destroy(e);
|
|
2735
|
-
}
|
|
2736
|
-
update(e, t) {
|
|
2737
|
-
this.core.isDestroyed || (this.core.updateOptions(e.options), this.managers.config.checkMobileOption(), this.managers.config.getDisableTime(), e.create && this.create(), t && t());
|
|
2738
|
-
}
|
|
2739
|
-
getValue() {
|
|
2740
|
-
if (this.core.isDestroyed) return {
|
|
2741
|
-
hour: "",
|
|
2742
|
-
minutes: "",
|
|
2743
|
-
type: void 0,
|
|
2744
|
-
time: "",
|
|
2745
|
-
degreesHours: null,
|
|
2746
|
-
degreesMinutes: null
|
|
2747
|
-
};
|
|
2748
|
-
let e = this.core.getModalElement(), t = this.core.getInput(), n = "12", r = "00", i = this.core.options.clock.type === "24h" ? void 0 : "AM", a = null, o = null;
|
|
2749
|
-
if (e) {
|
|
2750
|
-
let e = this.core.getHour(), t = this.core.getMinutes(), s = this.core.getActiveTypeMode();
|
|
2751
|
-
n = e?.value || "12", r = t?.value || "00", i = this.core.options.clock.type === "24h" ? void 0 : s?.textContent || "AM", a = this.core.degreesHours, o = this.core.degreesMinutes;
|
|
2752
|
-
} else if (t) {
|
|
2753
|
-
let e = T(t, this.core.options.clock.type);
|
|
2754
|
-
n = e.hour, r = e.minutes, i = e.type, a = Number(n) * 30, o = Number(r) * 6;
|
|
2755
|
-
}
|
|
2756
|
-
let s = "";
|
|
2757
|
-
return s = this.core.options.clock.type === "24h" ? `${n.padStart(2, "0")}:${r.padStart(2, "0")}` : `${n}:${r.padStart(2, "0")} ${i}`, {
|
|
2758
|
-
hour: n,
|
|
2759
|
-
minutes: r,
|
|
2760
|
-
type: i,
|
|
2761
|
-
time: s,
|
|
2762
|
-
degreesHours: a,
|
|
2763
|
-
degreesMinutes: o
|
|
2764
|
-
};
|
|
2765
|
-
}
|
|
2766
|
-
setValue(e, t = !0) {
|
|
2767
|
-
if (this.core.isDestroyed || !e || typeof e != "string") return;
|
|
2768
|
-
this.core.isInitialized || this.create();
|
|
2769
|
-
let n = Je(e.trim());
|
|
2770
|
-
try {
|
|
2771
|
-
let e = Ye(this.core, n);
|
|
2772
|
-
if (Xe(this.core, e), Ze(this.core, e.typeValue), t) {
|
|
2773
|
-
let e = this.core.getInput();
|
|
2774
|
-
e && (e.value = n);
|
|
2775
|
-
}
|
|
2776
|
-
Qe(this.core, this.managers, e);
|
|
2777
|
-
} catch {
|
|
2778
|
-
return;
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
getElement() {
|
|
2782
|
-
return this.core.element;
|
|
2783
|
-
}
|
|
2784
|
-
get instanceId() {
|
|
2785
|
-
return this.core.instanceId;
|
|
2786
|
-
}
|
|
2787
|
-
get options() {
|
|
2788
|
-
return this.core.options;
|
|
2789
|
-
}
|
|
2790
|
-
get isInitialized() {
|
|
2791
|
-
return this.core.isInitialized;
|
|
2792
|
-
}
|
|
2793
|
-
get isDestroyed() {
|
|
2794
|
-
return this.core.isDestroyed;
|
|
2795
|
-
}
|
|
2796
|
-
get hour() {
|
|
2797
|
-
return this.core.getHour();
|
|
2798
|
-
}
|
|
2799
|
-
get minutes() {
|
|
2800
|
-
return this.core.getMinutes();
|
|
2801
|
-
}
|
|
2802
|
-
get okButton() {
|
|
2803
|
-
return this.core.getOkButton();
|
|
2804
|
-
}
|
|
2805
|
-
get cancelButton() {
|
|
2806
|
-
return this.core.getCancelButton();
|
|
2807
|
-
}
|
|
2808
|
-
get clockHand() {
|
|
2809
|
-
return this.core.getClockHand();
|
|
2810
|
-
}
|
|
2811
|
-
on(e, t) {
|
|
2812
|
-
this.core.isDestroyed || this.emitter.on(e, t);
|
|
2813
|
-
}
|
|
2814
|
-
once(e, t) {
|
|
2815
|
-
this.core.isDestroyed || this.emitter.once(e, t);
|
|
2816
|
-
}
|
|
2817
|
-
off(e, t) {
|
|
2818
|
-
this.core.isDestroyed || this.emitter.off(e, t);
|
|
2819
|
-
}
|
|
2820
|
-
resolveInputElement(e) {
|
|
2821
|
-
if (t() === !1) return null;
|
|
2822
|
-
let n = null;
|
|
2823
|
-
if (typeof e == "string") {
|
|
2824
|
-
if (n = document.querySelector(e), !n) return null;
|
|
2825
|
-
} else if (e instanceof HTMLElement) n = e;
|
|
2826
|
-
else return null;
|
|
2827
|
-
return n.tagName === "INPUT" ? n : n.querySelector("input");
|
|
2828
|
-
}
|
|
2829
|
-
createWrapperElement(e) {
|
|
2830
|
-
if (t() === !1) return e;
|
|
2831
|
-
let n = e.parentElement;
|
|
2832
|
-
if (e.tagName === "INPUT" && !n?.classList.contains("tp-ui")) {
|
|
2833
|
-
let t = document.createElement("div");
|
|
2834
|
-
return t.className = "tp-ui", e.parentNode?.insertBefore(t, e), t.appendChild(e), t;
|
|
2835
|
-
}
|
|
2836
|
-
return n && !n.classList.contains("tp-ui") && n.classList.add("tp-ui"), n || e;
|
|
2837
|
-
}
|
|
2838
|
-
static getById(e) {
|
|
2839
|
-
return $.get(e);
|
|
2840
|
-
}
|
|
2841
|
-
static getAllInstances() {
|
|
2842
|
-
return Array.from($.values());
|
|
2843
|
-
}
|
|
2844
|
-
static isAvailable(t) {
|
|
2845
|
-
return e() ? !1 : typeof t == "string" ? document.querySelector(t) !== null : t instanceof HTMLElement && document.contains(t);
|
|
2846
|
-
}
|
|
2847
|
-
static destroyAll() {
|
|
2848
|
-
Array.from($.values()).forEach((e) => e.destroy()), $.clear();
|
|
2849
|
-
}
|
|
2850
|
-
};
|
|
2851
|
-
//#endregion
|
|
2852
|
-
export { h as PluginRegistry, $e as TimepickerUI };
|