asterui 0.12.64 → 0.12.66
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/AspectRatio.d.ts +9 -0
- package/dist/components/AspectRatio.js +14 -0
- package/dist/components/AspectRatio.js.map +1 -0
- package/dist/components/DatePicker.d.ts +2 -0
- package/dist/components/DatePicker.js +445 -302
- package/dist/components/DatePicker.js.map +1 -1
- package/dist/components/Image.js +85 -77
- package/dist/components/Image.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +261 -259
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -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
|