docthub-core-components 3.0.0 → 3.2.1

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 (81) hide show
  1. package/dist/components/overrides/ui/auto-complete.js +466 -0
  2. package/dist/components/overrides/ui/autocomplete-checkbox.js +491 -0
  3. package/dist/components/overrides/ui/chips/doct-chip.js +157 -0
  4. package/dist/components/overrides/ui/circular-progress.js +32 -0
  5. package/dist/components/overrides/ui/composed/address-form-section.js +67 -0
  6. package/dist/components/overrides/ui/composed/contact-form-section.js +56 -0
  7. package/dist/components/overrides/ui/composed/search-filter-section.js +132 -0
  8. package/dist/components/overrides/ui/composed/user-registration-section.js +77 -0
  9. package/dist/components/overrides/ui/currencyInput/currency-input.js +69 -0
  10. package/dist/components/overrides/ui/doct-animation-loader.js +13 -0
  11. package/dist/components/overrides/ui/expandable-card.js +115 -0
  12. package/dist/components/overrides/ui/footer/doct-footer.js +35 -0
  13. package/dist/components/overrides/ui/footer/footer-desktop.js +92 -0
  14. package/dist/components/overrides/ui/footer/footer-mobile.js +123 -0
  15. package/dist/components/overrides/ui/footer/footer-routes.js +87 -0
  16. package/dist/components/overrides/ui/footer/footer-shared.js +137 -0
  17. package/dist/components/overrides/ui/footer/presets.js +269 -0
  18. package/dist/components/overrides/ui/inputs/labeled-input.js +92 -0
  19. package/dist/components/overrides/ui/inputs/otp-input.js +101 -0
  20. package/dist/components/overrides/ui/inputs/password-input.js +77 -0
  21. package/dist/components/overrides/ui/inputs/phone-input.js +336 -0
  22. package/dist/components/overrides/ui/navigation-menu/doct-navigation-menu.js +22 -0
  23. package/dist/components/overrides/ui/navigation-menu/individual-nav-routes.js +46 -0
  24. package/dist/components/overrides/ui/navigation-menu/individual-navigation-menu-desktop.js +109 -0
  25. package/dist/components/overrides/ui/navigation-menu/individual-navigation-menu-mobile.js +231 -0
  26. package/dist/components/overrides/ui/navigation-menu/individual-navigation-menu.js +44 -0
  27. package/dist/components/overrides/ui/navigation-menu/nav-env.js +64 -0
  28. package/dist/components/overrides/ui/navigation-menu/navigation-menu-adapter.js +55 -0
  29. package/dist/components/overrides/ui/navigation-menu/navigation-menu-internal.js +36 -0
  30. package/dist/components/overrides/ui/navigation-menu/organization-nav-routes.js +34 -0
  31. package/dist/components/overrides/ui/navigation-menu/organization-navigation-menu-desktop.js +109 -0
  32. package/dist/components/overrides/ui/navigation-menu/organization-navigation-menu-mobile.js +231 -0
  33. package/dist/components/overrides/ui/navigation-menu/organization-navigation-menu.js +44 -0
  34. package/dist/components/overrides/ui/navigation-menu/presets.js +238 -0
  35. package/dist/components/overrides/ui/navigation-menu/types.js +6 -0
  36. package/dist/components/overrides/ui/pickers/date-picker-field.js +361 -0
  37. package/dist/components/overrides/ui/pickers/date-range-picker-field.js +288 -0
  38. package/dist/components/overrides/ui/pickers/day-picker-bounds.js +38 -0
  39. package/dist/components/overrides/ui/pickers/select-field.js +158 -0
  40. package/dist/components/overrides/ui/search/auto-complete.js +64 -0
  41. package/dist/components/overrides/ui/search/search-input.js +65 -0
  42. package/dist/components/overrides/ui/showcase/component-section.js +45 -0
  43. package/dist/components/ui/alert.js +94 -0
  44. package/dist/components/ui/avatar.js +69 -0
  45. package/dist/components/ui/badge.js +37 -0
  46. package/dist/components/ui/breadcrumb.js +117 -0
  47. package/dist/components/ui/button.js +223 -0
  48. package/dist/components/ui/calendar.js +100 -0
  49. package/dist/components/ui/checkbox.js +57 -0
  50. package/dist/components/ui/collapsible.js +25 -0
  51. package/dist/components/ui/command.js +132 -0
  52. package/dist/components/ui/dialog.js +230 -0
  53. package/dist/components/ui/drawer.js +119 -0
  54. package/dist/components/ui/dropdown-menu.js +216 -0
  55. package/dist/components/ui/input.js +48 -0
  56. package/dist/components/ui/label.js +22 -0
  57. package/dist/components/ui/popover.js +181 -0
  58. package/dist/components/ui/progress.js +91 -0
  59. package/dist/components/ui/radio-group.js +49 -0
  60. package/dist/components/ui/select.js +169 -0
  61. package/dist/components/ui/skeleton.js +91 -0
  62. package/dist/components/ui/spinner.js +32 -0
  63. package/dist/components/ui/tabs.js +68 -0
  64. package/dist/components/ui/textarea.js +73 -0
  65. package/dist/components/ui/timeline.js +177 -0
  66. package/dist/components/ui/toast.js +82 -0
  67. package/dist/components/ui/tooltip.js +91 -0
  68. package/dist/components/ui/typography.js +213 -0
  69. package/dist/hooks/use-exclusive-dropdown.js +53 -0
  70. package/dist/hooks/use-mobile.js +19 -0
  71. package/dist/hooks/useAutocompleteCheckbox.js +204 -0
  72. package/dist/index.js +187 -0
  73. package/dist/lib/dropdown-manager.js +17 -0
  74. package/dist/lib/get-floating-dropdown-position.js +32 -0
  75. package/dist/lib/get-scroll-parents.js +20 -0
  76. package/dist/lib/slot.js +40 -0
  77. package/dist/lib/utils.js +9 -0
  78. package/dist/src/components/overrides/ui/autocomplete-checkbox.d.ts +16 -1
  79. package/dist/style.css +1 -1
  80. package/dist/util/getInputClasses.js +19 -0
  81. package/package.json +5 -5
