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