@starasia/date 5.3.1 → 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
@@ -68,14 +68,19 @@ const J = `@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 J = `@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;
@@ -642,8 +651,8 @@ const W = (e) => {
642
651
  ...i
643
652
  } = e, f = P(null), g = () => {
644
653
  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
- k.stopPropagation(), u == null || u();
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",
@@ -687,7 +696,7 @@ const W = (e) => {
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
  {
@@ -742,29 +751,29 @@ const W = (e) => {
742
751
  maxDate: i,
743
752
  input: f
744
753
  }) => {
745
- var z, c, y;
754
+ var N, c, y;
746
755
  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;
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
759
  p === 0 && v === 0 ? d.setDate(d.getDate() - 7) : p === 0 ? d.setDate(
751
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);
767
- }, w = (p) => {
776
+ }, x = (p) => {
768
777
  let b = { ...t };
769
778
  if (b.from && b.to)
770
779
  b = { from: p, to: null };
@@ -783,27 +792,27 @@ const W = (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(), 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)" : "";
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
  {
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" : ""}`,
805
+ 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" : ""}`,
797
806
  style: {
798
807
  backgroundColor: I(),
799
808
  pointerEvents: F ? "none" : void 0,
800
809
  cursor: F ? "not-allowed" : "pointer",
801
810
  color: T(),
802
- opacity: C && !p.selected ? 0.75 : 1,
811
+ opacity: D && !p.selected ? 0.75 : 1,
803
812
  ...f ? {} : { width: "100%" }
804
813
  },
805
814
  onClick: () => {
806
- F || (s(p.date), w(p.date));
815
+ F || (s(p.date), x(p.date));
807
816
  },
808
817
  onMouseEnter: () => {
809
818
  F || r(p.date);
@@ -828,10 +837,10 @@ const W = (e) => {
828
837
  maxDate: g,
829
838
  input: r
830
839
  }) => {
831
- var N;
832
- const d = (N = l.from) == null ? void 0 : N.getFullYear(), v = 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 };
@@ -844,28 +853,28 @@ const W = (e) => {
844
853
  u(h), i(h);
845
854
  };
846
855
  return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: R.map((m, h) => {
847
- var z, c, y;
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;
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
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
- 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)" : "",
864
+ pointerEvents: x ? "none" : void 0,
865
+ cursor: x ? "not-allowed" : "pointer",
866
+ color: x ? "var(--sa-color-gray-400, #b7b9be)" : s ? "var(--sa-color-gray-500, #8c8f97)" : "",
858
867
  ...r ? {} : { width: "100%" }
859
868
  },
860
869
  onClick: () => {
861
- w || M(new Date(v, 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 = ({
@@ -880,11 +889,11 @@ const W = (e) => {
880
889
  maxDate: g,
881
890
  input: r
882
891
  }) => {
883
- var w, z;
892
+ var x, N;
884
893
  let d = [];
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
- for (let c = M; c < k; c++) {
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;
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,
@@ -1006,7 +1015,7 @@ const W = (e) => {
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
1021
  /* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: f, children: /* @__PURE__ */ a(tn, {}) }),
@@ -1027,37 +1036,39 @@ const on = ({
1027
1036
  helperText: u,
1028
1037
  errorText: i,
1029
1038
  fullWidth: f,
1030
- children: g
1039
+ size: g = "sm",
1040
+ children: r
1031
1041
  }) => {
1032
- const r = [
1042
+ const d = [
1033
1043
  "sa-date-field",
1044
+ `sa-date-field-size-${g}`,
1034
1045
  f ? "sa-date-field-fullwidth" : ""
1035
- ].filter(Boolean).join(" "), d = e ? /* @__PURE__ */ $("div", { className: "sa-date-field-label-row", children: [
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: "*" })
1039
- ] }) : null, v = /* @__PURE__ */ $(en, { children: [
1050
+ ] }) : null, w = /* @__PURE__ */ $(en, { children: [
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
- g,
1050
- v
1060
+ r,
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
- g,
1056
- v
1057
- ] }) : /* @__PURE__ */ $("div", { className: r, children: [
1066
+ r,
1067
+ w
1068
+ ] }) : /* @__PURE__ */ $("div", { className: d, children: [
1058
1069
  l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
1059
- g,
1060
- v
1070
+ r,
1071
+ w
1061
1072
  ] });
1062
1073
  }, X = "sa-calendar-styles", gn = (e) => {
1063
1074
  if (!document.getElementById(X)) {
@@ -1080,24 +1091,24 @@ const mn = K(
1080
1091
  variant: r,
1081
1092
  status: d,
1082
1093
  clearable: v,
1083
- fullWidth: M = !0,
1084
- withPadding: k = !0,
1085
- label: N,
1094
+ fullWidth: w = !0,
1095
+ withPadding: M = !0,
1096
+ label: C,
1086
1097
  labelPosition: m,
1087
1098
  required: h,
1088
1099
  optional: s,
1089
- description: w,
1090
- helperText: z,
1100
+ description: x,
1101
+ helperText: N,
1091
1102
  errorText: c
1092
1103
  }, y) => {
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({
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 x = e;
1100
- x.from && Y(x.from), L(x);
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,31 +1118,31 @@ const mn = K(
1107
1118
  }, [E]), B(() => {
1108
1119
  o || S(!0);
1109
1120
  }, [o]);
1110
- const G = () => {
1111
- var x, 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 `${H(D.from)} ~ ${H(D.to || D.from) || "-"}`;
1127
+ return `${H(z.from)} ~ ${H(z.to || z.from) || "-"}`;
1117
1128
  if (F === "months")
1118
- return `${R[D.from.getMonth()]} ~ ${D.to ? R[D.to.getMonth()] : "-"}`;
1129
+ return `${R[z.from.getMonth()]} ~ ${z.to ? R[z.to.getMonth()] : "-"}`;
1119
1130
  if (F === "years")
1120
- return `${(x = D.from) == null ? void 0 : x.getFullYear()} ~ ${((V = D.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 `${H(D.from)} ~ ${H(D.to || D.from) || "-"}`;
1133
+ return `${H(z.from)} ~ ${H(z.to || z.from) || "-"}`;
1123
1134
  }, j = () => {
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`;
1135
+ if (D.current && b.current && o) {
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
- C.current && b.current && o && j();
1131
- }, [C, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1141
+ D.current && b.current && o && j();
1142
+ }, [D, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1132
1143
  window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1133
1144
  }), []);
1134
- const U = /* @__PURE__ */ $(
1145
+ const G = /* @__PURE__ */ $(
1135
1146
  "div",
1136
1147
  {
1137
1148
  className: "sa-calendar-wrapper",
@@ -1141,7 +1152,7 @@ const mn = K(
1141
1152
  o ? /* @__PURE__ */ a(
1142
1153
  cn,
1143
1154
  {
1144
- value: G(),
1155
+ value: q(),
1145
1156
  inputMode: "none",
1146
1157
  onClick: () => {
1147
1158
  S(!0);
@@ -1160,9 +1171,9 @@ const mn = K(
1160
1171
  E ? /* @__PURE__ */ $(
1161
1172
  "div",
1162
1173
  {
1163
- className: `sa-calendar sa-calendar-size-${g || "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"}`,
1164
1175
  style: l ? { pointerEvents: "none" } : void 0,
1165
- ref: C,
1176
+ ref: D,
1166
1177
  children: [
1167
1178
  /* @__PURE__ */ a(
1168
1179
  fn,
@@ -1180,7 +1191,7 @@ const mn = K(
1180
1191
  date: T,
1181
1192
  setDate: Y,
1182
1193
  setIsComponentVisible: S,
1183
- dateRange: D,
1194
+ dateRange: z,
1184
1195
  setDateRange: L,
1185
1196
  input: o,
1186
1197
  onChange: n,
@@ -1194,7 +1205,7 @@ const mn = K(
1194
1205
  setDate: Y,
1195
1206
  filter: t,
1196
1207
  setViews: I,
1197
- dateRange: D,
1208
+ dateRange: z,
1198
1209
  setDateRange: L,
1199
1210
  setIsComponentVisible: S,
1200
1211
  input: o,
@@ -1209,7 +1220,7 @@ const mn = K(
1209
1220
  setDate: Y,
1210
1221
  filter: t,
1211
1222
  setViews: I,
1212
- dateRange: D,
1223
+ dateRange: z,
1213
1224
  setDateRange: L,
1214
1225
  setIsComponentVisible: S,
1215
1226
  input: o,
@@ -1227,15 +1238,16 @@ const mn = K(
1227
1238
  return /* @__PURE__ */ a(
1228
1239
  on,
1229
1240
  {
1230
- label: N,
1241
+ label: C,
1231
1242
  labelPosition: m,
1232
1243
  required: h,
1233
1244
  optional: s,
1234
- description: w,
1235
- helperText: z,
1245
+ description: x,
1246
+ helperText: N,
1236
1247
  errorText: c,
1237
- fullWidth: M,
1238
- children: U
1248
+ fullWidth: w,
1249
+ size: g,
1250
+ children: G
1239
1251
  }
1240
1252
  );
1241
1253
  }
@@ -1265,8 +1277,8 @@ const O = (e) => {
1265
1277
  ...i
1266
1278
  } = e, f = P(null), g = () => {
1267
1279
  f.current && i.onClick && (f.current.focus(), i.onClick(""));
1268
- }, r = t === "disable" || i.disabled, d = !!i.value, v = l && d && !r, M = (k) => {
1269
- k.stopPropagation(), u == null || u();
1280
+ }, r = t === "disable" || i.disabled, d = !!i.value, v = l && d && !r, w = (M) => {
1281
+ M.stopPropagation(), u == null || u();
1270
1282
  };
1271
1283
  return /* @__PURE__ */ $(
1272
1284
  "div",
@@ -1310,7 +1322,7 @@ const O = (e) => {
1310
1322
  type: "button",
1311
1323
  "aria-label": "Clear date",
1312
1324
  className: "sa-calendar-input-clear",
1313
- onClick: M,
1325
+ onClick: w,
1314
1326
  children: /* @__PURE__ */ a(
1315
1327
  "svg",
1316
1328
  {
@@ -1371,47 +1383,47 @@ const O = (e) => {
1371
1383
  t.getFullYear(),
1372
1384
  t.getMonth(),
1373
1385
  1
1374
- ), v = d.getDay(), M = [];
1375
- 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();
1376
1388
  for (let s = 0; s < 42; s++) {
1377
1389
  s === 0 && v === 0 ? d.setDate(d.getDate() - 7) : s === 0 ? d.setDate(
1378
1390
  d.getDate() + (s - v)
1379
1391
  ) : d.setDate(d.getDate() + 1);
1380
- let w = {
1392
+ let x = {
1381
1393
  currentMonth: d.getMonth() === m,
1382
1394
  date: new Date(d),
1383
1395
  month: d.getMonth(),
1384
1396
  number: d.getDate(),
1385
- selected: r && d.toDateString() === k,
1386
- isToday: d.toDateString() === N,
1397
+ selected: r && d.toDateString() === M,
1398
+ isToday: d.toDateString() === C,
1387
1399
  year: d.getFullYear(),
1388
1400
  isDisabled: u && d < u || i && d > i
1389
1401
  };
1390
- M.push(w);
1402
+ w.push(x);
1391
1403
  }
1392
1404
  const h = (s) => {
1393
1405
  (!u || s >= u) && (!i || s <= i) && (n(s), g(s), o(s), f && l(!1));
1394
1406
  };
1395
1407
  return /* @__PURE__ */ $("div", { className: "sa-calendar-days-preivew", children: [
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) => {
1398
- const z = s.isDisabled;
1408
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: an.map((s, x) => /* @__PURE__ */ a("p", { children: s }, x)) }),
1409
+ /* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: w.map((s, x) => {
1410
+ const N = s.isDisabled;
1399
1411
  return /* @__PURE__ */ a(
1400
1412
  "p",
1401
1413
  {
1402
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" : ""}`,
1403
1415
  style: {
1404
- color: z ? "#ccc" : void 0,
1405
- pointerEvents: z ? "none" : void 0,
1406
- cursor: z ? "not-allowed" : "pointer",
1416
+ color: N ? "#ccc" : void 0,
1417
+ pointerEvents: N ? "none" : void 0,
1418
+ cursor: N ? "not-allowed" : "pointer",
1407
1419
  ...f ? {} : { width: "100%" }
1408
1420
  },
1409
1421
  onClick: () => {
1410
- z || h(s.date);
1422
+ N || h(s.date);
1411
1423
  },
1412
1424
  children: s.number
1413
1425
  },
1414
- w
1426
+ x
1415
1427
  );
1416
1428
  }) })
1417
1429
  ] });
@@ -1428,15 +1440,15 @@ const O = (e) => {
1428
1440
  input: r,
1429
1441
  hasValue: d
1430
1442
  }) => {
1431
- const v = e.getMonth(), M = e.getFullYear(), k = u.getFullYear(), N = (m) => {
1443
+ const v = e.getMonth(), w = e.getFullYear(), M = u.getFullYear(), C = (m) => {
1432
1444
  (!f || m >= f) && (!g || m <= g) && (t ? (l(m), n(m), i(m)) : (o("days"), i(m)));
1433
1445
  };
1434
1446
  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;
1447
+ const s = f && new Date(M, h, 1) < f || g && new Date(M, h + 1, 0) > g;
1436
1448
  return /* @__PURE__ */ a(
1437
1449
  "p",
1438
1450
  {
1439
- className: d && h === v && k === M ? "sa-calendar-months-active" : "",
1451
+ className: d && h === v && M === w ? "sa-calendar-months-active" : "",
1440
1452
  style: {
1441
1453
  color: s ? "#ccc" : void 0,
1442
1454
  pointerEvents: s ? "none" : void 0,
@@ -1444,7 +1456,7 @@ const O = (e) => {
1444
1456
  ...r ? {} : { width: "100%" }
1445
1457
  },
1446
1458
  onClick: () => {
1447
- s || N(new Date(k, h));
1459
+ s || C(new Date(M, h));
1448
1460
  },
1449
1461
  children: m.slice(0, 3)
1450
1462
  },
@@ -1468,19 +1480,19 @@ const O = (e) => {
1468
1480
  hasValue: d
1469
1481
  }) => {
1470
1482
  let v = [];
1471
- const M = u.getFullYear(), { start: k, end: N } = Z(M), m = e.getFullYear();
1472
- for (let s = k; s < N; s++) {
1473
- let w = f && new Date(s, 0, 1) < f || g && new Date(s, 11, 31) > g;
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;
1474
1486
  v.push({
1475
1487
  year: s,
1476
1488
  active: !!d && s === m,
1477
- isDisabled: w
1489
+ isDisabled: x
1478
1490
  });
1479
1491
  }
1480
1492
  const h = (s) => {
1481
1493
  (!f || s >= f) && (!g || s <= g) && (n ? (l(s), o(s), i(s)) : (t("months"), i(s)));
1482
1494
  };
1483
- return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: v.map((s, w) => /* @__PURE__ */ a(
1495
+ return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: v.map((s, x) => /* @__PURE__ */ a(
1484
1496
  "p",
1485
1497
  {
1486
1498
  className: s.active ? "sa-calendar-months-active" : "",
@@ -1495,7 +1507,7 @@ const O = (e) => {
1495
1507
  },
1496
1508
  children: s.year
1497
1509
  },
1498
- w
1510
+ x
1499
1511
  )) });
1500
1512
  }, kn = ({
1501
1513
  setViews: e,
@@ -1557,7 +1569,7 @@ const O = (e) => {
1557
1569
  }
1558
1570
  };
1559
1571
  Mn(J);
1560
- const Dn = K(
1572
+ const zn = K(
1561
1573
  ({
1562
1574
  value: e,
1563
1575
  onChange: n,
@@ -1571,17 +1583,17 @@ const Dn = K(
1571
1583
  variant: r,
1572
1584
  status: d,
1573
1585
  clearable: v,
1574
- fullWidth: M = !0,
1575
- withPadding: k = !0,
1576
- label: N,
1586
+ fullWidth: w = !0,
1587
+ withPadding: M = !0,
1588
+ label: C,
1577
1589
  labelPosition: m,
1578
1590
  required: h,
1579
1591
  optional: s,
1580
- description: w,
1581
- helperText: z,
1592
+ description: x,
1593
+ helperText: N,
1582
1594
  errorText: c
1583
1595
  }, y) => {
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());
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());
1585
1597
  B(() => {
1586
1598
  e ? (Y(e), L(e)) : (Y(/* @__PURE__ */ new Date()), L(/* @__PURE__ */ new Date()));
1587
1599
  }, [e]), B(() => {
@@ -1591,18 +1603,18 @@ const Dn = K(
1591
1603
  }, [E]), B(() => {
1592
1604
  o || S(!0);
1593
1605
  }, [o]);
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`;
1606
+ const q = () => e ? t === "days" ? H(T) : t === "months" ? `${R[T.getMonth()]} ${T.getFullYear()}` : t === "years" ? T.getFullYear() : H(T) : "", j = () => {
1607
+ if (D.current && b.current && o) {
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`;
1598
1610
  }
1599
1611
  };
1600
1612
  B(() => {
1601
- C.current && b.current && o && j();
1602
- }, [C, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1613
+ D.current && b.current && o && j();
1614
+ }, [D, b, E]), B(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1603
1615
  window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1604
1616
  }), []);
1605
- const U = /* @__PURE__ */ $(
1617
+ const G = /* @__PURE__ */ $(
1606
1618
  "div",
1607
1619
  {
1608
1620
  className: "sa-calendar-wrapper",
@@ -1612,7 +1624,7 @@ const Dn = K(
1612
1624
  o ? /* @__PURE__ */ a(
1613
1625
  vn,
1614
1626
  {
1615
- value: G(),
1627
+ value: q(),
1616
1628
  onClick: () => S(!0),
1617
1629
  onChange: () => {
1618
1630
  },
@@ -1629,9 +1641,9 @@ const Dn = K(
1629
1641
  E ? /* @__PURE__ */ $(
1630
1642
  "div",
1631
1643
  {
1632
- className: `sa-calendar sa-calendar-size-${g || "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"}`,
1633
1645
  style: l ? { pointerEvents: "none" } : void 0,
1634
- ref: C,
1646
+ ref: D,
1635
1647
  children: [
1636
1648
  /* @__PURE__ */ a(
1637
1649
  kn,
@@ -1639,7 +1651,7 @@ const Dn = K(
1639
1651
  setViews: I,
1640
1652
  views: F,
1641
1653
  filter: t,
1642
- previewDate: D,
1654
+ previewDate: z,
1643
1655
  setPreviewDate: L,
1644
1656
  isComponentVisible: E
1645
1657
  }
@@ -1649,7 +1661,7 @@ const Dn = K(
1649
1661
  {
1650
1662
  date: T,
1651
1663
  setDate: Y,
1652
- previewDate: D,
1664
+ previewDate: z,
1653
1665
  setPreviewDate: L,
1654
1666
  setIsComponentVisible: S,
1655
1667
  input: o,
@@ -1663,7 +1675,7 @@ const Dn = K(
1663
1675
  {
1664
1676
  date: T,
1665
1677
  setDate: Y,
1666
- previewDate: D,
1678
+ previewDate: z,
1667
1679
  setPreviewDate: L,
1668
1680
  filter: t,
1669
1681
  setViews: I,
@@ -1678,7 +1690,7 @@ const Dn = K(
1678
1690
  {
1679
1691
  date: T,
1680
1692
  setDate: Y,
1681
- previewDate: D,
1693
+ previewDate: z,
1682
1694
  setPreviewDate: L,
1683
1695
  filter: t,
1684
1696
  setViews: I,
@@ -1698,19 +1710,20 @@ const Dn = K(
1698
1710
  return /* @__PURE__ */ a(
1699
1711
  on,
1700
1712
  {
1701
- label: N,
1713
+ label: C,
1702
1714
  labelPosition: m,
1703
1715
  required: h,
1704
1716
  optional: s,
1705
- description: w,
1706
- helperText: z,
1717
+ description: x,
1718
+ helperText: N,
1707
1719
  errorText: c,
1708
- fullWidth: M,
1709
- children: U
1720
+ fullWidth: w,
1721
+ size: g,
1722
+ children: G
1710
1723
  }
1711
1724
  );
1712
1725
  }
1713
- ), zn = K(
1726
+ ), Nn = K(
1714
1727
  ({
1715
1728
  value: e,
1716
1729
  onChange: n,
@@ -1724,14 +1737,14 @@ const Dn = K(
1724
1737
  size: r,
1725
1738
  variant: d,
1726
1739
  status: v,
1727
- clearable: M,
1728
- fullWidth: k,
1729
- withPadding: N,
1740
+ clearable: w,
1741
+ fullWidth: M,
1742
+ withPadding: C,
1730
1743
  label: m,
1731
1744
  labelPosition: h,
1732
1745
  required: s,
1733
- optional: w,
1734
- description: z,
1746
+ optional: x,
1747
+ description: N,
1735
1748
  helperText: c,
1736
1749
  errorText: y
1737
1750
  }, p) => {
@@ -1747,20 +1760,20 @@ const Dn = K(
1747
1760
  size: r,
1748
1761
  variant: d,
1749
1762
  status: v,
1750
- clearable: M,
1751
- fullWidth: k,
1752
- withPadding: N,
1763
+ clearable: w,
1764
+ fullWidth: M,
1765
+ withPadding: C,
1753
1766
  label: m,
1754
1767
  labelPosition: h,
1755
1768
  required: s,
1756
- optional: w,
1757
- description: z,
1769
+ optional: x,
1770
+ description: N,
1758
1771
  helperText: c,
1759
1772
  errorText: y
1760
1773
  };
1761
- return /* @__PURE__ */ a(en, { children: l ? /* @__PURE__ */ a(mn, { ...b, ref: p }) : /* @__PURE__ */ a(Dn, { ...b, ref: p }) });
1774
+ return /* @__PURE__ */ a(en, { children: l ? /* @__PURE__ */ a(mn, { ...b, ref: p }) : /* @__PURE__ */ a(zn, { ...b, ref: p }) });
1762
1775
  }
1763
1776
  );
1764
1777
  export {
1765
- zn as StarasiaDate
1778
+ Nn as StarasiaDate
1766
1779
  };
package/dist/date.umd.js CHANGED
@@ -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]=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"})});
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.1",
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",