@starasia/date 5.4.0 → 5.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date.es.js +152 -152
- package/dist/date.umd.js +1 -1
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as z, jsx as a, Fragment as
|
|
2
|
-
import { useState as O, useRef as J, useEffect as A, forwardRef as
|
|
1
|
+
import { jsxs as z, jsx as a, Fragment as tn } from "react/jsx-runtime";
|
|
2
|
+
import { useState as O, useRef as J, useEffect as A, forwardRef as rn, useMemo as G } from "react";
|
|
3
3
|
const X = `@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
|
* {
|
|
@@ -618,15 +618,15 @@ const X = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
618
618
|
"Dec"
|
|
619
619
|
];
|
|
620
620
|
function un(n) {
|
|
621
|
-
const [e,
|
|
622
|
-
|
|
621
|
+
const [e, t] = O(n), r = J(null), o = (d) => {
|
|
622
|
+
r.current && !r.current.contains(d.target) && t(!1);
|
|
623
623
|
};
|
|
624
624
|
return A(() => (document.addEventListener("click", o, !0), () => {
|
|
625
625
|
document.removeEventListener("click", o, !0);
|
|
626
|
-
}), []), { ref:
|
|
626
|
+
}), []), { ref: r, isComponentVisible: e, setIsComponentVisible: t };
|
|
627
627
|
}
|
|
628
628
|
const fn = "sa-calendar-input-styles", Bn = (n) => {
|
|
629
|
-
if (!document.getElementById(fn)) {
|
|
629
|
+
if (!(typeof document > "u") && !document.getElementById(fn)) {
|
|
630
630
|
const e = document.createElement("style");
|
|
631
631
|
e.id = fn, e.textContent = n, document.head.appendChild(e);
|
|
632
632
|
}
|
|
@@ -644,20 +644,20 @@ const U = (n) => {
|
|
|
644
644
|
}, Vn = (n) => {
|
|
645
645
|
const {
|
|
646
646
|
size: e = "sm",
|
|
647
|
-
status:
|
|
648
|
-
variant:
|
|
647
|
+
status: t = "default",
|
|
648
|
+
variant: r = "outline",
|
|
649
649
|
clearable: o,
|
|
650
650
|
onClear: d,
|
|
651
651
|
...l
|
|
652
652
|
} = n, u = J(null), h = () => {
|
|
653
653
|
u.current && l.onClick && (u.current.focus(), l.onClick(""));
|
|
654
|
-
}, s =
|
|
654
|
+
}, s = t === "disable" || l.disabled, c = !!l.value, y = o && c && !s, M = (D) => {
|
|
655
655
|
D.stopPropagation(), d == null || d();
|
|
656
656
|
};
|
|
657
657
|
return /* @__PURE__ */ z(
|
|
658
658
|
"div",
|
|
659
659
|
{
|
|
660
|
-
className: `sa-calendar-input-container sa-calendar-input-${
|
|
660
|
+
className: `sa-calendar-input-container sa-calendar-input-${r} sa-calendar-input-container-${t} ${e} `,
|
|
661
661
|
onClick: h,
|
|
662
662
|
children: [
|
|
663
663
|
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
|
|
@@ -744,8 +744,8 @@ const U = (n) => {
|
|
|
744
744
|
}, Pn = ({
|
|
745
745
|
date: n,
|
|
746
746
|
setDate: e,
|
|
747
|
-
dateRange:
|
|
748
|
-
setDateRange:
|
|
747
|
+
dateRange: t,
|
|
748
|
+
setDateRange: r,
|
|
749
749
|
onChange: o,
|
|
750
750
|
minDate: d,
|
|
751
751
|
maxDate: l,
|
|
@@ -754,7 +754,7 @@ const U = (n) => {
|
|
|
754
754
|
var S, g, k;
|
|
755
755
|
const [h, s] = O(null);
|
|
756
756
|
let c = new Date(n.getFullYear(), n.getMonth(), 1), y = c.getDay(), M = [];
|
|
757
|
-
const D = n.getMonth(), E = (/* @__PURE__ */ new Date()).toDateString(), v = !!(
|
|
757
|
+
const D = n.getMonth(), E = (/* @__PURE__ */ new Date()).toDateString(), v = !!(t.from && !t.to), m = v && h ? h : null;
|
|
758
758
|
for (let f = 0; f < 42; f++) {
|
|
759
759
|
f === 0 && y === 0 ? c.setDate(c.getDate() - 7) : f === 0 ? c.setDate(
|
|
760
760
|
c.getDate() + (f - y)
|
|
@@ -764,7 +764,7 @@ const U = (n) => {
|
|
|
764
764
|
date: new Date(c),
|
|
765
765
|
month: c.getMonth(),
|
|
766
766
|
number: c.getDate(),
|
|
767
|
-
selected: c.toDateString() === ((S =
|
|
767
|
+
selected: c.toDateString() === ((S = t.from) == null ? void 0 : S.toDateString()) || c.toDateString() === (((g = t.to) == null ? void 0 : g.toDateString()) || ((k = t.from) == null ? void 0 : k.toDateString())),
|
|
768
768
|
isToday: c.toDateString() === E,
|
|
769
769
|
year: c.getFullYear(),
|
|
770
770
|
isDisabled: d && c < d || l && c > l
|
|
@@ -774,7 +774,7 @@ const U = (n) => {
|
|
|
774
774
|
const i = (f) => {
|
|
775
775
|
e(f);
|
|
776
776
|
}, C = (f) => {
|
|
777
|
-
let w = { ...
|
|
777
|
+
let w = { ...t };
|
|
778
778
|
if (w.from && w.to)
|
|
779
779
|
w = { from: f, to: null };
|
|
780
780
|
else if (!w.from)
|
|
@@ -783,7 +783,7 @@ const U = (n) => {
|
|
|
783
783
|
const B = w.from.getTime();
|
|
784
784
|
f.getTime() > B ? w = { from: w.from, to: f } : w = { from: f, to: w.from };
|
|
785
785
|
}
|
|
786
|
-
|
|
786
|
+
r(w), o(w);
|
|
787
787
|
};
|
|
788
788
|
return /* @__PURE__ */ z(
|
|
789
789
|
"div",
|
|
@@ -793,10 +793,10 @@ const U = (n) => {
|
|
|
793
793
|
children: [
|
|
794
794
|
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: yn.map((f, w) => /* @__PURE__ */ a("p", { children: f }, w)) }),
|
|
795
795
|
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((f, w) => {
|
|
796
|
-
const B =
|
|
797
|
-
if (!m || !
|
|
796
|
+
const B = t.from && t.to && f.date.getTime() > t.from.getTime() && f.date.getTime() < t.to.getTime(), V = (() => {
|
|
797
|
+
if (!m || !t.from)
|
|
798
798
|
return !1;
|
|
799
|
-
const $ = f.date.getTime(), x =
|
|
799
|
+
const $ = f.date.getTime(), x = t.from.getTime(), I = m.getTime();
|
|
800
800
|
return I > x ? $ > x && $ < I : $ < x && $ > I;
|
|
801
801
|
})(), L = v && h && f.date.toDateString() === h.toDateString(), F = f.isDisabled, T = () => B || V ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", b = () => F ? "var(--sa-color-gray-400, #b7b9be)" : B || V ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
802
802
|
return /* @__PURE__ */ a(
|
|
@@ -828,8 +828,8 @@ const U = (n) => {
|
|
|
828
828
|
}, jn = ({
|
|
829
829
|
date: n,
|
|
830
830
|
setDate: e,
|
|
831
|
-
filter:
|
|
832
|
-
setViews:
|
|
831
|
+
filter: t,
|
|
832
|
+
setViews: r,
|
|
833
833
|
dateRange: o,
|
|
834
834
|
setDateRange: d,
|
|
835
835
|
onChange: l,
|
|
@@ -839,7 +839,7 @@ const U = (n) => {
|
|
|
839
839
|
}) => {
|
|
840
840
|
var E;
|
|
841
841
|
const c = (E = o.from) == null ? void 0 : E.getFullYear(), y = n.getFullYear(), M = (v) => {
|
|
842
|
-
|
|
842
|
+
t ? (D(v), e(v)) : (r("days"), e(v));
|
|
843
843
|
}, D = (v) => {
|
|
844
844
|
let m = { ...o };
|
|
845
845
|
if (m.from && m.to)
|
|
@@ -875,13 +875,13 @@ const U = (n) => {
|
|
|
875
875
|
);
|
|
876
876
|
}) });
|
|
877
877
|
}, dn = (n) => {
|
|
878
|
-
const e = Math.floor(n / 10) * 10,
|
|
879
|
-
return { start: e, end:
|
|
878
|
+
const e = Math.floor(n / 10) * 10, t = e + 10;
|
|
879
|
+
return { start: e, end: t };
|
|
880
880
|
}, An = ({
|
|
881
881
|
date: n,
|
|
882
882
|
filter: e,
|
|
883
|
-
setViews:
|
|
884
|
-
setDate:
|
|
883
|
+
setViews: t,
|
|
884
|
+
setDate: r,
|
|
885
885
|
dateRange: o,
|
|
886
886
|
setDateRange: d,
|
|
887
887
|
onChange: l,
|
|
@@ -902,7 +902,7 @@ const U = (n) => {
|
|
|
902
902
|
});
|
|
903
903
|
}
|
|
904
904
|
const m = (g) => {
|
|
905
|
-
e ? (i(g),
|
|
905
|
+
e ? (i(g), r(g)) : (r(g), t("months"));
|
|
906
906
|
}, i = (g) => {
|
|
907
907
|
let k = { ...o };
|
|
908
908
|
if (k.from && k.to)
|
|
@@ -976,12 +976,12 @@ const U = (n) => {
|
|
|
976
976
|
), Rn = ({
|
|
977
977
|
setViews: n,
|
|
978
978
|
views: e,
|
|
979
|
-
filter:
|
|
980
|
-
date:
|
|
979
|
+
filter: t,
|
|
980
|
+
date: r,
|
|
981
981
|
setDate: o
|
|
982
982
|
}) => {
|
|
983
983
|
const d = () => {
|
|
984
|
-
|
|
984
|
+
t || n((s) => s === "days" ? "months" : s === "months" ? "years" : "days");
|
|
985
985
|
}, l = () => {
|
|
986
986
|
if (e === "years") {
|
|
987
987
|
o((s) => new Date(s.getFullYear() + 10, 0));
|
|
@@ -1011,11 +1011,11 @@ const U = (n) => {
|
|
|
1011
1011
|
return /* @__PURE__ */ z("div", { className: "sa-calendar-header", children: [
|
|
1012
1012
|
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
|
|
1013
1013
|
if (e === "days")
|
|
1014
|
-
return `${q[
|
|
1014
|
+
return `${q[r.getMonth()]} ${r.getFullYear()}`;
|
|
1015
1015
|
if (e === "months")
|
|
1016
|
-
return `${
|
|
1016
|
+
return `${r.getFullYear()}`;
|
|
1017
1017
|
if (e === "years")
|
|
1018
|
-
return `${dn(
|
|
1018
|
+
return `${dn(r.getFullYear()).start} ~ ${dn(r.getFullYear()).end}`;
|
|
1019
1019
|
})() }),
|
|
1020
1020
|
/* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
|
|
1021
1021
|
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: u, children: /* @__PURE__ */ a(wn, {}) }),
|
|
@@ -1024,14 +1024,14 @@ const U = (n) => {
|
|
|
1024
1024
|
] });
|
|
1025
1025
|
};
|
|
1026
1026
|
function K(n) {
|
|
1027
|
-
const e = new Date(n),
|
|
1028
|
-
return `${e.getDate().toString().padStart(2, "0")} ${Tn[
|
|
1027
|
+
const e = new Date(n), t = e.getFullYear(), r = e.getMonth();
|
|
1028
|
+
return `${e.getDate().toString().padStart(2, "0")} ${Tn[r]} ${t}`;
|
|
1029
1029
|
}
|
|
1030
1030
|
const pn = ({
|
|
1031
1031
|
label: n,
|
|
1032
1032
|
labelPosition: e = "outside-top",
|
|
1033
|
-
required:
|
|
1034
|
-
optional:
|
|
1033
|
+
required: t,
|
|
1034
|
+
optional: r,
|
|
1035
1035
|
description: o,
|
|
1036
1036
|
helperText: d,
|
|
1037
1037
|
errorText: l,
|
|
@@ -1045,9 +1045,9 @@ const pn = ({
|
|
|
1045
1045
|
u ? "sa-date-field-fullwidth" : ""
|
|
1046
1046
|
].filter(Boolean).join(" "), y = n ? /* @__PURE__ */ z("div", { className: "sa-date-field-label-row", children: [
|
|
1047
1047
|
/* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: n }),
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
] }) : null, M = /* @__PURE__ */ z(
|
|
1048
|
+
r && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
|
|
1049
|
+
t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
|
|
1050
|
+
] }) : null, M = /* @__PURE__ */ z(tn, { children: [
|
|
1051
1051
|
d && !l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: d }),
|
|
1052
1052
|
l && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: l })
|
|
1053
1053
|
] });
|
|
@@ -1071,18 +1071,18 @@ const pn = ({
|
|
|
1071
1071
|
M
|
|
1072
1072
|
] });
|
|
1073
1073
|
}, gn = "sa-calendar-styles", Hn = (n) => {
|
|
1074
|
-
if (!document.getElementById(gn)) {
|
|
1074
|
+
if (!(typeof document > "u") && !document.getElementById(gn)) {
|
|
1075
1075
|
const e = document.createElement("style");
|
|
1076
1076
|
e.id = gn, e.textContent = n, document.head.appendChild(e);
|
|
1077
1077
|
}
|
|
1078
1078
|
};
|
|
1079
1079
|
Hn(X);
|
|
1080
|
-
const Wn =
|
|
1080
|
+
const Wn = rn(
|
|
1081
1081
|
({
|
|
1082
1082
|
value: n,
|
|
1083
1083
|
onChange: e,
|
|
1084
|
-
filter:
|
|
1085
|
-
input:
|
|
1084
|
+
filter: t,
|
|
1085
|
+
input: r = !0,
|
|
1086
1086
|
disabled: o,
|
|
1087
1087
|
minDate: d,
|
|
1088
1088
|
maxDate: l,
|
|
@@ -1112,17 +1112,17 @@ const Wn = tn(
|
|
|
1112
1112
|
} else
|
|
1113
1113
|
$(/* @__PURE__ */ new Date()), I({ from: null, to: null });
|
|
1114
1114
|
}, [n]), A(() => {
|
|
1115
|
-
|
|
1116
|
-
}, [
|
|
1117
|
-
|
|
1115
|
+
t && T(t);
|
|
1116
|
+
}, [t]), A(() => {
|
|
1117
|
+
t || T("days");
|
|
1118
1118
|
}, [B]), A(() => {
|
|
1119
|
-
|
|
1120
|
-
}, [
|
|
1119
|
+
r || V(!0);
|
|
1120
|
+
}, [r]);
|
|
1121
1121
|
const H = () => {
|
|
1122
1122
|
var N, j;
|
|
1123
1123
|
if (!n)
|
|
1124
1124
|
return "";
|
|
1125
|
-
if (
|
|
1125
|
+
if (t) {
|
|
1126
1126
|
if (F === "days")
|
|
1127
1127
|
return `${K(x.from)} ~ ${K(x.to || x.from) || "-"}`;
|
|
1128
1128
|
if (F === "months")
|
|
@@ -1132,13 +1132,13 @@ const Wn = tn(
|
|
|
1132
1132
|
} else
|
|
1133
1133
|
return `${K(x.from)} ~ ${K(x.to || x.from) || "-"}`;
|
|
1134
1134
|
}, P = () => {
|
|
1135
|
-
if (L.current && w.current &&
|
|
1135
|
+
if (L.current && w.current && r) {
|
|
1136
1136
|
const N = w.current.getBoundingClientRect(), j = L.current.getBoundingClientRect();
|
|
1137
1137
|
window.innerWidth < N.left + j.width ? L.current.style.left = `${N.left - j.width + N.width}px` : L.current.style.left = `${N.left}px`, N.top + j.height > window.innerHeight ? L.current.style.top = `${N.y - (N.height + j.height - 28)}px` : L.current.style.top = `${N.y + N.height}px`;
|
|
1138
1138
|
}
|
|
1139
1139
|
};
|
|
1140
1140
|
A(() => {
|
|
1141
|
-
L.current && w.current &&
|
|
1141
|
+
L.current && w.current && r && P();
|
|
1142
1142
|
}, [L, w, B]), A(() => (window.addEventListener("scroll", P, !0), window.addEventListener("resize", P), () => {
|
|
1143
1143
|
window.removeEventListener("scroll", P, !0), window.removeEventListener("resize", P);
|
|
1144
1144
|
}), []);
|
|
@@ -1146,10 +1146,10 @@ const Wn = tn(
|
|
|
1146
1146
|
"div",
|
|
1147
1147
|
{
|
|
1148
1148
|
className: "sa-calendar-wrapper",
|
|
1149
|
-
style: { height:
|
|
1150
|
-
ref:
|
|
1149
|
+
style: { height: r ? "auto" : "100%" },
|
|
1150
|
+
ref: r ? w : null,
|
|
1151
1151
|
children: [
|
|
1152
|
-
|
|
1152
|
+
r ? /* @__PURE__ */ a(
|
|
1153
1153
|
Vn,
|
|
1154
1154
|
{
|
|
1155
1155
|
value: H(),
|
|
@@ -1171,7 +1171,7 @@ const Wn = tn(
|
|
|
1171
1171
|
B ? /* @__PURE__ */ z(
|
|
1172
1172
|
"div",
|
|
1173
1173
|
{
|
|
1174
|
-
className: `sa-calendar sa-calendar-size-${h || "sm"} ${
|
|
1174
|
+
className: `sa-calendar sa-calendar-size-${h || "sm"} ${r ? "" : "sa-calendar-no-input"} ${D ? "" : "sa-calendar-no-padding"}`,
|
|
1175
1175
|
style: o ? { pointerEvents: "none" } : void 0,
|
|
1176
1176
|
ref: L,
|
|
1177
1177
|
children: [
|
|
@@ -1180,7 +1180,7 @@ const Wn = tn(
|
|
|
1180
1180
|
{
|
|
1181
1181
|
setViews: T,
|
|
1182
1182
|
views: F,
|
|
1183
|
-
filter:
|
|
1183
|
+
filter: t,
|
|
1184
1184
|
date: b,
|
|
1185
1185
|
setDate: $
|
|
1186
1186
|
}
|
|
@@ -1193,7 +1193,7 @@ const Wn = tn(
|
|
|
1193
1193
|
setIsComponentVisible: V,
|
|
1194
1194
|
dateRange: x,
|
|
1195
1195
|
setDateRange: I,
|
|
1196
|
-
input:
|
|
1196
|
+
input: r,
|
|
1197
1197
|
onChange: e,
|
|
1198
1198
|
minDate: d,
|
|
1199
1199
|
maxDate: l
|
|
@@ -1203,12 +1203,12 @@ const Wn = tn(
|
|
|
1203
1203
|
{
|
|
1204
1204
|
date: b,
|
|
1205
1205
|
setDate: $,
|
|
1206
|
-
filter:
|
|
1206
|
+
filter: t,
|
|
1207
1207
|
setViews: T,
|
|
1208
1208
|
dateRange: x,
|
|
1209
1209
|
setDateRange: I,
|
|
1210
1210
|
setIsComponentVisible: V,
|
|
1211
|
-
input:
|
|
1211
|
+
input: r,
|
|
1212
1212
|
onChange: e,
|
|
1213
1213
|
minDate: d,
|
|
1214
1214
|
maxDate: l
|
|
@@ -1218,12 +1218,12 @@ const Wn = tn(
|
|
|
1218
1218
|
{
|
|
1219
1219
|
date: b,
|
|
1220
1220
|
setDate: $,
|
|
1221
|
-
filter:
|
|
1221
|
+
filter: t,
|
|
1222
1222
|
setViews: T,
|
|
1223
1223
|
dateRange: x,
|
|
1224
1224
|
setDateRange: I,
|
|
1225
1225
|
setIsComponentVisible: V,
|
|
1226
|
-
input:
|
|
1226
|
+
input: r,
|
|
1227
1227
|
onChange: e,
|
|
1228
1228
|
minDate: d,
|
|
1229
1229
|
maxDate: l
|
|
@@ -1252,7 +1252,7 @@ const Wn = tn(
|
|
|
1252
1252
|
);
|
|
1253
1253
|
}
|
|
1254
1254
|
), mn = "sa-calendar-input-styles", On = (n) => {
|
|
1255
|
-
if (!document.getElementById(mn)) {
|
|
1255
|
+
if (!(typeof document > "u") && !document.getElementById(mn)) {
|
|
1256
1256
|
const e = document.createElement("style");
|
|
1257
1257
|
e.id = mn, e.textContent = n, document.head.appendChild(e);
|
|
1258
1258
|
}
|
|
@@ -1270,20 +1270,20 @@ const Z = (n) => {
|
|
|
1270
1270
|
}, Jn = (n) => {
|
|
1271
1271
|
const {
|
|
1272
1272
|
size: e = "sm",
|
|
1273
|
-
status:
|
|
1274
|
-
variant:
|
|
1273
|
+
status: t = "default",
|
|
1274
|
+
variant: r = "outline",
|
|
1275
1275
|
clearable: o,
|
|
1276
1276
|
onClear: d,
|
|
1277
1277
|
...l
|
|
1278
1278
|
} = n, u = J(null), h = () => {
|
|
1279
1279
|
u.current && l.onClick && (u.current.focus(), l.onClick(""));
|
|
1280
|
-
}, s =
|
|
1280
|
+
}, s = t === "disable" || l.disabled, c = !!l.value, y = o && c && !s, M = (D) => {
|
|
1281
1281
|
D.stopPropagation(), d == null || d();
|
|
1282
1282
|
};
|
|
1283
1283
|
return /* @__PURE__ */ z(
|
|
1284
1284
|
"div",
|
|
1285
1285
|
{
|
|
1286
|
-
className: `sa-calendar-input-container sa-calendar-input-${
|
|
1286
|
+
className: `sa-calendar-input-container sa-calendar-input-${r} sa-calendar-input-container-${t} ${e} `,
|
|
1287
1287
|
onClick: h,
|
|
1288
1288
|
children: [
|
|
1289
1289
|
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
|
|
@@ -1370,8 +1370,8 @@ const Z = (n) => {
|
|
|
1370
1370
|
}, qn = ({
|
|
1371
1371
|
date: n,
|
|
1372
1372
|
setDate: e,
|
|
1373
|
-
previewDate:
|
|
1374
|
-
setPreviewDate:
|
|
1373
|
+
previewDate: t,
|
|
1374
|
+
setPreviewDate: r,
|
|
1375
1375
|
setIsComponentVisible: o,
|
|
1376
1376
|
minDate: d,
|
|
1377
1377
|
maxDate: l,
|
|
@@ -1380,11 +1380,11 @@ const Z = (n) => {
|
|
|
1380
1380
|
hasValue: s
|
|
1381
1381
|
}) => {
|
|
1382
1382
|
let c = new Date(
|
|
1383
|
-
|
|
1384
|
-
|
|
1383
|
+
t.getFullYear(),
|
|
1384
|
+
t.getMonth(),
|
|
1385
1385
|
1
|
|
1386
1386
|
), y = c.getDay(), M = [];
|
|
1387
|
-
const D = n.toDateString(), E = (/* @__PURE__ */ new Date()).toDateString(), v =
|
|
1387
|
+
const D = n.toDateString(), E = (/* @__PURE__ */ new Date()).toDateString(), v = t.getMonth();
|
|
1388
1388
|
for (let i = 0; i < 42; i++) {
|
|
1389
1389
|
i === 0 && y === 0 ? c.setDate(c.getDate() - 7) : i === 0 ? c.setDate(
|
|
1390
1390
|
c.getDate() + (i - y)
|
|
@@ -1402,7 +1402,7 @@ const Z = (n) => {
|
|
|
1402
1402
|
M.push(C);
|
|
1403
1403
|
}
|
|
1404
1404
|
const m = (i) => {
|
|
1405
|
-
(!d || i >= d) && (!l || i <= l) && (e(i), h(i),
|
|
1405
|
+
(!d || i >= d) && (!l || i <= l) && (e(i), h(i), r(i), u && o(!1));
|
|
1406
1406
|
};
|
|
1407
1407
|
return /* @__PURE__ */ z("div", { className: "sa-calendar-days-preivew", children: [
|
|
1408
1408
|
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: yn.map((i, C) => /* @__PURE__ */ a("p", { children: i }, C)) }),
|
|
@@ -1430,8 +1430,8 @@ const Z = (n) => {
|
|
|
1430
1430
|
}, Gn = ({
|
|
1431
1431
|
date: n,
|
|
1432
1432
|
setDate: e,
|
|
1433
|
-
filter:
|
|
1434
|
-
setViews:
|
|
1433
|
+
filter: t,
|
|
1434
|
+
setViews: r,
|
|
1435
1435
|
onChange: o,
|
|
1436
1436
|
previewDate: d,
|
|
1437
1437
|
setPreviewDate: l,
|
|
@@ -1441,7 +1441,7 @@ const Z = (n) => {
|
|
|
1441
1441
|
hasValue: c
|
|
1442
1442
|
}) => {
|
|
1443
1443
|
const y = n.getMonth(), M = n.getFullYear(), D = d.getFullYear(), E = (v) => {
|
|
1444
|
-
(!u || v >= u) && (!h || v <= h) && (
|
|
1444
|
+
(!u || v >= u) && (!h || v <= h) && (t ? (o(v), e(v), l(v)) : (r("days"), l(v)));
|
|
1445
1445
|
};
|
|
1446
1446
|
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: q.map((v, m) => {
|
|
1447
1447
|
const i = u && new Date(D, m, 1) < u || h && new Date(D, m + 1, 0) > h;
|
|
@@ -1464,13 +1464,13 @@ const Z = (n) => {
|
|
|
1464
1464
|
);
|
|
1465
1465
|
}) });
|
|
1466
1466
|
}, cn = (n) => {
|
|
1467
|
-
const e = Math.floor(n / 10) * 10,
|
|
1468
|
-
return { start: e, end:
|
|
1467
|
+
const e = Math.floor(n / 10) * 10, t = e + 10;
|
|
1468
|
+
return { start: e, end: t };
|
|
1469
1469
|
}, Un = ({
|
|
1470
1470
|
date: n,
|
|
1471
1471
|
filter: e,
|
|
1472
|
-
setViews:
|
|
1473
|
-
setDate:
|
|
1472
|
+
setViews: t,
|
|
1473
|
+
setDate: r,
|
|
1474
1474
|
onChange: o,
|
|
1475
1475
|
previewDate: d,
|
|
1476
1476
|
setPreviewDate: l,
|
|
@@ -1490,7 +1490,7 @@ const Z = (n) => {
|
|
|
1490
1490
|
});
|
|
1491
1491
|
}
|
|
1492
1492
|
const m = (i) => {
|
|
1493
|
-
(!u || i >= u) && (!h || i <= h) && (e ? (o(i),
|
|
1493
|
+
(!u || i >= u) && (!h || i <= h) && (e ? (o(i), r(i), l(i)) : (t("months"), l(i)));
|
|
1494
1494
|
};
|
|
1495
1495
|
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: y.map((i, C) => /* @__PURE__ */ a(
|
|
1496
1496
|
"p",
|
|
@@ -1512,12 +1512,12 @@ const Z = (n) => {
|
|
|
1512
1512
|
}, Zn = ({
|
|
1513
1513
|
setViews: n,
|
|
1514
1514
|
views: e,
|
|
1515
|
-
filter:
|
|
1516
|
-
previewDate:
|
|
1515
|
+
filter: t,
|
|
1516
|
+
previewDate: r,
|
|
1517
1517
|
setPreviewDate: o
|
|
1518
1518
|
}) => {
|
|
1519
1519
|
const d = () => {
|
|
1520
|
-
|
|
1520
|
+
t || n((s) => s === "days" ? "months" : s === "months" ? "years" : "days");
|
|
1521
1521
|
}, l = () => {
|
|
1522
1522
|
if (e === "years") {
|
|
1523
1523
|
o((s) => new Date(s.getFullYear() + 10, 0));
|
|
@@ -1551,11 +1551,11 @@ const Z = (n) => {
|
|
|
1551
1551
|
return /* @__PURE__ */ z("div", { className: "sa-calendar-header", children: [
|
|
1552
1552
|
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
|
|
1553
1553
|
if (e === "days")
|
|
1554
|
-
return `${q[
|
|
1554
|
+
return `${q[r.getMonth()]} ${r.getFullYear()}`;
|
|
1555
1555
|
if (e === "months")
|
|
1556
|
-
return `${
|
|
1556
|
+
return `${r.getFullYear()}`;
|
|
1557
1557
|
if (e === "years")
|
|
1558
|
-
return `${cn(
|
|
1558
|
+
return `${cn(r.getFullYear()).start} ~ ${cn(r.getFullYear()).end}`;
|
|
1559
1559
|
})() }),
|
|
1560
1560
|
/* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
|
|
1561
1561
|
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: u, children: /* @__PURE__ */ a(wn, {}) }),
|
|
@@ -1563,18 +1563,18 @@ const Z = (n) => {
|
|
|
1563
1563
|
] })
|
|
1564
1564
|
] });
|
|
1565
1565
|
}, bn = "sa-calendar-styles", Kn = (n) => {
|
|
1566
|
-
if (!document.getElementById(bn)) {
|
|
1566
|
+
if (!(typeof document > "u") && !document.getElementById(bn)) {
|
|
1567
1567
|
const e = document.createElement("style");
|
|
1568
1568
|
e.id = bn, e.textContent = n, document.head.appendChild(e);
|
|
1569
1569
|
}
|
|
1570
1570
|
};
|
|
1571
1571
|
Kn(X);
|
|
1572
|
-
const _n =
|
|
1572
|
+
const _n = rn(
|
|
1573
1573
|
({
|
|
1574
1574
|
value: n,
|
|
1575
1575
|
onChange: e,
|
|
1576
|
-
filter:
|
|
1577
|
-
input:
|
|
1576
|
+
filter: t,
|
|
1577
|
+
input: r = !0,
|
|
1578
1578
|
disabled: o,
|
|
1579
1579
|
minDate: d,
|
|
1580
1580
|
maxDate: l,
|
|
@@ -1597,20 +1597,20 @@ const _n = tn(
|
|
|
1597
1597
|
A(() => {
|
|
1598
1598
|
n ? ($(n), I(n)) : ($(/* @__PURE__ */ new Date()), I(/* @__PURE__ */ new Date()));
|
|
1599
1599
|
}, [n]), A(() => {
|
|
1600
|
-
|
|
1601
|
-
}, [
|
|
1602
|
-
|
|
1600
|
+
t && T(t);
|
|
1601
|
+
}, [t]), A(() => {
|
|
1602
|
+
t || T("days");
|
|
1603
1603
|
}, [B]), A(() => {
|
|
1604
|
-
|
|
1605
|
-
}, [
|
|
1606
|
-
const H = () => n ?
|
|
1607
|
-
if (L.current && w.current &&
|
|
1604
|
+
r || V(!0);
|
|
1605
|
+
}, [r]);
|
|
1606
|
+
const H = () => n ? t === "days" ? K(b) : t === "months" ? `${q[b.getMonth()]} ${b.getFullYear()}` : t === "years" ? b.getFullYear() : K(b) : "", P = () => {
|
|
1607
|
+
if (L.current && w.current && r) {
|
|
1608
1608
|
const N = w.current.getBoundingClientRect(), j = L.current.getBoundingClientRect();
|
|
1609
1609
|
window.innerWidth < N.left + j.width ? L.current.style.left = `${N.left - j.width + N.width}px` : L.current.style.left = `${N.left}px`, N.top + j.height > window.innerHeight ? L.current.style.top = `${N.y - (N.height + j.height - 28)}px` : L.current.style.top = `${N.y + N.height}px`;
|
|
1610
1610
|
}
|
|
1611
1611
|
};
|
|
1612
1612
|
A(() => {
|
|
1613
|
-
L.current && w.current &&
|
|
1613
|
+
L.current && w.current && r && P();
|
|
1614
1614
|
}, [L, w, B]), A(() => (window.addEventListener("scroll", P, !0), window.addEventListener("resize", P), () => {
|
|
1615
1615
|
window.removeEventListener("scroll", P, !0), window.removeEventListener("resize", P);
|
|
1616
1616
|
}), []);
|
|
@@ -1618,10 +1618,10 @@ const _n = tn(
|
|
|
1618
1618
|
"div",
|
|
1619
1619
|
{
|
|
1620
1620
|
className: "sa-calendar-wrapper",
|
|
1621
|
-
style: { height:
|
|
1622
|
-
ref:
|
|
1621
|
+
style: { height: r ? "auto" : "100%" },
|
|
1622
|
+
ref: r ? w : null,
|
|
1623
1623
|
children: [
|
|
1624
|
-
|
|
1624
|
+
r ? /* @__PURE__ */ a(
|
|
1625
1625
|
Jn,
|
|
1626
1626
|
{
|
|
1627
1627
|
value: H(),
|
|
@@ -1641,7 +1641,7 @@ const _n = tn(
|
|
|
1641
1641
|
B ? /* @__PURE__ */ z(
|
|
1642
1642
|
"div",
|
|
1643
1643
|
{
|
|
1644
|
-
className: `sa-calendar sa-calendar-size-${h || "sm"} ${
|
|
1644
|
+
className: `sa-calendar sa-calendar-size-${h || "sm"} ${r ? "" : "sa-calendar-no-input"} ${D ? "" : "sa-calendar-no-padding"}`,
|
|
1645
1645
|
style: o ? { pointerEvents: "none" } : void 0,
|
|
1646
1646
|
ref: L,
|
|
1647
1647
|
children: [
|
|
@@ -1650,7 +1650,7 @@ const _n = tn(
|
|
|
1650
1650
|
{
|
|
1651
1651
|
setViews: T,
|
|
1652
1652
|
views: F,
|
|
1653
|
-
filter:
|
|
1653
|
+
filter: t,
|
|
1654
1654
|
previewDate: x,
|
|
1655
1655
|
setPreviewDate: I,
|
|
1656
1656
|
isComponentVisible: B
|
|
@@ -1664,7 +1664,7 @@ const _n = tn(
|
|
|
1664
1664
|
previewDate: x,
|
|
1665
1665
|
setPreviewDate: I,
|
|
1666
1666
|
setIsComponentVisible: V,
|
|
1667
|
-
input:
|
|
1667
|
+
input: r,
|
|
1668
1668
|
minDate: d,
|
|
1669
1669
|
maxDate: l,
|
|
1670
1670
|
onChange: e,
|
|
@@ -1677,12 +1677,12 @@ const _n = tn(
|
|
|
1677
1677
|
setDate: $,
|
|
1678
1678
|
previewDate: x,
|
|
1679
1679
|
setPreviewDate: I,
|
|
1680
|
-
filter:
|
|
1680
|
+
filter: t,
|
|
1681
1681
|
setViews: T,
|
|
1682
1682
|
onChange: e,
|
|
1683
1683
|
minDate: d,
|
|
1684
1684
|
maxDate: l,
|
|
1685
|
-
input:
|
|
1685
|
+
input: r,
|
|
1686
1686
|
hasValue: n != null
|
|
1687
1687
|
}
|
|
1688
1688
|
) : /* @__PURE__ */ a(
|
|
@@ -1692,12 +1692,12 @@ const _n = tn(
|
|
|
1692
1692
|
setDate: $,
|
|
1693
1693
|
previewDate: x,
|
|
1694
1694
|
setPreviewDate: I,
|
|
1695
|
-
filter:
|
|
1695
|
+
filter: t,
|
|
1696
1696
|
setViews: T,
|
|
1697
1697
|
onChange: e,
|
|
1698
1698
|
minDate: d,
|
|
1699
1699
|
maxDate: l,
|
|
1700
|
-
input:
|
|
1700
|
+
input: r,
|
|
1701
1701
|
hasValue: n != null
|
|
1702
1702
|
}
|
|
1703
1703
|
) })
|
|
@@ -1723,12 +1723,12 @@ const _n = tn(
|
|
|
1723
1723
|
}
|
|
1724
1724
|
);
|
|
1725
1725
|
}
|
|
1726
|
-
), le =
|
|
1726
|
+
), le = rn(
|
|
1727
1727
|
({
|
|
1728
1728
|
value: n,
|
|
1729
1729
|
onChange: e,
|
|
1730
|
-
filter:
|
|
1731
|
-
input:
|
|
1730
|
+
filter: t,
|
|
1731
|
+
input: r = !0,
|
|
1732
1732
|
rangedDate: o,
|
|
1733
1733
|
disabled: d,
|
|
1734
1734
|
minDate: l,
|
|
@@ -1751,8 +1751,8 @@ const _n = tn(
|
|
|
1751
1751
|
const w = {
|
|
1752
1752
|
onChange: e,
|
|
1753
1753
|
value: n,
|
|
1754
|
-
input:
|
|
1755
|
-
filter:
|
|
1754
|
+
input: r,
|
|
1755
|
+
filter: t,
|
|
1756
1756
|
disabled: d,
|
|
1757
1757
|
minDate: l,
|
|
1758
1758
|
maxDate: u,
|
|
@@ -1771,7 +1771,7 @@ const _n = tn(
|
|
|
1771
1771
|
helperText: g,
|
|
1772
1772
|
errorText: k
|
|
1773
1773
|
};
|
|
1774
|
-
return /* @__PURE__ */ a(
|
|
1774
|
+
return /* @__PURE__ */ a(tn, { children: o ? /* @__PURE__ */ a(Wn, { ...w, ref: f }) : /* @__PURE__ */ a(_n, { ...w, ref: f }) });
|
|
1775
1775
|
}
|
|
1776
1776
|
), Qn = `/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
1777
1777
|
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
@@ -1904,42 +1904,42 @@ const _n = tn(
|
|
|
1904
1904
|
.sa-time-input-wrap {
|
|
1905
1905
|
width: 100%;
|
|
1906
1906
|
}
|
|
1907
|
-
`, on = (n, e,
|
|
1907
|
+
`, on = (n, e, t) => Math.min(t, Math.max(e, n)), R = (n) => String(n).padStart(2, "0"), ln = (n) => {
|
|
1908
1908
|
if (!n)
|
|
1909
1909
|
return null;
|
|
1910
1910
|
const e = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(n.trim());
|
|
1911
1911
|
if (!e)
|
|
1912
1912
|
return null;
|
|
1913
|
-
const
|
|
1914
|
-
return
|
|
1915
|
-
}, Xn = (n, e) => e ? `${R(n.h)}:${R(n.m)}:${R(n.s)}` : `${R(n.h)}:${R(n.m)}`, W = (n) => n.h * 60 + n.m, ne = (n, e,
|
|
1916
|
-
const
|
|
1913
|
+
const t = Number(e[1]), r = Number(e[2]), o = e[3] != null ? Number(e[3]) : 0;
|
|
1914
|
+
return t > 23 || r > 59 || o > 59 ? null : { h: t, m: r, s: o };
|
|
1915
|
+
}, Xn = (n, e) => e ? `${R(n.h)}:${R(n.m)}:${R(n.s)}` : `${R(n.h)}:${R(n.m)}`, W = (n) => n.h * 60 + n.m, ne = (n, e, t) => {
|
|
1916
|
+
const r = t ? `:${R(n.s)}` : "";
|
|
1917
1917
|
if (e === "12h") {
|
|
1918
1918
|
const o = n.h >= 12 ? "PM" : "AM", d = n.h % 12 === 0 ? 12 : n.h % 12;
|
|
1919
|
-
return `${R(d)}:${R(n.m)}${
|
|
1919
|
+
return `${R(d)}:${R(n.m)}${r} ${o}`;
|
|
1920
1920
|
}
|
|
1921
|
-
return `${R(n.h)}:${R(n.m)}${
|
|
1922
|
-
}, ee = (n, e,
|
|
1923
|
-
const
|
|
1921
|
+
return `${R(n.h)}:${R(n.m)}${r}`;
|
|
1922
|
+
}, ee = (n, e, t) => {
|
|
1923
|
+
const r = n.toLowerCase(), o = /p/.test(r) ? "pm" : /a/.test(r) ? "am" : null, d = r.replace(/[^\d]/g, "");
|
|
1924
1924
|
if (!d)
|
|
1925
1925
|
return null;
|
|
1926
1926
|
let l = 0, u = 0, h = 0;
|
|
1927
1927
|
if (n.includes(":")) {
|
|
1928
1928
|
const s = n.split(":").map((c) => c.replace(/[^\d]/g, ""));
|
|
1929
|
-
l = Number(s[0] || 0), u = Number(s[1] || 0), h =
|
|
1929
|
+
l = Number(s[0] || 0), u = Number(s[1] || 0), h = t ? Number(s[2] || 0) : 0;
|
|
1930
1930
|
} else
|
|
1931
|
-
d.length <= 2 ? l = Number(d) : d.length <= 4 ? (l = Number(d.slice(0, d.length - 2)), u = Number(d.slice(-2))) : (l = Number(d.slice(0, d.length - 4)), u = Number(d.slice(-4, -2)), h =
|
|
1931
|
+
d.length <= 2 ? l = Number(d) : d.length <= 4 ? (l = Number(d.slice(0, d.length - 2)), u = Number(d.slice(-2))) : (l = Number(d.slice(0, d.length - 4)), u = Number(d.slice(-4, -2)), h = t ? Number(d.slice(-2)) : 0);
|
|
1932
1932
|
return o && (o === "pm" && l < 12 && (l += 12), o === "am" && l === 12 && (l = 0)), l > 23 || u > 59 || h > 59 ? null : { h: on(l, 0, 23), m: on(u, 0, 59), s: on(h, 0, 59) };
|
|
1933
1933
|
}, en = (n, e = 1) => {
|
|
1934
|
-
const
|
|
1935
|
-
for (let
|
|
1936
|
-
|
|
1937
|
-
return
|
|
1934
|
+
const t = [];
|
|
1935
|
+
for (let r = 0; r < n; r += e)
|
|
1936
|
+
t.push(r);
|
|
1937
|
+
return t;
|
|
1938
1938
|
}, kn = (n, e) => {
|
|
1939
1939
|
if (typeof document > "u" || document.getElementById(n))
|
|
1940
1940
|
return;
|
|
1941
|
-
const
|
|
1942
|
-
|
|
1941
|
+
const t = document.createElement("style");
|
|
1942
|
+
t.id = n, t.textContent = e, document.head.appendChild(t);
|
|
1943
1943
|
};
|
|
1944
1944
|
kn("sa-calendar-styles", X);
|
|
1945
1945
|
kn("sa-time-styles", Qn);
|
|
@@ -1952,7 +1952,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
1952
1952
|
strokeLinecap: "round",
|
|
1953
1953
|
strokeLinejoin: "round"
|
|
1954
1954
|
}
|
|
1955
|
-
) }),
|
|
1955
|
+
) }), te = ({ s: n }) => /* @__PURE__ */ a("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ a(
|
|
1956
1956
|
"path",
|
|
1957
1957
|
{
|
|
1958
1958
|
d: "M5 5l10 10M15 5L5 15",
|
|
@@ -1960,15 +1960,15 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
1960
1960
|
strokeWidth: "1.5",
|
|
1961
1961
|
strokeLinecap: "round"
|
|
1962
1962
|
}
|
|
1963
|
-
) }), an = ({ label: n, options: e, active:
|
|
1963
|
+
) }), an = ({ label: n, options: e, active: t, onPick: r }) => {
|
|
1964
1964
|
const o = J(null), d = J(null);
|
|
1965
1965
|
return A(() => {
|
|
1966
1966
|
var l;
|
|
1967
1967
|
(l = d.current) == null || l.scrollIntoView({ block: "nearest" });
|
|
1968
|
-
}, [
|
|
1968
|
+
}, [t]), /* @__PURE__ */ z("div", { className: "sa-time-col", children: [
|
|
1969
1969
|
/* @__PURE__ */ a("div", { className: "sa-time-col-head", children: n }),
|
|
1970
1970
|
/* @__PURE__ */ a("div", { className: "sa-time-col-list", ref: o, children: e.map((l) => {
|
|
1971
|
-
const u = l.value ===
|
|
1971
|
+
const u = l.value === t;
|
|
1972
1972
|
return /* @__PURE__ */ a(
|
|
1973
1973
|
"button",
|
|
1974
1974
|
{
|
|
@@ -1976,19 +1976,19 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
1976
1976
|
ref: u ? d : null,
|
|
1977
1977
|
disabled: l.disabled,
|
|
1978
1978
|
className: `sa-time-opt${u ? " sa-time-opt-active" : ""}`,
|
|
1979
|
-
onClick: () =>
|
|
1979
|
+
onClick: () => r(l.value),
|
|
1980
1980
|
children: l.label
|
|
1981
1981
|
},
|
|
1982
1982
|
l.value
|
|
1983
1983
|
);
|
|
1984
1984
|
}) })
|
|
1985
1985
|
] });
|
|
1986
|
-
},
|
|
1986
|
+
}, re = rn(
|
|
1987
1987
|
({
|
|
1988
1988
|
value: n,
|
|
1989
1989
|
onChange: e,
|
|
1990
|
-
format:
|
|
1991
|
-
withSeconds:
|
|
1990
|
+
format: t = "24h",
|
|
1991
|
+
withSeconds: r = !1,
|
|
1992
1992
|
step: o = 1,
|
|
1993
1993
|
minTime: d,
|
|
1994
1994
|
maxTime: l,
|
|
@@ -2028,7 +2028,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2028
2028
|
const Y = W(p);
|
|
2029
2029
|
return !($ && Y < W($) || x && Y > W(x));
|
|
2030
2030
|
}, N = (p) => {
|
|
2031
|
-
e(Xn(p,
|
|
2031
|
+
e(Xn(p, r)), H(null);
|
|
2032
2032
|
}, j = (p) => {
|
|
2033
2033
|
N({ ...b ?? { h: 0, m: 0, s: 0 }, ...p });
|
|
2034
2034
|
}, hn = () => {
|
|
@@ -2038,9 +2038,9 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2038
2038
|
e(null), H(null);
|
|
2039
2039
|
return;
|
|
2040
2040
|
}
|
|
2041
|
-
const p = ee(I,
|
|
2041
|
+
const p = ee(I, t, r);
|
|
2042
2042
|
p && _(p) ? N(p) : H(null);
|
|
2043
|
-
}, Nn = b ? ne(b,
|
|
2043
|
+
}, Nn = b ? ne(b, t, r) : "", Mn = I ?? Nn, Cn = c && !!b && !s, nn = b && b.h >= 12 ? "PM" : "AM", $n = G(() => t === "12h" ? en(12).map((p) => {
|
|
2044
2044
|
const Y = p === 0 ? 12 : p, Q = nn === "PM" ? Y % 12 + 12 : Y % 12;
|
|
2045
2045
|
return {
|
|
2046
2046
|
value: Y,
|
|
@@ -2051,7 +2051,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2051
2051
|
value: p,
|
|
2052
2052
|
label: R(p),
|
|
2053
2053
|
disabled: $ && p * 60 + 59 < W($) || x && p * 60 > W(x) || !1
|
|
2054
|
-
})), [
|
|
2054
|
+
})), [t, nn, $, x]), zn = G(() => {
|
|
2055
2055
|
const p = (b == null ? void 0 : b.h) ?? 0;
|
|
2056
2056
|
return en(60, o).map((Y) => ({
|
|
2057
2057
|
value: Y,
|
|
@@ -2061,8 +2061,8 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2061
2061
|
}, [o, b == null ? void 0 : b.h, $, x]), Dn = G(
|
|
2062
2062
|
() => en(60).map((p) => ({ value: p, label: R(p) })),
|
|
2063
2063
|
[]
|
|
2064
|
-
), Yn = b == null ? null :
|
|
2065
|
-
if (
|
|
2064
|
+
), Yn = b == null ? null : t === "12h" ? b.h % 12 === 0 ? 12 : b.h % 12 : b.h, Ln = (p) => {
|
|
2065
|
+
if (t === "12h") {
|
|
2066
2066
|
const Y = nn === "PM" ? p % 12 + 12 : p % 12;
|
|
2067
2067
|
j({ h: Y });
|
|
2068
2068
|
} else
|
|
@@ -2072,7 +2072,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2072
2072
|
N({ ...Y, h: In });
|
|
2073
2073
|
}, En = () => {
|
|
2074
2074
|
const p = /* @__PURE__ */ new Date(), Y = Math.floor(p.getMinutes() / o) * o;
|
|
2075
|
-
N({ h: p.getHours(), m: Y, s:
|
|
2075
|
+
N({ h: p.getHours(), m: Y, s: r ? p.getSeconds() : 0 });
|
|
2076
2076
|
}, sn = ae(y), Sn = /* @__PURE__ */ z(
|
|
2077
2077
|
"div",
|
|
2078
2078
|
{
|
|
@@ -2111,7 +2111,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2111
2111
|
onClick: (p) => {
|
|
2112
2112
|
p.stopPropagation(), e(null), H(null);
|
|
2113
2113
|
},
|
|
2114
|
-
children: /* @__PURE__ */ a(
|
|
2114
|
+
children: /* @__PURE__ */ a(te, { s: sn })
|
|
2115
2115
|
}
|
|
2116
2116
|
) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(vn, { s: sn }) })
|
|
2117
2117
|
]
|
|
@@ -2144,7 +2144,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2144
2144
|
onPick: (p) => j({ m: p })
|
|
2145
2145
|
}
|
|
2146
2146
|
),
|
|
2147
|
-
|
|
2147
|
+
r && /* @__PURE__ */ z(tn, { children: [
|
|
2148
2148
|
/* @__PURE__ */ a("div", { className: "sa-time-divider" }),
|
|
2149
2149
|
/* @__PURE__ */ a(
|
|
2150
2150
|
an,
|
|
@@ -2156,7 +2156,7 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2156
2156
|
}
|
|
2157
2157
|
)
|
|
2158
2158
|
] }),
|
|
2159
|
-
|
|
2159
|
+
t === "12h" && /* @__PURE__ */ z(tn, { children: [
|
|
2160
2160
|
/* @__PURE__ */ a("div", { className: "sa-time-divider" }),
|
|
2161
2161
|
/* @__PURE__ */ a(
|
|
2162
2162
|
an,
|
|
@@ -2217,8 +2217,8 @@ const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /*
|
|
|
2217
2217
|
);
|
|
2218
2218
|
}
|
|
2219
2219
|
);
|
|
2220
|
-
|
|
2220
|
+
re.displayName = "StarasiaTime";
|
|
2221
2221
|
export {
|
|
2222
2222
|
le as StarasiaDate,
|
|
2223
|
-
|
|
2223
|
+
re as StarasiaTime
|
|
2224
2224
|
};
|
package/dist/date.umd.js
CHANGED
|
@@ -588,7 +588,7 @@
|
|
|
588
588
|
width: 32px;
|
|
589
589
|
height: 32px;
|
|
590
590
|
}
|
|
591
|
-
`,ln=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],J=["January","February","March","April","May","June","July","August","September","October","November","December"],yn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function nn(e){const[a,r]=b.useState(e),s=b.useRef(null),o=i=>{s.current&&!s.current.contains(i.target)&&r(!1)};return b.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:s,isComponentVisible:a,setIsComponentVisible:r}}const dn="sa-calendar-input-styles";(e=>{if(!document.getElementById(dn)){const a=document.createElement("style");a.id=dn,a.textContent=e,document.head.appendChild(a)}})(Z);const q=e=>{if(e==="xs")return 14;if(e==="sm")return 16;if(e==="md")return 16;if(e==="lg")return 20},wn=e=>{const{size:a="sm",status:r="default",variant:s="outline",clearable:o,onClear:i,...l}=e,p=b.useRef(null),h=()=>{p.current&&l.onClick&&(p.current.focus(),l.onClick(""))},t=r==="disable"||l.disabled,c=!!l.value,w=o&&c&&!t,C=D=>{D.stopPropagation(),i==null||i()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${r} ${a} `,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:q(a),height:q(a),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",...l,disabled:t,value:l.value,ref:p})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:C,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:q(a),height:q(a),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:q(a),height:q(a),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"})})})]})},xn=({date:e,setDate:a,dateRange:r,setDateRange:s,onChange:o,minDate:i,maxDate:l,input:p})=>{var F,g,M;const[h,t]=b.useState(null);let c=new Date(e.getFullYear(),e.getMonth(),1),w=c.getDay(),C=[];const D=e.getMonth(),L=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let f=0;f<42;f++){f===0&&w===0?c.setDate(c.getDate()-7):f===0?c.setDate(c.getDate()+(f-w)):c.setDate(c.getDate()+1);let x={currentMonth:c.getMonth()===D,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((F=r.from)==null?void 0:F.toDateString())||c.toDateString()===(((g=r.to)==null?void 0:g.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===L,year:c.getFullYear(),isDisabled:i&&c<i||l&&c>l};C.push(x)}const d=f=>{a(f)},$=f=>{let x={...r};if(x.from&&x.to)x={from:f,to:null};else if(!x.from)x={from:f,to:null};else{const B=x.from.getTime();f.getTime()>B?x={from:x.from,to:f}:x={from:f,to:x.from}}s(x),o(x)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>t(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:ln.map((f,x)=>n.jsx("p",{children:f},x))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((f,x)=>{const B=r.from&&r.to&&f.date.getTime()>r.from.getTime()&&f.date.getTime()<r.to.getTime(),P=(()=>{if(!v||!r.from)return!1;const z=f.date.getTime(),k=r.from.getTime(),I=v.getTime();return I>k?z>k&&z<I:z<k&&z>I})(),Y=y&&h&&f.date.toDateString()===h.toDateString(),S=f.isDisabled,T=()=>B||P?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",m=()=>S?"var(--sa-color-gray-400, #b7b9be)":B||P?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${f.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${f.selected||Y?"sa-calendar-days-active":""} ${f.isToday&&!f.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:T(),pointerEvents:S?"none":void 0,cursor:S?"not-allowed":"pointer",color:m(),opacity:Y&&!f.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{S||(d(f.date),$(f.date))},onMouseEnter:()=>{S||t(f.date)},children:f.number},x)})})]})},kn=({date:e,setDate:a,filter:r,setViews:s,dateRange:o,setDateRange:i,onChange:l,minDate:p,maxDate:h,input:t})=>{var L;const c=(L=o.from)==null?void 0:L.getFullYear(),w=e.getFullYear(),C=y=>{r?(D(y),a(y)):(s("days"),a(y))},D=y=>{let v={...o};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const d=v.from.getTime();y.getTime()>d?v={from:v.from,to:y}:v={from:y,to:v.from}}i(v),l(v)};return n.jsx("div",{className:"sa-calendar-months-preview",children:J.map((y,v)=>{var F,g,M;const d=o.from!=null&&new Date(w,v).getTime()>o.from.getTime()&&new Date(w,v).getTime()<(((F=o.to)==null?void 0:F.getTime())||o.from.getTime()),$=p&&new Date(w,v)<p||h&&new Date(w,v)>h;return n.jsx("p",{className:c===w&&(v===((g=o.from)==null?void 0:g.getMonth())||v===((M=o.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:d?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",color:$?"var(--sa-color-gray-400, #b7b9be)":d?"var(--sa-color-gray-500, #8c8f97)":"",...t?{}:{width:"100%"}},onClick:()=>{$||C(new Date(w,v))},children:y.slice(0,3)},v)})})},en=e=>{const a=Math.floor(e/10)*10,r=a+10;return{start:a,end:r}},Mn=({date:e,filter:a,setViews:r,setDate:s,dateRange:o,setDateRange:i,onChange:l,minDate:p,maxDate:h,input:t})=>{var $,F;let c=[];const w=e.getFullYear(),{start:C,end:D}=en(w),L=($=o.from)==null?void 0:$.getFullYear(),y=(F=o.to)==null?void 0:F.getFullYear();for(let g=C;g<D;g++){const M=new Date(g,0),f=(!p||M>=p)&&(!h||M<=h),x=L!=null&&g===L||y!=null&&g===y,B=o.from!=null&&o.to!=null&&M>o.from&&M<o.to;c.push({year:g,active:x&&f,highlight:B&&f,disabled:!f})}const v=g=>{a?(d(g),s(g)):(s(g),r("months"))},d=g=>{let M={...o};if(M.from&&M.to)M={from:g,to:null};else if(!M.from)M={from:g,to:null};else{const f=M.from.getTime();g.getTime()>f?M={from:M.from,to:g}:M={from:g,to:M.from}}i(M),l(M)};return n.jsx("div",{className:"sa-calendar-years-preview",children:c.map((g,M)=>n.jsx("p",{className:`${g.active?"sa-calendar-months-active":""} ${g.highlight?"sa-calendar-months-highlight":""} ${g.disabled?"sa-calendar-disabled":""}`,onClick:()=>{g.disabled||v(new Date(g.year,0))},style:{backgroundColor:g.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:g.highlight?"var(--sa-color-gray-500, #8c8f97)":g.active?"":g.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:g.disabled?"not-allowed":"pointer",pointerEvents:g.disbled?"none":"all",...t?{}:{width:"100%"}},children:g.year},M))})},cn=({...e})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...e,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"})}),pn=({...e})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...e,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"})}),Nn=({setViews:e,views:a,filter:r,date:s,setDate:o})=>{const i=()=>{r||e(t=>t==="days"?"months":t==="months"?"years":"days")},l=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()+10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()+1,t.getMonth()));return}o(t=>new Date(t.getFullYear(),t.getMonth()+1))},p=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()-10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()-1,t.getMonth()));return}o(t=>new Date(t.getMonth()===0?t.getFullYear()-1:t.getFullYear(),t.getMonth()===0?11:t.getMonth()-1))},h=()=>{if(a==="days")return`${J[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${en(s.getFullYear()).start} ~ ${en(s.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:i,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:n.jsx(cn,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:l,children:n.jsx(pn,{})})]})]})};function G(e){const a=new Date(e),r=a.getFullYear(),s=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${yn[s]} ${r}`}const an=({label:e,labelPosition:a="outside-top",required:r,optional:s,description:o,helperText:i,errorText:l,fullWidth:p,size:h="sm",children:t})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),w=e?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:e}),s&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,C=n.jsxs(n.Fragment,{children:[i&&!l&&n.jsx("p",{className:"sa-date-field-helper",children:i}),l&&n.jsx("p",{className:"sa-date-field-error-msg",children:l})]});return e?a==="outside-left"?n.jsxs("div",{className:`${c} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[w,o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[t,C]})]}):n.jsxs("div",{className:c,children:[w,o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o}),t,C]}):n.jsxs("div",{className:c,children:[o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o}),t,C]})},un="sa-calendar-styles";(e=>{if(!document.getElementById(un)){const a=document.createElement("style");a.id=un,a.textContent=e,document.head.appendChild(a)}})(Z);const Cn=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,disabled:o,minDate:i,maxDate:l,placeholder:p,size:h="sm",variant:t,status:c,clearable:w,fullWidth:C=!0,withPadding:D=!0,label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g},M)=>{const f=g?"error":c,{ref:x,isComponentVisible:B,setIsComponentVisible:P}=nn(!1),Y=b.useRef(null),[S,T]=b.useState("days"),[m,z]=b.useState(new Date),[k,I]=b.useState({from:(e==null?void 0:e.from)??null,to:(e==null?void 0:e.to)??null});b.useEffect(()=>{if(e){const N=e;N.from&&z(N.from),I(N)}else z(new Date),I({from:null,to:null})},[e]),b.useEffect(()=>{r&&T(r)},[r]),b.useEffect(()=>{r||T("days")},[B]),b.useEffect(()=>{s||P(!0)},[s]);const H=()=>{var N,j;if(!e)return"";if(r){if(S==="days")return`${G(k.from)} ~ ${G(k.to||k.from)||"-"}`;if(S==="months")return`${J[k.from.getMonth()]} ~ ${k.to?J[k.to.getMonth()]:"-"}`;if(S==="years")return`${(N=k.from)==null?void 0:N.getFullYear()} ~ ${((j=k.to)==null?void 0:j.getFullYear())||"-"}`}else return`${G(k.from)} ~ ${G(k.to||k.from)||"-"}`},V=()=>{if(Y.current&&x.current&&s){const N=x.current.getBoundingClientRect(),j=Y.current.getBoundingClientRect();window.innerWidth<N.left+j.width?Y.current.style.left=`${N.left-j.width+N.width}px`:Y.current.style.left=`${N.left}px`,N.top+j.height>window.innerHeight?Y.current.style.top=`${N.y-(N.height+j.height-28)}px`:Y.current.style.top=`${N.y+N.height}px`}};b.useEffect(()=>{Y.current&&x.current&&s&&V()},[Y,x,B]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?x:null,children:[s?n.jsx(wn,{value:H(),inputMode:"none",onClick:()=>{P(!0)},onChange:()=>{},disabled:o,placeholder:p,size:h,variant:t,status:f,clearable:w,onClear:()=>a(void 0)}):null,B?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${s?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:o?{pointerEvents:"none"}:void 0,ref:Y,children:[n.jsx(Nn,{setViews:T,views:S,filter:r,date:m,setDate:z}),n.jsx("div",{className:"sa-calendar-body",children:S==="days"?n.jsx(xn,{date:m,setDate:z,setIsComponentVisible:P,dateRange:k,setDateRange:I,input:s,onChange:a,minDate:i,maxDate:l}):S==="months"?n.jsx(kn,{date:m,setDate:z,filter:r,setViews:T,dateRange:k,setDateRange:I,setIsComponentVisible:P,input:s,onChange:a,minDate:i,maxDate:l}):n.jsx(Mn,{date:m,setDate:z,filter:r,setViews:T,dateRange:k,setDateRange:I,setIsComponentVisible:P,input:s,onChange:a,minDate:i,maxDate:l})})]}):null]});return n.jsx(an,{label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g,fullWidth:C,size:h,children:K})}),hn="sa-calendar-input-styles";(e=>{if(!document.getElementById(hn)){const a=document.createElement("style");a.id=hn,a.textContent=e,document.head.appendChild(a)}})(Z);const U=e=>{if(e==="xs")return 14;if(e==="sm")return 16;if(e==="md")return 16;if(e==="lg")return 20},$n=e=>{const{size:a="sm",status:r="default",variant:s="outline",clearable:o,onClear:i,...l}=e,p=b.useRef(null),h=()=>{p.current&&l.onClick&&(p.current.focus(),l.onClick(""))},t=r==="disable"||l.disabled,c=!!l.value,w=o&&c&&!t,C=D=>{D.stopPropagation(),i==null||i()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${r} ${a} `,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:U(a),height:U(a),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",...l,disabled:t,value:l.value,ref:p})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:C,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:U(a),height:U(a),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:U(a),height:U(a),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"})})})]})},zn=({date:e,setDate:a,previewDate:r,setPreviewDate:s,setIsComponentVisible:o,minDate:i,maxDate:l,input:p,onChange:h,hasValue:t})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),w=c.getDay(),C=[];const D=e.toDateString(),L=new Date().toDateString(),y=r.getMonth();for(let d=0;d<42;d++){d===0&&w===0?c.setDate(c.getDate()-7):d===0?c.setDate(c.getDate()+(d-w)):c.setDate(c.getDate()+1);let $={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:t&&c.toDateString()===D,isToday:c.toDateString()===L,year:c.getFullYear(),isDisabled:i&&c<i||l&&c>l};C.push($)}const v=d=>{(!i||d>=i)&&(!l||d<=l)&&(a(d),h(d),s(d),p&&o(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:ln.map((d,$)=>n.jsx("p",{children:d},$))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((d,$)=>{const F=d.isDisabled;return n.jsx("p",{className:`${d.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${d.selected?"sa-calendar-days-active":""} ${d.isToday&&!d.selected?"sa-calendar-days-today":""}`,style:{color:F?"#ccc":void 0,pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{F||v(d.date)},children:d.number},$)})})]})},Dn=({date:e,setDate:a,filter:r,setViews:s,onChange:o,previewDate:i,setPreviewDate:l,minDate:p,maxDate:h,input:t,hasValue:c})=>{const w=e.getMonth(),C=e.getFullYear(),D=i.getFullYear(),L=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(o(y),a(y),l(y)):(s("days"),l(y)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:J.map((y,v)=>{const d=p&&new Date(D,v,1)<p||h&&new Date(D,v+1,0)>h;return n.jsx("p",{className:c&&v===w&&D===C?"sa-calendar-months-active":"",style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...t?{}:{width:"100%"}},onClick:()=>{d||L(new Date(D,v))},children:y.slice(0,3)},v)})})},rn=e=>{const a=Math.floor(e/10)*10,r=a+10;return{start:a,end:r}},En=({date:e,filter:a,setViews:r,setDate:s,onChange:o,previewDate:i,setPreviewDate:l,minDate:p,maxDate:h,input:t,hasValue:c})=>{let w=[];const C=i.getFullYear(),{start:D,end:L}=rn(C),y=e.getFullYear();for(let d=D;d<L;d++){let $=p&&new Date(d,0,1)<p||h&&new Date(d,11,31)>h;w.push({year:d,active:!!c&&d===y,isDisabled:$})}const v=d=>{(!p||d>=p)&&(!h||d<=h)&&(a?(o(d),s(d),l(d)):(r("months"),l(d)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:w.map((d,$)=>n.jsx("p",{className:d.active?"sa-calendar-months-active":"",style:{color:d.isDisabled?"#ccc":void 0,pointerEvents:d.isDisabled?"none":void 0,cursor:d.isDisabled?"not-allowed":"pointer",...t?{}:{width:"100%"}},onClick:()=>{d.isDisabled||v(new Date(d.year,0))},children:d.year},$))})},Yn=({setViews:e,views:a,filter:r,previewDate:s,setPreviewDate:o})=>{const i=()=>{r||e(t=>t==="days"?"months":t==="months"?"years":"days")},l=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()+10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()+1,t.getMonth()));return}o(t=>new Date(t.getFullYear(),t.getMonth()+1))},p=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()-10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()-1,t.getMonth()));return}o(t=>new Date(t.getMonth()===0?t.getFullYear()-1:t.getFullYear(),t.getMonth()===0?11:t.getMonth()-1))},h=()=>{if(a==="days")return`${J[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${rn(s.getFullYear()).start} ~ ${rn(s.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:i,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:n.jsx(cn,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:l,children:n.jsx(pn,{})})]})]})},fn="sa-calendar-styles";(e=>{if(!document.getElementById(fn)){const a=document.createElement("style");a.id=fn,a.textContent=e,document.head.appendChild(a)}})(Z);const Sn=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,disabled:o,minDate:i,maxDate:l,placeholder:p,size:h="sm",variant:t,status:c,clearable:w,fullWidth:C=!0,withPadding:D=!0,label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g},M)=>{const f=g?"error":c,{ref:x,isComponentVisible:B,setIsComponentVisible:P}=nn(!1),Y=b.useRef(null),[S,T]=b.useState("days"),[m,z]=b.useState(new Date),[k,I]=b.useState(new Date);b.useEffect(()=>{e?(z(e),I(e)):(z(new Date),I(new Date))},[e]),b.useEffect(()=>{r&&T(r)},[r]),b.useEffect(()=>{r||T("days")},[B]),b.useEffect(()=>{s||P(!0)},[s]);const H=()=>e?r==="days"?G(m):r==="months"?`${J[m.getMonth()]} ${m.getFullYear()}`:r==="years"?m.getFullYear():G(m):"",V=()=>{if(Y.current&&x.current&&s){const N=x.current.getBoundingClientRect(),j=Y.current.getBoundingClientRect();window.innerWidth<N.left+j.width?Y.current.style.left=`${N.left-j.width+N.width}px`:Y.current.style.left=`${N.left}px`,N.top+j.height>window.innerHeight?Y.current.style.top=`${N.y-(N.height+j.height-28)}px`:Y.current.style.top=`${N.y+N.height}px`}};b.useEffect(()=>{Y.current&&x.current&&s&&V()},[Y,x,B]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?x:null,children:[s?n.jsx($n,{value:H(),onClick:()=>P(!0),onChange:()=>{},placeholder:p,disabled:o,size:h,variant:t,status:f,inputMode:"none",clearable:w,onClear:()=>a(void 0)}):null,B?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${s?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:o?{pointerEvents:"none"}:void 0,ref:Y,children:[n.jsx(Yn,{setViews:T,views:S,filter:r,previewDate:k,setPreviewDate:I,isComponentVisible:B}),n.jsx("div",{className:"sa-calendar-body",children:S==="days"?n.jsx(zn,{date:m,setDate:z,previewDate:k,setPreviewDate:I,setIsComponentVisible:P,input:s,minDate:i,maxDate:l,onChange:a,hasValue:e!=null}):S==="months"?n.jsx(Dn,{date:m,setDate:z,previewDate:k,setPreviewDate:I,filter:r,setViews:T,onChange:a,minDate:i,maxDate:l,input:s,hasValue:e!=null}):n.jsx(En,{date:m,setDate:z,previewDate:k,setPreviewDate:I,filter:r,setViews:T,onChange:a,minDate:i,maxDate:l,input:s,hasValue:e!=null})})]}):null]});return n.jsx(an,{label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g,fullWidth:C,size:h,children:K})}),Ln=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,rangedDate:o,disabled:i,minDate:l,maxDate:p,placeholder:h,size:t,variant:c,status:w,clearable:C,fullWidth:D,withPadding:L,label:y,labelPosition:v,required:d,optional:$,description:F,helperText:g,errorText:M},f)=>{const x={onChange:a,value:e,input:s,filter:r,disabled:i,minDate:l,maxDate:p,placeholder:h,size:t,variant:c,status:w,clearable:C,fullWidth:D,withPadding:L,label:y,labelPosition:v,required:d,optional:$,description:F,helperText:g,errorText:M};return n.jsx(n.Fragment,{children:o?n.jsx(Cn,{...x,ref:f}):n.jsx(Sn,{...x,ref:f})})}),Fn=`/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
591
|
+
`,ln=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],J=["January","February","March","April","May","June","July","August","September","October","November","December"],yn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function nn(e){const[a,r]=b.useState(e),s=b.useRef(null),o=i=>{s.current&&!s.current.contains(i.target)&&r(!1)};return b.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:s,isComponentVisible:a,setIsComponentVisible:r}}const dn="sa-calendar-input-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(dn)){const a=document.createElement("style");a.id=dn,a.textContent=e,document.head.appendChild(a)}})(Z);const q=e=>{if(e==="xs")return 14;if(e==="sm")return 16;if(e==="md")return 16;if(e==="lg")return 20},wn=e=>{const{size:a="sm",status:r="default",variant:s="outline",clearable:o,onClear:i,...l}=e,p=b.useRef(null),h=()=>{p.current&&l.onClick&&(p.current.focus(),l.onClick(""))},t=r==="disable"||l.disabled,c=!!l.value,w=o&&c&&!t,C=D=>{D.stopPropagation(),i==null||i()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${r} ${a} `,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:q(a),height:q(a),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",...l,disabled:t,value:l.value,ref:p})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:C,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:q(a),height:q(a),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:q(a),height:q(a),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"})})})]})},xn=({date:e,setDate:a,dateRange:r,setDateRange:s,onChange:o,minDate:i,maxDate:l,input:p})=>{var F,g,M;const[h,t]=b.useState(null);let c=new Date(e.getFullYear(),e.getMonth(),1),w=c.getDay(),C=[];const D=e.getMonth(),L=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let f=0;f<42;f++){f===0&&w===0?c.setDate(c.getDate()-7):f===0?c.setDate(c.getDate()+(f-w)):c.setDate(c.getDate()+1);let x={currentMonth:c.getMonth()===D,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((F=r.from)==null?void 0:F.toDateString())||c.toDateString()===(((g=r.to)==null?void 0:g.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===L,year:c.getFullYear(),isDisabled:i&&c<i||l&&c>l};C.push(x)}const d=f=>{a(f)},$=f=>{let x={...r};if(x.from&&x.to)x={from:f,to:null};else if(!x.from)x={from:f,to:null};else{const B=x.from.getTime();f.getTime()>B?x={from:x.from,to:f}:x={from:f,to:x.from}}s(x),o(x)};return n.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>t(null),children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:ln.map((f,x)=>n.jsx("p",{children:f},x))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((f,x)=>{const B=r.from&&r.to&&f.date.getTime()>r.from.getTime()&&f.date.getTime()<r.to.getTime(),P=(()=>{if(!v||!r.from)return!1;const z=f.date.getTime(),k=r.from.getTime(),I=v.getTime();return I>k?z>k&&z<I:z<k&&z>I})(),Y=y&&h&&f.date.toDateString()===h.toDateString(),S=f.isDisabled,T=()=>B||P?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",m=()=>S?"var(--sa-color-gray-400, #b7b9be)":B||P?"var(--sa-color-gray-500, #8c8f97)":"";return n.jsx("p",{className:`${f.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${f.selected||Y?"sa-calendar-days-active":""} ${f.isToday&&!f.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:T(),pointerEvents:S?"none":void 0,cursor:S?"not-allowed":"pointer",color:m(),opacity:Y&&!f.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{S||(d(f.date),$(f.date))},onMouseEnter:()=>{S||t(f.date)},children:f.number},x)})})]})},kn=({date:e,setDate:a,filter:r,setViews:s,dateRange:o,setDateRange:i,onChange:l,minDate:p,maxDate:h,input:t})=>{var L;const c=(L=o.from)==null?void 0:L.getFullYear(),w=e.getFullYear(),C=y=>{r?(D(y),a(y)):(s("days"),a(y))},D=y=>{let v={...o};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const d=v.from.getTime();y.getTime()>d?v={from:v.from,to:y}:v={from:y,to:v.from}}i(v),l(v)};return n.jsx("div",{className:"sa-calendar-months-preview",children:J.map((y,v)=>{var F,g,M;const d=o.from!=null&&new Date(w,v).getTime()>o.from.getTime()&&new Date(w,v).getTime()<(((F=o.to)==null?void 0:F.getTime())||o.from.getTime()),$=p&&new Date(w,v)<p||h&&new Date(w,v)>h;return n.jsx("p",{className:c===w&&(v===((g=o.from)==null?void 0:g.getMonth())||v===((M=o.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:d?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:$?"none":void 0,cursor:$?"not-allowed":"pointer",color:$?"var(--sa-color-gray-400, #b7b9be)":d?"var(--sa-color-gray-500, #8c8f97)":"",...t?{}:{width:"100%"}},onClick:()=>{$||C(new Date(w,v))},children:y.slice(0,3)},v)})})},en=e=>{const a=Math.floor(e/10)*10,r=a+10;return{start:a,end:r}},Mn=({date:e,filter:a,setViews:r,setDate:s,dateRange:o,setDateRange:i,onChange:l,minDate:p,maxDate:h,input:t})=>{var $,F;let c=[];const w=e.getFullYear(),{start:C,end:D}=en(w),L=($=o.from)==null?void 0:$.getFullYear(),y=(F=o.to)==null?void 0:F.getFullYear();for(let g=C;g<D;g++){const M=new Date(g,0),f=(!p||M>=p)&&(!h||M<=h),x=L!=null&&g===L||y!=null&&g===y,B=o.from!=null&&o.to!=null&&M>o.from&&M<o.to;c.push({year:g,active:x&&f,highlight:B&&f,disabled:!f})}const v=g=>{a?(d(g),s(g)):(s(g),r("months"))},d=g=>{let M={...o};if(M.from&&M.to)M={from:g,to:null};else if(!M.from)M={from:g,to:null};else{const f=M.from.getTime();g.getTime()>f?M={from:M.from,to:g}:M={from:g,to:M.from}}i(M),l(M)};return n.jsx("div",{className:"sa-calendar-years-preview",children:c.map((g,M)=>n.jsx("p",{className:`${g.active?"sa-calendar-months-active":""} ${g.highlight?"sa-calendar-months-highlight":""} ${g.disabled?"sa-calendar-disabled":""}`,onClick:()=>{g.disabled||v(new Date(g.year,0))},style:{backgroundColor:g.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:g.highlight?"var(--sa-color-gray-500, #8c8f97)":g.active?"":g.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:g.disabled?"not-allowed":"pointer",pointerEvents:g.disbled?"none":"all",...t?{}:{width:"100%"}},children:g.year},M))})},cn=({...e})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...e,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"})}),pn=({...e})=>n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...e,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"})}),Nn=({setViews:e,views:a,filter:r,date:s,setDate:o})=>{const i=()=>{r||e(t=>t==="days"?"months":t==="months"?"years":"days")},l=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()+10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()+1,t.getMonth()));return}o(t=>new Date(t.getFullYear(),t.getMonth()+1))},p=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()-10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()-1,t.getMonth()));return}o(t=>new Date(t.getMonth()===0?t.getFullYear()-1:t.getFullYear(),t.getMonth()===0?11:t.getMonth()-1))},h=()=>{if(a==="days")return`${J[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${en(s.getFullYear()).start} ~ ${en(s.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:i,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:n.jsx(cn,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:l,children:n.jsx(pn,{})})]})]})};function G(e){const a=new Date(e),r=a.getFullYear(),s=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${yn[s]} ${r}`}const an=({label:e,labelPosition:a="outside-top",required:r,optional:s,description:o,helperText:i,errorText:l,fullWidth:p,size:h="sm",children:t})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),w=e?n.jsxs("div",{className:"sa-date-field-label-row",children:[n.jsx("span",{className:"sa-date-field-label-text",children:e}),s&&n.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&n.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,C=n.jsxs(n.Fragment,{children:[i&&!l&&n.jsx("p",{className:"sa-date-field-helper",children:i}),l&&n.jsx("p",{className:"sa-date-field-error-msg",children:l})]});return e?a==="outside-left"?n.jsxs("div",{className:`${c} sa-date-field-left`,children:[n.jsxs("div",{className:"sa-date-field-left-label",children:[w,o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o})]}),n.jsxs("div",{className:"sa-date-field-input-wrap",children:[t,C]})]}):n.jsxs("div",{className:c,children:[w,o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o}),t,C]}):n.jsxs("div",{className:c,children:[o&&n.jsx("p",{className:"sa-date-field-helper-top",children:o}),t,C]})},un="sa-calendar-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(un)){const a=document.createElement("style");a.id=un,a.textContent=e,document.head.appendChild(a)}})(Z);const Cn=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,disabled:o,minDate:i,maxDate:l,placeholder:p,size:h="sm",variant:t,status:c,clearable:w,fullWidth:C=!0,withPadding:D=!0,label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g},M)=>{const f=g?"error":c,{ref:x,isComponentVisible:B,setIsComponentVisible:P}=nn(!1),Y=b.useRef(null),[S,T]=b.useState("days"),[m,z]=b.useState(new Date),[k,I]=b.useState({from:(e==null?void 0:e.from)??null,to:(e==null?void 0:e.to)??null});b.useEffect(()=>{if(e){const N=e;N.from&&z(N.from),I(N)}else z(new Date),I({from:null,to:null})},[e]),b.useEffect(()=>{r&&T(r)},[r]),b.useEffect(()=>{r||T("days")},[B]),b.useEffect(()=>{s||P(!0)},[s]);const H=()=>{var N,j;if(!e)return"";if(r){if(S==="days")return`${G(k.from)} ~ ${G(k.to||k.from)||"-"}`;if(S==="months")return`${J[k.from.getMonth()]} ~ ${k.to?J[k.to.getMonth()]:"-"}`;if(S==="years")return`${(N=k.from)==null?void 0:N.getFullYear()} ~ ${((j=k.to)==null?void 0:j.getFullYear())||"-"}`}else return`${G(k.from)} ~ ${G(k.to||k.from)||"-"}`},V=()=>{if(Y.current&&x.current&&s){const N=x.current.getBoundingClientRect(),j=Y.current.getBoundingClientRect();window.innerWidth<N.left+j.width?Y.current.style.left=`${N.left-j.width+N.width}px`:Y.current.style.left=`${N.left}px`,N.top+j.height>window.innerHeight?Y.current.style.top=`${N.y-(N.height+j.height-28)}px`:Y.current.style.top=`${N.y+N.height}px`}};b.useEffect(()=>{Y.current&&x.current&&s&&V()},[Y,x,B]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?x:null,children:[s?n.jsx(wn,{value:H(),inputMode:"none",onClick:()=>{P(!0)},onChange:()=>{},disabled:o,placeholder:p,size:h,variant:t,status:f,clearable:w,onClear:()=>a(void 0)}):null,B?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${s?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:o?{pointerEvents:"none"}:void 0,ref:Y,children:[n.jsx(Nn,{setViews:T,views:S,filter:r,date:m,setDate:z}),n.jsx("div",{className:"sa-calendar-body",children:S==="days"?n.jsx(xn,{date:m,setDate:z,setIsComponentVisible:P,dateRange:k,setDateRange:I,input:s,onChange:a,minDate:i,maxDate:l}):S==="months"?n.jsx(kn,{date:m,setDate:z,filter:r,setViews:T,dateRange:k,setDateRange:I,setIsComponentVisible:P,input:s,onChange:a,minDate:i,maxDate:l}):n.jsx(Mn,{date:m,setDate:z,filter:r,setViews:T,dateRange:k,setDateRange:I,setIsComponentVisible:P,input:s,onChange:a,minDate:i,maxDate:l})})]}):null]});return n.jsx(an,{label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g,fullWidth:C,size:h,children:K})}),hn="sa-calendar-input-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(hn)){const a=document.createElement("style");a.id=hn,a.textContent=e,document.head.appendChild(a)}})(Z);const U=e=>{if(e==="xs")return 14;if(e==="sm")return 16;if(e==="md")return 16;if(e==="lg")return 20},$n=e=>{const{size:a="sm",status:r="default",variant:s="outline",clearable:o,onClear:i,...l}=e,p=b.useRef(null),h=()=>{p.current&&l.onClick&&(p.current.focus(),l.onClick(""))},t=r==="disable"||l.disabled,c=!!l.value,w=o&&c&&!t,C=D=>{D.stopPropagation(),i==null||i()};return n.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${r} ${a} `,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:U(a),height:U(a),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",...l,disabled:t,value:l.value,ref:p})}),w?n.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:C,children:n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:U(a),height:U(a),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:U(a),height:U(a),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"})})})]})},zn=({date:e,setDate:a,previewDate:r,setPreviewDate:s,setIsComponentVisible:o,minDate:i,maxDate:l,input:p,onChange:h,hasValue:t})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),w=c.getDay(),C=[];const D=e.toDateString(),L=new Date().toDateString(),y=r.getMonth();for(let d=0;d<42;d++){d===0&&w===0?c.setDate(c.getDate()-7):d===0?c.setDate(c.getDate()+(d-w)):c.setDate(c.getDate()+1);let $={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:t&&c.toDateString()===D,isToday:c.toDateString()===L,year:c.getFullYear(),isDisabled:i&&c<i||l&&c>l};C.push($)}const v=d=>{(!i||d>=i)&&(!l||d<=l)&&(a(d),h(d),s(d),p&&o(!1))};return n.jsxs("div",{className:"sa-calendar-days-preivew",children:[n.jsx("div",{className:"sa-calendar-days-name-preivew",children:ln.map((d,$)=>n.jsx("p",{children:d},$))}),n.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((d,$)=>{const F=d.isDisabled;return n.jsx("p",{className:`${d.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${d.selected?"sa-calendar-days-active":""} ${d.isToday&&!d.selected?"sa-calendar-days-today":""}`,style:{color:F?"#ccc":void 0,pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{F||v(d.date)},children:d.number},$)})})]})},Dn=({date:e,setDate:a,filter:r,setViews:s,onChange:o,previewDate:i,setPreviewDate:l,minDate:p,maxDate:h,input:t,hasValue:c})=>{const w=e.getMonth(),C=e.getFullYear(),D=i.getFullYear(),L=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(o(y),a(y),l(y)):(s("days"),l(y)))};return n.jsx("div",{className:"sa-calendar-months-preview",children:J.map((y,v)=>{const d=p&&new Date(D,v,1)<p||h&&new Date(D,v+1,0)>h;return n.jsx("p",{className:c&&v===w&&D===C?"sa-calendar-months-active":"",style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...t?{}:{width:"100%"}},onClick:()=>{d||L(new Date(D,v))},children:y.slice(0,3)},v)})})},rn=e=>{const a=Math.floor(e/10)*10,r=a+10;return{start:a,end:r}},En=({date:e,filter:a,setViews:r,setDate:s,onChange:o,previewDate:i,setPreviewDate:l,minDate:p,maxDate:h,input:t,hasValue:c})=>{let w=[];const C=i.getFullYear(),{start:D,end:L}=rn(C),y=e.getFullYear();for(let d=D;d<L;d++){let $=p&&new Date(d,0,1)<p||h&&new Date(d,11,31)>h;w.push({year:d,active:!!c&&d===y,isDisabled:$})}const v=d=>{(!p||d>=p)&&(!h||d<=h)&&(a?(o(d),s(d),l(d)):(r("months"),l(d)))};return n.jsx("div",{className:"sa-calendar-years-preview",children:w.map((d,$)=>n.jsx("p",{className:d.active?"sa-calendar-months-active":"",style:{color:d.isDisabled?"#ccc":void 0,pointerEvents:d.isDisabled?"none":void 0,cursor:d.isDisabled?"not-allowed":"pointer",...t?{}:{width:"100%"}},onClick:()=>{d.isDisabled||v(new Date(d.year,0))},children:d.year},$))})},Yn=({setViews:e,views:a,filter:r,previewDate:s,setPreviewDate:o})=>{const i=()=>{r||e(t=>t==="days"?"months":t==="months"?"years":"days")},l=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()+10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()+1,t.getMonth()));return}o(t=>new Date(t.getFullYear(),t.getMonth()+1))},p=()=>{if(a==="years"){o(t=>new Date(t.getFullYear()-10,0));return}if(a==="months"){o(t=>new Date(t.getFullYear()-1,t.getMonth()));return}o(t=>new Date(t.getMonth()===0?t.getFullYear()-1:t.getFullYear(),t.getMonth()===0?11:t.getMonth()-1))},h=()=>{if(a==="days")return`${J[s.getMonth()]} ${s.getFullYear()}`;if(a==="months")return`${s.getFullYear()}`;if(a==="years")return`${rn(s.getFullYear()).start} ~ ${rn(s.getFullYear()).end}`};return n.jsxs("div",{className:"sa-calendar-header",children:[n.jsx("div",{className:"sa-calendar-header-title",onClick:i,children:h()}),n.jsxs("div",{className:"sa-calendar-header-nav",children:[n.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:n.jsx(cn,{})}),n.jsx("button",{className:"sa-calendar-nav-btn",onClick:l,children:n.jsx(pn,{})})]})]})},fn="sa-calendar-styles";(e=>{if(!(typeof document>"u")&&!document.getElementById(fn)){const a=document.createElement("style");a.id=fn,a.textContent=e,document.head.appendChild(a)}})(Z);const Sn=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,disabled:o,minDate:i,maxDate:l,placeholder:p,size:h="sm",variant:t,status:c,clearable:w,fullWidth:C=!0,withPadding:D=!0,label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g},M)=>{const f=g?"error":c,{ref:x,isComponentVisible:B,setIsComponentVisible:P}=nn(!1),Y=b.useRef(null),[S,T]=b.useState("days"),[m,z]=b.useState(new Date),[k,I]=b.useState(new Date);b.useEffect(()=>{e?(z(e),I(e)):(z(new Date),I(new Date))},[e]),b.useEffect(()=>{r&&T(r)},[r]),b.useEffect(()=>{r||T("days")},[B]),b.useEffect(()=>{s||P(!0)},[s]);const H=()=>e?r==="days"?G(m):r==="months"?`${J[m.getMonth()]} ${m.getFullYear()}`:r==="years"?m.getFullYear():G(m):"",V=()=>{if(Y.current&&x.current&&s){const N=x.current.getBoundingClientRect(),j=Y.current.getBoundingClientRect();window.innerWidth<N.left+j.width?Y.current.style.left=`${N.left-j.width+N.width}px`:Y.current.style.left=`${N.left}px`,N.top+j.height>window.innerHeight?Y.current.style.top=`${N.y-(N.height+j.height-28)}px`:Y.current.style.top=`${N.y+N.height}px`}};b.useEffect(()=>{Y.current&&x.current&&s&&V()},[Y,x,B]),b.useEffect(()=>(window.addEventListener("scroll",V,!0),window.addEventListener("resize",V),()=>{window.removeEventListener("scroll",V,!0),window.removeEventListener("resize",V)}),[]);const K=n.jsxs("div",{className:"sa-calendar-wrapper",style:{height:s?"auto":"100%"},ref:s?x:null,children:[s?n.jsx($n,{value:H(),onClick:()=>P(!0),onChange:()=>{},placeholder:p,disabled:o,size:h,variant:t,status:f,inputMode:"none",clearable:w,onClear:()=>a(void 0)}):null,B?n.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${s?"":"sa-calendar-no-input"} ${D?"":"sa-calendar-no-padding"}`,style:o?{pointerEvents:"none"}:void 0,ref:Y,children:[n.jsx(Yn,{setViews:T,views:S,filter:r,previewDate:k,setPreviewDate:I,isComponentVisible:B}),n.jsx("div",{className:"sa-calendar-body",children:S==="days"?n.jsx(zn,{date:m,setDate:z,previewDate:k,setPreviewDate:I,setIsComponentVisible:P,input:s,minDate:i,maxDate:l,onChange:a,hasValue:e!=null}):S==="months"?n.jsx(Dn,{date:m,setDate:z,previewDate:k,setPreviewDate:I,filter:r,setViews:T,onChange:a,minDate:i,maxDate:l,input:s,hasValue:e!=null}):n.jsx(En,{date:m,setDate:z,previewDate:k,setPreviewDate:I,filter:r,setViews:T,onChange:a,minDate:i,maxDate:l,input:s,hasValue:e!=null})})]}):null]});return n.jsx(an,{label:L,labelPosition:y,required:v,optional:d,description:$,helperText:F,errorText:g,fullWidth:C,size:h,children:K})}),Ln=b.forwardRef(({value:e,onChange:a,filter:r,input:s=!0,rangedDate:o,disabled:i,minDate:l,maxDate:p,placeholder:h,size:t,variant:c,status:w,clearable:C,fullWidth:D,withPadding:L,label:y,labelPosition:v,required:d,optional:$,description:F,helperText:g,errorText:M},f)=>{const x={onChange:a,value:e,input:s,filter:r,disabled:i,minDate:l,maxDate:p,placeholder:h,size:t,variant:c,status:w,clearable:C,fullWidth:D,withPadding:L,label:y,labelPosition:v,required:d,optional:$,description:F,helperText:g,errorText:M};return n.jsx(n.Fragment,{children:o?n.jsx(Cn,{...x,ref:f}):n.jsx(Sn,{...x,ref:f})})}),Fn=`/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
592
592
|
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
593
593
|
.sa-calendar-input-* shells for the box + masked input. */
|
|
594
594
|
|