@dimasbaguspm/versaur 0.0.12 → 0.0.14

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.
Files changed (38) hide show
  1. package/dist/js/bottom-sheet-CBLNEX4F.js +281 -0
  2. package/dist/js/bottom-sheet.atoms-DFMOaMsU.js +78 -0
  3. package/dist/js/{calendar-De5dCVnE.js → calendar-B9rIZCdo.js} +318 -163
  4. package/dist/js/{index-DOdDlCoL.js → cn-BKwT3erk.js} +463 -788
  5. package/dist/js/enforce-subpath-import.js +1 -0
  6. package/dist/js/feedbacks/index.js +1 -1
  7. package/dist/js/{form-layout-BBDs1Y8m.js → form-layout-PLH-7bWq.js} +58 -57
  8. package/dist/js/forms/index.js +1 -1
  9. package/dist/js/index-Dmu_fHni.js +329 -0
  10. package/dist/js/index.js +32 -31
  11. package/dist/js/layouts/index.js +1 -1
  12. package/dist/js/{menu-Du409VIG.js → menu-oRrbZAAy.js} +56 -60
  13. package/dist/js/navigation/index.js +1 -1
  14. package/dist/js/overlays/index.js +5 -4
  15. package/dist/js/primitive/index.js +2 -2
  16. package/dist/js/{skeleton-BNZyaRjo.js → skeleton-Ma-Fcs06.js} +6 -5
  17. package/dist/js/{switch-input-B-pwBWbi.js → switch-input-o8oO4Rf4.js} +482 -435
  18. package/dist/js/{tabs-BbOkYchB.js → tabs-DSeR5XxX.js} +6 -5
  19. package/dist/js/{tile-6SeBYc08.js → tile-8hqVMf2m.js} +110 -139
  20. package/dist/types/forms/chip-input/types.d.ts +16 -0
  21. package/dist/types/forms/date-range-picker-input/date-range-picker-input.d.ts +10 -0
  22. package/dist/types/forms/date-range-picker-input/index.d.ts +2 -0
  23. package/dist/types/forms/date-range-picker-input/types.d.ts +64 -0
  24. package/dist/types/forms/date-range-picker-input/use-date-range-picker.d.ts +13 -0
  25. package/dist/types/overlays/bottom-sheet/bottom-sheet.atoms.d.ts +17 -0
  26. package/dist/types/overlays/bottom-sheet/bottom-sheet.d.ts +7 -0
  27. package/dist/types/overlays/bottom-sheet/index.d.ts +2 -0
  28. package/dist/types/overlays/bottom-sheet/types.d.ts +22 -0
  29. package/dist/types/overlays/drawer/drawer.atoms.d.ts +2 -1
  30. package/dist/types/overlays/drawer/drawer.d.ts +1 -0
  31. package/dist/types/overlays/drawer/types.d.ts +6 -3
  32. package/dist/types/overlays/index.d.ts +1 -0
  33. package/dist/types/primitive/calendar/calendar.atoms.d.ts +13 -0
  34. package/dist/types/primitive/calendar/index.d.ts +1 -1
  35. package/dist/types/primitive/calendar/types.d.ts +38 -4
  36. package/dist/types/primitive/calendar/use-calendar.d.ts +18 -0
  37. package/package.json +1 -1
  38. package/dist/js/drawer-Cn7sreJG.js +0 -221
@@ -1,5 +1,6 @@
1
- import { c as cva, j as jsxRuntimeExports, a as cn } from "./index-DOdDlCoL.js";
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 }, l) => /* @__PURE__ */ jsxRuntimeExports.jsx(
38
+ ), CalculatorButton = forwardRef(({ variant: r = "default", className: e, ...t }, i) => /* @__PURE__ */ jsxRuntimeExports.jsx(
38
39
  "button",
39
40
  {
40
- ref: l,
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: l = "md", className: c, ...i }, f) {
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: f,
173
- className: iconVariants({ color: t, size: l, className: c }),
174
- ...i
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: l = "md",
182
- shape: c = "rounded",
183
- disabled: i = !1,
184
- as: f,
185
- "aria-label": s,
186
- ...g
187
- }, h) {
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: h,
192
+ ref: d,
192
193
  type: "button",
193
194
  className: cn(
194
195
  buttonIconVariants({
195
196
  variant: t,
196
- size: l,
197
- shape: c
197
+ size: i,
198
+ shape: l
198
199
  }),
199
200
  e
200
201
  ),
201
- disabled: i,
202
- "aria-disabled": i,
203
- "aria-label": s,
204
- inert: i ? !0 : void 0,
205
- ...g,
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: f,
210
- size: l,
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: l,
289
- "aria-label": c
290
- }, i) => {
291
- const { input: f, inputRef: s, handleButton: g, handleInput: h } = useCalculator({
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: i,
300
- className: cn(calculatorRootVariants({ disabled: t }), l),
301
- "aria-label": c || "Calculator",
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: s,
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: f,
310
- onChange: h,
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((b, v) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full", children: b.map((u) => u === "⌫" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
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: () => g("⌫"),
324
+ onClick: () => f("⌫"),
324
325
  disabled: t
325
326
  },
326
327
  "backspace"
327
328
  ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
328
329
  CalculatorButton,
329
330
  {
330
- variant: u === "=" ? "action" : u === "C" ? "danger" : ["/", "*", "-", "+", "/"].includes(u) ? "operator" : "default",
331
- onClick: () => g(u),
331
+ variant: h === "=" ? "action" : h === "C" ? "danger" : ["/", "*", "-", "+", "/"].includes(h) ? "operator" : "default",
332
+ onClick: () => f(h),
332
333
  disabled: t,
333
- "aria-label": u,
334
- children: u
334
+ "aria-label": h,
335
+ children: h
335
336
  },
336
- u
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: l = "md",
399
- disabled: c = !1,
400
- type: i = "button",
401
- children: f,
402
- ...s
403
- }, g) {
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: g,
408
- type: i,
409
- className: cn(buttonVariants({ variant: t, size: l }), e),
410
- disabled: c,
411
- "aria-disabled": c,
412
- inert: c ? !0 : void 0,
413
- ...s,
414
- children: f
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: l = !1,
493
- align: c = "left",
494
- italic: i = !1,
495
- clamp: f = "none",
496
- ellipsis: s = !1,
497
- fontSize: g,
498
- fontWeight: h,
499
- className: b,
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
- ...u
502
- }, y) => {
503
- const a = [
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", w = g ? `text-${g}` : "", m = h ? `font-${h}` : "";
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: y,
518
+ ref: p,
518
519
  className: cn(
519
520
  textVariants({
520
521
  color: e,
521
522
  hasUnderline: t,
522
- isCapitalize: l,
523
- align: c,
524
- italic: i,
525
- clamp: f,
526
- ellipsis: s,
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: a
529
+ as: u
529
530
  }),
531
+ b,
530
532
  w,
531
- m,
532
- b
533
+ m
533
534
  ),
534
- ...u,
535
+ ...h,
535
536
  children: v
536
537
  }
537
538
  );
