@starasia/date 5.5.0 → 5.6.0

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 Y, jsx as a, Fragment as fn } from "react/jsx-runtime";
2
- import gn, { useState as Z, useRef as Q, useEffect as j, forwardRef as mn, useMemo as en } from "react";
3
- const un = `@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 z, jsx as s, Fragment as yn } from "react/jsx-runtime";
2
+ import wn, { useState as G, useRef as _, useEffect as P, forwardRef as xn, useMemo as tn } from "react";
3
+ const gn = `@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;
@@ -33,6 +33,12 @@ const un = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,w
33
33
  position: relative;
34
34
  width: 100%;
35
35
  }
36
+ /* Custom trigger: hug the trigger so the fixed calendar anchors to the actual
37
+ element (not a full-width container) — fixes right-edge flip misalignment. */
38
+ .sa-calendar-wrapper-custom {
39
+ width: max-content;
40
+ max-width: 100%;
41
+ }
36
42
 
37
43
  /* === DATE FIELD WRAPPER === */
38
44
  .sa-date-field {
@@ -590,7 +596,7 @@ const un = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,w
590
596
  width: 32px;
591
597
  height: 32px;
592
598
  }
593
- `, Ln = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], nn = [
599
+ `, Vn = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], Q = [
594
600
  "January",
595
601
  "February",
596
602
  "March",
@@ -603,7 +609,7 @@ const un = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,w
603
609
  "October",
604
610
  "November",
605
611
  "December"
606
- ], Vn = [
612
+ ], jn = [
607
613
  "Jan",
608
614
  "Feb",
609
615
  "Mar",
@@ -617,22 +623,22 @@ const un = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,w
617
623
  "Nov",
618
624
  "Dec"
619
625
  ];
