@starasia/date 5.3.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/date.es.js CHANGED
@@ -1,6 +1,6 @@
1
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;
@@ -581,7 +581,7 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
581
581
  width: 32px;
582
582
  height: 32px;
583
583
  }
584
- `, an = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], W = [
584
+ `, an = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], R = [
585
585
  "January",
586
586
  "February",
587
587
  "March",
@@ -609,7 +609,7 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
609
609
  "Dec"
610
610
  ];
611
611
  function rn(e) {
612
- const [n, t] = A(e), o = J(null), l = (u) => {
612
+ const [n, t] = A(e), o = P(null), l = (u) => {
613
613
  o.current && !o.current.contains(u.target) && t(!1);
614
614
  };
615
615
  return B(() => (document.addEventListener("click", l, !0), () => {
@@ -622,8 +622,8 @@ const Q = "sa-calendar-input-styles", dn = (e) => {
622
622
  n.id = Q, n.textContent = e, document.head.appendChild(n);
623
623
  }
624
624
  };
625
- dn(R);
626
- const O = (e) => {
625
+ dn(J);
626
+ const W = (e) => {
627
627
  if (e === "xs")
628
628
  return 14;
629
629
  if (e === "sm")
@@ -640,23 +640,23 @@ const O = (e) => {
640
640
  clearable: l,
641
641
  onClear: u,
642
642
  ...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) => {
643
+ } = e, f = P(null), g = () => {
644
+ f.current && i.onClick && (f.current.focus(), i.onClick(""));
645
+ }, r = t === "disable" || i.disabled, d = !!i.value, v = l && d && !r, M = (k) => {
646
646
  k.stopPropagation(), u == null || u();
647
647
  };
648
648
  return /* @__PURE__ */ $(
649
649
  "div",
650
650
  {
651
651
  className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${n} `,
652
- onClick: f,
652
+ onClick: g,
653
653
  children: [
654
654
  /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
655
655
  "svg",
656
656
  {
657
657
  xmlns: "http://www.w3.org/2000/svg",
658
- width: O(n),
659
- height: O(n),
658
+ width: W(n),
659
+ height: W(n),
660
660
  viewBox: "0 0 20 20",
661
661
  fill: "none",
662
662
  children: /* @__PURE__ */ a(
@@ -678,10 +678,10 @@ const O = (e) => {
678
678
  ...i,
679
679
  disabled: r,
680
680
  value: i.value,
681
- ref: g
681
+ ref: f
682
682
  }
683
683
  ) }),
684
- w ? /* @__PURE__ */ a(
684
+ v ? /* @__PURE__ */ a(
685
685
  "button",
686
686
  {
687
687
  type: "button",
@@ -692,8 +692,8 @@ const O = (e) => {
692
692
  "svg",
693
693
  {
694
694
  xmlns: "http://www.w3.org/2000/svg",
695
- width: O(n),
696
- height: O(n),
695
+ width: W(n),
696
+ height: W(n),
697
697
  viewBox: "0 0 20 20",
698
698
  fill: "none",
699
699
  children: /* @__PURE__ */ a(
@@ -713,8 +713,8 @@ const O = (e) => {
713
713
  "svg",
714
714
  {
715
715
  xmlns: "http://www.w3.org/2000/svg",
716
- width: O(n),
717
- height: O(n),
716
+ width: W(n),
717
+ height: W(n),
718
718
  viewBox: "0 0 20 20",
719
719
  fill: "none",
720
720
  children: /* @__PURE__ */ a(
@@ -740,15 +740,15 @@ const O = (e) => {
740
740
  onChange: l,
741
741
  minDate: u,
742
742
  maxDate: i,
743
- input: g
743
+ input: f
744
744
  }) => {
745
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;
746
+ const [g, r] = A(null);
747
+ let d = new Date(e.getFullYear(), e.getMonth(), 1), v = d.getDay(), M = [];
748
+ const k = e.getMonth(), N = (/* @__PURE__ */ new Date()).toDateString(), m = !!(t.from && !t.to), h = m && g ? g : null;
749
749
  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)
750
+ p === 0 && v === 0 ? d.setDate(d.getDate() - 7) : p === 0 ? d.setDate(
751
+ d.getDate() + (p - v)
752
752
  ) : d.setDate(d.getDate() + 1);
753
753
  let b = {
754
754
  currentMonth: d.getMonth() === k,
@@ -764,7 +764,7 @@ const O = (e) => {
764
764
  }
765
765
  const s = (p) => {
766
766
  n(p);
767
- }, x = (p) => {
767
+ }, w = (p) => {
768
768
  let b = { ...t };
769
769
  if (b.from && b.to)
770
770
  b = { from: p, to: null };
@@ -787,23 +787,23 @@ const O = (e) => {
787
787
  const E = t.from && t.to && p.date.getTime() > t.from.getTime() && p.date.getTime() < t.to.getTime(), S = (() => {
788
788
  if (!h || !t.from)
789
789
  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)" : "";
790
+ const Y = p.date.getTime(), D = t.from.getTime(), L = h.getTime();
791
+ return L > D ? Y > D && Y < L : Y < D && Y > L;
792
+ })(), C = 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
793
  return /* @__PURE__ */ a(
794
794
  "p",
795
795
  {
796
- className: `${p.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${p.selected || D ? "sa-calendar-days-active" : ""} ${p.isToday && !p.selected ? "sa-calendar-days-today" : ""}`,
796
+ 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" : ""}`,
797
797
  style: {
798
798
  backgroundColor: I(),
799
799
  pointerEvents: F ? "none" : void 0,
800
800
  cursor: F ? "not-allowed" : "pointer",
801
801
  color: T(),
802
- opacity: D && !p.selected ? 0.75 : 1,
803
- ...g ? {} : { width: "100%" }
802
+ opacity: C && !p.selected ? 0.75 : 1,
803
+ ...f ? {} : { width: "100%" }
804
804
  },
805
805
  onClick: () => {
806
- F || (s(p.date), x(p.date));
806
+ F || (s(p.date), w(p.date));
807
807
  },
808
808
  onMouseEnter: () => {
809
809
  F || r(p.date);
@@ -824,12 +824,12 @@ const O = (e) => {
824
824
  dateRange: l,
825
825
  setDateRange: u,
826
826
  onChange: i,
827
- minDate: g,
828
- maxDate: f,
827
+ minDate: f,
828
+ maxDate: g,
829
829
  input: r
830
830
  }) => {
831
831
  var N;
832
- const d = (N = l.from) == null ? void 0 : N.getFullYear(), w = e.getFullYear(), M = (m) => {
832
+ const d = (N = l.from) == null ? void 0 : N.getFullYear(), v = e.getFullYear(), M = (m) => {
833
833
  t ? (k(m), n(m)) : (o("days"), n(m));
834
834
  }, k = (m) => {
835
835
  let h = { ...l };
@@ -843,22 +843,22 @@ const O = (e) => {
843
843
  }
844
844
  u(h), i(h);
845
845
  };
846
- return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: W.map((m, h) => {
846
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: R.map((m, h) => {
847
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;
848
+ const s = l.from != null && new Date(v, h).getTime() > l.from.getTime() && new Date(v, h).getTime() < (((z = l.to) == null ? void 0 : z.getTime()) || l.from.getTime()), w = f && new Date(v, h) < f || g && new Date(v, h) > g;
849
849
  return /* @__PURE__ */ a(
850
850
  "p",
851
851
  {
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" : "",
852
+ 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
853
  style: {
854
854
  backgroundColor: s ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
855
- pointerEvents: x ? "none" : void 0,
856
- cursor: x ? "not-allowed" : "pointer",
857
- color: x ? "var(--sa-color-gray-400, #b7b9be)" : s ? "var(--sa-color-gray-500, #8c8f97)" : "",
855
+ pointerEvents: w ? "none" : void 0,
856
+ cursor: w ? "not-allowed" : "pointer",
857
+ color: w ? "var(--sa-color-gray-400, #b7b9be)" : s ? "var(--sa-color-gray-500, #8c8f97)" : "",
858
858
  ...r ? {} : { width: "100%" }
859
859
  },
860
860
  onClick: () => {
861
- x || M(new Date(w, h));
861
+ w || M(new Date(v, h));
862
862
  },
863
863
  children: m.slice(0, 3)
864
864
  },
@@ -876,15 +876,15 @@ const O = (e) => {
876
876
  dateRange: l,
877
877
  setDateRange: u,
878
878
  onChange: i,
879
- minDate: g,
880
- maxDate: f,
879
+ minDate: f,
880
+ maxDate: g,
881
881
  input: r
882
882
  }) => {
883
- var x, z;
883
+ var w, z;
884
884
  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();
885
+ const v = e.getFullYear(), { start: M, end: k } = q(v), N = (w = l.from) == null ? void 0 : w.getFullYear(), m = (z = l.to) == null ? void 0 : z.getFullYear();
886
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;
887
+ const y = new Date(c, 0), p = (!f || y >= f) && (!g || y <= g), b = N != null && c === N || m != null && c === m, E = l.from != null && l.to != null && y > l.from && y < l.to;
888
888
  d.push({
889
889
  year: c,
890
890
  active: b && p,
@@ -964,7 +964,7 @@ const O = (e) => {
964
964
  }
965
965
  )
966
966
  }
967
- ), gn = ({
967
+ ), fn = ({
968
968
  setViews: e,
969
969
  views: n,
970
970
  filter: t,
@@ -983,7 +983,7 @@ const O = (e) => {
983
983
  return;
984
984
  }
985
985
  l((r) => new Date(r.getFullYear(), r.getMonth() + 1));
986
- }, g = () => {
986
+ }, f = () => {
987
987
  if (n === "years") {
988
988
  l((r) => new Date(r.getFullYear() - 10, 0));
989
989
  return;
@@ -1002,19 +1002,19 @@ const O = (e) => {
1002
1002
  return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1003
1003
  /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
1004
1004
  if (n === "days")
1005
- return `${W[o.getMonth()]} ${o.getFullYear()}`;
1005
+ return `${R[o.getMonth()]} ${o.getFullYear()}`;
1006
1006
  if (n === "months")
1007
1007
  return `${o.getFullYear()}`;
1008
1008
  if (n === "years")
1009
1009
  return `${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`;
1010
1010
  })() }),
1011
1011
  /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
1012
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(tn, {}) }),
1012
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: f, children: /* @__PURE__ */ a(tn, {}) }),
1013
1013
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ a(sn, {}) })
1014
1014
  ] })
1015
1015
  ] });
1016
1016
  };
1017
- function P(e) {
1017
+ function H(e) {
1018
1018
  const n = new Date(e), t = n.getFullYear(), o = n.getMonth();
1019
1019
  return `${n.getDate().toString().padStart(2, "0")} ${ln[o]} ${t}`;
1020
1020
  }
@@ -1026,17 +1026,17 @@ const on = ({
1026
1026
  description: l,
1027
1027
  helperText: u,
1028
1028
  errorText: i,
1029
- fullWidth: g,
1030
- children: f
1029
+ fullWidth: f,
1030
+ children: g
1031
1031
  }) => {
1032
1032
  const r = [
1033
1033
  "sa-date-field",
1034
- g ? "sa-date-field-fullwidth" : ""
1034
+ f ? "sa-date-field-fullwidth" : ""
1035
1035
  ].filter(Boolean).join(" "), d = e ? /* @__PURE__ */ $("div", { className: "sa-date-field-label-row", children: [
1036
1036
  /* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: e }),
1037
1037
  o && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
1038
1038
  t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
1039
- ] }) : null, w = /* @__PURE__ */ $(en, { children: [
1039
+ ] }) : null, v = /* @__PURE__ */ $(en, { children: [
1040
1040
  u && !i && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: u }),
1041
1041
  i && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: i })
1042
1042
  ] });
@@ -1046,26 +1046,26 @@ const on = ({
1046
1046
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l })
1047
1047
  ] }),
1048
1048
  /* @__PURE__ */ $("div", { className: "sa-date-field-input-wrap", children: [
1049
- f,
1050
- w
1049
+ g,
1050
+ v
1051
1051
  ] })
1052
1052
  ] }) : /* @__PURE__ */ $("div", { className: r, children: [
1053
1053
  d,
1054
1054
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
1055
- f,
1056
- w
1055
+ g,
1056
+ v
1057
1057
  ] }) : /* @__PURE__ */ $("div", { className: r, children: [
1058
1058
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
1059
- f,
1060
- w
1059
+ g,
1060
+ v
1061
1061
  ] });
