@starasia/date 7.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date.es.js +136 -132
- package/dist/date.umd.js +2 -2
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as z, jsx as s, Fragment as yn } from "react/jsx-runtime";
|
|
2
|
-
import wn, { useState as G, useRef as _, useEffect as
|
|
2
|
+
import wn, { useState as G, useRef as _, useEffect as O, forwardRef as xn, useMemo as tn } from "react";
|
|
3
3
|
const gn = `
|
|
4
4
|
* {
|
|
5
5
|
margin: 0;
|
|
@@ -612,7 +612,7 @@ const gn = `
|
|
|
612
612
|
"October",
|
|
613
613
|
"November",
|
|
614
614
|
"December"
|
|
615
|
-
],
|
|
615
|
+
], An = [
|
|
616
616
|
"Jan",
|
|
617
617
|
"Feb",
|
|
618
618
|
"Mar",
|
|
@@ -630,17 +630,17 @@ function En(n) {
|
|
|
630
630
|
const [e, a] = G(n), o = _(null), r = (d) => {
|
|
631
631
|
o.current && !o.current.contains(d.target) && a(!1);
|
|
632
632
|
};
|
|
633
|
-
return
|
|
633
|
+
return O(() => (document.addEventListener("click", r, !0), () => {
|
|
634
634
|
document.removeEventListener("click", r, !0);
|
|
635
635
|
}), []), { ref: o, isComponentVisible: e, setIsComponentVisible: a };
|
|
636
636
|
}
|
|
637
|
-
const Ln = "sa-calendar-input-styles",
|
|
637
|
+
const Ln = "sa-calendar-input-styles", Hn = (n) => {
|
|
638
638
|
if (!(typeof document > "u") && !document.getElementById(Ln)) {
|
|
639
639
|
const e = document.createElement("style");
|
|
640
640
|
e.id = Ln, e.textContent = n, document.head.appendChild(e);
|
|
641
641
|
}
|
|
642
642
|
};
|
|
643
|
-
|
|
643
|
+
Hn(gn);
|
|
644
644
|
const rn = (n) => {
|
|
645
645
|
if (n === "xs")
|
|
646
646
|
return 14;
|
|
@@ -650,7 +650,7 @@ const rn = (n) => {
|
|
|
650
650
|
return 16;
|
|
651
651
|
if (n === "lg")
|
|
652
652
|
return 20;
|
|
653
|
-
},
|
|
653
|
+
}, Wn = (n) => {
|
|
654
654
|
const {
|
|
655
655
|
size: e = "sm",
|
|
656
656
|
status: a = "default",
|
|
@@ -750,7 +750,7 @@ const rn = (n) => {
|
|
|
750
750
|
]
|
|
751
751
|
}
|
|
752
752
|
);
|
|
753
|
-
},
|
|
753
|
+
}, Rn = ({
|
|
754
754
|
date: n,
|
|
755
755
|
setDate: e,
|
|
756
756
|
dateRange: a,
|
|
@@ -789,8 +789,8 @@ const rn = (n) => {
|
|
|
789
789
|
else if (!N.from)
|
|
790
790
|
N = { from: v, to: null };
|
|
791
791
|
else {
|
|
792
|
-
const
|
|
793
|
-
v.getTime() >
|
|
792
|
+
const B = N.from.getTime();
|
|
793
|
+
v.getTime() > B ? N = { from: N.from, to: v } : N = { from: v, to: N.from };
|
|
794
794
|
}
|
|
795
795
|
o(N), r(N);
|
|
796
796
|
};
|
|
@@ -802,22 +802,22 @@ const rn = (n) => {
|
|
|
802
802
|
children: [
|
|
803
803
|
/* @__PURE__ */ s("div", { className: "sa-calendar-days-name-preivew", children: Vn.map((v, N) => /* @__PURE__ */ s("p", { children: v }, N)) }),
|
|
804
804
|
/* @__PURE__ */ s("div", { className: "sa-calendar-days-number-preivew", children: M.map((v, N) => {
|
|
805
|
-
const
|
|
805
|
+
const B = a.from && a.to && v.date.getTime() > a.from.getTime() && v.date.getTime() < a.to.getTime(), H = (() => {
|
|
806
806
|
if (!g || !a.from)
|
|
807
807
|
return !1;
|
|
808
808
|
const Y = v.date.getTime(), L = a.from.getTime(), S = g.getTime();
|
|
809
809
|
return S > L ? Y > L && Y < S : Y < L && Y > S;
|
|
810
|
-
})(),
|
|
810
|
+
})(), V = b && h && v.date.toDateString() === h.toDateString(), F = v.isDisabled, $ = () => B || H ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", m = () => F ? "var(--sa-color-gray-400, #b7b9be)" : B || H ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
811
811
|
return /* @__PURE__ */ s(
|
|
812
812
|
"p",
|
|
813
813
|
{
|
|
814
|
-
className: `${v.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${v.selected ||
|
|
814
|
+
className: `${v.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${v.selected || V ? "sa-calendar-days-active" : ""} ${v.isToday && !v.selected ? "sa-calendar-days-today" : ""}`,
|
|
815
815
|
style: {
|
|
816
816
|
backgroundColor: $(),
|
|
817
817
|
pointerEvents: F ? "none" : void 0,
|
|
818
818
|
cursor: F ? "not-allowed" : "pointer",
|
|
819
819
|
color: m(),
|
|
820
|
-
opacity:
|
|
820
|
+
opacity: V && !v.selected ? 0.75 : 1,
|
|
821
821
|
...p ? {} : { width: "100%" }
|
|
822
822
|
},
|
|
823
823
|
onClick: () => {
|
|
@@ -902,11 +902,11 @@ const rn = (n) => {
|
|
|
902
902
|
let c = [];
|
|
903
903
|
const w = n.getFullYear(), { start: M, end: E } = Cn(w), x = (C = r.from) == null ? void 0 : C.getFullYear(), b = (T = r.to) == null ? void 0 : T.getFullYear();
|
|
904
904
|
for (let y = M; y < E; y++) {
|
|
905
|
-
const k = new Date(y, 0), v = (!p || k >= p) && (!h || k <= h), N = x != null && y === x || b != null && y === b,
|
|
905
|
+
const k = new Date(y, 0), v = (!p || k >= p) && (!h || k <= h), N = x != null && y === x || b != null && y === b, B = r.from != null && r.to != null && k > r.from && k < r.to;
|
|
906
906
|
c.push({
|
|
907
907
|
year: y,
|
|
908
908
|
active: N && v,
|
|
909
|
-
highlight:
|
|
909
|
+
highlight: B && v,
|
|
910
910
|
disabled: !v
|
|
911
911
|
});
|
|
912
912
|
}
|
|
@@ -962,7 +962,7 @@ const rn = (n) => {
|
|
|
962
962
|
}
|
|
963
963
|
)
|
|
964
964
|
}
|
|
965
|
-
),
|
|
965
|
+
), On = ({ ...n }) => /* @__PURE__ */ s(
|
|
966
966
|
"svg",
|
|
967
967
|
{
|
|
968
968
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1028,13 +1028,13 @@ const rn = (n) => {
|
|
|
1028
1028
|
})() }),
|
|
1029
1029
|
/* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
|
|
1030
1030
|
/* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ s(Pn, {}) }),
|
|
1031
|
-
/* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ s(
|
|
1031
|
+
/* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ s(On, {}) })
|
|
1032
1032
|
] })
|
|
1033
1033
|
] });
|
|
1034
1034
|
};
|
|
1035
1035
|
function on(n) {
|
|
1036
1036
|
const e = new Date(n), a = e.getFullYear(), o = e.getMonth();
|
|
1037
|
-
return `${e.getDate().toString().padStart(2, "0")} ${
|
|
1037
|
+
return `${e.getDate().toString().padStart(2, "0")} ${An[o]} ${a}`;
|
|
1038
1038
|
}
|
|
1039
1039
|
const Fn = (() => {
|
|
1040
1040
|
const n = {};
|
|
@@ -1164,25 +1164,25 @@ const _n = xn(
|
|
|
1164
1164
|
description: k,
|
|
1165
1165
|
helperText: v,
|
|
1166
1166
|
errorText: N
|
|
1167
|
-
},
|
|
1168
|
-
const
|
|
1167
|
+
}, B) => {
|
|
1168
|
+
const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), m = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), W = typeof g == "function" || b != null, A = !o && !W, J = !A, [D, K] = G({
|
|
1169
1169
|
from: (n == null ? void 0 : n.from) ?? null,
|
|
1170
1170
|
to: (n == null ? void 0 : n.to) ?? null
|
|
1171
1171
|
}), [q, U] = G(null);
|
|
1172
|
-
|
|
1172
|
+
O(() => {
|
|
1173
1173
|
if (n) {
|
|
1174
1174
|
const t = n;
|
|
1175
|
-
t.from && I(t.from),
|
|
1175
|
+
t.from && I(t.from), K(t);
|
|
1176
1176
|
} else
|
|
1177
|
-
I(/* @__PURE__ */ new Date()),
|
|
1177
|
+
I(/* @__PURE__ */ new Date()), K({ from: null, to: null });
|
|
1178
1178
|
U(null);
|
|
1179
|
-
}, [n]),
|
|
1179
|
+
}, [n]), O(() => {
|
|
1180
1180
|
a && L(a);
|
|
1181
|
-
}, [a]),
|
|
1181
|
+
}, [a]), O(() => {
|
|
1182
1182
|
a || L("days");
|
|
1183
|
-
}, [F]),
|
|
1184
|
-
|
|
1185
|
-
}, [
|
|
1183
|
+
}, [F]), O(() => {
|
|
1184
|
+
A && $(!0);
|
|
1185
|
+
}, [A]);
|
|
1186
1186
|
const X = () => {
|
|
1187
1187
|
var t, f;
|
|
1188
1188
|
if (!n)
|
|
@@ -1196,16 +1196,16 @@ const _n = xn(
|
|
|
1196
1196
|
return `${(t = D.from) == null ? void 0 : t.getFullYear()} ~ ${((f = D.to) == null ? void 0 : f.getFullYear()) || "-"}`;
|
|
1197
1197
|
} else
|
|
1198
1198
|
return `${on(D.from)} ~ ${on(D.to || D.from) || "-"}`;
|
|
1199
|
-
},
|
|
1200
|
-
if (m.current &&
|
|
1201
|
-
const t =
|
|
1199
|
+
}, j = () => {
|
|
1200
|
+
if (m.current && V.current && J) {
|
|
1201
|
+
const t = V.current.getBoundingClientRect(), f = m.current.getBoundingClientRect();
|
|
1202
1202
|
window.innerWidth < t.left + f.width ? m.current.style.left = `${t.left - f.width + t.width}px` : m.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? m.current.style.top = `${t.y - (t.height + f.height - 28)}px` : m.current.style.top = `${t.y + t.height}px`;
|
|
1203
1203
|
}
|
|
1204
1204
|
};
|
|
1205
|
-
|
|
1206
|
-
m.current &&
|
|
1207
|
-
}, [m,
|
|
1208
|
-
window.removeEventListener("scroll",
|
|
1205
|
+
O(() => {
|
|
1206
|
+
m.current && V.current && J && j();
|
|
1207
|
+
}, [m, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
|
|
1208
|
+
window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
|
|
1209
1209
|
}), []);
|
|
1210
1210
|
const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
|
|
1211
1211
|
x && U(Un(D, a));
|
|
@@ -1217,8 +1217,8 @@ const _n = xn(
|
|
|
1217
1217
|
e(void 0), U(null);
|
|
1218
1218
|
return;
|
|
1219
1219
|
}
|
|
1220
|
-
const f = Gn(t, a),
|
|
1221
|
-
f &&
|
|
1220
|
+
const f = Gn(t, a), P = f && Dn(f.from, d, i) && (!f.to || Dn(f.to, d, i));
|
|
1221
|
+
f && P && (e(f), K(f), I(f.from)), U(null);
|
|
1222
1222
|
}, un = (t) => {
|
|
1223
1223
|
t.key === "Enter" ? (en(), $(!1)) : t.key === "Escape" && (U(null), $(!1));
|
|
1224
1224
|
}, pn = {
|
|
@@ -1234,25 +1234,27 @@ const _n = xn(
|
|
|
1234
1234
|
}, hn = /* @__PURE__ */ z(
|
|
1235
1235
|
"div",
|
|
1236
1236
|
{
|
|
1237
|
-
className: `sa-calendar-wrapper${
|
|
1238
|
-
style: { height:
|
|
1239
|
-
ref:
|
|
1237
|
+
className: `sa-calendar-wrapper${W ? " sa-calendar-wrapper-custom" : ""}`,
|
|
1238
|
+
style: { height: A ? "100%" : "auto" },
|
|
1239
|
+
ref: (t) => {
|
|
1240
|
+
V.current = J ? t : null, typeof B == "function" ? B(t) : B && (B.current = t);
|
|
1241
|
+
},
|
|
1240
1242
|
children: [
|
|
1241
|
-
|
|
1243
|
+
W ? (() => {
|
|
1242
1244
|
if (typeof g == "function")
|
|
1243
1245
|
return g(pn);
|
|
1244
1246
|
if (wn.isValidElement(b)) {
|
|
1245
1247
|
const t = b;
|
|
1246
1248
|
return wn.cloneElement(t, {
|
|
1247
1249
|
onClick: (f) => {
|
|
1248
|
-
var
|
|
1249
|
-
(an = (
|
|
1250
|
+
var P, an;
|
|
1251
|
+
(an = (P = t.props) == null ? void 0 : P.onClick) == null || an.call(P, f), r || nn();
|
|
1250
1252
|
}
|
|
1251
1253
|
});
|
|
1252
1254
|
}
|
|
1253
1255
|
return b;
|
|
1254
1256
|
})() : o ? /* @__PURE__ */ s(
|
|
1255
|
-
|
|
1257
|
+
Wn,
|
|
1256
1258
|
{
|
|
1257
1259
|
value: x && q !== null ? q : X(),
|
|
1258
1260
|
inputMode: x ? "text" : "none",
|
|
@@ -1269,7 +1271,7 @@ const _n = xn(
|
|
|
1269
1271
|
placeholder: p,
|
|
1270
1272
|
size: h,
|
|
1271
1273
|
variant: l,
|
|
1272
|
-
status:
|
|
1274
|
+
status: H,
|
|
1273
1275
|
clearable: w,
|
|
1274
1276
|
onClear: () => e(void 0)
|
|
1275
1277
|
}
|
|
@@ -1277,7 +1279,7 @@ const _n = xn(
|
|
|
1277
1279
|
F ? /* @__PURE__ */ z(
|
|
1278
1280
|
"div",
|
|
1279
1281
|
{
|
|
1280
|
-
className: `sa-calendar sa-calendar-size-${h || "sm"} ${
|
|
1282
|
+
className: `sa-calendar sa-calendar-size-${h || "sm"} ${A ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
|
|
1281
1283
|
style: r ? { pointerEvents: "none" } : void 0,
|
|
1282
1284
|
ref: m,
|
|
1283
1285
|
children: [
|
|
@@ -1292,13 +1294,13 @@ const _n = xn(
|
|
|
1292
1294
|
}
|
|
1293
1295
|
),
|
|
1294
1296
|
/* @__PURE__ */ s("div", { className: "sa-calendar-body", children: Y === "days" ? /* @__PURE__ */ s(
|
|
1295
|
-
|
|
1297
|
+
Rn,
|
|
1296
1298
|
{
|
|
1297
1299
|
date: S,
|
|
1298
1300
|
setDate: I,
|
|
1299
1301
|
setIsComponentVisible: $,
|
|
1300
1302
|
dateRange: D,
|
|
1301
|
-
setDateRange:
|
|
1303
|
+
setDateRange: K,
|
|
1302
1304
|
input: o,
|
|
1303
1305
|
onChange: e,
|
|
1304
1306
|
minDate: d,
|
|
@@ -1312,7 +1314,7 @@ const _n = xn(
|
|
|
1312
1314
|
filter: a,
|
|
1313
1315
|
setViews: L,
|
|
1314
1316
|
dateRange: D,
|
|
1315
|
-
setDateRange:
|
|
1317
|
+
setDateRange: K,
|
|
1316
1318
|
setIsComponentVisible: $,
|
|
1317
1319
|
input: o,
|
|
1318
1320
|
onChange: e,
|
|
@@ -1327,7 +1329,7 @@ const _n = xn(
|
|
|
1327
1329
|
filter: a,
|
|
1328
1330
|
setViews: L,
|
|
1329
1331
|
dateRange: D,
|
|
1330
|
-
setDateRange:
|
|
1332
|
+
setDateRange: K,
|
|
1331
1333
|
setIsComponentVisible: $,
|
|
1332
1334
|
input: o,
|
|
1333
1335
|
onChange: e,
|
|
@@ -1519,7 +1521,7 @@ const sn = (n) => {
|
|
|
1519
1521
|
{
|
|
1520
1522
|
className: `${u.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${u.selected ? "sa-calendar-days-active" : ""} ${u.isToday && !u.selected ? "sa-calendar-days-today" : ""}`,
|
|
1521
1523
|
style: {
|
|
1522
|
-
color: T ? "#
|
|
1524
|
+
color: T ? "var(--sa-text-disable, #181a198f)" : void 0,
|
|
1523
1525
|
pointerEvents: T ? "none" : void 0,
|
|
1524
1526
|
cursor: T ? "not-allowed" : "pointer",
|
|
1525
1527
|
...p ? {} : { width: "100%" }
|
|
@@ -1556,7 +1558,7 @@ const sn = (n) => {
|
|
|
1556
1558
|
{
|
|
1557
1559
|
className: c && g === w && E === M ? "sa-calendar-months-active" : "",
|
|
1558
1560
|
style: {
|
|
1559
|
-
color: u ? "#
|
|
1561
|
+
color: u ? "var(--sa-text-disable, #181a198f)" : void 0,
|
|
1560
1562
|
pointerEvents: u ? "none" : void 0,
|
|
1561
1563
|
cursor: u ? "not-allowed" : "pointer",
|
|
1562
1564
|
...l ? {} : { width: "100%" }
|
|
@@ -1603,7 +1605,7 @@ const sn = (n) => {
|
|
|
1603
1605
|
{
|
|
1604
1606
|
className: u.active ? "sa-calendar-months-active" : "",
|
|
1605
1607
|
style: {
|
|
1606
|
-
color: u.isDisabled ? "#
|
|
1608
|
+
color: u.isDisabled ? "var(--sa-text-disable, #181a198f)" : void 0,
|
|
1607
1609
|
pointerEvents: u.isDisabled ? "none" : void 0,
|
|
1608
1610
|
cursor: u.isDisabled ? "not-allowed" : "pointer",
|
|
1609
1611
|
...l ? {} : { width: "100%" }
|
|
@@ -1665,7 +1667,7 @@ const sn = (n) => {
|
|
|
1665
1667
|
})() }),
|
|
1666
1668
|
/* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
|
|
1667
1669
|
/* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: p, children: /* @__PURE__ */ s(Pn, {}) }),
|
|
1668
|
-
/* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ s(
|
|
1670
|
+
/* @__PURE__ */ s("button", { className: "sa-calendar-nav-btn", onClick: i, children: /* @__PURE__ */ s(On, {}) })
|
|
1669
1671
|
] })
|
|
1670
1672
|
] });
|
|
1671
1673
|
}, Tn = "sa-calendar-styles", re = (n) => {
|
|
@@ -1701,40 +1703,40 @@ const se = xn(
|
|
|
1701
1703
|
description: k,
|
|
1702
1704
|
helperText: v,
|
|
1703
1705
|
errorText: N
|
|
1704
|
-
},
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
n ? (I(n),
|
|
1708
|
-
}, [n]),
|
|
1706
|
+
}, B) => {
|
|
1707
|
+
const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), m = _(null), [Y, L] = G("days"), [S, I] = G(/* @__PURE__ */ new Date()), [W, A] = G(/* @__PURE__ */ new Date()), [J, D] = G(null), K = typeof g == "function" || b != null, q = !o && !K, U = !q;
|
|
1708
|
+
O(() => {
|
|
1709
|
+
n ? (I(n), A(n)) : (I(/* @__PURE__ */ new Date()), A(/* @__PURE__ */ new Date())), D(null);
|
|
1710
|
+
}, [n]), O(() => {
|
|
1709
1711
|
a && L(a);
|
|
1710
|
-
}, [a]),
|
|
1712
|
+
}, [a]), O(() => {
|
|
1711
1713
|
a || L("days");
|
|
1712
|
-
}, [F]),
|
|
1714
|
+
}, [F]), O(() => {
|
|
1713
1715
|
q && $(!0);
|
|
1714
1716
|
}, [q]);
|
|
1715
|
-
const X = () => n ? a === "days" ? on(S) : a === "months" ? `${Q[S.getMonth()]} ${S.getFullYear()}` : a === "years" ? S.getFullYear() : on(S) : "",
|
|
1716
|
-
if (m.current &&
|
|
1717
|
-
const t =
|
|
1717
|
+
const X = () => n ? a === "days" ? on(S) : a === "months" ? `${Q[S.getMonth()]} ${S.getFullYear()}` : a === "years" ? S.getFullYear() : on(S) : "", j = () => {
|
|
1718
|
+
if (m.current && V.current && U) {
|
|
1719
|
+
const t = V.current.getBoundingClientRect(), f = m.current.getBoundingClientRect();
|
|
1718
1720
|
window.innerWidth < t.left + f.width ? m.current.style.left = `${t.left - f.width + t.width}px` : m.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? m.current.style.top = `${t.y - (t.height + f.height - 28)}px` : m.current.style.top = `${t.y + t.height}px`;
|
|
1719
1721
|
}
|
|
1720
1722
|
};
|
|
1721
|
-
|
|
1722
|
-
m.current &&
|
|
1723
|
-
}, [m,
|
|
1724
|
-
window.removeEventListener("scroll",
|
|
1723
|
+
O(() => {
|
|
1724
|
+
m.current && V.current && U && j();
|
|
1725
|
+
}, [m, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
|
|
1726
|
+
window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
|
|
1725
1727
|
}), []);
|
|
1726
1728
|
const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
|
|
1727
1729
|
x && D(n ? $n(n, a) : "");
|
|
1728
1730
|
}, en = () => {
|
|
1729
|
-
if (
|
|
1731
|
+
if (J === null)
|
|
1730
1732
|
return;
|
|
1731
|
-
const t =
|
|
1733
|
+
const t = J.trim();
|
|
1732
1734
|
if (!t) {
|
|
1733
1735
|
e(void 0), D(null);
|
|
1734
1736
|
return;
|
|
1735
1737
|
}
|
|
1736
1738
|
const f = bn(t, a);
|
|
1737
|
-
f && Dn(f, d, i) && (e(f), I(f),
|
|
1739
|
+
f && Dn(f, d, i) && (e(f), I(f), A(f)), D(null);
|
|
1738
1740
|
}, un = (t) => {
|
|
1739
1741
|
t.key === "Enter" ? (en(), $(!1)) : t.key === "Escape" && (D(null), $(!1));
|
|
1740
1742
|
}, pn = {
|
|
@@ -1750,19 +1752,21 @@ const se = xn(
|
|
|
1750
1752
|
}, hn = /* @__PURE__ */ z(
|
|
1751
1753
|
"div",
|
|
1752
1754
|
{
|
|
1753
|
-
className: `sa-calendar-wrapper${
|
|
1755
|
+
className: `sa-calendar-wrapper${K ? " sa-calendar-wrapper-custom" : ""}`,
|
|
1754
1756
|
style: { height: q ? "100%" : "auto" },
|
|
1755
|
-
ref:
|
|
1757
|
+
ref: (t) => {
|
|
1758
|
+
V.current = U ? t : null, typeof B == "function" ? B(t) : B && (B.current = t);
|
|
1759
|
+
},
|
|
1756
1760
|
children: [
|
|
1757
|
-
|
|
1761
|
+
K ? (() => {
|
|
1758
1762
|
if (typeof g == "function")
|
|
1759
1763
|
return g(pn);
|
|
1760
1764
|
if (wn.isValidElement(b)) {
|
|
1761
1765
|
const t = b;
|
|
1762
1766
|
return wn.cloneElement(t, {
|
|
1763
1767
|
onClick: (f) => {
|
|
1764
|
-
var
|
|
1765
|
-
(an = (
|
|
1768
|
+
var P, an;
|
|
1769
|
+
(an = (P = t.props) == null ? void 0 : P.onClick) == null || an.call(P, f), r || nn();
|
|
1766
1770
|
}
|
|
1767
1771
|
});
|
|
1768
1772
|
}
|
|
@@ -1770,7 +1774,7 @@ const se = xn(
|
|
|
1770
1774
|
})() : o ? /* @__PURE__ */ s(
|
|
1771
1775
|
Xn,
|
|
1772
1776
|
{
|
|
1773
|
-
value: x &&
|
|
1777
|
+
value: x && J !== null ? J : X(),
|
|
1774
1778
|
onClick: () => $(!0),
|
|
1775
1779
|
onChange: x ? (t) => D(t.target.value) : () => {
|
|
1776
1780
|
},
|
|
@@ -1781,7 +1785,7 @@ const se = xn(
|
|
|
1781
1785
|
disabled: r,
|
|
1782
1786
|
size: h,
|
|
1783
1787
|
variant: l,
|
|
1784
|
-
status:
|
|
1788
|
+
status: H,
|
|
1785
1789
|
inputMode: x ? "text" : "none",
|
|
1786
1790
|
readOnly: !x,
|
|
1787
1791
|
clearable: w,
|
|
@@ -1801,8 +1805,8 @@ const se = xn(
|
|
|
1801
1805
|
setViews: L,
|
|
1802
1806
|
views: Y,
|
|
1803
1807
|
filter: a,
|
|
1804
|
-
previewDate:
|
|
1805
|
-
setPreviewDate:
|
|
1808
|
+
previewDate: W,
|
|
1809
|
+
setPreviewDate: A,
|
|
1806
1810
|
isComponentVisible: F
|
|
1807
1811
|
}
|
|
1808
1812
|
),
|
|
@@ -1811,8 +1815,8 @@ const se = xn(
|
|
|
1811
1815
|
{
|
|
1812
1816
|
date: S,
|
|
1813
1817
|
setDate: I,
|
|
1814
|
-
previewDate:
|
|
1815
|
-
setPreviewDate:
|
|
1818
|
+
previewDate: W,
|
|
1819
|
+
setPreviewDate: A,
|
|
1816
1820
|
setIsComponentVisible: $,
|
|
1817
1821
|
input: o,
|
|
1818
1822
|
minDate: d,
|
|
@@ -1825,8 +1829,8 @@ const se = xn(
|
|
|
1825
1829
|
{
|
|
1826
1830
|
date: S,
|
|
1827
1831
|
setDate: I,
|
|
1828
|
-
previewDate:
|
|
1829
|
-
setPreviewDate:
|
|
1832
|
+
previewDate: W,
|
|
1833
|
+
setPreviewDate: A,
|
|
1830
1834
|
filter: a,
|
|
1831
1835
|
setViews: L,
|
|
1832
1836
|
onChange: e,
|
|
@@ -1840,8 +1844,8 @@ const se = xn(
|
|
|
1840
1844
|
{
|
|
1841
1845
|
date: S,
|
|
1842
1846
|
setDate: I,
|
|
1843
|
-
previewDate:
|
|
1844
|
-
setPreviewDate:
|
|
1847
|
+
previewDate: W,
|
|
1848
|
+
setPreviewDate: A,
|
|
1845
1849
|
filter: a,
|
|
1846
1850
|
setViews: L,
|
|
1847
1851
|
onChange: e,
|
|
@@ -1899,9 +1903,9 @@ const se = xn(
|
|
|
1899
1903
|
optional: k,
|
|
1900
1904
|
description: v,
|
|
1901
1905
|
helperText: N,
|
|
1902
|
-
errorText:
|
|
1903
|
-
},
|
|
1904
|
-
const
|
|
1906
|
+
errorText: B
|
|
1907
|
+
}, H) => {
|
|
1908
|
+
const V = {
|
|
1905
1909
|
onChange: e,
|
|
1906
1910
|
value: n,
|
|
1907
1911
|
input: o,
|
|
@@ -1925,9 +1929,9 @@ const se = xn(
|
|
|
1925
1929
|
optional: k,
|
|
1926
1930
|
description: v,
|
|
1927
1931
|
helperText: N,
|
|
1928
|
-
errorText:
|
|
1932
|
+
errorText: B
|
|
1929
1933
|
};
|
|
1930
|
-
return /* @__PURE__ */ s(yn, { children: r ? /* @__PURE__ */ s(_n, { ...
|
|
1934
|
+
return /* @__PURE__ */ s(yn, { children: r ? /* @__PURE__ */ s(_n, { ...V, ref: H }) : /* @__PURE__ */ s(se, { ...V, ref: H }) });
|
|
1931
1935
|
}
|
|
1932
1936
|
), oe = `/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
1933
1937
|
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
@@ -2060,7 +2064,7 @@ const se = xn(
|
|
|
2060
2064
|
.sa-time-input-wrap {
|
|
2061
2065
|
width: 100%;
|
|
2062
2066
|
}
|
|
2063
|
-
`, Nn = (n, e, a) => Math.min(a, Math.max(e, n)),
|
|
2067
|
+
`, Nn = (n, e, a) => Math.min(a, Math.max(e, n)), R = (n) => String(n).padStart(2, "0"), Mn = (n) => {
|
|
2064
2068
|
if (!n)
|
|
2065
2069
|
return null;
|
|
2066
2070
|
const e = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(n.trim());
|
|
@@ -2068,13 +2072,13 @@ const se = xn(
|
|
|
2068
2072
|
return null;
|
|
2069
2073
|
const a = Number(e[1]), o = Number(e[2]), r = e[3] != null ? Number(e[3]) : 0;
|
|
2070
2074
|
return a > 23 || o > 59 || r > 59 ? null : { h: a, m: o, s: r };
|
|
2071
|
-
}, le = (n, e) => e ? `${
|
|
2072
|
-
const o = a ? `:${
|
|
2075
|
+
}, le = (n, e) => e ? `${R(n.h)}:${R(n.m)}:${R(n.s)}` : `${R(n.h)}:${R(n.m)}`, Z = (n) => n.h * 60 + n.m, ie = (n, e, a) => {
|
|
2076
|
+
const o = a ? `:${R(n.s)}` : "";
|
|
2073
2077
|
if (e === "12h") {
|
|
2074
2078
|
const r = n.h >= 12 ? "PM" : "AM", d = n.h % 12 === 0 ? 12 : n.h % 12;
|
|
2075
|
-
return `${
|
|
2079
|
+
return `${R(d)}:${R(n.m)}${o} ${r}`;
|
|
2076
2080
|
}
|
|
2077
|
-
return `${
|
|
2081
|
+
return `${R(n.h)}:${R(n.m)}${o}`;
|
|
2078
2082
|
}, de = (n, e, a) => {
|
|
2079
2083
|
const o = n.toLowerCase(), r = /p/.test(o) ? "pm" : /a/.test(o) ? "am" : null, d = o.replace(/[^\d]/g, "");
|
|
2080
2084
|
if (!d)
|
|
@@ -2091,14 +2095,14 @@ const se = xn(
|
|
|
2091
2095
|
for (let o = 0; o < n; o += e)
|
|
2092
2096
|
a.push(o);
|
|
2093
2097
|
return a;
|
|
2094
|
-
},
|
|
2098
|
+
}, jn = (n, e) => {
|
|
2095
2099
|
if (typeof document > "u" || document.getElementById(n))
|
|
2096
2100
|
return;
|
|
2097
2101
|
const a = document.createElement("style");
|
|
2098
2102
|
a.id = n, a.textContent = e, document.head.appendChild(a);
|
|
2099
2103
|
};
|
|
2100
|
-
|
|
2101
|
-
|
|
2104
|
+
jn("sa-calendar-styles", gn);
|
|
2105
|
+
jn("sa-time-styles", oe);
|
|
2102
2106
|
const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /* @__PURE__ */ s("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ s(
|
|
2103
2107
|
"path",
|
|
2104
2108
|
{
|
|
@@ -2118,7 +2122,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2118
2122
|
}
|
|
2119
2123
|
) }), vn = ({ label: n, options: e, active: a, onPick: o }) => {
|
|
2120
2124
|
const r = _(null), d = _(null);
|
|
2121
|
-
return
|
|
2125
|
+
return O(() => {
|
|
2122
2126
|
var i;
|
|
2123
2127
|
(i = d.current) == null || i.scrollIntoView({ block: "nearest" });
|
|
2124
2128
|
}, [a]), /* @__PURE__ */ z("div", { className: "sa-time-col", children: [
|
|
@@ -2165,29 +2169,29 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2165
2169
|
helperText: k,
|
|
2166
2170
|
errorText: v
|
|
2167
2171
|
}, N) => {
|
|
2168
|
-
const
|
|
2169
|
-
|
|
2172
|
+
const B = v ? "error" : E, { ref: H, isComponentVisible: V, setIsComponentVisible: F } = En(!1), $ = _(null), m = tn(() => Mn(n), [n]), Y = tn(() => Mn(d), [d]), L = tn(() => Mn(i), [i]), [S, I] = G(null);
|
|
2173
|
+
O(() => {
|
|
2170
2174
|
p || F(!0);
|
|
2171
2175
|
}, [p]);
|
|
2172
|
-
const
|
|
2173
|
-
if (!$.current || !
|
|
2176
|
+
const W = () => {
|
|
2177
|
+
if (!$.current || !H.current || !p)
|
|
2174
2178
|
return;
|
|
2175
|
-
const t =
|
|
2179
|
+
const t = H.current.getBoundingClientRect(), f = $.current.getBoundingClientRect();
|
|
2176
2180
|
$.current.style.left = window.innerWidth < t.left + f.width ? `${t.left - f.width + t.width}px` : `${t.left}px`, $.current.style.top = t.top + f.height > window.innerHeight ? `${t.y - (t.height + f.height - 28)}px` : `${t.y + t.height}px`;
|
|
2177
2181
|
};
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
}, [
|
|
2181
|
-
window.removeEventListener("scroll",
|
|
2182
|
+
O(() => {
|
|
2183
|
+
W();
|
|
2184
|
+
}, [V]), O(() => (window.addEventListener("scroll", W, !0), window.addEventListener("resize", W), () => {
|
|
2185
|
+
window.removeEventListener("scroll", W, !0), window.removeEventListener("resize", W);
|
|
2182
2186
|
}), []);
|
|
2183
|
-
const
|
|
2187
|
+
const A = (t) => {
|
|
2184
2188
|
const f = Z(t);
|
|
2185
2189
|
return !(Y && f < Z(Y) || L && f > Z(L));
|
|
2186
|
-
},
|
|
2190
|
+
}, J = (t) => {
|
|
2187
2191
|
e(le(t, o)), I(null);
|
|
2188
2192
|
}, D = (t) => {
|
|
2189
|
-
|
|
2190
|
-
},
|
|
2193
|
+
J({ ...m ?? { h: 0, m: 0, s: 0 }, ...t });
|
|
2194
|
+
}, K = () => {
|
|
2191
2195
|
if (S == null)
|
|
2192
2196
|
return;
|
|
2193
2197
|
if (S.trim() === "") {
|
|
@@ -2195,51 +2199,51 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2195
2199
|
return;
|
|
2196
2200
|
}
|
|
2197
2201
|
const t = de(S, a, o);
|
|
2198
|
-
t &&
|
|
2199
|
-
}, q = m ? ie(m, a, o) : "", U = S ?? q, X = c && !!m && !l,
|
|
2200
|
-
const f = t === 0 ? 12 : t,
|
|
2202
|
+
t && A(t) ? J(t) : I(null);
|
|
2203
|
+
}, q = m ? ie(m, a, o) : "", U = S ?? q, X = c && !!m && !l, j = m && m.h >= 12 ? "PM" : "AM", ln = tn(() => a === "12h" ? mn(12).map((t) => {
|
|
2204
|
+
const f = t === 0 ? 12 : t, P = j === "PM" ? f % 12 + 12 : f % 12;
|
|
2201
2205
|
return {
|
|
2202
2206
|
value: f,
|
|
2203
|
-
label:
|
|
2204
|
-
disabled: Y &&
|
|
2207
|
+
label: R(f),
|
|
2208
|
+
disabled: Y && P * 60 + 59 < Z(Y) || L && P * 60 > Z(L) || !1
|
|
2205
2209
|
};
|
|
2206
2210
|
}) : mn(24).map((t) => ({
|
|
2207
2211
|
value: t,
|
|
2208
|
-
label:
|
|
2212
|
+
label: R(t),
|
|
2209
2213
|
disabled: Y && t * 60 + 59 < Z(Y) || L && t * 60 > Z(L) || !1
|
|
2210
|
-
})), [a,
|
|
2214
|
+
})), [a, j, Y, L]), dn = tn(() => {
|
|
2211
2215
|
const t = (m == null ? void 0 : m.h) ?? 0;
|
|
2212
2216
|
return mn(60, r).map((f) => ({
|
|
2213
2217
|
value: f,
|
|
2214
|
-
label:
|
|
2218
|
+
label: R(f),
|
|
2215
2219
|
disabled: Y && t * 60 + f < Z(Y) || L && t * 60 + f > Z(L) || !1
|
|
2216
2220
|
}));
|
|
2217
2221
|
}, [r, m == null ? void 0 : m.h, Y, L]), nn = tn(
|
|
2218
|
-
() => mn(60).map((t) => ({ value: t, label:
|
|
2222
|
+
() => mn(60).map((t) => ({ value: t, label: R(t) })),
|
|
2219
2223
|
[]
|
|
2220
2224
|
), cn = m == null ? null : a === "12h" ? m.h % 12 === 0 ? 12 : m.h % 12 : m.h, en = (t) => {
|
|
2221
2225
|
if (a === "12h") {
|
|
2222
|
-
const f =
|
|
2226
|
+
const f = j === "PM" ? t % 12 + 12 : t % 12;
|
|
2223
2227
|
D({ h: f });
|
|
2224
2228
|
} else
|
|
2225
2229
|
D({ h: t });
|
|
2226
2230
|
}, un = (t) => {
|
|
2227
|
-
const f = m ?? { h: 0, m: 0, s: 0 },
|
|
2228
|
-
|
|
2231
|
+
const f = m ?? { h: 0, m: 0, s: 0 }, P = f.h % 12 === 0 ? 12 : f.h % 12, an = t === "PM" ? P % 12 + 12 : P % 12;
|
|
2232
|
+
J({ ...f, h: an });
|
|
2229
2233
|
}, pn = () => {
|
|
2230
2234
|
const t = /* @__PURE__ */ new Date(), f = Math.floor(t.getMinutes() / r) * r;
|
|
2231
|
-
|
|
2235
|
+
J({ h: t.getHours(), m: f, s: o ? t.getSeconds() : 0 });
|
|
2232
2236
|
}, fn = ce(w), hn = /* @__PURE__ */ z(
|
|
2233
2237
|
"div",
|
|
2234
2238
|
{
|
|
2235
2239
|
className: "sa-calendar-wrapper",
|
|
2236
2240
|
style: { height: p ? "auto" : "100%" },
|
|
2237
|
-
ref: p ?
|
|
2241
|
+
ref: p ? H : null,
|
|
2238
2242
|
children: [
|
|
2239
2243
|
p ? /* @__PURE__ */ z(
|
|
2240
2244
|
"div",
|
|
2241
2245
|
{
|
|
2242
|
-
className: `sa-calendar-input-container sa-calendar-input-${M} sa-calendar-input-container-${
|
|
2246
|
+
className: `sa-calendar-input-container sa-calendar-input-${M} sa-calendar-input-container-${B || "default"} ${w}`,
|
|
2243
2247
|
onClick: () => !l && F(!0),
|
|
2244
2248
|
children: [
|
|
2245
2249
|
/* @__PURE__ */ s("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ s(Bn, { s: fn }) }),
|
|
@@ -2252,9 +2256,9 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2252
2256
|
disabled: l,
|
|
2253
2257
|
onChange: (t) => I(t.target.value),
|
|
2254
2258
|
onFocus: () => F(!0),
|
|
2255
|
-
onBlur:
|
|
2259
|
+
onBlur: K,
|
|
2256
2260
|
onKeyDown: (t) => {
|
|
2257
|
-
t.key === "Enter" && (
|
|
2261
|
+
t.key === "Enter" && (K(), F(!1)), t.key === "Escape" && (I(null), F(!1));
|
|
2258
2262
|
}
|
|
2259
2263
|
}
|
|
2260
2264
|
) }),
|
|
@@ -2273,7 +2277,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2273
2277
|
]
|
|
2274
2278
|
}
|
|
2275
2279
|
) : null,
|
|
2276
|
-
|
|
2280
|
+
V ? /* @__PURE__ */ z(
|
|
2277
2281
|
"div",
|
|
2278
2282
|
{
|
|
2279
2283
|
ref: $,
|
|
@@ -2322,7 +2326,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2322
2326
|
{ value: 0, label: "AM" },
|
|
2323
2327
|
{ value: 1, label: "PM" }
|
|
2324
2328
|
],
|
|
2325
|
-
active: m == null ? null :
|
|
2329
|
+
active: m == null ? null : j === "PM" ? 1 : 0,
|
|
2326
2330
|
onPick: (t) => un(t === 1 ? "PM" : "AM")
|
|
2327
2331
|
}
|
|
2328
2332
|
)
|
package/dist/date.umd.js
CHANGED
|
@@ -597,7 +597,7 @@
|
|
|
597
597
|
width: 32px;
|
|
598
598
|
height: 32px;
|
|
599
599
|
}
|
|
600
|
-
`,$n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],_=["January","February","March","April","May","June","July","August","September","October","November","December"],Bn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function vn(n){const[a,r]=g.useState(n),o=g.useRef(null),s=d=>{o.current&&!o.current.contains(d.target)&&r(!1)};return g.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:o,isComponentVisible:a,setIsComponentVisible:r}}const Cn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Cn)){const a=document.createElement("style");a.id=Cn,a.textContent=n,document.head.appendChild(a)}})(sn);const an=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},Vn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Pn=({date:n,setDate:a,dateRange:r,setDateRange:o,onChange:s,minDate:d,maxDate:i,input:p})=>{var T,w,M;const[h,l]=g.useState(null);let c=new Date(n.getFullYear(),n.getMonth(),1),x=c.getDay(),$=[];const E=n.getMonth(),k=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let m=0;m<42;m++){m===0&&x===0?c.setDate(c.getDate()-7):m===0?c.setDate(c.getDate()+(m-x)):c.setDate(c.getDate()+1);let N={currentMonth:c.getMonth()===E,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((T=r.from)==null?void 0:T.toDateString())||c.toDateString()===(((w=r.to)==null?void 0:w.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(N)}const u=m=>{a(m)},C=m=>{let N={...r};if(N.from&&N.to)N={from:m,to:null};else if(!N.from)N={from:m,to:null};else{const q=N.from.getTime();m.getTime()>q?N={from:N.from,to:m}:N={from:m,to:N.from}}o(N),s(N)};return e.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>l(null),children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((m,N)=>e.jsx("p",{children:m},N))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((m,N)=>{const q=r.from&&r.to&&m.date.getTime()>r.from.getTime()&&m.date.getTime()<r.to.getTime(),A=(()=>{if(!v||!r.from)return!1;const S=m.date.getTime(),Y=r.from.getTime(),L=v.getTime();return L>Y?S>Y&&S<L:S<Y&&S>L})(),B=y&&h&&m.date.toDateString()===h.toDateString(),F=m.isDisabled,D=()=>q||A?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",b=()=>F?"var(--sa-color-gray-400, #b7b9be)":q||A?"var(--sa-color-gray-500, #8c8f97)":"";return e.jsx("p",{className:`${m.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${m.selected||B?"sa-calendar-days-active":""} ${m.isToday&&!m.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:D(),pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",color:b(),opacity:B&&!m.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{F||(u(m.date),C(m.date))},onMouseEnter:()=>{F||l(m.date)},children:m.number},N)})})]})},jn=({date:n,setDate:a,filter:r,setViews:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var k;const c=(k=s.from)==null?void 0:k.getFullYear(),x=n.getFullYear(),$=y=>{r?(E(y),a(y)):(o("days"),a(y))},E=y=>{let v={...s};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const u=v.from.getTime();y.getTime()>u?v={from:v.from,to:y}:v={from:y,to:v.from}}d(v),i(v)};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{var T,w,M;const u=s.from!=null&&new Date(x,v).getTime()>s.from.getTime()&&new Date(x,v).getTime()<(((T=s.to)==null?void 0:T.getTime())||s.from.getTime()),C=p&&new Date(x,v)<p||h&&new Date(x,v)>h;return e.jsx("p",{className:c===x&&(v===((w=s.from)==null?void 0:w.getMonth())||v===((M=s.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:u?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:C?"none":void 0,cursor:C?"not-allowed":"pointer",color:C?"var(--sa-color-gray-400, #b7b9be)":u?"var(--sa-color-gray-500, #8c8f97)":"",...l?{}:{width:"100%"}},onClick:()=>{C||$(new Date(x,v))},children:y.slice(0,3)},v)})})},bn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},On=({date:n,filter:a,setViews:r,setDate:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var C,T;let c=[];const x=n.getFullYear(),{start:$,end:E}=bn(x),k=(C=s.from)==null?void 0:C.getFullYear(),y=(T=s.to)==null?void 0:T.getFullYear();for(let w=$;w<E;w++){const M=new Date(w,0),m=(!p||M>=p)&&(!h||M<=h),N=k!=null&&w===k||y!=null&&w===y,q=s.from!=null&&s.to!=null&&M>s.from&&M<s.to;c.push({year:w,active:N&&m,highlight:q&&m,disabled:!m})}const v=w=>{a?(u(w),o(w)):(o(w),r("months"))},u=w=>{let M={...s};if(M.from&&M.to)M={from:w,to:null};else if(!M.from)M={from:w,to:null};else{const m=M.from.getTime();w.getTime()>m?M={from:M.from,to:w}:M={from:w,to:M.from}}d(M),i(M)};return e.jsx("div",{className:"sa-calendar-years-preview",children:c.map((w,M)=>e.jsx("p",{className:`${w.active?"sa-calendar-months-active":""} ${w.highlight?"sa-calendar-months-highlight":""} ${w.disabled?"sa-calendar-disabled":""}`,onClick:()=>{w.disabled||v(new Date(w.year,0))},style:{backgroundColor:w.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:w.highlight?"var(--sa-color-gray-500, #8c8f97)":w.active?"":w.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:w.disabled?"not-allowed":"pointer",pointerEvents:w.disbled?"none":"all",...l?{}:{width:"100%"}},children:w.year},M))})},Dn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),zn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),An=({setViews:n,views:a,filter:r,date:o,setDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${bn(o.getFullYear()).start} ~ ${bn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})};function rn(n){const a=new Date(n),r=a.getFullYear(),o=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${Bn[o]} ${r}`}const En=(()=>{const n={};return _.forEach((a,r)=>{n[a.toLowerCase()]=r,n[a.slice(0,3).toLowerCase()]=r}),n})(),mn=n=>n<100?2e3+n:n;function yn(n,a){const r=String(n.getDate()).padStart(2,"0"),o=String(n.getMonth()+1).padStart(2,"0"),s=n.getFullYear();return a==="years"?`${s}`:a==="months"?`${o}/${s}`:`${r}/${o}/${s}`}function Hn(n,a){const r=n.from?yn(n.from,a):"",o=n.to?yn(n.to,a):"";return r?o?`${r} ~ ${o}`:r:""}function fn(n,a){const r=n.trim().toLowerCase().split(/[\s/.\-,]+/).filter(Boolean);if(!r.length)return null;let o=null;const s=[];for(const c of r)c in En?o=En[c]:/^\d+$/.test(c)&&s.push(parseInt(c,10));if(a==="years"){const c=s[0];return c==null?null:new Date(mn(c),0,1)}if(a==="months"){const c=o??s[0]-1,x=o!=null?s[0]:s[1];return c==null||isNaN(c)||c<0||c>11||x==null?null:new Date(mn(x),c,1)}let d,i,p;if(o!=null?(d=s[0],p=s[1],i=o):(d=s[0],i=s[1]!=null?s[1]-1:void 0,p=s[2]),d==null||i==null||p==null)return null;const h=mn(p),l=new Date(h,i,d);return l.getFullYear()!==h||l.getMonth()!==i||l.getDate()!==d?null:l}function Wn(n,a){const r=n.indexOf("~");if(r===-1){const d=fn(n,a);return d?{from:d,to:null}:null}const o=fn(n.slice(0,r),a);if(!o)return null;const s=fn(n.slice(r+1),a);return{from:o,to:s??null}}function wn(n,a,r){const o=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime(),s=o(n);return!(a&&s<o(a)||r&&s>o(r))}const xn=({label:n,labelPosition:a="outside-top",required:r,optional:o,description:s,helperText:d,errorText:i,fullWidth:p,size:h="sm",children:l})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),x=n?e.jsxs("div",{className:"sa-date-field-label-row",children:[e.jsx("span",{className:"sa-date-field-label-text",children:n}),o&&e.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&e.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,$=e.jsxs(e.Fragment,{children:[d&&!i&&e.jsx("p",{className:"sa-date-field-helper",children:d}),i&&e.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return n?a==="outside-left"?e.jsxs("div",{className:`${c} sa-date-field-left`,children:[e.jsxs("div",{className:"sa-date-field-left-label",children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s})]}),e.jsxs("div",{className:"sa-date-field-input-wrap",children:[l,$]})]}):e.jsxs("div",{className:c,children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]}):e.jsxs("div",{className:c,children:[s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]})},Sn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Sn)){const a=document.createElement("style");a.id=Sn,a.textContent=n,document.head.appendChild(a)}})(sn);const Jn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},q)=>{const A=N?"error":c,{ref:B,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),H=typeof v=="function"||y!=null,j=!o&&!H,W=!j,[z,J]=g.useState({from:(n==null?void 0:n.from)??null,to:(n==null?void 0:n.to)??null}),[K,U]=g.useState(null);g.useEffect(()=>{if(n){const t=n;t.from&&I(t.from),J(t)}else I(new Date),J({from:null,to:null});U(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{j&&D(!0)},[j]);const Q=()=>{var t,f;if(!n)return"";if(r){if(S==="days")return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`;if(S==="months")return`${_[z.from.getMonth()]} ~ ${z.to?_[z.to.getMonth()]:"-"}`;if(S==="years")return`${(t=z.from)==null?void 0:t.getFullYear()} ~ ${((f=z.to)==null?void 0:f.getFullYear())||"-"}`}else return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`},P=()=>{if(b.current&&B.current&&W){const t=B.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&B.current&&W&&P()},[b,B,F]),g.useEffect(()=>(window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&U(Hn(z,r))},R=()=>{if(K===null)return;const t=K.trim();if(!t){a(void 0),U(null);return}const f=Wn(t,r),V=f&&wn(f.from,d,i)&&(!f.to||wn(f.to,d,i));f&&V&&(a(f),J(f),I(f.from)),U(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(U(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var V,en;(en=(V=t.props)==null?void 0:V.onClick)==null||en.call(V,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${H?" sa-calendar-wrapper-custom":""}`,style:{height:j?"100%":"auto"},ref:W?B:null,children:[H?nn():o?e.jsx(Vn,{value:k&&K!==null?K:Q(),inputMode:k?"text":"none",readOnly:!k,onClick:()=>{D(!0)},onChange:k?t=>U(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,disabled:s,placeholder:p,size:h,variant:l,status:A,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${j?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(An,{setViews:Y,views:S,filter:r,date:L,setDate:I}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Pn,{date:L,setDate:I,setIsComponentVisible:D,dateRange:z,setDateRange:J,input:o,onChange:a,minDate:d,maxDate:i}):S==="months"?e.jsx(jn,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:J,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i}):e.jsx(On,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:J,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Yn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Yn)){const a=document.createElement("style");a.id=Yn,a.textContent=n,document.head.appendChild(a)}})(sn);const tn=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},qn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Kn=({date:n,setDate:a,previewDate:r,setPreviewDate:o,setIsComponentVisible:s,minDate:d,maxDate:i,input:p,onChange:h,hasValue:l})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),x=c.getDay(),$=[];const E=n.toDateString(),k=new Date().toDateString(),y=r.getMonth();for(let u=0;u<42;u++){u===0&&x===0?c.setDate(c.getDate()-7):u===0?c.setDate(c.getDate()+(u-x)):c.setDate(c.getDate()+1);let C={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:l&&c.toDateString()===E,isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(C)}const v=u=>{(!d||u>=d)&&(!i||u<=i)&&(a(u),h(u),o(u),p&&s(!1))};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((u,C)=>e.jsx("p",{children:u},C))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((u,C)=>{const T=u.isDisabled;return e.jsx("p",{className:`${u.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${u.selected?"sa-calendar-days-active":""} ${u.isToday&&!u.selected?"sa-calendar-days-today":""}`,style:{color:T?"#ccc":void 0,pointerEvents:T?"none":void 0,cursor:T?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{T||v(u.date)},children:u.number},C)})})]})},Un=({date:n,setDate:a,filter:r,setViews:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{const x=n.getMonth(),$=n.getFullYear(),E=d.getFullYear(),k=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(s(y),a(y),i(y)):(o("days"),i(y)))};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{const u=p&&new Date(E,v,1)<p||h&&new Date(E,v+1,0)>h;return e.jsx("p",{className:c&&v===x&&E===$?"sa-calendar-months-active":"",style:{color:u?"#ccc":void 0,pointerEvents:u?"none":void 0,cursor:u?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u||k(new Date(E,v))},children:y.slice(0,3)},v)})})},kn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},Gn=({date:n,filter:a,setViews:r,setDate:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{let x=[];const $=d.getFullYear(),{start:E,end:k}=kn($),y=n.getFullYear();for(let u=E;u<k;u++){let C=p&&new Date(u,0,1)<p||h&&new Date(u,11,31)>h;x.push({year:u,active:!!c&&u===y,isDisabled:C})}const v=u=>{(!p||u>=p)&&(!h||u<=h)&&(a?(s(u),o(u),i(u)):(r("months"),i(u)))};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((u,C)=>e.jsx("p",{className:u.active?"sa-calendar-months-active":"",style:{color:u.isDisabled?"#ccc":void 0,pointerEvents:u.isDisabled?"none":void 0,cursor:u.isDisabled?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u.isDisabled||v(new Date(u.year,0))},children:u.year},C))})},Zn=({setViews:n,views:a,filter:r,previewDate:o,setPreviewDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${kn(o.getFullYear()).start} ~ ${kn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})},Fn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Fn)){const a=document.createElement("style");a.id=Fn,a.textContent=n,document.head.appendChild(a)}})(sn);const _n=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},q)=>{const A=N?"error":c,{ref:B,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),[H,j]=g.useState(new Date),[W,z]=g.useState(null),J=typeof v=="function"||y!=null,K=!o&&!J,U=!K;g.useEffect(()=>{n?(I(n),j(n)):(I(new Date),j(new Date)),z(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{K&&D(!0)},[K]);const Q=()=>n?r==="days"?rn(L):r==="months"?`${_[L.getMonth()]} ${L.getFullYear()}`:r==="years"?L.getFullYear():rn(L):"",P=()=>{if(b.current&&B.current&&U){const t=B.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&B.current&&U&&P()},[b,B,F]),g.useEffect(()=>(window.addEventListener("scroll",P,!0),window.addEventListener("resize",P),()=>{window.removeEventListener("scroll",P,!0),window.removeEventListener("resize",P)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&z(n?yn(n,r):"")},R=()=>{if(W===null)return;const t=W.trim();if(!t){a(void 0),z(null);return}const f=fn(t,r);f&&wn(f,d,i)&&(a(f),I(f),j(f)),z(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(z(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var V,en;(en=(V=t.props)==null?void 0:V.onClick)==null||en.call(V,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${J?" sa-calendar-wrapper-custom":""}`,style:{height:K?"100%":"auto"},ref:U?B:null,children:[J?nn():o?e.jsx(qn,{value:k&&W!==null?W:Q(),onClick:()=>D(!0),onChange:k?t=>z(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,placeholder:p,disabled:s,size:h,variant:l,status:A,inputMode:k?"text":"none",readOnly:!k,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${K?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(Zn,{setViews:Y,views:S,filter:r,previewDate:H,setPreviewDate:j,isComponentVisible:F}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Kn,{date:L,setDate:I,previewDate:H,setPreviewDate:j,setIsComponentVisible:D,input:o,minDate:d,maxDate:i,onChange:a,hasValue:n!=null}):S==="months"?e.jsx(Un,{date:L,setDate:I,previewDate:H,setPreviewDate:j,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null}):e.jsx(Gn,{date:L,setDate:I,previewDate:H,setPreviewDate:j,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Qn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,rangedDate:s,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:q},A)=>{const B={onChange:a,value:n,input:o,filter:r,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:q};return e.jsx(e.Fragment,{children:s?e.jsx(Jn,{...B,ref:A}):e.jsx(_n,{...B,ref:A})})}),Xn=`/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
600
|
+
`,$n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],_=["January","February","March","April","May","June","July","August","September","October","November","December"],Bn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function vn(n){const[a,r]=g.useState(n),o=g.useRef(null),s=d=>{o.current&&!o.current.contains(d.target)&&r(!1)};return g.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:o,isComponentVisible:a,setIsComponentVisible:r}}const Cn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Cn)){const a=document.createElement("style");a.id=Cn,a.textContent=n,document.head.appendChild(a)}})(sn);const an=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},Vn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:an(a),height:an(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Pn=({date:n,setDate:a,dateRange:r,setDateRange:o,onChange:s,minDate:d,maxDate:i,input:p})=>{var T,w,M;const[h,l]=g.useState(null);let c=new Date(n.getFullYear(),n.getMonth(),1),x=c.getDay(),$=[];const E=n.getMonth(),k=new Date().toDateString(),y=!!(r.from&&!r.to),v=y&&h?h:null;for(let m=0;m<42;m++){m===0&&x===0?c.setDate(c.getDate()-7):m===0?c.setDate(c.getDate()+(m-x)):c.setDate(c.getDate()+1);let N={currentMonth:c.getMonth()===E,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:c.toDateString()===((T=r.from)==null?void 0:T.toDateString())||c.toDateString()===(((w=r.to)==null?void 0:w.toDateString())||((M=r.from)==null?void 0:M.toDateString())),isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(N)}const u=m=>{a(m)},C=m=>{let N={...r};if(N.from&&N.to)N={from:m,to:null};else if(!N.from)N={from:m,to:null};else{const B=N.from.getTime();m.getTime()>B?N={from:N.from,to:m}:N={from:m,to:N.from}}o(N),s(N)};return e.jsxs("div",{className:"sa-calendar-days-preivew",onMouseLeave:()=>l(null),children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((m,N)=>e.jsx("p",{children:m},N))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((m,N)=>{const B=r.from&&r.to&&m.date.getTime()>r.from.getTime()&&m.date.getTime()<r.to.getTime(),H=(()=>{if(!v||!r.from)return!1;const S=m.date.getTime(),Y=r.from.getTime(),L=v.getTime();return L>Y?S>Y&&S<L:S<Y&&S>L})(),V=y&&h&&m.date.toDateString()===h.toDateString(),F=m.isDisabled,D=()=>B||H?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",b=()=>F?"var(--sa-color-gray-400, #b7b9be)":B||H?"var(--sa-color-gray-500, #8c8f97)":"";return e.jsx("p",{className:`${m.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${m.selected||V?"sa-calendar-days-active":""} ${m.isToday&&!m.selected?"sa-calendar-days-today":""}`,style:{backgroundColor:D(),pointerEvents:F?"none":void 0,cursor:F?"not-allowed":"pointer",color:b(),opacity:V&&!m.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{F||(u(m.date),C(m.date))},onMouseEnter:()=>{F||l(m.date)},children:m.number},N)})})]})},jn=({date:n,setDate:a,filter:r,setViews:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var k;const c=(k=s.from)==null?void 0:k.getFullYear(),x=n.getFullYear(),$=y=>{r?(E(y),a(y)):(o("days"),a(y))},E=y=>{let v={...s};if(v.from&&v.to)v={from:y,to:null};else if(!v.from)v={from:y,to:null};else{const u=v.from.getTime();y.getTime()>u?v={from:v.from,to:y}:v={from:y,to:v.from}}d(v),i(v)};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{var T,w,M;const u=s.from!=null&&new Date(x,v).getTime()>s.from.getTime()&&new Date(x,v).getTime()<(((T=s.to)==null?void 0:T.getTime())||s.from.getTime()),C=p&&new Date(x,v)<p||h&&new Date(x,v)>h;return e.jsx("p",{className:c===x&&(v===((w=s.from)==null?void 0:w.getMonth())||v===((M=s.to)==null?void 0:M.getMonth()))?"sa-calendar-months-active":"",style:{backgroundColor:u?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",pointerEvents:C?"none":void 0,cursor:C?"not-allowed":"pointer",color:C?"var(--sa-color-gray-400, #b7b9be)":u?"var(--sa-color-gray-500, #8c8f97)":"",...l?{}:{width:"100%"}},onClick:()=>{C||$(new Date(x,v))},children:y.slice(0,3)},v)})})},bn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},On=({date:n,filter:a,setViews:r,setDate:o,dateRange:s,setDateRange:d,onChange:i,minDate:p,maxDate:h,input:l})=>{var C,T;let c=[];const x=n.getFullYear(),{start:$,end:E}=bn(x),k=(C=s.from)==null?void 0:C.getFullYear(),y=(T=s.to)==null?void 0:T.getFullYear();for(let w=$;w<E;w++){const M=new Date(w,0),m=(!p||M>=p)&&(!h||M<=h),N=k!=null&&w===k||y!=null&&w===y,B=s.from!=null&&s.to!=null&&M>s.from&&M<s.to;c.push({year:w,active:N&&m,highlight:B&&m,disabled:!m})}const v=w=>{a?(u(w),o(w)):(o(w),r("months"))},u=w=>{let M={...s};if(M.from&&M.to)M={from:w,to:null};else if(!M.from)M={from:w,to:null};else{const m=M.from.getTime();w.getTime()>m?M={from:M.from,to:w}:M={from:w,to:M.from}}d(M),i(M)};return e.jsx("div",{className:"sa-calendar-years-preview",children:c.map((w,M)=>e.jsx("p",{className:`${w.active?"sa-calendar-months-active":""} ${w.highlight?"sa-calendar-months-highlight":""} ${w.disabled?"sa-calendar-disabled":""}`,onClick:()=>{w.disabled||v(new Date(w.year,0))},style:{backgroundColor:w.highlight?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",color:w.highlight?"var(--sa-color-gray-500, #8c8f97)":w.active?"":w.disabled?"var(--sa-color-gray-400, #b7b9be)":"",cursor:w.disabled?"not-allowed":"pointer",pointerEvents:w.disbled?"none":"all",...l?{}:{width:"100%"}},children:w.year},M))})},Dn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),zn=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"var(--sa-color-brand-700, #031f43)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),An=({setViews:n,views:a,filter:r,date:o,setDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${bn(o.getFullYear()).start} ~ ${bn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})};function rn(n){const a=new Date(n),r=a.getFullYear(),o=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${Bn[o]} ${r}`}const En=(()=>{const n={};return _.forEach((a,r)=>{n[a.toLowerCase()]=r,n[a.slice(0,3).toLowerCase()]=r}),n})(),mn=n=>n<100?2e3+n:n;function yn(n,a){const r=String(n.getDate()).padStart(2,"0"),o=String(n.getMonth()+1).padStart(2,"0"),s=n.getFullYear();return a==="years"?`${s}`:a==="months"?`${o}/${s}`:`${r}/${o}/${s}`}function Hn(n,a){const r=n.from?yn(n.from,a):"",o=n.to?yn(n.to,a):"";return r?o?`${r} ~ ${o}`:r:""}function fn(n,a){const r=n.trim().toLowerCase().split(/[\s/.\-,]+/).filter(Boolean);if(!r.length)return null;let o=null;const s=[];for(const c of r)c in En?o=En[c]:/^\d+$/.test(c)&&s.push(parseInt(c,10));if(a==="years"){const c=s[0];return c==null?null:new Date(mn(c),0,1)}if(a==="months"){const c=o??s[0]-1,x=o!=null?s[0]:s[1];return c==null||isNaN(c)||c<0||c>11||x==null?null:new Date(mn(x),c,1)}let d,i,p;if(o!=null?(d=s[0],p=s[1],i=o):(d=s[0],i=s[1]!=null?s[1]-1:void 0,p=s[2]),d==null||i==null||p==null)return null;const h=mn(p),l=new Date(h,i,d);return l.getFullYear()!==h||l.getMonth()!==i||l.getDate()!==d?null:l}function Wn(n,a){const r=n.indexOf("~");if(r===-1){const d=fn(n,a);return d?{from:d,to:null}:null}const o=fn(n.slice(0,r),a);if(!o)return null;const s=fn(n.slice(r+1),a);return{from:o,to:s??null}}function wn(n,a,r){const o=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime(),s=o(n);return!(a&&s<o(a)||r&&s>o(r))}const xn=({label:n,labelPosition:a="outside-top",required:r,optional:o,description:s,helperText:d,errorText:i,fullWidth:p,size:h="sm",children:l})=>{const c=["sa-date-field",`sa-date-field-size-${h}`,p?"sa-date-field-fullwidth":""].filter(Boolean).join(" "),x=n?e.jsxs("div",{className:"sa-date-field-label-row",children:[e.jsx("span",{className:"sa-date-field-label-text",children:n}),o&&e.jsx("span",{className:"sa-date-field-optional-badge",children:"Optional"}),r&&e.jsx("span",{className:"sa-date-field-required",children:"*"})]}):null,$=e.jsxs(e.Fragment,{children:[d&&!i&&e.jsx("p",{className:"sa-date-field-helper",children:d}),i&&e.jsx("p",{className:"sa-date-field-error-msg",children:i})]});return n?a==="outside-left"?e.jsxs("div",{className:`${c} sa-date-field-left`,children:[e.jsxs("div",{className:"sa-date-field-left-label",children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s})]}),e.jsxs("div",{className:"sa-date-field-input-wrap",children:[l,$]})]}):e.jsxs("div",{className:c,children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]}):e.jsxs("div",{className:c,children:[s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,$]})},Sn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Sn)){const a=document.createElement("style");a.id=Sn,a.textContent=n,document.head.appendChild(a)}})(sn);const Jn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),W=typeof v=="function"||y!=null,O=!o&&!W,J=!O,[z,q]=g.useState({from:(n==null?void 0:n.from)??null,to:(n==null?void 0:n.to)??null}),[K,U]=g.useState(null);g.useEffect(()=>{if(n){const t=n;t.from&&I(t.from),q(t)}else I(new Date),q({from:null,to:null});U(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{O&&D(!0)},[O]);const Q=()=>{var t,f;if(!n)return"";if(r){if(S==="days")return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`;if(S==="months")return`${_[z.from.getMonth()]} ~ ${z.to?_[z.to.getMonth()]:"-"}`;if(S==="years")return`${(t=z.from)==null?void 0:t.getFullYear()} ~ ${((f=z.to)==null?void 0:f.getFullYear())||"-"}`}else return`${rn(z.from)} ~ ${rn(z.to||z.from)||"-"}`},j=()=>{if(b.current&&V.current&&J){const t=V.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&V.current&&J&&j()},[b,V,F]),g.useEffect(()=>(window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&U(Hn(z,r))},R=()=>{if(K===null)return;const t=K.trim();if(!t){a(void 0),U(null);return}const f=Wn(t,r),P=f&&wn(f.from,d,i)&&(!f.to||wn(f.to,d,i));f&&P&&(a(f),q(f),I(f.from)),U(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(U(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var P,en;(en=(P=t.props)==null?void 0:P.onClick)==null||en.call(P,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${W?" sa-calendar-wrapper-custom":""}`,style:{height:O?"100%":"auto"},ref:t=>{V.current=J?t:null,typeof B=="function"?B(t):B&&(B.current=t)},children:[W?nn():o?e.jsx(Vn,{value:k&&K!==null?K:Q(),inputMode:k?"text":"none",readOnly:!k,onClick:()=>{D(!0)},onChange:k?t=>U(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,disabled:s,placeholder:p,size:h,variant:l,status:H,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${O?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(An,{setViews:Y,views:S,filter:r,date:L,setDate:I}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Pn,{date:L,setDate:I,setIsComponentVisible:D,dateRange:z,setDateRange:q,input:o,onChange:a,minDate:d,maxDate:i}):S==="months"?e.jsx(jn,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i}):e.jsx(On,{date:L,setDate:I,filter:r,setViews:Y,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Yn="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Yn)){const a=document.createElement("style");a.id=Yn,a.textContent=n,document.head.appendChild(a)}})(sn);const tn=n=>{if(n==="xs")return 14;if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},qn=n=>{const{size:a="sm",status:r="default",variant:o="outline",clearable:s,onClear:d,...i}=n,p=g.useRef(null),h=()=>{p.current&&i.onClick&&(p.current.focus(),i.onClick(""))},l=r==="disable"||i.disabled,c=!!i.value,x=s&&c&&!l,$=E=>{E.stopPropagation(),d==null||d()};return e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${o} sa-calendar-input-container-${r} ${a} `,onClick:h,children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",...i,disabled:l,value:i.value,ref:p})}),x?e.jsx("button",{type:"button","aria-label":"Clear date",className:"sa-calendar-input-clear",onClick:$,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5L15 15M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:tn(a),height:tn(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Kn=({date:n,setDate:a,previewDate:r,setPreviewDate:o,setIsComponentVisible:s,minDate:d,maxDate:i,input:p,onChange:h,hasValue:l})=>{let c=new Date(r.getFullYear(),r.getMonth(),1),x=c.getDay(),$=[];const E=n.toDateString(),k=new Date().toDateString(),y=r.getMonth();for(let u=0;u<42;u++){u===0&&x===0?c.setDate(c.getDate()-7):u===0?c.setDate(c.getDate()+(u-x)):c.setDate(c.getDate()+1);let C={currentMonth:c.getMonth()===y,date:new Date(c),month:c.getMonth(),number:c.getDate(),selected:l&&c.toDateString()===E,isToday:c.toDateString()===k,year:c.getFullYear(),isDisabled:d&&c<d||i&&c>i};$.push(C)}const v=u=>{(!d||u>=d)&&(!i||u<=i)&&(a(u),h(u),o(u),p&&s(!1))};return e.jsxs("div",{className:"sa-calendar-days-preivew",children:[e.jsx("div",{className:"sa-calendar-days-name-preivew",children:$n.map((u,C)=>e.jsx("p",{children:u},C))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:$.map((u,C)=>{const T=u.isDisabled;return e.jsx("p",{className:`${u.currentMonth?"sa-calendar-days-current":"sa-calendar-days"} ${u.selected?"sa-calendar-days-active":""} ${u.isToday&&!u.selected?"sa-calendar-days-today":""}`,style:{color:T?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:T?"none":void 0,cursor:T?"not-allowed":"pointer",...p?{}:{width:"100%"}},onClick:()=>{T||v(u.date)},children:u.number},C)})})]})},Un=({date:n,setDate:a,filter:r,setViews:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{const x=n.getMonth(),$=n.getFullYear(),E=d.getFullYear(),k=y=>{(!p||y>=p)&&(!h||y<=h)&&(r?(s(y),a(y),i(y)):(o("days"),i(y)))};return e.jsx("div",{className:"sa-calendar-months-preview",children:_.map((y,v)=>{const u=p&&new Date(E,v,1)<p||h&&new Date(E,v+1,0)>h;return e.jsx("p",{className:c&&v===x&&E===$?"sa-calendar-months-active":"",style:{color:u?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:u?"none":void 0,cursor:u?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u||k(new Date(E,v))},children:y.slice(0,3)},v)})})},kn=n=>{const a=Math.floor(n/10)*10,r=a+10;return{start:a,end:r}},Gn=({date:n,filter:a,setViews:r,setDate:o,onChange:s,previewDate:d,setPreviewDate:i,minDate:p,maxDate:h,input:l,hasValue:c})=>{let x=[];const $=d.getFullYear(),{start:E,end:k}=kn($),y=n.getFullYear();for(let u=E;u<k;u++){let C=p&&new Date(u,0,1)<p||h&&new Date(u,11,31)>h;x.push({year:u,active:!!c&&u===y,isDisabled:C})}const v=u=>{(!p||u>=p)&&(!h||u<=h)&&(a?(s(u),o(u),i(u)):(r("months"),i(u)))};return e.jsx("div",{className:"sa-calendar-years-preview",children:x.map((u,C)=>e.jsx("p",{className:u.active?"sa-calendar-months-active":"",style:{color:u.isDisabled?"var(--sa-text-disable, #181a198f)":void 0,pointerEvents:u.isDisabled?"none":void 0,cursor:u.isDisabled?"not-allowed":"pointer",...l?{}:{width:"100%"}},onClick:()=>{u.isDisabled||v(new Date(u.year,0))},children:u.year},C))})},Zn=({setViews:n,views:a,filter:r,previewDate:o,setPreviewDate:s})=>{const d=()=>{r||n(l=>l==="days"?"months":l==="months"?"years":"days")},i=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()+10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()+1,l.getMonth()));return}s(l=>new Date(l.getFullYear(),l.getMonth()+1))},p=()=>{if(a==="years"){s(l=>new Date(l.getFullYear()-10,0));return}if(a==="months"){s(l=>new Date(l.getFullYear()-1,l.getMonth()));return}s(l=>new Date(l.getMonth()===0?l.getFullYear()-1:l.getFullYear(),l.getMonth()===0?11:l.getMonth()-1))},h=()=>{if(a==="days")return`${_[o.getMonth()]} ${o.getFullYear()}`;if(a==="months")return`${o.getFullYear()}`;if(a==="years")return`${kn(o.getFullYear()).start} ~ ${kn(o.getFullYear()).end}`};return e.jsxs("div",{className:"sa-calendar-header",children:[e.jsx("div",{className:"sa-calendar-header-title",onClick:d,children:h()}),e.jsxs("div",{className:"sa-calendar-header-nav",children:[e.jsx("button",{className:"sa-calendar-nav-btn",onClick:p,children:e.jsx(Dn,{})}),e.jsx("button",{className:"sa-calendar-nav-btn",onClick:i,children:e.jsx(zn,{})})]})]})},Fn="sa-calendar-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById(Fn)){const a=document.createElement("style");a.id=Fn,a.textContent=n,document.head.appendChild(a)}})(sn);const _n=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,disabled:s,minDate:d,maxDate:i,placeholder:p,size:h="sm",variant:l,status:c,clearable:x,fullWidth:$=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:F,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,Y]=g.useState("days"),[L,I]=g.useState(new Date),[W,O]=g.useState(new Date),[J,z]=g.useState(null),q=typeof v=="function"||y!=null,K=!o&&!q,U=!K;g.useEffect(()=>{n?(I(n),O(n)):(I(new Date),O(new Date)),z(null)},[n]),g.useEffect(()=>{r&&Y(r)},[r]),g.useEffect(()=>{r||Y("days")},[F]),g.useEffect(()=>{K&&D(!0)},[K]);const Q=()=>n?r==="days"?rn(L):r==="months"?`${_[L.getMonth()]} ${L.getFullYear()}`:r==="years"?L.getFullYear():rn(L):"",j=()=>{if(b.current&&V.current&&U){const t=V.current.getBoundingClientRect(),f=b.current.getBoundingClientRect();window.innerWidth<t.left+f.width?b.current.style.left=`${t.left-f.width+t.width}px`:b.current.style.left=`${t.left}px`,t.top+f.height>window.innerHeight?b.current.style.top=`${t.y-(t.height+f.height-28)}px`:b.current.style.top=`${t.y+t.height}px`}};g.useEffect(()=>{b.current&&V.current&&U&&j()},[b,V,F]),g.useEffect(()=>(window.addEventListener("scroll",j,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",j)}),[]);const on=()=>D(!0),ln=()=>D(!1),X=()=>D(t=>!t),dn=()=>{k&&z(n?yn(n,r):"")},R=()=>{if(J===null)return;const t=J.trim();if(!t){a(void 0),z(null);return}const f=fn(t,r);f&&wn(f,d,i)&&(a(f),I(f),O(f)),z(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(z(null),D(!1))},un={isOpen:F,open:on,close:ln,toggle:X,value:n,formattedValue:String(Q()??""),clear:()=>a(void 0),disabled:s,placeholder:p},nn=()=>{if(typeof v=="function")return v(un);if(g.isValidElement(y)){const t=y;return g.cloneElement(t,{onClick:f=>{var P,en;(en=(P=t.props)==null?void 0:P.onClick)==null||en.call(P,f),s||X()}})}return y},pn=e.jsxs("div",{className:`sa-calendar-wrapper${q?" sa-calendar-wrapper-custom":""}`,style:{height:K?"100%":"auto"},ref:t=>{V.current=U?t:null,typeof B=="function"?B(t):B&&(B.current=t)},children:[q?nn():o?e.jsx(qn,{value:k&&J!==null?J:Q(),onClick:()=>D(!0),onChange:k?t=>z(t.target.value):()=>{},onFocus:k?dn:void 0,onBlur:k?R:void 0,onKeyDown:k?cn:void 0,placeholder:p,disabled:s,size:h,variant:l,status:H,inputMode:k?"text":"none",readOnly:!k,clearable:x,onClear:()=>a(void 0)}):null,F?e.jsxs("div",{className:`sa-calendar sa-calendar-size-${h||"sm"} ${K?"sa-calendar-no-input":""} ${E?"":"sa-calendar-no-padding"}`,style:s?{pointerEvents:"none"}:void 0,ref:b,children:[e.jsx(Zn,{setViews:Y,views:S,filter:r,previewDate:W,setPreviewDate:O,isComponentVisible:F}),e.jsx("div",{className:"sa-calendar-body",children:S==="days"?e.jsx(Kn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,setIsComponentVisible:D,input:o,minDate:d,maxDate:i,onChange:a,hasValue:n!=null}):S==="months"?e.jsx(Un,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null}):e.jsx(Gn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:Y,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null})})]}):null]});return e.jsx(xn,{label:u,labelPosition:C,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:$,size:h,children:pn})}),Qn=g.forwardRef(({value:n,onChange:a,filter:r,input:o=!0,rangedDate:s,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B},H)=>{const V={onChange:a,value:n,input:o,filter:r,disabled:d,minDate:i,maxDate:p,placeholder:h,size:l,variant:c,status:x,clearable:$,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:C,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B};return e.jsx(e.Fragment,{children:s?e.jsx(Jn,{...V,ref:H}):e.jsx(_n,{...V,ref:H})})}),Xn=`/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
601
601
|
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
602
602
|
.sa-calendar-input-* shells for the box + masked input. */
|
|
603
603
|
|
|
@@ -728,4 +728,4 @@
|
|
|
728
728
|
.sa-time-input-wrap {
|
|
729
729
|
width: 100%;
|
|
730
730
|
}
|
|
731
|
-
`,Mn=(n,a,r)=>Math.min(r,Math.max(a,n)),
|
|
731
|
+
`,Mn=(n,a,r)=>Math.min(r,Math.max(a,n)),A=n=>String(n).padStart(2,"0"),Nn=n=>{if(!n)return null;const a=/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(n.trim());if(!a)return null;const r=Number(a[1]),o=Number(a[2]),s=a[3]!=null?Number(a[3]):0;return r>23||o>59||s>59?null:{h:r,m:o,s}},Rn=(n,a)=>a?`${A(n.h)}:${A(n.m)}:${A(n.s)}`:`${A(n.h)}:${A(n.m)}`,Z=n=>n.h*60+n.m,ne=(n,a,r)=>{const o=r?`:${A(n.s)}`:"";if(a==="12h"){const s=n.h>=12?"PM":"AM",d=n.h%12===0?12:n.h%12;return`${A(d)}:${A(n.m)}${o} ${s}`}return`${A(n.h)}:${A(n.m)}${o}`},ee=(n,a,r)=>{const o=n.toLowerCase(),s=/p/.test(o)?"pm":/a/.test(o)?"am":null,d=o.replace(/[^\d]/g,"");if(!d)return null;let i=0,p=0,h=0;if(n.includes(":")){const l=n.split(":").map(c=>c.replace(/[^\d]/g,""));i=Number(l[0]||0),p=Number(l[1]||0),h=r?Number(l[2]||0):0}else d.length<=2?i=Number(d):d.length<=4?(i=Number(d.slice(0,d.length-2)),p=Number(d.slice(-2))):(i=Number(d.slice(0,d.length-4)),p=Number(d.slice(-4,-2)),h=r?Number(d.slice(-2)):0);return s&&(s==="pm"&&i<12&&(i+=12),s==="am"&&i===12&&(i=0)),i>23||p>59||h>59?null:{h:Mn(i,0,23),m:Mn(p,0,59),s:Mn(h,0,59)}},hn=(n,a=1)=>{const r=[];for(let o=0;o<n;o+=a)r.push(o);return r},Ln=(n,a)=>{if(typeof document>"u"||document.getElementById(n))return;const r=document.createElement("style");r.id=n,r.textContent=a,document.head.appendChild(r)};Ln("sa-calendar-styles",sn),Ln("sa-time-styles",Xn);const ae=n=>n==="xs"?14:n==="lg"?20:16,In=({s:n})=>e.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M10 5v5l3 2M17.5 10a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),re=({s:n})=>e.jsx("svg",{width:n,height:n,viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M5 5l10 10M15 5L5 15",stroke:"var(--sa-color-gray-500, #8c8f97)",strokeWidth:"1.5",strokeLinecap:"round"})}),gn=({label:n,options:a,active:r,onPick:o})=>{const s=g.useRef(null),d=g.useRef(null);return g.useEffect(()=>{var i;(i=d.current)==null||i.scrollIntoView({block:"nearest"})},[r]),e.jsxs("div",{className:"sa-time-col",children:[e.jsx("div",{className:"sa-time-col-head",children:n}),e.jsx("div",{className:"sa-time-col-list",ref:s,children:a.map(i=>{const p=i.value===r;return e.jsx("button",{type:"button",ref:p?d:null,disabled:i.disabled,className:`sa-time-opt${p?" sa-time-opt-active":""}`,onClick:()=>o(i.value),children:i.label},i.value)})})]})},Tn=g.forwardRef(({value:n,onChange:a,format:r="24h",withSeconds:o=!1,step:s=1,minTime:d,maxTime:i,input:p=!0,placeholder:h="--:--",disabled:l,clearable:c,size:x="sm",variant:$="outline",status:E,fullWidth:k=!0,withPadding:y=!0,label:v,labelPosition:u,required:C,optional:T,description:w,helperText:M,errorText:m},N)=>{const B=m?"error":E,{ref:H,isComponentVisible:V,setIsComponentVisible:F}=vn(!1),D=g.useRef(null),b=g.useMemo(()=>Nn(n),[n]),S=g.useMemo(()=>Nn(d),[d]),Y=g.useMemo(()=>Nn(i),[i]),[L,I]=g.useState(null);g.useEffect(()=>{p||F(!0)},[p]);const W=()=>{if(!D.current||!H.current||!p)return;const t=H.current.getBoundingClientRect(),f=D.current.getBoundingClientRect();D.current.style.left=window.innerWidth<t.left+f.width?`${t.left-f.width+t.width}px`:`${t.left}px`,D.current.style.top=t.top+f.height>window.innerHeight?`${t.y-(t.height+f.height-28)}px`:`${t.y+t.height}px`};g.useEffect(()=>{W()},[V]),g.useEffect(()=>(window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}),[]);const O=t=>{const f=Z(t);return!(S&&f<Z(S)||Y&&f>Z(Y))},J=t=>{a(Rn(t,o)),I(null)},z=t=>{J({...b??{h:0,m:0,s:0},...t})},q=()=>{if(L==null)return;if(L.trim()===""){a(null),I(null);return}const t=ee(L,r,o);t&&O(t)?J(t):I(null)},K=b?ne(b,r,o):"",U=L??K,Q=c&&!!b&&!l,j=b&&b.h>=12?"PM":"AM",on=g.useMemo(()=>r==="12h"?hn(12).map(t=>{const f=t===0?12:t,P=j==="PM"?f%12+12:f%12;return{value:f,label:A(f),disabled:S&&P*60+59<Z(S)||Y&&P*60>Z(Y)||!1}}):hn(24).map(t=>({value:t,label:A(t),disabled:S&&t*60+59<Z(S)||Y&&t*60>Z(Y)||!1})),[r,j,S,Y]),ln=g.useMemo(()=>{const t=(b==null?void 0:b.h)??0;return hn(60,s).map(f=>({value:f,label:A(f),disabled:S&&t*60+f<Z(S)||Y&&t*60+f>Z(Y)||!1}))},[s,b==null?void 0:b.h,S,Y]),X=g.useMemo(()=>hn(60).map(t=>({value:t,label:A(t)})),[]),dn=b==null?null:r==="12h"?b.h%12===0?12:b.h%12:b.h,R=t=>{if(r==="12h"){const f=j==="PM"?t%12+12:t%12;z({h:f})}else z({h:t})},cn=t=>{const f=b??{h:0,m:0,s:0},P=f.h%12===0?12:f.h%12,en=t==="PM"?P%12+12:P%12;J({...f,h:en})},un=()=>{const t=new Date,f=Math.floor(t.getMinutes()/s)*s;J({h:t.getHours(),m:f,s:o?t.getSeconds():0})},nn=ae(x),pn=e.jsxs("div",{className:"sa-calendar-wrapper",style:{height:p?"auto":"100%"},ref:p?H:null,children:[p?e.jsxs("div",{className:`sa-calendar-input-container sa-calendar-input-${$} sa-calendar-input-container-${B||"default"} ${x}`,onClick:()=>!l&&F(!0),children:[e.jsx("div",{className:"sa-calendar-input-container-icon-left",children:e.jsx(In,{s:nn})}),e.jsx("div",{className:"sa-calendar-input-preview-container",children:e.jsx("input",{className:"sa-calendar-input",value:U,placeholder:h,disabled:l,onChange:t=>I(t.target.value),onFocus:()=>F(!0),onBlur:q,onKeyDown:t=>{t.key==="Enter"&&(q(),F(!1)),t.key==="Escape"&&(I(null),F(!1))}})}),Q?e.jsx("button",{type:"button","aria-label":"Clear time",className:"sa-calendar-input-clear",onClick:t=>{t.stopPropagation(),a(null),I(null)},children:e.jsx(re,{s:nn})}):e.jsx("div",{className:"sa-calendar-input-container-icon-right",children:e.jsx(In,{s:nn})})]}):null,V?e.jsxs("div",{ref:D,className:`sa-calendar sa-calendar-size-${x} ${p?"":"sa-calendar-no-input"} ${y?"":"sa-calendar-no-padding"}`,style:l?{pointerEvents:"none"}:void 0,children:[e.jsxs("div",{className:"sa-time-columns",children:[e.jsx(gn,{label:"Jam",options:on,active:dn,onPick:R}),e.jsx("div",{className:"sa-time-divider"}),e.jsx(gn,{label:"Menit",options:ln,active:(b==null?void 0:b.m)??null,onPick:t=>z({m:t})}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-time-divider"}),e.jsx(gn,{label:"Detik",options:X,active:(b==null?void 0:b.s)??null,onPick:t=>z({s:t})})]}),r==="12h"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sa-time-divider"}),e.jsx(gn,{label:"",options:[{value:0,label:"AM"},{value:1,label:"PM"}],active:b==null?null:j==="PM"?1:0,onPick:t=>cn(t===1?"PM":"AM")})]})]}),e.jsxs("div",{className:"sa-time-footer",children:[e.jsx("button",{type:"button",className:"sa-time-footer-btn",onClick:un,children:"Sekarang"}),e.jsx("button",{type:"button",className:"sa-time-footer-btn sa-time-footer-btn-muted",onClick:()=>{a(null),I(null)},children:"Hapus"})]})]}):null]});return e.jsx(xn,{label:v,labelPosition:u,required:C,optional:T,description:w,helperText:M,errorText:m,fullWidth:k,size:x,children:pn})});Tn.displayName="StarasiaTime",G.StarasiaDate=Qn,G.StarasiaTime=Tn,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|