@featherk/composables 0.5.6 → 0.6.0

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