@starasia/date 5.0.0 → 5.0.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.
package/dist/date.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs as N, jsx as r, Fragment as _ } from "react/jsx-runtime";
2
- import { useState as j, useRef as A, useEffect as $, forwardRef as G } from "react";
2
+ import { useState as z, useRef as A, useEffect as $, forwardRef as G } from "react";
3
3
  const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
4
4
 
5
5
  * {
@@ -26,6 +26,8 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
26
26
  --sa-date-placeholder: var(--sa-color-gray-400, #b7b9be);
27
27
  --sa-date-border-error: var(--sa-color-error-500, #ff4d6d);
28
28
  --sa-date-border-warning: var(--sa-color-warning-400, #ed9f30);
29
+ --sa-date-accent-subtle: var(--sa-background-neutral, #f0f1f2);
30
+ --sa-date-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
29
31
  }
30
32
  .sa-calendar-wrapper {
31
33
  position: relative;
@@ -36,7 +38,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
36
38
  .sa-date-field {
37
39
  display: flex;
38
40
  flex-direction: column;
39
- gap: 6px;
41
+ gap: 8px;
40
42
  width: max-content;
41
43
  font-family: "Poppins", sans-serif;
42
44
  }
@@ -46,7 +48,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
46
48
  .sa-date-field-left {
47
49
  flex-direction: row;
48
50
  align-items: flex-start;
49
- gap: 16px;
51
+ gap: 8px;
50
52
  }
51
53
  .sa-date-field-left-label {
52
54
  display: flex;
@@ -59,7 +61,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
59
61
  .sa-date-field-input-wrap {
60
62
  display: flex;
61
63
  flex-direction: column;
62
- gap: 6px;
64
+ gap: 8px;
63
65
  flex: 1;
64
66
  min-width: 0;
65
67
  }
@@ -84,16 +86,14 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
84
86
  .sa-date-field-optional-badge {
85
87
  display: inline-flex;
86
88
  align-items: center;
87
- justify-content: center;
88
- padding: 0 6px;
89
- border: 0.8px solid var(--sa-date-border-color);
89
+ padding: 0 8px;
90
+ border: 1px solid var(--sa-date-border-subtle);
90
91
  border-radius: 4px;
91
- background-color: transparent;
92
+ background: var(--sa-date-accent-subtle);
92
93
  font-size: 10px;
93
94
  font-weight: 500;
94
- color: var(--sa-date-text-subtle);
95
+ color: var(--sa-date-text-primary);
95
96
  line-height: 18px;
96
- text-transform: lowercase;
97
97
  }
98
98
  .sa-date-field-helper-top,
99
99
  .sa-date-field-helper {
@@ -358,7 +358,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
358
358
  outline: 2px solid var(--sa-date-brand);
359
359
  outline-offset: 1px;
360
360
  }
361
- `, ee = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], z = [
361
+ `, ee = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], j = [
362
362
  "January",
363
363
  "February",
364
364
  "March",
@@ -386,7 +386,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
386
386
  "Dec"
387
387
  ];
388
388
  function ne(a) {
389
- const [n, t] = j(a), s = A(null), l = (p) => {
389
+ const [n, t] = z(a), s = A(null), l = (p) => {
390
390
  s.current && !s.current.contains(p.target) && t(!1);
391
391
  };
392
392
  return $(() => (document.addEventListener("click", l, !0), () => {
@@ -417,7 +417,7 @@ const W = (a) => {
417
417
  ...d
418
418
  } = a, g = A(null), i = () => {
419
419
  g.current && d.onClick && (g.current.focus(), d.onClick(""));
420
- }, e = t === "disable" || d.disabled, w = !!d.value, y = l && w && !e, k = (M) => {
420
+ }, e = t === "disable" || d.disabled, w = !!d.value, v = l && w && !e, k = (M) => {
421
421
  M.stopPropagation(), p == null || p();
422
422
  };
423
423
  return /* @__PURE__ */ N(
@@ -456,7 +456,7 @@ const W = (a) => {
456
456
  ref: g
457
457
  }
458
458
  ) }),
459
- y ? /* @__PURE__ */ r(
459
+ v ? /* @__PURE__ */ r(
460
460
  "button",
461
461
  {
462
462
  type: "button",
@@ -519,13 +519,13 @@ const W = (a) => {
519
519
  }) => {
520
520
  var f, o, c;
521
521
  let i = new Date(a.getFullYear(), a.getMonth(), 1), e = i.getDay(), w = [];
522
- const y = a.getMonth();
523
- for (let h = 0; h < 42; h++) {
524
- h === 0 && e === 0 ? i.setDate(i.getDate() - 7) : h === 0 ? i.setDate(
525
- i.getDate() + (h - e)
522
+ const v = a.getMonth();
523
+ for (let u = 0; u < 42; u++) {
524
+ u === 0 && e === 0 ? i.setDate(i.getDate() - 7) : u === 0 ? i.setDate(
525
+ i.getDate() + (u - e)
526
526
  ) : i.setDate(i.getDate() + 1);
527
- let b = {
528
- currentMonth: i.getMonth() === y,
527
+ let y = {
528
+ currentMonth: i.getMonth() === v,
529
529
  date: new Date(i),
530
530
  month: i.getMonth(),
531
531
  number: i.getDate(),
@@ -533,43 +533,43 @@ const W = (a) => {
533
533
  year: i.getFullYear(),
534
534
  isDisabled: p && i < p || d && i > d
535
535
  };
536
- w.push(b);
536
+ w.push(y);
537
537
  }
538
- const k = (h) => {
539
- n(h);
540
- }, M = (h) => {
541
- var u;
542
- let b = { ...t };
543
- if (b.from && b.to)
544
- b = { from: h, to: null };
538
+ const k = (u) => {
539
+ n(u);
540
+ }, M = (u) => {
541
+ var h;
542
+ let y = { ...t };
543
+ if (y.from && y.to)
544
+ y = { from: u, to: null };
545
545
  else {
546
- const m = ((u = b.from) == null ? void 0 : u.getTime()) || 0;
547
- h.getTime() > m ? b = { from: b.from, to: h } : b = { from: h, to: b.from };
546
+ const m = ((h = y.from) == null ? void 0 : h.getTime()) || 0;
547
+ u.getTime() > m ? y = { from: y.from, to: u } : y = { from: u, to: y.from };
548
548
  }
549
- s(b), l(b);
549
+ s(y), l(y);
550
550
  };
551
551
  return /* @__PURE__ */ N("div", { className: "sa-calendar-days-preivew", children: [
552
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((h, b) => /* @__PURE__ */ r("p", { children: h }, b)) }),
553
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: w.map((h, b) => {
552
+ /* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((u, y) => /* @__PURE__ */ r("p", { children: u }, y)) }),
553
+ /* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: w.map((u, y) => {
554
554
  var x;
555
- const u = h.date.getTime() > t.from.getTime() && h.date.getTime() < (((x = t.to) == null ? void 0 : x.getTime()) || t.from.getTime()), m = h.isDisabled;
555
+ const h = u.date.getTime() > t.from.getTime() && u.date.getTime() < (((x = t.to) == null ? void 0 : x.getTime()) || t.from.getTime()), m = u.isDisabled;
556
556
  return /* @__PURE__ */ r(
557
557
  "p",
558
558
  {
559
- className: `${h.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${h.selected ? "sa-calendar-days-active" : ""}`,
559
+ className: `${u.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${u.selected ? "sa-calendar-days-active" : ""}`,
560
560
  style: {
561
- backgroundColor: u ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
561
+ backgroundColor: h ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
562
562
  pointerEvents: m ? "none" : void 0,
563
563
  cursor: m ? "not-allowed" : "pointer",
564
- color: m ? "var(--sa-color-gray-400, #b7b9be)" : u ? "var(--sa-color-gray-500, #8c8f97)" : "",
564
+ color: m ? "var(--sa-color-gray-400, #b7b9be)" : h ? "var(--sa-color-gray-500, #8c8f97)" : "",
565
565
  ...g ? {} : { width: "100%" }
566
566
  },
567
567
  onClick: () => {
568
- m || (k(h.date), M(h.date));
568
+ m || (k(u.date), M(u.date));
569
569
  },
570
- children: h.number
570
+ children: u.number
571
571
  },
572
- b
572
+ y
573
573
  );
574
574
  }) })
575
575
  ] });
@@ -585,7 +585,7 @@ const W = (a) => {
585
585
  maxDate: i,
586
586
  input: e
587
587
  }) => {
588
- const w = l.from.getFullYear(), y = a.getFullYear(), k = (f) => {
588
+ const w = l.from.getFullYear(), v = a.getFullYear(), k = (f) => {
589
589
  t ? (M(f), n(f)) : (s("days"), n(f));
590
590
  }, M = (f) => {
591
591
  var c;
@@ -593,27 +593,27 @@ const W = (a) => {
593
593
  if (o.from && o.to)
594
594
  o = { from: f, to: null };
595
595
  else {
596
- const h = ((c = o.from) == null ? void 0 : c.getTime()) || 0;
597
- f.getTime() > h ? o = { from: o.from, to: f } : o = { from: f, to: o.from };
596
+ const u = ((c = o.from) == null ? void 0 : c.getTime()) || 0;
597
+ f.getTime() > u ? o = { from: o.from, to: f } : o = { from: f, to: o.from };
598
598
  }
599
599
  p(o), d(o);
600
600
  };
601
- return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: z.map((f, o) => {
602
- var b, u, m;
603
- const c = new Date(y, o).getTime() > l.from.getTime() && new Date(y, o).getTime() < (((b = l.to) == null ? void 0 : b.getTime()) || l.from.getTime()), h = g && new Date(y, o) < g || i && new Date(y, o) > i;
601
+ return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: j.map((f, o) => {
602
+ var y, h, m;
603
+ const c = new Date(v, o).getTime() > l.from.getTime() && new Date(v, o).getTime() < (((y = l.to) == null ? void 0 : y.getTime()) || l.from.getTime()), u = g && new Date(v, o) < g || i && new Date(v, o) > i;
604
604
  return /* @__PURE__ */ r(
605
605
  "p",
606
606
  {
607
- className: w === y && (o === ((u = l.from) == null ? void 0 : u.getMonth()) || o === ((m = l.to) == null ? void 0 : m.getMonth())) ? "sa-calendar-months-active" : "",
607
+ className: w === v && (o === ((h = l.from) == null ? void 0 : h.getMonth()) || o === ((m = l.to) == null ? void 0 : m.getMonth())) ? "sa-calendar-months-active" : "",
608
608
  style: {
609
609
  backgroundColor: c ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
610
- pointerEvents: h ? "none" : void 0,
611
- cursor: h ? "not-allowed" : "pointer",
612
- color: h ? "var(--sa-color-gray-400, #b7b9be)" : c ? "var(--sa-color-gray-500, #8c8f97)" : "",
610
+ pointerEvents: u ? "none" : void 0,
611
+ cursor: u ? "not-allowed" : "pointer",
612
+ color: u ? "var(--sa-color-gray-400, #b7b9be)" : c ? "var(--sa-color-gray-500, #8c8f97)" : "",
613
613
  ...e ? {} : { width: "100%" }
614
614
  },
615
615
  onClick: () => {
616
- h || k(new Date(y, o));
616
+ u || k(new Date(v, o));
617
617
  },
618
618
  children: f.slice(0, 3)
619
619
  },
@@ -635,46 +635,46 @@ const W = (a) => {
635
635
  maxDate: i,
636
636
  input: e
637
637
  }) => {
638
- var b;
638
+ var y;
639
639
  let w = [];
640
- const y = a.getFullYear(), { start: k, end: M } = U(y), f = l.from.getFullYear(), o = (b = l.to) == null ? void 0 : b.getFullYear();
641
- for (let u = k; u < M; u++) {
642
- const m = new Date(u, 0), x = (!g || m >= g) && (!i || m <= i), F = u === f || u === o, L = m > l.from && m < l.to;
640
+ const v = a.getFullYear(), { start: k, end: M } = U(v), f = l.from.getFullYear(), o = (y = l.to) == null ? void 0 : y.getFullYear();
641
+ for (let h = k; h < M; h++) {
642
+ const m = new Date(h, 0), x = (!g || m >= g) && (!i || m <= i), F = h === f || h === o, L = m > l.from && m < l.to;
643
643
  w.push({
644
- year: u,
644
+ year: h,
645
645
  active: F && x,
646
646
  highlight: L && x,
647
647
  disabled: !x
648
648
  });
649
649
  }
650
- const c = (u) => {
651
- n ? (h(u), s(u)) : (s(u), t("months"));
652
- }, h = (u) => {
650
+ const c = (h) => {
651
+ n ? (u(h), s(h)) : (s(h), t("months"));
652
+ }, u = (h) => {
653
653
  var x;
654
654
  let m = { ...l };
655
655
  if (m.from && m.to)
656
- m = { from: u, to: null };
656
+ m = { from: h, to: null };
657
657
  else {
658
658
  const F = ((x = m.from) == null ? void 0 : x.getTime()) || 0;
659
- u.getTime() > F ? m = { from: m.from, to: u } : m = { from: u, to: m.from };
659
+ h.getTime() > F ? m = { from: m.from, to: h } : m = { from: h, to: m.from };
660
660
  }
661
661
  p(m), d(m);
662
662
  };
663
- return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: w.map((u, m) => /* @__PURE__ */ r(
663
+ return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: w.map((h, m) => /* @__PURE__ */ r(
664
664
  "p",
665
665
  {
666
- className: `${u.active ? "sa-calendar-months-active" : ""} ${u.highlight ? "sa-calendar-months-highlight" : ""} ${u.disabled ? "sa-calendar-disabled" : ""}`,
666
+ className: `${h.active ? "sa-calendar-months-active" : ""} ${h.highlight ? "sa-calendar-months-highlight" : ""} ${h.disabled ? "sa-calendar-disabled" : ""}`,
667
667
  onClick: () => {
668
- u.disabled || c(new Date(u.year, 0));
668
+ h.disabled || c(new Date(h.year, 0));
669
669
  },
670
670
  style: {
671
- backgroundColor: u.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
672
- color: u.highlight ? "var(--sa-color-gray-500, #8c8f97)" : u.active ? "" : u.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
673
- cursor: u.disabled ? "not-allowed" : "pointer",
674
- pointerEvents: u.disbled ? "none" : "all",
671
+ backgroundColor: h.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
672
+ color: h.highlight ? "var(--sa-color-gray-500, #8c8f97)" : h.active ? "" : h.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
673
+ cursor: h.disabled ? "not-allowed" : "pointer",
674
+ pointerEvents: h.disbled ? "none" : "all",
675
675
  ...e ? {} : { width: "100%" }
676
676
  },
677
- children: u.year
677
+ children: h.year
678
678
  },
679
679
  m
680
680
  )) });
@@ -718,7 +718,7 @@ const W = (a) => {
718
718
  }
719
719
  )
720
720
  }
721
- ), he = ({
721
+ ), ue = ({
722
722
  setViews: a,
723
723
  views: n,
724
724
  filter: t,
@@ -757,7 +757,7 @@ const W = (a) => {
757
757
  /* @__PURE__ */ r(ae, { onClick: () => g() }),
758
758
  /* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick: p, children: (() => {
759
759
  if (n === "days")
760
- return `${z[s.getMonth()]} ${s.getFullYear()}`;
760
+ return `${j[s.getMonth()]} ${s.getFullYear()}`;
761
761
  if (n === "months")
762
762
  return `${s.getFullYear()}`;
763
763
  if (n === "years")
@@ -788,7 +788,7 @@ const te = ({
788
788
  /* @__PURE__ */ r("span", { className: "sa-date-field-label-text", children: a }),
789
789
  s && /* @__PURE__ */ r("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
790
790
  t && /* @__PURE__ */ r("span", { className: "sa-date-field-required", children: "*" })
791
- ] }) : null, y = /* @__PURE__ */ N(_, { children: [
791
+ ] }) : null, v = /* @__PURE__ */ N(_, { children: [
792
792
  p && !d && /* @__PURE__ */ r("p", { className: "sa-date-field-helper", children: p }),
793
793
  d && /* @__PURE__ */ r("p", { className: "sa-date-field-error-msg", children: d })
794
794
  ] });
@@ -799,25 +799,25 @@ const te = ({
799
799
  ] }),
800
800
  /* @__PURE__ */ N("div", { className: "sa-date-field-input-wrap", children: [
801
801
  i,
802
- y
802
+ v
803
803
  ] })
804
804
  ] }) : /* @__PURE__ */ N("div", { className: e, children: [
805
805
  w,
806
806
  l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l }),
807
807
  i,
808
- y
808
+ v
809
809
  ] }) : /* @__PURE__ */ N("div", { className: e, children: [
810
810
  l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l }),
811
811
  i,
812
- y
812
+ v
813
813
  ] });
814
- }, Q = "sa-calendar-styles", ue = (a) => {
814
+ }, Q = "sa-calendar-styles", he = (a) => {
815
815
  if (!document.getElementById(Q)) {
816
816
  const n = document.createElement("style");
817
817
  n.id = Q, n.textContent = a, document.head.appendChild(n);
818
818
  }
819
819
  };
820
- ue(P);
820
+ he(P);
821
821
  const pe = G(
822
822
  ({
823
823
  value: a,
@@ -831,16 +831,16 @@ const pe = G(
831
831
  size: i,
832
832
  status: e,
833
833
  clearable: w,
834
- fullWidth: y = !0,
834
+ fullWidth: v = !0,
835
835
  label: k,
836
836
  labelPosition: M,
837
837
  required: f,
838
838
  optional: o,
839
839
  description: c,
840
- helperText: h,
841
- errorText: b
842
- }, u) => {
843
- const m = b ? "error" : e, { ref: x, isComponentVisible: F, setIsComponentVisible: L } = ne(!1), C = A(null), [V, S] = j("days"), [Y, E] = j(/* @__PURE__ */ new Date()), [D, I] = j({
840
+ helperText: u,
841
+ errorText: y
842
+ }, h) => {
843
+ const m = y ? "error" : e, { ref: x, isComponentVisible: F, setIsComponentVisible: L } = ne(!1), C = A(null), [V, S] = z("days"), [Y, E] = z(/* @__PURE__ */ new Date()), [D, I] = z({
844
844
  from: (a == null ? void 0 : a.from) || /* @__PURE__ */ new Date(),
845
845
  to: (a == null ? void 0 : a.to) || /* @__PURE__ */ new Date()
846
846
  });
@@ -857,30 +857,30 @@ const pe = G(
857
857
  s || L(!0);
858
858
  }, [s]);
859
859
  const J = () => {
860
- var v, T;
860
+ var b, T;
861
861
  if (!a)
862
862
  return "";
863
863
  if (t) {
864
864
  if (V === "days")
865
865
  return `${H(D.from)} ~ ${H(D.to || D.from) || "-"}`;
866
866
  if (V === "months")
867
- return `${z[D.from.getMonth()]} ~ ${D.to ? z[D.to.getMonth()] : "-"}`;
867
+ return `${j[D.from.getMonth()]} ~ ${D.to ? j[D.to.getMonth()] : "-"}`;
868
868
  if (V === "years")
869
- return `${(v = D.from) == null ? void 0 : v.getFullYear()} ~ ${((T = D.to) == null ? void 0 : T.getFullYear()) || "-"}`;
869
+ return `${(b = D.from) == null ? void 0 : b.getFullYear()} ~ ${((T = D.to) == null ? void 0 : T.getFullYear()) || "-"}`;
870
870
  } else
871
871
  return `${H(D.from)} ~ ${H(D.to || D.from) || "-"}`;
872
872
  }, B = () => {
873
873
  if (C.current && x.current && s) {
874
- const v = x.current.getBoundingClientRect(), T = C.current.getBoundingClientRect();
875
- window.innerWidth < v.left + T.width ? C.current.style.left = `${v.left - T.width + v.width}px` : C.current.style.left = `${v.left}px`, v.top + T.height > window.innerHeight ? C.current.style.top = `${v.y - (v.height + T.height - 28)}px` : C.current.style.top = `${v.y + v.height}px`;
874
+ const b = x.current.getBoundingClientRect(), T = C.current.getBoundingClientRect();
875
+ window.innerWidth < b.left + T.width ? C.current.style.left = `${b.left - T.width + b.width}px` : C.current.style.left = `${b.left}px`, b.top + T.height > window.innerHeight ? C.current.style.top = `${b.y - (b.height + T.height - 28)}px` : C.current.style.top = `${b.y + b.height}px`;
876
876
  }
877
877
  };
878
878
  $(() => {
879
879
  C.current && x.current && s && B();
880
880
  }, [C, x, F]), $(() => {
881
- const v = u == null ? void 0 : u.current;
882
- return v && v.addEventListener("scroll", B), window.addEventListener("scroll", B), () => {
883
- v && v.removeEventListener("scroll", B), window.removeEventListener("scroll", B);
881
+ const b = h == null ? void 0 : h.current;
882
+ return b && b.addEventListener("scroll", B), window.addEventListener("scroll", B), () => {
883
+ b && b.removeEventListener("scroll", B), window.removeEventListener("scroll", B);
884
884
  };
885
885
  }, []);
886
886
  const R = /* @__PURE__ */ N(
@@ -915,7 +915,7 @@ const pe = G(
915
915
  ref: C,
916
916
  children: [
917
917
  /* @__PURE__ */ r(
918
- he,
918
+ ue,
919
919
  {
920
920
  setViews: S,
921
921
  views: V,
@@ -982,9 +982,9 @@ const pe = G(
982
982
  required: f,
983
983
  optional: o,
984
984
  description: c,
985
- helperText: h,
986
- errorText: b,
987
- fullWidth: y,
985
+ helperText: u,
986
+ errorText: y,
987
+ fullWidth: v,
988
988
  children: R
989
989
  }
990
990
  );
@@ -1013,7 +1013,7 @@ const O = (a) => {
1013
1013
  ...d
1014
1014
  } = a, g = A(null), i = () => {
1015
1015
  g.current && d.onClick && (g.current.focus(), d.onClick(""));
1016
- }, e = t === "disable" || d.disabled, w = !!d.value, y = l && w && !e, k = (M) => {
1016
+ }, e = t === "disable" || d.disabled, w = !!d.value, v = l && w && !e, k = (M) => {
1017
1017
  M.stopPropagation(), p == null || p();
1018
1018
  };
1019
1019
  return /* @__PURE__ */ N(
@@ -1052,7 +1052,7 @@ const O = (a) => {
1052
1052
  ref: g
1053
1053
  }
1054
1054
  ) }),
1055
- y ? /* @__PURE__ */ r(
1055
+ v ? /* @__PURE__ */ r(
1056
1056
  "button",
1057
1057
  {
1058
1058
  type: "button",
@@ -1118,7 +1118,7 @@ const O = (a) => {
1118
1118
  t.getFullYear(),
1119
1119
  t.getMonth(),
1120
1120
  1
1121
- ), w = e.getDay(), y = [];
1121
+ ), w = e.getDay(), v = [];
1122
1122
  const k = a.toDateString(), M = t.getMonth();
1123
1123
  for (let o = 0; o < 42; o++) {
1124
1124
  o === 0 && w === 0 ? e.setDate(e.getDate() - 7) : o === 0 ? e.setDate(
@@ -1133,27 +1133,27 @@ const O = (a) => {
1133
1133
  year: e.getFullYear(),
1134
1134
  isDisabled: p && e < p || d && e > d
1135
1135
  };
1136
- y.push(c);
1136
+ v.push(c);
1137
1137
  }
1138
1138
  const f = (o) => {
1139
1139
  (!p || o >= p) && (!d || o <= d) && (n(o), i(o), s(o), g && l(!1));
1140
1140
  };
1141
1141
  return /* @__PURE__ */ N("div", { className: "sa-calendar-days-preivew", children: [
1142
1142
  /* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((o, c) => /* @__PURE__ */ r("p", { children: o }, c)) }),
1143
- /* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: y.map((o, c) => {
1144
- const h = o.isDisabled;
1143
+ /* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: v.map((o, c) => {
1144
+ const u = o.isDisabled;
1145
1145
  return /* @__PURE__ */ r(
1146
1146
  "p",
1147
1147
  {
1148
1148
  className: `${o.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${o.selected ? "sa-calendar-days-active" : ""}`,
1149
1149
  style: {
1150
- color: h ? "#ccc" : void 0,
1151
- pointerEvents: h ? "none" : void 0,
1152
- cursor: h ? "not-allowed" : "pointer",
1150
+ color: u ? "#ccc" : void 0,
1151
+ pointerEvents: u ? "none" : void 0,
1152
+ cursor: u ? "not-allowed" : "pointer",
1153
1153
  ...g ? {} : { width: "100%" }
1154
1154
  },
1155
1155
  onClick: () => {
1156
- h || f(o.date);
1156
+ u || f(o.date);
1157
1157
  },
1158
1158
  children: o.number
1159
1159
  },
@@ -1161,7 +1161,7 @@ const O = (a) => {
1161
1161
  );
1162
1162
  }) })
1163
1163
  ] });
1164
- }, ve = ({
1164
+ }, be = ({
1165
1165
  date: a,
1166
1166
  setDate: n,
1167
1167
  filter: t,
@@ -1173,15 +1173,15 @@ const O = (a) => {
1173
1173
  maxDate: i,
1174
1174
  input: e
1175
1175
  }) => {
1176
- const w = a.getMonth(), y = a.getFullYear(), k = p.getFullYear(), M = (f) => {
1176
+ const w = a.getMonth(), v = a.getFullYear(), k = p.getFullYear(), M = (f) => {
1177
1177
  (!g || f >= g) && (!i || f <= i) && (t ? (l(f), n(f), d(f)) : (s("days"), d(f)));
1178
1178
  };
1179
- return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: z.map((f, o) => {
1179
+ return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: j.map((f, o) => {
1180
1180
  const c = g && new Date(k, o, 1) < g || i && new Date(k, o + 1, 0) > i;
1181
1181
  return /* @__PURE__ */ r(
1182
1182
  "p",
1183
1183
  {
1184
- className: o === w && k === y ? "sa-calendar-months-active" : "",
1184
+ className: o === w && k === v ? "sa-calendar-months-active" : "",
1185
1185
  style: {
1186
1186
  color: c ? "#ccc" : void 0,
1187
1187
  pointerEvents: c ? "none" : void 0,
@@ -1199,7 +1199,7 @@ const O = (a) => {
1199
1199
  }, q = (a) => {
1200
1200
  const n = Math.floor(a / 10) * 10, t = n + 10;
1201
1201
  return { start: n, end: t };
1202
- }, ye = ({
1202
+ }, ve = ({
1203
1203
  date: a,
1204
1204
  filter: n,
1205
1205
  setViews: t,
@@ -1212,15 +1212,15 @@ const O = (a) => {
1212
1212
  input: e
1213
1213
  }) => {
1214
1214
  let w = [];
1215
- const y = p.getFullYear(), { start: k, end: M } = q(y), f = a.getFullYear();
1215
+ const v = p.getFullYear(), { start: k, end: M } = q(v), f = a.getFullYear();
1216
1216
  for (let c = k; c < M; c++) {
1217
- let h = g && new Date(c, 0, 1) < g || i && new Date(c, 11, 31) > i;
1218
- w.push({ year: c, active: c === f, isDisabled: h });
1217
+ let u = g && new Date(c, 0, 1) < g || i && new Date(c, 11, 31) > i;
1218
+ w.push({ year: c, active: c === f, isDisabled: u });
1219
1219
  }
1220
1220
  const o = (c) => {
1221
1221
  (!g || c >= g) && (!i || c <= i) && (n ? (l(c), s(c), d(c)) : (t("months"), d(c)));
1222
1222
  };
1223
- return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: w.map((c, h) => /* @__PURE__ */ r(
1223
+ return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: w.map((c, u) => /* @__PURE__ */ r(
1224
1224
  "p",
1225
1225
  {
1226
1226
  className: c.active ? "sa-calendar-months-active" : "",
@@ -1235,9 +1235,9 @@ const O = (a) => {
1235
1235
  },
1236
1236
  children: c.year
1237
1237
  },
1238
- h
1238
+ u
1239
1239
  )) });
1240
- }, be = ({
1240
+ }, ye = ({
1241
1241
  setViews: a,
1242
1242
  views: n,
1243
1243
  filter: t,
@@ -1280,7 +1280,7 @@ const O = (a) => {
1280
1280
  /* @__PURE__ */ r(ae, { onClick: () => g() }),
1281
1281
  /* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick: p, children: (() => {
1282
1282
  if (n === "days")
1283
- return `${z[s.getMonth()]} ${s.getFullYear()}`;
1283
+ return `${j[s.getMonth()]} ${s.getFullYear()}`;
1284
1284
  if (n === "months")
1285
1285
  return `${s.getFullYear()}`;
1286
1286
  if (n === "years")
@@ -1308,16 +1308,16 @@ const xe = G(
1308
1308
  size: i,
1309
1309
  status: e,
1310
1310
  clearable: w,
1311
- fullWidth: y = !0,
1311
+ fullWidth: v = !0,
1312
1312
  label: k,
1313
1313
  labelPosition: M,
1314
1314
  required: f,
1315
1315
  optional: o,
1316
1316
  description: c,
1317
- helperText: h,
1318
- errorText: b
1319
- }, u) => {
1320
- const m = b ? "error" : e, { ref: x, isComponentVisible: F, setIsComponentVisible: L } = ne(!1), C = A(null), [V, S] = j("days"), [Y, E] = j(/* @__PURE__ */ new Date()), [D, I] = j(/* @__PURE__ */ new Date());
1317
+ helperText: u,
1318
+ errorText: y
1319
+ }, h) => {
1320
+ const m = y ? "error" : e, { ref: x, isComponentVisible: F, setIsComponentVisible: L } = ne(!1), C = A(null), [V, S] = z("days"), [Y, E] = z(/* @__PURE__ */ new Date()), [D, I] = z(/* @__PURE__ */ new Date());
1321
1321
  $(() => {
1322
1322
  a ? (E(a), I(a)) : (E(/* @__PURE__ */ new Date()), I(/* @__PURE__ */ new Date()));
1323
1323
  }, [a]), $(() => {
@@ -1327,18 +1327,18 @@ const xe = G(
1327
1327
  }, [F]), $(() => {
1328
1328
  s || L(!0);
1329
1329
  }, [s]);
1330
- const J = () => a ? t === "days" ? H(Y) : t === "months" ? `${z[Y.getMonth()]} ${Y.getFullYear()}` : t === "years" ? Y.getFullYear() : H(Y) : "", B = () => {
1330
+ const J = () => a ? t === "days" ? H(Y) : t === "months" ? `${j[Y.getMonth()]} ${Y.getFullYear()}` : t === "years" ? Y.getFullYear() : H(Y) : "", B = () => {
1331
1331
  if (C.current && x.current && s) {
1332
- const v = x.current.getBoundingClientRect(), T = C.current.getBoundingClientRect();
1333
- window.innerWidth < v.left + T.width ? C.current.style.left = `${v.left - T.width + v.width}px` : C.current.style.left = `${v.left}px`, v.top + T.height > window.innerHeight ? C.current.style.top = `${v.y - (v.height + T.height - 28)}px` : C.current.style.top = `${v.y + v.height}px`;
1332
+ const b = x.current.getBoundingClientRect(), T = C.current.getBoundingClientRect();
1333
+ window.innerWidth < b.left + T.width ? C.current.style.left = `${b.left - T.width + b.width}px` : C.current.style.left = `${b.left}px`, b.top + T.height > window.innerHeight ? C.current.style.top = `${b.y - (b.height + T.height - 28)}px` : C.current.style.top = `${b.y + b.height}px`;
1334
1334
  }
1335
1335
  };
1336
1336
  $(() => {
1337
1337
  C.current && x.current && s && B();
1338
1338
  }, [C, x, F]), $(() => {
1339
- const v = u == null ? void 0 : u.current;
1340
- return v && v.addEventListener("scroll", B), window.addEventListener("scroll", B), () => {
1341
- v && v.removeEventListener("scroll", B), window.removeEventListener("scroll", B);
1339
+ const b = h == null ? void 0 : h.current;
1340
+ return b && b.addEventListener("scroll", B), window.addEventListener("scroll", B), () => {
1341
+ b && b.removeEventListener("scroll", B), window.removeEventListener("scroll", B);
1342
1342
  };
1343
1343
  }, []);
1344
1344
  const R = /* @__PURE__ */ N(
@@ -1371,7 +1371,7 @@ const xe = G(
1371
1371
  ref: C,
1372
1372
  children: [
1373
1373
  /* @__PURE__ */ r(
1374
- be,
1374
+ ye,
1375
1375
  {
1376
1376
  setViews: S,
1377
1377
  views: V,
@@ -1395,7 +1395,7 @@ const xe = G(
1395
1395
  onChange: n
1396
1396
  }
1397
1397
  ) : V === "months" ? /* @__PURE__ */ r(
1398
- ve,
1398
+ be,
1399
1399
  {
1400
1400
  date: Y,
1401
1401
  setDate: E,
@@ -1409,7 +1409,7 @@ const xe = G(
1409
1409
  input: s
1410
1410
  }
1411
1411
  ) : /* @__PURE__ */ r(
1412
- ye,
1412
+ ve,
1413
1413
  {
1414
1414
  date: Y,
1415
1415
  setDate: E,
@@ -1437,9 +1437,9 @@ const xe = G(
1437
1437
  required: f,
1438
1438
  optional: o,
1439
1439
  description: c,
1440
- helperText: h,
1441
- errorText: b,
1442
- fullWidth: y,
1440
+ helperText: u,
1441
+ errorText: y,
1442
+ fullWidth: v,
1443
1443
  children: R
1444
1444
  }
1445
1445
  );
@@ -1457,15 +1457,15 @@ const xe = G(
1457
1457
  placeholder: i,
1458
1458
  size: e,
1459
1459
  status: w,
1460
- clearable: y,
1460
+ clearable: v,
1461
1461
  fullWidth: k,
1462
1462
  label: M,
1463
1463
  labelPosition: f,
1464
1464
  required: o,
1465
1465
  optional: c,
1466
- description: h,
1467
- helperText: b,
1468
- errorText: u
1466
+ description: u,
1467
+ helperText: y,
1468
+ errorText: h
1469
1469
  }, m) => {
1470
1470
  const x = {
1471
1471
  onChange: n,
@@ -1478,15 +1478,15 @@ const xe = G(
1478
1478
  placeholder: i,
1479
1479
  size: e,
1480
1480
  status: w,
1481
- clearable: y,
1481
+ clearable: v,
1482
1482
  fullWidth: k,
1483
1483
  label: M,
1484
1484
  labelPosition: f,
1485
1485
  required: o,
1486
1486
  optional: c,
1487
- description: h,
1488
- helperText: b,
1489
- errorText: u
1487
+ description: u,
1488
+ helperText: y,
1489
+ errorText: h
1490
1490
  };
1491
1491
  return /* @__PURE__ */ r(_, { children: l ? /* @__PURE__ */ r(pe, { ...x, ref: m }) : /* @__PURE__ */ r(xe, { ...x, ref: m }) });
1492
1492
  }
package/dist/date.umd.js CHANGED
@@ -24,6 +24,8 @@
24
24
  --sa-date-placeholder: var(--sa-color-gray-400, #b7b9be);
25
25
  --sa-date-border-error: var(--sa-color-error-500, #ff4d6d);
26
26
  --sa-date-border-warning: var(--sa-color-warning-400, #ed9f30);
27
+ --sa-date-accent-subtle: var(--sa-background-neutral, #f0f1f2);
28
+ --sa-date-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
27
29
  }
28
30
  .sa-calendar-wrapper {
29
31
  position: relative;
@@ -34,7 +36,7 @@
34
36
  .sa-date-field {
35
37
  display: flex;
36
38
  flex-direction: column;
37
- gap: 6px;
39
+ gap: 8px;
38
40
  width: max-content;
39
41
  font-family: "Poppins", sans-serif;
40
42
  }
@@ -44,7 +46,7 @@
44
46
  .sa-date-field-left {
45
47
  flex-direction: row;
46
48
  align-items: flex-start;
47
- gap: 16px;
49
+ gap: 8px;
48
50
  }
49
51
  .sa-date-field-left-label {
50
52
  display: flex;
@@ -57,7 +59,7 @@
57
59
  .sa-date-field-input-wrap {
58
60
  display: flex;
59
61
  flex-direction: column;
60
- gap: 6px;
62
+ gap: 8px;
61
63
  flex: 1;
62
64
  min-width: 0;
63
65
  }
@@ -82,16 +84,14 @@
82
84
  .sa-date-field-optional-badge {
83
85
  display: inline-flex;
84
86
  align-items: center;
85
- justify-content: center;
86
- padding: 0 6px;
87
- border: 0.8px solid var(--sa-date-border-color);
87
+ padding: 0 8px;
88
+ border: 1px solid var(--sa-date-border-subtle);
88
89
  border-radius: 4px;
89
- background-color: transparent;
90
+ background: var(--sa-date-accent-subtle);
90
91
  font-size: 10px;
91
92
  font-weight: 500;
92
- color: var(--sa-date-text-subtle);
93
+ color: var(--sa-date-text-primary);
93
94
  line-height: 18px;
94
- text-transform: lowercase;
95
95
  }
96
96
  .sa-date-field-helper-top,
97
97
  .sa-date-field-helper {
@@ -356,4 +356,4 @@
356
356
  outline: 2px solid var(--sa-date-brand);
357
357
  outline-offset: 1px;
358
358
  }
359
- `,U=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],V=["January","February","March","April","May","June","July","August","September","October","November","December"],ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function G(r){const[a,t]=m.useState(r),s=m.useRef(null),l=p=>{s.current&&!s.current.contains(p.target)&&t(!1)};return m.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:s,isComponentVisible:a,setIsComponentVisible:t}}const K="sa-calendar-input-styles";(r=>{if(!document.getElementById(K)){const a=document.createElement("style");a.id=K,a.textContent=r,document.head.appendChild(a)}})(H);const z=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},ae=r=>{const{size:a="md",status:t="default",variant:s="outline",clearable:l,onClear:p,...i}=r,u=m.useRef(null),d=()=>{u.current&&i.onClick&&(u.current.focus(),i.onClick(""))},n=t==="disable"||i.disabled,x=!!i.value,b=l&&x&&!n,M=C=>{C.stopPropagation(),p==null||p()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${a} `,onClick:d,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:z(a),height:z(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:n,value:i.value,ref:u})}),b?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:M,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:z(a),height:z(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:z(a),height:z(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"})})})]})},re=({date:r,setDate:a,dateRange:t,setDateRange:s,onChange:l,minDate:p,maxDate:i,input:u})=>{var g,o,c;let d=new Date(r.getFullYear(),r.getMonth(),1),n=d.getDay(),x=[];const b=r.getMonth();for(let h=0;h<42;h++){h===0&&n===0?d.setDate(d.getDate()-7):h===0?d.setDate(d.getDate()+(h-n)):d.setDate(d.getDate()+1);let w={currentMonth:d.getMonth()===b,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===((g=t.from)==null?void 0:g.toDateString())||d.toDateString()===(((o=t.to)==null?void 0:o.toDateString())||((c=t.from)==null?void 0:c.toDateString())),year:d.getFullYear(),isDisabled:p&&d<p||i&&d>i};x.push(w)}const M=h=>{a(h)},C=h=>{var f;let w={...t};if(w.from&&w.to)w={from:h,to:null};else{const y=((f=w.from)==null?void 0:f.getTime())||0;h.getTime()>y?w={from:w.from,to:h}:w={from:h,to:w.from}}s(w),l(w)};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:U.map((h,w)=>e.jsx("p",{children:h},w))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:x.map((h,w)=>{var k;const f=h.date.getTime()>t.from.getTime()&&h.date.getTime()<(((k=t.to)==null?void 0:k.getTime())||t.from.getTime()),y=h.isDisabled;return e.jsx("p",{className:`${h.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${h.selected?"sa-calendar-days-active":""}`,style:{backgroundColor:f?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:y?"none":void 0,cursor:y?"not-allowed":"pointer",color:y?"var(--sa-color-gray-400, #b7b9be)":f?"var(--sa-color-gray-500, #8c8f97)":"",...u?{}:{width:"100%"}},onClick:()=>{y||(M(h.date),C(h.date))},children:h.number},w)})})]})},te=({date:r,setDate:a,filter:t,setViews:s,dateRange:l,setDateRange:p,onChange:i,minDate:u,maxDate:d,input:n})=>{const x=l.from.getFullYear(),b=r.getFullYear(),M=g=>{t?(C(g),a(g)):(s("days"),a(g))},C=g=>{var c;let o={...l};if(o.from&&o.to)o={from:g,to:null};else{const h=((c=o.from)==null?void 0:c.getTime())||0;g.getTime()>h?o={from:o.from,to:g}:o={from:g,to:o.from}}p(o),i(o)};return e.jsx("div",{className:"sa-calendar-months-preview",children:V.map((g,o)=>{var w,f,y;const c=new Date(b,o).getTime()>l.from.getTime()&&new Date(b,o).getTime()<(((w=l.to)==null?void 0:w.getTime())||l.from.getTime()),h=u&&new Date(b,o)<u||d&&new Date(b,o)>d;return e.jsx("p",{className:x===b&&(o===((f=l.from)==null?void 0:f.getMonth())||o===((y=l.to)==null?void 0:y.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:c?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:h?"none":void 0,cursor:h?"not-allowed":"pointer",color:h?"var(--sa-color-gray-400, #b7b9be)":c?"var(--sa-color-gray-500, #8c8f97)":"",...n?{}:{width:"100%"}},onClick:()=>{h||M(new Date(b,o))},children:g.slice(0,3)},o)})})},P=r=>{const a=Math.floor(r/10)*10,t=a+10;return{start:a,end:t}},se=({date:r,filter:a,setViews:t,setDate:s,dateRange:l,setDateRange:p,onChange:i,minDate:u,maxDate:d,input:n})=>{var w;let x=[];const b=r.getFullYear(),{start:M,end:C}=P(b),g=l.from.getFullYear(),o=(w=l.to)==null?void 0:w.getFullYear();for(let f=M;f<C;f++){const y=new Date(f,0),k=(!u||y>=u)&&(!d||y<=d),Y=f===g||f===o,F=y>l.from&&y<l.to;x.push({year:f,active:Y&&k,highlight:F&&k,disabled:!k})}const c=f=>{a?(h(f),s(f)):(s(f),t("months"))},h=f=>{var k;let y={...l};if(y.from&&y.to)y={from:f,to:null};else{const Y=((k=y.from)==null?void 0:k.getTime())||0;f.getTime()>Y?y={from:y.from,to:f}:y={from:f,to:y.from}}p(y),i(y)};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((f,y)=>e.jsx("p",{className:`${f.active?"sa-calendar-months-active":""} ${f.highlight?"sa-calendar-months-highlight":""} ${f.disabled?"sa-calendar-disabled":""}`,onClick:()=>{f.disabled||c(new Date(f.year,0))},style:{backgroundColor:f.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:f.highlight?"var(--sa-color-gray-500, #8c8f97)":f.active?"":f.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:f.disabled?"not-allowed":"pointer",pointerEvents:f.disbled?"none":"all",...n?{}:{width:"100%"}},children:f.year},y))})},Q=({...r})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,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"})}),X=({...r})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,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"})}),oe=({setViews:r,views:a,filter:t,date:s,setDate:l})=>{const p=()=>{t||r(n=>n==="days"?"months":n==="months"?"years":"days")},i=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()+10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()+1,n.getMonth()));return}l(n=>new Date(n.getFullYear(),n.getMonth()+1))},u=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()-10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()-1,n.getMonth()));return}l(n=>new Date(n.getMonth()===0?n.getFullYear()-1:n.getFullYear(),n.getMonth()===0?11:n.getMonth()-1))},d=()=>{if(a==="days")return`${V[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${P(s.getFullYear()).start} ~ ${P(s.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx(Q,{onClick:()=>u()}),e.jsx("div",{style:{cursor:"pointer"},onClick:p,children:d()}),e.jsx(X,{onClick:()=>i()})]})};function W(r){const a=new Date(r),t=a.getFullYear(),s=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${ne[s]} ${t}`}const Z=({label:r,labelPosition:a="outside-top",required:t,optional:s,description:l,helperText:p,errorText:i,fullWidth:u,children:d})=>{const n=["sa-date-field",u?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),x=r?e.jsxs("div",{className:"sa-date-field-label-row",children:[e.jsx("span",{className:"sa-date-field-label-text",children:r}),s&&e.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),t&&e.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,b=e.jsxs(e.Fragment,{children:[p&&!i&&e.jsx("p",{className:"sa-date-field-helper",children:p}),i&&e.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return r?a==="outside-left"?e.jsxs("div",{className:`${n} sa-date-field-left`,children:[e.jsxs("div",{className:"sa-date-field-left-label",children:[x,l&&e.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),e.jsxs("div",{className:"sa-date-field-input-wrap",children:[d,b]})]}):e.jsxs("div",{className:n,children:[x,l&&e.jsx("p",{className:"sa-date-field-helper-top",children:l}),d,b]}):e.jsxs("div",{className:n,children:[l&&e.jsx("p",{className:"sa-date-field-helper-top",children:l}),d,b]})},_="sa-calendar-styles";(r=>{if(!document.getElementById(_)){const a=document.createElement("style");a.id=_,a.textContent=r,document.head.appendChild(a)}})(H);const le=m.forwardRef(({value:r,onChange:a,filter:t,input:s=!0,disabled:l,minDate:p,maxDate:i,placeholder:u,size:d,status:n,clearable:x,fullWidth:b=!0,label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w},f)=>{const y=w?"error":n,{ref:k,isComponentVisible:Y,setIsComponentVisible:F}=G(!1),D=m.useRef(null),[j,T]=m.useState("days"),[N,E]=m.useState(new Date),[$,L]=m.useState({from:(r==null?void 0:r.from)||new Date,to:(r==null?void 0:r.to)||new Date});m.useEffect(()=>{r?(E(r.from),L(r)):(E(new Date),L({from:new Date,to:new Date}))},[r]),m.useEffect(()=>{t&&T(t)},[t]),m.useEffect(()=>{t||T("days")},[Y]),m.useEffect(()=>{s||F(!0)},[s]);const J=()=>{var v,S;if(!r)return"";if(t){if(j==="days")return`${W($.from)} ~ ${W($.to||$.from)||"-"}`;if(j==="months")return`${V[$.from.getMonth()]} ~ ${$.to?V[$.to.getMonth()]:"-"}`;if(j==="years")return`${(v=$.from)==null?void 0:v.getFullYear()} ~ ${((S=$.to)==null?void 0:S.getFullYear())||"-"}`}else return`${W($.from)} ~ ${W($.to||$.from)||"-"}`},I=()=>{if(D.current&&k.current&&s){const v=k.current.getBoundingClientRect(),S=D.current.getBoundingClientRect();window.innerWidth<v.left+S.width?D.current.style.left=`${v.left-S.width+v.width}px`:D.current.style.left=`${v.left}px`,v.top+S.height>window.innerHeight?D.current.style.top=`${v.y-(v.height+S.height-28)}px`:D.current.style.top=`${v.y+v.height}px`}};m.useEffect(()=>{D.current&&k.current&&s&&I()},[D,k,Y]),m.useEffect(()=>{const v=f==null?void 0:f.current;return v&&v.addEventListener("scroll",I),window.addEventListener("scroll",I),()=>{v&&v.removeEventListener("scroll",I),window.removeEventListener("scroll",I)}},[]);const q=e.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?k:null,children:[s?e.jsx(ae,{value:J(),inputMode:"none",onClick:()=>{F(!0)},onChange:()=>{},disabled:l,placeholder:u,size:d,status:y,clearable:x,onClear:()=>a(void 0)}):null,Y?e.jsxs("div",{className:`sa-calendar ${s?"":"sa-calendar-no-input"}`,ref:D,children:[e.jsx(oe,{setViews:T,views:j,filter:t,date:N,setDate:E}),e.jsx("div",{className:"sa-calendar-body",children:j==="days"?e.jsx(re,{date:N,setDate:E,setIsComponentVisible:F,dateRange:$,setDateRange:L,input:s,onChange:a,minDate:p,maxDate:i}):j==="months"?e.jsx(te,{date:N,setDate:E,filter:t,setViews:T,dateRange:$,setDateRange:L,setIsComponentVisible:F,input:s,onChange:a,minDate:p,maxDate:i}):e.jsx(se,{date:N,setDate:E,filter:t,setViews:T,dateRange:$,setDateRange:L,setIsComponentVisible:F,input:s,onChange:a,minDate:p,maxDate:i})})]}):null]});return e.jsx(Z,{label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w,fullWidth:b,children:q})}),R="sa-calendar-input-styles";(r=>{if(!document.getElementById(R)){const a=document.createElement("style");a.id=R,a.textContent=r,document.head.appendChild(a)}})(H);const O=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},de=r=>{const{size:a="md",status:t="default",variant:s="outline",clearable:l,onClear:p,...i}=r,u=m.useRef(null),d=()=>{u.current&&i.onClick&&(u.current.focus(),i.onClick(""))},n=t==="disable"||i.disabled,x=!!i.value,b=l&&x&&!n,M=C=>{C.stopPropagation(),p==null||p()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${a} `,onClick:d,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(a),height:O(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:n,value:i.value,ref:u})}),b?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:M,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(a),height:O(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:O(a),height:O(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"})})})]})},ie=({date:r,setDate:a,previewDate:t,setPreviewDate:s,setIsComponentVisible:l,minDate:p,maxDate:i,input:u,onChange:d})=>{let n=new Date(t.getFullYear(),t.getMonth(),1),x=n.getDay(),b=[];const M=r.toDateString(),C=t.getMonth();for(let o=0;o<42;o++){o===0&&x===0?n.setDate(n.getDate()-7):o===0?n.setDate(n.getDate()+(o-x)):n.setDate(n.getDate()+1);let c={currentMonth:n.getMonth()===C,date:new Date(n),month:n.getMonth(),number:n.getDate(),selected:n.toDateString()===M,year:n.getFullYear(),isDisabled:p&&n<p||i&&n>i};b.push(c)}const g=o=>{(!p||o>=p)&&(!i||o<=i)&&(a(o),d(o),s(o),u&&l(!1))};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:U.map((o,c)=>e.jsx("p",{children:o},c))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:b.map((o,c)=>{const h=o.isDisabled;return e.jsx("p",{className:`${o.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${o.selected?"sa-calendar-days-active":""}`,style:{color:h?"#ccc":void 0,pointerEvents:h?"none":void 0,cursor:h?"not-allowed":"pointer",...u?{}:{width:"100%"}},onClick:()=>{h||g(o.date)},children:o.number},c)})})]})},ce=({date:r,setDate:a,filter:t,setViews:s,onChange:l,previewDate:p,setPreviewDate:i,minDate:u,maxDate:d,input:n})=>{const x=r.getMonth(),b=r.getFullYear(),M=p.getFullYear(),C=g=>{(!u||g>=u)&&(!d||g<=d)&&(t?(l(g),a(g),i(g)):(s("days"),i(g)))};return e.jsx("div",{className:"sa-calendar-months-preview",children:V.map((g,o)=>{const c=u&&new Date(M,o,1)<u||d&&new Date(M,o+1,0)>d;return e.jsx("p",{className:o===x&&M===b?"sa-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...n?{}:{width:"100%"}},onClick:()=>{c||C(new Date(M,o))},children:g.slice(0,3)},o)})})},A=r=>{const a=Math.floor(r/10)*10,t=a+10;return{start:a,end:t}},he=({date:r,filter:a,setViews:t,setDate:s,onChange:l,previewDate:p,setPreviewDate:i,minDate:u,maxDate:d,input:n})=>{let x=[];const b=p.getFullYear(),{start:M,end:C}=A(b),g=r.getFullYear();for(let c=M;c<C;c++){let h=u&&new Date(c,0,1)<u||d&&new Date(c,11,31)>d;x.push({year:c,active:c===g,isDisabled:h})}const o=c=>{(!u||c>=u)&&(!d||c<=d)&&(a?(l(c),s(c),i(c)):(t("months"),i(c)))};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((c,h)=>e.jsx("p",{className:c.active?"sa-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...n?{}:{width:"100%"}},onClick:()=>{c.isDisabled||o(new Date(c.year,0))},children:c.year},h))})},fe=({setViews:r,views:a,filter:t,previewDate:s,setPreviewDate:l})=>{const p=()=>{t||r(n=>n==="days"?"months":n==="months"?"years":"days")},i=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()+10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()+1,n.getMonth()));return}l(n=>new Date(n.getFullYear(),n.getMonth()+1))},u=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()-10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()-1,n.getMonth()));return}l(n=>new Date(n.getMonth()===0?n.getFullYear()-1:n.getFullYear(),n.getMonth()===0?11:n.getMonth()-1))},d=()=>{if(a==="days")return`${V[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${A(s.getFullYear()).start} ~ ${A(s.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx(Q,{onClick:()=>u()}),e.jsx("div",{style:{cursor:"pointer"},onClick:p,children:d()}),e.jsx(X,{onClick:()=>i()})]})},ee="sa-calendar-styles";(r=>{if(!document.getElementById(ee)){const a=document.createElement("style");a.id=ee,a.textContent=r,document.head.appendChild(a)}})(H);const pe=m.forwardRef(({value:r,onChange:a,filter:t,input:s=!0,disabled:l,minDate:p,maxDate:i,placeholder:u,size:d,status:n,clearable:x,fullWidth:b=!0,label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w},f)=>{const y=w?"error":n,{ref:k,isComponentVisible:Y,setIsComponentVisible:F}=G(!1),D=m.useRef(null),[j,T]=m.useState("days"),[N,E]=m.useState(new Date),[$,L]=m.useState(new Date);m.useEffect(()=>{r?(E(r),L(r)):(E(new Date),L(new Date))},[r]),m.useEffect(()=>{t&&T(t)},[t]),m.useEffect(()=>{t||T("days")},[Y]),m.useEffect(()=>{s||F(!0)},[s]);const J=()=>r?t==="days"?W(N):t==="months"?`${V[N.getMonth()]} ${N.getFullYear()}`:t==="years"?N.getFullYear():W(N):"",I=()=>{if(D.current&&k.current&&s){const v=k.current.getBoundingClientRect(),S=D.current.getBoundingClientRect();window.innerWidth<v.left+S.width?D.current.style.left=`${v.left-S.width+v.width}px`:D.current.style.left=`${v.left}px`,v.top+S.height>window.innerHeight?D.current.style.top=`${v.y-(v.height+S.height-28)}px`:D.current.style.top=`${v.y+v.height}px`}};m.useEffect(()=>{D.current&&k.current&&s&&I()},[D,k,Y]),m.useEffect(()=>{const v=f==null?void 0:f.current;return v&&v.addEventListener("scroll",I),window.addEventListener("scroll",I),()=>{v&&v.removeEventListener("scroll",I),window.removeEventListener("scroll",I)}},[]);const q=e.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?k:null,children:[s?e.jsx(de,{value:J(),onClick:()=>F(!0),onChange:()=>{},placeholder:u,disabled:l,size:d,status:y,inputMode:"none",clearable:x,onClear:()=>a(void 0)}):null,Y?e.jsxs("div",{className:`sa-calendar ${s?"":"sa-calendar-no-input"}`,ref:D,children:[e.jsx(fe,{setViews:T,views:j,filter:t,previewDate:$,setPreviewDate:L,isComponentVisible:Y}),e.jsx("div",{className:"sa-calendar-body",children:j==="days"?e.jsx(ie,{date:N,setDate:E,previewDate:$,setPreviewDate:L,setIsComponentVisible:F,input:s,minDate:p,maxDate:i,onChange:a}):j==="months"?e.jsx(ce,{date:N,setDate:E,previewDate:$,setPreviewDate:L,filter:t,setViews:T,onChange:a,minDate:p,maxDate:i,input:s}):e.jsx(he,{date:N,setDate:E,previewDate:$,setPreviewDate:L,filter:t,setViews:T,onChange:a,minDate:p,maxDate:i,input:s})})]}):null]});return e.jsx(Z,{label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w,fullWidth:b,children:q})}),ue=m.forwardRef(({value:r,onChange:a,filter:t,input:s=!0,rangedDate:l,disabled:p,minDate:i,maxDate:u,placeholder:d,size:n,status:x,clearable:b,fullWidth:M,label:C,labelPosition:g,required:o,optional:c,description:h,helperText:w,errorText:f},y)=>{const k={onChange:a,value:r,input:s,filter:t,disabled:p,minDate:i,maxDate:u,placeholder:d,size:n,status:x,clearable:b,fullWidth:M,label:C,labelPosition:g,required:o,optional:c,description:h,helperText:w,errorText:f};return e.jsx(e.Fragment,{children:l?e.jsx(le,{...k,ref:y}):e.jsx(pe,{...k,ref:y})})});B.StarasiaDate=ue,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
359
+ `,U=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],V=["January","February","March","April","May","June","July","August","September","October","November","December"],ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function G(r){const[a,t]=m.useState(r),s=m.useRef(null),l=p=>{s.current&&!s.current.contains(p.target)&&t(!1)};return m.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:s,isComponentVisible:a,setIsComponentVisible:t}}const K="sa-calendar-input-styles";(r=>{if(!document.getElementById(K)){const a=document.createElement("style");a.id=K,a.textContent=r,document.head.appendChild(a)}})(H);const z=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},ae=r=>{const{size:a="md",status:t="default",variant:s="outline",clearable:l,onClear:p,...i}=r,u=m.useRef(null),d=()=>{u.current&&i.onClick&&(u.current.focus(),i.onClick(""))},n=t==="disable"||i.disabled,x=!!i.value,v=l&&x&&!n,M=C=>{C.stopPropagation(),p==null||p()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${a} `,onClick:d,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:z(a),height:z(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:n,value:i.value,ref:u})}),v?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:M,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:z(a),height:z(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:z(a),height:z(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"})})})]})},re=({date:r,setDate:a,dateRange:t,setDateRange:s,onChange:l,minDate:p,maxDate:i,input:u})=>{var g,o,c;let d=new Date(r.getFullYear(),r.getMonth(),1),n=d.getDay(),x=[];const v=r.getMonth();for(let h=0;h<42;h++){h===0&&n===0?d.setDate(d.getDate()-7):h===0?d.setDate(d.getDate()+(h-n)):d.setDate(d.getDate()+1);let w={currentMonth:d.getMonth()===v,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===((g=t.from)==null?void 0:g.toDateString())||d.toDateString()===(((o=t.to)==null?void 0:o.toDateString())||((c=t.from)==null?void 0:c.toDateString())),year:d.getFullYear(),isDisabled:p&&d<p||i&&d>i};x.push(w)}const M=h=>{a(h)},C=h=>{var f;let w={...t};if(w.from&&w.to)w={from:h,to:null};else{const y=((f=w.from)==null?void 0:f.getTime())||0;h.getTime()>y?w={from:w.from,to:h}:w={from:h,to:w.from}}s(w),l(w)};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:U.map((h,w)=>e.jsx("p",{children:h},w))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:x.map((h,w)=>{var k;const f=h.date.getTime()>t.from.getTime()&&h.date.getTime()<(((k=t.to)==null?void 0:k.getTime())||t.from.getTime()),y=h.isDisabled;return e.jsx("p",{className:`${h.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${h.selected?"sa-calendar-days-active":""}`,style:{backgroundColor:f?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:y?"none":void 0,cursor:y?"not-allowed":"pointer",color:y?"var(--sa-color-gray-400, #b7b9be)":f?"var(--sa-color-gray-500, #8c8f97)":"",...u?{}:{width:"100%"}},onClick:()=>{y||(M(h.date),C(h.date))},children:h.number},w)})})]})},te=({date:r,setDate:a,filter:t,setViews:s,dateRange:l,setDateRange:p,onChange:i,minDate:u,maxDate:d,input:n})=>{const x=l.from.getFullYear(),v=r.getFullYear(),M=g=>{t?(C(g),a(g)):(s("days"),a(g))},C=g=>{var c;let o={...l};if(o.from&&o.to)o={from:g,to:null};else{const h=((c=o.from)==null?void 0:c.getTime())||0;g.getTime()>h?o={from:o.from,to:g}:o={from:g,to:o.from}}p(o),i(o)};return e.jsx("div",{className:"sa-calendar-months-preview",children:V.map((g,o)=>{var w,f,y;const c=new Date(v,o).getTime()>l.from.getTime()&&new Date(v,o).getTime()<(((w=l.to)==null?void 0:w.getTime())||l.from.getTime()),h=u&&new Date(v,o)<u||d&&new Date(v,o)>d;return e.jsx("p",{className:x===v&&(o===((f=l.from)==null?void 0:f.getMonth())||o===((y=l.to)==null?void 0:y.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:c?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:h?"none":void 0,cursor:h?"not-allowed":"pointer",color:h?"var(--sa-color-gray-400, #b7b9be)":c?"var(--sa-color-gray-500, #8c8f97)":"",...n?{}:{width:"100%"}},onClick:()=>{h||M(new Date(v,o))},children:g.slice(0,3)},o)})})},P=r=>{const a=Math.floor(r/10)*10,t=a+10;return{start:a,end:t}},se=({date:r,filter:a,setViews:t,setDate:s,dateRange:l,setDateRange:p,onChange:i,minDate:u,maxDate:d,input:n})=>{var w;let x=[];const v=r.getFullYear(),{start:M,end:C}=P(v),g=l.from.getFullYear(),o=(w=l.to)==null?void 0:w.getFullYear();for(let f=M;f<C;f++){const y=new Date(f,0),k=(!u||y>=u)&&(!d||y<=d),Y=f===g||f===o,F=y>l.from&&y<l.to;x.push({year:f,active:Y&&k,highlight:F&&k,disabled:!k})}const c=f=>{a?(h(f),s(f)):(s(f),t("months"))},h=f=>{var k;let y={...l};if(y.from&&y.to)y={from:f,to:null};else{const Y=((k=y.from)==null?void 0:k.getTime())||0;f.getTime()>Y?y={from:y.from,to:f}:y={from:f,to:y.from}}p(y),i(y)};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((f,y)=>e.jsx("p",{className:`${f.active?"sa-calendar-months-active":""} ${f.highlight?"sa-calendar-months-highlight":""} ${f.disabled?"sa-calendar-disabled":""}`,onClick:()=>{f.disabled||c(new Date(f.year,0))},style:{backgroundColor:f.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:f.highlight?"var(--sa-color-gray-500, #8c8f97)":f.active?"":f.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:f.disabled?"not-allowed":"pointer",pointerEvents:f.disbled?"none":"all",...n?{}:{width:"100%"}},children:f.year},y))})},Q=({...r})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,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"})}),X=({...r})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...r,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"})}),oe=({setViews:r,views:a,filter:t,date:s,setDate:l})=>{const p=()=>{t||r(n=>n==="days"?"months":n==="months"?"years":"days")},i=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()+10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()+1,n.getMonth()));return}l(n=>new Date(n.getFullYear(),n.getMonth()+1))},u=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()-10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()-1,n.getMonth()));return}l(n=>new Date(n.getMonth()===0?n.getFullYear()-1:n.getFullYear(),n.getMonth()===0?11:n.getMonth()-1))},d=()=>{if(a==="days")return`${V[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${P(s.getFullYear()).start} ~ ${P(s.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx(Q,{onClick:()=>u()}),e.jsx("div",{style:{cursor:"pointer"},onClick:p,children:d()}),e.jsx(X,{onClick:()=>i()})]})};function W(r){const a=new Date(r),t=a.getFullYear(),s=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${ne[s]} ${t}`}const Z=({label:r,labelPosition:a="outside-top",required:t,optional:s,description:l,helperText:p,errorText:i,fullWidth:u,children:d})=>{const n=["sa-date-field",u?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),x=r?e.jsxs("div",{className:"sa-date-field-label-row",children:[e.jsx("span",{className:"sa-date-field-label-text",children:r}),s&&e.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),t&&e.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,v=e.jsxs(e.Fragment,{children:[p&&!i&&e.jsx("p",{className:"sa-date-field-helper",children:p}),i&&e.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return r?a==="outside-left"?e.jsxs("div",{className:`${n} sa-date-field-left`,children:[e.jsxs("div",{className:"sa-date-field-left-label",children:[x,l&&e.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),e.jsxs("div",{className:"sa-date-field-input-wrap",children:[d,v]})]}):e.jsxs("div",{className:n,children:[x,l&&e.jsx("p",{className:"sa-date-field-helper-top",children:l}),d,v]}):e.jsxs("div",{className:n,children:[l&&e.jsx("p",{className:"sa-date-field-helper-top",children:l}),d,v]})},_="sa-calendar-styles";(r=>{if(!document.getElementById(_)){const a=document.createElement("style");a.id=_,a.textContent=r,document.head.appendChild(a)}})(H);const le=m.forwardRef(({value:r,onChange:a,filter:t,input:s=!0,disabled:l,minDate:p,maxDate:i,placeholder:u,size:d,status:n,clearable:x,fullWidth:v=!0,label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w},f)=>{const y=w?"error":n,{ref:k,isComponentVisible:Y,setIsComponentVisible:F}=G(!1),D=m.useRef(null),[j,T]=m.useState("days"),[N,E]=m.useState(new Date),[$,L]=m.useState({from:(r==null?void 0:r.from)||new Date,to:(r==null?void 0:r.to)||new Date});m.useEffect(()=>{r?(E(r.from),L(r)):(E(new Date),L({from:new Date,to:new Date}))},[r]),m.useEffect(()=>{t&&T(t)},[t]),m.useEffect(()=>{t||T("days")},[Y]),m.useEffect(()=>{s||F(!0)},[s]);const J=()=>{var b,S;if(!r)return"";if(t){if(j==="days")return`${W($.from)} ~ ${W($.to||$.from)||"-"}`;if(j==="months")return`${V[$.from.getMonth()]} ~ ${$.to?V[$.to.getMonth()]:"-"}`;if(j==="years")return`${(b=$.from)==null?void 0:b.getFullYear()} ~ ${((S=$.to)==null?void 0:S.getFullYear())||"-"}`}else return`${W($.from)} ~ ${W($.to||$.from)||"-"}`},I=()=>{if(D.current&&k.current&&s){const b=k.current.getBoundingClientRect(),S=D.current.getBoundingClientRect();window.innerWidth<b.left+S.width?D.current.style.left=`${b.left-S.width+b.width}px`:D.current.style.left=`${b.left}px`,b.top+S.height>window.innerHeight?D.current.style.top=`${b.y-(b.height+S.height-28)}px`:D.current.style.top=`${b.y+b.height}px`}};m.useEffect(()=>{D.current&&k.current&&s&&I()},[D,k,Y]),m.useEffect(()=>{const b=f==null?void 0:f.current;return b&&b.addEventListener("scroll",I),window.addEventListener("scroll",I),()=>{b&&b.removeEventListener("scroll",I),window.removeEventListener("scroll",I)}},[]);const q=e.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?k:null,children:[s?e.jsx(ae,{value:J(),inputMode:"none",onClick:()=>{F(!0)},onChange:()=>{},disabled:l,placeholder:u,size:d,status:y,clearable:x,onClear:()=>a(void 0)}):null,Y?e.jsxs("div",{className:`sa-calendar ${s?"":"sa-calendar-no-input"}`,ref:D,children:[e.jsx(oe,{setViews:T,views:j,filter:t,date:N,setDate:E}),e.jsx("div",{className:"sa-calendar-body",children:j==="days"?e.jsx(re,{date:N,setDate:E,setIsComponentVisible:F,dateRange:$,setDateRange:L,input:s,onChange:a,minDate:p,maxDate:i}):j==="months"?e.jsx(te,{date:N,setDate:E,filter:t,setViews:T,dateRange:$,setDateRange:L,setIsComponentVisible:F,input:s,onChange:a,minDate:p,maxDate:i}):e.jsx(se,{date:N,setDate:E,filter:t,setViews:T,dateRange:$,setDateRange:L,setIsComponentVisible:F,input:s,onChange:a,minDate:p,maxDate:i})})]}):null]});return e.jsx(Z,{label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w,fullWidth:v,children:q})}),R="sa-calendar-input-styles";(r=>{if(!document.getElementById(R)){const a=document.createElement("style");a.id=R,a.textContent=r,document.head.appendChild(a)}})(H);const O=r=>{if(r==="sm")return 16;if(r==="md")return 16;if(r==="lg")return 20},de=r=>{const{size:a="md",status:t="default",variant:s="outline",clearable:l,onClear:p,...i}=r,u=m.useRef(null),d=()=>{u.current&&i.onClick&&(u.current.focus(),i.onClick(""))},n=t==="disable"||i.disabled,x=!!i.value,v=l&&x&&!n,M=C=>{C.stopPropagation(),p==null||p()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${a} `,onClick:d,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(a),height:O(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:n,value:i.value,ref:u})}),v?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:M,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(a),height:O(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:O(a),height:O(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"})})})]})},ie=({date:r,setDate:a,previewDate:t,setPreviewDate:s,setIsComponentVisible:l,minDate:p,maxDate:i,input:u,onChange:d})=>{let n=new Date(t.getFullYear(),t.getMonth(),1),x=n.getDay(),v=[];const M=r.toDateString(),C=t.getMonth();for(let o=0;o<42;o++){o===0&&x===0?n.setDate(n.getDate()-7):o===0?n.setDate(n.getDate()+(o-x)):n.setDate(n.getDate()+1);let c={currentMonth:n.getMonth()===C,date:new Date(n),month:n.getMonth(),number:n.getDate(),selected:n.toDateString()===M,year:n.getFullYear(),isDisabled:p&&n<p||i&&n>i};v.push(c)}const g=o=>{(!p||o>=p)&&(!i||o<=i)&&(a(o),d(o),s(o),u&&l(!1))};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:U.map((o,c)=>e.jsx("p",{children:o},c))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:v.map((o,c)=>{const h=o.isDisabled;return e.jsx("p",{className:`${o.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${o.selected?"sa-calendar-days-active":""}`,style:{color:h?"#ccc":void 0,pointerEvents:h?"none":void 0,cursor:h?"not-allowed":"pointer",...u?{}:{width:"100%"}},onClick:()=>{h||g(o.date)},children:o.number},c)})})]})},ce=({date:r,setDate:a,filter:t,setViews:s,onChange:l,previewDate:p,setPreviewDate:i,minDate:u,maxDate:d,input:n})=>{const x=r.getMonth(),v=r.getFullYear(),M=p.getFullYear(),C=g=>{(!u||g>=u)&&(!d||g<=d)&&(t?(l(g),a(g),i(g)):(s("days"),i(g)))};return e.jsx("div",{className:"sa-calendar-months-preview",children:V.map((g,o)=>{const c=u&&new Date(M,o,1)<u||d&&new Date(M,o+1,0)>d;return e.jsx("p",{className:o===x&&M===v?"sa-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...n?{}:{width:"100%"}},onClick:()=>{c||C(new Date(M,o))},children:g.slice(0,3)},o)})})},A=r=>{const a=Math.floor(r/10)*10,t=a+10;return{start:a,end:t}},he=({date:r,filter:a,setViews:t,setDate:s,onChange:l,previewDate:p,setPreviewDate:i,minDate:u,maxDate:d,input:n})=>{let x=[];const v=p.getFullYear(),{start:M,end:C}=A(v),g=r.getFullYear();for(let c=M;c<C;c++){let h=u&&new Date(c,0,1)<u||d&&new Date(c,11,31)>d;x.push({year:c,active:c===g,isDisabled:h})}const o=c=>{(!u||c>=u)&&(!d||c<=d)&&(a?(l(c),s(c),i(c)):(t("months"),i(c)))};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((c,h)=>e.jsx("p",{className:c.active?"sa-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...n?{}:{width:"100%"}},onClick:()=>{c.isDisabled||o(new Date(c.year,0))},children:c.year},h))})},fe=({setViews:r,views:a,filter:t,previewDate:s,setPreviewDate:l})=>{const p=()=>{t||r(n=>n==="days"?"months":n==="months"?"years":"days")},i=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()+10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()+1,n.getMonth()));return}l(n=>new Date(n.getFullYear(),n.getMonth()+1))},u=()=>{if(a==="years"){l(n=>new Date(n.getFullYear()-10,0));return}if(a==="months"){l(n=>new Date(n.getFullYear()-1,n.getMonth()));return}l(n=>new Date(n.getMonth()===0?n.getFullYear()-1:n.getFullYear(),n.getMonth()===0?11:n.getMonth()-1))},d=()=>{if(a==="days")return`${V[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${A(s.getFullYear()).start} ~ ${A(s.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx(Q,{onClick:()=>u()}),e.jsx("div",{style:{cursor:"pointer"},onClick:p,children:d()}),e.jsx(X,{onClick:()=>i()})]})},ee="sa-calendar-styles";(r=>{if(!document.getElementById(ee)){const a=document.createElement("style");a.id=ee,a.textContent=r,document.head.appendChild(a)}})(H);const pe=m.forwardRef(({value:r,onChange:a,filter:t,input:s=!0,disabled:l,minDate:p,maxDate:i,placeholder:u,size:d,status:n,clearable:x,fullWidth:v=!0,label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w},f)=>{const y=w?"error":n,{ref:k,isComponentVisible:Y,setIsComponentVisible:F}=G(!1),D=m.useRef(null),[j,T]=m.useState("days"),[N,E]=m.useState(new Date),[$,L]=m.useState(new Date);m.useEffect(()=>{r?(E(r),L(r)):(E(new Date),L(new Date))},[r]),m.useEffect(()=>{t&&T(t)},[t]),m.useEffect(()=>{t||T("days")},[Y]),m.useEffect(()=>{s||F(!0)},[s]);const J=()=>r?t==="days"?W(N):t==="months"?`${V[N.getMonth()]} ${N.getFullYear()}`:t==="years"?N.getFullYear():W(N):"",I=()=>{if(D.current&&k.current&&s){const b=k.current.getBoundingClientRect(),S=D.current.getBoundingClientRect();window.innerWidth<b.left+S.width?D.current.style.left=`${b.left-S.width+b.width}px`:D.current.style.left=`${b.left}px`,b.top+S.height>window.innerHeight?D.current.style.top=`${b.y-(b.height+S.height-28)}px`:D.current.style.top=`${b.y+b.height}px`}};m.useEffect(()=>{D.current&&k.current&&s&&I()},[D,k,Y]),m.useEffect(()=>{const b=f==null?void 0:f.current;return b&&b.addEventListener("scroll",I),window.addEventListener("scroll",I),()=>{b&&b.removeEventListener("scroll",I),window.removeEventListener("scroll",I)}},[]);const q=e.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?k:null,children:[s?e.jsx(de,{value:J(),onClick:()=>F(!0),onChange:()=>{},placeholder:u,disabled:l,size:d,status:y,inputMode:"none",clearable:x,onClear:()=>a(void 0)}):null,Y?e.jsxs("div",{className:`sa-calendar ${s?"":"sa-calendar-no-input"}`,ref:D,children:[e.jsx(fe,{setViews:T,views:j,filter:t,previewDate:$,setPreviewDate:L,isComponentVisible:Y}),e.jsx("div",{className:"sa-calendar-body",children:j==="days"?e.jsx(ie,{date:N,setDate:E,previewDate:$,setPreviewDate:L,setIsComponentVisible:F,input:s,minDate:p,maxDate:i,onChange:a}):j==="months"?e.jsx(ce,{date:N,setDate:E,previewDate:$,setPreviewDate:L,filter:t,setViews:T,onChange:a,minDate:p,maxDate:i,input:s}):e.jsx(he,{date:N,setDate:E,previewDate:$,setPreviewDate:L,filter:t,setViews:T,onChange:a,minDate:p,maxDate:i,input:s})})]}):null]});return e.jsx(Z,{label:M,labelPosition:C,required:g,optional:o,description:c,helperText:h,errorText:w,fullWidth:v,children:q})}),ue=m.forwardRef(({value:r,onChange:a,filter:t,input:s=!0,rangedDate:l,disabled:p,minDate:i,maxDate:u,placeholder:d,size:n,status:x,clearable:v,fullWidth:M,label:C,labelPosition:g,required:o,optional:c,description:h,helperText:w,errorText:f},y)=>{const k={onChange:a,value:r,input:s,filter:t,disabled:p,minDate:i,maxDate:u,placeholder:d,size:n,status:x,clearable:v,fullWidth:M,label:C,labelPosition:g,required:o,optional:c,description:h,helperText:w,errorText:f};return e.jsx(e.Fragment,{children:l?e.jsx(le,{...k,ref:y}):e.jsx(pe,{...k,ref:y})})});B.StarasiaDate=ue,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",