@featherk/composables 0.5.6 → 0.5.7

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