asterui 0.12.70 → 0.12.72
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.
- package/dist/components/DateOfBirth.d.ts +39 -0
- package/dist/components/DateOfBirth.js +189 -0
- package/dist/components/DateOfBirth.js.map +1 -0
- package/dist/components/DatePicker.js +183 -173
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/Form.d.ts +2 -0
- package/dist/components/Form.js +107 -105
- package/dist/components/Form.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +227 -224
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as F, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { Input as
|
|
4
|
-
import { useConfig as
|
|
5
|
-
const
|
|
2
|
+
import be, { forwardRef as ve, useState as R, useRef as te, useCallback as ye, useEffect as L } from "react";
|
|
3
|
+
import { Input as Me } from "./Input.js";
|
|
4
|
+
import { useConfig as $e } from "../providers/ConfigProvider.js";
|
|
5
|
+
const I = "btn", B = "btn-ghost", j = "btn-sm", ne = "btn-square", xe = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], ke = [
|
|
6
6
|
"January",
|
|
7
7
|
"February",
|
|
8
8
|
"March",
|
|
@@ -16,104 +16,109 @@ const z = "btn", L = "btn-ghost", I = "btn-sm", te = "btn-square", Me = ["Su", "
|
|
|
16
16
|
"November",
|
|
17
17
|
"December"
|
|
18
18
|
];
|
|
19
|
-
function
|
|
19
|
+
function _(o, a = "MM/DD/YYYY") {
|
|
20
20
|
if (!o) return "";
|
|
21
|
-
const
|
|
22
|
-
return a.replace("YYYY", String(
|
|
21
|
+
const p = o.getFullYear(), k = String(o.getMonth() + 1).padStart(2, "0"), q = String(o.getDate()).padStart(2, "0");
|
|
22
|
+
return a.replace("YYYY", String(p)).replace("MM", k).replace("DD", q);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function re(o, a) {
|
|
25
25
|
return new Date(o, a + 1, 0).getDate();
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function Ne(o, a) {
|
|
28
28
|
return new Date(o, a, 1).getDay();
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function ae(o) {
|
|
31
31
|
return new Date(o.getFullYear(), o.getMonth(), o.getDate());
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function ee(o, a) {
|
|
34
34
|
return o.getFullYear() === a.getFullYear() && o.getMonth() === a.getMonth() && o.getDate() === a.getDate();
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
return
|
|
36
|
+
function we(o, a) {
|
|
37
|
+
return ae(o).getTime() < ae(a).getTime();
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function Se(o, a) {
|
|
40
|
+
return ae(o).getTime() > ae(a).getTime();
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
return
|
|
42
|
+
function oe(o, a) {
|
|
43
|
+
const p = new Date(o);
|
|
44
|
+
return p.setDate(p.getDate() + a), p;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
47
|
-
const [
|
|
48
|
-
return
|
|
46
|
+
function Fe(o, a = "MM/DD/YYYY") {
|
|
47
|
+
const [p, k] = o;
|
|
48
|
+
return p && k ? `${_(p, a)} - ${_(k, a)}` : p ? `${_(p, a)} - ` : "";
|
|
49
49
|
}
|
|
50
|
-
const
|
|
50
|
+
const Ye = ve(function({
|
|
51
51
|
value: a,
|
|
52
|
-
defaultValue:
|
|
53
|
-
onChange:
|
|
54
|
-
format:
|
|
55
|
-
placeholder:
|
|
52
|
+
defaultValue: p,
|
|
53
|
+
onChange: k,
|
|
54
|
+
format: q,
|
|
55
|
+
placeholder: T,
|
|
56
56
|
disabledDate: d,
|
|
57
57
|
disabled: v = !1,
|
|
58
|
-
size:
|
|
59
|
-
"data-testid":
|
|
60
|
-
className:
|
|
61
|
-
...
|
|
62
|
-
},
|
|
63
|
-
const { componentSize: ie, locale:
|
|
64
|
-
a ||
|
|
65
|
-
), [
|
|
66
|
-
|
|
67
|
-
), [D, P] =
|
|
68
|
-
|
|
69
|
-
), f =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
58
|
+
size: se,
|
|
59
|
+
"data-testid": C,
|
|
60
|
+
className: le = "",
|
|
61
|
+
...ce
|
|
62
|
+
}, y) {
|
|
63
|
+
const { componentSize: ie, locale: K } = $e(), ue = se ?? ie ?? "md", G = T ?? K?.DatePicker?.placeholder ?? "Select date", W = K?.DatePicker?.today ?? "Today", V = /* @__PURE__ */ new Date(), de = v || d?.(V), Q = (e) => C ? `${C}-${e}` : void 0, [h, H] = R(
|
|
64
|
+
a || p || null
|
|
65
|
+
), [M, m] = R(!1), [i, $] = R(null), [u, c] = R(
|
|
66
|
+
h ? h.getMonth() : (/* @__PURE__ */ new Date()).getMonth()
|
|
67
|
+
), [D, P] = R(
|
|
68
|
+
h ? h.getFullYear() : (/* @__PURE__ */ new Date()).getFullYear()
|
|
69
|
+
), f = te(null), N = te(null), w = be.useId(), E = ye(
|
|
70
|
+
(e) => {
|
|
71
|
+
f.current = e, y && (typeof y == "function" ? y(e) : y.current = e);
|
|
72
|
+
},
|
|
73
|
+
[y]
|
|
74
|
+
);
|
|
75
|
+
L(() => {
|
|
76
|
+
a !== void 0 && H(a);
|
|
77
|
+
}, [a]), L(() => {
|
|
73
78
|
function e(n) {
|
|
74
79
|
f.current && !f.current.contains(n.target) && m(!1);
|
|
75
80
|
}
|
|
76
|
-
if (
|
|
77
|
-
return document.addEventListener("mousedown", e),
|
|
78
|
-
}, [
|
|
79
|
-
if (!
|
|
80
|
-
|
|
81
|
-
}, [
|
|
82
|
-
const
|
|
81
|
+
if (M)
|
|
82
|
+
return document.addEventListener("mousedown", e), $(h ?? V), () => document.removeEventListener("mousedown", e);
|
|
83
|
+
}, [M]), L(() => {
|
|
84
|
+
if (!M || !N.current) return;
|
|
85
|
+
N.current.querySelector('[data-calendar-focus="true"]')?.focus();
|
|
86
|
+
}, [M, u, D, i]);
|
|
87
|
+
const O = (e) => {
|
|
83
88
|
const n = new Date(D, u, e);
|
|
84
|
-
v || d?.(n) || (
|
|
85
|
-
},
|
|
86
|
-
let
|
|
89
|
+
v || d?.(n) || (H(n), k?.(n), m(!1));
|
|
90
|
+
}, Y = (e, n) => {
|
|
91
|
+
let x = oe(e, n);
|
|
87
92
|
for (let b = 0; b < 31; b++) {
|
|
88
|
-
if (!d?.(
|
|
89
|
-
|
|
93
|
+
if (!d?.(x)) return x;
|
|
94
|
+
x = oe(x, n);
|
|
90
95
|
}
|
|
91
96
|
return e;
|
|
92
|
-
},
|
|
97
|
+
}, X = (e) => {
|
|
93
98
|
if (!i) return;
|
|
94
99
|
let n = i;
|
|
95
100
|
switch (e.key) {
|
|
96
101
|
case "ArrowRight":
|
|
97
|
-
e.preventDefault(), n =
|
|
102
|
+
e.preventDefault(), n = Y(i, 1);
|
|
98
103
|
break;
|
|
99
104
|
case "ArrowLeft":
|
|
100
|
-
e.preventDefault(), n =
|
|
105
|
+
e.preventDefault(), n = Y(i, -1);
|
|
101
106
|
break;
|
|
102
107
|
case "ArrowDown":
|
|
103
|
-
e.preventDefault(), n =
|
|
108
|
+
e.preventDefault(), n = Y(i, 7);
|
|
104
109
|
break;
|
|
105
110
|
case "ArrowUp":
|
|
106
|
-
e.preventDefault(), n =
|
|
111
|
+
e.preventDefault(), n = Y(i, -7);
|
|
107
112
|
break;
|
|
108
113
|
case "Home":
|
|
109
|
-
e.preventDefault(), n = new Date(i.getFullYear(), i.getMonth(), 1), d?.(n) && (n =
|
|
114
|
+
e.preventDefault(), n = new Date(i.getFullYear(), i.getMonth(), 1), d?.(n) && (n = Y(n, 1));
|
|
110
115
|
break;
|
|
111
116
|
case "End":
|
|
112
|
-
e.preventDefault(), n = new Date(i.getFullYear(), i.getMonth(),
|
|
117
|
+
e.preventDefault(), n = new Date(i.getFullYear(), i.getMonth(), re(i.getFullYear(), i.getMonth())), d?.(n) && (n = Y(n, -1));
|
|
113
118
|
break;
|
|
114
119
|
case "Enter":
|
|
115
120
|
case " ":
|
|
116
|
-
e.preventDefault(),
|
|
121
|
+
e.preventDefault(), O(i.getDate());
|
|
117
122
|
return;
|
|
118
123
|
case "Escape":
|
|
119
124
|
e.preventDefault(), m(!1);
|
|
@@ -121,55 +126,55 @@ const ke = be(function({
|
|
|
121
126
|
default:
|
|
122
127
|
return;
|
|
123
128
|
}
|
|
124
|
-
|
|
125
|
-
},
|
|
129
|
+
$(n), c(n.getMonth()), P(n.getFullYear());
|
|
130
|
+
}, fe = () => {
|
|
126
131
|
u === 0 ? (c(11), P(D - 1)) : c(u - 1);
|
|
127
|
-
},
|
|
132
|
+
}, Z = () => {
|
|
128
133
|
u === 11 ? (c(0), P(D + 1)) : c(u + 1);
|
|
129
|
-
}, S =
|
|
130
|
-
for (let e = 0; e <
|
|
131
|
-
|
|
134
|
+
}, S = re(D, u), ge = Ne(D, u), J = [];
|
|
135
|
+
for (let e = 0; e < ge; e++)
|
|
136
|
+
J.push(null);
|
|
132
137
|
for (let e = 1; e <= S; e++)
|
|
133
|
-
|
|
134
|
-
const
|
|
138
|
+
J.push(e);
|
|
139
|
+
const U = (e) => !e || !h ? !1 : h.getDate() === e && h.getMonth() === u && h.getFullYear() === D, pe = (e) => {
|
|
135
140
|
if (!e) return !1;
|
|
136
141
|
const n = /* @__PURE__ */ new Date();
|
|
137
142
|
return n.getDate() === e && n.getMonth() === u && n.getFullYear() === D;
|
|
138
143
|
};
|
|
139
|
-
return /* @__PURE__ */ F("div", { ref:
|
|
144
|
+
return /* @__PURE__ */ F("div", { ref: E, className: `relative ${le}`, "data-state": M ? "open" : "closed", "data-testid": C, ...ce, children: [
|
|
140
145
|
/* @__PURE__ */ l(
|
|
141
|
-
|
|
146
|
+
Me,
|
|
142
147
|
{
|
|
143
|
-
value:
|
|
144
|
-
placeholder:
|
|
148
|
+
value: _(h, q),
|
|
149
|
+
placeholder: G,
|
|
145
150
|
disabled: v,
|
|
146
151
|
size: ue,
|
|
147
152
|
readOnly: !0,
|
|
148
|
-
onClick: () => !v && m(!
|
|
153
|
+
onClick: () => !v && m(!M),
|
|
149
154
|
"aria-haspopup": "dialog",
|
|
150
|
-
"aria-expanded":
|
|
155
|
+
"aria-expanded": M,
|
|
151
156
|
"aria-controls": w,
|
|
152
157
|
className: "cursor-pointer",
|
|
153
|
-
"data-testid":
|
|
158
|
+
"data-testid": Q("input")
|
|
154
159
|
}
|
|
155
160
|
),
|
|
156
|
-
|
|
161
|
+
M && /* @__PURE__ */ F(
|
|
157
162
|
"div",
|
|
158
163
|
{
|
|
159
|
-
ref:
|
|
164
|
+
ref: N,
|
|
160
165
|
id: w,
|
|
161
166
|
role: "dialog",
|
|
162
167
|
"aria-label": "Date picker calendar",
|
|
163
168
|
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":
|
|
169
|
+
"data-testid": Q("calendar"),
|
|
165
170
|
children: [
|
|
166
171
|
/* @__PURE__ */ F("div", { className: "flex items-center justify-between mb-4", children: [
|
|
167
172
|
/* @__PURE__ */ l(
|
|
168
173
|
"button",
|
|
169
174
|
{
|
|
170
175
|
type: "button",
|
|
171
|
-
onClick:
|
|
172
|
-
className: `${
|
|
176
|
+
onClick: fe,
|
|
177
|
+
className: `${I} ${B} ${j} ${ne}`,
|
|
173
178
|
children: /* @__PURE__ */ l(
|
|
174
179
|
"svg",
|
|
175
180
|
{
|
|
@@ -190,7 +195,7 @@ const ke = be(function({
|
|
|
190
195
|
}
|
|
191
196
|
),
|
|
192
197
|
/* @__PURE__ */ F("div", { className: "text-base font-semibold", children: [
|
|
193
|
-
|
|
198
|
+
ke[u],
|
|
194
199
|
" ",
|
|
195
200
|
D
|
|
196
201
|
] }),
|
|
@@ -198,8 +203,8 @@ const ke = be(function({
|
|
|
198
203
|
"button",
|
|
199
204
|
{
|
|
200
205
|
type: "button",
|
|
201
|
-
onClick:
|
|
202
|
-
className: `${
|
|
206
|
+
onClick: Z,
|
|
207
|
+
className: `${I} ${B} ${j} ${ne}`,
|
|
203
208
|
children: /* @__PURE__ */ l(
|
|
204
209
|
"svg",
|
|
205
210
|
{
|
|
@@ -220,7 +225,7 @@ const ke = be(function({
|
|
|
220
225
|
}
|
|
221
226
|
)
|
|
222
227
|
] }),
|
|
223
|
-
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1 mb-2", role: "row", children:
|
|
228
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1 mb-2", role: "row", children: xe.map((e) => /* @__PURE__ */ l(
|
|
224
229
|
"div",
|
|
225
230
|
{
|
|
226
231
|
className: "text-center text-xs font-semibold text-base-content/60 py-2",
|
|
@@ -229,25 +234,25 @@ const ke = be(function({
|
|
|
229
234
|
},
|
|
230
235
|
e
|
|
231
236
|
)) }),
|
|
232
|
-
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1", role: "grid", onKeyDown:
|
|
233
|
-
const
|
|
237
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1", role: "grid", onKeyDown: X, children: J.map((e, n) => {
|
|
238
|
+
const x = e ? new Date(D, u, e) : null, b = v || !!x && !!d?.(x), A = !!x && !!i && ee(x, i);
|
|
234
239
|
return /* @__PURE__ */ l(
|
|
235
240
|
"button",
|
|
236
241
|
{
|
|
237
242
|
type: "button",
|
|
238
243
|
disabled: !e || b,
|
|
239
244
|
"aria-disabled": b || void 0,
|
|
240
|
-
"aria-selected":
|
|
245
|
+
"aria-selected": U(e) || void 0,
|
|
241
246
|
role: "gridcell",
|
|
242
|
-
onClick: () => e &&
|
|
243
|
-
tabIndex:
|
|
244
|
-
"data-calendar-focus":
|
|
247
|
+
onClick: () => e && O(e),
|
|
248
|
+
tabIndex: A ? 0 : -1,
|
|
249
|
+
"data-calendar-focus": A ? "true" : void 0,
|
|
245
250
|
className: `
|
|
246
251
|
aspect-square flex items-center justify-center text-sm rounded-lg
|
|
247
252
|
${e ? "" : "invisible"}
|
|
248
253
|
${e && !b ? "hover:bg-base-200 cursor-pointer" : ""}
|
|
249
|
-
${
|
|
250
|
-
${
|
|
254
|
+
${U(e) ? "bg-primary text-primary-content hover:bg-primary/90" : ""}
|
|
255
|
+
${pe(e) && !U(e) ? "border border-primary" : ""}
|
|
251
256
|
${b ? "text-base-content/30 cursor-not-allowed" : ""}
|
|
252
257
|
`,
|
|
253
258
|
children: e
|
|
@@ -261,63 +266,68 @@ const ke = be(function({
|
|
|
261
266
|
type: "button",
|
|
262
267
|
onClick: () => {
|
|
263
268
|
const e = /* @__PURE__ */ new Date();
|
|
264
|
-
d?.(e) || (
|
|
269
|
+
d?.(e) || (H(e), c(e.getMonth()), P(e.getFullYear()), k?.(e), m(!1));
|
|
265
270
|
},
|
|
266
|
-
className: `${
|
|
271
|
+
className: `${I} ${B} ${j}`,
|
|
267
272
|
disabled: de,
|
|
268
|
-
children:
|
|
273
|
+
children: W
|
|
269
274
|
}
|
|
270
275
|
) })
|
|
271
276
|
]
|
|
272
277
|
}
|
|
273
278
|
)
|
|
274
279
|
] });
|
|
275
|
-
}),
|
|
280
|
+
}), Re = ve(function({
|
|
276
281
|
value: a,
|
|
277
|
-
defaultValue:
|
|
278
|
-
onChange:
|
|
279
|
-
format:
|
|
280
|
-
placeholder:
|
|
282
|
+
defaultValue: p,
|
|
283
|
+
onChange: k,
|
|
284
|
+
format: q,
|
|
285
|
+
placeholder: T,
|
|
281
286
|
disabledDate: d,
|
|
282
287
|
disabled: v = !1,
|
|
283
|
-
size:
|
|
284
|
-
"data-testid":
|
|
285
|
-
className:
|
|
286
|
-
...
|
|
287
|
-
},
|
|
288
|
-
const { componentSize: ie, locale:
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
], de = Array.isArray(
|
|
292
|
-
a ||
|
|
293
|
-
), [
|
|
294
|
-
|
|
288
|
+
size: se,
|
|
289
|
+
"data-testid": C,
|
|
290
|
+
className: le = "",
|
|
291
|
+
...ce
|
|
292
|
+
}, y) {
|
|
293
|
+
const { componentSize: ie, locale: K } = $e(), ue = se ?? ie ?? "md", G = K?.DatePicker?.rangePlaceholder, [W, V] = Array.isArray(T) ? T : [
|
|
294
|
+
T ?? G?.[0] ?? "Start date",
|
|
295
|
+
G?.[1] ?? "End date"
|
|
296
|
+
], de = Array.isArray(T) ? `${W} - ${V}` : T ?? `${W} - ${V}`, Q = K?.DatePicker?.today ?? "Today", h = /* @__PURE__ */ new Date(), H = v || d?.(h), M = (t) => C ? `${C}-${t}` : void 0, [m, i] = R(
|
|
297
|
+
a || p || [null, null]
|
|
298
|
+
), [$, u] = R(!1), [c, D] = R(null), P = m[0] ?? m[1] ?? /* @__PURE__ */ new Date(), [f, N] = R(P.getMonth()), [w, E] = R(P.getFullYear()), O = te(null), Y = te(null), X = be.useId(), fe = ye(
|
|
299
|
+
(t) => {
|
|
300
|
+
O.current = t, y && (typeof y == "function" ? y(t) : y.current = t);
|
|
301
|
+
},
|
|
302
|
+
[y]
|
|
303
|
+
);
|
|
304
|
+
L(() => {
|
|
295
305
|
a !== void 0 && i(a);
|
|
296
|
-
}, [a]),
|
|
306
|
+
}, [a]), L(() => {
|
|
297
307
|
function t(r) {
|
|
298
|
-
|
|
308
|
+
O.current && !O.current.contains(r.target) && u(!1);
|
|
299
309
|
}
|
|
300
|
-
if (
|
|
301
|
-
return document.addEventListener("mousedown", t), D(m[0] ?? m[1] ??
|
|
302
|
-
}, [
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
}, [
|
|
306
|
-
const
|
|
310
|
+
if ($)
|
|
311
|
+
return document.addEventListener("mousedown", t), D(m[0] ?? m[1] ?? h), () => document.removeEventListener("mousedown", t);
|
|
312
|
+
}, [$]), L(() => {
|
|
313
|
+
if (!$ || !Y.current) return;
|
|
314
|
+
Y.current.querySelector('[data-calendar-focus="true"]')?.focus();
|
|
315
|
+
}, [$, f, w, c]);
|
|
316
|
+
const Z = (t) => {
|
|
307
317
|
const r = new Date(w, f, t);
|
|
308
318
|
if (v || d?.(r)) return;
|
|
309
319
|
let [s, g] = m;
|
|
310
|
-
!s || s && g ? (s = r, g = null) : s && !g && (
|
|
311
|
-
const
|
|
312
|
-
i(
|
|
320
|
+
!s || s && g ? (s = r, g = null) : s && !g && (we(r, s) ? (g = s, s = r) : g = r);
|
|
321
|
+
const z = [s, g];
|
|
322
|
+
i(z), k?.(z), s && g && u(!1);
|
|
313
323
|
}, S = (t, r) => {
|
|
314
|
-
let s =
|
|
324
|
+
let s = oe(t, r);
|
|
315
325
|
for (let g = 0; g < 31; g++) {
|
|
316
326
|
if (!d?.(s)) return s;
|
|
317
|
-
s =
|
|
327
|
+
s = oe(s, r);
|
|
318
328
|
}
|
|
319
329
|
return t;
|
|
320
|
-
},
|
|
330
|
+
}, ge = (t) => {
|
|
321
331
|
if (!c) return;
|
|
322
332
|
let r = c;
|
|
323
333
|
switch (t.key) {
|
|
@@ -337,11 +347,11 @@ const ke = be(function({
|
|
|
337
347
|
t.preventDefault(), r = new Date(c.getFullYear(), c.getMonth(), 1), d?.(r) && (r = S(r, 1));
|
|
338
348
|
break;
|
|
339
349
|
case "End":
|
|
340
|
-
t.preventDefault(), r = new Date(c.getFullYear(), c.getMonth(),
|
|
350
|
+
t.preventDefault(), r = new Date(c.getFullYear(), c.getMonth(), re(c.getFullYear(), c.getMonth())), d?.(r) && (r = S(r, -1));
|
|
341
351
|
break;
|
|
342
352
|
case "Enter":
|
|
343
353
|
case " ":
|
|
344
|
-
t.preventDefault(),
|
|
354
|
+
t.preventDefault(), Z(c.getDate());
|
|
345
355
|
return;
|
|
346
356
|
case "Escape":
|
|
347
357
|
t.preventDefault(), u(!1);
|
|
@@ -349,55 +359,55 @@ const ke = be(function({
|
|
|
349
359
|
default:
|
|
350
360
|
return;
|
|
351
361
|
}
|
|
352
|
-
D(r),
|
|
353
|
-
}, H = () => {
|
|
354
|
-
f === 0 ? (k(11), A(w - 1)) : k(f - 1);
|
|
362
|
+
D(r), N(r.getMonth()), E(r.getFullYear());
|
|
355
363
|
}, J = () => {
|
|
356
|
-
f ===
|
|
357
|
-
},
|
|
364
|
+
f === 0 ? (N(11), E(w - 1)) : N(f - 1);
|
|
365
|
+
}, U = () => {
|
|
366
|
+
f === 11 ? (N(0), E(w + 1)) : N(f + 1);
|
|
367
|
+
}, pe = re(w, f), e = Ne(w, f), n = [];
|
|
358
368
|
for (let t = 0; t < e; t++)
|
|
359
369
|
n.push(null);
|
|
360
|
-
for (let t = 1; t <=
|
|
370
|
+
for (let t = 1; t <= pe; t++)
|
|
361
371
|
n.push(t);
|
|
362
|
-
const
|
|
372
|
+
const x = (t) => {
|
|
363
373
|
if (!t) return !1;
|
|
364
374
|
const r = /* @__PURE__ */ new Date();
|
|
365
375
|
return r.getDate() === t && r.getMonth() === f && r.getFullYear() === w;
|
|
366
|
-
}, [b,
|
|
367
|
-
return /* @__PURE__ */ F("div", { ref:
|
|
376
|
+
}, [b, A] = m;
|
|
377
|
+
return /* @__PURE__ */ F("div", { ref: fe, className: `relative ${le}`, "data-state": $ ? "open" : "closed", "data-testid": C, ...ce, children: [
|
|
368
378
|
/* @__PURE__ */ l(
|
|
369
|
-
|
|
379
|
+
Me,
|
|
370
380
|
{
|
|
371
|
-
value:
|
|
381
|
+
value: Fe(m, q),
|
|
372
382
|
placeholder: de,
|
|
373
383
|
disabled: v,
|
|
374
384
|
size: ue,
|
|
375
385
|
readOnly: !0,
|
|
376
|
-
onClick: () => !v && u(
|
|
386
|
+
onClick: () => !v && u(!$),
|
|
377
387
|
"aria-haspopup": "dialog",
|
|
378
|
-
"aria-expanded":
|
|
379
|
-
"aria-controls":
|
|
388
|
+
"aria-expanded": $,
|
|
389
|
+
"aria-controls": X,
|
|
380
390
|
className: "cursor-pointer",
|
|
381
|
-
"data-testid":
|
|
391
|
+
"data-testid": M("input")
|
|
382
392
|
}
|
|
383
393
|
),
|
|
384
|
-
|
|
394
|
+
$ && /* @__PURE__ */ F(
|
|
385
395
|
"div",
|
|
386
396
|
{
|
|
387
|
-
ref:
|
|
388
|
-
id:
|
|
397
|
+
ref: Y,
|
|
398
|
+
id: X,
|
|
389
399
|
role: "dialog",
|
|
390
400
|
"aria-label": "Date range picker calendar",
|
|
391
401
|
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":
|
|
402
|
+
"data-testid": M("calendar"),
|
|
393
403
|
children: [
|
|
394
404
|
/* @__PURE__ */ F("div", { className: "flex items-center justify-between mb-4", children: [
|
|
395
405
|
/* @__PURE__ */ l(
|
|
396
406
|
"button",
|
|
397
407
|
{
|
|
398
408
|
type: "button",
|
|
399
|
-
onClick:
|
|
400
|
-
className: `${
|
|
409
|
+
onClick: J,
|
|
410
|
+
className: `${I} ${B} ${j} ${ne}`,
|
|
401
411
|
children: /* @__PURE__ */ l(
|
|
402
412
|
"svg",
|
|
403
413
|
{
|
|
@@ -418,7 +428,7 @@ const ke = be(function({
|
|
|
418
428
|
}
|
|
419
429
|
),
|
|
420
430
|
/* @__PURE__ */ F("div", { className: "text-base font-semibold", children: [
|
|
421
|
-
|
|
431
|
+
ke[f],
|
|
422
432
|
" ",
|
|
423
433
|
w
|
|
424
434
|
] }),
|
|
@@ -426,8 +436,8 @@ const ke = be(function({
|
|
|
426
436
|
"button",
|
|
427
437
|
{
|
|
428
438
|
type: "button",
|
|
429
|
-
onClick:
|
|
430
|
-
className: `${
|
|
439
|
+
onClick: U,
|
|
440
|
+
className: `${I} ${B} ${j} ${ne}`,
|
|
431
441
|
children: /* @__PURE__ */ l(
|
|
432
442
|
"svg",
|
|
433
443
|
{
|
|
@@ -448,7 +458,7 @@ const ke = be(function({
|
|
|
448
458
|
}
|
|
449
459
|
)
|
|
450
460
|
] }),
|
|
451
|
-
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1 mb-2", role: "row", children:
|
|
461
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1 mb-2", role: "row", children: xe.map((t) => /* @__PURE__ */ l(
|
|
452
462
|
"div",
|
|
453
463
|
{
|
|
454
464
|
className: "text-center text-xs font-semibold text-base-content/60 py-2",
|
|
@@ -457,26 +467,26 @@ const ke = be(function({
|
|
|
457
467
|
},
|
|
458
468
|
t
|
|
459
469
|
)) }),
|
|
460
|
-
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1", role: "grid", onKeyDown:
|
|
461
|
-
const s = t ? new Date(w, f, t) : null, g = v || !!s && !!d?.(s),
|
|
470
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-7 gap-1", role: "grid", onKeyDown: ge, children: n.map((t, r) => {
|
|
471
|
+
const s = t ? new Date(w, f, t) : null, g = v || !!s && !!d?.(s), z = !!s && !!b && ee(s, b), he = !!s && !!A && ee(s, A), me = !!s && !!b && !!A && Se(s, b) && we(s, A), De = !!s && !!c && ee(s, c);
|
|
462
472
|
return /* @__PURE__ */ l(
|
|
463
473
|
"button",
|
|
464
474
|
{
|
|
465
475
|
type: "button",
|
|
466
476
|
disabled: !t || g,
|
|
467
477
|
"aria-disabled": g || void 0,
|
|
468
|
-
"aria-selected":
|
|
478
|
+
"aria-selected": z || he || me || void 0,
|
|
469
479
|
role: "gridcell",
|
|
470
|
-
onClick: () => t &&
|
|
471
|
-
tabIndex:
|
|
472
|
-
"data-calendar-focus":
|
|
480
|
+
onClick: () => t && Z(t),
|
|
481
|
+
tabIndex: De ? 0 : -1,
|
|
482
|
+
"data-calendar-focus": De ? "true" : void 0,
|
|
473
483
|
className: `
|
|
474
484
|
aspect-square flex items-center justify-center text-sm rounded-lg
|
|
475
485
|
${t ? "" : "invisible"}
|
|
476
486
|
${t && !g ? "hover:bg-base-200 cursor-pointer" : ""}
|
|
477
|
-
${
|
|
478
|
-
${
|
|
479
|
-
${
|
|
487
|
+
${me ? "bg-primary/10" : ""}
|
|
488
|
+
${z || he ? "bg-primary text-primary-content hover:bg-primary/90" : ""}
|
|
489
|
+
${x(t) && !z && !he ? "border border-primary" : ""}
|
|
480
490
|
${g ? "text-base-content/30 cursor-not-allowed" : ""}
|
|
481
491
|
`,
|
|
482
492
|
children: t
|
|
@@ -490,11 +500,11 @@ const ke = be(function({
|
|
|
490
500
|
type: "button",
|
|
491
501
|
onClick: () => {
|
|
492
502
|
const t = /* @__PURE__ */ new Date();
|
|
493
|
-
d?.(t) || (i([t, t]),
|
|
503
|
+
d?.(t) || (i([t, t]), N(t.getMonth()), E(t.getFullYear()), k?.([t, t]), u(!1));
|
|
494
504
|
},
|
|
495
|
-
className: `${
|
|
496
|
-
disabled:
|
|
497
|
-
children:
|
|
505
|
+
className: `${I} ${B} ${j}`,
|
|
506
|
+
disabled: H,
|
|
507
|
+
children: Q
|
|
498
508
|
}
|
|
499
509
|
) })
|
|
500
510
|
]
|
|
@@ -502,11 +512,11 @@ const ke = be(function({
|
|
|
502
512
|
)
|
|
503
513
|
] });
|
|
504
514
|
});
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
const
|
|
508
|
-
|
|
515
|
+
Ye.displayName = "DatePicker";
|
|
516
|
+
Re.displayName = "DatePicker.Range";
|
|
517
|
+
const Te = Ye;
|
|
518
|
+
Te.Range = Re;
|
|
509
519
|
export {
|
|
510
|
-
|
|
520
|
+
Te as DatePicker
|
|
511
521
|
};
|
|
512
522
|
//# sourceMappingURL=DatePicker.js.map
|