1062
- }, X = "sa-calendar-styles", fn = (e) => {
1062
+ }, X = "sa-calendar-styles", gn = (e) => {
1063
1063
  if (!document.getElementById(X)) {
1064
1064
  const n = document.createElement("style");
1065
1065
  n.id = X, n.textContent = e, document.head.appendChild(n);
1066
1066
  }
1067
1067
  };
1068
- fn(R);
1068
+ gn(J);
1069
1069
  const mn = K(
1070
1070
  ({
1071
1071
  value: e,
@@ -1075,29 +1075,29 @@ const mn = K(
1075
1075
  disabled: l,
1076
1076
  minDate: u,
1077
1077
  maxDate: i,
1078
- placeholder: g,
1079
- size: f = "sm",
1078
+ placeholder: f,
1079
+ size: g = "sm",
1080
1080
  variant: r,
1081
1081
  status: d,
1082
- clearable: w,
1082
+ clearable: v,
1083
1083
  fullWidth: M = !0,
1084
1084
  withPadding: k = !0,
1085
1085
  label: N,
1086
1086
  labelPosition: m,
1087
1087
  required: h,
1088
1088
  optional: s,
1089
- description: x,
1089
+ description: w,
1090
1090
  helperText: z,
1091
1091
  errorText: c
1092
1092
  }, 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({
1093
+ const p = c ? "error" : d, { ref: b, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), C = P(null), [F, I] = A("days"), [T, Y] = A(/* @__PURE__ */ new Date()), [D, L] = A({
1094
1094
  from: (e == null ? void 0 : e.from) ?? null,
1095
1095
  to: (e == null ? void 0 : e.to) ?? null
1096
1096
  });
1097
1097
  B(() => {
1098
1098
  if (e) {
1099
- const v = e;
1100
- v.from && Y(v.from), L(v);
1099
+ const x = e;
1100
+ x.from && Y(x.from), L(x);
1101
1101
  } else
1102
1102
  Y(/* @__PURE__ */ new Date()), L({ from: null, to: null });
1103
1103
  }, [e]), B(() => {
@@ -1108,32 +1108,29 @@ const mn = K(
1108
1108
  o || S(!0);
1109
1109
  }, [o]);
1110
1110
  const G = () => {
1111
- var v, V;
1111
+ var x, V;
1112
1112
  if (!e)
1113
1113
  return "";
1114
1114
  if (t) {
1115
1115
  if (F === "days")
1116
- return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
1116
+ return `${H(D.from)} ~ ${H(D.to || D.from) || "-"}`;
1117
1117
  if (F === "months")
1118
- return `${W[C.from.getMonth()]} ~ ${C.to ? W[C.to.getMonth()] : "-"}`;
1118
+ return `${R[D.from.getMonth()]} ~ ${D.to ? R[D.to.getMonth()] : "-"}`;
1119
1119
  if (F === "years")
1120
- return `${(v = C.from) == null ? void 0 : v.getFullYear()} ~ ${((V = C.to) == null ? void 0 : V.getFullYear()) || "-"}`;
1120
+ return `${(x = D.from) == null ? void 0 : x.getFullYear()} ~ ${((V = D.to) == null ? void 0 : V.getFullYear()) || "-"}`;
1121
1121
  } else
1122
- return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
1122
+ return `${H(D.from)} ~ ${H(D.to || D.from) || "-"}`;
1123
1123
  }, j = () => {
1124
- 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`;
1124
+ if (C.current && b.current && o) {
1125
+ const x = b.current.getBoundingClientRect(), V = C.current.getBoundingClientRect();
1126
+ window.innerWidth < x.left + V.width ? C.current.style.left = `${x.left - V.width + x.width}px` : C.current.style.left = `${x.left}px`, x.top + V.height > window.innerHeight ? C.current.style.top = `${x.y - (x.height + V.height - 28)}px` : C.current.style.top = `${x.y + x.height}px`;
1127
1127
  }
1128
1128
  };
1129
1129
  B(() => {
1130
- 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
- }, []);
1130
+ C.current && b.current && o && j();
1131
+ }, [C, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1132
+ window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1133
+ }), []);
1137
1134
  const U = /* @__PURE__ */ $(
1138
1135
  "div",
1139
1136
  {
@@ -1152,23 +1149,23 @@ const mn = K(
1152
1149
  onChange: () => {
1153
1150
  },
1154
1151
  disabled: l,
1155
- placeholder: g,
1156
- size: f,
1152
+ placeholder: f,
1153
+ size: g,
1157
1154
  variant: r,
1158
1155
  status: p,
1159
- clearable: w,
1156
+ clearable: v,
1160
1157
  onClear: () => n(void 0)
1161
1158
  }
1162
1159
  ) : null,
1163
1160
  E ? /* @__PURE__ */ $(
1164
1161
  "div",
1165
1162
  {
1166
- className: `sa-calendar sa-calendar-size-${f || "sm"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
1163
+ className: `sa-calendar sa-calendar-size-${g || "sm"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
1167
1164
  style: l ? { pointerEvents: "none" } : void 0,
1168
- ref: D,
1165
+ ref: C,
1169
1166
  children: [
1170
1167
  /* @__PURE__ */ a(
1171
- gn,
1168
+ fn,
1172
1169
  {
1173
1170
  setViews: I,
1174
1171
  views: F,
@@ -1183,7 +1180,7 @@ const mn = K(
1183
1180
  date: T,
1184
1181
  setDate: Y,
1185
1182
  setIsComponentVisible: S,
1186
- dateRange: C,
1183
+ dateRange: D,
1187
1184
  setDateRange: L,
1188
1185
  input: o,
1189
1186
  onChange: n,
@@ -1197,7 +1194,7 @@ const mn = K(
1197
1194
  setDate: Y,
1198
1195
  filter: t,
1199
1196
  setViews: I,
1200
- dateRange: C,
1197
+ dateRange: D,
1201
1198
  setDateRange: L,
1202
1199
  setIsComponentVisible: S,
1203
1200
  input: o,
@@ -1212,7 +1209,7 @@ const mn = K(
1212
1209
  setDate: Y,
1213
1210
  filter: t,
1214
1211
  setViews: I,
1215
- dateRange: C,
1212
+ dateRange: D,
1216
1213
  setDateRange: L,
1217
1214
  setIsComponentVisible: S,
1218
1215
  input: o,
@@ -1234,7 +1231,7 @@ const mn = K(
1234
1231
  labelPosition: m,
1235
1232
  required: h,
1236
1233
  optional: s,
1237
- description: x,
1234
+ description: w,
1238
1235
  helperText: z,
1239
1236
  errorText: c,
1240
1237
  fullWidth: M,
@@ -1248,8 +1245,8 @@ const mn = K(
1248
1245
  n.id = _, n.textContent = e, document.head.appendChild(n);
1249
1246
  }
1250
1247
  };
1251
- bn(R);
1252
- const H = (e) => {
1248
+ bn(J);
1249
+ const O = (e) => {
1253
1250
  if (e === "xs")
1254
1251
  return 14;
1255
1252
  if (e === "sm")
@@ -1266,23 +1263,23 @@ const H = (e) => {
1266
1263
  clearable: l,
1267
1264
  onClear: u,
1268
1265
  ...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) => {
1266
+ } = e, f = P(null), g = () => {
1267
+ f.current && i.onClick && (f.current.focus(), i.onClick(""));
1268
+ }, r = t === "disable" || i.disabled, d = !!i.value, v = l && d && !r, M = (k) => {
1272
1269
  k.stopPropagation(), u == null || u();
1273
1270
  };
1274
1271
  return /* @__PURE__ */ $(
1275
1272
  "div",
1276
1273
  {
1277
1274
  className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${n} `,
1278
- onClick: f,
1275
+ onClick: g,
1279
1276
  children: [
1280
1277
  /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
1281
1278
  "svg",
1282
1279
  {
1283
1280
  xmlns: "http://www.w3.org/2000/svg",
1284
- width: H(n),
1285
- height: H(n),
1281
+ width: O(n),
1282
+ height: O(n),
1286
1283
  viewBox: "0 0 20 20",
1287
1284
  fill: "none",
1288
1285
  children: /* @__PURE__ */ a(
@@ -1304,10 +1301,10 @@ const H = (e) => {
1304
1301
  ...i,
1305
1302
  disabled: r,
1306
1303
  value: i.value,
1307
- ref: g
1304
+ ref: f
1308
1305
  }
1309
1306
  ) }),
1310
- w ? /* @__PURE__ */ a(
1307
+ v ? /* @__PURE__ */ a(
1311
1308
  "button",
1312
1309
  {
1313
1310
  type: "button",
@@ -1318,8 +1315,8 @@ const H = (e) => {
1318
1315
  "svg",
1319
1316
  {
1320
1317
  xmlns: "http://www.w3.org/2000/svg",
1321
- width: H(n),
1322
- height: H(n),
1318
+ width: O(n),
1319
+ height: O(n),
1323
1320
  viewBox: "0 0 20 20",
1324
1321
  fill: "none",
1325
1322
  children: /* @__PURE__ */ a(
@@ -1339,8 +1336,8 @@ const H = (e) => {
1339
1336
  "svg",
1340
1337
  {
1341
1338
  xmlns: "http://www.w3.org/2000/svg",
1342
- width: H(n),
1343
- height: H(n),
1339
+ width: O(n),
1340
+ height: O(n),
1344
1341
  viewBox: "0 0 20 20",
1345
1342
  fill: "none",
1346
1343
  children: /* @__PURE__ */ a(
@@ -1366,21 +1363,21 @@ const H = (e) => {
1366
1363
  setIsComponentVisible: l,
1367
1364
  minDate: u,
1368
1365
  maxDate: i,
1369
- input: g,
1370
- onChange: f,
1366
+ input: f,
1367
+ onChange: g,
1371
1368
  hasValue: r
1372
1369
  }) => {
1373
1370
  let d = new Date(
1374
1371
  t.getFullYear(),
1375
1372
  t.getMonth(),
1376
1373
  1
1377
- ), w = d.getDay(), M = [];
1374
+ ), v = d.getDay(), M = [];
1378
1375
  const k = e.toDateString(), N = (/* @__PURE__ */ new Date()).toDateString(), m = t.getMonth();
1379
1376
  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)
1377
+ s === 0 && v === 0 ? d.setDate(d.getDate() - 7) : s === 0 ? d.setDate(
1378
+ d.getDate() + (s - v)
1382
1379
  ) : d.setDate(d.getDate() + 1);
1383
- let x = {
1380
+ let w = {
1384
1381
  currentMonth: d.getMonth() === m,
1385
1382
  date: new Date(d),
1386
1383
  month: d.getMonth(),
@@ -1390,14 +1387,14 @@ const H = (e) => {
1390
1387
  year: d.getFullYear(),
1391
1388
  isDisabled: u && d < u || i && d > i
1392
1389
  };
1393
- M.push(x);
1390
+ M.push(w);
1394
1391
  }
1395
1392
  const h = (s) => {
1396
- (!u || s >= u) && (!i || s <= i) && (n(s), f(s), o(s), g && l(!1));
1393
+ (!u || s >= u) && (!i || s <= i) && (n(s), g(s), o(s), f && l(!1));
1397
1394
  };
1398
1395
  return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
1399
- /* @__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) => {
1396
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: an.map((s, w) => /* @__PURE__ */ a("p", { children: s }, w)) }),
1397
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((s, w) => {
1401
1398
  const z = s.isDisabled;
1402
1399
  return /* @__PURE__ */ a(
1403
1400
  "p",
@@ -1407,14 +1404,14 @@ const H = (e) => {
1407
1404
  color: z ? "#ccc" : void 0,
1408
1405
  pointerEvents: z ? "none" : void 0,
1409
1406
  cursor: z ? "not-allowed" : "pointer",
1410
- ...g ? {} : { width: "100%" }
1407
+ ...f ? {} : { width: "100%" }
1411
1408
  },
1412
1409
  onClick: () => {
1413
1410
  z || h(s.date);
1414
1411
  },
1415
1412
  children: s.number
1416
1413
  },
1417
- x
1414
+ w
1418
1415
  );
1419
1416
  }) })
1420
1417
  ] });
@@ -1426,20 +1423,20 @@ const H = (e) => {
1426
1423
  onChange: l,
1427
1424
  previewDate: u,
1428
1425
  setPreviewDate: i,
1429
- minDate: g,
1430
- maxDate: f,
1426
+ minDate: f,
1427
+ maxDate: g,
1431
1428
  input: r,
1432
1429
  hasValue: d
1433
1430
  }) => {
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)));
1431
+ const v = e.getMonth(), M = e.getFullYear(), k = u.getFullYear(), N = (m) => {
1432
+ (!f || m >= f) && (!g || m <= g) && (t ? (l(m), n(m), i(m)) : (o("days"), i(m)));
1436
1433
  };
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;
1434
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: R.map((m, h) => {
1435
+ const s = f && new Date(k, h, 1) < f || g && new Date(k, h + 1, 0) > g;
1439
1436
  return /* @__PURE__ */ a(
1440
1437
  "p",
1441
1438
  {
1442
- className: d && h === w && k === M ? "sa-calendar-months-active" : "",
1439
+ className: d && h === v && k === M ? "sa-calendar-months-active" : "",
1443
1440
  style: {
1444
1441
  color: s ? "#ccc" : void 0,
1445
1442
  pointerEvents: s ? "none" : void 0,
@@ -1465,25 +1462,25 @@ const H = (e) => {
1465
1462
  onChange: l,
1466
1463
  previewDate: u,
1467
1464
  setPreviewDate: i,
1468
- minDate: g,
1469
- maxDate: f,
1465
+ minDate: f,
1466
+ maxDate: g,
1470
1467
  input: r,
1471
1468
  hasValue: d
1472
1469
  }) => {
1473
- let w = [];
1470
+ let v = [];
1474
1471
  const M = u.getFullYear(), { start: k, end: N } = Z(M), m = e.getFullYear();
1475
1472
  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({
1473
+ let w = f && new Date(s, 0, 1) < f || g && new Date(s, 11, 31) > g;
1474
+ v.push({
1478
1475
  year: s,
1479
1476
  active: !!d && s === m,
1480
- isDisabled: x
1477
+ isDisabled: w
1481
1478
  });
1482
1479
  }
1483
1480
  const h = (s) => {
1484
- (!g || s >= g) && (!f || s <= f) && (n ? (l(s), o(s), i(s)) : (t("months"), i(s)));
1481
+ (!f || s >= f) && (!g || s <= g) && (n ? (l(s), o(s), i(s)) : (t("months"), i(s)));
1485
1482
  };
1486
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: w.map((s, x) => /* @__PURE__ */ a(
1483
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: v.map((s, w) => /* @__PURE__ */ a(
1487
1484
  "p",
1488
1485
  {
1489
1486
  className: s.active ? "sa-calendar-months-active" : "",
@@ -1498,7 +1495,7 @@ const H = (e) => {
1498
1495
  },
1499
1496
  children: s.year
1500
1497
  },
1501
- x
1498
+ w
1502
1499
  )) });
1503
1500
  }, kn = ({
1504
1501
  setViews: e,
@@ -1521,7 +1518,7 @@ const H = (e) => {
1521
1518
  return;
1522
1519
  }
1523
1520
  l((r) => new Date(r.getFullYear(), r.getMonth() + 1));
1524
- }, g = () => {
1521
+ }, f = () => {
1525
1522
  if (n === "years") {
1526
1523
  l((r) => new Date(r.getFullYear() - 10, 0));
1527
1524
  return;
@@ -1542,14 +1539,14 @@ const H = (e) => {
1542
1539
  return /* @__PURE__ */ $("div", { className: "sa-calendar-header", children: [
1543
1540
  /* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: u, children: (() => {
1544
1541
  if (n === "days")
1545
- return `${W[o.getMonth()]} ${o.getFullYear()}`;
1542
+ return `${R[o.getMonth()]} ${o.getFullYear()}`;
1546
1543
  if (n === "months")
1547
1544
  return `${o.getFullYear()}`;
1548
1545
  if (n === "years")
1549
1546
  return `${Z(o.getFullYear()).start} ~ ${Z(o.getFullYear()).end}`;
1550
1547
  })() }),
1551
1548
  /* @__PURE__ */ $("div", { className: "sa-calendar-header-nav", children: [
1552
- /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(tn, {}) }),
1549
+ /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: f, children: /* @__PURE__ */ a(tn, {}) }),
1553
1550
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ a(sn, {}) })
1554
1551
  ] })
1555
1552
  ] });
@@ -1559,8 +1556,8 @@ const H = (e) => {
1559
1556
  n.id = nn, n.textContent = e, document.head.appendChild(n);
1560
1557
  }
1561
1558
  };
1562
- Mn(R);
1563
- const Cn = K(
1559
+ Mn(J);
1560
+ const Dn = K(
1564
1561
  ({
1565
1562
  value: e,
1566
1563
  onChange: n,
@@ -1569,22 +1566,22 @@ const Cn = K(
1569
1566
  disabled: l,
1570
1567
  minDate: u,
1571
1568
  maxDate: i,
1572
- placeholder: g,
1573
- size: f = "sm",
1569
+ placeholder: f,
1570
+ size: g = "sm",
1574
1571
  variant: r,
1575
1572
  status: d,
1576
- clearable: w,
1573
+ clearable: v,
1577
1574
  fullWidth: M = !0,
1578
1575
  withPadding: k = !0,
1579
1576
  label: N,
1580
1577
  labelPosition: m,
1581
1578
  required: h,
1582
1579
  optional: s,
1583
- description: x,
1580
+ description: w,
1584
1581
  helperText: z,
1585
1582
  errorText: c
1586
1583
  }, 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());
1584
+ const p = c ? "error" : d, { ref: b, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), C = P(null), [F, I] = A("days"), [T, Y] = A(/* @__PURE__ */ new Date()), [D, L] = A(/* @__PURE__ */ new Date());
1588
1585
  B(() => {
1589
1586
  e ? (Y(e), L(e)) : (Y(/* @__PURE__ */ new Date()), L(/* @__PURE__ */ new Date()));
1590
1587
  }, [e]), B(() => {
@@ -1594,20 +1591,17 @@ const Cn = K(
1594
1591
  }, [E]), B(() => {
1595
1592
  o || S(!0);
1596
1593
  }, [o]);
1597
- const G = () => e ? t === "days" ? P(T) : t === "months" ? `${W[T.getMonth()]} ${T.getFullYear()}` : t === "years" ? T.getFullYear() : P(T) : "", j = () => {
1598
- 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`;
1594
+ const G = () => e ? t === "days" ? H(T) : t === "months" ? `${R[T.getMonth()]} ${T.getFullYear()}` : t === "years" ? T.getFullYear() : H(T) : "", j = () => {
1595
+ if (C.current && b.current && o) {
1596
+ const x = b.current.getBoundingClientRect(), V = C.current.getBoundingClientRect();
1597
+ window.innerWidth < x.left + V.width ? C.current.style.left = `${x.left - V.width + x.width}px` : C.current.style.left = `${x.left}px`, x.top + V.height > window.innerHeight ? C.current.style.top = `${x.y - (x.height + V.height - 28)}px` : C.current.style.top = `${x.y + x.height}px`;
1601
1598
  }
1602
1599
  };
1603
1600
  B(() => {
1604
- 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
- }, []);
1601
+ C.current && b.current && o && j();
1602
+ }, [C, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1603
+ window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1604
+ }), []);
1611
1605
  const U = /* @__PURE__ */ $(
1612
1606
  "div",
1613
1607
  {
@@ -1622,22 +1616,22 @@ const Cn = K(
1622
1616
  onClick: () => S(!0),
1623
1617
  onChange: () => {
1624
1618
  },
1625
- placeholder: g,
1619
+ placeholder: f,
1626
1620
  disabled: l,
1627
- size: f,
1621
+ size: g,
1628
1622
  variant: r,
1629
1623
  status: p,
1630
1624
  inputMode: "none",
1631
- clearable: w,
1625
+ clearable: v,
1632
1626
  onClear: () => n(void 0)
1633
1627
  }
1634
1628
  ) : null,
1635
1629
  E ? /* @__PURE__ */ $(
1636
1630
  "div",
1637
1631
  {
1638
- className: `sa-calendar sa-calendar-size-${f || "sm"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
1632
+ className: `sa-calendar sa-calendar-size-${g || "sm"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
1639
1633
  style: l ? { pointerEvents: "none" } : void 0,
1640
- ref: D,
1634
+ ref: C,
1641
1635
  children: [
1642
1636
  /* @__PURE__ */ a(
1643
1637
  kn,
@@ -1645,7 +1639,7 @@ const Cn = K(
1645
1639
  setViews: I,
1646
1640
  views: F,
1647
1641
  filter: t,
1648
- previewDate: C,
1642
+ previewDate: D,
1649
1643
  setPreviewDate: L,
1650
1644
  isComponentVisible: E
1651
1645
  }
@@ -1655,7 +1649,7 @@ const Cn = K(
1655
1649
  {
1656
1650
  date: T,
1657
1651
  setDate: Y,
1658
- previewDate: C,
1652
+ previewDate: D,
1659
1653
  setPreviewDate: L,
1660
1654
  setIsComponentVisible: S,
1661
1655
  input: o,
@@ -1669,7 +1663,7 @@ const Cn = K(
1669
1663
  {
1670
1664
  date: T,
1671
1665
  setDate: Y,
1672
- previewDate: C,
1666
+ previewDate: D,
1673
1667
  setPreviewDate: L,
1674
1668
  filter: t,
1675
1669
  setViews: I,
@@ -1684,7 +1678,7 @@ const Cn = K(
1684
1678
  {
1685
1679
  date: T,
1686
1680
  setDate: Y,
1687
- previewDate: C,
1681
+ previewDate: D,
1688
1682
  setPreviewDate: L,
1689
1683
  filter: t,
1690
1684
  setViews: I,
@@ -1708,7 +1702,7 @@ const Cn = K(
1708
1702
  labelPosition: m,
1709
1703
  required: h,
1710
1704
  optional: s,
1711
- description: x,
1705
+ description: w,
1712
1706
  helperText: z,
1713
1707
  errorText: c,
1714
1708
  fullWidth: M,
@@ -1725,18 +1719,18 @@ const Cn = K(
1725
1719
  rangedDate: l,
1726
1720
  disabled: u,
1727
1721
  minDate: i,
1728
- maxDate: g,
1729
- placeholder: f,
1722
+ maxDate: f,
1723
+ placeholder: g,
1730
1724
  size: r,
1731
1725
  variant: d,
1732
- status: w,
1726
+ status: v,
1733
1727
  clearable: M,
1734
1728
  fullWidth: k,
1735
1729
  withPadding: N,
1736
1730
  label: m,
1737
1731
  labelPosition: h,
1738
1732
  required: s,
1739
- optional: x,
1733
+ optional: w,
1740
1734
  description: z,
1741
1735
  helperText: c,
1742
1736
  errorText: y
@@ -1748,23 +1742,23 @@ const Cn = K(
1748
1742
  filter: t,
1749
1743
  disabled: u,
1750
1744
  minDate: i,
1751
- maxDate: g,
1752
- placeholder: f,
1745
+ maxDate: f,
1746
+ placeholder: g,
1753
1747
  size: r,
1754
1748
  variant: d,
1755
- status: w,
1749
+ status: v,
1756
1750
  clearable: M,
1757
1751
  fullWidth: k,
1758
1752
  withPadding: N,
1759
1753
  label: m,
1760
1754
  labelPosition: h,
1761
1755
  required: s,
1762
- optional: x,
1756
+ optional: w,
1763
1757
  description: z,
1764
1758
  helperText: c,
1765
1759
  errorText: y
1766
1760
  };
1767
- return /* @__PURE__ */ a(en, { children: l ? /* @__PURE__ */ a(mn, { ...b, ref: p }) : /* @__PURE__ */ a(Cn, { ...b, ref: p }) });
1761
+ return /* @__PURE__ */ a(en, { children: l ? /* @__PURE__ */ a(mn, { ...b, ref: p }) : /* @__PURE__ */ a(Dn, { ...b, ref: p }) });
1768
1762
  }
1769
1763
  );
1770
1764
  export {
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;
@@ -579,4 +579,4 @@
579
579
  width: 32px;
580
580
  height: 32px;
581
581
  }
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"})});
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]=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,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})}),y?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,x;const[f,r]=w.useState(null);let d=new Date(a.getFullYear(),a.getMonth(),1),y=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&&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()===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())||((x=s.from)==null?void 0:x.toDateString())),isToday:d.toDateString()===z,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};D.push(v)}const t=p=>{e(p)},m=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),m(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(),y=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,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()),m=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:m?"none":void 0,cursor:m?"not-allowed":"pointer",color:m?"var(--sa-color-gray-400, #b7b9be)":t?"var(--sa-color-gray-500, #8c8f97)":"",...r?{}:{width:"100%"}},onClick:()=>{m||D(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 m,$;let d=[];const y=a.getFullYear(),{start:D,end:M}=J(y),z=(m=l.from)==null?void 0:m.getFullYear(),b=($=l.to)==null?void 0:$.getFullYear();for(let c=D;c<M;c++){const x=new Date(c,0),p=(!g||x>=g)&&(!f||x<=f),v=z!=null&&c===z||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,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,y=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,y]})]}):n.jsxs("div",{className:r,children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),f,y]}):n.jsxs("div",{className:r,children:[l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),f,y]})},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:D=!0,withPadding:M=!0,label:z,labelPosition:b,required:u,optional:t,description:m,helperText:$,errorText:c},x)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),N=w.useRef(null),[E,I]=w.useState("days"),[L,Y]=w.useState(new Date),[C,F]=w.useState({from:(a==null?void 0:a.from)??null,to:(a==null?void 0:a.to)??null});w.useEffect(()=>{if(a){const k=a;k.from&&Y(k.from),F(k)}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 k,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`${(k=C.from)==null?void 0:k.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 k=v.current.getBoundingClientRect(),j=N.current.getBoundingClientRect();window.innerWidth<k.left+j.width?N.current.style.left=`${k.left-j.width+k.width}px`:N.current.style.left=`${k.left}px`,k.top+j.height>window.innerHeight?N.current.style.top=`${k.y-(k.height+j.height-28)}px`:N.current.style.top=`${k.y+k.height}px`}};w.useEffect(()=>{N.current&&v.current&&o&&B()},[N,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"} ${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:m,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=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,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})}),y?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),y=d.getDay(),D=[];const M=a.toDateString(),z=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 m={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(m)}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,m)=>n.jsx("p",{children:t},m))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((t,m)=>{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},m)})})]})},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(),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===y&&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 y=[];const D=h.getFullYear(),{start:M,end:z}=q(D),b=a.getFullYear();for(let t=M;t<z;t++){let m=g&&new Date(t,0,1)<g||f&&new Date(t,11,31)>f;y.push({year:t,active:!!d&&t===b,isDisabled:m})}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,m)=>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},m))})},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:D=!0,withPadding:M=!0,label:z,labelPosition:b,required:u,optional:t,description:m,helperText:$,errorText:c},x)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),N=w.useRef(null),[E,I]=w.useState("days"),[L,Y]=w.useState(new Date),[C,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(N.current&&v.current&&o){const k=v.current.getBoundingClientRect(),j=N.current.getBoundingClientRect();window.innerWidth<k.left+j.width?N.current.style.left=`${k.left-j.width+k.width}px`:N.current.style.left=`${k.left}px`,k.top+j.height>window.innerHeight?N.current.style.top=`${k.y-(k.height+j.height-28)}px`:N.current.style.top=`${k.y+k.height}px`}};w.useEffect(()=>{N.current&&v.current&&o&&B()},[N,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"} ${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:m,helperText:$,errorText:c,fullWidth:D,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:D,fullWidth:M,withPadding:z,label:b,labelPosition:u,required:t,optional:m,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:D,fullWidth:M,withPadding:z,label:b,labelPosition:u,required:t,optional:m,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.1",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",