@gspa/ui 0.1.4 → 0.3.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.
Files changed (124) hide show
  1. package/README.md +34 -1
  2. package/dist/Button.vue_vue_type_script_setup_true_lang-B3TkBTvG.js +205 -0
  3. package/dist/Button.vue_vue_type_script_setup_true_lang-DZxttvYH.cjs +1 -0
  4. package/dist/DataTable.css +1 -0
  5. package/dist/DataTableToolBar.css +1 -0
  6. package/dist/DatePicker.vue_vue_type_script_setup_true_lang-CIKiZaO1.cjs +1 -0
  7. package/dist/DatePicker.vue_vue_type_script_setup_true_lang-Dx_9f8DO.js +557 -0
  8. package/dist/FormField.vue_vue_type_script_setup_true_lang-BljDj5YZ.js +205 -0
  9. package/dist/FormField.vue_vue_type_script_setup_true_lang-FWitIR3U.cjs +1 -0
  10. package/dist/Header.css +1 -0
  11. package/dist/Input.vue_vue_type_script_setup_true_lang-C1OQn24h.cjs +1 -0
  12. package/dist/Input.vue_vue_type_script_setup_true_lang-CpBoY97r.js +137 -0
  13. package/dist/Loader.css +1 -0
  14. package/dist/ReminderConfig.css +1 -0
  15. package/dist/ReusableForm.css +1 -0
  16. package/dist/Sidebar.css +1 -0
  17. package/dist/Toast.css +1 -0
  18. package/dist/components/AccordionItem.cjs +1 -1
  19. package/dist/components/AccordionItem.js +5 -5
  20. package/dist/components/Alert.cjs +1 -1
  21. package/dist/components/Alert.js +71 -66
  22. package/dist/components/Button.cjs +1 -1
  23. package/dist/components/Button.js +2 -188
  24. package/dist/components/DataTable.cjs +1 -1
  25. package/dist/components/DataTable.js +1 -1
  26. package/dist/components/DataTableFilters.cjs +1 -1
  27. package/dist/components/DataTableFilters.js +19 -19
  28. package/dist/components/DataTableToolBar.cjs +1 -1
  29. package/dist/components/DataTableToolBar.js +1 -1
  30. package/dist/components/DatePicker.cjs +1 -1
  31. package/dist/components/DatePicker.js +2 -399
  32. package/dist/components/FormField.cjs +1 -1
  33. package/dist/components/FormField.js +2 -188
  34. package/dist/components/GraphFilters.cjs +1 -1
  35. package/dist/components/GraphFilters.js +29 -29
  36. package/dist/components/Icon.cjs +1 -1
  37. package/dist/components/Icon.js +23 -16
  38. package/dist/components/Input.cjs +1 -1
  39. package/dist/components/Input.js +2 -164
  40. package/dist/components/ReusableForm.cjs +1 -1
  41. package/dist/components/ReusableForm.js +188 -159
  42. package/dist/components/ThemeConfigurator.cjs +1 -1
  43. package/dist/components/ThemeConfigurator.js +51 -28
  44. package/dist/gspa-ui.css +1 -1
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.esm.js +124 -118
  47. package/dist/layouts/AuthLayout.cjs +1 -1
  48. package/dist/layouts/AuthLayout.js +110 -112
  49. package/dist/lib/form-field.cjs +1 -0
  50. package/dist/lib/form-field.js +4 -0
  51. package/dist/lib/icon.cjs +1 -0
  52. package/dist/lib/icon.js +4 -0
  53. package/dist/lib/theme.cjs +1 -1
  54. package/dist/lib/theme.js +73 -63
  55. package/dist/src/components/Alert.vue.d.ts.map +1 -1
  56. package/dist/src/components/Button.vue.d.ts +127 -29
  57. package/dist/src/components/Button.vue.d.ts.map +1 -1
  58. package/dist/src/components/Calendar.vue.d.ts +4 -4
  59. package/dist/src/components/Checkbox.vue.d.ts +2 -2
  60. package/dist/src/components/DataTable.vue.d.ts +1 -1
  61. package/dist/src/components/DatePicker.vue.d.ts +139 -29
  62. package/dist/src/components/DatePicker.vue.d.ts.map +1 -1
  63. package/dist/src/components/FormField.vue.d.ts +106 -38
  64. package/dist/src/components/FormField.vue.d.ts.map +1 -1
  65. package/dist/src/components/Icon.vue.d.ts.map +1 -1
  66. package/dist/src/components/Input.vue.d.ts +137 -33
  67. package/dist/src/components/Input.vue.d.ts.map +1 -1
  68. package/dist/src/components/ReusableForm.vue.d.ts +1 -1
  69. package/dist/src/components/ReusableForm.vue.d.ts.map +1 -1
  70. package/dist/src/components/ReusableFormModal.vue.d.ts +1 -1
  71. package/dist/src/components/Textarea.vue.d.ts +2 -2
  72. package/dist/src/index.d.ts +9 -4
  73. package/dist/src/index.d.ts.map +1 -1
  74. package/dist/src/layouts/AuthLayout.vue.d.ts +2 -0
  75. package/dist/src/layouts/AuthLayout.vue.d.ts.map +1 -1
  76. package/dist/src/lib/form-field.d.ts +2 -0
  77. package/dist/src/lib/form-field.d.ts.map +1 -0
  78. package/dist/src/lib/icon.d.ts +2 -0
  79. package/dist/src/lib/icon.d.ts.map +1 -0
  80. package/dist/src/lib/theme.d.ts +4 -0
  81. package/dist/src/lib/theme.d.ts.map +1 -1
  82. package/dist/src/types.d.ts +47 -0
  83. package/dist/src/types.d.ts.map +1 -0
  84. package/dist/styles/auth-layout.css +1 -0
  85. package/dist/styles/button.css +1 -0
  86. package/dist/styles/form-field.css +1 -0
  87. package/dist/styles/input.css +1 -0
  88. package/dist/styles/tokens.css +1 -0
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +10 -3
  91. package/dist/src/__tests__/Alert.spec.d.ts +0 -2
  92. package/dist/src/__tests__/Alert.spec.d.ts.map +0 -1
  93. package/dist/src/__tests__/App.spec.d.ts +0 -2
  94. package/dist/src/__tests__/App.spec.d.ts.map +0 -1
  95. package/dist/src/__tests__/AuthLayout.spec.d.ts +0 -2
  96. package/dist/src/__tests__/AuthLayout.spec.d.ts.map +0 -1
  97. package/dist/src/__tests__/Badge.spec.d.ts +0 -2
  98. package/dist/src/__tests__/Badge.spec.d.ts.map +0 -1
  99. package/dist/src/__tests__/Button.spec.d.ts +0 -2
  100. package/dist/src/__tests__/Button.spec.d.ts.map +0 -1
  101. package/dist/src/__tests__/Card.spec.d.ts +0 -2
  102. package/dist/src/__tests__/Card.spec.d.ts.map +0 -1
  103. package/dist/src/__tests__/Checkbox.spec.d.ts +0 -2
  104. package/dist/src/__tests__/Checkbox.spec.d.ts.map +0 -1
  105. package/dist/src/__tests__/Dropdown.spec.d.ts +0 -2
  106. package/dist/src/__tests__/Dropdown.spec.d.ts.map +0 -1
  107. package/dist/src/__tests__/Input.spec.d.ts +0 -2
  108. package/dist/src/__tests__/Input.spec.d.ts.map +0 -1
  109. package/dist/src/__tests__/Modal.spec.d.ts +0 -2
  110. package/dist/src/__tests__/Modal.spec.d.ts.map +0 -1
  111. package/dist/src/__tests__/Radio.spec.d.ts +0 -2
  112. package/dist/src/__tests__/Radio.spec.d.ts.map +0 -1
  113. package/dist/src/__tests__/ReusableForm.spec.d.ts +0 -2
  114. package/dist/src/__tests__/ReusableForm.spec.d.ts.map +0 -1
  115. package/dist/src/__tests__/Tabs.spec.d.ts +0 -2
  116. package/dist/src/__tests__/Tabs.spec.d.ts.map +0 -1
  117. package/dist/src/__tests__/integration/CardIntegration.spec.d.ts +0 -2
  118. package/dist/src/__tests__/integration/CardIntegration.spec.d.ts.map +0 -1
  119. package/dist/src/__tests__/integration/FormIntegration.spec.d.ts +0 -2
  120. package/dist/src/__tests__/integration/FormIntegration.spec.d.ts.map +0 -1
  121. package/dist/src/__tests__/integration/ModalIntegration.spec.d.ts +0 -2
  122. package/dist/src/__tests__/integration/ModalIntegration.spec.d.ts.map +0 -1
  123. package/dist/src/__tests__/integration/NavigationIntegration.spec.d.ts +0 -2
  124. package/dist/src/__tests__/integration/NavigationIntegration.spec.d.ts.map +0 -1
