@featherk/composables 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useFocusTrap as
|
|
1
|
+
import { ref as j, onBeforeUnmount as xe, nextTick as H, computed as b, watch as ie, onMounted as De, readonly as B, getCurrentScope as Me, onScopeDispose as $e, toValue as ue, unref as Ce, shallowRef as Ie } from "vue";
|
|
2
|
+
import { useFocusTrap as Te } from "@vueuse/integrations/useFocusTrap";
|
|
3
3
|
const Ve = (e) => {
|
|
4
|
-
const n =
|
|
5
|
-
let d = !1,
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
[" ", "Spacebar", "Space", "Enter"].includes(
|
|
9
|
-
},
|
|
4
|
+
const n = j(null);
|
|
5
|
+
let d = !1, P = null, q = null;
|
|
6
|
+
const V = [], W = ".k-table-row[data-grid-row-index] [tabindex]", A = () => e?.value?.columns, D = (a) => {
|
|
7
|
+
const m = a.key || a.code;
|
|
8
|
+
[" ", "Spacebar", "Space", "Enter"].includes(m) && (a.preventDefault(), a.stopPropagation(), n.value = a.target, a.target.click());
|
|
9
|
+
}, h = (a) => {
|
|
10
10
|
if (!n.value) return;
|
|
11
|
-
if (
|
|
12
|
-
|
|
11
|
+
if (a.code === "Escape") {
|
|
12
|
+
a.preventDefault(), a.stopPropagation(), n.value && n.value.focus();
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
const
|
|
15
|
+
const m = Array.from(
|
|
16
16
|
document.querySelectorAll(
|
|
17
17
|
".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
|
|
18
18
|
)
|
|
19
19
|
), l = document.querySelector(".k-filter-menu-container");
|
|
20
20
|
if (l) {
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
21
|
+
if (a.code === "Tab") {
|
|
22
|
+
const u = [
|
|
23
23
|
".k-filter-menu-container .k-dropdownlist[tabindex='0']",
|
|
24
24
|
".k-filter-menu-container input.k-input-inner:not([tabindex='-1']):not([disabled])",
|
|
25
25
|
".k-filter-menu-container button:not([tabindex='-1']):not([disabled])"
|
|
26
|
-
],
|
|
27
|
-
l.querySelectorAll(
|
|
26
|
+
], p = Array.from(
|
|
27
|
+
l.querySelectorAll(u.join(","))
|
|
28
28
|
);
|
|
29
|
-
if (
|
|
30
|
-
const
|
|
31
|
-
(
|
|
29
|
+
if (p.length === 0) return;
|
|
30
|
+
const x = p.findIndex(
|
|
31
|
+
(L) => L === document.activeElement
|
|
32
32
|
);
|
|
33
33
|
let w;
|
|
34
|
-
|
|
34
|
+
x === -1 ? w = 0 : a.shiftKey ? w = (x - 1 + p.length) % p.length : w = (x + 1) % p.length, a.preventDefault(), a.stopPropagation(), p[w]?.focus();
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
} else if (
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
(
|
|
37
|
+
} else if (a.code === "ArrowUp" || a.code === "ArrowDown") {
|
|
38
|
+
a.preventDefault(), a.stopPropagation();
|
|
39
|
+
const u = m.findIndex(
|
|
40
|
+
(x) => x === document.activeElement
|
|
41
41
|
);
|
|
42
|
-
let
|
|
43
|
-
|
|
42
|
+
let p = u;
|
|
43
|
+
a.code === "ArrowUp" ? p = u > 0 ? u - 1 : m.length - 1 : a.code === "ArrowDown" && (p = u < m.length - 1 ? u + 1 : 0), m[p]?.focus();
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
a.code === "Tab" && (a.preventDefault(), a.stopPropagation(), a.shiftKey ? (n.value?.previousElementSibling).focus() : (n.value?.nextElementSibling).focus());
|
|
47
|
+
}, k = () => {
|
|
48
|
+
P = new MutationObserver((a) => {
|
|
49
|
+
a.forEach((m) => {
|
|
50
|
+
m.addedNodes.forEach((l) => {
|
|
51
51
|
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
const u = l;
|
|
53
|
+
if (u.classList.contains("k-animation-container")) {
|
|
54
|
+
const x = n.value;
|
|
55
|
+
x && (x.dataset.featherKSortable === "true" || H(() => {
|
|
56
|
+
u.querySelectorAll(
|
|
57
57
|
".k-columnmenu-item-wrapper"
|
|
58
|
-
).forEach((
|
|
59
|
-
|
|
58
|
+
).forEach((G) => {
|
|
59
|
+
G.textContent?.toLowerCase().includes("sort") && G.remove();
|
|
60
60
|
});
|
|
61
|
-
})),
|
|
61
|
+
})), u.addEventListener(
|
|
62
62
|
"keydown",
|
|
63
|
-
|
|
64
|
-
),
|
|
63
|
+
h
|
|
64
|
+
), H(() => {
|
|
65
65
|
const w = () => {
|
|
66
|
-
const
|
|
67
|
-
|
|
66
|
+
const L = Array.from(
|
|
67
|
+
u.querySelectorAll(
|
|
68
68
|
".k-animation-container .k-popup .k-column-menu .k-columnmenu-item-wrapper .k-columnmenu-item"
|
|
69
69
|
)
|
|
70
70
|
);
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
else if (
|
|
71
|
+
if (L.length === 1)
|
|
72
|
+
L[0].focus(), L[0].click(), w.attempts = 0;
|
|
73
|
+
else if (L.length > 1) {
|
|
74
74
|
w.attempts = 0;
|
|
75
75
|
return;
|
|
76
76
|
} else
|
|
@@ -79,51 +79,51 @@ const Ve = (e) => {
|
|
|
79
79
|
w();
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
u.querySelectorAll(
|
|
83
83
|
".k-animation-container"
|
|
84
|
-
).forEach((
|
|
85
|
-
|
|
84
|
+
).forEach((x) => {
|
|
85
|
+
x.addEventListener(
|
|
86
86
|
"keydown",
|
|
87
|
-
|
|
87
|
+
h
|
|
88
88
|
);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
|
-
}),
|
|
91
|
+
}), m.removedNodes.forEach((l) => {
|
|
92
92
|
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
93
|
-
const
|
|
94
|
-
|
|
93
|
+
const u = l;
|
|
94
|
+
u.classList.contains("k-animation-container") && u.removeEventListener(
|
|
95
95
|
"keydown",
|
|
96
|
-
|
|
97
|
-
),
|
|
96
|
+
h
|
|
97
|
+
), u.querySelectorAll(
|
|
98
98
|
".k-animation-container"
|
|
99
|
-
).forEach((
|
|
100
|
-
|
|
99
|
+
).forEach((x) => {
|
|
100
|
+
x.removeEventListener(
|
|
101
101
|
"keydown",
|
|
102
|
-
|
|
102
|
+
h
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
});
|
|
108
|
-
}),
|
|
108
|
+
}), P.observe(document.body, {
|
|
109
109
|
childList: !0,
|
|
110
110
|
subtree: !0
|
|
111
111
|
});
|
|
112
|
-
},
|
|
113
|
-
if (!
|
|
112
|
+
}, T = (a) => {
|
|
113
|
+
if (!a.type || !a)
|
|
114
114
|
return;
|
|
115
|
-
const
|
|
116
|
-
if (
|
|
117
|
-
if (
|
|
115
|
+
const m = a.target;
|
|
116
|
+
if (m) {
|
|
117
|
+
if (a.code === "Escape") {
|
|
118
118
|
const l = document.activeElement?.closest(".k-table-row[data-grid-row-index]");
|
|
119
119
|
if (l) {
|
|
120
|
-
|
|
120
|
+
a.preventDefault(), a.stopPropagation();
|
|
121
121
|
try {
|
|
122
122
|
Array.from(
|
|
123
123
|
e?.value.$el.querySelectorAll(
|
|
124
124
|
".k-table-row[data-grid-row-index]"
|
|
125
125
|
)
|
|
126
|
-
).forEach((
|
|
126
|
+
).forEach((p) => p.setAttribute("tabindex", "-1"));
|
|
127
127
|
} catch {
|
|
128
128
|
}
|
|
129
129
|
l.setAttribute("tabindex", "0"), l.focus();
|
|
@@ -137,142 +137,142 @@ const Ve = (e) => {
|
|
|
137
137
|
"ArrowUp",
|
|
138
138
|
"Enter",
|
|
139
139
|
"Space"
|
|
140
|
-
].includes(
|
|
141
|
-
if (
|
|
142
|
-
n.value =
|
|
140
|
+
].includes(a.code)) {
|
|
141
|
+
if (a.preventDefault(), m.classList.contains("k-grid-header-menu") && m.classList.contains("k-grid-column-menu")) {
|
|
142
|
+
n.value = m;
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
const l =
|
|
145
|
+
const l = m.closest(
|
|
146
146
|
".k-table-row[data-grid-row-index]"
|
|
147
147
|
);
|
|
148
148
|
if (l) {
|
|
149
|
-
if (["ArrowDown", "ArrowUp"].includes(
|
|
150
|
-
const
|
|
151
|
-
let
|
|
152
|
-
for (;
|
|
153
|
-
const
|
|
149
|
+
if (["ArrowDown", "ArrowUp"].includes(a.code)) {
|
|
150
|
+
const u = (x, w) => {
|
|
151
|
+
let L = w === "next" ? x.nextElementSibling : x.previousElementSibling;
|
|
152
|
+
for (; L; ) {
|
|
153
|
+
const G = L;
|
|
154
154
|
try {
|
|
155
|
-
if (
|
|
156
|
-
return
|
|
155
|
+
if (G.hasAttribute && G.classList.contains("k-table-row"))
|
|
156
|
+
return G;
|
|
157
157
|
} catch {
|
|
158
158
|
}
|
|
159
|
-
|
|
159
|
+
L = w === "next" ? L.nextElementSibling : L.previousElementSibling;
|
|
160
160
|
}
|
|
161
161
|
return null;
|
|
162
|
-
},
|
|
163
|
-
|
|
162
|
+
}, p = a.code === "ArrowDown" ? u(l, "next") : u(l, "previous");
|
|
163
|
+
p && (l.setAttribute("tabindex", "-1"), p.setAttribute("tabindex", "0"), p.focus());
|
|
164
164
|
return;
|
|
165
165
|
}
|
|
166
|
-
if (["ArrowLeft", "ArrowRight"].includes(
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
166
|
+
if (["ArrowLeft", "ArrowRight"].includes(a.code)) {
|
|
167
|
+
a.preventDefault();
|
|
168
|
+
const u = l.querySelectorAll(
|
|
169
|
+
W
|
|
170
170
|
);
|
|
171
|
-
if (
|
|
172
|
-
let
|
|
173
|
-
(
|
|
171
|
+
if (u.length === 0) return;
|
|
172
|
+
let p = Array.from(u).findIndex(
|
|
173
|
+
(x) => x === document.activeElement
|
|
174
174
|
);
|
|
175
|
-
if (
|
|
176
|
-
|
|
175
|
+
if (p === -1 && document.activeElement === l) {
|
|
176
|
+
u[0].focus();
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
|
-
|
|
179
|
+
a.code === "ArrowRight" ? p = p === u.length - 1 ? 0 : p + 1 : a.code === "ArrowLeft" && (p = p === u.length - 1 ? p - 1 : u.length - 1), u[p].focus();
|
|
180
180
|
return;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
185
|
+
}, E = () => {
|
|
186
|
+
H(() => {
|
|
187
|
+
const a = e.value.$el.closest(".k-grid");
|
|
188
|
+
a && a.classList.add("fk-grid");
|
|
189
189
|
});
|
|
190
190
|
}, S = () => {
|
|
191
|
-
if (!
|
|
191
|
+
if (!q)
|
|
192
192
|
try {
|
|
193
|
-
const
|
|
193
|
+
const a = () => {
|
|
194
194
|
try {
|
|
195
|
-
const
|
|
195
|
+
const u = Array.from(
|
|
196
196
|
e.value.$el.querySelectorAll(
|
|
197
197
|
".k-table-row[data-grid-row-index]"
|
|
198
198
|
)
|
|
199
199
|
);
|
|
200
|
-
if (!
|
|
200
|
+
if (!u || u.length === 0 || u.filter(
|
|
201
201
|
(w) => w.getAttribute("tabindex") === "0"
|
|
202
202
|
).length === 1) return;
|
|
203
|
-
const
|
|
203
|
+
const x = u.find(
|
|
204
204
|
(w) => w === document.activeElement || w.contains(document.activeElement)
|
|
205
205
|
);
|
|
206
|
-
if (
|
|
207
|
-
|
|
206
|
+
if (u.forEach((w) => w.setAttribute("tabindex", "-1")), x) {
|
|
207
|
+
x.setAttribute("tabindex", "0");
|
|
208
208
|
return;
|
|
209
209
|
}
|
|
210
|
-
|
|
211
|
-
} catch (
|
|
212
|
-
console.error("ensureSingleTabindex error:",
|
|
210
|
+
u[0].setAttribute("tabindex", "0");
|
|
211
|
+
} catch (u) {
|
|
212
|
+
console.error("ensureSingleTabindex error:", u);
|
|
213
213
|
}
|
|
214
|
-
},
|
|
214
|
+
}, m = Array.from(
|
|
215
215
|
e.value.$el.querySelectorAll(
|
|
216
216
|
".k-table-row[data-grid-row-index]"
|
|
217
217
|
)
|
|
218
218
|
);
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
m.length > 0 && m.forEach((u, p) => {
|
|
220
|
+
u.setAttribute("tabindex", p === 0 ? "0" : "-1");
|
|
221
221
|
});
|
|
222
222
|
const l = e.value.$el.querySelector(".k-table-tbody");
|
|
223
|
-
l && (
|
|
224
|
-
|
|
225
|
-
}),
|
|
226
|
-
} catch (
|
|
227
|
-
console.error("Error setting up row navigation:",
|
|
223
|
+
l && (q = new MutationObserver(() => {
|
|
224
|
+
a();
|
|
225
|
+
}), q.observe(l, { childList: !0, subtree: !0 }));
|
|
226
|
+
} catch (a) {
|
|
227
|
+
console.error("Error setting up row navigation:", a);
|
|
228
228
|
}
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
229
|
+
}, C = () => {
|
|
230
|
+
H(() => {
|
|
231
|
+
const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
|
|
232
|
+
m && m.forEach((l) => {
|
|
233
233
|
l.setAttribute("role", "button"), l.addEventListener(
|
|
234
234
|
"keydown",
|
|
235
|
-
|
|
235
|
+
D
|
|
236
236
|
);
|
|
237
|
-
}),
|
|
237
|
+
}), k(), f();
|
|
238
238
|
});
|
|
239
|
-
},
|
|
240
|
-
const
|
|
241
|
-
|
|
239
|
+
}, R = () => {
|
|
240
|
+
const m = document.querySelectorAll(".k-grid-header .k-grid-header-menu.k-grid-column-menu");
|
|
241
|
+
m && m.forEach((l) => {
|
|
242
242
|
l.removeEventListener(
|
|
243
243
|
"keydown",
|
|
244
|
-
|
|
244
|
+
D
|
|
245
245
|
);
|
|
246
|
-
}),
|
|
246
|
+
}), P && (P.disconnect(), P = null), q && (q.disconnect(), q = null), V.forEach((l) => l()), V.length = 0;
|
|
247
247
|
}, f = () => {
|
|
248
248
|
document.querySelectorAll(
|
|
249
249
|
".k-grid-header .k-table-thead th"
|
|
250
|
-
).forEach((l,
|
|
251
|
-
const
|
|
250
|
+
).forEach((l, u) => {
|
|
251
|
+
const p = l.querySelector(
|
|
252
252
|
".k-grid-header-menu.k-grid-column-menu"
|
|
253
253
|
);
|
|
254
|
-
if (!
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
-
const
|
|
258
|
-
l.setAttribute("data-feather-k-field",
|
|
254
|
+
if (!p) return;
|
|
255
|
+
const x = A();
|
|
256
|
+
if (x && x[u]) {
|
|
257
|
+
const Y = x[u].field ?? "";
|
|
258
|
+
l.setAttribute("data-feather-k-field", Y), l.setAttribute(
|
|
259
259
|
"data-feather-k-filterable",
|
|
260
|
-
|
|
260
|
+
x[u].filterable === !1 ? "false" : "true"
|
|
261
261
|
), l.setAttribute(
|
|
262
262
|
"data-feather-k-sortable",
|
|
263
|
-
|
|
263
|
+
x[u].sortable === !1 ? "false" : "true"
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
|
-
const w = l.dataset.featherKFilterable !== "false",
|
|
267
|
-
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
}, X = (
|
|
266
|
+
const w = l.dataset.featherKFilterable !== "false", L = l.dataset.featherKSortable !== "false";
|
|
267
|
+
p.setAttribute("tabindex", "-1"), w || L ? l.style.cursor = "pointer" : l.style.cursor = "default", w ? (l.setAttribute("tabindex", "0"), l.setAttribute("role", "button"), l.setAttribute("aria-haspopup", "menu")) : (l.setAttribute("tabindex", "0"), l.setAttribute("role", "columnheader"), l.removeAttribute("aria-haspopup"));
|
|
268
|
+
const G = (Y) => {
|
|
269
|
+
Y.target?.closest(".k-column-resizer") || (n.value = l, p.click());
|
|
270
|
+
}, X = (Y) => {
|
|
271
271
|
if (w)
|
|
272
|
-
n.value = l,
|
|
273
|
-
else if (
|
|
272
|
+
n.value = l, Y.preventDefault(), Y.stopPropagation(), G(Y);
|
|
273
|
+
else if (L) {
|
|
274
274
|
n.value = l;
|
|
275
|
-
const
|
|
275
|
+
const J = new KeyboardEvent("keydown", {
|
|
276
276
|
key: "Enter",
|
|
277
277
|
code: "Enter",
|
|
278
278
|
keyCode: 13,
|
|
@@ -280,211 +280,211 @@ const Ve = (e) => {
|
|
|
280
280
|
bubbles: !0,
|
|
281
281
|
cancelable: !0
|
|
282
282
|
});
|
|
283
|
-
l.dispatchEvent(
|
|
283
|
+
l.dispatchEvent(J);
|
|
284
284
|
}
|
|
285
285
|
};
|
|
286
|
-
l.addEventListener("click", X),
|
|
286
|
+
l.addEventListener("click", X), V.push(() => {
|
|
287
287
|
l.removeEventListener("click", X);
|
|
288
288
|
});
|
|
289
|
-
const
|
|
290
|
-
if ((
|
|
289
|
+
const re = (Y) => {
|
|
290
|
+
if ((Y.code === "Enter" || Y.code === "Space") && (w || L)) {
|
|
291
291
|
if (n.value = l, n.value.focus(), w)
|
|
292
|
-
|
|
293
|
-
else if (
|
|
294
|
-
const
|
|
295
|
-
|
|
292
|
+
Y.preventDefault(), Y.stopPropagation(), G(Y);
|
|
293
|
+
else if (L) {
|
|
294
|
+
const J = l.querySelector(".k-link");
|
|
295
|
+
J && J.click();
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
|
-
l.addEventListener("keydown",
|
|
300
|
-
l.removeEventListener("keydown",
|
|
299
|
+
l.addEventListener("keydown", re, !0), V.push(() => {
|
|
300
|
+
l.removeEventListener("keydown", re, !0);
|
|
301
301
|
});
|
|
302
302
|
});
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
const l = (
|
|
306
|
-
const
|
|
307
|
-
|
|
303
|
+
const m = document.querySelector(".k-grid-header .k-table-thead");
|
|
304
|
+
if (m) {
|
|
305
|
+
const l = (u) => {
|
|
306
|
+
const p = u.target.closest("th");
|
|
307
|
+
p && (u.code === "Enter" || u.code === "Space") && p.dataset.featherKFilterable === "false" && p.dataset.featherKSortable === "false" && (u.preventDefault(), u.stopImmediatePropagation());
|
|
308
308
|
};
|
|
309
|
-
|
|
309
|
+
m.addEventListener(
|
|
310
310
|
"keydown",
|
|
311
311
|
l,
|
|
312
312
|
!0
|
|
313
313
|
// NOTE: capture phase
|
|
314
|
-
),
|
|
315
|
-
|
|
314
|
+
), V.push(() => {
|
|
315
|
+
m.removeEventListener(
|
|
316
316
|
"keydown",
|
|
317
317
|
l,
|
|
318
318
|
!0
|
|
319
319
|
);
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
|
-
},
|
|
323
|
-
const l =
|
|
324
|
-
if (!l || !
|
|
325
|
-
const
|
|
326
|
-
if (!
|
|
327
|
-
if (
|
|
328
|
-
(
|
|
329
|
-
(
|
|
322
|
+
}, g = function(a, m) {
|
|
323
|
+
const l = a?.event.event.target, u = A();
|
|
324
|
+
if (!l || !u) return;
|
|
325
|
+
const p = l.classList.contains("k-link"), x = l.classList.contains("k-columnmenu-item"), w = u.find((L) => L.field === a.event.field)?.sortable && !0;
|
|
326
|
+
if (!p) {
|
|
327
|
+
if (x && !w) {
|
|
328
|
+
(a.event.sort && void 0)?.filter(
|
|
329
|
+
(G) => G.field !== a.event.field
|
|
330
330
|
);
|
|
331
331
|
return;
|
|
332
332
|
}
|
|
333
|
-
typeof
|
|
334
|
-
n.value && n.value.focus(),
|
|
333
|
+
typeof m == "function" && H(() => {
|
|
334
|
+
n.value && n.value.focus(), m(a);
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
|
-
},
|
|
337
|
+
}, U = () => {
|
|
338
338
|
if (!d)
|
|
339
339
|
try {
|
|
340
|
-
|
|
341
|
-
} catch (
|
|
342
|
-
console.error("initA11y failed:",
|
|
340
|
+
E(), S(), C(), d = !0;
|
|
341
|
+
} catch (a) {
|
|
342
|
+
console.error("initA11y failed:", a), R();
|
|
343
343
|
}
|
|
344
344
|
};
|
|
345
345
|
return xe(() => {
|
|
346
|
-
|
|
346
|
+
R();
|
|
347
347
|
}), {
|
|
348
348
|
activeFilterButton: n,
|
|
349
|
-
handleGridKeyDown:
|
|
350
|
-
handleSortChange:
|
|
351
|
-
initA11y:
|
|
349
|
+
handleGridKeyDown: T,
|
|
350
|
+
handleSortChange: g,
|
|
351
|
+
initA11y: U
|
|
352
352
|
};
|
|
353
353
|
};
|
|
354
354
|
function Ye(e) {
|
|
355
|
-
const n =
|
|
356
|
-
const
|
|
357
|
-
return parseInt(
|
|
358
|
-
}),
|
|
359
|
-
const
|
|
360
|
-
return parseInt(
|
|
361
|
-
}), S =
|
|
362
|
-
const
|
|
363
|
-
return parseInt(
|
|
364
|
-
}),
|
|
365
|
-
if (
|
|
366
|
-
e.onChange({ value: null, event:
|
|
355
|
+
const n = j(""), d = j(void 0), P = j(!!e.debug), q = j(e.dateFormat ?? "mm/dd/yyyy"), V = b(() => !!e.required), W = j(!1), A = ["ArrowUp", "ArrowDown"], D = ["ArrowLeft", "ArrowRight"], h = b(() => (n.value ?? "").replace(/\D/g, "")), k = (o) => o <= 2 ? "mm" : o <= 5 ? "dd" : h.value.length <= 10 ? "yyyy" : "mm", T = b(() => {
|
|
356
|
+
const o = n.value && n.value.substring(0, 2).replace(/\D/g, "0") || "0";
|
|
357
|
+
return parseInt(o).toString().padStart(2, "0");
|
|
358
|
+
}), E = b(() => {
|
|
359
|
+
const o = n.value && n.value.substring(3, 5).replace(/\D/g, "0") || "0";
|
|
360
|
+
return parseInt(o).toString().padStart(2, "0");
|
|
361
|
+
}), S = b(() => {
|
|
362
|
+
const o = n.value && n.value.substring(6, 10).replace(/\D/g, "0") || "0";
|
|
363
|
+
return parseInt(o).toString().padStart(4, "0");
|
|
364
|
+
}), C = (o) => {
|
|
365
|
+
if (h.value.length === 0) {
|
|
366
|
+
e.onChange({ value: null, event: o });
|
|
367
367
|
return;
|
|
368
368
|
}
|
|
369
|
-
if (
|
|
370
|
-
e.onChange({ value: null, event:
|
|
369
|
+
if (h.value.length < 8) {
|
|
370
|
+
e.onChange({ value: null, event: o });
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
|
-
if ((n.value ?? "").length === 10 &&
|
|
374
|
-
const [
|
|
375
|
-
if (
|
|
376
|
-
const
|
|
377
|
-
|
|
373
|
+
if ((n.value ?? "").length === 10 && h.value.length === 8) {
|
|
374
|
+
const [c, I, ee] = n.value.split("/"), r = parseInt(c), i = parseInt(I), y = parseInt(ee);
|
|
375
|
+
if (a(y, r, i)) {
|
|
376
|
+
const $ = new Date(y, r - 1, i);
|
|
377
|
+
R($) ? e.onChange({ value: $, event: o }) : e.onChange({ value: null, event: o });
|
|
378
378
|
} else
|
|
379
|
-
e.onChange({ value: null, event:
|
|
379
|
+
e.onChange({ value: null, event: o });
|
|
380
380
|
}
|
|
381
|
-
},
|
|
382
|
-
const
|
|
383
|
-
return !(
|
|
384
|
-
}, f =
|
|
385
|
-
if ((n.value ?? "").length === 10 &&
|
|
386
|
-
const [
|
|
387
|
-
if (
|
|
388
|
-
return new Date(
|
|
381
|
+
}, R = (o) => {
|
|
382
|
+
const c = e.min ?? void 0, I = e.max ?? void 0;
|
|
383
|
+
return !(c && o < c || I && o > I);
|
|
384
|
+
}, f = b(() => {
|
|
385
|
+
if ((n.value ?? "").length === 10 && h.value.length === 8) {
|
|
386
|
+
const [o, c, I] = (n.value ?? "").split("/"), ee = parseInt(o), r = parseInt(c), i = parseInt(I);
|
|
387
|
+
if (a(i, ee, r))
|
|
388
|
+
return new Date(i, ee - 1, r);
|
|
389
389
|
}
|
|
390
390
|
return null;
|
|
391
|
-
}),
|
|
392
|
-
n.value =
|
|
393
|
-
const
|
|
394
|
-
d.value =
|
|
395
|
-
}, l = (
|
|
396
|
-
d.value =
|
|
397
|
-
},
|
|
398
|
-
const
|
|
399
|
-
d.value =
|
|
400
|
-
let
|
|
401
|
-
if (!(
|
|
402
|
-
const
|
|
403
|
-
|
|
391
|
+
}), g = b(() => (n.value ?? "").length === 10 && h.value.length === 8), U = (o, c) => new Date(o, c, 0).getDate(), a = (o, c, I) => c >= 1 && c <= 12 && o >= 1900 && I >= 1 && I <= U(o, c), m = (o) => {
|
|
392
|
+
n.value = o.value;
|
|
393
|
+
const c = o.event?.target;
|
|
394
|
+
d.value = c?.selectionStart ?? 0, C(o);
|
|
395
|
+
}, l = (o) => {
|
|
396
|
+
d.value = o.target.selectionStart ?? 0;
|
|
397
|
+
}, u = (o, c, I) => {
|
|
398
|
+
const ee = c?.selectionStart ?? d.value ?? 0;
|
|
399
|
+
d.value = ee;
|
|
400
|
+
let r = parseInt(T.value), i = parseInt(E.value), y = parseInt(S.value);
|
|
401
|
+
if (!(h.value.length >= 8) || !a(y, r, i)) {
|
|
402
|
+
const z = e.defaultValue ?? /* @__PURE__ */ new Date();
|
|
403
|
+
r = z.getMonth() + 1, i = z.getDate(), y = z.getFullYear(), n.value = `${String(r).padStart(2, "0")}/${String(i).padStart(
|
|
404
404
|
2,
|
|
405
405
|
"0"
|
|
406
|
-
)}/${String(
|
|
407
|
-
const t = new Date(
|
|
408
|
-
e.onChange({ value:
|
|
406
|
+
)}/${String(y)}`;
|
|
407
|
+
const t = new Date(y, r - 1, i);
|
|
408
|
+
e.onChange({ value: R(t) ? t : null, event: I }), H(() => {
|
|
409
409
|
requestAnimationFrame(() => {
|
|
410
410
|
const s = document.getElementById(
|
|
411
411
|
e.id
|
|
412
|
-
),
|
|
413
|
-
s && (s.focus(), s.setSelectionRange(
|
|
412
|
+
), v = d.value ?? 0;
|
|
413
|
+
s && (s.focus(), s.setSelectionRange(v, v));
|
|
414
414
|
});
|
|
415
415
|
});
|
|
416
416
|
return;
|
|
417
417
|
}
|
|
418
|
-
const
|
|
419
|
-
if (
|
|
420
|
-
|
|
421
|
-
else if (
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
} else
|
|
425
|
-
n.value = `${String(
|
|
418
|
+
const F = k(ee);
|
|
419
|
+
if (F === "mm")
|
|
420
|
+
r = o === "ArrowUp" ? r < 12 ? r + 1 : 1 : r > 1 ? r - 1 : 12;
|
|
421
|
+
else if (F === "dd") {
|
|
422
|
+
const z = new Date(y, r, 0).getDate();
|
|
423
|
+
i = o === "ArrowUp" ? i < z ? i + 1 : 1 : i > 1 ? i - 1 : z;
|
|
424
|
+
} else F === "yyyy" && (y = o === "ArrowUp" ? y + 1 : Math.max(1, y - 1));
|
|
425
|
+
n.value = `${String(r).padStart(2, "0")}/${String(i).padStart(
|
|
426
426
|
2,
|
|
427
427
|
"0"
|
|
428
|
-
)}/${String(
|
|
429
|
-
const [
|
|
430
|
-
parseInt(
|
|
431
|
-
parseInt(
|
|
432
|
-
parseInt(
|
|
428
|
+
)}/${String(y)}`;
|
|
429
|
+
const [ne, _, N] = n.value.split("/"), ae = new Date(
|
|
430
|
+
parseInt(N),
|
|
431
|
+
parseInt(ne) - 1,
|
|
432
|
+
parseInt(_)
|
|
433
433
|
);
|
|
434
|
-
|
|
435
|
-
value:
|
|
436
|
-
event:
|
|
437
|
-
}) : e.onChange({ value: null, event:
|
|
434
|
+
ae.toString() !== "Invalid Date" && parseInt(N) >= 1e3 ? e.onChange({
|
|
435
|
+
value: R(ae) ? ae : null,
|
|
436
|
+
event: I
|
|
437
|
+
}) : e.onChange({ value: null, event: I }), H(() => {
|
|
438
438
|
requestAnimationFrame(() => {
|
|
439
|
-
const
|
|
439
|
+
const z = document.getElementById(
|
|
440
440
|
e.id
|
|
441
441
|
), t = d.value ?? 0;
|
|
442
|
-
|
|
442
|
+
z && (z.focus(), z.setSelectionRange(t, t));
|
|
443
443
|
});
|
|
444
444
|
});
|
|
445
|
-
},
|
|
446
|
-
if (
|
|
447
|
-
e.onShowCalendar(
|
|
445
|
+
}, p = (o) => {
|
|
446
|
+
if (o.code === "Space" || o.key === " ") {
|
|
447
|
+
e.onShowCalendar(o);
|
|
448
448
|
return;
|
|
449
449
|
}
|
|
450
|
-
if (
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
|
|
450
|
+
if (A.includes(o.key)) {
|
|
451
|
+
o.preventDefault();
|
|
452
|
+
const c = o.target;
|
|
453
|
+
u(o.key, c, o);
|
|
454
454
|
}
|
|
455
|
-
},
|
|
456
|
-
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
}, w = (
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
462
|
-
d.value =
|
|
455
|
+
}, x = (o) => {
|
|
456
|
+
o.preventDefault();
|
|
457
|
+
const c = o.deltaY < 0 ? "ArrowUp" : "ArrowDown";
|
|
458
|
+
u(c, o.target, o);
|
|
459
|
+
}, w = (o) => {
|
|
460
|
+
const c = o.target;
|
|
461
|
+
if (D.includes(o.key)) {
|
|
462
|
+
d.value = c?.selectionStart ?? 0;
|
|
463
463
|
return;
|
|
464
464
|
}
|
|
465
|
-
|
|
466
|
-
},
|
|
467
|
-
|
|
468
|
-
const
|
|
469
|
-
|
|
465
|
+
A.includes(o.key) && (o.preventDefault(), d.value = c?.selectionStart ?? 0);
|
|
466
|
+
}, L = (o) => {
|
|
467
|
+
W.value = !0, V.value && !e.defaultValue && e.externalValue && e.externalValue.value === void 0 && h.value.length === 0 && (e.externalValue.value = "");
|
|
468
|
+
const c = o.target;
|
|
469
|
+
c && (d.value = c.selectionStart ?? 0);
|
|
470
470
|
};
|
|
471
471
|
e.externalValue && ie(
|
|
472
472
|
e.externalValue,
|
|
473
|
-
(
|
|
474
|
-
if (
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
n.value = `${
|
|
473
|
+
(o) => {
|
|
474
|
+
if (o) {
|
|
475
|
+
const c = new Date(o);
|
|
476
|
+
if (c.toString() !== "Invalid Date") {
|
|
477
|
+
const I = (c.getMonth() + 1).toString().padStart(2, "0"), ee = c.getDate().toString().padStart(2, "0"), r = c.getFullYear().toString();
|
|
478
|
+
n.value = `${I}/${ee}/${r}`;
|
|
479
479
|
return;
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
482
|
},
|
|
483
483
|
{ immediate: !0 }
|
|
484
484
|
);
|
|
485
|
-
const
|
|
486
|
-
["Date", `${
|
|
487
|
-
["Digits only",
|
|
485
|
+
const G = b(() => [
|
|
486
|
+
["Date", `${T.value} / ${E.value} / ${S.value}`],
|
|
487
|
+
["Digits only", h.value],
|
|
488
488
|
[
|
|
489
489
|
"min",
|
|
490
490
|
e.min?.toLocaleDateString("en-US", {
|
|
@@ -501,127 +501,130 @@ function Ye(e) {
|
|
|
501
501
|
day: "2-digit"
|
|
502
502
|
}) ?? null
|
|
503
503
|
]
|
|
504
|
-
]), X =
|
|
505
|
-
if (!
|
|
506
|
-
if (!
|
|
507
|
-
const
|
|
508
|
-
return
|
|
504
|
+
]), X = b(() => {
|
|
505
|
+
if (!V.value) {
|
|
506
|
+
if (!g.value) return !0;
|
|
507
|
+
const c = f.value;
|
|
508
|
+
return c ? R(c) : !1;
|
|
509
509
|
}
|
|
510
|
-
if (!
|
|
511
|
-
const
|
|
512
|
-
return !
|
|
513
|
-
}),
|
|
514
|
-
if (!
|
|
515
|
-
if (!
|
|
516
|
-
const
|
|
517
|
-
return
|
|
510
|
+
if (!W.value) return !0;
|
|
511
|
+
const o = f.value;
|
|
512
|
+
return !g.value || !o ? !1 : R(o);
|
|
513
|
+
}), re = b(() => {
|
|
514
|
+
if (!V.value) {
|
|
515
|
+
if (!g.value) return;
|
|
516
|
+
const c = f.value;
|
|
517
|
+
return c ? R(c) ? "valid" : "out-of-bounds" : "invalid-date";
|
|
518
518
|
}
|
|
519
|
-
if (!
|
|
520
|
-
if (
|
|
519
|
+
if (!W.value) return;
|
|
520
|
+
if (h.value.length === 0 || !g.value)
|
|
521
521
|
return "incomplete";
|
|
522
|
-
const
|
|
523
|
-
return
|
|
524
|
-
}),
|
|
525
|
-
const
|
|
526
|
-
if (!
|
|
527
|
-
if (
|
|
522
|
+
const o = f.value;
|
|
523
|
+
return o ? R(o) ? "valid" : "out-of-bounds" : "invalid-date";
|
|
524
|
+
}), Y = b(() => {
|
|
525
|
+
const o = re.value;
|
|
526
|
+
if (!o || o === "valid") return "";
|
|
527
|
+
if (o === "incomplete")
|
|
528
528
|
return "Required";
|
|
529
|
-
if (
|
|
530
|
-
return `Must be in ${
|
|
531
|
-
const
|
|
529
|
+
if (o === "invalid-date")
|
|
530
|
+
return `Must be in ${q.value} format.`;
|
|
531
|
+
const c = e.min ? e.min.toLocaleDateString("en-US", {
|
|
532
532
|
year: "numeric",
|
|
533
533
|
month: "2-digit",
|
|
534
534
|
day: "2-digit"
|
|
535
|
-
}) : null,
|
|
535
|
+
}) : null, I = e.max ? e.max.toLocaleDateString("en-US", {
|
|
536
536
|
year: "numeric",
|
|
537
537
|
month: "2-digit",
|
|
538
538
|
day: "2-digit"
|
|
539
539
|
}) : null;
|
|
540
|
-
if (
|
|
541
|
-
if (
|
|
542
|
-
if (
|
|
543
|
-
if (
|
|
540
|
+
if (o === "out-of-bounds") {
|
|
541
|
+
if (c && I) return `Must be between ${c} and ${I}.`;
|
|
542
|
+
if (c) return `Must be on or after ${c}.`;
|
|
543
|
+
if (I) return `Must be on or before ${I}.`;
|
|
544
544
|
}
|
|
545
545
|
return "";
|
|
546
|
-
}),
|
|
547
|
-
|
|
548
|
-
const
|
|
546
|
+
}), J = () => {
|
|
547
|
+
H(() => {
|
|
548
|
+
const o = document.getElementById(
|
|
549
549
|
e.id
|
|
550
550
|
);
|
|
551
|
-
if (!
|
|
551
|
+
if (!o) {
|
|
552
552
|
console.warn(`ID (#${e.id}) not found for styling.`);
|
|
553
553
|
return;
|
|
554
554
|
}
|
|
555
|
-
const
|
|
556
|
-
if (
|
|
557
|
-
|
|
558
|
-
|
|
555
|
+
const c = o.closest(".k-datepicker");
|
|
556
|
+
if (c) {
|
|
557
|
+
const I = c.parentElement;
|
|
558
|
+
I ? I.classList.add("fk-datepicker") : console.warn(
|
|
559
|
+
`Parent of .k-datepicker not found for #${e.id} styling.`
|
|
560
|
+
);
|
|
561
|
+
} else {
|
|
559
562
|
console.warn(`.k-datepicker parent not found for #${e.id} styling.`);
|
|
560
563
|
return;
|
|
561
564
|
}
|
|
562
565
|
});
|
|
563
566
|
};
|
|
564
567
|
return De(() => {
|
|
565
|
-
|
|
568
|
+
J();
|
|
566
569
|
}), {
|
|
567
570
|
raw: n,
|
|
568
571
|
cursorPos: d,
|
|
569
|
-
debugEnabled:
|
|
570
|
-
debugLines:
|
|
571
|
-
placeholder:
|
|
572
|
+
debugEnabled: P,
|
|
573
|
+
debugLines: G,
|
|
574
|
+
placeholder: q,
|
|
572
575
|
isValid: X,
|
|
573
|
-
reason:
|
|
574
|
-
validationMessage:
|
|
575
|
-
digitsOnly:
|
|
576
|
-
month:
|
|
577
|
-
day:
|
|
578
|
-
year:
|
|
579
|
-
datePart:
|
|
580
|
-
handleChange:
|
|
581
|
-
handleKeyDown:
|
|
582
|
-
handleWheel:
|
|
576
|
+
reason: B(re),
|
|
577
|
+
validationMessage: Y,
|
|
578
|
+
digitsOnly: h,
|
|
579
|
+
month: B(T),
|
|
580
|
+
day: B(E),
|
|
581
|
+
year: B(S),
|
|
582
|
+
datePart: k,
|
|
583
|
+
handleChange: m,
|
|
584
|
+
handleKeyDown: p,
|
|
585
|
+
handleWheel: x,
|
|
583
586
|
handleKeyUp: w,
|
|
584
587
|
handleClick: l,
|
|
585
|
-
handleBlur:
|
|
588
|
+
handleBlur: L
|
|
586
589
|
};
|
|
587
590
|
}
|
|
588
591
|
function Ne(e) {
|
|
589
|
-
const n =
|
|
590
|
-
e.min = e.min ??
|
|
591
|
-
const
|
|
592
|
+
const n = j(""), d = j(void 0), P = j(!!e.debug), q = j(!1), W = 365 * (1440 * 60 * 1e3), A = /* @__PURE__ */ new Date(), D = new Date(A.getTime() - W), h = new Date(A.getTime() + W);
|
|
593
|
+
e.min = e.min ?? D, e.max = e.max ?? h;
|
|
594
|
+
const k = b(() => (n.value ?? "").replace(/\D/g, "")), T = (t, s) => new Date(t, s, 0).getDate(), E = (t, s, v) => s >= 1 && s <= 12 && t >= 1e3 && v >= 1 && v <= T(t, s), S = (t) => Date.UTC(t.getFullYear(), t.getMonth(), t.getDate()), C = (t) => {
|
|
592
595
|
if (!t) return null;
|
|
593
|
-
const s = e.min,
|
|
594
|
-
return
|
|
595
|
-
},
|
|
596
|
-
if ((t ?? "").length < 23 ||
|
|
596
|
+
const s = e.min, v = e.max, M = S(t);
|
|
597
|
+
return M < S(s) || M > S(v) ? null : t;
|
|
598
|
+
}, R = (t, s) => e.allowReverse ?? !1 ? !0 : t <= s, f = b(() => (n.value?.length ?? 0) >= 23 && k.value.length >= 16), g = (t) => {
|
|
599
|
+
if ((t ?? "").length < 23 || k.value.length < 16)
|
|
597
600
|
return { start: null, end: null };
|
|
598
|
-
const s = t.substring(0, 10),
|
|
601
|
+
const s = t.substring(0, 10), v = t.substring(13, 23), [M, K, Q] = s.split("/").map((le) => parseInt(le || "0", 10)), [me, se, ce] = v.split("/").map((le) => parseInt(le || "0", 10)), de = new Date(Q, M - 1, K), pe = new Date(ce, me - 1, se), ye = E(Q, M, K) && de.toString() !== "Invalid Date", he = E(ce, me, se) && pe.toString() !== "Invalid Date";
|
|
599
602
|
return { start: ye ? de : null, end: he ? pe : null };
|
|
600
|
-
},
|
|
601
|
-
const t =
|
|
603
|
+
}, U = e.externalValid ?? j(void 0), a = b(() => g(n.value)), m = b(() => {
|
|
604
|
+
const t = C(a.value.start), s = C(a.value.end);
|
|
602
605
|
return { start: t, end: s };
|
|
603
|
-
}), l =
|
|
606
|
+
}), l = b(() => {
|
|
604
607
|
if (!f.value) return;
|
|
605
|
-
const t =
|
|
608
|
+
const t = m.value.start, s = m.value.end;
|
|
606
609
|
if (!t || !s) return;
|
|
607
|
-
const
|
|
608
|
-
return Math.round(
|
|
609
|
-
}),
|
|
610
|
-
const { start: t, end: s } =
|
|
610
|
+
const v = (K) => Date.UTC(K.getFullYear(), K.getMonth(), K.getDate()), M = Math.abs(v(s) - v(t));
|
|
611
|
+
return Math.round(M / 864e5);
|
|
612
|
+
}), u = b(() => {
|
|
613
|
+
const { start: t, end: s } = a.value;
|
|
611
614
|
if (!f.value) return;
|
|
612
|
-
if (!t || !s || !
|
|
613
|
-
const
|
|
614
|
-
return !(!
|
|
615
|
-
}),
|
|
616
|
-
const { start: t, end: s } =
|
|
615
|
+
if (!t || !s || !m.value.start || !m.value.end) return !1;
|
|
616
|
+
const v = m.value.start, M = m.value.end;
|
|
617
|
+
return !(!R(v, M) || typeof e.maxSpanDays == "number" && l.value !== void 0 && l.value > e.maxSpanDays);
|
|
618
|
+
}), p = b(() => {
|
|
619
|
+
const { start: t, end: s } = a.value;
|
|
617
620
|
if (!f.value) return "incomplete";
|
|
618
621
|
if (!t || !s) return "invalid-date";
|
|
619
|
-
if (!
|
|
620
|
-
const
|
|
621
|
-
return
|
|
622
|
-
}),
|
|
623
|
-
const { start: t, end: s } =
|
|
624
|
-
switch (console.table({ start: t, end: s, min:
|
|
622
|
+
if (!m.value.start || !m.value.end) return "out-of-bounds";
|
|
623
|
+
const v = m.value.start, M = m.value.end;
|
|
624
|
+
return R(v, M) ? typeof e.maxSpanDays == "number" && l.value !== void 0 && l.value > e.maxSpanDays ? "span-exceeds-limit" : "valid" : "reversed-range";
|
|
625
|
+
}), x = b(() => {
|
|
626
|
+
const { start: t, end: s } = a.value, { min: v, max: M } = e;
|
|
627
|
+
switch (console.table({ start: t, end: s, min: v, max: M }), p.value) {
|
|
625
628
|
case "incomplete":
|
|
626
629
|
return "Required";
|
|
627
630
|
case "invalid-date":
|
|
@@ -629,7 +632,7 @@ function Ne(e) {
|
|
|
629
632
|
case "reversed-range":
|
|
630
633
|
return "End Date must be on or after Start Date.";
|
|
631
634
|
case "out-of-bounds":
|
|
632
|
-
return t && s && (S(t) < S(
|
|
635
|
+
return t && s && (S(t) < S(v) || S(s) < S(v) || S(t) > S(M) || S(s) > S(M)) ? `Dates must be between ${X(v)} and ${X(M)}.` : "Dates must be within the allowed range.";
|
|
633
636
|
case "span-exceeds-limit":
|
|
634
637
|
return typeof e.maxSpanDays == "number" ? `Date range exceeds ${e.maxSpanDays} days.` : "Date range exceeds maximum allowed span.";
|
|
635
638
|
case "valid":
|
|
@@ -638,84 +641,84 @@ function Ne(e) {
|
|
|
638
641
|
}
|
|
639
642
|
});
|
|
640
643
|
ie(
|
|
641
|
-
|
|
644
|
+
u,
|
|
642
645
|
(t) => {
|
|
643
|
-
(e.manageValid ?? !0) && (
|
|
646
|
+
(e.manageValid ?? !0) && (U.value = t);
|
|
644
647
|
},
|
|
645
648
|
{ immediate: !0 }
|
|
646
649
|
);
|
|
647
|
-
const w = ["ArrowUp", "ArrowDown"],
|
|
650
|
+
const w = ["ArrowUp", "ArrowDown"], L = ["ArrowLeft", "ArrowRight"], G = (t, s) => String(t).padStart(s, "0"), X = (t) => `${G(t.getMonth() + 1, 2)}/${G(t.getDate(), 2)}/${G(
|
|
648
651
|
t.getFullYear(),
|
|
649
652
|
4
|
|
650
|
-
)}`,
|
|
651
|
-
const
|
|
652
|
-
d.value =
|
|
653
|
-
const { start:
|
|
654
|
-
if (!
|
|
655
|
-
const
|
|
656
|
-
n.value = `${
|
|
653
|
+
)}`, re = (t) => t <= 2 ? { side: "start", part: "mm" } : t <= 5 ? { side: "start", part: (t <= 3, "dd") } : t <= 11 ? { side: "start", part: "yyyy" } : t <= 15 ? { side: "end", part: "mm" } : t <= 18 ? { side: "end", part: "dd" } : { side: "end", part: "yyyy" }, Y = (t, s, v) => {
|
|
654
|
+
const M = s?.selectionStart ?? d.value ?? 0;
|
|
655
|
+
d.value = M;
|
|
656
|
+
const { start: K, end: Q } = g(n.value);
|
|
657
|
+
if (!K && !Q) {
|
|
658
|
+
const O = /* @__PURE__ */ new Date(), oe = X(O);
|
|
659
|
+
n.value = `${oe} - ${oe}`, e.onChange({ value: { start: O, end: O }, event: v }), H(() => {
|
|
657
660
|
requestAnimationFrame(() => {
|
|
658
|
-
const
|
|
661
|
+
const Z = document.getElementById(
|
|
659
662
|
e.id
|
|
660
|
-
),
|
|
661
|
-
|
|
663
|
+
), te = d.value ?? 0;
|
|
664
|
+
Z && (Z.focus(), Z.setSelectionRange(te, te));
|
|
662
665
|
});
|
|
663
666
|
});
|
|
664
667
|
return;
|
|
665
668
|
}
|
|
666
|
-
const me = /* @__PURE__ */ new Date(), se =
|
|
667
|
-
let ce =
|
|
668
|
-
const pe = (
|
|
669
|
-
if (
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
const ge =
|
|
673
|
-
|
|
674
|
-
} else if (
|
|
675
|
-
const
|
|
676
|
-
|
|
677
|
-
} else if (
|
|
678
|
-
const
|
|
679
|
-
|
|
680
|
-
const
|
|
681
|
-
|
|
669
|
+
const me = /* @__PURE__ */ new Date(), se = re(M);
|
|
670
|
+
let ce = K ? new Date(K) : new Date(me), de = Q ? new Date(Q) : new Date(me);
|
|
671
|
+
const pe = (O, oe) => {
|
|
672
|
+
if (oe === "mm") {
|
|
673
|
+
const Z = O.getMonth() + 1, te = t === "ArrowUp" ? Z < 12 ? Z + 1 : 1 : Z > 1 ? Z - 1 : 12;
|
|
674
|
+
O.setMonth(te - 1);
|
|
675
|
+
const ge = T(O.getFullYear(), te);
|
|
676
|
+
O.getDate() > ge && O.setDate(ge);
|
|
677
|
+
} else if (oe === "dd") {
|
|
678
|
+
const Z = T(O.getFullYear(), O.getMonth() + 1), te = O.getDate(), ge = t === "ArrowUp" ? te < Z ? te + 1 : 1 : te > 1 ? te - 1 : Z;
|
|
679
|
+
O.setDate(ge);
|
|
680
|
+
} else if (oe === "yyyy") {
|
|
681
|
+
const Z = O.getFullYear();
|
|
682
|
+
O.setFullYear(t === "ArrowUp" ? Z + 1 : Math.max(1, Z - 1));
|
|
683
|
+
const te = T(O.getFullYear(), O.getMonth() + 1);
|
|
684
|
+
O.getDate() > te && O.setDate(te);
|
|
682
685
|
}
|
|
683
686
|
};
|
|
684
687
|
se.side === "start" ? pe(ce, se.part) : pe(de, se.part);
|
|
685
688
|
const ye = X(ce), he = X(de);
|
|
686
689
|
n.value = `${ye} - ${he}`;
|
|
687
|
-
const le =
|
|
688
|
-
le && be &&
|
|
690
|
+
const le = C(ce), be = C(de);
|
|
691
|
+
le && be && R(le, be) ? e.onChange({ value: { start: le, end: be }, event: v }) : e.onChange({ value: null, event: v }), H(() => {
|
|
689
692
|
requestAnimationFrame(() => {
|
|
690
|
-
const
|
|
693
|
+
const O = document.getElementById(
|
|
691
694
|
e.id
|
|
692
|
-
),
|
|
693
|
-
|
|
695
|
+
), oe = d.value ?? 0;
|
|
696
|
+
O && (O.focus(), O.setSelectionRange(oe, oe));
|
|
694
697
|
});
|
|
695
698
|
});
|
|
696
|
-
},
|
|
697
|
-
const { start: s, end:
|
|
698
|
-
if (!s || !
|
|
699
|
+
}, J = (t) => {
|
|
700
|
+
const { start: s, end: v } = g(n.value);
|
|
701
|
+
if (!s || !v) {
|
|
699
702
|
e.onChange({ value: null, event: t });
|
|
700
703
|
return;
|
|
701
704
|
}
|
|
702
|
-
const
|
|
703
|
-
if (!
|
|
705
|
+
const M = C(s), K = C(v);
|
|
706
|
+
if (!M || !K) {
|
|
704
707
|
e.onChange({ value: null, event: t });
|
|
705
708
|
return;
|
|
706
709
|
}
|
|
707
|
-
if (!
|
|
710
|
+
if (!R(M, K)) {
|
|
708
711
|
e.onChange({ value: null, event: t });
|
|
709
712
|
return;
|
|
710
713
|
}
|
|
711
|
-
e.onChange({ value: { start:
|
|
712
|
-
},
|
|
714
|
+
e.onChange({ value: { start: M, end: K }, event: t });
|
|
715
|
+
}, o = (t) => {
|
|
713
716
|
n.value = t.value;
|
|
714
717
|
const s = t.event?.target;
|
|
715
|
-
d.value = s?.selectionStart ?? 0,
|
|
716
|
-
},
|
|
718
|
+
d.value = s?.selectionStart ?? 0, J(t);
|
|
719
|
+
}, c = (t) => {
|
|
717
720
|
d.value = t.target.selectionStart ?? 0;
|
|
718
|
-
},
|
|
721
|
+
}, I = (t) => {
|
|
719
722
|
if (t.code === "Space" || t.key === " ") {
|
|
720
723
|
t.preventDefault(), e.onShowCalendar(t);
|
|
721
724
|
return;
|
|
@@ -727,14 +730,14 @@ function Ne(e) {
|
|
|
727
730
|
if (w.includes(t.key)) {
|
|
728
731
|
t.preventDefault();
|
|
729
732
|
const s = t.target;
|
|
730
|
-
|
|
733
|
+
Y(t.key, s, t);
|
|
731
734
|
}
|
|
732
|
-
},
|
|
735
|
+
}, ee = (t) => {
|
|
733
736
|
t.preventDefault();
|
|
734
737
|
const s = t.deltaY < 0 ? "ArrowUp" : "ArrowDown";
|
|
735
|
-
|
|
736
|
-
},
|
|
737
|
-
if (
|
|
738
|
+
Y(s, t.target, t);
|
|
739
|
+
}, r = (t) => {
|
|
740
|
+
if (L.includes(t.key) || w.includes(t.key)) {
|
|
738
741
|
t.preventDefault();
|
|
739
742
|
const s = t.target;
|
|
740
743
|
d.value = s?.selectionStart ?? 0;
|
|
@@ -743,33 +746,33 @@ function Ne(e) {
|
|
|
743
746
|
e.externalValue && ie(
|
|
744
747
|
e.externalValue,
|
|
745
748
|
(t) => {
|
|
746
|
-
const s = t?.start ?? null,
|
|
747
|
-
if (s &&
|
|
748
|
-
if (n.value = `${X(s)} - ${X(
|
|
749
|
-
const
|
|
749
|
+
const s = t?.start ?? null, v = t?.end ?? null;
|
|
750
|
+
if (s && v) {
|
|
751
|
+
if (n.value = `${X(s)} - ${X(v)}`, e.isOpen?.value && q.value && e.onRequestClose) {
|
|
752
|
+
const M = typeof e.closeDelay == "number" ? e.closeDelay : e.closeDelay?.value ?? 0;
|
|
750
753
|
setTimeout(() => {
|
|
751
|
-
e.onRequestClose?.(),
|
|
752
|
-
},
|
|
754
|
+
e.onRequestClose?.(), q.value = !1;
|
|
755
|
+
}, M);
|
|
753
756
|
}
|
|
754
757
|
return;
|
|
755
758
|
}
|
|
756
759
|
},
|
|
757
760
|
{ immediate: !0 }
|
|
758
761
|
);
|
|
759
|
-
const
|
|
762
|
+
const i = b(
|
|
760
763
|
() => n.value && n.value.substring(0, 2).replace(/\D/g, "0") || "0"
|
|
761
|
-
),
|
|
764
|
+
), y = b(
|
|
762
765
|
() => n.value && n.value.substring(3, 5).replace(/\D/g, "0") || "0"
|
|
763
|
-
),
|
|
766
|
+
), $ = b(
|
|
764
767
|
() => n.value && n.value.substring(6, 10).replace(/\D/g, "0") || "0"
|
|
765
|
-
),
|
|
768
|
+
), F = b(
|
|
766
769
|
() => n.value && n.value.substring(13, 15).replace(/\D/g, "0") || "0"
|
|
767
|
-
),
|
|
770
|
+
), ne = b(
|
|
768
771
|
() => n.value && n.value.substring(16, 18).replace(/\D/g, "0") || "0"
|
|
769
|
-
),
|
|
772
|
+
), _ = b(
|
|
770
773
|
() => n.value && n.value.substring(19, 23).replace(/\D/g, "0") || "0"
|
|
771
|
-
),
|
|
772
|
-
const { start: t, end: s } =
|
|
774
|
+
), N = b(() => {
|
|
775
|
+
const { start: t, end: s } = g(n.value);
|
|
773
776
|
return [
|
|
774
777
|
{
|
|
775
778
|
label: "Raw",
|
|
@@ -785,17 +788,17 @@ function Ne(e) {
|
|
|
785
788
|
},
|
|
786
789
|
{
|
|
787
790
|
label: "Start",
|
|
788
|
-
value: `${String(
|
|
789
|
-
|
|
790
|
-
).padStart(2, "0")} / ${String(
|
|
791
|
+
value: `${String(i.value).padStart(2, "0")} / ${String(
|
|
792
|
+
y.value
|
|
793
|
+
).padStart(2, "0")} / ${String($.value).padStart(4, "0")}`
|
|
791
794
|
},
|
|
792
795
|
{
|
|
793
796
|
label: "End",
|
|
794
|
-
value: `${String(
|
|
795
|
-
|
|
796
|
-
).padStart(2, "0")} / ${String(
|
|
797
|
+
value: `${String(F.value).padStart(2, "0")} / ${String(
|
|
798
|
+
ne.value
|
|
799
|
+
).padStart(2, "0")} / ${String(_.value).padStart(4, "0")}`
|
|
797
800
|
},
|
|
798
|
-
{ label: "Digits only", value:
|
|
801
|
+
{ label: "Digits only", value: k.value },
|
|
799
802
|
{ label: "Mask complete", value: `${f.value}` },
|
|
800
803
|
{
|
|
801
804
|
label: "Parsed",
|
|
@@ -803,23 +806,23 @@ function Ne(e) {
|
|
|
803
806
|
},
|
|
804
807
|
{
|
|
805
808
|
label: "Valid (managed)",
|
|
806
|
-
value: `${
|
|
809
|
+
value: `${U.value ?? "-"}`
|
|
807
810
|
},
|
|
808
811
|
{ label: "Span (days)", value: `${l.value ?? "-"}` },
|
|
809
812
|
{
|
|
810
813
|
label: "Reason",
|
|
811
|
-
value: `${
|
|
814
|
+
value: `${p.value ?? "-"}`
|
|
812
815
|
},
|
|
813
816
|
{
|
|
814
817
|
label: "Cursor in",
|
|
815
818
|
value: `${d.value ?? "-"} (${(() => {
|
|
816
|
-
const
|
|
817
|
-
return `${
|
|
819
|
+
const v = d.value ?? 0, M = re(v);
|
|
820
|
+
return `${M.side}.${M.part}`;
|
|
818
821
|
})()})`
|
|
819
822
|
}
|
|
820
823
|
];
|
|
821
|
-
}),
|
|
822
|
-
|
|
824
|
+
}), ae = () => {
|
|
825
|
+
H(() => {
|
|
823
826
|
const t = document.getElementById(e.id);
|
|
824
827
|
if (!t) {
|
|
825
828
|
console.warn(`#${e.id} not found for styling.`);
|
|
@@ -830,25 +833,25 @@ function Ne(e) {
|
|
|
830
833
|
});
|
|
831
834
|
};
|
|
832
835
|
De(() => {
|
|
833
|
-
|
|
836
|
+
ae();
|
|
834
837
|
});
|
|
835
|
-
const
|
|
836
|
-
|
|
838
|
+
const z = () => {
|
|
839
|
+
H(() => {
|
|
837
840
|
try {
|
|
838
841
|
const t = Array.from(
|
|
839
842
|
document.querySelectorAll(".k-animation-container")
|
|
840
843
|
);
|
|
841
844
|
if (!t.length) return;
|
|
842
|
-
const
|
|
845
|
+
const v = [...t].reverse().find((Q) => Q.querySelector(".k-calendar"))?.querySelector(
|
|
843
846
|
".k-calendar"
|
|
844
847
|
);
|
|
845
|
-
if (!
|
|
846
|
-
const
|
|
848
|
+
if (!v) return;
|
|
849
|
+
const M = v.querySelectorAll(
|
|
847
850
|
".k-calendar-table"
|
|
848
851
|
);
|
|
849
|
-
let
|
|
850
|
-
|
|
851
|
-
|
|
852
|
+
let K = !1;
|
|
853
|
+
M.forEach((Q) => {
|
|
854
|
+
Q.tabIndex === 0 && (K ? Q.tabIndex = -1 : K = !0);
|
|
852
855
|
});
|
|
853
856
|
} catch (t) {
|
|
854
857
|
console.warn(t);
|
|
@@ -858,214 +861,226 @@ function Ne(e) {
|
|
|
858
861
|
return e.isOpen && ie(
|
|
859
862
|
e.isOpen,
|
|
860
863
|
(t) => {
|
|
861
|
-
t && setTimeout(() =>
|
|
864
|
+
t && setTimeout(() => z(), 0);
|
|
862
865
|
},
|
|
863
866
|
{ immediate: !1 }
|
|
864
867
|
), {
|
|
865
868
|
raw: n,
|
|
866
869
|
cursorPos: d,
|
|
867
|
-
debugEnabled:
|
|
868
|
-
debugLines:
|
|
869
|
-
digitsOnly:
|
|
870
|
-
valid:
|
|
871
|
-
validComputed:
|
|
872
|
-
reason:
|
|
873
|
-
validationMessage:
|
|
874
|
-
spanDays:
|
|
875
|
-
month1:
|
|
876
|
-
day1:
|
|
877
|
-
year1:
|
|
878
|
-
month2:
|
|
879
|
-
day2:
|
|
880
|
-
year2: _
|
|
881
|
-
handleChange:
|
|
882
|
-
handleKeyDown:
|
|
883
|
-
handleWheel:
|
|
884
|
-
handleKeyUp:
|
|
885
|
-
handleClick:
|
|
870
|
+
debugEnabled: P,
|
|
871
|
+
debugLines: N,
|
|
872
|
+
digitsOnly: k,
|
|
873
|
+
valid: U,
|
|
874
|
+
validComputed: B(u),
|
|
875
|
+
reason: B(p),
|
|
876
|
+
validationMessage: B(x),
|
|
877
|
+
spanDays: B(l),
|
|
878
|
+
month1: B(i),
|
|
879
|
+
day1: B(y),
|
|
880
|
+
year1: B($),
|
|
881
|
+
month2: B(F),
|
|
882
|
+
day2: B(ne),
|
|
883
|
+
year2: B(_),
|
|
884
|
+
handleChange: o,
|
|
885
|
+
handleKeyDown: I,
|
|
886
|
+
handleWheel: ee,
|
|
887
|
+
handleKeyUp: r,
|
|
888
|
+
handleClick: c,
|
|
886
889
|
onCalendarChange: () => {
|
|
887
|
-
|
|
890
|
+
q.value = !0;
|
|
888
891
|
}
|
|
889
892
|
};
|
|
890
893
|
}
|
|
891
894
|
function He(e) {
|
|
892
|
-
const n =
|
|
895
|
+
const n = j(""), d = j(void 0), P = j(!!e.debug), q = j(e.timeFormat ?? "hh:mm AM"), V = b(() => !!e.required), W = j(!1), A = ["ArrowUp", "ArrowDown"], D = ["ArrowLeft", "ArrowRight"], h = b(() => (n.value ?? "").replace(/\D/g, "")), k = {
|
|
893
896
|
H: /[0-9]/,
|
|
894
897
|
h: /[0-9]/,
|
|
895
898
|
M: /[0-9]/,
|
|
896
899
|
m: /[0-9]/,
|
|
897
900
|
A: /[AaPp]/,
|
|
898
901
|
a: /[Mm]/
|
|
899
|
-
},
|
|
900
|
-
const r = n.value && n.value.substring(0, 2).replace(/\D/g, "0") || "0",
|
|
901
|
-
return Math.min(Math.max(
|
|
902
|
-
}), S =
|
|
903
|
-
const r = n.value && n.value.substring(3, 5).replace(/\D/g, "0") || "0",
|
|
904
|
-
return Math.min(Math.max(
|
|
905
|
-
}),
|
|
902
|
+
}, T = (r) => r <= 2 ? "hh" : r <= 5 ? "mm" : "ampm", E = b(() => {
|
|
903
|
+
const r = n.value && n.value.substring(0, 2).replace(/\D/g, "0") || "0", i = parseInt(r);
|
|
904
|
+
return Math.min(Math.max(i, 0), 23);
|
|
905
|
+
}), S = b(() => {
|
|
906
|
+
const r = n.value && n.value.substring(3, 5).replace(/\D/g, "0") || "0", i = parseInt(r);
|
|
907
|
+
return Math.min(Math.max(i, 0), 59);
|
|
908
|
+
}), C = b(() => (n.value?.substring(6, 8) || "AM").toUpperCase().startsWith("P") ? "PM" : "AM"), R = b(() => {
|
|
909
|
+
const r = parseInt(n.value?.substring(0, 2).replace(/\D/g, "0") || "0"), i = C.value;
|
|
910
|
+
return r === 12 ? i === "AM" ? 0 : 12 : i === "PM" ? r + 12 : r;
|
|
911
|
+
}), f = b(() => g.value ? `${String(R.value).padStart(2, "0")}:${String(S.value).padStart(2, "0")}:00` : null), g = b(
|
|
906
912
|
() => /^(\d{2}):(\d{2})\s([AP]M)$/i.test(n.value ?? "")
|
|
907
|
-
),
|
|
908
|
-
let
|
|
909
|
-
return
|
|
913
|
+
), U = (r, i, y) => {
|
|
914
|
+
let $ = r % 12;
|
|
915
|
+
return $ === 0 && ($ = 12), `${String($).padStart(2, "0")}:${String(i).padStart(
|
|
910
916
|
2,
|
|
911
917
|
"0"
|
|
912
|
-
)} ${
|
|
913
|
-
},
|
|
914
|
-
const
|
|
915
|
-
if (!
|
|
916
|
-
const
|
|
917
|
-
if (
|
|
918
|
-
let
|
|
919
|
-
|
|
920
|
-
const
|
|
921
|
-
return
|
|
922
|
-
},
|
|
923
|
-
if (
|
|
918
|
+
)} ${y}`;
|
|
919
|
+
}, a = (r) => {
|
|
920
|
+
const i = r.match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
|
|
921
|
+
if (!i) return null;
|
|
922
|
+
const y = parseInt(i[1]), $ = parseInt(i[2]), F = i[3].toUpperCase();
|
|
923
|
+
if (y < 1 || y > 12 || $ < 0 || $ > 59) return null;
|
|
924
|
+
let ne = y % 12;
|
|
925
|
+
F === "PM" && (ne += 12);
|
|
926
|
+
const _ = /* @__PURE__ */ new Date();
|
|
927
|
+
return _.setSeconds(0, 0), _.setHours(ne), _.setMinutes($), _;
|
|
928
|
+
}, m = (r) => {
|
|
929
|
+
if (h.value.length === 0) {
|
|
924
930
|
e.onChange({ value: null, event: r });
|
|
925
931
|
return;
|
|
926
932
|
}
|
|
927
|
-
if (!
|
|
933
|
+
if (!g.value) {
|
|
928
934
|
e.onChange({ value: null, event: r });
|
|
929
935
|
return;
|
|
930
936
|
}
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
},
|
|
934
|
-
const
|
|
935
|
-
if (
|
|
936
|
-
const
|
|
937
|
-
if (
|
|
937
|
+
const i = a(n.value);
|
|
938
|
+
i && u(i) ? e.onChange({ value: i, event: r }) : e.onChange({ value: null, event: r });
|
|
939
|
+
}, l = (r) => r.getHours() * 60 + r.getMinutes(), u = (r) => {
|
|
940
|
+
const i = e.min ?? void 0, y = e.max ?? void 0, $ = l(r);
|
|
941
|
+
if (i) {
|
|
942
|
+
const F = l(i);
|
|
943
|
+
if ($ < F) return !1;
|
|
938
944
|
}
|
|
939
|
-
if (
|
|
940
|
-
const
|
|
941
|
-
if (
|
|
945
|
+
if (y) {
|
|
946
|
+
const F = l(y);
|
|
947
|
+
if ($ > F) return !1;
|
|
942
948
|
}
|
|
943
949
|
return !0;
|
|
944
|
-
},
|
|
950
|
+
}, p = (r) => {
|
|
945
951
|
n.value = r.value;
|
|
946
|
-
const
|
|
947
|
-
d.value =
|
|
952
|
+
const i = r.event?.target;
|
|
953
|
+
d.value = i?.selectionStart ?? 0;
|
|
948
954
|
try {
|
|
949
|
-
const
|
|
950
|
-
if (
|
|
951
|
-
const
|
|
952
|
-
/[Aa]/.test(
|
|
955
|
+
const y = d.value ?? 0;
|
|
956
|
+
if (T(y) === "ampm" && (n.value ?? "").length >= 8) {
|
|
957
|
+
const $ = n.value.charAt(6);
|
|
958
|
+
/[Aa]/.test($) ? (n.value = `${n.value.slice(0, 6)}AM${n.value.slice(8)}`, H(() => {
|
|
953
959
|
requestAnimationFrame(() => {
|
|
954
|
-
const
|
|
960
|
+
const F = document.getElementById(
|
|
955
961
|
e.id
|
|
956
962
|
);
|
|
957
|
-
|
|
963
|
+
F && (F.focus(), F.setSelectionRange(8, 8));
|
|
958
964
|
});
|
|
959
|
-
})) : /[Pp]/.test(
|
|
965
|
+
})) : /[Pp]/.test($) && (n.value = `${n.value.slice(0, 6)}PM${n.value.slice(8)}`, H(() => {
|
|
960
966
|
requestAnimationFrame(() => {
|
|
961
|
-
const
|
|
967
|
+
const F = document.getElementById(
|
|
962
968
|
e.id
|
|
963
969
|
);
|
|
964
|
-
|
|
970
|
+
F && (F.focus(), F.setSelectionRange(8, 8));
|
|
965
971
|
});
|
|
966
972
|
}));
|
|
967
973
|
}
|
|
968
974
|
} catch {
|
|
969
975
|
}
|
|
970
|
-
|
|
971
|
-
},
|
|
976
|
+
m(r);
|
|
977
|
+
}, x = (r) => {
|
|
972
978
|
d.value = r.target.selectionStart ?? 0;
|
|
973
|
-
},
|
|
974
|
-
const
|
|
975
|
-
d.value =
|
|
976
|
-
const
|
|
977
|
-
if (!
|
|
978
|
-
if ((n.value ?? "").length === 0 ||
|
|
979
|
-
const
|
|
980
|
-
n.value =
|
|
981
|
-
const
|
|
982
|
-
|
|
979
|
+
}, w = (r, i, y) => {
|
|
980
|
+
const $ = i?.selectionStart ?? d.value ?? 0;
|
|
981
|
+
d.value = $;
|
|
982
|
+
const F = T($), ne = (n.value ?? "").match(/^(\d{2}):(\d{2})\s([AP]M)$/i);
|
|
983
|
+
if (!ne) {
|
|
984
|
+
if ((n.value ?? "").length === 0 || h.value.length === 0) {
|
|
985
|
+
const t = /* @__PURE__ */ new Date(), s = t.getHours(), v = s >= 12 ? "PM" : "AM";
|
|
986
|
+
n.value = U(s, t.getMinutes(), v);
|
|
987
|
+
const M = a(n.value);
|
|
988
|
+
M && u(M) ? e.onChange({ value: M, event: y }) : e.onChange({ value: null, event: y }), H(() => {
|
|
983
989
|
requestAnimationFrame(() => {
|
|
984
|
-
const
|
|
990
|
+
const K = document.getElementById(
|
|
985
991
|
e.id
|
|
986
|
-
),
|
|
987
|
-
|
|
992
|
+
), Q = d.value ?? 0;
|
|
993
|
+
K && (K.focus(), K.setSelectionRange(Q, Q));
|
|
988
994
|
});
|
|
989
995
|
});
|
|
990
996
|
}
|
|
991
997
|
return;
|
|
992
998
|
}
|
|
993
|
-
let
|
|
994
|
-
if (
|
|
995
|
-
r === "ArrowUp" ?
|
|
996
|
-
else if (
|
|
997
|
-
const
|
|
998
|
-
if (
|
|
999
|
-
r === "ArrowUp" ?
|
|
999
|
+
let _ = parseInt(ne[1]), N = parseInt(ne[2]), ae = ne[3].toUpperCase();
|
|
1000
|
+
if (F === "hh")
|
|
1001
|
+
r === "ArrowUp" ? _ = _ < 12 ? _ + 1 : 1 : _ = _ > 1 ? _ - 1 : 12;
|
|
1002
|
+
else if (F === "mm") {
|
|
1003
|
+
const t = e.minuteStepRef?.value ?? e.minuteStep ?? 1;
|
|
1004
|
+
if (t === 1)
|
|
1005
|
+
r === "ArrowUp" ? N = N < 59 ? N + 1 : 0 : N = N > 0 ? N - 1 : 59;
|
|
1000
1006
|
else if (r === "ArrowUp") {
|
|
1001
|
-
const
|
|
1002
|
-
let
|
|
1003
|
-
|
|
1007
|
+
const s = N % t;
|
|
1008
|
+
let v = s === 0 ? N + t : N + (t - s);
|
|
1009
|
+
v >= 60 && (v = 0), N = v;
|
|
1004
1010
|
} else {
|
|
1005
|
-
const
|
|
1006
|
-
let
|
|
1007
|
-
|
|
1011
|
+
const s = N % t;
|
|
1012
|
+
let v = s === 0 ? N - t : N - s;
|
|
1013
|
+
v < 0 && (v = 60 - t), N = v;
|
|
1008
1014
|
}
|
|
1009
|
-
} else
|
|
1010
|
-
n.value = `${String(
|
|
1015
|
+
} else F === "ampm" && (ae = ae === "AM" ? "PM" : "AM");
|
|
1016
|
+
n.value = `${String(_).padStart(2, "0")}:${String(N).padStart(
|
|
1011
1017
|
2,
|
|
1012
1018
|
"0"
|
|
1013
1019
|
)} ${ae}`;
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1020
|
+
const z = a(n.value);
|
|
1021
|
+
z && u(z) ? e.onChange({ value: z, event: y }) : e.onChange({ value: null, event: y }), H(() => {
|
|
1016
1022
|
requestAnimationFrame(() => {
|
|
1017
|
-
const
|
|
1023
|
+
const t = document.getElementById(
|
|
1018
1024
|
e.id
|
|
1019
|
-
),
|
|
1020
|
-
|
|
1025
|
+
), s = d.value ?? 0;
|
|
1026
|
+
t && (t.focus(), t.setSelectionRange(s, s));
|
|
1021
1027
|
});
|
|
1022
1028
|
});
|
|
1023
|
-
},
|
|
1029
|
+
}, L = (r) => {
|
|
1024
1030
|
if (r.code === "Space" || r.key === " ") {
|
|
1025
1031
|
e.onShowPicker(r);
|
|
1026
1032
|
return;
|
|
1027
1033
|
}
|
|
1028
|
-
if (
|
|
1034
|
+
if (A.includes(r.key)) {
|
|
1029
1035
|
r.preventDefault();
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1036
|
+
const i = r.target;
|
|
1037
|
+
w(r.key, i, r);
|
|
1032
1038
|
}
|
|
1033
|
-
},
|
|
1039
|
+
}, G = (r) => {
|
|
1034
1040
|
r.preventDefault();
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
},
|
|
1038
|
-
const
|
|
1039
|
-
if (
|
|
1040
|
-
d.value =
|
|
1041
|
+
const i = r.deltaY < 0 ? "ArrowUp" : "ArrowDown";
|
|
1042
|
+
w(i, r.target, r);
|
|
1043
|
+
}, X = (r) => {
|
|
1044
|
+
const i = r.target;
|
|
1045
|
+
if (D.includes(r.key)) {
|
|
1046
|
+
d.value = i?.selectionStart ?? 0;
|
|
1041
1047
|
return;
|
|
1042
1048
|
}
|
|
1043
|
-
|
|
1044
|
-
},
|
|
1045
|
-
|
|
1046
|
-
const
|
|
1047
|
-
|
|
1049
|
+
A.includes(r.key) && (r.preventDefault(), d.value = i?.selectionStart ?? 0);
|
|
1050
|
+
}, re = (r) => {
|
|
1051
|
+
W.value = !0, V.value && e.externalValue && e.externalValue.value === void 0 && h.value.length === 0 && (e.externalValue.value = "");
|
|
1052
|
+
const i = r.target;
|
|
1053
|
+
i && (d.value = i.selectionStart ?? 0);
|
|
1048
1054
|
};
|
|
1049
1055
|
e.externalValue && ie(
|
|
1050
1056
|
e.externalValue,
|
|
1051
1057
|
(r) => {
|
|
1052
1058
|
if (r) {
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1055
|
-
const
|
|
1056
|
-
n.value =
|
|
1059
|
+
const i = new Date(r);
|
|
1060
|
+
if (i.toString() !== "Invalid Date") {
|
|
1061
|
+
const y = i.getHours(), $ = y >= 12 ? "PM" : "AM";
|
|
1062
|
+
n.value = U(y, i.getMinutes(), $);
|
|
1057
1063
|
return;
|
|
1058
1064
|
}
|
|
1059
1065
|
}
|
|
1060
1066
|
},
|
|
1061
1067
|
{ immediate: !0 }
|
|
1062
1068
|
);
|
|
1063
|
-
const
|
|
1069
|
+
const Y = b(() => [
|
|
1064
1070
|
["Time", n.value || "--:-- --"],
|
|
1065
|
-
["Hour (12h)",
|
|
1071
|
+
["Hour (12h)", E.value],
|
|
1072
|
+
["Hour (24h)", R.value],
|
|
1066
1073
|
["Minute", S.value],
|
|
1067
|
-
["Period",
|
|
1068
|
-
["
|
|
1074
|
+
["Period", C.value],
|
|
1075
|
+
["Time (24h)", f.value ?? "--:--:--"],
|
|
1076
|
+
["Digits only", h.value],
|
|
1077
|
+
[
|
|
1078
|
+
"Parsed Date",
|
|
1079
|
+
J.value?.toLocaleDateString("en-US", {
|
|
1080
|
+
hour: "2-digit",
|
|
1081
|
+
minute: "2-digit"
|
|
1082
|
+
}) ?? null
|
|
1083
|
+
],
|
|
1069
1084
|
[
|
|
1070
1085
|
"min",
|
|
1071
1086
|
e.min?.toLocaleTimeString("en-US", {
|
|
@@ -1080,87 +1095,97 @@ function He(e) {
|
|
|
1080
1095
|
minute: "2-digit"
|
|
1081
1096
|
}) ?? null
|
|
1082
1097
|
],
|
|
1083
|
-
["valid",
|
|
1084
|
-
["reason",
|
|
1085
|
-
["validationMessage",
|
|
1086
|
-
]),
|
|
1087
|
-
() =>
|
|
1088
|
-
),
|
|
1089
|
-
if (!
|
|
1090
|
-
if (!
|
|
1091
|
-
const
|
|
1092
|
-
return
|
|
1098
|
+
["valid", o.value],
|
|
1099
|
+
["reason", c.value],
|
|
1100
|
+
["validationMessage", I.value]
|
|
1101
|
+
]), J = b(
|
|
1102
|
+
() => a(n.value) ?? null
|
|
1103
|
+
), o = b(() => {
|
|
1104
|
+
if (!V.value) {
|
|
1105
|
+
if (!g.value) return !0;
|
|
1106
|
+
const i = J.value;
|
|
1107
|
+
return i ? u(i) : !1;
|
|
1093
1108
|
}
|
|
1094
|
-
if (!
|
|
1095
|
-
const r =
|
|
1096
|
-
return !
|
|
1097
|
-
}),
|
|
1098
|
-
if (!
|
|
1099
|
-
if (!
|
|
1100
|
-
const
|
|
1101
|
-
return
|
|
1109
|
+
if (!W.value) return !0;
|
|
1110
|
+
const r = J.value;
|
|
1111
|
+
return !g.value || !r ? !1 : u(r);
|
|
1112
|
+
}), c = b(() => {
|
|
1113
|
+
if (!V.value) {
|
|
1114
|
+
if (!g.value) return;
|
|
1115
|
+
const i = J.value;
|
|
1116
|
+
return i ? u(i) ? "valid" : "out-of-bounds" : "invalid-time";
|
|
1102
1117
|
}
|
|
1103
|
-
if (!
|
|
1104
|
-
if (
|
|
1118
|
+
if (!W.value) return;
|
|
1119
|
+
if (h.value.length === 0 || !g.value)
|
|
1105
1120
|
return "incomplete";
|
|
1106
|
-
const r =
|
|
1107
|
-
return r ?
|
|
1108
|
-
}),
|
|
1109
|
-
const r =
|
|
1121
|
+
const r = J.value;
|
|
1122
|
+
return r ? u(r) ? "valid" : "out-of-bounds" : "invalid-time";
|
|
1123
|
+
}), I = b(() => {
|
|
1124
|
+
const r = c.value;
|
|
1110
1125
|
if (!r || r === "valid") return "";
|
|
1111
1126
|
if (r === "incomplete")
|
|
1112
1127
|
return "Required";
|
|
1113
1128
|
if (r === "invalid-time")
|
|
1114
|
-
return `Must be in ${
|
|
1115
|
-
const
|
|
1129
|
+
return `Must be in ${q.value} format.`;
|
|
1130
|
+
const i = {
|
|
1116
1131
|
hour: "2-digit",
|
|
1117
1132
|
minute: "2-digit"
|
|
1118
|
-
},
|
|
1133
|
+
}, y = e.min ? e.min.toLocaleTimeString("en-US", i) : null, $ = e.max ? e.max.toLocaleTimeString("en-US", i) : null;
|
|
1119
1134
|
if (r === "out-of-bounds") {
|
|
1120
|
-
if (
|
|
1121
|
-
if (
|
|
1122
|
-
if (
|
|
1135
|
+
if (y && $) return `Must be between ${y} and ${$}.`;
|
|
1136
|
+
if (y) return `Must be ${y} or later.`;
|
|
1137
|
+
if ($) return `Must be ${$} or earlier.`;
|
|
1123
1138
|
}
|
|
1124
1139
|
return "";
|
|
1125
|
-
}),
|
|
1126
|
-
|
|
1140
|
+
}), ee = () => {
|
|
1141
|
+
H(() => {
|
|
1127
1142
|
const r = document.getElementById(e.id);
|
|
1128
1143
|
if (!r) {
|
|
1129
1144
|
console.warn(`#${e.id} not found for styling.`);
|
|
1130
1145
|
return;
|
|
1131
1146
|
}
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1147
|
+
const i = r.closest(".k-timepicker");
|
|
1148
|
+
if (!i)
|
|
1149
|
+
console.warn(
|
|
1150
|
+
`.k-timepicker parent of #${e.id} not found for styling.`
|
|
1151
|
+
);
|
|
1152
|
+
else {
|
|
1153
|
+
const y = i.parentElement;
|
|
1154
|
+
y ? y.classList.add("fk-timepicker") : console.warn(
|
|
1155
|
+
`Parent of .k-timepicker not found for #${e.id} styling.`
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1136
1158
|
});
|
|
1137
1159
|
};
|
|
1138
1160
|
return De(() => {
|
|
1139
|
-
|
|
1161
|
+
ee();
|
|
1140
1162
|
}), {
|
|
1141
1163
|
raw: n,
|
|
1142
|
-
rules:
|
|
1143
|
-
debugEnabled:
|
|
1144
|
-
debugLines:
|
|
1145
|
-
placeholder:
|
|
1146
|
-
isValid:
|
|
1147
|
-
reason:
|
|
1148
|
-
validationMessage:
|
|
1149
|
-
isComplete:
|
|
1150
|
-
inRangeTime:
|
|
1164
|
+
rules: k,
|
|
1165
|
+
debugEnabled: P,
|
|
1166
|
+
debugLines: Y,
|
|
1167
|
+
placeholder: q,
|
|
1168
|
+
isValid: o,
|
|
1169
|
+
reason: B(c),
|
|
1170
|
+
validationMessage: I,
|
|
1171
|
+
isComplete: g,
|
|
1172
|
+
inRangeTime: u,
|
|
1151
1173
|
cursorPos: d,
|
|
1152
|
-
hour:
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1174
|
+
hour: B(E),
|
|
1175
|
+
hour24: B(R),
|
|
1176
|
+
minute: B(S),
|
|
1177
|
+
period: B(C),
|
|
1178
|
+
time24: B(f),
|
|
1179
|
+
parsedRawTime: B(J),
|
|
1180
|
+
handleChange: p,
|
|
1181
|
+
handleKeyDown: L,
|
|
1182
|
+
handleKeyUp: X,
|
|
1183
|
+
handleClick: x,
|
|
1184
|
+
handleWheel: G,
|
|
1185
|
+
handleBlur: re
|
|
1161
1186
|
};
|
|
1162
1187
|
}
|
|
1163
|
-
function
|
|
1188
|
+
function Le(e) {
|
|
1164
1189
|
return Me() ? ($e(e), !0) : !1;
|
|
1165
1190
|
}
|
|
1166
1191
|
const Ae = typeof window < "u" && typeof document < "u";
|
|
@@ -1192,104 +1217,104 @@ function ve(e) {
|
|
|
1192
1217
|
}
|
|
1193
1218
|
function we(...e) {
|
|
1194
1219
|
const n = [], d = () => {
|
|
1195
|
-
n.forEach((
|
|
1196
|
-
},
|
|
1197
|
-
const
|
|
1198
|
-
return
|
|
1199
|
-
}),
|
|
1220
|
+
n.forEach((A) => A()), n.length = 0;
|
|
1221
|
+
}, P = (A, D, h, k) => (A.addEventListener(D, h, k), () => A.removeEventListener(D, h, k)), q = b(() => {
|
|
1222
|
+
const A = Se(ue(e[0])).filter((D) => D != null);
|
|
1223
|
+
return A.every((D) => typeof D != "string") ? A : void 0;
|
|
1224
|
+
}), V = Ue(
|
|
1200
1225
|
() => {
|
|
1201
|
-
var
|
|
1226
|
+
var A, D;
|
|
1202
1227
|
return [
|
|
1203
|
-
(
|
|
1204
|
-
Se(ue(
|
|
1205
|
-
Se(Ce(
|
|
1228
|
+
(D = (A = q.value) == null ? void 0 : A.map((h) => ve(h))) != null ? D : [Ee].filter((h) => h != null),
|
|
1229
|
+
Se(ue(q.value ? e[1] : e[0])),
|
|
1230
|
+
Se(Ce(q.value ? e[2] : e[1])),
|
|
1206
1231
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
1207
|
-
ue(
|
|
1232
|
+
ue(q.value ? e[3] : e[2])
|
|
1208
1233
|
];
|
|
1209
1234
|
},
|
|
1210
|
-
([
|
|
1211
|
-
if (d(), !
|
|
1235
|
+
([A, D, h, k]) => {
|
|
1236
|
+
if (d(), !A?.length || !D?.length || !h?.length)
|
|
1212
1237
|
return;
|
|
1213
|
-
const
|
|
1238
|
+
const T = qe(k) ? { ...k } : k;
|
|
1214
1239
|
n.push(
|
|
1215
|
-
...
|
|
1216
|
-
(
|
|
1217
|
-
(S) =>
|
|
1240
|
+
...A.flatMap(
|
|
1241
|
+
(E) => D.flatMap(
|
|
1242
|
+
(S) => h.map((C) => P(E, S, C, T))
|
|
1218
1243
|
)
|
|
1219
1244
|
)
|
|
1220
1245
|
);
|
|
1221
1246
|
},
|
|
1222
1247
|
{ flush: "post" }
|
|
1223
|
-
),
|
|
1224
|
-
|
|
1248
|
+
), W = () => {
|
|
1249
|
+
V(), d();
|
|
1225
1250
|
};
|
|
1226
|
-
return
|
|
1251
|
+
return Le(d), W;
|
|
1227
1252
|
}
|
|
1228
1253
|
let ke = !1;
|
|
1229
1254
|
function Oe(e, n, d = {}) {
|
|
1230
|
-
const { window:
|
|
1231
|
-
if (!
|
|
1232
|
-
return
|
|
1255
|
+
const { window: P = Ee, ignore: q = [], capture: V = !0, detectIframe: W = !1, controls: A = !1 } = d;
|
|
1256
|
+
if (!P)
|
|
1257
|
+
return A ? { stop: fe, cancel: fe, trigger: fe } : fe;
|
|
1233
1258
|
if (Re && !ke) {
|
|
1234
1259
|
ke = !0;
|
|
1235
1260
|
const f = { passive: !0 };
|
|
1236
|
-
Array.from(
|
|
1261
|
+
Array.from(P.document.body.children).forEach((g) => g.addEventListener("click", fe, f)), P.document.documentElement.addEventListener("click", fe, f);
|
|
1237
1262
|
}
|
|
1238
|
-
let
|
|
1239
|
-
const
|
|
1240
|
-
if (typeof
|
|
1241
|
-
return Array.from(
|
|
1263
|
+
let D = !0;
|
|
1264
|
+
const h = (f) => ue(q).some((g) => {
|
|
1265
|
+
if (typeof g == "string")
|
|
1266
|
+
return Array.from(P.document.querySelectorAll(g)).some((U) => U === f.target || f.composedPath().includes(U));
|
|
1242
1267
|
{
|
|
1243
|
-
const
|
|
1244
|
-
return
|
|
1268
|
+
const U = ve(g);
|
|
1269
|
+
return U && (f.target === U || f.composedPath().includes(U));
|
|
1245
1270
|
}
|
|
1246
1271
|
});
|
|
1247
|
-
function
|
|
1248
|
-
const
|
|
1249
|
-
return
|
|
1272
|
+
function k(f) {
|
|
1273
|
+
const g = ue(f);
|
|
1274
|
+
return g && g.$.subTree.shapeFlag === 16;
|
|
1250
1275
|
}
|
|
1251
|
-
function
|
|
1252
|
-
const
|
|
1253
|
-
return
|
|
1276
|
+
function T(f, g) {
|
|
1277
|
+
const U = ue(f), a = U.$.subTree && U.$.subTree.children;
|
|
1278
|
+
return a == null || !Array.isArray(a) ? !1 : a.some((m) => m.el === g.target || g.composedPath().includes(m.el));
|
|
1254
1279
|
}
|
|
1255
|
-
const
|
|
1256
|
-
const
|
|
1257
|
-
if (f.target != null && !(!(
|
|
1258
|
-
if ("detail" in f && f.detail === 0 && (
|
|
1259
|
-
|
|
1280
|
+
const E = (f) => {
|
|
1281
|
+
const g = ve(e);
|
|
1282
|
+
if (f.target != null && !(!(g instanceof Element) && k(e) && T(e, f)) && !(!g || g === f.target || f.composedPath().includes(g))) {
|
|
1283
|
+
if ("detail" in f && f.detail === 0 && (D = !h(f)), !D) {
|
|
1284
|
+
D = !0;
|
|
1260
1285
|
return;
|
|
1261
1286
|
}
|
|
1262
1287
|
n(f);
|
|
1263
1288
|
}
|
|
1264
1289
|
};
|
|
1265
1290
|
let S = !1;
|
|
1266
|
-
const
|
|
1267
|
-
we(
|
|
1291
|
+
const C = [
|
|
1292
|
+
we(P, "click", (f) => {
|
|
1268
1293
|
S || (S = !0, setTimeout(() => {
|
|
1269
1294
|
S = !1;
|
|
1270
|
-
}, 0),
|
|
1271
|
-
}, { passive: !0, capture:
|
|
1272
|
-
we(
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1295
|
+
}, 0), E(f));
|
|
1296
|
+
}, { passive: !0, capture: V }),
|
|
1297
|
+
we(P, "pointerdown", (f) => {
|
|
1298
|
+
const g = ve(e);
|
|
1299
|
+
D = !h(f) && !!(g && !f.composedPath().includes(g));
|
|
1275
1300
|
}, { passive: !0 }),
|
|
1276
|
-
|
|
1301
|
+
W && we(P, "blur", (f) => {
|
|
1277
1302
|
setTimeout(() => {
|
|
1278
|
-
var
|
|
1279
|
-
const
|
|
1280
|
-
((
|
|
1303
|
+
var g;
|
|
1304
|
+
const U = ve(e);
|
|
1305
|
+
((g = P.document.activeElement) == null ? void 0 : g.tagName) === "IFRAME" && !U?.contains(P.document.activeElement) && n(f);
|
|
1281
1306
|
}, 0);
|
|
1282
1307
|
}, { passive: !0 })
|
|
1283
|
-
].filter(Boolean),
|
|
1284
|
-
return
|
|
1285
|
-
stop:
|
|
1308
|
+
].filter(Boolean), R = () => C.forEach((f) => f());
|
|
1309
|
+
return A ? {
|
|
1310
|
+
stop: R,
|
|
1286
1311
|
cancel: () => {
|
|
1287
|
-
|
|
1312
|
+
D = !1;
|
|
1288
1313
|
},
|
|
1289
1314
|
trigger: (f) => {
|
|
1290
|
-
|
|
1315
|
+
D = !0, E(f), D = !1;
|
|
1291
1316
|
}
|
|
1292
|
-
} :
|
|
1317
|
+
} : R;
|
|
1293
1318
|
}
|
|
1294
1319
|
function We(e) {
|
|
1295
1320
|
const n = Ie(null), d = [
|
|
@@ -1297,70 +1322,70 @@ function We(e) {
|
|
|
1297
1322
|
".k-popup",
|
|
1298
1323
|
".k-timepicker-popup",
|
|
1299
1324
|
".k-menu-popup"
|
|
1300
|
-
],
|
|
1325
|
+
], P = Array.isArray(e.popupSelector) ? e.popupSelector : [e.popupSelector ?? d].flat(), q = (k) => k ? typeof e.initialFocus == "string" ? k.querySelector(e.initialFocus) ?? k : typeof e.initialFocus == "function" ? e.initialFocus(k) ?? k : k.querySelector(
|
|
1301
1326
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
1302
|
-
) ??
|
|
1327
|
+
) ?? k : null, { activate: V, deactivate: W } = Te(n, {
|
|
1303
1328
|
escapeDeactivates: !1,
|
|
1304
1329
|
clickOutsideDeactivates: !1,
|
|
1305
1330
|
fallbackFocus: () => n.value,
|
|
1306
|
-
initialFocus: () =>
|
|
1331
|
+
initialFocus: () => q(n.value),
|
|
1307
1332
|
...e.focusTrapOptions ?? {}
|
|
1308
1333
|
});
|
|
1309
|
-
let
|
|
1310
|
-
const
|
|
1334
|
+
let A = null, D = j(null);
|
|
1335
|
+
const h = () => {
|
|
1311
1336
|
if (e.resolvePopupEl) return e.resolvePopupEl();
|
|
1312
|
-
const
|
|
1313
|
-
const
|
|
1314
|
-
if (!
|
|
1315
|
-
const
|
|
1337
|
+
const k = (E, S) => {
|
|
1338
|
+
const C = Array.from(E.querySelectorAll(S));
|
|
1339
|
+
if (!C.length) return null;
|
|
1340
|
+
const R = C.filter(
|
|
1316
1341
|
(f) => f.offsetParent !== null || f.getClientRects().length > 0
|
|
1317
1342
|
);
|
|
1318
|
-
return
|
|
1319
|
-
},
|
|
1320
|
-
for (const
|
|
1321
|
-
const S =
|
|
1343
|
+
return R[R.length - 1] ?? C[C.length - 1] ?? null;
|
|
1344
|
+
}, T = e.triggerEl?.value?.closest?.(".k-animation-container") ?? document.body;
|
|
1345
|
+
for (const E of P) {
|
|
1346
|
+
const S = k(T, E);
|
|
1322
1347
|
if (S) return S;
|
|
1323
1348
|
}
|
|
1324
|
-
for (const
|
|
1325
|
-
const S =
|
|
1349
|
+
for (const E of P) {
|
|
1350
|
+
const S = k(document, E);
|
|
1326
1351
|
if (S) return S;
|
|
1327
1352
|
}
|
|
1328
1353
|
return null;
|
|
1329
1354
|
};
|
|
1330
|
-
return Oe(n, (
|
|
1331
|
-
|
|
1355
|
+
return Oe(n, (k) => {
|
|
1356
|
+
D.value = "outside", e.isOpen.value && e.onRequestClose?.("outside", k);
|
|
1332
1357
|
}), ie(
|
|
1333
1358
|
() => e.isOpen.value,
|
|
1334
|
-
(
|
|
1335
|
-
|
|
1336
|
-
const
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
}, document.addEventListener("keydown",
|
|
1340
|
-
})) : (
|
|
1341
|
-
const
|
|
1342
|
-
const
|
|
1343
|
-
|
|
1359
|
+
(k) => {
|
|
1360
|
+
k ? (D.value = null, H(() => {
|
|
1361
|
+
const T = h();
|
|
1362
|
+
T && (n.value = T, setTimeout(() => V(), 0), A || (A = (E) => {
|
|
1363
|
+
E.key === "Escape" && (D.value = "escape", e.isOpen.value && e.onRequestClose?.("escape", E));
|
|
1364
|
+
}, document.addEventListener("keydown", A, !0)));
|
|
1365
|
+
})) : (W(), A && (document.removeEventListener("keydown", A, !0), A = null), n.value = null, D.value === "outside" && H(() => {
|
|
1366
|
+
const T = () => {
|
|
1367
|
+
const E = e.triggerEl?.value, S = E?.querySelector("input"), C = document.activeElement;
|
|
1368
|
+
C && (C === S || E && E.contains(C)) && (S ?? E)?.blur?.();
|
|
1344
1369
|
};
|
|
1345
|
-
requestAnimationFrame(() => setTimeout(
|
|
1346
|
-
}), e.returnFocusToTrigger !== !1 &&
|
|
1370
|
+
requestAnimationFrame(() => setTimeout(T, 0));
|
|
1371
|
+
}), e.returnFocusToTrigger !== !1 && D.value === "escape" && e.triggerEl?.value && (console.log(
|
|
1347
1372
|
"Returning focus to trigger element:",
|
|
1348
1373
|
e.triggerEl.value
|
|
1349
|
-
),
|
|
1350
|
-
const
|
|
1351
|
-
const
|
|
1352
|
-
if (!
|
|
1353
|
-
(
|
|
1374
|
+
), H(() => {
|
|
1375
|
+
const T = () => {
|
|
1376
|
+
const E = e.triggerEl?.value;
|
|
1377
|
+
if (!E) return;
|
|
1378
|
+
(E.querySelector("input") ?? E)?.focus?.();
|
|
1354
1379
|
};
|
|
1355
|
-
requestAnimationFrame(() => setTimeout(
|
|
1380
|
+
requestAnimationFrame(() => setTimeout(T, 0));
|
|
1356
1381
|
})));
|
|
1357
1382
|
}
|
|
1358
1383
|
), {
|
|
1359
1384
|
popupRef: n,
|
|
1360
|
-
activate:
|
|
1361
|
-
deactivate:
|
|
1362
|
-
lastCloseReason:
|
|
1363
|
-
setPopupEl: (
|
|
1385
|
+
activate: V,
|
|
1386
|
+
deactivate: W,
|
|
1387
|
+
lastCloseReason: B(D),
|
|
1388
|
+
setPopupEl: (k) => n.value = k
|
|
1364
1389
|
};
|
|
1365
1390
|
}
|
|
1366
1391
|
export {
|