@starasia/date 5.3.0 → 5.3.2

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.
@@ -9,6 +9,7 @@ export interface IFieldWrapperProps {
9
9
  helperText?: string;
10
10
  errorText?: string;
11
11
  fullWidth?: boolean;
12
+ size?: "xs" | "sm" | "md" | "lg";
12
13
  children: ReactNode;
13
14
  }
14
15
  export declare const FieldWrapper: React.FC<IFieldWrapperProps>;
package/dist/date.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs as $, jsx as a, Fragment as en } from "react/jsx-runtime";
2
- import { useState as A, useRef as J, useEffect as B, forwardRef as K } from "react";
3
- const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
2
+ import { useState as A, useRef as P, useEffect as B, forwardRef as K } from "react";
3
+ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
4
4
 
5
5
  * {
6
6
  margin: 0;
@@ -68,14 +68,19 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
68
68
  .sa-date-field-label-row {
69
69
  display: flex;
70
70
  align-items: center;
71
- gap: 6px;
71
+ gap: 4px;
72
72
  flex-wrap: wrap;
73
73
  }
74
74
  .sa-date-field-label-text {
75
75
  font-size: 14px;
76
76
  font-weight: 500;
77
77
  color: var(--sa-date-text-primary);
78
- line-height: 1.3;
78
+ line-height: normal;
79
+ }
80
+ /* match Input: xs/sm label drops to 12px */
81
+ .sa-date-field-size-xs .sa-date-field-label-text,
82
+ .sa-date-field-size-sm .sa-date-field-label-text {
83
+ font-size: 12px;
79
84
  }
80
85
  .sa-date-field-required {
81
86
  font-size: 14px;
@@ -83,6 +88,10 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
83
88
  color: var(--sa-date-border-error);
84
89
  line-height: 1;
85
90
  }
91
+ .sa-date-field-size-xs .sa-date-field-required,
92
+ .sa-date-field-size-sm .sa-date-field-required {
93
+ font-size: 12px;
94
+ }
86
95
  .sa-date-field-optional-badge {
87
96
  display: inline-flex;
88
97
  align-items: center;
@@ -581,7 +590,7 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
581
590
  width: 32px;
582
591
  height: 32px;
583
592
  }
584
- `, an = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], W = [
593
+ `, an = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], R = [
585
594
  "January",
586
595
  "February",
587
596
  "March",
@@ -609,7 +618,7 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
609
618
  "Dec"
610
619
  ];