@@ -0,0 +1,557 @@
1
+ import { defineComponent as et, ref as h, computed as g, watch as se, onMounted as tt, onBeforeUnmount as at, createElementBlock as f, openBlock as d, createElementVNode as o, createBlock as rt, createCommentVNode as Z, normalizeClass as V, withModifiers as Ae, Teleport as lt, createVNode as nt, Transition as it, withCtx as ut, normalizeStyle as ot, toDisplayString as F, Fragment as C, renderList as A, unref as de, nextTick as R } from "vue";
2
+ const st = { class: "relative w-full rounded-md bg-(--ui-surface)" }, dt = { class: "relative" }, ct = ["id", "value", "disabled", "placeholder", "required", "aria-describedby", "aria-expanded"], ft = { class: "min-w-0" }, vt = { class: "mb-3 flex items-center justify-between gap-2" }, gt = ["disabled", "aria-disabled", "aria-label"], mt = ["aria-label"], bt = ["disabled", "aria-disabled", "aria-label"], pt = {
3
+ class: "mb-1 grid grid-cols-7 gap-1",
4
+ "aria-hidden": "true"
5
+ }, yt = ["aria-label"], ht = ["data-day", "data-focus-preferred", "disabled", "aria-disabled", "aria-selected", "aria-label", "onClick", "onKeydown"], xt = ["aria-label"], wt = ["data-focus-preferred", "disabled", "aria-disabled", "aria-selected", "aria-label", "onClick"], Dt = ["aria-label"], kt = ["data-focus-preferred", "disabled", "aria-disabled", "aria-selected", "aria-label", "onClick"], Mt = {
6
+ key: 3,
7
+ class: "mt-3 border-t pt-2 ui-border"
8
+ }, St = ["disabled", "aria-disabled"], Nt = {
9
+ key: 0,
10
+ class: "border-t pt-3 ui-border sm:border-l sm:border-t-0 sm:pl-3 sm:pt-0"
11
+ }, Yt = { class: "max-h-64 space-y-1 overflow-y-auto pr-1" }, Tt = ["aria-selected", "onClick"], M = 12, Ft = /* @__PURE__ */ et({
12
+ __name: "DatePicker",
13
+ props: {
14
+ id: String,
15
+ modelValue: { type: [String, Date], default: "" },
16
+ disabled: { type: Boolean, default: !1 },
17
+ required: { type: Boolean, default: !1 },
18
+ min: [String, Date],
19
+ max: [String, Date],
20
+ minDate: [String, Date],
21
+ maxDate: [String, Date],
22
+ yearRange: Array,
23
+ initialView: {
24
+ type: String,
25
+ default: "day",
26
+ validator: (m) => ["day", "month", "year"].includes(m)
27
+ },
28
+ placeholder: { type: String, default: "Select date" },
29
+ format: { type: String, default: "DD/MM/YYYY" },
30
+ clearable: { type: Boolean, default: !0 },
31
+ showToday: { type: Boolean, default: !0 },
32
+ calendarPosition: { type: String, default: "left-0 bottom-full" },
33
+ ariaDescribedby: String,
34
+ customValidation: { type: Function, default: null },
35
+ disabledDates: { type: [Array, Function], default: null },
36
+ enableTime: { type: Boolean, default: !1 },
37
+ minuteInterval: { type: Number, default: 1 }
38
+ },
39
+ emits: ["update:modelValue", "validation-error"],
40
+ setup(m, { emit: Ie }) {
41
+ const i = m, I = Ie, x = h(!1), s = h("day"), P = h(null), J = h(null), ce = h({}), b = O(/* @__PURE__ */ new Date()), v = h(b.getMonth()), l = h(b.getFullYear()), z = h(b.getDate()), w = h(Math.floor(b.getFullYear() / M) * M), u = h(null), H = h(!1), Y = h("00:00"), Ee = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], fe = Array.from(
42
+ { length: 12 },
43
+ (e, t) => new Date(2e3, t, 1).toLocaleString("default", { month: "long" })
44
+ ), S = g(() => U(i.minDate ?? i.min)), N = g(() => U(i.maxDate ?? i.max)), p = g(() => {
45
+ if (!i.yearRange || i.yearRange.length !== 2) return null;
46
+ const e = Math.trunc(Number(i.yearRange[0])), t = Math.trunc(Number(i.yearRange[1]));
47
+ return !Number.isFinite(e) || !Number.isFinite(t) ? null : e <= t ? [e, t] : [t, e];
48
+ }), E = g(() => Math.max(
49
+ p.value?.[0] ?? Number.NEGATIVE_INFINITY,
50
+ S.value?.getFullYear() ?? Number.NEGATIVE_INFINITY
51
+ )), L = g(() => Math.min(
52
+ p.value?.[1] ?? Number.POSITIVE_INFINITY,
53
+ N.value?.getFullYear() ?? Number.POSITIVE_INFINITY
54
+ )), Q = g(() => fe[v.value]), ve = g(() => _(l.value, v.value)), ge = g(() => c(l.value, v.value, 1).getDay()), me = g(() => {
55
+ const e = _(l.value, v.value - 1);
56
+ return Array.from(
57
+ { length: ge.value },
58
+ (t, a) => e - ge.value + a + 1
59
+ );
60
+ }), _e = g(() => {
61
+ const e = me.value.length + ve.value, t = e % 7 === 0 ? 0 : 7 - e % 7;
62
+ return Array.from({ length: t }, (a, r) => r + 1);
63
+ }), be = g(
64
+ () => Array.from({ length: M }, (e, t) => w.value + t).filter((e) => e >= E.value && e <= L.value)
65
+ ), pe = g(() => w.value + M - 1), K = g(() => {
66
+ if (s.value === "day") return `${Q.value} ${l.value}`;
67
+ if (s.value === "month") return String(l.value);
68
+ const e = be.value;
69
+ return e.length ? `${e[0]}–${e[e.length - 1]}` : `${w.value}–${pe.value}`;
70
+ }), Be = g(() => s.value === "day" ? `Select the month. Currently ${K.value}` : s.value === "month" ? `Select the year. Currently ${l.value}` : `Return to day selection. Showing years ${K.value}`), Re = g(() => s.value === "day" ? "Previous month" : s.value === "month" ? "Previous year" : "Previous year range"), Pe = g(() => s.value === "day" ? "Next month" : s.value === "month" ? "Next year" : "Next year range"), X = g(() => s.value === "day" ? re(l.value, v.value - 1) : s.value === "month" ? l.value - 1 >= E.value : w.value > E.value), ee = g(() => s.value === "day" ? re(l.value, v.value + 1) : s.value === "month" ? l.value + 1 <= L.value : pe.value < L.value), ye = g(() => u.value ? i.enableTime ? Le(u.value) : he(u.value) : ""), He = g(() => {
71
+ const e = Math.min(60, Math.max(1, Number(i.minuteInterval) || 1)), t = [];
72
+ for (let a = 0; a < 24; a++)
73
+ for (let r = 0; r < 60; r += e)
74
+ t.push(`${String(a).padStart(2, "0")}:${String(r).padStart(2, "0")}`);
75
+ return t;
76
+ });
77
+ function c(e, t, a, r = 0, n = 0) {
78
+ const D = /* @__PURE__ */ new Date(0);
79
+ return D.setFullYear(e, t, a), D.setHours(r, n, 0, 0), D;
80
+ }
81
+ function O(e) {
82
+ return c(e.getFullYear(), e.getMonth(), e.getDate());
83
+ }
84
+ function _(e, t) {
85
+ return c(e, t + 1, 0).getDate();
86
+ }
87
+ function U(e) {
88
+ if (!e) return null;
89
+ if (e instanceof Date)
90
+ return Number.isNaN(e.getTime()) ? null : c(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes());
91
+ const t = e.match(/^(\d{4,})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?/);
92
+ if (t) {
93
+ const [, r, n, D, k = "0", B = "0"] = t, Fe = Number(r), Ce = Number(n) - 1, Ve = Number(D), G = c(Fe, Ce, Ve, Number(k), Number(B));
94
+ return G.getFullYear() === Fe && G.getMonth() === Ce && G.getDate() === Ve ? G : null;
95
+ }
96
+ const a = new Date(e);
97
+ return Number.isNaN(a.getTime()) ? null : a;
98
+ }
99
+ function y(e) {
100
+ return c(e.getFullYear(), e.getMonth(), e.getDate()).getTime();
101
+ }
102
+ function he(e) {
103
+ const t = String(e.getMonth() + 1).padStart(2, "0"), a = String(e.getDate()).padStart(2, "0");
104
+ return i.format.replace("MM", t).replace("DD", a).replace("YYYY", String(e.getFullYear()));
105
+ }
106
+ function Le(e) {
107
+ const t = String(e.getHours()).padStart(2, "0"), a = String(e.getMinutes()).padStart(2, "0");
108
+ return `${he(e)} ${t}:${a}`;
109
+ }
110
+ function ze(e) {
111
+ const t = String(e.getFullYear()).padStart(4, "0"), a = String(e.getMonth() + 1).padStart(2, "0"), r = String(e.getDate()).padStart(2, "0");
112
+ return `${t}-${a}-${r}`;
113
+ }
114
+ function te(e) {
115
+ const t = y(e);
116
+ return !(S.value && t < y(S.value) || N.value && t > y(N.value) || p.value && (e.getFullYear() < p.value[0] || e.getFullYear() > p.value[1]));
117
+ }
118
+ function T(e) {
119
+ return !te(e) || i.disabledDates && (typeof i.disabledDates == "function" && i.disabledDates(new Date(e)) || Array.isArray(i.disabledDates) && i.disabledDates.some((t) => {
120
+ const a = U(t);
121
+ return a ? y(a) === y(e) : !1;
122
+ })) ? !0 : !!i.customValidation?.(new Date(e));
123
+ }
124
+ function ae(e) {
125
+ return T(c(l.value, v.value, e));
126
+ }
127
+ function j(e) {
128
+ for (let t = 1; t <= _(l.value, e); t++)
129
+ if (!T(c(l.value, e, t))) return !1;
130
+ return !0;
131
+ }
132
+ function q(e) {
133
+ if (e < E.value || e > L.value) return !0;
134
+ for (let t = 0; t < 12; t++)
135
+ for (let a = 1; a <= _(e, t); a++)
136
+ if (!T(c(e, t, a))) return !1;
137
+ return !0;
138
+ }
139
+ function re(e, t) {
140
+ const a = c(e, t, 1), r = c(a.getFullYear(), a.getMonth() + 1, 0);
141
+ return !(a.getFullYear() < E.value || a.getFullYear() > L.value || S.value && y(r) < y(S.value) || N.value && y(a) > y(N.value));
142
+ }
143
+ function le(e) {
144
+ const t = p.value?.[0];
145
+ return t !== void 0 ? t + Math.floor((e - t) / M) * M : Math.floor(e / M) * M;
146
+ }
147
+ function xe(e) {
148
+ let t = O(e);
149
+ return p.value && t.getFullYear() < p.value[0] && (t = c(p.value[0], 0, 1)), p.value && t.getFullYear() > p.value[1] && (t = c(p.value[1], 11, 31)), S.value && y(t) < y(S.value) && (t = O(S.value)), N.value && y(t) > y(N.value) && (t = O(N.value)), t;
150
+ }
151
+ function Ke(e) {
152
+ return b.getDate() === e && b.getMonth() === v.value && b.getFullYear() === l.value;
153
+ }
154
+ function ne(e) {
155
+ return !!(u.value && u.value.getDate() === e && u.value.getMonth() === v.value && u.value.getFullYear() === l.value);
156
+ }
157
+ function we(e) {
158
+ if (!e)
159
+ return H.value = !1, I("validation-error", null), !0;
160
+ const t = i.customValidation?.(new Date(e)) || null;
161
+ return H.value = !!t, I("validation-error", t), !t;
162
+ }
163
+ async function ie() {
164
+ await R();
165
+ const e = J.value || (i.id ? document.getElementById(i.id) : null);
166
+ if (!e || !P.value) return;
167
+ const t = e.getBoundingClientRect(), a = P.value.offsetHeight || 360, r = P.value.offsetWidth || (i.enableTime ? 448 : 320), n = window.innerHeight - t.bottom, D = n >= a || n > t.top ? t.bottom + 8 : Math.max(8, t.top - a - 8), k = Math.min(Math.max(16, t.left), Math.max(16, window.innerWidth - r - 16));
168
+ ce.value = { top: `${D}px`, left: `${k}px` };
169
+ }
170
+ function $(e) {
171
+ z.value = e.getDate(), v.value = e.getMonth(), l.value = e.getFullYear(), w.value = le(e.getFullYear());
172
+ }
173
+ async function De() {
174
+ i.disabled || x.value || ((!u.value || !te(u.value)) && $(xe(b)), s.value = i.initialView, w.value = le(l.value), x.value = !0, await ie(), await Se());
175
+ }
176
+ function Oe() {
177
+ x.value ? W() : De();
178
+ }
179
+ function W(e = !1) {
180
+ x.value = !1, e && R(() => J.value?.focus());
181
+ }
182
+ async function ue(e) {
183
+ s.value = e, e === "year" && (w.value = le(l.value)), await R(), await ie(), await Se();
184
+ }
185
+ function Ue() {
186
+ ue({ day: "month", month: "year", year: "day" }[s.value]);
187
+ }
188
+ function je() {
189
+ X.value && (s.value === "day" ? $(c(l.value, v.value - 1, 1)) : s.value === "month" ? l.value-- : w.value = Math.max(w.value - M, E.value));
190
+ }
191
+ function qe() {
192
+ ee.value && (s.value === "day" ? $(c(l.value, v.value + 1, 1)) : s.value === "month" ? l.value++ : w.value += M);
193
+ }
194
+ function We(e) {
195
+ q(e) || (l.value = e, ue("month"));
196
+ }
197
+ function Ge(e) {
198
+ j(e) || (v.value = e, z.value = Math.min(z.value, _(l.value, e)), ue("day"));
199
+ }
200
+ function ke(e) {
201
+ const t = c(l.value, v.value, e);
202
+ if (T(t) || !we(t)) return;
203
+ const [a = "0", r = "0"] = Y.value.split(":");
204
+ t.setHours(Number(a), Number(r), 0, 0), u.value = t, Me(t), i.enableTime || window.setTimeout(() => W(), 150);
205
+ }
206
+ function Me(e) {
207
+ const t = ze(e);
208
+ i.enableTime ? I("update:modelValue", `${t}T${Y.value}`) : I("update:modelValue", t);
209
+ }
210
+ function Ze() {
211
+ T(b) || ($(b), ke(b.getDate()));
212
+ }
213
+ function Je() {
214
+ u.value = null, Y.value = "00:00", H.value = !1, I("update:modelValue", ""), I("validation-error", null);
215
+ }
216
+ function oe() {
217
+ return Array.from(P.value?.querySelectorAll("[data-picker-option]:not(:disabled)") || []);
218
+ }
219
+ async function Se() {
220
+ await R();
221
+ const e = oe(), t = e.find((r) => r.getAttribute("aria-selected") === "true"), a = e.find((r) => r.dataset.focusPreferred === "true");
222
+ (t || a || e[0])?.focus();
223
+ }
224
+ function Ne(e, t) {
225
+ const a = oe(), r = a.indexOf(e.currentTarget);
226
+ if (r < 0) return;
227
+ let n = r;
228
+ if (e.key === "ArrowRight") n = Math.min(a.length - 1, r + 1);
229
+ else if (e.key === "ArrowLeft") n = Math.max(0, r - 1);
230
+ else if (e.key === "ArrowDown") n = Math.min(a.length - 1, r + t);
231
+ else if (e.key === "ArrowUp") n = Math.max(0, r - t);
232
+ else if (e.key === "Home") n = r - r % t;
233
+ else if (e.key === "End") n = Math.min(a.length - 1, r + t - 1 - r % t);
234
+ else return;
235
+ e.preventDefault(), a[n]?.focus();
236
+ }
237
+ function Qe(e, t) {
238
+ if (e.key === "PageUp" || e.key === "PageDown") {
239
+ e.preventDefault();
240
+ const k = e.key === "PageUp" ? -1 : 1, B = c(l.value, v.value + k, Math.min(t, _(l.value, v.value + k)));
241
+ re(B.getFullYear(), B.getMonth()) && ($(B), R(() => Ye(B.getDate(), k)));
242
+ return;
243
+ }
244
+ if (!["ArrowRight", "ArrowLeft", "ArrowDown", "ArrowUp", "Home", "End"].includes(e.key)) return;
245
+ e.preventDefault();
246
+ let r = { ArrowRight: 1, ArrowLeft: -1, ArrowDown: 7, ArrowUp: -7 }[e.key];
247
+ e.key === "Home" && (r = -c(l.value, v.value, t).getDay()), e.key === "End" && (r = 6 - c(l.value, v.value, t).getDay());
248
+ let n = c(l.value, v.value, t + r);
249
+ const D = r < 0 ? -1 : 1;
250
+ for (let k = 0; k < 3660; k++) {
251
+ if (!te(n)) return;
252
+ if (!T(n)) {
253
+ $(n), R(() => Ye(n.getDate(), D));
254
+ return;
255
+ }
256
+ n = c(n.getFullYear(), n.getMonth(), n.getDate() + D);
257
+ }
258
+ }
259
+ function Ye(e, t) {
260
+ const a = oe();
261
+ (a.find((n) => Number(n.dataset.day) === e) || (t < 0 ? a.at(-1) : a[0]))?.focus();
262
+ }
263
+ function Xe(e) {
264
+ ["Enter", " ", "ArrowDown"].includes(e.key) ? (e.preventDefault(), De()) : e.key === "Escape" && x.value && (e.preventDefault(), W(!0));
265
+ }
266
+ function Te(e) {
267
+ e.key === "Escape" && x.value && (e.preventDefault(), W(!0));
268
+ }
269
+ function $e() {
270
+ x.value && ie();
271
+ }
272
+ return se(() => i.modelValue, (e) => {
273
+ const t = U(e);
274
+ if (!t) {
275
+ u.value = null, H.value = !1;
276
+ return;
277
+ }
278
+ u.value = t, Y.value = `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}`, $(t), we(t);
279
+ }, { immediate: !0 }), se([p, S, N], () => {
280
+ !u.value && !x.value && $(xe(b));
281
+ }), se(Y, (e) => {
282
+ if (!i.enableTime || !u.value) return;
283
+ const [t = "0", a = "0"] = e.split(":");
284
+ u.value.setHours(Number(t), Number(a), 0, 0), Me(u.value);
285
+ }), tt(() => {
286
+ document.addEventListener("keydown", Te), window.addEventListener("resize", $e);
287
+ }), at(() => {
288
+ document.removeEventListener("keydown", Te), window.removeEventListener("resize", $e);
289
+ }), (e, t) => (d(), f("div", st, [
290
+ o("div", dt, [
291
+ o("input", {
292
+ id: m.id,
293
+ ref_key: "inputRef",
294
+ ref: J,
295
+ type: "text",
296
+ value: ye.value,
297
+ readonly: "",
298
+ disabled: m.disabled,
299
+ placeholder: m.placeholder,
300
+ required: m.required,
301
+ "aria-describedby": m.ariaDescribedby,
302
+ "aria-haspopup": "dialog",
303
+ "aria-expanded": x.value,
304
+ class: V([
305
+ "w-full cursor-pointer rounded-md border px-3 py-2 pr-10 text-sm ui-surface ui-text placeholder:text-(--ui-text-muted) transition-colors",
306
+ "focus:border-(--ui-primary) focus:outline-none focus:ring-2 focus:ring-(--ui-ring)",
307
+ "disabled:cursor-not-allowed disabled:bg-(--ui-surface-muted) disabled:text-(--ui-text-muted)",
308
+ H.value ? "border-(--ui-danger) focus:border-(--ui-danger) focus:ring-(--ui-danger)" : "ui-border"
309
+ ]),
310
+ onClick: Oe,
311
+ onKeydown: Xe
312
+ }, null, 42, ct),
313
+ t[4] || (t[4] = o("div", { class: "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2" }, [
314
+ o("svg", {
315
+ class: "h-4 w-4 ui-text-muted",
316
+ fill: "none",
317
+ stroke: "currentColor",
318
+ viewBox: "0 0 24 24",
319
+ "aria-hidden": "true"
320
+ }, [
321
+ o("path", {
322
+ "stroke-linecap": "round",
323
+ "stroke-linejoin": "round",
324
+ "stroke-width": "2",
325
+ d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
326
+ })
327
+ ])
328
+ ], -1)),
329
+ m.clearable && ye.value && !m.disabled ? (d(), f("button", {
330
+ key: 0,
331
+ type: "button",
332
+ class: "absolute right-9 top-1/2 -translate-y-1/2 rounded p-1 ui-text-muted transition-colors hover:bg-(--ui-surface-muted) hover:text-(--ui-text) focus-visible:ring-2 focus-visible:ring-(--ui-ring)",
333
+ "aria-label": "Clear date",
334
+ onClick: Ae(Je, ["stop"])
335
+ }, [...t[3] || (t[3] = [
336
+ o("svg", {
337
+ class: "h-3.5 w-3.5",
338
+ fill: "none",
339
+ stroke: "currentColor",
340
+ viewBox: "0 0 24 24",
341
+ "aria-hidden": "true"
342
+ }, [
343
+ o("path", {
344
+ "stroke-linecap": "round",
345
+ "stroke-linejoin": "round",
346
+ "stroke-width": "2",
347
+ d: "M6 18L18 6M6 6l12 12"
348
+ })
349
+ ], -1)
350
+ ])])) : Z("", !0)
351
+ ]),
352
+ (d(), rt(lt, { to: "body" }, [
353
+ nt(it, {
354
+ "enter-active-class": "transition duration-100 ease-out",
355
+ "enter-from-class": "scale-95 opacity-0",
356
+ "enter-to-class": "scale-100 opacity-100",
357
+ "leave-active-class": "transition duration-75 ease-in",
358
+ "leave-from-class": "scale-100 opacity-100",
359
+ "leave-to-class": "scale-95 opacity-0"
360
+ }, {
361
+ default: ut(() => [
362
+ x.value ? (d(), f("div", {
363
+ key: 0,
364
+ ref_key: "calendarRef",
365
+ ref: P,
366
+ style: ot(ce.value),
367
+ role: "dialog",
368
+ "aria-label": "Choose date",
369
+ "aria-modal": "false",
370
+ class: V(["fixed z-10000 max-w-[calc(100vw-2rem)] rounded-lg border p-3 shadow-xl ui-surface ui-border-strong", m.enableTime ? "w-[28rem]" : "w-80"]),
371
+ onClick: t[2] || (t[2] = Ae(() => {
372
+ }, ["stop"]))
373
+ }, [
374
+ o("div", {
375
+ class: V(m.enableTime ? "grid grid-cols-1 gap-3 sm:grid-cols-[1fr_7.75rem]" : "block")
376
+ }, [
377
+ o("div", ft, [
378
+ o("div", vt, [
379
+ o("button", {
380
+ type: "button",
381
+ class: "rounded p-1.5 ui-text-muted transition-colors hover:bg-(--ui-surface-muted) hover:text-(--ui-text) focus-visible:ring-2 focus-visible:ring-(--ui-ring) disabled:cursor-not-allowed disabled:opacity-40",
382
+ disabled: !X.value,
383
+ "aria-disabled": !X.value,
384
+ "aria-label": Re.value,
385
+ onClick: je
386
+ }, [...t[5] || (t[5] = [
387
+ o("svg", {
388
+ class: "h-4 w-4",
389
+ fill: "none",
390
+ stroke: "currentColor",
391
+ viewBox: "0 0 24 24",
392
+ "aria-hidden": "true"
393
+ }, [
394
+ o("path", {
395
+ "stroke-linecap": "round",
396
+ "stroke-linejoin": "round",
397
+ "stroke-width": "2",
398
+ d: "M15 18l-6-6 6-6"
399
+ })
400
+ ], -1)
401
+ ])], 8, gt),
402
+ o("button", {
403
+ type: "button",
404
+ class: "min-w-0 flex-1 rounded px-2 py-1 text-sm font-semibold ui-text transition-colors hover:bg-(--ui-surface-muted) focus-visible:ring-2 focus-visible:ring-(--ui-ring)",
405
+ "aria-label": Be.value,
406
+ onClick: Ue
407
+ }, F(K.value), 9, mt),
408
+ o("button", {
409
+ type: "button",
410
+ class: "rounded p-1.5 ui-text-muted transition-colors hover:bg-(--ui-surface-muted) hover:text-(--ui-text) focus-visible:ring-2 focus-visible:ring-(--ui-ring) disabled:cursor-not-allowed disabled:opacity-40",
411
+ disabled: !ee.value,
412
+ "aria-disabled": !ee.value,
413
+ "aria-label": Pe.value,
414
+ onClick: qe
415
+ }, [...t[6] || (t[6] = [
416
+ o("svg", {
417
+ class: "h-4 w-4",
418
+ fill: "none",
419
+ stroke: "currentColor",
420
+ viewBox: "0 0 24 24",
421
+ "aria-hidden": "true"
422
+ }, [
423
+ o("path", {
424
+ "stroke-linecap": "round",
425
+ "stroke-linejoin": "round",
426
+ "stroke-width": "2",
427
+ d: "M9 18l6-6-6-6"
428
+ })
429
+ ], -1)
430
+ ])], 8, bt)
431
+ ]),
432
+ s.value === "day" ? (d(), f(C, { key: 0 }, [
433
+ o("div", pt, [
434
+ (d(), f(C, null, A(Ee, (a) => o("div", {
435
+ key: a,
436
+ class: "py-1 text-center text-xs font-medium ui-text-muted"
437
+ }, F(a), 1)), 64))
438
+ ]),
439
+ o("div", {
440
+ class: "grid grid-cols-7 gap-1",
441
+ role: "grid",
442
+ "aria-label": `${Q.value} ${l.value}`
443
+ }, [
444
+ (d(!0), f(C, null, A(me.value, (a, r) => (d(), f("div", {
445
+ key: `prev-${r}`,
446
+ class: "py-1.5 text-center text-xs ui-text-soft",
447
+ "aria-hidden": "true"
448
+ }, F(a), 1))), 128)),
449
+ (d(!0), f(C, null, A(ve.value, (a) => (d(), f("button", {
450
+ key: a,
451
+ type: "button",
452
+ role: "gridcell",
453
+ "data-picker-option": "",
454
+ "data-day": a,
455
+ "data-focus-preferred": a === z.value,
456
+ disabled: ae(a),
457
+ "aria-disabled": ae(a),
458
+ "aria-selected": ne(a),
459
+ "aria-label": `${Q.value} ${a}, ${l.value}`,
460
+ class: V([
461
+ "h-8 w-full min-w-0 rounded text-xs font-medium transition-colors focus-visible:ring-2 focus-visible:ring-(--ui-ring)",
462
+ Ke(a) && !ne(a) ? "ui-primary-soft ring-1 ring-(--ui-primary)" : "",
463
+ ne(a) ? "ui-primary-bg" : "ui-text hover:bg-(--ui-surface-muted)",
464
+ ae(a) ? "cursor-not-allowed text-(--ui-text-soft) opacity-45 line-through hover:bg-transparent" : "cursor-pointer"
465
+ ]),
466
+ onClick: (r) => ke(a),
467
+ onKeydown: (r) => Qe(r, a)
468
+ }, F(a), 43, ht))), 128)),
469
+ (d(!0), f(C, null, A(_e.value, (a, r) => (d(), f("div", {
470
+ key: `next-${r}`,
471
+ class: "py-1.5 text-center text-xs ui-text-soft",
472
+ "aria-hidden": "true"
473
+ }, F(a), 1))), 128))
474
+ ], 8, yt)
475
+ ], 64)) : s.value === "month" ? (d(), f("div", {
476
+ key: 1,
477
+ class: "grid grid-cols-3 gap-2",
478
+ role: "grid",
479
+ "aria-label": `Select a month in ${l.value}`
480
+ }, [
481
+ (d(!0), f(C, null, A(de(fe), (a, r) => (d(), f("button", {
482
+ key: a,
483
+ type: "button",
484
+ role: "gridcell",
485
+ "data-picker-option": "",
486
+ "data-focus-preferred": r === v.value,
487
+ disabled: j(r),
488
+ "aria-disabled": j(r),
489
+ "aria-selected": u.value?.getFullYear() === l.value && u.value?.getMonth() === r,
490
+ "aria-label": `Select ${a} ${l.value}`,
491
+ class: V([
492
+ "min-h-11 rounded px-2 py-2 text-sm transition-colors focus-visible:ring-2 focus-visible:ring-(--ui-ring)",
493
+ u.value?.getFullYear() === l.value && u.value?.getMonth() === r ? "ui-primary-bg" : "ui-text hover:bg-(--ui-surface-muted)",
494
+ j(r) ? "cursor-not-allowed text-(--ui-text-soft) opacity-45 hover:bg-transparent" : ""
495
+ ]),
496
+ onClick: (n) => Ge(r),
497
+ onKeydown: t[0] || (t[0] = (n) => Ne(n, 3))
498
+ }, F(a.slice(0, 3)), 43, wt))), 128))
499
+ ], 8, xt)) : (d(), f("div", {
500
+ key: 2,
501
+ class: "grid grid-cols-3 gap-2 sm:grid-cols-4",
502
+ role: "grid",
503
+ "aria-label": `Select a year from ${K.value}`
504
+ }, [
505
+ (d(!0), f(C, null, A(be.value, (a) => (d(), f("button", {
506
+ key: a,
507
+ type: "button",
508
+ role: "gridcell",
509
+ "data-picker-option": "",
510
+ "data-focus-preferred": a === l.value,
511
+ disabled: q(a),
512
+ "aria-disabled": q(a),
513
+ "aria-selected": u.value?.getFullYear() === a,
514
+ "aria-label": `Select year ${a}`,
515
+ class: V([
516
+ "min-h-11 rounded px-1 py-2 text-sm transition-colors focus-visible:ring-2 focus-visible:ring-(--ui-ring)",
517
+ u.value?.getFullYear() === a ? "ui-primary-bg" : "ui-text hover:bg-(--ui-surface-muted)",
518
+ q(a) ? "cursor-not-allowed text-(--ui-text-soft) opacity-45 hover:bg-transparent" : ""
519
+ ]),
520
+ onClick: (r) => We(a),
521
+ onKeydown: t[1] || (t[1] = (r) => Ne(r, 3))
522
+ }, F(a), 43, kt))), 128))
523
+ ], 8, Dt)),
524
+ m.showToday && s.value === "day" ? (d(), f("div", Mt, [
525
+ o("button", {
526
+ type: "button",
527
+ class: "w-full rounded px-3 py-1.5 text-xs font-medium ui-primary transition-colors hover:bg-(--ui-primary-soft) focus-visible:ring-2 focus-visible:ring-(--ui-ring) disabled:cursor-not-allowed disabled:opacity-40",
528
+ disabled: T(de(b)),
529
+ "aria-disabled": T(de(b)),
530
+ onClick: Ze
531
+ }, " Today ", 8, St)
532
+ ])) : Z("", !0)
533
+ ]),
534
+ m.enableTime ? (d(), f("div", Nt, [
535
+ t[7] || (t[7] = o("div", { class: "mb-2 text-xs font-semibold ui-text" }, " Time ", -1)),
536
+ o("div", Yt, [
537
+ (d(!0), f(C, null, A(He.value, (a) => (d(), f("button", {
538
+ key: a,
539
+ type: "button",
540
+ class: V(["w-full rounded px-2 py-1.5 text-left text-sm transition-colors focus-visible:ring-2 focus-visible:ring-(--ui-ring)", a === Y.value ? "ui-primary-bg" : "ui-text hover:bg-(--ui-surface-muted)"]),
541
+ "aria-selected": a === Y.value,
542
+ onClick: (r) => Y.value = a
543
+ }, F(a), 11, Tt))), 128))
544
+ ])
545
+ ])) : Z("", !0)
546
+ ], 2)
547
+ ], 6)) : Z("", !0)
548
+ ]),
549
+ _: 1
550
+ })
551
+ ]))
552
+ ]));
553
+ }
554
+ });
555
+ export {
556
+ Ft as _
557
+ };