@starasia/date 7.0.3 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date.es.js +129 -102
- package/dist/date.umd.js +32 -5
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { jsxs as z, jsx as s, Fragment as yn } from "react/jsx-runtime";
|
|
2
|
-
import wn, { useState as
|
|
3
|
-
const
|
|
2
|
+
import wn, { useState as U, useRef as _, useEffect as O, forwardRef as xn, useMemo as tn } from "react";
|
|
3
|
+
const mn = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
4
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
5
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
6
|
+
@layer starasia.components {
|
|
7
|
+
|
|
8
|
+
|
|
4
9
|
* {
|
|
5
10
|
margin: 0;
|
|
6
11
|
padding: 0;
|
|
@@ -27,6 +32,9 @@ const gn = `
|
|
|
27
32
|
--sa-date-border-warning: var(--sa-color-warning-400, #ed9f30);
|
|
28
33
|
--sa-date-accent-subtle: var(--sa-background-neutral, #f0f1f2);
|
|
29
34
|
--sa-date-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
|
|
35
|
+
/* Batas field (outline/flushed) — ≥ 3:1 terhadap kanvas (WCAG 1.4.11).
|
|
36
|
+
--sa-date-border-color (alpha ≈1.3:1) tetap untuk thumb scrollbar Time. */
|
|
37
|
+
--sa-date-border-field: var(--sa-border-input, #8c8f97);
|
|
30
38
|
}
|
|
31
39
|
.sa-calendar-wrapper {
|
|
32
40
|
position: relative;
|
|
@@ -360,7 +368,7 @@ const gn = `
|
|
|
360
368
|
}
|
|
361
369
|
|
|
362
370
|
.sa-calendar-input-outline {
|
|
363
|
-
border-color: var(--sa-date-border-
|
|
371
|
+
border-color: var(--sa-date-border-field);
|
|
364
372
|
background-color: transparent;
|
|
365
373
|
border-width: var(--sa-border, 1px);
|
|
366
374
|
border-style: solid;
|
|
@@ -410,7 +418,7 @@ const gn = `
|
|
|
410
418
|
border-top: none;
|
|
411
419
|
border-left: none;
|
|
412
420
|
border-right: none;
|
|
413
|
-
border-bottom: 1px solid var(--sa-date-border-
|
|
421
|
+
border-bottom: 1px solid var(--sa-date-border-field);
|
|
414
422
|
border-radius: 0;
|
|
415
423
|
padding-inline: 0;
|
|
416
424
|
}
|
|
@@ -599,6 +607,18 @@ const gn = `
|
|
|
599
607
|
width: 32px;
|
|
600
608
|
height: 32px;
|
|
601
609
|
}
|
|
610
|
+
|
|
611
|
+
/* Forced colors (Windows High Contrast): fokus field ditandai ganti warna
|
|
612
|
+
border + ring box-shadow — keduanya hilang di mode ini. Ganti outline
|
|
613
|
+
warna sistem. */
|
|
614
|
+
@media (forced-colors: active) {
|
|
615
|
+
.sa-calendar-input-container:has(input:focus) {
|
|
616
|
+
outline: 2px solid Highlight;
|
|
617
|
+
outline-offset: 1px;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
} /* @layer starasia.components */
|
|
602
622
|
`, Vn = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], Q = [
|
|
603
623
|
"January",
|
|
604
624
|
"February",
|
|
@@ -627,7 +647,7 @@ const gn = `
|
|
|
627
647
|
"Dec"
|
|
628
648
|
];
|
|
629
649
|
function En(n) {
|
|
630
|
-
const [e, a] =
|
|
650
|
+
const [e, a] = U(n), o = _(null), r = (d) => {
|
|
631
651
|
o.current && !o.current.contains(d.target) && a(!1);
|
|
632
652
|
};
|
|
633
653
|
return O(() => (document.addEventListener("click", r, !0), () => {
|
|
@@ -640,7 +660,7 @@ const Ln = "sa-calendar-input-styles", Hn = (n) => {
|
|
|
640
660
|
e.id = Ln, e.textContent = n, document.head.appendChild(e);
|
|
641
661
|
}
|
|
642
662
|
};
|
|
643
|
-
Hn(
|
|
663
|
+
Hn(mn);
|
|
644
664
|
const rn = (n) => {
|
|
645
665
|
if (n === "xs")
|
|
646
666
|
return 14;
|
|
@@ -761,9 +781,9 @@ const rn = (n) => {
|
|
|
761
781
|
input: p
|
|
762
782
|
}) => {
|
|
763
783
|
var T, y, k;
|
|
764
|
-
const [h, l] =
|
|
784
|
+
const [h, l] = U(null);
|
|
765
785
|
let c = new Date(n.getFullYear(), n.getMonth(), 1), w = c.getDay(), M = [];
|
|
766
|
-
const E = n.getMonth(), x = (/* @__PURE__ */ new Date()).toDateString(), b = !!(a.from && !a.to),
|
|
786
|
+
const E = n.getMonth(), x = (/* @__PURE__ */ new Date()).toDateString(), b = !!(a.from && !a.to), m = b && h ? h : null;
|
|
767
787
|
for (let v = 0; v < 42; v++) {
|
|
768
788
|
v === 0 && w === 0 ? c.setDate(c.getDate() - 7) : v === 0 ? c.setDate(
|
|
769
789
|
c.getDate() + (v - w)
|
|
@@ -803,11 +823,11 @@ const rn = (n) => {
|
|
|
803
823
|
/* @__PURE__ */ s("div", { className: "sa-calendar-days-name-preivew", children: Vn.map((v, N) => /* @__PURE__ */ s("p", { children: v }, N)) }),
|
|
804
824
|
/* @__PURE__ */ s("div", { className: "sa-calendar-days-number-preivew", children: M.map((v, N) => {
|
|
805
825
|
const B = a.from && a.to && v.date.getTime() > a.from.getTime() && v.date.getTime() < a.to.getTime(), H = (() => {
|
|
806
|
-
if (!
|
|
826
|
+
if (!m || !a.from)
|
|
807
827
|
return !1;
|
|
808
|
-
const Y = v.date.getTime(), L = a.from.getTime(), S =
|
|
828
|
+
const Y = v.date.getTime(), L = a.from.getTime(), S = m.getTime();
|
|
809
829
|
return S > L ? Y > L && Y < S : Y < L && Y > S;
|
|
810
|
-
})(), V = b && h && v.date.toDateString() === h.toDateString(), F = v.isDisabled, $ = () => B || H ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
830
|
+
})(), V = b && h && v.date.toDateString() === h.toDateString(), F = v.isDisabled, $ = () => B || H ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", g = () => F ? "var(--sa-color-gray-400, #b7b9be)" : B || H ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
811
831
|
return /* @__PURE__ */ s(
|
|
812
832
|
"p",
|
|
813
833
|
{
|
|
@@ -816,7 +836,7 @@ const rn = (n) => {
|
|
|
816
836
|
backgroundColor: $(),
|
|
817
837
|
pointerEvents: F ? "none" : void 0,
|
|
818
838
|
cursor: F ? "not-allowed" : "pointer",
|
|
819
|
-
color:
|
|
839
|
+
color: g(),
|
|
820
840
|
opacity: V && !v.selected ? 0.75 : 1,
|
|
821
841
|
...p ? {} : { width: "100%" }
|
|
822
842
|
},
|
|
@@ -850,24 +870,24 @@ const rn = (n) => {
|
|
|
850
870
|
const c = (x = r.from) == null ? void 0 : x.getFullYear(), w = n.getFullYear(), M = (b) => {
|
|
851
871
|
a ? (E(b), e(b)) : (o("days"), e(b));
|
|
852
872
|
}, E = (b) => {
|
|
853
|
-
let
|
|
854
|
-
if (
|
|
855
|
-
|
|
856
|
-
else if (!
|
|
857
|
-
|
|
873
|
+
let m = { ...r };
|
|
874
|
+
if (m.from && m.to)
|
|
875
|
+
m = { from: b, to: null };
|
|
876
|
+
else if (!m.from)
|
|
877
|
+
m = { from: b, to: null };
|
|
858
878
|
else {
|
|
859
|
-
const u =
|
|
860
|
-
b.getTime() > u ?
|
|
879
|
+
const u = m.from.getTime();
|
|
880
|
+
b.getTime() > u ? m = { from: m.from, to: b } : m = { from: b, to: m.from };
|
|
861
881
|
}
|
|
862
|
-
d(
|
|
882
|
+
d(m), i(m);
|
|
863
883
|
};
|
|
864
|
-
return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b,
|
|
884
|
+
return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, m) => {
|
|
865
885
|
var T, y, k;
|
|
866
|
-
const u = r.from != null && new Date(w,
|
|
886
|
+
const u = r.from != null && new Date(w, m).getTime() > r.from.getTime() && new Date(w, m).getTime() < (((T = r.to) == null ? void 0 : T.getTime()) || r.from.getTime()), C = p && new Date(w, m) < p || h && new Date(w, m) > h;
|
|
867
887
|
return /* @__PURE__ */ s(
|
|
868
888
|
"p",
|
|
869
889
|
{
|
|
870
|
-
className: c === w && (
|
|
890
|
+
className: c === w && (m === ((y = r.from) == null ? void 0 : y.getMonth()) || m === ((k = r.to) == null ? void 0 : k.getMonth())) ? "sa-calendar-months-active" : "",
|
|
871
891
|
style: {
|
|
872
892
|
backgroundColor: u ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
873
893
|
pointerEvents: C ? "none" : void 0,
|
|
@@ -876,11 +896,11 @@ const rn = (n) => {
|
|
|
876
896
|
...l ? {} : { width: "100%" }
|
|
877
897
|
},
|
|
878
898
|
onClick: () => {
|
|
879
|
-
C || M(new Date(w,
|
|
899
|
+
C || M(new Date(w, m));
|
|
880
900
|
},
|
|
881
901
|
children: b.slice(0, 3)
|
|
882
902
|
},
|
|
883
|
-
|
|
903
|
+
m
|
|
884
904
|
);
|
|
885
905
|
}) });
|
|
886
906
|
}, Cn = (n) => {
|
|
@@ -910,7 +930,7 @@ const rn = (n) => {
|
|
|
910
930
|
disabled: !v
|
|
911
931
|
});
|
|
912
932
|
}
|
|
913
|
-
const
|
|
933
|
+
const m = (y) => {
|
|
914
934
|
e ? (u(y), o(y)) : (o(y), a("months"));
|
|
915
935
|
}, u = (y) => {
|
|
916
936
|
let k = { ...r };
|
|
@@ -929,7 +949,7 @@ const rn = (n) => {
|
|
|
929
949
|
{
|
|
930
950
|
className: `${y.active ? "sa-calendar-months-active" : ""} ${y.highlight ? "sa-calendar-months-highlight" : ""} ${y.disabled ? "sa-calendar-disabled" : ""}`,
|
|
931
951
|
onClick: () => {
|
|
932
|
-
y.disabled ||
|
|
952
|
+
y.disabled || m(new Date(y.year, 0));
|
|
933
953
|
},
|
|
934
954
|
style: {
|
|
935
955
|
backgroundColor: y.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
@@ -982,7 +1002,7 @@ const rn = (n) => {
|
|
|
982
1002
|
}
|
|
983
1003
|
)
|
|
984
1004
|
}
|
|
985
|
-
),
|
|
1005
|
+
), Gn = ({
|
|
986
1006
|
setViews: n,
|
|
987
1007
|
views: e,
|
|
988
1008
|
filter: a,
|
|
@@ -1046,7 +1066,7 @@ function $n(n, e) {
|
|
|
1046
1066
|
const a = String(n.getDate()).padStart(2, "0"), o = String(n.getMonth() + 1).padStart(2, "0"), r = n.getFullYear();
|
|
1047
1067
|
return e === "years" ? `${r}` : e === "months" ? `${o}/${r}` : `${a}/${o}/${r}`;
|
|
1048
1068
|
}
|
|
1049
|
-
function
|
|
1069
|
+
function qn(n, e) {
|
|
1050
1070
|
const a = n.from ? $n(n.from, e) : "", o = n.to ? $n(n.to, e) : "";
|
|
1051
1071
|
return a ? o ? `${a} ~ ${o}` : a : "";
|
|
1052
1072
|
}
|
|
@@ -1072,7 +1092,7 @@ function bn(n, e) {
|
|
|
1072
1092
|
const h = kn(p), l = new Date(h, i, d);
|
|
1073
1093
|
return l.getFullYear() !== h || l.getMonth() !== i || l.getDate() !== d ? null : l;
|
|
1074
1094
|
}
|
|
1075
|
-
function
|
|
1095
|
+
function Un(n, e) {
|
|
1076
1096
|
const a = n.indexOf("~");
|
|
1077
1097
|
if (a === -1) {
|
|
1078
1098
|
const d = bn(n, e);
|
|
@@ -1137,7 +1157,7 @@ const Yn = ({
|
|
|
1137
1157
|
e.id = Sn, e.textContent = n, document.head.appendChild(e);
|
|
1138
1158
|
}
|
|
1139
1159
|
};
|
|
1140
|
-
Zn(
|
|
1160
|
+
Zn(mn);
|
|
1141
1161
|
const _n = xn(
|
|
1142
1162
|
({
|
|
1143
1163
|
value: n,
|
|
@@ -1156,7 +1176,7 @@ const _n = xn(
|
|
|
1156
1176
|
withPadding: E = !0,
|
|
1157
1177
|
editable: x = !1,
|
|
1158
1178
|
trigger: b,
|
|
1159
|
-
renderTrigger:
|
|
1179
|
+
renderTrigger: m,
|
|
1160
1180
|
label: u,
|
|
1161
1181
|
labelPosition: C,
|
|
1162
1182
|
required: T,
|
|
@@ -1165,17 +1185,17 @@ const _n = xn(
|
|
|
1165
1185
|
helperText: v,
|
|
1166
1186
|
errorText: N
|
|
1167
1187
|
}, B) => {
|
|
1168
|
-
const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1),
|
|
1188
|
+
const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), g = _(null), [Y, L] = U("days"), [S, I] = U(/* @__PURE__ */ new Date()), W = typeof m == "function" || b != null, A = !o && !W, J = !A, [D, K] = U({
|
|
1169
1189
|
from: (n == null ? void 0 : n.from) ?? null,
|
|
1170
1190
|
to: (n == null ? void 0 : n.to) ?? null
|
|
1171
|
-
}), [
|
|
1191
|
+
}), [G, q] = U(null);
|
|
1172
1192
|
O(() => {
|
|
1173
1193
|
if (n) {
|
|
1174
1194
|
const t = n;
|
|
1175
1195
|
t.from && I(t.from), K(t);
|
|
1176
1196
|
} else
|
|
1177
1197
|
I(/* @__PURE__ */ new Date()), K({ from: null, to: null });
|
|
1178
|
-
|
|
1198
|
+
q(null);
|
|
1179
1199
|
}, [n]), O(() => {
|
|
1180
1200
|
a && L(a);
|
|
1181
1201
|
}, [a]), O(() => {
|
|
@@ -1197,30 +1217,30 @@ const _n = xn(
|
|
|
1197
1217
|
} else
|
|
1198
1218
|
return `${on(D.from)} ~ ${on(D.to || D.from) || "-"}`;
|
|
1199
1219
|
}, j = () => {
|
|
1200
|
-
if (
|
|
1201
|
-
const t = V.current.getBoundingClientRect(), f =
|
|
1202
|
-
window.innerWidth < t.left + f.width ?
|
|
1220
|
+
if (g.current && V.current && J) {
|
|
1221
|
+
const t = V.current.getBoundingClientRect(), f = g.current.getBoundingClientRect();
|
|
1222
|
+
window.innerWidth < t.left + f.width ? g.current.style.left = `${t.left - f.width + t.width}px` : g.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? g.current.style.top = `${t.y - (t.height + f.height - 28)}px` : g.current.style.top = `${t.y + t.height}px`;
|
|
1203
1223
|
}
|
|
1204
1224
|
};
|
|
1205
1225
|
O(() => {
|
|
1206
|
-
|
|
1207
|
-
}, [
|
|
1226
|
+
g.current && V.current && J && j();
|
|
1227
|
+
}, [g, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
|
|
1208
1228
|
window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
|
|
1209
1229
|
}), []);
|
|
1210
1230
|
const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
|
|
1211
|
-
x &&
|
|
1231
|
+
x && q(qn(D, a));
|
|
1212
1232
|
}, en = () => {
|
|
1213
|
-
if (
|
|
1233
|
+
if (G === null)
|
|
1214
1234
|
return;
|
|
1215
|
-
const t =
|
|
1235
|
+
const t = G.trim();
|
|
1216
1236
|
if (!t) {
|
|
1217
|
-
e(void 0),
|
|
1237
|
+
e(void 0), q(null);
|
|
1218
1238
|
return;
|
|
1219
1239
|
}
|
|
1220
|
-
const f =
|
|
1221
|
-
f && P && (e(f), K(f), I(f.from)),
|
|
1240
|
+
const f = Un(t, a), P = f && Dn(f.from, d, i) && (!f.to || Dn(f.to, d, i));
|
|
1241
|
+
f && P && (e(f), K(f), I(f.from)), q(null);
|
|
1222
1242
|
}, un = (t) => {
|
|
1223
|
-
t.key === "Enter" ? (en(), $(!1)) : t.key === "Escape" && (
|
|
1243
|
+
t.key === "Enter" ? (en(), $(!1)) : t.key === "Escape" && (q(null), $(!1));
|
|
1224
1244
|
}, pn = {
|
|
1225
1245
|
isOpen: F,
|
|
1226
1246
|
open: ln,
|
|
@@ -1241,8 +1261,8 @@ const _n = xn(
|
|
|
1241
1261
|
},
|
|
1242
1262
|
children: [
|
|
1243
1263
|
W ? (() => {
|
|
1244
|
-
if (typeof
|
|
1245
|
-
return
|
|
1264
|
+
if (typeof m == "function")
|
|
1265
|
+
return m(pn);
|
|
1246
1266
|
if (wn.isValidElement(b)) {
|
|
1247
1267
|
const t = b;
|
|
1248
1268
|
return wn.cloneElement(t, {
|
|
@@ -1256,13 +1276,13 @@ const _n = xn(
|
|
|
1256
1276
|
})() : o ? /* @__PURE__ */ s(
|
|
1257
1277
|
Wn,
|
|
1258
1278
|
{
|
|
1259
|
-
value: x &&
|
|
1279
|
+
value: x && G !== null ? G : X(),
|
|
1260
1280
|
inputMode: x ? "text" : "none",
|
|
1261
1281
|
readOnly: !x,
|
|
1262
1282
|
onClick: () => {
|
|
1263
1283
|
$(!0);
|
|
1264
1284
|
},
|
|
1265
|
-
onChange: x ? (t) =>
|
|
1285
|
+
onChange: x ? (t) => q(t.target.value) : () => {
|
|
1266
1286
|
},
|
|
1267
1287
|
onFocus: x ? cn : void 0,
|
|
1268
1288
|
onBlur: x ? en : void 0,
|
|
@@ -1281,10 +1301,10 @@ const _n = xn(
|
|
|
1281
1301
|
{
|
|
1282
1302
|
className: `sa-calendar sa-calendar-size-${h || "sm"} ${A ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
|
|
1283
1303
|
style: r ? { pointerEvents: "none" } : void 0,
|
|
1284
|
-
ref:
|
|
1304
|
+
ref: g,
|
|
1285
1305
|
children: [
|
|
1286
1306
|
/* @__PURE__ */ s(
|
|
1287
|
-
|
|
1307
|
+
Gn,
|
|
1288
1308
|
{
|
|
1289
1309
|
setViews: L,
|
|
1290
1310
|
views: Y,
|
|
@@ -1365,7 +1385,7 @@ const _n = xn(
|
|
|
1365
1385
|
e.id = In, e.textContent = n, document.head.appendChild(e);
|
|
1366
1386
|
}
|
|
1367
1387
|
};
|
|
1368
|
-
Qn(
|
|
1388
|
+
Qn(mn);
|
|
1369
1389
|
const sn = (n) => {
|
|
1370
1390
|
if (n === "xs")
|
|
1371
1391
|
return 14;
|
|
@@ -1509,7 +1529,7 @@ const sn = (n) => {
|
|
|
1509
1529
|
};
|
|
1510
1530
|
M.push(C);
|
|
1511
1531
|
}
|
|
1512
|
-
const
|
|
1532
|
+
const m = (u) => {
|
|
1513
1533
|
(!d || u >= d) && (!i || u <= i) && (e(u), h(u), o(u), p && r(!1));
|
|
1514
1534
|
};
|
|
1515
1535
|
return /* @__PURE__ */ z("div", { className: "sa-calendar-days-preivew", children: [
|
|
@@ -1527,7 +1547,7 @@ const sn = (n) => {
|
|
|
1527
1547
|
...p ? {} : { width: "100%" }
|
|
1528
1548
|
},
|
|
1529
1549
|
onClick: () => {
|
|
1530
|
-
T ||
|
|
1550
|
+
T || m(u.date);
|
|
1531
1551
|
},
|
|
1532
1552
|
children: u.number
|
|
1533
1553
|
},
|
|
@@ -1551,12 +1571,12 @@ const sn = (n) => {
|
|
|
1551
1571
|
const w = n.getMonth(), M = n.getFullYear(), E = d.getFullYear(), x = (b) => {
|
|
1552
1572
|
(!p || b >= p) && (!h || b <= h) && (a ? (r(b), e(b), i(b)) : (o("days"), i(b)));
|
|
1553
1573
|
};
|
|
1554
|
-
return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b,
|
|
1555
|
-
const u = p && new Date(E,
|
|
1574
|
+
return /* @__PURE__ */ s("div", { className: "sa-calendar-months-preview", children: Q.map((b, m) => {
|
|
1575
|
+
const u = p && new Date(E, m, 1) < p || h && new Date(E, m + 1, 0) > h;
|
|
1556
1576
|
return /* @__PURE__ */ s(
|
|
1557
1577
|
"p",
|
|
1558
1578
|
{
|
|
1559
|
-
className: c &&
|
|
1579
|
+
className: c && m === w && E === M ? "sa-calendar-months-active" : "",
|
|
1560
1580
|
style: {
|
|
1561
1581
|
color: u ? "var(--sa-text-disable, #181a198f)" : void 0,
|
|
1562
1582
|
pointerEvents: u ? "none" : void 0,
|
|
@@ -1564,11 +1584,11 @@ const sn = (n) => {
|
|
|
1564
1584
|
...l ? {} : { width: "100%" }
|
|
1565
1585
|
},
|
|
1566
1586
|
onClick: () => {
|
|
1567
|
-
u || x(new Date(E,
|
|
1587
|
+
u || x(new Date(E, m));
|
|
1568
1588
|
},
|
|
1569
1589
|
children: b.slice(0, 3)
|
|
1570
1590
|
},
|
|
1571
|
-
|
|
1591
|
+
m
|
|
1572
1592
|
);
|
|
1573
1593
|
}) });
|
|
1574
1594
|
}, zn = (n) => {
|
|
@@ -1597,7 +1617,7 @@ const sn = (n) => {
|
|
|
1597
1617
|
isDisabled: C
|
|
1598
1618
|
});
|
|
1599
1619
|
}
|
|
1600
|
-
const
|
|
1620
|
+
const m = (u) => {
|
|
1601
1621
|
(!p || u >= p) && (!h || u <= h) && (e ? (r(u), o(u), i(u)) : (a("months"), i(u)));
|
|
1602
1622
|
};
|
|
1603
1623
|
return /* @__PURE__ */ s("div", { className: "sa-calendar-years-preview", children: w.map((u, C) => /* @__PURE__ */ s(
|
|
@@ -1611,7 +1631,7 @@ const sn = (n) => {
|
|
|
1611
1631
|
...l ? {} : { width: "100%" }
|
|
1612
1632
|
},
|
|
1613
1633
|
onClick: () => {
|
|
1614
|
-
u.isDisabled ||
|
|
1634
|
+
u.isDisabled || m(new Date(u.year, 0));
|
|
1615
1635
|
},
|
|
1616
1636
|
children: u.year
|
|
1617
1637
|
},
|
|
@@ -1676,7 +1696,7 @@ const sn = (n) => {
|
|
|
1676
1696
|
e.id = Tn, e.textContent = n, document.head.appendChild(e);
|
|
1677
1697
|
}
|
|
1678
1698
|
};
|
|
1679
|
-
re(
|
|
1699
|
+
re(mn);
|
|
1680
1700
|
const se = xn(
|
|
1681
1701
|
({
|
|
1682
1702
|
value: n,
|
|
@@ -1695,7 +1715,7 @@ const se = xn(
|
|
|
1695
1715
|
withPadding: E = !0,
|
|
1696
1716
|
editable: x = !1,
|
|
1697
1717
|
trigger: b,
|
|
1698
|
-
renderTrigger:
|
|
1718
|
+
renderTrigger: m,
|
|
1699
1719
|
label: u,
|
|
1700
1720
|
labelPosition: C,
|
|
1701
1721
|
required: T,
|
|
@@ -1704,7 +1724,7 @@ const se = xn(
|
|
|
1704
1724
|
helperText: v,
|
|
1705
1725
|
errorText: N
|
|
1706
1726
|
}, B) => {
|
|
1707
|
-
const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1),
|
|
1727
|
+
const H = N ? "error" : c, { ref: V, isComponentVisible: F, setIsComponentVisible: $ } = En(!1), g = _(null), [Y, L] = U("days"), [S, I] = U(/* @__PURE__ */ new Date()), [W, A] = U(/* @__PURE__ */ new Date()), [J, D] = U(null), K = typeof m == "function" || b != null, G = !o && !K, q = !G;
|
|
1708
1728
|
O(() => {
|
|
1709
1729
|
n ? (I(n), A(n)) : (I(/* @__PURE__ */ new Date()), A(/* @__PURE__ */ new Date())), D(null);
|
|
1710
1730
|
}, [n]), O(() => {
|
|
@@ -1712,17 +1732,17 @@ const se = xn(
|
|
|
1712
1732
|
}, [a]), O(() => {
|
|
1713
1733
|
a || L("days");
|
|
1714
1734
|
}, [F]), O(() => {
|
|
1715
|
-
|
|
1716
|
-
}, [
|
|
1735
|
+
G && $(!0);
|
|
1736
|
+
}, [G]);
|
|
1717
1737
|
const X = () => n ? a === "days" ? on(S) : a === "months" ? `${Q[S.getMonth()]} ${S.getFullYear()}` : a === "years" ? S.getFullYear() : on(S) : "", j = () => {
|
|
1718
|
-
if (
|
|
1719
|
-
const t = V.current.getBoundingClientRect(), f =
|
|
1720
|
-
window.innerWidth < t.left + f.width ?
|
|
1738
|
+
if (g.current && V.current && q) {
|
|
1739
|
+
const t = V.current.getBoundingClientRect(), f = g.current.getBoundingClientRect();
|
|
1740
|
+
window.innerWidth < t.left + f.width ? g.current.style.left = `${t.left - f.width + t.width}px` : g.current.style.left = `${t.left}px`, t.top + f.height > window.innerHeight ? g.current.style.top = `${t.y - (t.height + f.height - 28)}px` : g.current.style.top = `${t.y + t.height}px`;
|
|
1721
1741
|
}
|
|
1722
1742
|
};
|
|
1723
1743
|
O(() => {
|
|
1724
|
-
|
|
1725
|
-
}, [
|
|
1744
|
+
g.current && V.current && q && j();
|
|
1745
|
+
}, [g, V, F]), O(() => (window.addEventListener("scroll", j, !0), window.addEventListener("resize", j), () => {
|
|
1726
1746
|
window.removeEventListener("scroll", j, !0), window.removeEventListener("resize", j);
|
|
1727
1747
|
}), []);
|
|
1728
1748
|
const ln = () => $(!0), dn = () => $(!1), nn = () => $((t) => !t), cn = () => {
|
|
@@ -1753,14 +1773,14 @@ const se = xn(
|
|
|
1753
1773
|
"div",
|
|
1754
1774
|
{
|
|
1755
1775
|
className: `sa-calendar-wrapper${K ? " sa-calendar-wrapper-custom" : ""}`,
|
|
1756
|
-
style: { height:
|
|
1776
|
+
style: { height: G ? "100%" : "auto" },
|
|
1757
1777
|
ref: (t) => {
|
|
1758
|
-
V.current =
|
|
1778
|
+
V.current = q ? t : null, typeof B == "function" ? B(t) : B && (B.current = t);
|
|
1759
1779
|
},
|
|
1760
1780
|
children: [
|
|
1761
1781
|
K ? (() => {
|
|
1762
|
-
if (typeof
|
|
1763
|
-
return
|
|
1782
|
+
if (typeof m == "function")
|
|
1783
|
+
return m(pn);
|
|
1764
1784
|
if (wn.isValidElement(b)) {
|
|
1765
1785
|
const t = b;
|
|
1766
1786
|
return wn.cloneElement(t, {
|
|
@@ -1795,9 +1815,9 @@ const se = xn(
|
|
|
1795
1815
|
F ? /* @__PURE__ */ z(
|
|
1796
1816
|
"div",
|
|
1797
1817
|
{
|
|
1798
|
-
className: `sa-calendar sa-calendar-size-${h || "sm"} ${
|
|
1818
|
+
className: `sa-calendar sa-calendar-size-${h || "sm"} ${G ? "sa-calendar-no-input" : ""} ${E ? "" : "sa-calendar-no-padding"}`,
|
|
1799
1819
|
style: r ? { pointerEvents: "none" } : void 0,
|
|
1800
|
-
ref:
|
|
1820
|
+
ref: g,
|
|
1801
1821
|
children: [
|
|
1802
1822
|
/* @__PURE__ */ s(
|
|
1803
1823
|
te,
|
|
@@ -1877,7 +1897,7 @@ const se = xn(
|
|
|
1877
1897
|
}
|
|
1878
1898
|
);
|
|
1879
1899
|
}
|
|
1880
|
-
),
|
|
1900
|
+
), me = xn(
|
|
1881
1901
|
({
|
|
1882
1902
|
value: n,
|
|
1883
1903
|
onChange: e,
|
|
@@ -1895,7 +1915,7 @@ const se = xn(
|
|
|
1895
1915
|
fullWidth: E,
|
|
1896
1916
|
withPadding: x,
|
|
1897
1917
|
editable: b,
|
|
1898
|
-
trigger:
|
|
1918
|
+
trigger: m,
|
|
1899
1919
|
renderTrigger: u,
|
|
1900
1920
|
label: C,
|
|
1901
1921
|
labelPosition: T,
|
|
@@ -1921,7 +1941,7 @@ const se = xn(
|
|
|
1921
1941
|
fullWidth: E,
|
|
1922
1942
|
withPadding: x,
|
|
1923
1943
|
editable: b,
|
|
1924
|
-
trigger:
|
|
1944
|
+
trigger: m,
|
|
1925
1945
|
renderTrigger: u,
|
|
1926
1946
|
label: C,
|
|
1927
1947
|
labelPosition: T,
|
|
@@ -1933,7 +1953,12 @@ const se = xn(
|
|
|
1933
1953
|
};
|
|
1934
1954
|
return /* @__PURE__ */ s(yn, { children: r ? /* @__PURE__ */ s(_n, { ...V, ref: H }) : /* @__PURE__ */ s(se, { ...V, ref: H }) });
|
|
1935
1955
|
}
|
|
1936
|
-
), oe = `/*
|
|
1956
|
+
), oe = `/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
1957
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
1958
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
1959
|
+
@layer starasia.components {
|
|
1960
|
+
|
|
1961
|
+
/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
1937
1962
|
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
1938
1963
|
.sa-calendar-input-* shells for the box + masked input. */
|
|
1939
1964
|
|
|
@@ -2064,6 +2089,8 @@ const se = xn(
|
|
|
2064
2089
|
.sa-time-input-wrap {
|
|
2065
2090
|
width: 100%;
|
|
2066
2091
|
}
|
|
2092
|
+
|
|
2093
|
+
} /* @layer starasia.components */
|
|
2067
2094
|
`, Nn = (n, e, a) => Math.min(a, Math.max(e, n)), R = (n) => String(n).padStart(2, "0"), Mn = (n) => {
|
|
2068
2095
|
if (!n)
|
|
2069
2096
|
return null;
|
|
@@ -2090,7 +2117,7 @@ const se = xn(
|
|
|
2090
2117
|
} else
|
|
2091
2118
|
d.length <= 2 ? i = Number(d) : d.length <= 4 ? (i = Number(d.slice(0, d.length - 2)), p = Number(d.slice(-2))) : (i = Number(d.slice(0, d.length - 4)), p = Number(d.slice(-4, -2)), h = a ? Number(d.slice(-2)) : 0);
|
|
2092
2119
|
return r && (r === "pm" && i < 12 && (i += 12), r === "am" && i === 12 && (i = 0)), i > 23 || p > 59 || h > 59 ? null : { h: Nn(i, 0, 23), m: Nn(p, 0, 59), s: Nn(h, 0, 59) };
|
|
2093
|
-
},
|
|
2120
|
+
}, gn = (n, e = 1) => {
|
|
2094
2121
|
const a = [];
|
|
2095
2122
|
for (let o = 0; o < n; o += e)
|
|
2096
2123
|
a.push(o);
|
|
@@ -2101,7 +2128,7 @@ const se = xn(
|
|
|
2101
2128
|
const a = document.createElement("style");
|
|
2102
2129
|
a.id = n, a.textContent = e, document.head.appendChild(a);
|
|
2103
2130
|
};
|
|
2104
|
-
jn("sa-calendar-styles",
|
|
2131
|
+
jn("sa-calendar-styles", mn);
|
|
2105
2132
|
jn("sa-time-styles", oe);
|
|
2106
2133
|
const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /* @__PURE__ */ s("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ s(
|
|
2107
2134
|
"path",
|
|
@@ -2161,7 +2188,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2161
2188
|
status: E,
|
|
2162
2189
|
fullWidth: x = !0,
|
|
2163
2190
|
withPadding: b = !0,
|
|
2164
|
-
label:
|
|
2191
|
+
label: m,
|
|
2165
2192
|
labelPosition: u,
|
|
2166
2193
|
required: C,
|
|
2167
2194
|
optional: T,
|
|
@@ -2169,7 +2196,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2169
2196
|
helperText: k,
|
|
2170
2197
|
errorText: v
|
|
2171
2198
|
}, N) => {
|
|
2172
|
-
const B = v ? "error" : E, { ref: H, isComponentVisible: V, setIsComponentVisible: F } = En(!1), $ = _(null),
|
|
2199
|
+
const B = v ? "error" : E, { ref: H, isComponentVisible: V, setIsComponentVisible: F } = En(!1), $ = _(null), g = tn(() => Mn(n), [n]), Y = tn(() => Mn(d), [d]), L = tn(() => Mn(i), [i]), [S, I] = U(null);
|
|
2173
2200
|
O(() => {
|
|
2174
2201
|
p || F(!0);
|
|
2175
2202
|
}, [p]);
|
|
@@ -2190,7 +2217,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2190
2217
|
}, J = (t) => {
|
|
2191
2218
|
e(le(t, o)), I(null);
|
|
2192
2219
|
}, D = (t) => {
|
|
2193
|
-
J({ ...
|
|
2220
|
+
J({ ...g ?? { h: 0, m: 0, s: 0 }, ...t });
|
|
2194
2221
|
}, K = () => {
|
|
2195
2222
|
if (S == null)
|
|
2196
2223
|
return;
|
|
@@ -2200,35 +2227,35 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2200
2227
|
}
|
|
2201
2228
|
const t = de(S, a, o);
|
|
2202
2229
|
t && A(t) ? J(t) : I(null);
|
|
2203
|
-
},
|
|
2230
|
+
}, G = g ? ie(g, a, o) : "", q = S ?? G, X = c && !!g && !l, j = g && g.h >= 12 ? "PM" : "AM", ln = tn(() => a === "12h" ? gn(12).map((t) => {
|
|
2204
2231
|
const f = t === 0 ? 12 : t, P = j === "PM" ? f % 12 + 12 : f % 12;
|
|
2205
2232
|
return {
|
|
2206
2233
|
value: f,
|
|
2207
2234
|
label: R(f),
|
|
2208
2235
|
disabled: Y && P * 60 + 59 < Z(Y) || L && P * 60 > Z(L) || !1
|
|
2209
2236
|
};
|
|
2210
|
-
}) :
|
|
2237
|
+
}) : gn(24).map((t) => ({
|
|
2211
2238
|
value: t,
|
|
2212
2239
|
label: R(t),
|
|
2213
2240
|
disabled: Y && t * 60 + 59 < Z(Y) || L && t * 60 > Z(L) || !1
|
|
2214
2241
|
})), [a, j, Y, L]), dn = tn(() => {
|
|
2215
|
-
const t = (
|
|
2216
|
-
return
|
|
2242
|
+
const t = (g == null ? void 0 : g.h) ?? 0;
|
|
2243
|
+
return gn(60, r).map((f) => ({
|
|
2217
2244
|
value: f,
|
|
2218
2245
|
label: R(f),
|
|
2219
2246
|
disabled: Y && t * 60 + f < Z(Y) || L && t * 60 + f > Z(L) || !1
|
|
2220
2247
|
}));
|
|
2221
|
-
}, [r,
|
|
2222
|
-
() =>
|
|
2248
|
+
}, [r, g == null ? void 0 : g.h, Y, L]), nn = tn(
|
|
2249
|
+
() => gn(60).map((t) => ({ value: t, label: R(t) })),
|
|
2223
2250
|
[]
|
|
2224
|
-
), cn =
|
|
2251
|
+
), cn = g == null ? null : a === "12h" ? g.h % 12 === 0 ? 12 : g.h % 12 : g.h, en = (t) => {
|
|
2225
2252
|
if (a === "12h") {
|
|
2226
2253
|
const f = j === "PM" ? t % 12 + 12 : t % 12;
|
|
2227
2254
|
D({ h: f });
|
|
2228
2255
|
} else
|
|
2229
2256
|
D({ h: t });
|
|
2230
2257
|
}, un = (t) => {
|
|
2231
|
-
const f =
|
|
2258
|
+
const f = g ?? { h: 0, m: 0, s: 0 }, P = f.h % 12 === 0 ? 12 : f.h % 12, an = t === "PM" ? P % 12 + 12 : P % 12;
|
|
2232
2259
|
J({ ...f, h: an });
|
|
2233
2260
|
}, pn = () => {
|
|
2234
2261
|
const t = /* @__PURE__ */ new Date(), f = Math.floor(t.getMinutes() / r) * r;
|
|
@@ -2251,7 +2278,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2251
2278
|
"input",
|
|
2252
2279
|
{
|
|
2253
2280
|
className: "sa-calendar-input",
|
|
2254
|
-
value:
|
|
2281
|
+
value: q,
|
|
2255
2282
|
placeholder: h,
|
|
2256
2283
|
disabled: l,
|
|
2257
2284
|
onChange: (t) => I(t.target.value),
|
|
@@ -2300,7 +2327,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2300
2327
|
{
|
|
2301
2328
|
label: "Menit",
|
|
2302
2329
|
options: dn,
|
|
2303
|
-
active: (
|
|
2330
|
+
active: (g == null ? void 0 : g.m) ?? null,
|
|
2304
2331
|
onPick: (t) => D({ m: t })
|
|
2305
2332
|
}
|
|
2306
2333
|
),
|
|
@@ -2311,7 +2338,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2311
2338
|
{
|
|
2312
2339
|
label: "Detik",
|
|
2313
2340
|
options: nn,
|
|
2314
|
-
active: (
|
|
2341
|
+
active: (g == null ? void 0 : g.s) ?? null,
|
|
2315
2342
|
onPick: (t) => D({ s: t })
|
|
2316
2343
|
}
|
|
2317
2344
|
)
|
|
@@ -2326,7 +2353,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2326
2353
|
{ value: 0, label: "AM" },
|
|
2327
2354
|
{ value: 1, label: "PM" }
|
|
2328
2355
|
],
|
|
2329
|
-
active:
|
|
2356
|
+
active: g == null ? null : j === "PM" ? 1 : 0,
|
|
2330
2357
|
onPick: (t) => un(t === 1 ? "PM" : "AM")
|
|
2331
2358
|
}
|
|
2332
2359
|
)
|
|
@@ -2363,7 +2390,7 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2363
2390
|
return /* @__PURE__ */ s(
|
|
2364
2391
|
Yn,
|
|
2365
2392
|
{
|
|
2366
|
-
label:
|
|
2393
|
+
label: m,
|
|
2367
2394
|
labelPosition: u,
|
|
2368
2395
|
required: C,
|
|
2369
2396
|
optional: T,
|
|
@@ -2379,6 +2406,6 @@ const ce = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, Bn = ({ s: n }) => /*
|
|
|
2379
2406
|
);
|
|
2380
2407
|
pe.displayName = "StarasiaTime";
|
|
2381
2408
|
export {
|
|
2382
|
-
|
|
2409
|
+
me as StarasiaDate,
|
|
2383
2410
|
pe as StarasiaTime
|
|
2384
2411
|
};
|
package/dist/date.umd.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(U,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(U=typeof globalThis<"u"?globalThis:U||self,e(U.Date={},U.jsxRuntime,U.React))})(this,function(U,e,g){"use strict";const sn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
2
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
3
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
4
|
+
@layer starasia.components {
|
|
5
|
+
|
|
6
|
+
|
|
2
7
|
* {
|
|
3
8
|
margin: 0;
|
|
4
9
|
padding: 0;
|
|
@@ -25,6 +30,9 @@
|
|
|
25
30
|
--sa-date-border-warning: var(--sa-color-warning-400, #ed9f30);
|
|
26
31
|
--sa-date-accent-subtle: var(--sa-background-neutral, #f0f1f2);
|
|
27
32
|
--sa-date-border-subtle: var(--sa-border-subtle, rgba(11, 18, 14, 0.14));
|
|
33
|
+
/* Batas field (outline/flushed) — ≥ 3:1 terhadap kanvas (WCAG 1.4.11).
|
|
34
|
+
--sa-date-border-color (alpha ≈1.3:1) tetap untuk thumb scrollbar Time. */
|
|
35
|
+
--sa-date-border-field: var(--sa-border-input, #8c8f97);
|
|
28
36
|
}
|
|
29
37
|
.sa-calendar-wrapper {
|
|
30
38
|
position: relative;
|
|
@@ -358,7 +366,7 @@
|
|
|
358
366
|
}
|
|
359
367
|
|
|
360
368
|
.sa-calendar-input-outline {
|
|
361
|
-
border-color: var(--sa-date-border-
|
|
369
|
+
border-color: var(--sa-date-border-field);
|
|
362
370
|
background-color: transparent;
|
|
363
371
|
border-width: var(--sa-border, 1px);
|
|
364
372
|
border-style: solid;
|
|
@@ -408,7 +416,7 @@
|
|
|
408
416
|
border-top: none;
|
|
409
417
|
border-left: none;
|
|
410
418
|
border-right: none;
|
|
411
|
-
border-bottom: 1px solid var(--sa-date-border-
|
|
419
|
+
border-bottom: 1px solid var(--sa-date-border-field);
|
|
412
420
|
border-radius: 0;
|
|
413
421
|
padding-inline: 0;
|
|
414
422
|
}
|
|
@@ -597,7 +605,24 @@
|
|
|
597
605
|
width: 32px;
|
|
598
606
|
height: 32px;
|
|
599
607
|
}
|
|
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
|
|
608
|
+
|
|
609
|
+
/* Forced colors (Windows High Contrast): fokus field ditandai ganti warna
|
|
610
|
+
border + ring box-shadow — keduanya hilang di mode ini. Ganti outline
|
|
611
|
+
warna sistem. */
|
|
612
|
+
@media (forced-colors: active) {
|
|
613
|
+
.sa-calendar-input-container:has(input:focus) {
|
|
614
|
+
outline: 2px solid Highlight;
|
|
615
|
+
outline-offset: 1px;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
} /* @layer starasia.components */
|
|
620
|
+
`,Cn=["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 $n="sa-calendar-input-styles";(n=>{if(!(typeof document>"u")&&!document.getElementById($n)){const a=document.createElement("style");a.id=$n,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,C=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:C,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(),C=[];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};C.push(N)}const u=m=>{a(m)},$=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:Cn.map((m,N)=>e.jsx("p",{children:m},N))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.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(),F=r.from.getTime(),L=v.getTime();return L>F?S>F&&S<L:S<F&&S>L})(),V=y&&h&&m.date.toDateString()===h.toDateString(),Y=m.isDisabled,D=()=>B||H?"var(--sa-color-info-alpha-a10, #64b5f61a)":"",b=()=>Y?"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:Y?"none":void 0,cursor:Y?"not-allowed":"pointer",color:b(),opacity:V&&!m.selected?.75:1,...p?{}:{width:"100%"}},onClick:()=>{Y||(u(m.date),$(m.date))},onMouseEnter:()=>{Y||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(),C=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()),$=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:$?"none":void 0,cursor:$?"not-allowed":"pointer",color:$?"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 $,T;let c=[];const x=n.getFullYear(),{start:C,end:E}=bn(x),k=($=s.from)==null?void 0:$.getFullYear(),y=(T=s.to)==null?void 0:T.getFullYear();for(let w=C;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,C=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,C]})]}):e.jsxs("div",{className:c,children:[x,s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,C]}):e.jsxs("div",{className:c,children:[s&&e.jsx("p",{className:"sa-date-field-helper-top",children:s}),l,C]})},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:C=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:$,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:Y,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,F]=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,G]=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});G(null)},[n]),g.useEffect(()=>{r&&F(r)},[r]),g.useEffect(()=>{r||F("days")},[Y]),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,Y]),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&&G(Hn(z,r))},R=()=>{if(K===null)return;const t=K.trim();if(!t){a(void 0),G(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)),G(null)},cn=t=>{t.key==="Enter"?(R(),D(!1)):t.key==="Escape"&&(G(null),D(!1))},un={isOpen:Y,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=>G(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,Y?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:F,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:F,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i}):e.jsx(On,{date:L,setDate:I,filter:r,setViews:F,dateRange:z,setDateRange:q,setIsComponentVisible:D,input:o,onChange:a,minDate:d,maxDate:i})})]}):null]});return e.jsx(xn,{label:u,labelPosition:$,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:C,size:h,children:pn})}),Fn="sa-calendar-input-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 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,C=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:C,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(),C=[];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 $={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};C.push($)}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:Cn.map((u,$)=>e.jsx("p",{children:u},$))}),e.jsx("div",{className:"sa-calendar-days-number-preivew",children:C.map((u,$)=>{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},$)})})]})},Gn=({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(),C=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===C?"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}},Un=({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 C=d.getFullYear(),{start:E,end:k}=kn(C),y=n.getFullYear();for(let u=E;u<k;u++){let $=p&&new Date(u,0,1)<p||h&&new Date(u,11,31)>h;x.push({year:u,active:!!c&&u===y,isDisabled:$})}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,$)=>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},$))})},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,{})})]})]})},Yn="sa-calendar-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 _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:C=!0,withPadding:E=!0,editable:k=!1,trigger:y,renderTrigger:v,label:u,labelPosition:$,required:T,optional:w,description:M,helperText:m,errorText:N},B)=>{const H=N?"error":c,{ref:V,isComponentVisible:Y,setIsComponentVisible:D}=vn(!1),b=g.useRef(null),[S,F]=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,G=!K;g.useEffect(()=>{n?(I(n),O(n)):(I(new Date),O(new Date)),z(null)},[n]),g.useEffect(()=>{r&&F(r)},[r]),g.useEffect(()=>{r||F("days")},[Y]),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&&G){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&&G&&j()},[b,V,Y]),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:Y,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=G?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,Y?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:F,views:S,filter:r,previewDate:W,setPreviewDate:O,isComponentVisible:Y}),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(Gn,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:F,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null}):e.jsx(Un,{date:L,setDate:I,previewDate:W,setPreviewDate:O,filter:r,setViews:F,onChange:a,minDate:d,maxDate:i,input:o,hasValue:n!=null})})]}):null]});return e.jsx(xn,{label:u,labelPosition:$,required:T,optional:w,description:M,helperText:m,errorText:N,fullWidth:C,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:C,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:$,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:C,fullWidth:E,withPadding:k,editable:y,trigger:v,renderTrigger:u,label:$,labelPosition:T,required:w,optional:M,description:m,helperText:N,errorText:B};return e.jsx(e.Fragment,{children:s?e.jsx(Jn,{...V,ref:H}):e.jsx(_n,{...V,ref:H})})}),Xn=`/* Cascade layer \`starasia.components\` — lihat @starasia/css (urutan: theme, base,
|
|
621
|
+
starasia, components, utilities). CSS app/Tailwind utility selalu bisa
|
|
622
|
+
menimpa aturan di sini. Isi sengaja tidak di-indent (diff minimal). */
|
|
623
|
+
@layer starasia.components {
|
|
624
|
+
|
|
625
|
+
/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
601
626
|
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
602
627
|
.sa-calendar-input-* shells for the box + masked input. */
|
|
603
628
|
|
|
@@ -728,4 +753,6 @@
|
|
|
728
753
|
.sa-time-input-wrap {
|
|
729
754
|
width: 100%;
|
|
730
755
|
}
|
|
731
|
-
|
|
756
|
+
|
|
757
|
+
} /* @layer starasia.components */
|
|
758
|
+
`,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:C="outline",status:E,fullWidth:k=!0,withPadding:y=!0,label:v,labelPosition:u,required:$,optional:T,description:w,helperText:M,errorText:m},N)=>{const B=m?"error":E,{ref:H,isComponentVisible:V,setIsComponentVisible:Y}=vn(!1),D=g.useRef(null),b=g.useMemo(()=>Nn(n),[n]),S=g.useMemo(()=>Nn(d),[d]),F=g.useMemo(()=>Nn(i),[i]),[L,I]=g.useState(null);g.useEffect(()=>{p||Y(!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)||F&&f>Z(F))},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):"",G=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)||F&&P*60>Z(F)||!1}}):hn(24).map(t=>({value:t,label:A(t),disabled:S&&t*60+59<Z(S)||F&&t*60>Z(F)||!1})),[r,j,S,F]),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)||F&&t*60+f>Z(F)||!1}))},[s,b==null?void 0:b.h,S,F]),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-${C} sa-calendar-input-container-${B||"default"} ${x}`,onClick:()=>!l&&Y(!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:G,placeholder:h,disabled:l,onChange:t=>I(t.target.value),onFocus:()=>Y(!0),onBlur:q,onKeyDown:t=>{t.key==="Enter"&&(q(),Y(!1)),t.key==="Escape"&&(I(null),Y(!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:$,optional:T,description:w,helperText:M,errorText:m,fullWidth:k,size:x,children:pn})});Tn.displayName="StarasiaTime",U.StarasiaDate=Qn,U.StarasiaTime=Tn,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});
|