@dimasbaguspm/versaur 0.0.12 → 0.0.13
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/js/bottom-sheet-CBLNEX4F.js +281 -0
- package/dist/js/bottom-sheet.atoms-DFMOaMsU.js +78 -0
- package/dist/js/{calendar-De5dCVnE.js → calendar-B9rIZCdo.js} +318 -163
- package/dist/js/{index-DOdDlCoL.js → cn-BKwT3erk.js} +463 -788
- package/dist/js/enforce-subpath-import.js +1 -0
- package/dist/js/feedbacks/index.js +1 -1
- package/dist/js/{form-layout-BBDs1Y8m.js → form-layout-PLH-7bWq.js} +58 -57
- package/dist/js/forms/index.js +1 -1
- package/dist/js/index-Dmu_fHni.js +329 -0
- package/dist/js/index.js +32 -31
- package/dist/js/layouts/index.js +1 -1
- package/dist/js/{menu-Du409VIG.js → menu-oRrbZAAy.js} +56 -60
- package/dist/js/navigation/index.js +1 -1
- package/dist/js/overlays/index.js +5 -4
- package/dist/js/primitive/index.js +2 -2
- package/dist/js/{skeleton-BNZyaRjo.js → skeleton-Ma-Fcs06.js} +6 -5
- package/dist/js/{switch-input-B-pwBWbi.js → switch-input-o8oO4Rf4.js} +482 -435
- package/dist/js/{tabs-BbOkYchB.js → tabs-DSeR5XxX.js} +6 -5
- package/dist/js/{tile-6SeBYc08.js → tile-8hqVMf2m.js} +110 -139
- package/dist/types/forms/chip-input/types.d.ts +16 -0
- package/dist/types/forms/date-range-picker-input/date-range-picker-input.d.ts +10 -0
- package/dist/types/forms/date-range-picker-input/index.d.ts +2 -0
- package/dist/types/forms/date-range-picker-input/types.d.ts +64 -0
- package/dist/types/forms/date-range-picker-input/use-date-range-picker.d.ts +13 -0
- package/dist/types/overlays/bottom-sheet/bottom-sheet.atoms.d.ts +17 -0
- package/dist/types/overlays/bottom-sheet/bottom-sheet.d.ts +7 -0
- package/dist/types/overlays/bottom-sheet/index.d.ts +2 -0
- package/dist/types/overlays/bottom-sheet/types.d.ts +22 -0
- package/dist/types/overlays/drawer/drawer.atoms.d.ts +2 -1
- package/dist/types/overlays/drawer/drawer.d.ts +1 -0
- package/dist/types/overlays/drawer/types.d.ts +6 -3
- package/dist/types/overlays/index.d.ts +1 -0
- package/dist/types/primitive/calendar/calendar.atoms.d.ts +13 -0
- package/dist/types/primitive/calendar/index.d.ts +1 -1
- package/dist/types/primitive/calendar/types.d.ts +38 -4
- package/dist/types/primitive/calendar/use-calendar.d.ts +18 -0
- package/package.json +1 -1
- package/dist/js/drawer-Cn7sreJG.js +0 -221
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React__default, { forwardRef, useState, useRef, useEffect, useCallback } from "react";
|
|
1
|
+
import { a as cva, j as jsxRuntimeExports } from "./index-Dmu_fHni.js";
|
|
2
|
+
import React__default, { forwardRef, useState, useRef, useEffect, useCallback, createContext, useContext } from "react";
|
|
3
|
+
import { c as cn } from "./cn-BKwT3erk.js";
|
|
3
4
|
import { X, ChevronLeft, ChevronRight } from "lucide-react";
|
|
4
5
|
const calculatorRootVariants = cva(
|
|
5
6
|
"flex flex-col w-full max-w-xs rounded-lg bg-background",
|
|
@@ -34,10 +35,10 @@ const calculatorRootVariants = cva(
|
|
|
34
35
|
disabled: !1
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
), CalculatorButton = forwardRef(({ variant: r = "default", className: e, ...t },
|
|
38
|
+
), CalculatorButton = forwardRef(({ variant: r = "default", className: e, ...t }, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
38
39
|
"button",
|
|
39
40
|
{
|
|
40
|
-
ref:
|
|
41
|
+
ref: i,
|
|
41
42
|
type: "button",
|
|
42
43
|
className: cn(
|
|
43
44
|
calculatorButtonVariants({ variant: r, disabled: t.disabled }),
|
|
@@ -165,49 +166,49 @@ const buttonIconVariants = cva(
|
|
|
165
166
|
size: "md",
|
|
166
167
|
color: "primary"
|
|
167
168
|
}
|
|
168
|
-
}), Icon = React__default.forwardRef(function({ as: e, color: t = "primary", size:
|
|
169
|
+
}), Icon = React__default.forwardRef(function({ as: e, color: t = "primary", size: i = "md", className: l, ...n }, a) {
|
|
169
170
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
170
171
|
e,
|
|
171
172
|
{
|
|
172
|
-
ref:
|
|
173
|
-
className: iconVariants({ color: t, size:
|
|
174
|
-
...
|
|
173
|
+
ref: a,
|
|
174
|
+
className: iconVariants({ color: t, size: i, className: l }),
|
|
175
|
+
...n
|
|
175
176
|
}
|
|
176
177
|
);
|
|
177
178
|
}), ButtonIcon = React__default.forwardRef(
|
|
178
179
|
function({
|
|
179
180
|
className: e,
|
|
180
181
|
variant: t = "primary",
|
|
181
|
-
size:
|
|
182
|
-
shape:
|
|
183
|
-
disabled:
|
|
184
|
-
as:
|
|
185
|
-
"aria-label":
|
|
186
|
-
...
|
|
187
|
-
},
|
|
182
|
+
size: i = "md",
|
|
183
|
+
shape: l = "rounded",
|
|
184
|
+
disabled: n = !1,
|
|
185
|
+
as: a,
|
|
186
|
+
"aria-label": c,
|
|
187
|
+
...f
|
|
188
|
+
}, d) {
|
|
188
189
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
189
190
|
"button",
|
|
190
191
|
{
|
|
191
|
-
ref:
|
|
192
|
+
ref: d,
|
|
192
193
|
type: "button",
|
|
193
194
|
className: cn(
|
|
194
195
|
buttonIconVariants({
|
|
195
196
|
variant: t,
|
|
196
|
-
size:
|
|
197
|
-
shape:
|
|
197
|
+
size: i,
|
|
198
|
+
shape: l
|
|
198
199
|
}),
|
|
199
200
|
e
|
|
200
201
|
),
|
|
201
|
-
disabled:
|
|
202
|
-
"aria-disabled":
|
|
203
|
-
"aria-label":
|
|
204
|
-
inert:
|
|
205
|
-
...
|
|
202
|
+
disabled: n,
|
|
203
|
+
"aria-disabled": n,
|
|
204
|
+
"aria-label": c,
|
|
205
|
+
inert: n ? !0 : void 0,
|
|
206
|
+
...f,
|
|
206
207
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
207
208
|
Icon,
|
|
208
209
|
{
|
|
209
|
-
as:
|
|
210
|
-
size:
|
|
210
|
+
as: a,
|
|
211
|
+
size: i,
|
|
211
212
|
color: getIconColorFromVariant(t)
|
|
212
213
|
}
|
|
213
214
|
)
|
|
@@ -285,10 +286,10 @@ const BUTTONS = [
|
|
|
285
286
|
initialValue: r = "",
|
|
286
287
|
onChange: e,
|
|
287
288
|
disabled: t,
|
|
288
|
-
className:
|
|
289
|
-
"aria-label":
|
|
290
|
-
},
|
|
291
|
-
const { input:
|
|
289
|
+
className: i,
|
|
290
|
+
"aria-label": l
|
|
291
|
+
}, n) => {
|
|
292
|
+
const { input: a, inputRef: c, handleButton: f, handleInput: d } = useCalculator({
|
|
292
293
|
initialValue: r,
|
|
293
294
|
disabled: t,
|
|
294
295
|
onChange: e
|
|
@@ -296,44 +297,44 @@ const BUTTONS = [
|
|
|
296
297
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
297
298
|
"div",
|
|
298
299
|
{
|
|
299
|
-
ref:
|
|
300
|
-
className: cn(calculatorRootVariants({ disabled: t }),
|
|
301
|
-
"aria-label":
|
|
300
|
+
ref: n,
|
|
301
|
+
className: cn(calculatorRootVariants({ disabled: t }), i),
|
|
302
|
+
"aria-label": l || "Calculator",
|
|
302
303
|
role: "region",
|
|
303
304
|
children: [
|
|
304
305
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
305
306
|
"input",
|
|
306
307
|
{
|
|
307
|
-
ref:
|
|
308
|
+
ref: c,
|
|
308
309
|
className: "w-full mb-3 px-3 py-2 rounded border border-[var(--color-neutral)] bg-[var(--color-neutral-soft)] text-right text-xl font-mono focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)]",
|
|
309
|
-
value:
|
|
310
|
-
onChange:
|
|
310
|
+
value: a,
|
|
311
|
+
onChange: d,
|
|
311
312
|
disabled: t,
|
|
312
313
|
inputMode: "decimal",
|
|
313
314
|
"aria-label": "Calculator input"
|
|
314
315
|
}
|
|
315
316
|
),
|
|
316
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1 mb-3", children: BUTTONS.map((
|
|
317
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1 mb-3", children: BUTTONS.map((m, v) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full", children: m.map((h) => h === "⌫" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
317
318
|
ButtonIcon,
|
|
318
319
|
{
|
|
319
320
|
as: X,
|
|
320
321
|
variant: "danger-ghost",
|
|
321
322
|
"aria-label": "Backspace",
|
|
322
323
|
size: "md",
|
|
323
|
-
onClick: () =>
|
|
324
|
+
onClick: () => f("⌫"),
|
|
324
325
|
disabled: t
|
|
325
326
|
},
|
|
326
327
|
"backspace"
|
|
327
328
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
328
329
|
CalculatorButton,
|
|
329
330
|
{
|
|
330
|
-
variant:
|
|
331
|
-
onClick: () =>
|
|
331
|
+
variant: h === "=" ? "action" : h === "C" ? "danger" : ["/", "*", "-", "+", "/"].includes(h) ? "operator" : "default",
|
|
332
|
+
onClick: () => f(h),
|
|
332
333
|
disabled: t,
|
|
333
|
-
"aria-label":
|
|
334
|
-
children:
|
|
334
|
+
"aria-label": h,
|
|
335
|
+
children: h
|
|
335
336
|
},
|
|
336
|
-
|
|
337
|
+
h
|
|
337
338
|
)) }, v)) })
|
|
338
339
|
]
|
|
339
340
|
}
|
|
@@ -395,23 +396,23 @@ const buttonVariants = cva(
|
|
|
395
396
|
function r({
|
|
396
397
|
className: e,
|
|
397
398
|
variant: t = "primary",
|
|
398
|
-
size:
|
|
399
|
-
disabled:
|
|
400
|
-
type:
|
|
401
|
-
children:
|
|
402
|
-
...
|
|
403
|
-
},
|
|
399
|
+
size: i = "md",
|
|
400
|
+
disabled: l = !1,
|
|
401
|
+
type: n = "button",
|
|
402
|
+
children: a,
|
|
403
|
+
...c
|
|
404
|
+
}, f) {
|
|
404
405
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
405
406
|
"button",
|
|
406
407
|
{
|
|
407
|
-
ref:
|
|
408
|
-
type:
|
|
409
|
-
className: cn(buttonVariants({ variant: t, size:
|
|
410
|
-
disabled:
|
|
411
|
-
"aria-disabled":
|
|
412
|
-
inert:
|
|
413
|
-
...
|
|
414
|
-
children:
|
|
408
|
+
ref: f,
|
|
409
|
+
type: n,
|
|
410
|
+
className: cn(buttonVariants({ variant: t, size: i }), e),
|
|
411
|
+
disabled: l,
|
|
412
|
+
"aria-disabled": l,
|
|
413
|
+
inert: l ? !0 : void 0,
|
|
414
|
+
...c,
|
|
415
|
+
children: a
|
|
415
416
|
}
|
|
416
417
|
);
|
|
417
418
|
}
|
|
@@ -489,18 +490,18 @@ const buttonVariants = cva(
|
|
|
489
490
|
as: r = "span",
|
|
490
491
|
color: e = "ghost",
|
|
491
492
|
hasUnderline: t = !1,
|
|
492
|
-
isCapitalize:
|
|
493
|
-
align:
|
|
494
|
-
italic:
|
|
495
|
-
clamp:
|
|
496
|
-
ellipsis:
|
|
497
|
-
fontSize:
|
|
498
|
-
fontWeight:
|
|
499
|
-
className:
|
|
493
|
+
isCapitalize: i = !1,
|
|
494
|
+
align: l = "left",
|
|
495
|
+
italic: n = !1,
|
|
496
|
+
clamp: a = "none",
|
|
497
|
+
ellipsis: c = !1,
|
|
498
|
+
fontSize: f,
|
|
499
|
+
fontWeight: d,
|
|
500
|
+
className: m,
|
|
500
501
|
children: v,
|
|
501
|
-
...
|
|
502
|
-
},
|
|
503
|
-
const
|
|
502
|
+
...h
|
|
503
|
+
}, p) => {
|
|
504
|
+
const u = [
|
|
504
505
|
"h1",
|
|
505
506
|
"h2",
|
|
506
507
|
"h3",
|
|
@@ -510,43 +511,51 @@ const buttonVariants = cva(
|
|
|
510
511
|
"p",
|
|
511
512
|
"span",
|
|
512
513
|
"label"
|
|
513
|
-
].includes(r) ? r : "span",
|
|
514
|
+
].includes(r) ? r : "span", b = f ? `text-${f}` : "", w = d ? `font-${d}` : "";
|
|
514
515
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
515
516
|
r,
|
|
516
517
|
{
|
|
517
|
-
ref:
|
|
518
|
+
ref: p,
|
|
518
519
|
className: cn(
|
|
519
520
|
textVariants({
|
|
520
521
|
color: e,
|
|
521
522
|
hasUnderline: t,
|
|
522
|
-
isCapitalize:
|
|
523
|
-
align:
|
|
524
|
-
italic:
|
|
525
|
-
clamp:
|
|
526
|
-
ellipsis:
|
|
523
|
+
isCapitalize: i,
|
|
524
|
+
align: l,
|
|
525
|
+
italic: n,
|
|
526
|
+
clamp: a,
|
|
527
|
+
ellipsis: c,
|
|
527
528
|
// @ts-expect-error - `as` is not a valid variant
|
|
528
|
-
as:
|
|
529
|
+
as: u
|
|
529
530
|
}),
|
|
531
|
+
b,
|
|
530
532
|
w,
|
|
531
|
-
m
|
|
532
|
-
b
|
|
533
|
+
m
|
|
533
534
|
),
|
|
534
|
-
...
|
|
535
|
+
...h,
|
|
535
536
|
children: v
|
|
536
537
|
}
|
|
537
538
|
);
|
|
538
539
|
}
|
|
539
|
-
),
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
540
|
+
), CalendarContext = createContext(null);
|
|
541
|
+
function useCalendarContext() {
|
|
542
|
+
const r = useContext(CalendarContext);
|
|
543
|
+
if (!r)
|
|
544
|
+
throw new Error(
|
|
545
|
+
"useCalendarContext must be used within CalendarContext.Provider"
|
|
546
|
+
);
|
|
547
|
+
return r;
|
|
548
|
+
}
|
|
549
|
+
const CalendarHeader = () => {
|
|
550
|
+
const { value: r, year: e, month: t, setMonth: i } = useCalendarContext();
|
|
551
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between px-4 pt-4 pb-2", children: [
|
|
552
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fontSize: "base", fontWeight: "semibold", className: "ml-2", children: r ? r instanceof Date ? r.toLocaleDateString(void 0, {
|
|
553
|
+
year: "numeric",
|
|
554
|
+
month: "long"
|
|
555
|
+
}) : Array.isArray(r) && r[0] ? r[0].toLocaleDateString(void 0, {
|
|
547
556
|
year: "numeric",
|
|
548
557
|
month: "long"
|
|
549
|
-
}) : `${
|
|
558
|
+
}) : `${e} ${new Date(e, t).toLocaleString(void 0, { month: "long" })}` : `${e} ${new Date(e, t).toLocaleString(void 0, { month: "long" })}` }),
|
|
550
559
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
|
|
551
560
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
552
561
|
ButtonIcon,
|
|
@@ -555,10 +564,7 @@ const buttonVariants = cva(
|
|
|
555
564
|
variant: "ghost",
|
|
556
565
|
size: "sm",
|
|
557
566
|
"aria-label": "Previous month",
|
|
558
|
-
onClick: () =>
|
|
559
|
-
const n = i === 0 ? 11 : i - 1, a = i === 0 ? s - 1 : s;
|
|
560
|
-
f(n), g(a), e?.(new Date(a, n, 1));
|
|
561
|
-
}
|
|
567
|
+
onClick: () => i(t === 0 ? 11 : t - 1)
|
|
562
568
|
}
|
|
563
569
|
),
|
|
564
570
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -568,84 +574,233 @@ const buttonVariants = cva(
|
|
|
568
574
|
variant: "ghost",
|
|
569
575
|
size: "sm",
|
|
570
576
|
"aria-label": "Next month",
|
|
571
|
-
onClick: () =>
|
|
572
|
-
const n = i === 11 ? 0 : i + 1, a = i === 11 ? s + 1 : s;
|
|
573
|
-
f(n), g(a), e?.(new Date(a, n, 1));
|
|
574
|
-
}
|
|
577
|
+
onClick: () => i(t === 11 ? 0 : t + 1)
|
|
575
578
|
}
|
|
576
579
|
)
|
|
577
580
|
] })
|
|
578
|
-
] })
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
581
|
+
] });
|
|
582
|
+
}, CalendarWeekdays = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 px-4 text-ghost-500 mb-3", children: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((r) => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fontSize: "xs", color: "ghost", align: "center", children: r }, r)) }), CalendarDaysSingle = () => {
|
|
583
|
+
const r = useCalendarContext(), { year: e, month: t, value: i, onChange: l, setMonth: n, setYear: a } = r, c = (o, x) => new Date(o, x + 1, 0).getDate(), d = ((o, x) => new Date(o, x, 1).getDay())(e, t), m = c(e, t), v = t - 1 < 0 ? 11 : t - 1, h = t === 0 ? e - 1 : e, p = c(e, v), y = t === 11 ? 0 : t + 1, u = t === 11 ? e + 1 : e, b = [];
|
|
584
|
+
for (let o = 0; o < d; o++) {
|
|
585
|
+
const x = p - d + o + 1;
|
|
586
|
+
b.push(
|
|
587
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
588
|
+
ButtonIcon,
|
|
589
|
+
{
|
|
590
|
+
as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: x }),
|
|
591
|
+
size: "sm",
|
|
592
|
+
"aria-label": "Previous month day",
|
|
593
|
+
variant: "ghost",
|
|
594
|
+
onClick: () => {
|
|
595
|
+
l?.(new Date(h, v, x)), n(v), a(h);
|
|
596
|
+
}
|
|
597
|
+
},
|
|
598
|
+
"prev-" + o
|
|
599
|
+
)
|
|
600
|
+
);
|
|
601
|
+
}
|
|
602
|
+
for (let o = 1; o <= m; o++) {
|
|
603
|
+
const x = i instanceof Date && i.getFullYear() === e && i.getMonth() === t && i.getDate() === o;
|
|
604
|
+
b.push(
|
|
605
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
606
|
+
ButtonIcon,
|
|
607
|
+
{
|
|
608
|
+
as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
609
|
+
Text,
|
|
610
|
+
{
|
|
611
|
+
as: "span",
|
|
612
|
+
fontSize: "sm",
|
|
613
|
+
color: x ? "inherit" : "ghost",
|
|
614
|
+
className: x ? "bg-primary text-white rounded-full" : "",
|
|
615
|
+
children: o
|
|
593
616
|
}
|
|
594
|
-
|
|
595
|
-
"
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
)
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
617
|
+
),
|
|
618
|
+
variant: x ? "primary" : "ghost",
|
|
619
|
+
size: "sm",
|
|
620
|
+
"aria-label": `Select ${e}-${t + 1}-${o}`,
|
|
621
|
+
"aria-current": x ? "date" : void 0,
|
|
622
|
+
onClick: () => {
|
|
623
|
+
l?.(new Date(e, t, o));
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
o
|
|
627
|
+
)
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
const w = d + m;
|
|
631
|
+
for (let o = 0; o < (w % 7 === 0 ? 0 : 7 - w % 7); o++)
|
|
632
|
+
b.push(
|
|
633
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
634
|
+
ButtonIcon,
|
|
635
|
+
{
|
|
636
|
+
as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: o + 1 }),
|
|
637
|
+
size: "sm",
|
|
638
|
+
"aria-label": "Next month day",
|
|
639
|
+
variant: "ghost",
|
|
640
|
+
onClick: () => {
|
|
641
|
+
l?.(new Date(u, y, o + 1)), n(y), a(u);
|
|
642
|
+
}
|
|
643
|
+
},
|
|
644
|
+
"next-" + o
|
|
645
|
+
)
|
|
646
|
+
);
|
|
647
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 gap-2 px-4 pb-4", children: b });
|
|
648
|
+
}, CalendarDaysRange = () => {
|
|
649
|
+
const { year: r, month: e, value: t, onChange: i, setMonth: l, setYear: n } = useCalendarContext(), a = (s, g) => new Date(s, g + 1, 0).getDate(), f = ((s, g) => new Date(s, g, 1).getDay())(r, e), d = a(r, e), m = e - 1 < 0 ? 11 : e - 1, v = e === 0 ? r - 1 : r, h = a(r, m), p = e === 11 ? 0 : e + 1, y = e === 11 ? r + 1 : r, u = [], b = () => {
|
|
650
|
+
if (!Array.isArray(t)) return [null, null];
|
|
651
|
+
const [s, g] = t;
|
|
652
|
+
return !s && !g ? [null, null] : s && g ? s <= g ? [s, g] : [g, s] : [s, g];
|
|
653
|
+
}, [w, o] = b(), x = (s) => {
|
|
654
|
+
if (!w || !o) return !1;
|
|
655
|
+
const g = new Date(r, e, s);
|
|
656
|
+
return g >= w && g <= o;
|
|
657
|
+
}, I = (s) => w ? w.getFullYear() === r && w.getMonth() === e && w.getDate() === s : !1, B = (s) => o ? o.getFullYear() === r && o.getMonth() === e && o.getDate() === s : !1;
|
|
658
|
+
for (let s = 0; s < f; s++) {
|
|
659
|
+
const g = h - f + s + 1;
|
|
660
|
+
u.push(
|
|
661
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
662
|
+
ButtonIcon,
|
|
663
|
+
{
|
|
664
|
+
as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: g }),
|
|
665
|
+
size: "sm",
|
|
666
|
+
"aria-label": "Previous month day",
|
|
667
|
+
variant: "ghost",
|
|
668
|
+
onClick: () => {
|
|
669
|
+
i?.([null, null]), l(m), n(v);
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
"prev-" + s
|
|
673
|
+
)
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
for (let s = 1; s <= d; s++) {
|
|
677
|
+
const g = x(s), R = I(s), E = B(s);
|
|
678
|
+
u.push(
|
|
679
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
680
|
+
ButtonIcon,
|
|
681
|
+
{
|
|
682
|
+
as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
683
|
+
Text,
|
|
684
|
+
{
|
|
685
|
+
as: "span",
|
|
686
|
+
fontSize: "sm",
|
|
687
|
+
color: g || R || E ? "inherit" : "ghost",
|
|
688
|
+
className: cn(
|
|
689
|
+
g && " bg-primary text-white",
|
|
690
|
+
R && "rounded-l-full bg-primary text-white",
|
|
691
|
+
E && "rounded-r-full bg-primary text-white"
|
|
692
|
+
),
|
|
693
|
+
children: s
|
|
637
694
|
}
|
|
638
|
-
|
|
639
|
-
"
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
695
|
+
),
|
|
696
|
+
variant: R || E || g ? "primary" : "ghost",
|
|
697
|
+
size: "sm",
|
|
698
|
+
"aria-label": `Select ${r}-${e + 1}-${s}`,
|
|
699
|
+
"aria-current": R || E ? "date" : void 0,
|
|
700
|
+
onClick: () => {
|
|
701
|
+
if (!Array.isArray(t) || !t[0] || t[0] && t[1])
|
|
702
|
+
i?.([new Date(r, e, s), null]);
|
|
703
|
+
else if (t[0] && !t[1]) {
|
|
704
|
+
const j = t[0], C = new Date(r, e, s);
|
|
705
|
+
j.getTime() === C.getTime() ? i?.([j, C]) : i?.(j < C ? [j, C] : [C, j]);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
s
|
|
710
|
+
)
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
const D = f + d;
|
|
714
|
+
for (let s = 0; s < (D % 7 === 0 ? 0 : 7 - D % 7); s++)
|
|
715
|
+
u.push(
|
|
716
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
717
|
+
ButtonIcon,
|
|
718
|
+
{
|
|
719
|
+
as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: s + 1 }),
|
|
720
|
+
size: "sm",
|
|
721
|
+
"aria-label": "Next month day",
|
|
722
|
+
variant: "ghost",
|
|
723
|
+
onClick: () => {
|
|
724
|
+
i?.([null, null]), l(p), n(y);
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
"next-" + s
|
|
728
|
+
)
|
|
729
|
+
);
|
|
730
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 gap-2 px-4 pb-4", children: u });
|
|
731
|
+
}, CalendarDays = () => {
|
|
732
|
+
const { type: r } = useCalendarContext();
|
|
733
|
+
return r === "range" ? /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDaysRange, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDaysSingle, {});
|
|
734
|
+
};
|
|
735
|
+
function useCalendar({
|
|
736
|
+
value: r,
|
|
737
|
+
type: e,
|
|
738
|
+
onChange: t,
|
|
739
|
+
initialYear: i,
|
|
740
|
+
initialMonth: l
|
|
741
|
+
}) {
|
|
742
|
+
const [n, a] = useState(l), [c, f] = useState(i), [d, m] = useState([
|
|
743
|
+
null,
|
|
744
|
+
null
|
|
745
|
+
]);
|
|
746
|
+
let v = r;
|
|
747
|
+
e === "range" && !r && (v = d);
|
|
748
|
+
const h = useCallback(() => {
|
|
749
|
+
const u = n === 0 ? 11 : n - 1, b = n === 0 ? c - 1 : c;
|
|
750
|
+
a(u), f(b), e === "single" && t?.(new Date(b, u, 1));
|
|
751
|
+
}, [n, c, e, t]), p = useCallback(() => {
|
|
752
|
+
const u = n === 11 ? 0 : n + 1, b = n === 11 ? c + 1 : c;
|
|
753
|
+
a(u), f(b), e === "single" && t?.(new Date(b, u, 1));
|
|
754
|
+
}, [n, c, e, t]), y = useCallback(
|
|
755
|
+
(u) => {
|
|
756
|
+
e === "single" ? t?.(u) : e === "range" && (m(u), t?.(u));
|
|
757
|
+
},
|
|
758
|
+
[e, t]
|
|
759
|
+
);
|
|
760
|
+
return {
|
|
761
|
+
year: c,
|
|
762
|
+
month: n,
|
|
763
|
+
value: v,
|
|
764
|
+
setMonth: a,
|
|
765
|
+
setYear: f,
|
|
766
|
+
onChange: y,
|
|
767
|
+
handlePrevMonth: h,
|
|
768
|
+
handleNextMonth: p
|
|
643
769
|
};
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
770
|
+
}
|
|
771
|
+
const CalendarRoot = ({
|
|
772
|
+
value: r,
|
|
773
|
+
onChange: e,
|
|
774
|
+
className: t,
|
|
775
|
+
type: i = "single",
|
|
776
|
+
...l
|
|
777
|
+
}) => {
|
|
778
|
+
const n = /* @__PURE__ */ new Date(), a = useCalendar({
|
|
779
|
+
value: r,
|
|
780
|
+
onChange: e,
|
|
781
|
+
type: i,
|
|
782
|
+
initialYear: n.getFullYear(),
|
|
783
|
+
initialMonth: n.getMonth()
|
|
784
|
+
});
|
|
785
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
786
|
+
CalendarContext.Provider,
|
|
787
|
+
{
|
|
788
|
+
value: {
|
|
789
|
+
year: a.year,
|
|
790
|
+
month: a.month,
|
|
791
|
+
value: a.value,
|
|
792
|
+
type: i,
|
|
793
|
+
setMonth: a.setMonth,
|
|
794
|
+
setYear: a.setYear,
|
|
795
|
+
onChange: a.onChange
|
|
796
|
+
},
|
|
797
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("select-none", t), ...l, children: [
|
|
798
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CalendarHeader, {}),
|
|
799
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CalendarWeekdays, {}),
|
|
800
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(CalendarDays, {})
|
|
801
|
+
] })
|
|
802
|
+
}
|
|
803
|
+
);
|
|
649
804
|
}, Calendar = Object.assign(CalendarRoot, {});
|
|
650
805
|
export {
|
|
651
806
|
Button as B,
|