@featherk/composables 0.6.19 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -38
- package/dist/__tests__/fixtures.d.ts +9 -0
- package/dist/__tests__/withSetupHarness.d.ts +9 -0
- package/dist/date/useMaskedDateInput.test.d.ts +1 -0
- package/dist/featherk-composables.es.js +300 -311
- package/dist/featherk-composables.umd.js +1 -1
- package/dist/grid/index.d.ts +2 -1
- package/dist/{useGridA11y.d.ts → grid/useGridA11y.d.ts} +1 -1
- package/dist/grid/useGridA11y.test.d.ts +1 -0
- package/dist/grid/useGridActiveFilter.d.ts +22 -0
- package/dist/grid/useGridActiveFilter.test.d.ts +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/range/useMaskedDateRangeInput.test.d.ts +1 -0
- package/dist/time/useMaskedTimeInput.test.d.ts +1 -0
- package/dist/trap/usePopupTrap.test.d.ts +1 -0
- package/docs/grid/useGridActiveFilter.md +108 -0
- package/docs/range/useMaskedDateRangeInput.md +2 -2
- package/docs/trap/usePopupTrap.md +1 -2
- package/package.json +11 -20
- package/dist/useGridFilter.d.ts +0 -7
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as Q, onBeforeUnmount as Ie, nextTick as j, computed as b, watch as ge, onMounted as xe, readonly as G, getCurrentScope as Le, onScopeDispose as Te, toValue as de, unref as Re, shallowRef as Fe } from "vue";
|
|
2
2
|
import { useFocusTrap as qe } from "@vueuse/integrations/useFocusTrap";
|
|
3
3
|
const _e = (e, t) => {
|
|
4
|
-
const s =
|
|
5
|
-
let
|
|
4
|
+
const s = Q(null);
|
|
5
|
+
let N = !1, q = null, U = null;
|
|
6
6
|
const H = [], x = ".k-table-row[data-grid-row-index] [tabindex]", D = () => {
|
|
7
7
|
const a = e?.value?.$el;
|
|
8
8
|
return a ? a.closest(".k-grid") : null;
|
|
@@ -16,7 +16,7 @@ const _e = (e, t) => {
|
|
|
16
16
|
".k-grid-header, .k-grid-content, .k-grid-content-locked"
|
|
17
17
|
);
|
|
18
18
|
return c ? m.contains(c) : !1;
|
|
19
|
-
}, w = (a) => a.key === "Enter" || a.code === "Enter" || a.code === "NumpadEnter",
|
|
19
|
+
}, w = (a) => a.key === "Enter" || a.code === "Enter" || a.code === "NumpadEnter", C = () => e?.value?.columns, A = (a) => {
|
|
20
20
|
const m = a.key || a.code;
|
|
21
21
|
([" ", "Spacebar", "Space"].includes(m) || w(a)) && (a.preventDefault(), a.stopPropagation(), s.value = a.target, a.target.click());
|
|
22
22
|
}, E = (a) => {
|
|
@@ -50,8 +50,8 @@ const _e = (e, t) => {
|
|
|
50
50
|
const h = f.findIndex(
|
|
51
51
|
(W) => W === document.activeElement
|
|
52
52
|
);
|
|
53
|
-
let
|
|
54
|
-
h === -1 ?
|
|
53
|
+
let I;
|
|
54
|
+
h === -1 ? I = 0 : a.shiftKey ? I = (h - 1 + f.length) % f.length : I = (h + 1) % f.length, a.preventDefault(), a.stopPropagation(), f[I]?.focus();
|
|
55
55
|
}
|
|
56
56
|
} else if (a.code === "ArrowUp" || a.code === "ArrowDown") {
|
|
57
57
|
a.preventDefault(), a.stopPropagation();
|
|
@@ -69,8 +69,8 @@ const _e = (e, t) => {
|
|
|
69
69
|
"button, [role='button'], .k-link"
|
|
70
70
|
)?.focus();
|
|
71
71
|
}
|
|
72
|
-
},
|
|
73
|
-
|
|
72
|
+
}, P = () => {
|
|
73
|
+
q = new MutationObserver((a) => {
|
|
74
74
|
a.forEach((m) => {
|
|
75
75
|
m.addedNodes.forEach((i) => {
|
|
76
76
|
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -88,14 +88,14 @@ const _e = (e, t) => {
|
|
|
88
88
|
E
|
|
89
89
|
), j(() => {
|
|
90
90
|
const h = () => {
|
|
91
|
-
const
|
|
91
|
+
const I = Array.from(
|
|
92
92
|
c.querySelectorAll(
|
|
93
93
|
".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
|
|
94
94
|
)
|
|
95
95
|
);
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
else if (
|
|
96
|
+
if (I.length === 1)
|
|
97
|
+
I[0].focus(), I[0].click(), h.attempts = 0;
|
|
98
|
+
else if (I.length > 1) {
|
|
99
99
|
h.attempts = 0;
|
|
100
100
|
return;
|
|
101
101
|
} else
|
|
@@ -130,11 +130,11 @@ const _e = (e, t) => {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
|
-
}),
|
|
133
|
+
}), q.observe(document.body, {
|
|
134
134
|
childList: !0,
|
|
135
135
|
subtree: !0
|
|
136
136
|
});
|
|
137
|
-
},
|
|
137
|
+
}, O = (a) => {
|
|
138
138
|
const m = a.tagName.toLowerCase();
|
|
139
139
|
return !!(["input", "textarea", "select", "button"].includes(m) || a.closest(
|
|
140
140
|
'.k-picker-wrap, .k-input-inner, .k-textbox, [role="combobox"]'
|
|
@@ -152,7 +152,7 @@ const _e = (e, t) => {
|
|
|
152
152
|
const c = ["ArrowLeft", "ArrowRight"].includes(
|
|
153
153
|
a.code
|
|
154
154
|
);
|
|
155
|
-
if (!(
|
|
155
|
+
if (!(O(m) && !(i && c))) {
|
|
156
156
|
if (a.code === "Escape") {
|
|
157
157
|
const y = document.activeElement?.closest(".k-table-row[data-grid-row-index]");
|
|
158
158
|
if (y) {
|
|
@@ -185,8 +185,8 @@ const _e = (e, t) => {
|
|
|
185
185
|
if (i) {
|
|
186
186
|
if (["ArrowDown", "ArrowUp"].includes(a.code)) {
|
|
187
187
|
a.preventDefault(), a.stopPropagation();
|
|
188
|
-
const y = (h,
|
|
189
|
-
let W =
|
|
188
|
+
const y = (h, I) => {
|
|
189
|
+
let W = I === "next" ? h.nextElementSibling : h.previousElementSibling;
|
|
190
190
|
for (; W; ) {
|
|
191
191
|
const o = W;
|
|
192
192
|
try {
|
|
@@ -194,7 +194,7 @@ const _e = (e, t) => {
|
|
|
194
194
|
return o;
|
|
195
195
|
} catch {
|
|
196
196
|
}
|
|
197
|
-
W =
|
|
197
|
+
W = I === "next" ? W.nextElementSibling : W.previousElementSibling;
|
|
198
198
|
}
|
|
199
199
|
return null;
|
|
200
200
|
}, f = a.code === "ArrowDown" ? y(i, "next") : y(i, "previous");
|
|
@@ -225,8 +225,8 @@ const _e = (e, t) => {
|
|
|
225
225
|
const a = e.value.$el.closest(".k-grid");
|
|
226
226
|
a && a.classList.add("fk-grid");
|
|
227
227
|
});
|
|
228
|
-
},
|
|
229
|
-
if (!
|
|
228
|
+
}, R = () => {
|
|
229
|
+
if (!U)
|
|
230
230
|
try {
|
|
231
231
|
const a = () => {
|
|
232
232
|
try {
|
|
@@ -258,9 +258,9 @@ const _e = (e, t) => {
|
|
|
258
258
|
c.setAttribute("tabindex", y === 0 ? "0" : "-1");
|
|
259
259
|
});
|
|
260
260
|
const i = e.value.$el.querySelector(".k-table-tbody");
|
|
261
|
-
i && (
|
|
261
|
+
i && (U = new MutationObserver(() => {
|
|
262
262
|
a();
|
|
263
|
-
}),
|
|
263
|
+
}), U.observe(i, { childList: !0, subtree: !0 }));
|
|
264
264
|
} catch (a) {
|
|
265
265
|
console.error("Error setting up row navigation:", a);
|
|
266
266
|
}
|
|
@@ -272,7 +272,7 @@ const _e = (e, t) => {
|
|
|
272
272
|
"keydown",
|
|
273
273
|
A
|
|
274
274
|
);
|
|
275
|
-
}),
|
|
275
|
+
}), P(), ee();
|
|
276
276
|
});
|
|
277
277
|
}, _ = () => {
|
|
278
278
|
const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
|
|
@@ -281,7 +281,7 @@ const _e = (e, t) => {
|
|
|
281
281
|
"keydown",
|
|
282
282
|
A
|
|
283
283
|
);
|
|
284
|
-
}),
|
|
284
|
+
}), q && (q.disconnect(), q = null), U && (U.disconnect(), U = null), H.forEach((i) => i()), H.length = 0;
|
|
285
285
|
}, ee = () => {
|
|
286
286
|
document.querySelectorAll(
|
|
287
287
|
".k-grid-header .k-table-thead th"
|
|
@@ -292,7 +292,7 @@ const _e = (e, t) => {
|
|
|
292
292
|
".k-grid-header-menu.k-grid-column-menu"
|
|
293
293
|
);
|
|
294
294
|
if (!y) return;
|
|
295
|
-
const f =
|
|
295
|
+
const f = C();
|
|
296
296
|
if (f && f[c]) {
|
|
297
297
|
const v = f[c].field ?? "";
|
|
298
298
|
i.setAttribute("data-feather-k-field", v), i.setAttribute(
|
|
@@ -303,29 +303,29 @@ const _e = (e, t) => {
|
|
|
303
303
|
f[c].sortable === !1 ? "false" : "true"
|
|
304
304
|
);
|
|
305
305
|
}
|
|
306
|
-
const h = i.dataset.featherKFilterable !== "false",
|
|
307
|
-
y.setAttribute("tabindex", "-1"), h ||
|
|
306
|
+
const h = i.dataset.featherKFilterable !== "false", I = i.dataset.featherKSortable !== "false";
|
|
307
|
+
y.setAttribute("tabindex", "-1"), h || I ? i.style.cursor = "pointer" : i.style.cursor = "default", h ? (i.setAttribute("tabindex", "0"), i.setAttribute("role", "button"), i.setAttribute("aria-haspopup", "menu")) : (i.setAttribute("tabindex", "0"), i.setAttribute("role", "columnheader"), i.removeAttribute("aria-haspopup"));
|
|
308
308
|
const W = (v) => {
|
|
309
309
|
v.target?.closest(".k-column-resizer") || (s.value = i, y.click());
|
|
310
310
|
}, o = (v) => {
|
|
311
311
|
if (h)
|
|
312
312
|
s.value = i, v.preventDefault(), v.stopPropagation(), W(v);
|
|
313
|
-
else if (
|
|
313
|
+
else if (I) {
|
|
314
314
|
s.value = i;
|
|
315
|
-
const
|
|
316
|
-
|
|
315
|
+
const T = i.querySelector(".k-link");
|
|
316
|
+
T && T.click();
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
319
|
i.addEventListener("click", o), H.push(() => {
|
|
320
320
|
i.removeEventListener("click", o);
|
|
321
321
|
});
|
|
322
322
|
const d = (v) => {
|
|
323
|
-
if ((w(v) || v.code === "Space") && (h ||
|
|
323
|
+
if ((w(v) || v.code === "Space") && (h || I)) {
|
|
324
324
|
if (v.preventDefault(), v.stopPropagation(), s.value = i, s.value.focus(), h)
|
|
325
325
|
W(v);
|
|
326
|
-
else if (
|
|
327
|
-
const
|
|
328
|
-
|
|
326
|
+
else if (I) {
|
|
327
|
+
const T = i.querySelector(".k-link");
|
|
328
|
+
T && T.click();
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
};
|
|
@@ -353,9 +353,9 @@ const _e = (e, t) => {
|
|
|
353
353
|
}), m.dataset.featherKHeaderBound = "true";
|
|
354
354
|
}
|
|
355
355
|
}, te = function(a, m) {
|
|
356
|
-
const i = a?.event?.event.target, c =
|
|
356
|
+
const i = a?.event?.event.target, c = C();
|
|
357
357
|
if (!i || !c) return;
|
|
358
|
-
const y = i.classList.contains("k-grid-header-menu"), f = i.classList.contains("k-columnmenu-item"), h = c.find((
|
|
358
|
+
const y = i.classList.contains("k-grid-header-menu"), f = i.classList.contains("k-columnmenu-item"), h = c.find((I) => I.field === a?.event?.field)?.sortable && !0;
|
|
359
359
|
if (!y) {
|
|
360
360
|
if (f && !h) {
|
|
361
361
|
a?.event?.sort?.filter(
|
|
@@ -370,9 +370,9 @@ const _e = (e, t) => {
|
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
}, le = () => {
|
|
373
|
-
if (!
|
|
373
|
+
if (!N)
|
|
374
374
|
try {
|
|
375
|
-
S(),
|
|
375
|
+
S(), R(), X(), N = !0;
|
|
376
376
|
} catch (a) {
|
|
377
377
|
console.error("initA11y failed:", a), _();
|
|
378
378
|
}
|
|
@@ -385,9 +385,13 @@ const _e = (e, t) => {
|
|
|
385
385
|
handleSortChange: te,
|
|
386
386
|
initA11y: le
|
|
387
387
|
};
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
}, Ue = (e) => !!e && typeof e == "object" && "filters" in e && Array.isArray(e.filters), Oe = (e) => !!e && typeof e == "object" && "field" in e, $e = (e, t) => !e || typeof e != "object" ? !1 : Ue(e) ? e.filters.some(
|
|
389
|
+
(s) => $e(s, t)
|
|
390
|
+
) : Oe(e) ? e.field === t : !1, ze = (e) => (t) => e.value?.filters && e.value.filters.some(
|
|
391
|
+
(s) => $e(s, t)
|
|
392
|
+
) ? "active" : "";
|
|
393
|
+
function Xe(e) {
|
|
394
|
+
const t = Q(""), s = Q(void 0), N = Q(!!e.debug), q = Q(e.dateFormat ?? "mm/dd/yyyy"), U = b(() => !!e.required), H = Q(!1), x = ["ArrowUp", "ArrowDown"], D = ["ArrowLeft", "ArrowRight"], k = b(() => (t.value ?? "").replace(/\D/g, "")), w = (o) => o <= 2 ? "mm" : o <= 5 ? "dd" : k.value.length <= 10 ? "yyyy" : "mm", C = b(() => {
|
|
391
395
|
const o = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0";
|
|
392
396
|
return parseInt(o).toString().padStart(2, "0");
|
|
393
397
|
}), A = b(() => {
|
|
@@ -396,7 +400,7 @@ function ze(e) {
|
|
|
396
400
|
}), E = b(() => {
|
|
397
401
|
const o = t.value && t.value.substring(6, 10).replace(/\D/g, "0") || "0";
|
|
398
402
|
return parseInt(o).toString().padStart(4, "0");
|
|
399
|
-
}),
|
|
403
|
+
}), P = (o) => {
|
|
400
404
|
if (k.value.length === 0) {
|
|
401
405
|
e.onChange({ value: null, event: o });
|
|
402
406
|
return;
|
|
@@ -406,61 +410,61 @@ function ze(e) {
|
|
|
406
410
|
return;
|
|
407
411
|
}
|
|
408
412
|
if ((t.value ?? "").length === 10 && k.value.length === 8) {
|
|
409
|
-
const [d, v,
|
|
410
|
-
if (X(Z,
|
|
411
|
-
const ie = new Date(Z,
|
|
412
|
-
|
|
413
|
+
const [d, v, T] = t.value.split("/"), K = parseInt(d), B = parseInt(v), Z = parseInt(T);
|
|
414
|
+
if (X(Z, K, B)) {
|
|
415
|
+
const ie = new Date(Z, K - 1, B);
|
|
416
|
+
O(ie) ? e.onChange({ value: ie, event: o }) : e.onChange({ value: null, event: o });
|
|
413
417
|
} else
|
|
414
418
|
e.onChange({ value: null, event: o });
|
|
415
419
|
}
|
|
416
|
-
},
|
|
420
|
+
}, O = (o) => {
|
|
417
421
|
const d = e.min ?? void 0, v = e.max ?? void 0;
|
|
418
422
|
return !(d && o < d || v && o > v);
|
|
419
423
|
}, p = b(() => {
|
|
420
424
|
if ((t.value ?? "").length === 10 && k.value.length === 8) {
|
|
421
|
-
const [o, d, v] = (t.value ?? "").split("/"),
|
|
422
|
-
if (X(
|
|
423
|
-
return new Date(
|
|
425
|
+
const [o, d, v] = (t.value ?? "").split("/"), T = parseInt(o), K = parseInt(d), B = parseInt(v);
|
|
426
|
+
if (X(B, T, K))
|
|
427
|
+
return new Date(B, T - 1, K);
|
|
424
428
|
}
|
|
425
429
|
return null;
|
|
426
|
-
}), S = b(() => (t.value ?? "").length === 10 && k.value.length === 8),
|
|
430
|
+
}), S = b(() => (t.value ?? "").length === 10 && k.value.length === 8), R = (o, d) => new Date(o, d, 0).getDate(), X = (o, d, v) => d >= 1 && d <= 12 && o >= 1900 && v >= 1 && v <= R(o, d), _ = (o) => {
|
|
427
431
|
t.value = o.value;
|
|
428
432
|
const d = o.event?.target;
|
|
429
|
-
s.value = d?.selectionStart ?? 0,
|
|
433
|
+
s.value = d?.selectionStart ?? 0, P(o);
|
|
430
434
|
}, ee = (o) => {
|
|
431
435
|
s.value = o.target.selectionStart ?? 0;
|
|
432
436
|
}, te = (o, d, v) => {
|
|
433
|
-
const
|
|
434
|
-
s.value =
|
|
435
|
-
let
|
|
436
|
-
if (!(k.value.length >= 8) || !X(Z,
|
|
437
|
+
const T = d?.selectionStart ?? s.value ?? 0;
|
|
438
|
+
s.value = T;
|
|
439
|
+
let K = parseInt(C.value), B = parseInt(A.value), Z = parseInt(E.value);
|
|
440
|
+
if (!(k.value.length >= 8) || !X(Z, K, B)) {
|
|
437
441
|
const z = e.defaultValue ?? /* @__PURE__ */ new Date();
|
|
438
|
-
|
|
442
|
+
K = z.getMonth() + 1, B = z.getDate(), Z = z.getFullYear(), t.value = `${String(K).padStart(2, "0")}/${String(B).padStart(
|
|
439
443
|
2,
|
|
440
444
|
"0"
|
|
441
445
|
)}/${String(Z)}`;
|
|
442
|
-
const
|
|
443
|
-
e.onChange({ value:
|
|
446
|
+
const F = new Date(Z, K - 1, B);
|
|
447
|
+
e.onChange({ value: O(F) ? F : null, event: v }), c({ useRAF: !0 });
|
|
444
448
|
return;
|
|
445
449
|
}
|
|
446
|
-
const r = w(
|
|
450
|
+
const r = w(T);
|
|
447
451
|
if (r === "mm")
|
|
448
|
-
|
|
452
|
+
K = o === "ArrowUp" ? K < 12 ? K + 1 : 1 : K > 1 ? K - 1 : 12;
|
|
449
453
|
else if (r === "dd") {
|
|
450
|
-
const z = new Date(Z,
|
|
451
|
-
|
|
454
|
+
const z = new Date(Z, K, 0).getDate();
|
|
455
|
+
B = o === "ArrowUp" ? B < z ? B + 1 : 1 : B > 1 ? B - 1 : z;
|
|
452
456
|
} else r === "yyyy" && (Z = o === "ArrowUp" ? Z + 1 : Math.max(1, Z - 1));
|
|
453
|
-
t.value = `${String(
|
|
457
|
+
t.value = `${String(K).padStart(2, "0")}/${String(B).padStart(
|
|
454
458
|
2,
|
|
455
459
|
"0"
|
|
456
460
|
)}/${String(Z)}`;
|
|
457
|
-
const [l,
|
|
458
|
-
parseInt(
|
|
461
|
+
const [l, $, L] = t.value.split("/"), V = new Date(
|
|
462
|
+
parseInt(L),
|
|
459
463
|
parseInt(l) - 1,
|
|
460
|
-
parseInt(
|
|
464
|
+
parseInt($)
|
|
461
465
|
);
|
|
462
|
-
|
|
463
|
-
value:
|
|
466
|
+
V.toString() !== "Invalid Date" && parseInt(L) >= 1e3 ? e.onChange({
|
|
467
|
+
value: O(V) ? V : null,
|
|
464
468
|
event: v
|
|
465
469
|
}) : e.onChange({ value: null, event: v }), c({ useRAF: !0 });
|
|
466
470
|
}, le = (o) => {
|
|
@@ -494,7 +498,7 @@ function ze(e) {
|
|
|
494
498
|
s.value = d?.selectionStart ?? 0;
|
|
495
499
|
}
|
|
496
500
|
}, i = (o) => {
|
|
497
|
-
H.value = !0,
|
|
501
|
+
H.value = !0, U.value && !e.defaultValue && e.externalValue && e.externalValue.value === void 0 && k.value.length === 0 && (e.externalValue.value = "");
|
|
498
502
|
const d = o.target;
|
|
499
503
|
d && (s.value = d.selectionStart ?? 0);
|
|
500
504
|
}, c = (o) => {
|
|
@@ -503,9 +507,9 @@ function ze(e) {
|
|
|
503
507
|
e.id
|
|
504
508
|
);
|
|
505
509
|
if (!v) return;
|
|
506
|
-
const
|
|
510
|
+
const T = o?.pos ?? s.value ?? v.value.length;
|
|
507
511
|
try {
|
|
508
|
-
v.focus(), v.setSelectionRange(
|
|
512
|
+
v.focus(), v.setSelectionRange(T, T);
|
|
509
513
|
} catch {
|
|
510
514
|
}
|
|
511
515
|
};
|
|
@@ -527,8 +531,8 @@ function ze(e) {
|
|
|
527
531
|
if (o) {
|
|
528
532
|
const d = new Date(o);
|
|
529
533
|
if (d.toString() !== "Invalid Date") {
|
|
530
|
-
const v = (d.getMonth() + 1).toString().padStart(2, "0"),
|
|
531
|
-
t.value = `${v}/${
|
|
534
|
+
const v = (d.getMonth() + 1).toString().padStart(2, "0"), T = d.getDate().toString().padStart(2, "0"), K = d.getFullYear().toString();
|
|
535
|
+
t.value = `${v}/${T}/${K}`, c({ delay: 50 });
|
|
532
536
|
return;
|
|
533
537
|
}
|
|
534
538
|
}
|
|
@@ -536,7 +540,7 @@ function ze(e) {
|
|
|
536
540
|
{ immediate: !0 }
|
|
537
541
|
);
|
|
538
542
|
const y = b(() => [
|
|
539
|
-
["Date", `${
|
|
543
|
+
["Date", `${C.value} / ${A.value} / ${E.value}`],
|
|
540
544
|
["Digits only", k.value],
|
|
541
545
|
[
|
|
542
546
|
"min",
|
|
@@ -555,32 +559,32 @@ function ze(e) {
|
|
|
555
559
|
}) ?? null
|
|
556
560
|
]
|
|
557
561
|
]), f = b(() => {
|
|
558
|
-
if (!
|
|
562
|
+
if (!U.value) {
|
|
559
563
|
if (!S.value) return !0;
|
|
560
564
|
const d = p.value;
|
|
561
|
-
return d ?
|
|
565
|
+
return d ? O(d) : !1;
|
|
562
566
|
}
|
|
563
567
|
if (!H.value) return !0;
|
|
564
568
|
const o = p.value;
|
|
565
|
-
return !S.value || !o ? !1 :
|
|
569
|
+
return !S.value || !o ? !1 : O(o);
|
|
566
570
|
}), h = b(() => {
|
|
567
|
-
if (!
|
|
571
|
+
if (!U.value) {
|
|
568
572
|
if (!S.value) return;
|
|
569
573
|
const d = p.value;
|
|
570
|
-
return d ?
|
|
574
|
+
return d ? O(d) ? "valid" : "out-of-bounds" : "invalid-date";
|
|
571
575
|
}
|
|
572
576
|
if (!H.value) return;
|
|
573
577
|
if (k.value.length === 0 || !S.value)
|
|
574
578
|
return "incomplete";
|
|
575
579
|
const o = p.value;
|
|
576
|
-
return o ?
|
|
577
|
-
}),
|
|
580
|
+
return o ? O(o) ? "valid" : "out-of-bounds" : "invalid-date";
|
|
581
|
+
}), I = b(() => {
|
|
578
582
|
const o = h.value;
|
|
579
583
|
if (!o || o === "valid") return "";
|
|
580
584
|
if (o === "incomplete")
|
|
581
585
|
return "Required";
|
|
582
586
|
if (o === "invalid-date")
|
|
583
|
-
return `Must be in ${
|
|
587
|
+
return `Must be in ${q.value} format.`;
|
|
584
588
|
const d = e.min ? e.min.toLocaleDateString("en-US", {
|
|
585
589
|
year: "numeric",
|
|
586
590
|
month: "2-digit",
|
|
@@ -626,14 +630,14 @@ function ze(e) {
|
|
|
626
630
|
}), {
|
|
627
631
|
raw: t,
|
|
628
632
|
cursorPos: s,
|
|
629
|
-
debugEnabled:
|
|
633
|
+
debugEnabled: N,
|
|
630
634
|
debugLines: y,
|
|
631
|
-
placeholder:
|
|
635
|
+
placeholder: q,
|
|
632
636
|
isValid: f,
|
|
633
637
|
reason: G(h),
|
|
634
|
-
validationMessage:
|
|
638
|
+
validationMessage: I,
|
|
635
639
|
digitsOnly: k,
|
|
636
|
-
month: G(
|
|
640
|
+
month: G(C),
|
|
637
641
|
day: G(A),
|
|
638
642
|
year: G(E),
|
|
639
643
|
datePart: w,
|
|
@@ -647,20 +651,20 @@ function ze(e) {
|
|
|
647
651
|
initStyling: W
|
|
648
652
|
};
|
|
649
653
|
}
|
|
650
|
-
function
|
|
651
|
-
const t =
|
|
654
|
+
function Je(e) {
|
|
655
|
+
const t = Q(""), s = Q(void 0), N = Q(!!e.debug), q = Q(!1), U = 1440 * 60 * 1e3, H = 365 * U, x = /* @__PURE__ */ new Date(), D = new Date(x.getTime() - H), k = new Date(x.getTime() + H);
|
|
652
656
|
e.min = e.min ?? D, e.max = e.max ?? k;
|
|
653
|
-
const w = b(() => (t.value ?? "").replace(/\D/g, "")),
|
|
657
|
+
const w = b(() => (t.value ?? "").replace(/\D/g, "")), C = (n, u) => new Date(n, u, 0).getDate(), A = (n, u, g) => u >= 1 && u <= 12 && n >= 1e3 && g >= 1 && g <= C(n, u), E = (n) => Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()), P = (n) => {
|
|
654
658
|
if (!n) return null;
|
|
655
|
-
const u = e.min ?? new Date(Date.now() - 90 *
|
|
659
|
+
const u = e.min ?? new Date(Date.now() - 90 * U), g = e.max ?? /* @__PURE__ */ new Date(), M = E(n);
|
|
656
660
|
return M < E(u) || M > E(g) ? null : n;
|
|
657
|
-
},
|
|
661
|
+
}, O = (n, u) => e.allowReverse ?? !1 ? !0 : n <= u, p = b(() => (t.value?.length ?? 0) >= 23 && w.value.length >= 16), S = (n) => {
|
|
658
662
|
if ((n ?? "").length < 23 || w.value.length < 16)
|
|
659
663
|
return { start: null, end: null };
|
|
660
664
|
const u = n.substring(0, 10), g = n.substring(13, 23), [M, ne, re] = u.split("/").map((ce) => parseInt(ce || "0", 10)), [se, fe, pe] = g.split("/").map((ce) => parseInt(ce || "0", 10)), me = new Date(re, M - 1, ne), he = new Date(pe, se - 1, fe), we = A(re, M, ne) && me.toString() !== "Invalid Date", ke = A(pe, se, fe) && he.toString() !== "Invalid Date";
|
|
661
665
|
return { start: we ? me : null, end: ke ? he : null };
|
|
662
|
-
},
|
|
663
|
-
const n =
|
|
666
|
+
}, R = e.externalValid ?? Q(!0), X = b(() => S(t.value)), _ = b(() => {
|
|
667
|
+
const n = P(X.value.start), u = P(X.value.end);
|
|
664
668
|
return { start: n, end: u };
|
|
665
669
|
}), ee = b(() => {
|
|
666
670
|
if (!p.value) return;
|
|
@@ -673,16 +677,16 @@ function Xe(e) {
|
|
|
673
677
|
const { start: n, end: u } = X.value;
|
|
674
678
|
if (!n || !u || !_.value.start || !_.value.end) return !1;
|
|
675
679
|
const g = _.value.start, M = _.value.end;
|
|
676
|
-
return !(!
|
|
680
|
+
return !(!O(g, M) || typeof e.maxSpanDays == "number" && ee.value !== void 0 && ee.value > e.maxSpanDays);
|
|
677
681
|
}), le = b(() => {
|
|
678
682
|
const { start: n, end: u } = X.value;
|
|
679
683
|
if (!p.value) return "incomplete";
|
|
680
684
|
if (!n || !u) return "invalid-date";
|
|
681
685
|
if (!_.value.start || !_.value.end) return "out-of-bounds";
|
|
682
686
|
const g = _.value.start, M = _.value.end;
|
|
683
|
-
return
|
|
684
|
-
}), a =
|
|
685
|
-
if (
|
|
687
|
+
return O(g, M) ? typeof e.maxSpanDays == "number" && ee.value !== void 0 && ee.value > e.maxSpanDays ? "span-exceeds-limit" : "valid" : "reversed-range";
|
|
688
|
+
}), a = Q(void 0), m = b(() => {
|
|
689
|
+
if (R.value !== !1) return "";
|
|
686
690
|
const { min: n, max: u } = e, g = a.value;
|
|
687
691
|
if (!g) return "";
|
|
688
692
|
switch (g) {
|
|
@@ -702,7 +706,7 @@ function Xe(e) {
|
|
|
702
706
|
}), i = ["ArrowUp", "ArrowDown"], c = ["ArrowLeft", "ArrowRight"], y = (n, u) => String(n).padStart(u, "0"), f = (n) => `${y(n.getMonth() + 1, 2)}/${y(n.getDate(), 2)}/${y(
|
|
703
707
|
n.getFullYear(),
|
|
704
708
|
4
|
|
705
|
-
)}`, h = (n) => n <= 2 ? { side: "start", part: "mm" } : n <= 5 ? { side: "start", part: (n <= 3, "dd") } : n <= 11 ? { side: "start", part: "yyyy" } : n <= 15 ? { side: "end", part: "mm" } : n <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" },
|
|
709
|
+
)}`, h = (n) => n <= 2 ? { side: "start", part: "mm" } : n <= 5 ? { side: "start", part: (n <= 3, "dd") } : n <= 11 ? { side: "start", part: "yyyy" } : n <= 15 ? { side: "end", part: "mm" } : n <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" }, I = (n, u, g) => {
|
|
706
710
|
const M = u?.selectionStart ?? s.value ?? 0;
|
|
707
711
|
s.value = M;
|
|
708
712
|
const { start: ne, end: re } = S(t.value);
|
|
@@ -724,23 +728,23 @@ function Xe(e) {
|
|
|
724
728
|
if (ue === "mm") {
|
|
725
729
|
const oe = Y.getMonth() + 1, ae = n === "ArrowUp" ? oe < 12 ? oe + 1 : 1 : oe > 1 ? oe - 1 : 12;
|
|
726
730
|
Y.setMonth(ae - 1);
|
|
727
|
-
const be =
|
|
731
|
+
const be = C(Y.getFullYear(), ae);
|
|
728
732
|
Y.getDate() > be && Y.setDate(be);
|
|
729
733
|
} else if (ue === "dd") {
|
|
730
|
-
const oe =
|
|
734
|
+
const oe = C(Y.getFullYear(), Y.getMonth() + 1), ae = Y.getDate(), be = n === "ArrowUp" ? ae < oe ? ae + 1 : 1 : ae > 1 ? ae - 1 : oe;
|
|
731
735
|
Y.setDate(be);
|
|
732
736
|
} else if (ue === "yyyy") {
|
|
733
737
|
const oe = Y.getFullYear();
|
|
734
738
|
Y.setFullYear(n === "ArrowUp" ? oe + 1 : Math.max(1, oe - 1));
|
|
735
|
-
const ae =
|
|
739
|
+
const ae = C(Y.getFullYear(), Y.getMonth() + 1);
|
|
736
740
|
Y.getDate() > ae && Y.setDate(ae);
|
|
737
741
|
}
|
|
738
742
|
};
|
|
739
743
|
fe.side === "start" ? he(pe, fe.part) : he(me, fe.part);
|
|
740
744
|
const we = f(pe), ke = f(me);
|
|
741
745
|
t.value = `${we} - ${ke}`;
|
|
742
|
-
const ce =
|
|
743
|
-
ce && De &&
|
|
746
|
+
const ce = P(pe), De = P(me);
|
|
747
|
+
ce && De && O(ce, De) ? e.onChange({ value: { start: ce, end: De }, event: g }) : e.onChange({ value: null, event: g }), j(() => {
|
|
744
748
|
requestAnimationFrame(() => {
|
|
745
749
|
const Y = document.getElementById(
|
|
746
750
|
e.id
|
|
@@ -754,12 +758,12 @@ function Xe(e) {
|
|
|
754
758
|
e.onChange({ value: null, event: n });
|
|
755
759
|
return;
|
|
756
760
|
}
|
|
757
|
-
const M =
|
|
761
|
+
const M = P(u), ne = P(g);
|
|
758
762
|
if (!M || !ne) {
|
|
759
763
|
e.onChange({ value: null, event: n });
|
|
760
764
|
return;
|
|
761
765
|
}
|
|
762
|
-
if (!
|
|
766
|
+
if (!O(M, ne)) {
|
|
763
767
|
e.onChange({ value: null, event: n });
|
|
764
768
|
return;
|
|
765
769
|
}
|
|
@@ -787,24 +791,24 @@ function Xe(e) {
|
|
|
787
791
|
if (i.includes(n.key)) {
|
|
788
792
|
n.preventDefault(), n.stopPropagation();
|
|
789
793
|
const u = n.target;
|
|
790
|
-
|
|
794
|
+
I(n.key, u, n);
|
|
791
795
|
return;
|
|
792
796
|
}
|
|
793
|
-
},
|
|
797
|
+
}, T = (n) => {
|
|
794
798
|
n.preventDefault();
|
|
795
799
|
const u = n.deltaY < 0 ? "ArrowUp" : "ArrowDown";
|
|
796
|
-
|
|
797
|
-
},
|
|
800
|
+
I(u, n.target, n);
|
|
801
|
+
}, K = (n) => {
|
|
798
802
|
if (c.includes(n.key) || i.includes(n.key)) {
|
|
799
803
|
const u = n.target;
|
|
800
804
|
s.value = u?.selectionStart ?? 0;
|
|
801
805
|
}
|
|
802
|
-
},
|
|
803
|
-
a.value = le.value, (e.manageValid ?? !0) && (
|
|
806
|
+
}, B = () => {
|
|
807
|
+
a.value = le.value, (e.manageValid ?? !0) && (R.value = te.value);
|
|
804
808
|
}, Z = (n) => {
|
|
805
|
-
|
|
809
|
+
B();
|
|
806
810
|
}, ie = (n) => {
|
|
807
|
-
console.log("Clear event:", n), t.value = "", s.value = 0, e.onChange({ value: null, event: n }),
|
|
811
|
+
console.log("Clear event:", n), t.value = "", s.value = 0, e.onChange({ value: null, event: n }), B(), j(() => {
|
|
808
812
|
const u = document.getElementById(
|
|
809
813
|
e.id
|
|
810
814
|
);
|
|
@@ -816,10 +820,10 @@ function Xe(e) {
|
|
|
816
820
|
(n) => {
|
|
817
821
|
const u = n?.start ?? null, g = n?.end ?? null;
|
|
818
822
|
if (u && g) {
|
|
819
|
-
if (t.value = `${f(u)} - ${f(g)}`, e.isOpen?.value &&
|
|
823
|
+
if (t.value = `${f(u)} - ${f(g)}`, e.isOpen?.value && q.value && e.onRequestClose) {
|
|
820
824
|
const M = typeof e.closeDelay == "number" ? e.closeDelay : e.closeDelay?.value ?? 0;
|
|
821
825
|
setTimeout(() => {
|
|
822
|
-
e.onRequestClose?.(),
|
|
826
|
+
e.onRequestClose?.(), q.value = !1, B();
|
|
823
827
|
}, M);
|
|
824
828
|
}
|
|
825
829
|
return;
|
|
@@ -831,15 +835,15 @@ function Xe(e) {
|
|
|
831
835
|
() => t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0"
|
|
832
836
|
), l = b(
|
|
833
837
|
() => t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0"
|
|
834
|
-
),
|
|
838
|
+
), $ = b(
|
|
835
839
|
() => t.value && t.value.substring(6, 10).replace(/\D/g, "0") || "0"
|
|
836
|
-
),
|
|
840
|
+
), L = b(
|
|
837
841
|
() => t.value && t.value.substring(13, 15).replace(/\D/g, "0") || "0"
|
|
838
|
-
),
|
|
842
|
+
), V = b(
|
|
839
843
|
() => t.value && t.value.substring(16, 18).replace(/\D/g, "0") || "0"
|
|
840
844
|
), z = b(
|
|
841
845
|
() => t.value && t.value.substring(19, 23).replace(/\D/g, "0") || "0"
|
|
842
|
-
),
|
|
846
|
+
), F = b(() => {
|
|
843
847
|
const { start: n, end: u } = S(t.value);
|
|
844
848
|
return [
|
|
845
849
|
{
|
|
@@ -858,12 +862,12 @@ function Xe(e) {
|
|
|
858
862
|
label: "Start",
|
|
859
863
|
value: `${String(r.value).padStart(2, "0")} / ${String(
|
|
860
864
|
l.value
|
|
861
|
-
).padStart(2, "0")} / ${String(
|
|
865
|
+
).padStart(2, "0")} / ${String($.value).padStart(4, "0")}`
|
|
862
866
|
},
|
|
863
867
|
{
|
|
864
868
|
label: "End",
|
|
865
|
-
value: `${String(
|
|
866
|
-
|
|
869
|
+
value: `${String(L.value).padStart(2, "0")} / ${String(
|
|
870
|
+
V.value
|
|
867
871
|
).padStart(2, "0")} / ${String(z.value).padStart(4, "0")}`
|
|
868
872
|
},
|
|
869
873
|
{ label: "Digits only", value: w.value },
|
|
@@ -874,7 +878,7 @@ function Xe(e) {
|
|
|
874
878
|
},
|
|
875
879
|
{
|
|
876
880
|
label: "Valid (managed)",
|
|
877
|
-
value: `${
|
|
881
|
+
value: `${R.value ?? "-"}`
|
|
878
882
|
},
|
|
879
883
|
{ label: "Span (days)", value: `${ee.value ?? "-"}` },
|
|
880
884
|
{
|
|
@@ -889,7 +893,7 @@ function Xe(e) {
|
|
|
889
893
|
})()})`
|
|
890
894
|
}
|
|
891
895
|
];
|
|
892
|
-
}),
|
|
896
|
+
}), J = () => {
|
|
893
897
|
j(() => {
|
|
894
898
|
const n = document.getElementById(e.id);
|
|
895
899
|
if (!n) {
|
|
@@ -905,7 +909,7 @@ function Xe(e) {
|
|
|
905
909
|
});
|
|
906
910
|
};
|
|
907
911
|
xe(() => {
|
|
908
|
-
|
|
912
|
+
J();
|
|
909
913
|
});
|
|
910
914
|
const ye = () => {
|
|
911
915
|
j(() => {
|
|
@@ -939,67 +943,67 @@ function Xe(e) {
|
|
|
939
943
|
), {
|
|
940
944
|
raw: t,
|
|
941
945
|
cursorPos: s,
|
|
942
|
-
debugEnabled:
|
|
943
|
-
debugLines:
|
|
946
|
+
debugEnabled: N,
|
|
947
|
+
debugLines: F,
|
|
944
948
|
digitsOnly: w,
|
|
945
|
-
valid:
|
|
949
|
+
valid: R,
|
|
946
950
|
validComputed: G(te),
|
|
947
951
|
reason: G(le),
|
|
948
952
|
validationMessage: G(m),
|
|
949
953
|
spanDays: G(ee),
|
|
950
954
|
month1: G(r),
|
|
951
955
|
day1: G(l),
|
|
952
|
-
year1: G(
|
|
953
|
-
month2: G(
|
|
954
|
-
day2: G(
|
|
956
|
+
year1: G($),
|
|
957
|
+
month2: G(L),
|
|
958
|
+
day2: G(V),
|
|
955
959
|
year2: G(z),
|
|
956
960
|
handleChange: o,
|
|
957
961
|
handleKeyDown: v,
|
|
958
|
-
handleWheel:
|
|
959
|
-
handleKeyUp:
|
|
962
|
+
handleWheel: T,
|
|
963
|
+
handleKeyUp: K,
|
|
960
964
|
handleClick: d,
|
|
961
965
|
handleBlur: Z,
|
|
962
966
|
handleClear: ie,
|
|
963
967
|
onCalendarChange: () => {
|
|
964
|
-
|
|
968
|
+
q.value = !0;
|
|
965
969
|
},
|
|
966
|
-
initStyling:
|
|
970
|
+
initStyling: J
|
|
967
971
|
};
|
|
968
972
|
}
|
|
969
|
-
function
|
|
970
|
-
const t =
|
|
973
|
+
function Qe(e) {
|
|
974
|
+
const t = Q(""), s = Q(void 0), N = Q(!!e.debug), q = Q(e.timeFormat ?? "hh:mm AM"), U = b(() => !!e.required), H = Q(!1), x = ["ArrowUp", "ArrowDown"], D = ["ArrowLeft", "ArrowRight"], k = b(() => (t.value ?? "").replace(/\D/g, "")), w = {
|
|
971
975
|
H: /[0-9]/,
|
|
972
976
|
h: /[0-9]/,
|
|
973
977
|
M: /[0-9]/,
|
|
974
978
|
m: /[0-9]/,
|
|
975
979
|
A: /[AaPp]/,
|
|
976
980
|
a: /[Mm]/
|
|
977
|
-
},
|
|
981
|
+
}, C = (r) => r <= 2 ? "hh" : r <= 5 ? "mm" : "ampm", A = b(() => {
|
|
978
982
|
const r = t.value && t.value.substring(0, 2).replace(/\D/g, "0") || "0", l = parseInt(r);
|
|
979
983
|
return Math.min(Math.max(l, 0), 23);
|
|
980
984
|
}), E = b(() => {
|
|
981
985
|
const r = t.value && t.value.substring(3, 5).replace(/\D/g, "0") || "0", l = parseInt(r);
|
|
982
986
|
return Math.min(Math.max(l, 0), 59);
|
|
983
|
-
}),
|
|
984
|
-
const r = parseInt(t.value?.substring(0, 2).replace(/\D/g, "0") || "0"), l =
|
|
987
|
+
}), P = b(() => (t.value?.substring(6, 8) || "AM").toUpperCase().startsWith("P") ? "PM" : "AM"), O = b(() => {
|
|
988
|
+
const r = parseInt(t.value?.substring(0, 2).replace(/\D/g, "0") || "0"), l = P.value;
|
|
985
989
|
return r === 12 ? l === "AM" ? 0 : 12 : l === "PM" ? r + 12 : r;
|
|
986
|
-
}), p = b(() => S.value ? `${String(
|
|
990
|
+
}), p = b(() => S.value ? `${String(O.value).padStart(2, "0")}:${String(E.value).padStart(2, "0")}:00` : null), S = b(
|
|
987
991
|
() => /^(\d{2}):(\d{2})\s([AP]M)$/i.test(t.value ?? "")
|
|
988
|
-
),
|
|
989
|
-
let
|
|
990
|
-
return
|
|
992
|
+
), R = (r, l, $) => {
|
|
993
|
+
let L = r % 12;
|
|
994
|
+
return L === 0 && (L = 12), `${String(L).padStart(2, "0")}:${String(l).padStart(
|
|
991
995
|
2,
|
|
992
996
|
"0"
|
|
993
|
-
)} ${
|
|
997
|
+
)} ${$}`;
|
|
994
998
|
}, X = (r) => {
|
|
995
999
|
const l = r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
|
|
996
1000
|
if (!l) return null;
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
let z =
|
|
1000
|
-
|
|
1001
|
-
const
|
|
1002
|
-
return
|
|
1001
|
+
const $ = parseInt(l[1]), L = parseInt(l[2]), V = l[3].toUpperCase();
|
|
1002
|
+
if ($ < 1 || $ > 12 || L < 0 || L > 59) return null;
|
|
1003
|
+
let z = $ % 12;
|
|
1004
|
+
V === "PM" && (z += 12);
|
|
1005
|
+
const F = /* @__PURE__ */ new Date();
|
|
1006
|
+
return F.setSeconds(0, 0), F.setHours(z), F.setMinutes(L), F;
|
|
1003
1007
|
}, _ = (r) => {
|
|
1004
1008
|
if (k.value.length === 0) {
|
|
1005
1009
|
e.onChange({ value: null, event: r });
|
|
@@ -1012,19 +1016,19 @@ function Je(e) {
|
|
|
1012
1016
|
const l = X(t.value);
|
|
1013
1017
|
l && te(l) ? e.onChange({ value: l, event: r }) : e.onChange({ value: null, event: r });
|
|
1014
1018
|
}, ee = (r) => r.getHours() * 60 + r.getMinutes(), te = (r) => {
|
|
1015
|
-
const l = e.min ?? void 0,
|
|
1019
|
+
const l = e.min ?? void 0, $ = e.max ?? void 0, L = ee(r);
|
|
1016
1020
|
if (l) {
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1021
|
+
const V = ee(l);
|
|
1022
|
+
if (L < V) return !1;
|
|
1019
1023
|
}
|
|
1020
|
-
if (
|
|
1021
|
-
const
|
|
1022
|
-
if (
|
|
1024
|
+
if ($) {
|
|
1025
|
+
const V = ee($);
|
|
1026
|
+
if (L > V) return !1;
|
|
1023
1027
|
}
|
|
1024
1028
|
return !0;
|
|
1025
1029
|
}, le = (r) => {
|
|
1026
|
-
const l = r.getHours(),
|
|
1027
|
-
t.value =
|
|
1030
|
+
const l = r.getHours(), $ = l >= 12 ? "PM" : "AM";
|
|
1031
|
+
t.value = R(l, r.getMinutes(), $);
|
|
1028
1032
|
}, a = (r, l) => {
|
|
1029
1033
|
e.onChange({ value: r, event: l });
|
|
1030
1034
|
}, m = () => {
|
|
@@ -1050,15 +1054,15 @@ function Je(e) {
|
|
|
1050
1054
|
}, y = (...r) => {
|
|
1051
1055
|
const l = r[0];
|
|
1052
1056
|
if (!l) return;
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1055
|
-
const
|
|
1056
|
-
le(
|
|
1057
|
+
const $ = i(l);
|
|
1058
|
+
if ($ === "now") {
|
|
1059
|
+
const V = /* @__PURE__ */ new Date();
|
|
1060
|
+
le(V), c(V, l), m();
|
|
1057
1061
|
return;
|
|
1058
1062
|
}
|
|
1059
1063
|
if (l?.value instanceof Date) {
|
|
1060
|
-
const
|
|
1061
|
-
le(
|
|
1064
|
+
const V = new Date(l.value);
|
|
1065
|
+
le(V), c(V, l), $ === "set" && m();
|
|
1062
1066
|
return;
|
|
1063
1067
|
}
|
|
1064
1068
|
if (l?.value === null) {
|
|
@@ -1066,25 +1070,25 @@ function Je(e) {
|
|
|
1066
1070
|
return;
|
|
1067
1071
|
}
|
|
1068
1072
|
t.value = l.value;
|
|
1069
|
-
const
|
|
1070
|
-
s.value =
|
|
1073
|
+
const L = l.event?.target;
|
|
1074
|
+
s.value = L?.selectionStart ?? 0;
|
|
1071
1075
|
try {
|
|
1072
|
-
const
|
|
1073
|
-
if (
|
|
1076
|
+
const V = s.value ?? 0;
|
|
1077
|
+
if (C(V) === "ampm" && (t.value ?? "").length >= 8) {
|
|
1074
1078
|
const z = t.value.charAt(6);
|
|
1075
1079
|
/[Aa]/.test(z) ? (t.value = `${t.value.slice(0, 6)}AM${t.value.slice(8)}`, j(() => {
|
|
1076
1080
|
requestAnimationFrame(() => {
|
|
1077
|
-
const
|
|
1081
|
+
const F = document.getElementById(
|
|
1078
1082
|
e.id
|
|
1079
1083
|
);
|
|
1080
|
-
|
|
1084
|
+
F && (F.focus(), F.setSelectionRange(8, 8));
|
|
1081
1085
|
});
|
|
1082
1086
|
})) : /[Pp]/.test(z) && (t.value = `${t.value.slice(0, 6)}PM${t.value.slice(8)}`, j(() => {
|
|
1083
1087
|
requestAnimationFrame(() => {
|
|
1084
|
-
const
|
|
1088
|
+
const F = document.getElementById(
|
|
1085
1089
|
e.id
|
|
1086
1090
|
);
|
|
1087
|
-
|
|
1091
|
+
F && (F.focus(), F.setSelectionRange(8, 8));
|
|
1088
1092
|
});
|
|
1089
1093
|
}));
|
|
1090
1094
|
}
|
|
@@ -1093,16 +1097,16 @@ function Je(e) {
|
|
|
1093
1097
|
_(l);
|
|
1094
1098
|
}, f = (r) => {
|
|
1095
1099
|
s.value = r.target.selectionStart ?? 0;
|
|
1096
|
-
}, h = (r, l,
|
|
1097
|
-
const
|
|
1098
|
-
s.value =
|
|
1099
|
-
const
|
|
1100
|
+
}, h = (r, l, $) => {
|
|
1101
|
+
const L = l?.selectionStart ?? s.value ?? 0;
|
|
1102
|
+
s.value = L;
|
|
1103
|
+
const V = C(L), z = (t.value ?? "").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
|
|
1100
1104
|
if (!z) {
|
|
1101
1105
|
if ((t.value ?? "").length === 0 || k.value.length === 0) {
|
|
1102
1106
|
const u = /* @__PURE__ */ new Date(), g = u.getHours(), M = g >= 12 ? "PM" : "AM";
|
|
1103
|
-
t.value =
|
|
1107
|
+
t.value = R(g, u.getMinutes(), M);
|
|
1104
1108
|
const ne = X(t.value);
|
|
1105
|
-
c(ne,
|
|
1109
|
+
c(ne, $), j(() => {
|
|
1106
1110
|
requestAnimationFrame(() => {
|
|
1107
1111
|
const re = document.getElementById(
|
|
1108
1112
|
e.id
|
|
@@ -1113,29 +1117,29 @@ function Je(e) {
|
|
|
1113
1117
|
}
|
|
1114
1118
|
return;
|
|
1115
1119
|
}
|
|
1116
|
-
let
|
|
1117
|
-
if (
|
|
1118
|
-
r === "ArrowUp" ?
|
|
1119
|
-
else if (
|
|
1120
|
+
let F = parseInt(z[1]), J = parseInt(z[2]), ye = z[3].toUpperCase();
|
|
1121
|
+
if (V === "hh")
|
|
1122
|
+
r === "ArrowUp" ? F = F < 12 ? F + 1 : 1 : F = F > 1 ? F - 1 : 12;
|
|
1123
|
+
else if (V === "mm") {
|
|
1120
1124
|
const u = e.minuteStepRef?.value ?? e.minuteStep ?? 1;
|
|
1121
1125
|
if (u === 1)
|
|
1122
|
-
r === "ArrowUp" ?
|
|
1126
|
+
r === "ArrowUp" ? J = J < 59 ? J + 1 : 0 : J = J > 0 ? J - 1 : 59;
|
|
1123
1127
|
else if (r === "ArrowUp") {
|
|
1124
|
-
const g =
|
|
1125
|
-
let M = g === 0 ?
|
|
1126
|
-
M >= 60 && (M = 0),
|
|
1128
|
+
const g = J % u;
|
|
1129
|
+
let M = g === 0 ? J + u : J + (u - g);
|
|
1130
|
+
M >= 60 && (M = 0), J = M;
|
|
1127
1131
|
} else {
|
|
1128
|
-
const g =
|
|
1129
|
-
let M = g === 0 ?
|
|
1130
|
-
M < 0 && (M = 60 - u),
|
|
1132
|
+
const g = J % u;
|
|
1133
|
+
let M = g === 0 ? J - u : J - g;
|
|
1134
|
+
M < 0 && (M = 60 - u), J = M;
|
|
1131
1135
|
}
|
|
1132
|
-
} else
|
|
1133
|
-
t.value = `${String(
|
|
1136
|
+
} else V === "ampm" && (ye = ye === "AM" ? "PM" : "AM");
|
|
1137
|
+
t.value = `${String(F).padStart(2, "0")}:${String(J).padStart(
|
|
1134
1138
|
2,
|
|
1135
1139
|
"0"
|
|
1136
1140
|
)} ${ye}`;
|
|
1137
1141
|
const n = X(t.value);
|
|
1138
|
-
c(n,
|
|
1142
|
+
c(n, $), j(() => {
|
|
1139
1143
|
requestAnimationFrame(() => {
|
|
1140
1144
|
const u = document.getElementById(
|
|
1141
1145
|
e.id
|
|
@@ -1143,7 +1147,7 @@ function Je(e) {
|
|
|
1143
1147
|
u && (u.focus(), u.setSelectionRange(g, g));
|
|
1144
1148
|
});
|
|
1145
1149
|
});
|
|
1146
|
-
},
|
|
1150
|
+
}, I = (r) => {
|
|
1147
1151
|
if (r.code === "Space" || r.key === " ") {
|
|
1148
1152
|
r.preventDefault(), r.stopPropagation(), e.onShowPicker(r);
|
|
1149
1153
|
return;
|
|
@@ -1174,7 +1178,7 @@ function Je(e) {
|
|
|
1174
1178
|
s.value = l?.selectionStart ?? 0;
|
|
1175
1179
|
}
|
|
1176
1180
|
}, d = (r) => {
|
|
1177
|
-
H.value = !0,
|
|
1181
|
+
H.value = !0, U.value && e.externalValue && e.externalValue.value === void 0 && k.value.length === 0 && (e.externalValue.value = "");
|
|
1178
1182
|
const l = r.target;
|
|
1179
1183
|
l && (s.value = l.selectionStart ?? 0);
|
|
1180
1184
|
};
|
|
@@ -1184,8 +1188,8 @@ function Je(e) {
|
|
|
1184
1188
|
if (r) {
|
|
1185
1189
|
const l = new Date(r);
|
|
1186
1190
|
if (l.toString() !== "Invalid Date") {
|
|
1187
|
-
const
|
|
1188
|
-
t.value =
|
|
1191
|
+
const $ = l.getHours(), L = $ >= 12 ? "PM" : "AM";
|
|
1192
|
+
t.value = R($, l.getMinutes(), L);
|
|
1189
1193
|
return;
|
|
1190
1194
|
}
|
|
1191
1195
|
}
|
|
@@ -1195,14 +1199,14 @@ function Je(e) {
|
|
|
1195
1199
|
const v = b(() => [
|
|
1196
1200
|
["Time", t.value || "--:-- --"],
|
|
1197
1201
|
["Hour (12h)", A.value],
|
|
1198
|
-
["Hour (24h)",
|
|
1202
|
+
["Hour (24h)", O.value],
|
|
1199
1203
|
["Minute", E.value],
|
|
1200
|
-
["Period",
|
|
1204
|
+
["Period", P.value],
|
|
1201
1205
|
["Time (24h)", p.value ?? "--:--:--"],
|
|
1202
1206
|
["Digits only", k.value],
|
|
1203
1207
|
[
|
|
1204
1208
|
"Parsed Date",
|
|
1205
|
-
|
|
1209
|
+
T.value?.toLocaleDateString("en-US", {
|
|
1206
1210
|
hour: "2-digit",
|
|
1207
1211
|
minute: "2-digit"
|
|
1208
1212
|
}) ?? null
|
|
@@ -1221,46 +1225,46 @@ function Je(e) {
|
|
|
1221
1225
|
minute: "2-digit"
|
|
1222
1226
|
}) ?? null
|
|
1223
1227
|
],
|
|
1224
|
-
["valid",
|
|
1225
|
-
["reason",
|
|
1228
|
+
["valid", K.value],
|
|
1229
|
+
["reason", B.value],
|
|
1226
1230
|
["validationMessage", Z.value]
|
|
1227
|
-
]),
|
|
1231
|
+
]), T = b(
|
|
1228
1232
|
() => X(t.value) ?? null
|
|
1229
|
-
),
|
|
1230
|
-
if (!
|
|
1233
|
+
), K = b(() => {
|
|
1234
|
+
if (!U.value) {
|
|
1231
1235
|
if (!S.value) return !0;
|
|
1232
|
-
const l =
|
|
1236
|
+
const l = T.value;
|
|
1233
1237
|
return l ? te(l) : !1;
|
|
1234
1238
|
}
|
|
1235
1239
|
if (!H.value) return !0;
|
|
1236
|
-
const r =
|
|
1240
|
+
const r = T.value;
|
|
1237
1241
|
return !S.value || !r ? !1 : te(r);
|
|
1238
|
-
}),
|
|
1239
|
-
if (!
|
|
1242
|
+
}), B = b(() => {
|
|
1243
|
+
if (!U.value) {
|
|
1240
1244
|
if (!S.value) return;
|
|
1241
|
-
const l =
|
|
1245
|
+
const l = T.value;
|
|
1242
1246
|
return l ? te(l) ? "valid" : "out-of-bounds" : "invalid-time";
|
|
1243
1247
|
}
|
|
1244
1248
|
if (!H.value) return;
|
|
1245
1249
|
if (k.value.length === 0 || !S.value)
|
|
1246
1250
|
return "incomplete";
|
|
1247
|
-
const r =
|
|
1251
|
+
const r = T.value;
|
|
1248
1252
|
return r ? te(r) ? "valid" : "out-of-bounds" : "invalid-time";
|
|
1249
1253
|
}), Z = b(() => {
|
|
1250
|
-
const r =
|
|
1254
|
+
const r = B.value;
|
|
1251
1255
|
if (!r || r === "valid") return "";
|
|
1252
1256
|
if (r === "incomplete")
|
|
1253
1257
|
return "Required";
|
|
1254
1258
|
if (r === "invalid-time")
|
|
1255
|
-
return `Must be in ${
|
|
1259
|
+
return `Must be in ${q.value} format.`;
|
|
1256
1260
|
const l = {
|
|
1257
1261
|
hour: "2-digit",
|
|
1258
1262
|
minute: "2-digit"
|
|
1259
|
-
},
|
|
1263
|
+
}, $ = e.min ? e.min.toLocaleTimeString("en-US", l) : null, L = e.max ? e.max.toLocaleTimeString("en-US", l) : null;
|
|
1260
1264
|
if (r === "out-of-bounds") {
|
|
1261
|
-
if (
|
|
1262
|
-
if (
|
|
1263
|
-
if (
|
|
1265
|
+
if ($ && L) return `Must be between ${$} and ${L}.`;
|
|
1266
|
+
if ($) return `Must be ${$} or later.`;
|
|
1267
|
+
if (L) return `Must be ${L} or earlier.`;
|
|
1264
1268
|
}
|
|
1265
1269
|
return "";
|
|
1266
1270
|
}), ie = () => {
|
|
@@ -1277,14 +1281,14 @@ function Je(e) {
|
|
|
1277
1281
|
);
|
|
1278
1282
|
return;
|
|
1279
1283
|
}
|
|
1280
|
-
const
|
|
1281
|
-
if (
|
|
1284
|
+
const $ = l.parentElement;
|
|
1285
|
+
if (!$) {
|
|
1282
1286
|
console.warn(
|
|
1283
1287
|
`Parent of .k-timepicker not found for #${e.id} styling.`
|
|
1284
1288
|
);
|
|
1285
1289
|
return;
|
|
1286
1290
|
}
|
|
1287
|
-
|
|
1291
|
+
$.classList.contains("fk-timepicker") || $.classList.add("fk-timepicker");
|
|
1288
1292
|
});
|
|
1289
1293
|
};
|
|
1290
1294
|
return xe(() => {
|
|
@@ -1292,23 +1296,23 @@ function Je(e) {
|
|
|
1292
1296
|
}), {
|
|
1293
1297
|
raw: t,
|
|
1294
1298
|
rules: w,
|
|
1295
|
-
debugEnabled:
|
|
1299
|
+
debugEnabled: N,
|
|
1296
1300
|
debugLines: v,
|
|
1297
|
-
placeholder:
|
|
1298
|
-
isValid:
|
|
1299
|
-
reason: G(
|
|
1301
|
+
placeholder: q,
|
|
1302
|
+
isValid: K,
|
|
1303
|
+
reason: G(B),
|
|
1300
1304
|
validationMessage: Z,
|
|
1301
1305
|
isComplete: S,
|
|
1302
1306
|
inRangeTime: te,
|
|
1303
1307
|
cursorPos: s,
|
|
1304
1308
|
hour: G(A),
|
|
1305
|
-
hour24: G(
|
|
1309
|
+
hour24: G(O),
|
|
1306
1310
|
minute: G(E),
|
|
1307
|
-
period: G(
|
|
1311
|
+
period: G(P),
|
|
1308
1312
|
time24: G(p),
|
|
1309
|
-
parsedRawTime: G(
|
|
1313
|
+
parsedRawTime: G(T),
|
|
1310
1314
|
handleChange: y,
|
|
1311
|
-
handleKeyDown:
|
|
1315
|
+
handleKeyDown: I,
|
|
1312
1316
|
handleKeyUp: o,
|
|
1313
1317
|
handleClick: f,
|
|
1314
1318
|
handleWheel: W,
|
|
@@ -1317,21 +1321,21 @@ function Je(e) {
|
|
|
1317
1321
|
initStyling: ie
|
|
1318
1322
|
};
|
|
1319
1323
|
}
|
|
1320
|
-
function
|
|
1324
|
+
function Ke(e) {
|
|
1321
1325
|
return Le() ? (Te(e), !0) : !1;
|
|
1322
1326
|
}
|
|
1323
1327
|
const Ce = typeof window < "u" && typeof document < "u";
|
|
1324
1328
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
1325
|
-
const
|
|
1326
|
-
},
|
|
1327
|
-
function
|
|
1329
|
+
const Be = Object.prototype.toString, Ve = (e) => Be.call(e) === "[object Object]", ve = () => {
|
|
1330
|
+
}, Ne = /* @__PURE__ */ He();
|
|
1331
|
+
function He() {
|
|
1328
1332
|
var e, t;
|
|
1329
1333
|
return Ce && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
|
|
1330
1334
|
}
|
|
1331
1335
|
function Ae(e) {
|
|
1332
1336
|
return Array.isArray(e) ? e : [e];
|
|
1333
1337
|
}
|
|
1334
|
-
function
|
|
1338
|
+
function Ye(e, t, s) {
|
|
1335
1339
|
return ge(
|
|
1336
1340
|
e,
|
|
1337
1341
|
t,
|
|
@@ -1341,7 +1345,7 @@ function Ne(e, t, s) {
|
|
|
1341
1345
|
}
|
|
1342
1346
|
);
|
|
1343
1347
|
}
|
|
1344
|
-
const
|
|
1348
|
+
const Pe = Ce ? window : void 0;
|
|
1345
1349
|
function Se(e) {
|
|
1346
1350
|
var t;
|
|
1347
1351
|
const s = de(e);
|
|
@@ -1350,68 +1354,68 @@ function Se(e) {
|
|
|
1350
1354
|
function Ee(...e) {
|
|
1351
1355
|
const t = [], s = () => {
|
|
1352
1356
|
t.forEach((x) => x()), t.length = 0;
|
|
1353
|
-
},
|
|
1357
|
+
}, N = (x, D, k, w) => (x.addEventListener(D, k, w), () => x.removeEventListener(D, k, w)), q = b(() => {
|
|
1354
1358
|
const x = Ae(de(e[0])).filter((D) => D != null);
|
|
1355
1359
|
return x.every((D) => typeof D != "string") ? x : void 0;
|
|
1356
|
-
}),
|
|
1360
|
+
}), U = Ye(
|
|
1357
1361
|
() => {
|
|
1358
1362
|
var x, D;
|
|
1359
1363
|
return [
|
|
1360
|
-
(D = (x =
|
|
1361
|
-
Ae(de(
|
|
1362
|
-
Ae(
|
|
1364
|
+
(D = (x = q.value) == null ? void 0 : x.map((k) => Se(k))) != null ? D : [Pe].filter((k) => k != null),
|
|
1365
|
+
Ae(de(q.value ? e[1] : e[0])),
|
|
1366
|
+
Ae(Re(q.value ? e[2] : e[1])),
|
|
1363
1367
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
1364
|
-
de(
|
|
1368
|
+
de(q.value ? e[3] : e[2])
|
|
1365
1369
|
];
|
|
1366
1370
|
},
|
|
1367
1371
|
([x, D, k, w]) => {
|
|
1368
1372
|
if (s(), !x?.length || !D?.length || !k?.length)
|
|
1369
1373
|
return;
|
|
1370
|
-
const
|
|
1374
|
+
const C = Ve(w) ? { ...w } : w;
|
|
1371
1375
|
t.push(
|
|
1372
1376
|
...x.flatMap(
|
|
1373
1377
|
(A) => D.flatMap(
|
|
1374
|
-
(E) => k.map((
|
|
1378
|
+
(E) => k.map((P) => N(A, E, P, C))
|
|
1375
1379
|
)
|
|
1376
1380
|
)
|
|
1377
1381
|
);
|
|
1378
1382
|
},
|
|
1379
1383
|
{ flush: "post" }
|
|
1380
1384
|
), H = () => {
|
|
1381
|
-
|
|
1385
|
+
U(), s();
|
|
1382
1386
|
};
|
|
1383
|
-
return
|
|
1387
|
+
return Ke(s), H;
|
|
1384
1388
|
}
|
|
1385
1389
|
let Me = !1;
|
|
1386
|
-
function
|
|
1387
|
-
const { window:
|
|
1388
|
-
if (!
|
|
1390
|
+
function We(e, t, s = {}) {
|
|
1391
|
+
const { window: N = Pe, ignore: q = [], capture: U = !0, detectIframe: H = !1, controls: x = !1 } = s;
|
|
1392
|
+
if (!N)
|
|
1389
1393
|
return x ? { stop: ve, cancel: ve, trigger: ve } : ve;
|
|
1390
|
-
if (
|
|
1394
|
+
if (Ne && !Me) {
|
|
1391
1395
|
Me = !0;
|
|
1392
1396
|
const p = { passive: !0 };
|
|
1393
|
-
Array.from(
|
|
1397
|
+
Array.from(N.document.body.children).forEach((S) => S.addEventListener("click", ve, p)), N.document.documentElement.addEventListener("click", ve, p);
|
|
1394
1398
|
}
|
|
1395
1399
|
let D = !0;
|
|
1396
|
-
const k = (p) => de(
|
|
1400
|
+
const k = (p) => de(q).some((S) => {
|
|
1397
1401
|
if (typeof S == "string")
|
|
1398
|
-
return Array.from(
|
|
1402
|
+
return Array.from(N.document.querySelectorAll(S)).some((R) => R === p.target || p.composedPath().includes(R));
|
|
1399
1403
|
{
|
|
1400
|
-
const
|
|
1401
|
-
return
|
|
1404
|
+
const R = Se(S);
|
|
1405
|
+
return R && (p.target === R || p.composedPath().includes(R));
|
|
1402
1406
|
}
|
|
1403
1407
|
});
|
|
1404
1408
|
function w(p) {
|
|
1405
1409
|
const S = de(p);
|
|
1406
1410
|
return S && S.$.subTree.shapeFlag === 16;
|
|
1407
1411
|
}
|
|
1408
|
-
function
|
|
1409
|
-
const
|
|
1412
|
+
function C(p, S) {
|
|
1413
|
+
const R = de(p), X = R.$.subTree && R.$.subTree.children;
|
|
1410
1414
|
return X == null || !Array.isArray(X) ? !1 : X.some((_) => _.el === S.target || S.composedPath().includes(_.el));
|
|
1411
1415
|
}
|
|
1412
1416
|
const A = (p) => {
|
|
1413
1417
|
const S = Se(e);
|
|
1414
|
-
if (p.target != null && !(!(S instanceof Element) && w(e) &&
|
|
1418
|
+
if (p.target != null && !(!(S instanceof Element) && w(e) && C(e, p)) && !(!S || S === p.target || p.composedPath().includes(S))) {
|
|
1415
1419
|
if ("detail" in p && p.detail === 0 && (D = !k(p)), !D) {
|
|
1416
1420
|
D = !0;
|
|
1417
1421
|
return;
|
|
@@ -1420,126 +1424,111 @@ function He(e, t, s = {}) {
|
|
|
1420
1424
|
}
|
|
1421
1425
|
};
|
|
1422
1426
|
let E = !1;
|
|
1423
|
-
const
|
|
1424
|
-
Ee(
|
|
1427
|
+
const P = [
|
|
1428
|
+
Ee(N, "click", (p) => {
|
|
1425
1429
|
E || (E = !0, setTimeout(() => {
|
|
1426
1430
|
E = !1;
|
|
1427
1431
|
}, 0), A(p));
|
|
1428
|
-
}, { passive: !0, capture:
|
|
1429
|
-
Ee(
|
|
1432
|
+
}, { passive: !0, capture: U }),
|
|
1433
|
+
Ee(N, "pointerdown", (p) => {
|
|
1430
1434
|
const S = Se(e);
|
|
1431
1435
|
D = !k(p) && !!(S && !p.composedPath().includes(S));
|
|
1432
1436
|
}, { passive: !0 }),
|
|
1433
|
-
H && Ee(
|
|
1437
|
+
H && Ee(N, "blur", (p) => {
|
|
1434
1438
|
setTimeout(() => {
|
|
1435
1439
|
var S;
|
|
1436
|
-
const
|
|
1437
|
-
((S =
|
|
1440
|
+
const R = Se(e);
|
|
1441
|
+
((S = N.document.activeElement) == null ? void 0 : S.tagName) === "IFRAME" && !R?.contains(N.document.activeElement) && t(p);
|
|
1438
1442
|
}, 0);
|
|
1439
1443
|
}, { passive: !0 })
|
|
1440
|
-
].filter(Boolean),
|
|
1444
|
+
].filter(Boolean), O = () => P.forEach((p) => p());
|
|
1441
1445
|
return x ? {
|
|
1442
|
-
stop:
|
|
1446
|
+
stop: O,
|
|
1443
1447
|
cancel: () => {
|
|
1444
1448
|
D = !1;
|
|
1445
1449
|
},
|
|
1446
1450
|
trigger: (p) => {
|
|
1447
1451
|
D = !0, A(p), D = !1;
|
|
1448
1452
|
}
|
|
1449
|
-
} :
|
|
1453
|
+
} : O;
|
|
1450
1454
|
}
|
|
1451
|
-
function
|
|
1452
|
-
const t =
|
|
1455
|
+
function Ze(e) {
|
|
1456
|
+
const t = Fe(null), s = [
|
|
1453
1457
|
".k-animation-container .k-popup",
|
|
1454
1458
|
".k-popup",
|
|
1455
1459
|
".k-timepicker-popup",
|
|
1456
1460
|
".k-menu-popup"
|
|
1457
|
-
],
|
|
1461
|
+
], N = Array.isArray(e.popupSelector) ? e.popupSelector : [e.popupSelector ?? s].flat(), q = (w) => w ? typeof e.initialFocus == "string" ? w.querySelector(e.initialFocus) ?? w : typeof e.initialFocus == "function" ? e.initialFocus(w) ?? w : w.querySelector(
|
|
1458
1462
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
1459
|
-
) ?? w : null, { activate:
|
|
1463
|
+
) ?? w : null, { activate: U, deactivate: H } = qe(t, {
|
|
1460
1464
|
escapeDeactivates: !1,
|
|
1461
1465
|
clickOutsideDeactivates: !1,
|
|
1462
1466
|
fallbackFocus: () => t.value,
|
|
1463
|
-
initialFocus: () =>
|
|
1467
|
+
initialFocus: () => q(t.value),
|
|
1464
1468
|
...e.focusTrapOptions ?? {}
|
|
1465
1469
|
});
|
|
1466
|
-
let x = null, D =
|
|
1470
|
+
let x = null, D = Q(null);
|
|
1467
1471
|
const k = () => {
|
|
1468
1472
|
if (e.resolvePopupEl) return e.resolvePopupEl();
|
|
1469
1473
|
const w = (A, E) => {
|
|
1470
|
-
const
|
|
1471
|
-
if (!
|
|
1472
|
-
const
|
|
1474
|
+
const P = Array.from(A.querySelectorAll(E));
|
|
1475
|
+
if (!P.length) return null;
|
|
1476
|
+
const O = P.filter(
|
|
1473
1477
|
(p) => p.offsetParent !== null || p.getClientRects().length > 0
|
|
1474
1478
|
);
|
|
1475
|
-
return
|
|
1476
|
-
},
|
|
1477
|
-
for (const A of
|
|
1478
|
-
const E = w(
|
|
1479
|
+
return O[O.length - 1] ?? P[P.length - 1] ?? null;
|
|
1480
|
+
}, C = e.triggerEl?.value?.closest?.(".k-animation-container") ?? document.body;
|
|
1481
|
+
for (const A of N) {
|
|
1482
|
+
const E = w(C, A);
|
|
1479
1483
|
if (E) return E;
|
|
1480
1484
|
}
|
|
1481
|
-
for (const A of
|
|
1485
|
+
for (const A of N) {
|
|
1482
1486
|
const E = w(document, A);
|
|
1483
1487
|
if (E) return E;
|
|
1484
1488
|
}
|
|
1485
1489
|
return null;
|
|
1486
1490
|
};
|
|
1487
|
-
return
|
|
1491
|
+
return We(t, (w) => {
|
|
1488
1492
|
D.value = "outside", e.isOpen.value && e.onRequestClose?.("outside", w);
|
|
1489
1493
|
}), ge(
|
|
1490
1494
|
() => e.isOpen.value,
|
|
1491
1495
|
(w) => {
|
|
1492
1496
|
w ? (D.value = null, j(() => {
|
|
1493
|
-
const
|
|
1494
|
-
|
|
1497
|
+
const C = k();
|
|
1498
|
+
C && (t.value = C, setTimeout(() => U(), 0), x || (x = (A) => {
|
|
1495
1499
|
A.key === "Escape" && (D.value = "escape", e.isOpen.value && e.onRequestClose?.("escape", A));
|
|
1496
1500
|
}, document.addEventListener("keydown", x, !0)));
|
|
1497
1501
|
})) : (H(), x && (document.removeEventListener("keydown", x, !0), x = null), t.value = null, D.value === "outside" && j(() => {
|
|
1498
|
-
const
|
|
1499
|
-
const A = e.triggerEl?.value, E = A?.querySelector("input"),
|
|
1500
|
-
|
|
1502
|
+
const C = () => {
|
|
1503
|
+
const A = e.triggerEl?.value, E = A?.querySelector("input"), P = document.activeElement;
|
|
1504
|
+
P && (P === E || A && A.contains(P)) && (E ?? A)?.blur?.();
|
|
1501
1505
|
};
|
|
1502
|
-
requestAnimationFrame(() => setTimeout(
|
|
1506
|
+
requestAnimationFrame(() => setTimeout(C, 0));
|
|
1503
1507
|
}), e.returnFocusToTrigger !== !1 && D.value === "escape" && e.triggerEl?.value && (console.log(
|
|
1504
1508
|
"Returning focus to trigger element:",
|
|
1505
1509
|
e.triggerEl.value
|
|
1506
1510
|
), j(() => {
|
|
1507
|
-
const
|
|
1511
|
+
const C = () => {
|
|
1508
1512
|
const A = e.triggerEl?.value;
|
|
1509
1513
|
if (!A) return;
|
|
1510
1514
|
(A.querySelector("input") ?? A)?.focus?.();
|
|
1511
1515
|
};
|
|
1512
|
-
requestAnimationFrame(() => setTimeout(
|
|
1516
|
+
requestAnimationFrame(() => setTimeout(C, 0));
|
|
1513
1517
|
})));
|
|
1514
1518
|
}
|
|
1515
1519
|
), {
|
|
1516
1520
|
popupRef: t,
|
|
1517
|
-
activate:
|
|
1521
|
+
activate: U,
|
|
1518
1522
|
deactivate: H,
|
|
1519
1523
|
lastCloseReason: G(D),
|
|
1520
1524
|
setPopupEl: (w) => t.value = w
|
|
1521
1525
|
};
|
|
1522
1526
|
}
|
|
1523
|
-
const Ye = (e) => !!e && typeof e == "object" && "filters" in e && Array.isArray(e.filters), We = (e) => !!e && typeof e == "object" && "field" in e, Pe = (e, t) => !e || typeof e != "object" ? !1 : Ye(e) ? e.filters.some(
|
|
1524
|
-
(s) => Pe(s, t)
|
|
1525
|
-
) : We(e) ? e.field === t : !1, Ze = (e) => {
|
|
1526
|
-
const t = J({}), s = ($) => !e.value || !e.value.filters ? !1 : e.value.filters.some(
|
|
1527
|
-
(P) => Pe(P, $)
|
|
1528
|
-
);
|
|
1529
|
-
return {
|
|
1530
|
-
activeClasses: t,
|
|
1531
|
-
hasFieldFilter: s,
|
|
1532
|
-
updateActiveClass: ($) => {
|
|
1533
|
-
const P = s($);
|
|
1534
|
-
console.log("updateActiveClass for", $, "hasFilter:", P), t.value[$] = P ? "active" : "", console.log("activeClasses after update", t.value);
|
|
1535
|
-
}
|
|
1536
|
-
};
|
|
1537
|
-
};
|
|
1538
1527
|
export {
|
|
1539
1528
|
_e as useGridA11y,
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1529
|
+
ze as useGridActiveFilter,
|
|
1530
|
+
Xe as useMaskedDateInput,
|
|
1531
|
+
Je as useMaskedDateRangeInput,
|
|
1532
|
+
Qe as useMaskedTimeInput,
|
|
1533
|
+
Ze as usePopupTrap
|
|
1545
1534
|
};
|