620
- function Nn(n) {
621
- const [e, t] = Z(n), o = Q(null), s = (d) => {
622
- o.current && !o.current.contains(d.target) && t(!1);
626
+ function En(n) {
627
+ const [e, a] = G(n), o = _(null), r = (d) => {
628
+ o.current && !o.current.contains(d.target) && a(!1);
623
629
  };
624
- return j(() => (document.addEventListener("click", s, !0), () => {
625
- document.removeEventListener("click", s, !0);
626
- }), []), { ref: o, isComponentVisible: e, setIsComponentVisible: t };
630
+ return P(() => (document.addEventListener("click", r, !0), () => {
631
+ document.removeEventListener("click", r, !0);
632
+ }), []), { ref: o, isComponentVisible: e, setIsComponentVisible: a };
627
633
  }
628
- const Cn = "sa-calendar-input-styles", Bn = (n) => {
629
- if (!(typeof document > "u") && !document.getElementById(Cn)) {
634
+ const Ln = "sa-calendar-input-styles", An = (n) => {
635
+ if (!(typeof document > "u") && !document.getElementById(Ln)) {
630
636
  const e = document.createElement("style");
631
- e.id = Cn, e.textContent = n, document.head.appendChild(e);
637
+ e.id = Ln, e.textContent = n, document.head.appendChild(e);
632
638
  }
633
639
  };
634
- Bn(un);
635
- const an = (n) => {
640
+ An(gn);
641
+ const rn = (n) => {
636
642
  if (n === "xs")
637
643
  return 14;
638
644
  if (n === "sm")
@@ -641,34 +647,34 @@ const an = (n) => {
641
647
  return 16;
642
648
  if (n === "lg")
643
649
  return 20;
644
- }, Pn = (n) => {
650
+ }, Hn = (n) => {
645
651
  const {
646
652
  size: e = "sm",
647
- status: t = "default",
653
+ status: a = "default",
648
654
  variant: o = "outline",
649
- clearable: s,
655
+ clearable: r,
650
656
  onClear: d,
651
- ...l
652
- } = n, u = Q(null), h = () => {
653
- u.current && l.onClick && (u.current.focus(), l.onClick(""));
654
- }, r = t === "disable" || l.disabled, c = !!l.value, y = s && c && !r, k = (L) => {
655
- L.stopPropagation(), d == null || d();
657
+ ...i
658
+ } = n, p = _(null), h = () => {
659
+ p.current && i.onClick && (p.current.focus(), i.onClick(""));
660
+ }, l = a === "disable" || i.disabled, c = !!i.value, w = r && c && !l, M = (E) => {
661
+ E.stopPropagation(), d == null || d();
656
662
  };
657
- return /* @__PURE__ */ Y(
663
+ return /* @__PURE__ */ z(
658
664
  "div",
659
665
  {
660
- className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,
666
+ className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${a} ${e} `,
661
667
  onClick: h,
662
668
  children: [
663
- /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
669
+ /* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ s(
664
670
  "svg",
665
671
  {
666
672
  xmlns: "http://www.w3.org/2000/svg",
667
- width: an(e),
668
- height: an(e),
673
+ width: rn(e),
674
+ height: rn(e),
669
675
  viewBox: "0 0 20 20",
670
676
  fill: "none",
671
- children: /* @__PURE__ */ a(
677
+ children: /* @__PURE__ */ s(
672
678
  "path",
673
679
  {
674
680
  d: "M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",
@@ -680,32 +686,32 @@ const an = (n) => {
680
686
  )
681
687
  }
682
688
  ) }),
683
- /* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
689
+ /* @__PURE__ */ s("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ s(
684
690
  "input",
685
691
  {
686
692
  className: "sa-calendar-input",
687
- ...l,
688
- disabled: r,
689
- value: l.value,
690
- ref: u
693
+ ...i,
694
+ disabled: l,
695
+ value: i.value,
696
+ ref: p
691
697
  }
692
698
  ) }),
693
- y ? /* @__PURE__ */ a(
699
+ w ? /* @__PURE__ */ s(
694
700
  "button",
695
701
  {
696
702
  type: "button",
697
703
  "aria-label": "Clear date",
698
704
  className: "sa-calendar-input-clear",
699
- onClick: k,
700
- children: /* @__PURE__ */ a(
705
+ onClick: M,
706
+ children: /* @__PURE__ */ s(
701
707
  "svg",
702
708
  {
703
709
  xmlns: "http://www.w3.org/2000/svg",
704
- width: an(e),
705
- height: an(e),
710
+ width: rn(e),
711
+ height: rn(e),
706
712
  viewBox: "0 0 20 20",
707
713
  fill: "none",
708
- children: /* @__PURE__ */ a(
714
+ children: /* @__PURE__ */ s(
709
715
  "path",
710
716
  {
711
717
  d: "M5 5L15 15M15 5L5 15",
@@ -718,15 +724,15 @@ const an = (n) => {
718
724
  }
719
725
  )
720
726
  }
721
- ) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(
727
+ ) : /* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ s(
722
728
  "svg",
723
729
  {
724
730
  xmlns: "http://www.w3.org/2000/svg",
725
- width: an(e),
726
- height: an(e),
731
+ width: rn(e),
732
+ height: rn(e),
727
733
  viewBox: "0 0 20 20",
728
734
  fill: "none",
729
- children: /* @__PURE__ */ a(
735
+ children: /* @__PURE__ */ s(
730
736
  "path",
731
737
  {
732
738
  d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
@@ -741,199 +747,199 @@ const an = (n) => {
741
747
  ]
742
748
  }
743
749
  );
744
- }, jn = ({
750
+ }, Wn = ({
745
751
  date: n,
746
752
  setDate: e,
747
- dateRange: t,
753
+ dateRange: a,
748
754
  setDateRange: o,
749
- onChange: s,
755
+ onChange: r,
750
756
  minDate: d,
751
- maxDate: l,
752
- input: u
757
+ maxDate: i,
758
+ input: p
753
759
  }) => {
754
- var T, m, x;
755
- const [h, r] = Z(null);
756
- let c = new Date(n.getFullYear(), n.getMonth(), 1), y = c.getDay(), k = [];
757
- const L = n.getMonth(), C = (/* @__PURE__ */ new Date()).toDateString(), b = !!(t.from && !t.to), g = b && h ? h : null;
758
- for (let f = 0; f < 42; f++) {
759
- f === 0 && y === 0 ? c.setDate(c.getDate() - 7) : f === 0 ? c.setDate(
760
- c.getDate() + (f - y)
760
+ var T, y, k;
761
+ const [h, l] = G(null);
762
+ let c = new Date(n.getFullYear(), n.getMonth(), 1), w = c.getDay(), M = [];
763
+ const E = n.getMonth(), x = (/* @__PURE__ */ new Date()).toDateString(), b = !!(a.from && !a.to), g = b && h ? h : null;
764
+ for (let v = 0; v < 42; v++) {
765
+ v === 0 && w === 0 ? c.setDate(c.getDate() - 7) : v === 0 ? c.setDate(
766
+ c.getDate() + (v - w)
761
767
  ) : c.setDate(c.getDate() + 1);
762
- let E = {
763
- currentMonth: c.getMonth() === L,
768
+ let N = {
769
+ currentMonth: c.getMonth() === E,
764
770
  date: new Date(c),
765
771
  month: c.getMonth(),
766
772
  number: c.getDate(),
767
- selected: c.toDateString() === ((T = t.from) == null ? void 0 : T.toDateString()) || c.toDateString() === (((m = t.to) == null ? void 0 : m.toDateString()) || ((x = t.from) == null ? void 0 : x.toDateString())),
768
- isToday: c.toDateString() === C,
773
+ selected: c.toDateString() === ((T = a.from) == null ? void 0 : T.toDateString()) || c.toDateString() === (((y = a.to) == null ? void 0 : y.toDateString()) || ((k = a.from) == null ? void 0 : k.toDateString())),
774
+ isToday: c.toDateString() === x,
769
775
  year: c.getFullYear(),
770
- isDisabled: d && c < d || l && c > l
776
+ isDisabled: d && c < d || i && c > i
771
777
  };
772
- k.push(E);
778
+ M.push(N);
773
779
  }
774
- const i = (f) => {
775
- e(f);
776
- }, N = (f) => {
777
- let E = { ...t };
778
- if (E.from && E.to)
779
- E = { from: f, to: null };
780
- else if (!E.from)
781
- E = { from: f, to: null };
780
+ const u = (v) => {
781
+ e(v);
782
+ }, C = (v) => {
783
+ let N = { ...a };
784
+ if (N.from && N.to)
785
+ N = { from: v, to: null };
786
+ else if (!N.from)
787
+ N = { from: v, to: null };
782
788
  else {
783
- const A = E.from.getTime();
784
- f.getTime() > A ? E = { from: E.from, to: f } : E = { from: f, to: E.from };
789
+ const K = N.from.getTime();
790
+ v.getTime() > K ? N = { from: N.from, to: v } : N = { from: v, to: N.from };
785
791
  }
786
- o(E), s(E);
792
+ o(N), r(N);
787
793
  };
788
- return /* @__PURE__ */ Y(
794
+ return /* @__PURE__ */ z(
789
795
  "div",
790
796
  {
791
797
  className: "sa-calendar-days-preivew",
792
- onMouseLeave: () => r(null),
798
+ onMouseLeave: () => l(null),
793
799
  children: [
794
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: Ln.map((f, E) => /* @__PURE__ */ a("p", { children: f }, E)) }),
795
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: k.map((f, E) => {
796
- const A = t.from && t.to && f.date.getTime() > t.from.getTime() && f.date.getTime() < t.to.getTime(), I = (() => {
797
- if (!g || !t.from)
800
+ /* @__PURE__ */ s("div", { className: "sa-calendar-days-name-preivew", children: Vn.map((v, N) => /* @__PURE__ */ s("p", { children: v }, N)) }),
801
+ /* @__PURE__ */ s("div", { className: "sa-calendar-days-number-preivew", children: M.map((v, N) => {
802
+ const K = a.from && a.to && v.date.getTime() > a.from.getTime() && v.date.getTime() < a.to.getTime(), j = (() => {
803
+ if (!g || !a.from)
798
804
  return !1;
799
- const D = f.date.getTime(), M = t.from.getTime(), V = g.getTime();
800
- return V > M ? D > M && D < V : D < M && D > V;
801
- })(), R = b && h && f.date.toDateString() === h.toDateString(), $ = f.isDisabled, z = () => A || I ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", w = () => $ ? "var(--sa-color-gray-400, #b7b9be)" : A || I ? "var(--sa-color-gray-500, #8c8f97)" : "";
802
- return /* @__PURE__ */ a(
805
+ const Y = v.date.getTime(), L = a.from.getTime(), S = g.getTime();
806
+ return S > L ? Y > L && Y < S : Y < L && Y > S;
807
+ })(), B = b && h && v.date.toDateString() === h.toDateString(), F = v.isDisabled, $ = () => K || j ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", m = () => F ? "var(--sa-color-gray-400, #b7b9be)" : K || j ? "var(--sa-color-gray-500, #8c8f97)" : "";
808
+ return /* @__PURE__ */ s(
803
809
  "p",
804
810
  {
805
- className: `${f.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${f.selected || R ? "sa-calendar-days-active" : ""} ${f.isToday && !f.selected ? "sa-calendar-days-today" : ""}`,
811
+ className: `${v.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${v.selected || B ? "sa-calendar-days-active" : ""} ${v.isToday && !v.selected ? "sa-calendar-days-today" : ""}`,
806
812
  style: {
807
- backgroundColor: z(),
808
- pointerEvents: $ ? "none" : void 0,
809
- cursor: $ ? "not-allowed" : "pointer",
810
- color: w(),
811
- opacity: R && !f.selected ? 0.75 : 1,
812
- ...u ? {} : { width: "100%" }
813
+ backgroundColor: $(),
814
+ pointerEvents: F ? "none" : void 0,
815
+ cursor: F ? "not-allowed" : "pointer",
816
+ color: m(),
817
+ opacity: B && !v.selected ? 0.75 : 1,
818
+ ...p ? {} : { width: "100%" }
813
819
  },
814
820
  onClick: () => {
815
- $ || (i(f.date), N(f.date));
821
+ F || (u(v.date), C(v.date));
816
822
  },
817
823
  onMouseEnter: () => {
818
- $ || r(f.date);
824
+ F || l(v.date);
819
825
  },
820
- children: f.number
826
+ children: v.number
821
827
  },
822
- E
828
+ N
823
829
  );
824
830
  }) })
825
831
  ]
826
832
  }
827
833
  );
828
- }, Rn = ({
834
+ }, Jn = ({
829
835
  date: n,
830
836
  setDate: e,
831
- filter: t,
837
+ filter: a,
832
838
  setViews: o,
833
- dateRange: s,
839
+ dateRange: r,
834
840
  setDateRange: d,
835
- onChange: l,
836
- minDate: u,
841
+ onChange: i,
842
+ minDate: p,
837
843
  maxDate: h,
838
- input: r
844
+ input: l
839
845
  }) => {
840
- var C;
841
- const c = (C = s.from) == null ? void 0 : C.getFullYear(), y = n.getFullYear(), k = (b) => {
842
- t ? (L(b), e(b)) : (o("days"), e(b));
843
- }, L = (b) => {
844
- let g = { ...s };
846
+ var x;
847
+ const c = (x = r.from) == null ? void 0 : x.getFullYear(), w = n.getFullYear(), M = (b) => {
848
+ a ? (E(b), e(b)) : (o("days"), e(b));
849
+ }, E = (b) => {
850
+ let g = { ...r };
845
851
  if (g.from && g.to)
846
852
  g = { from: b, to: null };
847
853
  else if (!g.from)
848
854
  g = { from: b, to: null };
849
855
  else {
850
- const i = g.from.getTime();
851
- b.getTime() > i ? g = { from: g.from, to: b } : g = { from: b, to: g.from };
856
+ const u = g.from.getTime();
857
+ b.getTime() > u ? g = { from: g.from, to: b } : g = { from: b, to: g.from };
852
858
  }
853
- d(g), l(g);
859
+ d(g), i(g);
854
860
  };
855
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: nn.map((b, g) => {
856
- var T, m, x;
857
- const i = s.from != null && new Date(y, g).getTime() > s.from.getTime() && new Date(y, g).getTime() < (((T = s.to) == null ? void 0 : T.getTime()) || s.from.getTime()), N = u && new Date(y, g) < u || h && new Date(y, g) > h;
858
- return /* @__PURE__ */ a(
861
+ return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, g) => {
862
+ var T, y, k;
863
+ const u = r.from != null && new Date(w, g).getTime() > r.from.getTime() && new Date(w, g).getTime() < (((T = r.to) == null ? void 0 : T.getTime()) || r.from.getTime()), C = p && new Date(w, g) < p || h && new Date(w, g) > h;
864
+ return /* @__PURE__ */ s(
859
865
  "p",
860
866
  {
861
- className: c === y && (g === ((m = s.from) == null ? void 0 : m.getMonth()) || g === ((x = s.to) == null ? void 0 : x.getMonth())) ? "sa-calendar-months-active" : "",
867
+ className: c === w && (g === ((y = r.from) == null ? void 0 : y.getMonth()) || g === ((k = r.to) == null ? void 0 : k.getMonth())) ? "sa-calendar-months-active" : "",
862
868
  style: {
863
- backgroundColor: i ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
864
- pointerEvents: N ? "none" : void 0,
865
- cursor: N ? "not-allowed" : "pointer",
866
- color: N ? "var(--sa-color-gray-400, #b7b9be)" : i ? "var(--sa-color-gray-500, #8c8f97)" : "",
867
- ...r ? {} : { width: "100%" }
869
+ backgroundColor: u ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
870
+ pointerEvents: C ? "none" : void 0,
871
+ cursor: C ? "not-allowed" : "pointer",
872
+ color: C ? "var(--sa-color-gray-400, #b7b9be)" : u ? "var(--sa-color-gray-500, #8c8f97)" : "",
873
+ ...l ? {} : { width: "100%" }
868
874
  },
869
875
  onClick: () => {
870
- N || k(new Date(y, g));
876
+ C || M(new Date(w, g));
871
877
  },
872
878
  children: b.slice(0, 3)
873
879
  },
874
880
  g
875
881
  );
876
882
  }) });
877
- }, xn = (n) => {
878
- const e = Math.floor(n / 10) * 10, t = e + 10;
879
- return { start: e, end: t };
880
- }, An = ({
883
+ }, Cn = (n) => {
884
+ const e = Math.floor(n / 10) * 10, a = e + 10;
885
+ return { start: e, end: a };
886
+ }, Kn = ({
881
887
  date: n,
882
888
  filter: e,
883
- setViews: t,
889
+ setViews: a,
884
890
  setDate: o,
885
- dateRange: s,
891
+ dateRange: r,
886
892
  setDateRange: d,
887
- onChange: l,
888
- minDate: u,
893
+ onChange: i,
894
+ minDate: p,
889
895
  maxDate: h,
890
- input: r
896
+ input: l
891
897
  }) => {
892
- var N, T;
898
+ var C, T;
893
899
  let c = [];
894
- const y = n.getFullYear(), { start: k, end: L } = xn(y), C = (N = s.from) == null ? void 0 : N.getFullYear(), b = (T = s.to) == null ? void 0 : T.getFullYear();
895
- for (let m = k; m < L; m++) {
896
- const x = new Date(m, 0), f = (!u || x >= u) && (!h || x <= h), E = C != null && m === C || b != null && m === b, A = s.from != null && s.to != null && x > s.from && x < s.to;
900
+ const w = n.getFullYear(), { start: M, end: E } = Cn(w), x = (C = r.from) == null ? void 0 : C.getFullYear(), b = (T = r.to) == null ? void 0 : T.getFullYear();
901
+ for (let y = M; y < E; y++) {
902
+ const k = new Date(y, 0), v = (!p || k >= p) && (!h || k <= h), N = x != null && y === x || b != null && y === b, K = r.from != null && r.to != null && k > r.from && k < r.to;
897
903
  c.push({
898
- year: m,
899
- active: E && f,
900
- highlight: A && f,
901
- disabled: !f
904
+ year: y,
905
+ active: N && v,
906
+ highlight: K && v,
907
+ disabled: !v
902
908
  });
903
909
  }
904
- const g = (m) => {
905
- e ? (i(m), o(m)) : (o(m), t("months"));
906
- }, i = (m) => {
907
- let x = { ...s };
908
- if (x.from && x.to)
909
- x = { from: m, to: null };
910
- else if (!x.from)
911
- x = { from: m, to: null };
910
+ const g = (y) => {
911
+ e ? (u(y), o(y)) : (o(y), a("months"));
912
+ }, u = (y) => {
913
+ let k = { ...r };
914
+ if (k.from && k.to)
915
+ k = { from: y, to: null };
916
+ else if (!k.from)
917
+ k = { from: y, to: null };
912
918
  else {
913
- const f = x.from.getTime();
914
- m.getTime() > f ? x = { from: x.from, to: m } : x = { from: m, to: x.from };
919
+ const v = k.from.getTime();
920
+ y.getTime() > v ? k = { from: k.from, to: y } : k = { from: y, to: k.from };
915
921
  }
916
- d(x), l(x);
922
+ d(k), i(k);
917
923
  };
918
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: c.map((m, x) => /* @__PURE__ */ a(
924
+ return /* @__PURE__ */ s("div", { className: "sa-calendar-years-preview", children: c.map((y, k) => /* @__PURE__ */ s(
919
925
  "p",
920
926
  {
921
- className: `${m.active ? "sa-calendar-months-active" : ""} ${m.highlight ? "sa-calendar-months-highlight" : ""} ${m.disabled ? "sa-calendar-disabled" : ""}`,
927
+ className: `${y.active ? "sa-calendar-months-active" : ""} ${y.highlight ? "sa-calendar-months-highlight" : ""} ${y.disabled ? "sa-calendar-disabled" : ""}`,
922
928
  onClick: () => {
923
- m.disabled || g(new Date(m.year, 0));
929
+ y.disabled || g(new Date(y.year, 0));
924
930
  },
925
931
  style: {
926
- backgroundColor: m.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
927
- color: m.highlight ? "var(--sa-color-gray-500, #8c8f97)" : m.active ? "" : m.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
928
- cursor: m.disabled ? "not-allowed" : "pointer",
929
- pointerEvents: m.disbled ? "none" : "all",
930
- ...r ? {} : { width: "100%" }
932
+ backgroundColor: y.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
933
+ color: y.highlight ? "var(--sa-color-gray-500, #8c8f97)" : y.active ? "" : y.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
934
+ cursor: y.disabled ? "not-allowed" : "pointer",
935
+ pointerEvents: y.disbled ? "none" : "all",
936
+ ...l ? {} : { width: "100%" }
931
937
  },
932
- children: m.year
938
+ children: y.year
933
939
  },
934
- x
940
+ k
935
941
  )) });
936
- }, En = ({ ...n }) => /* @__PURE__ */ a(
942
+ }, Pn = ({ ...n }) => /* @__PURE__ */ s(
937
943
  "svg",
938
944
  {
939
945
  xmlns: "http://www.w3.org/2000/svg",
@@ -942,7 +948,7 @@ const an = (n) => {
942
948
  viewBox: "0 0 20 20",
943
949
  fill: "none",
944
950
  ...n,
945
- children: /* @__PURE__ */ a(
951
+ children: /* @__PURE__ */ s(
946
952
  "path",
947
953
  {
948
954
  d: "M12.5 3.33334L5.83337 10L12.5 16.6667",
@@ -953,7 +959,7 @@ const an = (n) => {
953
959
  }
954
960
  )
955
961
  }
956
- ), Fn = ({ ...n }) => /* @__PURE__ */ a(
962
+ ), Rn = ({ ...n }) => /* @__PURE__ */ s(
957
963
  "svg",
958
964
  {
959
965
  xmlns: "http://www.w3.org/2000/svg",
@@ -962,7 +968,7 @@ const an = (n) => {
962
968
  viewBox: "0 0 20 20",
963
969
  fill: "none",
964
970
  ...n,
965
- children: /* @__PURE__ */ a(
971
+ children: /* @__PURE__ */ s(
966
972
  "path",
967
973
  {
968
974
  d: "M7.5 16.6667L14.1667 10L7.5 3.33334",
@@ -973,285 +979,357 @@ const an = (n) => {
973
979
  }
974
980
  )
975
981
  }
976
- ), On = ({
982
+ ), qn = ({
977
983
  setViews: n,
978
984
  views: e,
979
- filter: t,
985
+ filter: a,
980
986
  date: o,
981
- setDate: s
987
+ setDate: r
982
988
  }) => {
983
989
  const d = () => {
984
- t || n((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
985
- }, l = () => {
990
+ a || n((l) => l === "days" ? "months" : l === "months" ? "years" : "days");
991
+ }, i = () => {
986
992
  if (e === "years") {
987
- s((r) => new Date(r.getFullYear() + 10, 0));
993
+ r((l) => new Date(l.getFullYear() + 10, 0));
988
994
  return;
989
995
  }
990
996
  if (e === "months") {
991
- s((r) => new Date(r.getFullYear() + 1, r.getMonth()));
997
+ r((l) => new Date(l.getFullYear() + 1, l.getMonth()));
992
998
  return;
993
999
  }
994
- s((r) => new Date(r.getFullYear(), r.getMonth() + 1));
995
- }, u = () => {
1000
+ r((l) => new Date(l.getFullYear(), l.getMonth() + 1));
1001
+ }, p = () => {
996
1002
  if (e === "years") {
997
- s((r) => new Date(r.getFullYear() - 10, 0));
1003
+ r((l) => new Date(l.getFullYear() - 10, 0));
998
1004
  return;
999
1005
  }
1000
1006
  if (e === "months") {
1001
- s((r) => new Date(r.getFullYear() - 1, r.getMonth()));
1007
+ r((l) => new Date(l.getFullYear() - 1, l.getMonth()));
1002
1008
  return;
1003
1009
  }
1004
- s(
1005
- (r) => new Date(
1006
- r.getMonth() === 0 ? r.getFullYear() - 1 : r.getFullYear(),
1007
- r.getMonth() === 0 ? 11 : r.getMonth() - 1
1010
+ r(
1011
+ (l) => new Date(
1012
+ l.getMonth() === 0 ? l.getFullYear() - 1 : l.getFullYear(),
1013
+ l.getMonth() === 0 ? 11 : l.getMonth() - 1
1008
1014
  )
1009
1015
  );
1010
1016
  };
1011
- return /* @__PURE__ */ Y("div", { className: "sa-calendar-header", children: [
1012
- /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
1017
+ return /* @__PURE__ */ z("div", { className: "sa-calendar-header", children: [
1018
+ /* @__PURE__ */ s("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
1013
1019
  if (e === "days")
1014
- return `${nn[o.getMonth()]} ${o.getFullYear()}`;
1020
+ return `${Q[o.getMonth()]} ${o.getFullYear()}`;
1015
1021
  if (e === "months")
1016
1022
  return `${o.getFullYear()}`;
1017
1023
  if (e === "years")
1018
- return `${xn(o.getFullYear()).start} ~ ${xn(o.getFullYear()).end}`;
1024
+ return `${Cn(o.getFullYear()).start} ~ ${Cn(o.getFullYear()).end}`;
1019
1025
  })() }),
1020
- /* @__PURE__ */ Y("div", { className: "sa-calendar-header-nav", children: [
1021
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: u, children: /* @__PURE__ */ a(En, {}) }),
1022
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: l, children: /* @__PURE__ */ a(Fn, {}) })
1026
+ /* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
1027
+ /* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ s(Pn, {}) }),
1028
+ /* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ s(Rn, {}) })
1023
1029
  ] })
1024
1030
  ] });
1025
1031
  };
1026
- function rn(n) {
1027
- const e = new Date(n), t = e.getFullYear(), o = e.getMonth();
1028
- return `${e.getDate().toString().padStart(2, "0")} ${Vn[o]} ${t}`;
1032
+ function on(n) {
1033
+ const e = new Date(n), a = e.getFullYear(), o = e.getMonth();
1034
+ return `${e.getDate().toString().padStart(2, "0")} ${jn[o]} ${a}`;
1035
+ }
1036
+ const Fn = (() => {
1037
+ const n = {};
1038
+ return Q.forEach((e, a) => {
1039
+ n[e.toLowerCase()] = a, n[e.slice(0, 3).toLowerCase()] = a;
1040
+ }), n;
1041
+ })(), kn = (n) => n < 100 ? 2e3 + n : n;
1042
+ function $n(n, e) {
1043
+ const a = String(n.getDate()).padStart(2, "0"), o = String(n.getMonth() + 1).padStart(2, "0"), r = n.getFullYear();
1044
+ return e === "years" ? `${r}` : e === "months" ? `${o}/${r}` : `${a}/${o}/${r}`;
1045
+ }
1046
+ function Un(n, e) {
1047
+ const a = n.from ? $n(n.from, e) : "", o = n.to ? $n(n.to, e) : "";
1048
+ return a ? o ? `${a} ~ ${o}` : a : "";
1049
+ }
1050
+ function bn(n, e) {
1051
+ const a = n.trim().toLowerCase().split(/[\s/.\-,]+/).filter(Boolean);
1052
+ if (!a.length)
1053
+ return null;
1054
+ let o = null;
1055
+ const r = [];
1056
+ for (const c of a)
1057
+ c in Fn ? o = Fn[c] : /^\d+$/.test(c) && r.push(parseInt(c, 10));
1058
+ if (e === "years") {
1059
+ const c = r[0];
1060
+ return c == null ? null : new Date(kn(c), 0, 1);
1061
+ }
1062
+ if (e === "months") {
1063
+ const c = o ?? r[0] - 1, w = o != null ? r[0] : r[1];
1064
+ return c == null || isNaN(c) || c < 0 || c > 11 || w == null ? null : new Date(kn(w), c, 1);
1065
+ }
1066
+ let d, i, p;
1067
+ if (o != null ? (d = r[0], p = r[1], i = o) : (d = r[0], i = r[1] != null ? r[1] - 1 : void 0, p = r[2]), d == null || i == null || p == null)
1068
+ return null;
1069
+ const h = kn(p), l = new Date(h, i, d);
1070
+ return l.getFullYear() !== h || l.getMonth() !== i || l.getDate() !== d ? null : l;
1071
+ }
1072
+ function Gn(n, e) {
1073
+ const a = n.indexOf("~");
1074
+ if (a === -1) {
1075
+ const d = bn(n, e);
1076
+ return d ? { from: d, to: null } : null;
1077
+ }
1078
+ const o = bn(n.slice(0, a), e);
1079
+ if (!o)
1080
+ return null;
1081
+ const r = bn(n.slice(a + 1), e);
1082
+ return { from: o, to: r ?? null };
1083
+ }
1084
+ function Dn(n, e, a) {
1085
+ const o = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime(), r = o(n);
1086
+ return !(e && r < o(e) || a && r > o(a));
1029
1087
  }
1030
- const Mn = ({
1088
+ const Yn = ({
1031
1089
  label: n,
1032
1090
  labelPosition: e = "outside-top",
1033
- required: t,
1091
+ required: a,
1034
1092
  optional: o,
1035
- description: s,
1093
+ description: r,
1036
1094
  helperText: d,
1037
- errorText: l,
1038
- fullWidth: u,
1095
+ errorText: i,
1096
+ fullWidth: p,
1039
1097
  size: h = "sm",
1040
- children: r
1098
+ children: l
1041
1099
  }) => {
1042
1100
  const c = [
1043
1101
  "sa-date-field",
1044
1102
  `sa-date-field-size-${h}`,
1045
- u ? "sa-date-field-fullwidth" : ""
1046
- ].filter(Boolean).join(" "), y = n ? /* @__PURE__ */ Y("div", { className: "sa-date-field-label-row", children: [
1047
- /* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: n }),
1048
- o && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
1049
- t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
1050
- ] }) : null, k = /* @__PURE__ */ Y(fn, { children: [
1051
- d && !l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: d }),
1052
- l && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: l })
1103
+ p ? "sa-date-field-fullwidth" : ""
1104
+ ].filter(Boolean).join(" "), w = n ? /* @__PURE__ */ z("div", { className: "sa-date-field-label-row", children: [
1105
+ /* @__PURE__ */ s("span", { className: "sa-date-field-label-text", children: n }),
1106
+ o && /* @__PURE__ */ s("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
1107
+ a && /* @__PURE__ */ s("span", { className: "sa-date-field-required", children: "*" })
1108
+ ] }) : null, M = /* @__PURE__ */ z(yn, { children: [
1109
+ d && !i && /* @__PURE__ */ s("p", { className: "sa-date-field-helper", children: d }),
1110
+ i && /* @__PURE__ */ s("p", { className: "sa-date-field-error-msg", children: i })
1053
1111
  ] });
1054
- return n ? e === "outside-left" ? /* @__PURE__ */ Y("div", { className: `${c} sa-date-field-left`, children: [
1055
- /* @__PURE__ */ Y("div", { className: "sa-date-field-left-label", children: [
1056
- y,
1057
- s && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: s })
1112
+ return n ? e === "outside-left" ? /* @__PURE__ */ z("div", { className: `${c} sa-date-field-left`, children: [
1113
+ /* @__PURE__ */ z("div", { className: "sa-date-field-left-label", children: [
1114
+ w,
1115
+ r && /* @__PURE__ */ s("p", { className: "sa-date-field-helper-top", children: r })
1058
1116
  ] }),
1059
- /* @__PURE__ */ Y("div", { className: "sa-date-field-input-wrap", children: [
1060
- r,
1061
- k
1117
+ /* @__PURE__ */ z("div", { className: "sa-date-field-input-wrap", children: [
1118
+ l,
1119
+ M
1062
1120
  ] })
1063
- ] }) : /* @__PURE__ */ Y("div", { className: c, children: [
1064
- y,
1065
- s && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: s }),
1066
- r,
1067
- k
1068
- ] }) : /* @__PURE__ */ Y("div", { className: c, children: [
1069
- s && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: s }),
1070
- r,
1071
- k
1121
+ ] }) : /* @__PURE__ */ z("div", { className: c, children: [
1122
+ w,
1123
+ r && /* @__PURE__ */ s("p", { className: "sa-date-field-helper-top", children: r }),
1124
+ l,
1125
+ M
1126
+ ] }) : /* @__PURE__ */ z("div", { className: c, children: [
1127
+ r && /* @__PURE__ */ s("p", { className: "sa-date-field-helper-top", children: r }),
1128
+ l,
1129
+ M
1072
1130
  ] });
1073
- }, $n = "sa-calendar-styles", Hn = (n) => {
1074
- if (!(typeof document > "u") && !document.getElementById($n)) {
1131
+ }, Sn = "sa-calendar-styles", Zn = (n) => {
1132
+ if (!(typeof document > "u") && !document.getElementById(Sn)) {
1075
1133
  const e = document.createElement("style");
1076
- e.id = $n, e.textContent = n, document.head.appendChild(e);
1134
+ e.id = Sn, e.textContent = n, document.head.appendChild(e);
1077
1135
  }
1078
1136
  };
1079
- Hn(un);
1080
- const Wn = mn(
1137
+ Zn(gn);
1138
+ const _n = xn(
1081
1139
  ({
1082
1140
  value: n,
1083
1141
  onChange: e,
1084
- filter: t,
1142
+ filter: a,
1085
1143
  input: o = !0,
1086
- disabled: s,
1144
+ disabled: r,
1087
1145
  minDate: d,
1088
- maxDate: l,
1089
- placeholder: u,
1146
+ maxDate: i,
1147
+ placeholder: p,
1090
1148
  size: h = "sm",
1091
- variant: r,
1149
+ variant: l,
1092
1150
  status: c,
1093
- clearable: y,
1094
- fullWidth: k = !0,
1095
- withPadding: L = !0,
1096
- trigger: C,
1097
- renderTrigger: b,
1098
- label: g,
1099
- labelPosition: i,
1100
- required: N,
1101
- optional: T,
1102
- description: m,
1103
- helperText: x,
1104
- errorText: f
1105
- }, E) => {
1106
- const A = f ? "error" : c, { ref: I, isComponentVisible: R, setIsComponentVisible: $ } = Nn(!1), z = Q(null), [w, D] = Z("days"), [M, V] = Z(/* @__PURE__ */ new Date()), O = typeof b == "function" || C != null, B = !o && !O, K = !B, [S, H] = Z({
1151
+ clearable: w,
1152
+ fullWidth: M = !0,
1153
+ withPadding: E = !0,
1154
+ editable: x = !1,
1155
+ trigger: b,
1156
+ renderTrigger: g,
1157
+ label: u,
1158
+ labelPosition: C,
1159
+ required: T,
1160
+ optional: y,
1161
+ description: k,
1162
+ helperText: v,
1163
+ errorText: N
1164
+ }, K) => {
1165
+ const j = N ? "error" : c, { ref: B, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), m = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), A = typeof g == "function" || b != null, O = !o && !A, W = !O, [D, J] = G({
1107
1166
  from: (n == null ? void 0 : n.from) ?? null,
1108
1167
  to: (n == null ? void 0 : n.to) ?? null
1109
- });
1110
- j(() => {
1168
+ }), [q, U] = G(null);
1169
+ P(() => {
1111
1170
  if (n) {
1112
- const v = n;
1113
- v.from && V(v.from), H(v);
1171
+ const t = n;
1172
+ t.from && I(t.from), J(t);
1114
1173
  } else
1115
- V(/* @__PURE__ */ new Date()), H({ from: null, to: null });
1116
- }, [n]), j(() => {
1117
- t && D(t);
1118
- }, [t]), j(() => {
1119
- t || D("days");
1120
- }, [R]), j(() => {
1121
- B && $(!0);
1122
- }, [B]);
1123
- const _ = () => {
1124
- var v, P;
1174
+ I(/* @__PURE__ */ new Date()), J({ from: null, to: null });
1175
+ U(null);
1176
+ }, [n]), P(() => {
1177
+ a && L(a);
1178
+ }, [a]), P(() => {
1179
+ a || L("days");
1180
+ }, [F]), P(() => {
1181
+ O && $(!0);
1182
+ }, [O]);
1183
+ const X = () => {
1184
+ var t, f;
1125
1185
  if (!n)
1126
1186
  return "";
1127
- if (t) {
1128
- if (w === "days")
1129
- return `${rn(S.from)} ~ ${rn(S.to || S.from) || "-"}`;
1130
- if (w === "months")
1131
- return `${nn[S.from.getMonth()]} ~ ${S.to ? nn[S.to.getMonth()] : "-"}`;
1132
- if (w === "years")
1133
- return `${(v = S.from) == null ? void 0 : v.getFullYear()} ~ ${((P = S.to) == null ? void 0 : P.getFullYear()) || "-"}`;
1187
+ if (a) {
1188
+ if (Y === "days")
1189
+ return `${on(D.from)} ~ ${on(D.to || D.from) || "-"}`;
1190
+ if (Y === "months")
1191
+ return `${Q[D.from.getMonth()]} ~ ${D.to ? Q[D.to.getMonth()] : "-"}`;
1192
+ if (Y === "years")
1193
+ return `${(t = D.from) == null ? void 0 : t.getFullYear()} ~ ${((f = D.to) == null ? void 0 : f.getFullYear()) || "-"}`;
1134
1194
  } else
1135
- return `${rn(S.from)} ~ ${rn(S.to || S.from) || "-"}`;
1136
- }, J = () => {
1137
- if (z.current && I.current && K) {
1138
- const v = I.current.getBoundingClientRect(), P = z.current.getBoundingClientRect();
1139
- window.innerWidth < v.left + P.width ? z.current.style.left = `${v.left - P.width + v.width}px` : z.current.style.left = `${v.left}px`, v.top + P.height > window.innerHeight ? z.current.style.top = `${v.y - (v.height + P.height - 28)}px` : z.current.style.top = `${v.y + v.height}px`;
1195
+ return `${on(D.from)} ~ ${on(D.to || D.from) || "-"}`;
1196
+ }, R = () => {
1197
+ if (m.current && B.current && W) {
1198
+ const t = B.current.getBoundingClientRect(), f = m.current.getBoundingClientRect();
1199
+ window.innerWidth < t.left + f.width ? m.current.style.left = `${t.left - f.width + t.width}px` : m.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? m.current.style.top = `${t.y - (t.height + f.height - 28)}px` : m.current.style.top = `${t.y + t.height}px`;
1140
1200
  }
1141
1201
  };
1142
- j(() => {
1143
- z.current && I.current && K && J();
1144
- }, [z, I, R]), j(() => (window.addEventListener("scroll", J, !0), window.addEventListener("resize", J), () => {
1145
- window.removeEventListener("scroll", J, !0), window.removeEventListener("resize", J);
1202
+ P(() => {
1203
+ m.current && B.current && W && R();
1204
+ }, [m, B, F]), P(() => (window.addEventListener("scroll", R, !0), window.addEventListener("resize", R), () => {
1205
+ window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R);
1146
1206
  }), []);
1147
- const sn = () => $(!0), on = () => $(!1), G = () => $((v) => !v), ln = {
1148
- isOpen: R,
1149
- open: sn,
1150
- close: on,
1151
- toggle: G,
1207
+ const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
1208
+ x && U(Un(D, a));
1209
+ }, en = () => {
1210
+ if (q === null)
1211
+ return;
1212
+ const t = q.trim();
1213
+ if (!t) {
1214
+ e(void 0), U(null);
1215
+ return;
1216
+ }
1217
+ const f = Gn(t, a), V = f && Dn(f.from, d, i) && (!f.to || Dn(f.to, d, i));
1218
+ f && V && (e(f), J(f), I(f.from)), U(null);
1219
+ }, un = (t) => {
1220
+ t.key === "Enter" ? (en(), $(!1)) : t.key === "Escape" && (U(null), $(!1));
1221
+ }, pn = {
1222
+ isOpen: F,
1223
+ open: ln,
1224
+ close: dn,
1225
+ toggle: nn,
1152
1226
  value: n,
1153
- formattedValue: String(_() ?? ""),
1227
+ formattedValue: String(X() ?? ""),
1154
1228
  clear: () => e(void 0),
1155
- disabled: s,
1156
- placeholder: u
1157
- }, dn = /* @__PURE__ */ Y(
1229
+ disabled: r,
1230
+ placeholder: p
1231
+ }, hn = /* @__PURE__ */ z(
1158
1232
  "div",
1159
1233
  {
1160
- className: "sa-calendar-wrapper",
1161
- style: { height: B ? "100%" : "auto" },
1162
- ref: K ? I : null,
1234
+ className: `sa-calendar-wrapper${A ? " sa-calendar-wrapper-custom" : ""}`,
1235
+ style: { height: O ? "100%" : "auto" },
1236
+ ref: W ? B : null,
1163
1237
  children: [
1164
- O ? (() => {
1165
- if (typeof b == "function")
1166
- return b(ln);
1167
- if (gn.isValidElement(C)) {
1168
- const v = C;
1169
- return gn.cloneElement(v, {
1170
- onClick: (P) => {
1171
- var q, X;
1172
- (X = (q = v.props) == null ? void 0 : q.onClick) == null || X.call(q, P), s || G();
1238
+ A ? (() => {
1239
+ if (typeof g == "function")
1240
+ return g(pn);
1241
+ if (wn.isValidElement(b)) {
1242
+ const t = b;
1243
+ return wn.cloneElement(t, {
1244
+ onClick: (f) => {
1245
+ var V, an;
1246
+ (an = (V = t.props) == null ? void 0 : V.onClick) == null || an.call(V, f), r || nn();
1173
1247
  }
1174
1248
  });
1175
1249
  }
1176
- return C;
1177
- })() : o ? /* @__PURE__ */ a(
1178
- Pn,
1250
+ return b;
1251
+ })() : o ? /* @__PURE__ */ s(
1252
+ Hn,
1179
1253
  {
1180
- value: _(),
1181
- inputMode: "none",
1254
+ value: x && q !== null ? q : X(),
1255
+ inputMode: x ? "text" : "none",
1256
+ readOnly: !x,
1182
1257
  onClick: () => {
1183
1258
  $(!0);
1184
1259
  },
1185
- onChange: () => {
1260
+ onChange: x ? (t) => U(t.target.value) : () => {
1186
1261
  },
1187
- disabled: s,
1188
- placeholder: u,
1262
+ onFocus: x ? cn : void 0,
1263
+ onBlur: x ? en : void 0,
1264
+ onKeyDown: x ? un : void 0,
1265
+ disabled: r,
1266
+ placeholder: p,
1189
1267
  size: h,
1190
- variant: r,
1191
- status: A,
1192
- clearable: y,
1268
+ variant: l,
1269
+ status: j,
1270
+ clearable: w,
1193
1271
  onClear: () => e(void 0)
1194
1272
  }
1195
1273
  ) : null,
1196
- R ? /* @__PURE__ */ Y(
1274
+ F ? /* @__PURE__ */ z(
1197
1275
  "div",
1198
1276
  {
1199
- className: `sa-calendar sa-calendar-size-${h || "sm"} ${B ? "sa-calendar-no-input" : ""} ${L ? "" : "sa-calendar-no-padding"}`,
1200
- style: s ? { pointerEvents: "none" } : void 0,
1201
- ref: z,
1277
+ className: `sa-calendar sa-calendar-size-${h || "sm"} ${O ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
1278
+ style: r ? { pointerEvents: "none" } : void 0,
1279
+ ref: m,
1202
1280
  children: [
1203
- /* @__PURE__ */ a(
1204
- On,
1281
+ /* @__PURE__ */ s(
1282
+ qn,
1205
1283
  {
1206
- setViews: D,
1207
- views: w,
1208
- filter: t,
1209
- date: M,
1210
- setDate: V
1284
+ setViews: L,
1285
+ views: Y,
1286
+ filter: a,
1287
+ date: S,
1288
+ setDate: I
1211
1289
  }
1212
1290
  ),
1213
- /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: w === "days" ? /* @__PURE__ */ a(
1214
- jn,
1291
+ /* @__PURE__ */ s("div", { className: "sa-calendar-body", children: Y === "days" ? /* @__PURE__ */ s(
1292
+ Wn,
1215
1293
  {
1216
- date: M,
1217
- setDate: V,
1294
+ date: S,
1295
+ setDate: I,
1218
1296
  setIsComponentVisible: $,
1219
- dateRange: S,
1220
- setDateRange: H,
1297
+ dateRange: D,
1298
+ setDateRange: J,
1221
1299
  input: o,
1222
1300
  onChange: e,
1223
1301
  minDate: d,
1224
- maxDate: l
1302
+ maxDate: i
1225
1303
  }
1226
- ) : w === "months" ? /* @__PURE__ */ a(
1227
- Rn,
1304
+ ) : Y === "months" ? /* @__PURE__ */ s(
1305
+ Jn,
1228
1306
  {
1229
- date: M,
1230
- setDate: V,
1231
- filter: t,
1232
- setViews: D,
1233
- dateRange: S,
1234
- setDateRange: H,
1307
+ date: S,
1308
+ setDate: I,
1309
+ filter: a,
1310
+ setViews: L,
1311
+ dateRange: D,
1312
+ setDateRange: J,
1235
1313
  setIsComponentVisible: $,
1236
1314
  input: o,
1237
1315
  onChange: e,
1238
1316
  minDate: d,
1239
- maxDate: l
1317
+ maxDate: i
1240
1318
  }
1241
- ) : /* @__PURE__ */ a(
1242
- An,
1319
+ ) : /* @__PURE__ */ s(
1320
+ Kn,
1243
1321
  {
1244
- date: M,
1245
- setDate: V,
1246
- filter: t,
1247
- setViews: D,
1248
- dateRange: S,
1249
- setDateRange: H,
1322
+ date: S,
1323
+ setDate: I,
1324
+ filter: a,
1325
+ setViews: L,
1326
+ dateRange: D,
1327
+ setDateRange: J,
1250
1328
  setIsComponentVisible: $,
1251
1329
  input: o,
1252
1330
  onChange: e,
1253
1331
  minDate: d,
1254
- maxDate: l
1332
+ maxDate: i
1255
1333
  }
1256
1334
  ) })
1257
1335
  ]
@@ -1260,30 +1338,30 @@ const Wn = mn(
1260
1338
  ]
1261
1339
  }
1262
1340
  );
1263
- return /* @__PURE__ */ a(
1264
- Mn,
1341
+ return /* @__PURE__ */ s(
1342
+ Yn,
1265
1343
  {
1266
- label: g,
1267
- labelPosition: i,
1268
- required: N,
1269
- optional: T,
1270
- description: m,
1271
- helperText: x,
1272
- errorText: f,
1273
- fullWidth: k,
1344
+ label: u,
1345
+ labelPosition: C,
1346
+ required: T,
1347
+ optional: y,
1348
+ description: k,
1349
+ helperText: v,
1350
+ errorText: N,
1351
+ fullWidth: M,
1274
1352
  size: h,
1275
- children: dn
1353
+ children: hn
1276
1354
  }
1277
1355
  );
1278
1356
  }
1279
- ), zn = "sa-calendar-input-styles", Jn = (n) => {
1280
- if (!(typeof document > "u") && !document.getElementById(zn)) {
1357
+ ), In = "sa-calendar-input-styles", Qn = (n) => {
1358
+ if (!(typeof document > "u") && !document.getElementById(In)) {
1281
1359
  const e = document.createElement("style");
1282
- e.id = zn, e.textContent = n, document.head.appendChild(e);
1360
+ e.id = In, e.textContent = n, document.head.appendChild(e);
1283
1361
  }
1284
1362
  };
1285
- Jn(un);
1286
- const tn = (n) => {
1363
+ Qn(gn);
1364
+ const sn = (n) => {
1287
1365
  if (n === "xs")
1288
1366
  return 14;
1289
1367
  if (n === "sm")
@@ -1292,34 +1370,34 @@ const tn = (n) => {
1292
1370
  return 16;
1293
1371
  if (n === "lg")
1294
1372
  return 20;
1295
- }, qn = (n) => {
1373
+ }, Xn = (n) => {
1296
1374
  const {
1297
1375
  size: e = "sm",
1298
- status: t = "default",
1376
+ status: a = "default",
1299
1377
  variant: o = "outline",
1300
- clearable: s,
1378
+ clearable: r,
1301
1379
  onClear: d,
1302
- ...l
1303
- } = n, u = Q(null), h = () => {
1304
- u.current && l.onClick && (u.current.focus(), l.onClick(""));
1305
- }, r = t === "disable" || l.disabled, c = !!l.value, y = s && c && !r, k = (L) => {
1306
- L.stopPropagation(), d == null || d();
1380
+ ...i
1381
+ } = n, p = _(null), h = () => {
1382
+ p.current && i.onClick && (p.current.focus(), i.onClick(""));
1383
+ }, l = a === "disable" || i.disabled, c = !!i.value, w = r && c && !l, M = (E) => {
1384
+ E.stopPropagation(), d == null || d();
1307
1385
  };
1308
- return /* @__PURE__ */ Y(
1386
+ return /* @__PURE__ */ z(
1309
1387
  "div",
1310
1388
  {
1311
- className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,
1389
+ className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${a} ${e} `,
1312
1390
  onClick: h,
1313
1391
  children: [
1314
- /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
1392
+ /* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ s(
1315
1393
  "svg",
1316
1394
  {
1317
1395
  xmlns: "http://www.w3.org/2000/svg",
1318
- width: tn(e),
1319
- height: tn(e),
1396
+ width: sn(e),
1397
+ height: sn(e),
1320
1398
  viewBox: "0 0 20 20",
1321
1399
  fill: "none",
1322
- children: /* @__PURE__ */ a(
1400
+ children: /* @__PURE__ */ s(
1323
1401
  "path",
1324
1402
  {
1325
1403
  d: "M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",
@@ -1331,32 +1409,32 @@ const tn = (n) => {
1331
1409
  )
1332
1410
  }
1333
1411
  ) }),
1334
- /* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
1412
+ /* @__PURE__ */ s("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ s(
1335
1413
  "input",
1336
1414
  {
1337
1415
  className: "sa-calendar-input",
1338
- ...l,
1339
- disabled: r,
1340
- value: l.value,
1341
- ref: u
1416
+ ...i,
1417
+ disabled: l,
1418
+ value: i.value,
1419
+ ref: p
1342
1420
  }
1343
1421
  ) }),
1344
- y ? /* @__PURE__ */ a(
1422
+ w ? /* @__PURE__ */ s(
1345
1423
  "button",
1346
1424
  {
1347
1425
  type: "button",
1348
1426
  "aria-label": "Clear date",
1349
1427
  className: "sa-calendar-input-clear",
1350
- onClick: k,
1351
- children: /* @__PURE__ */ a(
1428
+ onClick: M,
1429
+ children: /* @__PURE__ */ s(
1352
1430
  "svg",
1353
1431
  {
1354
1432
  xmlns: "http://www.w3.org/2000/svg",
1355
- width: tn(e),
1356
- height: tn(e),
1433
+ width: sn(e),
1434
+ height: sn(e),
1357
1435
  viewBox: "0 0 20 20",
1358
1436
  fill: "none",
1359
- children: /* @__PURE__ */ a(
1437
+ children: /* @__PURE__ */ s(
1360
1438
  "path",
1361
1439
  {
1362
1440
  d: "M5 5L15 15M15 5L5 15",
@@ -1369,15 +1447,15 @@ const tn = (n) => {
1369
1447
  }
1370
1448
  )
1371
1449
  }
1372
- ) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(
1450
+ ) : /* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ s(
1373
1451
  "svg",
1374
1452
  {
1375
1453
  xmlns: "http://www.w3.org/2000/svg",
1376
- width: tn(e),
1377
- height: tn(e),
1454
+ width: sn(e),
1455
+ height: sn(e),
1378
1456
  viewBox: "0 0 20 20",
1379
1457
  fill: "none",
1380
- children: /* @__PURE__ */ a(
1458
+ children: /* @__PURE__ */ s(
1381
1459
  "path",
1382
1460
  {
1383
1461
  d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
@@ -1392,361 +1470,380 @@ const tn = (n) => {
1392
1470
  ]
1393
1471
  }
1394
1472
  );
1395
- }, Gn = ({
1473
+ }, ne = ({
1396
1474
  date: n,
1397
1475
  setDate: e,
1398
- previewDate: t,
1476
+ previewDate: a,
1399
1477
  setPreviewDate: o,
1400
- setIsComponentVisible: s,
1478
+ setIsComponentVisible: r,
1401
1479
  minDate: d,
1402
- maxDate: l,
1403
- input: u,
1480
+ maxDate: i,
1481
+ input: p,
1404
1482
  onChange: h,
1405
- hasValue: r
1483
+ hasValue: l
1406
1484
  }) => {
1407
1485
  let c = new Date(
1408
- t.getFullYear(),
1409
- t.getMonth(),
1486
+ a.getFullYear(),
1487
+ a.getMonth(),
1410
1488
  1
1411
- ), y = c.getDay(), k = [];
1412
- const L = n.toDateString(), C = (/* @__PURE__ */ new Date()).toDateString(), b = t.getMonth();
1413
- for (let i = 0; i < 42; i++) {
1414
- i === 0 && y === 0 ? c.setDate(c.getDate() - 7) : i === 0 ? c.setDate(
1415
- c.getDate() + (i - y)
1489
+ ), w = c.getDay(), M = [];
1490
+ const E = n.toDateString(), x = (/* @__PURE__ */ new Date()).toDateString(), b = a.getMonth();
1491
+ for (let u = 0; u < 42; u++) {
1492
+ u === 0 && w === 0 ? c.setDate(c.getDate() - 7) : u === 0 ? c.setDate(
1493
+ c.getDate() + (u - w)
1416
1494
  ) : c.setDate(c.getDate() + 1);
1417
- let N = {
1495
+ let C = {
1418
1496
  currentMonth: c.getMonth() === b,
1419
1497
  date: new Date(c),
1420
1498
  month: c.getMonth(),
1421
1499
  number: c.getDate(),
1422
- selected: r && c.toDateString() === L,
1423
- isToday: c.toDateString() === C,
1500
+ selected: l && c.toDateString() === E,
1501
+ isToday: c.toDateString() === x,
1424
1502
  year: c.getFullYear(),
1425
- isDisabled: d && c < d || l && c > l
1503
+ isDisabled: d && c < d || i && c > i
1426
1504
  };
1427
- k.push(N);
1505
+ M.push(C);
1428
1506
  }
1429
- const g = (i) => {
1430
- (!d || i >= d) && (!l || i <= l) && (e(i), h(i), o(i), u && s(!1));
1507
+ const g = (u) => {
1508
+ (!d || u >= d) && (!i || u <= i) && (e(u), h(u), o(u), p && r(!1));
1431
1509
  };
1432
- return /* @__PURE__ */ Y("div", { className: "sa-calendar-days-preivew", children: [
1433
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: Ln.map((i, N) => /* @__PURE__ */ a("p", { children: i }, N)) }),
1434
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: k.map((i, N) => {
1435
- const T = i.isDisabled;
1436
- return /* @__PURE__ */ a(
1510
+ return /* @__PURE__ */ z("div", { className: "sa-calendar-days-preivew", children: [
1511
+ /* @__PURE__ */ s("div", { className: "sa-calendar-days-name-preivew", children: Vn.map((u, C) => /* @__PURE__ */ s("p", { children: u }, C)) }),
1512
+ /* @__PURE__ */ s("div", { className: "sa-calendar-days-number-preivew", children: M.map((u, C) => {
1513
+ const T = u.isDisabled;
1514
+ return /* @__PURE__ */ s(
1437
1515
  "p",
1438
1516
  {
1439
- className: `${i.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${i.selected ? "sa-calendar-days-active" : ""} ${i.isToday && !i.selected ? "sa-calendar-days-today" : ""}`,
1517
+ className: `${u.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${u.selected ? "sa-calendar-days-active" : ""} ${u.isToday && !u.selected ? "sa-calendar-days-today" : ""}`,
1440
1518
  style: {
1441
1519
  color: T ? "#ccc" : void 0,
1442
1520
  pointerEvents: T ? "none" : void 0,
1443
1521
  cursor: T ? "not-allowed" : "pointer",
1444
- ...u ? {} : { width: "100%" }
1522
+ ...p ? {} : { width: "100%" }
1445
1523
  },
1446
1524
  onClick: () => {
1447
- T || g(i.date);
1525
+ T || g(u.date);
1448
1526
  },
1449
- children: i.number
1527
+ children: u.number
1450
1528
  },
1451
- N
1529
+ C
1452
1530
  );
1453
1531
  }) })
1454
1532
  ] });
1455
- }, Un = ({
1533
+ }, ee = ({
1456
1534
  date: n,
1457
1535
  setDate: e,
1458
- filter: t,
1536
+ filter: a,
1459
1537
  setViews: o,
1460
- onChange: s,
1538
+ onChange: r,
1461
1539
  previewDate: d,
1462
- setPreviewDate: l,
1463
- minDate: u,
1540
+ setPreviewDate: i,
1541
+ minDate: p,
1464
1542
  maxDate: h,
1465
- input: r,
1543
+ input: l,
1466
1544
  hasValue: c
1467
1545
  }) => {
1468
- const y = n.getMonth(), k = n.getFullYear(), L = d.getFullYear(), C = (b) => {
1469
- (!u || b >= u) && (!h || b <= h) && (t ? (s(b), e(b), l(b)) : (o("days"), l(b)));
1546
+ const w = n.getMonth(), M = n.getFullYear(), E = d.getFullYear(), x = (b) => {
1547
+ (!p || b >= p) && (!h || b <= h) && (a ? (r(b), e(b), i(b)) : (o("days"), i(b)));
1470
1548
  };
1471
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: nn.map((b, g) => {
1472
- const i = u && new Date(L, g, 1) < u || h && new Date(L, g + 1, 0) > h;
1473
- return /* @__PURE__ */ a(
1549
+ return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, g) => {
1550
+ const u = p && new Date(E, g, 1) < p || h && new Date(E, g + 1, 0) > h;
1551
+ return /* @__PURE__ */ s(
1474
1552
  "p",
1475
1553
  {
1476
- className: c && g === y && L === k ? "sa-calendar-months-active" : "",
1554
+ className: c && g === w && E === M ? "sa-calendar-months-active" : "",
1477
1555
  style: {
1478
- color: i ? "#ccc" : void 0,
1479
- pointerEvents: i ? "none" : void 0,
1480
- cursor: i ? "not-allowed" : "pointer",
1481
- ...r ? {} : { width: "100%" }
1556
+ color: u ? "#ccc" : void 0,
1557
+ pointerEvents: u ? "none" : void 0,
1558
+ cursor: u ? "not-allowed" : "pointer",
1559
+ ...l ? {} : { width: "100%" }
1482
1560
  },
1483
1561
  onClick: () => {
1484
- i || C(new Date(L, g));
1562
+ u || x(new Date(E, g));
1485
1563
  },
1486
1564
  children: b.slice(0, 3)
1487
1565
  },
1488
1566
  g
1489
1567
  );
1490
1568
  }) });
1491
- }, kn = (n) => {
1492
- const e = Math.floor(n / 10) * 10, t = e + 10;
1493
- return { start: e, end: t };
1494
- }, Zn = ({
1569
+ }, zn = (n) => {
1570
+ const e = Math.floor(n / 10) * 10, a = e + 10;
1571
+ return { start: e, end: a };
1572
+ }, ae = ({
1495
1573
  date: n,
1496
1574
  filter: e,
1497
- setViews: t,
1575
+ setViews: a,
1498
1576
  setDate: o,
1499
- onChange: s,
1577
+ onChange: r,
1500
1578
  previewDate: d,
1501
- setPreviewDate: l,
1502
- minDate: u,
1579
+ setPreviewDate: i,
1580
+ minDate: p,
1503
1581
  maxDate: h,
1504
- input: r,
1582
+ input: l,
1505
1583
  hasValue: c
1506
1584
  }) => {
1507
- let y = [];
1508
- const k = d.getFullYear(), { start: L, end: C } = kn(k), b = n.getFullYear();
1509
- for (let i = L; i < C; i++) {
1510
- let N = u && new Date(i, 0, 1) < u || h && new Date(i, 11, 31) > h;
1511
- y.push({
1512
- year: i,
1513
- active: !!c && i === b,
1514
- isDisabled: N
1585
+ let w = [];
1586
+ const M = d.getFullYear(), { start: E, end: x } = zn(M), b = n.getFullYear();
1587
+ for (let u = E; u < x; u++) {
1588
+ let C = p && new Date(u, 0, 1) < p || h && new Date(u, 11, 31) > h;
1589
+ w.push({
1590
+ year: u,
1591
+ active: !!c && u === b,
1592
+ isDisabled: C
1515
1593
  });
1516
1594
  }
1517
- const g = (i) => {
1518
- (!u || i >= u) && (!h || i <= h) && (e ? (s(i), o(i), l(i)) : (t("months"), l(i)));
1595
+ const g = (u) => {
1596
+ (!p || u >= p) && (!h || u <= h) && (e ? (r(u), o(u), i(u)) : (a("months"), i(u)));
1519
1597
  };
1520
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: y.map((i, N) => /* @__PURE__ */ a(
1598
+ return /* @__PURE__ */ s("div", { className: "sa-calendar-years-preview", children: w.map((u, C) => /* @__PURE__ */ s(
1521
1599
  "p",
1522
1600
  {
1523
- className: i.active ? "sa-calendar-months-active" : "",
1601
+ className: u.active ? "sa-calendar-months-active" : "",
1524
1602
  style: {
1525
- color: i.isDisabled ? "#ccc" : void 0,
1526
- pointerEvents: i.isDisabled ? "none" : void 0,
1527
- cursor: i.isDisabled ? "not-allowed" : "pointer",
1528
- ...r ? {} : { width: "100%" }
1603
+ color: u.isDisabled ? "#ccc" : void 0,
1604
+ pointerEvents: u.isDisabled ? "none" : void 0,
1605
+ cursor: u.isDisabled ? "not-allowed" : "pointer",
1606
+ ...l ? {} : { width: "100%" }
1529
1607
  },
1530
1608
  onClick: () => {
1531
- i.isDisabled || g(new Date(i.year, 0));
1609
+ u.isDisabled || g(new Date(u.year, 0));
1532
1610
  },
1533
- children: i.year
1611
+ children: u.year
1534
1612
  },
1535
- N
1613
+ C
1536
1614
  )) });
1537
- }, Kn = ({
1615
+ }, te = ({
1538
1616
  setViews: n,
1539
1617
  views: e,
1540
- filter: t,
1618
+ filter: a,
1541
1619
  previewDate: o,
1542
- setPreviewDate: s
1620
+ setPreviewDate: r
1543
1621
  }) => {
1544
1622
  const d = () => {
1545
- t || n((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
1546
- }, l = () => {
1623
+ a || n((l) => l === "days" ? "months" : l === "months" ? "years" : "days");
1624
+ }, i = () => {
1547
1625
  if (e === "years") {
1548
- s((r) => new Date(r.getFullYear() + 10, 0));
1626
+ r((l) => new Date(l.getFullYear() + 10, 0));
1549
1627
  return;
1550
1628
  }
1551
1629
  if (e === "months") {
1552
- s(
1553
- (r) => new Date(r.getFullYear() + 1, r.getMonth())
1630
+ r(
1631
+ (l) => new Date(l.getFullYear() + 1, l.getMonth())
1554
1632
  );
1555
1633
  return;
1556
1634
  }
1557
- s((r) => new Date(r.getFullYear(), r.getMonth() + 1));
1558
- }, u = () => {
1635
+ r((l) => new Date(l.getFullYear(), l.getMonth() + 1));
1636
+ }, p = () => {
1559
1637
  if (e === "years") {
1560
- s((r) => new Date(r.getFullYear() - 10, 0));
1638
+ r((l) => new Date(l.getFullYear() - 10, 0));
1561
1639
  return;
1562
1640
  }
1563
1641
  if (e === "months") {
1564
- s(
1565
- (r) => new Date(r.getFullYear() - 1, r.getMonth())
1642
+ r(
1643
+ (l) => new Date(l.getFullYear() - 1, l.getMonth())
1566
1644
  );
1567
1645
  return;
1568
1646
  }
1569
- s(
1570
- (r) => new Date(
1571
- r.getMonth() === 0 ? r.getFullYear() - 1 : r.getFullYear(),
1572
- r.getMonth() === 0 ? 11 : r.getMonth() - 1
1647
+ r(
1648
+ (l) => new Date(
1649
+ l.getMonth() === 0 ? l.getFullYear() - 1 : l.getFullYear(),
1650
+ l.getMonth() === 0 ? 11 : l.getMonth() - 1
1573
1651
  )
1574
1652
  );
1575
1653
  };
1576
- return /* @__PURE__ */ Y("div", { className: "sa-calendar-header", children: [
1577
- /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
1654
+ return /* @__PURE__ */ z("div", { className: "sa-calendar-header", children: [
1655
+ /* @__PURE__ */ s("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
1578
1656
  if (e === "days")
1579
- return `${nn[o.getMonth()]} ${o.getFullYear()}`;
1657
+ return `${Q[o.getMonth()]} ${o.getFullYear()}`;
1580
1658
  if (e === "months")
1581
1659
  return `${o.getFullYear()}`;
1582
1660
  if (e === "years")
1583
- return `${kn(o.getFullYear()).start} ~ ${kn(o.getFullYear()).end}`;
1661
+ return `${zn(o.getFullYear()).start} ~ ${zn(o.getFullYear()).end}`;
1584
1662
  })() }),
1585
- /* @__PURE__ */ Y("div", { className: "sa-calendar-header-nav", children: [
1586
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: u, children: /* @__PURE__ */ a(En, {}) }),
1587
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: l, children: /* @__PURE__ */ a(Fn, {}) })
1663
+ /* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
1664
+ /* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ s(Pn, {}) }),
1665
+ /* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ s(Rn, {}) })
1588
1666
  ] })
1589
1667
  ] });
1590
- }, Dn = "sa-calendar-styles", _n = (n) => {
1591
- if (!(typeof document > "u") && !document.getElementById(Dn)) {
1668
+ }, Tn = "sa-calendar-styles", re = (n) => {
1669
+ if (!(typeof document > "u") && !document.getElementById(Tn)) {
1592
1670
  const e = document.createElement("style");
1593
- e.id = Dn, e.textContent = n, document.head.appendChild(e);
1671
+ e.id = Tn, e.textContent = n, document.head.appendChild(e);
1594
1672
  }
1595
1673
  };
1596
- _n(un);
1597
- const Qn = mn(
1674
+ re(gn);
1675
+ const se = xn(
1598
1676
  ({
1599
1677
  value: n,
1600
1678
  onChange: e,
1601
- filter: t,
1679
+ filter: a,
1602
1680
  input: o = !0,
1603
- disabled: s,
1681
+ disabled: r,
1604
1682
  minDate: d,
1605
- maxDate: l,
1606
- placeholder: u,
1683
+ maxDate: i,
1684
+ placeholder: p,
1607
1685
  size: h = "sm",
1608
- variant: r,
1686
+ variant: l,
1609
1687
  status: c,
1610
- clearable: y,
1611
- fullWidth: k = !0,
1612
- withPadding: L = !0,
1613
- trigger: C,
1614
- renderTrigger: b,
1615
- label: g,
1616
- labelPosition: i,
1617
- required: N,
1618
- optional: T,
1619
- description: m,
1620
- helperText: x,
1621
- errorText: f
1622
- }, E) => {
1623
- const A = f ? "error" : c, { ref: I, isComponentVisible: R, setIsComponentVisible: $ } = Nn(!1), z = Q(null), [w, D] = Z("days"), [M, V] = Z(/* @__PURE__ */ new Date()), [O, B] = Z(/* @__PURE__ */ new Date()), K = typeof b == "function" || C != null, S = !o && !K, H = !S;
1624
- j(() => {
1625
- n ? (V(n), B(n)) : (V(/* @__PURE__ */ new Date()), B(/* @__PURE__ */ new Date()));
1626
- }, [n]), j(() => {
1627
- t && D(t);
1628
- }, [t]), j(() => {
1629
- t || D("days");
1630
- }, [R]), j(() => {
1631
- S && $(!0);
1632
- }, [S]);
1633
- const _ = () => n ? t === "days" ? rn(M) : t === "months" ? `${nn[M.getMonth()]} ${M.getFullYear()}` : t === "years" ? M.getFullYear() : rn(M) : "", J = () => {
1634
- if (z.current && I.current && H) {
1635
- const v = I.current.getBoundingClientRect(), P = z.current.getBoundingClientRect();
1636
- window.innerWidth < v.left + P.width ? z.current.style.left = `${v.left - P.width + v.width}px` : z.current.style.left = `${v.left}px`, v.top + P.height > window.innerHeight ? z.current.style.top = `${v.y - (v.height + P.height - 28)}px` : z.current.style.top = `${v.y + v.height}px`;
1688
+ clearable: w,
1689
+ fullWidth: M = !0,
1690
+ withPadding: E = !0,
1691
+ editable: x = !1,
1692
+ trigger: b,
1693
+ renderTrigger: g,
1694
+ label: u,
1695
+ labelPosition: C,
1696
+ required: T,
1697
+ optional: y,
1698
+ description: k,
1699
+ helperText: v,
1700
+ errorText: N
1701
+ }, K) => {
1702
+ const j = N ? "error" : c, { ref: B, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), m = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), [A, O] = G(/* @__PURE__ */ new Date()), [W, D] = G(null), J = typeof g == "function" || b != null, q = !o && !J, U = !q;
1703
+ P(() => {
1704
+ n ? (I(n), O(n)) : (I(/* @__PURE__ */ new Date()), O(/* @__PURE__ */ new Date())), D(null);
1705
+ }, [n]), P(() => {
1706
+ a && L(a);
1707
+ }, [a]), P(() => {
1708
+ a || L("days");
1709
+ }, [F]), P(() => {
1710
+ q && $(!0);
1711
+ }, [q]);
1712
+ const X = () => n ? a === "days" ? on(S) : a === "months" ? `${Q[S.getMonth()]} ${S.getFullYear()}` : a === "years" ? S.getFullYear() : on(S) : "", R = () => {
1713
+ if (m.current && B.current && U) {
1714
+ const t = B.current.getBoundingClientRect(), f = m.current.getBoundingClientRect();
1715
+ window.innerWidth < t.left + f.width ? m.current.style.left = `${t.left - f.width + t.width}px` : m.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? m.current.style.top = `${t.y - (t.height + f.height - 28)}px` : m.current.style.top = `${t.y + t.height}px`;
1637
1716
  }
1638
1717
  };
1639
- j(() => {
1640
- z.current && I.current && H && J();
1641
- }, [z, I, R]), j(() => (window.addEventListener("scroll", J, !0), window.addEventListener("resize", J), () => {
1642
- window.removeEventListener("scroll", J, !0), window.removeEventListener("resize", J);
1718
+ P(() => {
1719
+ m.current && B.current && U && R();
1720
+ }, [m, B, F]), P(() => (window.addEventListener("scroll", R, !0), window.addEventListener("resize", R), () => {
1721
+ window.removeEventListener("scroll", R, !0), window.removeEventListener("resize", R);
1643
1722
  }), []);
1644
- const sn = () => $(!0), on = () => $(!1), G = () => $((v) => !v), ln = {
1645
- isOpen: R,
1646
- open: sn,
1647
- close: on,
1648
- toggle: G,
1723
+ const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
1724
+ x && D(n ? $n(n, a) : "");
1725
+ }, en = () => {
1726
+ if (W === null)
1727
+ return;
1728
+ const t = W.trim();
1729
+ if (!t) {
1730
+ e(void 0), D(null);
1731
+ return;
1732
+ }
1733
+ const f = bn(t, a);
1734
+ f && Dn(f, d, i) && (e(f), I(f), O(f)), D(null);
1735
+ }, un = (t) => {
1736
+ t.key === "Enter" ? (en(), $(!1)) : t.key === "Escape" && (D(null), $(!1));
1737
+ }, pn = {
1738
+ isOpen: F,
1739
+ open: ln,
1740
+ close: dn,
1741
+ toggle: nn,
1649
1742
  value: n,
1650
- formattedValue: String(_() ?? ""),
1743
+ formattedValue: String(X() ?? ""),
1651
1744
  clear: () => e(void 0),
1652
- disabled: s,
1653
- placeholder: u
1654
- }, dn = /* @__PURE__ */ Y(
1745
+ disabled: r,
1746
+ placeholder: p
1747
+ }, hn = /* @__PURE__ */ z(
1655
1748
  "div",
1656
1749
  {
1657
- className: "sa-calendar-wrapper",
1658
- style: { height: S ? "100%" : "auto" },
1659
- ref: H ? I : null,
1750
+ className: `sa-calendar-wrapper${J ? " sa-calendar-wrapper-custom" : ""}`,
1751
+ style: { height: q ? "100%" : "auto" },
1752
+ ref: U ? B : null,
1660
1753
  children: [
1661
- K ? (() => {
1662
- if (typeof b == "function")
1663
- return b(ln);
1664
- if (gn.isValidElement(C)) {
1665
- const v = C;
1666
- return gn.cloneElement(v, {
1667
- onClick: (P) => {
1668
- var q, X;
1669
- (X = (q = v.props) == null ? void 0 : q.onClick) == null || X.call(q, P), s || G();
1754
+ J ? (() => {
1755
+ if (typeof g == "function")
1756
+ return g(pn);
1757
+ if (wn.isValidElement(b)) {
1758
+ const t = b;
1759
+ return wn.cloneElement(t, {
1760
+ onClick: (f) => {
1761
+ var V, an;
1762
+ (an = (V = t.props) == null ? void 0 : V.onClick) == null || an.call(V, f), r || nn();
1670
1763
  }
1671
1764
  });
1672
1765
  }
1673
- return C;
1674
- })() : o ? /* @__PURE__ */ a(
1675
- qn,
1766
+ return b;
1767
+ })() : o ? /* @__PURE__ */ s(
1768
+ Xn,
1676
1769
  {
1677
- value: _(),
1770
+ value: x && W !== null ? W : X(),
1678
1771
  onClick: () => $(!0),
1679
- onChange: () => {
1772
+ onChange: x ? (t) => D(t.target.value) : () => {
1680
1773
  },
1681
- placeholder: u,
1682
- disabled: s,
1774
+ onFocus: x ? cn : void 0,
1775
+ onBlur: x ? en : void 0,
1776
+ onKeyDown: x ? un : void 0,
1777
+ placeholder: p,
1778
+ disabled: r,
1683
1779
  size: h,
1684
- variant: r,
1685
- status: A,
1686
- inputMode: "none",
1687
- clearable: y,
1780
+ variant: l,
1781
+ status: j,
1782
+ inputMode: x ? "text" : "none",
1783
+ readOnly: !x,
1784
+ clearable: w,
1688
1785
  onClear: () => e(void 0)
1689
1786
  }
1690
1787
  ) : null,
1691
- R ? /* @__PURE__ */ Y(
1788
+ F ? /* @__PURE__ */ z(
1692
1789
  "div",
1693
1790
  {
1694
- className: `sa-calendar sa-calendar-size-${h || "sm"} ${S ? "sa-calendar-no-input" : ""} ${L ? "" : "sa-calendar-no-padding"}`,
1695
- style: s ? { pointerEvents: "none" } : void 0,
1696
- ref: z,
1791
+ className: `sa-calendar sa-calendar-size-${h || "sm"} ${q ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
1792
+ style: r ? { pointerEvents: "none" } : void 0,
1793
+ ref: m,
1697
1794
  children: [
1698
- /* @__PURE__ */ a(
1699
- Kn,
1795
+ /* @__PURE__ */ s(
1796
+ te,
1700
1797
  {
1701
- setViews: D,
1702
- views: w,
1703
- filter: t,
1704
- previewDate: O,
1705
- setPreviewDate: B,
1706
- isComponentVisible: R
1798
+ setViews: L,
1799
+ views: Y,
1800
+ filter: a,
1801
+ previewDate: A,
1802
+ setPreviewDate: O,
1803
+ isComponentVisible: F
1707
1804
  }
1708
1805
  ),
1709
- /* @__PURE__ */ a("div", { className: "sa-calendar-body", children: w === "days" ? /* @__PURE__ */ a(
1710
- Gn,
1806
+ /* @__PURE__ */ s("div", { className: "sa-calendar-body", children: Y === "days" ? /* @__PURE__ */ s(
1807
+ ne,
1711
1808
  {
1712
- date: M,
1713
- setDate: V,
1714
- previewDate: O,
1715
- setPreviewDate: B,
1809
+ date: S,
1810
+ setDate: I,
1811
+ previewDate: A,
1812
+ setPreviewDate: O,
1716
1813
  setIsComponentVisible: $,
1717
1814
  input: o,
1718
1815
  minDate: d,
1719
- maxDate: l,
1816
+ maxDate: i,
1720
1817
  onChange: e,
1721
1818
  hasValue: n != null
1722
1819
  }
1723
- ) : w === "months" ? /* @__PURE__ */ a(
1724
- Un,
1820
+ ) : Y === "months" ? /* @__PURE__ */ s(
1821
+ ee,
1725
1822
  {
1726
- date: M,
1727
- setDate: V,
1728
- previewDate: O,
1729
- setPreviewDate: B,
1730
- filter: t,
1731
- setViews: D,
1823
+ date: S,
1824
+ setDate: I,
1825
+ previewDate: A,
1826
+ setPreviewDate: O,
1827
+ filter: a,
1828
+ setViews: L,
1732
1829
  onChange: e,
1733
1830
  minDate: d,
1734
- maxDate: l,
1831
+ maxDate: i,
1735
1832
  input: o,
1736
1833
  hasValue: n != null
1737
1834
  }
1738
- ) : /* @__PURE__ */ a(
1739
- Zn,
1835
+ ) : /* @__PURE__ */ s(
1836
+ ae,
1740
1837
  {
1741
- date: M,
1742
- setDate: V,
1743
- previewDate: O,
1744
- setPreviewDate: B,
1745
- filter: t,
1746
- setViews: D,
1838
+ date: S,
1839
+ setDate: I,
1840
+ previewDate: A,
1841
+ setPreviewDate: O,
1842
+ filter: a,
1843
+ setViews: L,
1747
1844
  onChange: e,
1748
1845
  minDate: d,
1749
- maxDate: l,
1846
+ maxDate: i,
1750
1847
  input: o,
1751
1848
  hasValue: n != null
1752
1849
  }
@@ -1757,77 +1854,79 @@ const Qn = mn(
1757
1854
  ]
1758
1855
  }
1759
1856
  );
1760
- return /* @__PURE__ */ a(
1761
- Mn,
1857
+ return /* @__PURE__ */ s(
1858
+ Yn,
1762
1859
  {
1763
- label: g,
1764
- labelPosition: i,
1765
- required: N,
1766
- optional: T,
1767
- description: m,
1768
- helperText: x,
1769
- errorText: f,
1770
- fullWidth: k,
1860
+ label: u,
1861
+ labelPosition: C,
1862
+ required: T,
1863
+ optional: y,
1864
+ description: k,
1865
+ helperText: v,
1866
+ errorText: N,
1867
+ fullWidth: M,
1771
1868
  size: h,
1772
- children: dn
1869
+ children: hn
1773
1870
  }
1774
1871
  );
1775
1872
  }
1776
- ), ie = mn(
1873
+ ), ge = xn(
1777
1874
  ({
1778
1875
  value: n,
1779
1876
  onChange: e,
1780
- filter: t,
1877
+ filter: a,
1781
1878
  input: o = !0,
1782
- rangedDate: s,
1879
+ rangedDate: r,
1783
1880
  disabled: d,
1784
- minDate: l,
1785
- maxDate: u,
1881
+ minDate: i,
1882
+ maxDate: p,
1786
1883
  placeholder: h,
1787
- size: r,
1884
+ size: l,
1788
1885
  variant: c,
1789
- status: y,
1790
- clearable: k,
1791
- fullWidth: L,
1792
- withPadding: C,
1793
- trigger: b,
1794
- renderTrigger: g,
1795
- label: i,
1796
- labelPosition: N,
1797
- required: T,
1798
- optional: m,
1799
- description: x,
1800
- helperText: f,
1801
- errorText: E
1802
- }, A) => {
1803
- const I = {
1886
+ status: w,
1887
+ clearable: M,
1888
+ fullWidth: E,
1889
+ withPadding: x,
1890
+ editable: b,
1891
+ trigger: g,
1892
+ renderTrigger: u,
1893
+ label: C,
1894
+ labelPosition: T,
1895
+ required: y,
1896
+ optional: k,
1897
+ description: v,
1898
+ helperText: N,
1899
+ errorText: K
1900
+ }, j) => {
1901
+ const B = {
1804
1902
  onChange: e,
1805
1903
  value: n,
1806
1904
  input: o,
1807
- filter: t,
1905
+ filter: a,
1808
1906
  disabled: d,
1809
- minDate: l,
1810
- maxDate: u,
1907
+ minDate: i,
1908
+ maxDate: p,
1811
1909
  placeholder: h,
1812
- size: r,
1910
+ size: l,
1813
1911
  variant: c,
1814
- status: y,
1815
- clearable: k,
1816
- fullWidth: L,
1817
- withPadding: C,
1818
- trigger: b,
1819
- renderTrigger: g,
1820
- label: i,
1821
- labelPosition: N,
1822
- required: T,
1823
- optional: m,
1824
- description: x,
1825
- helperText: f,
1826
- errorText: E
1912
+ status: w,
1913
+ clearable: M,
1914
+ fullWidth: E,
1915
+ withPadding: x,
1916
+ editable: b,
1917
+ trigger: g,
1918
+ renderTrigger: u,
1919
+ label: C,
1920
+ labelPosition: T,
1921
+ required: y,
1922
+ optional: k,
1923
+ description: v,
1924
+ helperText: N,
1925
+ errorText: K
1827
1926
  };
1828
- return /* @__PURE__ */ a(fn, { children: s ? /* @__PURE__ */ a(Wn, { ...I, ref: A }) : /* @__PURE__ */ a(Qn, { ...I, ref: A }) });
1927
+ return /* @__PURE__ */ s(yn, { children: r ? /* @__PURE__ */ s(_n, { ...B, ref: j }) : /* @__PURE__ */ s(se, { ...B, ref: j }) });
1829
1928
  }
1830
- ), Xn = `/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
1929
+ ), oe = `/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
1831
1930
  date.module.css, injected alongside this sheet) and the .sa-calendar /
1832
1931
  .sa-calendar-input-* shells for the box + masked input. */
1833
1932
 
@@ -1958,46 +2057,46 @@ const Qn = mn(
1958
2057
  .sa-time-input-wrap {
1959
2058
  width: 100%;
1960
2059
  }
1961
- `, yn = (n, e, t) => Math.min(t, Math.max(e, n)), W = (n) => String(n).padStart(2, "0"), wn = (n) => {
2060
+ `, Nn = (n, e, a) => Math.min(a, Math.max(e, n)), H = (n) => String(n).padStart(2, "0"), Mn = (n) => {
1962
2061
  if (!n)
1963
2062
  return null;
1964
2063
  const e = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(n.trim());
1965
2064
  if (!e)
1966
2065
  return null;
1967
- const t = Number(e[1]), o = Number(e[2]), s = e[3] != null ? Number(e[3]) : 0;
1968
- return t > 23 || o > 59 || s > 59 ? null : { h: t, m: o, s };
1969
- }, ne = (n, e) => e ? `${W(n.h)}:${W(n.m)}:${W(n.s)}` : `${W(n.h)}:${W(n.m)}`, U = (n) => n.h * 60 + n.m, ee = (n, e, t) => {
1970
- const o = t ? `:${W(n.s)}` : "";
2066
+ const a = Number(e[1]), o = Number(e[2]), r = e[3] != null ? Number(e[3]) : 0;
2067
+ return a > 23 || o > 59 || r > 59 ? null : { h: a, m: o, s: r };
2068
+ }, le = (n, e) => e ? `${H(n.h)}:${H(n.m)}:${H(n.s)}` : `${H(n.h)}:${H(n.m)}`, Z = (n) => n.h * 60 + n.m, ie = (n, e, a) => {
2069
+ const o = a ? `:${H(n.s)}` : "";
1971
2070
  if (e === "12h") {
1972
- const s = n.h >= 12 ? "PM" : "AM", d = n.h % 12 === 0 ? 12 : n.h % 12;
1973
- return `${W(d)}:${W(n.m)}${o} ${s}`;
2071
+ const r = n.h >= 12 ? "PM" : "AM", d = n.h % 12 === 0 ? 12 : n.h % 12;
2072
+ return `${H(d)}:${H(n.m)}${o} ${r}`;
1974
2073
  }
1975
- return `${W(n.h)}:${W(n.m)}${o}`;
1976
- }, ae = (n, e, t) => {
1977
- const o = n.toLowerCase(), s = /p/.test(o) ? "pm" : /a/.test(o) ? "am" : null, d = o.replace(/[^\d]/g, "");
2074
+ return `${H(n.h)}:${H(n.m)}${o}`;
2075
+ }, de = (n, e, a) => {
2076
+ const o = n.toLowerCase(), r = /p/.test(o) ? "pm" : /a/.test(o) ? "am" : null, d = o.replace(/[^\d]/g, "");
1978
2077
  if (!d)
1979
2078
  return null;
1980
- let l = 0, u = 0, h = 0;
2079
+ let i = 0, p = 0, h = 0;
1981
2080
  if (n.includes(":")) {
1982
- const r = n.split(":").map((c) => c.replace(/[^\d]/g, ""));
1983
- l = Number(r[0] || 0), u = Number(r[1] || 0), h = t ? Number(r[2] || 0) : 0;
2081
+ const l = n.split(":").map((c) => c.replace(/[^\d]/g, ""));
2082
+ i = Number(l[0] || 0), p = Number(l[1] || 0), h = a ? Number(l[2] || 0) : 0;
1984
2083
  } else
1985
- d.length <= 2 ? l = Number(d) : d.length <= 4 ? (l = Number(d.slice(0, d.length - 2)), u = Number(d.slice(-2))) : (l = Number(d.slice(0, d.length - 4)), u = Number(d.slice(-4, -2)), h = t ? Number(d.slice(-2)) : 0);
1986
- return s && (s === "pm" && l < 12 && (l += 12), s === "am" && l === 12 && (l = 0)), l > 23 || u > 59 || h > 59 ? null : { h: yn(l, 0, 23), m: yn(u, 0, 59), s: yn(h, 0, 59) };
1987
- }, pn = (n, e = 1) => {
1988
- const t = [];
2084
+ d.length <= 2 ? i = Number(d) : d.length <= 4 ? (i = Number(d.slice(0, d.length - 2)), p = Number(d.slice(-2))) : (i = Number(d.slice(0, d.length - 4)), p = Number(d.slice(-4, -2)), h = a ? Number(d.slice(-2)) : 0);
2085
+ return r && (r === "pm" && i < 12 && (i += 12), r === "am" && i === 12 && (i = 0)), i > 23 || p > 59 || h > 59 ? null : { h: Nn(i, 0, 23), m: Nn(p, 0, 59), s: Nn(h, 0, 59) };
2086
+ }, mn = (n, e = 1) => {
2087
+ const a = [];
1989
2088
  for (let o = 0; o < n; o += e)
1990
- t.push(o);
1991
- return t;
1992
- }, Sn = (n, e) => {
2089
+ a.push(o);
2090
+ return a;
2091
+ }, On = (n, e) => {
1993
2092
  if (typeof document > "u" || document.getElementById(n))
1994
2093
  return;
1995
- const t = document.createElement("style");
1996
- t.id = n, t.textContent = e, document.head.appendChild(t);
2094
+ const a = document.createElement("style");
2095
+ a.id = n, a.textContent = e, document.head.appendChild(a);
1997
2096
  };
1998
- Sn("sa-calendar-styles", un);
1999
- Sn("sa-time-styles", Xn);
2000
- const te = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Yn = ({ s: n }) => /* @__PURE__ */ a("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ a(
2097
+ On("sa-calendar-styles", gn);
2098
+ On("sa-time-styles", oe);
2099
+ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /* @__PURE__ */ s("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ s(
2001
2100
  "path",
2002
2101
  {
2003
2102
  d: "M10 5v5l3 2M17.5 10a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",
@@ -2006,7 +2105,7 @@ const te = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Yn = ({ s: n }) => /*
2006
2105
  strokeLinecap: "round",
2007
2106
  strokeLinejoin: "round"
2008
2107
  }
2009
- ) }), re = ({ s: n }) => /* @__PURE__ */ a("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ a(
2108
+ ) }), ue = ({ s: n }) => /* @__PURE__ */ s("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ s(
2010
2109
  "path",
2011
2110
  {
2012
2111
  d: "M5 5l10 10M15 5L5 15",
@@ -2014,235 +2113,235 @@ const te = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Yn = ({ s: n }) => /*
2014
2113
  strokeWidth: "1.5",
2015
2114
  strokeLinecap: "round"
2016
2115
  }
2017
- ) }), hn = ({ label: n, options: e, active: t, onPick: o }) => {
2018
- const s = Q(null), d = Q(null);
2019
- return j(() => {
2020
- var l;
2021
- (l = d.current) == null || l.scrollIntoView({ block: "nearest" });
2022
- }, [t]), /* @__PURE__ */ Y("div", { className: "sa-time-col", children: [
2023
- /* @__PURE__ */ a("div", { className: "sa-time-col-head", children: n }),
2024
- /* @__PURE__ */ a("div", { className: "sa-time-col-list", ref: s, children: e.map((l) => {
2025
- const u = l.value === t;
2026
- return /* @__PURE__ */ a(
2116
+ ) }), vn = ({ label: n, options: e, active: a, onPick: o }) => {
2117
+ const r = _(null), d = _(null);
2118
+ return P(() => {
2119
+ var i;
2120
+ (i = d.current) == null || i.scrollIntoView({ block: "nearest" });
2121
+ }, [a]), /* @__PURE__ */ z("div", { className: "sa-time-col", children: [
2122
+ /* @__PURE__ */ s("div", { className: "sa-time-col-head", children: n }),
2123
+ /* @__PURE__ */ s("div", { className: "sa-time-col-list", ref: r, children: e.map((i) => {
2124
+ const p = i.value === a;
2125
+ return /* @__PURE__ */ s(
2027
2126
  "button",
2028
2127
  {
2029
2128
  type: "button",
2030
- ref: u ? d : null,
2031
- disabled: l.disabled,
2032
- className: `sa-time-opt${u ? " sa-time-opt-active" : ""}`,
2033
- onClick: () => o(l.value),
2034
- children: l.label
2129
+ ref: p ? d : null,
2130
+ disabled: i.disabled,
2131
+ className: `sa-time-opt${p ? " sa-time-opt-active" : ""}`,
2132
+ onClick: () => o(i.value),
2133
+ children: i.label
2035
2134
  },
2036
- l.value
2135
+ i.value
2037
2136
  );
2038
2137
  }) })
2039
2138
  ] });
2040
- }, se = mn(
2139
+ }, pe = xn(
2041
2140
  ({
2042
2141
  value: n,
2043
2142
  onChange: e,
2044
- format: t = "24h",
2143
+ format: a = "24h",
2045
2144
  withSeconds: o = !1,
2046
- step: s = 1,
2145
+ step: r = 1,
2047
2146
  minTime: d,
2048
- maxTime: l,
2049
- input: u = !0,
2147
+ maxTime: i,
2148
+ input: p = !0,
2050
2149
  placeholder: h = "--:--",
2051
- disabled: r,
2150
+ disabled: l,
2052
2151
  clearable: c,
2053
- size: y = "sm",
2054
- variant: k = "outline",
2055
- status: L,
2056
- fullWidth: C = !0,
2152
+ size: w = "sm",
2153
+ variant: M = "outline",
2154
+ status: E,
2155
+ fullWidth: x = !0,
2057
2156
  withPadding: b = !0,
2058
2157
  label: g,
2059
- labelPosition: i,
2060
- required: N,
2158
+ labelPosition: u,
2159
+ required: C,
2061
2160
  optional: T,
2062
- description: m,
2063
- helperText: x,
2064
- errorText: f
2065
- }, E) => {
2066
- const A = f ? "error" : L, { ref: I, isComponentVisible: R, setIsComponentVisible: $ } = Nn(!1), z = Q(null), w = en(() => wn(n), [n]), D = en(() => wn(d), [d]), M = en(() => wn(l), [l]), [V, O] = Z(null);
2067
- j(() => {
2068
- u || $(!0);
2069
- }, [u]);
2070
- const B = () => {
2071
- if (!z.current || !I.current || !u)
2161
+ description: y,
2162
+ helperText: k,
2163
+ errorText: v
2164
+ }, N) => {
2165
+ const K = v ? "error" : E, { ref: j, isComponentVisible: B, setIsComponentVisible: F } = En(!1), $ = _(null), m = tn(() => Mn(n), [n]), Y = tn(() => Mn(d), [d]), L = tn(() => Mn(i), [i]), [S, I] = G(null);
2166
+ P(() => {
2167
+ p || F(!0);
2168
+ }, [p]);
2169
+ const A = () => {
2170
+ if (!$.current || !j.current || !p)
2072
2171
  return;
2073
- const p = I.current.getBoundingClientRect(), F = z.current.getBoundingClientRect();
2074
- z.current.style.left = window.innerWidth < p.left + F.width ? `${p.left - F.width + p.width}px` : `${p.left}px`, z.current.style.top = p.top + F.height > window.innerHeight ? `${p.y - (p.height + F.height - 28)}px` : `${p.y + p.height}px`;
2172
+ const t = j.current.getBoundingClientRect(), f = $.current.getBoundingClientRect();
2173
+ $.current.style.left = window.innerWidth < t.left + f.width ? `${t.left - f.width + t.width}px` : `${t.left}px`, $.current.style.top = t.top + f.height > window.innerHeight ? `${t.y - (t.height + f.height - 28)}px` : `${t.y + t.height}px`;
2075
2174
  };
2076
- j(() => {
2077
- B();
2078
- }, [R]), j(() => (window.addEventListener("scroll", B, !0), window.addEventListener("resize", B), () => {
2079
- window.removeEventListener("scroll", B, !0), window.removeEventListener("resize", B);
2175
+ P(() => {
2176
+ A();
2177
+ }, [B]), P(() => (window.addEventListener("scroll", A, !0), window.addEventListener("resize", A), () => {
2178
+ window.removeEventListener("scroll", A, !0), window.removeEventListener("resize", A);
2080
2179
  }), []);
2081
- const K = (p) => {
2082
- const F = U(p);
2083
- return !(D && F < U(D) || M && F > U(M));
2084
- }, S = (p) => {
2085
- e(ne(p, o)), O(null);
2086
- }, H = (p) => {
2087
- S({ ...w ?? { h: 0, m: 0, s: 0 }, ...p });
2088
- }, _ = () => {
2089
- if (V == null)
2180
+ const O = (t) => {
2181
+ const f = Z(t);
2182
+ return !(Y && f < Z(Y) || L && f > Z(L));
2183
+ }, W = (t) => {
2184
+ e(le(t, o)), I(null);
2185
+ }, D = (t) => {
2186
+ W({ ...m ?? { h: 0, m: 0, s: 0 }, ...t });
2187
+ }, J = () => {
2188
+ if (S == null)
2090
2189
  return;
2091
- if (V.trim() === "") {
2092
- e(null), O(null);
2190
+ if (S.trim() === "") {
2191
+ e(null), I(null);
2093
2192
  return;
2094
2193
  }
2095
- const p = ae(V, t, o);
2096
- p && K(p) ? S(p) : O(null);
2097
- }, J = w ? ee(w, t, o) : "", sn = V ?? J, on = c && !!w && !r, G = w && w.h >= 12 ? "PM" : "AM", ln = en(() => t === "12h" ? pn(12).map((p) => {
2098
- const F = p === 0 ? 12 : p, cn = G === "PM" ? F % 12 + 12 : F % 12;
2194
+ const t = de(S, a, o);
2195
+ t && O(t) ? W(t) : I(null);
2196
+ }, q = m ? ie(m, a, o) : "", U = S ?? q, X = c && !!m && !l, R = m && m.h >= 12 ? "PM" : "AM", ln = tn(() => a === "12h" ? mn(12).map((t) => {
2197
+ const f = t === 0 ? 12 : t, V = R === "PM" ? f % 12 + 12 : f % 12;
2099
2198
  return {
2100
- value: F,
2101
- label: W(F),
2102
- disabled: D && cn * 60 + 59 < U(D) || M && cn * 60 > U(M) || !1
2199
+ value: f,
2200
+ label: H(f),
2201
+ disabled: Y && V * 60 + 59 < Z(Y) || L && V * 60 > Z(L) || !1
2103
2202
  };
2104
- }) : pn(24).map((p) => ({
2105
- value: p,
2106
- label: W(p),
2107
- disabled: D && p * 60 + 59 < U(D) || M && p * 60 > U(M) || !1
2108
- })), [t, G, D, M]), bn = en(() => {
2109
- const p = (w == null ? void 0 : w.h) ?? 0;
2110
- return pn(60, s).map((F) => ({
2111
- value: F,
2112
- label: W(F),
2113
- disabled: D && p * 60 + F < U(D) || M && p * 60 + F > U(M) || !1
2203
+ }) : mn(24).map((t) => ({
2204
+ value: t,
2205
+ label: H(t),
2206
+ disabled: Y && t * 60 + 59 < Z(Y) || L && t * 60 > Z(L) || !1
2207
+ })), [a, R, Y, L]), dn = tn(() => {
2208
+ const t = (m == null ? void 0 : m.h) ?? 0;
2209
+ return mn(60, r).map((f) => ({
2210
+ value: f,
2211
+ label: H(f),
2212
+ disabled: Y && t * 60 + f < Z(Y) || L && t * 60 + f > Z(L) || !1
2114
2213
  }));
2115
- }, [s, w == null ? void 0 : w.h, D, M]), dn = en(
2116
- () => pn(60).map((p) => ({ value: p, label: W(p) })),
2214
+ }, [r, m == null ? void 0 : m.h, Y, L]), nn = tn(
2215
+ () => mn(60).map((t) => ({ value: t, label: H(t) })),
2117
2216
  []
2118
- ), v = w == null ? null : t === "12h" ? w.h % 12 === 0 ? 12 : w.h % 12 : w.h, P = (p) => {
2119
- if (t === "12h") {
2120
- const F = G === "PM" ? p % 12 + 12 : p % 12;
2121
- H({ h: F });
2217
+ ), cn = m == null ? null : a === "12h" ? m.h % 12 === 0 ? 12 : m.h % 12 : m.h, en = (t) => {
2218
+ if (a === "12h") {
2219
+ const f = R === "PM" ? t % 12 + 12 : t % 12;
2220
+ D({ h: f });
2122
2221
  } else
2123
- H({ h: p });
2124
- }, q = (p) => {
2125
- const F = w ?? { h: 0, m: 0, s: 0 }, cn = F.h % 12 === 0 ? 12 : F.h % 12, Tn = p === "PM" ? cn % 12 + 12 : cn % 12;
2126
- S({ ...F, h: Tn });
2127
- }, X = () => {
2128
- const p = /* @__PURE__ */ new Date(), F = Math.floor(p.getMinutes() / s) * s;
2129
- S({ h: p.getHours(), m: F, s: o ? p.getSeconds() : 0 });
2130
- }, vn = te(y), In = /* @__PURE__ */ Y(
2222
+ D({ h: t });
2223
+ }, un = (t) => {
2224
+ const f = m ?? { h: 0, m: 0, s: 0 }, V = f.h % 12 === 0 ? 12 : f.h % 12, an = t === "PM" ? V % 12 + 12 : V % 12;
2225
+ W({ ...f, h: an });
2226
+ }, pn = () => {
2227
+ const t = /* @__PURE__ */ new Date(), f = Math.floor(t.getMinutes() / r) * r;
2228
+ W({ h: t.getHours(), m: f, s: o ? t.getSeconds() : 0 });
2229
+ }, fn = ce(w), hn = /* @__PURE__ */ z(
2131
2230
  "div",
2132
2231
  {
2133
2232
  className: "sa-calendar-wrapper",
2134
- style: { height: u ? "auto" : "100%" },
2135
- ref: u ? I : null,
2233
+ style: { height: p ? "auto" : "100%" },
2234
+ ref: p ? j : null,
2136
2235
  children: [
2137
- u ? /* @__PURE__ */ Y(
2236
+ p ? /* @__PURE__ */ z(
2138
2237
  "div",
2139
2238
  {
2140
- className: `sa-calendar-input-container sa-calendar-input-${k} sa-calendar-input-container-${A || "default"} ${y}`,
2141
- onClick: () => !r && $(!0),
2239
+ className: `sa-calendar-input-container sa-calendar-input-${M} sa-calendar-input-container-${K || "default"} ${w}`,
2240
+ onClick: () => !l && F(!0),
2142
2241
  children: [
2143
- /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(Yn, { s: vn }) }),
2144
- /* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
2242
+ /* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ s(Bn, { s: fn }) }),
2243
+ /* @__PURE__ */ s("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ s(
2145
2244
  "input",
2146
2245
  {
2147
2246
  className: "sa-calendar-input",
2148
- value: sn,
2247
+ value: U,
2149
2248
  placeholder: h,
2150
- disabled: r,
2151
- onChange: (p) => O(p.target.value),
2152
- onFocus: () => $(!0),
2153
- onBlur: _,
2154
- onKeyDown: (p) => {
2155
- p.key === "Enter" && (_(), $(!1)), p.key === "Escape" && (O(null), $(!1));
2249
+ disabled: l,
2250
+ onChange: (t) => I(t.target.value),
2251
+ onFocus: () => F(!0),
2252
+ onBlur: J,
2253
+ onKeyDown: (t) => {
2254
+ t.key === "Enter" && (J(), F(!1)), t.key === "Escape" && (I(null), F(!1));
2156
2255
  }
2157
2256
  }
2158
2257
  ) }),
2159
- on ? /* @__PURE__ */ a(
2258
+ X ? /* @__PURE__ */ s(
2160
2259
  "button",
2161
2260
  {
2162
2261
  type: "button",
2163
2262
  "aria-label": "Clear time",
2164
2263
  className: "sa-calendar-input-clear",
2165
- onClick: (p) => {
2166
- p.stopPropagation(), e(null), O(null);
2264
+ onClick: (t) => {
2265
+ t.stopPropagation(), e(null), I(null);
2167
2266
  },
2168
- children: /* @__PURE__ */ a(re, { s: vn })
2267
+ children: /* @__PURE__ */ s(ue, { s: fn })
2169
2268
  }
2170
- ) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(Yn, { s: vn }) })
2269
+ ) : /* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ s(Bn, { s: fn }) })
2171
2270
  ]
2172
2271
  }
2173
2272
  ) : null,
2174
- R ? /* @__PURE__ */ Y(
2273
+ B ? /* @__PURE__ */ z(
2175
2274
  "div",
2176
2275
  {
2177
- ref: z,
2178
- className: `sa-calendar sa-calendar-size-${y} ${u ? "" : "sa-calendar-no-input"} ${b ? "" : "sa-calendar-no-padding"}`,
2179
- style: r ? { pointerEvents: "none" } : void 0,
2276
+ ref: $,
2277
+ className: `sa-calendar sa-calendar-size-${w} ${p ? "" : "sa-calendar-no-input"} ${b ? "" : "sa-calendar-no-padding"}`,
2278
+ style: l ? { pointerEvents: "none" } : void 0,
2180
2279
  children: [
2181
- /* @__PURE__ */ Y("div", { className: "sa-time-columns", children: [
2182
- /* @__PURE__ */ a(
2183
- hn,
2280
+ /* @__PURE__ */ z("div", { className: "sa-time-columns", children: [
2281
+ /* @__PURE__ */ s(
2282
+ vn,
2184
2283
  {
2185
2284
  label: "Jam",
2186
2285
  options: ln,
2187
- active: v,
2188
- onPick: P
2286
+ active: cn,
2287
+ onPick: en
2189
2288
  }
2190
2289
  ),
2191
- /* @__PURE__ */ a("div", { className: "sa-time-divider" }),
2192
- /* @__PURE__ */ a(
2193
- hn,
2290
+ /* @__PURE__ */ s("div", { className: "sa-time-divider" }),
2291
+ /* @__PURE__ */ s(
2292
+ vn,
2194
2293
  {
2195
2294
  label: "Menit",
2196
- options: bn,
2197
- active: (w == null ? void 0 : w.m) ?? null,
2198
- onPick: (p) => H({ m: p })
2295
+ options: dn,
2296
+ active: (m == null ? void 0 : m.m) ?? null,
2297
+ onPick: (t) => D({ m: t })
2199
2298
  }
2200
2299
  ),
2201
- o && /* @__PURE__ */ Y(fn, { children: [
2202
- /* @__PURE__ */ a("div", { className: "sa-time-divider" }),
2203
- /* @__PURE__ */ a(
2204
- hn,
2300
+ o && /* @__PURE__ */ z(yn, { children: [
2301
+ /* @__PURE__ */ s("div", { className: "sa-time-divider" }),
2302
+ /* @__PURE__ */ s(
2303
+ vn,
2205
2304
  {
2206
2305
  label: "Detik",
2207
- options: dn,
2208
- active: (w == null ? void 0 : w.s) ?? null,
2209
- onPick: (p) => H({ s: p })
2306
+ options: nn,
2307
+ active: (m == null ? void 0 : m.s) ?? null,
2308
+ onPick: (t) => D({ s: t })
2210
2309
  }
2211
2310
  )
2212
2311
  ] }),
2213
- t === "12h" && /* @__PURE__ */ Y(fn, { children: [
2214
- /* @__PURE__ */ a("div", { className: "sa-time-divider" }),
2215
- /* @__PURE__ */ a(
2216
- hn,
2312
+ a === "12h" && /* @__PURE__ */ z(yn, { children: [
2313
+ /* @__PURE__ */ s("div", { className: "sa-time-divider" }),
2314
+ /* @__PURE__ */ s(
2315
+ vn,
2217
2316
  {
2218
2317
  label: "",
2219
2318
  options: [
2220
2319
  { value: 0, label: "AM" },
2221
2320
  { value: 1, label: "PM" }
2222
2321
  ],
2223
- active: w == null ? null : G === "PM" ? 1 : 0,
2224
- onPick: (p) => q(p === 1 ? "PM" : "AM")
2322
+ active: m == null ? null : R === "PM" ? 1 : 0,
2323
+ onPick: (t) => un(t === 1 ? "PM" : "AM")
2225
2324
  }
2226
2325
  )
2227
2326
  ] })
2228
2327
  ] }),
2229
- /* @__PURE__ */ Y("div", { className: "sa-time-footer", children: [
2230
- /* @__PURE__ */ a(
2328
+ /* @__PURE__ */ z("div", { className: "sa-time-footer", children: [
2329
+ /* @__PURE__ */ s(
2231
2330
  "button",
2232
2331
  {
2233
2332
  type: "button",
2234
2333
  className: "sa-time-footer-btn",
2235
- onClick: X,
2334
+ onClick: pn,
2236
2335
  children: "Sekarang"
2237
2336
  }
2238
2337
  ),
2239
- /* @__PURE__ */ a(
2338
+ /* @__PURE__ */ s(
2240
2339
  "button",
2241
2340
  {
2242
2341
  type: "button",
2243
2342
  className: "sa-time-footer-btn sa-time-footer-btn-muted",
2244
2343
  onClick: () => {
2245
- e(null), O(null);
2344
+ e(null), I(null);
2246
2345
  },
2247
2346
  children: "Hapus"
2248
2347
  }
@@ -2254,25 +2353,25 @@ const te = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Yn = ({ s: n }) => /*
2254
2353
  ]
2255
2354
  }
2256
2355
  );
2257
- return /* @__PURE__ */ a(
2258
- Mn,
2356
+ return /* @__PURE__ */ s(
2357
+ Yn,
2259
2358
  {
2260
2359
  label: g,
2261
- labelPosition: i,
2262
- required: N,
2360
+ labelPosition: u,
2361
+ required: C,
2263
2362
  optional: T,
2264
- description: m,
2265
- helperText: x,
2266
- errorText: f,
2267
- fullWidth: C,
2268
- size: y,
2269
- children: In
2363
+ description: y,
2364
+ helperText: k,
2365
+ errorText: v,
2366
+ fullWidth: x,
2367
+ size: w,
2368
+ children: hn
2270
2369
  }
2271
2370
  );
2272
2371
  }
2273
2372
  );
2274
- se.displayName = "StarasiaTime";
2373
+ pe.displayName = "StarasiaTime";
2275
2374
  export {
2276
- ie as StarasiaDate,
2277
- se as StarasiaTime
2375
+ ge as StarasiaDate,
2376
+ pe as StarasiaTime
2278
2377
  };