@starasia/date 7.0.3 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/date.es.js CHANGED
@@ -1,6 +1,11 @@
1
1
  import { jsxs as z, jsx as s, Fragment as yn } from "react/jsx-runtime";
2
2
  import wn, { useState as G, useRef as _, useEffect as O, forwardRef as xn, useMemo as tn } from "react";
3
- const gn = `
3
+ const mn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
4
+ starasia, components, utilities). CSS app/Tailwind utility selalu bisa
5
+ menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
6
+ @layer starasia.components {
7
+
8
+
4
9
  * {
5
10
  margin: 0;
6
11
  padding: 0;
@@ -599,6 +604,8 @@ const gn = `
599
604
  width: 32px;
600
605
  height: 32px;
601
606
  }
607
+
608
+ } /* @layer starasia.components */
602
609
  `, Vn = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], Q = [
603
610
  "January",
604
611
  "February",
@@ -640,7 +647,7 @@ const Ln = "sa-calendar-input-styles", Hn = (n) => {
640
647
  e.id = Ln, e.textContent = n, document.head.appendChild(e);
641
648
  }
642
649
  };
643
- Hn(gn);
650
+ Hn(mn);
644
651
  const rn = (n) => {
645
652
  if (n === "xs")
646
653
  return 14;
@@ -763,7 +770,7 @@ const rn = (n) => {
763
770
  var T, y, k;
764
771
  const [h, l] = G(null);
765
772
  let c = new Date(n.getFullYear(), n.getMonth(), 1), w = c.getDay(), M = [];
766
- const E = n.getMonth(), x = (/* @__PURE__ */ new Date()).toDateString(), b = !!(a.from && !a.to), g = b && h ? h : null;
773
+ const E = n.getMonth(), x = (/* @__PURE__ */ new Date()).toDateString(), b = !!(a.from && !a.to), m = b && h ? h : null;
767
774
  for (let v = 0; v < 42; v++) {
768
775
  v === 0 && w === 0 ? c.setDate(c.getDate() - 7) : v === 0 ? c.setDate(
769
776
  c.getDate() + (v - w)
@@ -803,11 +810,11 @@ const rn = (n) => {
803
810
  /* @__PURE__ */ s("div", { className: "sa-calendar-days-name-preivew", children: Vn.map((v, N) => /* @__PURE__ */ s("p", { children: v }, N)) }),
804
811
  /* @__PURE__ */ s("div", { className: "sa-calendar-days-number-preivew", children: M.map((v, N) => {
805
812
  const B = a.from && a.to && v.date.getTime() > a.from.getTime() && v.date.getTime() < a.to.getTime(), H = (() => {
806
- if (!g || !a.from)
813
+ if (!m || !a.from)
807
814
  return !1;
808
- const Y = v.date.getTime(), L = a.from.getTime(), S = g.getTime();
815
+ const Y = v.date.getTime(), L = a.from.getTime(), S = m.getTime();
809
816
  return S > L ? Y > L && Y < S : Y < L && Y > S;
810
- })(), V = b && h && v.date.toDateString() === h.toDateString(), F = v.isDisabled, $ = () => B || H ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", m = () => F ? "var(--sa-color-gray-400, #b7b9be)" : B || H ? "var(--sa-color-gray-500, #8c8f97)" : "";
817
+ })(), V = b && h && v.date.toDateString() === h.toDateString(), F = v.isDisabled, $ = () => B || H ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", g = () => F ? "var(--sa-color-gray-400, #b7b9be)" : B || H ? "var(--sa-color-gray-500, #8c8f97)" : "";
811
818
  return /* @__PURE__ */ s(
812
819
  "p",
813
820
  {
@@ -816,7 +823,7 @@ const rn = (n) => {
816
823
  backgroundColor: $(),
817
824
  pointerEvents: F ? "none" : void 0,
818
825
  cursor: F ? "not-allowed" : "pointer",
819
- color: m(),
826
+ color: g(),
820
827
  opacity: V && !v.selected ? 0.75 : 1,
821
828
  ...p ? {} : { width: "100%" }
822
829
  },
@@ -850,24 +857,24 @@ const rn = (n) => {
850
857
  const c = (x = r.from) == null ? void 0 : x.getFullYear(), w = n.getFullYear(), M = (b) => {
851
858
  a ? (E(b), e(b)) : (o("days"), e(b));
852
859
  }, E = (b) => {
853
- let g = { ...r };
854
- if (g.from && g.to)
855
- g = { from: b, to: null };
856
- else if (!g.from)
857
- g = { from: b, to: null };
860
+ let m = { ...r };
861
+ if (m.from && m.to)
862
+ m = { from: b, to: null };
863
+ else if (!m.from)
864
+ m = { from: b, to: null };
858
865
  else {
859
- const u = g.from.getTime();
860
- b.getTime() > u ? g = { from: g.from, to: b } : g = { from: b, to: g.from };
866
+ const u = m.from.getTime();
867
+ b.getTime() > u ? m = { from: m.from, to: b } : m = { from: b, to: m.from };
861
868
  }
862
- d(g), i(g);
869
+ d(m), i(m);
863
870
  };
864
- return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, g) => {
871
+ return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, m) => {
865
872
  var T, y, k;
866
- const u = r.from != null && new Date(w, g).getTime() > r.from.getTime() && new Date(w, g).getTime() < (((T = r.to) == null ? void 0 : T.getTime()) || r.from.getTime()), C = p && new Date(w, g) < p || h && new Date(w, g) > h;
873
+ const u = r.from != null && new Date(w, m).getTime() > r.from.getTime() && new Date(w, m).getTime() < (((T = r.to) == null ? void 0 : T.getTime()) || r.from.getTime()), C = p && new Date(w, m) < p || h && new Date(w, m) > h;
867
874
  return /* @__PURE__ */ s(
868
875
  "p",
869
876
  {
870
- className: c === w && (g === ((y = r.from) == null ? void 0 : y.getMonth()) || g === ((k = r.to) == null ? void 0 : k.getMonth())) ? "sa-calendar-months-active" : "",
877
+ className: c === w && (m === ((y = r.from) == null ? void 0 : y.getMonth()) || m === ((k = r.to) == null ? void 0 : k.getMonth())) ? "sa-calendar-months-active" : "",
871
878
  style: {
872
879
  backgroundColor: u ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
873
880
  pointerEvents: C ? "none" : void 0,
@@ -876,11 +883,11 @@ const rn = (n) => {
876
883
  ...l ? {} : { width: "100%" }
877
884
  },
878
885
  onClick: () => {
879
- C || M(new Date(w, g));
886
+ C || M(new Date(w, m));
880
887
  },
881
888
  children: b.slice(0, 3)
882
889
  },
883
- g
890
+ m
884
891
  );
885
892
  }) });
886
893
  }, Cn = (n) => {
@@ -910,7 +917,7 @@ const rn = (n) => {
910
917
  disabled: !v
911
918
  });
912
919
  }
913
- const g = (y) => {
920
+ const m = (y) => {
914
921
  e ? (u(y), o(y)) : (o(y), a("months"));
915
922
  }, u = (y) => {
916
923
  let k = { ...r };
@@ -929,7 +936,7 @@ const rn = (n) => {
929
936
  {
930
937
  className: `${y.active ? "sa-calendar-months-active" : ""} ${y.highlight ? "sa-calendar-months-highlight" : ""} ${y.disabled ? "sa-calendar-disabled" : ""}`,
931
938
  onClick: () => {
932
- y.disabled || g(new Date(y.year, 0));
939
+ y.disabled || m(new Date(y.year, 0));
933
940
  },
934
941
  style: {
935
942
  backgroundColor: y.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
@@ -1137,7 +1144,7 @@ const Yn = ({
1137
1144
  e.id = Sn, e.textContent = n, document.head.appendChild(e);
1138
1145
  }
1139
1146
  };
1140
- Zn(gn);
1147
+ Zn(mn);
1141
1148
  const _n = xn(
1142
1149
  ({
1143
1150
  value: n,
@@ -1156,7 +1163,7 @@ const _n = xn(
1156
1163
  withPadding: E = !0,
1157
1164
  editable: x = !1,
1158
1165
  trigger: b,
1159
- renderTrigger: g,
1166
+ renderTrigger: m,
1160
1167
  label: u,
1161
1168
  labelPosition: C,
1162
1169
  required: T,
@@ -1165,7 +1172,7 @@ const _n = xn(
1165
1172
  helperText: v,
1166
1173
  errorText: N
1167
1174
  }, B) => {
1168
- const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), m = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), W = typeof g == "function" || b != null, A = !o && !W, J = !A, [D, K] = G({
1175
+ const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), g = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), W = typeof m == "function" || b != null, A = !o && !W, J = !A, [D, K] = G({
1169
1176
  from: (n == null ? void 0 : n.from) ?? null,
1170
1177
  to: (n == null ? void 0 : n.to) ?? null
1171
1178
  }), [q, U] = G(null);
@@ -1197,14 +1204,14 @@ const _n = xn(
1197
1204
  } else
1198
1205
  return `${on(D.from)} ~ ${on(D.to || D.from) || "-"}`;
1199
1206
  }, j = () => {
1200
- if (m.current && V.current && J) {
1201
- const t = V.current.getBoundingClientRect(), f = m.current.getBoundingClientRect();
1202
- window.innerWidth < t.left + f.width ? m.current.style.left = `${t.left - f.width + t.width}px` : m.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? m.current.style.top = `${t.y - (t.height + f.height - 28)}px` : m.current.style.top = `${t.y + t.height}px`;
1207
+ if (g.current && V.current && J) {
1208
+ const t = V.current.getBoundingClientRect(), f = g.current.getBoundingClientRect();
1209
+ window.innerWidth < t.left + f.width ? g.current.style.left = `${t.left - f.width + t.width}px` : g.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? g.current.style.top = `${t.y - (t.height + f.height - 28)}px` : g.current.style.top = `${t.y + t.height}px`;
1203
1210
  }
1204
1211
  };
1205
1212
  O(() => {
1206
- m.current && V.current && J && j();
1207
- }, [m, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1213
+ g.current && V.current && J && j();
1214
+ }, [g, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1208
1215
  window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1209
1216
  }), []);
1210
1217
  const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
@@ -1241,8 +1248,8 @@ const _n = xn(
1241
1248
  },
1242
1249
  children: [
1243
1250
  W ? (() => {
1244
- if (typeof g == "function")
1245
- return g(pn);
1251
+ if (typeof m == "function")
1252
+ return m(pn);
1246
1253
  if (wn.isValidElement(b)) {
1247
1254
  const t = b;
1248
1255
  return wn.cloneElement(t, {
@@ -1281,7 +1288,7 @@ const _n = xn(
1281
1288
  {
1282
1289
  className: `sa-calendar sa-calendar-size-${h || "sm"} ${A ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
1283
1290
  style: r ? { pointerEvents: "none" } : void 0,
1284
- ref: m,
1291
+ ref: g,
1285
1292
  children: [
1286
1293
  /* @__PURE__ */ s(
1287
1294
  qn,
@@ -1365,7 +1372,7 @@ const _n = xn(
1365
1372
  e.id = In, e.textContent = n, document.head.appendChild(e);
1366
1373
  }
1367
1374
  };
1368
- Qn(gn);
1375
+ Qn(mn);
1369
1376
  const sn = (n) => {
1370
1377
  if (n === "xs")
1371
1378
  return 14;
@@ -1509,7 +1516,7 @@ const sn = (n) => {
1509
1516
  };
1510
1517
  M.push(C);
1511
1518
  }
1512
- const g = (u) => {
1519
+ const m = (u) => {
1513
1520
  (!d || u >= d) && (!i || u <= i) && (e(u), h(u), o(u), p && r(!1));
1514
1521
  };
1515
1522
  return /* @__PURE__ */ z("div", { className: "sa-calendar-days-preivew", children: [
@@ -1527,7 +1534,7 @@ const sn = (n) => {
1527
1534
  ...p ? {} : { width: "100%" }
1528
1535
  },
1529
1536
  onClick: () => {
1530
- T || g(u.date);
1537
+ T || m(u.date);
1531
1538
  },
1532
1539
  children: u.number
1533
1540
  },
@@ -1551,12 +1558,12 @@ const sn = (n) => {
1551
1558
  const w = n.getMonth(), M = n.getFullYear(), E = d.getFullYear(), x = (b) => {
1552
1559
  (!p || b >= p) && (!h || b <= h) && (a ? (r(b), e(b), i(b)) : (o("days"), i(b)));
1553
1560
  };
1554
- return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, g) => {
1555
- const u = p && new Date(E, g, 1) < p || h && new Date(E, g + 1, 0) > h;
1561
+ return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, m) => {
1562
+ const u = p && new Date(E, m, 1) < p || h && new Date(E, m + 1, 0) > h;
1556
1563
  return /* @__PURE__ */ s(
1557
1564
  "p",
1558
1565
  {
1559
- className: c && g === w && E === M ? "sa-calendar-months-active" : "",
1566
+ className: c && m === w && E === M ? "sa-calendar-months-active" : "",
1560
1567
  style: {
1561
1568
  color: u ? "var(--sa-text-disable, #181a198f)" : void 0,
1562
1569
  pointerEvents: u ? "none" : void 0,
@@ -1564,11 +1571,11 @@ const sn = (n) => {
1564
1571
  ...l ? {} : { width: "100%" }
1565
1572
  },
1566
1573
  onClick: () => {
1567
- u || x(new Date(E, g));
1574
+ u || x(new Date(E, m));
1568
1575
  },
1569
1576
  children: b.slice(0, 3)
1570
1577
  },
1571
- g
1578
+ m
1572
1579
  );
1573
1580
  }) });
1574
1581
  }, zn = (n) => {
@@ -1597,7 +1604,7 @@ const sn = (n) => {
1597
1604
  isDisabled: C
1598
1605
  });
1599
1606
  }
1600
- const g = (u) => {
1607
+ const m = (u) => {
1601
1608
  (!p || u >= p) && (!h || u <= h) && (e ? (r(u), o(u), i(u)) : (a("months"), i(u)));
1602
1609
  };
1603
1610
  return /* @__PURE__ */ s("div", { className: "sa-calendar-years-preview", children: w.map((u, C) => /* @__PURE__ */ s(
@@ -1611,7 +1618,7 @@ const sn = (n) => {
1611
1618
  ...l ? {} : { width: "100%" }
1612
1619
  },
1613
1620
  onClick: () => {
1614
- u.isDisabled || g(new Date(u.year, 0));
1621
+ u.isDisabled || m(new Date(u.year, 0));
1615
1622
  },
1616
1623
  children: u.year
1617
1624
  },
@@ -1676,7 +1683,7 @@ const sn = (n) => {
1676
1683
  e.id = Tn, e.textContent = n, document.head.appendChild(e);
1677
1684
  }
1678
1685
  };
1679
- re(gn);
1686
+ re(mn);
1680
1687
  const se = xn(
1681
1688
  ({
1682
1689
  value: n,
@@ -1695,7 +1702,7 @@ const se = xn(
1695
1702
  withPadding: E = !0,
1696
1703
  editable: x = !1,
1697
1704
  trigger: b,
1698
- renderTrigger: g,
1705
+ renderTrigger: m,
1699
1706
  label: u,
1700
1707
  labelPosition: C,
1701
1708
  required: T,
@@ -1704,7 +1711,7 @@ const se = xn(
1704
1711
  helperText: v,
1705
1712
  errorText: N
1706
1713
  }, B) => {
1707
- const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), m = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), [W, A] = G(/* @__PURE__ */ new Date()), [J, D] = G(null), K = typeof g == "function" || b != null, q = !o && !K, U = !q;
1714
+ const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), g = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), [W, A] = G(/* @__PURE__ */ new Date()), [J, D] = G(null), K = typeof m == "function" || b != null, q = !o && !K, U = !q;
1708
1715
  O(() => {
1709
1716
  n ? (I(n), A(n)) : (I(/* @__PURE__ */ new Date()), A(/* @__PURE__ */ new Date())), D(null);
1710
1717
  }, [n]), O(() => {
@@ -1715,14 +1722,14 @@ const se = xn(
1715
1722
  q && $(!0);
1716
1723
  }, [q]);
1717
1724
  const X = () => n ? a === "days" ? on(S) : a === "months" ? `${Q[S.getMonth()]} ${S.getFullYear()}` : a === "years" ? S.getFullYear() : on(S) : "", j = () => {
1718
- if (m.current && V.current && U) {
1719
- const t = V.current.getBoundingClientRect(), f = m.current.getBoundingClientRect();
1720
- window.innerWidth < t.left + f.width ? m.current.style.left = `${t.left - f.width + t.width}px` : m.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? m.current.style.top = `${t.y - (t.height + f.height - 28)}px` : m.current.style.top = `${t.y + t.height}px`;
1725
+ if (g.current && V.current && U) {
1726
+ const t = V.current.getBoundingClientRect(), f = g.current.getBoundingClientRect();
1727
+ window.innerWidth < t.left + f.width ? g.current.style.left = `${t.left - f.width + t.width}px` : g.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? g.current.style.top = `${t.y - (t.height + f.height - 28)}px` : g.current.style.top = `${t.y + t.height}px`;
1721
1728
  }
1722
1729
  };
1723
1730
  O(() => {
1724
- m.current && V.current && U && j();
1725
- }, [m, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1731
+ g.current && V.current && U && j();
1732
+ }, [g, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
1726
1733
  window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
1727
1734
  }), []);
1728
1735
  const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
@@ -1759,8 +1766,8 @@ const se = xn(
1759
1766
  },
1760
1767
  children: [
1761
1768
  K ? (() => {
1762
- if (typeof g == "function")
1763
- return g(pn);
1769
+ if (typeof m == "function")
1770
+ return m(pn);
1764
1771
  if (wn.isValidElement(b)) {
1765
1772
  const t = b;
1766
1773
  return wn.cloneElement(t, {
@@ -1797,7 +1804,7 @@ const se = xn(
1797
1804
  {
1798
1805
  className: `sa-calendar sa-calendar-size-${h || "sm"} ${q ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
1799
1806
  style: r ? { pointerEvents: "none" } : void 0,
1800
- ref: m,
1807
+ ref: g,
1801
1808
  children: [
1802
1809
  /* @__PURE__ */ s(
1803
1810
  te,
@@ -1877,7 +1884,7 @@ const se = xn(
1877
1884
  }
1878
1885
  );
1879
1886
  }
1880
- ), ge = xn(
1887
+ ), me = xn(
1881
1888
  ({
1882
1889
  value: n,
1883
1890
  onChange: e,
@@ -1895,7 +1902,7 @@ const se = xn(
1895
1902
  fullWidth: E,
1896
1903
  withPadding: x,
1897
1904
  editable: b,
1898
- trigger: g,
1905
+ trigger: m,
1899
1906
  renderTrigger: u,
1900
1907
  label: C,
1901
1908
  labelPosition: T,
@@ -1921,7 +1928,7 @@ const se = xn(
1921
1928
  fullWidth: E,
1922
1929
  withPadding: x,
1923
1930
  editable: b,
1924
- trigger: g,
1931
+ trigger: m,
1925
1932
  renderTrigger: u,
1926
1933
  label: C,
1927
1934
  labelPosition: T,
@@ -1933,7 +1940,12 @@ const se = xn(
1933
1940
  };
1934
1941
  return /* @__PURE__ */ s(yn, { children: r ? /* @__PURE__ */ s(_n, { ...V, ref: H }) : /* @__PURE__ */ s(se, { ...V, ref: H }) });
1935
1942
  }
1936
- ), oe = `/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
1943
+ ), oe = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
1944
+ starasia, components, utilities). CSS app/Tailwind utility selalu bisa
1945
+ menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
1946
+ @layer starasia.components {
1947
+
1948
+ /* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
1937
1949
  date.module.css, injected alongside this sheet) and the .sa-calendar /
1938
1950
  .sa-calendar-input-* shells for the box + masked input. */
1939
1951
 
@@ -2064,6 +2076,8 @@ const se = xn(
2064
2076
  .sa-time-input-wrap {
2065
2077
  width: 100%;
2066
2078
  }
2079
+
2080
+ } /* @layer starasia.components */
2067
2081
  `, Nn = (n, e, a) => Math.min(a, Math.max(e, n)), R = (n) => String(n).padStart(2, "0"), Mn = (n) => {
2068
2082
  if (!n)
2069
2083
  return null;
@@ -2090,7 +2104,7 @@ const se = xn(
2090
2104
  } else
2091
2105
  d.length <= 2 ? i = Number(d) : d.length <= 4 ? (i = Number(d.slice(0, d.length - 2)), p = Number(d.slice(-2))) : (i = Number(d.slice(0, d.length - 4)), p = Number(d.slice(-4, -2)), h = a ? Number(d.slice(-2)) : 0);
2092
2106
  return r && (r === "pm" && i < 12 && (i += 12), r === "am" && i === 12 && (i = 0)), i > 23 || p > 59 || h > 59 ? null : { h: Nn(i, 0, 23), m: Nn(p, 0, 59), s: Nn(h, 0, 59) };
2093
- }, mn = (n, e = 1) => {
2107
+ }, gn = (n, e = 1) => {
2094
2108
  const a = [];
2095
2109
  for (let o = 0; o < n; o += e)
2096
2110
  a.push(o);
@@ -2101,7 +2115,7 @@ const se = xn(
2101
2115
  const a = document.createElement("style");
2102
2116
  a.id = n, a.textContent = e, document.head.appendChild(a);
2103
2117
  };
2104
- jn("sa-calendar-styles", gn);
2118
+ jn("sa-calendar-styles", mn);
2105
2119
  jn("sa-time-styles", oe);
2106
2120
  const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /* @__PURE__ */ s("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ s(
2107
2121
  "path",
@@ -2161,7 +2175,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2161
2175
  status: E,
2162
2176
  fullWidth: x = !0,
2163
2177
  withPadding: b = !0,
2164
- label: g,
2178
+ label: m,
2165
2179
  labelPosition: u,
2166
2180
  required: C,
2167
2181
  optional: T,
@@ -2169,7 +2183,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2169
2183
  helperText: k,
2170
2184
  errorText: v
2171
2185
  }, N) => {
2172
- const B = v ? "error" : E, { ref: H, isComponentVisible: V, setIsComponentVisible: F } = En(!1), $ = _(null), m = tn(() => Mn(n), [n]), Y = tn(() => Mn(d), [d]), L = tn(() => Mn(i), [i]), [S, I] = G(null);
2186
+ const B = v ? "error" : E, { ref: H, isComponentVisible: V, setIsComponentVisible: F } = En(!1), $ = _(null), g = tn(() => Mn(n), [n]), Y = tn(() => Mn(d), [d]), L = tn(() => Mn(i), [i]), [S, I] = G(null);
2173
2187
  O(() => {
2174
2188
  p || F(!0);
2175
2189
  }, [p]);
@@ -2190,7 +2204,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2190
2204
  }, J = (t) => {
2191
2205
  e(le(t, o)), I(null);
2192
2206
  }, D = (t) => {
2193
- J({ ...m ?? { h: 0, m: 0, s: 0 }, ...t });
2207
+ J({ ...g ?? { h: 0, m: 0, s: 0 }, ...t });
2194
2208
  }, K = () => {
2195
2209
  if (S == null)
2196
2210
  return;
@@ -2200,35 +2214,35 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2200
2214
  }
2201
2215
  const t = de(S, a, o);
2202
2216
  t && A(t) ? J(t) : I(null);
2203
- }, q = m ? ie(m, a, o) : "", U = S ?? q, X = c && !!m && !l, j = m && m.h >= 12 ? "PM" : "AM", ln = tn(() => a === "12h" ? mn(12).map((t) => {
2217
+ }, q = g ? ie(g, a, o) : "", U = S ?? q, X = c && !!g && !l, j = g && g.h >= 12 ? "PM" : "AM", ln = tn(() => a === "12h" ? gn(12).map((t) => {
2204
2218
  const f = t === 0 ? 12 : t, P = j === "PM" ? f % 12 + 12 : f % 12;
2205
2219
  return {
2206
2220
  value: f,
2207
2221
  label: R(f),
2208
2222
  disabled: Y && P * 60 + 59 < Z(Y) || L && P * 60 > Z(L) || !1
2209
2223
  };
2210
- }) : mn(24).map((t) => ({
2224
+ }) : gn(24).map((t) => ({
2211
2225
  value: t,
2212
2226
  label: R(t),
2213
2227
  disabled: Y && t * 60 + 59 < Z(Y) || L && t * 60 > Z(L) || !1
2214
2228
  })), [a, j, Y, L]), dn = tn(() => {
2215
- const t = (m == null ? void 0 : m.h) ?? 0;
2216
- return mn(60, r).map((f) => ({
2229
+ const t = (g == null ? void 0 : g.h) ?? 0;
2230
+ return gn(60, r).map((f) => ({
2217
2231
  value: f,
2218
2232
  label: R(f),
2219
2233
  disabled: Y && t * 60 + f < Z(Y) || L && t * 60 + f > Z(L) || !1
2220
2234
  }));
2221
- }, [r, m == null ? void 0 : m.h, Y, L]), nn = tn(
2222
- () => mn(60).map((t) => ({ value: t, label: R(t) })),
2235
+ }, [r, g == null ? void 0 : g.h, Y, L]), nn = tn(
2236
+ () => gn(60).map((t) => ({ value: t, label: R(t) })),
2223
2237
  []
2224
- ), cn = m == null ? null : a === "12h" ? m.h % 12 === 0 ? 12 : m.h % 12 : m.h, en = (t) => {
2238
+ ), cn = g == null ? null : a === "12h" ? g.h % 12 === 0 ? 12 : g.h % 12 : g.h, en = (t) => {
2225
2239
  if (a === "12h") {
2226
2240
  const f = j === "PM" ? t % 12 + 12 : t % 12;
2227
2241
  D({ h: f });
2228
2242
  } else
2229
2243
  D({ h: t });
2230
2244
  }, un = (t) => {
2231
- const f = m ?? { h: 0, m: 0, s: 0 }, P = f.h % 12 === 0 ? 12 : f.h % 12, an = t === "PM" ? P % 12 + 12 : P % 12;
2245
+ const f = g ?? { h: 0, m: 0, s: 0 }, P = f.h % 12 === 0 ? 12 : f.h % 12, an = t === "PM" ? P % 12 + 12 : P % 12;
2232
2246
  J({ ...f, h: an });
2233
2247
  }, pn = () => {
2234
2248
  const t = /* @__PURE__ */ new Date(), f = Math.floor(t.getMinutes() / r) * r;
@@ -2300,7 +2314,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2300
2314
  {
2301
2315
  label: "Menit",
2302
2316
  options: dn,
2303
- active: (m == null ? void 0 : m.m) ?? null,
2317
+ active: (g == null ? void 0 : g.m) ?? null,
2304
2318
  onPick: (t) => D({ m: t })
2305
2319
  }
2306
2320
  ),
@@ -2311,7 +2325,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2311
2325
  {
2312
2326
  label: "Detik",
2313
2327
  options: nn,
2314
- active: (m == null ? void 0 : m.s) ?? null,
2328
+ active: (g == null ? void 0 : g.s) ?? null,
2315
2329
  onPick: (t) => D({ s: t })
2316
2330
  }
2317
2331
  )
@@ -2326,7 +2340,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2326
2340
  { value: 0, label: "AM" },
2327
2341
  { value: 1, label: "PM" }
2328
2342
  ],
2329
- active: m == null ? null : j === "PM" ? 1 : 0,
2343
+ active: g == null ? null : j === "PM" ? 1 : 0,
2330
2344
  onPick: (t) => un(t === 1 ? "PM" : "AM")
2331
2345
  }
2332
2346
  )
@@ -2363,7 +2377,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2363
2377
  return /* @__PURE__ */ s(
2364
2378
  Yn,
2365
2379
  {
2366
- label: g,
2380
+ label: m,
2367
2381
  labelPosition: u,
2368
2382
  required: C,
2369
2383
  optional: T,
@@ -2379,6 +2393,6 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
2379
2393
  );
2380
2394
  pe.displayName = "StarasiaTime";
2381
2395
  export {
2382
- ge as StarasiaDate,
2396
+ me as StarasiaDate,
2383
2397
  pe as StarasiaTime
2384
2398
  };
package/dist/date.umd.js CHANGED
@@ -1,4 +1,9 @@
1
- (function(G,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(G=typeof globalThis<"u"?globalThis:G||self,e(G.Date={},G.jsxRuntime,G.React))})(this,function(G,e,g){"use strict";const sn=`
1
+ (function(G,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(G=typeof globalThis<"u"?globalThis:G||self,e(G.Date={},G.jsxRuntime,G.React))})(this,function(G,e,g){"use strict";const sn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
2
+ starasia, components, utilities). CSS app/Tailwind utility selalu bisa
3
+ menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
4
+ @layer starasia.components {
5
+
6
+
2
7
  * {
3
8
  margin: 0;
4
9
  padding: 0;
@@ -597,7 +602,14 @@
597
602
  width: 32px;
598
603
  height: 32px;
599
604
  }
600
- `,$n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],_=["January","February","March","April","May","June","July","August","September","October","November","December"],Bn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function vn(n){const[a,r]=g.useState(n),o=g.useRef(null),s=d=>{o.current&&!o.current.contains(d.target)&&r(!1)};return g.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:o,isComponentVisible:a,setIsComponentVisible:r}}const Cn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Cn)){const a=document.createElement("style");a.id=Cn,a.textContent=n,document.head.appendChild(a)}})(sn);const an=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},Vn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})})]})},Pn=({date:n,setDate:a,dateRange:r,setDateRange:o,onChange:s,minDate:d,maxDate:i,input:p})=>{var T,w,M;const[h,l]=g.useState(null);let c=new Date(n.getFullYear(),n.getMonth(),1),x=c.getDay(),$=[];const E=n.getMonth(),k=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let m=0;m<42;m++){m===0&&x===0?c.setDate(c.getDate()-7):m===0?c.setDate(c.getDate()+(m-x)):c.setDate(c.getDate()+1);let N={currentMonth:c.getMonth()===E,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((T=r.from)==null?void 0:T.toDateString())||c.toDateString()===(((w=r.to)==null?void 0:w.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(N)}const u=m=>{a(m)},C=m=>{let N={...r};if(N.from&&N.to)N={from:m,to:null};else if(!N.from)N={from:m,to:null};else{const B=N.from.getTime();m.getTime()>B?N={from:N.from,to:m}:N={from:m,to:N.from}}o(N),s(N)};return e.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>l(null),children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((m,N)=>e.jsx("p",{children:m},N))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((m,N)=>{const B=r.from&&r.to&&m.date.getTime()>r.from.getTime()&&m.date.getTime()<r.to.getTime(),H=(()=>{if(!v||!r.from)return!1;const S=m.date.getTime(),Y=r.from.getTime(),L=v.getTime();return L>Y?S>Y&&S<L:S<Y&&S>L})(),V=y&&h&&m.date.toDateString()===h.toDateString(),F=m.isDisabled,D=()=>B||H?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",b=()=>F?"var(--sa-color-gray-400, #b7b9be)":B||H?"var(--sa-color-gray-500, #8c8f97)":"";return e.jsx("p",{className:`${m.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${m.selected||V?"sa-calendar-days-active":""} ${m.isToday&&!m.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:D(),pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",color:b(),opacity:V&&!m.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{F||(u(m.date),C(m.date))},onMouseEnter:()=>{F||l(m.date)},children:m.number},N)})})]})},jn=({date:n,setDate:a,filter:r,setViews:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var k;const c=(k=s.from)==null?void 0:k.getFullYear(),x=n.getFullYear(),$=y=>{r?(E(y),a(y)):(o("days"),a(y))},E=y=>{let v={...s};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const u=v.from.getTime();y.getTime()>u?v={from:v.from,to:y}:v={from:y,to:v.from}}d(v),i(v)};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{var T,w,M;const u=s.from!=null&&new Date(x,v).getTime()>s.from.getTime()&&new Date(x,v).getTime()<(((T=s.to)==null?void 0:T.getTime())||s.from.getTime()),C=p&&new Date(x,v)<p||h&&new Date(x,v)>h;return e.jsx("p",{className:c===x&&(v===((w=s.from)==null?void 0:w.getMonth())||v===((M=s.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:u?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:C?"none":void 0,cursor:C?"not-allowed":"pointer",color:C?"var(--sa-color-gray-400, #b7b9be)":u?"var(--sa-color-gray-500, #8c8f97)":"",...l?{}:{width:"100%"}},onClick:()=>{C||$(new Date(x,v))},children:y.slice(0,3)},v)})})},bn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},On=({date:n,filter:a,setViews:r,setDate:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var C,T;let c=[];const x=n.getFullYear(),{start:$,end:E}=bn(x),k=(C=s.from)==null?void 0:C.getFullYear(),y=(T=s.to)==null?void 0:T.getFullYear();for(let w=$;w<E;w++){const M=new Date(w,0),m=(!p||M>=p)&&(!h||M<=h),N=k!=null&&w===k||y!=null&&w===y,B=s.from!=null&&s.to!=null&&M>s.from&&M<s.to;c.push({year:w,active:N&&m,highlight:B&&m,disabled:!m})}const v=w=>{a?(u(w),o(w)):(o(w),r("months"))},u=w=>{let M={...s};if(M.from&&M.to)M={from:w,to:null};else if(!M.from)M={from:w,to:null};else{const m=M.from.getTime();w.getTime()>m?M={from:M.from,to:w}:M={from:w,to:M.from}}d(M),i(M)};return e.jsx("div",{className:"sa-calendar-years-preview",children:c.map((w,M)=>e.jsx("p",{className:`${w.active?"sa-calendar-months-active":""} ${w.highlight?"sa-calendar-months-highlight":""} ${w.disabled?"sa-calendar-disabled":""}`,onClick:()=>{w.disabled||v(new Date(w.year,0))},style:{backgroundColor:w.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:w.highlight?"var(--sa-color-gray-500, #8c8f97)":w.active?"":w.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:w.disabled?"not-allowed":"pointer",pointerEvents:w.disbled?"none":"all",...l?{}:{width:"100%"}},children:w.year},M))})},Dn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.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"})}),zn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.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"})}),An=({setViews:n,views:a,filter:r,date:o,setDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${bn(o.getFullYear()).start} ~ ${bn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})};function rn(n){const a=new Date(n),r=a.getFullYear(),o=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${Bn[o]} ${r}`}const En=(()=>{const n={};return _.forEach((a,r)=>{n[a.toLowerCase()]=r,n[a.slice(0,3).toLowerCase()]=r}),n})(),mn=n=>n<100?2e3+n:n;function yn(n,a){const r=String(n.getDate()).padStart(2,"0"),o=String(n.getMonth()+1).padStart(2,"0"),s=n.getFullYear();return a==="years"?`${s}`:a==="months"?`${o}/${s}`:`${r}/${o}/${s}`}function Hn(n,a){const r=n.from?yn(n.from,a):"",o=n.to?yn(n.to,a):"";return r?o?`${r} ~ ${o}`:r:""}function fn(n,a){const r=n.trim().toLowerCase().split(/[\s/.\-,]+/).filter(Boolean);if(!r.length)return null;let o=null;const s=[];for(const c of r)c in En?o=En[c]:/^\d+$/.test(c)&&s.push(parseInt(c,10));if(a==="years"){const c=s[0];return c==null?null:new Date(mn(c),0,1)}if(a==="months"){const c=o??s[0]-1,x=o!=null?s[0]:s[1];return c==null||isNaN(c)||c<0||c>11||x==null?null:new Date(mn(x),c,1)}let d,i,p;if(o!=null?(d=s[0],p=s[1],i=o):(d=s[0],i=s[1]!=null?s[1]-1:void 0,p=s[2]),d==null||i==null||p==null)return null;const h=mn(p),l=new Date(h,i,d);return l.getFullYear()!==h||l.getMonth()!==i||l.getDate()!==d?null:l}function Wn(n,a){const r=n.indexOf("~");if(r===-1){const d=fn(n,a);return d?{from:d,to:null}:null}const o=fn(n.slice(0,r),a);if(!o)return null;const s=fn(n.slice(r+1),a);return{from:o,to:s??null}}function wn(n,a,r){const o=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime(),s=o(n);return!(a&&s<o(a)||r&&s>o(r))}const xn=({label:n,labelPosition:a="outside-top",required:r,optional:o,description:s,helperText:d,errorText:i,fullWidth:p,size:h="sm",children:l})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),x=n?e.jsxs("div",{className:"sa-date-field-label-row",children:[e.jsx("span",{className:"sa-date-field-label-text",children:n}),o&&e.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&e.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,$=e.jsxs(e.Fragment,{children:[d&&!i&&e.jsx("p",{className:"sa-date-field-helper",children:d}),i&&e.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return n?a==="outside-left"?e.jsxs("div",{className:`${c} sa-date-field-left`,children:[e.jsxs("div",{className:"sa-date-field-left-label",children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s})]}),e.jsxs("div",{className:"sa-date-field-input-wrap",children:[l,$]})]}):e.jsxs("div",{className:c,children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]}):e.jsxs("div",{className:c,children:[s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]})},Sn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Sn)){const a=document.createElement("style");a.id=Sn,a.textContent=n,document.head.appendChild(a)}})(sn);const Jn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),W=typeof v=="function"||y!=null,O=!o&&!W,J=!O,[z,q]=g.useState({from:(n==null?void 0:n.from)??null,to:(n==null?void 0:n.to)??null}),[K,U]=g.useState(null);g.useEffect(()=>{if(n){const t=n;t.from&&I(t.from),q(t)}else I(new Date),q({from:null,to:null});U(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{O&&D(!0)},[O]);const Q=()=>{var t,f;if(!n)return"";if(r){if(S==="days")return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`;if(S==="months")return`${_[z.from.getMonth()]} ~ ${z.to?_[z.to.getMonth()]:"-"}`;if(S==="years")return`${(t=z.from)==null?void 0:t.getFullYear()} ~ ${((f=z.to)==null?void 0:f.getFullYear())||"-"}`}else return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`},j=()=>{if(b.current&&V.current&&J){const t=V.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&V.current&&J&&j()},[b,V,F]),g.useEffect(()=>(window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&U(Hn(z,r))},R=()=>{if(K===null)return;const t=K.trim();if(!t){a(void 0),U(null);return}const f=Wn(t,r),P=f&&wn(f.from,d,i)&&(!f.to||wn(f.to,d,i));f&&P&&(a(f),q(f),I(f.from)),U(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(U(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var P,en;(en=(P=t.props)==null?void 0:P.onClick)==null||en.call(P,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${W?" sa-calendar-wrapper-custom":""}`,style:{height:O?"100%":"auto"},ref:t=>{V.current=J?t:null,typeof B=="function"?B(t):B&&(B.current=t)},children:[W?nn():o?e.jsx(Vn,{value:k&&K!==null?K:Q(),inputMode:k?"text":"none",readOnly:!k,onClick:()=>{D(!0)},onChange:k?t=>U(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,disabled:s,placeholder:p,size:h,variant:l,status:H,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${O?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(An,{setViews:Y,views:S,filter:r,date:L,setDate:I}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Pn,{date:L,setDate:I,setIsComponentVisible:D,dateRange:z,setDateRange:q,input:o,onChange:a,minDate:d,maxDate:i}):S==="months"?e.jsx(jn,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i}):e.jsx(On,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Yn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Yn)){const a=document.createElement("style");a.id=Yn,a.textContent=n,document.head.appendChild(a)}})(sn);const tn=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},qn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})})]})},Kn=({date:n,setDate:a,previewDate:r,setPreviewDate:o,setIsComponentVisible:s,minDate:d,maxDate:i,input:p,onChange:h,hasValue:l})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),x=c.getDay(),$=[];const E=n.toDateString(),k=new Date().toDateString(),y=r.getMonth();for(let u=0;u<42;u++){u===0&&x===0?c.setDate(c.getDate()-7):u===0?c.setDate(c.getDate()+(u-x)):c.setDate(c.getDate()+1);let C={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:l&&c.toDateString()===E,isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(C)}const v=u=>{(!d||u>=d)&&(!i||u<=i)&&(a(u),h(u),o(u),p&&s(!1))};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((u,C)=>e.jsx("p",{children:u},C))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((u,C)=>{const T=u.isDisabled;return e.jsx("p",{className:`${u.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${u.selected?"sa-calendar-days-active":""} ${u.isToday&&!u.selected?"sa-calendar-days-today":""}`,style:{color:T?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:T?"none":void 0,cursor:T?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{T||v(u.date)},children:u.number},C)})})]})},Un=({date:n,setDate:a,filter:r,setViews:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{const x=n.getMonth(),$=n.getFullYear(),E=d.getFullYear(),k=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(s(y),a(y),i(y)):(o("days"),i(y)))};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{const u=p&&new Date(E,v,1)<p||h&&new Date(E,v+1,0)>h;return e.jsx("p",{className:c&&v===x&&E===$?"sa-calendar-months-active":"",style:{color:u?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:u?"none":void 0,cursor:u?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u||k(new Date(E,v))},children:y.slice(0,3)},v)})})},kn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},Gn=({date:n,filter:a,setViews:r,setDate:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{let x=[];const $=d.getFullYear(),{start:E,end:k}=kn($),y=n.getFullYear();for(let u=E;u<k;u++){let C=p&&new Date(u,0,1)<p||h&&new Date(u,11,31)>h;x.push({year:u,active:!!c&&u===y,isDisabled:C})}const v=u=>{(!p||u>=p)&&(!h||u<=h)&&(a?(s(u),o(u),i(u)):(r("months"),i(u)))};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((u,C)=>e.jsx("p",{className:u.active?"sa-calendar-months-active":"",style:{color:u.isDisabled?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:u.isDisabled?"none":void 0,cursor:u.isDisabled?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u.isDisabled||v(new Date(u.year,0))},children:u.year},C))})},Zn=({setViews:n,views:a,filter:r,previewDate:o,setPreviewDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${kn(o.getFullYear()).start} ~ ${kn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})},Fn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Fn)){const a=document.createElement("style");a.id=Fn,a.textContent=n,document.head.appendChild(a)}})(sn);const _n=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),[W,O]=g.useState(new Date),[J,z]=g.useState(null),q=typeof v=="function"||y!=null,K=!o&&!q,U=!K;g.useEffect(()=>{n?(I(n),O(n)):(I(new Date),O(new Date)),z(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{K&&D(!0)},[K]);const Q=()=>n?r==="days"?rn(L):r==="months"?`${_[L.getMonth()]} ${L.getFullYear()}`:r==="years"?L.getFullYear():rn(L):"",j=()=>{if(b.current&&V.current&&U){const t=V.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&V.current&&U&&j()},[b,V,F]),g.useEffect(()=>(window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&z(n?yn(n,r):"")},R=()=>{if(J===null)return;const t=J.trim();if(!t){a(void 0),z(null);return}const f=fn(t,r);f&&wn(f,d,i)&&(a(f),I(f),O(f)),z(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(z(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var P,en;(en=(P=t.props)==null?void 0:P.onClick)==null||en.call(P,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${q?" sa-calendar-wrapper-custom":""}`,style:{height:K?"100%":"auto"},ref:t=>{V.current=U?t:null,typeof B=="function"?B(t):B&&(B.current=t)},children:[q?nn():o?e.jsx(qn,{value:k&&J!==null?J:Q(),onClick:()=>D(!0),onChange:k?t=>z(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,placeholder:p,disabled:s,size:h,variant:l,status:H,inputMode:k?"text":"none",readOnly:!k,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${K?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(Zn,{setViews:Y,views:S,filter:r,previewDate:W,setPreviewDate:O,isComponentVisible:F}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Kn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,setIsComponentVisible:D,input:o,minDate:d,maxDate:i,onChange:a,hasValue:n!=null}):S==="months"?e.jsx(Un,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null}):e.jsx(Gn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Qn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,rangedDate:s,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B},H)=>{const V={onChange:a,value:n,input:o,filter:r,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B};return e.jsx(e.Fragment,{children:s?e.jsx(Jn,{...V,ref:H}):e.jsx(_n,{...V,ref:H})})}),Xn=`/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
605
+
606
+ } /* @layer starasia.components */
607
+ `,$n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],_=["January","February","March","April","May","June","July","August","September","October","November","December"],Bn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function vn(n){const[a,r]=g.useState(n),o=g.useRef(null),s=d=>{o.current&&!o.current.contains(d.target)&&r(!1)};return g.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:o,isComponentVisible:a,setIsComponentVisible:r}}const Cn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Cn)){const a=document.createElement("style");a.id=Cn,a.textContent=n,document.head.appendChild(a)}})(sn);const an=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},Vn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})})]})},Pn=({date:n,setDate:a,dateRange:r,setDateRange:o,onChange:s,minDate:d,maxDate:i,input:p})=>{var T,w,M;const[h,l]=g.useState(null);let c=new Date(n.getFullYear(),n.getMonth(),1),x=c.getDay(),$=[];const E=n.getMonth(),k=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let m=0;m<42;m++){m===0&&x===0?c.setDate(c.getDate()-7):m===0?c.setDate(c.getDate()+(m-x)):c.setDate(c.getDate()+1);let N={currentMonth:c.getMonth()===E,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((T=r.from)==null?void 0:T.toDateString())||c.toDateString()===(((w=r.to)==null?void 0:w.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(N)}const u=m=>{a(m)},C=m=>{let N={...r};if(N.from&&N.to)N={from:m,to:null};else if(!N.from)N={from:m,to:null};else{const B=N.from.getTime();m.getTime()>B?N={from:N.from,to:m}:N={from:m,to:N.from}}o(N),s(N)};return e.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>l(null),children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((m,N)=>e.jsx("p",{children:m},N))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((m,N)=>{const B=r.from&&r.to&&m.date.getTime()>r.from.getTime()&&m.date.getTime()<r.to.getTime(),H=(()=>{if(!v||!r.from)return!1;const S=m.date.getTime(),Y=r.from.getTime(),L=v.getTime();return L>Y?S>Y&&S<L:S<Y&&S>L})(),V=y&&h&&m.date.toDateString()===h.toDateString(),F=m.isDisabled,D=()=>B||H?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",b=()=>F?"var(--sa-color-gray-400, #b7b9be)":B||H?"var(--sa-color-gray-500, #8c8f97)":"";return e.jsx("p",{className:`${m.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${m.selected||V?"sa-calendar-days-active":""} ${m.isToday&&!m.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:D(),pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",color:b(),opacity:V&&!m.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{F||(u(m.date),C(m.date))},onMouseEnter:()=>{F||l(m.date)},children:m.number},N)})})]})},jn=({date:n,setDate:a,filter:r,setViews:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var k;const c=(k=s.from)==null?void 0:k.getFullYear(),x=n.getFullYear(),$=y=>{r?(E(y),a(y)):(o("days"),a(y))},E=y=>{let v={...s};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const u=v.from.getTime();y.getTime()>u?v={from:v.from,to:y}:v={from:y,to:v.from}}d(v),i(v)};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{var T,w,M;const u=s.from!=null&&new Date(x,v).getTime()>s.from.getTime()&&new Date(x,v).getTime()<(((T=s.to)==null?void 0:T.getTime())||s.from.getTime()),C=p&&new Date(x,v)<p||h&&new Date(x,v)>h;return e.jsx("p",{className:c===x&&(v===((w=s.from)==null?void 0:w.getMonth())||v===((M=s.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:u?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:C?"none":void 0,cursor:C?"not-allowed":"pointer",color:C?"var(--sa-color-gray-400, #b7b9be)":u?"var(--sa-color-gray-500, #8c8f97)":"",...l?{}:{width:"100%"}},onClick:()=>{C||$(new Date(x,v))},children:y.slice(0,3)},v)})})},bn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},On=({date:n,filter:a,setViews:r,setDate:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var C,T;let c=[];const x=n.getFullYear(),{start:$,end:E}=bn(x),k=(C=s.from)==null?void 0:C.getFullYear(),y=(T=s.to)==null?void 0:T.getFullYear();for(let w=$;w<E;w++){const M=new Date(w,0),m=(!p||M>=p)&&(!h||M<=h),N=k!=null&&w===k||y!=null&&w===y,B=s.from!=null&&s.to!=null&&M>s.from&&M<s.to;c.push({year:w,active:N&&m,highlight:B&&m,disabled:!m})}const v=w=>{a?(u(w),o(w)):(o(w),r("months"))},u=w=>{let M={...s};if(M.from&&M.to)M={from:w,to:null};else if(!M.from)M={from:w,to:null};else{const m=M.from.getTime();w.getTime()>m?M={from:M.from,to:w}:M={from:w,to:M.from}}d(M),i(M)};return e.jsx("div",{className:"sa-calendar-years-preview",children:c.map((w,M)=>e.jsx("p",{className:`${w.active?"sa-calendar-months-active":""} ${w.highlight?"sa-calendar-months-highlight":""} ${w.disabled?"sa-calendar-disabled":""}`,onClick:()=>{w.disabled||v(new Date(w.year,0))},style:{backgroundColor:w.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:w.highlight?"var(--sa-color-gray-500, #8c8f97)":w.active?"":w.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:w.disabled?"not-allowed":"pointer",pointerEvents:w.disbled?"none":"all",...l?{}:{width:"100%"}},children:w.year},M))})},Dn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.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"})}),zn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.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"})}),An=({setViews:n,views:a,filter:r,date:o,setDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${bn(o.getFullYear()).start} ~ ${bn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})};function rn(n){const a=new Date(n),r=a.getFullYear(),o=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${Bn[o]} ${r}`}const En=(()=>{const n={};return _.forEach((a,r)=>{n[a.toLowerCase()]=r,n[a.slice(0,3).toLowerCase()]=r}),n})(),mn=n=>n<100?2e3+n:n;function yn(n,a){const r=String(n.getDate()).padStart(2,"0"),o=String(n.getMonth()+1).padStart(2,"0"),s=n.getFullYear();return a==="years"?`${s}`:a==="months"?`${o}/${s}`:`${r}/${o}/${s}`}function Hn(n,a){const r=n.from?yn(n.from,a):"",o=n.to?yn(n.to,a):"";return r?o?`${r} ~ ${o}`:r:""}function fn(n,a){const r=n.trim().toLowerCase().split(/[\s/.\-,]+/).filter(Boolean);if(!r.length)return null;let o=null;const s=[];for(const c of r)c in En?o=En[c]:/^\d+$/.test(c)&&s.push(parseInt(c,10));if(a==="years"){const c=s[0];return c==null?null:new Date(mn(c),0,1)}if(a==="months"){const c=o??s[0]-1,x=o!=null?s[0]:s[1];return c==null||isNaN(c)||c<0||c>11||x==null?null:new Date(mn(x),c,1)}let d,i,p;if(o!=null?(d=s[0],p=s[1],i=o):(d=s[0],i=s[1]!=null?s[1]-1:void 0,p=s[2]),d==null||i==null||p==null)return null;const h=mn(p),l=new Date(h,i,d);return l.getFullYear()!==h||l.getMonth()!==i||l.getDate()!==d?null:l}function Wn(n,a){const r=n.indexOf("~");if(r===-1){const d=fn(n,a);return d?{from:d,to:null}:null}const o=fn(n.slice(0,r),a);if(!o)return null;const s=fn(n.slice(r+1),a);return{from:o,to:s??null}}function wn(n,a,r){const o=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime(),s=o(n);return!(a&&s<o(a)||r&&s>o(r))}const xn=({label:n,labelPosition:a="outside-top",required:r,optional:o,description:s,helperText:d,errorText:i,fullWidth:p,size:h="sm",children:l})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),x=n?e.jsxs("div",{className:"sa-date-field-label-row",children:[e.jsx("span",{className:"sa-date-field-label-text",children:n}),o&&e.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&e.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,$=e.jsxs(e.Fragment,{children:[d&&!i&&e.jsx("p",{className:"sa-date-field-helper",children:d}),i&&e.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return n?a==="outside-left"?e.jsxs("div",{className:`${c} sa-date-field-left`,children:[e.jsxs("div",{className:"sa-date-field-left-label",children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s})]}),e.jsxs("div",{className:"sa-date-field-input-wrap",children:[l,$]})]}):e.jsxs("div",{className:c,children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]}):e.jsxs("div",{className:c,children:[s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]})},Sn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Sn)){const a=document.createElement("style");a.id=Sn,a.textContent=n,document.head.appendChild(a)}})(sn);const Jn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),W=typeof v=="function"||y!=null,O=!o&&!W,J=!O,[z,q]=g.useState({from:(n==null?void 0:n.from)??null,to:(n==null?void 0:n.to)??null}),[K,U]=g.useState(null);g.useEffect(()=>{if(n){const t=n;t.from&&I(t.from),q(t)}else I(new Date),q({from:null,to:null});U(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{O&&D(!0)},[O]);const Q=()=>{var t,f;if(!n)return"";if(r){if(S==="days")return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`;if(S==="months")return`${_[z.from.getMonth()]} ~ ${z.to?_[z.to.getMonth()]:"-"}`;if(S==="years")return`${(t=z.from)==null?void 0:t.getFullYear()} ~ ${((f=z.to)==null?void 0:f.getFullYear())||"-"}`}else return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`},j=()=>{if(b.current&&V.current&&J){const t=V.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&V.current&&J&&j()},[b,V,F]),g.useEffect(()=>(window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&U(Hn(z,r))},R=()=>{if(K===null)return;const t=K.trim();if(!t){a(void 0),U(null);return}const f=Wn(t,r),P=f&&wn(f.from,d,i)&&(!f.to||wn(f.to,d,i));f&&P&&(a(f),q(f),I(f.from)),U(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(U(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var P,en;(en=(P=t.props)==null?void 0:P.onClick)==null||en.call(P,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${W?" sa-calendar-wrapper-custom":""}`,style:{height:O?"100%":"auto"},ref:t=>{V.current=J?t:null,typeof B=="function"?B(t):B&&(B.current=t)},children:[W?nn():o?e.jsx(Vn,{value:k&&K!==null?K:Q(),inputMode:k?"text":"none",readOnly:!k,onClick:()=>{D(!0)},onChange:k?t=>U(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,disabled:s,placeholder:p,size:h,variant:l,status:H,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${O?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(An,{setViews:Y,views:S,filter:r,date:L,setDate:I}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Pn,{date:L,setDate:I,setIsComponentVisible:D,dateRange:z,setDateRange:q,input:o,onChange:a,minDate:d,maxDate:i}):S==="months"?e.jsx(jn,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i}):e.jsx(On,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Yn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Yn)){const a=document.createElement("style");a.id=Yn,a.textContent=n,document.head.appendChild(a)}})(sn);const tn=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},qn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.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"})})})]})},Kn=({date:n,setDate:a,previewDate:r,setPreviewDate:o,setIsComponentVisible:s,minDate:d,maxDate:i,input:p,onChange:h,hasValue:l})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),x=c.getDay(),$=[];const E=n.toDateString(),k=new Date().toDateString(),y=r.getMonth();for(let u=0;u<42;u++){u===0&&x===0?c.setDate(c.getDate()-7):u===0?c.setDate(c.getDate()+(u-x)):c.setDate(c.getDate()+1);let C={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:l&&c.toDateString()===E,isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(C)}const v=u=>{(!d||u>=d)&&(!i||u<=i)&&(a(u),h(u),o(u),p&&s(!1))};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((u,C)=>e.jsx("p",{children:u},C))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((u,C)=>{const T=u.isDisabled;return e.jsx("p",{className:`${u.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${u.selected?"sa-calendar-days-active":""} ${u.isToday&&!u.selected?"sa-calendar-days-today":""}`,style:{color:T?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:T?"none":void 0,cursor:T?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{T||v(u.date)},children:u.number},C)})})]})},Un=({date:n,setDate:a,filter:r,setViews:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{const x=n.getMonth(),$=n.getFullYear(),E=d.getFullYear(),k=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(s(y),a(y),i(y)):(o("days"),i(y)))};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{const u=p&&new Date(E,v,1)<p||h&&new Date(E,v+1,0)>h;return e.jsx("p",{className:c&&v===x&&E===$?"sa-calendar-months-active":"",style:{color:u?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:u?"none":void 0,cursor:u?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u||k(new Date(E,v))},children:y.slice(0,3)},v)})})},kn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},Gn=({date:n,filter:a,setViews:r,setDate:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{let x=[];const $=d.getFullYear(),{start:E,end:k}=kn($),y=n.getFullYear();for(let u=E;u<k;u++){let C=p&&new Date(u,0,1)<p||h&&new Date(u,11,31)>h;x.push({year:u,active:!!c&&u===y,isDisabled:C})}const v=u=>{(!p||u>=p)&&(!h||u<=h)&&(a?(s(u),o(u),i(u)):(r("months"),i(u)))};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((u,C)=>e.jsx("p",{className:u.active?"sa-calendar-months-active":"",style:{color:u.isDisabled?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:u.isDisabled?"none":void 0,cursor:u.isDisabled?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u.isDisabled||v(new Date(u.year,0))},children:u.year},C))})},Zn=({setViews:n,views:a,filter:r,previewDate:o,setPreviewDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${kn(o.getFullYear()).start} ~ ${kn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})},Fn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Fn)){const a=document.createElement("style");a.id=Fn,a.textContent=n,document.head.appendChild(a)}})(sn);const _n=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),[W,O]=g.useState(new Date),[J,z]=g.useState(null),q=typeof v=="function"||y!=null,K=!o&&!q,U=!K;g.useEffect(()=>{n?(I(n),O(n)):(I(new Date),O(new Date)),z(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{K&&D(!0)},[K]);const Q=()=>n?r==="days"?rn(L):r==="months"?`${_[L.getMonth()]} ${L.getFullYear()}`:r==="years"?L.getFullYear():rn(L):"",j=()=>{if(b.current&&V.current&&U){const t=V.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&V.current&&U&&j()},[b,V,F]),g.useEffect(()=>(window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&z(n?yn(n,r):"")},R=()=>{if(J===null)return;const t=J.trim();if(!t){a(void 0),z(null);return}const f=fn(t,r);f&&wn(f,d,i)&&(a(f),I(f),O(f)),z(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(z(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var P,en;(en=(P=t.props)==null?void 0:P.onClick)==null||en.call(P,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${q?" sa-calendar-wrapper-custom":""}`,style:{height:K?"100%":"auto"},ref:t=>{V.current=U?t:null,typeof B=="function"?B(t):B&&(B.current=t)},children:[q?nn():o?e.jsx(qn,{value:k&&J!==null?J:Q(),onClick:()=>D(!0),onChange:k?t=>z(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,placeholder:p,disabled:s,size:h,variant:l,status:H,inputMode:k?"text":"none",readOnly:!k,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${K?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(Zn,{setViews:Y,views:S,filter:r,previewDate:W,setPreviewDate:O,isComponentVisible:F}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Kn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,setIsComponentVisible:D,input:o,minDate:d,maxDate:i,onChange:a,hasValue:n!=null}):S==="months"?e.jsx(Un,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null}):e.jsx(Gn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Qn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,rangedDate:s,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B},H)=>{const V={onChange:a,value:n,input:o,filter:r,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B};return e.jsx(e.Fragment,{children:s?e.jsx(Jn,{...V,ref:H}):e.jsx(_n,{...V,ref:H})})}),Xn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
608
+ starasia, components, utilities). CSS app/Tailwind utility selalu bisa
609
+ menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
610
+ @layer starasia.components {
611
+
612
+ /* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
601
613
  date.module.css, injected alongside this sheet) and the .sa-calendar /
602
614
  .sa-calendar-input-* shells for the box + masked input. */
603
615
 
@@ -728,4 +740,6 @@
728
740
  .sa-time-input-wrap {
729
741
  width: 100%;
730
742
  }
743
+
744
+ } /* @layer starasia.components */
731
745
  `,Mn=(n,a,r)=>Math.min(r,Math.max(a,n)),A=n=>String(n).padStart(2,"0"),Nn=n=>{if(!n)return null;const a=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(n.trim());if(!a)return null;const r=Number(a[1]),o=Number(a[2]),s=a[3]!=null?Number(a[3]):0;return r>23||o>59||s>59?null:{h:r,m:o,s}},Rn=(n,a)=>a?`${A(n.h)}:${A(n.m)}:${A(n.s)}`:`${A(n.h)}:${A(n.m)}`,Z=n=>n.h*60+n.m,ne=(n,a,r)=>{const o=r?`:${A(n.s)}`:"";if(a==="12h"){const s=n.h>=12?"PM":"AM",d=n.h%12===0?12:n.h%12;return`${A(d)}:${A(n.m)}${o} ${s}`}return`${A(n.h)}:${A(n.m)}${o}`},ee=(n,a,r)=>{const o=n.toLowerCase(),s=/p/.test(o)?"pm":/a/.test(o)?"am":null,d=o.replace(/[^\d]/g,"");if(!d)return null;let i=0,p=0,h=0;if(n.includes(":")){const l=n.split(":").map(c=>c.replace(/[^\d]/g,""));i=Number(l[0]||0),p=Number(l[1]||0),h=r?Number(l[2]||0):0}else d.length<=2?i=Number(d):d.length<=4?(i=Number(d.slice(0,d.length-2)),p=Number(d.slice(-2))):(i=Number(d.slice(0,d.length-4)),p=Number(d.slice(-4,-2)),h=r?Number(d.slice(-2)):0);return s&&(s==="pm"&&i<12&&(i+=12),s==="am"&&i===12&&(i=0)),i>23||p>59||h>59?null:{h:Mn(i,0,23),m:Mn(p,0,59),s:Mn(h,0,59)}},hn=(n,a=1)=>{const r=[];for(let o=0;o<n;o+=a)r.push(o);return r},Ln=(n,a)=>{if(typeof document>"u"||document.getElementById(n))return;const r=document.createElement("style");r.id=n,r.textContent=a,document.head.appendChild(r)};Ln("sa-calendar-styles",sn),Ln("sa-time-styles",Xn);const ae=n=>n==="xs"?14:n==="lg"?20:16,In=({s:n})=>e.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M10 5v5l3 2M17.5 10a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),re=({s:n})=>e.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5l10 10M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round"})}),gn=({label:n,options:a,active:r,onPick:o})=>{const s=g.useRef(null),d=g.useRef(null);return g.useEffect(()=>{var i;(i=d.current)==null||i.scrollIntoView({block:"nearest"})},[r]),e.jsxs("div",{className:"sa-time-col",children:[e.jsx("div",{className:"sa-time-col-head",children:n}),e.jsx("div",{className:"sa-time-col-list",ref:s,children:a.map(i=>{const p=i.value===r;return e.jsx("button",{type:"button",ref:p?d:null,disabled:i.disabled,className:`sa-time-opt${p?" sa-time-opt-active":""}`,onClick:()=>o(i.value),children:i.label},i.value)})})]})},Tn=g.forwardRef(({value:n,onChange:a,format:r="24h",withSeconds:o=!1,step:s=1,minTime:d,maxTime:i,input:p=!0,placeholder:h="--:--",disabled:l,clearable:c,size:x="sm",variant:$="outline",status:E,fullWidth:k=!0,withPadding:y=!0,label:v,labelPosition:u,required:C,optional:T,description:w,helperText:M,errorText:m},N)=>{const B=m?"error":E,{ref:H,isComponentVisible:V,setIsComponentVisible:F}=vn(!1),D=g.useRef(null),b=g.useMemo(()=>Nn(n),[n]),S=g.useMemo(()=>Nn(d),[d]),Y=g.useMemo(()=>Nn(i),[i]),[L,I]=g.useState(null);g.useEffect(()=>{p||F(!0)},[p]);const W=()=>{if(!D.current||!H.current||!p)return;const t=H.current.getBoundingClientRect(),f=D.current.getBoundingClientRect();D.current.style.left=window.innerWidth<t.left+f.width?`${t.left-f.width+t.width}px`:`${t.left}px`,D.current.style.top=t.top+f.height>window.innerHeight?`${t.y-(t.height+f.height-28)}px`:`${t.y+t.height}px`};g.useEffect(()=>{W()},[V]),g.useEffect(()=>(window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}),[]);const O=t=>{const f=Z(t);return!(S&&f<Z(S)||Y&&f>Z(Y))},J=t=>{a(Rn(t,o)),I(null)},z=t=>{J({...b??{h:0,m:0,s:0},...t})},q=()=>{if(L==null)return;if(L.trim()===""){a(null),I(null);return}const t=ee(L,r,o);t&&O(t)?J(t):I(null)},K=b?ne(b,r,o):"",U=L??K,Q=c&&!!b&&!l,j=b&&b.h>=12?"PM":"AM",on=g.useMemo(()=>r==="12h"?hn(12).map(t=>{const f=t===0?12:t,P=j==="PM"?f%12+12:f%12;return{value:f,label:A(f),disabled:S&&P*60+59<Z(S)||Y&&P*60>Z(Y)||!1}}):hn(24).map(t=>({value:t,label:A(t),disabled:S&&t*60+59<Z(S)||Y&&t*60>Z(Y)||!1})),[r,j,S,Y]),ln=g.useMemo(()=>{const t=(b==null?void 0:b.h)??0;return hn(60,s).map(f=>({value:f,label:A(f),disabled:S&&t*60+f<Z(S)||Y&&t*60+f>Z(Y)||!1}))},[s,b==null?void 0:b.h,S,Y]),X=g.useMemo(()=>hn(60).map(t=>({value:t,label:A(t)})),[]),dn=b==null?null:r==="12h"?b.h%12===0?12:b.h%12:b.h,R=t=>{if(r==="12h"){const f=j==="PM"?t%12+12:t%12;z({h:f})}else z({h:t})},cn=t=>{const f=b??{h:0,m:0,s:0},P=f.h%12===0?12:f.h%12,en=t==="PM"?P%12+12:P%12;J({...f,h:en})},un=()=>{const t=new Date,f=Math.floor(t.getMinutes()/s)*s;J({h:t.getHours(),m:f,s:o?t.getSeconds():0})},nn=ae(x),pn=e.jsxs("div",{className:"sa-calendar-wrapper",style:{height:p?"auto":"100%"},ref:p?H:null,children:[p?e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${$} sa-calendar-input-container-${B||"default"} ${x}`,onClick:()=>!l&&F(!0),children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx(In,{s:nn})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",value:U,placeholder:h,disabled:l,onChange:t=>I(t.target.value),onFocus:()=>F(!0),onBlur:q,onKeyDown:t=>{t.key==="Enter"&&(q(),F(!1)),t.key==="Escape"&&(I(null),F(!1))}})}),Q?e.jsx("button",{type:"button","aria-label":"Clear time",className:"sa-calendar-input-clear",onClick:t=>{t.stopPropagation(),a(null),I(null)},children:e.jsx(re,{s:nn})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx(In,{s:nn})})]}):null,V?e.jsxs("div",{ref:D,className:`sa-calendar sa-calendar-size-${x} ${p?"":"sa-calendar-no-input"} ${y?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,children:[e.jsxs("div",{className:"sa-time-columns",children:[e.jsx(gn,{label:"Jam",options:on,active:dn,onPick:R}),e.jsx("div",{className:"sa-time-divider"}),e.jsx(gn,{label:"Menit",options:ln,active:(b==null?void 0:b.m)??null,onPick:t=>z({m:t})}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-time-divider"}),e.jsx(gn,{label:"Detik",options:X,active:(b==null?void 0:b.s)??null,onPick:t=>z({s:t})})]}),r==="12h"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-time-divider"}),e.jsx(gn,{label:"",options:[{value:0,label:"AM"},{value:1,label:"PM"}],active:b==null?null:j==="PM"?1:0,onPick:t=>cn(t===1?"PM":"AM")})]})]}),e.jsxs("div",{className:"sa-time-footer",children:[e.jsx("button",{type:"button",className:"sa-time-footer-btn",onClick:un,children:"Sekarang"}),e.jsx("button",{type:"button",className:"sa-time-footer-btn sa-time-footer-btn-muted",onClick:()=>{a(null),I(null)},children:"Hapus"})]})]}):null]});return e.jsx(xn,{label:v,labelPosition:u,required:C,optional:T,description:w,helperText:M,errorText:m,fullWidth:k,size:x,children:pn})});Tn.displayName="StarasiaTime",G.StarasiaDate=Qn,G.StarasiaTime=Tn,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "7.0.3",
3
+ "version": "7.1.0",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",