@starasia/date 5.1.0 → 5.1.1

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/date.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { jsxs as N, jsx as a, Fragment as nn } from "react/jsx-runtime";
2
- import { useState as j, useRef as P, useEffect as S, forwardRef as Z } from "react";
3
- const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
1
+ import { jsxs as $, jsx as a, Fragment as nn } from "react/jsx-runtime";
2
+ import { useState as j, useRef as J, useEffect as I, forwardRef as Z } from "react";
3
+ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
4
4
 
5
5
  * {
6
6
  margin: 0;
@@ -10,7 +10,7 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
10
10
  /* box-sizing: border-box; */
11
11
  }
12
12
  :root {
13
- --sa-date-radius: var(--sa-radii-md, 0.5rem);
13
+ --sa-date-radius: var(--sa-radii-sm, 0.375rem);
14
14
  --sa-date-radius-lg: var(--sa-radii-lg, 0.75rem);
15
15
  --sa-date-bg: var(--sa-background-primary, #ffffff);
16
16
  --sa-date-border-color: var(--sa-color-gray-alpha-a20, #78867f33);
@@ -235,8 +235,28 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
235
235
  }
236
236
 
237
237
  .sa-calendar-days-active {
238
- background: var(--sa-date-brand-secondary);
238
+ background: var(--sa-date-brand);
239
+ color: #fff;
240
+ }
241
+
242
+ .sa-calendar-days-today {
243
+ position: relative;
239
244
  color: var(--sa-date-brand);
245
+ font-weight: 700;
246
+ background: transparent;
247
+ }
248
+
249
+ .sa-calendar-days-today::before {
250
+ content: '';
251
+ position: absolute;
252
+ top: 50%;
253
+ left: 50%;
254
+ transform: translate(-50%, -50%);
255
+ width: 32px;
256
+ height: 32px;
257
+ background: var(--sa-date-brand-secondary);
258
+ border-radius: 50%;
259
+ z-index: -1;
240
260
  }
241
261
 
242
262
  /* MONTH STYLING */
@@ -500,7 +520,7 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
500
520
  width: 32px;
501
521
  height: 32px;
502
522
  }
503
- `, en = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], A = [
523
+ `, en = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], W = [
504
524
  "January",
505
525
  "February",
506
526
  "March",
@@ -528,12 +548,12 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
528
548
  "Dec"
529
549
  ];