611
620
  function rn(e) {
612
- const [n, t] = A(e), o = J(null), l = (u) => {
621
+ const [n, t] = A(e), o = P(null), l = (u) => {
613
622
  o.current && !o.current.contains(u.target) && t(!1);
614
623
  };
615
624
  return B(() => (document.addEventListener("click", l, !0), () => {
@@ -622,8 +631,8 @@ const Q = "sa-calendar-input-styles", dn = (e) => {
622
631
  n.id = Q, n.textContent = e, document.head.appendChild(n);
623
632
  }
624
633
  };
625
- dn(R);
626
- const O = (e) => {
634
+ dn(J);
635
+ const W = (e) => {
627
636
  if (e === "xs")
628
637
  return 14;
629
638
  if (e === "sm")
@@ -640,23 +649,23 @@ const O = (e) => {
640
649
  clearable: l,
641
650
  onClear: u,
642
651
  ...i
643
- } = e, g = J(null), f = () => {
644
- g.current && i.onClick && (g.current.focus(), i.onClick(""));
645
- }, r = t === "disable" || i.disabled, d = !!i.value, w = l && d && !r, M = (k) => {
646
- k.stopPropagation(), u == null || u();
652
+ } = e, f = P(null), g = () => {
653
+ f.current && i.onClick && (f.current.focus(), i.onClick(""));
654
+ }, r = t === "disable" || i.disabled, d = !!i.value, v = l && d && !r, w = (M) => {
655
+ M.stopPropagation(), u == null || u();
647
656
  };
648
657
  return /* @__PURE__ */ $(
649
658
  "div",
650
659
  {
651
660
  className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${n} `,
652
- onClick: f,
661
+ onClick: g,
653
662
  children: [
654
663
  /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
655
664
  "svg",
656
665
  {
657
666
  xmlns: "http://www.w3.org/2000/svg",
658
- width: O(n),
659
- height: O(n),
667
+ width: W(n),
668
+ height: W(n),
660
669
  viewBox: "0 0 20 20",
661
670
  fill: "none",
662
671
  children: /* @__PURE__ */ a(
@@ -678,22 +687,22 @@ const O = (e) => {
678
687
  ...i,
679
688
  disabled: r,
680
689
  value: i.value,
681
- ref: g
690
+ ref: f
682
691
  }
683
692
  ) }),
684
- w ? /* @__PURE__ */ a(
693
+ v ? /* @__PURE__ */ a(
685
694
  "button",
686
695
  {
687
696
  type: "button",
688
697
  "aria-label": "Clear date",
689
698
  className: "sa-calendar-input-clear",
690
- onClick: M,
699
+ onClick: w,
691
700
  children: /* @__PURE__ */ a(
692
701
  "svg",
693
702
  {
694
703
  xmlns: "http://www.w3.org/2000/svg",
695
- width: O(n),
696
- height: O(n),
704
+ width: W(n),
705
+ height: W(n),
697
706
  viewBox: "0 0 20 20",
698
707
  fill: "none",
699
708
  children: /* @__PURE__ */ a(
@@ -713,8 +722,8 @@ const O = (e) => {
713
722
  "svg",
714
723
  {
715
724
  xmlns: "http://www.w3.org/2000/svg",
716
- width: O(n),
717
- height: O(n),
725
+ width: W(n),
726
+ height: W(n),
718
727
  viewBox: "0 0 20 20",
719
728
  fill: "none",
720
729
  children: /* @__PURE__ */ a(
@@ -740,27 +749,27 @@ const O = (e) => {
740
749
  onChange: l,
741
750
  minDate: u,
742
751
  maxDate: i,
743
- input: g
752
+ input: f
744
753
  }) => {
745
- var z, c, y;
746
- const [f, r] = A(null);
747
- let d = new Date(e.getFullYear(), e.getMonth(), 1), w = d.getDay(), M = [];
748
- const k = e.getMonth(), N = (/* @__PURE__ */ new Date()).toDateString(), m = !!(t.from && !t.to), h = m && f ? f : null;
754
+ var N, c, y;
755
+ const [g, r] = A(null);
756
+ let d = new Date(e.getFullYear(), e.getMonth(), 1), v = d.getDay(), w = [];
757
+ const M = e.getMonth(), C = (/* @__PURE__ */ new Date()).toDateString(), m = !!(t.from && !t.to), h = m && g ? g : null;
749
758
  for (let p = 0; p < 42; p++) {
750
- p === 0 && w === 0 ? d.setDate(d.getDate() - 7) : p === 0 ? d.setDate(
751
- d.getDate() + (p - w)
759
+ p === 0 && v === 0 ? d.setDate(d.getDate() - 7) : p === 0 ? d.setDate(
760
+ d.getDate() + (p - v)
752
761
  ) : d.setDate(d.getDate() + 1);
753
762
  let b = {
754
- currentMonth: d.getMonth() === k,
763
+ currentMonth: d.getMonth() === M,
755
764
  date: new Date(d),
756
765
  month: d.getMonth(),
757
766
  number: d.getDate(),
758
- selected: d.toDateString() === ((z = t.from) == null ? void 0 : z.toDateString()) || d.toDateString() === (((c = t.to) == null ? void 0 : c.toDateString()) || ((y = t.from) == null ? void 0 : y.toDateString())),
759
- isToday: d.toDateString() === N,
767
+ selected: d.toDateString() === ((N = t.from) == null ? void 0 : N.toDateString()) || d.toDateString() === (((c = t.to) == null ? void 0 : c.toDateString()) || ((y = t.from) == null ? void 0 : y.toDateString())),
768
+ isToday: d.toDateString() === C,
760
769
  year: d.getFullYear(),
761
770
  isDisabled: u && d < u || i && d > i
762
771
  };
763
- M.push(b);
772
+ w.push(b);
764
773
  }
765
774
  const s = (p) => {
766
775
  n(p);
@@ -783,13 +792,13 @@ const O = (e) => {
783
792
  onMouseLeave: () => r(null),
784
793
  children: [
785
794
  /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: an.map((p, b) => /* @__PURE__ */ a("p", { children: p }, b)) }),
786
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((p, b) => {
795
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: w.map((p, b) => {
787
796
  const E = t.from && t.to && p.date.getTime() > t.from.getTime() && p.date.getTime() < t.to.getTime(), S = (() => {
788
797
  if (!h || !t.from)
789
798
  return !1;
790
- const Y = p.date.getTime(), C = t.from.getTime(), L = h.getTime();
791
- return L > C ? Y > C && Y < L : Y < C && Y > L;
792
- })(), D = m && f && p.date.toDateString() === f.toDateString(), F = p.isDisabled, I = () => E || S ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", T = () => F ? "var(--sa-color-gray-400, #b7b9be)" : E || S ? "var(--sa-color-gray-500, #8c8f97)" : "";
799
+ const Y = p.date.getTime(), z = t.from.getTime(), L = h.getTime();
800
+ return L > z ? Y > z && Y < L : Y < z && Y > L;
801
+ })(), D = m && g && p.date.toDateString() === g.toDateString(), F = p.isDisabled, I = () => E || S ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", T = () => F ? "var(--sa-color-gray-400, #b7b9be)" : E || S ? "var(--sa-color-gray-500, #8c8f97)" : "";
793
802
  return /* @__PURE__ */ a(
794
803
  "p",
795
804
  {
@@ -800,7 +809,7 @@ const O = (e) => {
800
809
  cursor: F ? "not-allowed" : "pointer",
801
810
  color: T(),
802
811
  opacity: D && !p.selected ? 0.75 : 1,
803
- ...g ? {} : { width: "100%" }
812
+ ...f ? {} : { width: "100%" }
804
813
  },
805
814
  onClick: () => {
806
815
  F || (s(p.date), x(p.date));
@@ -824,14 +833,14 @@ const O = (e) => {
824
833
  dateRange: l,
825
834
  setDateRange: u,
826
835
  onChange: i,
827
- minDate: g,
828
- maxDate: f,
836
+ minDate: f,
837
+ maxDate: g,
829
838
  input: r
830
839
  }) => {
831
- var N;
832
- const d = (N = l.from) == null ? void 0 : N.getFullYear(), w = e.getFullYear(), M = (m) => {
833
- t ? (k(m), n(m)) : (o("days"), n(m));
834
- }, k = (m) => {
840
+ var C;
841
+ const d = (C = l.from) == null ? void 0 : C.getFullYear(), v = e.getFullYear(), w = (m) => {
842
+ t ? (M(m), n(m)) : (o("days"), n(m));
843
+ }, M = (m) => {
835
844
  let h = { ...l };
836
845
  if (h.from && h.to)
837
846
  h = { from: m, to: null };
@@ -843,13 +852,13 @@ const O = (e) => {
843
852
  }
844
853
  u(h), i(h);
845
854
  };
846
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((m, h) => {
847
- var z, c, y;
848
- const s = l.from != null && new Date(w, h).getTime() > l.from.getTime() && new Date(w, h).getTime() < (((z = l.to) == null ? void 0 : z.getTime()) || l.from.getTime()), x = g && new Date(w, h) < g || f && new Date(w, h) > f;
855
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: R.map((m, h) => {
856
+ var N, c, y;
857
+ const s = l.from != null && new Date(v, h).getTime() > l.from.getTime() && new Date(v, h).getTime() < (((N = l.to) == null ? void 0 : N.getTime()) || l.from.getTime()), x = f && new Date(v, h) < f || g && new Date(v, h) > g;
849
858
  return /* @__PURE__ */ a(
850
859
  "p",
851
860
  {
852
- className: d === w && (h === ((c = l.from) == null ? void 0 : c.getMonth()) || h === ((y = l.to) == null ? void 0 : y.getMonth())) ? "sa-calendar-months-active" : "",
861
+ className: d === v && (h === ((c = l.from) == null ? void 0 : c.getMonth()) || h === ((y = l.to) == null ? void 0 : y.getMonth())) ? "sa-calendar-months-active" : "",
853
862
  style: {
854
863
  backgroundColor: s ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
855
864
  pointerEvents: x ? "none" : void 0,
@@ -858,14 +867,14 @@ const O = (e) => {
858
867
  ...r ? {} : { width: "100%" }
859
868
  },
860
869
  onClick: () => {
861
- x || M(new Date(w, h));
870
+ x || w(new Date(v, h));
862
871
  },
863
872
  children: m.slice(0, 3)
864
873
  },
865
874
  h
866
875
  );
867
876
  }) });
868
- }, q = (e) => {
877
+ }, U = (e) => {
869
878
  const n = Math.floor(e / 10) * 10, t = n + 10;
870
879
  return { start: n, end: t };
871
880
  }, hn = ({
@@ -876,15 +885,15 @@ const O = (e) => {
876
885
  dateRange: l,
877
886
  setDateRange: u,
878
887
  onChange: i,
879
- minDate: g,
880
- maxDate: f,
888
+ minDate: f,
889
+ maxDate: g,
881
890
  input: r
882
891
  }) => {
883
- var x, z;
892
+ var x, N;
884
893
  let d = [];
885
- const w = e.getFullYear(), { start: M, end: k } = q(w), N = (x = l.from) == null ? void 0 : x.getFullYear(), m = (z = l.to) == null ? void 0 : z.getFullYear();
886
- for (let c = M; c < k; c++) {
887
- const y = new Date(c, 0), p = (!g || y >= g) && (!f || y <= f), b = N != null && c === N || m != null && c === m, E = l.from != null && l.to != null && y > l.from && y < l.to;
894
+ const v = e.getFullYear(), { start: w, end: M } = U(v), C = (x = l.from) == null ? void 0 : x.getFullYear(), m = (N = l.to) == null ? void 0 : N.getFullYear();
895
+ for (let c = w; c < M; c++) {
896
+ const y = new Date(c, 0), p = (!f || y >= f) && (!g || y <= g), b = C != null && c === C || m != null && c === m, E = l.from != null && l.to != null && y > l.from && y < l.to;
888
897
  d.push({
889
898
  year: c,
890
899
  active: b && p,
@@ -964,7 +973,7 @@ const O = (e) => {
964
973
  }
965
974
  )
966
975
  }
967
- ), gn = ({
976
+ ), fn = ({
968
977
  setViews: e,
969
978
  views: n,
970
979
  filter: t,
@@ -983,7 +992,7 @@ const O = (e) => {
983
992
  return;
984
993
  }
985
994
  l((r) => new Date(r.getFullYear(), r.getMonth() + 1));
986
- }, g = () => {
995
+ }, f = () => {
987
996
  if (n === "years") {
988
997
  l((r) => new Date(r.getFullYear() - 10, 0));
989
998
  return;
@@ -1002,19 +1011,19 @@ const O = (e) => {
1002
1011
  return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1003
1012
  /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
1004
1013
  if (n === "days")
1005
- return `${W[o.getMonth()]} ${o.getFullYear()}`;
1014
+ return `${R[o.getMonth()]} ${o.getFullYear()}`;
1006
1015
  if (n === "months")
1007
1016
  return `${o.getFullYear()}`;
1008
1017
  if (n === "years")
1009
- return `${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`;
1018
+ return `${U(o.getFullYear()).start} ~ ${U(o.getFullYear()).end}`;
1010
1019
  })() }),
1011
1020
  /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
1012
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(tn, {}) }),
1021
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: f, children: /* @__PURE__ */ a(tn, {}) }),
1013
1022
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ a(sn, {}) })
1014
1023
  ] })
1015
1024
  ] });
1016
1025
  };
1017
- function P(e) {
1026
+ function H(e) {
1018
1027
  const n = new Date(e), t = n.getFullYear(), o = n.getMonth();
1019
1028
  return `${n.getDate().toString().padStart(2, "0")} ${ln[o]} ${t}`;
1020
1029
  }
@@ -1026,13 +1035,15 @@ const on = ({
1026
1035
  description: l,
1027
1036
  helperText: u,
1028
1037
  errorText: i,
1029
- fullWidth: g,
1030
- children: f
1038
+ fullWidth: f,
1039
+ size: g = "sm",
1040
+ children: r
1031
1041
  }) => {
1032
- const r = [
1042
+ const d = [
1033
1043
  "sa-date-field",
1034
- g ? "sa-date-field-fullwidth" : ""
1035
- ].filter(Boolean).join(" "), d = e ? /* @__PURE__ */ $("div", { className: "sa-date-field-label-row", children: [
1044
+ `sa-date-field-size-${g}`,
1045
+ f ? "sa-date-field-fullwidth" : ""
1046
+ ].filter(Boolean).join(" "), v = e ? /* @__PURE__ */ $("div", { className: "sa-date-field-label-row", children: [
1036
1047
  /* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: e }),
1037
1048
  o && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
1038
1049
  t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
@@ -1040,32 +1051,32 @@ const on = ({
1040
1051
  u && !i && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: u }),
1041
1052
  i && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: i })
1042
1053
  ] });
1043
- return e ? n === "outside-left" ? /* @__PURE__ */ $("div", { className: `${r} sa-date-field-left`, children: [
1054
+ return e ? n === "outside-left" ? /* @__PURE__ */ $("div", { className: `${d} sa-date-field-left`, children: [
1044
1055
  /* @__PURE__ */ $("div", { className: "sa-date-field-left-label", children: [
1045
- d,
1056
+ v,
1046
1057
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l })
1047
1058
  ] }),
1048
1059
  /* @__PURE__ */ $("div", { className: "sa-date-field-input-wrap", children: [
1049
- f,
1060
+ r,
1050
1061
  w
1051
1062
  ] })
1052
- ] }) : /* @__PURE__ */ $("div", { className: r, children: [
1053
- d,
1063
+ ] }) : /* @__PURE__ */ $("div", { className: d, children: [
1064
+ v,
1054
1065
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
1055
- f,
1066
+ r,
1056
1067
  w
1057
- ] }) : /* @__PURE__ */ $("div", { className: r, children: [
1068
+ ] }) : /* @__PURE__ */ $("div", { className: d, children: [
1058
1069
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
1059
- f,
1070
+ r,
1060
1071
  w
1061
1072
  ] });
1062
- }, X = "sa-calendar-styles", fn = (e) => {
1073
+ }, X = "sa-calendar-styles", gn = (e) => {
1063
1074
  if (!document.getElementById(X)) {
1064
1075
  const n = document.createElement("style");
1065
1076
  n.id = X, n.textContent = e, document.head.appendChild(n);
1066
1077
  }
1067
1078
  };
1068
- fn(R);
1079
+ gn(J);
1069
1080
  const mn = K(
1070
1081
  ({
1071
1082
  value: e,
@@ -1075,29 +1086,29 @@ const mn = K(
1075
1086
  disabled: l,
1076
1087
  minDate: u,
1077
1088
  maxDate: i,
1078
- placeholder: g,
1079
- size: f = "sm",
1089
+ placeholder: f,
1090
+ size: g = "sm",
1080
1091
  variant: r,
1081
1092
  status: d,
1082
- clearable: w,
1083
- fullWidth: M = !0,
1084
- withPadding: k = !0,
1085
- label: N,
1093
+ clearable: v,
1094
+ fullWidth: w = !0,
1095
+ withPadding: M = !0,
1096
+ label: C,
1086
1097
  labelPosition: m,
1087
1098
  required: h,
1088
1099
  optional: s,
1089
1100
  description: x,
1090
- helperText: z,
1101
+ helperText: N,
1091
1102
  errorText: c
1092
1103
  }, y) => {
1093
- const p = c ? "error" : d, { ref: b, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), D = J(null), [F, I] = A("days"), [T, Y] = A(/* @__PURE__ */ new Date()), [C, L] = A({
1104
+ const p = c ? "error" : d, { ref: b, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), D = P(null), [F, I] = A("days"), [T, Y] = A(/* @__PURE__ */ new Date()), [z, L] = A({
1094
1105
  from: (e == null ? void 0 : e.from) ?? null,
1095
1106
  to: (e == null ? void 0 : e.to) ?? null
1096
1107
  });
1097
1108
  B(() => {
1098
1109
  if (e) {
1099
- const v = e;
1100
- v.from && Y(v.from), L(v);
1110
+ const k = e;
1111
+ k.from && Y(k.from), L(k);
1101
1112
  } else
1102
1113
  Y(/* @__PURE__ */ new Date()), L({ from: null, to: null });
1103
1114
  }, [e]), B(() => {
@@ -1107,34 +1118,31 @@ const mn = K(
1107
1118
  }, [E]), B(() => {
1108
1119
  o || S(!0);
1109
1120
  }, [o]);
1110
- const G = () => {
1111
- var v, V;
1121
+ const q = () => {
1122
+ var k, V;
1112
1123
  if (!e)
1113
1124
  return "";
1114
1125
  if (t) {
1115
1126
  if (F === "days")
1116
- return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
1127
+ return `${H(z.from)} ~ ${H(z.to || z.from) || "-"}`;
1117
1128
  if (F === "months")
1118
- return `${W[C.from.getMonth()]} ~ ${C.to ? W[C.to.getMonth()] : "-"}`;
1129
+ return `${R[z.from.getMonth()]} ~ ${z.to ? R[z.to.getMonth()] : "-"}`;
1119
1130
  if (F === "years")
1120
- return `${(v = C.from) == null ? void 0 : v.getFullYear()} ~ ${((V = C.to) == null ? void 0 : V.getFullYear()) || "-"}`;
1131
+ return `${(k = z.from) == null ? void 0 : k.getFullYear()} ~ ${((V = z.to) == null ? void 0 : V.getFullYear()) || "-"}`;
1121
1132
  } else
1122
- return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
1133
+ return `${H(z.from)} ~ ${H(z.to || z.from) || "-"}`;
1123
1134
  }, j = () => {
1124
1135
  if (D.current && b.current && o) {
1125
- const v = b.current.getBoundingClientRect(), V = D.current.getBoundingClientRect();
1126
- window.innerWidth < v.left + V.width ? D.current.style.left = `${v.left - V.width + v.width}px` : D.current.style.left = `${v.left}px`, v.top + V.height > window.innerHeight ? D.current.style.top = `${v.y - (v.height + V.height - 28)}px` : D.current.style.top = `${v.y + v.height}px`;
1136
+ const k = b.current.getBoundingClientRect(), V = D.current.getBoundingClientRect();
1137
+ window.innerWidth < k.left + V.width ? D.current.style.left = `${k.left - V.width + k.width}px` : D.current.style.left = `${k.left}px`, k.top + V.height > window.innerHeight ? D.current.style.top = `${k.y - (k.height + V.height - 28)}px` : D.current.style.top = `${k.y + k.height}px`;
1127
1138
  }
1128
1139
  };
1129
1140
  B(() => {
1130
1141
  D.current && b.current && o && j();
1131
- }, [D, b, E]), B(() => {
1132
- const v = y == null ? void 0 : y.current;
1133
- return v && v.addEventListener("scroll", j), window.addEventListener("scroll", j), () => {
1134
- v && v.removeEventListener("scroll", j), window.removeEventListener("scroll", j);
1135
- };
1136
- }, []);
1137
- const U = /* @__PURE__ */ $(
1142
+ }, [D, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1143
+ window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1144
+ }), []);
1145
+ const G = /* @__PURE__ */ $(
1138
1146
  "div",
1139
1147
  {
1140
1148
  className: "sa-calendar-wrapper",
@@ -1144,7 +1152,7 @@ const mn = K(
1144
1152
  o ? /* @__PURE__ */ a(
1145
1153
  cn,
1146
1154
  {
1147
- value: G(),
1155
+ value: q(),
1148
1156
  inputMode: "none",
1149
1157
  onClick: () => {
1150
1158
  S(!0);
@@ -1152,23 +1160,23 @@ const mn = K(
1152
1160
  onChange: () => {
1153
1161
  },
1154
1162
  disabled: l,
1155
- placeholder: g,
1156
- size: f,
1163
+ placeholder: f,
1164
+ size: g,
1157
1165
  variant: r,
1158
1166
  status: p,
1159
- clearable: w,
1167
+ clearable: v,
1160
1168
  onClear: () => n(void 0)
1161
1169
  }
1162
1170
  ) : null,
1163
1171
  E ? /* @__PURE__ */ $(
1164
1172
  "div",
1165
1173
  {
1166
- className: `sa-calendar sa-calendar-size-${f || "sm"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
1174
+ className: `sa-calendar sa-calendar-size-${g || "sm"} ${o ? "" : "sa-calendar-no-input"} ${M ? "" : "sa-calendar-no-padding"}`,
1167
1175
  style: l ? { pointerEvents: "none" } : void 0,
1168
1176
  ref: D,
1169
1177
  children: [
1170
1178
  /* @__PURE__ */ a(
1171
- gn,
1179
+ fn,
1172
1180
  {
1173
1181
  setViews: I,
1174
1182
  views: F,
@@ -1183,7 +1191,7 @@ const mn = K(
1183
1191
  date: T,
1184
1192
  setDate: Y,
1185
1193
  setIsComponentVisible: S,
1186
- dateRange: C,
1194
+ dateRange: z,
1187
1195
  setDateRange: L,
1188
1196
  input: o,
1189
1197
  onChange: n,
@@ -1197,7 +1205,7 @@ const mn = K(
1197
1205
  setDate: Y,
1198
1206
  filter: t,
1199
1207
  setViews: I,
1200
- dateRange: C,
1208
+ dateRange: z,
1201
1209
  setDateRange: L,
1202
1210
  setIsComponentVisible: S,
1203
1211
  input: o,
@@ -1212,7 +1220,7 @@ const mn = K(
1212
1220
  setDate: Y,
1213
1221
  filter: t,
1214
1222
  setViews: I,
1215
- dateRange: C,
1223
+ dateRange: z,
1216
1224
  setDateRange: L,
1217
1225
  setIsComponentVisible: S,
1218
1226
  input: o,
@@ -1230,15 +1238,16 @@ const mn = K(
1230
1238
  return /* @__PURE__ */ a(
1231
1239
  on,
1232
1240
  {
1233
- label: N,
1241
+ label: C,
1234
1242
  labelPosition: m,
1235
1243
  required: h,
1236
1244
  optional: s,
1237
1245
  description: x,
1238
- helperText: z,
1246
+ helperText: N,
1239
1247
  errorText: c,
1240
- fullWidth: M,
1241
- children: U
1248
+ fullWidth: w,
1249
+ size: g,
1250
+ children: G
1242
1251
  }
1243
1252
  );
1244
1253
  }
@@ -1248,8 +1257,8 @@ const mn = K(
1248
1257
  n.id = _, n.textContent = e, document.head.appendChild(n);
1249
1258
  }
1250
1259
  };
1251
- bn(R);
1252
- const H = (e) => {
1260
+ bn(J);
1261
+ const O = (e) => {
1253
1262
  if (e === "xs")
1254
1263
  return 14;
1255
1264
  if (e === "sm")
@@ -1266,23 +1275,23 @@ const H = (e) => {
1266
1275
  clearable: l,
1267
1276
  onClear: u,
1268
1277
  ...i
1269
- } = e, g = J(null), f = () => {
1270
- g.current && i.onClick && (g.current.focus(), i.onClick(""));
1271
- }, r = t === "disable" || i.disabled, d = !!i.value, w = l && d && !r, M = (k) => {
1272
- k.stopPropagation(), u == null || u();
1278
+ } = e, f = P(null), g = () => {
1279
+ f.current && i.onClick && (f.current.focus(), i.onClick(""));
1280
+ }, r = t === "disable" || i.disabled, d = !!i.value, v = l && d && !r, w = (M) => {
1281
+ M.stopPropagation(), u == null || u();
1273
1282
  };
1274
1283
  return /* @__PURE__ */ $(
1275
1284
  "div",
1276
1285
  {
1277
1286
  className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${n} `,
1278
- onClick: f,
1287
+ onClick: g,
1279
1288
  children: [
1280
1289
  /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
1281
1290
  "svg",
1282
1291
  {
1283
1292
  xmlns: "http://www.w3.org/2000/svg",
1284
- width: H(n),
1285
- height: H(n),
1293
+ width: O(n),
1294
+ height: O(n),
1286
1295
  viewBox: "0 0 20 20",
1287
1296
  fill: "none",
1288
1297
  children: /* @__PURE__ */ a(
@@ -1304,22 +1313,22 @@ const H = (e) => {
1304
1313
  ...i,
1305
1314
  disabled: r,
1306
1315
  value: i.value,
1307
- ref: g
1316
+ ref: f
1308
1317
  }
1309
1318
  ) }),
1310
- w ? /* @__PURE__ */ a(
1319
+ v ? /* @__PURE__ */ a(
1311
1320
  "button",
1312
1321
  {
1313
1322
  type: "button",
1314
1323
  "aria-label": "Clear date",
1315
1324
  className: "sa-calendar-input-clear",
1316
- onClick: M,
1325
+ onClick: w,
1317
1326
  children: /* @__PURE__ */ a(
1318
1327
  "svg",
1319
1328
  {
1320
1329
  xmlns: "http://www.w3.org/2000/svg",
1321
- width: H(n),
1322
- height: H(n),
1330
+ width: O(n),
1331
+ height: O(n),
1323
1332
  viewBox: "0 0 20 20",
1324
1333
  fill: "none",
1325
1334
  children: /* @__PURE__ */ a(
@@ -1339,8 +1348,8 @@ const H = (e) => {
1339
1348
  "svg",
1340
1349
  {
1341
1350
  xmlns: "http://www.w3.org/2000/svg",
1342
- width: H(n),
1343
- height: H(n),
1351
+ width: O(n),
1352
+ height: O(n),
1344
1353
  viewBox: "0 0 20 20",
1345
1354
  fill: "none",
1346
1355
  children: /* @__PURE__ */ a(
@@ -1366,51 +1375,51 @@ const H = (e) => {
1366
1375
  setIsComponentVisible: l,
1367
1376
  minDate: u,
1368
1377
  maxDate: i,
1369
- input: g,
1370
- onChange: f,
1378
+ input: f,
1379
+ onChange: g,
1371
1380
  hasValue: r
1372
1381
  }) => {
1373
1382
  let d = new Date(
1374
1383
  t.getFullYear(),
1375
1384
  t.getMonth(),
1376
1385
  1
1377
- ), w = d.getDay(), M = [];
1378
- const k = e.toDateString(), N = (/* @__PURE__ */ new Date()).toDateString(), m = t.getMonth();
1386
+ ), v = d.getDay(), w = [];
1387
+ const M = e.toDateString(), C = (/* @__PURE__ */ new Date()).toDateString(), m = t.getMonth();
1379
1388
  for (let s = 0; s < 42; s++) {
1380
- s === 0 && w === 0 ? d.setDate(d.getDate() - 7) : s === 0 ? d.setDate(
1381
- d.getDate() + (s - w)
1389
+ s === 0 && v === 0 ? d.setDate(d.getDate() - 7) : s === 0 ? d.setDate(
1390
+ d.getDate() + (s - v)
1382
1391
  ) : d.setDate(d.getDate() + 1);
1383
1392
  let x = {
1384
1393
  currentMonth: d.getMonth() === m,
1385
1394
  date: new Date(d),
1386
1395
  month: d.getMonth(),
1387
1396
  number: d.getDate(),
1388
- selected: r && d.toDateString() === k,
1389
- isToday: d.toDateString() === N,
1397
+ selected: r && d.toDateString() === M,
1398
+ isToday: d.toDateString() === C,
1390
1399
  year: d.getFullYear(),
1391
1400
  isDisabled: u && d < u || i && d > i
1392
1401
  };
1393
- M.push(x);
1402
+ w.push(x);
1394
1403
  }
1395
1404
  const h = (s) => {
1396
- (!u || s >= u) && (!i || s <= i) && (n(s), f(s), o(s), g && l(!1));
1405
+ (!u || s >= u) && (!i || s <= i) && (n(s), g(s), o(s), f && l(!1));
1397
1406
  };
1398
1407
  return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
1399
1408
  /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: an.map((s, x) => /* @__PURE__ */ a("p", { children: s }, x)) }),
1400
- /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((s, x) => {
1401
- const z = s.isDisabled;
1409
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: w.map((s, x) => {
1410
+ const N = s.isDisabled;
1402
1411
  return /* @__PURE__ */ a(
1403
1412
  "p",
1404
1413
  {
1405
1414
  className: `${s.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${s.selected ? "sa-calendar-days-active" : ""} ${s.isToday && !s.selected ? "sa-calendar-days-today" : ""}`,
1406
1415
  style: {
1407
- color: z ? "#ccc" : void 0,
1408
- pointerEvents: z ? "none" : void 0,
1409
- cursor: z ? "not-allowed" : "pointer",
1410
- ...g ? {} : { width: "100%" }
1416
+ color: N ? "#ccc" : void 0,
1417
+ pointerEvents: N ? "none" : void 0,
1418
+ cursor: N ? "not-allowed" : "pointer",
1419
+ ...f ? {} : { width: "100%" }
1411
1420
  },
1412
1421
  onClick: () => {
1413
- z || h(s.date);
1422
+ N || h(s.date);
1414
1423
  },
1415
1424
  children: s.number
1416
1425
  },
@@ -1426,20 +1435,20 @@ const H = (e) => {
1426
1435
  onChange: l,
1427
1436
  previewDate: u,
1428
1437
  setPreviewDate: i,
1429
- minDate: g,
1430
- maxDate: f,
1438
+ minDate: f,
1439
+ maxDate: g,
1431
1440
  input: r,
1432
1441
  hasValue: d
1433
1442
  }) => {
1434
- const w = e.getMonth(), M = e.getFullYear(), k = u.getFullYear(), N = (m) => {
1435
- (!g || m >= g) && (!f || m <= f) && (t ? (l(m), n(m), i(m)) : (o("days"), i(m)));
1443
+ const v = e.getMonth(), w = e.getFullYear(), M = u.getFullYear(), C = (m) => {
1444
+ (!f || m >= f) && (!g || m <= g) && (t ? (l(m), n(m), i(m)) : (o("days"), i(m)));
1436
1445
  };
1437
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((m, h) => {
1438
- const s = g && new Date(k, h, 1) < g || f && new Date(k, h + 1, 0) > f;
1446
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: R.map((m, h) => {
1447
+ const s = f && new Date(M, h, 1) < f || g && new Date(M, h + 1, 0) > g;
1439
1448
  return /* @__PURE__ */ a(
1440
1449
  "p",
1441
1450
  {
1442
- className: d && h === w && k === M ? "sa-calendar-months-active" : "",
1451
+ className: d && h === v && M === w ? "sa-calendar-months-active" : "",
1443
1452
  style: {
1444
1453
  color: s ? "#ccc" : void 0,
1445
1454
  pointerEvents: s ? "none" : void 0,
@@ -1447,7 +1456,7 @@ const H = (e) => {
1447
1456
  ...r ? {} : { width: "100%" }
1448
1457
  },
1449
1458
  onClick: () => {
1450
- s || N(new Date(k, h));
1459
+ s || C(new Date(M, h));
1451
1460
  },
1452
1461
  children: m.slice(0, 3)
1453
1462
  },
@@ -1465,25 +1474,25 @@ const H = (e) => {
1465
1474
  onChange: l,
1466
1475
  previewDate: u,
1467
1476
  setPreviewDate: i,
1468
- minDate: g,
1469
- maxDate: f,
1477
+ minDate: f,
1478
+ maxDate: g,
1470
1479
  input: r,
1471
1480
  hasValue: d
1472
1481
  }) => {
1473
- let w = [];
1474
- const M = u.getFullYear(), { start: k, end: N } = Z(M), m = e.getFullYear();
1475
- for (let s = k; s < N; s++) {
1476
- let x = g && new Date(s, 0, 1) < g || f && new Date(s, 11, 31) > f;
1477
- w.push({
1482
+ let v = [];
1483
+ const w = u.getFullYear(), { start: M, end: C } = Z(w), m = e.getFullYear();
1484
+ for (let s = M; s < C; s++) {
1485
+ let x = f && new Date(s, 0, 1) < f || g && new Date(s, 11, 31) > g;
1486
+ v.push({
1478
1487
  year: s,
1479
1488
  active: !!d && s === m,
1480
1489
  isDisabled: x
1481
1490
  });
1482
1491
  }
1483
1492
  const h = (s) => {
1484
- (!g || s >= g) && (!f || s <= f) && (n ? (l(s), o(s), i(s)) : (t("months"), i(s)));
1493
+ (!f || s >= f) && (!g || s <= g) && (n ? (l(s), o(s), i(s)) : (t("months"), i(s)));
1485
1494
  };
1486
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: w.map((s, x) => /* @__PURE__ */ a(
1495
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: v.map((s, x) => /* @__PURE__ */ a(
1487
1496
  "p",
1488
1497
  {
1489
1498
  className: s.active ? "sa-calendar-months-active" : "",
@@ -1521,7 +1530,7 @@ const H = (e) => {
1521
1530
  return;
1522
1531
  }
1523
1532
  l((r) => new Date(r.getFullYear(), r.getMonth() + 1));
1524
- }, g = () => {
1533
+ }, f = () => {
1525
1534
  if (n === "years") {
1526
1535
  l((r) => new Date(r.getFullYear() - 10, 0));
1527
1536
  return;
@@ -1542,14 +1551,14 @@ const H = (e) => {
1542
1551
  return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1543
1552
  /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
1544
1553
  if (n === "days")
1545
- return `${W[o.getMonth()]} ${o.getFullYear()}`;
1554
+ return `${R[o.getMonth()]} ${o.getFullYear()}`;
1546
1555
  if (n === "months")
1547
1556
  return `${o.getFullYear()}`;
1548
1557
  if (n === "years")
1549
1558
  return `${Z(o.getFullYear()).start} ~ ${Z(o.getFullYear()).end}`;
1550
1559
  })() }),
1551
1560
  /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
1552
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(tn, {}) }),
1561
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: f, children: /* @__PURE__ */ a(tn, {}) }),
1553
1562
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ a(sn, {}) })
1554
1563
  ] })
1555
1564
  ] });
@@ -1559,8 +1568,8 @@ const H = (e) => {
1559
1568
  n.id = nn, n.textContent = e, document.head.appendChild(n);
1560
1569
  }
1561
1570
  };
1562
- Mn(R);
1563
- const Cn = K(
1571
+ Mn(J);
1572
+ const zn = K(
1564
1573
  ({
1565
1574
  value: e,
1566
1575
  onChange: n,
@@ -1569,22 +1578,22 @@ const Cn = K(
1569
1578
  disabled: l,
1570
1579
  minDate: u,
1571
1580
  maxDate: i,
1572
- placeholder: g,
1573
- size: f = "sm",
1581
+ placeholder: f,
1582
+ size: g = "sm",
1574
1583
  variant: r,
1575
1584
  status: d,
1576
- clearable: w,
1577
- fullWidth: M = !0,
1578
- withPadding: k = !0,
1579
- label: N,
1585
+ clearable: v,
1586
+ fullWidth: w = !0,
1587
+ withPadding: M = !0,
1588
+ label: C,
1580
1589
  labelPosition: m,
1581
1590
  required: h,
1582
1591
  optional: s,
1583
1592
  description: x,
1584
- helperText: z,
1593
+ helperText: N,
1585
1594
  errorText: c
1586
1595
  }, y) => {
1587
- const p = c ? "error" : d, { ref: b, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), D = J(null), [F, I] = A("days"), [T, Y] = A(/* @__PURE__ */ new Date()), [C, L] = A(/* @__PURE__ */ new Date());
1596
+ const p = c ? "error" : d, { ref: b, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), D = P(null), [F, I] = A("days"), [T, Y] = A(/* @__PURE__ */ new Date()), [z, L] = A(/* @__PURE__ */ new Date());
1588
1597
  B(() => {
1589
1598
  e ? (Y(e), L(e)) : (Y(/* @__PURE__ */ new Date()), L(/* @__PURE__ */ new Date()));
1590
1599
  }, [e]), B(() => {
@@ -1594,21 +1603,18 @@ const Cn = K(
1594
1603
  }, [E]), B(() => {
1595
1604
  o || S(!0);
1596
1605
  }, [o]);
1597
- const G = () => e ? t === "days" ? P(T) : t === "months" ? `${W[T.getMonth()]} ${T.getFullYear()}` : t === "years" ? T.getFullYear() : P(T) : "", j = () => {
1606
+ const q = () => e ? t === "days" ? H(T) : t === "months" ? `${R[T.getMonth()]} ${T.getFullYear()}` : t === "years" ? T.getFullYear() : H(T) : "", j = () => {
1598
1607
  if (D.current && b.current && o) {
1599
- const v = b.current.getBoundingClientRect(), V = D.current.getBoundingClientRect();
1600
- window.innerWidth < v.left + V.width ? D.current.style.left = `${v.left - V.width + v.width}px` : D.current.style.left = `${v.left}px`, v.top + V.height > window.innerHeight ? D.current.style.top = `${v.y - (v.height + V.height - 28)}px` : D.current.style.top = `${v.y + v.height}px`;
1608
+ const k = b.current.getBoundingClientRect(), V = D.current.getBoundingClientRect();
1609
+ window.innerWidth < k.left + V.width ? D.current.style.left = `${k.left - V.width + k.width}px` : D.current.style.left = `${k.left}px`, k.top + V.height > window.innerHeight ? D.current.style.top = `${k.y - (k.height + V.height - 28)}px` : D.current.style.top = `${k.y + k.height}px`;
1601
1610
  }
1602
1611
  };
1603
1612
  B(() => {
1604
1613
  D.current && b.current && o && j();
1605
- }, [D, b, E]), B(() => {
1606
- const v = y == null ? void 0 : y.current;
1607
- return v && v.addEventListener("scroll", j), window.addEventListener("scroll", j), () => {
1608
- v && v.removeEventListener("scroll", j), window.removeEventListener("scroll", j);
1609
- };
1610
- }, []);
1611
- const U = /* @__PURE__ */ $(
1614
+ }, [D, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1615
+ window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1616
+ }), []);
1617
+ const G = /* @__PURE__ */ $(
1612
1618
  "div",
1613
1619
  {
1614
1620
  className: "sa-calendar-wrapper",
@@ -1618,24 +1624,24 @@ const Cn = K(
1618
1624
  o ? /* @__PURE__ */ a(
1619
1625
  vn,
1620
1626
  {
1621
- value: G(),
1627
+ value: q(),
1622
1628
  onClick: () => S(!0),
1623
1629
  onChange: () => {
1624
1630
  },
1625
- placeholder: g,
1631
+ placeholder: f,
1626
1632
  disabled: l,
1627
- size: f,
1633
+ size: g,
1628
1634
  variant: r,
1629
1635
  status: p,
1630
1636
  inputMode: "none",
1631
- clearable: w,
1637
+ clearable: v,
1632
1638
  onClear: () => n(void 0)
1633
1639
  }
1634
1640
  ) : null,
1635
1641
  E ? /* @__PURE__ */ $(
1636
1642
  "div",
1637
1643
  {
1638
- className: `sa-calendar sa-calendar-size-${f || "sm"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
1644
+ className: `sa-calendar sa-calendar-size-${g || "sm"} ${o ? "" : "sa-calendar-no-input"} ${M ? "" : "sa-calendar-no-padding"}`,
1639
1645
  style: l ? { pointerEvents: "none" } : void 0,
1640
1646
  ref: D,
1641
1647
  children: [
@@ -1645,7 +1651,7 @@ const Cn = K(
1645
1651
  setViews: I,
1646
1652
  views: F,
1647
1653
  filter: t,
1648
- previewDate: C,
1654
+ previewDate: z,
1649
1655
  setPreviewDate: L,
1650
1656
  isComponentVisible: E
1651
1657
  }
@@ -1655,7 +1661,7 @@ const Cn = K(
1655
1661
  {
1656
1662
  date: T,
1657
1663
  setDate: Y,
1658
- previewDate: C,
1664
+ previewDate: z,
1659
1665
  setPreviewDate: L,
1660
1666
  setIsComponentVisible: S,
1661
1667
  input: o,
@@ -1669,7 +1675,7 @@ const Cn = K(
1669
1675
  {
1670
1676
  date: T,
1671
1677
  setDate: Y,
1672
- previewDate: C,
1678
+ previewDate: z,
1673
1679
  setPreviewDate: L,
1674
1680
  filter: t,
1675
1681
  setViews: I,
@@ -1684,7 +1690,7 @@ const Cn = K(
1684
1690
  {
1685
1691
  date: T,
1686
1692
  setDate: Y,
1687
- previewDate: C,
1693
+ previewDate: z,
1688
1694
  setPreviewDate: L,
1689
1695
  filter: t,
1690
1696
  setViews: I,
@@ -1704,19 +1710,20 @@ const Cn = K(
1704
1710
  return /* @__PURE__ */ a(
1705
1711
  on,
1706
1712
  {
1707
- label: N,
1713
+ label: C,
1708
1714
  labelPosition: m,
1709
1715
  required: h,
1710
1716
  optional: s,
1711
1717
  description: x,
1712
- helperText: z,
1718
+ helperText: N,
1713
1719
  errorText: c,
1714
- fullWidth: M,
1715
- children: U
1720
+ fullWidth: w,
1721
+ size: g,
1722
+ children: G
1716
1723
  }
1717
1724
  );
1718
1725
  }
1719
- ), zn = K(
1726
+ ), Nn = K(
1720
1727
  ({
1721
1728
  value: e,
1722
1729
  onChange: n,
@@ -1725,19 +1732,19 @@ const Cn = K(
1725
1732
  rangedDate: l,
1726
1733
  disabled: u,
1727
1734
  minDate: i,
1728
- maxDate: g,
1729
- placeholder: f,
1735
+ maxDate: f,
1736
+ placeholder: g,
1730
1737
  size: r,
1731
1738
  variant: d,
1732
- status: w,
1733
- clearable: M,
1734
- fullWidth: k,
1735
- withPadding: N,
1739
+ status: v,
1740
+ clearable: w,
1741
+ fullWidth: M,
1742
+ withPadding: C,
1736
1743
  label: m,
1737
1744
  labelPosition: h,
1738
1745
  required: s,
1739
1746
  optional: x,
1740
- description: z,
1747
+ description: N,
1741
1748
  helperText: c,
1742
1749
  errorText: y
1743
1750
  }, p) => {
@@ -1748,25 +1755,25 @@ const Cn = K(
1748
1755
  filter: t,
1749
1756
  disabled: u,
1750
1757
  minDate: i,
1751
- maxDate: g,
1752
- placeholder: f,
1758
+ maxDate: f,
1759
+ placeholder: g,
1753
1760
  size: r,
1754
1761
  variant: d,
1755
- status: w,
1756
- clearable: M,
1757
- fullWidth: k,
1758
- withPadding: N,
1762
+ status: v,
1763
+ clearable: w,
1764
+ fullWidth: M,
1765
+ withPadding: C,
1759
1766
  label: m,
1760
1767
  labelPosition: h,
1761
1768
  required: s,
1762
1769
  optional: x,
1763
- description: z,
1770
+ description: N,
1764
1771
  helperText: c,
1765
1772
  errorText: y
1766
1773
  };
1767
- return /* @__PURE__ */ a(en, { children: l ? /* @__PURE__ */ a(mn, { ...b, ref: p }) : /* @__PURE__ */ a(Cn, { ...b, ref: p }) });
1774
+ return /* @__PURE__ */ a(en, { children: l ? /* @__PURE__ */ a(mn, { ...b, ref: p }) : /* @__PURE__ */ a(zn, { ...b, ref: p }) });
1768
1775
  }
1769
1776
  );
1770
1777
  export {
1771
- zn as StarasiaDate
1778
+ Nn as StarasiaDate
1772
1779
  };
package/dist/date.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(V,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(V=typeof globalThis<"u"?globalThis:V||self,n(V.Date={},V.jsxRuntime,V.React))})(this,function(V,n,m){"use strict";const P=`@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
+ (function(V,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(V=typeof globalThis<"u"?globalThis:V||self,n(V.Date={},V.jsxRuntime,V.React))})(this,function(V,n,w){"use strict";const P=`@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");
2
2
 
3
3
  * {
4
4
  margin: 0;
@@ -66,14 +66,19 @@
66
66
  .sa-date-field-label-row {
67
67
  display: flex;
68
68
  align-items: center;
69
- gap: 6px;
69
+ gap: 4px;
70
70
  flex-wrap: wrap;
71
71
  }
72
72
  .sa-date-field-label-text {
73
73
  font-size: 14px;
74
74
  font-weight: 500;
75
75
  color: var(--sa-date-text-primary);
76
- line-height: 1.3;
76
+ line-height: normal;
77
+ }
78
+ /* match Input: xs/sm label drops to 12px */
79
+ .sa-date-field-size-xs .sa-date-field-label-text,
80
+ .sa-date-field-size-sm .sa-date-field-label-text {
81
+ font-size: 12px;
77
82
  }
78
83
  .sa-date-field-required {
79
84
  font-size: 14px;
@@ -81,6 +86,10 @@
81
86
  color: var(--sa-date-border-error);
82
87
  line-height: 1;
83
88
  }
89
+ .sa-date-field-size-xs .sa-date-field-required,
90
+ .sa-date-field-size-sm .sa-date-field-required {
91
+ font-size: 12px;
92
+ }
84
93
  .sa-date-field-optional-badge {
85
94
  display: inline-flex;
86
95
  align-items: center;
@@ -579,4 +588,4 @@
579
588
  width: 32px;
580
589
  height: 32px;
581
590
  }
582
- `,Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A=["January","February","March","April","May","June","July","August","September","October","November","December"],rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(a){const[e,s]=m.useState(a),o=m.useRef(null),l=h=>{o.current&&!o.current.contains(h.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:s}}const Q="sa-calendar-input-styles";(a=>{if(!document.getElementById(Q)){const e=document.createElement("style");e.id=Q,e.textContent=a,document.head.appendChild(e)}})(P);const O=a=>{if(a==="xs")return 14;if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},sn=a=>{const{size:e="sm",status:s="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=m.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=s==="disable"||i.disabled,d=!!i.value,x=l&&d&&!r,D=M=>{M.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),x?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:D,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},tn=({date:a,setDate:e,dateRange:s,setDateRange:o,onChange:l,minDate:h,maxDate:i,input:g})=>{var $,c,w;const[f,r]=m.useState(null);let d=new Date(a.getFullYear(),a.getMonth(),1),x=d.getDay(),D=[];const M=a.getMonth(),z=new Date().toDateString(),b=!!(s.from&&!s.to),u=b&&f?f:null;for(let p=0;p<42;p++){p===0&&x===0?d.setDate(d.getDate()-7):p===0?d.setDate(d.getDate()+(p-x)):d.setDate(d.getDate()+1);let v={currentMonth:d.getMonth()===M,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===(($=s.from)==null?void 0:$.toDateString())||d.toDateString()===(((c=s.to)==null?void 0:c.toDateString())||((w=s.from)==null?void 0:w.toDateString())),isToday:d.toDateString()===z,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};D.push(v)}const t=p=>{e(p)},k=p=>{let v={...s};if(v.from&&v.to)v={from:p,to:null};else if(!v.from)v={from:p,to:null};else{const S=v.from.getTime();p.getTime()>S?v={from:v.from,to:p}:v={from:p,to:v.from}}o(v),l(v)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>r(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((p,v)=>n.jsx("p",{children:p},v))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((p,v)=>{const S=s.from&&s.to&&p.date.getTime()>s.from.getTime()&&p.date.getTime()<s.to.getTime(),T=(()=>{if(!u||!s.from)return!1;const Y=p.date.getTime(),C=s.from.getTime(),F=u.getTime();return F>C?Y>C&&Y<F:Y<C&&Y>F})(),N=b&&f&&p.date.toDateString()===f.toDateString(),E=p.isDisabled,I=()=>S||T?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",L=()=>E?"var(--sa-color-gray-400, #b7b9be)":S||T?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${p.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${p.selected||N?"sa-calendar-days-active":""} ${p.isToday&&!p.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:I(),pointerEvents:E?"none":void 0,cursor:E?"not-allowed":"pointer",color:L(),opacity:N&&!p.selected?.75:1,...g?{}:{width:"100%"}},onClick:()=>{E||(t(p.date),k(p.date))},onMouseEnter:()=>{E||r(p.date)},children:p.number},v)})})]})},on=({date:a,setDate:e,filter:s,setViews:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var z;const d=(z=l.from)==null?void 0:z.getFullYear(),x=a.getFullYear(),D=b=>{s?(M(b),e(b)):(o("days"),e(b))},M=b=>{let u={...l};if(u.from&&u.to)u={from:b,to:null};else if(!u.from)u={from:b,to:null};else{const t=u.from.getTime();b.getTime()>t?u={from:u.from,to:b}:u={from:b,to:u.from}}h(u),i(u)};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{var $,c,w;const t=l.from!=null&&new Date(x,u).getTime()>l.from.getTime()&&new Date(x,u).getTime()<((($=l.to)==null?void 0:$.getTime())||l.from.getTime()),k=g&&new Date(x,u)<g||f&&new Date(x,u)>f;return n.jsx("p",{className:d===x&&(u===((c=l.from)==null?void 0:c.getMonth())||u===((w=l.to)==null?void 0:w.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:t?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:k?"none":void 0,cursor:k?"not-allowed":"pointer",color:k?"var(--sa-color-gray-400, #b7b9be)":t?"var(--sa-color-gray-500, #8c8f97)":"",...r?{}:{width:"100%"}},onClick:()=>{k||D(new Date(x,u))},children:b.slice(0,3)},u)})})},J=a=>{const e=Math.floor(a/10)*10,s=e+10;return{start:e,end:s}},ln=({date:a,filter:e,setViews:s,setDate:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var k,$;let d=[];const x=a.getFullYear(),{start:D,end:M}=J(x),z=(k=l.from)==null?void 0:k.getFullYear(),b=($=l.to)==null?void 0:$.getFullYear();for(let c=D;c<M;c++){const w=new Date(c,0),p=(!g||w>=g)&&(!f||w<=f),v=z!=null&&c===z||b!=null&&c===b,S=l.from!=null&&l.to!=null&&w>l.from&&w<l.to;d.push({year:c,active:v&&p,highlight:S&&p,disabled:!p})}const u=c=>{e?(t(c),o(c)):(o(c),s("months"))},t=c=>{let w={...l};if(w.from&&w.to)w={from:c,to:null};else if(!w.from)w={from:c,to:null};else{const p=w.from.getTime();c.getTime()>p?w={from:w.from,to:c}:w={from:c,to:w.from}}h(w),i(w)};return n.jsx("div",{className:"sa-calendar-years-preview",children:d.map((c,w)=>n.jsx("p",{className:`${c.active?"sa-calendar-months-active":""} ${c.highlight?"sa-calendar-months-highlight":""} ${c.disabled?"sa-calendar-disabled":""}`,onClick:()=>{c.disabled||u(new Date(c.year,0))},style:{backgroundColor:c.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:c.highlight?"var(--sa-color-gray-500, #8c8f97)":c.active?"":c.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:c.disabled?"not-allowed":"pointer",pointerEvents:c.disbled?"none":"all",...r?{}:{width:"100%"}},children:c.year},w))})},X=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),dn=({setViews:a,views:e,filter:s,date:o,setDate:l})=>{const h=()=>{s||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${J(o.getFullYear()).start} ~ ${J(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})};function W(a){const e=new Date(a),s=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${rn[o]} ${s}`}const R=({label:a,labelPosition:e="outside-top",required:s,optional:o,description:l,helperText:h,errorText:i,fullWidth:g,children:f})=>{const r=["sa-date-field",g?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),d=a?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:a}),o&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),s&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,x=n.jsxs(n.Fragment,{children:[h&&!i&&n.jsx("p",{className:"sa-date-field-helper",children:h}),i&&n.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return a?e==="outside-left"?n.jsxs("div",{className:`${r} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[f,x]})]}):n.jsxs("div",{className:r,children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),f,x]}):n.jsxs("div",{className:r,children:[l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),f,x]})},nn="sa-calendar-styles";(a=>{if(!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=a,document.head.appendChild(e)}})(P);const cn=m.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f="sm",variant:r,status:d,clearable:x,fullWidth:D=!0,withPadding:M=!0,label:z,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c},w)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),N=m.useRef(null),[E,I]=m.useState("days"),[L,Y]=m.useState(new Date),[C,F]=m.useState({from:(a==null?void 0:a.from)??null,to:(a==null?void 0:a.to)??null});m.useEffect(()=>{if(a){const y=a;y.from&&Y(y.from),F(y)}else Y(new Date),F({from:null,to:null})},[a]),m.useEffect(()=>{s&&I(s)},[s]),m.useEffect(()=>{s||I("days")},[S]),m.useEffect(()=>{o||T(!0)},[o]);const G=()=>{var y,j;if(!a)return"";if(s){if(E==="days")return`${W(C.from)} ~ ${W(C.to||C.from)||"-"}`;if(E==="months")return`${A[C.from.getMonth()]} ~ ${C.to?A[C.to.getMonth()]:"-"}`;if(E==="years")return`${(y=C.from)==null?void 0:y.getFullYear()} ~ ${((j=C.to)==null?void 0:j.getFullYear())||"-"}`}else return`${W(C.from)} ~ ${W(C.to||C.from)||"-"}`},B=()=>{if(N.current&&v.current&&o){const y=v.current.getBoundingClientRect(),j=N.current.getBoundingClientRect();window.innerWidth<y.left+j.width?N.current.style.left=`${y.left-j.width+y.width}px`:N.current.style.left=`${y.left}px`,y.top+j.height>window.innerHeight?N.current.style.top=`${y.y-(y.height+j.height-28)}px`:N.current.style.top=`${y.y+y.height}px`}};m.useEffect(()=>{N.current&&v.current&&o&&B()},[N,v,S]),m.useEffect(()=>{const y=w==null?void 0:w.current;return y&&y.addEventListener("scroll",B),window.addEventListener("scroll",B),()=>{y&&y.removeEventListener("scroll",B),window.removeEventListener("scroll",B)}},[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(sn,{value:G(),inputMode:"none",onClick:()=>{T(!0)},onChange:()=>{},disabled:l,placeholder:g,size:f,variant:r,status:p,clearable:x,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"sm"} ${o?"":"sa-calendar-no-input"} ${M?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:N,children:[n.jsx(dn,{setViews:I,views:E,filter:s,date:L,setDate:Y}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(tn,{date:L,setDate:Y,setIsComponentVisible:T,dateRange:C,setDateRange:F,input:o,onChange:e,minDate:h,maxDate:i}):E==="months"?n.jsx(on,{date:L,setDate:Y,filter:s,setViews:I,dateRange:C,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i}):n.jsx(ln,{date:L,setDate:Y,filter:s,setViews:I,dateRange:C,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i})})]}):null]});return n.jsx(R,{label:z,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c,fullWidth:D,children:U})}),en="sa-calendar-input-styles";(a=>{if(!document.getElementById(en)){const e=document.createElement("style");e.id=en,e.textContent=a,document.head.appendChild(e)}})(P);const H=a=>{if(a==="xs")return 14;if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},pn=a=>{const{size:e="sm",status:s="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=m.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=s==="disable"||i.disabled,d=!!i.value,x=l&&d&&!r,D=M=>{M.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),x?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:D,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},hn=({date:a,setDate:e,previewDate:s,setPreviewDate:o,setIsComponentVisible:l,minDate:h,maxDate:i,input:g,onChange:f,hasValue:r})=>{let d=new Date(s.getFullYear(),s.getMonth(),1),x=d.getDay(),D=[];const M=a.toDateString(),z=new Date().toDateString(),b=s.getMonth();for(let t=0;t<42;t++){t===0&&x===0?d.setDate(d.getDate()-7):t===0?d.setDate(d.getDate()+(t-x)):d.setDate(d.getDate()+1);let k={currentMonth:d.getMonth()===b,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:r&&d.toDateString()===M,isToday:d.toDateString()===z,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};D.push(k)}const u=t=>{(!h||t>=h)&&(!i||t<=i)&&(e(t),f(t),o(t),g&&l(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((t,k)=>n.jsx("p",{children:t},k))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((t,k)=>{const $=t.isDisabled;return n.jsx("p",{className:`${t.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${t.selected?"sa-calendar-days-active":""} ${t.isToday&&!t.selected?"sa-calendar-days-today":""}`,style:{color:$?"#ccc":void 0,pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",...g?{}:{width:"100%"}},onClick:()=>{$||u(t.date)},children:t.number},k)})})]})},fn=({date:a,setDate:e,filter:s,setViews:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{const x=a.getMonth(),D=a.getFullYear(),M=h.getFullYear(),z=b=>{(!g||b>=g)&&(!f||b<=f)&&(s?(l(b),e(b),i(b)):(o("days"),i(b)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{const t=g&&new Date(M,u,1)<g||f&&new Date(M,u+1,0)>f;return n.jsx("p",{className:d&&u===x&&M===D?"sa-calendar-months-active":"",style:{color:t?"#ccc":void 0,pointerEvents:t?"none":void 0,cursor:t?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{t||z(new Date(M,u))},children:b.slice(0,3)},u)})})},q=a=>{const e=Math.floor(a/10)*10,s=e+10;return{start:e,end:s}},un=({date:a,filter:e,setViews:s,setDate:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{let x=[];const D=h.getFullYear(),{start:M,end:z}=q(D),b=a.getFullYear();for(let t=M;t<z;t++){let k=g&&new Date(t,0,1)<g||f&&new Date(t,11,31)>f;x.push({year:t,active:!!d&&t===b,isDisabled:k})}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(e?(l(t),o(t),i(t)):(s("months"),i(t)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:x.map((t,k)=>n.jsx("p",{className:t.active?"sa-calendar-months-active":"",style:{color:t.isDisabled?"#ccc":void 0,pointerEvents:t.isDisabled?"none":void 0,cursor:t.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{t.isDisabled||u(new Date(t.year,0))},children:t.year},k))})},gn=({setViews:a,views:e,filter:s,previewDate:o,setPreviewDate:l})=>{const h=()=>{s||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})},an="sa-calendar-styles";(a=>{if(!document.getElementById(an)){const e=document.createElement("style");e.id=an,e.textContent=a,document.head.appendChild(e)}})(P);const bn=m.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f="sm",variant:r,status:d,clearable:x,fullWidth:D=!0,withPadding:M=!0,label:z,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c},w)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),N=m.useRef(null),[E,I]=m.useState("days"),[L,Y]=m.useState(new Date),[C,F]=m.useState(new Date);m.useEffect(()=>{a?(Y(a),F(a)):(Y(new Date),F(new Date))},[a]),m.useEffect(()=>{s&&I(s)},[s]),m.useEffect(()=>{s||I("days")},[S]),m.useEffect(()=>{o||T(!0)},[o]);const G=()=>a?s==="days"?W(L):s==="months"?`${A[L.getMonth()]} ${L.getFullYear()}`:s==="years"?L.getFullYear():W(L):"",B=()=>{if(N.current&&v.current&&o){const y=v.current.getBoundingClientRect(),j=N.current.getBoundingClientRect();window.innerWidth<y.left+j.width?N.current.style.left=`${y.left-j.width+y.width}px`:N.current.style.left=`${y.left}px`,y.top+j.height>window.innerHeight?N.current.style.top=`${y.y-(y.height+j.height-28)}px`:N.current.style.top=`${y.y+y.height}px`}};m.useEffect(()=>{N.current&&v.current&&o&&B()},[N,v,S]),m.useEffect(()=>{const y=w==null?void 0:w.current;return y&&y.addEventListener("scroll",B),window.addEventListener("scroll",B),()=>{y&&y.removeEventListener("scroll",B),window.removeEventListener("scroll",B)}},[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(pn,{value:G(),onClick:()=>T(!0),onChange:()=>{},placeholder:g,disabled:l,size:f,variant:r,status:p,inputMode:"none",clearable:x,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"sm"} ${o?"":"sa-calendar-no-input"} ${M?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:N,children:[n.jsx(gn,{setViews:I,views:E,filter:s,previewDate:C,setPreviewDate:F,isComponentVisible:S}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(hn,{date:L,setDate:Y,previewDate:C,setPreviewDate:F,setIsComponentVisible:T,input:o,minDate:h,maxDate:i,onChange:e,hasValue:a!=null}):E==="months"?n.jsx(fn,{date:L,setDate:Y,previewDate:C,setPreviewDate:F,filter:s,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null}):n.jsx(un,{date:L,setDate:Y,previewDate:C,setPreviewDate:F,filter:s,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null})})]}):null]});return n.jsx(R,{label:z,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c,fullWidth:D,children:U})}),vn=m.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,rangedDate:l,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:x,clearable:D,fullWidth:M,withPadding:z,label:b,labelPosition:u,required:t,optional:k,description:$,helperText:c,errorText:w},p)=>{const v={onChange:e,value:a,input:o,filter:s,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:x,clearable:D,fullWidth:M,withPadding:z,label:b,labelPosition:u,required:t,optional:k,description:$,helperText:c,errorText:w};return n.jsx(n.Fragment,{children:l?n.jsx(cn,{...v,ref:p}):n.jsx(bn,{...v,ref:p})})});V.StarasiaDate=vn,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
591
+ `,Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A=["January","February","March","April","May","June","July","August","September","October","November","December"],rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(a){const[e,s]=w.useState(a),o=w.useRef(null),l=h=>{o.current&&!o.current.contains(h.target)&&s(!1)};return w.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:s}}const Q="sa-calendar-input-styles";(a=>{if(!document.getElementById(Q)){const e=document.createElement("style");e.id=Q,e.textContent=a,document.head.appendChild(e)}})(P);const O=a=>{if(a==="xs")return 14;if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},sn=a=>{const{size:e="sm",status:s="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=w.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=s==="disable"||i.disabled,d=!!i.value,y=l&&d&&!r,m=D=>{D.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),y?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:m,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},tn=({date:a,setDate:e,dateRange:s,setDateRange:o,onChange:l,minDate:h,maxDate:i,input:g})=>{var $,c,x;const[f,r]=w.useState(null);let d=new Date(a.getFullYear(),a.getMonth(),1),y=d.getDay(),m=[];const D=a.getMonth(),N=new Date().toDateString(),b=!!(s.from&&!s.to),u=b&&f?f:null;for(let p=0;p<42;p++){p===0&&y===0?d.setDate(d.getDate()-7):p===0?d.setDate(d.getDate()+(p-y)):d.setDate(d.getDate()+1);let v={currentMonth:d.getMonth()===D,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===(($=s.from)==null?void 0:$.toDateString())||d.toDateString()===(((c=s.to)==null?void 0:c.toDateString())||((x=s.from)==null?void 0:x.toDateString())),isToday:d.toDateString()===N,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};m.push(v)}const t=p=>{e(p)},k=p=>{let v={...s};if(v.from&&v.to)v={from:p,to:null};else if(!v.from)v={from:p,to:null};else{const S=v.from.getTime();p.getTime()>S?v={from:v.from,to:p}:v={from:p,to:v.from}}o(v),l(v)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>r(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((p,v)=>n.jsx("p",{children:p},v))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:m.map((p,v)=>{const S=s.from&&s.to&&p.date.getTime()>s.from.getTime()&&p.date.getTime()<s.to.getTime(),T=(()=>{if(!u||!s.from)return!1;const Y=p.date.getTime(),z=s.from.getTime(),F=u.getTime();return F>z?Y>z&&Y<F:Y<z&&Y>F})(),C=b&&f&&p.date.toDateString()===f.toDateString(),E=p.isDisabled,I=()=>S||T?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",L=()=>E?"var(--sa-color-gray-400, #b7b9be)":S||T?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${p.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${p.selected||C?"sa-calendar-days-active":""} ${p.isToday&&!p.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:I(),pointerEvents:E?"none":void 0,cursor:E?"not-allowed":"pointer",color:L(),opacity:C&&!p.selected?.75:1,...g?{}:{width:"100%"}},onClick:()=>{E||(t(p.date),k(p.date))},onMouseEnter:()=>{E||r(p.date)},children:p.number},v)})})]})},on=({date:a,setDate:e,filter:s,setViews:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var N;const d=(N=l.from)==null?void 0:N.getFullYear(),y=a.getFullYear(),m=b=>{s?(D(b),e(b)):(o("days"),e(b))},D=b=>{let u={...l};if(u.from&&u.to)u={from:b,to:null};else if(!u.from)u={from:b,to:null};else{const t=u.from.getTime();b.getTime()>t?u={from:u.from,to:b}:u={from:b,to:u.from}}h(u),i(u)};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{var $,c,x;const t=l.from!=null&&new Date(y,u).getTime()>l.from.getTime()&&new Date(y,u).getTime()<((($=l.to)==null?void 0:$.getTime())||l.from.getTime()),k=g&&new Date(y,u)<g||f&&new Date(y,u)>f;return n.jsx("p",{className:d===y&&(u===((c=l.from)==null?void 0:c.getMonth())||u===((x=l.to)==null?void 0:x.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:t?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:k?"none":void 0,cursor:k?"not-allowed":"pointer",color:k?"var(--sa-color-gray-400, #b7b9be)":t?"var(--sa-color-gray-500, #8c8f97)":"",...r?{}:{width:"100%"}},onClick:()=>{k||m(new Date(y,u))},children:b.slice(0,3)},u)})})},J=a=>{const e=Math.floor(a/10)*10,s=e+10;return{start:e,end:s}},ln=({date:a,filter:e,setViews:s,setDate:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var k,$;let d=[];const y=a.getFullYear(),{start:m,end:D}=J(y),N=(k=l.from)==null?void 0:k.getFullYear(),b=($=l.to)==null?void 0:$.getFullYear();for(let c=m;c<D;c++){const x=new Date(c,0),p=(!g||x>=g)&&(!f||x<=f),v=N!=null&&c===N||b!=null&&c===b,S=l.from!=null&&l.to!=null&&x>l.from&&x<l.to;d.push({year:c,active:v&&p,highlight:S&&p,disabled:!p})}const u=c=>{e?(t(c),o(c)):(o(c),s("months"))},t=c=>{let x={...l};if(x.from&&x.to)x={from:c,to:null};else if(!x.from)x={from:c,to:null};else{const p=x.from.getTime();c.getTime()>p?x={from:x.from,to:c}:x={from:c,to:x.from}}h(x),i(x)};return n.jsx("div",{className:"sa-calendar-years-preview",children:d.map((c,x)=>n.jsx("p",{className:`${c.active?"sa-calendar-months-active":""} ${c.highlight?"sa-calendar-months-highlight":""} ${c.disabled?"sa-calendar-disabled":""}`,onClick:()=>{c.disabled||u(new Date(c.year,0))},style:{backgroundColor:c.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:c.highlight?"var(--sa-color-gray-500, #8c8f97)":c.active?"":c.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:c.disabled?"not-allowed":"pointer",pointerEvents:c.disbled?"none":"all",...r?{}:{width:"100%"}},children:c.year},x))})},X=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),dn=({setViews:a,views:e,filter:s,date:o,setDate:l})=>{const h=()=>{s||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${J(o.getFullYear()).start} ~ ${J(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})};function W(a){const e=new Date(a),s=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${rn[o]} ${s}`}const R=({label:a,labelPosition:e="outside-top",required:s,optional:o,description:l,helperText:h,errorText:i,fullWidth:g,size:f="sm",children:r})=>{const d=["sa-date-field",`sa-date-field-size-${f}`,g?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),y=a?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:a}),o&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),s&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,m=n.jsxs(n.Fragment,{children:[h&&!i&&n.jsx("p",{className:"sa-date-field-helper",children:h}),i&&n.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return a?e==="outside-left"?n.jsxs("div",{className:`${d} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[y,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[r,m]})]}):n.jsxs("div",{className:d,children:[y,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),r,m]}):n.jsxs("div",{className:d,children:[l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),r,m]})},nn="sa-calendar-styles";(a=>{if(!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=a,document.head.appendChild(e)}})(P);const cn=w.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f="sm",variant:r,status:d,clearable:y,fullWidth:m=!0,withPadding:D=!0,label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c},x)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),C=w.useRef(null),[E,I]=w.useState("days"),[L,Y]=w.useState(new Date),[z,F]=w.useState({from:(a==null?void 0:a.from)??null,to:(a==null?void 0:a.to)??null});w.useEffect(()=>{if(a){const M=a;M.from&&Y(M.from),F(M)}else Y(new Date),F({from:null,to:null})},[a]),w.useEffect(()=>{s&&I(s)},[s]),w.useEffect(()=>{s||I("days")},[S]),w.useEffect(()=>{o||T(!0)},[o]);const G=()=>{var M,j;if(!a)return"";if(s){if(E==="days")return`${W(z.from)} ~ ${W(z.to||z.from)||"-"}`;if(E==="months")return`${A[z.from.getMonth()]} ~ ${z.to?A[z.to.getMonth()]:"-"}`;if(E==="years")return`${(M=z.from)==null?void 0:M.getFullYear()} ~ ${((j=z.to)==null?void 0:j.getFullYear())||"-"}`}else return`${W(z.from)} ~ ${W(z.to||z.from)||"-"}`},B=()=>{if(C.current&&v.current&&o){const M=v.current.getBoundingClientRect(),j=C.current.getBoundingClientRect();window.innerWidth<M.left+j.width?C.current.style.left=`${M.left-j.width+M.width}px`:C.current.style.left=`${M.left}px`,M.top+j.height>window.innerHeight?C.current.style.top=`${M.y-(M.height+j.height-28)}px`:C.current.style.top=`${M.y+M.height}px`}};w.useEffect(()=>{C.current&&v.current&&o&&B()},[C,v,S]),w.useEffect(()=>(window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}),[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(sn,{value:G(),inputMode:"none",onClick:()=>{T(!0)},onChange:()=>{},disabled:l,placeholder:g,size:f,variant:r,status:p,clearable:y,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"sm"} ${o?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:C,children:[n.jsx(dn,{setViews:I,views:E,filter:s,date:L,setDate:Y}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(tn,{date:L,setDate:Y,setIsComponentVisible:T,dateRange:z,setDateRange:F,input:o,onChange:e,minDate:h,maxDate:i}):E==="months"?n.jsx(on,{date:L,setDate:Y,filter:s,setViews:I,dateRange:z,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i}):n.jsx(ln,{date:L,setDate:Y,filter:s,setViews:I,dateRange:z,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i})})]}):null]});return n.jsx(R,{label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c,fullWidth:m,size:f,children:U})}),en="sa-calendar-input-styles";(a=>{if(!document.getElementById(en)){const e=document.createElement("style");e.id=en,e.textContent=a,document.head.appendChild(e)}})(P);const H=a=>{if(a==="xs")return 14;if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},pn=a=>{const{size:e="sm",status:s="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=w.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=s==="disable"||i.disabled,d=!!i.value,y=l&&d&&!r,m=D=>{D.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${s} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{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",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),y?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:m,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},hn=({date:a,setDate:e,previewDate:s,setPreviewDate:o,setIsComponentVisible:l,minDate:h,maxDate:i,input:g,onChange:f,hasValue:r})=>{let d=new Date(s.getFullYear(),s.getMonth(),1),y=d.getDay(),m=[];const D=a.toDateString(),N=new Date().toDateString(),b=s.getMonth();for(let t=0;t<42;t++){t===0&&y===0?d.setDate(d.getDate()-7):t===0?d.setDate(d.getDate()+(t-y)):d.setDate(d.getDate()+1);let k={currentMonth:d.getMonth()===b,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:r&&d.toDateString()===D,isToday:d.toDateString()===N,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};m.push(k)}const u=t=>{(!h||t>=h)&&(!i||t<=i)&&(e(t),f(t),o(t),g&&l(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((t,k)=>n.jsx("p",{children:t},k))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:m.map((t,k)=>{const $=t.isDisabled;return n.jsx("p",{className:`${t.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${t.selected?"sa-calendar-days-active":""} ${t.isToday&&!t.selected?"sa-calendar-days-today":""}`,style:{color:$?"#ccc":void 0,pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",...g?{}:{width:"100%"}},onClick:()=>{$||u(t.date)},children:t.number},k)})})]})},fn=({date:a,setDate:e,filter:s,setViews:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{const y=a.getMonth(),m=a.getFullYear(),D=h.getFullYear(),N=b=>{(!g||b>=g)&&(!f||b<=f)&&(s?(l(b),e(b),i(b)):(o("days"),i(b)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{const t=g&&new Date(D,u,1)<g||f&&new Date(D,u+1,0)>f;return n.jsx("p",{className:d&&u===y&&D===m?"sa-calendar-months-active":"",style:{color:t?"#ccc":void 0,pointerEvents:t?"none":void 0,cursor:t?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{t||N(new Date(D,u))},children:b.slice(0,3)},u)})})},q=a=>{const e=Math.floor(a/10)*10,s=e+10;return{start:e,end:s}},un=({date:a,filter:e,setViews:s,setDate:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{let y=[];const m=h.getFullYear(),{start:D,end:N}=q(m),b=a.getFullYear();for(let t=D;t<N;t++){let k=g&&new Date(t,0,1)<g||f&&new Date(t,11,31)>f;y.push({year:t,active:!!d&&t===b,isDisabled:k})}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(e?(l(t),o(t),i(t)):(s("months"),i(t)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:y.map((t,k)=>n.jsx("p",{className:t.active?"sa-calendar-months-active":"",style:{color:t.isDisabled?"#ccc":void 0,pointerEvents:t.isDisabled?"none":void 0,cursor:t.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{t.isDisabled||u(new Date(t.year,0))},children:t.year},k))})},gn=({setViews:a,views:e,filter:s,previewDate:o,setPreviewDate:l})=>{const h=()=>{s||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})},an="sa-calendar-styles";(a=>{if(!document.getElementById(an)){const e=document.createElement("style");e.id=an,e.textContent=a,document.head.appendChild(e)}})(P);const bn=w.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f="sm",variant:r,status:d,clearable:y,fullWidth:m=!0,withPadding:D=!0,label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c},x)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),C=w.useRef(null),[E,I]=w.useState("days"),[L,Y]=w.useState(new Date),[z,F]=w.useState(new Date);w.useEffect(()=>{a?(Y(a),F(a)):(Y(new Date),F(new Date))},[a]),w.useEffect(()=>{s&&I(s)},[s]),w.useEffect(()=>{s||I("days")},[S]),w.useEffect(()=>{o||T(!0)},[o]);const G=()=>a?s==="days"?W(L):s==="months"?`${A[L.getMonth()]} ${L.getFullYear()}`:s==="years"?L.getFullYear():W(L):"",B=()=>{if(C.current&&v.current&&o){const M=v.current.getBoundingClientRect(),j=C.current.getBoundingClientRect();window.innerWidth<M.left+j.width?C.current.style.left=`${M.left-j.width+M.width}px`:C.current.style.left=`${M.left}px`,M.top+j.height>window.innerHeight?C.current.style.top=`${M.y-(M.height+j.height-28)}px`:C.current.style.top=`${M.y+M.height}px`}};w.useEffect(()=>{C.current&&v.current&&o&&B()},[C,v,S]),w.useEffect(()=>(window.addEventListener("scroll",B,!0),window.addEventListener("resize",B),()=>{window.removeEventListener("scroll",B,!0),window.removeEventListener("resize",B)}),[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(pn,{value:G(),onClick:()=>T(!0),onChange:()=>{},placeholder:g,disabled:l,size:f,variant:r,status:p,inputMode:"none",clearable:y,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"sm"} ${o?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:C,children:[n.jsx(gn,{setViews:I,views:E,filter:s,previewDate:z,setPreviewDate:F,isComponentVisible:S}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(hn,{date:L,setDate:Y,previewDate:z,setPreviewDate:F,setIsComponentVisible:T,input:o,minDate:h,maxDate:i,onChange:e,hasValue:a!=null}):E==="months"?n.jsx(fn,{date:L,setDate:Y,previewDate:z,setPreviewDate:F,filter:s,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null}):n.jsx(un,{date:L,setDate:Y,previewDate:z,setPreviewDate:F,filter:s,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null})})]}):null]});return n.jsx(R,{label:N,labelPosition:b,required:u,optional:t,description:k,helperText:$,errorText:c,fullWidth:m,size:f,children:U})}),vn=w.forwardRef(({value:a,onChange:e,filter:s,input:o=!0,rangedDate:l,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:y,clearable:m,fullWidth:D,withPadding:N,label:b,labelPosition:u,required:t,optional:k,description:$,helperText:c,errorText:x},p)=>{const v={onChange:e,value:a,input:o,filter:s,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:y,clearable:m,fullWidth:D,withPadding:N,label:b,labelPosition:u,required:t,optional:k,description:$,helperText:c,errorText:x};return n.jsx(n.Fragment,{children:l?n.jsx(cn,{...v,ref:p}):n.jsx(bn,{...v,ref:p})})});V.StarasiaDate=vn,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",