datex-ui 1.2.0 → 1.2.1
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/datex.d.ts +1 -0
- package/dist/index.esm.js +490 -273
- package/dist/services/keyboard-service.d.ts +5 -0
- package/dist/services/theme-service.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function
|
|
2
|
-
const e = l.getFullYear(), a = String(l.getMonth() + 1).padStart(2, "0"), i = String(l.getDate()).padStart(2, "0"), o = String(l.getHours()).padStart(2, "0"),
|
|
3
|
-
return t.replace(/YYYY/g, String(e)).replace(/MM/g, a).replace(/DD/g, i).replace(/HH/g, o).replace(/mm/g,
|
|
1
|
+
function D(l, t) {
|
|
2
|
+
const e = l.getFullYear(), a = String(l.getMonth() + 1).padStart(2, "0"), i = String(l.getDate()).padStart(2, "0"), o = String(l.getHours()).padStart(2, "0"), n = String(l.getMinutes()).padStart(2, "0"), r = String(l.getSeconds()).padStart(2, "0");
|
|
3
|
+
return t.replace(/YYYY/g, String(e)).replace(/MM/g, a).replace(/DD/g, i).replace(/HH/g, o).replace(/mm/g, n).replace(/ss/g, r);
|
|
4
4
|
}
|
|
5
5
|
function g(l, t) {
|
|
6
6
|
const e = new Date(l);
|
|
@@ -17,10 +17,10 @@ function S(l) {
|
|
|
17
17
|
function y(l, t) {
|
|
18
18
|
return l.getTime() > t.getTime();
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function x(l, t) {
|
|
21
21
|
return l.getTime() < t.getTime();
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function u(l, t, e = "day") {
|
|
24
24
|
if (!l || !t) return !1;
|
|
25
25
|
switch (e) {
|
|
26
26
|
case "day":
|
|
@@ -33,10 +33,10 @@ function m(l, t, e = "day") {
|
|
|
33
33
|
return !1;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function k(l) {
|
|
37
37
|
return l instanceof Date && !isNaN(l.getTime());
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function f(l, t) {
|
|
40
40
|
if (t === "YYYY-MM-DD") {
|
|
41
41
|
const e = l.split("-");
|
|
42
42
|
if (e.length === 3) {
|
|
@@ -55,8 +55,8 @@ function x(l, t) {
|
|
|
55
55
|
if (t === "DD/MM/YYYY HH:mm") {
|
|
56
56
|
const [e, a] = l.split(" "), i = e.split("/"), o = a ? a.split(":") : ["0", "0"];
|
|
57
57
|
if (i.length === 3) {
|
|
58
|
-
const
|
|
59
|
-
return new Date(r, n,
|
|
58
|
+
const n = parseInt(i[0], 10), r = parseInt(i[1], 10) - 1, s = parseInt(i[2], 10), d = parseInt(o[0], 10) || 0, c = parseInt(o[1], 10) || 0;
|
|
59
|
+
return new Date(s, r, n, d, c);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
return new Date(l);
|
|
@@ -64,14 +64,14 @@ function x(l, t) {
|
|
|
64
64
|
function w(l) {
|
|
65
65
|
return new Date(l.getFullYear(), l.getMonth(), 1);
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function B(l) {
|
|
68
68
|
return new Date(l.getFullYear(), l.getMonth() + 1, 0);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function H(l, t = 1) {
|
|
71
71
|
const a = (l.getDay() - t + 7) % 7, i = new Date(l);
|
|
72
72
|
return i.setDate(l.getDate() - a), i;
|
|
73
73
|
}
|
|
74
|
-
const
|
|
74
|
+
const M = {
|
|
75
75
|
primaryColor: "#357ebd",
|
|
76
76
|
secondaryColor: "#ccc",
|
|
77
77
|
backgroundColor: "#ffffff",
|
|
@@ -116,21 +116,22 @@ const E = {
|
|
|
116
116
|
disabledColor: "#bdbdbd",
|
|
117
117
|
applyButtonColor: "#4caf50",
|
|
118
118
|
cancelButtonColor: "#f44336",
|
|
119
|
-
borderRadius: "
|
|
119
|
+
borderRadius: "8px",
|
|
120
|
+
// Material Design usa bordes más redondeados
|
|
120
121
|
fontSize: "14px",
|
|
121
122
|
fontFamily: 'Roboto, "Helvetica Neue", Arial, sans-serif'
|
|
122
123
|
};
|
|
123
|
-
class
|
|
124
|
-
constructor(t, e =
|
|
124
|
+
class T {
|
|
125
|
+
constructor(t, e = M) {
|
|
125
126
|
this.mode = "light", this.handleMediaChange = () => {
|
|
126
127
|
this.mode === "auto" && this.applyTheme();
|
|
127
|
-
}, this.container = t, this.theme = { ...
|
|
128
|
+
}, this.container = t, this.theme = { ...M, ...e }, this.setupMediaQueryListener();
|
|
128
129
|
}
|
|
129
130
|
applyTheme() {
|
|
130
131
|
this.removeExistingStyles(), this.createAndApplyStyles(), this.forceReflow();
|
|
131
132
|
}
|
|
132
133
|
setTheme(t) {
|
|
133
|
-
this.theme = { ...
|
|
134
|
+
this.theme = { ...M, ...t }, this.applyTheme();
|
|
134
135
|
}
|
|
135
136
|
setMode(t) {
|
|
136
137
|
this.mode = t, this.applyTheme();
|
|
@@ -174,6 +175,217 @@ class A {
|
|
|
174
175
|
// Mantener color original
|
|
175
176
|
} : this.theme;
|
|
176
177
|
}
|
|
178
|
+
isMaterialTheme() {
|
|
179
|
+
var t;
|
|
180
|
+
return this.theme.borderRadius === "8px" && (((t = this.theme.fontFamily) == null ? void 0 : t.includes("Roboto")) ?? !1);
|
|
181
|
+
}
|
|
182
|
+
getMaterialDesignStyles(t, e) {
|
|
183
|
+
return `
|
|
184
|
+
/* Material Design - Contenedor principal con elevación */
|
|
185
|
+
.datex-picker.datex-material {
|
|
186
|
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15),
|
|
187
|
+
0 2px 4px rgba(0, 0, 0, 0.12) !important;
|
|
188
|
+
border: none !important;
|
|
189
|
+
border-radius: 8px !important;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/* Material Design - Celdas de calendario con bordes más redondeados */
|
|
193
|
+
.datex-picker.datex-material .calendar-table th,
|
|
194
|
+
.datex-picker.datex-material .calendar-table td {
|
|
195
|
+
border-radius: 50% !important; /* Círculos completos para las fechas */
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* Material Design - Fechas seleccionadas con bordes redondeados */
|
|
199
|
+
.datex-picker.datex-material .calendar-table td.start-date {
|
|
200
|
+
border-radius: 50% 0 0 50% !important;
|
|
201
|
+
background-color: ${t.selectedColor} !important;
|
|
202
|
+
color: #fff !important;
|
|
203
|
+
border-color: transparent !important;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.datex-picker.datex-material .calendar-table td.end-date {
|
|
207
|
+
border-radius: 0 50% 50% 0 !important;
|
|
208
|
+
background-color: ${t.selectedColor} !important;
|
|
209
|
+
color: #fff !important;
|
|
210
|
+
border-color: transparent !important;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.datex-picker.datex-material .calendar-table td.start-date.end-date {
|
|
214
|
+
border-radius: 50% !important;
|
|
215
|
+
background-color: ${t.selectedColor} !important;
|
|
216
|
+
color: #fff !important;
|
|
217
|
+
border-color: transparent !important;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* Material Design - Fechas activas */
|
|
221
|
+
.datex-picker.datex-material .calendar-table td.active,
|
|
222
|
+
.datex-picker.datex-material .calendar-table td.active:hover {
|
|
223
|
+
background-color: ${t.selectedColor} !important;
|
|
224
|
+
color: #fff !important;
|
|
225
|
+
border-color: transparent !important;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/* Material Design - Asegurar que end-date siempre tenga el color correcto */
|
|
229
|
+
.datex-picker.datex-material .calendar-table tbody td.end-date,
|
|
230
|
+
.datex-picker.datex-material .calendar-table tbody td.end-date:hover {
|
|
231
|
+
background-color: ${t.selectedColor} !important;
|
|
232
|
+
color: #fff !important;
|
|
233
|
+
border-color: transparent !important;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.datex-picker.datex-material .calendar-table tbody td.start-date,
|
|
237
|
+
.datex-picker.datex-material .calendar-table tbody td.start-date:hover {
|
|
238
|
+
background-color: ${t.selectedColor} !important;
|
|
239
|
+
color: #fff !important;
|
|
240
|
+
border-color: transparent !important;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* Material Design - Rango con bordes suaves */
|
|
244
|
+
.datex-picker.datex-material td.in-range {
|
|
245
|
+
border-radius: 0 !important;
|
|
246
|
+
background-color: ${t.rangeColor} !important;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* Material Design - Botones con elevación y ripple effect */
|
|
250
|
+
.datex-picker.datex-material .drp-buttons .datex-btn {
|
|
251
|
+
border-radius: 4px !important;
|
|
252
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
|
|
253
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
|
254
|
+
text-transform: uppercase !important;
|
|
255
|
+
font-weight: 500 !important;
|
|
256
|
+
letter-spacing: 0.5px !important;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.datex-picker.datex-material .drp-buttons .datex-btn:hover:not(:disabled) {
|
|
260
|
+
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
|
|
261
|
+
transform: translateY(-1px) !important;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.datex-picker.datex-material .drp-buttons .datex-btn:active:not(:disabled) {
|
|
265
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) !important;
|
|
266
|
+
transform: translateY(0) !important;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/* Material Design - Botones móviles */
|
|
270
|
+
.datex-picker.datex-material .datex-mobile-header .mobile-cancelBtn,
|
|
271
|
+
.datex-picker.datex-material .datex-mobile-header .mobile-applyBtn {
|
|
272
|
+
border-radius: 4px !important;
|
|
273
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
|
|
274
|
+
text-transform: uppercase !important;
|
|
275
|
+
font-weight: 500 !important;
|
|
276
|
+
letter-spacing: 0.5px !important;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/* Material Design - Ranges con bordes pill más pronunciados */
|
|
280
|
+
.datex-picker.datex-material .ranges li {
|
|
281
|
+
border-radius: 16px !important;
|
|
282
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
|
|
283
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.datex-picker.datex-material .ranges li:hover {
|
|
287
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12) !important;
|
|
288
|
+
transform: translateY(-1px) !important;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.datex-picker.datex-material .ranges li.active {
|
|
292
|
+
box-shadow: 0 3px 8px rgba(25, 118, 210, 0.25) !important;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/* Material Design - Selectores con bordes redondeados */
|
|
296
|
+
.datex-picker.datex-material select.monthselect,
|
|
297
|
+
.datex-picker.datex-material select.yearselect,
|
|
298
|
+
.datex-picker.datex-material select.hourselect,
|
|
299
|
+
.datex-picker.datex-material select.minuteselect,
|
|
300
|
+
.datex-picker.datex-material select.secondselect,
|
|
301
|
+
.datex-picker.datex-material select.ampmselect {
|
|
302
|
+
border-radius: 4px !important;
|
|
303
|
+
border: 1px solid ${t.borderColor} !important;
|
|
304
|
+
transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.datex-picker.datex-material select:focus {
|
|
308
|
+
border-color: ${t.primaryColor} !important;
|
|
309
|
+
outline: none !important;
|
|
310
|
+
box-shadow: 0 0 0 2px ${t.rangeColor} !important;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/* Material Design - Hover states más suaves */
|
|
314
|
+
.datex-picker.datex-material td.available:hover,
|
|
315
|
+
.datex-picker.datex-material th.available:hover {
|
|
316
|
+
background-color: ${e === "dark" ? "#4b5563" : "#f5f5f5"} !important;
|
|
317
|
+
transform: scale(1.05) !important;
|
|
318
|
+
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/* Material Design - Navegación con iconos más suaves */
|
|
322
|
+
.datex-picker.datex-material .calendar-table .next:hover,
|
|
323
|
+
.datex-picker.datex-material .calendar-table .prev:hover {
|
|
324
|
+
background-color: ${e === "dark" ? "#4b5563" : "#f5f5f5"} !important;
|
|
325
|
+
border-radius: 50% !important;
|
|
326
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/* Material Design - Flecha del dropdown más suave */
|
|
330
|
+
.datex-picker.datex-material:before {
|
|
331
|
+
border-bottom: 8px solid ${t.backgroundColor} !important;
|
|
332
|
+
filter: drop-shadow(0 -2px 4px rgba(0, 0, 0, 0.1)) !important;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.datex-picker.datex-material:after {
|
|
336
|
+
display: none !important;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* Material Design - Mobile header con elevación */
|
|
340
|
+
@media (max-width: 768px) {
|
|
341
|
+
.datex-picker.datex-material,
|
|
342
|
+
.datex-picker.datex-material.mobile-view {
|
|
343
|
+
border-radius: 16px 16px 0 0 !important;
|
|
344
|
+
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.datex-picker.datex-material .datex-mobile-header,
|
|
348
|
+
.datex-picker.datex-material.mobile-view .datex-mobile-header {
|
|
349
|
+
border-radius: 16px 16px 0 0 !important;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* Material Design - Celdas móviles circulares */
|
|
353
|
+
.datex-picker.datex-material .drp-calendar .calendar-table tbody td,
|
|
354
|
+
.datex-picker.datex-material.mobile-view .drp-calendar .calendar-table tbody td {
|
|
355
|
+
border-radius: 50% !important;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.datex-picker.datex-material .calendar-table tbody td.start-date,
|
|
359
|
+
.datex-picker.datex-material .calendar-table tbody td.start-date:hover {
|
|
360
|
+
border-radius: 50% !important;
|
|
361
|
+
background-color: ${t.selectedColor} !important;
|
|
362
|
+
color: #fff !important;
|
|
363
|
+
border-color: transparent !important;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.datex-picker.datex-material .calendar-table tbody td.end-date,
|
|
367
|
+
.datex-picker.datex-material .calendar-table tbody td.end-date:hover {
|
|
368
|
+
border-radius: 50% !important;
|
|
369
|
+
background-color: ${t.selectedColor} !important;
|
|
370
|
+
color: #fff !important;
|
|
371
|
+
border-color: transparent !important;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.datex-picker.datex-material .calendar-table tbody td.in-range {
|
|
375
|
+
border-radius: 50% !important;
|
|
376
|
+
opacity: 0.7 !important;
|
|
377
|
+
background-color: ${t.rangeColor} !important;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.datex-picker.datex-material .calendar-table tbody td.active,
|
|
381
|
+
.datex-picker.datex-material .calendar-table tbody td.active:hover {
|
|
382
|
+
background-color: ${t.selectedColor} !important;
|
|
383
|
+
color: #fff !important;
|
|
384
|
+
border-color: transparent !important;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
177
389
|
removeExistingStyles() {
|
|
178
390
|
if (this.styleId) {
|
|
179
391
|
const t = document.getElementById(this.styleId);
|
|
@@ -192,8 +404,12 @@ class A {
|
|
|
192
404
|
this.container.offsetHeight;
|
|
193
405
|
}
|
|
194
406
|
generateThemeCSS() {
|
|
195
|
-
const t = this.getThemeForMode(), e = this.getCurrentMode();
|
|
196
|
-
return this.container.classList.remove(
|
|
407
|
+
const t = this.getThemeForMode(), e = this.getCurrentMode(), a = this.isMaterialTheme();
|
|
408
|
+
return this.container.classList.remove(
|
|
409
|
+
"datex-light",
|
|
410
|
+
"datex-dark",
|
|
411
|
+
"datex-material"
|
|
412
|
+
), this.container.classList.add(`datex-${e}`), a && this.container.classList.add("datex-material"), `
|
|
197
413
|
/* Simple dropdown arrow for inputs */
|
|
198
414
|
input.datex-input {
|
|
199
415
|
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e") !important;
|
|
@@ -582,7 +798,7 @@ class A {
|
|
|
582
798
|
color: ${t.textColor} !important;
|
|
583
799
|
}
|
|
584
800
|
|
|
585
|
-
.datex-picker .drp-buttons .btn {
|
|
801
|
+
.datex-picker .drp-buttons .datex-btn {
|
|
586
802
|
margin-left: 4px !important;
|
|
587
803
|
font-size: 12px !important;
|
|
588
804
|
font-weight: bold !important;
|
|
@@ -593,25 +809,25 @@ class A {
|
|
|
593
809
|
transition: all 0.15s ease-in-out !important;
|
|
594
810
|
}
|
|
595
811
|
|
|
596
|
-
.datex-picker .drp-buttons .btn.btn-success {
|
|
812
|
+
.datex-picker .drp-buttons .datex-btn.datex-btn-success {
|
|
597
813
|
background-color: ${t.applyButtonColor} !important;
|
|
598
814
|
border-color: ${t.applyButtonColor} !important;
|
|
599
815
|
color: #fff !important;
|
|
600
816
|
}
|
|
601
817
|
|
|
602
|
-
.datex-picker .drp-buttons .btn.btn-success:hover:not(:disabled) {
|
|
818
|
+
.datex-picker .drp-buttons .datex-btn.datex-btn-success:hover:not(:disabled) {
|
|
603
819
|
background-color: ${t.applyButtonColor} !important;
|
|
604
820
|
border-color: ${t.applyButtonColor} !important;
|
|
605
821
|
opacity: 0.8 !important;
|
|
606
822
|
}
|
|
607
823
|
|
|
608
|
-
.datex-picker .drp-buttons .btn.btn-danger {
|
|
824
|
+
.datex-picker .drp-buttons .datex-btn.datex-btn-danger {
|
|
609
825
|
background-color: ${t.cancelButtonColor} !important;
|
|
610
826
|
border-color: ${t.cancelButtonColor} !important;
|
|
611
827
|
color: #fff !important;
|
|
612
828
|
}
|
|
613
829
|
|
|
614
|
-
.datex-picker .drp-buttons .btn.btn-danger:hover:not(:disabled) {
|
|
830
|
+
.datex-picker .drp-buttons .datex-btn.datex-btn-danger:hover:not(:disabled) {
|
|
615
831
|
background-color: ${t.cancelButtonColor} !important;
|
|
616
832
|
border-color: ${t.cancelButtonColor} !important;
|
|
617
833
|
opacity: 0.8 !important;
|
|
@@ -1132,8 +1348,8 @@ class A {
|
|
|
1132
1348
|
display: none !important; /* Hide on mobile - buttons are in header */
|
|
1133
1349
|
}
|
|
1134
1350
|
|
|
1135
|
-
.datex-picker .drp-buttons .btn,
|
|
1136
|
-
.datex-picker.mobile-view .drp-buttons .btn {
|
|
1351
|
+
.datex-picker .drp-buttons .datex-btn,
|
|
1352
|
+
.datex-picker.mobile-view .drp-buttons .datex-btn {
|
|
1137
1353
|
min-width: 70px !important;
|
|
1138
1354
|
padding: 8px 14px !important;
|
|
1139
1355
|
margin: 0 4px !important;
|
|
@@ -1251,10 +1467,13 @@ class A {
|
|
|
1251
1467
|
clear: none !important;
|
|
1252
1468
|
}
|
|
1253
1469
|
}
|
|
1470
|
+
|
|
1471
|
+
/* Material Design specific styles */
|
|
1472
|
+
${a ? this.getMaterialDesignStyles(t, e) : ""}
|
|
1254
1473
|
`;
|
|
1255
1474
|
}
|
|
1256
1475
|
}
|
|
1257
|
-
class
|
|
1476
|
+
class F {
|
|
1258
1477
|
constructor() {
|
|
1259
1478
|
this.boundHandlers = /* @__PURE__ */ new Map();
|
|
1260
1479
|
}
|
|
@@ -1289,7 +1508,7 @@ class T {
|
|
|
1289
1508
|
t.dispatchEvent(i);
|
|
1290
1509
|
}
|
|
1291
1510
|
}
|
|
1292
|
-
class
|
|
1511
|
+
class E {
|
|
1293
1512
|
constructor(t, e, a) {
|
|
1294
1513
|
this.element = t, this.container = e, this.options = a, this.setupOrientationHandler();
|
|
1295
1514
|
}
|
|
@@ -1336,11 +1555,11 @@ class L {
|
|
|
1336
1555
|
const e = this.container.offsetWidth, a = this.container.offsetHeight, { top: i, drops: o } = this.calculateVerticalPosition(
|
|
1337
1556
|
t,
|
|
1338
1557
|
a
|
|
1339
|
-
),
|
|
1558
|
+
), n = this.calculateHorizontalPosition(
|
|
1340
1559
|
t,
|
|
1341
1560
|
e
|
|
1342
1561
|
);
|
|
1343
|
-
this.applyDropUpClass(o), this.applyFinalPosition(i,
|
|
1562
|
+
this.applyDropUpClass(o), this.applyFinalPosition(i, n);
|
|
1344
1563
|
}
|
|
1345
1564
|
resetContainerPosition() {
|
|
1346
1565
|
this.container.style.top = "0", this.container.style.left = "0", this.container.style.right = "auto", this.container.style.position = "fixed";
|
|
@@ -1394,27 +1613,27 @@ class L {
|
|
|
1394
1613
|
t && (t.style.display = "none");
|
|
1395
1614
|
}
|
|
1396
1615
|
}
|
|
1397
|
-
class
|
|
1616
|
+
class L {
|
|
1398
1617
|
constructor(t, e) {
|
|
1399
1618
|
this.options = t, this.locale = e;
|
|
1400
1619
|
}
|
|
1401
1620
|
buildCalendarMatrix(t) {
|
|
1402
|
-
const e = w(t), a =
|
|
1621
|
+
const e = w(t), a = H(e, this.locale.firstDay), i = [];
|
|
1403
1622
|
let o = [];
|
|
1404
|
-
const
|
|
1405
|
-
for (let
|
|
1406
|
-
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1623
|
+
const n = new Date(a);
|
|
1624
|
+
for (let r = 0; r < 42; r++) {
|
|
1625
|
+
r > 0 && r % 7 === 0 && (i.push(o), o = []);
|
|
1626
|
+
const s = new Date(n);
|
|
1627
|
+
s.setDate(n.getDate() + r), o.push(s);
|
|
1409
1628
|
}
|
|
1410
1629
|
return o.length > 0 && i.push(o), i;
|
|
1411
1630
|
}
|
|
1412
|
-
renderCalendarHTML(t, e, a, i, o,
|
|
1413
|
-
const
|
|
1631
|
+
renderCalendarHTML(t, e, a, i, o, n) {
|
|
1632
|
+
const r = t.month, s = r.getFullYear(), d = r.getMonth();
|
|
1414
1633
|
let c = '<table class="table-condensed">';
|
|
1415
|
-
return c += this.renderHeader(e, d,
|
|
1634
|
+
return c += this.renderHeader(e, d, s, o, n), c += this.renderDayHeaders(), c += this.renderCalendarBody(
|
|
1416
1635
|
t.calendar,
|
|
1417
|
-
|
|
1636
|
+
r,
|
|
1418
1637
|
a,
|
|
1419
1638
|
i
|
|
1420
1639
|
), c += "</table>", this.options.timePicker && (c += this.renderTimeControls(
|
|
@@ -1425,30 +1644,30 @@ class M {
|
|
|
1425
1644
|
let e = '<div class="calendar-time">';
|
|
1426
1645
|
e += '<select class="hourselect">';
|
|
1427
1646
|
const a = this.options.timePicker24Hour, i = a ? 23 : 12, o = a ? 0 : 1;
|
|
1428
|
-
for (let
|
|
1429
|
-
const
|
|
1430
|
-
let
|
|
1647
|
+
for (let r = o; r <= i; r++) {
|
|
1648
|
+
const s = a ? r : r === 0 ? 12 : r, d = String(s).padStart(2, "0"), c = a ? t.getHours() : t.getHours() % 12 || 12;
|
|
1649
|
+
let m = !1;
|
|
1431
1650
|
if (this.options.minDate || this.options.maxDate) {
|
|
1432
|
-
const
|
|
1433
|
-
if (
|
|
1434
|
-
const v = new Date(
|
|
1435
|
-
v.setMinutes(59), v < this.options.minDate && (
|
|
1651
|
+
const b = new Date(t), $ = a ? s : t.getHours() >= 12 ? s === 12 ? 12 : s + 12 : s === 12 ? 0 : s;
|
|
1652
|
+
if (b.setHours($), this.options.minDate) {
|
|
1653
|
+
const v = new Date(b);
|
|
1654
|
+
v.setMinutes(59), v < this.options.minDate && (m = !0);
|
|
1436
1655
|
}
|
|
1437
1656
|
if (this.options.maxDate) {
|
|
1438
|
-
const v = new Date(
|
|
1439
|
-
v.setMinutes(0), v > this.options.maxDate && (
|
|
1657
|
+
const v = new Date(b);
|
|
1658
|
+
v.setMinutes(0), v > this.options.maxDate && (m = !0);
|
|
1440
1659
|
}
|
|
1441
1660
|
}
|
|
1442
|
-
e += `<option value="${
|
|
1661
|
+
e += `<option value="${s}"${s === c && !m ? ' selected="selected"' : ""}${m ? ' disabled="disabled" class="disabled"' : ""}>${d}</option>`;
|
|
1443
1662
|
}
|
|
1444
1663
|
e += "</select>", e += " : ", e += '<select class="minuteselect">';
|
|
1445
|
-
const
|
|
1446
|
-
for (let
|
|
1447
|
-
const
|
|
1664
|
+
const n = this.options.timePickerIncrement || 1;
|
|
1665
|
+
for (let r = 0; r < 60; r += n) {
|
|
1666
|
+
const s = String(r).padStart(2, "0");
|
|
1448
1667
|
let d = !1;
|
|
1449
1668
|
if (this.options.minDate || this.options.maxDate) {
|
|
1450
1669
|
const h = new Date(t);
|
|
1451
|
-
if (h.setMinutes(
|
|
1670
|
+
if (h.setMinutes(r), this.options.minDate) {
|
|
1452
1671
|
const p = new Date(h);
|
|
1453
1672
|
p.setSeconds(59), p < this.options.minDate && (d = !0);
|
|
1454
1673
|
}
|
|
@@ -1457,43 +1676,43 @@ class M {
|
|
|
1457
1676
|
p.setSeconds(0), p > this.options.maxDate && (d = !0);
|
|
1458
1677
|
}
|
|
1459
1678
|
}
|
|
1460
|
-
const c =
|
|
1461
|
-
e += `<option value="${
|
|
1679
|
+
const c = r === t.getMinutes() && !d ? ' selected="selected"' : "";
|
|
1680
|
+
e += `<option value="${r}"${c}${d ? ' disabled="disabled" class="disabled"' : ""}>${s}</option>`;
|
|
1462
1681
|
}
|
|
1463
1682
|
if (e += "</select>", this.options.timePickerSeconds) {
|
|
1464
1683
|
e += " : ", e += '<select class="secondselect">';
|
|
1465
|
-
for (let
|
|
1466
|
-
const
|
|
1684
|
+
for (let r = 0; r < 60; r++) {
|
|
1685
|
+
const s = String(r).padStart(2, "0");
|
|
1467
1686
|
let d = !1;
|
|
1468
1687
|
if (this.options.minDate || this.options.maxDate) {
|
|
1469
1688
|
const h = new Date(t);
|
|
1470
|
-
h.setSeconds(
|
|
1689
|
+
h.setSeconds(r), this.options.minDate && h < this.options.minDate && (d = !0), this.options.maxDate && h > this.options.maxDate && (d = !0);
|
|
1471
1690
|
}
|
|
1472
|
-
const c =
|
|
1473
|
-
e += `<option value="${
|
|
1691
|
+
const c = r === t.getSeconds() && !d ? ' selected="selected"' : "";
|
|
1692
|
+
e += `<option value="${r}"${c}${d ? ' disabled="disabled" class="disabled"' : ""}>${s}</option>`;
|
|
1474
1693
|
}
|
|
1475
1694
|
e += "</select>";
|
|
1476
1695
|
}
|
|
1477
1696
|
if (!a) {
|
|
1478
1697
|
e += " ", e += '<select class="ampmselect">';
|
|
1479
|
-
const
|
|
1480
|
-
let
|
|
1698
|
+
const r = t.getHours() < 12;
|
|
1699
|
+
let s = !1, d = !1;
|
|
1481
1700
|
if (this.options.minDate || this.options.maxDate) {
|
|
1482
1701
|
const h = new Date(t);
|
|
1483
1702
|
h.setHours(6, 0, 0);
|
|
1484
1703
|
const p = new Date(t);
|
|
1485
|
-
p.setHours(18, 0, 0), this.options.minDate && h < this.options.minDate && (
|
|
1704
|
+
p.setHours(18, 0, 0), this.options.minDate && h < this.options.minDate && (s = !0), this.options.maxDate && p > this.options.maxDate && (d = !0);
|
|
1486
1705
|
}
|
|
1487
|
-
const c =
|
|
1488
|
-
e += `<option value="AM"${
|
|
1706
|
+
const c = s ? ' disabled="disabled" class="disabled"' : "", m = d ? ' disabled="disabled" class="disabled"' : "";
|
|
1707
|
+
e += `<option value="AM"${r ? ' selected="selected"' : ""}${c}>AM</option>`, e += `<option value="PM"${r ? "" : ' selected="selected"'}${m}>PM</option>`, e += "</select>";
|
|
1489
1708
|
}
|
|
1490
1709
|
return e += "</div>", e;
|
|
1491
1710
|
}
|
|
1492
1711
|
renderHeader(t, e, a, i, o) {
|
|
1493
|
-
let
|
|
1494
|
-
i && (!this.options.linkedCalendars || t === "left") ?
|
|
1495
|
-
let
|
|
1496
|
-
return this.options.showDropdowns && (
|
|
1712
|
+
let n = "<thead><tr>";
|
|
1713
|
+
i && (!this.options.linkedCalendars || t === "left") ? n += '<th class="prev available"><span></span></th>' : n += "<th></th>";
|
|
1714
|
+
let r = this.locale.monthNames[e] + " " + a;
|
|
1715
|
+
return this.options.showDropdowns && (r = this.renderDropdowns(e, a)), n += `<th colspan="5" class="month">${r}</th>`, o && (!this.options.linkedCalendars || t === "right" || this.options.singleDatePicker) ? n += '<th class="next available"><span></span></th>' : n += "<th></th>", n += "</tr>", n;
|
|
1497
1716
|
}
|
|
1498
1717
|
renderDayHeaders() {
|
|
1499
1718
|
let t = "<tr>";
|
|
@@ -1503,19 +1722,19 @@ class M {
|
|
|
1503
1722
|
}
|
|
1504
1723
|
renderCalendarBody(t, e, a, i) {
|
|
1505
1724
|
let o = "<tbody>";
|
|
1506
|
-
for (const
|
|
1725
|
+
for (const n of t) {
|
|
1507
1726
|
o += "<tr>";
|
|
1508
|
-
for (const
|
|
1509
|
-
const
|
|
1510
|
-
|
|
1727
|
+
for (const r of n) {
|
|
1728
|
+
const s = this.getDayClasses(
|
|
1729
|
+
r,
|
|
1511
1730
|
e,
|
|
1512
1731
|
a,
|
|
1513
1732
|
i
|
|
1514
|
-
), d =
|
|
1515
|
-
o += `<td class="${c}" data-date="${
|
|
1516
|
-
|
|
1733
|
+
), d = s.includes("disabled"), c = s.join(" ") + (d ? "" : " available");
|
|
1734
|
+
o += `<td class="${c}" data-date="${D(
|
|
1735
|
+
r,
|
|
1517
1736
|
"YYYY-MM-DD"
|
|
1518
|
-
)}">${
|
|
1737
|
+
)}">${r.getDate()}</td>`;
|
|
1519
1738
|
}
|
|
1520
1739
|
o += "</tr>";
|
|
1521
1740
|
}
|
|
@@ -1527,21 +1746,21 @@ class M {
|
|
|
1527
1746
|
e,
|
|
1528
1747
|
a,
|
|
1529
1748
|
i
|
|
1530
|
-
),
|
|
1531
|
-
return o + " " +
|
|
1749
|
+
), n = this.renderYearDropdown(e, a, i);
|
|
1750
|
+
return o + " " + n;
|
|
1532
1751
|
}
|
|
1533
1752
|
calculateYearRange(t) {
|
|
1534
1753
|
let e = this.options.minYear, a = this.options.maxYear;
|
|
1535
1754
|
return this.options.minDate && (e = Math.max(e, this.options.minDate.getFullYear())), this.options.maxDate && (a = Math.min(a, this.options.maxDate.getFullYear())), { minYear: e, maxYear: a };
|
|
1536
1755
|
}
|
|
1537
1756
|
renderMonthDropdown(t, e, a, i) {
|
|
1538
|
-
const o = e === a,
|
|
1539
|
-
let
|
|
1540
|
-
for (let
|
|
1757
|
+
const o = e === a, n = e === i;
|
|
1758
|
+
let r = '<select class="monthselect">';
|
|
1759
|
+
for (let s = 0; s < 12; s++) {
|
|
1541
1760
|
let d = !1;
|
|
1542
|
-
o && this.options.minDate &&
|
|
1761
|
+
o && this.options.minDate && s < this.options.minDate.getMonth() && (d = !0), n && this.options.maxDate && s > this.options.maxDate.getMonth() && (d = !0), r += `<option value="${s}"${s === t ? ' selected="selected"' : ""}${d ? ' disabled="disabled"' : ""}>${this.locale.monthNames[s]}</option>`;
|
|
1543
1762
|
}
|
|
1544
|
-
return
|
|
1763
|
+
return r += "</select>", r;
|
|
1545
1764
|
}
|
|
1546
1765
|
renderYearDropdown(t, e, a) {
|
|
1547
1766
|
let i = '<select class="yearselect">';
|
|
@@ -1551,16 +1770,16 @@ class M {
|
|
|
1551
1770
|
}
|
|
1552
1771
|
getDayClasses(t, e, a, i) {
|
|
1553
1772
|
const o = [];
|
|
1554
|
-
return
|
|
1773
|
+
return u(t, /* @__PURE__ */ new Date(), "day") && o.push("today"), (t.getDay() === 0 || t.getDay() === 6) && o.push("weekend"), t.getMonth() !== e.getMonth() && o.push("off", "ends"), this.options.minDate && x(t, C(this.options.minDate)) && o.push("off", "disabled"), this.options.maxDate && y(t, S(this.options.maxDate)) && o.push("off", "disabled"), u(t, a, "day") && o.push("active", "start-date"), i && u(t, i, "day") && o.push("active", "end-date"), i && y(t, a) && x(t, i) && o.push("in-range"), o;
|
|
1555
1774
|
}
|
|
1556
1775
|
canNavigatePrevious(t) {
|
|
1557
1776
|
return !this.options.minDate || y(w(t), this.options.minDate);
|
|
1558
1777
|
}
|
|
1559
1778
|
canNavigateNext(t) {
|
|
1560
|
-
return !this.options.maxDate ||
|
|
1779
|
+
return !this.options.maxDate || x(B(t), this.options.maxDate);
|
|
1561
1780
|
}
|
|
1562
1781
|
}
|
|
1563
|
-
class
|
|
1782
|
+
class A {
|
|
1564
1783
|
constructor(t = {}) {
|
|
1565
1784
|
this.validation = t;
|
|
1566
1785
|
}
|
|
@@ -1653,10 +1872,11 @@ class F {
|
|
|
1653
1872
|
return ((e = this.validation.holidays) == null ? void 0 : e.some((a) => this.isSameDate(a, t))) || !1;
|
|
1654
1873
|
}
|
|
1655
1874
|
}
|
|
1656
|
-
class
|
|
1875
|
+
class P {
|
|
1657
1876
|
constructor(t, e = {}) {
|
|
1658
1877
|
this.currentFocusedDate = null, this.isActive = !1, this.container = t, this.options = {
|
|
1659
|
-
enabled: !
|
|
1878
|
+
enabled: !1,
|
|
1879
|
+
// Deshabilitado por defecto para evitar conflictos
|
|
1660
1880
|
shortcuts: {
|
|
1661
1881
|
today: "t",
|
|
1662
1882
|
clear: "c",
|
|
@@ -1669,82 +1889,78 @@ class I {
|
|
|
1669
1889
|
}, this.options.enabled && this.setupKeyboardEvents();
|
|
1670
1890
|
}
|
|
1671
1891
|
setHandlers(t) {
|
|
1672
|
-
this.onDateSelect = t.onDateSelect, this.onClose = t.onClose, this.onApply = t.onApply, this.onToday = t.onToday, this.onClear = t.onClear;
|
|
1892
|
+
this.onDateSelect = t.onDateSelect, this.onClose = t.onClose, this.onApply = t.onApply, this.onToday = t.onToday, this.onClear = t.onClear, this.onMonthChange = t.onMonthChange;
|
|
1673
1893
|
}
|
|
1674
1894
|
activate(t) {
|
|
1675
1895
|
this.isActive = !0, this.currentFocusedDate = t ? new Date(t.getTime()) : /* @__PURE__ */ new Date(), setTimeout(() => {
|
|
1676
1896
|
this.isActive && this.updateFocusedDate();
|
|
1677
|
-
}, 100), this.
|
|
1897
|
+
}, 100), this.handleKeyDownBound && document.addEventListener("keydown", this.handleKeyDownBound);
|
|
1678
1898
|
}
|
|
1679
1899
|
deactivate() {
|
|
1680
|
-
this.isActive = !1, this.currentFocusedDate = null, this.removeFocusStyles();
|
|
1900
|
+
this.isActive = !1, this.currentFocusedDate = null, this.removeFocusStyles(), this.handleKeyDownBound && document.removeEventListener("keydown", this.handleKeyDownBound);
|
|
1681
1901
|
}
|
|
1682
1902
|
setupKeyboardEvents() {
|
|
1683
|
-
this.container.setAttribute("tabindex", "0"), this.
|
|
1903
|
+
this.container.setAttribute("tabindex", "0"), this.handleKeyDownBound = this.handleKeyDown.bind(this), this.handleFocusBound = this.handleFocus.bind(this), this.handleBlurBound = this.handleBlur.bind(this), this.container.addEventListener("keydown", this.handleKeyDownBound), this.container.addEventListener("focus", this.handleFocusBound), this.container.addEventListener("blur", this.handleBlurBound);
|
|
1684
1904
|
}
|
|
1685
1905
|
handleKeyDown(t) {
|
|
1686
|
-
var
|
|
1906
|
+
var c, m, h, p;
|
|
1687
1907
|
if (!this.isActive || !this.currentFocusedDate) return;
|
|
1688
|
-
const { key: e, ctrlKey: a, shiftKey: i, altKey: o } = t;
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
case "PageUp":
|
|
1709
|
-
t.preventDefault(), this.navigateMonth(i ? -12 : -1);
|
|
1710
|
-
break;
|
|
1711
|
-
case "PageDown":
|
|
1712
|
-
t.preventDefault(), this.navigateMonth(i ? 12 : 1);
|
|
1713
|
-
break;
|
|
1714
|
-
}
|
|
1715
|
-
switch (e) {
|
|
1716
|
-
case "Enter":
|
|
1717
|
-
case " ":
|
|
1718
|
-
if (t.preventDefault(), this.currentFocusedDate && this.onDateSelect) {
|
|
1719
|
-
const c = new Date(this.currentFocusedDate.getTime());
|
|
1720
|
-
console.log("=== KEYBOARD DEBUG ==="), console.log("Original focused date:", this.currentFocusedDate), console.log(
|
|
1721
|
-
"Original focused day:",
|
|
1722
|
-
this.currentFocusedDate.getDate()
|
|
1723
|
-
), console.log("Copy to select:", c), console.log("Copy day:", c.getDate()), console.log(
|
|
1724
|
-
"Are they equal?",
|
|
1725
|
-
this.currentFocusedDate.getTime() === c.getTime()
|
|
1726
|
-
), console.log("======================"), this.onDateSelect(c);
|
|
1727
|
-
}
|
|
1728
|
-
break;
|
|
1729
|
-
case "Escape":
|
|
1730
|
-
t.preventDefault(), this.onClose && this.onClose();
|
|
1731
|
-
break;
|
|
1732
|
-
}
|
|
1733
|
-
if (!a && !o)
|
|
1734
|
-
switch (e.toLowerCase()) {
|
|
1735
|
-
case ((n = (s = this.options.shortcuts) == null ? void 0 : s.today) == null ? void 0 : n.toLowerCase()):
|
|
1736
|
-
t.preventDefault(), this.onToday && this.onToday();
|
|
1908
|
+
const { key: e, ctrlKey: a, shiftKey: i, altKey: o } = t, n = t.target, r = this.container.contains(n), s = n.tagName === "INPUT" || n.tagName === "BUTTON";
|
|
1909
|
+
if (n.tagName !== "SELECT" && !(!r && !s)) {
|
|
1910
|
+
switch (e) {
|
|
1911
|
+
case "ArrowLeft":
|
|
1912
|
+
t.preventDefault(), t.stopPropagation(), this.navigateDate(-1);
|
|
1913
|
+
break;
|
|
1914
|
+
case "ArrowRight":
|
|
1915
|
+
t.preventDefault(), t.stopPropagation(), this.navigateDate(1);
|
|
1916
|
+
break;
|
|
1917
|
+
case "ArrowUp":
|
|
1918
|
+
t.preventDefault(), t.stopPropagation(), this.navigateDate(-7);
|
|
1919
|
+
break;
|
|
1920
|
+
case "ArrowDown":
|
|
1921
|
+
t.preventDefault(), t.stopPropagation(), this.navigateDate(7);
|
|
1922
|
+
break;
|
|
1923
|
+
case "Home":
|
|
1924
|
+
t.preventDefault(), t.stopPropagation(), this.navigateToStartOfWeek();
|
|
1925
|
+
break;
|
|
1926
|
+
case "End":
|
|
1927
|
+
t.preventDefault(), t.stopPropagation(), this.navigateToEndOfWeek();
|
|
1737
1928
|
break;
|
|
1738
|
-
case
|
|
1739
|
-
t.preventDefault(),
|
|
1929
|
+
case "PageUp":
|
|
1930
|
+
t.preventDefault(), t.stopPropagation(), this.navigateMonth(i ? -12 : -1);
|
|
1931
|
+
break;
|
|
1932
|
+
case "PageDown":
|
|
1933
|
+
t.preventDefault(), t.stopPropagation(), this.navigateMonth(i ? 12 : 1);
|
|
1740
1934
|
break;
|
|
1741
1935
|
}
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
case "
|
|
1745
|
-
t.preventDefault(), this.
|
|
1936
|
+
switch (e) {
|
|
1937
|
+
case "Enter":
|
|
1938
|
+
case " ":
|
|
1939
|
+
if (t.preventDefault(), t.stopPropagation(), this.currentFocusedDate && this.onDateSelect) {
|
|
1940
|
+
const b = new Date(this.currentFocusedDate.getTime());
|
|
1941
|
+
this.onDateSelect(b);
|
|
1942
|
+
}
|
|
1943
|
+
break;
|
|
1944
|
+
case "Escape":
|
|
1945
|
+
t.preventDefault(), t.stopPropagation(), this.onClose && this.onClose();
|
|
1746
1946
|
break;
|
|
1747
1947
|
}
|
|
1948
|
+
if (!a && !o)
|
|
1949
|
+
switch (e.toLowerCase()) {
|
|
1950
|
+
case ((m = (c = this.options.shortcuts) == null ? void 0 : c.today) == null ? void 0 : m.toLowerCase()):
|
|
1951
|
+
t.preventDefault(), t.stopPropagation(), this.onToday && this.onToday();
|
|
1952
|
+
break;
|
|
1953
|
+
case ((p = (h = this.options.shortcuts) == null ? void 0 : h.clear) == null ? void 0 : p.toLowerCase()):
|
|
1954
|
+
t.preventDefault(), t.stopPropagation(), this.onClear && this.onClear();
|
|
1955
|
+
break;
|
|
1956
|
+
}
|
|
1957
|
+
if (a && !o && !i)
|
|
1958
|
+
switch (e.toLowerCase()) {
|
|
1959
|
+
case "enter":
|
|
1960
|
+
t.preventDefault(), t.stopPropagation(), this.onApply && this.onApply();
|
|
1961
|
+
break;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1748
1964
|
}
|
|
1749
1965
|
handleFocus() {
|
|
1750
1966
|
this.isActive || (this.isActive = !0, this.currentFocusedDate = this.currentFocusedDate || /* @__PURE__ */ new Date(), setTimeout(() => {
|
|
@@ -1758,13 +1974,13 @@ class I {
|
|
|
1758
1974
|
}
|
|
1759
1975
|
navigateDate(t) {
|
|
1760
1976
|
if (!this.currentFocusedDate) return;
|
|
1761
|
-
const e = new Date(this.currentFocusedDate.getTime());
|
|
1762
|
-
|
|
1977
|
+
const e = this.currentFocusedDate.getMonth(), a = this.currentFocusedDate.getFullYear(), i = new Date(this.currentFocusedDate.getTime());
|
|
1978
|
+
i.setDate(i.getDate() + t), this.currentFocusedDate = i, (i.getMonth() !== e || i.getFullYear() !== a) && this.onMonthChange && this.onMonthChange(i), this.updateFocusedDate();
|
|
1763
1979
|
}
|
|
1764
1980
|
navigateMonth(t) {
|
|
1765
1981
|
if (!this.currentFocusedDate) return;
|
|
1766
1982
|
const e = new Date(this.currentFocusedDate.getTime());
|
|
1767
|
-
e.setMonth(e.getMonth() + t), this.currentFocusedDate = e, this.updateFocusedDate();
|
|
1983
|
+
e.setMonth(e.getMonth() + t), this.currentFocusedDate = e, this.onMonthChange && this.onMonthChange(e), this.updateFocusedDate();
|
|
1768
1984
|
}
|
|
1769
1985
|
navigateToStartOfWeek() {
|
|
1770
1986
|
if (!this.currentFocusedDate) return;
|
|
@@ -1779,25 +1995,17 @@ class I {
|
|
|
1779
1995
|
updateFocusedDate() {
|
|
1780
1996
|
if (!this.currentFocusedDate) return;
|
|
1781
1997
|
this.removeFocusStyles();
|
|
1782
|
-
const t = this.formatDateForSelector(this.currentFocusedDate)
|
|
1783
|
-
console.log("Keyboard: Looking for cell with data-date:", t), console.log(
|
|
1784
|
-
"Keyboard: Current focused date:",
|
|
1785
|
-
this.currentFocusedDate.toDateString()
|
|
1786
|
-
);
|
|
1787
|
-
const e = this.container.querySelector(
|
|
1998
|
+
const t = this.formatDateForSelector(this.currentFocusedDate), e = this.container.querySelector(
|
|
1788
1999
|
`[data-date="${t}"]`
|
|
1789
2000
|
);
|
|
1790
|
-
if (e) {
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
}
|
|
1799
|
-
} else
|
|
1800
|
-
console.log("Keyboard: Cell not found for date:", t);
|
|
2001
|
+
if (e && (e.classList.add("keyboard-focused"), e.setAttribute("aria-selected", "true"), this.isActive && this.container.offsetParent !== null)) {
|
|
2002
|
+
const a = this.container.getBoundingClientRect(), i = e.getBoundingClientRect();
|
|
2003
|
+
(i.top < a.top || i.bottom > a.bottom || i.left < a.left || i.right > a.right) && e.scrollIntoView({
|
|
2004
|
+
block: "nearest",
|
|
2005
|
+
inline: "nearest",
|
|
2006
|
+
behavior: "smooth"
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
1801
2009
|
this.addFocusStyles();
|
|
1802
2010
|
}
|
|
1803
2011
|
removeFocusStyles() {
|
|
@@ -1809,7 +2017,8 @@ class I {
|
|
|
1809
2017
|
if (this.container.querySelector(".keyboard-focus-styles")) return;
|
|
1810
2018
|
const t = document.createElement("style");
|
|
1811
2019
|
t.className = "keyboard-focus-styles", t.textContent = `
|
|
1812
|
-
|
|
2020
|
+
/* Keyboard focus - solo para fechas NO seleccionadas */
|
|
2021
|
+
.datex-picker .calendar-table td.keyboard-focused:not(.start-date):not(.end-date):not(.active) {
|
|
1813
2022
|
outline: 2px solid #10b981 !important;
|
|
1814
2023
|
outline-offset: -2px !important;
|
|
1815
2024
|
z-index: 10 !important;
|
|
@@ -1817,11 +2026,22 @@ class I {
|
|
|
1817
2026
|
box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
|
|
1818
2027
|
}
|
|
1819
2028
|
|
|
1820
|
-
.datex-picker .calendar-table td.keyboard-focused > * {
|
|
2029
|
+
.datex-picker .calendar-table td.keyboard-focused:not(.start-date):not(.end-date):not(.active) > * {
|
|
1821
2030
|
background: #10b981 !important;
|
|
1822
2031
|
color: white !important;
|
|
1823
2032
|
font-weight: 600 !important;
|
|
1824
2033
|
}
|
|
2034
|
+
|
|
2035
|
+
/* Keyboard focus para fechas seleccionadas - solo un outline sutil */
|
|
2036
|
+
.datex-picker .calendar-table td.keyboard-focused.start-date,
|
|
2037
|
+
.datex-picker .calendar-table td.keyboard-focused.end-date,
|
|
2038
|
+
.datex-picker .calendar-table td.keyboard-focused.active {
|
|
2039
|
+
outline: 2px solid rgba(255, 255, 255, 0.5) !important;
|
|
2040
|
+
outline-offset: -2px !important;
|
|
2041
|
+
z-index: 10 !important;
|
|
2042
|
+
position: relative !important;
|
|
2043
|
+
box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1) !important;
|
|
2044
|
+
}
|
|
1825
2045
|
|
|
1826
2046
|
/* Prevent layout shifts */
|
|
1827
2047
|
.datex-picker {
|
|
@@ -1834,13 +2054,8 @@ class I {
|
|
|
1834
2054
|
`, document.head.appendChild(t);
|
|
1835
2055
|
}
|
|
1836
2056
|
formatDateForSelector(t) {
|
|
1837
|
-
const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0")
|
|
1838
|
-
return
|
|
1839
|
-
"Keyboard: Formatting date for selector:",
|
|
1840
|
-
t.toDateString(),
|
|
1841
|
-
"-> formatted:",
|
|
1842
|
-
o
|
|
1843
|
-
), o;
|
|
2057
|
+
const e = t.getFullYear(), a = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0");
|
|
2058
|
+
return `${e}-${a}-${i}`;
|
|
1844
2059
|
}
|
|
1845
2060
|
// Public methods
|
|
1846
2061
|
getCurrentFocusedDate() {
|
|
@@ -1850,15 +2065,12 @@ class I {
|
|
|
1850
2065
|
this.currentFocusedDate = new Date(t.getTime()), this.updateFocusedDate();
|
|
1851
2066
|
}
|
|
1852
2067
|
cleanup() {
|
|
1853
|
-
this.container.removeEventListener(
|
|
1854
|
-
"keydown",
|
|
1855
|
-
this.handleKeyDown.bind(this)
|
|
1856
|
-
), this.container.removeEventListener("focus", this.handleFocus.bind(this)), this.container.removeEventListener("blur", this.handleBlur.bind(this)), this.removeFocusStyles();
|
|
2068
|
+
this.handleKeyDownBound && (this.container.removeEventListener("keydown", this.handleKeyDownBound), document.removeEventListener("keydown", this.handleKeyDownBound)), this.handleFocusBound && this.container.removeEventListener("focus", this.handleFocusBound), this.handleBlurBound && this.container.removeEventListener("blur", this.handleBlurBound), this.removeFocusStyles();
|
|
1857
2069
|
const t = document.querySelector(".keyboard-focus-styles");
|
|
1858
2070
|
t && t.remove();
|
|
1859
2071
|
}
|
|
1860
2072
|
}
|
|
1861
|
-
const
|
|
2073
|
+
const I = {
|
|
1862
2074
|
format: "DD/MM/YYYY",
|
|
1863
2075
|
separator: " - ",
|
|
1864
2076
|
applyLabel: "Aplicar",
|
|
@@ -1903,10 +2115,10 @@ const P = {
|
|
|
1903
2115
|
],
|
|
1904
2116
|
firstDay: 1
|
|
1905
2117
|
};
|
|
1906
|
-
class
|
|
2118
|
+
class N {
|
|
1907
2119
|
constructor(t, e = {}, a) {
|
|
1908
2120
|
this.element = this.resolveElement(t), this.options = this.mergeWithDefaults(e), this.locale = this.options.locale, this.callback = a || (() => {
|
|
1909
|
-
}), this.eventService = new
|
|
2121
|
+
}), this.eventService = new F(), this.initializeState(), this.initializeServices(), this.addDropdownArrow(), this.createContainer(), this.setupEventListeners(), this.updateElement(), this.calculateChosenLabel();
|
|
1910
2122
|
}
|
|
1911
2123
|
resolveElement(t) {
|
|
1912
2124
|
if (typeof t == "string") {
|
|
@@ -1940,11 +2152,11 @@ class V {
|
|
|
1940
2152
|
ranges: t.ranges || {},
|
|
1941
2153
|
opens: t.opens || "center",
|
|
1942
2154
|
drops: t.drops || "auto",
|
|
1943
|
-
locale: t.locale ||
|
|
1944
|
-
buttonClasses: t.buttonClasses || "btn btn-sm",
|
|
1945
|
-
applyButtonClasses: t.applyButtonClasses || "btn-success",
|
|
1946
|
-
cancelButtonClasses: t.cancelButtonClasses || "btn-danger",
|
|
1947
|
-
theme: t.theme ||
|
|
2155
|
+
locale: t.locale || I,
|
|
2156
|
+
buttonClasses: t.buttonClasses || "datex-btn datex-btn-sm",
|
|
2157
|
+
applyButtonClasses: t.applyButtonClasses || "datex-btn-success",
|
|
2158
|
+
cancelButtonClasses: t.cancelButtonClasses || "datex-btn-danger",
|
|
2159
|
+
theme: t.theme || M,
|
|
1948
2160
|
validation: t.validation || {},
|
|
1949
2161
|
events: t.events || {}
|
|
1950
2162
|
};
|
|
@@ -1965,7 +2177,7 @@ class V {
|
|
|
1965
2177
|
};
|
|
1966
2178
|
}
|
|
1967
2179
|
initializeServices() {
|
|
1968
|
-
this.calendarService = new
|
|
2180
|
+
this.calendarService = new L(this.options, this.locale);
|
|
1969
2181
|
}
|
|
1970
2182
|
addDropdownArrow() {
|
|
1971
2183
|
this.element.tagName === "INPUT" && this.element.classList.add("datex-input");
|
|
@@ -2013,12 +2225,13 @@ class V {
|
|
|
2013
2225
|
`;
|
|
2014
2226
|
}
|
|
2015
2227
|
initializeContainerServices() {
|
|
2016
|
-
this.themeService = new
|
|
2228
|
+
this.themeService = new T(this.container, this.options.theme), this.positionService = new E(
|
|
2017
2229
|
this.element,
|
|
2018
2230
|
this.container,
|
|
2019
2231
|
this.options
|
|
2020
|
-
), this.validationService = new
|
|
2021
|
-
enabled: !
|
|
2232
|
+
), this.validationService = new A(this.options.validation), this.keyboardService = new P(this.container, {
|
|
2233
|
+
enabled: !1
|
|
2234
|
+
// Deshabilitado por defecto para evitar conflictos
|
|
2022
2235
|
}), this.keyboardService.setHandlers({
|
|
2023
2236
|
onDateSelect: (t) => {
|
|
2024
2237
|
this.handleKeyboardDateSelect(t);
|
|
@@ -2032,6 +2245,9 @@ class V {
|
|
|
2032
2245
|
},
|
|
2033
2246
|
onClear: () => {
|
|
2034
2247
|
this.clearSelection();
|
|
2248
|
+
},
|
|
2249
|
+
onMonthChange: (t) => {
|
|
2250
|
+
this.handleKeyboardMonthChange(t);
|
|
2035
2251
|
}
|
|
2036
2252
|
});
|
|
2037
2253
|
}
|
|
@@ -2045,9 +2261,7 @@ class V {
|
|
|
2045
2261
|
}
|
|
2046
2262
|
// Public API methods
|
|
2047
2263
|
show() {
|
|
2048
|
-
this.state.isShowing || (this.storeOldValues(), this.themeService.applyTheme(), this.setupDocumentListeners(), this.updateView(), this.displayContainer(), this.positionContainer(), this.element.tagName === "INPUT" && this.element.classList.add("datex-active"),
|
|
2049
|
-
this.state.isShowing && this.keyboardService.activate(this.state.startDate);
|
|
2050
|
-
}, 200), this.dispatchShowEvent());
|
|
2264
|
+
this.state.isShowing || (this.storeOldValues(), this.themeService.applyTheme(), this.setupDocumentListeners(), this.updateView(), this.displayContainer(), this.positionContainer(), this.element.tagName === "INPUT" && this.element.classList.add("datex-active"), this.dispatchShowEvent());
|
|
2051
2265
|
}
|
|
2052
2266
|
hide() {
|
|
2053
2267
|
this.state.isShowing && (this.revertIfIncomplete(), this.triggerCallbackIfChanged(), this.updateElement(), this.removeDocumentListeners(), this.keyboardService.deactivate(), this.hideContainer(), this.element.tagName === "INPUT" && this.element.classList.remove("datex-active"), this.dispatchHideEvent());
|
|
@@ -2104,7 +2318,7 @@ class V {
|
|
|
2104
2318
|
this.options = this.mergeWithDefaults(e), t.locale && (this.locale = t.locale), this.reinitializeServices(), this.updateContainerConfiguration(), this.updateView(), this.state.isShowing && this.positionContainer();
|
|
2105
2319
|
}
|
|
2106
2320
|
reinitializeServices() {
|
|
2107
|
-
this.calendarService = new
|
|
2321
|
+
this.calendarService = new L(this.options, this.locale), this.validationService.updateValidation(this.options.validation), this.themeService.setTheme(this.options.theme), this.positionService = new E(
|
|
2108
2322
|
this.element,
|
|
2109
2323
|
this.container,
|
|
2110
2324
|
this.options
|
|
@@ -2175,11 +2389,11 @@ class V {
|
|
|
2175
2389
|
this.state.endDate || (this.state.startDate = new Date(this.state.oldStartDate), this.state.endDate = this.state.oldEndDate ? new Date(this.state.oldEndDate) : null);
|
|
2176
2390
|
}
|
|
2177
2391
|
triggerCallbackIfChanged() {
|
|
2178
|
-
const t = !
|
|
2392
|
+
const t = !u(
|
|
2179
2393
|
this.state.startDate,
|
|
2180
2394
|
this.state.oldStartDate,
|
|
2181
2395
|
"day"
|
|
2182
|
-
), e = this.state.endDate && this.state.oldEndDate && !
|
|
2396
|
+
), e = this.state.endDate && this.state.oldEndDate && !u(this.state.endDate, this.state.oldEndDate, "day");
|
|
2183
2397
|
(t || e) && this.callback(
|
|
2184
2398
|
new Date(this.state.startDate),
|
|
2185
2399
|
this.state.endDate ? new Date(this.state.endDate) : new Date(this.state.startDate),
|
|
@@ -2202,13 +2416,16 @@ class V {
|
|
|
2202
2416
|
this.removeDocumentListeners(), this.themeService.cleanup(), this.eventService.cleanup(), this.keyboardService.cleanup(), this.positionService.cleanup(), (t = this.container) != null && t.parentNode && this.container.parentNode.removeChild(this.container), this.element.tagName === "INPUT" && this.element.classList.remove("datex-input", "datex-active");
|
|
2203
2417
|
}
|
|
2204
2418
|
handleKeyboardDateSelect(t) {
|
|
2205
|
-
console.log("DateX: Received date from keyboard:", t.toDateString()), console.log("DateX: Received date day:", t.getDate());
|
|
2206
2419
|
const e = this.validationService.validateDate(t);
|
|
2207
2420
|
if (!e.isValid) {
|
|
2208
2421
|
this.showValidationError(e.error, e.errorCode);
|
|
2209
2422
|
return;
|
|
2210
2423
|
}
|
|
2211
|
-
this.state.hoverDate = null, this.state.endDate ||
|
|
2424
|
+
this.state.hoverDate = null, this.state.endDate || x(t, this.state.startDate) ? (this.state.endDate = null, this.setStartDate(t)) : (this.setEndDate(t), this.options.autoApply && (this.calculateChosenLabel(), this.handleApplyClick())), this.options.singleDatePicker && (this.setEndDate(this.state.startDate), this.options.autoApply && this.handleApplyClick()), this.updateDateClasses();
|
|
2425
|
+
}
|
|
2426
|
+
handleKeyboardMonthChange(t) {
|
|
2427
|
+
const e = new Date(t.getFullYear(), t.getMonth(), 1);
|
|
2428
|
+
this.state.leftCalendar.month = e, this.options.singleDatePicker || this.options.linkedCalendars && (this.state.rightCalendar.month = g(e, 1)), this.updateCalendars();
|
|
2212
2429
|
}
|
|
2213
2430
|
clearSelection() {
|
|
2214
2431
|
const t = /* @__PURE__ */ new Date();
|
|
@@ -2216,7 +2433,7 @@ class V {
|
|
|
2216
2433
|
}
|
|
2217
2434
|
showValidationError(t, e) {
|
|
2218
2435
|
var a;
|
|
2219
|
-
(a = this.options.events) != null && a.onValidationError && this.options.events.onValidationError(t, e)
|
|
2436
|
+
(a = this.options.events) != null && a.onValidationError && this.options.events.onValidationError(t, e);
|
|
2220
2437
|
}
|
|
2221
2438
|
setupEventListeners() {
|
|
2222
2439
|
this.setupElementEvents(), this.setupContainerEvents();
|
|
@@ -2302,11 +2519,11 @@ class V {
|
|
|
2302
2519
|
const t = this.element;
|
|
2303
2520
|
if (!((o = t.value) != null && o.length)) return;
|
|
2304
2521
|
const e = t.value.split(this.locale.separator), { startDate: a, endDate: i } = this.parseDateParts(e);
|
|
2305
|
-
a &&
|
|
2522
|
+
a && k(a) && i && k(i) && (this.setStartDate(a), this.setEndDate(i), this.updateView());
|
|
2306
2523
|
}
|
|
2307
2524
|
parseDateParts(t) {
|
|
2308
2525
|
let e = null, a = null;
|
|
2309
|
-
return t.length === 2 ? (e =
|
|
2526
|
+
return t.length === 2 ? (e = f(t[0].trim(), this.locale.format), a = f(t[1].trim(), this.locale.format)) : (this.options.singleDatePicker || t.length === 1) && (e = f(t[0].trim(), this.locale.format), a = e), { startDate: e, endDate: a };
|
|
2310
2527
|
}
|
|
2311
2528
|
handleKeydown(t) {
|
|
2312
2529
|
t.key === "Tab" || t.key === "Enter" ? this.hide() : t.key === "Escape" && (t.preventDefault(), t.stopPropagation(), this.hide());
|
|
@@ -2320,8 +2537,8 @@ class V {
|
|
|
2320
2537
|
else {
|
|
2321
2538
|
const i = this.options.ranges[a];
|
|
2322
2539
|
if (i) {
|
|
2323
|
-
const [o,
|
|
2324
|
-
this.state.startDate = new Date(o), this.state.endDate = new Date(
|
|
2540
|
+
const [o, n] = i;
|
|
2541
|
+
this.state.startDate = new Date(o), this.state.endDate = new Date(n), this.showCalendars(), this.updateView(), this.options.autoApply && this.handleApplyClick();
|
|
2325
2542
|
}
|
|
2326
2543
|
}
|
|
2327
2544
|
}
|
|
@@ -2358,38 +2575,38 @@ class V {
|
|
|
2358
2575
|
))), this.updateCalendars());
|
|
2359
2576
|
}
|
|
2360
2577
|
handleDateClick(t) {
|
|
2361
|
-
var
|
|
2578
|
+
var n, r;
|
|
2362
2579
|
const e = t.target;
|
|
2363
2580
|
if (!e.classList.contains("available")) return;
|
|
2364
2581
|
const a = e.dataset.date;
|
|
2365
2582
|
if (!a) return;
|
|
2366
|
-
const i =
|
|
2367
|
-
if (!
|
|
2583
|
+
const i = f(a, "YYYY-MM-DD");
|
|
2584
|
+
if (!k(i)) return;
|
|
2368
2585
|
const o = this.validationService.validateDate(i);
|
|
2369
2586
|
if (!o.isValid) {
|
|
2370
2587
|
this.showValidationError(o.error, o.errorCode);
|
|
2371
2588
|
return;
|
|
2372
2589
|
}
|
|
2373
|
-
if (!((
|
|
2374
|
-
if (this.applyTimeToDate(i, e), this.state.hoverDate = null, this.state.endDate ||
|
|
2590
|
+
if (!((n = this.options.events) != null && n.beforeDateSelect && !this.options.events.beforeDateSelect(i))) {
|
|
2591
|
+
if (this.applyTimeToDate(i, e), this.state.hoverDate = null, this.state.endDate || x(i, this.state.startDate))
|
|
2375
2592
|
this.state.endDate = null, this.setStartDate(i);
|
|
2376
2593
|
else {
|
|
2377
2594
|
if (this.setEndDate(i), this.state.startDate && this.state.endDate) {
|
|
2378
|
-
const
|
|
2595
|
+
const s = this.validationService.validateDateRange(
|
|
2379
2596
|
this.state.startDate,
|
|
2380
2597
|
this.state.endDate
|
|
2381
2598
|
);
|
|
2382
|
-
if (!
|
|
2599
|
+
if (!s.isValid) {
|
|
2383
2600
|
this.showValidationError(
|
|
2384
|
-
|
|
2385
|
-
|
|
2601
|
+
s.error,
|
|
2602
|
+
s.errorCode
|
|
2386
2603
|
), this.state.endDate = null, this.updateDateClasses();
|
|
2387
2604
|
return;
|
|
2388
2605
|
}
|
|
2389
2606
|
}
|
|
2390
2607
|
this.options.autoApply && (this.calculateChosenLabel(), this.handleApplyClick());
|
|
2391
2608
|
}
|
|
2392
|
-
this.options.singleDatePicker && (this.setEndDate(this.state.startDate), this.options.autoApply && this.handleApplyClick()), (
|
|
2609
|
+
this.options.singleDatePicker && (this.setEndDate(this.state.startDate), this.options.autoApply && this.handleApplyClick()), (r = this.options.events) != null && r.onDateSelect && this.options.events.onDateSelect(i), this.updateDateClasses();
|
|
2393
2610
|
}
|
|
2394
2611
|
}
|
|
2395
2612
|
handleDateHover(t) {
|
|
@@ -2397,46 +2614,46 @@ class V {
|
|
|
2397
2614
|
if (!e.classList.contains("available")) return;
|
|
2398
2615
|
const a = e.dataset.date;
|
|
2399
2616
|
if (!a) return;
|
|
2400
|
-
const i =
|
|
2401
|
-
|
|
2617
|
+
const i = f(a, "YYYY-MM-DD");
|
|
2618
|
+
k(i) && !this.state.endDate && !x(i, this.state.startDate) && (this.state.hoverDate = i, this.updateDateClasses());
|
|
2402
2619
|
}
|
|
2403
2620
|
handleMonthYearChange(t) {
|
|
2404
2621
|
const a = t.target.closest(".drp-calendar");
|
|
2405
2622
|
if (!a) return;
|
|
2406
2623
|
const i = a.classList.contains("left"), o = a.querySelector(
|
|
2407
2624
|
".monthselect"
|
|
2408
|
-
),
|
|
2625
|
+
), n = a.querySelector(
|
|
2409
2626
|
".yearselect"
|
|
2410
2627
|
);
|
|
2411
|
-
if (!o || !
|
|
2412
|
-
const
|
|
2628
|
+
if (!o || !n) return;
|
|
2629
|
+
const r = parseInt(o.value, 10), s = parseInt(n.value, 10), d = new Date(s, r, 1);
|
|
2413
2630
|
i ? (this.state.leftCalendar.month = d, this.options.linkedCalendars && (this.state.rightCalendar.month = g(d, 1))) : (this.state.rightCalendar.month = d, this.options.linkedCalendars && (this.state.leftCalendar.month = g(d, -1))), this.updateCalendars();
|
|
2414
2631
|
}
|
|
2415
2632
|
handleTimeChange(t) {
|
|
2416
2633
|
const a = t.target.closest(".drp-calendar");
|
|
2417
2634
|
if (!a) return;
|
|
2418
|
-
const i = a.classList.contains("left"), o = i ? this.state.startDate : this.state.endDate || this.state.startDate,
|
|
2635
|
+
const i = a.classList.contains("left"), o = i ? this.state.startDate : this.state.endDate || this.state.startDate, n = a.querySelector(
|
|
2419
2636
|
".hourselect"
|
|
2420
|
-
), n = a.querySelector(
|
|
2421
|
-
".minuteselect"
|
|
2422
2637
|
), r = a.querySelector(
|
|
2638
|
+
".minuteselect"
|
|
2639
|
+
), s = a.querySelector(
|
|
2423
2640
|
".secondselect"
|
|
2424
2641
|
), d = a.querySelector(
|
|
2425
2642
|
".ampmselect"
|
|
2426
2643
|
);
|
|
2427
|
-
if (!
|
|
2428
|
-
let c = parseInt(
|
|
2429
|
-
const
|
|
2644
|
+
if (!n || !r) return;
|
|
2645
|
+
let c = parseInt(n.value, 10);
|
|
2646
|
+
const m = parseInt(r.value, 10) || 0, h = s ? parseInt(s.value, 10) : 0;
|
|
2430
2647
|
if (!this.options.timePicker24Hour && d) {
|
|
2431
|
-
const
|
|
2432
|
-
|
|
2648
|
+
const b = d.value;
|
|
2649
|
+
b === "PM" && c < 12 && (c += 12), b === "AM" && c === 12 && (c = 0);
|
|
2433
2650
|
}
|
|
2434
2651
|
const p = new Date(o);
|
|
2435
|
-
if (p.setHours(c), p.setMinutes(
|
|
2652
|
+
if (p.setHours(c), p.setMinutes(m), p.setSeconds(h), this.options.timePickerIncrement && this.roundToIncrement(p), !(this.options.minDate && p < this.options.minDate) && !(this.options.maxDate && p > this.options.maxDate)) {
|
|
2436
2653
|
if (this.validationService) {
|
|
2437
|
-
const
|
|
2438
|
-
if (!
|
|
2439
|
-
this.showValidationError(
|
|
2654
|
+
const b = this.validationService.validateDate(p);
|
|
2655
|
+
if (!b.isValid) {
|
|
2656
|
+
this.showValidationError(b.error, b.errorCode);
|
|
2440
2657
|
return;
|
|
2441
2658
|
}
|
|
2442
2659
|
}
|
|
@@ -2476,7 +2693,7 @@ class V {
|
|
|
2476
2693
|
e.calendar = this.calendarService.buildCalendarMatrix(
|
|
2477
2694
|
e.month
|
|
2478
2695
|
);
|
|
2479
|
-
const i = this.calendarService.canNavigatePrevious(e.month), o = this.calendarService.canNavigateNext(e.month),
|
|
2696
|
+
const i = this.calendarService.canNavigatePrevious(e.month), o = this.calendarService.canNavigateNext(e.month), n = this.calendarService.renderCalendarHTML(
|
|
2480
2697
|
e,
|
|
2481
2698
|
t,
|
|
2482
2699
|
this.state.startDate,
|
|
@@ -2484,18 +2701,18 @@ class V {
|
|
|
2484
2701
|
i,
|
|
2485
2702
|
o
|
|
2486
2703
|
);
|
|
2487
|
-
a.innerHTML =
|
|
2704
|
+
a.innerHTML = n;
|
|
2488
2705
|
}
|
|
2489
2706
|
updateFormInputs() {
|
|
2490
2707
|
const t = this.container.querySelector(
|
|
2491
2708
|
".applyBtn"
|
|
2492
|
-
), e = this.options.singleDatePicker || this.state.endDate && (
|
|
2709
|
+
), e = this.options.singleDatePicker || this.state.endDate && (x(this.state.startDate, this.state.endDate) || u(this.state.startDate, this.state.endDate, "day"));
|
|
2493
2710
|
t.disabled = !e, this.updateMobileHeaderButtons();
|
|
2494
2711
|
}
|
|
2495
2712
|
updateSelectedDisplay() {
|
|
2496
2713
|
const t = this.container.querySelector(".drp-selected");
|
|
2497
|
-
let e =
|
|
2498
|
-
!this.options.singleDatePicker && this.state.endDate && (e += this.locale.separator +
|
|
2714
|
+
let e = D(this.state.startDate, this.locale.format);
|
|
2715
|
+
!this.options.singleDatePicker && this.state.endDate && (e += this.locale.separator + D(this.state.endDate, this.locale.format)), t.textContent = e, this.updateMobileHeader(e);
|
|
2499
2716
|
}
|
|
2500
2717
|
updateMobileHeader(t) {
|
|
2501
2718
|
const e = this.container.querySelector(
|
|
@@ -2512,15 +2729,15 @@ class V {
|
|
|
2512
2729
|
".mobile-applyBtn"
|
|
2513
2730
|
);
|
|
2514
2731
|
if (t) {
|
|
2515
|
-
const e = this.options.singleDatePicker || this.state.endDate && (
|
|
2732
|
+
const e = this.options.singleDatePicker || this.state.endDate && (x(this.state.startDate, this.state.endDate) || u(this.state.startDate, this.state.endDate, "day"));
|
|
2516
2733
|
t.disabled = !e;
|
|
2517
2734
|
}
|
|
2518
2735
|
}
|
|
2519
2736
|
updateElement() {
|
|
2520
2737
|
if (this.element.tagName === "INPUT" && this.options.autoUpdateInput) {
|
|
2521
2738
|
const t = this.element;
|
|
2522
|
-
let e =
|
|
2523
|
-
!this.options.singleDatePicker && this.state.endDate && (e += this.locale.separator +
|
|
2739
|
+
let e = D(this.state.startDate, this.locale.format);
|
|
2740
|
+
!this.options.singleDatePicker && this.state.endDate && (e += this.locale.separator + D(this.state.endDate, this.locale.format)), e !== t.value && (t.value = e, this.eventService.dispatchEvent(this.element, "change"));
|
|
2524
2741
|
}
|
|
2525
2742
|
}
|
|
2526
2743
|
renderRanges() {
|
|
@@ -2547,13 +2764,13 @@ class V {
|
|
|
2547
2764
|
this.container.querySelectorAll("td[data-date]").forEach((e) => {
|
|
2548
2765
|
const a = e.dataset.date;
|
|
2549
2766
|
if (!a) return;
|
|
2550
|
-
const i =
|
|
2551
|
-
if (!
|
|
2767
|
+
const i = f(a, "YYYY-MM-DD");
|
|
2768
|
+
if (!k(i)) return;
|
|
2552
2769
|
e.classList.remove("in-range", "end-date", "start-date", "active");
|
|
2553
|
-
const o = this.state.startDate,
|
|
2554
|
-
if (o &&
|
|
2555
|
-
const
|
|
2556
|
-
|
|
2770
|
+
const o = this.state.startDate, n = this.state.endDate, r = this.state.hoverDate;
|
|
2771
|
+
if (o && u(i, o, "day") && e.classList.add("active", "start-date"), n && u(i, n, "day") && e.classList.add("active", "end-date"), o && n && y(i, o) && x(i, n) && e.classList.add("in-range"), o && r && !n) {
|
|
2772
|
+
const s = x(r, o) ? r : o, d = x(r, o) ? o : r;
|
|
2773
|
+
u(i, r, "day") ? e.classList.add("end-date") : y(i, s) && x(i, d) && e.classList.add("in-range");
|
|
2557
2774
|
}
|
|
2558
2775
|
});
|
|
2559
2776
|
}
|
|
@@ -2565,24 +2782,24 @@ class V {
|
|
|
2565
2782
|
".hourselect"
|
|
2566
2783
|
), o = a.querySelector(
|
|
2567
2784
|
".minuteselect"
|
|
2568
|
-
), s = a.querySelector(
|
|
2569
|
-
".secondselect"
|
|
2570
2785
|
), n = a.querySelector(
|
|
2786
|
+
".secondselect"
|
|
2787
|
+
), r = a.querySelector(
|
|
2571
2788
|
".ampmselect"
|
|
2572
2789
|
);
|
|
2573
2790
|
if (i) {
|
|
2574
|
-
let
|
|
2575
|
-
if (!this.options.timePicker24Hour &&
|
|
2576
|
-
const d =
|
|
2577
|
-
d === "PM" &&
|
|
2791
|
+
let s = parseInt(i.value, 10);
|
|
2792
|
+
if (!this.options.timePicker24Hour && r) {
|
|
2793
|
+
const d = r.value;
|
|
2794
|
+
d === "PM" && s < 12 && (s += 12), d === "AM" && s === 12 && (s = 0);
|
|
2578
2795
|
}
|
|
2579
|
-
t.setHours(
|
|
2796
|
+
t.setHours(s);
|
|
2580
2797
|
}
|
|
2581
2798
|
if (o) {
|
|
2582
|
-
const
|
|
2583
|
-
t.setMinutes(
|
|
2799
|
+
const s = parseInt(o.value, 10) || 0;
|
|
2800
|
+
t.setMinutes(s);
|
|
2584
2801
|
}
|
|
2585
|
-
this.options.timePickerSeconds &&
|
|
2802
|
+
this.options.timePickerSeconds && n && t.setSeconds(parseInt(n.value, 10));
|
|
2586
2803
|
}
|
|
2587
2804
|
createRangeService() {
|
|
2588
2805
|
return {
|
|
@@ -2594,13 +2811,13 @@ class V {
|
|
|
2594
2811
|
},
|
|
2595
2812
|
calculateChosenLabel: (t, e) => {
|
|
2596
2813
|
let a = null;
|
|
2597
|
-
for (const [i, [o,
|
|
2814
|
+
for (const [i, [o, n]] of Object.entries(
|
|
2598
2815
|
this.options.ranges
|
|
2599
2816
|
)) {
|
|
2600
|
-
const
|
|
2601
|
-
let
|
|
2602
|
-
if (e ?
|
|
2603
|
-
const d = Math.abs(
|
|
2817
|
+
const r = u(t, o, "day");
|
|
2818
|
+
let s = !1;
|
|
2819
|
+
if (e ? s = u(e, n, "day") : s = u(t, n, "day"), r && s) {
|
|
2820
|
+
const d = Math.abs(n.getTime() - o.getTime()) / 864e5 + 1;
|
|
2604
2821
|
(!a || d > a.days) && (a = { label: i, days: d });
|
|
2605
2822
|
}
|
|
2606
2823
|
}
|
|
@@ -2619,19 +2836,19 @@ class V {
|
|
|
2619
2836
|
}
|
|
2620
2837
|
export {
|
|
2621
2838
|
Y as BOOTSTRAP_THEME,
|
|
2622
|
-
|
|
2623
|
-
|
|
2839
|
+
M as DEFAULT_THEME,
|
|
2840
|
+
N as Datex,
|
|
2624
2841
|
z as MATERIAL_THEME,
|
|
2625
|
-
|
|
2842
|
+
I as SPANISH_LOCALE,
|
|
2626
2843
|
R as SPANISH_LOCALE_WITH_TIME,
|
|
2627
2844
|
g as addMonths,
|
|
2628
2845
|
S as endOfDay,
|
|
2629
|
-
|
|
2846
|
+
D as formatDate,
|
|
2630
2847
|
w as getStartOfMonth,
|
|
2631
2848
|
y as isAfterDate,
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2849
|
+
x as isBeforeDate,
|
|
2850
|
+
u as isSameDate,
|
|
2851
|
+
k as isValidDate,
|
|
2852
|
+
f as parseDate,
|
|
2636
2853
|
C as startOfDay
|
|
2637
2854
|
};
|