@starasia/date 5.2.4 → 5.2.5
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 +309 -306
- package/dist/date.umd.js +1 -1
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -572,8 +572,8 @@ const R = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
572
572
|
"Dec"
|
|
573
573
|
];
|
|
574
574
|
function rn(a) {
|
|
575
|
-
const [n, t] = A(a), o = J(null), l = (
|
|
576
|
-
o.current && !o.current.contains(
|
|
575
|
+
const [n, t] = A(a), o = J(null), l = (p) => {
|
|
576
|
+
o.current && !o.current.contains(p.target) && t(!1);
|
|
577
577
|
};
|
|
578
578
|
return B(() => (document.addEventListener("click", l, !0), () => {
|
|
579
579
|
document.removeEventListener("click", l, !0);
|
|
@@ -599,18 +599,18 @@ const O = (a) => {
|
|
|
599
599
|
status: t = "default",
|
|
600
600
|
variant: o = "outline",
|
|
601
601
|
clearable: l,
|
|
602
|
-
onClear:
|
|
602
|
+
onClear: p,
|
|
603
603
|
...i
|
|
604
|
-
} = a,
|
|
605
|
-
|
|
606
|
-
}, r = t === "disable" || i.disabled, d = !!i.value,
|
|
607
|
-
k.stopPropagation(),
|
|
604
|
+
} = a, g = J(null), f = () => {
|
|
605
|
+
g.current && i.onClick && (g.current.focus(), i.onClick(""));
|
|
606
|
+
}, r = t === "disable" || i.disabled, d = !!i.value, w = l && d && !r, M = (k) => {
|
|
607
|
+
k.stopPropagation(), p == null || p();
|
|
608
608
|
};
|
|
609
609
|
return /* @__PURE__ */ Y(
|
|
610
610
|
"div",
|
|
611
611
|
{
|
|
612
612
|
className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${n} `,
|
|
613
|
-
onClick:
|
|
613
|
+
onClick: f,
|
|
614
614
|
children: [
|
|
615
615
|
/* @__PURE__ */ e("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ e(
|
|
616
616
|
"svg",
|
|
@@ -639,10 +639,10 @@ const O = (a) => {
|
|
|
639
639
|
...i,
|
|
640
640
|
disabled: r,
|
|
641
641
|
value: i.value,
|
|
642
|
-
ref:
|
|
642
|
+
ref: g
|
|
643
643
|
}
|
|
644
644
|
) }),
|
|
645
|
-
|
|
645
|
+
w ? /* @__PURE__ */ e(
|
|
646
646
|
"button",
|
|
647
647
|
{
|
|
648
648
|
type: "button",
|
|
@@ -699,42 +699,43 @@ const O = (a) => {
|
|
|
699
699
|
dateRange: t,
|
|
700
700
|
setDateRange: o,
|
|
701
701
|
onChange: l,
|
|
702
|
-
minDate:
|
|
702
|
+
minDate: p,
|
|
703
703
|
maxDate: i,
|
|
704
|
-
input:
|
|
704
|
+
input: g
|
|
705
705
|
}) => {
|
|
706
|
-
var
|
|
707
|
-
const [
|
|
708
|
-
let d = new Date(a.getFullYear(), a.getMonth(), 1),
|
|
709
|
-
const k = a.getMonth(),
|
|
710
|
-
for (let
|
|
711
|
-
|
|
712
|
-
d.getDate() + (
|
|
706
|
+
var $, c, y;
|
|
707
|
+
const [f, r] = A(null);
|
|
708
|
+
let d = new Date(a.getFullYear(), a.getMonth(), 1), w = d.getDay(), M = [];
|
|
709
|
+
const k = a.getMonth(), N = (/* @__PURE__ */ new Date()).toDateString(), b = !!(t.from && !t.to), h = b && f ? f : null;
|
|
710
|
+
for (let u = 0; u < 42; u++) {
|
|
711
|
+
u === 0 && w === 0 ? d.setDate(d.getDate() - 7) : u === 0 ? d.setDate(
|
|
712
|
+
d.getDate() + (u - w)
|
|
713
713
|
) : d.setDate(d.getDate() + 1);
|
|
714
|
-
let
|
|
714
|
+
let m = {
|
|
715
715
|
currentMonth: d.getMonth() === k,
|
|
716
716
|
date: new Date(d),
|
|
717
717
|
month: d.getMonth(),
|
|
718
718
|
number: d.getDate(),
|
|
719
|
-
selected: d.toDateString() === ((
|
|
720
|
-
isToday: d.toDateString() ===
|
|
719
|
+
selected: d.toDateString() === (($ = t.from) == null ? void 0 : $.toDateString()) || d.toDateString() === (((c = t.to) == null ? void 0 : c.toDateString()) || ((y = t.from) == null ? void 0 : y.toDateString())),
|
|
720
|
+
isToday: d.toDateString() === N,
|
|
721
721
|
year: d.getFullYear(),
|
|
722
|
-
isDisabled:
|
|
722
|
+
isDisabled: p && d < p || i && d > i
|
|
723
723
|
};
|
|
724
|
-
M.push(
|
|
724
|
+
M.push(m);
|
|
725
725
|
}
|
|
726
|
-
const s = (
|
|
727
|
-
n(
|
|
728
|
-
}, x = (
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
726
|
+
const s = (u) => {
|
|
727
|
+
n(u);
|
|
728
|
+
}, x = (u) => {
|
|
729
|
+
let m = { ...t };
|
|
730
|
+
if (m.from && m.to)
|
|
731
|
+
m = { from: u, to: null };
|
|
732
|
+
else if (!m.from)
|
|
733
|
+
m = { from: u, to: null };
|
|
733
734
|
else {
|
|
734
|
-
const
|
|
735
|
-
|
|
735
|
+
const E = m.from.getTime();
|
|
736
|
+
u.getTime() > E ? m = { from: m.from, to: u } : m = { from: u, to: m.from };
|
|
736
737
|
}
|
|
737
|
-
o(
|
|
738
|
+
o(m), l(m);
|
|
738
739
|
};
|
|
739
740
|
return /* @__PURE__ */ Y(
|
|
740
741
|
"div",
|
|
@@ -742,35 +743,35 @@ const O = (a) => {
|
|
|
742
743
|
className: "sa-calendar-days-preivew",
|
|
743
744
|
onMouseLeave: () => r(null),
|
|
744
745
|
children: [
|
|
745
|
-
/* @__PURE__ */ e("div", { className: "sa-calendar-days-name-preivew", children: an.map((
|
|
746
|
-
/* @__PURE__ */ e("div", { className: "sa-calendar-days-number-preivew", children: M.map((
|
|
747
|
-
const
|
|
748
|
-
if (!
|
|
746
|
+
/* @__PURE__ */ e("div", { className: "sa-calendar-days-name-preivew", children: an.map((u, m) => /* @__PURE__ */ e("p", { children: u }, m)) }),
|
|
747
|
+
/* @__PURE__ */ e("div", { className: "sa-calendar-days-number-preivew", children: M.map((u, m) => {
|
|
748
|
+
const E = t.from && t.to && u.date.getTime() > t.from.getTime() && u.date.getTime() < t.to.getTime(), S = (() => {
|
|
749
|
+
if (!h || !t.from)
|
|
749
750
|
return !1;
|
|
750
|
-
const
|
|
751
|
-
return
|
|
752
|
-
})(),
|
|
751
|
+
const z = u.date.getTime(), C = t.from.getTime(), L = h.getTime();
|
|
752
|
+
return L > C ? z > C && z < L : z < C && z > L;
|
|
753
|
+
})(), D = b && f && u.date.toDateString() === f.toDateString(), F = u.isDisabled, I = () => E || S ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", T = () => F ? "var(--sa-color-gray-400, #b7b9be)" : E || S ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
753
754
|
return /* @__PURE__ */ e(
|
|
754
755
|
"p",
|
|
755
756
|
{
|
|
756
|
-
className: `${
|
|
757
|
+
className: `${u.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${u.selected || D ? "sa-calendar-days-active" : ""} ${u.isToday && !u.selected ? "sa-calendar-days-today" : ""}`,
|
|
757
758
|
style: {
|
|
758
759
|
backgroundColor: I(),
|
|
759
|
-
pointerEvents:
|
|
760
|
-
cursor:
|
|
760
|
+
pointerEvents: F ? "none" : void 0,
|
|
761
|
+
cursor: F ? "not-allowed" : "pointer",
|
|
761
762
|
color: T(),
|
|
762
|
-
opacity:
|
|
763
|
-
...
|
|
763
|
+
opacity: D && !u.selected ? 0.75 : 1,
|
|
764
|
+
...g ? {} : { width: "100%" }
|
|
764
765
|
},
|
|
765
766
|
onClick: () => {
|
|
766
|
-
|
|
767
|
+
F || (s(u.date), x(u.date));
|
|
767
768
|
},
|
|
768
769
|
onMouseEnter: () => {
|
|
769
|
-
|
|
770
|
+
F || r(u.date);
|
|
770
771
|
},
|
|
771
|
-
children:
|
|
772
|
+
children: u.number
|
|
772
773
|
},
|
|
773
|
-
|
|
774
|
+
m
|
|
774
775
|
);
|
|
775
776
|
}) })
|
|
776
777
|
]
|
|
@@ -782,33 +783,34 @@ const O = (a) => {
|
|
|
782
783
|
filter: t,
|
|
783
784
|
setViews: o,
|
|
784
785
|
dateRange: l,
|
|
785
|
-
setDateRange:
|
|
786
|
+
setDateRange: p,
|
|
786
787
|
onChange: i,
|
|
787
|
-
minDate:
|
|
788
|
-
maxDate:
|
|
788
|
+
minDate: g,
|
|
789
|
+
maxDate: f,
|
|
789
790
|
input: r
|
|
790
791
|
}) => {
|
|
791
|
-
var
|
|
792
|
-
const d = (
|
|
793
|
-
t ? (k(
|
|
794
|
-
}, k = (
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
792
|
+
var N;
|
|
793
|
+
const d = (N = l.from) == null ? void 0 : N.getFullYear(), w = a.getFullYear(), M = (b) => {
|
|
794
|
+
t ? (k(b), n(b)) : (o("days"), n(b));
|
|
795
|
+
}, k = (b) => {
|
|
796
|
+
let h = { ...l };
|
|
797
|
+
if (h.from && h.to)
|
|
798
|
+
h = { from: b, to: null };
|
|
799
|
+
else if (!h.from)
|
|
800
|
+
h = { from: b, to: null };
|
|
799
801
|
else {
|
|
800
|
-
const
|
|
801
|
-
|
|
802
|
+
const s = h.from.getTime();
|
|
803
|
+
b.getTime() > s ? h = { from: h.from, to: b } : h = { from: b, to: h.from };
|
|
802
804
|
}
|
|
803
|
-
|
|
805
|
+
p(h), i(h);
|
|
804
806
|
};
|
|
805
|
-
return /* @__PURE__ */ e("div", { className: "sa-calendar-months-preview", children: W.map((
|
|
806
|
-
var
|
|
807
|
-
const s = l.from != null && new Date(
|
|
807
|
+
return /* @__PURE__ */ e("div", { className: "sa-calendar-months-preview", children: W.map((b, h) => {
|
|
808
|
+
var $, c, y;
|
|
809
|
+
const s = l.from != null && new Date(w, h).getTime() > l.from.getTime() && new Date(w, h).getTime() < ((($ = l.to) == null ? void 0 : $.getTime()) || l.from.getTime()), x = g && new Date(w, h) < g || f && new Date(w, h) > f;
|
|
808
810
|
return /* @__PURE__ */ e(
|
|
809
811
|
"p",
|
|
810
812
|
{
|
|
811
|
-
className: d ===
|
|
813
|
+
className: d === w && (h === ((c = l.from) == null ? void 0 : c.getMonth()) || h === ((y = l.to) == null ? void 0 : y.getMonth())) ? "sa-calendar-months-active" : "",
|
|
812
814
|
style: {
|
|
813
815
|
backgroundColor: s ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
814
816
|
pointerEvents: x ? "none" : void 0,
|
|
@@ -817,11 +819,11 @@ const O = (a) => {
|
|
|
817
819
|
...r ? {} : { width: "100%" }
|
|
818
820
|
},
|
|
819
821
|
onClick: () => {
|
|
820
|
-
x || M(new Date(
|
|
822
|
+
x || M(new Date(w, h));
|
|
821
823
|
},
|
|
822
|
-
children:
|
|
824
|
+
children: b.slice(0, 3)
|
|
823
825
|
},
|
|
824
|
-
|
|
826
|
+
h
|
|
825
827
|
);
|
|
826
828
|
}) });
|
|
827
829
|
}, q = (a) => {
|
|
@@ -833,54 +835,55 @@ const O = (a) => {
|
|
|
833
835
|
setViews: t,
|
|
834
836
|
setDate: o,
|
|
835
837
|
dateRange: l,
|
|
836
|
-
setDateRange:
|
|
838
|
+
setDateRange: p,
|
|
837
839
|
onChange: i,
|
|
838
|
-
minDate:
|
|
839
|
-
maxDate:
|
|
840
|
+
minDate: g,
|
|
841
|
+
maxDate: f,
|
|
840
842
|
input: r
|
|
841
843
|
}) => {
|
|
842
|
-
var x,
|
|
844
|
+
var x, $;
|
|
843
845
|
let d = [];
|
|
844
|
-
const
|
|
845
|
-
for (let
|
|
846
|
-
const
|
|
846
|
+
const w = a.getFullYear(), { start: M, end: k } = q(w), N = (x = l.from) == null ? void 0 : x.getFullYear(), b = ($ = l.to) == null ? void 0 : $.getFullYear();
|
|
847
|
+
for (let c = M; c < k; c++) {
|
|
848
|
+
const y = new Date(c, 0), u = (!g || y >= g) && (!f || y <= f), m = N != null && c === N || b != null && c === b, E = l.from != null && l.to != null && y > l.from && y < l.to;
|
|
847
849
|
d.push({
|
|
848
|
-
year:
|
|
849
|
-
active:
|
|
850
|
-
highlight:
|
|
851
|
-
disabled: !
|
|
850
|
+
year: c,
|
|
851
|
+
active: m && u,
|
|
852
|
+
highlight: E && u,
|
|
853
|
+
disabled: !u
|
|
852
854
|
});
|
|
853
855
|
}
|
|
854
|
-
const
|
|
855
|
-
n ? (s(
|
|
856
|
-
}, s = (
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
856
|
+
const h = (c) => {
|
|
857
|
+
n ? (s(c), o(c)) : (o(c), t("months"));
|
|
858
|
+
}, s = (c) => {
|
|
859
|
+
let y = { ...l };
|
|
860
|
+
if (y.from && y.to)
|
|
861
|
+
y = { from: c, to: null };
|
|
862
|
+
else if (!y.from)
|
|
863
|
+
y = { from: c, to: null };
|
|
861
864
|
else {
|
|
862
|
-
const
|
|
863
|
-
|
|
865
|
+
const u = y.from.getTime();
|
|
866
|
+
c.getTime() > u ? y = { from: y.from, to: c } : y = { from: c, to: y.from };
|
|
864
867
|
}
|
|
865
|
-
|
|
868
|
+
p(y), i(y);
|
|
866
869
|
};
|
|
867
|
-
return /* @__PURE__ */ e("div", { className: "sa-calendar-years-preview", children: d.map((
|
|
870
|
+
return /* @__PURE__ */ e("div", { className: "sa-calendar-years-preview", children: d.map((c, y) => /* @__PURE__ */ e(
|
|
868
871
|
"p",
|
|
869
872
|
{
|
|
870
|
-
className: `${
|
|
873
|
+
className: `${c.active ? "sa-calendar-months-active" : ""} ${c.highlight ? "sa-calendar-months-highlight" : ""} ${c.disabled ? "sa-calendar-disabled" : ""}`,
|
|
871
874
|
onClick: () => {
|
|
872
|
-
|
|
875
|
+
c.disabled || h(new Date(c.year, 0));
|
|
873
876
|
},
|
|
874
877
|
style: {
|
|
875
|
-
backgroundColor:
|
|
876
|
-
color:
|
|
877
|
-
cursor:
|
|
878
|
-
pointerEvents:
|
|
878
|
+
backgroundColor: c.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
879
|
+
color: c.highlight ? "var(--sa-color-gray-500, #8c8f97)" : c.active ? "" : c.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
|
|
880
|
+
cursor: c.disabled ? "not-allowed" : "pointer",
|
|
881
|
+
pointerEvents: c.disbled ? "none" : "all",
|
|
879
882
|
...r ? {} : { width: "100%" }
|
|
880
883
|
},
|
|
881
|
-
children:
|
|
884
|
+
children: c.year
|
|
882
885
|
},
|
|
883
|
-
|
|
886
|
+
y
|
|
884
887
|
)) });
|
|
885
888
|
}, tn = ({ ...a }) => /* @__PURE__ */ e(
|
|
886
889
|
"svg",
|
|
@@ -929,7 +932,7 @@ const O = (a) => {
|
|
|
929
932
|
date: o,
|
|
930
933
|
setDate: l
|
|
931
934
|
}) => {
|
|
932
|
-
const
|
|
935
|
+
const p = () => {
|
|
933
936
|
t || a((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
|
|
934
937
|
}, i = () => {
|
|
935
938
|
if (n === "years") {
|
|
@@ -941,7 +944,7 @@ const O = (a) => {
|
|
|
941
944
|
return;
|
|
942
945
|
}
|
|
943
946
|
l((r) => new Date(r.getFullYear(), r.getMonth() + 1));
|
|
944
|
-
},
|
|
947
|
+
}, g = () => {
|
|
945
948
|
if (n === "years") {
|
|
946
949
|
l((r) => new Date(r.getFullYear() - 10, 0));
|
|
947
950
|
return;
|
|
@@ -958,7 +961,7 @@ const O = (a) => {
|
|
|
958
961
|
);
|
|
959
962
|
};
|
|
960
963
|
return /* @__PURE__ */ Y("div", { className: "sa-calendar-header", children: [
|
|
961
|
-
/* @__PURE__ */ e("div", { className: "sa-calendar-header-title", onClick:
|
|
964
|
+
/* @__PURE__ */ e("div", { className: "sa-calendar-header-title", onClick: p, children: (() => {
|
|
962
965
|
if (n === "days")
|
|
963
966
|
return `${W[o.getMonth()]} ${o.getFullYear()}`;
|
|
964
967
|
if (n === "months")
|
|
@@ -967,7 +970,7 @@ const O = (a) => {
|
|
|
967
970
|
return `${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`;
|
|
968
971
|
})() }),
|
|
969
972
|
/* @__PURE__ */ Y("div", { className: "sa-calendar-header-nav", children: [
|
|
970
|
-
/* @__PURE__ */ e("button", { className: "sa-calendar-nav-btn", onClick:
|
|
973
|
+
/* @__PURE__ */ e("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ e(tn, {}) }),
|
|
971
974
|
/* @__PURE__ */ e("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ e(sn, {}) })
|
|
972
975
|
] })
|
|
973
976
|
] });
|
|
@@ -982,20 +985,20 @@ const on = ({
|
|
|
982
985
|
required: t,
|
|
983
986
|
optional: o,
|
|
984
987
|
description: l,
|
|
985
|
-
helperText:
|
|
988
|
+
helperText: p,
|
|
986
989
|
errorText: i,
|
|
987
|
-
fullWidth:
|
|
988
|
-
children:
|
|
990
|
+
fullWidth: g,
|
|
991
|
+
children: f
|
|
989
992
|
}) => {
|
|
990
993
|
const r = [
|
|
991
994
|
"sa-date-field",
|
|
992
|
-
|
|
995
|
+
g ? "sa-date-field-fullwidth" : ""
|
|
993
996
|
].filter(Boolean).join(" "), d = a ? /* @__PURE__ */ Y("div", { className: "sa-date-field-label-row", children: [
|
|
994
997
|
/* @__PURE__ */ e("span", { className: "sa-date-field-label-text", children: a }),
|
|
995
998
|
o && /* @__PURE__ */ e("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
|
|
996
999
|
t && /* @__PURE__ */ e("span", { className: "sa-date-field-required", children: "*" })
|
|
997
|
-
] }) : null,
|
|
998
|
-
|
|
1000
|
+
] }) : null, w = /* @__PURE__ */ Y(en, { children: [
|
|
1001
|
+
p && !i && /* @__PURE__ */ e("p", { className: "sa-date-field-helper", children: p }),
|
|
999
1002
|
i && /* @__PURE__ */ e("p", { className: "sa-date-field-error-msg", children: i })
|
|
1000
1003
|
] });
|
|
1001
1004
|
return a ? n === "outside-left" ? /* @__PURE__ */ Y("div", { className: `${r} sa-date-field-left`, children: [
|
|
@@ -1004,18 +1007,18 @@ const on = ({
|
|
|
1004
1007
|
l && /* @__PURE__ */ e("p", { className: "sa-date-field-helper-top", children: l })
|
|
1005
1008
|
] }),
|
|
1006
1009
|
/* @__PURE__ */ Y("div", { className: "sa-date-field-input-wrap", children: [
|
|
1007
|
-
|
|
1008
|
-
|
|
1010
|
+
f,
|
|
1011
|
+
w
|
|
1009
1012
|
] })
|
|
1010
1013
|
] }) : /* @__PURE__ */ Y("div", { className: r, children: [
|
|
1011
1014
|
d,
|
|
1012
1015
|
l && /* @__PURE__ */ e("p", { className: "sa-date-field-helper-top", children: l }),
|
|
1013
|
-
|
|
1014
|
-
|
|
1016
|
+
f,
|
|
1017
|
+
w
|
|
1015
1018
|
] }) : /* @__PURE__ */ Y("div", { className: r, children: [
|
|
1016
1019
|
l && /* @__PURE__ */ e("p", { className: "sa-date-field-helper-top", children: l }),
|
|
1017
|
-
|
|
1018
|
-
|
|
1020
|
+
f,
|
|
1021
|
+
w
|
|
1019
1022
|
] });
|
|
1020
1023
|
}, X = "sa-calendar-styles", fn = (a) => {
|
|
1021
1024
|
if (!document.getElementById(X)) {
|
|
@@ -1031,65 +1034,65 @@ const bn = K(
|
|
|
1031
1034
|
filter: t,
|
|
1032
1035
|
input: o = !0,
|
|
1033
1036
|
disabled: l,
|
|
1034
|
-
minDate:
|
|
1037
|
+
minDate: p,
|
|
1035
1038
|
maxDate: i,
|
|
1036
|
-
placeholder:
|
|
1037
|
-
size:
|
|
1039
|
+
placeholder: g,
|
|
1040
|
+
size: f,
|
|
1038
1041
|
variant: r,
|
|
1039
1042
|
status: d,
|
|
1040
|
-
clearable:
|
|
1043
|
+
clearable: w,
|
|
1041
1044
|
fullWidth: M = !0,
|
|
1042
1045
|
withPadding: k = !0,
|
|
1043
|
-
label:
|
|
1044
|
-
labelPosition:
|
|
1045
|
-
required:
|
|
1046
|
+
label: N,
|
|
1047
|
+
labelPosition: b,
|
|
1048
|
+
required: h,
|
|
1046
1049
|
optional: s,
|
|
1047
1050
|
description: x,
|
|
1048
|
-
helperText:
|
|
1049
|
-
errorText:
|
|
1050
|
-
},
|
|
1051
|
-
const
|
|
1051
|
+
helperText: $,
|
|
1052
|
+
errorText: c
|
|
1053
|
+
}, y) => {
|
|
1054
|
+
const u = c ? "error" : d, { ref: m, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), D = J(null), [F, I] = A("days"), [T, z] = A(/* @__PURE__ */ new Date()), [C, L] = A({
|
|
1052
1055
|
from: (a == null ? void 0 : a.from) ?? null,
|
|
1053
1056
|
to: (a == null ? void 0 : a.to) ?? null
|
|
1054
1057
|
});
|
|
1055
1058
|
B(() => {
|
|
1056
1059
|
if (a) {
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1060
|
+
const v = a;
|
|
1061
|
+
v.from && z(v.from), L(v);
|
|
1059
1062
|
} else
|
|
1060
|
-
|
|
1063
|
+
z(/* @__PURE__ */ new Date()), L({ from: null, to: null });
|
|
1061
1064
|
}, [a]), B(() => {
|
|
1062
1065
|
t && I(t);
|
|
1063
1066
|
}, [t]), B(() => {
|
|
1064
1067
|
t || I("days");
|
|
1065
|
-
}, [
|
|
1068
|
+
}, [E]), B(() => {
|
|
1066
1069
|
o || S(!0);
|
|
1067
1070
|
}, [o]);
|
|
1068
1071
|
const G = () => {
|
|
1069
|
-
var
|
|
1072
|
+
var v, V;
|
|
1070
1073
|
if (!a)
|
|
1071
1074
|
return "";
|
|
1072
1075
|
if (t) {
|
|
1073
|
-
if (
|
|
1074
|
-
return `${P(
|
|
1075
|
-
if (
|
|
1076
|
-
return `${W[
|
|
1077
|
-
if (
|
|
1078
|
-
return `${(
|
|
1076
|
+
if (F === "days")
|
|
1077
|
+
return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
|
|
1078
|
+
if (F === "months")
|
|
1079
|
+
return `${W[C.from.getMonth()]} ~ ${C.to ? W[C.to.getMonth()] : "-"}`;
|
|
1080
|
+
if (F === "years")
|
|
1081
|
+
return `${(v = C.from) == null ? void 0 : v.getFullYear()} ~ ${((V = C.to) == null ? void 0 : V.getFullYear()) || "-"}`;
|
|
1079
1082
|
} else
|
|
1080
|
-
return `${P(
|
|
1083
|
+
return `${P(C.from)} ~ ${P(C.to || C.from) || "-"}`;
|
|
1081
1084
|
}, j = () => {
|
|
1082
|
-
if (
|
|
1083
|
-
const
|
|
1084
|
-
window.innerWidth <
|
|
1085
|
+
if (D.current && m.current && o) {
|
|
1086
|
+
const v = m.current.getBoundingClientRect(), V = D.current.getBoundingClientRect();
|
|
1087
|
+
window.innerWidth < v.left + V.width ? D.current.style.left = `${v.left - V.width + v.width}px` : D.current.style.left = `${v.left}px`, v.top + V.height > window.innerHeight ? D.current.style.top = `${v.y - (v.height + V.height - 28)}px` : D.current.style.top = `${v.y + v.height}px`;
|
|
1085
1088
|
}
|
|
1086
1089
|
};
|
|
1087
1090
|
B(() => {
|
|
1088
|
-
|
|
1089
|
-
}, [
|
|
1090
|
-
const
|
|
1091
|
-
return
|
|
1092
|
-
|
|
1091
|
+
D.current && m.current && o && j();
|
|
1092
|
+
}, [D, m, E]), B(() => {
|
|
1093
|
+
const v = y == null ? void 0 : y.current;
|
|
1094
|
+
return v && v.addEventListener("scroll", j), window.addEventListener("scroll", j), () => {
|
|
1095
|
+
v && v.removeEventListener("scroll", j), window.removeEventListener("scroll", j);
|
|
1093
1096
|
};
|
|
1094
1097
|
}, []);
|
|
1095
1098
|
const U = /* @__PURE__ */ Y(
|
|
@@ -1097,7 +1100,7 @@ const bn = K(
|
|
|
1097
1100
|
{
|
|
1098
1101
|
className: "sa-calendar-wrapper",
|
|
1099
1102
|
style: { height: o ? "auto" : "100%" },
|
|
1100
|
-
ref: o ?
|
|
1103
|
+
ref: o ? m : null,
|
|
1101
1104
|
children: [
|
|
1102
1105
|
o ? /* @__PURE__ */ e(
|
|
1103
1106
|
cn,
|
|
@@ -1110,72 +1113,72 @@ const bn = K(
|
|
|
1110
1113
|
onChange: () => {
|
|
1111
1114
|
},
|
|
1112
1115
|
disabled: l,
|
|
1113
|
-
placeholder:
|
|
1114
|
-
size:
|
|
1116
|
+
placeholder: g,
|
|
1117
|
+
size: f,
|
|
1115
1118
|
variant: r,
|
|
1116
|
-
status:
|
|
1117
|
-
clearable:
|
|
1119
|
+
status: u,
|
|
1120
|
+
clearable: w,
|
|
1118
1121
|
onClear: () => n(void 0)
|
|
1119
1122
|
}
|
|
1120
1123
|
) : null,
|
|
1121
|
-
|
|
1124
|
+
E ? /* @__PURE__ */ Y(
|
|
1122
1125
|
"div",
|
|
1123
1126
|
{
|
|
1124
|
-
className: `sa-calendar sa-calendar-size-${
|
|
1127
|
+
className: `sa-calendar sa-calendar-size-${f || "md"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
|
|
1125
1128
|
style: l ? { pointerEvents: "none" } : void 0,
|
|
1126
|
-
ref:
|
|
1129
|
+
ref: D,
|
|
1127
1130
|
children: [
|
|
1128
1131
|
/* @__PURE__ */ e(
|
|
1129
1132
|
gn,
|
|
1130
1133
|
{
|
|
1131
1134
|
setViews: I,
|
|
1132
|
-
views:
|
|
1135
|
+
views: F,
|
|
1133
1136
|
filter: t,
|
|
1134
1137
|
date: T,
|
|
1135
|
-
setDate:
|
|
1138
|
+
setDate: z
|
|
1136
1139
|
}
|
|
1137
1140
|
),
|
|
1138
|
-
/* @__PURE__ */ e("div", { className: "sa-calendar-body", children:
|
|
1141
|
+
/* @__PURE__ */ e("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ e(
|
|
1139
1142
|
un,
|
|
1140
1143
|
{
|
|
1141
1144
|
date: T,
|
|
1142
|
-
setDate:
|
|
1145
|
+
setDate: z,
|
|
1143
1146
|
setIsComponentVisible: S,
|
|
1144
|
-
dateRange:
|
|
1145
|
-
setDateRange:
|
|
1147
|
+
dateRange: C,
|
|
1148
|
+
setDateRange: L,
|
|
1146
1149
|
input: o,
|
|
1147
1150
|
onChange: n,
|
|
1148
|
-
minDate:
|
|
1151
|
+
minDate: p,
|
|
1149
1152
|
maxDate: i
|
|
1150
1153
|
}
|
|
1151
|
-
) :
|
|
1154
|
+
) : F === "months" ? /* @__PURE__ */ e(
|
|
1152
1155
|
pn,
|
|
1153
1156
|
{
|
|
1154
1157
|
date: T,
|
|
1155
|
-
setDate:
|
|
1158
|
+
setDate: z,
|
|
1156
1159
|
filter: t,
|
|
1157
1160
|
setViews: I,
|
|
1158
|
-
dateRange:
|
|
1159
|
-
setDateRange:
|
|
1161
|
+
dateRange: C,
|
|
1162
|
+
setDateRange: L,
|
|
1160
1163
|
setIsComponentVisible: S,
|
|
1161
1164
|
input: o,
|
|
1162
1165
|
onChange: n,
|
|
1163
|
-
minDate:
|
|
1166
|
+
minDate: p,
|
|
1164
1167
|
maxDate: i
|
|
1165
1168
|
}
|
|
1166
1169
|
) : /* @__PURE__ */ e(
|
|
1167
1170
|
hn,
|
|
1168
1171
|
{
|
|
1169
1172
|
date: T,
|
|
1170
|
-
setDate:
|
|
1173
|
+
setDate: z,
|
|
1171
1174
|
filter: t,
|
|
1172
1175
|
setViews: I,
|
|
1173
|
-
dateRange:
|
|
1174
|
-
setDateRange:
|
|
1176
|
+
dateRange: C,
|
|
1177
|
+
setDateRange: L,
|
|
1175
1178
|
setIsComponentVisible: S,
|
|
1176
1179
|
input: o,
|
|
1177
1180
|
onChange: n,
|
|
1178
|
-
minDate:
|
|
1181
|
+
minDate: p,
|
|
1179
1182
|
maxDate: i
|
|
1180
1183
|
}
|
|
1181
1184
|
) })
|
|
@@ -1188,13 +1191,13 @@ const bn = K(
|
|
|
1188
1191
|
return /* @__PURE__ */ e(
|
|
1189
1192
|
on,
|
|
1190
1193
|
{
|
|
1191
|
-
label:
|
|
1192
|
-
labelPosition:
|
|
1193
|
-
required:
|
|
1194
|
+
label: N,
|
|
1195
|
+
labelPosition: b,
|
|
1196
|
+
required: h,
|
|
1194
1197
|
optional: s,
|
|
1195
1198
|
description: x,
|
|
1196
|
-
helperText:
|
|
1197
|
-
errorText:
|
|
1199
|
+
helperText: $,
|
|
1200
|
+
errorText: c,
|
|
1198
1201
|
fullWidth: M,
|
|
1199
1202
|
children: U
|
|
1200
1203
|
}
|
|
@@ -1220,18 +1223,18 @@ const H = (a) => {
|
|
|
1220
1223
|
status: t = "default",
|
|
1221
1224
|
variant: o = "outline",
|
|
1222
1225
|
clearable: l,
|
|
1223
|
-
onClear:
|
|
1226
|
+
onClear: p,
|
|
1224
1227
|
...i
|
|
1225
|
-
} = a,
|
|
1226
|
-
|
|
1227
|
-
}, r = t === "disable" || i.disabled, d = !!i.value,
|
|
1228
|
-
k.stopPropagation(),
|
|
1228
|
+
} = a, g = J(null), f = () => {
|
|
1229
|
+
g.current && i.onClick && (g.current.focus(), i.onClick(""));
|
|
1230
|
+
}, r = t === "disable" || i.disabled, d = !!i.value, w = l && d && !r, M = (k) => {
|
|
1231
|
+
k.stopPropagation(), p == null || p();
|
|
1229
1232
|
};
|
|
1230
1233
|
return /* @__PURE__ */ Y(
|
|
1231
1234
|
"div",
|
|
1232
1235
|
{
|
|
1233
1236
|
className: `sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${n} `,
|
|
1234
|
-
onClick:
|
|
1237
|
+
onClick: f,
|
|
1235
1238
|
children: [
|
|
1236
1239
|
/* @__PURE__ */ e("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ e(
|
|
1237
1240
|
"svg",
|
|
@@ -1260,10 +1263,10 @@ const H = (a) => {
|
|
|
1260
1263
|
...i,
|
|
1261
1264
|
disabled: r,
|
|
1262
1265
|
value: i.value,
|
|
1263
|
-
ref:
|
|
1266
|
+
ref: g
|
|
1264
1267
|
}
|
|
1265
1268
|
) }),
|
|
1266
|
-
|
|
1269
|
+
w ? /* @__PURE__ */ e(
|
|
1267
1270
|
"button",
|
|
1268
1271
|
{
|
|
1269
1272
|
type: "button",
|
|
@@ -1320,53 +1323,53 @@ const H = (a) => {
|
|
|
1320
1323
|
previewDate: t,
|
|
1321
1324
|
setPreviewDate: o,
|
|
1322
1325
|
setIsComponentVisible: l,
|
|
1323
|
-
minDate:
|
|
1326
|
+
minDate: p,
|
|
1324
1327
|
maxDate: i,
|
|
1325
|
-
input:
|
|
1326
|
-
onChange:
|
|
1328
|
+
input: g,
|
|
1329
|
+
onChange: f,
|
|
1327
1330
|
hasValue: r
|
|
1328
1331
|
}) => {
|
|
1329
1332
|
let d = new Date(
|
|
1330
1333
|
t.getFullYear(),
|
|
1331
1334
|
t.getMonth(),
|
|
1332
1335
|
1
|
|
1333
|
-
),
|
|
1334
|
-
const k = a.toDateString(),
|
|
1336
|
+
), w = d.getDay(), M = [];
|
|
1337
|
+
const k = a.toDateString(), N = (/* @__PURE__ */ new Date()).toDateString(), b = t.getMonth();
|
|
1335
1338
|
for (let s = 0; s < 42; s++) {
|
|
1336
|
-
s === 0 &&
|
|
1337
|
-
d.getDate() + (s -
|
|
1339
|
+
s === 0 && w === 0 ? d.setDate(d.getDate() - 7) : s === 0 ? d.setDate(
|
|
1340
|
+
d.getDate() + (s - w)
|
|
1338
1341
|
) : d.setDate(d.getDate() + 1);
|
|
1339
1342
|
let x = {
|
|
1340
|
-
currentMonth: d.getMonth() ===
|
|
1343
|
+
currentMonth: d.getMonth() === b,
|
|
1341
1344
|
date: new Date(d),
|
|
1342
1345
|
month: d.getMonth(),
|
|
1343
1346
|
number: d.getDate(),
|
|
1344
1347
|
selected: r && d.toDateString() === k,
|
|
1345
|
-
isToday: d.toDateString() ===
|
|
1348
|
+
isToday: d.toDateString() === N,
|
|
1346
1349
|
year: d.getFullYear(),
|
|
1347
|
-
isDisabled:
|
|
1350
|
+
isDisabled: p && d < p || i && d > i
|
|
1348
1351
|
};
|
|
1349
1352
|
M.push(x);
|
|
1350
1353
|
}
|
|
1351
|
-
const
|
|
1352
|
-
(!
|
|
1354
|
+
const h = (s) => {
|
|
1355
|
+
(!p || s >= p) && (!i || s <= i) && (n(s), f(s), o(s), g && l(!1));
|
|
1353
1356
|
};
|
|
1354
1357
|
return /* @__PURE__ */ Y("div", { className: "sa-calendar-days-preivew", children: [
|
|
1355
1358
|
/* @__PURE__ */ e("div", { className: "sa-calendar-days-name-preivew", children: an.map((s, x) => /* @__PURE__ */ e("p", { children: s }, x)) }),
|
|
1356
1359
|
/* @__PURE__ */ e("div", { className: "sa-calendar-days-number-preivew", children: M.map((s, x) => {
|
|
1357
|
-
const
|
|
1360
|
+
const $ = s.isDisabled;
|
|
1358
1361
|
return /* @__PURE__ */ e(
|
|
1359
1362
|
"p",
|
|
1360
1363
|
{
|
|
1361
1364
|
className: `${s.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${s.selected ? "sa-calendar-days-active" : ""} ${s.isToday && !s.selected ? "sa-calendar-days-today" : ""}`,
|
|
1362
1365
|
style: {
|
|
1363
|
-
color:
|
|
1364
|
-
pointerEvents:
|
|
1365
|
-
cursor:
|
|
1366
|
-
...
|
|
1366
|
+
color: $ ? "#ccc" : void 0,
|
|
1367
|
+
pointerEvents: $ ? "none" : void 0,
|
|
1368
|
+
cursor: $ ? "not-allowed" : "pointer",
|
|
1369
|
+
...g ? {} : { width: "100%" }
|
|
1367
1370
|
},
|
|
1368
1371
|
onClick: () => {
|
|
1369
|
-
|
|
1372
|
+
$ || h(s.date);
|
|
1370
1373
|
},
|
|
1371
1374
|
children: s.number
|
|
1372
1375
|
},
|
|
@@ -1380,22 +1383,22 @@ const H = (a) => {
|
|
|
1380
1383
|
filter: t,
|
|
1381
1384
|
setViews: o,
|
|
1382
1385
|
onChange: l,
|
|
1383
|
-
previewDate:
|
|
1386
|
+
previewDate: p,
|
|
1384
1387
|
setPreviewDate: i,
|
|
1385
|
-
minDate:
|
|
1386
|
-
maxDate:
|
|
1388
|
+
minDate: g,
|
|
1389
|
+
maxDate: f,
|
|
1387
1390
|
input: r,
|
|
1388
1391
|
hasValue: d
|
|
1389
1392
|
}) => {
|
|
1390
|
-
const
|
|
1391
|
-
(!
|
|
1393
|
+
const w = a.getMonth(), M = a.getFullYear(), k = p.getFullYear(), N = (b) => {
|
|
1394
|
+
(!g || b >= g) && (!f || b <= f) && (t ? (l(b), n(b), i(b)) : (o("days"), i(b)));
|
|
1392
1395
|
};
|
|
1393
|
-
return /* @__PURE__ */ e("div", { className: "sa-calendar-months-preview", children: W.map((
|
|
1394
|
-
const s =
|
|
1396
|
+
return /* @__PURE__ */ e("div", { className: "sa-calendar-months-preview", children: W.map((b, h) => {
|
|
1397
|
+
const s = g && new Date(k, h, 1) < g || f && new Date(k, h + 1, 0) > f;
|
|
1395
1398
|
return /* @__PURE__ */ e(
|
|
1396
1399
|
"p",
|
|
1397
1400
|
{
|
|
1398
|
-
className: d &&
|
|
1401
|
+
className: d && h === w && k === M ? "sa-calendar-months-active" : "",
|
|
1399
1402
|
style: {
|
|
1400
1403
|
color: s ? "#ccc" : void 0,
|
|
1401
1404
|
pointerEvents: s ? "none" : void 0,
|
|
@@ -1403,11 +1406,11 @@ const H = (a) => {
|
|
|
1403
1406
|
...r ? {} : { width: "100%" }
|
|
1404
1407
|
},
|
|
1405
1408
|
onClick: () => {
|
|
1406
|
-
s ||
|
|
1409
|
+
s || N(new Date(k, h));
|
|
1407
1410
|
},
|
|
1408
|
-
children:
|
|
1411
|
+
children: b.slice(0, 3)
|
|
1409
1412
|
},
|
|
1410
|
-
|
|
1413
|
+
h
|
|
1411
1414
|
);
|
|
1412
1415
|
}) });
|
|
1413
1416
|
}, Z = (a) => {
|
|
@@ -1419,27 +1422,27 @@ const H = (a) => {
|
|
|
1419
1422
|
setViews: t,
|
|
1420
1423
|
setDate: o,
|
|
1421
1424
|
onChange: l,
|
|
1422
|
-
previewDate:
|
|
1425
|
+
previewDate: p,
|
|
1423
1426
|
setPreviewDate: i,
|
|
1424
|
-
minDate:
|
|
1425
|
-
maxDate:
|
|
1427
|
+
minDate: g,
|
|
1428
|
+
maxDate: f,
|
|
1426
1429
|
input: r,
|
|
1427
1430
|
hasValue: d
|
|
1428
1431
|
}) => {
|
|
1429
|
-
let
|
|
1430
|
-
const M =
|
|
1431
|
-
for (let s = k; s <
|
|
1432
|
-
let x =
|
|
1433
|
-
|
|
1432
|
+
let w = [];
|
|
1433
|
+
const M = p.getFullYear(), { start: k, end: N } = Z(M), b = a.getFullYear();
|
|
1434
|
+
for (let s = k; s < N; s++) {
|
|
1435
|
+
let x = g && new Date(s, 0, 1) < g || f && new Date(s, 11, 31) > f;
|
|
1436
|
+
w.push({
|
|
1434
1437
|
year: s,
|
|
1435
|
-
active: !!d && s ===
|
|
1438
|
+
active: !!d && s === b,
|
|
1436
1439
|
isDisabled: x
|
|
1437
1440
|
});
|
|
1438
1441
|
}
|
|
1439
|
-
const
|
|
1440
|
-
(!
|
|
1442
|
+
const h = (s) => {
|
|
1443
|
+
(!g || s >= g) && (!f || s <= f) && (n ? (l(s), o(s), i(s)) : (t("months"), i(s)));
|
|
1441
1444
|
};
|
|
1442
|
-
return /* @__PURE__ */ e("div", { className: "sa-calendar-years-preview", children:
|
|
1445
|
+
return /* @__PURE__ */ e("div", { className: "sa-calendar-years-preview", children: w.map((s, x) => /* @__PURE__ */ e(
|
|
1443
1446
|
"p",
|
|
1444
1447
|
{
|
|
1445
1448
|
className: s.active ? "sa-calendar-months-active" : "",
|
|
@@ -1450,7 +1453,7 @@ const H = (a) => {
|
|
|
1450
1453
|
...r ? {} : { width: "100%" }
|
|
1451
1454
|
},
|
|
1452
1455
|
onClick: () => {
|
|
1453
|
-
s.isDisabled ||
|
|
1456
|
+
s.isDisabled || h(new Date(s.year, 0));
|
|
1454
1457
|
},
|
|
1455
1458
|
children: s.year
|
|
1456
1459
|
},
|
|
@@ -1463,7 +1466,7 @@ const H = (a) => {
|
|
|
1463
1466
|
previewDate: o,
|
|
1464
1467
|
setPreviewDate: l
|
|
1465
1468
|
}) => {
|
|
1466
|
-
const
|
|
1469
|
+
const p = () => {
|
|
1467
1470
|
t || a((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
|
|
1468
1471
|
}, i = () => {
|
|
1469
1472
|
if (n === "years") {
|
|
@@ -1477,7 +1480,7 @@ const H = (a) => {
|
|
|
1477
1480
|
return;
|
|
1478
1481
|
}
|
|
1479
1482
|
l((r) => new Date(r.getFullYear(), r.getMonth() + 1));
|
|
1480
|
-
},
|
|
1483
|
+
}, g = () => {
|
|
1481
1484
|
if (n === "years") {
|
|
1482
1485
|
l((r) => new Date(r.getFullYear() - 10, 0));
|
|
1483
1486
|
return;
|
|
@@ -1496,7 +1499,7 @@ const H = (a) => {
|
|
|
1496
1499
|
);
|
|
1497
1500
|
};
|
|
1498
1501
|
return /* @__PURE__ */ Y("div", { className: "sa-calendar-header", children: [
|
|
1499
|
-
/* @__PURE__ */ e("div", { className: "sa-calendar-header-title", onClick:
|
|
1502
|
+
/* @__PURE__ */ e("div", { className: "sa-calendar-header-title", onClick: p, children: (() => {
|
|
1500
1503
|
if (n === "days")
|
|
1501
1504
|
return `${W[o.getMonth()]} ${o.getFullYear()}`;
|
|
1502
1505
|
if (n === "months")
|
|
@@ -1505,7 +1508,7 @@ const H = (a) => {
|
|
|
1505
1508
|
return `${Z(o.getFullYear()).start} ~ ${Z(o.getFullYear()).end}`;
|
|
1506
1509
|
})() }),
|
|
1507
1510
|
/* @__PURE__ */ Y("div", { className: "sa-calendar-header-nav", children: [
|
|
1508
|
-
/* @__PURE__ */ e("button", { className: "sa-calendar-nav-btn", onClick:
|
|
1511
|
+
/* @__PURE__ */ e("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ e(tn, {}) }),
|
|
1509
1512
|
/* @__PURE__ */ e("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ e(sn, {}) })
|
|
1510
1513
|
] })
|
|
1511
1514
|
] });
|
|
@@ -1523,45 +1526,45 @@ const Cn = K(
|
|
|
1523
1526
|
filter: t,
|
|
1524
1527
|
input: o = !0,
|
|
1525
1528
|
disabled: l,
|
|
1526
|
-
minDate:
|
|
1529
|
+
minDate: p,
|
|
1527
1530
|
maxDate: i,
|
|
1528
|
-
placeholder:
|
|
1529
|
-
size:
|
|
1531
|
+
placeholder: g,
|
|
1532
|
+
size: f,
|
|
1530
1533
|
variant: r,
|
|
1531
1534
|
status: d,
|
|
1532
|
-
clearable:
|
|
1535
|
+
clearable: w,
|
|
1533
1536
|
fullWidth: M = !0,
|
|
1534
1537
|
withPadding: k = !0,
|
|
1535
|
-
label:
|
|
1536
|
-
labelPosition:
|
|
1537
|
-
required:
|
|
1538
|
+
label: N,
|
|
1539
|
+
labelPosition: b,
|
|
1540
|
+
required: h,
|
|
1538
1541
|
optional: s,
|
|
1539
1542
|
description: x,
|
|
1540
|
-
helperText:
|
|
1541
|
-
errorText:
|
|
1542
|
-
},
|
|
1543
|
-
const
|
|
1543
|
+
helperText: $,
|
|
1544
|
+
errorText: c
|
|
1545
|
+
}, y) => {
|
|
1546
|
+
const u = c ? "error" : d, { ref: m, isComponentVisible: E, setIsComponentVisible: S } = rn(!1), D = J(null), [F, I] = A("days"), [T, z] = A(/* @__PURE__ */ new Date()), [C, L] = A(/* @__PURE__ */ new Date());
|
|
1544
1547
|
B(() => {
|
|
1545
|
-
a ? (
|
|
1548
|
+
a ? (z(a), L(a)) : (z(/* @__PURE__ */ new Date()), L(/* @__PURE__ */ new Date()));
|
|
1546
1549
|
}, [a]), B(() => {
|
|
1547
1550
|
t && I(t);
|
|
1548
1551
|
}, [t]), B(() => {
|
|
1549
1552
|
t || I("days");
|
|
1550
|
-
}, [
|
|
1553
|
+
}, [E]), B(() => {
|
|
1551
1554
|
o || S(!0);
|
|
1552
1555
|
}, [o]);
|
|
1553
1556
|
const G = () => a ? t === "days" ? P(T) : t === "months" ? `${W[T.getMonth()]} ${T.getFullYear()}` : t === "years" ? T.getFullYear() : P(T) : "", j = () => {
|
|
1554
|
-
if (
|
|
1555
|
-
const
|
|
1556
|
-
window.innerWidth <
|
|
1557
|
+
if (D.current && m.current && o) {
|
|
1558
|
+
const v = m.current.getBoundingClientRect(), V = D.current.getBoundingClientRect();
|
|
1559
|
+
window.innerWidth < v.left + V.width ? D.current.style.left = `${v.left - V.width + v.width}px` : D.current.style.left = `${v.left}px`, v.top + V.height > window.innerHeight ? D.current.style.top = `${v.y - (v.height + V.height - 28)}px` : D.current.style.top = `${v.y + v.height}px`;
|
|
1557
1560
|
}
|
|
1558
1561
|
};
|
|
1559
1562
|
B(() => {
|
|
1560
|
-
|
|
1561
|
-
}, [
|
|
1562
|
-
const
|
|
1563
|
-
return
|
|
1564
|
-
|
|
1563
|
+
D.current && m.current && o && j();
|
|
1564
|
+
}, [D, m, E]), B(() => {
|
|
1565
|
+
const v = y == null ? void 0 : y.current;
|
|
1566
|
+
return v && v.addEventListener("scroll", j), window.addEventListener("scroll", j), () => {
|
|
1567
|
+
v && v.removeEventListener("scroll", j), window.removeEventListener("scroll", j);
|
|
1565
1568
|
};
|
|
1566
1569
|
}, []);
|
|
1567
1570
|
const U = /* @__PURE__ */ Y(
|
|
@@ -1569,7 +1572,7 @@ const Cn = K(
|
|
|
1569
1572
|
{
|
|
1570
1573
|
className: "sa-calendar-wrapper",
|
|
1571
1574
|
style: { height: o ? "auto" : "100%" },
|
|
1572
|
-
ref: o ?
|
|
1575
|
+
ref: o ? m : null,
|
|
1573
1576
|
children: [
|
|
1574
1577
|
o ? /* @__PURE__ */ e(
|
|
1575
1578
|
vn,
|
|
@@ -1578,59 +1581,59 @@ const Cn = K(
|
|
|
1578
1581
|
onClick: () => S(!0),
|
|
1579
1582
|
onChange: () => {
|
|
1580
1583
|
},
|
|
1581
|
-
placeholder:
|
|
1584
|
+
placeholder: g,
|
|
1582
1585
|
disabled: l,
|
|
1583
|
-
size:
|
|
1586
|
+
size: f,
|
|
1584
1587
|
variant: r,
|
|
1585
|
-
status:
|
|
1588
|
+
status: u,
|
|
1586
1589
|
inputMode: "none",
|
|
1587
|
-
clearable:
|
|
1590
|
+
clearable: w,
|
|
1588
1591
|
onClear: () => n(void 0)
|
|
1589
1592
|
}
|
|
1590
1593
|
) : null,
|
|
1591
|
-
|
|
1594
|
+
E ? /* @__PURE__ */ Y(
|
|
1592
1595
|
"div",
|
|
1593
1596
|
{
|
|
1594
|
-
className: `sa-calendar sa-calendar-size-${
|
|
1597
|
+
className: `sa-calendar sa-calendar-size-${f || "md"} ${o ? "" : "sa-calendar-no-input"} ${k ? "" : "sa-calendar-no-padding"}`,
|
|
1595
1598
|
style: l ? { pointerEvents: "none" } : void 0,
|
|
1596
|
-
ref:
|
|
1599
|
+
ref: D,
|
|
1597
1600
|
children: [
|
|
1598
1601
|
/* @__PURE__ */ e(
|
|
1599
1602
|
kn,
|
|
1600
1603
|
{
|
|
1601
1604
|
setViews: I,
|
|
1602
|
-
views:
|
|
1605
|
+
views: F,
|
|
1603
1606
|
filter: t,
|
|
1604
|
-
previewDate:
|
|
1605
|
-
setPreviewDate:
|
|
1606
|
-
isComponentVisible:
|
|
1607
|
+
previewDate: C,
|
|
1608
|
+
setPreviewDate: L,
|
|
1609
|
+
isComponentVisible: E
|
|
1607
1610
|
}
|
|
1608
1611
|
),
|
|
1609
|
-
/* @__PURE__ */ e("div", { className: "sa-calendar-body", children:
|
|
1612
|
+
/* @__PURE__ */ e("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ e(
|
|
1610
1613
|
yn,
|
|
1611
1614
|
{
|
|
1612
1615
|
date: T,
|
|
1613
|
-
setDate:
|
|
1614
|
-
previewDate:
|
|
1615
|
-
setPreviewDate:
|
|
1616
|
+
setDate: z,
|
|
1617
|
+
previewDate: C,
|
|
1618
|
+
setPreviewDate: L,
|
|
1616
1619
|
setIsComponentVisible: S,
|
|
1617
1620
|
input: o,
|
|
1618
|
-
minDate:
|
|
1621
|
+
minDate: p,
|
|
1619
1622
|
maxDate: i,
|
|
1620
1623
|
onChange: n,
|
|
1621
1624
|
hasValue: a != null
|
|
1622
1625
|
}
|
|
1623
|
-
) :
|
|
1626
|
+
) : F === "months" ? /* @__PURE__ */ e(
|
|
1624
1627
|
wn,
|
|
1625
1628
|
{
|
|
1626
1629
|
date: T,
|
|
1627
|
-
setDate:
|
|
1628
|
-
previewDate:
|
|
1629
|
-
setPreviewDate:
|
|
1630
|
+
setDate: z,
|
|
1631
|
+
previewDate: C,
|
|
1632
|
+
setPreviewDate: L,
|
|
1630
1633
|
filter: t,
|
|
1631
1634
|
setViews: I,
|
|
1632
1635
|
onChange: n,
|
|
1633
|
-
minDate:
|
|
1636
|
+
minDate: p,
|
|
1634
1637
|
maxDate: i,
|
|
1635
1638
|
input: o,
|
|
1636
1639
|
hasValue: a != null
|
|
@@ -1639,13 +1642,13 @@ const Cn = K(
|
|
|
1639
1642
|
xn,
|
|
1640
1643
|
{
|
|
1641
1644
|
date: T,
|
|
1642
|
-
setDate:
|
|
1643
|
-
previewDate:
|
|
1644
|
-
setPreviewDate:
|
|
1645
|
+
setDate: z,
|
|
1646
|
+
previewDate: C,
|
|
1647
|
+
setPreviewDate: L,
|
|
1645
1648
|
filter: t,
|
|
1646
1649
|
setViews: I,
|
|
1647
1650
|
onChange: n,
|
|
1648
|
-
minDate:
|
|
1651
|
+
minDate: p,
|
|
1649
1652
|
maxDate: i,
|
|
1650
1653
|
input: o,
|
|
1651
1654
|
hasValue: a != null
|
|
@@ -1660,13 +1663,13 @@ const Cn = K(
|
|
|
1660
1663
|
return /* @__PURE__ */ e(
|
|
1661
1664
|
on,
|
|
1662
1665
|
{
|
|
1663
|
-
label:
|
|
1664
|
-
labelPosition:
|
|
1665
|
-
required:
|
|
1666
|
+
label: N,
|
|
1667
|
+
labelPosition: b,
|
|
1668
|
+
required: h,
|
|
1666
1669
|
optional: s,
|
|
1667
1670
|
description: x,
|
|
1668
|
-
helperText:
|
|
1669
|
-
errorText:
|
|
1671
|
+
helperText: $,
|
|
1672
|
+
errorText: c,
|
|
1670
1673
|
fullWidth: M,
|
|
1671
1674
|
children: U
|
|
1672
1675
|
}
|
|
@@ -1679,48 +1682,48 @@ const Cn = K(
|
|
|
1679
1682
|
filter: t,
|
|
1680
1683
|
input: o = !0,
|
|
1681
1684
|
rangedDate: l,
|
|
1682
|
-
disabled:
|
|
1685
|
+
disabled: p,
|
|
1683
1686
|
minDate: i,
|
|
1684
|
-
maxDate:
|
|
1685
|
-
placeholder:
|
|
1687
|
+
maxDate: g,
|
|
1688
|
+
placeholder: f,
|
|
1686
1689
|
size: r,
|
|
1687
1690
|
variant: d,
|
|
1688
|
-
status:
|
|
1691
|
+
status: w,
|
|
1689
1692
|
clearable: M,
|
|
1690
1693
|
fullWidth: k,
|
|
1691
|
-
withPadding:
|
|
1692
|
-
label:
|
|
1693
|
-
labelPosition:
|
|
1694
|
+
withPadding: N,
|
|
1695
|
+
label: b,
|
|
1696
|
+
labelPosition: h,
|
|
1694
1697
|
required: s,
|
|
1695
1698
|
optional: x,
|
|
1696
|
-
description:
|
|
1697
|
-
helperText:
|
|
1698
|
-
errorText:
|
|
1699
|
-
},
|
|
1700
|
-
const
|
|
1699
|
+
description: $,
|
|
1700
|
+
helperText: c,
|
|
1701
|
+
errorText: y
|
|
1702
|
+
}, u) => {
|
|
1703
|
+
const m = {
|
|
1701
1704
|
onChange: n,
|
|
1702
1705
|
value: a,
|
|
1703
1706
|
input: o,
|
|
1704
1707
|
filter: t,
|
|
1705
|
-
disabled:
|
|
1708
|
+
disabled: p,
|
|
1706
1709
|
minDate: i,
|
|
1707
|
-
maxDate:
|
|
1708
|
-
placeholder:
|
|
1710
|
+
maxDate: g,
|
|
1711
|
+
placeholder: f,
|
|
1709
1712
|
size: r,
|
|
1710
1713
|
variant: d,
|
|
1711
|
-
status:
|
|
1714
|
+
status: w,
|
|
1712
1715
|
clearable: M,
|
|
1713
1716
|
fullWidth: k,
|
|
1714
|
-
withPadding:
|
|
1715
|
-
label:
|
|
1716
|
-
labelPosition:
|
|
1717
|
+
withPadding: N,
|
|
1718
|
+
label: b,
|
|
1719
|
+
labelPosition: h,
|
|
1717
1720
|
required: s,
|
|
1718
1721
|
optional: x,
|
|
1719
|
-
description:
|
|
1720
|
-
helperText:
|
|
1721
|
-
errorText:
|
|
1722
|
+
description: $,
|
|
1723
|
+
helperText: c,
|
|
1724
|
+
errorText: y
|
|
1722
1725
|
};
|
|
1723
|
-
return /* @__PURE__ */ e(en, { children: l ? /* @__PURE__ */ e(bn, { ...
|
|
1726
|
+
return /* @__PURE__ */ e(en, { children: l ? /* @__PURE__ */ e(bn, { ...m, ref: u }) : /* @__PURE__ */ e(Cn, { ...m, ref: u }) });
|
|
1724
1727
|
}
|
|
1725
1728
|
);
|
|
1726
1729
|
export {
|
package/dist/date.umd.js
CHANGED
|
@@ -542,4 +542,4 @@
|
|
|
542
542
|
width: 32px;
|
|
543
543
|
height: 32px;
|
|
544
544
|
}
|
|
545
|
-
`,Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A=["January","February","March","April","May","June","July","August","September","October","November","December"],rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(a){const[e,t]=x.useState(a),o=x.useRef(null),l=p=>{o.current&&!o.current.contains(p.target)&&t(!1)};return x.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:t}}const Q="sa-calendar-input-styles";(a=>{if(!document.getElementById(Q)){const e=document.createElement("style");e.id=Q,e.textContent=a,document.head.appendChild(e)}})(P);const O=a=>{if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},tn=a=>{const{size:e="md",status:t="default",variant:o="outline",clearable:l,onClear:p,...i}=a,u=x.useRef(null),h=()=>{u.current&&i.onClick&&(u.current.focus(),i.onClick(""))},r=t==="disable"||i.disabled,d=!!i.value,w=l&&d&&!r,D=M=>{M.stopPropagation(),p==null||p()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,onClick:h,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:u})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:D,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},sn=({date:a,setDate:e,dateRange:t,setDateRange:o,onChange:l,minDate:p,maxDate:i,input:u})=>{var $,f,m;const[h,r]=x.useState(null);let d=new Date(a.getFullYear(),a.getMonth(),1),w=d.getDay(),D=[];const M=a.getMonth(),Y=new Date().toDateString(),v=!!(t.from&&!t.to),g=v&&h?h:null;for(let c=0;c<42;c++){c===0&&w===0?d.setDate(d.getDate()-7):c===0?d.setDate(d.getDate()+(c-w)):d.setDate(d.getDate()+1);let y={currentMonth:d.getMonth()===M,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===(($=t.from)==null?void 0:$.toDateString())||d.toDateString()===(((f=t.to)==null?void 0:f.toDateString())||((m=t.from)==null?void 0:m.toDateString())),isToday:d.toDateString()===Y,year:d.getFullYear(),isDisabled:p&&d<p||i&&d>i};D.push(y)}const s=c=>{e(c)},k=c=>{var z;let y={...t};if(y.from&&y.to)y={from:c,to:null};else{const T=((z=y.from)==null?void 0:z.getTime())||0;c.getTime()>T?y={from:y.from,to:c}:y={from:c,to:y.from}}o(y),l(y)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>r(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((c,y)=>n.jsx("p",{children:c},y))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((c,y)=>{const z=t.from&&t.to&&c.date.getTime()>t.from.getTime()&&c.date.getTime()<t.to.getTime(),T=(()=>{if(!g||!t.from)return!1;const E=c.date.getTime(),N=t.from.getTime(),S=g.getTime();return S>N?E>N&&E<S:E<N&&E>S})(),C=v&&h&&c.date.toDateString()===h.toDateString(),F=c.isDisabled,I=()=>z||T?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",L=()=>F?"var(--sa-color-gray-400, #b7b9be)":z||T?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${c.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${c.selected||C?"sa-calendar-days-active":""} ${c.isToday&&!c.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:I(),pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",color:L(),opacity:C&&!c.selected?.75:1,...u?{}:{width:"100%"}},onClick:()=>{F||(s(c.date),k(c.date))},onMouseEnter:()=>{F||r(c.date)},children:c.number},y)})})]})},on=({date:a,setDate:e,filter:t,setViews:o,dateRange:l,setDateRange:p,onChange:i,minDate:u,maxDate:h,input:r})=>{var Y;const d=(Y=l.from)==null?void 0:Y.getFullYear(),w=a.getFullYear(),D=v=>{t?(M(v),e(v)):(o("days"),e(v))},M=v=>{var s;let g={...l};if(g.from&&g.to)g={from:v,to:null};else{const k=((s=g.from)==null?void 0:s.getTime())||0;v.getTime()>k?g={from:g.from,to:v}:g={from:v,to:g.from}}p(g),i(g)};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((v,g)=>{var $,f,m;const s=l.from!=null&&new Date(w,g).getTime()>l.from.getTime()&&new Date(w,g).getTime()<((($=l.to)==null?void 0:$.getTime())||l.from.getTime()),k=u&&new Date(w,g)<u||h&&new Date(w,g)>h;return n.jsx("p",{className:d===w&&(g===((f=l.from)==null?void 0:f.getMonth())||g===((m=l.to)==null?void 0:m.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:s?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:k?"none":void 0,cursor:k?"not-allowed":"pointer",color:k?"var(--sa-color-gray-400, #b7b9be)":s?"var(--sa-color-gray-500, #8c8f97)":"",...r?{}:{width:"100%"}},onClick:()=>{k||D(new Date(w,g))},children:v.slice(0,3)},g)})})},J=a=>{const e=Math.floor(a/10)*10,t=e+10;return{start:e,end:t}},ln=({date:a,filter:e,setViews:t,setDate:o,dateRange:l,setDateRange:p,onChange:i,minDate:u,maxDate:h,input:r})=>{var k,$;let d=[];const w=a.getFullYear(),{start:D,end:M}=J(w),Y=(k=l.from)==null?void 0:k.getFullYear(),v=($=l.to)==null?void 0:$.getFullYear();for(let f=D;f<M;f++){const m=new Date(f,0),c=(!u||m>=u)&&(!h||m<=h),y=Y!=null&&f===Y||v!=null&&f===v,z=l.from!=null&&l.to!=null&&m>l.from&&m<l.to;d.push({year:f,active:y&&c,highlight:z&&c,disabled:!c})}const g=f=>{e?(s(f),o(f)):(o(f),t("months"))},s=f=>{var c;let m={...l};if(m.from&&m.to)m={from:f,to:null};else{const y=((c=m.from)==null?void 0:c.getTime())||0;f.getTime()>y?m={from:m.from,to:f}:m={from:f,to:m.from}}p(m),i(m)};return n.jsx("div",{className:"sa-calendar-years-preview",children:d.map((f,m)=>n.jsx("p",{className:`${f.active?"sa-calendar-months-active":""} ${f.highlight?"sa-calendar-months-highlight":""} ${f.disabled?"sa-calendar-disabled":""}`,onClick:()=>{f.disabled||g(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",...r?{}:{width:"100%"}},children:f.year},m))})},X=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),dn=({setViews:a,views:e,filter:t,date:o,setDate:l})=>{const p=()=>{t||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},u=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},h=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${J(o.getFullYear()).start} ~ ${J(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:p,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:u,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})};function W(a){const e=new Date(a),t=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${rn[o]} ${t}`}const R=({label:a,labelPosition:e="outside-top",required:t,optional:o,description:l,helperText:p,errorText:i,fullWidth:u,children:h})=>{const r=["sa-date-field",u?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),d=a?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:a}),o&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),t&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,w=n.jsxs(n.Fragment,{children:[p&&!i&&n.jsx("p",{className:"sa-date-field-helper",children:p}),i&&n.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return a?e==="outside-left"?n.jsxs("div",{className:`${r} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[h,w]})]}):n.jsxs("div",{className:r,children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),h,w]}):n.jsxs("div",{className:r,children:[l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),h,w]})},nn="sa-calendar-styles";(a=>{if(!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=a,document.head.appendChild(e)}})(P);const cn=x.forwardRef(({value:a,onChange:e,filter:t,input:o=!0,disabled:l,minDate:p,maxDate:i,placeholder:u,size:h,variant:r,status:d,clearable:w,fullWidth:D=!0,withPadding:M=!0,label:Y,labelPosition:v,required:g,optional:s,description:k,helperText:$,errorText:f},m)=>{const c=f?"error":d,{ref:y,isComponentVisible:z,setIsComponentVisible:T}=K(!1),C=x.useRef(null),[F,I]=x.useState("days"),[L,E]=x.useState(new Date),[N,S]=x.useState({from:(a==null?void 0:a.from)??null,to:(a==null?void 0:a.to)??null});x.useEffect(()=>{if(a){const b=a;b.from&&E(b.from),S(b)}else E(new Date),S({from:null,to:null})},[a]),x.useEffect(()=>{t&&I(t)},[t]),x.useEffect(()=>{t||I("days")},[z]),x.useEffect(()=>{o||T(!0)},[o]);const G=()=>{var b,j;if(!a)return"";if(t){if(F==="days")return`${W(N.from)} ~ ${W(N.to||N.from)||"-"}`;if(F==="months")return`${A[N.from.getMonth()]} ~ ${N.to?A[N.to.getMonth()]:"-"}`;if(F==="years")return`${(b=N.from)==null?void 0:b.getFullYear()} ~ ${((j=N.to)==null?void 0:j.getFullYear())||"-"}`}else return`${W(N.from)} ~ ${W(N.to||N.from)||"-"}`},B=()=>{if(C.current&&y.current&&o){const b=y.current.getBoundingClientRect(),j=C.current.getBoundingClientRect();window.innerWidth<b.left+j.width?C.current.style.left=`${b.left-j.width+b.width}px`:C.current.style.left=`${b.left}px`,b.top+j.height>window.innerHeight?C.current.style.top=`${b.y-(b.height+j.height-28)}px`:C.current.style.top=`${b.y+b.height}px`}};x.useEffect(()=>{C.current&&y.current&&o&&B()},[C,y,z]),x.useEffect(()=>{const b=m==null?void 0:m.current;return b&&b.addEventListener("scroll",B),window.addEventListener("scroll",B),()=>{b&&b.removeEventListener("scroll",B),window.removeEventListener("scroll",B)}},[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?y:null,children:[o?n.jsx(tn,{value:G(),inputMode:"none",onClick:()=>{T(!0)},onChange:()=>{},disabled:l,placeholder:u,size:h,variant:r,status:c,clearable:w,onClear:()=>e(void 0)}):null,z?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"md"} ${o?"":"sa-calendar-no-input"} ${M?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:C,children:[n.jsx(dn,{setViews:I,views:F,filter:t,date:L,setDate:E}),n.jsx("div",{className:"sa-calendar-body",children:F==="days"?n.jsx(sn,{date:L,setDate:E,setIsComponentVisible:T,dateRange:N,setDateRange:S,input:o,onChange:e,minDate:p,maxDate:i}):F==="months"?n.jsx(on,{date:L,setDate:E,filter:t,setViews:I,dateRange:N,setDateRange:S,setIsComponentVisible:T,input:o,onChange:e,minDate:p,maxDate:i}):n.jsx(ln,{date:L,setDate:E,filter:t,setViews:I,dateRange:N,setDateRange:S,setIsComponentVisible:T,input:o,onChange:e,minDate:p,maxDate:i})})]}):null]});return n.jsx(R,{label:Y,labelPosition:v,required:g,optional:s,description:k,helperText:$,errorText:f,fullWidth:D,children:U})}),en="sa-calendar-input-styles";(a=>{if(!document.getElementById(en)){const e=document.createElement("style");e.id=en,e.textContent=a,document.head.appendChild(e)}})(P);const H=a=>{if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},pn=a=>{const{size:e="md",status:t="default",variant:o="outline",clearable:l,onClear:p,...i}=a,u=x.useRef(null),h=()=>{u.current&&i.onClick&&(u.current.focus(),i.onClick(""))},r=t==="disable"||i.disabled,d=!!i.value,w=l&&d&&!r,D=M=>{M.stopPropagation(),p==null||p()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,onClick:h,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:u})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:D,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},hn=({date:a,setDate:e,previewDate:t,setPreviewDate:o,setIsComponentVisible:l,minDate:p,maxDate:i,input:u,onChange:h,hasValue:r})=>{let d=new Date(t.getFullYear(),t.getMonth(),1),w=d.getDay(),D=[];const M=a.toDateString(),Y=new Date().toDateString(),v=t.getMonth();for(let s=0;s<42;s++){s===0&&w===0?d.setDate(d.getDate()-7):s===0?d.setDate(d.getDate()+(s-w)):d.setDate(d.getDate()+1);let k={currentMonth:d.getMonth()===v,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:r&&d.toDateString()===M,isToday:d.toDateString()===Y,year:d.getFullYear(),isDisabled:p&&d<p||i&&d>i};D.push(k)}const g=s=>{(!p||s>=p)&&(!i||s<=i)&&(e(s),h(s),o(s),u&&l(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((s,k)=>n.jsx("p",{children:s},k))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((s,k)=>{const $=s.isDisabled;return n.jsx("p",{className:`${s.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${s.selected?"sa-calendar-days-active":""} ${s.isToday&&!s.selected?"sa-calendar-days-today":""}`,style:{color:$?"#ccc":void 0,pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",...u?{}:{width:"100%"}},onClick:()=>{$||g(s.date)},children:s.number},k)})})]})},fn=({date:a,setDate:e,filter:t,setViews:o,onChange:l,previewDate:p,setPreviewDate:i,minDate:u,maxDate:h,input:r,hasValue:d})=>{const w=a.getMonth(),D=a.getFullYear(),M=p.getFullYear(),Y=v=>{(!u||v>=u)&&(!h||v<=h)&&(t?(l(v),e(v),i(v)):(o("days"),i(v)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((v,g)=>{const s=u&&new Date(M,g,1)<u||h&&new Date(M,g+1,0)>h;return n.jsx("p",{className:d&&g===w&&M===D?"sa-calendar-months-active":"",style:{color:s?"#ccc":void 0,pointerEvents:s?"none":void 0,cursor:s?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{s||Y(new Date(M,g))},children:v.slice(0,3)},g)})})},q=a=>{const e=Math.floor(a/10)*10,t=e+10;return{start:e,end:t}},un=({date:a,filter:e,setViews:t,setDate:o,onChange:l,previewDate:p,setPreviewDate:i,minDate:u,maxDate:h,input:r,hasValue:d})=>{let w=[];const D=p.getFullYear(),{start:M,end:Y}=q(D),v=a.getFullYear();for(let s=M;s<Y;s++){let k=u&&new Date(s,0,1)<u||h&&new Date(s,11,31)>h;w.push({year:s,active:!!d&&s===v,isDisabled:k})}const g=s=>{(!u||s>=u)&&(!h||s<=h)&&(e?(l(s),o(s),i(s)):(t("months"),i(s)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:w.map((s,k)=>n.jsx("p",{className:s.active?"sa-calendar-months-active":"",style:{color:s.isDisabled?"#ccc":void 0,pointerEvents:s.isDisabled?"none":void 0,cursor:s.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{s.isDisabled||g(new Date(s.year,0))},children:s.year},k))})},gn=({setViews:a,views:e,filter:t,previewDate:o,setPreviewDate:l})=>{const p=()=>{t||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},u=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},h=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:p,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:u,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})},an="sa-calendar-styles";(a=>{if(!document.getElementById(an)){const e=document.createElement("style");e.id=an,e.textContent=a,document.head.appendChild(e)}})(P);const bn=x.forwardRef(({value:a,onChange:e,filter:t,input:o=!0,disabled:l,minDate:p,maxDate:i,placeholder:u,size:h,variant:r,status:d,clearable:w,fullWidth:D=!0,withPadding:M=!0,label:Y,labelPosition:v,required:g,optional:s,description:k,helperText:$,errorText:f},m)=>{const c=f?"error":d,{ref:y,isComponentVisible:z,setIsComponentVisible:T}=K(!1),C=x.useRef(null),[F,I]=x.useState("days"),[L,E]=x.useState(new Date),[N,S]=x.useState(new Date);x.useEffect(()=>{a?(E(a),S(a)):(E(new Date),S(new Date))},[a]),x.useEffect(()=>{t&&I(t)},[t]),x.useEffect(()=>{t||I("days")},[z]),x.useEffect(()=>{o||T(!0)},[o]);const G=()=>a?t==="days"?W(L):t==="months"?`${A[L.getMonth()]} ${L.getFullYear()}`:t==="years"?L.getFullYear():W(L):"",B=()=>{if(C.current&&y.current&&o){const b=y.current.getBoundingClientRect(),j=C.current.getBoundingClientRect();window.innerWidth<b.left+j.width?C.current.style.left=`${b.left-j.width+b.width}px`:C.current.style.left=`${b.left}px`,b.top+j.height>window.innerHeight?C.current.style.top=`${b.y-(b.height+j.height-28)}px`:C.current.style.top=`${b.y+b.height}px`}};x.useEffect(()=>{C.current&&y.current&&o&&B()},[C,y,z]),x.useEffect(()=>{const b=m==null?void 0:m.current;return b&&b.addEventListener("scroll",B),window.addEventListener("scroll",B),()=>{b&&b.removeEventListener("scroll",B),window.removeEventListener("scroll",B)}},[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?y:null,children:[o?n.jsx(pn,{value:G(),onClick:()=>T(!0),onChange:()=>{},placeholder:u,disabled:l,size:h,variant:r,status:c,inputMode:"none",clearable:w,onClear:()=>e(void 0)}):null,z?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"md"} ${o?"":"sa-calendar-no-input"} ${M?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:C,children:[n.jsx(gn,{setViews:I,views:F,filter:t,previewDate:N,setPreviewDate:S,isComponentVisible:z}),n.jsx("div",{className:"sa-calendar-body",children:F==="days"?n.jsx(hn,{date:L,setDate:E,previewDate:N,setPreviewDate:S,setIsComponentVisible:T,input:o,minDate:p,maxDate:i,onChange:e,hasValue:a!=null}):F==="months"?n.jsx(fn,{date:L,setDate:E,previewDate:N,setPreviewDate:S,filter:t,setViews:I,onChange:e,minDate:p,maxDate:i,input:o,hasValue:a!=null}):n.jsx(un,{date:L,setDate:E,previewDate:N,setPreviewDate:S,filter:t,setViews:I,onChange:e,minDate:p,maxDate:i,input:o,hasValue:a!=null})})]}):null]});return n.jsx(R,{label:Y,labelPosition:v,required:g,optional:s,description:k,helperText:$,errorText:f,fullWidth:D,children:U})}),vn=x.forwardRef(({value:a,onChange:e,filter:t,input:o=!0,rangedDate:l,disabled:p,minDate:i,maxDate:u,placeholder:h,size:r,variant:d,status:w,clearable:D,fullWidth:M,withPadding:Y,label:v,labelPosition:g,required:s,optional:k,description:$,helperText:f,errorText:m},c)=>{const y={onChange:e,value:a,input:o,filter:t,disabled:p,minDate:i,maxDate:u,placeholder:h,size:r,variant:d,status:w,clearable:D,fullWidth:M,withPadding:Y,label:v,labelPosition:g,required:s,optional:k,description:$,helperText:f,errorText:m};return n.jsx(n.Fragment,{children:l?n.jsx(cn,{...y,ref:c}):n.jsx(bn,{...y,ref:c})})});V.StarasiaDate=vn,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|
|
545
|
+
`,Z=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A=["January","February","March","April","May","June","July","August","September","October","November","December"],rn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function K(a){const[e,t]=x.useState(a),o=x.useRef(null),l=h=>{o.current&&!o.current.contains(h.target)&&t(!1)};return x.useEffect(()=>(document.addEventListener("click",l,!0),()=>{document.removeEventListener("click",l,!0)}),[]),{ref:o,isComponentVisible:e,setIsComponentVisible:t}}const Q="sa-calendar-input-styles";(a=>{if(!document.getElementById(Q)){const e=document.createElement("style");e.id=Q,e.textContent=a,document.head.appendChild(e)}})(P);const O=a=>{if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},tn=a=>{const{size:e="md",status:t="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=x.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=t==="disable"||i.disabled,d=!!i.value,m=l&&d&&!r,D=M=>{M.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),m?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:D,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:O(e),height:O(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},sn=({date:a,setDate:e,dateRange:t,setDateRange:o,onChange:l,minDate:h,maxDate:i,input:g})=>{var Y,c,w;const[f,r]=x.useState(null);let d=new Date(a.getFullYear(),a.getMonth(),1),m=d.getDay(),D=[];const M=a.getMonth(),$=new Date().toDateString(),b=!!(t.from&&!t.to),u=b&&f?f:null;for(let p=0;p<42;p++){p===0&&m===0?d.setDate(d.getDate()-7):p===0?d.setDate(d.getDate()+(p-m)):d.setDate(d.getDate()+1);let v={currentMonth:d.getMonth()===M,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:d.toDateString()===((Y=t.from)==null?void 0:Y.toDateString())||d.toDateString()===(((c=t.to)==null?void 0:c.toDateString())||((w=t.from)==null?void 0:w.toDateString())),isToday:d.toDateString()===$,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};D.push(v)}const s=p=>{e(p)},k=p=>{let v={...t};if(v.from&&v.to)v={from:p,to:null};else if(!v.from)v={from:p,to:null};else{const S=v.from.getTime();p.getTime()>S?v={from:v.from,to:p}:v={from:p,to:v.from}}o(v),l(v)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>r(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((p,v)=>n.jsx("p",{children:p},v))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((p,v)=>{const S=t.from&&t.to&&p.date.getTime()>t.from.getTime()&&p.date.getTime()<t.to.getTime(),T=(()=>{if(!u||!t.from)return!1;const z=p.date.getTime(),C=t.from.getTime(),F=u.getTime();return F>C?z>C&&z<F:z<C&&z>F})(),N=b&&f&&p.date.toDateString()===f.toDateString(),E=p.isDisabled,I=()=>S||T?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",L=()=>E?"var(--sa-color-gray-400, #b7b9be)":S||T?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${p.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${p.selected||N?"sa-calendar-days-active":""} ${p.isToday&&!p.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:I(),pointerEvents:E?"none":void 0,cursor:E?"not-allowed":"pointer",color:L(),opacity:N&&!p.selected?.75:1,...g?{}:{width:"100%"}},onClick:()=>{E||(s(p.date),k(p.date))},onMouseEnter:()=>{E||r(p.date)},children:p.number},v)})})]})},on=({date:a,setDate:e,filter:t,setViews:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var $;const d=($=l.from)==null?void 0:$.getFullYear(),m=a.getFullYear(),D=b=>{t?(M(b),e(b)):(o("days"),e(b))},M=b=>{let u={...l};if(u.from&&u.to)u={from:b,to:null};else if(!u.from)u={from:b,to:null};else{const s=u.from.getTime();b.getTime()>s?u={from:u.from,to:b}:u={from:b,to:u.from}}h(u),i(u)};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{var Y,c,w;const s=l.from!=null&&new Date(m,u).getTime()>l.from.getTime()&&new Date(m,u).getTime()<(((Y=l.to)==null?void 0:Y.getTime())||l.from.getTime()),k=g&&new Date(m,u)<g||f&&new Date(m,u)>f;return n.jsx("p",{className:d===m&&(u===((c=l.from)==null?void 0:c.getMonth())||u===((w=l.to)==null?void 0:w.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:s?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:k?"none":void 0,cursor:k?"not-allowed":"pointer",color:k?"var(--sa-color-gray-400, #b7b9be)":s?"var(--sa-color-gray-500, #8c8f97)":"",...r?{}:{width:"100%"}},onClick:()=>{k||D(new Date(m,u))},children:b.slice(0,3)},u)})})},J=a=>{const e=Math.floor(a/10)*10,t=e+10;return{start:e,end:t}},ln=({date:a,filter:e,setViews:t,setDate:o,dateRange:l,setDateRange:h,onChange:i,minDate:g,maxDate:f,input:r})=>{var k,Y;let d=[];const m=a.getFullYear(),{start:D,end:M}=J(m),$=(k=l.from)==null?void 0:k.getFullYear(),b=(Y=l.to)==null?void 0:Y.getFullYear();for(let c=D;c<M;c++){const w=new Date(c,0),p=(!g||w>=g)&&(!f||w<=f),v=$!=null&&c===$||b!=null&&c===b,S=l.from!=null&&l.to!=null&&w>l.from&&w<l.to;d.push({year:c,active:v&&p,highlight:S&&p,disabled:!p})}const u=c=>{e?(s(c),o(c)):(o(c),t("months"))},s=c=>{let w={...l};if(w.from&&w.to)w={from:c,to:null};else if(!w.from)w={from:c,to:null};else{const p=w.from.getTime();c.getTime()>p?w={from:w.from,to:c}:w={from:c,to:w.from}}h(w),i(w)};return n.jsx("div",{className:"sa-calendar-years-preview",children:d.map((c,w)=>n.jsx("p",{className:`${c.active?"sa-calendar-months-active":""} ${c.highlight?"sa-calendar-months-highlight":""} ${c.disabled?"sa-calendar-disabled":""}`,onClick:()=>{c.disabled||u(new Date(c.year,0))},style:{backgroundColor:c.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:c.highlight?"var(--sa-color-gray-500, #8c8f97)":c.active?"":c.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:c.disabled?"not-allowed":"pointer",pointerEvents:c.disbled?"none":"all",...r?{}:{width:"100%"}},children:c.year},w))})},X=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),_=({...a})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...a,children:n.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),dn=({setViews:a,views:e,filter:t,date:o,setDate:l})=>{const h=()=>{t||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${J(o.getFullYear()).start} ~ ${J(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})};function W(a){const e=new Date(a),t=e.getFullYear(),o=e.getMonth();return`${e.getDate().toString().padStart(2,"0")} ${rn[o]} ${t}`}const R=({label:a,labelPosition:e="outside-top",required:t,optional:o,description:l,helperText:h,errorText:i,fullWidth:g,children:f})=>{const r=["sa-date-field",g?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),d=a?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:a}),o&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),t&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,m=n.jsxs(n.Fragment,{children:[h&&!i&&n.jsx("p",{className:"sa-date-field-helper",children:h}),i&&n.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return a?e==="outside-left"?n.jsxs("div",{className:`${r} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[f,m]})]}):n.jsxs("div",{className:r,children:[d,l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),f,m]}):n.jsxs("div",{className:r,children:[l&&n.jsx("p",{className:"sa-date-field-helper-top",children:l}),f,m]})},nn="sa-calendar-styles";(a=>{if(!document.getElementById(nn)){const e=document.createElement("style");e.id=nn,e.textContent=a,document.head.appendChild(e)}})(P);const cn=x.forwardRef(({value:a,onChange:e,filter:t,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f,variant:r,status:d,clearable:m,fullWidth:D=!0,withPadding:M=!0,label:$,labelPosition:b,required:u,optional:s,description:k,helperText:Y,errorText:c},w)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),N=x.useRef(null),[E,I]=x.useState("days"),[L,z]=x.useState(new Date),[C,F]=x.useState({from:(a==null?void 0:a.from)??null,to:(a==null?void 0:a.to)??null});x.useEffect(()=>{if(a){const y=a;y.from&&z(y.from),F(y)}else z(new Date),F({from:null,to:null})},[a]),x.useEffect(()=>{t&&I(t)},[t]),x.useEffect(()=>{t||I("days")},[S]),x.useEffect(()=>{o||T(!0)},[o]);const G=()=>{var y,j;if(!a)return"";if(t){if(E==="days")return`${W(C.from)} ~ ${W(C.to||C.from)||"-"}`;if(E==="months")return`${A[C.from.getMonth()]} ~ ${C.to?A[C.to.getMonth()]:"-"}`;if(E==="years")return`${(y=C.from)==null?void 0:y.getFullYear()} ~ ${((j=C.to)==null?void 0:j.getFullYear())||"-"}`}else return`${W(C.from)} ~ ${W(C.to||C.from)||"-"}`},B=()=>{if(N.current&&v.current&&o){const y=v.current.getBoundingClientRect(),j=N.current.getBoundingClientRect();window.innerWidth<y.left+j.width?N.current.style.left=`${y.left-j.width+y.width}px`:N.current.style.left=`${y.left}px`,y.top+j.height>window.innerHeight?N.current.style.top=`${y.y-(y.height+j.height-28)}px`:N.current.style.top=`${y.y+y.height}px`}};x.useEffect(()=>{N.current&&v.current&&o&&B()},[N,v,S]),x.useEffect(()=>{const y=w==null?void 0:w.current;return y&&y.addEventListener("scroll",B),window.addEventListener("scroll",B),()=>{y&&y.removeEventListener("scroll",B),window.removeEventListener("scroll",B)}},[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(tn,{value:G(),inputMode:"none",onClick:()=>{T(!0)},onChange:()=>{},disabled:l,placeholder:g,size:f,variant:r,status:p,clearable:m,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"md"} ${o?"":"sa-calendar-no-input"} ${M?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:N,children:[n.jsx(dn,{setViews:I,views:E,filter:t,date:L,setDate:z}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(sn,{date:L,setDate:z,setIsComponentVisible:T,dateRange:C,setDateRange:F,input:o,onChange:e,minDate:h,maxDate:i}):E==="months"?n.jsx(on,{date:L,setDate:z,filter:t,setViews:I,dateRange:C,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i}):n.jsx(ln,{date:L,setDate:z,filter:t,setViews:I,dateRange:C,setDateRange:F,setIsComponentVisible:T,input:o,onChange:e,minDate:h,maxDate:i})})]}):null]});return n.jsx(R,{label:$,labelPosition:b,required:u,optional:s,description:k,helperText:Y,errorText:c,fullWidth:D,children:U})}),en="sa-calendar-input-styles";(a=>{if(!document.getElementById(en)){const e=document.createElement("style");e.id=en,e.textContent=a,document.head.appendChild(e)}})(P);const H=a=>{if(a==="sm")return 16;if(a==="md")return 16;if(a==="lg")return 20},pn=a=>{const{size:e="md",status:t="default",variant:o="outline",clearable:l,onClear:h,...i}=a,g=x.useRef(null),f=()=>{g.current&&i.onClick&&(g.current.focus(),i.onClick(""))},r=t==="disable"||i.disabled,d=!!i.value,m=l&&d&&!r,D=M=>{M.stopPropagation(),h==null||h()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${t} ${e} `,onClick:f,children:[n.jsx("div",{className:"sa-calendar-input-container-icon-left",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsx("div",{className:"sa-calendar-input-preview-container",children:n.jsx("input",{className:"sa-calendar-input",...i,disabled:r,value:i.value,ref:g})}),m?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:D,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):n.jsx("div",{className:"sa-calendar-input-container-icon-right",children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:H(e),height:H(e),viewBox:"0 0 20 20",fill:"none",children:n.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},hn=({date:a,setDate:e,previewDate:t,setPreviewDate:o,setIsComponentVisible:l,minDate:h,maxDate:i,input:g,onChange:f,hasValue:r})=>{let d=new Date(t.getFullYear(),t.getMonth(),1),m=d.getDay(),D=[];const M=a.toDateString(),$=new Date().toDateString(),b=t.getMonth();for(let s=0;s<42;s++){s===0&&m===0?d.setDate(d.getDate()-7):s===0?d.setDate(d.getDate()+(s-m)):d.setDate(d.getDate()+1);let k={currentMonth:d.getMonth()===b,date:new Date(d),month:d.getMonth(),number:d.getDate(),selected:r&&d.toDateString()===M,isToday:d.toDateString()===$,year:d.getFullYear(),isDisabled:h&&d<h||i&&d>i};D.push(k)}const u=s=>{(!h||s>=h)&&(!i||s<=i)&&(e(s),f(s),o(s),g&&l(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:Z.map((s,k)=>n.jsx("p",{children:s},k))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:D.map((s,k)=>{const Y=s.isDisabled;return n.jsx("p",{className:`${s.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${s.selected?"sa-calendar-days-active":""} ${s.isToday&&!s.selected?"sa-calendar-days-today":""}`,style:{color:Y?"#ccc":void 0,pointerEvents:Y?"none":void 0,cursor:Y?"not-allowed":"pointer",...g?{}:{width:"100%"}},onClick:()=>{Y||u(s.date)},children:s.number},k)})})]})},fn=({date:a,setDate:e,filter:t,setViews:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{const m=a.getMonth(),D=a.getFullYear(),M=h.getFullYear(),$=b=>{(!g||b>=g)&&(!f||b<=f)&&(t?(l(b),e(b),i(b)):(o("days"),i(b)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:A.map((b,u)=>{const s=g&&new Date(M,u,1)<g||f&&new Date(M,u+1,0)>f;return n.jsx("p",{className:d&&u===m&&M===D?"sa-calendar-months-active":"",style:{color:s?"#ccc":void 0,pointerEvents:s?"none":void 0,cursor:s?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{s||$(new Date(M,u))},children:b.slice(0,3)},u)})})},q=a=>{const e=Math.floor(a/10)*10,t=e+10;return{start:e,end:t}},un=({date:a,filter:e,setViews:t,setDate:o,onChange:l,previewDate:h,setPreviewDate:i,minDate:g,maxDate:f,input:r,hasValue:d})=>{let m=[];const D=h.getFullYear(),{start:M,end:$}=q(D),b=a.getFullYear();for(let s=M;s<$;s++){let k=g&&new Date(s,0,1)<g||f&&new Date(s,11,31)>f;m.push({year:s,active:!!d&&s===b,isDisabled:k})}const u=s=>{(!g||s>=g)&&(!f||s<=f)&&(e?(l(s),o(s),i(s)):(t("months"),i(s)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:m.map((s,k)=>n.jsx("p",{className:s.active?"sa-calendar-months-active":"",style:{color:s.isDisabled?"#ccc":void 0,pointerEvents:s.isDisabled?"none":void 0,cursor:s.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{s.isDisabled||u(new Date(s.year,0))},children:s.year},k))})},gn=({setViews:a,views:e,filter:t,previewDate:o,setPreviewDate:l})=>{const h=()=>{t||a(r=>r==="days"?"months":r==="months"?"years":"days")},i=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()+10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()+1,r.getMonth()));return}l(r=>new Date(r.getFullYear(),r.getMonth()+1))},g=()=>{if(e==="years"){l(r=>new Date(r.getFullYear()-10,0));return}if(e==="months"){l(r=>new Date(r.getFullYear()-1,r.getMonth()));return}l(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},f=()=>{if(e==="days")return`${A[o.getMonth()]} ${o.getFullYear()}`;if(e==="months")return`${o.getFullYear()}`;if(e==="years")return`${q(o.getFullYear()).start} ~ ${q(o.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:h,children:f()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:g,children:n.jsx(X,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:n.jsx(_,{})})]})]})},an="sa-calendar-styles";(a=>{if(!document.getElementById(an)){const e=document.createElement("style");e.id=an,e.textContent=a,document.head.appendChild(e)}})(P);const bn=x.forwardRef(({value:a,onChange:e,filter:t,input:o=!0,disabled:l,minDate:h,maxDate:i,placeholder:g,size:f,variant:r,status:d,clearable:m,fullWidth:D=!0,withPadding:M=!0,label:$,labelPosition:b,required:u,optional:s,description:k,helperText:Y,errorText:c},w)=>{const p=c?"error":d,{ref:v,isComponentVisible:S,setIsComponentVisible:T}=K(!1),N=x.useRef(null),[E,I]=x.useState("days"),[L,z]=x.useState(new Date),[C,F]=x.useState(new Date);x.useEffect(()=>{a?(z(a),F(a)):(z(new Date),F(new Date))},[a]),x.useEffect(()=>{t&&I(t)},[t]),x.useEffect(()=>{t||I("days")},[S]),x.useEffect(()=>{o||T(!0)},[o]);const G=()=>a?t==="days"?W(L):t==="months"?`${A[L.getMonth()]} ${L.getFullYear()}`:t==="years"?L.getFullYear():W(L):"",B=()=>{if(N.current&&v.current&&o){const y=v.current.getBoundingClientRect(),j=N.current.getBoundingClientRect();window.innerWidth<y.left+j.width?N.current.style.left=`${y.left-j.width+y.width}px`:N.current.style.left=`${y.left}px`,y.top+j.height>window.innerHeight?N.current.style.top=`${y.y-(y.height+j.height-28)}px`:N.current.style.top=`${y.y+y.height}px`}};x.useEffect(()=>{N.current&&v.current&&o&&B()},[N,v,S]),x.useEffect(()=>{const y=w==null?void 0:w.current;return y&&y.addEventListener("scroll",B),window.addEventListener("scroll",B),()=>{y&&y.removeEventListener("scroll",B),window.removeEventListener("scroll",B)}},[]);const U=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:o?"auto":"100%"},ref:o?v:null,children:[o?n.jsx(pn,{value:G(),onClick:()=>T(!0),onChange:()=>{},placeholder:g,disabled:l,size:f,variant:r,status:p,inputMode:"none",clearable:m,onClear:()=>e(void 0)}):null,S?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${f||"md"} ${o?"":"sa-calendar-no-input"} ${M?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,ref:N,children:[n.jsx(gn,{setViews:I,views:E,filter:t,previewDate:C,setPreviewDate:F,isComponentVisible:S}),n.jsx("div",{className:"sa-calendar-body",children:E==="days"?n.jsx(hn,{date:L,setDate:z,previewDate:C,setPreviewDate:F,setIsComponentVisible:T,input:o,minDate:h,maxDate:i,onChange:e,hasValue:a!=null}):E==="months"?n.jsx(fn,{date:L,setDate:z,previewDate:C,setPreviewDate:F,filter:t,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null}):n.jsx(un,{date:L,setDate:z,previewDate:C,setPreviewDate:F,filter:t,setViews:I,onChange:e,minDate:h,maxDate:i,input:o,hasValue:a!=null})})]}):null]});return n.jsx(R,{label:$,labelPosition:b,required:u,optional:s,description:k,helperText:Y,errorText:c,fullWidth:D,children:U})}),vn=x.forwardRef(({value:a,onChange:e,filter:t,input:o=!0,rangedDate:l,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:m,clearable:D,fullWidth:M,withPadding:$,label:b,labelPosition:u,required:s,optional:k,description:Y,helperText:c,errorText:w},p)=>{const v={onChange:e,value:a,input:o,filter:t,disabled:h,minDate:i,maxDate:g,placeholder:f,size:r,variant:d,status:m,clearable:D,fullWidth:M,withPadding:$,label:b,labelPosition:u,required:s,optional:k,description:Y,helperText:c,errorText:w};return n.jsx(n.Fragment,{children:l?n.jsx(cn,{...v,ref:p}):n.jsx(bn,{...v,ref:p})})});V.StarasiaDate=vn,Object.defineProperty(V,Symbol.toStringTag,{value:"Module"})});
|