asterui 0.12.64 → 0.12.65
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.
|
@@ -5,6 +5,7 @@ export interface DatePickerProps extends Omit<React.HTMLAttributes<HTMLDivElemen
|
|
|
5
5
|
onChange?: (date: Date | null) => void;
|
|
6
6
|
format?: string;
|
|
7
7
|
placeholder?: string;
|
|
8
|
+
disabledDate?: (date: Date) => boolean;
|
|
8
9
|
disabled?: boolean;
|
|
9
10
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
11
|
/** Test ID prefix for child elements */
|
|
@@ -17,6 +18,7 @@ export interface DateRangePickerProps extends Omit<React.HTMLAttributes<HTMLDivE
|
|
|
17
18
|
onChange?: (range: DateRangeValue) => void;
|
|
18
19
|
format?: string;
|
|
19
20
|
placeholder?: [string, string] | string;
|
|
21
|
+
disabledDate?: (date: Date) => boolean;
|
|
20
22
|
disabled?: boolean;
|
|
21
23
|
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
22
24
|
/** Test ID prefix for child elements */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Input as
|
|
4
|
-
import { useConfig as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as F, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import we, { forwardRef as be, useState as Y, useRef as ee, useEffect as O } from "react";
|
|
3
|
+
import { Input as ve } from "./Input.js";
|
|
4
|
+
import { useConfig as ye } from "../providers/ConfigProvider.js";
|
|
5
|
+
const z = "btn", L = "btn-ghost", I = "btn-sm", te = "btn-square", Me = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], $e = [
|
|
6
6
|
"January",
|
|
7
7
|
"February",
|
|
8
8
|
"March",
|
|
@@ -16,354 +16,497 @@ const x = "btn", Y = "btn-ghost", S = "btn-sm", I = "btn-square", se = ["Su", "M
|
|
|
16
16
|
"November",
|
|
17
17
|
"December"
|
|
18
18
|
];
|
|
19
|
-
function
|
|
20
|
-
if (!
|
|
21
|
-
const
|
|
22
|
-
return
|
|
19
|
+
function Z(o, a = "MM/DD/YYYY") {
|
|
20
|
+
if (!o) return "";
|
|
21
|
+
const h = o.getFullYear(), x = String(o.getMonth() + 1).padStart(2, "0"), B = String(o.getDate()).padStart(2, "0");
|
|
22
|
+
return a.replace("YYYY", String(h)).replace("MM", x).replace("DD", B);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return new Date(
|
|
24
|
+
function ne(o, a) {
|
|
25
|
+
return new Date(o, a + 1, 0).getDate();
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return new Date(
|
|
27
|
+
function xe(o, a) {
|
|
28
|
+
return new Date(o, a, 1).getDay();
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
return new Date(
|
|
30
|
+
function re(o) {
|
|
31
|
+
return new Date(o.getFullYear(), o.getMonth(), o.getDate());
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function _(o, a) {
|
|
34
|
+
return o.getFullYear() === a.getFullYear() && o.getMonth() === a.getMonth() && o.getDate() === a.getDate();
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function De(o, a) {
|
|
37
|
+
return re(o).getTime() < re(a).getTime();
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function Ye(o, a) {
|
|
40
|
+
return re(o).getTime() > re(a).getTime();
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
return
|
|
42
|
+
function ae(o, a) {
|
|
43
|
+
const h = new Date(o);
|
|
44
|
+
return h.setDate(h.getDate() + a), h;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
46
|
+
function Se(o, a = "MM/DD/YYYY") {
|
|
47
|
+
const [h, x] = o;
|
|
48
|
+
return h && x ? `${Z(h, a)} - ${Z(x, a)}` : h ? `${Z(h, a)} - ` : "";
|
|
49
|
+
}
|
|
50
|
+
const ke = be(function({
|
|
51
|
+
value: a,
|
|
52
|
+
defaultValue: h,
|
|
53
|
+
onChange: x,
|
|
54
|
+
format: B,
|
|
55
|
+
placeholder: R,
|
|
56
|
+
disabledDate: d,
|
|
57
|
+
disabled: v = !1,
|
|
58
|
+
size: oe,
|
|
59
|
+
"data-testid": T,
|
|
60
|
+
className: se = "",
|
|
61
|
+
...le
|
|
62
|
+
}, ce) {
|
|
63
|
+
const { componentSize: ie, locale: j } = ye(), ue = oe ?? ie ?? "md", U = R ?? j?.DatePicker?.placeholder ?? "Select date", G = j?.DatePicker?.today ?? "Today", q = /* @__PURE__ */ new Date(), de = v || d?.(q), W = (e) => T ? `${T}-${e}` : void 0, [p, K] = Y(
|
|
64
|
+
a || h || null
|
|
65
|
+
), [y, m] = Y(!1), [i, M] = Y(null), [u, c] = Y(
|
|
66
|
+
p ? p.getMonth() : (/* @__PURE__ */ new Date()).getMonth()
|
|
67
|
+
), [D, P] = Y(
|
|
68
|
+
p ? p.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear()
|
|
69
|
+
), f = ee(null), k = ee(null), w = we.useId();
|
|
70
|
+
O(() => {
|
|
71
|
+
a !== void 0 && K(a);
|
|
72
|
+
}, [a]), O(() => {
|
|
73
|
+
function e(n) {
|
|
74
|
+
f.current && !f.current.contains(n.target) && m(!1);
|
|
75
|
+
}
|
|
76
|
+
if (y)
|
|
77
|
+
return document.addEventListener("mousedown", e), M(p ?? q), () => document.removeEventListener("mousedown", e);
|
|
78
|
+
}, [y]), O(() => {
|
|
79
|
+
if (!y || !k.current) return;
|
|
80
|
+
k.current.querySelector('[data-calendar-focus="true"]')?.focus();
|
|
81
|
+
}, [y, u, D, i]);
|
|
82
|
+
const A = (e) => {
|
|
83
|
+
const n = new Date(D, u, e);
|
|
84
|
+
v || d?.(n) || (K(n), x?.(n), m(!1));
|
|
85
|
+
}, N = (e, n) => {
|
|
86
|
+
let $ = ae(e, n);
|
|
87
|
+
for (let b = 0; b < 31; b++) {
|
|
88
|
+
if (!d?.($)) return $;
|
|
89
|
+
$ = ae($, n);
|
|
70
90
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
return e;
|
|
92
|
+
}, V = (e) => {
|
|
93
|
+
if (!i) return;
|
|
94
|
+
let n = i;
|
|
95
|
+
switch (e.key) {
|
|
96
|
+
case "ArrowRight":
|
|
97
|
+
e.preventDefault(), n = N(i, 1);
|
|
98
|
+
break;
|
|
99
|
+
case "ArrowLeft":
|
|
100
|
+
e.preventDefault(), n = N(i, -1);
|
|
101
|
+
break;
|
|
102
|
+
case "ArrowDown":
|
|
103
|
+
e.preventDefault(), n = N(i, 7);
|
|
104
|
+
break;
|
|
105
|
+
case "ArrowUp":
|
|
106
|
+
e.preventDefault(), n = N(i, -7);
|
|
107
|
+
break;
|
|
108
|
+
case "Home":
|
|
109
|
+
e.preventDefault(), n = new Date(i.getFullYear(), i.getMonth(), 1), d?.(n) && (n = N(n, 1));
|
|
110
|
+
break;
|
|
111
|
+
case "End":
|
|
112
|
+
e.preventDefault(), n = new Date(i.getFullYear(), i.getMonth(), ne(i.getFullYear(), i.getMonth())), d?.(n) && (n = N(n, -1));
|
|
113
|
+
break;
|
|
114
|
+
case "Enter":
|
|
115
|
+
case " ":
|
|
116
|
+
e.preventDefault(), A(i.getDate());
|
|
117
|
+
return;
|
|
118
|
+
case "Escape":
|
|
119
|
+
e.preventDefault(), m(!1);
|
|
120
|
+
return;
|
|
121
|
+
default:
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
M(n), c(n.getMonth()), P(n.getFullYear());
|
|
125
|
+
}, Q = () => {
|
|
126
|
+
u === 0 ? (c(11), P(D - 1)) : c(u - 1);
|
|
127
|
+
}, X = () => {
|
|
128
|
+
u === 11 ? (c(0), P(D + 1)) : c(u + 1);
|
|
129
|
+
}, S = ne(D, u), fe = xe(D, u), H = [];
|
|
130
|
+
for (let e = 0; e < fe; e++)
|
|
131
|
+
H.push(null);
|
|
132
|
+
for (let e = 1; e <= S; e++)
|
|
133
|
+
H.push(e);
|
|
134
|
+
const J = (e) => !e || !p ? !1 : p.getDate() === e && p.getMonth() === u && p.getFullYear() === D, ge = (e) => {
|
|
87
135
|
if (!e) return !1;
|
|
88
|
-
const
|
|
89
|
-
return
|
|
136
|
+
const n = /* @__PURE__ */ new Date();
|
|
137
|
+
return n.getDate() === e && n.getMonth() === u && n.getFullYear() === D;
|
|
90
138
|
};
|
|
91
|
-
return /* @__PURE__ */
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
|
|
139
|
+
return /* @__PURE__ */ F("div", { ref: ce || f, className: `relative ${se}`, "data-state": y ? "open" : "closed", "data-testid": T, ...le, children: [
|
|
140
|
+
/* @__PURE__ */ l(
|
|
141
|
+
ve,
|
|
94
142
|
{
|
|
95
|
-
value:
|
|
96
|
-
placeholder:
|
|
97
|
-
disabled:
|
|
98
|
-
size:
|
|
143
|
+
value: Z(p, B),
|
|
144
|
+
placeholder: U,
|
|
145
|
+
disabled: v,
|
|
146
|
+
size: ue,
|
|
99
147
|
readOnly: !0,
|
|
100
|
-
onClick: () => !
|
|
148
|
+
onClick: () => !v && m(!y),
|
|
149
|
+
"aria-haspopup": "dialog",
|
|
150
|
+
"aria-expanded": y,
|
|
151
|
+
"aria-controls": w,
|
|
101
152
|
className: "cursor-pointer",
|
|
102
|
-
"data-testid":
|
|
153
|
+
"data-testid": W("input")
|
|
103
154
|
}
|
|
104
155
|
),
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
156
|
+
y && /* @__PURE__ */ F(
|
|
157
|
+
"div",
|
|
158
|
+
{
|
|
159
|
+
ref: k,
|
|
160
|
+
id: w,
|
|
161
|
+
role: "dialog",
|
|
162
|
+
"aria-label": "Date picker calendar",
|
|
163
|
+
className: "absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg p-4 z-50 w-80",
|
|
164
|
+
"data-testid": W("calendar"),
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ F("div", { className: "flex items-center justify-between mb-4", children: [
|
|
167
|
+
/* @__PURE__ */ l(
|
|
168
|
+
"button",
|
|
115
169
|
{
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"path",
|
|
170
|
+
type: "button",
|
|
171
|
+
onClick: Q,
|
|
172
|
+
className: `${z} ${L} ${I} ${te}`,
|
|
173
|
+
children: /* @__PURE__ */ l(
|
|
174
|
+
"svg",
|
|
122
175
|
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
176
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
177
|
+
className: "h-5 w-5",
|
|
178
|
+
viewBox: "0 0 20 20",
|
|
179
|
+
fill: "currentColor",
|
|
180
|
+
children: /* @__PURE__ */ l(
|
|
181
|
+
"path",
|
|
182
|
+
{
|
|
183
|
+
fillRule: "evenodd",
|
|
184
|
+
d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",
|
|
185
|
+
clipRule: "evenodd"
|
|
186
|
+
}
|
|
187
|
+
)
|
|
126
188
|
}
|
|
127
189
|
)
|
|
128
190
|
}
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
/* @__PURE__ */ s(
|
|
138
|
-
"button",
|
|
139
|
-
{
|
|
140
|
-
type: "button",
|
|
141
|
-
onClick: F,
|
|
142
|
-
className: `${x} ${Y} ${S} ${I}`,
|
|
143
|
-
children: /* @__PURE__ */ s(
|
|
144
|
-
"svg",
|
|
191
|
+
),
|
|
192
|
+
/* @__PURE__ */ F("div", { className: "text-base font-semibold", children: [
|
|
193
|
+
$e[u],
|
|
194
|
+
" ",
|
|
195
|
+
D
|
|
196
|
+
] }),
|
|
197
|
+
/* @__PURE__ */ l(
|
|
198
|
+
"button",
|
|
145
199
|
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
"path",
|
|
200
|
+
type: "button",
|
|
201
|
+
onClick: X,
|
|
202
|
+
className: `${z} ${L} ${I} ${te}`,
|
|
203
|
+
children: /* @__PURE__ */ l(
|
|
204
|
+
"svg",
|
|
152
205
|
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
206
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
207
|
+
className: "h-5 w-5",
|
|
208
|
+
viewBox: "0 0 20 20",
|
|
209
|
+
fill: "currentColor",
|
|
210
|
+
children: /* @__PURE__ */ l(
|
|
211
|
+
"path",
|
|
212
|
+
{
|
|
213
|
+
fillRule: "evenodd",
|
|
214
|
+
d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
|
|
215
|
+
clipRule: "evenodd"
|
|
216
|
+
}
|
|
217
|
+
)
|
|
156
218
|
}
|
|
157
219
|
)
|
|
158
220
|
}
|
|
159
221
|
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
className:
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
222
|
+
] }),
|
|
223
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1 mb-2", role: "row", children: Me.map((e) => /* @__PURE__ */ l(
|
|
224
|
+
"div",
|
|
225
|
+
{
|
|
226
|
+
className: "text-center text-xs font-semibold text-base-content/60 py-2",
|
|
227
|
+
role: "columnheader",
|
|
228
|
+
children: e
|
|
229
|
+
},
|
|
230
|
+
e
|
|
231
|
+
)) }),
|
|
232
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1", role: "grid", onKeyDown: V, children: H.map((e, n) => {
|
|
233
|
+
const $ = e ? new Date(D, u, e) : null, b = v || !!$ && !!d?.($), C = !!$ && !!i && _($, i);
|
|
234
|
+
return /* @__PURE__ */ l(
|
|
235
|
+
"button",
|
|
236
|
+
{
|
|
237
|
+
type: "button",
|
|
238
|
+
disabled: !e || b,
|
|
239
|
+
"aria-disabled": b || void 0,
|
|
240
|
+
"aria-selected": J(e) || void 0,
|
|
241
|
+
role: "gridcell",
|
|
242
|
+
onClick: () => e && A(e),
|
|
243
|
+
tabIndex: C ? 0 : -1,
|
|
244
|
+
"data-calendar-focus": C ? "true" : void 0,
|
|
245
|
+
className: `
|
|
246
|
+
aspect-square flex items-center justify-center text-sm rounded-lg
|
|
247
|
+
${e ? "" : "invisible"}
|
|
248
|
+
${e && !b ? "hover:bg-base-200 cursor-pointer" : ""}
|
|
249
|
+
${J(e) ? "bg-primary text-primary-content hover:bg-primary/90" : ""}
|
|
250
|
+
${ge(e) && !J(e) ? "border border-primary" : ""}
|
|
251
|
+
${b ? "text-base-content/30 cursor-not-allowed" : ""}
|
|
252
|
+
`,
|
|
253
|
+
children: e
|
|
254
|
+
},
|
|
255
|
+
n
|
|
256
|
+
);
|
|
257
|
+
}) }),
|
|
258
|
+
/* @__PURE__ */ l("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ l(
|
|
259
|
+
"button",
|
|
260
|
+
{
|
|
261
|
+
type: "button",
|
|
262
|
+
onClick: () => {
|
|
263
|
+
const e = /* @__PURE__ */ new Date();
|
|
264
|
+
d?.(e) || (K(e), c(e.getMonth()), P(e.getFullYear()), x?.(e), m(!1));
|
|
265
|
+
},
|
|
266
|
+
className: `${z} ${L} ${I}`,
|
|
267
|
+
disabled: de,
|
|
268
|
+
children: G
|
|
269
|
+
}
|
|
270
|
+
) })
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
)
|
|
201
274
|
] });
|
|
202
|
-
}),
|
|
203
|
-
value:
|
|
204
|
-
defaultValue:
|
|
205
|
-
onChange:
|
|
206
|
-
format:
|
|
207
|
-
placeholder:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
275
|
+
}), Ne = be(function({
|
|
276
|
+
value: a,
|
|
277
|
+
defaultValue: h,
|
|
278
|
+
onChange: x,
|
|
279
|
+
format: B,
|
|
280
|
+
placeholder: R,
|
|
281
|
+
disabledDate: d,
|
|
282
|
+
disabled: v = !1,
|
|
283
|
+
size: oe,
|
|
284
|
+
"data-testid": T,
|
|
285
|
+
className: se = "",
|
|
286
|
+
...le
|
|
287
|
+
}, ce) {
|
|
288
|
+
const { componentSize: ie, locale: j } = ye(), ue = oe ?? ie ?? "md", U = j?.DatePicker?.rangePlaceholder, [G, q] = Array.isArray(R) ? R : [
|
|
289
|
+
R ?? U?.[0] ?? "Start date",
|
|
290
|
+
U?.[1] ?? "End date"
|
|
291
|
+
], de = Array.isArray(R) ? `${G} - ${q}` : R ?? `${G} - ${q}`, W = j?.DatePicker?.today ?? "Today", p = /* @__PURE__ */ new Date(), K = v || d?.(p), y = (t) => T ? `${T}-${t}` : void 0, [m, i] = Y(
|
|
292
|
+
a || h || [null, null]
|
|
293
|
+
), [M, u] = Y(!1), [c, D] = Y(null), P = m[0] ?? m[1] ?? /* @__PURE__ */ new Date(), [f, k] = Y(P.getMonth()), [w, A] = Y(P.getFullYear()), N = ee(null), V = ee(null), Q = we.useId();
|
|
294
|
+
O(() => {
|
|
295
|
+
a !== void 0 && i(a);
|
|
296
|
+
}, [a]), O(() => {
|
|
297
|
+
function t(r) {
|
|
298
|
+
N.current && !N.current.contains(r.target) && u(!1);
|
|
299
|
+
}
|
|
300
|
+
if (M)
|
|
301
|
+
return document.addEventListener("mousedown", t), D(m[0] ?? m[1] ?? p), () => document.removeEventListener("mousedown", t);
|
|
302
|
+
}, [M]), O(() => {
|
|
303
|
+
if (!M || !V.current) return;
|
|
304
|
+
V.current.querySelector('[data-calendar-focus="true"]')?.focus();
|
|
305
|
+
}, [M, f, w, c]);
|
|
306
|
+
const X = (t) => {
|
|
307
|
+
const r = new Date(w, f, t);
|
|
308
|
+
if (v || d?.(r)) return;
|
|
309
|
+
let [s, g] = m;
|
|
310
|
+
!s || s && g ? (s = r, g = null) : s && !g && (De(r, s) ? (g = s, s = r) : g = r);
|
|
311
|
+
const E = [s, g];
|
|
312
|
+
i(E), x?.(E), s && g && u(!1);
|
|
313
|
+
}, S = (t, r) => {
|
|
314
|
+
let s = ae(t, r);
|
|
315
|
+
for (let g = 0; g < 31; g++) {
|
|
316
|
+
if (!d?.(s)) return s;
|
|
317
|
+
s = ae(s, r);
|
|
222
318
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
319
|
+
return t;
|
|
320
|
+
}, fe = (t) => {
|
|
321
|
+
if (!c) return;
|
|
322
|
+
let r = c;
|
|
323
|
+
switch (t.key) {
|
|
324
|
+
case "ArrowRight":
|
|
325
|
+
t.preventDefault(), r = S(c, 1);
|
|
326
|
+
break;
|
|
327
|
+
case "ArrowLeft":
|
|
328
|
+
t.preventDefault(), r = S(c, -1);
|
|
329
|
+
break;
|
|
330
|
+
case "ArrowDown":
|
|
331
|
+
t.preventDefault(), r = S(c, 7);
|
|
332
|
+
break;
|
|
333
|
+
case "ArrowUp":
|
|
334
|
+
t.preventDefault(), r = S(c, -7);
|
|
335
|
+
break;
|
|
336
|
+
case "Home":
|
|
337
|
+
t.preventDefault(), r = new Date(c.getFullYear(), c.getMonth(), 1), d?.(r) && (r = S(r, 1));
|
|
338
|
+
break;
|
|
339
|
+
case "End":
|
|
340
|
+
t.preventDefault(), r = new Date(c.getFullYear(), c.getMonth(), ne(c.getFullYear(), c.getMonth())), d?.(r) && (r = S(r, -1));
|
|
341
|
+
break;
|
|
342
|
+
case "Enter":
|
|
343
|
+
case " ":
|
|
344
|
+
t.preventDefault(), X(c.getDate());
|
|
345
|
+
return;
|
|
346
|
+
case "Escape":
|
|
347
|
+
t.preventDefault(), u(!1);
|
|
348
|
+
return;
|
|
349
|
+
default:
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
D(r), k(r.getMonth()), A(r.getFullYear());
|
|
353
|
+
}, H = () => {
|
|
354
|
+
f === 0 ? (k(11), A(w - 1)) : k(f - 1);
|
|
355
|
+
}, J = () => {
|
|
356
|
+
f === 11 ? (k(0), A(w + 1)) : k(f + 1);
|
|
357
|
+
}, ge = ne(w, f), e = xe(w, f), n = [];
|
|
237
358
|
for (let t = 0; t < e; t++)
|
|
238
|
-
|
|
239
|
-
for (let t = 1; t <=
|
|
240
|
-
|
|
241
|
-
const
|
|
359
|
+
n.push(null);
|
|
360
|
+
for (let t = 1; t <= ge; t++)
|
|
361
|
+
n.push(t);
|
|
362
|
+
const $ = (t) => {
|
|
242
363
|
if (!t) return !1;
|
|
243
|
-
const
|
|
244
|
-
return
|
|
245
|
-
}, [
|
|
246
|
-
return /* @__PURE__ */
|
|
247
|
-
/* @__PURE__ */
|
|
248
|
-
|
|
364
|
+
const r = /* @__PURE__ */ new Date();
|
|
365
|
+
return r.getDate() === t && r.getMonth() === f && r.getFullYear() === w;
|
|
366
|
+
}, [b, C] = m;
|
|
367
|
+
return /* @__PURE__ */ F("div", { ref: ce || N, className: `relative ${se}`, "data-state": M ? "open" : "closed", "data-testid": T, ...le, children: [
|
|
368
|
+
/* @__PURE__ */ l(
|
|
369
|
+
ve,
|
|
249
370
|
{
|
|
250
|
-
value:
|
|
251
|
-
placeholder:
|
|
252
|
-
disabled:
|
|
253
|
-
size:
|
|
371
|
+
value: Se(m, B),
|
|
372
|
+
placeholder: de,
|
|
373
|
+
disabled: v,
|
|
374
|
+
size: ue,
|
|
254
375
|
readOnly: !0,
|
|
255
|
-
onClick: () => !
|
|
376
|
+
onClick: () => !v && u(!M),
|
|
377
|
+
"aria-haspopup": "dialog",
|
|
378
|
+
"aria-expanded": M,
|
|
379
|
+
"aria-controls": Q,
|
|
256
380
|
className: "cursor-pointer",
|
|
257
|
-
"data-testid":
|
|
381
|
+
"data-testid": y("input")
|
|
258
382
|
}
|
|
259
383
|
),
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
384
|
+
M && /* @__PURE__ */ F(
|
|
385
|
+
"div",
|
|
386
|
+
{
|
|
387
|
+
ref: V,
|
|
388
|
+
id: Q,
|
|
389
|
+
role: "dialog",
|
|
390
|
+
"aria-label": "Date range picker calendar",
|
|
391
|
+
className: "absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg p-4 z-50 w-80",
|
|
392
|
+
"data-testid": y("calendar"),
|
|
393
|
+
children: [
|
|
394
|
+
/* @__PURE__ */ F("div", { className: "flex items-center justify-between mb-4", children: [
|
|
395
|
+
/* @__PURE__ */ l(
|
|
396
|
+
"button",
|
|
270
397
|
{
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
"path",
|
|
398
|
+
type: "button",
|
|
399
|
+
onClick: H,
|
|
400
|
+
className: `${z} ${L} ${I} ${te}`,
|
|
401
|
+
children: /* @__PURE__ */ l(
|
|
402
|
+
"svg",
|
|
277
403
|
{
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
404
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
405
|
+
className: "h-5 w-5",
|
|
406
|
+
viewBox: "0 0 20 20",
|
|
407
|
+
fill: "currentColor",
|
|
408
|
+
children: /* @__PURE__ */ l(
|
|
409
|
+
"path",
|
|
410
|
+
{
|
|
411
|
+
fillRule: "evenodd",
|
|
412
|
+
d: "M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",
|
|
413
|
+
clipRule: "evenodd"
|
|
414
|
+
}
|
|
415
|
+
)
|
|
281
416
|
}
|
|
282
417
|
)
|
|
283
418
|
}
|
|
284
|
-
)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
/* @__PURE__ */ s(
|
|
293
|
-
"button",
|
|
294
|
-
{
|
|
295
|
-
type: "button",
|
|
296
|
-
onClick: B,
|
|
297
|
-
className: `${x} ${Y} ${S} ${I}`,
|
|
298
|
-
children: /* @__PURE__ */ s(
|
|
299
|
-
"svg",
|
|
419
|
+
),
|
|
420
|
+
/* @__PURE__ */ F("div", { className: "text-base font-semibold", children: [
|
|
421
|
+
$e[f],
|
|
422
|
+
" ",
|
|
423
|
+
w
|
|
424
|
+
] }),
|
|
425
|
+
/* @__PURE__ */ l(
|
|
426
|
+
"button",
|
|
300
427
|
{
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
"path",
|
|
428
|
+
type: "button",
|
|
429
|
+
onClick: J,
|
|
430
|
+
className: `${z} ${L} ${I} ${te}`,
|
|
431
|
+
children: /* @__PURE__ */ l(
|
|
432
|
+
"svg",
|
|
307
433
|
{
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
434
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
435
|
+
className: "h-5 w-5",
|
|
436
|
+
viewBox: "0 0 20 20",
|
|
437
|
+
fill: "currentColor",
|
|
438
|
+
children: /* @__PURE__ */ l(
|
|
439
|
+
"path",
|
|
440
|
+
{
|
|
441
|
+
fillRule: "evenodd",
|
|
442
|
+
d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
|
|
443
|
+
clipRule: "evenodd"
|
|
444
|
+
}
|
|
445
|
+
)
|
|
311
446
|
}
|
|
312
447
|
)
|
|
313
448
|
}
|
|
314
449
|
)
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
450
|
+
] }),
|
|
451
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1 mb-2", role: "row", children: Me.map((t) => /* @__PURE__ */ l(
|
|
452
|
+
"div",
|
|
453
|
+
{
|
|
454
|
+
className: "text-center text-xs font-semibold text-base-content/60 py-2",
|
|
455
|
+
role: "columnheader",
|
|
456
|
+
children: t
|
|
457
|
+
},
|
|
458
|
+
t
|
|
459
|
+
)) }),
|
|
460
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1", role: "grid", onKeyDown: fe, children: n.map((t, r) => {
|
|
461
|
+
const s = t ? new Date(w, f, t) : null, g = v || !!s && !!d?.(s), E = !!s && !!b && _(s, b), he = !!s && !!C && _(s, C), pe = !!s && !!b && !!C && Ye(s, b) && De(s, C), me = !!s && !!c && _(s, c);
|
|
462
|
+
return /* @__PURE__ */ l(
|
|
463
|
+
"button",
|
|
464
|
+
{
|
|
465
|
+
type: "button",
|
|
466
|
+
disabled: !t || g,
|
|
467
|
+
"aria-disabled": g || void 0,
|
|
468
|
+
"aria-selected": E || he || pe || void 0,
|
|
469
|
+
role: "gridcell",
|
|
470
|
+
onClick: () => t && X(t),
|
|
471
|
+
tabIndex: me ? 0 : -1,
|
|
472
|
+
"data-calendar-focus": me ? "true" : void 0,
|
|
473
|
+
className: `
|
|
335
474
|
aspect-square flex items-center justify-center text-sm rounded-lg
|
|
336
|
-
${t ? "
|
|
337
|
-
${
|
|
338
|
-
${
|
|
339
|
-
${
|
|
340
|
-
${t ? "
|
|
475
|
+
${t ? "" : "invisible"}
|
|
476
|
+
${t && !g ? "hover:bg-base-200 cursor-pointer" : ""}
|
|
477
|
+
${pe ? "bg-primary/10" : ""}
|
|
478
|
+
${E || he ? "bg-primary text-primary-content hover:bg-primary/90" : ""}
|
|
479
|
+
${$(t) && !E && !he ? "border border-primary" : ""}
|
|
480
|
+
${g ? "text-base-content/30 cursor-not-allowed" : ""}
|
|
341
481
|
`,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
482
|
+
children: t
|
|
483
|
+
},
|
|
484
|
+
r
|
|
485
|
+
);
|
|
486
|
+
}) }),
|
|
487
|
+
/* @__PURE__ */ l("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ l(
|
|
488
|
+
"button",
|
|
489
|
+
{
|
|
490
|
+
type: "button",
|
|
491
|
+
onClick: () => {
|
|
492
|
+
const t = /* @__PURE__ */ new Date();
|
|
493
|
+
d?.(t) || (i([t, t]), k(t.getMonth()), A(t.getFullYear()), x?.([t, t]), u(!1));
|
|
494
|
+
},
|
|
495
|
+
className: `${z} ${L} ${I}`,
|
|
496
|
+
disabled: K,
|
|
497
|
+
children: W
|
|
498
|
+
}
|
|
499
|
+
) })
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
)
|
|
360
503
|
] });
|
|
361
504
|
});
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
|
|
505
|
+
ke.displayName = "DatePicker";
|
|
506
|
+
Ne.displayName = "DatePicker.Range";
|
|
507
|
+
const Fe = ke;
|
|
508
|
+
Fe.Range = Ne;
|
|
366
509
|
export {
|
|
367
|
-
|
|
510
|
+
Fe as DatePicker
|
|
368
511
|
};
|
|
369
512
|
//# sourceMappingURL=DatePicker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sources":["../../src/components/DatePicker.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, forwardRef } from 'react'\nimport { Input } from './Input'\nimport { useConfig } from '../providers/ConfigProvider'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnSm = 'btn-sm'\nconst dBtnSquare = 'btn-square'\n\nexport interface DatePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n value?: Date | null\n defaultValue?: Date | null\n onChange?: (date: Date | null) => void\n format?: string\n placeholder?: string\n disabled?: boolean\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nexport type DateRangeValue = [Date | null, Date | null]\n\nexport interface DateRangePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n value?: DateRangeValue\n defaultValue?: DateRangeValue\n onChange?: (range: DateRangeValue) => void\n format?: string\n placeholder?: [string, string] | string\n disabled?: boolean\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nconst DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']\nconst MONTHS = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n]\n\nfunction formatDate(date: Date | null, format: string = 'MM/DD/YYYY'): string {\n if (!date) return ''\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, '0')\n const day = String(date.getDate()).padStart(2, '0')\n\n return format\n .replace('YYYY', String(year))\n .replace('MM', month)\n .replace('DD', day)\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate()\n}\n\nfunction getFirstDayOfMonth(year: number, month: number): number {\n return new Date(year, month, 1).getDay()\n}\n\nfunction stripTime(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\nfunction isSameDay(a: Date, b: Date): boolean {\n return a.getFullYear() === b.getFullYear()\n && a.getMonth() === b.getMonth()\n && a.getDate() === b.getDate()\n}\n\nfunction isBeforeDay(a: Date, b: Date): boolean {\n return stripTime(a).getTime() < stripTime(b).getTime()\n}\n\nfunction isAfterDay(a: Date, b: Date): boolean {\n return stripTime(a).getTime() > stripTime(b).getTime()\n}\n\nfunction formatRange(range: DateRangeValue, format: string = 'MM/DD/YYYY'): string {\n const [start, end] = range\n if (start && end) return `${formatDate(start, format)} - ${formatDate(end, format)}`\n if (start) return `${formatDate(start, format)} - `\n return ''\n}\n\nconst DatePickerComponent = forwardRef<HTMLDivElement, DatePickerProps>(function DatePicker(\n {\n value,\n defaultValue,\n onChange,\n format,\n placeholder = 'Select date',\n disabled = false,\n size,\n 'data-testid': testId,\n className = '',\n ...rest\n },\n ref\n) {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n\n // Helper for test IDs\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n const [selectedDate, setSelectedDate] = useState<Date | null>(\n value || defaultValue || null\n )\n const [isOpen, setIsOpen] = useState(false)\n const [viewMonth, setViewMonth] = useState(\n selectedDate ? selectedDate.getMonth() : new Date().getMonth()\n )\n const [viewYear, setViewYear] = useState(\n selectedDate ? selectedDate.getFullYear() : new Date().getFullYear()\n )\n\n const containerRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (value !== undefined) {\n setSelectedDate(value)\n }\n }, [value])\n\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setIsOpen(false)\n }\n }\n\n if (isOpen) {\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [isOpen])\n\n const handleDateSelect = (day: number) => {\n const newDate = new Date(viewYear, viewMonth, day)\n setSelectedDate(newDate)\n onChange?.(newDate)\n setIsOpen(false)\n }\n\n const handlePrevMonth = () => {\n if (viewMonth === 0) {\n setViewMonth(11)\n setViewYear(viewYear - 1)\n } else {\n setViewMonth(viewMonth - 1)\n }\n }\n\n const handleNextMonth = () => {\n if (viewMonth === 11) {\n setViewMonth(0)\n setViewYear(viewYear + 1)\n } else {\n setViewMonth(viewMonth + 1)\n }\n }\n\n const daysInMonth = getDaysInMonth(viewYear, viewMonth)\n const firstDayOfMonth = getFirstDayOfMonth(viewYear, viewMonth)\n\n const calendarDays: (number | null)[] = []\n for (let i = 0; i < firstDayOfMonth; i++) {\n calendarDays.push(null)\n }\n for (let i = 1; i <= daysInMonth; i++) {\n calendarDays.push(i)\n }\n\n const isSelectedDay = (day: number | null): boolean => {\n if (!day || !selectedDate) return false\n return (\n selectedDate.getDate() === day &&\n selectedDate.getMonth() === viewMonth &&\n selectedDate.getFullYear() === viewYear\n )\n }\n\n const isToday = (day: number | null): boolean => {\n if (!day) return false\n const today = new Date()\n return (\n today.getDate() === day &&\n today.getMonth() === viewMonth &&\n today.getFullYear() === viewYear\n )\n }\n\n return (\n <div ref={ref || containerRef} className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} data-testid={testId} {...rest}>\n <Input\n value={formatDate(selectedDate, format)}\n placeholder={placeholder}\n disabled={disabled}\n size={effectiveSize}\n readOnly\n onClick={() => !disabled && setIsOpen(!isOpen)}\n className=\"cursor-pointer\"\n data-testid={getTestId('input')}\n />\n\n {isOpen && (\n <div className=\"absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg p-4 z-50 w-80\" data-testid={getTestId('calendar')}>\n {/* Header */}\n <div className=\"flex items-center justify-between mb-4\">\n <button\n type=\"button\"\n onClick={handlePrevMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n <div className=\"text-base font-semibold\">\n {MONTHS[viewMonth]} {viewYear}\n </div>\n\n <button\n type=\"button\"\n onClick={handleNextMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n </div>\n\n {/* Days of week */}\n <div className=\"grid grid-cols-7 gap-1 mb-2\">\n {DAYS.map((day) => (\n <div\n key={day}\n className=\"text-center text-xs font-semibold text-base-content/60 py-2\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid grid-cols-7 gap-1\">\n {calendarDays.map((day, index) => (\n <button\n key={index}\n type=\"button\"\n disabled={!day}\n onClick={() => day && handleDateSelect(day)}\n className={`\n aspect-square flex items-center justify-center text-sm rounded-lg\n ${!day ? 'invisible' : 'hover:bg-base-200'}\n ${isSelectedDay(day) ? 'bg-primary text-primary-content hover:bg-primary/90' : ''}\n ${isToday(day) && !isSelectedDay(day) ? 'border border-primary' : ''}\n ${day ? 'cursor-pointer' : ''}\n `}\n >\n {day}\n </button>\n ))}\n </div>\n\n {/* Today button */}\n <div className=\"mt-4 flex justify-end\">\n <button\n type=\"button\"\n onClick={() => {\n const today = new Date()\n setSelectedDate(today)\n setViewMonth(today.getMonth())\n setViewYear(today.getFullYear())\n onChange?.(today)\n setIsOpen(false)\n }}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm}`}\n >\n Today\n </button>\n </div>\n </div>\n )}\n </div>\n )\n})\n\nconst DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(function DateRangePicker(\n {\n value,\n defaultValue,\n onChange,\n format,\n placeholder,\n disabled = false,\n size,\n 'data-testid': testId,\n className = '',\n ...rest\n },\n ref\n) {\n const { componentSize } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n\n const [startPlaceholder, endPlaceholder] = Array.isArray(placeholder)\n ? placeholder\n : [placeholder ?? 'Start date', 'End date']\n const resolvedPlaceholder = Array.isArray(placeholder)\n ? `${startPlaceholder} - ${endPlaceholder}`\n : placeholder ?? 'Start date - End date'\n\n // Helper for test IDs\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n const [selectedRange, setSelectedRange] = useState<DateRangeValue>(\n value || defaultValue || [null, null]\n )\n const [isOpen, setIsOpen] = useState(false)\n const initialDate = selectedRange[0] ?? selectedRange[1] ?? new Date()\n const [viewMonth, setViewMonth] = useState(initialDate.getMonth())\n const [viewYear, setViewYear] = useState(initialDate.getFullYear())\n\n const containerRef = useRef<HTMLDivElement>(null)\n\n useEffect(() => {\n if (value !== undefined) {\n setSelectedRange(value)\n }\n }, [value])\n\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setIsOpen(false)\n }\n }\n\n if (isOpen) {\n document.addEventListener('mousedown', handleClickOutside)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [isOpen])\n\n const handleDateSelect = (day: number) => {\n const newDate = new Date(viewYear, viewMonth, day)\n let [start, end] = selectedRange\n\n if (!start || (start && end)) {\n start = newDate\n end = null\n } else if (start && !end) {\n if (isBeforeDay(newDate, start)) {\n end = start\n start = newDate\n } else {\n end = newDate\n }\n }\n\n const nextRange: DateRangeValue = [start, end]\n setSelectedRange(nextRange)\n onChange?.(nextRange)\n if (start && end) {\n setIsOpen(false)\n }\n }\n\n const handlePrevMonth = () => {\n if (viewMonth === 0) {\n setViewMonth(11)\n setViewYear(viewYear - 1)\n } else {\n setViewMonth(viewMonth - 1)\n }\n }\n\n const handleNextMonth = () => {\n if (viewMonth === 11) {\n setViewMonth(0)\n setViewYear(viewYear + 1)\n } else {\n setViewMonth(viewMonth + 1)\n }\n }\n\n const daysInMonth = getDaysInMonth(viewYear, viewMonth)\n const firstDayOfMonth = getFirstDayOfMonth(viewYear, viewMonth)\n\n const calendarDays: (number | null)[] = []\n for (let i = 0; i < firstDayOfMonth; i++) {\n calendarDays.push(null)\n }\n for (let i = 1; i <= daysInMonth; i++) {\n calendarDays.push(i)\n }\n\n const isToday = (day: number | null): boolean => {\n if (!day) return false\n const today = new Date()\n return (\n today.getDate() === day &&\n today.getMonth() === viewMonth &&\n today.getFullYear() === viewYear\n )\n }\n\n const [rangeStart, rangeEnd] = selectedRange\n\n return (\n <div ref={ref || containerRef} className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} data-testid={testId} {...rest}>\n <Input\n value={formatRange(selectedRange, format)}\n placeholder={resolvedPlaceholder}\n disabled={disabled}\n size={effectiveSize}\n readOnly\n onClick={() => !disabled && setIsOpen(!isOpen)}\n className=\"cursor-pointer\"\n data-testid={getTestId('input')}\n />\n\n {isOpen && (\n <div className=\"absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg p-4 z-50 w-80\" data-testid={getTestId('calendar')}>\n {/* Header */}\n <div className=\"flex items-center justify-between mb-4\">\n <button\n type=\"button\"\n onClick={handlePrevMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n <div className=\"text-base font-semibold\">\n {MONTHS[viewMonth]} {viewYear}\n </div>\n\n <button\n type=\"button\"\n onClick={handleNextMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n </div>\n\n {/* Days of week */}\n <div className=\"grid grid-cols-7 gap-1 mb-2\">\n {DAYS.map((day) => (\n <div\n key={day}\n className=\"text-center text-xs font-semibold text-base-content/60 py-2\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid grid-cols-7 gap-1\">\n {calendarDays.map((day, index) => {\n const dayDate = day ? new Date(viewYear, viewMonth, day) : null\n const isStart = !!dayDate && !!rangeStart && isSameDay(dayDate, rangeStart)\n const isEnd = !!dayDate && !!rangeEnd && isSameDay(dayDate, rangeEnd)\n const isInRange = !!dayDate && !!rangeStart && !!rangeEnd\n && isAfterDay(dayDate, rangeStart)\n && isBeforeDay(dayDate, rangeEnd)\n\n return (\n <button\n key={index}\n type=\"button\"\n disabled={!day}\n onClick={() => day && handleDateSelect(day)}\n className={`\n aspect-square flex items-center justify-center text-sm rounded-lg\n ${!day ? 'invisible' : 'hover:bg-base-200'}\n ${isInRange ? 'bg-primary/10' : ''}\n ${isStart || isEnd ? 'bg-primary text-primary-content hover:bg-primary/90' : ''}\n ${isToday(day) && !isStart && !isEnd ? 'border border-primary' : ''}\n ${day ? 'cursor-pointer' : ''}\n `}\n >\n {day}\n </button>\n )\n })}\n </div>\n\n {/* Today button */}\n <div className=\"mt-4 flex justify-end\">\n <button\n type=\"button\"\n onClick={() => {\n const today = new Date()\n setSelectedRange([today, today])\n setViewMonth(today.getMonth())\n setViewYear(today.getFullYear())\n onChange?.([today, today])\n setIsOpen(false)\n }}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm}`}\n >\n Today\n </button>\n </div>\n </div>\n )}\n </div>\n )\n})\n\nDatePickerComponent.displayName = 'DatePicker'\nDateRangePicker.displayName = 'DatePicker.Range'\n\ntype DatePickerType = typeof DatePickerComponent & {\n Range: typeof DateRangePicker\n}\n\nexport const DatePicker = DatePickerComponent as DatePickerType\nDatePicker.Range = DateRangePicker\n"],"names":["dBtn","dBtnGhost","dBtnSm","dBtnSquare","DAYS","MONTHS","formatDate","date","format","year","month","day","getDaysInMonth","getFirstDayOfMonth","stripTime","isSameDay","a","b","isBeforeDay","isAfterDay","formatRange","range","start","end","DatePickerComponent","forwardRef","value","defaultValue","onChange","placeholder","disabled","size","testId","className","rest","ref","componentSize","useConfig","effectiveSize","getTestId","suffix","selectedDate","setSelectedDate","useState","isOpen","setIsOpen","viewMonth","setViewMonth","viewYear","setViewYear","containerRef","useRef","useEffect","handleClickOutside","event","handleDateSelect","newDate","handlePrevMonth","handleNextMonth","daysInMonth","firstDayOfMonth","calendarDays","i","isSelectedDay","isToday","today","jsx","Input","jsxs","index","DateRangePicker","startPlaceholder","endPlaceholder","resolvedPlaceholder","selectedRange","setSelectedRange","initialDate","nextRange","rangeStart","rangeEnd","dayDate","isStart","isEnd","isInRange","DatePicker"],"mappings":";;;;AAKA,MAAMA,IAAO,OACPC,IAAY,aACZC,IAAS,UACTC,IAAa,cA4BbC,KAAO,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI,GAChDC,KAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAASC,EAAWC,GAAmBC,IAAiB,cAAsB;AAC5E,MAAI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KAAK,CAACsE,KAAW,CAACC,IAAQ,0BAA0B,EAAE;AAAA,sBACjEvE,IAAM,mBAAmB,EAAE;AAAA;AAAA,YAG9B,UAAAA;AAAA,UAAA;AAAA,UAbI0D;AAAA,QAAA;AAAA,MAgBX,CAAC,EAAA,CACH;AAAA,MAGA,gBAAAH,EAAC,OAAA,EAAI,WAAU,yBACb,UAAA,gBAAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,MAAM;AACb,kBAAMD,wBAAY,KAAA;AAClB,YAAAU,EAAiB,CAACV,GAAOA,CAAK,CAAC,GAC/BlB,EAAakB,EAAM,UAAU,GAC7BhB,EAAYgB,EAAM,aAAa,GAC/BrC,IAAW,CAACqC,GAAOA,CAAK,CAAC,GACzBpB,EAAU,EAAK;AAAA,UACjB;AAAA,UACA,WAAW,GAAG7C,CAAI,IAAIC,CAAS,IAAIC,CAAM;AAAA,UAC1C,UAAA;AAAA,QAAA;AAAA,MAAA,EAED,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GAEJ;AAEJ,CAAC;AAEDsB,GAAoB,cAAc;AAClC8C,GAAgB,cAAc;AAMvB,MAAMc,KAAa5D;AAC1B4D,GAAW,QAAQd;"}
|
|
1
|
+
{"version":3,"file":"DatePicker.js","sources":["../../src/components/DatePicker.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect, forwardRef } from 'react'\nimport { Input } from './Input'\nimport { useConfig } from '../providers/ConfigProvider'\n\n// DaisyUI classes\nconst dBtn = 'btn'\nconst dBtnGhost = 'btn-ghost'\nconst dBtnSm = 'btn-sm'\nconst dBtnSquare = 'btn-square'\n\nexport interface DatePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n value?: Date | null\n defaultValue?: Date | null\n onChange?: (date: Date | null) => void\n format?: string\n placeholder?: string\n disabledDate?: (date: Date) => boolean\n disabled?: boolean\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nexport type DateRangeValue = [Date | null, Date | null]\n\nexport interface DateRangePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange' | 'defaultValue'> {\n value?: DateRangeValue\n defaultValue?: DateRangeValue\n onChange?: (range: DateRangeValue) => void\n format?: string\n placeholder?: [string, string] | string\n disabledDate?: (date: Date) => boolean\n disabled?: boolean\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n /** Test ID prefix for child elements */\n 'data-testid'?: string\n}\n\nconst DAYS = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']\nconst MONTHS = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n]\n\nfunction formatDate(date: Date | null, format: string = 'MM/DD/YYYY'): string {\n if (!date) return ''\n\n const year = date.getFullYear()\n const month = String(date.getMonth() + 1).padStart(2, '0')\n const day = String(date.getDate()).padStart(2, '0')\n\n return format\n .replace('YYYY', String(year))\n .replace('MM', month)\n .replace('DD', day)\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate()\n}\n\nfunction getFirstDayOfMonth(year: number, month: number): number {\n return new Date(year, month, 1).getDay()\n}\n\nfunction stripTime(date: Date): Date {\n return new Date(date.getFullYear(), date.getMonth(), date.getDate())\n}\n\nfunction isSameDay(a: Date, b: Date): boolean {\n return a.getFullYear() === b.getFullYear()\n && a.getMonth() === b.getMonth()\n && a.getDate() === b.getDate()\n}\n\nfunction isBeforeDay(a: Date, b: Date): boolean {\n return stripTime(a).getTime() < stripTime(b).getTime()\n}\n\nfunction isAfterDay(a: Date, b: Date): boolean {\n return stripTime(a).getTime() > stripTime(b).getTime()\n}\n\nfunction addDays(date: Date, amount: number): Date {\n const next = new Date(date)\n next.setDate(next.getDate() + amount)\n return next\n}\n\nfunction formatRange(range: DateRangeValue, format: string = 'MM/DD/YYYY'): string {\n const [start, end] = range\n if (start && end) return `${formatDate(start, format)} - ${formatDate(end, format)}`\n if (start) return `${formatDate(start, format)} - `\n return ''\n}\n\nconst DatePickerComponent = forwardRef<HTMLDivElement, DatePickerProps>(function DatePicker(\n {\n value,\n defaultValue,\n onChange,\n format,\n placeholder,\n disabledDate,\n disabled = false,\n size,\n 'data-testid': testId,\n className = '',\n ...rest\n },\n ref\n) {\n const { componentSize, locale } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n const resolvedPlaceholder = placeholder ?? locale?.DatePicker?.placeholder ?? 'Select date'\n const todayLabel = locale?.DatePicker?.today ?? 'Today'\n const todayDate = new Date()\n const isTodayDisabled = disabled || disabledDate?.(todayDate)\n\n // Helper for test IDs\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n const [selectedDate, setSelectedDate] = useState<Date | null>(\n value || defaultValue || null\n )\n const [isOpen, setIsOpen] = useState(false)\n const [focusedDate, setFocusedDate] = useState<Date | null>(null)\n const [viewMonth, setViewMonth] = useState(\n selectedDate ? selectedDate.getMonth() : new Date().getMonth()\n )\n const [viewYear, setViewYear] = useState(\n selectedDate ? selectedDate.getFullYear() : new Date().getFullYear()\n )\n\n const containerRef = useRef<HTMLDivElement>(null)\n const calendarRef = useRef<HTMLDivElement>(null)\n const calendarId = React.useId()\n\n useEffect(() => {\n if (value !== undefined) {\n setSelectedDate(value)\n }\n }, [value])\n\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setIsOpen(false)\n }\n }\n\n if (isOpen) {\n document.addEventListener('mousedown', handleClickOutside)\n setFocusedDate(selectedDate ?? todayDate)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [isOpen])\n\n useEffect(() => {\n if (!isOpen || !calendarRef.current) return\n const focusTarget = calendarRef.current.querySelector<HTMLButtonElement>('[data-calendar-focus=\"true\"]')\n focusTarget?.focus()\n }, [isOpen, viewMonth, viewYear, focusedDate])\n\n const handleDateSelect = (day: number) => {\n const newDate = new Date(viewYear, viewMonth, day)\n if (disabled || disabledDate?.(newDate)) return\n setSelectedDate(newDate)\n onChange?.(newDate)\n setIsOpen(false)\n }\n\n const focusNextEnabledDate = (start: Date, delta: number) => {\n let candidate = addDays(start, delta)\n for (let i = 0; i < 31; i++) {\n if (!disabledDate?.(candidate)) return candidate\n candidate = addDays(candidate, delta)\n }\n return start\n }\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!focusedDate) return\n let nextDate = focusedDate\n\n switch (event.key) {\n case 'ArrowRight':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, 1)\n break\n case 'ArrowLeft':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, -1)\n break\n case 'ArrowDown':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, 7)\n break\n case 'ArrowUp':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, -7)\n break\n case 'Home':\n event.preventDefault()\n nextDate = new Date(focusedDate.getFullYear(), focusedDate.getMonth(), 1)\n if (disabledDate?.(nextDate)) {\n nextDate = focusNextEnabledDate(nextDate, 1)\n }\n break\n case 'End':\n event.preventDefault()\n nextDate = new Date(focusedDate.getFullYear(), focusedDate.getMonth(), getDaysInMonth(focusedDate.getFullYear(), focusedDate.getMonth()))\n if (disabledDate?.(nextDate)) {\n nextDate = focusNextEnabledDate(nextDate, -1)\n }\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n handleDateSelect(focusedDate.getDate())\n return\n case 'Escape':\n event.preventDefault()\n setIsOpen(false)\n return\n default:\n return\n }\n\n setFocusedDate(nextDate)\n setViewMonth(nextDate.getMonth())\n setViewYear(nextDate.getFullYear())\n }\n\n const handlePrevMonth = () => {\n if (viewMonth === 0) {\n setViewMonth(11)\n setViewYear(viewYear - 1)\n } else {\n setViewMonth(viewMonth - 1)\n }\n }\n\n const handleNextMonth = () => {\n if (viewMonth === 11) {\n setViewMonth(0)\n setViewYear(viewYear + 1)\n } else {\n setViewMonth(viewMonth + 1)\n }\n }\n\n const daysInMonth = getDaysInMonth(viewYear, viewMonth)\n const firstDayOfMonth = getFirstDayOfMonth(viewYear, viewMonth)\n\n const calendarDays: (number | null)[] = []\n for (let i = 0; i < firstDayOfMonth; i++) {\n calendarDays.push(null)\n }\n for (let i = 1; i <= daysInMonth; i++) {\n calendarDays.push(i)\n }\n\n const isSelectedDay = (day: number | null): boolean => {\n if (!day || !selectedDate) return false\n return (\n selectedDate.getDate() === day &&\n selectedDate.getMonth() === viewMonth &&\n selectedDate.getFullYear() === viewYear\n )\n }\n\n const isToday = (day: number | null): boolean => {\n if (!day) return false\n const today = new Date()\n return (\n today.getDate() === day &&\n today.getMonth() === viewMonth &&\n today.getFullYear() === viewYear\n )\n }\n\n return (\n <div ref={ref || containerRef} className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} data-testid={testId} {...rest}>\n <Input\n value={formatDate(selectedDate, format)}\n placeholder={resolvedPlaceholder}\n disabled={disabled}\n size={effectiveSize}\n readOnly\n onClick={() => !disabled && setIsOpen(!isOpen)}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={calendarId}\n className=\"cursor-pointer\"\n data-testid={getTestId('input')}\n />\n\n {isOpen && (\n <div\n ref={calendarRef}\n id={calendarId}\n role=\"dialog\"\n aria-label=\"Date picker calendar\"\n className=\"absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg p-4 z-50 w-80\"\n data-testid={getTestId('calendar')}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between mb-4\">\n <button\n type=\"button\"\n onClick={handlePrevMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n <div className=\"text-base font-semibold\">\n {MONTHS[viewMonth]} {viewYear}\n </div>\n\n <button\n type=\"button\"\n onClick={handleNextMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n </div>\n\n {/* Days of week */}\n <div className=\"grid grid-cols-7 gap-1 mb-2\" role=\"row\">\n {DAYS.map((day) => (\n <div\n key={day}\n className=\"text-center text-xs font-semibold text-base-content/60 py-2\"\n role=\"columnheader\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid grid-cols-7 gap-1\" role=\"grid\" onKeyDown={handleKeyDown}>\n {calendarDays.map((day, index) => {\n const dayDate = day ? new Date(viewYear, viewMonth, day) : null\n const isDayDisabled = disabled || (!!dayDate && !!disabledDate?.(dayDate))\n const isFocusedDay = !!dayDate && !!focusedDate && isSameDay(dayDate, focusedDate)\n\n return (\n <button\n key={index}\n type=\"button\"\n disabled={!day || isDayDisabled}\n aria-disabled={isDayDisabled || undefined}\n aria-selected={isSelectedDay(day) || undefined}\n role=\"gridcell\"\n onClick={() => day && handleDateSelect(day)}\n tabIndex={isFocusedDay ? 0 : -1}\n data-calendar-focus={isFocusedDay ? 'true' : undefined}\n className={`\n aspect-square flex items-center justify-center text-sm rounded-lg\n ${!day ? 'invisible' : ''}\n ${day && !isDayDisabled ? 'hover:bg-base-200 cursor-pointer' : ''}\n ${isSelectedDay(day) ? 'bg-primary text-primary-content hover:bg-primary/90' : ''}\n ${isToday(day) && !isSelectedDay(day) ? 'border border-primary' : ''}\n ${isDayDisabled ? 'text-base-content/30 cursor-not-allowed' : ''}\n `}\n >\n {day}\n </button>\n )\n })}\n </div>\n\n {/* Today button */}\n <div className=\"mt-4 flex justify-end\">\n <button\n type=\"button\"\n onClick={() => {\n const today = new Date()\n if (disabledDate?.(today)) return\n setSelectedDate(today)\n setViewMonth(today.getMonth())\n setViewYear(today.getFullYear())\n onChange?.(today)\n setIsOpen(false)\n }}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm}`}\n disabled={isTodayDisabled}\n >\n {todayLabel}\n </button>\n </div>\n </div>\n )}\n </div>\n )\n})\n\nconst DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(function DateRangePicker(\n {\n value,\n defaultValue,\n onChange,\n format,\n placeholder,\n disabledDate,\n disabled = false,\n size,\n 'data-testid': testId,\n className = '',\n ...rest\n },\n ref\n) {\n const { componentSize, locale } = useConfig()\n const effectiveSize = size ?? componentSize ?? 'md'\n\n const localeRangePlaceholder = locale?.DatePicker?.rangePlaceholder\n const [startPlaceholder, endPlaceholder] = Array.isArray(placeholder)\n ? placeholder\n : [\n placeholder ?? localeRangePlaceholder?.[0] ?? 'Start date',\n localeRangePlaceholder?.[1] ?? 'End date',\n ]\n const resolvedPlaceholder = Array.isArray(placeholder)\n ? `${startPlaceholder} - ${endPlaceholder}`\n : placeholder ?? `${startPlaceholder} - ${endPlaceholder}`\n const todayLabel = locale?.DatePicker?.today ?? 'Today'\n const todayDate = new Date()\n const isTodayDisabled = disabled || disabledDate?.(todayDate)\n\n // Helper for test IDs\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n const [selectedRange, setSelectedRange] = useState<DateRangeValue>(\n value || defaultValue || [null, null]\n )\n const [isOpen, setIsOpen] = useState(false)\n const [focusedDate, setFocusedDate] = useState<Date | null>(null)\n const initialDate = selectedRange[0] ?? selectedRange[1] ?? new Date()\n const [viewMonth, setViewMonth] = useState(initialDate.getMonth())\n const [viewYear, setViewYear] = useState(initialDate.getFullYear())\n\n const containerRef = useRef<HTMLDivElement>(null)\n const calendarRef = useRef<HTMLDivElement>(null)\n const calendarId = React.useId()\n\n useEffect(() => {\n if (value !== undefined) {\n setSelectedRange(value)\n }\n }, [value])\n\n useEffect(() => {\n function handleClickOutside(event: MouseEvent) {\n if (containerRef.current && !containerRef.current.contains(event.target as Node)) {\n setIsOpen(false)\n }\n }\n\n if (isOpen) {\n document.addEventListener('mousedown', handleClickOutside)\n setFocusedDate(selectedRange[0] ?? selectedRange[1] ?? todayDate)\n return () => document.removeEventListener('mousedown', handleClickOutside)\n }\n }, [isOpen])\n\n useEffect(() => {\n if (!isOpen || !calendarRef.current) return\n const focusTarget = calendarRef.current.querySelector<HTMLButtonElement>('[data-calendar-focus=\"true\"]')\n focusTarget?.focus()\n }, [isOpen, viewMonth, viewYear, focusedDate])\n\n const handleDateSelect = (day: number) => {\n const newDate = new Date(viewYear, viewMonth, day)\n if (disabled || disabledDate?.(newDate)) return\n let [start, end] = selectedRange\n\n if (!start || (start && end)) {\n start = newDate\n end = null\n } else if (start && !end) {\n if (isBeforeDay(newDate, start)) {\n end = start\n start = newDate\n } else {\n end = newDate\n }\n }\n\n const nextRange: DateRangeValue = [start, end]\n setSelectedRange(nextRange)\n onChange?.(nextRange)\n if (start && end) {\n setIsOpen(false)\n }\n }\n\n const focusNextEnabledDate = (start: Date, delta: number) => {\n let candidate = addDays(start, delta)\n for (let i = 0; i < 31; i++) {\n if (!disabledDate?.(candidate)) return candidate\n candidate = addDays(candidate, delta)\n }\n return start\n }\n\n const handleKeyDown = (event: React.KeyboardEvent) => {\n if (!focusedDate) return\n let nextDate = focusedDate\n\n switch (event.key) {\n case 'ArrowRight':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, 1)\n break\n case 'ArrowLeft':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, -1)\n break\n case 'ArrowDown':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, 7)\n break\n case 'ArrowUp':\n event.preventDefault()\n nextDate = focusNextEnabledDate(focusedDate, -7)\n break\n case 'Home':\n event.preventDefault()\n nextDate = new Date(focusedDate.getFullYear(), focusedDate.getMonth(), 1)\n if (disabledDate?.(nextDate)) {\n nextDate = focusNextEnabledDate(nextDate, 1)\n }\n break\n case 'End':\n event.preventDefault()\n nextDate = new Date(focusedDate.getFullYear(), focusedDate.getMonth(), getDaysInMonth(focusedDate.getFullYear(), focusedDate.getMonth()))\n if (disabledDate?.(nextDate)) {\n nextDate = focusNextEnabledDate(nextDate, -1)\n }\n break\n case 'Enter':\n case ' ':\n event.preventDefault()\n handleDateSelect(focusedDate.getDate())\n return\n case 'Escape':\n event.preventDefault()\n setIsOpen(false)\n return\n default:\n return\n }\n\n setFocusedDate(nextDate)\n setViewMonth(nextDate.getMonth())\n setViewYear(nextDate.getFullYear())\n }\n\n const handlePrevMonth = () => {\n if (viewMonth === 0) {\n setViewMonth(11)\n setViewYear(viewYear - 1)\n } else {\n setViewMonth(viewMonth - 1)\n }\n }\n\n const handleNextMonth = () => {\n if (viewMonth === 11) {\n setViewMonth(0)\n setViewYear(viewYear + 1)\n } else {\n setViewMonth(viewMonth + 1)\n }\n }\n\n const daysInMonth = getDaysInMonth(viewYear, viewMonth)\n const firstDayOfMonth = getFirstDayOfMonth(viewYear, viewMonth)\n\n const calendarDays: (number | null)[] = []\n for (let i = 0; i < firstDayOfMonth; i++) {\n calendarDays.push(null)\n }\n for (let i = 1; i <= daysInMonth; i++) {\n calendarDays.push(i)\n }\n\n const isToday = (day: number | null): boolean => {\n if (!day) return false\n const today = new Date()\n return (\n today.getDate() === day &&\n today.getMonth() === viewMonth &&\n today.getFullYear() === viewYear\n )\n }\n\n const [rangeStart, rangeEnd] = selectedRange\n\n return (\n <div ref={ref || containerRef} className={`relative ${className}`} data-state={isOpen ? 'open' : 'closed'} data-testid={testId} {...rest}>\n <Input\n value={formatRange(selectedRange, format)}\n placeholder={resolvedPlaceholder}\n disabled={disabled}\n size={effectiveSize}\n readOnly\n onClick={() => !disabled && setIsOpen(!isOpen)}\n aria-haspopup=\"dialog\"\n aria-expanded={isOpen}\n aria-controls={calendarId}\n className=\"cursor-pointer\"\n data-testid={getTestId('input')}\n />\n\n {isOpen && (\n <div\n ref={calendarRef}\n id={calendarId}\n role=\"dialog\"\n aria-label=\"Date range picker calendar\"\n className=\"absolute top-full left-0 mt-2 bg-base-100 border border-base-300 rounded-lg shadow-lg p-4 z-50 w-80\"\n data-testid={getTestId('calendar')}\n >\n {/* Header */}\n <div className=\"flex items-center justify-between mb-4\">\n <button\n type=\"button\"\n onClick={handlePrevMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n <div className=\"text-base font-semibold\">\n {MONTHS[viewMonth]} {viewYear}\n </div>\n\n <button\n type=\"button\"\n onClick={handleNextMonth}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm} ${dBtnSquare}`}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n className=\"h-5 w-5\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n </div>\n\n {/* Days of week */}\n <div className=\"grid grid-cols-7 gap-1 mb-2\" role=\"row\">\n {DAYS.map((day) => (\n <div\n key={day}\n className=\"text-center text-xs font-semibold text-base-content/60 py-2\"\n role=\"columnheader\"\n >\n {day}\n </div>\n ))}\n </div>\n\n {/* Calendar grid */}\n <div className=\"grid grid-cols-7 gap-1\" role=\"grid\" onKeyDown={handleKeyDown}>\n {calendarDays.map((day, index) => {\n const dayDate = day ? new Date(viewYear, viewMonth, day) : null\n const isDayDisabled = disabled || (!!dayDate && !!disabledDate?.(dayDate))\n const isStart = !!dayDate && !!rangeStart && isSameDay(dayDate, rangeStart)\n const isEnd = !!dayDate && !!rangeEnd && isSameDay(dayDate, rangeEnd)\n const isInRange = !!dayDate && !!rangeStart && !!rangeEnd\n && isAfterDay(dayDate, rangeStart)\n && isBeforeDay(dayDate, rangeEnd)\n const isFocusedDay = !!dayDate && !!focusedDate && isSameDay(dayDate, focusedDate)\n\n return (\n <button\n key={index}\n type=\"button\"\n disabled={!day || isDayDisabled}\n aria-disabled={isDayDisabled || undefined}\n aria-selected={isStart || isEnd || isInRange || undefined}\n role=\"gridcell\"\n onClick={() => day && handleDateSelect(day)}\n tabIndex={isFocusedDay ? 0 : -1}\n data-calendar-focus={isFocusedDay ? 'true' : undefined}\n className={`\n aspect-square flex items-center justify-center text-sm rounded-lg\n ${!day ? 'invisible' : ''}\n ${day && !isDayDisabled ? 'hover:bg-base-200 cursor-pointer' : ''}\n ${isInRange ? 'bg-primary/10' : ''}\n ${isStart || isEnd ? 'bg-primary text-primary-content hover:bg-primary/90' : ''}\n ${isToday(day) && !isStart && !isEnd ? 'border border-primary' : ''}\n ${isDayDisabled ? 'text-base-content/30 cursor-not-allowed' : ''}\n `}\n >\n {day}\n </button>\n )\n })}\n </div>\n\n {/* Today button */}\n <div className=\"mt-4 flex justify-end\">\n <button\n type=\"button\"\n onClick={() => {\n const today = new Date()\n if (disabledDate?.(today)) return\n setSelectedRange([today, today])\n setViewMonth(today.getMonth())\n setViewYear(today.getFullYear())\n onChange?.([today, today])\n setIsOpen(false)\n }}\n className={`${dBtn} ${dBtnGhost} ${dBtnSm}`}\n disabled={isTodayDisabled}\n >\n {todayLabel}\n </button>\n </div>\n </div>\n )}\n </div>\n )\n})\n\nDatePickerComponent.displayName = 'DatePicker'\nDateRangePicker.displayName = 'DatePicker.Range'\n\ntype DatePickerType = typeof DatePickerComponent & {\n Range: typeof DateRangePicker\n}\n\nexport const DatePicker = DatePickerComponent as DatePickerType\nDatePicker.Range = DateRangePicker\n"],"names":["dBtn","dBtnGhost","dBtnSm","dBtnSquare","DAYS","MONTHS","formatDate","date","format","year","month","day","getDaysInMonth","getFirstDayOfMonth","stripTime","isSameDay","a","b","isBeforeDay","isAfterDay","addDays","amount","next","formatRange","range","start","end","DatePickerComponent","forwardRef","value","defaultValue","onChange","placeholder","disabledDate","disabled","size","testId","className","rest","ref","componentSize","locale","useConfig","effectiveSize","resolvedPlaceholder","todayLabel","todayDate","isTodayDisabled","getTestId","suffix","selectedDate","setSelectedDate","useState","isOpen","setIsOpen","focusedDate","setFocusedDate","viewMonth","setViewMonth","viewYear","setViewYear","containerRef","useRef","calendarRef","calendarId","React","useEffect","handleClickOutside","event","handleDateSelect","newDate","focusNextEnabledDate","delta","candidate","i","handleKeyDown","nextDate","handlePrevMonth","handleNextMonth","daysInMonth","firstDayOfMonth","calendarDays","isSelectedDay","isToday","today","jsx","Input","jsxs","index","dayDate","isDayDisabled","isFocusedDay","DateRangePicker","localeRangePlaceholder","startPlaceholder","endPlaceholder","selectedRange","setSelectedRange","initialDate","nextRange","rangeStart","rangeEnd","isStart","isEnd","isInRange","DatePicker"],"mappings":";;;;AAKA,MAAMA,IAAO,OACPC,IAAY,aACZC,IAAS,UACTC,KAAa,cA8BbC,KAAO,CAAC,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM,IAAI,GAChDC,KAAS;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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