@athbnb/ui 0.0.2 → 0.0.3

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.
@@ -0,0 +1,650 @@
1
+ import { MONTH_NAMES as e, WEEKDAYS as t, compareDay as n, formatDateDisplay as r, getDaysInMonth as i, getFirstWeekdayOfMonth as a, isDayBetweenInclusive as o, parseBoundaryDate as s, parseFlexibleDateInput as c, sameDay as l, startOfDay as u, toISODateString as d } from "../utils/date-picker-utils.js";
2
+ import { c as f } from "react/compiler-runtime";
3
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
4
+ import * as g from "react";
5
+ //#region src/ui/DatePicker.tsx
6
+ function _(e) {
7
+ let t = f(3), { className: n } = e, r;
8
+ t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ m("path", { d: "M18 6L6 18M6 6l12 12" }), t[0] = r) : r = t[0];
9
+ let i;
10
+ return t[1] === n ? i = t[2] : (i = /* @__PURE__ */ m("svg", {
11
+ xmlns: "http://www.w3.org/2000/svg",
12
+ viewBox: "0 0 24 24",
13
+ fill: "none",
14
+ stroke: "currentColor",
15
+ strokeWidth: "2",
16
+ className: n,
17
+ "aria-hidden": !0,
18
+ children: r
19
+ }), t[1] = n, t[2] = i), i;
20
+ }
21
+ function v(e) {
22
+ let t = f(2), { dir: n } = e, r;
23
+ return t[0] === n ? r = t[1] : (r = /* @__PURE__ */ m("svg", {
24
+ xmlns: "http://www.w3.org/2000/svg",
25
+ viewBox: "0 0 24 24",
26
+ fill: "currentColor",
27
+ className: "w-3 h-3",
28
+ "aria-hidden": !0,
29
+ children: n === "left" ? /* @__PURE__ */ m("path", { d: "M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) : /* @__PURE__ */ m("path", { d: "M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" })
30
+ }), t[0] = n, t[1] = r), r;
31
+ }
32
+ function y() {
33
+ let e = f(1), t;
34
+ return e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ h("svg", {
35
+ xmlns: "http://www.w3.org/2000/svg",
36
+ width: "24",
37
+ height: "24",
38
+ viewBox: "0 0 24 24",
39
+ fill: "none",
40
+ stroke: "currentColor",
41
+ strokeWidth: "2",
42
+ className: "min-w-6 min-h-6 shrink-0 text-red-500 pe-2",
43
+ "aria-hidden": !0,
44
+ children: [
45
+ /* @__PURE__ */ m("circle", {
46
+ cx: "12",
47
+ cy: "12",
48
+ r: "10"
49
+ }),
50
+ /* @__PURE__ */ m("line", {
51
+ x1: "12",
52
+ y1: "8",
53
+ x2: "12",
54
+ y2: "12"
55
+ }),
56
+ /* @__PURE__ */ m("line", {
57
+ x1: "12",
58
+ y1: "16",
59
+ x2: "12.01",
60
+ y2: "16"
61
+ })
62
+ ]
63
+ }), e[0] = t) : t = e[0], t;
64
+ }
65
+ var b = 380, x = 320, S = g.forwardRef(function({ value: o, onChange: f, onBlur: v, autoFocus: y = !1, placeholder: S = "Select Date", min: C = null, max: w = null, disabled: T = !1, className: E = "", inputClassName: D = "", disabledDates: O = [], error: k = "", rangeStart: A = null, rangeEnd: j = null, valueFormat: M = "display", onOpenChange: N }, P) {
66
+ let [F, I] = g.useState(!1), [L, R] = g.useState(() => /* @__PURE__ */ new Date()), [z, B] = g.useState(null), [V, H] = g.useState(""), U = g.useRef(null), [W, ee] = g.useState(!1), [te, ne] = g.useState(!1), G = g.useCallback((e) => {
67
+ I((t) => {
68
+ let n = typeof e == "function" ? e(t) : e;
69
+ return n !== t && N?.(n), n;
70
+ });
71
+ }, [N]);
72
+ g.useImperativeHandle(P, () => ({
73
+ open: () => {
74
+ T || G(!0);
75
+ },
76
+ close: () => G(!1),
77
+ toggle: () => {
78
+ T || G((e) => !e);
79
+ }
80
+ })), g.useEffect(() => {
81
+ if (!F || !U.current) return;
82
+ let e = U.current.getBoundingClientRect(), t = window.innerHeight - e.bottom, n = window.innerWidth - e.left;
83
+ ee(t < b && e.top > b), ne(n < x && e.right > x);
84
+ }, [F]), g.useEffect(() => {
85
+ if (!F) return;
86
+ let e = (e) => {
87
+ U.current && !U.current.contains(e.target) && (G(!1), v?.());
88
+ };
89
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
90
+ }, [
91
+ F,
92
+ v,
93
+ G
94
+ ]), g.useEffect(() => {
95
+ y && G(!0);
96
+ }, [y, G]);
97
+ let K = g.useMemo(() => s(C), [C]), q = g.useMemo(() => s(w), [w]), J = g.useCallback((e) => {
98
+ if (T) return !0;
99
+ let t = u(e);
100
+ if (K && t.getTime() < K.getTime() || q && t.getTime() > q.getTime()) return !0;
101
+ for (let e of O) {
102
+ let n = typeof e == "string" ? c(e) ?? s(e) : u(e);
103
+ if (n && t.getTime() === n.getTime()) return !0;
104
+ }
105
+ return !1;
106
+ }, [
107
+ T,
108
+ O,
109
+ K,
110
+ q
111
+ ]);
112
+ g.useEffect(() => {
113
+ if (!o) {
114
+ B(null);
115
+ return;
116
+ }
117
+ let e = c(o);
118
+ if (!e) {
119
+ B(null);
120
+ return;
121
+ }
122
+ J(e) ? (H("Date is outside allowed range"), B(e)) : (H(""), B(e), R(new Date(e.getFullYear(), e.getMonth(), 1)));
123
+ }, [o]), g.useEffect(() => {
124
+ H(k);
125
+ }, [k]);
126
+ let re = g.useCallback((e) => {
127
+ f(M === "iso" ? d(e) : r(e));
128
+ }, [f, M]), ie = (e) => {
129
+ let t = new Date(L.getFullYear(), L.getMonth(), e);
130
+ if (J(t)) {
131
+ H("Date is outside allowed range");
132
+ return;
133
+ }
134
+ H(""), B(t), re(t), v?.(), G(!1);
135
+ }, ae = (e) => {
136
+ R((t) => {
137
+ let n = t.getFullYear(), r = t.getMonth();
138
+ return new Date(n, r + e, 1);
139
+ });
140
+ }, oe = (e) => {
141
+ R((t) => new Date(t.getFullYear() + e, t.getMonth(), 1));
142
+ }, Y = A ? c(A) : null, X = j ? c(j) : null, Z = () => {
143
+ let e = L.getFullYear(), t = L.getMonth(), r = i(e, t), o = a(e, t), s = [];
144
+ for (let e = 0; e < o; e++) s.push(/* @__PURE__ */ m("div", { className: "w-full h-9" }, `e-${e}`));
145
+ for (let i = 1; i <= r; i++) {
146
+ let r = new Date(e, t, i);
147
+ r.setHours(0, 0, 0, 0);
148
+ let a = J(r), o = l(r, z), c = l(r, /* @__PURE__ */ new Date()), u = !!(Y && l(r, Y)), d = !!(X && l(r, X)), f = Y != null && X != null && n(r, Y) > 0 && n(r, X) < 0, p = "relative z-10 w-full h-full flex items-center justify-center text-sm font-medium ";
149
+ a ? p += "text-gray-300 cursor-not-allowed" : u || d || o && !f ? p += "text-white font-bold" : f ? p += "text-black font-bold" : p += "text-secondary hover:bg-gray-100 rounded-full", s.push(/* @__PURE__ */ h("div", {
150
+ className: "relative w-full h-9 flex items-center justify-center cursor-pointer",
151
+ onClick: (e) => {
152
+ e.preventDefault(), a || ie(i);
153
+ },
154
+ children: [
155
+ f && !a ? /* @__PURE__ */ m("div", { className: "absolute inset-x-0 inset-y-0 bg-primary/20" }) : null,
156
+ u && !a ? /* @__PURE__ */ m("div", { className: `absolute inset-y-0 bg-primary left-0 right-0 ${X ? "rounded-l-md" : "rounded-md"}` }) : null,
157
+ d && !a ? /* @__PURE__ */ m("div", { className: `absolute inset-y-0 bg-primary left-0 right-0 ${Y ? "rounded-r-md" : "rounded-md"}` }) : null,
158
+ o && !u && !d && !a ? /* @__PURE__ */ m("div", { className: "absolute inset-0 m-auto w-8 h-8 rounded-full bg-primary" }) : null,
159
+ c && !o && !u && !d && !f ? /* @__PURE__ */ m("div", { className: "absolute inset-0 m-auto w-8 h-8 rounded-full border border-primary" }) : null,
160
+ /* @__PURE__ */ m("span", {
161
+ className: p,
162
+ children: i
163
+ })
164
+ ]
165
+ }, i));
166
+ }
167
+ return s;
168
+ }, se = (e) => {
169
+ T || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), G((e) => !e));
170
+ }, Q = z ? r(z) : null;
171
+ return /* @__PURE__ */ h("div", {
172
+ className: `relative ${E}`,
173
+ ref: U,
174
+ children: [
175
+ /* @__PURE__ */ m("div", {
176
+ onClick: () => !T && G((e) => !e),
177
+ onKeyDown: se,
178
+ tabIndex: T ? -1 : 0,
179
+ role: "button",
180
+ "aria-expanded": F,
181
+ "aria-haspopup": "dialog",
182
+ "aria-label": S,
183
+ className: `flex-1 text-sm sm:text-sm font-bold cursor-pointer text-left ${D} ${T ? "cursor-not-allowed opacity-50" : ""} ${Q ? "text-secondary" : "text-secondary/50"}`,
184
+ children: Q ?? S
185
+ }),
186
+ V ? /* @__PURE__ */ m("p", {
187
+ className: "text-red-500 text-xs mt-1",
188
+ children: V
189
+ }) : null,
190
+ F ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("div", {
191
+ className: "fixed inset-0 bg-black/50 z-50 sm:hidden",
192
+ onClick: () => G(!1),
193
+ "aria-hidden": !0
194
+ }), /* @__PURE__ */ h("div", {
195
+ className: [
196
+ "z-50 bg-white border border-gray-200 shadow-lg p-4 sm:p-4",
197
+ "fixed left-0 right-0 bottom-0 rounded-t-xl rounded-br-none rounded-bl-none max-h-[80vh] overflow-y-auto",
198
+ "sm:absolute sm:inset-x-auto sm:bottom-auto sm:max-h-none sm:overflow-visible sm:rounded-lg sm:min-w-[280px] sm:max-w-[320px]",
199
+ te ? "sm:right-0 sm:left-auto" : "sm:left-0 sm:right-auto",
200
+ W ? "sm:bottom-full sm:mb-2" : "sm:top-full sm:mt-2"
201
+ ].join(" "),
202
+ role: "dialog",
203
+ "aria-label": "Choose date",
204
+ onMouseDown: (e) => e.stopPropagation(),
205
+ children: [
206
+ /* @__PURE__ */ h("div", {
207
+ className: "flex items-center justify-between mb-4 sm:hidden",
208
+ children: [/* @__PURE__ */ m("h3", {
209
+ className: "text-lg font-semibold text-secondary",
210
+ children: "Select Date"
211
+ }), /* @__PURE__ */ m("button", {
212
+ type: "button",
213
+ onClick: () => G(!1),
214
+ className: "p-1 hover:bg-gray-100 rounded-full text-secondary",
215
+ "aria-label": "Close",
216
+ children: /* @__PURE__ */ m(_, { className: "w-5 h-5" })
217
+ })]
218
+ }),
219
+ /* @__PURE__ */ h("div", {
220
+ className: "flex items-center justify-between gap-2 mb-4 min-h-10",
221
+ children: [
222
+ /* @__PURE__ */ h("div", {
223
+ className: "flex items-center gap-3 shrink-0",
224
+ children: [/* @__PURE__ */ m("button", {
225
+ type: "button",
226
+ onClick: (e) => {
227
+ e.stopPropagation(), oe(-1);
228
+ },
229
+ className: "min-w-9 min-h-9 flex items-center justify-center p-1.5 hover:bg-gray-100 text-xl rounded text-secondary leading-none",
230
+ "aria-label": "Previous year",
231
+ children: "‹‹"
232
+ }), /* @__PURE__ */ m("button", {
233
+ type: "button",
234
+ onClick: (e) => {
235
+ e.stopPropagation(), ae(-1);
236
+ },
237
+ className: "min-w-9 min-h-9 flex items-center justify-center p-1.5 hover:bg-gray-100 text-xl rounded text-secondary leading-none",
238
+ "aria-label": "Previous month",
239
+ children: "‹"
240
+ })]
241
+ }),
242
+ /* @__PURE__ */ h("div", {
243
+ className: "font-semibold text-secondary text-sm sm:text-base px-2 text-center shrink min-w-0",
244
+ children: [
245
+ e[L.getMonth()],
246
+ " ",
247
+ L.getFullYear()
248
+ ]
249
+ }),
250
+ /* @__PURE__ */ h("div", {
251
+ className: "flex items-center gap-3 shrink-0",
252
+ children: [/* @__PURE__ */ m("button", {
253
+ type: "button",
254
+ onClick: (e) => {
255
+ e.stopPropagation(), ae(1);
256
+ },
257
+ className: "min-w-9 min-h-9 flex items-center justify-center p-1.5 hover:bg-gray-100 text-xl rounded text-secondary leading-none",
258
+ "aria-label": "Next month",
259
+ children: "›"
260
+ }), /* @__PURE__ */ m("button", {
261
+ type: "button",
262
+ onClick: (e) => {
263
+ e.stopPropagation(), oe(1);
264
+ },
265
+ className: "min-w-9 min-h-9 flex items-center justify-center p-1.5 hover:bg-gray-100 text-xl rounded text-secondary leading-none",
266
+ "aria-label": "Next year",
267
+ children: "››"
268
+ })]
269
+ })
270
+ ]
271
+ }),
272
+ /* @__PURE__ */ m("div", {
273
+ className: "grid grid-cols-7 gap-0 mb-2",
274
+ children: t.map((e) => /* @__PURE__ */ m("div", {
275
+ className: "text-xs text-secondary text-[14px] text-center font-semibold p-1",
276
+ children: e
277
+ }, e))
278
+ }),
279
+ /* @__PURE__ */ m("div", {
280
+ className: "grid grid-cols-7 gap-0",
281
+ children: Z()
282
+ })
283
+ ]
284
+ })] }) : null
285
+ ]
286
+ });
287
+ });
288
+ function C(e) {
289
+ let t = f(50), n, i, a, o, s, l, u, d, p, _, v, y;
290
+ t[0] === e ? (n = t[1], i = t[2], a = t[3], o = t[4], s = t[5], l = t[6], u = t[7], d = t[8], p = t[9], _ = t[10], v = t[11], y = t[12]) : ({label: s, name: n, value: l, onChange: a, onBlur: i, error: u, description: d, helperText: p, required: _, disabled: v, className: y, ...o} = e, t[0] = e, t[1] = n, t[2] = i, t[3] = a, t[4] = o, t[5] = s, t[6] = l, t[7] = u, t[8] = d, t[9] = p, t[10] = _, t[11] = v, t[12] = y);
291
+ let b = s === void 0 ? "" : s, x = l === void 0 ? "" : l, S = u === void 0 ? "" : u, C = d === void 0 ? "" : d, w = p === void 0 ? "" : p, T = _ === void 0 ? !1 : _, E = v === void 0 ? !1 : v, D = y === void 0 ? "" : y, [O, k] = g.useState(!1), A = O || !!x, j;
292
+ if (t[13] !== x) {
293
+ let e = x ? c(x) : null;
294
+ j = e ? r(e) : x, t[13] = x, t[14] = j;
295
+ } else j = t[14];
296
+ let M = j, N = `relative ${D}`, P = `flex items-center border sm:h-[48px] h-[42px] rounded-md transition-all bg-white ${S ? "border-red-500" : O ? "border border-primary" : "border border-primary/50"} ${E ? "bg-white cursor-not-allowed opacity-75" : "cursor-pointer"}`, F;
297
+ t[15] === E ? F = t[16] : (F = () => !E && k(!0), t[15] = E, t[16] = F);
298
+ let I;
299
+ t[17] !== E || t[18] !== M || t[19] !== O || t[20] !== n || t[21] !== i || t[22] !== a || t[23] !== o || t[24] !== x ? (I = O ? /* @__PURE__ */ m("input", {
300
+ id: n,
301
+ name: n,
302
+ type: "date",
303
+ value: x,
304
+ onChange: a,
305
+ onBlur: (e) => {
306
+ k(!1), i?.(e);
307
+ },
308
+ disabled: E,
309
+ autoFocus: !0,
310
+ className: "peer w-full h-full min-h-[42px] sm:min-h-[48px] px-3 py-2 text-base bg-transparent outline-none",
311
+ ...o
312
+ }) : /* @__PURE__ */ m("div", {
313
+ className: "w-full px-3 flex items-center text-base text-secondary min-h-[42px] sm:min-h-[48px]",
314
+ children: x ? /* @__PURE__ */ m("span", {
315
+ className: "text-secondary",
316
+ children: M
317
+ }) : /* @__PURE__ */ m("span", {
318
+ className: "text-transparent select-none",
319
+ "aria-hidden": !0,
320
+ children: "."
321
+ })
322
+ }), t[17] = E, t[18] = M, t[19] = O, t[20] = n, t[21] = i, t[22] = a, t[23] = o, t[24] = x, t[25] = I) : I = t[25];
323
+ let L;
324
+ t[26] !== P || t[27] !== F || t[28] !== I ? (L = /* @__PURE__ */ m("div", {
325
+ className: P,
326
+ onClick: F,
327
+ children: I
328
+ }), t[26] = P, t[27] = F, t[28] = I, t[29] = L) : L = t[29];
329
+ let R = `absolute left-2 px-1 transition-all duration-300 ease-in-out bg-white sm:text-base text-sm pointer-events-none z-[1]
330
+ ${A ? "-top-2.5 text-sm! text-secondary bg-white font-bold" : "top-1/2 -translate-y-1/2 text-secondary/50"}
331
+ ${S ? "text-red-500!" : ""}
332
+ `, z;
333
+ t[30] === T ? z = t[31] : (z = T ? /* @__PURE__ */ m("span", {
334
+ className: "text-red-500 ml-0.5",
335
+ children: "*"
336
+ }) : null, t[30] = T, t[31] = z);
337
+ let B;
338
+ t[32] !== b || t[33] !== n || t[34] !== R || t[35] !== z ? (B = /* @__PURE__ */ h("label", {
339
+ htmlFor: n,
340
+ className: R,
341
+ children: [b, z]
342
+ }), t[32] = b, t[33] = n, t[34] = R, t[35] = z, t[36] = B) : B = t[36];
343
+ let V;
344
+ t[37] !== L || t[38] !== B ? (V = /* @__PURE__ */ h("div", {
345
+ className: "relative",
346
+ children: [L, B]
347
+ }), t[37] = L, t[38] = B, t[39] = V) : V = t[39];
348
+ let H;
349
+ t[40] === C ? H = t[41] : (H = C ? /* @__PURE__ */ m("div", {
350
+ className: "mt-1 sm:text-base text-sm text-secondary/60",
351
+ children: C
352
+ }) : null, t[40] = C, t[41] = H);
353
+ let U;
354
+ t[42] !== S || t[43] !== w ? (U = (S || w) && /* @__PURE__ */ m("p", {
355
+ className: `mt-1 text-xs ${S ? "text-red-500" : "text-secondary/50"}`,
356
+ children: S || w
357
+ }), t[42] = S, t[43] = w, t[44] = U) : U = t[44];
358
+ let W;
359
+ return t[45] !== N || t[46] !== V || t[47] !== H || t[48] !== U ? (W = /* @__PURE__ */ h("div", {
360
+ className: N,
361
+ children: [
362
+ V,
363
+ H,
364
+ U
365
+ ]
366
+ }), t[45] = N, t[46] = V, t[47] = H, t[48] = U, t[49] = W) : W = t[49], W;
367
+ }
368
+ var w = g.forwardRef(function(e, t) {
369
+ let n = f(37), { placeholder: r, value: i, onChange: a, error: o, inputProps: s, label: c, labelClassName: l, description: u, descriptionClassName: d, leftComponent: p, rightComponent: g, className: _, containerClassName: v, errorClassName: b, min: x, max: S, step: C, disabled: w } = e, T = r === void 0 ? "Select date" : r, E;
370
+ n[0] === s ? E = n[1] : (E = s === void 0 ? {} : s, n[0] = s, n[1] = E);
371
+ let D = E, O = l === void 0 ? "" : l, k = d === void 0 ? "" : d, A = _ === void 0 ? "" : _, j = v === void 0 ? "" : v, M = b === void 0 ? "" : b, N = w === void 0 ? !1 : w, P;
372
+ n[2] !== c || n[3] !== O ? (P = c ? /* @__PURE__ */ m("label", {
373
+ className: `block text-sm sm:text-lg font-bold text-secondary mb-1 ${O}`,
374
+ children: c
375
+ }) : null, n[2] = c, n[3] = O, n[4] = P) : P = n[4];
376
+ let F;
377
+ n[5] !== u || n[6] !== k ? (F = u ? /* @__PURE__ */ m("div", {
378
+ className: `block text-xs sm:text-base text-secondary/50 mb-2 ${k}`,
379
+ children: u
380
+ }) : null, n[5] = u, n[6] = k, n[7] = F) : F = n[7];
381
+ let I = "flex items-center rounded-medium sm:rounded-primary md:rounded-medium lg:rounded-primary bg-white outline -outline-offset-1 outline-primary/50 has-[input:focus-within]:outline-1 has-[input:focus-within]:outline-offset-1 has-[input:focus-within]:outline-primary text-sm sm:text-base " + (N ? "opacity-50 " : "") + j, L;
382
+ n[8] === a ? L = n[9] : (L = (e) => a?.(e.currentTarget.value), n[8] = a, n[9] = L);
383
+ let R = "block min-w-0 grow sm:py-2.5 py-1.5 pr-3 pl-3 focus:outline-none text-[16px] sm:text-[14px] " + A, z;
384
+ n[10] !== N || n[11] !== D || n[12] !== S || n[13] !== x || n[14] !== T || n[15] !== t || n[16] !== C || n[17] !== L || n[18] !== R || n[19] !== i ? (z = /* @__PURE__ */ m("input", {
385
+ ref: t,
386
+ type: "date",
387
+ placeholder: T,
388
+ value: i,
389
+ onChange: L,
390
+ min: x,
391
+ max: S,
392
+ step: C,
393
+ disabled: N,
394
+ className: R,
395
+ ...D
396
+ }), n[10] = N, n[11] = D, n[12] = S, n[13] = x, n[14] = T, n[15] = t, n[16] = C, n[17] = L, n[18] = R, n[19] = i, n[20] = z) : z = n[20];
397
+ let B;
398
+ n[21] !== o || n[22] !== g ? (B = o ? /* @__PURE__ */ m(y, {}) : g, n[21] = o, n[22] = g, n[23] = B) : B = n[23];
399
+ let V;
400
+ n[24] !== p || n[25] !== I || n[26] !== z || n[27] !== B ? (V = /* @__PURE__ */ h("div", {
401
+ className: I,
402
+ children: [
403
+ p,
404
+ z,
405
+ B
406
+ ]
407
+ }), n[24] = p, n[25] = I, n[26] = z, n[27] = B, n[28] = V) : V = n[28];
408
+ let H;
409
+ n[29] !== o || n[30] !== M ? (H = o ? /* @__PURE__ */ m("div", {
410
+ className: "text-2xs font-semibold text-red-500 mt-0.75 pl-3 " + M,
411
+ children: o
412
+ }) : null, n[29] = o, n[30] = M, n[31] = H) : H = n[31];
413
+ let U;
414
+ return n[32] !== P || n[33] !== F || n[34] !== V || n[35] !== H ? (U = /* @__PURE__ */ h("div", {
415
+ className: "w-full",
416
+ children: [
417
+ P,
418
+ F,
419
+ V,
420
+ H
421
+ ]
422
+ }), n[32] = P, n[33] = F, n[34] = V, n[35] = H, n[36] = U) : U = n[36], U;
423
+ });
424
+ function T(e) {
425
+ let t = f(42), { day: n, disabled: r, onClick: i, singleDay: a, rangeStart: o, rangeEnd: s, inRangeMiddle: c, displayInRange: u, displayStart: g, displayEnd: _ } = e, v;
426
+ t[0] === n ? v = t[1] : (v = l(n, /* @__PURE__ */ new Date()), t[0] = n, t[1] = v);
427
+ let y = v, b = y && !a && !o && !s && !c && !u, x = r ? "text-gray-400" : a || o ? "font-semibold text-white" : s || c ? "font-semibold text-secondary" : g || _ ? "font-semibold text-white" : u ? "font-semibold text-secondary" : y ? "font-bold text-primary" : "text-secondary", S = `relative w-full h-9 flex items-center justify-center ${r ? "cursor-not-allowed opacity-40" : "cursor-pointer"}`, C;
428
+ t[2] !== r || t[3] !== i ? (C = () => !r && i(), t[2] = r, t[3] = i, t[4] = C) : C = t[4];
429
+ let w;
430
+ t[5] === n ? w = t[6] : (w = d(n), t[5] = n, t[6] = w);
431
+ let T;
432
+ t[7] !== r || t[8] !== a ? (T = a && !r ? /* @__PURE__ */ m("span", { className: "absolute h-8 w-8 rounded-full bg-primary" }) : null, t[7] = r, t[8] = a, t[9] = T) : T = t[9];
433
+ let E;
434
+ t[10] !== r || t[11] !== o ? (E = o && !r ? /* @__PURE__ */ m("span", { className: "absolute inset-y-0 left-0 right-0 bg-primary rounded-l-md" }) : null, t[10] = r, t[11] = o, t[12] = E) : E = t[12];
435
+ let D;
436
+ t[13] !== r || t[14] !== c ? (D = c && !r ? /* @__PURE__ */ m("span", { className: "absolute inset-y-0 left-0 right-0 bg-primary/20" }) : null, t[13] = r, t[14] = c, t[15] = D) : D = t[15];
437
+ let O;
438
+ t[16] !== r || t[17] !== s ? (O = s && !r ? /* @__PURE__ */ m("span", { className: "absolute inset-y-0 left-0 right-0 bg-primary/20 rounded-r-md" }) : null, t[16] = r, t[17] = s, t[18] = O) : O = t[18];
439
+ let k;
440
+ t[19] !== _ || t[20] !== u || t[21] !== g || t[22] !== a ? (k = g && _ && u && !a ? /* @__PURE__ */ m("span", { className: "absolute inset-0 rounded-md border border-primary/40 bg-primary/5" }) : /* @__PURE__ */ h(p, { children: [
441
+ g ? /* @__PURE__ */ m("span", { className: "absolute inset-y-0 left-0 right-0 rounded-l-md border border-primary/30 bg-primary/10 border-r-0" }) : null,
442
+ _ ? /* @__PURE__ */ m("span", { className: "absolute inset-y-0 left-0 right-0 rounded-r-md border border-primary/30 bg-primary/10 border-l-0" }) : null,
443
+ u && !g && !_ ? /* @__PURE__ */ m("span", { className: "absolute inset-y-0 left-0 right-0 bg-primary/10 border-y border-primary/20" }) : null
444
+ ] }), t[19] = _, t[20] = u, t[21] = g, t[22] = a, t[23] = k) : k = t[23];
445
+ let A;
446
+ t[24] === b ? A = t[25] : (A = b ? /* @__PURE__ */ m("span", { className: "absolute inset-0 m-auto h-8 w-8 rounded-full border border-primary pointer-events-none" }) : null, t[24] = b, t[25] = A);
447
+ let j = `relative z-10 text-sm ${x}`, M;
448
+ t[26] === n ? M = t[27] : (M = n.getDate(), t[26] = n, t[27] = M);
449
+ let N;
450
+ t[28] !== j || t[29] !== M ? (N = /* @__PURE__ */ m("span", {
451
+ className: j,
452
+ children: M
453
+ }), t[28] = j, t[29] = M, t[30] = N) : N = t[30];
454
+ let P;
455
+ return t[31] !== A || t[32] !== N || t[33] !== S || t[34] !== C || t[35] !== w || t[36] !== T || t[37] !== E || t[38] !== D || t[39] !== O || t[40] !== k ? (P = /* @__PURE__ */ h("div", {
456
+ className: S,
457
+ onClick: C,
458
+ title: w,
459
+ children: [
460
+ T,
461
+ E,
462
+ D,
463
+ O,
464
+ k,
465
+ A,
466
+ N
467
+ ]
468
+ }), t[31] = A, t[32] = N, t[33] = S, t[34] = C, t[35] = w, t[36] = T, t[37] = E, t[38] = D, t[39] = O, t[40] = k, t[41] = P) : P = t[41], P;
469
+ }
470
+ function E(r) {
471
+ let p = f(58), { value: _, onChange: y, onMonthChange: b, minDate: x, maxDate: S, disablePast: C, displayRanges: w, cursorMonth: E, className: k } = r, A = _ === void 0 ? null : _, j = C === void 0 ? !0 : C, M;
472
+ p[0] === w ? M = p[1] : (M = w === void 0 ? [] : w, p[0] = w, p[1] = M);
473
+ let N = M, P = k === void 0 ? "" : k, F;
474
+ if (p[2] !== E) {
475
+ let e = u(E ? new Date(E) : /* @__PURE__ */ new Date());
476
+ F = new Date(e.getFullYear(), e.getMonth(), 1), p[2] = E, p[3] = F;
477
+ } else F = p[3];
478
+ let I = F, L;
479
+ p[4] === A ? L = p[5] : (L = () => A ? {
480
+ start: c(A.startDate) ?? /* @__PURE__ */ new Date(),
481
+ end: c(A.endDate) ?? /* @__PURE__ */ new Date()
482
+ } : null, p[4] = A, p[5] = L);
483
+ let [R, z] = g.useState(L), [B, V] = g.useState(I), [H, U] = g.useState(null), W, ee;
484
+ p[6] === E ? (W = p[7], ee = p[8]) : (W = () => {
485
+ if (E) {
486
+ let e = E;
487
+ V(new Date(e.getFullYear(), e.getMonth(), 1));
488
+ }
489
+ }, ee = [E], p[6] = E, p[7] = W, p[8] = ee), g.useEffect(W, ee);
490
+ let te, ne;
491
+ p[9] === A ? (te = p[10], ne = p[11]) : (te = () => {
492
+ if (!A) {
493
+ z(null);
494
+ return;
495
+ }
496
+ let e = c(A.startDate), t = c(A.endDate);
497
+ e && t && z({
498
+ start: e,
499
+ end: t
500
+ });
501
+ }, ne = [A], p[9] = A, p[10] = te, p[11] = ne), g.useEffect(te, ne);
502
+ let G;
503
+ p[12] === y ? G = p[13] : (G = (e) => {
504
+ if (!e) {
505
+ y(null);
506
+ return;
507
+ }
508
+ y({
509
+ startDate: d(e.start),
510
+ endDate: d(e.end)
511
+ });
512
+ }, p[12] = y, p[13] = G);
513
+ let K = G, q;
514
+ p[14] !== j || p[15] !== S || p[16] !== x ? (q = (e) => {
515
+ let t = u(e);
516
+ if (j) {
517
+ let e = u(/* @__PURE__ */ new Date());
518
+ if (t.getTime() < e.getTime()) return !0;
519
+ }
520
+ let n = s(x), r = s(S);
521
+ return !!(n && t.getTime() < n.getTime() || r && t.getTime() > r.getTime());
522
+ }, p[14] = j, p[15] = S, p[16] = x, p[17] = q) : q = p[17];
523
+ let J = q, re;
524
+ p[18] !== K || p[19] !== J || p[20] !== R || p[21] !== H ? (re = (e) => {
525
+ if (!J(e)) {
526
+ if (!R || R.start && R.end && !H) {
527
+ U(e);
528
+ let t = u(e), n = {
529
+ start: t,
530
+ end: t
531
+ };
532
+ z(n), K(n);
533
+ return;
534
+ }
535
+ if (H) {
536
+ let t = u(H), r = u(e);
537
+ n(r, t) < 0 && ([t, r] = [r, t]);
538
+ let i = {
539
+ start: t,
540
+ end: r
541
+ };
542
+ z(i), U(null), K(i);
543
+ }
544
+ }
545
+ }, p[18] = K, p[19] = J, p[20] = R, p[21] = H, p[22] = re) : re = p[22];
546
+ let ie = re, ae;
547
+ p[23] === Symbol.for("react.memo_cache_sentinel") ? (ae = (e) => {
548
+ V((t) => new Date(t.getFullYear(), t.getMonth() + e, 1));
549
+ }, p[23] = ae) : ae = p[23];
550
+ let oe = ae, Y, X;
551
+ p[24] !== B || p[25] !== b ? (Y = () => {
552
+ b?.(B);
553
+ }, X = [B, b], p[24] = B, p[25] = b, p[26] = Y, p[27] = X) : (Y = p[26], X = p[27]), g.useEffect(Y, X);
554
+ let Z, se, Q, ce, le, $, ue;
555
+ if (p[28] !== P || p[29] !== B || p[30] !== N || p[31] !== ie || p[32] !== J || p[33] !== R) {
556
+ let r = B.getFullYear(), s = B.getMonth(), u = i(r, s), f = a(r, s), g = [];
557
+ for (let e = 1; e <= u; e++) g.push(new Date(r, s, e));
558
+ ue = `p-2 sm:p-4 w-full sm:max-w-fit flex justify-center sm:justify-start sm:gap-4 ${P}`, ce = "w-full sm:w-auto";
559
+ let _;
560
+ p[41] === Symbol.for("react.memo_cache_sentinel") ? (_ = () => oe(-1), p[41] = _) : _ = p[41];
561
+ let y;
562
+ p[42] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ m("button", {
563
+ type: "button",
564
+ onClick: _,
565
+ className: "p-1.5 sm:p-1 hover:bg-primary/20 bg-primary/10 rounded-full w-8 h-8 flex items-center justify-center cursor-pointer text-primary",
566
+ "aria-label": "Previous month",
567
+ children: /* @__PURE__ */ m(v, { dir: "left" })
568
+ }), p[42] = y) : y = p[42];
569
+ let b;
570
+ p[43] === Symbol.for("react.memo_cache_sentinel") ? (b = () => oe(1), p[43] = b) : b = p[43];
571
+ let x;
572
+ p[44] === Symbol.for("react.memo_cache_sentinel") ? (x = /* @__PURE__ */ m("button", {
573
+ type: "button",
574
+ onClick: b,
575
+ className: "p-1.5 sm:p-1 hover:bg-primary/20 bg-primary/10 rounded-full w-8 h-8 flex items-center justify-center cursor-pointer text-primary",
576
+ "aria-label": "Next month",
577
+ children: /* @__PURE__ */ m(v, { dir: "right" })
578
+ }), p[44] = x) : x = p[44], le = /* @__PURE__ */ h("div", {
579
+ className: "flex items-center justify-between mb-4",
580
+ children: [
581
+ y,
582
+ /* @__PURE__ */ h("div", {
583
+ className: "font-bold text-secondary text-sm sm:text-base px-2",
584
+ children: [
585
+ e[s],
586
+ " ",
587
+ r
588
+ ]
589
+ }),
590
+ x
591
+ ]
592
+ }), p[45] === Symbol.for("react.memo_cache_sentinel") ? ($ = /* @__PURE__ */ m("div", {
593
+ className: "grid grid-cols-7 text-xs text-center mb-2",
594
+ children: t.map(O)
595
+ }), p[45] = $) : $ = p[45], Z = "grid grid-cols-7 gap-y-1 w-full sm:min-w-[21rem]", se = Array.from({ length: f }).map(D), Q = g.map((e) => {
596
+ let t = J(e), r = !1, i = !1, a = !1, s = !1;
597
+ if (R) {
598
+ let t = n(R.start, R.end) !== 0, o = l(e, R.start), c = l(e, R.end);
599
+ r = !t && o && c, i = t && o && !c, a = t && c && !o, s = t && n(e, R.start) > 0 && n(e, R.end) < 0;
600
+ }
601
+ let u = !1, f = !1, p = !1;
602
+ for (let t of N) {
603
+ let n = c(t.startDate), r = c(t.endDate);
604
+ n && r && (o(e, n, r) && (u = !0), l(e, n) && (f = !0), l(e, r) && (p = !0));
605
+ }
606
+ return /* @__PURE__ */ m(T, {
607
+ day: e,
608
+ singleDay: r,
609
+ rangeStart: i,
610
+ rangeEnd: a,
611
+ inRangeMiddle: s,
612
+ displayInRange: u,
613
+ displayStart: f,
614
+ displayEnd: p,
615
+ disabled: t,
616
+ onClick: () => ie(e)
617
+ }, d(e));
618
+ }), p[28] = P, p[29] = B, p[30] = N, p[31] = ie, p[32] = J, p[33] = R, p[34] = Z, p[35] = se, p[36] = Q, p[37] = ce, p[38] = le, p[39] = $, p[40] = ue;
619
+ } else Z = p[34], se = p[35], Q = p[36], ce = p[37], le = p[38], $ = p[39], ue = p[40];
620
+ let de;
621
+ p[46] !== Z || p[47] !== se || p[48] !== Q ? (de = /* @__PURE__ */ h("div", {
622
+ className: Z,
623
+ children: [se, Q]
624
+ }), p[46] = Z, p[47] = se, p[48] = Q, p[49] = de) : de = p[49];
625
+ let fe;
626
+ p[50] !== ce || p[51] !== le || p[52] !== $ || p[53] !== de ? (fe = /* @__PURE__ */ h("div", {
627
+ className: ce,
628
+ children: [
629
+ le,
630
+ $,
631
+ de
632
+ ]
633
+ }), p[50] = ce, p[51] = le, p[52] = $, p[53] = de, p[54] = fe) : fe = p[54];
634
+ let pe;
635
+ return p[55] !== ue || p[56] !== fe ? (pe = /* @__PURE__ */ m("div", {
636
+ className: ue,
637
+ children: fe
638
+ }), p[55] = ue, p[56] = fe, p[57] = pe) : pe = p[57], pe;
639
+ }
640
+ function D(e, t) {
641
+ return /* @__PURE__ */ m("div", {}, `p-${t}`);
642
+ }
643
+ function O(e) {
644
+ return /* @__PURE__ */ m("div", {
645
+ className: "text-black font-bold",
646
+ children: e
647
+ }, e);
648
+ }
649
+ //#endregion
650
+ export { S as DatePicker, C as DatePickerFloatingInput, w as DatePickerStacked, E as DateRangePicker };