530
550
  function an(r) {
531
- const [e, t] = j(r), s = P(null), l = (c) => {
532
- s.current && !s.current.contains(c.target) && t(!1);
551
+ const [e, t] = j(r), o = J(null), l = (u) => {
552
+ o.current && !o.current.contains(u.target) && t(!1);
533
553
  };
534
- return S(() => (document.addEventListener("click", l, !0), () => {
554
+ return I(() => (document.addEventListener("click", l, !0), () => {
535
555
  document.removeEventListener("click", l, !0);
536
- }), []), { ref: s, isComponentVisible: e, setIsComponentVisible: t };
556
+ }), []), { ref: o, isComponentVisible: e, setIsComponentVisible: t };
537
557
  }
538
558
  const K = "sa-calendar-input-styles", ln = (r) => {
539
559
  if (!document.getElementById(K)) {
@@ -541,8 +561,8 @@ const K = "sa-calendar-input-styles", ln = (r) => {
541
561
  e.id = K, e.textContent = r, document.head.appendChild(e);
542
562
  }
543
563
  };
544
- ln(J);
545
- const W = (r) => {
564
+ ln(R);
565
+ const H = (r) => {
546
566
  if (r === "sm")
547
567
  return 16;
548
568
  if (r === "md")
@@ -553,27 +573,27 @@ const W = (r) => {
553
573
  const {
554
574
  size: e = "md",
555
575
  status: t = "default",
556
- variant: s = "outline",
576
+ variant: o = "outline",
557
577
  clearable: l,
558
- onClear: c,
578
+ onClear: u,
559
579
  ...d
560
- } = r, g = P(null), f = () => {
561
- g.current && d.onClick && (g.current.focus(), d.onClick(""));
562
- }, n = t === "disable" || d.disabled, u = !!d.value, y = l && u && !n, x = (D) => {
563
- D.stopPropagation(), c == null || c();
580
+ } = r, p = J(null), g = () => {
581
+ p.current && d.onClick && (p.current.focus(), d.onClick(""));
582
+ }, n = t === "disable" || d.disabled, c = !!d.value, v = l && c && !n, k = (D) => {
583
+ D.stopPropagation(), u == null || u();
564
584
  };
565
- return /* @__PURE__ */ N(
585
+ return /* @__PURE__ */ $(
566
586
  "div",
567
587
  {
568
- className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${e} `,
569
- onClick: f,
588
+ className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,
589
+ onClick: g,
570
590
  children: [
571
591
  /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
572
592
  "svg",
573
593
  {
574
594
  xmlns: "http://www.w3.org/2000/svg",
575
- width: W(e),
576
- height: W(e),
595
+ width: H(e),
596
+ height: H(e),
577
597
  viewBox: "0 0 20 20",
578
598
  fill: "none",
579
599
  children: /* @__PURE__ */ a(
@@ -595,22 +615,22 @@ const W = (r) => {
595
615
  ...d,
596
616
  disabled: n,
597
617
  value: d.value,
598
- ref: g
618
+ ref: p
599
619
  }
600
620
  ) }),
601
- y ? /* @__PURE__ */ a(
621
+ v ? /* @__PURE__ */ a(
602
622
  "button",
603
623
  {
604
624
  type: "button",
605
625
  "aria-label": "Clear date",
606
626
  className: "sa-calendar-input-clear",
607
- onClick: x,
627
+ onClick: k,
608
628
  children: /* @__PURE__ */ a(
609
629
  "svg",
610
630
  {
611
631
  xmlns: "http://www.w3.org/2000/svg",
612
- width: W(e),
613
- height: W(e),
632
+ width: H(e),
633
+ height: H(e),
614
634
  viewBox: "0 0 20 20",
615
635
  fill: "none",
616
636
  children: /* @__PURE__ */ a(
@@ -630,8 +650,8 @@ const W = (r) => {
630
650
  "svg",
631
651
  {
632
652
  xmlns: "http://www.w3.org/2000/svg",
633
- width: W(e),
634
- height: W(e),
653
+ width: H(e),
654
+ height: H(e),
635
655
  viewBox: "0 0 20 20",
636
656
  fill: "none",
637
657
  children: /* @__PURE__ */ a(
@@ -653,79 +673,80 @@ const W = (r) => {
653
673
  date: r,
654
674
  setDate: e,
655
675
  dateRange: t,
656
- setDateRange: s,
676
+ setDateRange: o,
657
677
  onChange: l,
658
- minDate: c,
678
+ minDate: u,
659
679
  maxDate: d,
660
- input: g
680
+ input: p
661
681
  }) => {
662
- var L, h, v;
663
- const [f, n] = j(null);
664
- let u = new Date(r.getFullYear(), r.getMonth(), 1), y = u.getDay(), x = [];
665
- const D = r.getMonth(), m = !!(t.from && !t.to), o = m && f ? f : null;
666
- for (let p = 0; p < 42; p++) {
667
- p === 0 && y === 0 ? u.setDate(u.getDate() - 7) : p === 0 ? u.setDate(
668
- u.getDate() + (p - y)
669
- ) : u.setDate(u.getDate() + 1);
670
- let b = {
671
- currentMonth: u.getMonth() === D,
672
- date: new Date(u),
673
- month: u.getMonth(),
674
- number: u.getDate(),
675
- selected: u.toDateString() === ((L = t.from) == null ? void 0 : L.toDateString()) || u.toDateString() === (((h = t.to) == null ? void 0 : h.toDateString()) || ((v = t.from) == null ? void 0 : v.toDateString())),
676
- year: u.getFullYear(),
677
- isDisabled: c && u < c || d && u > d
682
+ var h, m, F;
683
+ const [g, n] = j(null);
684
+ let c = new Date(r.getFullYear(), r.getMonth(), 1), v = c.getDay(), k = [];
685
+ const D = r.getMonth(), b = (/* @__PURE__ */ new Date()).toDateString(), f = !!(t.from && !t.to), s = f && g ? g : null;
686
+ for (let i = 0; i < 42; i++) {
687
+ i === 0 && v === 0 ? c.setDate(c.getDate() - 7) : i === 0 ? c.setDate(
688
+ c.getDate() + (i - v)
689
+ ) : c.setDate(c.getDate() + 1);
690
+ let w = {
691
+ currentMonth: c.getMonth() === D,
692
+ date: new Date(c),
693
+ month: c.getMonth(),
694
+ number: c.getDate(),
695
+ selected: c.toDateString() === ((h = t.from) == null ? void 0 : h.toDateString()) || c.toDateString() === (((m = t.to) == null ? void 0 : m.toDateString()) || ((F = t.from) == null ? void 0 : F.toDateString())),
696
+ isToday: c.toDateString() === b,
697
+ year: c.getFullYear(),
698
+ isDisabled: u && c < u || d && c > d
678
699
  };
679
- x.push(b);
700
+ k.push(w);
680
701
  }
681
- const i = (p) => {
682
- e(p);
683
- }, k = (p) => {
684
- var $;
685
- let b = { ...t };
686
- if (b.from && b.to)
687
- b = { from: p, to: null };
702
+ const x = (i) => {
703
+ e(i);
704
+ }, N = (i) => {
705
+ var L;
706
+ let w = { ...t };
707
+ if (w.from && w.to)
708
+ w = { from: i, to: null };
688
709
  else {
689
- const T = (($ = b.from) == null ? void 0 : $.getTime()) || 0;
690
- p.getTime() > T ? b = { from: b.from, to: p } : b = { from: p, to: b.from };
710
+ const M = ((L = w.from) == null ? void 0 : L.getTime()) || 0;
711
+ i.getTime() > M ? w = { from: w.from, to: i } : w = { from: i, to: w.from };
691
712
  }
692
- s(b), l(b);
713
+ o(w), l(w);
693
714
  };
694
- return /* @__PURE__ */ N(
715
+ return /* @__PURE__ */ $(
695
716
  "div",
696
717
  {
697
718
  className: "sa-calendar-days-preivew",
698
719
  onMouseLeave: () => n(null),
699
720
  children: [
700
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((p, b) => /* @__PURE__ */ a("p", { children: p }, b)) }),
701
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: x.map((p, b) => {
702
- const $ = t.from && t.to && p.date.getTime() > t.from.getTime() && p.date.getTime() < t.to.getTime(), T = (() => {
703
- if (!o || !t.from)
721
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((i, w) => /* @__PURE__ */ a("p", { children: i }, w)) }),
722
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: k.map((i, w) => {
723
+ const L = t.from && t.to && i.date.getTime() > t.from.getTime() && i.date.getTime() < t.to.getTime(), M = (() => {
724
+ if (!s || !t.from)
704
725
  return !1;
705
- const Y = p.date.getTime(), C = t.from.getTime(), z = o.getTime();
706
- return z > C ? Y > C && Y < z : Y < C && Y > z;
707
- })(), M = m && f && p.date.toDateString() === f.toDateString(), F = p.isDisabled, I = () => $ || T ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", E = () => F ? "var(--sa-color-gray-400, #b7b9be)" : $ || T ? "var(--sa-color-gray-500, #8c8f97)" : "";
726
+ const C = i.date.getTime(), z = t.from.getTime(), A = s.getTime();
727
+ return A > z ? C > z && C < A : C < z && C > A;
728
+ })(), T = f && g && i.date.toDateString() === g.toDateString(), Y = i.isDisabled, E = () => L || M ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", S = () => Y ? "var(--sa-color-gray-400, #b7b9be)" : L || M ? "var(--sa-color-gray-500, #8c8f97)" : "";
708
729
  return /* @__PURE__ */ a(
709
730
  "p",
710
731
  {
711
- className: `${p.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${p.selected || M ? "sa-calendar-days-active" : ""}`,
732
+ className: `${i.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${i.selected || T ? "sa-calendar-days-active" : ""} ${i.isToday && !i.selected ? "sa-calendar-days-today" : ""}`,
712
733
  style: {
713
- backgroundColor: I(),
714
- pointerEvents: F ? "none" : void 0,
715
- cursor: F ? "not-allowed" : "pointer",
716
- color: E(),
717
- opacity: M && !p.selected ? 0.75 : 1,
718
- ...g ? {} : { width: "100%" }
734
+ backgroundColor: E(),
735
+ pointerEvents: Y ? "none" : void 0,
736
+ cursor: Y ? "not-allowed" : "pointer",
737
+ color: S(),
738
+ opacity: T && !i.selected ? 0.75 : 1,
739
+ ...p ? {} : { width: "100%" }
719
740
  },
720
741
  onClick: () => {
721
- F || (i(p.date), k(p.date));
742
+ Y || (x(i.date), N(i.date));
722
743
  },
723
744
  onMouseEnter: () => {
724
- F || n(p.date);
745
+ Y || n(i.date);
725
746
  },
726
- children: p.number
747
+ children: i.number
727
748
  },
728
- b
749
+ w
729
750
  );
730
751
  }) })
731
752
  ]
@@ -735,47 +756,47 @@ const W = (r) => {
735
756
  date: r,
736
757
  setDate: e,
737
758
  filter: t,
738
- setViews: s,
759
+ setViews: o,
739
760
  dateRange: l,
740
- setDateRange: c,
761
+ setDateRange: u,
741
762
  onChange: d,
742
- minDate: g,
743
- maxDate: f,
763
+ minDate: p,
764
+ maxDate: g,
744
765
  input: n
745
766
  }) => {
746
- const u = l.from.getFullYear(), y = r.getFullYear(), x = (m) => {
747
- t ? (D(m), e(m)) : (s("days"), e(m));
748
- }, D = (m) => {
749
- var i;
750
- let o = { ...l };
751
- if (o.from && o.to)
752
- o = { from: m, to: null };
767
+ const c = l.from.getFullYear(), v = r.getFullYear(), k = (b) => {
768
+ t ? (D(b), e(b)) : (o("days"), e(b));
769
+ }, D = (b) => {
770
+ var s;
771
+ let f = { ...l };
772
+ if (f.from && f.to)
773
+ f = { from: b, to: null };
753
774
  else {
754
- const k = ((i = o.from) == null ? void 0 : i.getTime()) || 0;
755
- m.getTime() > k ? o = { from: o.from, to: m } : o = { from: m, to: o.from };
775
+ const x = ((s = f.from) == null ? void 0 : s.getTime()) || 0;
776
+ b.getTime() > x ? f = { from: f.from, to: b } : f = { from: b, to: f.from };
756
777
  }
757
- c(o), d(o);
778
+ u(f), d(f);
758
779
  };
759
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: A.map((m, o) => {
760
- var L, h, v;
761
- const i = new Date(y, o).getTime() > l.from.getTime() && new Date(y, o).getTime() < (((L = l.to) == null ? void 0 : L.getTime()) || l.from.getTime()), k = g && new Date(y, o) < g || f && new Date(y, o) > f;
780
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((b, f) => {
781
+ var N, h, m;
782
+ const s = new Date(v, f).getTime() > l.from.getTime() && new Date(v, f).getTime() < (((N = l.to) == null ? void 0 : N.getTime()) || l.from.getTime()), x = p && new Date(v, f) < p || g && new Date(v, f) > g;
762
783
  return /* @__PURE__ */ a(
763
784
  "p",
764
785
  {
765
- className: u === y && (o === ((h = l.from) == null ? void 0 : h.getMonth()) || o === ((v = l.to) == null ? void 0 : v.getMonth())) ? "sa-calendar-months-active" : "",
786
+ className: c === v && (f === ((h = l.from) == null ? void 0 : h.getMonth()) || f === ((m = l.to) == null ? void 0 : m.getMonth())) ? "sa-calendar-months-active" : "",
766
787
  style: {
767
- backgroundColor: i ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
768
- pointerEvents: k ? "none" : void 0,
769
- cursor: k ? "not-allowed" : "pointer",
770
- color: k ? "var(--sa-color-gray-400, #b7b9be)" : i ? "var(--sa-color-gray-500, #8c8f97)" : "",
788
+ backgroundColor: s ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
789
+ pointerEvents: x ? "none" : void 0,
790
+ cursor: x ? "not-allowed" : "pointer",
791
+ color: x ? "var(--sa-color-gray-400, #b7b9be)" : s ? "var(--sa-color-gray-500, #8c8f97)" : "",
771
792
  ...n ? {} : { width: "100%" }
772
793
  },
773
794
  onClick: () => {
774
- k || x(new Date(y, o));
795
+ x || k(new Date(v, f));
775
796
  },
776
- children: m.slice(0, 3)
797
+ children: b.slice(0, 3)
777
798
  },
778
- o
799
+ f
779
800
  );
780
801
  }) });
781
802
  }, q = (r) => {
@@ -785,45 +806,45 @@ const W = (r) => {
785
806
  date: r,
786
807
  filter: e,
787
808
  setViews: t,
788
- setDate: s,
809
+ setDate: o,
789
810
  dateRange: l,
790
- setDateRange: c,
811
+ setDateRange: u,
791
812
  onChange: d,
792
- minDate: g,
793
- maxDate: f,
813
+ minDate: p,
814
+ maxDate: g,
794
815
  input: n
795
816
  }) => {
796
- var L;
797
- let u = [];
798
- const y = r.getFullYear(), { start: x, end: D } = q(y), m = l.from.getFullYear(), o = (L = l.to) == null ? void 0 : L.getFullYear();
799
- for (let h = x; h < D; h++) {
800
- const v = new Date(h, 0), p = (!g || v >= g) && (!f || v <= f), b = h === m || h === o, $ = v > l.from && v < l.to;
801
- u.push({
817
+ var N;
818
+ let c = [];
819
+ const v = r.getFullYear(), { start: k, end: D } = q(v), b = l.from.getFullYear(), f = (N = l.to) == null ? void 0 : N.getFullYear();
820
+ for (let h = k; h < D; h++) {
821
+ const m = new Date(h, 0), F = (!p || m >= p) && (!g || m <= g), i = h === b || h === f, w = m > l.from && m < l.to;
822
+ c.push({
802
823
  year: h,
803
- active: b && p,
804
- highlight: $ && p,
805
- disabled: !p
824
+ active: i && F,
825
+ highlight: w && F,
826
+ disabled: !F
806
827
  });
807
828
  }
808
- const i = (h) => {
809
- e ? (k(h), s(h)) : (s(h), t("months"));
810
- }, k = (h) => {
811
- var p;
812
- let v = { ...l };
813
- if (v.from && v.to)
814
- v = { from: h, to: null };
829
+ const s = (h) => {
830
+ e ? (x(h), o(h)) : (o(h), t("months"));
831
+ }, x = (h) => {
832
+ var F;
833
+ let m = { ...l };
834
+ if (m.from && m.to)
835
+ m = { from: h, to: null };
815
836
  else {
816
- const b = ((p = v.from) == null ? void 0 : p.getTime()) || 0;
817
- h.getTime() > b ? v = { from: v.from, to: h } : v = { from: h, to: v.from };
837
+ const i = ((F = m.from) == null ? void 0 : F.getTime()) || 0;
838
+ h.getTime() > i ? m = { from: m.from, to: h } : m = { from: h, to: m.from };
818
839
  }
819
- c(v), d(v);
840
+ u(m), d(m);
820
841
  };
821
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: u.map((h, v) => /* @__PURE__ */ a(
842
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: c.map((h, m) => /* @__PURE__ */ a(
822
843
  "p",
823
844
  {
824
845
  className: `${h.active ? "sa-calendar-months-active" : ""} ${h.highlight ? "sa-calendar-months-highlight" : ""} ${h.disabled ? "sa-calendar-disabled" : ""}`,
825
846
  onClick: () => {
826
- h.disabled || i(new Date(h.year, 0));
847
+ h.disabled || s(new Date(h.year, 0));
827
848
  },
828
849
  style: {
829
850
  backgroundColor: h.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
@@ -834,7 +855,7 @@ const W = (r) => {
834
855
  },
835
856
  children: h.year
836
857
  },
837
- v
858
+ m
838
859
  )) });
839
860
  }, rn = ({ ...r }) => /* @__PURE__ */ a(
840
861
  "svg",
@@ -880,10 +901,10 @@ const W = (r) => {
880
901
  setViews: r,
881
902
  views: e,
882
903
  filter: t,
883
- date: s,
904
+ date: o,
884
905
  setDate: l
885
906
  }) => {
886
- const c = () => {
907
+ const u = () => {
887
908
  t || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
888
909
  }, d = () => {
889
910
  if (e === "years") {
@@ -895,7 +916,7 @@ const W = (r) => {
895
916
  return;
896
917
  }
897
918
  l((n) => new Date(n.getFullYear(), n.getMonth() + 1));
898
- }, g = () => {
919
+ }, p = () => {
899
920
  if (e === "years") {
900
921
  l((n) => new Date(n.getFullYear() - 10, 0));
901
922
  return;
@@ -911,65 +932,65 @@ const W = (r) => {
911
932
  )
912
933
  );
913
934
  };
914
- return /* @__PURE__ */ N("div", { className: "sa-calendar-header", children: [
915
- /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: c, children: (() => {
935
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
936
+ /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
916
937
  if (e === "days")
917
- return `${A[s.getMonth()]} ${s.getFullYear()}`;
938
+ return `${W[o.getMonth()]} ${o.getFullYear()}`;
918
939
  if (e === "months")
919
- return `${s.getFullYear()}`;
940
+ return `${o.getFullYear()}`;
920
941
  if (e === "years")
921
- return `${q(s.getFullYear()).start} ~ ${q(s.getFullYear()).end}`;
942
+ return `${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`;
922
943
  })() }),
923
- /* @__PURE__ */ N("div", { className: "sa-calendar-header-nav", children: [
924
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(rn, {}) }),
944
+ /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
945
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ a(rn, {}) }),
925
946
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: d, children: /* @__PURE__ */ a(tn, {}) })
926
947
  ] })
927
948
  ] });
928
949
  };
929
- function O(r) {
930
- const e = new Date(r), t = e.getFullYear(), s = e.getMonth();
931
- return `${e.getDate().toString().padStart(2, "0")} ${on[s]} ${t}`;
950
+ function P(r) {
951
+ const e = new Date(r), t = e.getFullYear(), o = e.getMonth();
952
+ return `${e.getDate().toString().padStart(2, "0")} ${on[o]} ${t}`;
932
953
  }
933
954
  const sn = ({
934
955
  label: r,
935
956
  labelPosition: e = "outside-top",
936
957
  required: t,
937
- optional: s,
958
+ optional: o,
938
959
  description: l,
939
- helperText: c,
960
+ helperText: u,
940
961
  errorText: d,
941
- fullWidth: g,
942
- children: f
962
+ fullWidth: p,
963
+ children: g
943
964
  }) => {
944
965
  const n = [
945
966
  "sa-date-field",
946
- g ? "sa-date-field-fullwidth" : ""
947
- ].filter(Boolean).join(" "), u = r ? /* @__PURE__ */ N("div", { className: "sa-date-field-label-row", children: [
967
+ p ? "sa-date-field-fullwidth" : ""
968
+ ].filter(Boolean).join(" "), c = r ? /* @__PURE__ */ $("div", { className: "sa-date-field-label-row", children: [
948
969
  /* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: r }),
949
- s && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
970
+ o && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
950
971
  t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
951
- ] }) : null, y = /* @__PURE__ */ N(nn, { children: [
952
- c && !d && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: c }),
972
+ ] }) : null, v = /* @__PURE__ */ $(nn, { children: [
973
+ u && !d && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: u }),
953
974
  d && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: d })
954
975
  ] });
955
- return r ? e === "outside-left" ? /* @__PURE__ */ N("div", { className: `${n} sa-date-field-left`, children: [
956
- /* @__PURE__ */ N("div", { className: "sa-date-field-left-label", children: [
957
- u,
976
+ return r ? e === "outside-left" ? /* @__PURE__ */ $("div", { className: `${n} sa-date-field-left`, children: [
977
+ /* @__PURE__ */ $("div", { className: "sa-date-field-left-label", children: [
978
+ c,
958
979
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l })
959
980
  ] }),
960
- /* @__PURE__ */ N("div", { className: "sa-date-field-input-wrap", children: [
961
- f,
962
- y
981
+ /* @__PURE__ */ $("div", { className: "sa-date-field-input-wrap", children: [
982
+ g,
983
+ v
963
984
  ] })
964
- ] }) : /* @__PURE__ */ N("div", { className: n, children: [
965
- u,
985
+ ] }) : /* @__PURE__ */ $("div", { className: n, children: [
986
+ c,
966
987
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
967
- f,
968
- y
969
- ] }) : /* @__PURE__ */ N("div", { className: n, children: [
988
+ g,
989
+ v
990
+ ] }) : /* @__PURE__ */ $("div", { className: n, children: [
970
991
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
971
- f,
972
- y
992
+ g,
993
+ v
973
994
  ] });
974
995
  }, Q = "sa-calendar-styles", gn = (r) => {
975
996
  if (!document.getElementById(Q)) {
@@ -977,156 +998,156 @@ const sn = ({
977
998
  e.id = Q, e.textContent = r, document.head.appendChild(e);
978
999
  }
979
1000
  };
980
- gn(J);
1001
+ gn(R);
981
1002
  const fn = Z(
982
1003
  ({
983
1004
  value: r,
984
1005
  onChange: e,
985
1006
  filter: t,
986
- input: s = !0,
1007
+ input: o = !0,
987
1008
  disabled: l,
988
- minDate: c,
1009
+ minDate: u,
989
1010
  maxDate: d,
990
- placeholder: g,
991
- size: f,
1011
+ placeholder: p,
1012
+ size: g,
992
1013
  variant: n,
993
- status: u,
994
- clearable: y,
995
- fullWidth: x = !0,
1014
+ status: c,
1015
+ clearable: v,
1016
+ fullWidth: k = !0,
996
1017
  label: D,
997
- labelPosition: m,
998
- required: o,
999
- optional: i,
1000
- description: k,
1001
- helperText: L,
1018
+ labelPosition: b,
1019
+ required: f,
1020
+ optional: s,
1021
+ description: x,
1022
+ helperText: N,
1002
1023
  errorText: h
1003
- }, v) => {
1004
- const p = h ? "error" : u, { ref: b, isComponentVisible: $, setIsComponentVisible: T } = an(!1), M = P(null), [F, I] = j("days"), [E, Y] = j(/* @__PURE__ */ new Date()), [C, z] = j({
1024
+ }, m) => {
1025
+ const F = h ? "error" : c, { ref: i, isComponentVisible: w, setIsComponentVisible: L } = an(!1), M = J(null), [T, Y] = j("days"), [E, S] = j(/* @__PURE__ */ new Date()), [C, z] = j({
1005
1026
  from: (r == null ? void 0 : r.from) || /* @__PURE__ */ new Date(),
1006
1027
  to: (r == null ? void 0 : r.to) || /* @__PURE__ */ new Date()
1007
1028
  });
1008
- S(() => {
1009
- r ? (Y(r.from), z(r)) : (Y(/* @__PURE__ */ new Date()), z({
1029
+ I(() => {
1030
+ r ? (S(r.from), z(r)) : (S(/* @__PURE__ */ new Date()), z({
1010
1031
  from: /* @__PURE__ */ new Date(),
1011
1032
  to: /* @__PURE__ */ new Date()
1012
1033
  }));
1013
- }, [r]), S(() => {
1014
- t && I(t);
1015
- }, [t]), S(() => {
1016
- t || I("days");
1017
- }, [$]), S(() => {
1018
- s || T(!0);
1019
- }, [s]);
1020
- const R = () => {
1021
- var w, B;
1034
+ }, [r]), I(() => {
1035
+ t && Y(t);
1036
+ }, [t]), I(() => {
1037
+ t || Y("days");
1038
+ }, [w]), I(() => {
1039
+ o || L(!0);
1040
+ }, [o]);
1041
+ const A = () => {
1042
+ var y, B;
1022
1043
  if (!r)
1023
1044
  return "";
1024
1045
  if (t) {
1025
- if (F === "days")
1026
- return `${O(C.from)} ~ ${O(C.to || C.from) || "-"}`;
1027
- if (F === "months")
1028
- return `${A[C.from.getMonth()]} ~ ${C.to ? A[C.to.getMonth()] : "-"}`;
1029
- if (F === "years")
1030
- return `${(w = C.from) == null ? void 0 : w.getFullYear()} ~ ${((B = C.to) == null ? void 0 : B.getFullYear()) || "-"}`;
1046
+ if (T === "days")
1047
+ return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
1048
+ if (T === "months")
1049
+ return `${W[C.from.getMonth()]} ~ ${C.to ? W[C.to.getMonth()] : "-"}`;
1050
+ if (T === "years")
1051
+ return `${(y = C.from) == null ? void 0 : y.getFullYear()} ~ ${((B = C.to) == null ? void 0 : B.getFullYear()) || "-"}`;
1031
1052
  } else
1032
- return `${O(C.from)} ~ ${O(C.to || C.from) || "-"}`;
1053
+ return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
1033
1054
  }, V = () => {
1034
- if (M.current && b.current && s) {
1035
- const w = b.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1036
- window.innerWidth < w.left + B.width ? M.current.style.left = `${w.left - B.width + w.width}px` : M.current.style.left = `${w.left}px`, w.top + B.height > window.innerHeight ? M.current.style.top = `${w.y - (w.height + B.height - 28)}px` : M.current.style.top = `${w.y + w.height}px`;
1055
+ if (M.current && i.current && o) {
1056
+ const y = i.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1057
+ window.innerWidth < y.left + B.width ? M.current.style.left = `${y.left - B.width + y.width}px` : M.current.style.left = `${y.left}px`, y.top + B.height > window.innerHeight ? M.current.style.top = `${y.y - (y.height + B.height - 28)}px` : M.current.style.top = `${y.y + y.height}px`;
1037
1058
  }
1038
1059
  };
1039
- S(() => {
1040
- M.current && b.current && s && V();
1041
- }, [M, b, $]), S(() => {
1042
- const w = v == null ? void 0 : v.current;
1043
- return w && w.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1044
- w && w.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1060
+ I(() => {
1061
+ M.current && i.current && o && V();
1062
+ }, [M, i, w]), I(() => {
1063
+ const y = m == null ? void 0 : m.current;
1064
+ return y && y.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1065
+ y && y.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1045
1066
  };
1046
1067
  }, []);
1047
- const U = /* @__PURE__ */ N(
1068
+ const U = /* @__PURE__ */ $(
1048
1069
  "div",
1049
1070
  {
1050
1071
  className: "sa-calendar-wrapper",
1051
- style: { height: s ? "auto" : "100%" },
1052
- ref: s ? b : null,
1072
+ style: { height: o ? "auto" : "100%" },
1073
+ ref: o ? i : null,
1053
1074
  children: [
1054
- s ? /* @__PURE__ */ a(
1075
+ o ? /* @__PURE__ */ a(
1055
1076
  dn,
1056
1077
  {
1057
- value: R(),
1078
+ value: A(),
1058
1079
  inputMode: "none",
1059
1080
  onClick: () => {
1060
- T(!0);
1081
+ L(!0);
1061
1082
  },
1062
1083
  onChange: () => {
1063
1084
  },
1064
1085
  disabled: l,
1065
- placeholder: g,
1066
- size: f,
1086
+ placeholder: p,
1087
+ size: g,
1067
1088
  variant: n,
1068
- status: p,
1069
- clearable: y,
1089
+ status: F,
1090
+ clearable: v,
1070
1091
  onClear: () => e(void 0)
1071
1092
  }
1072
1093
  ) : null,
1073
- $ ? /* @__PURE__ */ N(
1094
+ w ? /* @__PURE__ */ $(
1074
1095
  "div",
1075
1096
  {
1076
- className: `sa-calendar sa-calendar-size-${f || "md"} ${s ? "" : "sa-calendar-no-input"}`,
1097
+ className: `sa-calendar sa-calendar-size-${g || "md"} ${o ? "" : "sa-calendar-no-input"}`,
1077
1098
  ref: M,
1078
1099
  children: [
1079
1100
  /* @__PURE__ */ a(
1080
1101
  pn,
1081
1102
  {
1082
- setViews: I,
1083
- views: F,
1103
+ setViews: Y,
1104
+ views: T,
1084
1105
  filter: t,
1085
1106
  date: E,
1086
- setDate: Y
1107
+ setDate: S
1087
1108
  }
1088
1109
  ),
1089
- /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ a(
1110
+ /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ a(
1090
1111
  cn,
1091
1112
  {
1092
1113
  date: E,
1093
- setDate: Y,
1094
- setIsComponentVisible: T,
1114
+ setDate: S,
1115
+ setIsComponentVisible: L,
1095
1116
  dateRange: C,
1096
1117
  setDateRange: z,
1097
- input: s,
1118
+ input: o,
1098
1119
  onChange: e,
1099
- minDate: c,
1120
+ minDate: u,
1100
1121
  maxDate: d
1101
1122
  }
1102
- ) : F === "months" ? /* @__PURE__ */ a(
1123
+ ) : T === "months" ? /* @__PURE__ */ a(
1103
1124
  un,
1104
1125
  {
1105
1126
  date: E,
1106
- setDate: Y,
1127
+ setDate: S,
1107
1128
  filter: t,
1108
- setViews: I,
1129
+ setViews: Y,
1109
1130
  dateRange: C,
1110
1131
  setDateRange: z,
1111
- setIsComponentVisible: T,
1112
- input: s,
1132
+ setIsComponentVisible: L,
1133
+ input: o,
1113
1134
  onChange: e,
1114
- minDate: c,
1135
+ minDate: u,
1115
1136
  maxDate: d
1116
1137
  }
1117
1138
  ) : /* @__PURE__ */ a(
1118
1139
  hn,
1119
1140
  {
1120
1141
  date: E,
1121
- setDate: Y,
1142
+ setDate: S,
1122
1143
  filter: t,
1123
- setViews: I,
1144
+ setViews: Y,
1124
1145
  dateRange: C,
1125
1146
  setDateRange: z,
1126
- setIsComponentVisible: T,
1127
- input: s,
1147
+ setIsComponentVisible: L,
1148
+ input: o,
1128
1149
  onChange: e,
1129
- minDate: c,
1150
+ minDate: u,
1130
1151
  maxDate: d
1131
1152
  }
1132
1153
  ) })
@@ -1140,13 +1161,13 @@ const fn = Z(
1140
1161
  sn,
1141
1162
  {
1142
1163
  label: D,
1143
- labelPosition: m,
1144
- required: o,
1145
- optional: i,
1146
- description: k,
1147
- helperText: L,
1164
+ labelPosition: b,
1165
+ required: f,
1166
+ optional: s,
1167
+ description: x,
1168
+ helperText: N,
1148
1169
  errorText: h,
1149
- fullWidth: x,
1170
+ fullWidth: k,
1150
1171
  children: U
1151
1172
  }
1152
1173
  );
@@ -1157,8 +1178,8 @@ const fn = Z(
1157
1178
  e.id = X, e.textContent = r, document.head.appendChild(e);
1158
1179
  }
1159
1180
  };
1160
- bn(J);
1161
- const H = (r) => {
1181
+ bn(R);
1182
+ const O = (r) => {
1162
1183
  if (r === "sm")
1163
1184
  return 16;
1164
1185
  if (r === "md")
@@ -1169,27 +1190,27 @@ const H = (r) => {
1169
1190
  const {
1170
1191
  size: e = "md",
1171
1192
  status: t = "default",
1172
- variant: s = "outline",
1193
+ variant: o = "outline",
1173
1194
  clearable: l,
1174
- onClear: c,
1195
+ onClear: u,
1175
1196
  ...d
1176
- } = r, g = P(null), f = () => {
1177
- g.current && d.onClick && (g.current.focus(), d.onClick(""));
1178
- }, n = t === "disable" || d.disabled, u = !!d.value, y = l && u && !n, x = (D) => {
1179
- D.stopPropagation(), c == null || c();
1197
+ } = r, p = J(null), g = () => {
1198
+ p.current && d.onClick && (p.current.focus(), d.onClick(""));
1199
+ }, n = t === "disable" || d.disabled, c = !!d.value, v = l && c && !n, k = (D) => {
1200
+ D.stopPropagation(), u == null || u();
1180
1201
  };
1181
- return /* @__PURE__ */ N(
1202
+ return /* @__PURE__ */ $(
1182
1203
  "div",
1183
1204
  {
1184
- className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${e} `,
1185
- onClick: f,
1205
+ className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,
1206
+ onClick: g,
1186
1207
  children: [
1187
1208
  /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
1188
1209
  "svg",
1189
1210
  {
1190
1211
  xmlns: "http://www.w3.org/2000/svg",
1191
- width: H(e),
1192
- height: H(e),
1212
+ width: O(e),
1213
+ height: O(e),
1193
1214
  viewBox: "0 0 20 20",
1194
1215
  fill: "none",
1195
1216
  children: /* @__PURE__ */ a(
@@ -1211,22 +1232,22 @@ const H = (r) => {
1211
1232
  ...d,
1212
1233
  disabled: n,
1213
1234
  value: d.value,
1214
- ref: g
1235
+ ref: p
1215
1236
  }
1216
1237
  ) }),
1217
- y ? /* @__PURE__ */ a(
1238
+ v ? /* @__PURE__ */ a(
1218
1239
  "button",
1219
1240
  {
1220
1241
  type: "button",
1221
1242
  "aria-label": "Clear date",
1222
1243
  className: "sa-calendar-input-clear",
1223
- onClick: x,
1244
+ onClick: k,
1224
1245
  children: /* @__PURE__ */ a(
1225
1246
  "svg",
1226
1247
  {
1227
1248
  xmlns: "http://www.w3.org/2000/svg",
1228
- width: H(e),
1229
- height: H(e),
1249
+ width: O(e),
1250
+ height: O(e),
1230
1251
  viewBox: "0 0 20 20",
1231
1252
  fill: "none",
1232
1253
  children: /* @__PURE__ */ a(
@@ -1246,8 +1267,8 @@ const H = (r) => {
1246
1267
  "svg",
1247
1268
  {
1248
1269
  xmlns: "http://www.w3.org/2000/svg",
1249
- width: H(e),
1250
- height: H(e),
1270
+ width: O(e),
1271
+ height: O(e),
1251
1272
  viewBox: "0 0 20 20",
1252
1273
  fill: "none",
1253
1274
  children: /* @__PURE__ */ a(
@@ -1269,57 +1290,58 @@ const H = (r) => {
1269
1290
  date: r,
1270
1291
  setDate: e,
1271
1292
  previewDate: t,
1272
- setPreviewDate: s,
1293
+ setPreviewDate: o,
1273
1294
  setIsComponentVisible: l,
1274
- minDate: c,
1295
+ minDate: u,
1275
1296
  maxDate: d,
1276
- input: g,
1277
- onChange: f
1297
+ input: p,
1298
+ onChange: g
1278
1299
  }) => {
1279
1300
  let n = new Date(
1280
1301
  t.getFullYear(),
1281
1302
  t.getMonth(),
1282
1303
  1
1283
- ), u = n.getDay(), y = [];
1284
- const x = r.toDateString(), D = t.getMonth();
1285
- for (let o = 0; o < 42; o++) {
1286
- o === 0 && u === 0 ? n.setDate(n.getDate() - 7) : o === 0 ? n.setDate(
1287
- n.getDate() + (o - u)
1304
+ ), c = n.getDay(), v = [];
1305
+ const k = r.toDateString(), D = (/* @__PURE__ */ new Date()).toDateString(), b = t.getMonth();
1306
+ for (let s = 0; s < 42; s++) {
1307
+ s === 0 && c === 0 ? n.setDate(n.getDate() - 7) : s === 0 ? n.setDate(
1308
+ n.getDate() + (s - c)
1288
1309
  ) : n.setDate(n.getDate() + 1);
1289
- let i = {
1290
- currentMonth: n.getMonth() === D,
1310
+ let x = {
1311
+ currentMonth: n.getMonth() === b,
1291
1312
  date: new Date(n),
1292
1313
  month: n.getMonth(),
1293
1314
  number: n.getDate(),
1294
- selected: n.toDateString() === x,
1315
+ selected: n.toDateString() === k,
1316
+ isToday: n.toDateString() === D,
1295
1317
  year: n.getFullYear(),
1296
- isDisabled: c && n < c || d && n > d
1318
+ isDisabled: u && n < u || d && n > d
1297
1319
  };
1298
- y.push(i);
1320
+ v.push(x);
1299
1321
  }
1300
- const m = (o) => {
1301
- (!c || o >= c) && (!d || o <= d) && (e(o), f(o), s(o), g && l(!1));
1322
+ const f = (s) => {
1323
+ (!u || s >= u) && (!d || s <= d) && (e(s), g(s), o(s), p && l(!1));
1302
1324
  };
1303
- return /* @__PURE__ */ N("div", { className: "sa-calendar-days-preivew", children: [
1304
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((o, i) => /* @__PURE__ */ a("p", { children: o }, i)) }),
1305
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: y.map((o, i) => {
1306
- const k = o.isDisabled;
1325
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
1326
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((s, x) => /* @__PURE__ */ a("p", { children: s }, x)) }),
1327
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: v.map((s, x) => {
1328
+ const N = s.isDisabled;
1307
1329
  return /* @__PURE__ */ a(
1308
1330
  "p",
1309
1331
  {
1310
- className: `${o.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${o.selected ? "sa-calendar-days-active" : ""}`,
1332
+ className: `${s.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${s.selected ? "sa-calendar-days-active" : ""} ${s.isToday && !s.selected ? "sa-calendar-days-today" : ""}`,
1311
1333
  style: {
1312
- color: k ? "#ccc" : void 0,
1313
- pointerEvents: k ? "none" : void 0,
1314
- cursor: k ? "not-allowed" : "pointer",
1315
- ...g ? {} : { width: "100%" }
1334
+ color: N ? "#ccc" : void 0,
1335
+ pointerEvents: N ? "none" : void 0,
1336
+ cursor: N ? "not-allowed" : "pointer",
1337
+ ...p ? {} : { width: "100%" }
1316
1338
  },
1317
1339
  onClick: () => {
1318
- k || m(o.date);
1340
+ N || f(s.date);
1319
1341
  },
1320
- children: o.number
1342
+ children: s.number
1321
1343
  },
1322
- i
1344
+ x
1323
1345
  );
1324
1346
  }) })
1325
1347
  ] });
@@ -1327,35 +1349,35 @@ const H = (r) => {
1327
1349
  date: r,
1328
1350
  setDate: e,
1329
1351
  filter: t,
1330
- setViews: s,
1352
+ setViews: o,
1331
1353
  onChange: l,
1332
- previewDate: c,
1354
+ previewDate: u,
1333
1355
  setPreviewDate: d,
1334
- minDate: g,
1335
- maxDate: f,
1356
+ minDate: p,
1357
+ maxDate: g,
1336
1358
  input: n
1337
1359
  }) => {
1338
- const u = r.getMonth(), y = r.getFullYear(), x = c.getFullYear(), D = (m) => {
1339
- (!g || m >= g) && (!f || m <= f) && (t ? (l(m), e(m), d(m)) : (s("days"), d(m)));
1360
+ const c = r.getMonth(), v = r.getFullYear(), k = u.getFullYear(), D = (b) => {
1361
+ (!p || b >= p) && (!g || b <= g) && (t ? (l(b), e(b), d(b)) : (o("days"), d(b)));
1340
1362
  };
1341
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: A.map((m, o) => {
1342
- const i = g && new Date(x, o, 1) < g || f && new Date(x, o + 1, 0) > f;
1363
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((b, f) => {
1364
+ const s = p && new Date(k, f, 1) < p || g && new Date(k, f + 1, 0) > g;
1343
1365
  return /* @__PURE__ */ a(
1344
1366
  "p",
1345
1367
  {
1346
- className: o === u && x === y ? "sa-calendar-months-active" : "",
1368
+ className: f === c && k === v ? "sa-calendar-months-active" : "",
1347
1369
  style: {
1348
- color: i ? "#ccc" : void 0,
1349
- pointerEvents: i ? "none" : void 0,
1350
- cursor: i ? "not-allowed" : "pointer",
1370
+ color: s ? "#ccc" : void 0,
1371
+ pointerEvents: s ? "none" : void 0,
1372
+ cursor: s ? "not-allowed" : "pointer",
1351
1373
  ...n ? {} : { width: "100%" }
1352
1374
  },
1353
1375
  onClick: () => {
1354
- i || D(new Date(x, o));
1376
+ s || D(new Date(k, f));
1355
1377
  },
1356
- children: m.slice(0, 3)
1378
+ children: b.slice(0, 3)
1357
1379
  },
1358
- o
1380
+ f
1359
1381
  );
1360
1382
  }) });
1361
1383
  }, G = (r) => {
@@ -1365,48 +1387,48 @@ const H = (r) => {
1365
1387
  date: r,
1366
1388
  filter: e,
1367
1389
  setViews: t,
1368
- setDate: s,
1390
+ setDate: o,
1369
1391
  onChange: l,
1370
- previewDate: c,
1392
+ previewDate: u,
1371
1393
  setPreviewDate: d,
1372
- minDate: g,
1373
- maxDate: f,
1394
+ minDate: p,
1395
+ maxDate: g,
1374
1396
  input: n
1375
1397
  }) => {
1376
- let u = [];
1377
- const y = c.getFullYear(), { start: x, end: D } = G(y), m = r.getFullYear();
1378
- for (let i = x; i < D; i++) {
1379
- let k = g && new Date(i, 0, 1) < g || f && new Date(i, 11, 31) > f;
1380
- u.push({ year: i, active: i === m, isDisabled: k });
1398
+ let c = [];
1399
+ const v = u.getFullYear(), { start: k, end: D } = G(v), b = r.getFullYear();
1400
+ for (let s = k; s < D; s++) {
1401
+ let x = p && new Date(s, 0, 1) < p || g && new Date(s, 11, 31) > g;
1402
+ c.push({ year: s, active: s === b, isDisabled: x });
1381
1403
  }
1382
- const o = (i) => {
1383
- (!g || i >= g) && (!f || i <= f) && (e ? (l(i), s(i), d(i)) : (t("months"), d(i)));
1404
+ const f = (s) => {
1405
+ (!p || s >= p) && (!g || s <= g) && (e ? (l(s), o(s), d(s)) : (t("months"), d(s)));
1384
1406
  };
1385
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: u.map((i, k) => /* @__PURE__ */ a(
1407
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: c.map((s, x) => /* @__PURE__ */ a(
1386
1408
  "p",
1387
1409
  {
1388
- className: i.active ? "sa-calendar-months-active" : "",
1410
+ className: s.active ? "sa-calendar-months-active" : "",
1389
1411
  style: {
1390
- color: i.isDisabled ? "#ccc" : void 0,
1391
- pointerEvents: i.isDisabled ? "none" : void 0,
1392
- cursor: i.isDisabled ? "not-allowed" : "pointer",
1412
+ color: s.isDisabled ? "#ccc" : void 0,
1413
+ pointerEvents: s.isDisabled ? "none" : void 0,
1414
+ cursor: s.isDisabled ? "not-allowed" : "pointer",
1393
1415
  ...n ? {} : { width: "100%" }
1394
1416
  },
1395
1417
  onClick: () => {
1396
- i.isDisabled || o(new Date(i.year, 0));
1418
+ s.isDisabled || f(new Date(s.year, 0));
1397
1419
  },
1398
- children: i.year
1420
+ children: s.year
1399
1421
  },
1400
- k
1422
+ x
1401
1423
  )) });
1402
1424
  }, xn = ({
1403
1425
  setViews: r,
1404
1426
  views: e,
1405
1427
  filter: t,
1406
- previewDate: s,
1428
+ previewDate: o,
1407
1429
  setPreviewDate: l
1408
1430
  }) => {
1409
- const c = () => {
1431
+ const u = () => {
1410
1432
  t || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
1411
1433
  }, d = () => {
1412
1434
  if (e === "years") {
@@ -1420,7 +1442,7 @@ const H = (r) => {
1420
1442
  return;
1421
1443
  }
1422
1444
  l((n) => new Date(n.getFullYear(), n.getMonth() + 1));
1423
- }, g = () => {
1445
+ }, p = () => {
1424
1446
  if (e === "years") {
1425
1447
  l((n) => new Date(n.getFullYear() - 10, 0));
1426
1448
  return;
@@ -1438,17 +1460,17 @@ const H = (r) => {
1438
1460
  )
1439
1461
  );
1440
1462
  };
1441
- return /* @__PURE__ */ N("div", { className: "sa-calendar-header", children: [
1442
- /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: c, children: (() => {
1463
+ return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1464
+ /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
1443
1465
  if (e === "days")
1444
- return `${A[s.getMonth()]} ${s.getFullYear()}`;
1466
+ return `${W[o.getMonth()]} ${o.getFullYear()}`;
1445
1467
  if (e === "months")
1446
- return `${s.getFullYear()}`;
1468
+ return `${o.getFullYear()}`;
1447
1469
  if (e === "years")
1448
- return `${G(s.getFullYear()).start} ~ ${G(s.getFullYear()).end}`;
1470
+ return `${G(o.getFullYear()).start} ~ ${G(o.getFullYear()).end}`;
1449
1471
  })() }),
1450
- /* @__PURE__ */ N("div", { className: "sa-calendar-header-nav", children: [
1451
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(rn, {}) }),
1472
+ /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
1473
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ a(rn, {}) }),
1452
1474
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: d, children: /* @__PURE__ */ a(tn, {}) })
1453
1475
  ] })
1454
1476
  ] });
@@ -1458,135 +1480,135 @@ const H = (r) => {
1458
1480
  e.id = _, e.textContent = r, document.head.appendChild(e);
1459
1481
  }
1460
1482
  };
1461
- kn(J);
1483
+ kn(R);
1462
1484
  const Mn = Z(
1463
1485
  ({
1464
1486
  value: r,
1465
1487
  onChange: e,
1466
1488
  filter: t,
1467
- input: s = !0,
1489
+ input: o = !0,
1468
1490
  disabled: l,
1469
- minDate: c,
1491
+ minDate: u,
1470
1492
  maxDate: d,
1471
- placeholder: g,
1472
- size: f,
1493
+ placeholder: p,
1494
+ size: g,
1473
1495
  variant: n,
1474
- status: u,
1475
- clearable: y,
1476
- fullWidth: x = !0,
1496
+ status: c,
1497
+ clearable: v,
1498
+ fullWidth: k = !0,
1477
1499
  label: D,
1478
- labelPosition: m,
1479
- required: o,
1480
- optional: i,
1481
- description: k,
1482
- helperText: L,
1500
+ labelPosition: b,
1501
+ required: f,
1502
+ optional: s,
1503
+ description: x,
1504
+ helperText: N,
1483
1505
  errorText: h
1484
- }, v) => {
1485
- const p = h ? "error" : u, { ref: b, isComponentVisible: $, setIsComponentVisible: T } = an(!1), M = P(null), [F, I] = j("days"), [E, Y] = j(/* @__PURE__ */ new Date()), [C, z] = j(/* @__PURE__ */ new Date());
1486
- S(() => {
1487
- r ? (Y(r), z(r)) : (Y(/* @__PURE__ */ new Date()), z(/* @__PURE__ */ new Date()));
1488
- }, [r]), S(() => {
1489
- t && I(t);
1490
- }, [t]), S(() => {
1491
- t || I("days");
1492
- }, [$]), S(() => {
1493
- s || T(!0);
1494
- }, [s]);
1495
- const R = () => r ? t === "days" ? O(E) : t === "months" ? `${A[E.getMonth()]} ${E.getFullYear()}` : t === "years" ? E.getFullYear() : O(E) : "", V = () => {
1496
- if (M.current && b.current && s) {
1497
- const w = b.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1498
- window.innerWidth < w.left + B.width ? M.current.style.left = `${w.left - B.width + w.width}px` : M.current.style.left = `${w.left}px`, w.top + B.height > window.innerHeight ? M.current.style.top = `${w.y - (w.height + B.height - 28)}px` : M.current.style.top = `${w.y + w.height}px`;
1506
+ }, m) => {
1507
+ const F = h ? "error" : c, { ref: i, isComponentVisible: w, setIsComponentVisible: L } = an(!1), M = J(null), [T, Y] = j("days"), [E, S] = j(/* @__PURE__ */ new Date()), [C, z] = j(/* @__PURE__ */ new Date());
1508
+ I(() => {
1509
+ r ? (S(r), z(r)) : (S(/* @__PURE__ */ new Date()), z(/* @__PURE__ */ new Date()));
1510
+ }, [r]), I(() => {
1511
+ t && Y(t);
1512
+ }, [t]), I(() => {
1513
+ t || Y("days");
1514
+ }, [w]), I(() => {
1515
+ o || L(!0);
1516
+ }, [o]);
1517
+ const A = () => r ? t === "days" ? P(E) : t === "months" ? `${W[E.getMonth()]} ${E.getFullYear()}` : t === "years" ? E.getFullYear() : P(E) : "", V = () => {
1518
+ if (M.current && i.current && o) {
1519
+ const y = i.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
1520
+ window.innerWidth < y.left + B.width ? M.current.style.left = `${y.left - B.width + y.width}px` : M.current.style.left = `${y.left}px`, y.top + B.height > window.innerHeight ? M.current.style.top = `${y.y - (y.height + B.height - 28)}px` : M.current.style.top = `${y.y + y.height}px`;
1499
1521
  }
1500
1522
  };
1501
- S(() => {
1502
- M.current && b.current && s && V();
1503
- }, [M, b, $]), S(() => {
1504
- const w = v == null ? void 0 : v.current;
1505
- return w && w.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1506
- w && w.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1523
+ I(() => {
1524
+ M.current && i.current && o && V();
1525
+ }, [M, i, w]), I(() => {
1526
+ const y = m == null ? void 0 : m.current;
1527
+ return y && y.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
1528
+ y && y.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
1507
1529
  };
1508
1530
  }, []);
1509
- const U = /* @__PURE__ */ N(
1531
+ const U = /* @__PURE__ */ $(
1510
1532
  "div",
1511
1533
  {
1512
1534
  className: "sa-calendar-wrapper",
1513
- style: { height: s ? "auto" : "100%" },
1514
- ref: s ? b : null,
1535
+ style: { height: o ? "auto" : "100%" },
1536
+ ref: o ? i : null,
1515
1537
  children: [
1516
- s ? /* @__PURE__ */ a(
1538
+ o ? /* @__PURE__ */ a(
1517
1539
  mn,
1518
1540
  {
1519
- value: R(),
1520
- onClick: () => T(!0),
1541
+ value: A(),
1542
+ onClick: () => L(!0),
1521
1543
  onChange: () => {
1522
1544
  },
1523
- placeholder: g,
1545
+ placeholder: p,
1524
1546
  disabled: l,
1525
- size: f,
1547
+ size: g,
1526
1548
  variant: n,
1527
- status: p,
1549
+ status: F,
1528
1550
  inputMode: "none",
1529
- clearable: y,
1551
+ clearable: v,
1530
1552
  onClear: () => e(void 0)
1531
1553
  }
1532
1554
  ) : null,
1533
- $ ? /* @__PURE__ */ N(
1555
+ w ? /* @__PURE__ */ $(
1534
1556
  "div",
1535
1557
  {
1536
- className: `sa-calendar sa-calendar-size-${f || "md"} ${s ? "" : "sa-calendar-no-input"}`,
1558
+ className: `sa-calendar sa-calendar-size-${g || "md"} ${o ? "" : "sa-calendar-no-input"}`,
1537
1559
  ref: M,
1538
1560
  children: [
1539
1561
  /* @__PURE__ */ a(
1540
1562
  xn,
1541
1563
  {
1542
- setViews: I,
1543
- views: F,
1564
+ setViews: Y,
1565
+ views: T,
1544
1566
  filter: t,
1545
1567
  previewDate: C,
1546
1568
  setPreviewDate: z,
1547
- isComponentVisible: $
1569
+ isComponentVisible: w
1548
1570
  }
1549
1571
  ),
1550
- /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ a(
1572
+ /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ a(
1551
1573
  vn,
1552
1574
  {
1553
1575
  date: E,
1554
- setDate: Y,
1576
+ setDate: S,
1555
1577
  previewDate: C,
1556
1578
  setPreviewDate: z,
1557
- setIsComponentVisible: T,
1558
- input: s,
1559
- minDate: c,
1579
+ setIsComponentVisible: L,
1580
+ input: o,
1581
+ minDate: u,
1560
1582
  maxDate: d,
1561
1583
  onChange: e
1562
1584
  }
1563
- ) : F === "months" ? /* @__PURE__ */ a(
1585
+ ) : T === "months" ? /* @__PURE__ */ a(
1564
1586
  yn,
1565
1587
  {
1566
1588
  date: E,
1567
- setDate: Y,
1589
+ setDate: S,
1568
1590
  previewDate: C,
1569
1591
  setPreviewDate: z,
1570
1592
  filter: t,
1571
- setViews: I,
1593
+ setViews: Y,
1572
1594
  onChange: e,
1573
- minDate: c,
1595
+ minDate: u,
1574
1596
  maxDate: d,
1575
- input: s
1597
+ input: o
1576
1598
  }
1577
1599
  ) : /* @__PURE__ */ a(
1578
1600
  wn,
1579
1601
  {
1580
1602
  date: E,
1581
- setDate: Y,
1603
+ setDate: S,
1582
1604
  previewDate: C,
1583
1605
  setPreviewDate: z,
1584
1606
  filter: t,
1585
- setViews: I,
1607
+ setViews: Y,
1586
1608
  onChange: e,
1587
- minDate: c,
1609
+ minDate: u,
1588
1610
  maxDate: d,
1589
- input: s
1611
+ input: o
1590
1612
  }
1591
1613
  ) })
1592
1614
  ]
@@ -1599,13 +1621,13 @@ const Mn = Z(
1599
1621
  sn,
1600
1622
  {
1601
1623
  label: D,
1602
- labelPosition: m,
1603
- required: o,
1604
- optional: i,
1605
- description: k,
1606
- helperText: L,
1624
+ labelPosition: b,
1625
+ required: f,
1626
+ optional: s,
1627
+ description: x,
1628
+ helperText: N,
1607
1629
  errorText: h,
1608
- fullWidth: x,
1630
+ fullWidth: k,
1609
1631
  children: U
1610
1632
  }
1611
1633
  );
@@ -1615,48 +1637,48 @@ const Mn = Z(
1615
1637
  value: r,
1616
1638
  onChange: e,
1617
1639
  filter: t,
1618
- input: s = !0,
1640
+ input: o = !0,
1619
1641
  rangedDate: l,
1620
- disabled: c,
1642
+ disabled: u,
1621
1643
  minDate: d,
1622
- maxDate: g,
1623
- placeholder: f,
1644
+ maxDate: p,
1645
+ placeholder: g,
1624
1646
  size: n,
1625
- variant: u,
1626
- status: y,
1627
- clearable: x,
1647
+ variant: c,
1648
+ status: v,
1649
+ clearable: k,
1628
1650
  fullWidth: D,
1629
- label: m,
1630
- labelPosition: o,
1631
- required: i,
1632
- optional: k,
1633
- description: L,
1651
+ label: b,
1652
+ labelPosition: f,
1653
+ required: s,
1654
+ optional: x,
1655
+ description: N,
1634
1656
  helperText: h,
1635
- errorText: v
1636
- }, p) => {
1637
- const b = {
1657
+ errorText: m
1658
+ }, F) => {
1659
+ const i = {
1638
1660
  onChange: e,
1639
1661
  value: r,
1640
- input: s,
1662
+ input: o,
1641
1663
  filter: t,
1642
- disabled: c,
1664
+ disabled: u,
1643
1665
  minDate: d,
1644
- maxDate: g,
1645
- placeholder: f,
1666
+ maxDate: p,
1667
+ placeholder: g,
1646
1668
  size: n,
1647
- variant: u,
1648
- status: y,
1649
- clearable: x,
1669
+ variant: c,
1670
+ status: v,
1671
+ clearable: k,
1650
1672
  fullWidth: D,
1651
- label: m,
1652
- labelPosition: o,
1653
- required: i,
1654
- optional: k,
1655
- description: L,
1673
+ label: b,
1674
+ labelPosition: f,
1675
+ required: s,
1676
+ optional: x,
1677
+ description: N,
1656
1678
  helperText: h,
1657
- errorText: v
1679
+ errorText: m
1658
1680
  };
1659
- return /* @__PURE__ */ a(nn, { children: l ? /* @__PURE__ */ a(fn, { ...b, ref: p }) : /* @__PURE__ */ a(Mn, { ...b, ref: p }) });
1681
+ return /* @__PURE__ */ a(nn, { children: l ? /* @__PURE__ */ a(fn, { ...i, ref: F }) : /* @__PURE__ */ a(Mn, { ...i, ref: F }) });
1660
1682
  }
1661
1683
  );
1662
1684
  export {