538
539
  }
539
- ), CalendarRoot = ({
540
- value: r,
541
- onChange: e,
542
- className: t,
543
- ...l
544
- }) => {
545
- const c = /* @__PURE__ */ new Date(), [i, f] = useState(c.getMonth()), [s, g] = useState(c.getFullYear()), h = (n, a) => new Date(n, a + 1, 0).getDate(), b = (n, a) => new Date(n, a, 1).getDay(), v = () => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between px-4 pt-4 pb-2", children: [
546
- /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fontSize: "base", fontWeight: "semibold", className: "ml-2", children: r ? r.toLocaleDateString(void 0, {
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
- }) : `${s} ${new Date(s, i).toLocaleString(void 0, { month: "long" })}` }),
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
- ] }), u = () => /* @__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((n) => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { fontSize: "xs", color: "ghost", align: "center", children: n }, n)) }), y = () => {
579
- const n = [], a = b(s, i), w = h(s, i), m = h(s, i - 1 < 0 ? 11 : i - 1);
580
- for (let o = 0; o < a; o++) {
581
- const d = m - a + o + 1;
582
- n.push(
583
- /* @__PURE__ */ jsxRuntimeExports.jsx(
584
- ButtonIcon,
585
- {
586
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: d }),
587
- size: "sm",
588
- "aria-label": "Previous month day",
589
- variant: "ghost",
590
- onClick: () => {
591
- const x = i === 0 ? 11 : i - 1, p = i === 0 ? s - 1 : s, R = m - a + o + 1;
592
- e?.(new Date(p, x, R)), f(x), g(p);
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
- "prev-" + o
596
- )
597
- );
598
- }
599
- for (let o = 1; o <= w; o++) {
600
- const d = r && r.getFullYear() === s && r.getMonth() === i && r.getDate() === o;
601
- n.push(
602
- /* @__PURE__ */ jsxRuntimeExports.jsx(
603
- ButtonIcon,
604
- {
605
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(
606
- Text,
607
- {
608
- as: "span",
609
- fontSize: "sm",
610
- color: d ? "inherit" : "ghost",
611
- children: o
612
- }
613
- ),
614
- variant: d ? "primary" : "ghost",
615
- size: "sm",
616
- "aria-label": `Select ${s}-${i + 1}-${o}`,
617
- "aria-current": d ? "date" : void 0,
618
- onClick: () => e?.(new Date(s, i, o))
619
- },
620
- o
621
- )
622
- );
623
- }
624
- const j = a + w;
625
- for (let o = 0; o < (j % 7 === 0 ? 0 : 7 - j % 7); o++)
626
- n.push(
627
- /* @__PURE__ */ jsxRuntimeExports.jsx(
628
- ButtonIcon,
629
- {
630
- as: () => /* @__PURE__ */ jsxRuntimeExports.jsx(Text, { as: "span", fontSize: "sm", color: "tertiary", children: o + 1 }),
631
- size: "sm",
632
- "aria-label": "Next month day",
633
- variant: "ghost",
634
- onClick: () => {
635
- const d = i === 11 ? 0 : i + 1, x = i === 11 ? s + 1 : s, p = o + 1;
636
- e?.(new Date(x, d, p)), f(d), g(x);
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
- "next-" + o
640
- )
641
- );
642
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-7 gap-2 px-4 pb-4", children: n });
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
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("select-none", t), ...l, children: [
645
- v(),
646
- u(),
647
- y()
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,