@@ -0,0 +1,361 @@
1
+ "use client";
2
+ import { jsxs as C, jsx as l } from "react/jsx-runtime";
3
+ import { c as Pe } from "react-compiler-runtime";
4
+ import H from "dayjs";
5
+ import Ae from "dayjs/plugin/customParseFormat";
6
+ import Ce from "dayjs/plugin/localizedFormat";
7
+ import { X as Ie, CalendarDays as Ee, ChevronLeft as Ve, ChevronRight as je } from "lucide-react";
8
+ import * as o from "react";
9
+ import { DayPicker as Fe } from "react-day-picker";
10
+ import { Input as Le } from "../../../ui/input.js";
11
+ import { Label as Re } from "../../../ui/label.js";
12
+ import { Popover as Te, PopoverTrigger as Oe, PopoverContent as Be } from "../../../ui/popover.js";
13
+ import { SelectContent as me, Select as pe, SelectItem as Ye, SelectTrigger as ge, SelectValue as he } from "../../../ui/select.js";
14
+ import { cn as S } from "../../../../lib/utils.js";
15
+ import { mergeDisabledMatchers as Ke, minMaxDisabledMatchers as ze, calendarMonthAnchor as be, isDateWithinMinMaxLocalDay as Ue } from "./day-picker-bounds.js";
16
+ H.extend(Ae);
17
+ H.extend(Ce);
18
+ const oe = 100;
19
+ function de(g, D, e = /* @__PURE__ */ new Date()) {
20
+ const n = e.getFullYear();
21
+ let s = n - oe, a = n + oe;
22
+ return g && (s = Math.max(s, g.getFullYear())), D && (a = Math.min(a, D.getFullYear())), s > a && (s = n - oe, a = n + oe), {
23
+ minYear: s,
24
+ maxYear: a
25
+ };
26
+ }
27
+ function ye(g, D, e) {
28
+ const n = g.getFullYear(), {
29
+ minYear: s,
30
+ maxYear: a
31
+ } = de(D, e);
32
+ return n >= s && n <= a;
33
+ }
34
+ const We = o.memo(function(D) {
35
+ const e = Pe(57), {
36
+ month: n,
37
+ onMonthChange: s,
38
+ locale: a,
39
+ minDate: c,
40
+ maxDate: ee
41
+ } = D, h = a === void 0 ? "en" : a, u = n.getFullYear(), L = n.getMonth();
42
+ let A;
43
+ e[0] !== h ? (A = Array.from({
44
+ length: 12
45
+ }, (d, m) => {
46
+ const U = new Date(2024, m, 1);
47
+ return H(U).locale(h).format("MMMM");
48
+ }), e[0] = h, e[1] = A) : A = e[1];
49
+ const I = A;
50
+ let X;
51
+ e[2] !== ee || e[3] !== c ? (X = de(c, ee), e[2] = ee, e[3] = c, e[4] = X) : X = e[4];
52
+ const {
53
+ minYear: f,
54
+ maxYear: E
55
+ } = X;
56
+ let Z;
57
+ if (e[5] !== E || e[6] !== f) {
58
+ let d;
59
+ e[8] !== f ? (d = (m, U) => f + U, e[8] = f, e[9] = d) : d = e[9], Z = Array.from({
60
+ length: E - f + 1
61
+ }, d), e[5] = E, e[6] = f, e[7] = Z;
62
+ } else
63
+ Z = e[7];
64
+ const N = Z;
65
+ let y;
66
+ e[10] !== n || e[11] !== s ? (y = (d) => {
67
+ const m = new Date(n);
68
+ m.setMonth(Number.parseInt(d, 10)), s(m);
69
+ }, e[10] = n, e[11] = s, e[12] = y) : y = e[12];
70
+ const _ = y;
71
+ let R;
72
+ e[13] !== n || e[14] !== s ? (R = (d) => {
73
+ const m = new Date(n);
74
+ m.setFullYear(Number.parseInt(d, 10)), s(m);
75
+ }, e[13] = n, e[14] = s, e[15] = R) : R = e[15];
76
+ const te = R;
77
+ let q;
78
+ e[16] !== n || e[17] !== s ? (q = () => {
79
+ const d = new Date(n);
80
+ d.setMonth(d.getMonth() - 1), s(d);
81
+ }, e[16] = n, e[17] = s, e[18] = q) : q = e[18];
82
+ const M = q;
83
+ let J;
84
+ e[19] !== n || e[20] !== s ? (J = () => {
85
+ const d = new Date(n);
86
+ d.setMonth(d.getMonth() + 1), s(d);
87
+ }, e[19] = n, e[20] = s, e[21] = J) : J = e[21];
88
+ const re = J;
89
+ let T;
90
+ e[22] !== u || e[23] !== n || e[24] !== s || e[25] !== N ? (T = () => {
91
+ if (N.length === 0)
92
+ return;
93
+ const d = N[0], m = N[N.length - 1];
94
+ if (u >= d && u <= m)
95
+ return;
96
+ const U = Math.min(Math.max(u, d), m), ne = new Date(n);
97
+ ne.setFullYear(U), s(ne);
98
+ }, e[22] = u, e[23] = n, e[24] = s, e[25] = N, e[26] = T) : T = e[26], o.useLayoutEffect(T, [N, u, n, s]);
99
+ const ue = "flex items-center justify-between p-2 border-b bg-muted";
100
+ let se;
101
+ e[27] === Symbol.for("react.memo_cache_sentinel") ? (se = /* @__PURE__ */ l(Ve, { className: "h-4 w-4" }), e[27] = se) : se = e[27];
102
+ let V;
103
+ e[28] !== M ? (V = /* @__PURE__ */ l("button", { type: "button", onClick: M, className: "h-7 w-7 p-0 border border-gray-300 bg-white text-gray-700 hover:bg-gray-100 rounded-md flex items-center justify-center", children: se }), e[28] = M, e[29] = V) : V = e[29];
104
+ const le = "flex items-center gap-2", O = L.toString(), ae = I[L];
105
+ let j;
106
+ e[30] !== ae ? (j = /* @__PURE__ */ l(ge, { className: "w-32 h-8 text-sm", children: /* @__PURE__ */ l(he, { children: ae }) }), e[30] = ae, e[31] = j) : j = e[31];
107
+ let Y;
108
+ e[32] !== I ? (Y = /* @__PURE__ */ l(me, { children: I.map(Xe) }), e[32] = I, e[33] = Y) : Y = e[33];
109
+ let v;
110
+ e[34] !== _ || e[35] !== O || e[36] !== j || e[37] !== Y ? (v = /* @__PURE__ */ C(pe, { value: O, onValueChange: _, children: [
111
+ j,
112
+ Y
113
+ ] }), e[34] = _, e[35] = O, e[36] = j, e[37] = Y, e[38] = v) : v = e[38];
114
+ const B = pe, k = u.toString();
115
+ let w;
116
+ e[39] === Symbol.for("react.memo_cache_sentinel") ? (w = /* @__PURE__ */ l(ge, { className: "w-20 h-8 text-sm", children: /* @__PURE__ */ l(he, {}) }), e[39] = w) : w = e[39];
117
+ let x;
118
+ e[40] !== N ? (x = /* @__PURE__ */ l(me, { className: "max-h-[200px]", children: N.map(Ze) }), e[40] = N, e[41] = x) : x = e[41];
119
+ let $;
120
+ e[42] !== B || e[43] !== te || e[44] !== k || e[45] !== x ? ($ = /* @__PURE__ */ C(B, { value: k, onValueChange: te, children: [
121
+ w,
122
+ x
123
+ ] }), e[42] = B, e[43] = te, e[44] = k, e[45] = x, e[46] = $) : $ = e[46];
124
+ let b;
125
+ e[47] !== v || e[48] !== $ ? (b = /* @__PURE__ */ C("div", { className: le, children: [
126
+ v,
127
+ $
128
+ ] }), e[47] = v, e[48] = $, e[49] = b) : b = e[49];
129
+ let K;
130
+ e[50] === Symbol.for("react.memo_cache_sentinel") ? (K = /* @__PURE__ */ l(je, { className: "h-4 w-4" }), e[50] = K) : K = e[50];
131
+ let P;
132
+ e[51] !== re ? (P = /* @__PURE__ */ l("button", { type: "button", onClick: re, className: "h-7 w-7 p-0 border border-gray-300 bg-white text-gray-700 hover:bg-gray-100 rounded-md flex items-center justify-center", children: K }), e[51] = re, e[52] = P) : P = e[52];
133
+ let z;
134
+ return e[53] !== V || e[54] !== b || e[55] !== P ? (z = /* @__PURE__ */ C("div", { className: ue, children: [
135
+ V,
136
+ b,
137
+ P
138
+ ] }), e[53] = V, e[54] = b, e[55] = P, e[56] = z) : z = e[56], z;
139
+ }), Ge = {
140
+ "MM/DD/YYYY": {
141
+ separator: "/",
142
+ pattern: /^[0-9/]$/
143
+ },
144
+ "DD/MM/YYYY": {
145
+ separator: "/",
146
+ pattern: /^[0-9/]$/
147
+ },
148
+ "YYYY-MM-DD": {
149
+ separator: "-",
150
+ pattern: /^[0-9-]$/
151
+ },
152
+ "DD-MM-YYYY": {
153
+ separator: "-",
154
+ pattern: /^[0-9-]$/
155
+ },
156
+ "DD MMM YYYY": {
157
+ separator: " ",
158
+ pattern: /^[0-9a-zA-Z\s]$/
159
+ }
160
+ }, He = o.memo(({
161
+ label: g,
162
+ placeholder: D,
163
+ helperText: e,
164
+ required: n,
165
+ value: s,
166
+ onSelect: a,
167
+ onChange: c,
168
+ className: ee,
169
+ minDate: h,
170
+ maxDate: u,
171
+ disabled: L,
172
+ readOnly: A,
173
+ locale: I = "en",
174
+ inputClassName: X,
175
+ dateFormat: f = "YYYY-MM-DD",
176
+ error: E,
177
+ showOutsideDays: Z,
178
+ clearable: N = !1,
179
+ month: y,
180
+ onMonthChange: _,
181
+ open: R,
182
+ onOpenChange: te,
183
+ dayPickerProps: q,
184
+ manual: M = !1,
185
+ // Default to true for backward compatibility
186
+ popoverAlign: J = "end",
187
+ ...re
188
+ }) => {
189
+ const {
190
+ disabled: T,
191
+ fromDate: ue,
192
+ toDate: se,
193
+ startMonth: V,
194
+ endMonth: le,
195
+ ...O
196
+ } = q ?? {}, [ae, j] = o.useState(!1), Y = R !== void 0 ? R : ae, v = te || j, [B, k] = o.useState(""), [w, x] = o.useState(s), [$, b] = o.useState(), [K, P] = o.useState(y ?? s ?? /* @__PURE__ */ new Date()), z = o.useMemo(() => y ?? K, [y, K]), d = o.useCallback((t) => {
197
+ _ ? _(t) : P(t);
198
+ }, [_]), m = o.useMemo(() => {
199
+ const t = Ge[f];
200
+ return t || {
201
+ separator: "",
202
+ pattern: /.*/
203
+ };
204
+ }, [f]), U = o.useMemo(() => D || (M ? f.toLowerCase() : "Click to select date"), [D, f, M]), ne = o.useCallback((t) => {
205
+ const r = t.replace(/\D/g, ""), {
206
+ separator: i
207
+ } = m;
208
+ if (r.length <= 2)
209
+ return r;
210
+ switch (f) {
211
+ case "MM/DD/YYYY":
212
+ case "DD/MM/YYYY":
213
+ return r.length <= 4 ? `${r.substring(0, 2)}${i}${r.substring(2)}` : `${r.substring(0, 2)}${i}${r.substring(2, 4)}${i}${r.substring(4, 8)}`;
214
+ case "YYYY-MM-DD":
215
+ return r.length <= 4 ? r : r.length <= 6 ? `${r.substring(0, 4)}${i}${r.substring(4)}` : `${r.substring(0, 4)}${i}${r.substring(4, 6)}${i}${r.substring(6, 8)}`;
216
+ case "DD-MM-YYYY":
217
+ return r.length <= 4 ? `${r.substring(0, 2)}${i}${r.substring(2)}` : `${r.substring(0, 2)}${i}${r.substring(2, 4)}${i}${r.substring(4, 8)}`;
218
+ case "DD MMM YYYY":
219
+ return t;
220
+ default:
221
+ return t;
222
+ }
223
+ }, [f, m]), ie = o.useMemo(() => (t) => {
224
+ const r = t.trim();
225
+ return r && H(r, f, !0).isValid() ? H(r, f) : null;
226
+ }, [f]), W = o.useCallback((t) => H(t).format(f), [f]), ve = o.useMemo(() => ({
227
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
228
+ month: "space-y-4",
229
+ caption: "hidden",
230
+ // Hide default caption since we have custom navigation
231
+ caption_label: "text-sm font-medium",
232
+ nav: "hidden",
233
+ // Hide default navigation
234
+ nav_button: "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
235
+ nav_button_previous: "absolute left-1 top-1",
236
+ nav_button_next: "absolute right-1 top-1",
237
+ table: "w-full border-collapse space-y-1",
238
+ head_row: "flex",
239
+ head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
240
+ row: "flex w-full mt-2",
241
+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
242
+ day: "p-0 font-normal aria-selected:opacity-100 rounded-md transition-colors items-center justify-center hover:bg-accent hover:text-accent-foreground aria-selected:bg-primary aria-selected:text-white aria-selected:hover:bg-primary aria-selected:hover:text-white",
243
+ day_button: "h-9 w-9 flex items-center justify-center rounded-md transition-colors hover:bg-accent hover:text-accent-foreground aria-selected:bg-primary aria-selected:text-primary-foreground aria-selected:opacity-100 aria-disabled:pointer-events-none aria-disabled:cursor-not-allowed aria-disabled:opacity-40 aria-disabled:text-muted-foreground aria-disabled:grayscale aria-disabled:hover:bg-transparent aria-disabled:hover:text-muted-foreground",
244
+ day_range_end: "day-range-end",
245
+ day_selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
246
+ day_today: "bg-accent text-accent-foreground",
247
+ day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
248
+ disabled: "text-muted-foreground opacity-40 grayscale pointer-events-none cursor-not-allowed",
249
+ day_disabled: "text-muted-foreground opacity-40 grayscale pointer-events-none cursor-not-allowed",
250
+ day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground",
251
+ day_hidden: "invisible"
252
+ }), []), Me = o.useMemo(() => Ke(ze(h, u), T), [h, u, T]), we = h ? be(h) : V, xe = u ? be(u) : le;
253
+ o.useEffect(() => {
254
+ k(s ? W(s) : ""), x(s), b(void 0), s && !y && P(s), H.locale(I);
255
+ }, [s, I, W, y]);
256
+ const fe = o.useRef(!1);
257
+ o.useLayoutEffect(() => {
258
+ const t = Y && !fe.current;
259
+ if (fe.current = Y, !t) return;
260
+ const r = s ?? w;
261
+ if (!r) return;
262
+ const i = new Date(r.getFullYear(), r.getMonth(), 1), p = i.getFullYear(), F = i.getMonth();
263
+ if (y !== void 0) {
264
+ _ && (y.getFullYear() !== p || y.getMonth() !== F) && _(i);
265
+ return;
266
+ }
267
+ P(i);
268
+ }, [Y, y, s, w, _]);
269
+ const Q = o.useCallback((t) => ye(t, h, u) && Ue(t, h, u), [h, u]), De = o.useCallback((t) => {
270
+ if (!M) return;
271
+ b(void 0);
272
+ let r = t.target.value;
273
+ if (k(r), !r.trim()) {
274
+ x(void 0), a == null || a(void 0), c == null || c(void 0);
275
+ return;
276
+ }
277
+ const i = ne(r);
278
+ i !== r && r.replace(/\D/g, "").length > 1 && (k(i), r = i);
279
+ const p = ie(r);
280
+ if (p != null && p.isValid()) {
281
+ const F = p.toDate();
282
+ Q(F) && (x(F), a == null || a(F), c == null || c(F));
283
+ }
284
+ }, [M, ne, ie, a, c, Q]), ce = o.useCallback(() => {
285
+ const t = B.trim(), r = s ?? w;
286
+ if (!t) {
287
+ k(""), b(void 0);
288
+ return;
289
+ }
290
+ const i = ie(t), p = i != null && i.isValid() ? i.toDate() : void 0;
291
+ if (p && Q(p)) {
292
+ k(W(p)), b(void 0), (!w || w.getTime() !== p.getTime()) && (x(p), a == null || a(p), c == null || c(p));
293
+ return;
294
+ }
295
+ if (i != null && i.isValid() && p) {
296
+ const {
297
+ minYear: F,
298
+ maxYear: _e
299
+ } = de(h, u);
300
+ ye(p, h, u) ? b("Date is outside the allowed range.") : b(`Enter a year between ${F} and ${_e}.`);
301
+ } else
302
+ b(void 0);
303
+ k(r ? W(r) : "");
304
+ }, [B, s, w, ie, W, Q, h, u, a, c]), Ne = o.useCallback((t) => {
305
+ t && Q(t) && (k(W(t)), x(t), b(void 0), a == null || a(t), c == null || c(t), v(!1));
306
+ }, [Q, a, c, W, v]), ke = o.useCallback((t) => {
307
+ t.stopPropagation(), k(""), x(void 0), a == null || a(void 0), c == null || c(void 0);
308
+ }, [a, c]), G = !!(L || A), $e = o.useCallback((t) => {
309
+ if (!M) {
310
+ !G && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), v(!Y));
311
+ return;
312
+ }
313
+ if (!["Backspace", "Delete", "Tab", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(t.key) && !m.pattern.test(t.key) && !t.ctrlKey && !t.metaKey) {
314
+ t.preventDefault();
315
+ return;
316
+ }
317
+ t.key === "Enter" && (t.preventDefault(), ce());
318
+ }, [M, m.pattern, ce, v, Y, G]);
319
+ return /* @__PURE__ */ C("div", { className: S("space-y-1", ee), ...re, children: [
320
+ g && /* @__PURE__ */ C(Re, { className: "text-sm font-medium text-gray-700", children: [
321
+ g,
322
+ n && /* @__PURE__ */ l("span", { className: "text-red-500 ml-1", children: "*" })
323
+ ] }),
324
+ /* @__PURE__ */ C(Te, { open: Y, onOpenChange: (t) => {
325
+ G && t || v(t);
326
+ }, children: [
327
+ /* @__PURE__ */ C("div", { className: S("w-60 relative", X), children: [
328
+ /* @__PURE__ */ l(Le, { type: "text", value: B, onChange: De, onBlur: ce, onKeyDown: $e, placeholder: U, disabled: L, readOnly: A || !M, onClick: () => {
329
+ !M && !L && !A && v(!0);
330
+ }, className: S("w-full pr-12", (E || $) && "border border-destructive focus-visible:ring-destructive", !M && !G && "cursor-pointer") }),
331
+ N && (s ?? w) && !L && !A && /* @__PURE__ */ l("button", { type: "button", onClick: ke, className: "absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring", "aria-label": "Clear date", children: /* @__PURE__ */ l(Ie, { className: "h-4 w-4 text-muted-foreground" }) }),
332
+ /* @__PURE__ */ l(Oe, { asChild: !0, children: /* @__PURE__ */ l("button", { type: "button", className: S("absolute right-1 top-1/2 -translate-y-1/2 border-0 bg-transparent outline-none", G ? "cursor-default text-muted-foreground" : "cursor-pointer text-black hover:text-black"), style: {
333
+ height: "1.75rem",
334
+ width: "1.75rem"
335
+ }, onClick: G ? void 0 : () => {
336
+ v(!Y);
337
+ }, disabled: G, "aria-label": "Open calendar", children: /* @__PURE__ */ l(Ee, { strokeWidth: 1, className: "h-5 w-5" }) }) })
338
+ ] }),
339
+ /* @__PURE__ */ l(Be, { className: "w-auto p-0 mt-2", align: J, children: /* @__PURE__ */ C("div", { className: "bg-white rounded-md border shadow-md", children: [
340
+ /* @__PURE__ */ l(We, { month: z, onMonthChange: d, locale: I, minDate: h, maxDate: u }),
341
+ /* @__PURE__ */ l("div", { className: "p-3", children: /* @__PURE__ */ l(Fe, { ...O, mode: "single", selected: w, onSelect: Ne, month: z, onMonthChange: d, startMonth: we, endMonth: xe, disabled: Me, showOutsideDays: Z, className: S("p-0", O.className), classNames: {
342
+ ...ve,
343
+ ...O.classNames
344
+ } }) })
345
+ ] }) })
346
+ ] }),
347
+ (e || E || $) && /* @__PURE__ */ l("p", { className: S("text-xs", E || $ ? "text-destructive" : "text-gray-500"), children: E || $ || e })
348
+ ] });
349
+ });
350
+ He.displayName = "DatePickerField";
351
+ function Xe(g, D) {
352
+ return /* @__PURE__ */ l(Ye, { value: D.toString(), children: g }, g);
353
+ }
354
+ function Ze(g) {
355
+ return /* @__PURE__ */ l(Ye, { value: g.toString(), children: g }, g);
356
+ }
357
+ export {
358
+ oe as CALENDAR_YEAR_HALF_SPAN,
359
+ He as DatePickerField,
360
+ de as getEffectiveCalendarYearBounds
361
+ };
@@ -0,0 +1,288 @@
1
+ "use client";
2
+ import { jsx as d, jsxs as F } from "react/jsx-runtime";
3
+ import { c as Le } from "react-compiler-runtime";
4
+ import K from "dayjs";
5
+ import $e from "dayjs/plugin/customParseFormat";
6
+ import Fe from "dayjs/plugin/localizedFormat";
7
+ import { CalendarDays as Be, X as Te, ChevronLeft as ze, ChevronRight as Ae } from "lucide-react";
8
+ import * as i from "react";
9
+ import { DayPicker as Ke } from "react-day-picker";
10
+ import { Input as We } from "../../../ui/input.js";
11
+ import { Label as Xe } from "../../../ui/label.js";
12
+ import { Popover as qe, PopoverTrigger as fe, PopoverContent as Ge } from "../../../ui/popover.js";
13
+ import { cn as _ } from "../../../../lib/utils.js";
14
+ import { mergeDisabledMatchers as He, minMaxDisabledMatchers as Je, calendarMonthAnchor as me, isRangeWithinMinMaxLocalDay as U } from "./day-picker-bounds.js";
15
+ K.extend($e);
16
+ K.extend(Fe);
17
+ const Qe = i.memo(function(B) {
18
+ const e = Le(30), {
19
+ month: m,
20
+ onMonthChange: l,
21
+ locale: r,
22
+ numberOfMonths: s
23
+ } = B, V = r === void 0 ? "en" : r, c = s === void 0 ? 2 : s;
24
+ let u;
25
+ e[0] !== m || e[1] !== l ? (u = () => {
26
+ const a = new Date(m);
27
+ a.setMonth(a.getMonth() - 1), l(a);
28
+ }, e[0] = m, e[1] = l, e[2] = u) : u = e[2];
29
+ const h = u;
30
+ let k;
31
+ e[3] !== m || e[4] !== l ? (k = () => {
32
+ const a = new Date(m);
33
+ a.setMonth(a.getMonth() + 1), l(a);
34
+ }, e[3] = m, e[4] = l, e[5] = k) : k = e[5];
35
+ const M = k;
36
+ let O;
37
+ if (e[6] !== V || e[7] !== m || e[8] !== c) {
38
+ let a;
39
+ e[10] !== V || e[11] !== m ? (a = (se, W) => K(m).add(W, "month").locale(V).format("MMMM YYYY"), e[10] = V, e[11] = m, e[12] = a) : a = e[12], O = Array.from({
40
+ length: c
41
+ }, a), e[6] = V, e[7] = m, e[8] = c, e[9] = O;
42
+ } else
43
+ O = e[9];
44
+ const v = O;
45
+ let L;
46
+ e[13] === Symbol.for("react.memo_cache_sentinel") ? (L = /* @__PURE__ */ d(ze, { className: "h-4 w-4" }), e[13] = L) : L = e[13];
47
+ let b;
48
+ e[14] !== h ? (b = /* @__PURE__ */ d("button", { type: "button", onClick: h, className: "flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background p-0 text-foreground hover:bg-accent", "aria-label": "Previous month", children: L }), e[14] = h, e[15] = b) : b = e[15];
49
+ const T = `repeat(${c}, minmax(0, 1fr))`;
50
+ let P;
51
+ e[16] !== T ? (P = {
52
+ gridTemplateColumns: T
53
+ }, e[16] = T, e[17] = P) : P = e[17];
54
+ let p;
55
+ e[18] !== v ? (p = v.map(Ze), e[18] = v, e[19] = p) : p = e[19];
56
+ let x;
57
+ e[20] !== p || e[21] !== P ? (x = /* @__PURE__ */ d("div", { className: "grid flex-1 gap-2 px-2 text-center text-sm font-semibold text-foreground", style: P, children: p }), e[20] = p, e[21] = P, e[22] = x) : x = e[22];
58
+ let D;
59
+ e[23] === Symbol.for("react.memo_cache_sentinel") ? (D = /* @__PURE__ */ d(Ae, { className: "h-4 w-4" }), e[23] = D) : D = e[23];
60
+ let R;
61
+ e[24] !== M ? (R = /* @__PURE__ */ d("button", { type: "button", onClick: M, className: "flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background p-0 text-foreground hover:bg-accent", "aria-label": "Next month", children: D }), e[24] = M, e[25] = R) : R = e[25];
62
+ let $;
63
+ return e[26] !== x || e[27] !== R || e[28] !== b ? ($ = /* @__PURE__ */ F("div", { className: "flex items-center border-b border-border bg-muted px-2 py-1.5", children: [
64
+ b,
65
+ x,
66
+ R
67
+ ] }), e[26] = x, e[27] = R, e[28] = b, e[29] = $) : $ = e[29], $;
68
+ }), Ue = i.memo(({
69
+ label: Y,
70
+ placeholder: B,
71
+ helperText: e,
72
+ required: m,
73
+ value: l,
74
+ onSelect: r,
75
+ onChange: s,
76
+ className: V,
77
+ minDate: c,
78
+ maxDate: u,
79
+ disabled: h,
80
+ readOnly: k,
81
+ locale: M = "en",
82
+ inputClassName: O,
83
+ dateFormat: v = "YYYY-MM-DD",
84
+ displayFormat: L,
85
+ error: b,
86
+ showOutsideDays: T,
87
+ clearable: P = !1,
88
+ month: p,
89
+ onMonthChange: x,
90
+ open: D,
91
+ onOpenChange: R,
92
+ dayPickerProps: $,
93
+ manual: a = !1,
94
+ // Default to false: calendar-only selection unless enabled
95
+ popoverAlign: se = "end",
96
+ iconPosition: W = "right",
97
+ // Default to right
98
+ icon: z,
99
+ iconClassName: X,
100
+ iconColor: I,
101
+ presets: Z,
102
+ numberOfMonths: oe = 2,
103
+ openOnInputClick: pe = !0,
104
+ openOnFieldClick: be = !1,
105
+ trigger: ie,
106
+ ...ye
107
+ }) => {
108
+ const {
109
+ disabled: ae,
110
+ fromDate: Ce,
111
+ toDate: Se,
112
+ startMonth: he,
113
+ endMonth: ve,
114
+ showOutsideDays: xe,
115
+ ...C
116
+ } = $ ?? {}, ge = T ?? xe, de = L ?? v, [we, ke] = i.useState(!1), q = D !== void 0 ? D : we, j = R || ke, [S, y] = i.useState(""), [E, g] = i.useState(l), [ne, le] = i.useState(p ?? (l == null ? void 0 : l.from) ?? /* @__PURE__ */ new Date()), ce = i.useMemo(() => p ?? ne, [p, ne]), G = i.useCallback((t) => {
117
+ x ? x(t) : le(t);
118
+ }, [x]), Me = i.useMemo(() => B || (a ? `${v.toLowerCase()} - ${v.toLowerCase()}` : "Click to select date range"), [B, v, a]), H = i.useCallback((t) => K(t).locale(M).format(de), [de, M]), w = i.useCallback((t) => t != null && t.from ? t.from && t.to ? `${H(t.from)} - ${H(t.to)}` : H(t.from) : "", [H]), J = i.useCallback((t) => {
119
+ const o = t.trim();
120
+ if (!o) return null;
121
+ const f = K(o, v, !0).locale(M);
122
+ return f.isValid() ? f : null;
123
+ }, [v, M]), Q = i.useCallback((t) => {
124
+ const o = t.trim();
125
+ if (!o) return null;
126
+ const f = o.split(/\s+-\s+/);
127
+ if (f.length === 1) {
128
+ const n = J(f[0]);
129
+ return n != null && n.isValid() ? {
130
+ from: n.toDate()
131
+ } : null;
132
+ }
133
+ if (f.length === 2) {
134
+ const n = J(f[0]), A = J(f[1]);
135
+ if (n != null && n.isValid() && (A != null && A.isValid())) {
136
+ const te = n.toDate(), re = A.toDate();
137
+ return te > re ? {
138
+ from: re,
139
+ to: te
140
+ } : {
141
+ from: te,
142
+ to: re
143
+ };
144
+ }
145
+ if (n != null && n.isValid())
146
+ return {
147
+ from: n.toDate()
148
+ };
149
+ }
150
+ return null;
151
+ }, [J]), ue = i.useCallback((t) => t, []), Ne = i.useMemo(() => ({
152
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
153
+ month: "space-y-4",
154
+ caption: "hidden",
155
+ // Hide default caption since we have custom navigation
156
+ month_caption: "hidden",
157
+ // react-day-picker v9 month title wrapper
158
+ caption_label: "text-sm font-medium",
159
+ nav: "hidden",
160
+ // Hide default navigation
161
+ nav_button: "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
162
+ nav_button_previous: "absolute left-1 top-1",
163
+ nav_button_next: "absolute right-1 top-1",
164
+ table: "w-full border-collapse space-y-1",
165
+ head_row: "flex",
166
+ head_cell: "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
167
+ row: "flex w-full mt-2",
168
+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
169
+ day: "p-0 font-normal aria-selected:opacity-100 rounded-md transition-colors items-center justify-center hover:bg-accent hover:text-accent-foreground aria-selected:bg-primary aria-selected:text-white aria-selected:hover:bg-primary aria-selected:hover:text-white",
170
+ day_button: "h-9 w-9 flex items-center justify-center rounded-md transition-colors hover:bg-accent hover:text-accent-foreground aria-selected:bg-primary aria-selected:text-primary-foreground aria-selected:opacity-100 aria-disabled:pointer-events-none aria-disabled:cursor-not-allowed aria-disabled:opacity-40 aria-disabled:text-muted-foreground aria-disabled:grayscale aria-disabled:hover:bg-transparent aria-disabled:hover:text-muted-foreground",
171
+ day_range_end: "day-range-end",
172
+ // react-day-picker v9 selection state keys
173
+ range_end: "day-range-end",
174
+ day_selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
175
+ // react-day-picker v9 selection state keys
176
+ selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
177
+ day_today: "bg-accent text-accent-foreground",
178
+ day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
179
+ disabled: "text-muted-foreground opacity-40 grayscale pointer-events-none cursor-not-allowed",
180
+ day_disabled: "text-muted-foreground opacity-40 grayscale pointer-events-none cursor-not-allowed",
181
+ day_range_middle: (
182
+ // Middle of selected range: gray background + no rounded corners
183
+ // react-day-picker v9 uses `range_middle` on the Day cell (no aria-selected).
184
+ "!bg-muted !text-foreground rounded-none [&>button]:!rounded-none"
185
+ ),
186
+ // react-day-picker v9 selection state keys
187
+ range_middle: "!bg-muted !text-foreground rounded-none [&>button]:!rounded-none",
188
+ day_hidden: "invisible"
189
+ }), []), _e = i.useMemo(() => He(Je(c, u), ae), [c, u, ae]), Pe = c ? me(c) : he, Re = u ? me(u) : ve;
190
+ i.useEffect(() => {
191
+ y(w(l)), g(l), l != null && l.from && !p && le(l.from);
192
+ }, [l, w, p]);
193
+ const Ve = i.useCallback((t) => {
194
+ if (!a) return;
195
+ let o = t.target.value;
196
+ if (y(o), !o.trim()) {
197
+ g(void 0), r == null || r(void 0), s == null || s(void 0);
198
+ return;
199
+ }
200
+ const f = ue(o);
201
+ f !== o && (y(f), o = f);
202
+ const n = Q(o);
203
+ n && U(n, c, u) && (g(n), r == null || r(n), s == null || s(n));
204
+ }, [a, r, s, ue, Q, c, u]), ee = i.useCallback(() => {
205
+ const t = S.trim();
206
+ if (!t) {
207
+ g(void 0), r == null || r(void 0), s == null || s(void 0);
208
+ return;
209
+ }
210
+ const o = Q(t);
211
+ o && U(o, c, u) ? (g(o), y(w(o)), r == null || r(o), s == null || s(o)) : E ? y(w(E)) : (y(""), g(void 0), r == null || r(void 0), s == null || s(void 0));
212
+ }, [S, E, w, Q, c, u, r, s]), De = i.useCallback((t) => {
213
+ t && !U(t, c, u) || (y(w(t)), g(t), r == null || r(t), s == null || s(t));
214
+ }, [r, s, w, c, u]), Ie = i.useCallback((t) => {
215
+ t.stopPropagation(), y(""), g(void 0), r == null || r(void 0), s == null || s(void 0);
216
+ }, [r, s]), je = i.useCallback((t) => {
217
+ const o = t.getRange();
218
+ U(o, c, u) && (y(w(o)), g(o), o.from && G(o.from), r == null || r(o), s == null || s(o));
219
+ }, [w, G, c, u, s, r]), Ee = !!(P && E && !h && !k), N = !!(h || k), Ye = i.useCallback((t) => {
220
+ if (!a) {
221
+ !N && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), j(!q));
222
+ return;
223
+ }
224
+ t.key === "Enter" && (t.preventDefault(), ee());
225
+ }, [a, ee, j, q, N]), Oe = i.useMemo(() => {
226
+ var t, o;
227
+ if (z) {
228
+ if (i.isValidElement(z)) {
229
+ const f = z;
230
+ return i.cloneElement(f, {
231
+ className: _("h-5 w-5", X, (t = f.props) == null ? void 0 : t.className),
232
+ style: {
233
+ ...((o = f.props) == null ? void 0 : o.style) || {},
234
+ ...I ? {
235
+ color: I
236
+ } : {}
237
+ }
238
+ });
239
+ }
240
+ return /* @__PURE__ */ d("span", { className: _("h-5 w-5 inline-flex items-center justify-center", X), style: I ? {
241
+ color: I
242
+ } : void 0, children: z });
243
+ }
244
+ return /* @__PURE__ */ d(Be, { strokeWidth: 1, className: _("h-5 w-5", X, h && "opacity-50"), style: I ? {
245
+ color: I
246
+ } : void 0 });
247
+ }, [z, X, I, h]);
248
+ return /* @__PURE__ */ F("div", { className: _("space-y-1", V), ...ye, children: [
249
+ Y && /* @__PURE__ */ F(Xe, { className: "text-sm font-medium text-foreground", children: [
250
+ Y,
251
+ m && /* @__PURE__ */ d("span", { className: "text-red-500 ml-1", children: "*" })
252
+ ] }),
253
+ /* @__PURE__ */ F(qe, { open: q, onOpenChange: (t) => {
254
+ N && t || j(t);
255
+ }, children: [
256
+ ie ? /* @__PURE__ */ d(fe, { asChild: !0, children: ie }) : /* @__PURE__ */ F("div", { className: _("w-80 relative", O), onMouseDownCapture: () => {
257
+ a && be && !h && !k && j(!0);
258
+ }, children: [
259
+ /* @__PURE__ */ d(We, { type: "text", value: S, onChange: Ve, onBlur: ee, onKeyDown: Ye, onClick: () => {
260
+ (!a && !N || a && pe && !N) && j(!0);
261
+ }, placeholder: Me, disabled: h, readOnly: k || !a, className: _("w-full pr-12", W === "left" && "pl-12", b && "border border-destructive focus-visible:ring-destructive", !a && !N && "cursor-pointer") }),
262
+ Ee && /* @__PURE__ */ d("button", { type: "button", onClick: Ie, className: "absolute right-10 top-1/2 -translate-y-1/2 p-1 rounded hover:bg-muted focus:outline-none focus:ring-2 focus:ring-ring", "aria-label": "Clear date range", children: /* @__PURE__ */ d(Te, { className: "h-4 w-4 text-muted-foreground" }) }),
263
+ /* @__PURE__ */ d(fe, { asChild: !0, children: /* @__PURE__ */ d("button", { type: "button", className: _("absolute top-1/2 -translate-y-1/2 border-0 bg-transparent outline-none", W === "left" ? "left-3" : "right-1", N ? "cursor-default text-muted-foreground" : "cursor-pointer text-black hover:text-black"), style: {
264
+ height: "1.75rem",
265
+ width: "1.75rem"
266
+ }, onClick: N ? void 0 : () => {
267
+ j(!q);
268
+ }, disabled: N, "aria-label": "Open calendar", children: Oe }) })
269
+ ] }),
270
+ /* @__PURE__ */ d(Ge, { className: "w-auto p-0 mt-2", align: se, children: /* @__PURE__ */ F("div", { className: "rounded-md border border-border bg-popover text-popover-foreground shadow-md", children: [
271
+ Z && Z.length > 0 && /* @__PURE__ */ d("div", { className: "flex flex-wrap gap-2 p-3 border-b bg-muted/40", children: Z.map((t) => /* @__PURE__ */ d("button", { type: "button", className: "rounded-md border bg-background px-2.5 py-1.5 text-xs font-medium hover:bg-accent hover:text-accent-foreground", onClick: () => je(t), children: t.label }, t.label)) }),
272
+ /* @__PURE__ */ d(Qe, { month: ce, onMonthChange: G, locale: M, numberOfMonths: oe }),
273
+ /* @__PURE__ */ d("div", { className: "p-3", children: /* @__PURE__ */ d(Ke, { ...C, mode: "range", selected: E, onSelect: De, month: ce, onMonthChange: G, startMonth: Pe, endMonth: Re, disabled: _e, numberOfMonths: oe, showOutsideDays: ge, className: _("p-0", C.className), classNames: {
274
+ ...Ne,
275
+ ...C.classNames
276
+ } }) })
277
+ ] }) })
278
+ ] }),
279
+ (e || b) && /* @__PURE__ */ d("p", { className: _("text-xs", b ? "text-destructive" : "text-muted-foreground"), children: b || e })
280
+ ] });
281
+ });
282
+ Ue.displayName = "DateRangePickerField";
283
+ function Ze(Y) {
284
+ return /* @__PURE__ */ d("span", { className: "truncate", children: Y }, Y);
285
+ }
286
+ export {
287
+ Ue as DateRangePickerField
288
+ };