@starasia/date 5.4.2 → 5.6.0

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