@starasia/date 5.3.1 → 5.4.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/FieldWrapper.d.ts +1 -0
- package/dist/components/Time/index.d.ts +3 -0
- package/dist/date.es.js +1176 -718
- package/dist/date.umd.js +144 -4
- package/dist/index.d.ts +1 -0
- package/dist/interfaces.d.ts +43 -0
- package/dist/utils/time-functions.d.ts +25 -0
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as z, jsx as a, Fragment as rn } from "react/jsx-runtime";
|
|
2
|
+
import { useState as O, useRef as J, useEffect as A, forwardRef as tn, useMemo as G } from "react";
|
|
3
|
+
const X = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
|
|
4
4
|
|
|
5
5
|
* {
|
|
6
6
|
margin: 0;
|
|
@@ -68,14 +68,19 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
68
68
|
.sa-date-field-label-row {
|
|
69
69
|
display: flex;
|
|
70
70
|
align-items: center;
|
|
71
|
-
gap:
|
|
71
|
+
gap: 4px;
|
|
72
72
|
flex-wrap: wrap;
|
|
73
73
|
}
|
|
74
74
|
.sa-date-field-label-text {
|
|
75
75
|
font-size: 14px;
|
|
76
76
|
font-weight: 500;
|
|
77
77
|
color: var(--sa-date-text-primary);
|
|
78
|
-
line-height:
|
|
78
|
+
line-height: normal;
|
|
79
|
+
}
|
|
80
|
+
/* match Input: xs/sm label drops to 12px */
|
|
81
|
+
.sa-date-field-size-xs .sa-date-field-label-text,
|
|
82
|
+
.sa-date-field-size-sm .sa-date-field-label-text {
|
|
83
|
+
font-size: 12px;
|
|
79
84
|
}
|
|
80
85
|
.sa-date-field-required {
|
|
81
86
|
font-size: 14px;
|
|
@@ -83,6 +88,10 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
83
88
|
color: var(--sa-date-border-error);
|
|
84
89
|
line-height: 1;
|
|
85
90
|
}
|
|
91
|
+
.sa-date-field-size-xs .sa-date-field-required,
|
|
92
|
+
.sa-date-field-size-sm .sa-date-field-required {
|
|
93
|
+
font-size: 12px;
|
|
94
|
+
}
|
|
86
95
|
.sa-date-field-optional-badge {
|
|
87
96
|
display: inline-flex;
|
|
88
97
|
align-items: center;
|
|
@@ -581,7 +590,7 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
581
590
|
width: 32px;
|
|
582
591
|
height: 32px;
|
|
583
592
|
}
|
|
584
|
-
`,
|
|
593
|
+
`, yn = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], q = [
|
|
585
594
|
"January",
|
|
586
595
|
"February",
|
|
587
596
|
"March",
|
|
@@ -594,7 +603,7 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
594
603
|
"October",
|
|
595
604
|
"November",
|
|
596
605
|
"December"
|
|
597
|
-
],
|
|
606
|
+
], Tn = [
|
|
598
607
|
"Jan",
|
|
599
608
|
"Feb",
|
|
600
609
|
"Mar",
|
|
@@ -608,55 +617,55 @@ const J = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
608
617
|
"Nov",
|
|
609
618
|
"Dec"
|
|
610
619
|
];
|
|
611
|
-
function
|
|
612
|
-
const [
|
|
613
|
-
|
|
620
|
+
function un(n) {
|
|
621
|
+
const [e, r] = O(n), t = J(null), o = (d) => {
|
|
622
|
+
t.current && !t.current.contains(d.target) && r(!1);
|
|
614
623
|
};
|
|
615
|
-
return
|
|
616
|
-
document.removeEventListener("click",
|
|
617
|
-
}), []), { ref:
|
|
618
|
-
}
|
|
619
|
-
const
|
|
620
|
-
if (!document.getElementById(
|
|
621
|
-
const
|
|
622
|
-
|
|
624
|
+
return A(() => (document.addEventListener("click", o, !0), () => {
|
|
625
|
+
document.removeEventListener("click", o, !0);
|
|
626
|
+
}), []), { ref: t, isComponentVisible: e, setIsComponentVisible: r };
|
|
627
|
+
}
|
|
628
|
+
const fn = "sa-calendar-input-styles", Bn = (n) => {
|
|
629
|
+
if (!document.getElementById(fn)) {
|
|
630
|
+
const e = document.createElement("style");
|
|
631
|
+
e.id = fn, e.textContent = n, document.head.appendChild(e);
|
|
623
632
|
}
|
|
624
633
|
};
|
|
625
|
-
|
|
626
|
-
const
|
|
627
|
-
if (
|
|
634
|
+
Bn(X);
|
|
635
|
+
const U = (n) => {
|
|
636
|
+
if (n === "xs")
|
|
628
637
|
return 14;
|
|
629
|
-
if (
|
|
638
|
+
if (n === "sm")
|
|
630
639
|
return 16;
|
|
631
|
-
if (
|
|
640
|
+
if (n === "md")
|
|
632
641
|
return 16;
|
|
633
|
-
if (
|
|
642
|
+
if (n === "lg")
|
|
634
643
|
return 20;
|
|
635
|
-
},
|
|
644
|
+
}, Vn = (n) => {
|
|
636
645
|
const {
|
|
637
|
-
size:
|
|
638
|
-
status:
|
|
639
|
-
variant:
|
|
640
|
-
clearable:
|
|
641
|
-
onClear:
|
|
642
|
-
...
|
|
643
|
-
} =
|
|
644
|
-
|
|
645
|
-
},
|
|
646
|
-
|
|
646
|
+
size: e = "sm",
|
|
647
|
+
status: r = "default",
|
|
648
|
+
variant: t = "outline",
|
|
649
|
+
clearable: o,
|
|
650
|
+
onClear: d,
|
|
651
|
+
...l
|
|
652
|
+
} = n, u = J(null), h = () => {
|
|
653
|
+
u.current && l.onClick && (u.current.focus(), l.onClick(""));
|
|
654
|
+
}, s = r === "disable" || l.disabled, c = !!l.value, y = o && c && !s, M = (D) => {
|
|
655
|
+
D.stopPropagation(), d == null || d();
|
|
647
656
|
};
|
|
648
|
-
return /* @__PURE__ */
|
|
657
|
+
return /* @__PURE__ */ z(
|
|
649
658
|
"div",
|
|
650
659
|
{
|
|
651
|
-
className: `sa-calendar-input-container sa-calendar-input-${
|
|
652
|
-
onClick:
|
|
660
|
+
className: `sa-calendar-input-container sa-calendar-input-${t} sa-calendar-input-container-${r} ${e} `,
|
|
661
|
+
onClick: h,
|
|
653
662
|
children: [
|
|
654
663
|
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
|
|
655
664
|
"svg",
|
|
656
665
|
{
|
|
657
666
|
xmlns: "http://www.w3.org/2000/svg",
|
|
658
|
-
width:
|
|
659
|
-
height:
|
|
667
|
+
width: U(e),
|
|
668
|
+
height: U(e),
|
|
660
669
|
viewBox: "0 0 20 20",
|
|
661
670
|
fill: "none",
|
|
662
671
|
children: /* @__PURE__ */ a(
|
|
@@ -675,13 +684,13 @@ const W = (e) => {
|
|
|
675
684
|
"input",
|
|
676
685
|
{
|
|
677
686
|
className: "sa-calendar-input",
|
|
678
|
-
...
|
|
679
|
-
disabled:
|
|
680
|
-
value:
|
|
681
|
-
ref:
|
|
687
|
+
...l,
|
|
688
|
+
disabled: s,
|
|
689
|
+
value: l.value,
|
|
690
|
+
ref: u
|
|
682
691
|
}
|
|
683
692
|
) }),
|
|
684
|
-
|
|
693
|
+
y ? /* @__PURE__ */ a(
|
|
685
694
|
"button",
|
|
686
695
|
{
|
|
687
696
|
type: "button",
|
|
@@ -692,8 +701,8 @@ const W = (e) => {
|
|
|
692
701
|
"svg",
|
|
693
702
|
{
|
|
694
703
|
xmlns: "http://www.w3.org/2000/svg",
|
|
695
|
-
width:
|
|
696
|
-
height:
|
|
704
|
+
width: U(e),
|
|
705
|
+
height: U(e),
|
|
697
706
|
viewBox: "0 0 20 20",
|
|
698
707
|
fill: "none",
|
|
699
708
|
children: /* @__PURE__ */ a(
|
|
@@ -713,8 +722,8 @@ const W = (e) => {
|
|
|
713
722
|
"svg",
|
|
714
723
|
{
|
|
715
724
|
xmlns: "http://www.w3.org/2000/svg",
|
|
716
|
-
width:
|
|
717
|
-
height:
|
|
725
|
+
width: U(e),
|
|
726
|
+
height: U(e),
|
|
718
727
|
viewBox: "0 0 20 20",
|
|
719
728
|
fill: "none",
|
|
720
729
|
children: /* @__PURE__ */ a(
|
|
@@ -732,199 +741,199 @@ const W = (e) => {
|
|
|
732
741
|
]
|
|
733
742
|
}
|
|
734
743
|
);
|
|
735
|
-
},
|
|
736
|
-
date:
|
|
737
|
-
setDate:
|
|
738
|
-
dateRange:
|
|
739
|
-
setDateRange:
|
|
740
|
-
onChange:
|
|
741
|
-
minDate:
|
|
742
|
-
maxDate:
|
|
743
|
-
input:
|
|
744
|
+
}, Pn = ({
|
|
745
|
+
date: n,
|
|
746
|
+
setDate: e,
|
|
747
|
+
dateRange: r,
|
|
748
|
+
setDateRange: t,
|
|
749
|
+
onChange: o,
|
|
750
|
+
minDate: d,
|
|
751
|
+
maxDate: l,
|
|
752
|
+
input: u
|
|
744
753
|
}) => {
|
|
745
|
-
var
|
|
746
|
-
const [
|
|
747
|
-
let
|
|
748
|
-
const
|
|
749
|
-
for (let
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
) :
|
|
753
|
-
let
|
|
754
|
-
currentMonth:
|
|
755
|
-
date: new Date(
|
|
756
|
-
month:
|
|
757
|
-
number:
|
|
758
|
-
selected:
|
|
759
|
-
isToday:
|
|
760
|
-
year:
|
|
761
|
-
isDisabled:
|
|
754
|
+
var S, g, k;
|
|
755
|
+
const [h, s] = O(null);
|
|
756
|
+
let c = new Date(n.getFullYear(), n.getMonth(), 1), y = c.getDay(), M = [];
|
|
757
|
+
const D = n.getMonth(), E = (/* @__PURE__ */ new Date()).toDateString(), v = !!(r.from && !r.to), m = v && h ? h : null;
|
|
758
|
+
for (let f = 0; f < 42; f++) {
|
|
759
|
+
f === 0 && y === 0 ? c.setDate(c.getDate() - 7) : f === 0 ? c.setDate(
|
|
760
|
+
c.getDate() + (f - y)
|
|
761
|
+
) : c.setDate(c.getDate() + 1);
|
|
762
|
+
let w = {
|
|
763
|
+
currentMonth: c.getMonth() === D,
|
|
764
|
+
date: new Date(c),
|
|
765
|
+
month: c.getMonth(),
|
|
766
|
+
number: c.getDate(),
|
|
767
|
+
selected: c.toDateString() === ((S = r.from) == null ? void 0 : S.toDateString()) || c.toDateString() === (((g = r.to) == null ? void 0 : g.toDateString()) || ((k = r.from) == null ? void 0 : k.toDateString())),
|
|
768
|
+
isToday: c.toDateString() === E,
|
|
769
|
+
year: c.getFullYear(),
|
|
770
|
+
isDisabled: d && c < d || l && c > l
|
|
762
771
|
};
|
|
763
|
-
M.push(
|
|
772
|
+
M.push(w);
|
|
764
773
|
}
|
|
765
|
-
const
|
|
766
|
-
|
|
767
|
-
},
|
|
768
|
-
let
|
|
769
|
-
if (
|
|
770
|
-
|
|
771
|
-
else if (!
|
|
772
|
-
|
|
774
|
+
const i = (f) => {
|
|
775
|
+
e(f);
|
|
776
|
+
}, C = (f) => {
|
|
777
|
+
let w = { ...r };
|
|
778
|
+
if (w.from && w.to)
|
|
779
|
+
w = { from: f, to: null };
|
|
780
|
+
else if (!w.from)
|
|
781
|
+
w = { from: f, to: null };
|
|
773
782
|
else {
|
|
774
|
-
const
|
|
775
|
-
|
|
783
|
+
const B = w.from.getTime();
|
|
784
|
+
f.getTime() > B ? w = { from: w.from, to: f } : w = { from: f, to: w.from };
|
|
776
785
|
}
|
|
777
|
-
|
|
786
|
+
t(w), o(w);
|
|
778
787
|
};
|
|
779
|
-
return /* @__PURE__ */
|
|
788
|
+
return /* @__PURE__ */ z(
|
|
780
789
|
"div",
|
|
781
790
|
{
|
|
782
791
|
className: "sa-calendar-days-preivew",
|
|
783
|
-
onMouseLeave: () =>
|
|
792
|
+
onMouseLeave: () => s(null),
|
|
784
793
|
children: [
|
|
785
|
-
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children:
|
|
786
|
-
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((
|
|
787
|
-
const
|
|
788
|
-
if (!
|
|
794
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: yn.map((f, w) => /* @__PURE__ */ a("p", { children: f }, w)) }),
|
|
795
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((f, w) => {
|
|
796
|
+
const B = r.from && r.to && f.date.getTime() > r.from.getTime() && f.date.getTime() < r.to.getTime(), V = (() => {
|
|
797
|
+
if (!m || !r.from)
|
|
789
798
|
return !1;
|
|
790
|
-
const
|
|
791
|
-
return
|
|
792
|
-
})(),
|
|
799
|
+
const $ = f.date.getTime(), x = r.from.getTime(), I = m.getTime();
|
|
800
|
+
return I > x ? $ > x && $ < I : $ < x && $ > I;
|
|
801
|
+
})(), L = v && h && f.date.toDateString() === h.toDateString(), F = f.isDisabled, T = () => B || V ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", b = () => F ? "var(--sa-color-gray-400, #b7b9be)" : B || V ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
793
802
|
return /* @__PURE__ */ a(
|
|
794
803
|
"p",
|
|
795
804
|
{
|
|
796
|
-
className: `${
|
|
805
|
+
className: `${f.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${f.selected || L ? "sa-calendar-days-active" : ""} ${f.isToday && !f.selected ? "sa-calendar-days-today" : ""}`,
|
|
797
806
|
style: {
|
|
798
|
-
backgroundColor:
|
|
807
|
+
backgroundColor: T(),
|
|
799
808
|
pointerEvents: F ? "none" : void 0,
|
|
800
809
|
cursor: F ? "not-allowed" : "pointer",
|
|
801
|
-
color:
|
|
802
|
-
opacity:
|
|
803
|
-
...
|
|
810
|
+
color: b(),
|
|
811
|
+
opacity: L && !f.selected ? 0.75 : 1,
|
|
812
|
+
...u ? {} : { width: "100%" }
|
|
804
813
|
},
|
|
805
814
|
onClick: () => {
|
|
806
|
-
F || (
|
|
815
|
+
F || (i(f.date), C(f.date));
|
|
807
816
|
},
|
|
808
817
|
onMouseEnter: () => {
|
|
809
|
-
F ||
|
|
818
|
+
F || s(f.date);
|
|
810
819
|
},
|
|
811
|
-
children:
|
|
820
|
+
children: f.number
|
|
812
821
|
},
|
|
813
|
-
|
|
822
|
+
w
|
|
814
823
|
);
|
|
815
824
|
}) })
|
|
816
825
|
]
|
|
817
826
|
}
|
|
818
827
|
);
|
|
819
|
-
},
|
|
820
|
-
date:
|
|
821
|
-
setDate:
|
|
822
|
-
filter:
|
|
823
|
-
setViews:
|
|
824
|
-
dateRange:
|
|
825
|
-
setDateRange:
|
|
826
|
-
onChange:
|
|
827
|
-
minDate:
|
|
828
|
-
maxDate:
|
|
829
|
-
input:
|
|
828
|
+
}, jn = ({
|
|
829
|
+
date: n,
|
|
830
|
+
setDate: e,
|
|
831
|
+
filter: r,
|
|
832
|
+
setViews: t,
|
|
833
|
+
dateRange: o,
|
|
834
|
+
setDateRange: d,
|
|
835
|
+
onChange: l,
|
|
836
|
+
minDate: u,
|
|
837
|
+
maxDate: h,
|
|
838
|
+
input: s
|
|
830
839
|
}) => {
|
|
831
|
-
var
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
},
|
|
835
|
-
let
|
|
836
|
-
if (
|
|
837
|
-
|
|
838
|
-
else if (!
|
|
839
|
-
|
|
840
|
+
var E;
|
|
841
|
+
const c = (E = o.from) == null ? void 0 : E.getFullYear(), y = n.getFullYear(), M = (v) => {
|
|
842
|
+
r ? (D(v), e(v)) : (t("days"), e(v));
|
|
843
|
+
}, D = (v) => {
|
|
844
|
+
let m = { ...o };
|
|
845
|
+
if (m.from && m.to)
|
|
846
|
+
m = { from: v, to: null };
|
|
847
|
+
else if (!m.from)
|
|
848
|
+
m = { from: v, to: null };
|
|
840
849
|
else {
|
|
841
|
-
const
|
|
842
|
-
|
|
850
|
+
const i = m.from.getTime();
|
|
851
|
+
v.getTime() > i ? m = { from: m.from, to: v } : m = { from: v, to: m.from };
|
|
843
852
|
}
|
|
844
|
-
|
|
853
|
+
d(m), l(m);
|
|
845
854
|
};
|
|
846
|
-
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children:
|
|
847
|
-
var
|
|
848
|
-
const
|
|
855
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: q.map((v, m) => {
|
|
856
|
+
var S, g, k;
|
|
857
|
+
const i = o.from != null && new Date(y, m).getTime() > o.from.getTime() && new Date(y, m).getTime() < (((S = o.to) == null ? void 0 : S.getTime()) || o.from.getTime()), C = u && new Date(y, m) < u || h && new Date(y, m) > h;
|
|
849
858
|
return /* @__PURE__ */ a(
|
|
850
859
|
"p",
|
|
851
860
|
{
|
|
852
|
-
className:
|
|
861
|
+
className: c === y && (m === ((g = o.from) == null ? void 0 : g.getMonth()) || m === ((k = o.to) == null ? void 0 : k.getMonth())) ? "sa-calendar-months-active" : "",
|
|
853
862
|
style: {
|
|
854
|
-
backgroundColor:
|
|
855
|
-
pointerEvents:
|
|
856
|
-
cursor:
|
|
857
|
-
color:
|
|
858
|
-
...
|
|
863
|
+
backgroundColor: i ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
864
|
+
pointerEvents: C ? "none" : void 0,
|
|
865
|
+
cursor: C ? "not-allowed" : "pointer",
|
|
866
|
+
color: C ? "var(--sa-color-gray-400, #b7b9be)" : i ? "var(--sa-color-gray-500, #8c8f97)" : "",
|
|
867
|
+
...s ? {} : { width: "100%" }
|
|
859
868
|
},
|
|
860
869
|
onClick: () => {
|
|
861
|
-
|
|
870
|
+
C || M(new Date(y, m));
|
|
862
871
|
},
|
|
863
|
-
children:
|
|
872
|
+
children: v.slice(0, 3)
|
|
864
873
|
},
|
|
865
|
-
|
|
874
|
+
m
|
|
866
875
|
);
|
|
867
876
|
}) });
|
|
868
|
-
},
|
|
869
|
-
const
|
|
870
|
-
return { start:
|
|
871
|
-
},
|
|
872
|
-
date:
|
|
873
|
-
filter:
|
|
874
|
-
setViews:
|
|
875
|
-
setDate:
|
|
876
|
-
dateRange:
|
|
877
|
-
setDateRange:
|
|
878
|
-
onChange:
|
|
879
|
-
minDate:
|
|
880
|
-
maxDate:
|
|
881
|
-
input:
|
|
877
|
+
}, dn = (n) => {
|
|
878
|
+
const e = Math.floor(n / 10) * 10, r = e + 10;
|
|
879
|
+
return { start: e, end: r };
|
|
880
|
+
}, An = ({
|
|
881
|
+
date: n,
|
|
882
|
+
filter: e,
|
|
883
|
+
setViews: r,
|
|
884
|
+
setDate: t,
|
|
885
|
+
dateRange: o,
|
|
886
|
+
setDateRange: d,
|
|
887
|
+
onChange: l,
|
|
888
|
+
minDate: u,
|
|
889
|
+
maxDate: h,
|
|
890
|
+
input: s
|
|
882
891
|
}) => {
|
|
883
|
-
var
|
|
884
|
-
let
|
|
885
|
-
const
|
|
886
|
-
for (let
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
year:
|
|
890
|
-
active:
|
|
891
|
-
highlight:
|
|
892
|
-
disabled: !
|
|
892
|
+
var C, S;
|
|
893
|
+
let c = [];
|
|
894
|
+
const y = n.getFullYear(), { start: M, end: D } = dn(y), E = (C = o.from) == null ? void 0 : C.getFullYear(), v = (S = o.to) == null ? void 0 : S.getFullYear();
|
|
895
|
+
for (let g = M; g < D; g++) {
|
|
896
|
+
const k = new Date(g, 0), f = (!u || k >= u) && (!h || k <= h), w = E != null && g === E || v != null && g === v, B = o.from != null && o.to != null && k > o.from && k < o.to;
|
|
897
|
+
c.push({
|
|
898
|
+
year: g,
|
|
899
|
+
active: w && f,
|
|
900
|
+
highlight: B && f,
|
|
901
|
+
disabled: !f
|
|
893
902
|
});
|
|
894
903
|
}
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
},
|
|
898
|
-
let
|
|
899
|
-
if (
|
|
900
|
-
|
|
901
|
-
else if (!
|
|
902
|
-
|
|
904
|
+
const m = (g) => {
|
|
905
|
+
e ? (i(g), t(g)) : (t(g), r("months"));
|
|
906
|
+
}, i = (g) => {
|
|
907
|
+
let k = { ...o };
|
|
908
|
+
if (k.from && k.to)
|
|
909
|
+
k = { from: g, to: null };
|
|
910
|
+
else if (!k.from)
|
|
911
|
+
k = { from: g, to: null };
|
|
903
912
|
else {
|
|
904
|
-
const
|
|
905
|
-
|
|
913
|
+
const f = k.from.getTime();
|
|
914
|
+
g.getTime() > f ? k = { from: k.from, to: g } : k = { from: g, to: k.from };
|
|
906
915
|
}
|
|
907
|
-
|
|
916
|
+
d(k), l(k);
|
|
908
917
|
};
|
|
909
|
-
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children:
|
|
918
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: c.map((g, k) => /* @__PURE__ */ a(
|
|
910
919
|
"p",
|
|
911
920
|
{
|
|
912
|
-
className: `${
|
|
921
|
+
className: `${g.active ? "sa-calendar-months-active" : ""} ${g.highlight ? "sa-calendar-months-highlight" : ""} ${g.disabled ? "sa-calendar-disabled" : ""}`,
|
|
913
922
|
onClick: () => {
|
|
914
|
-
|
|
923
|
+
g.disabled || m(new Date(g.year, 0));
|
|
915
924
|
},
|
|
916
925
|
style: {
|
|
917
|
-
backgroundColor:
|
|
918
|
-
color:
|
|
919
|
-
cursor:
|
|
920
|
-
pointerEvents:
|
|
921
|
-
...
|
|
926
|
+
backgroundColor: g.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
927
|
+
color: g.highlight ? "var(--sa-color-gray-500, #8c8f97)" : g.active ? "" : g.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
|
|
928
|
+
cursor: g.disabled ? "not-allowed" : "pointer",
|
|
929
|
+
pointerEvents: g.disbled ? "none" : "all",
|
|
930
|
+
...s ? {} : { width: "100%" }
|
|
922
931
|
},
|
|
923
|
-
children:
|
|
932
|
+
children: g.year
|
|
924
933
|
},
|
|
925
|
-
|
|
934
|
+
k
|
|
926
935
|
)) });
|
|
927
|
-
},
|
|
936
|
+
}, wn = ({ ...n }) => /* @__PURE__ */ a(
|
|
928
937
|
"svg",
|
|
929
938
|
{
|
|
930
939
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -932,7 +941,7 @@ const W = (e) => {
|
|
|
932
941
|
height: "20",
|
|
933
942
|
viewBox: "0 0 20 20",
|
|
934
943
|
fill: "none",
|
|
935
|
-
...
|
|
944
|
+
...n,
|
|
936
945
|
children: /* @__PURE__ */ a(
|
|
937
946
|
"path",
|
|
938
947
|
{
|
|
@@ -944,7 +953,7 @@ const W = (e) => {
|
|
|
944
953
|
}
|
|
945
954
|
)
|
|
946
955
|
}
|
|
947
|
-
),
|
|
956
|
+
), xn = ({ ...n }) => /* @__PURE__ */ a(
|
|
948
957
|
"svg",
|
|
949
958
|
{
|
|
950
959
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -952,7 +961,7 @@ const W = (e) => {
|
|
|
952
961
|
height: "20",
|
|
953
962
|
viewBox: "0 0 20 20",
|
|
954
963
|
fill: "none",
|
|
955
|
-
...
|
|
964
|
+
...n,
|
|
956
965
|
children: /* @__PURE__ */ a(
|
|
957
966
|
"path",
|
|
958
967
|
{
|
|
@@ -964,258 +973,260 @@ const W = (e) => {
|
|
|
964
973
|
}
|
|
965
974
|
)
|
|
966
975
|
}
|
|
967
|
-
),
|
|
968
|
-
setViews:
|
|
969
|
-
views:
|
|
970
|
-
filter:
|
|
971
|
-
date:
|
|
972
|
-
setDate:
|
|
976
|
+
), Rn = ({
|
|
977
|
+
setViews: n,
|
|
978
|
+
views: e,
|
|
979
|
+
filter: r,
|
|
980
|
+
date: t,
|
|
981
|
+
setDate: o
|
|
973
982
|
}) => {
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
},
|
|
977
|
-
if (
|
|
978
|
-
|
|
983
|
+
const d = () => {
|
|
984
|
+
r || n((s) => s === "days" ? "months" : s === "months" ? "years" : "days");
|
|
985
|
+
}, l = () => {
|
|
986
|
+
if (e === "years") {
|
|
987
|
+
o((s) => new Date(s.getFullYear() + 10, 0));
|
|
979
988
|
return;
|
|
980
989
|
}
|
|
981
|
-
if (
|
|
982
|
-
|
|
990
|
+
if (e === "months") {
|
|
991
|
+
o((s) => new Date(s.getFullYear() + 1, s.getMonth()));
|
|
983
992
|
return;
|
|
984
993
|
}
|
|
985
|
-
|
|
986
|
-
},
|
|
987
|
-
if (
|
|
988
|
-
|
|
994
|
+
o((s) => new Date(s.getFullYear(), s.getMonth() + 1));
|
|
995
|
+
}, u = () => {
|
|
996
|
+
if (e === "years") {
|
|
997
|
+
o((s) => new Date(s.getFullYear() - 10, 0));
|
|
989
998
|
return;
|
|
990
999
|
}
|
|
991
|
-
if (
|
|
992
|
-
|
|
1000
|
+
if (e === "months") {
|
|
1001
|
+
o((s) => new Date(s.getFullYear() - 1, s.getMonth()));
|
|
993
1002
|
return;
|
|
994
1003
|
}
|
|
995
|
-
|
|
996
|
-
(
|
|
997
|
-
|
|
998
|
-
|
|
1004
|
+
o(
|
|
1005
|
+
(s) => new Date(
|
|
1006
|
+
s.getMonth() === 0 ? s.getFullYear() - 1 : s.getFullYear(),
|
|
1007
|
+
s.getMonth() === 0 ? 11 : s.getMonth() - 1
|
|
999
1008
|
)
|
|
1000
1009
|
);
|
|
1001
1010
|
};
|
|
1002
|
-
return /* @__PURE__ */
|
|
1003
|
-
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick:
|
|
1004
|
-
if (
|
|
1005
|
-
return `${
|
|
1006
|
-
if (
|
|
1007
|
-
return `${
|
|
1008
|
-
if (
|
|
1009
|
-
return `${
|
|
1011
|
+
return /* @__PURE__ */ z("div", { className: "sa-calendar-header", children: [
|
|
1012
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
|
|
1013
|
+
if (e === "days")
|
|
1014
|
+
return `${q[t.getMonth()]} ${t.getFullYear()}`;
|
|
1015
|
+
if (e === "months")
|
|
1016
|
+
return `${t.getFullYear()}`;
|
|
1017
|
+
if (e === "years")
|
|
1018
|
+
return `${dn(t.getFullYear()).start} ~ ${dn(t.getFullYear()).end}`;
|
|
1010
1019
|
})() }),
|
|
1011
|
-
/* @__PURE__ */
|
|
1012
|
-
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick:
|
|
1013
|
-
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick:
|
|
1020
|
+
/* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
|
|
1021
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: u, children: /* @__PURE__ */ a(wn, {}) }),
|
|
1022
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: l, children: /* @__PURE__ */ a(xn, {}) })
|
|
1014
1023
|
] })
|
|
1015
1024
|
] });
|
|
1016
1025
|
};
|
|
1017
|
-
function
|
|
1018
|
-
const
|
|
1019
|
-
return `${
|
|
1020
|
-
}
|
|
1021
|
-
const
|
|
1022
|
-
label:
|
|
1023
|
-
labelPosition:
|
|
1024
|
-
required:
|
|
1025
|
-
optional:
|
|
1026
|
-
description:
|
|
1027
|
-
helperText:
|
|
1028
|
-
errorText:
|
|
1029
|
-
fullWidth:
|
|
1030
|
-
|
|
1026
|
+
function K(n) {
|
|
1027
|
+
const e = new Date(n), r = e.getFullYear(), t = e.getMonth();
|
|
1028
|
+
return `${e.getDate().toString().padStart(2, "0")} ${Tn[t]} ${r}`;
|
|
1029
|
+
}
|
|
1030
|
+
const pn = ({
|
|
1031
|
+
label: n,
|
|
1032
|
+
labelPosition: e = "outside-top",
|
|
1033
|
+
required: r,
|
|
1034
|
+
optional: t,
|
|
1035
|
+
description: o,
|
|
1036
|
+
helperText: d,
|
|
1037
|
+
errorText: l,
|
|
1038
|
+
fullWidth: u,
|
|
1039
|
+
size: h = "sm",
|
|
1040
|
+
children: s
|
|
1031
1041
|
}) => {
|
|
1032
|
-
const
|
|
1042
|
+
const c = [
|
|
1033
1043
|
"sa-date-field",
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
t && /* @__PURE__ */ a("span", { className: "sa-date-field-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1044
|
+
`sa-date-field-size-${h}`,
|
|
1045
|
+
u ? "sa-date-field-fullwidth" : ""
|
|
1046
|
+
].filter(Boolean).join(" "), y = n ? /* @__PURE__ */ z("div", { className: "sa-date-field-label-row", children: [
|
|
1047
|
+
/* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: n }),
|
|
1048
|
+
t && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
|
|
1049
|
+
r && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
|
|
1050
|
+
] }) : null, M = /* @__PURE__ */ z(rn, { children: [
|
|
1051
|
+
d && !l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: d }),
|
|
1052
|
+
l && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: l })
|
|
1042
1053
|
] });
|
|
1043
|
-
return
|
|
1044
|
-
/* @__PURE__ */
|
|
1045
|
-
|
|
1046
|
-
|
|
1054
|
+
return n ? e === "outside-left" ? /* @__PURE__ */ z("div", { className: `${c} sa-date-field-left`, children: [
|
|
1055
|
+
/* @__PURE__ */ z("div", { className: "sa-date-field-left-label", children: [
|
|
1056
|
+
y,
|
|
1057
|
+
o && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: o })
|
|
1047
1058
|
] }),
|
|
1048
|
-
/* @__PURE__ */
|
|
1049
|
-
|
|
1050
|
-
|
|
1059
|
+
/* @__PURE__ */ z("div", { className: "sa-date-field-input-wrap", children: [
|
|
1060
|
+
s,
|
|
1061
|
+
M
|
|
1051
1062
|
] })
|
|
1052
|
-
] }) : /* @__PURE__ */
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
] }) : /* @__PURE__ */
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1063
|
+
] }) : /* @__PURE__ */ z("div", { className: c, children: [
|
|
1064
|
+
y,
|
|
1065
|
+
o && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: o }),
|
|
1066
|
+
s,
|
|
1067
|
+
M
|
|
1068
|
+
] }) : /* @__PURE__ */ z("div", { className: c, children: [
|
|
1069
|
+
o && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: o }),
|
|
1070
|
+
s,
|
|
1071
|
+
M
|
|
1061
1072
|
] });
|
|
1062
|
-
},
|
|
1063
|
-
if (!document.getElementById(
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1073
|
+
}, gn = "sa-calendar-styles", Hn = (n) => {
|
|
1074
|
+
if (!document.getElementById(gn)) {
|
|
1075
|
+
const e = document.createElement("style");
|
|
1076
|
+
e.id = gn, e.textContent = n, document.head.appendChild(e);
|
|
1066
1077
|
}
|
|
1067
1078
|
};
|
|
1068
|
-
|
|
1069
|
-
const
|
|
1079
|
+
Hn(X);
|
|
1080
|
+
const Wn = tn(
|
|
1070
1081
|
({
|
|
1071
|
-
value:
|
|
1072
|
-
onChange:
|
|
1073
|
-
filter:
|
|
1074
|
-
input:
|
|
1075
|
-
disabled:
|
|
1076
|
-
minDate:
|
|
1077
|
-
maxDate:
|
|
1078
|
-
placeholder:
|
|
1079
|
-
size:
|
|
1080
|
-
variant:
|
|
1081
|
-
status:
|
|
1082
|
-
clearable:
|
|
1082
|
+
value: n,
|
|
1083
|
+
onChange: e,
|
|
1084
|
+
filter: r,
|
|
1085
|
+
input: t = !0,
|
|
1086
|
+
disabled: o,
|
|
1087
|
+
minDate: d,
|
|
1088
|
+
maxDate: l,
|
|
1089
|
+
placeholder: u,
|
|
1090
|
+
size: h = "sm",
|
|
1091
|
+
variant: s,
|
|
1092
|
+
status: c,
|
|
1093
|
+
clearable: y,
|
|
1083
1094
|
fullWidth: M = !0,
|
|
1084
|
-
withPadding:
|
|
1085
|
-
label:
|
|
1086
|
-
labelPosition:
|
|
1087
|
-
required:
|
|
1088
|
-
optional:
|
|
1089
|
-
description:
|
|
1090
|
-
helperText:
|
|
1091
|
-
errorText:
|
|
1092
|
-
},
|
|
1093
|
-
const
|
|
1094
|
-
from: (
|
|
1095
|
-
to: (
|
|
1095
|
+
withPadding: D = !0,
|
|
1096
|
+
label: E,
|
|
1097
|
+
labelPosition: v,
|
|
1098
|
+
required: m,
|
|
1099
|
+
optional: i,
|
|
1100
|
+
description: C,
|
|
1101
|
+
helperText: S,
|
|
1102
|
+
errorText: g
|
|
1103
|
+
}, k) => {
|
|
1104
|
+
const f = g ? "error" : c, { ref: w, isComponentVisible: B, setIsComponentVisible: V } = un(!1), L = J(null), [F, T] = O("days"), [b, $] = O(/* @__PURE__ */ new Date()), [x, I] = O({
|
|
1105
|
+
from: (n == null ? void 0 : n.from) ?? null,
|
|
1106
|
+
to: (n == null ? void 0 : n.to) ?? null
|
|
1096
1107
|
});
|
|
1097
|
-
|
|
1098
|
-
if (
|
|
1099
|
-
const
|
|
1100
|
-
|
|
1108
|
+
A(() => {
|
|
1109
|
+
if (n) {
|
|
1110
|
+
const N = n;
|
|
1111
|
+
N.from && $(N.from), I(N);
|
|
1101
1112
|
} else
|
|
1102
|
-
|
|
1103
|
-
}, [
|
|
1104
|
-
|
|
1105
|
-
}, [
|
|
1106
|
-
|
|
1107
|
-
}, [
|
|
1108
|
-
|
|
1109
|
-
}, [
|
|
1110
|
-
const
|
|
1111
|
-
var
|
|
1112
|
-
if (!
|
|
1113
|
+
$(/* @__PURE__ */ new Date()), I({ from: null, to: null });
|
|
1114
|
+
}, [n]), A(() => {
|
|
1115
|
+
r && T(r);
|
|
1116
|
+
}, [r]), A(() => {
|
|
1117
|
+
r || T("days");
|
|
1118
|
+
}, [B]), A(() => {
|
|
1119
|
+
t || V(!0);
|
|
1120
|
+
}, [t]);
|
|
1121
|
+
const H = () => {
|
|
1122
|
+
var N, j;
|
|
1123
|
+
if (!n)
|
|
1113
1124
|
return "";
|
|
1114
|
-
if (
|
|
1125
|
+
if (r) {
|
|
1115
1126
|
if (F === "days")
|
|
1116
|
-
return `${
|
|
1127
|
+
return `${K(x.from)} ~ ${K(x.to || x.from) || "-"}`;
|
|
1117
1128
|
if (F === "months")
|
|
1118
|
-
return `${
|
|
1129
|
+
return `${q[x.from.getMonth()]} ~ ${x.to ? q[x.to.getMonth()] : "-"}`;
|
|
1119
1130
|
if (F === "years")
|
|
1120
|
-
return `${(
|
|
1131
|
+
return `${(N = x.from) == null ? void 0 : N.getFullYear()} ~ ${((j = x.to) == null ? void 0 : j.getFullYear()) || "-"}`;
|
|
1121
1132
|
} else
|
|
1122
|
-
return `${
|
|
1123
|
-
},
|
|
1124
|
-
if (
|
|
1125
|
-
const
|
|
1126
|
-
window.innerWidth <
|
|
1133
|
+
return `${K(x.from)} ~ ${K(x.to || x.from) || "-"}`;
|
|
1134
|
+
}, P = () => {
|
|
1135
|
+
if (L.current && w.current && t) {
|
|
1136
|
+
const N = w.current.getBoundingClientRect(), j = L.current.getBoundingClientRect();
|
|
1137
|
+
window.innerWidth < N.left + j.width ? L.current.style.left = `${N.left - j.width + N.width}px` : L.current.style.left = `${N.left}px`, N.top + j.height > window.innerHeight ? L.current.style.top = `${N.y - (N.height + j.height - 28)}px` : L.current.style.top = `${N.y + N.height}px`;
|
|
1127
1138
|
}
|
|
1128
1139
|
};
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
}, [
|
|
1132
|
-
window.removeEventListener("scroll",
|
|
1140
|
+
A(() => {
|
|
1141
|
+
L.current && w.current && t && P();
|
|
1142
|
+
}, [L, w, B]), A(() => (window.addEventListener("scroll", P, !0), window.addEventListener("resize", P), () => {
|
|
1143
|
+
window.removeEventListener("scroll", P, !0), window.removeEventListener("resize", P);
|
|
1133
1144
|
}), []);
|
|
1134
|
-
const
|
|
1145
|
+
const _ = /* @__PURE__ */ z(
|
|
1135
1146
|
"div",
|
|
1136
1147
|
{
|
|
1137
1148
|
className: "sa-calendar-wrapper",
|
|
1138
|
-
style: { height:
|
|
1139
|
-
ref:
|
|
1149
|
+
style: { height: t ? "auto" : "100%" },
|
|
1150
|
+
ref: t ? w : null,
|
|
1140
1151
|
children: [
|
|
1141
|
-
|
|
1142
|
-
|
|
1152
|
+
t ? /* @__PURE__ */ a(
|
|
1153
|
+
Vn,
|
|
1143
1154
|
{
|
|
1144
|
-
value:
|
|
1155
|
+
value: H(),
|
|
1145
1156
|
inputMode: "none",
|
|
1146
1157
|
onClick: () => {
|
|
1147
|
-
|
|
1158
|
+
V(!0);
|
|
1148
1159
|
},
|
|
1149
1160
|
onChange: () => {
|
|
1150
1161
|
},
|
|
1151
|
-
disabled:
|
|
1152
|
-
placeholder:
|
|
1153
|
-
size:
|
|
1154
|
-
variant:
|
|
1155
|
-
status:
|
|
1156
|
-
clearable:
|
|
1157
|
-
onClear: () =>
|
|
1162
|
+
disabled: o,
|
|
1163
|
+
placeholder: u,
|
|
1164
|
+
size: h,
|
|
1165
|
+
variant: s,
|
|
1166
|
+
status: f,
|
|
1167
|
+
clearable: y,
|
|
1168
|
+
onClear: () => e(void 0)
|
|
1158
1169
|
}
|
|
1159
1170
|
) : null,
|
|
1160
|
-
|
|
1171
|
+
B ? /* @__PURE__ */ z(
|
|
1161
1172
|
"div",
|
|
1162
1173
|
{
|
|
1163
|
-
className: `sa-calendar sa-calendar-size-${
|
|
1164
|
-
style:
|
|
1165
|
-
ref:
|
|
1174
|
+
className: `sa-calendar sa-calendar-size-${h || "sm"} ${t ? "" : "sa-calendar-no-input"} ${D ? "" : "sa-calendar-no-padding"}`,
|
|
1175
|
+
style: o ? { pointerEvents: "none" } : void 0,
|
|
1176
|
+
ref: L,
|
|
1166
1177
|
children: [
|
|
1167
1178
|
/* @__PURE__ */ a(
|
|
1168
|
-
|
|
1179
|
+
Rn,
|
|
1169
1180
|
{
|
|
1170
|
-
setViews:
|
|
1181
|
+
setViews: T,
|
|
1171
1182
|
views: F,
|
|
1172
|
-
filter:
|
|
1173
|
-
date:
|
|
1174
|
-
setDate:
|
|
1183
|
+
filter: r,
|
|
1184
|
+
date: b,
|
|
1185
|
+
setDate: $
|
|
1175
1186
|
}
|
|
1176
1187
|
),
|
|
1177
1188
|
/* @__PURE__ */ a("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ a(
|
|
1178
|
-
|
|
1189
|
+
Pn,
|
|
1179
1190
|
{
|
|
1180
|
-
date:
|
|
1181
|
-
setDate:
|
|
1182
|
-
setIsComponentVisible:
|
|
1183
|
-
dateRange:
|
|
1184
|
-
setDateRange:
|
|
1185
|
-
input:
|
|
1186
|
-
onChange:
|
|
1187
|
-
minDate:
|
|
1188
|
-
maxDate:
|
|
1191
|
+
date: b,
|
|
1192
|
+
setDate: $,
|
|
1193
|
+
setIsComponentVisible: V,
|
|
1194
|
+
dateRange: x,
|
|
1195
|
+
setDateRange: I,
|
|
1196
|
+
input: t,
|
|
1197
|
+
onChange: e,
|
|
1198
|
+
minDate: d,
|
|
1199
|
+
maxDate: l
|
|
1189
1200
|
}
|
|
1190
1201
|
) : F === "months" ? /* @__PURE__ */ a(
|
|
1191
|
-
|
|
1202
|
+
jn,
|
|
1192
1203
|
{
|
|
1193
|
-
date:
|
|
1194
|
-
setDate:
|
|
1195
|
-
filter:
|
|
1196
|
-
setViews:
|
|
1197
|
-
dateRange:
|
|
1198
|
-
setDateRange:
|
|
1199
|
-
setIsComponentVisible:
|
|
1200
|
-
input:
|
|
1201
|
-
onChange:
|
|
1202
|
-
minDate:
|
|
1203
|
-
maxDate:
|
|
1204
|
+
date: b,
|
|
1205
|
+
setDate: $,
|
|
1206
|
+
filter: r,
|
|
1207
|
+
setViews: T,
|
|
1208
|
+
dateRange: x,
|
|
1209
|
+
setDateRange: I,
|
|
1210
|
+
setIsComponentVisible: V,
|
|
1211
|
+
input: t,
|
|
1212
|
+
onChange: e,
|
|
1213
|
+
minDate: d,
|
|
1214
|
+
maxDate: l
|
|
1204
1215
|
}
|
|
1205
1216
|
) : /* @__PURE__ */ a(
|
|
1206
|
-
|
|
1217
|
+
An,
|
|
1207
1218
|
{
|
|
1208
|
-
date:
|
|
1209
|
-
setDate:
|
|
1210
|
-
filter:
|
|
1211
|
-
setViews:
|
|
1212
|
-
dateRange:
|
|
1213
|
-
setDateRange:
|
|
1214
|
-
setIsComponentVisible:
|
|
1215
|
-
input:
|
|
1216
|
-
onChange:
|
|
1217
|
-
minDate:
|
|
1218
|
-
maxDate:
|
|
1219
|
+
date: b,
|
|
1220
|
+
setDate: $,
|
|
1221
|
+
filter: r,
|
|
1222
|
+
setViews: T,
|
|
1223
|
+
dateRange: x,
|
|
1224
|
+
setDateRange: I,
|
|
1225
|
+
setIsComponentVisible: V,
|
|
1226
|
+
input: t,
|
|
1227
|
+
onChange: e,
|
|
1228
|
+
minDate: d,
|
|
1229
|
+
maxDate: l
|
|
1219
1230
|
}
|
|
1220
1231
|
) })
|
|
1221
1232
|
]
|
|
@@ -1225,61 +1236,62 @@ const mn = K(
|
|
|
1225
1236
|
}
|
|
1226
1237
|
);
|
|
1227
1238
|
return /* @__PURE__ */ a(
|
|
1228
|
-
|
|
1239
|
+
pn,
|
|
1229
1240
|
{
|
|
1230
|
-
label:
|
|
1231
|
-
labelPosition:
|
|
1232
|
-
required:
|
|
1233
|
-
optional:
|
|
1234
|
-
description:
|
|
1235
|
-
helperText:
|
|
1236
|
-
errorText:
|
|
1241
|
+
label: E,
|
|
1242
|
+
labelPosition: v,
|
|
1243
|
+
required: m,
|
|
1244
|
+
optional: i,
|
|
1245
|
+
description: C,
|
|
1246
|
+
helperText: S,
|
|
1247
|
+
errorText: g,
|
|
1237
1248
|
fullWidth: M,
|
|
1238
|
-
|
|
1249
|
+
size: h,
|
|
1250
|
+
children: _
|
|
1239
1251
|
}
|
|
1240
1252
|
);
|
|
1241
1253
|
}
|
|
1242
|
-
),
|
|
1243
|
-
if (!document.getElementById(
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1254
|
+
), mn = "sa-calendar-input-styles", On = (n) => {
|
|
1255
|
+
if (!document.getElementById(mn)) {
|
|
1256
|
+
const e = document.createElement("style");
|
|
1257
|
+
e.id = mn, e.textContent = n, document.head.appendChild(e);
|
|
1246
1258
|
}
|
|
1247
1259
|
};
|
|
1248
|
-
|
|
1249
|
-
const
|
|
1250
|
-
if (
|
|
1260
|
+
On(X);
|
|
1261
|
+
const Z = (n) => {
|
|
1262
|
+
if (n === "xs")
|
|
1251
1263
|
return 14;
|
|
1252
|
-
if (
|
|
1264
|
+
if (n === "sm")
|
|
1253
1265
|
return 16;
|
|
1254
|
-
if (
|
|
1266
|
+
if (n === "md")
|
|
1255
1267
|
return 16;
|
|
1256
|
-
if (
|
|
1268
|
+
if (n === "lg")
|
|
1257
1269
|
return 20;
|
|
1258
|
-
},
|
|
1270
|
+
}, Jn = (n) => {
|
|
1259
1271
|
const {
|
|
1260
|
-
size:
|
|
1261
|
-
status:
|
|
1262
|
-
variant:
|
|
1263
|
-
clearable:
|
|
1264
|
-
onClear:
|
|
1265
|
-
...
|
|
1266
|
-
} =
|
|
1267
|
-
|
|
1268
|
-
},
|
|
1269
|
-
|
|
1272
|
+
size: e = "sm",
|
|
1273
|
+
status: r = "default",
|
|
1274
|
+
variant: t = "outline",
|
|
1275
|
+
clearable: o,
|
|
1276
|
+
onClear: d,
|
|
1277
|
+
...l
|
|
1278
|
+
} = n, u = J(null), h = () => {
|
|
1279
|
+
u.current && l.onClick && (u.current.focus(), l.onClick(""));
|
|
1280
|
+
}, s = r === "disable" || l.disabled, c = !!l.value, y = o && c && !s, M = (D) => {
|
|
1281
|
+
D.stopPropagation(), d == null || d();
|
|
1270
1282
|
};
|
|
1271
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ z(
|
|
1272
1284
|
"div",
|
|
1273
1285
|
{
|
|
1274
|
-
className: `sa-calendar-input-container sa-calendar-input-${
|
|
1275
|
-
onClick:
|
|
1286
|
+
className: `sa-calendar-input-container sa-calendar-input-${t} sa-calendar-input-container-${r} ${e} `,
|
|
1287
|
+
onClick: h,
|
|
1276
1288
|
children: [
|
|
1277
1289
|
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
|
|
1278
1290
|
"svg",
|
|
1279
1291
|
{
|
|
1280
1292
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1281
|
-
width:
|
|
1282
|
-
height:
|
|
1293
|
+
width: Z(e),
|
|
1294
|
+
height: Z(e),
|
|
1283
1295
|
viewBox: "0 0 20 20",
|
|
1284
1296
|
fill: "none",
|
|
1285
1297
|
children: /* @__PURE__ */ a(
|
|
@@ -1298,13 +1310,13 @@ const O = (e) => {
|
|
|
1298
1310
|
"input",
|
|
1299
1311
|
{
|
|
1300
1312
|
className: "sa-calendar-input",
|
|
1301
|
-
...
|
|
1302
|
-
disabled:
|
|
1303
|
-
value:
|
|
1304
|
-
ref:
|
|
1313
|
+
...l,
|
|
1314
|
+
disabled: s,
|
|
1315
|
+
value: l.value,
|
|
1316
|
+
ref: u
|
|
1305
1317
|
}
|
|
1306
1318
|
) }),
|
|
1307
|
-
|
|
1319
|
+
y ? /* @__PURE__ */ a(
|
|
1308
1320
|
"button",
|
|
1309
1321
|
{
|
|
1310
1322
|
type: "button",
|
|
@@ -1315,8 +1327,8 @@ const O = (e) => {
|
|
|
1315
1327
|
"svg",
|
|
1316
1328
|
{
|
|
1317
1329
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1318
|
-
width:
|
|
1319
|
-
height:
|
|
1330
|
+
width: Z(e),
|
|
1331
|
+
height: Z(e),
|
|
1320
1332
|
viewBox: "0 0 20 20",
|
|
1321
1333
|
fill: "none",
|
|
1322
1334
|
children: /* @__PURE__ */ a(
|
|
@@ -1336,8 +1348,8 @@ const O = (e) => {
|
|
|
1336
1348
|
"svg",
|
|
1337
1349
|
{
|
|
1338
1350
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1339
|
-
width:
|
|
1340
|
-
height:
|
|
1351
|
+
width: Z(e),
|
|
1352
|
+
height: Z(e),
|
|
1341
1353
|
viewBox: "0 0 20 20",
|
|
1342
1354
|
fill: "none",
|
|
1343
1355
|
children: /* @__PURE__ */ a(
|
|
@@ -1355,338 +1367,338 @@ const O = (e) => {
|
|
|
1355
1367
|
]
|
|
1356
1368
|
}
|
|
1357
1369
|
);
|
|
1358
|
-
},
|
|
1359
|
-
date:
|
|
1360
|
-
setDate:
|
|
1361
|
-
previewDate:
|
|
1362
|
-
setPreviewDate:
|
|
1363
|
-
setIsComponentVisible:
|
|
1364
|
-
minDate:
|
|
1365
|
-
maxDate:
|
|
1366
|
-
input:
|
|
1367
|
-
onChange:
|
|
1368
|
-
hasValue:
|
|
1370
|
+
}, qn = ({
|
|
1371
|
+
date: n,
|
|
1372
|
+
setDate: e,
|
|
1373
|
+
previewDate: r,
|
|
1374
|
+
setPreviewDate: t,
|
|
1375
|
+
setIsComponentVisible: o,
|
|
1376
|
+
minDate: d,
|
|
1377
|
+
maxDate: l,
|
|
1378
|
+
input: u,
|
|
1379
|
+
onChange: h,
|
|
1380
|
+
hasValue: s
|
|
1369
1381
|
}) => {
|
|
1370
|
-
let
|
|
1371
|
-
|
|
1372
|
-
|
|
1382
|
+
let c = new Date(
|
|
1383
|
+
r.getFullYear(),
|
|
1384
|
+
r.getMonth(),
|
|
1373
1385
|
1
|
|
1374
|
-
),
|
|
1375
|
-
const
|
|
1376
|
-
for (let
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
) :
|
|
1380
|
-
let
|
|
1381
|
-
currentMonth:
|
|
1382
|
-
date: new Date(
|
|
1383
|
-
month:
|
|
1384
|
-
number:
|
|
1385
|
-
selected:
|
|
1386
|
-
isToday:
|
|
1387
|
-
year:
|
|
1388
|
-
isDisabled:
|
|
1386
|
+
), y = c.getDay(), M = [];
|
|
1387
|
+
const D = n.toDateString(), E = (/* @__PURE__ */ new Date()).toDateString(), v = r.getMonth();
|
|
1388
|
+
for (let i = 0; i < 42; i++) {
|
|
1389
|
+
i === 0 && y === 0 ? c.setDate(c.getDate() - 7) : i === 0 ? c.setDate(
|
|
1390
|
+
c.getDate() + (i - y)
|
|
1391
|
+
) : c.setDate(c.getDate() + 1);
|
|
1392
|
+
let C = {
|
|
1393
|
+
currentMonth: c.getMonth() === v,
|
|
1394
|
+
date: new Date(c),
|
|
1395
|
+
month: c.getMonth(),
|
|
1396
|
+
number: c.getDate(),
|
|
1397
|
+
selected: s && c.toDateString() === D,
|
|
1398
|
+
isToday: c.toDateString() === E,
|
|
1399
|
+
year: c.getFullYear(),
|
|
1400
|
+
isDisabled: d && c < d || l && c > l
|
|
1389
1401
|
};
|
|
1390
|
-
M.push(
|
|
1402
|
+
M.push(C);
|
|
1391
1403
|
}
|
|
1392
|
-
const
|
|
1393
|
-
(!
|
|
1404
|
+
const m = (i) => {
|
|
1405
|
+
(!d || i >= d) && (!l || i <= l) && (e(i), h(i), t(i), u && o(!1));
|
|
1394
1406
|
};
|
|
1395
|
-
return /* @__PURE__ */
|
|
1396
|
-
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children:
|
|
1397
|
-
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((
|
|
1398
|
-
const
|
|
1407
|
+
return /* @__PURE__ */ z("div", { className: "sa-calendar-days-preivew", children: [
|
|
1408
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: yn.map((i, C) => /* @__PURE__ */ a("p", { children: i }, C)) }),
|
|
1409
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: M.map((i, C) => {
|
|
1410
|
+
const S = i.isDisabled;
|
|
1399
1411
|
return /* @__PURE__ */ a(
|
|
1400
1412
|
"p",
|
|
1401
1413
|
{
|
|
1402
|
-
className: `${
|
|
1414
|
+
className: `${i.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${i.selected ? "sa-calendar-days-active" : ""} ${i.isToday && !i.selected ? "sa-calendar-days-today" : ""}`,
|
|
1403
1415
|
style: {
|
|
1404
|
-
color:
|
|
1405
|
-
pointerEvents:
|
|
1406
|
-
cursor:
|
|
1407
|
-
...
|
|
1416
|
+
color: S ? "#ccc" : void 0,
|
|
1417
|
+
pointerEvents: S ? "none" : void 0,
|
|
1418
|
+
cursor: S ? "not-allowed" : "pointer",
|
|
1419
|
+
...u ? {} : { width: "100%" }
|
|
1408
1420
|
},
|
|
1409
1421
|
onClick: () => {
|
|
1410
|
-
|
|
1422
|
+
S || m(i.date);
|
|
1411
1423
|
},
|
|
1412
|
-
children:
|
|
1424
|
+
children: i.number
|
|
1413
1425
|
},
|
|
1414
|
-
|
|
1426
|
+
C
|
|
1415
1427
|
);
|
|
1416
1428
|
}) })
|
|
1417
1429
|
] });
|
|
1418
|
-
},
|
|
1419
|
-
date:
|
|
1420
|
-
setDate:
|
|
1421
|
-
filter:
|
|
1422
|
-
setViews:
|
|
1423
|
-
onChange:
|
|
1424
|
-
previewDate:
|
|
1425
|
-
setPreviewDate:
|
|
1426
|
-
minDate:
|
|
1427
|
-
maxDate:
|
|
1428
|
-
input:
|
|
1429
|
-
hasValue:
|
|
1430
|
+
}, Gn = ({
|
|
1431
|
+
date: n,
|
|
1432
|
+
setDate: e,
|
|
1433
|
+
filter: r,
|
|
1434
|
+
setViews: t,
|
|
1435
|
+
onChange: o,
|
|
1436
|
+
previewDate: d,
|
|
1437
|
+
setPreviewDate: l,
|
|
1438
|
+
minDate: u,
|
|
1439
|
+
maxDate: h,
|
|
1440
|
+
input: s,
|
|
1441
|
+
hasValue: c
|
|
1430
1442
|
}) => {
|
|
1431
|
-
const
|
|
1432
|
-
(!
|
|
1443
|
+
const y = n.getMonth(), M = n.getFullYear(), D = d.getFullYear(), E = (v) => {
|
|
1444
|
+
(!u || v >= u) && (!h || v <= h) && (r ? (o(v), e(v), l(v)) : (t("days"), l(v)));
|
|
1433
1445
|
};
|
|
1434
|
-
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children:
|
|
1435
|
-
const
|
|
1446
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: q.map((v, m) => {
|
|
1447
|
+
const i = u && new Date(D, m, 1) < u || h && new Date(D, m + 1, 0) > h;
|
|
1436
1448
|
return /* @__PURE__ */ a(
|
|
1437
1449
|
"p",
|
|
1438
1450
|
{
|
|
1439
|
-
className:
|
|
1451
|
+
className: c && m === y && D === M ? "sa-calendar-months-active" : "",
|
|
1440
1452
|
style: {
|
|
1441
|
-
color:
|
|
1442
|
-
pointerEvents:
|
|
1443
|
-
cursor:
|
|
1444
|
-
...
|
|
1453
|
+
color: i ? "#ccc" : void 0,
|
|
1454
|
+
pointerEvents: i ? "none" : void 0,
|
|
1455
|
+
cursor: i ? "not-allowed" : "pointer",
|
|
1456
|
+
...s ? {} : { width: "100%" }
|
|
1445
1457
|
},
|
|
1446
1458
|
onClick: () => {
|
|
1447
|
-
|
|
1459
|
+
i || E(new Date(D, m));
|
|
1448
1460
|
},
|
|
1449
|
-
children:
|
|
1461
|
+
children: v.slice(0, 3)
|
|
1450
1462
|
},
|
|
1451
|
-
|
|
1463
|
+
m
|
|
1452
1464
|
);
|
|
1453
1465
|
}) });
|
|
1454
|
-
},
|
|
1455
|
-
const
|
|
1456
|
-
return { start:
|
|
1457
|
-
},
|
|
1458
|
-
date:
|
|
1459
|
-
filter:
|
|
1460
|
-
setViews:
|
|
1461
|
-
setDate:
|
|
1462
|
-
onChange:
|
|
1463
|
-
previewDate:
|
|
1464
|
-
setPreviewDate:
|
|
1465
|
-
minDate:
|
|
1466
|
-
maxDate:
|
|
1467
|
-
input:
|
|
1468
|
-
hasValue:
|
|
1466
|
+
}, cn = (n) => {
|
|
1467
|
+
const e = Math.floor(n / 10) * 10, r = e + 10;
|
|
1468
|
+
return { start: e, end: r };
|
|
1469
|
+
}, Un = ({
|
|
1470
|
+
date: n,
|
|
1471
|
+
filter: e,
|
|
1472
|
+
setViews: r,
|
|
1473
|
+
setDate: t,
|
|
1474
|
+
onChange: o,
|
|
1475
|
+
previewDate: d,
|
|
1476
|
+
setPreviewDate: l,
|
|
1477
|
+
minDate: u,
|
|
1478
|
+
maxDate: h,
|
|
1479
|
+
input: s,
|
|
1480
|
+
hasValue: c
|
|
1469
1481
|
}) => {
|
|
1470
|
-
let
|
|
1471
|
-
const M =
|
|
1472
|
-
for (let
|
|
1473
|
-
let
|
|
1474
|
-
|
|
1475
|
-
year:
|
|
1476
|
-
active: !!
|
|
1477
|
-
isDisabled:
|
|
1482
|
+
let y = [];
|
|
1483
|
+
const M = d.getFullYear(), { start: D, end: E } = cn(M), v = n.getFullYear();
|
|
1484
|
+
for (let i = D; i < E; i++) {
|
|
1485
|
+
let C = u && new Date(i, 0, 1) < u || h && new Date(i, 11, 31) > h;
|
|
1486
|
+
y.push({
|
|
1487
|
+
year: i,
|
|
1488
|
+
active: !!c && i === v,
|
|
1489
|
+
isDisabled: C
|
|
1478
1490
|
});
|
|
1479
1491
|
}
|
|
1480
|
-
const
|
|
1481
|
-
(!
|
|
1492
|
+
const m = (i) => {
|
|
1493
|
+
(!u || i >= u) && (!h || i <= h) && (e ? (o(i), t(i), l(i)) : (r("months"), l(i)));
|
|
1482
1494
|
};
|
|
1483
|
-
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children:
|
|
1495
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: y.map((i, C) => /* @__PURE__ */ a(
|
|
1484
1496
|
"p",
|
|
1485
1497
|
{
|
|
1486
|
-
className:
|
|
1498
|
+
className: i.active ? "sa-calendar-months-active" : "",
|
|
1487
1499
|
style: {
|
|
1488
|
-
color:
|
|
1489
|
-
pointerEvents:
|
|
1490
|
-
cursor:
|
|
1491
|
-
...
|
|
1500
|
+
color: i.isDisabled ? "#ccc" : void 0,
|
|
1501
|
+
pointerEvents: i.isDisabled ? "none" : void 0,
|
|
1502
|
+
cursor: i.isDisabled ? "not-allowed" : "pointer",
|
|
1503
|
+
...s ? {} : { width: "100%" }
|
|
1492
1504
|
},
|
|
1493
1505
|
onClick: () => {
|
|
1494
|
-
|
|
1506
|
+
i.isDisabled || m(new Date(i.year, 0));
|
|
1495
1507
|
},
|
|
1496
|
-
children:
|
|
1508
|
+
children: i.year
|
|
1497
1509
|
},
|
|
1498
|
-
|
|
1510
|
+
C
|
|
1499
1511
|
)) });
|
|
1500
|
-
},
|
|
1501
|
-
setViews:
|
|
1502
|
-
views:
|
|
1503
|
-
filter:
|
|
1504
|
-
previewDate:
|
|
1505
|
-
setPreviewDate:
|
|
1512
|
+
}, Zn = ({
|
|
1513
|
+
setViews: n,
|
|
1514
|
+
views: e,
|
|
1515
|
+
filter: r,
|
|
1516
|
+
previewDate: t,
|
|
1517
|
+
setPreviewDate: o
|
|
1506
1518
|
}) => {
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
},
|
|
1510
|
-
if (
|
|
1511
|
-
|
|
1519
|
+
const d = () => {
|
|
1520
|
+
r || n((s) => s === "days" ? "months" : s === "months" ? "years" : "days");
|
|
1521
|
+
}, l = () => {
|
|
1522
|
+
if (e === "years") {
|
|
1523
|
+
o((s) => new Date(s.getFullYear() + 10, 0));
|
|
1512
1524
|
return;
|
|
1513
1525
|
}
|
|
1514
|
-
if (
|
|
1515
|
-
|
|
1516
|
-
(
|
|
1526
|
+
if (e === "months") {
|
|
1527
|
+
o(
|
|
1528
|
+
(s) => new Date(s.getFullYear() + 1, s.getMonth())
|
|
1517
1529
|
);
|
|
1518
1530
|
return;
|
|
1519
1531
|
}
|
|
1520
|
-
|
|
1521
|
-
},
|
|
1522
|
-
if (
|
|
1523
|
-
|
|
1532
|
+
o((s) => new Date(s.getFullYear(), s.getMonth() + 1));
|
|
1533
|
+
}, u = () => {
|
|
1534
|
+
if (e === "years") {
|
|
1535
|
+
o((s) => new Date(s.getFullYear() - 10, 0));
|
|
1524
1536
|
return;
|
|
1525
1537
|
}
|
|
1526
|
-
if (
|
|
1527
|
-
|
|
1528
|
-
(
|
|
1538
|
+
if (e === "months") {
|
|
1539
|
+
o(
|
|
1540
|
+
(s) => new Date(s.getFullYear() - 1, s.getMonth())
|
|
1529
1541
|
);
|
|
1530
1542
|
return;
|
|
1531
1543
|
}
|
|
1532
|
-
|
|
1533
|
-
(
|
|
1534
|
-
|
|
1535
|
-
|
|
1544
|
+
o(
|
|
1545
|
+
(s) => new Date(
|
|
1546
|
+
s.getMonth() === 0 ? s.getFullYear() - 1 : s.getFullYear(),
|
|
1547
|
+
s.getMonth() === 0 ? 11 : s.getMonth() - 1
|
|
1536
1548
|
)
|
|
1537
1549
|
);
|
|
1538
1550
|
};
|
|
1539
|
-
return /* @__PURE__ */
|
|
1540
|
-
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick:
|
|
1541
|
-
if (
|
|
1542
|
-
return `${
|
|
1543
|
-
if (
|
|
1544
|
-
return `${
|
|
1545
|
-
if (
|
|
1546
|
-
return `${
|
|
1551
|
+
return /* @__PURE__ */ z("div", { className: "sa-calendar-header", children: [
|
|
1552
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: d, children: (() => {
|
|
1553
|
+
if (e === "days")
|
|
1554
|
+
return `${q[t.getMonth()]} ${t.getFullYear()}`;
|
|
1555
|
+
if (e === "months")
|
|
1556
|
+
return `${t.getFullYear()}`;
|
|
1557
|
+
if (e === "years")
|
|
1558
|
+
return `${cn(t.getFullYear()).start} ~ ${cn(t.getFullYear()).end}`;
|
|
1547
1559
|
})() }),
|
|
1548
|
-
/* @__PURE__ */
|
|
1549
|
-
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick:
|
|
1550
|
-
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick:
|
|
1560
|
+
/* @__PURE__ */ z("div", { className: "sa-calendar-header-nav", children: [
|
|
1561
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: u, children: /* @__PURE__ */ a(wn, {}) }),
|
|
1562
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: l, children: /* @__PURE__ */ a(xn, {}) })
|
|
1551
1563
|
] })
|
|
1552
1564
|
] });
|
|
1553
|
-
},
|
|
1554
|
-
if (!document.getElementById(
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1565
|
+
}, bn = "sa-calendar-styles", Kn = (n) => {
|
|
1566
|
+
if (!document.getElementById(bn)) {
|
|
1567
|
+
const e = document.createElement("style");
|
|
1568
|
+
e.id = bn, e.textContent = n, document.head.appendChild(e);
|
|
1557
1569
|
}
|
|
1558
1570
|
};
|
|
1559
|
-
|
|
1560
|
-
const
|
|
1571
|
+
Kn(X);
|
|
1572
|
+
const _n = tn(
|
|
1561
1573
|
({
|
|
1562
|
-
value:
|
|
1563
|
-
onChange:
|
|
1564
|
-
filter:
|
|
1565
|
-
input:
|
|
1566
|
-
disabled:
|
|
1567
|
-
minDate:
|
|
1568
|
-
maxDate:
|
|
1569
|
-
placeholder:
|
|
1570
|
-
size:
|
|
1571
|
-
variant:
|
|
1572
|
-
status:
|
|
1573
|
-
clearable:
|
|
1574
|
+
value: n,
|
|
1575
|
+
onChange: e,
|
|
1576
|
+
filter: r,
|
|
1577
|
+
input: t = !0,
|
|
1578
|
+
disabled: o,
|
|
1579
|
+
minDate: d,
|
|
1580
|
+
maxDate: l,
|
|
1581
|
+
placeholder: u,
|
|
1582
|
+
size: h = "sm",
|
|
1583
|
+
variant: s,
|
|
1584
|
+
status: c,
|
|
1585
|
+
clearable: y,
|
|
1574
1586
|
fullWidth: M = !0,
|
|
1575
|
-
withPadding:
|
|
1576
|
-
label:
|
|
1577
|
-
labelPosition:
|
|
1578
|
-
required:
|
|
1579
|
-
optional:
|
|
1580
|
-
description:
|
|
1581
|
-
helperText:
|
|
1582
|
-
errorText:
|
|
1583
|
-
},
|
|
1584
|
-
const
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
}, [
|
|
1588
|
-
|
|
1589
|
-
}, [
|
|
1590
|
-
|
|
1591
|
-
}, [
|
|
1592
|
-
|
|
1593
|
-
}, [
|
|
1594
|
-
const
|
|
1595
|
-
if (
|
|
1596
|
-
const
|
|
1597
|
-
window.innerWidth <
|
|
1587
|
+
withPadding: D = !0,
|
|
1588
|
+
label: E,
|
|
1589
|
+
labelPosition: v,
|
|
1590
|
+
required: m,
|
|
1591
|
+
optional: i,
|
|
1592
|
+
description: C,
|
|
1593
|
+
helperText: S,
|
|
1594
|
+
errorText: g
|
|
1595
|
+
}, k) => {
|
|
1596
|
+
const f = g ? "error" : c, { ref: w, isComponentVisible: B, setIsComponentVisible: V } = un(!1), L = J(null), [F, T] = O("days"), [b, $] = O(/* @__PURE__ */ new Date()), [x, I] = O(/* @__PURE__ */ new Date());
|
|
1597
|
+
A(() => {
|
|
1598
|
+
n ? ($(n), I(n)) : ($(/* @__PURE__ */ new Date()), I(/* @__PURE__ */ new Date()));
|
|
1599
|
+
}, [n]), A(() => {
|
|
1600
|
+
r && T(r);
|
|
1601
|
+
}, [r]), A(() => {
|
|
1602
|
+
r || T("days");
|
|
1603
|
+
}, [B]), A(() => {
|
|
1604
|
+
t || V(!0);
|
|
1605
|
+
}, [t]);
|
|
1606
|
+
const H = () => n ? r === "days" ? K(b) : r === "months" ? `${q[b.getMonth()]} ${b.getFullYear()}` : r === "years" ? b.getFullYear() : K(b) : "", P = () => {
|
|
1607
|
+
if (L.current && w.current && t) {
|
|
1608
|
+
const N = w.current.getBoundingClientRect(), j = L.current.getBoundingClientRect();
|
|
1609
|
+
window.innerWidth < N.left + j.width ? L.current.style.left = `${N.left - j.width + N.width}px` : L.current.style.left = `${N.left}px`, N.top + j.height > window.innerHeight ? L.current.style.top = `${N.y - (N.height + j.height - 28)}px` : L.current.style.top = `${N.y + N.height}px`;
|
|
1598
1610
|
}
|
|
1599
1611
|
};
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
}, [
|
|
1603
|
-
window.removeEventListener("scroll",
|
|
1612
|
+
A(() => {
|
|
1613
|
+
L.current && w.current && t && P();
|
|
1614
|
+
}, [L, w, B]), A(() => (window.addEventListener("scroll", P, !0), window.addEventListener("resize", P), () => {
|
|
1615
|
+
window.removeEventListener("scroll", P, !0), window.removeEventListener("resize", P);
|
|
1604
1616
|
}), []);
|
|
1605
|
-
const
|
|
1617
|
+
const _ = /* @__PURE__ */ z(
|
|
1606
1618
|
"div",
|
|
1607
1619
|
{
|
|
1608
1620
|
className: "sa-calendar-wrapper",
|
|
1609
|
-
style: { height:
|
|
1610
|
-
ref:
|
|
1621
|
+
style: { height: t ? "auto" : "100%" },
|
|
1622
|
+
ref: t ? w : null,
|
|
1611
1623
|
children: [
|
|
1612
|
-
|
|
1613
|
-
|
|
1624
|
+
t ? /* @__PURE__ */ a(
|
|
1625
|
+
Jn,
|
|
1614
1626
|
{
|
|
1615
|
-
value:
|
|
1616
|
-
onClick: () =>
|
|
1627
|
+
value: H(),
|
|
1628
|
+
onClick: () => V(!0),
|
|
1617
1629
|
onChange: () => {
|
|
1618
1630
|
},
|
|
1619
|
-
placeholder:
|
|
1620
|
-
disabled:
|
|
1621
|
-
size:
|
|
1622
|
-
variant:
|
|
1623
|
-
status:
|
|
1631
|
+
placeholder: u,
|
|
1632
|
+
disabled: o,
|
|
1633
|
+
size: h,
|
|
1634
|
+
variant: s,
|
|
1635
|
+
status: f,
|
|
1624
1636
|
inputMode: "none",
|
|
1625
|
-
clearable:
|
|
1626
|
-
onClear: () =>
|
|
1637
|
+
clearable: y,
|
|
1638
|
+
onClear: () => e(void 0)
|
|
1627
1639
|
}
|
|
1628
1640
|
) : null,
|
|
1629
|
-
|
|
1641
|
+
B ? /* @__PURE__ */ z(
|
|
1630
1642
|
"div",
|
|
1631
1643
|
{
|
|
1632
|
-
className: `sa-calendar sa-calendar-size-${
|
|
1633
|
-
style:
|
|
1634
|
-
ref:
|
|
1644
|
+
className: `sa-calendar sa-calendar-size-${h || "sm"} ${t ? "" : "sa-calendar-no-input"} ${D ? "" : "sa-calendar-no-padding"}`,
|
|
1645
|
+
style: o ? { pointerEvents: "none" } : void 0,
|
|
1646
|
+
ref: L,
|
|
1635
1647
|
children: [
|
|
1636
1648
|
/* @__PURE__ */ a(
|
|
1637
|
-
|
|
1649
|
+
Zn,
|
|
1638
1650
|
{
|
|
1639
|
-
setViews:
|
|
1651
|
+
setViews: T,
|
|
1640
1652
|
views: F,
|
|
1641
|
-
filter:
|
|
1642
|
-
previewDate:
|
|
1643
|
-
setPreviewDate:
|
|
1644
|
-
isComponentVisible:
|
|
1653
|
+
filter: r,
|
|
1654
|
+
previewDate: x,
|
|
1655
|
+
setPreviewDate: I,
|
|
1656
|
+
isComponentVisible: B
|
|
1645
1657
|
}
|
|
1646
1658
|
),
|
|
1647
1659
|
/* @__PURE__ */ a("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ a(
|
|
1648
|
-
|
|
1660
|
+
qn,
|
|
1649
1661
|
{
|
|
1650
|
-
date:
|
|
1651
|
-
setDate:
|
|
1652
|
-
previewDate:
|
|
1653
|
-
setPreviewDate:
|
|
1654
|
-
setIsComponentVisible:
|
|
1655
|
-
input:
|
|
1656
|
-
minDate:
|
|
1657
|
-
maxDate:
|
|
1658
|
-
onChange:
|
|
1659
|
-
hasValue:
|
|
1662
|
+
date: b,
|
|
1663
|
+
setDate: $,
|
|
1664
|
+
previewDate: x,
|
|
1665
|
+
setPreviewDate: I,
|
|
1666
|
+
setIsComponentVisible: V,
|
|
1667
|
+
input: t,
|
|
1668
|
+
minDate: d,
|
|
1669
|
+
maxDate: l,
|
|
1670
|
+
onChange: e,
|
|
1671
|
+
hasValue: n != null
|
|
1660
1672
|
}
|
|
1661
1673
|
) : F === "months" ? /* @__PURE__ */ a(
|
|
1662
|
-
|
|
1674
|
+
Gn,
|
|
1663
1675
|
{
|
|
1664
|
-
date:
|
|
1665
|
-
setDate:
|
|
1666
|
-
previewDate:
|
|
1667
|
-
setPreviewDate:
|
|
1668
|
-
filter:
|
|
1669
|
-
setViews:
|
|
1670
|
-
onChange:
|
|
1671
|
-
minDate:
|
|
1672
|
-
maxDate:
|
|
1673
|
-
input:
|
|
1674
|
-
hasValue:
|
|
1676
|
+
date: b,
|
|
1677
|
+
setDate: $,
|
|
1678
|
+
previewDate: x,
|
|
1679
|
+
setPreviewDate: I,
|
|
1680
|
+
filter: r,
|
|
1681
|
+
setViews: T,
|
|
1682
|
+
onChange: e,
|
|
1683
|
+
minDate: d,
|
|
1684
|
+
maxDate: l,
|
|
1685
|
+
input: t,
|
|
1686
|
+
hasValue: n != null
|
|
1675
1687
|
}
|
|
1676
1688
|
) : /* @__PURE__ */ a(
|
|
1677
|
-
|
|
1689
|
+
Un,
|
|
1678
1690
|
{
|
|
1679
|
-
date:
|
|
1680
|
-
setDate:
|
|
1681
|
-
previewDate:
|
|
1682
|
-
setPreviewDate:
|
|
1683
|
-
filter:
|
|
1684
|
-
setViews:
|
|
1685
|
-
onChange:
|
|
1686
|
-
minDate:
|
|
1687
|
-
maxDate:
|
|
1688
|
-
input:
|
|
1689
|
-
hasValue:
|
|
1691
|
+
date: b,
|
|
1692
|
+
setDate: $,
|
|
1693
|
+
previewDate: x,
|
|
1694
|
+
setPreviewDate: I,
|
|
1695
|
+
filter: r,
|
|
1696
|
+
setViews: T,
|
|
1697
|
+
onChange: e,
|
|
1698
|
+
minDate: d,
|
|
1699
|
+
maxDate: l,
|
|
1700
|
+
input: t,
|
|
1701
|
+
hasValue: n != null
|
|
1690
1702
|
}
|
|
1691
1703
|
) })
|
|
1692
1704
|
]
|
|
@@ -1696,71 +1708,517 @@ const Dn = K(
|
|
|
1696
1708
|
}
|
|
1697
1709
|
);
|
|
1698
1710
|
return /* @__PURE__ */ a(
|
|
1699
|
-
|
|
1711
|
+
pn,
|
|
1700
1712
|
{
|
|
1701
|
-
label:
|
|
1702
|
-
labelPosition:
|
|
1703
|
-
required:
|
|
1704
|
-
optional:
|
|
1705
|
-
description:
|
|
1706
|
-
helperText:
|
|
1707
|
-
errorText:
|
|
1713
|
+
label: E,
|
|
1714
|
+
labelPosition: v,
|
|
1715
|
+
required: m,
|
|
1716
|
+
optional: i,
|
|
1717
|
+
description: C,
|
|
1718
|
+
helperText: S,
|
|
1719
|
+
errorText: g,
|
|
1708
1720
|
fullWidth: M,
|
|
1709
|
-
|
|
1721
|
+
size: h,
|
|
1722
|
+
children: _
|
|
1710
1723
|
}
|
|
1711
1724
|
);
|
|
1712
1725
|
}
|
|
1713
|
-
),
|
|
1726
|
+
), le = tn(
|
|
1714
1727
|
({
|
|
1715
|
-
value:
|
|
1716
|
-
onChange:
|
|
1717
|
-
filter:
|
|
1718
|
-
input:
|
|
1719
|
-
rangedDate:
|
|
1720
|
-
disabled:
|
|
1721
|
-
minDate:
|
|
1722
|
-
maxDate:
|
|
1723
|
-
placeholder:
|
|
1724
|
-
size:
|
|
1725
|
-
variant:
|
|
1726
|
-
status:
|
|
1728
|
+
value: n,
|
|
1729
|
+
onChange: e,
|
|
1730
|
+
filter: r,
|
|
1731
|
+
input: t = !0,
|
|
1732
|
+
rangedDate: o,
|
|
1733
|
+
disabled: d,
|
|
1734
|
+
minDate: l,
|
|
1735
|
+
maxDate: u,
|
|
1736
|
+
placeholder: h,
|
|
1737
|
+
size: s,
|
|
1738
|
+
variant: c,
|
|
1739
|
+
status: y,
|
|
1727
1740
|
clearable: M,
|
|
1728
|
-
fullWidth:
|
|
1729
|
-
withPadding:
|
|
1730
|
-
label:
|
|
1731
|
-
labelPosition:
|
|
1732
|
-
required:
|
|
1733
|
-
optional:
|
|
1734
|
-
description:
|
|
1735
|
-
helperText:
|
|
1736
|
-
errorText:
|
|
1737
|
-
},
|
|
1738
|
-
const
|
|
1739
|
-
onChange:
|
|
1740
|
-
value:
|
|
1741
|
-
input:
|
|
1742
|
-
filter:
|
|
1743
|
-
disabled:
|
|
1744
|
-
minDate:
|
|
1745
|
-
maxDate:
|
|
1746
|
-
placeholder:
|
|
1747
|
-
size:
|
|
1748
|
-
variant:
|
|
1749
|
-
status:
|
|
1741
|
+
fullWidth: D,
|
|
1742
|
+
withPadding: E,
|
|
1743
|
+
label: v,
|
|
1744
|
+
labelPosition: m,
|
|
1745
|
+
required: i,
|
|
1746
|
+
optional: C,
|
|
1747
|
+
description: S,
|
|
1748
|
+
helperText: g,
|
|
1749
|
+
errorText: k
|
|
1750
|
+
}, f) => {
|
|
1751
|
+
const w = {
|
|
1752
|
+
onChange: e,
|
|
1753
|
+
value: n,
|
|
1754
|
+
input: t,
|
|
1755
|
+
filter: r,
|
|
1756
|
+
disabled: d,
|
|
1757
|
+
minDate: l,
|
|
1758
|
+
maxDate: u,
|
|
1759
|
+
placeholder: h,
|
|
1760
|
+
size: s,
|
|
1761
|
+
variant: c,
|
|
1762
|
+
status: y,
|
|
1750
1763
|
clearable: M,
|
|
1751
|
-
fullWidth:
|
|
1752
|
-
withPadding:
|
|
1753
|
-
label:
|
|
1754
|
-
labelPosition:
|
|
1755
|
-
required:
|
|
1756
|
-
optional:
|
|
1757
|
-
description:
|
|
1758
|
-
helperText:
|
|
1759
|
-
errorText:
|
|
1764
|
+
fullWidth: D,
|
|
1765
|
+
withPadding: E,
|
|
1766
|
+
label: v,
|
|
1767
|
+
labelPosition: m,
|
|
1768
|
+
required: i,
|
|
1769
|
+
optional: C,
|
|
1770
|
+
description: S,
|
|
1771
|
+
helperText: g,
|
|
1772
|
+
errorText: k
|
|
1760
1773
|
};
|
|
1761
|
-
return /* @__PURE__ */ a(
|
|
1774
|
+
return /* @__PURE__ */ a(rn, { children: o ? /* @__PURE__ */ a(Wn, { ...w, ref: f }) : /* @__PURE__ */ a(_n, { ...w, ref: f }) });
|
|
1775
|
+
}
|
|
1776
|
+
), Qn = `/* StarasiaTime — popover columns. Reuses --sa-date-* tokens (defined in
|
|
1777
|
+
date.module.css, injected alongside this sheet) and the .sa-calendar /
|
|
1778
|
+
.sa-calendar-input-* shells for the box + masked input. */
|
|
1779
|
+
|
|
1780
|
+
.sa-time-columns {
|
|
1781
|
+
display: flex;
|
|
1782
|
+
align-items: stretch;
|
|
1783
|
+
gap: var(--sa-spacing-xs, 4px);
|
|
1784
|
+
width: max-content;
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
.sa-time-col {
|
|
1788
|
+
display: flex;
|
|
1789
|
+
flex-direction: column;
|
|
1790
|
+
min-width: 56px;
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
.sa-time-col-head {
|
|
1794
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
1795
|
+
font-weight: 500;
|
|
1796
|
+
color: var(--sa-date-text-subtle);
|
|
1797
|
+
text-align: center;
|
|
1798
|
+
padding-block: var(--sa-spacing-xs, 4px);
|
|
1799
|
+
position: sticky;
|
|
1800
|
+
top: 0;
|
|
1801
|
+
background: var(--sa-date-bg);
|
|
1802
|
+
z-index: 1;
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
.sa-time-col-list {
|
|
1806
|
+
display: flex;
|
|
1807
|
+
flex-direction: column;
|
|
1808
|
+
gap: 2px;
|
|
1809
|
+
max-height: 220px;
|
|
1810
|
+
overflow-y: auto;
|
|
1811
|
+
padding-right: 4px;
|
|
1812
|
+
scrollbar-width: thin;
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
.sa-time-col-list::-webkit-scrollbar {
|
|
1816
|
+
width: 6px;
|
|
1817
|
+
}
|
|
1818
|
+
.sa-time-col-list::-webkit-scrollbar-thumb {
|
|
1819
|
+
background: var(--sa-date-border-color);
|
|
1820
|
+
border-radius: 999px;
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
.sa-time-opt {
|
|
1824
|
+
appearance: none;
|
|
1825
|
+
border: none;
|
|
1826
|
+
outline: none;
|
|
1827
|
+
cursor: pointer;
|
|
1828
|
+
font-family: inherit;
|
|
1829
|
+
font-size: var(--sa-font-size-md, 14px);
|
|
1830
|
+
font-weight: 500;
|
|
1831
|
+
color: var(--sa-date-text-primary);
|
|
1832
|
+
background: transparent;
|
|
1833
|
+
border-radius: var(--sa-date-radius);
|
|
1834
|
+
padding: var(--sa-spacing-xs, 4px) var(--sa-spacing-sm, 8px);
|
|
1835
|
+
text-align: center;
|
|
1836
|
+
transition: background-color 0.12s ease, color 0.12s ease;
|
|
1837
|
+
white-space: nowrap;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
.sa-time-opt:hover:not(:disabled):not(.sa-time-opt-active) {
|
|
1841
|
+
background: var(--sa-date-brand-subtle);
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
.sa-time-opt-active {
|
|
1845
|
+
background: var(--sa-date-brand);
|
|
1846
|
+
color: #ffffff;
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
.sa-time-opt:disabled {
|
|
1850
|
+
color: var(--sa-date-text-muted);
|
|
1851
|
+
cursor: not-allowed;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
.sa-time-opt:focus-visible {
|
|
1855
|
+
outline: 2px solid var(--sa-date-brand);
|
|
1856
|
+
outline-offset: 1px;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
.sa-time-divider {
|
|
1860
|
+
width: 1px;
|
|
1861
|
+
align-self: stretch;
|
|
1862
|
+
background: var(--sa-date-border-subtle);
|
|
1863
|
+
margin-inline: 2px;
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
.sa-time-footer {
|
|
1867
|
+
display: flex;
|
|
1868
|
+
align-items: center;
|
|
1869
|
+
justify-content: space-between;
|
|
1870
|
+
gap: var(--sa-spacing-sm, 8px);
|
|
1871
|
+
border-top: 1px solid var(--sa-date-border-subtle);
|
|
1872
|
+
padding-top: var(--sa-spacing-sm, 8px);
|
|
1873
|
+
margin-top: 2px;
|
|
1874
|
+
}
|
|
1875
|
+
|
|
1876
|
+
.sa-time-footer-btn {
|
|
1877
|
+
appearance: none;
|
|
1878
|
+
border: none;
|
|
1879
|
+
background: transparent;
|
|
1880
|
+
cursor: pointer;
|
|
1881
|
+
font-family: inherit;
|
|
1882
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
1883
|
+
font-weight: 500;
|
|
1884
|
+
color: var(--sa-date-brand);
|
|
1885
|
+
border-radius: var(--sa-date-radius);
|
|
1886
|
+
padding: var(--sa-spacing-xs, 4px) var(--sa-spacing-sm, 8px);
|
|
1887
|
+
transition: background-color 0.12s ease;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
.sa-time-footer-btn:hover {
|
|
1891
|
+
background: var(--sa-date-brand-subtle);
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
.sa-time-footer-btn-muted {
|
|
1895
|
+
color: var(--sa-date-text-subtle);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
.sa-time-footer-btn:focus-visible {
|
|
1899
|
+
outline: 2px solid var(--sa-date-brand);
|
|
1900
|
+
outline-offset: 1px;
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
/* Clock glyph in the input left slot inherits sizing from the date input. */
|
|
1904
|
+
.sa-time-input-wrap {
|
|
1905
|
+
width: 100%;
|
|
1906
|
+
}
|
|
1907
|
+
`, on = (n, e, r) => Math.min(r, Math.max(e, n)), R = (n) => String(n).padStart(2, "0"), ln = (n) => {
|
|
1908
|
+
if (!n)
|
|
1909
|
+
return null;
|
|
1910
|
+
const e = /^(\d{1,2}):(\d{2})(?::(\d{2}))?$/.exec(n.trim());
|
|
1911
|
+
if (!e)
|
|
1912
|
+
return null;
|
|
1913
|
+
const r = Number(e[1]), t = Number(e[2]), o = e[3] != null ? Number(e[3]) : 0;
|
|
1914
|
+
return r > 23 || t > 59 || o > 59 ? null : { h: r, m: t, s: o };
|
|
1915
|
+
}, Xn = (n, e) => e ? `${R(n.h)}:${R(n.m)}:${R(n.s)}` : `${R(n.h)}:${R(n.m)}`, W = (n) => n.h * 60 + n.m, ne = (n, e, r) => {
|
|
1916
|
+
const t = r ? `:${R(n.s)}` : "";
|
|
1917
|
+
if (e === "12h") {
|
|
1918
|
+
const o = n.h >= 12 ? "PM" : "AM", d = n.h % 12 === 0 ? 12 : n.h % 12;
|
|
1919
|
+
return `${R(d)}:${R(n.m)}${t} ${o}`;
|
|
1920
|
+
}
|
|
1921
|
+
return `${R(n.h)}:${R(n.m)}${t}`;
|
|
1922
|
+
}, ee = (n, e, r) => {
|
|
1923
|
+
const t = n.toLowerCase(), o = /p/.test(t) ? "pm" : /a/.test(t) ? "am" : null, d = t.replace(/[^\d]/g, "");
|
|
1924
|
+
if (!d)
|
|
1925
|
+
return null;
|
|
1926
|
+
let l = 0, u = 0, h = 0;
|
|
1927
|
+
if (n.includes(":")) {
|
|
1928
|
+
const s = n.split(":").map((c) => c.replace(/[^\d]/g, ""));
|
|
1929
|
+
l = Number(s[0] || 0), u = Number(s[1] || 0), h = r ? Number(s[2] || 0) : 0;
|
|
1930
|
+
} else
|
|
1931
|
+
d.length <= 2 ? l = Number(d) : d.length <= 4 ? (l = Number(d.slice(0, d.length - 2)), u = Number(d.slice(-2))) : (l = Number(d.slice(0, d.length - 4)), u = Number(d.slice(-4, -2)), h = r ? Number(d.slice(-2)) : 0);
|
|
1932
|
+
return o && (o === "pm" && l < 12 && (l += 12), o === "am" && l === 12 && (l = 0)), l > 23 || u > 59 || h > 59 ? null : { h: on(l, 0, 23), m: on(u, 0, 59), s: on(h, 0, 59) };
|
|
1933
|
+
}, en = (n, e = 1) => {
|
|
1934
|
+
const r = [];
|
|
1935
|
+
for (let t = 0; t < n; t += e)
|
|
1936
|
+
r.push(t);
|
|
1937
|
+
return r;
|
|
1938
|
+
}, kn = (n, e) => {
|
|
1939
|
+
if (typeof document > "u" || document.getElementById(n))
|
|
1940
|
+
return;
|
|
1941
|
+
const r = document.createElement("style");
|
|
1942
|
+
r.id = n, r.textContent = e, document.head.appendChild(r);
|
|
1943
|
+
};
|
|
1944
|
+
kn("sa-calendar-styles", X);
|
|
1945
|
+
kn("sa-time-styles", Qn);
|
|
1946
|
+
const ae = (n) => n === "xs" ? 14 : n === "lg" ? 20 : 16, vn = ({ s: n }) => /* @__PURE__ */ a("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ a(
|
|
1947
|
+
"path",
|
|
1948
|
+
{
|
|
1949
|
+
d: "M10 5v5l3 2M17.5 10a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Z",
|
|
1950
|
+
stroke: "var(--sa-color-gray-500, #8c8f97)",
|
|
1951
|
+
strokeWidth: "1.5",
|
|
1952
|
+
strokeLinecap: "round",
|
|
1953
|
+
strokeLinejoin: "round"
|
|
1954
|
+
}
|
|
1955
|
+
) }), re = ({ s: n }) => /* @__PURE__ */ a("svg", { width: n, height: n, viewBox: "0 0 20 20", fill: "none", children: /* @__PURE__ */ a(
|
|
1956
|
+
"path",
|
|
1957
|
+
{
|
|
1958
|
+
d: "M5 5l10 10M15 5L5 15",
|
|
1959
|
+
stroke: "var(--sa-color-gray-500, #8c8f97)",
|
|
1960
|
+
strokeWidth: "1.5",
|
|
1961
|
+
strokeLinecap: "round"
|
|
1962
|
+
}
|
|
1963
|
+
) }), an = ({ label: n, options: e, active: r, onPick: t }) => {
|
|
1964
|
+
const o = J(null), d = J(null);
|
|
1965
|
+
return A(() => {
|
|
1966
|
+
var l;
|
|
1967
|
+
(l = d.current) == null || l.scrollIntoView({ block: "nearest" });
|
|
1968
|
+
}, [r]), /* @__PURE__ */ z("div", { className: "sa-time-col", children: [
|
|
1969
|
+
/* @__PURE__ */ a("div", { className: "sa-time-col-head", children: n }),
|
|
1970
|
+
/* @__PURE__ */ a("div", { className: "sa-time-col-list", ref: o, children: e.map((l) => {
|
|
1971
|
+
const u = l.value === r;
|
|
1972
|
+
return /* @__PURE__ */ a(
|
|
1973
|
+
"button",
|
|
1974
|
+
{
|
|
1975
|
+
type: "button",
|
|
1976
|
+
ref: u ? d : null,
|
|
1977
|
+
disabled: l.disabled,
|
|
1978
|
+
className: `sa-time-opt${u ? " sa-time-opt-active" : ""}`,
|
|
1979
|
+
onClick: () => t(l.value),
|
|
1980
|
+
children: l.label
|
|
1981
|
+
},
|
|
1982
|
+
l.value
|
|
1983
|
+
);
|
|
1984
|
+
}) })
|
|
1985
|
+
] });
|
|
1986
|
+
}, te = tn(
|
|
1987
|
+
({
|
|
1988
|
+
value: n,
|
|
1989
|
+
onChange: e,
|
|
1990
|
+
format: r = "24h",
|
|
1991
|
+
withSeconds: t = !1,
|
|
1992
|
+
step: o = 1,
|
|
1993
|
+
minTime: d,
|
|
1994
|
+
maxTime: l,
|
|
1995
|
+
input: u = !0,
|
|
1996
|
+
placeholder: h = "--:--",
|
|
1997
|
+
disabled: s,
|
|
1998
|
+
clearable: c,
|
|
1999
|
+
size: y = "sm",
|
|
2000
|
+
variant: M = "outline",
|
|
2001
|
+
status: D,
|
|
2002
|
+
fullWidth: E = !0,
|
|
2003
|
+
withPadding: v = !0,
|
|
2004
|
+
label: m,
|
|
2005
|
+
labelPosition: i,
|
|
2006
|
+
required: C,
|
|
2007
|
+
optional: S,
|
|
2008
|
+
description: g,
|
|
2009
|
+
helperText: k,
|
|
2010
|
+
errorText: f
|
|
2011
|
+
}, w) => {
|
|
2012
|
+
const B = f ? "error" : D, { ref: V, isComponentVisible: L, setIsComponentVisible: F } = un(!1), T = J(null), b = G(() => ln(n), [n]), $ = G(() => ln(d), [d]), x = G(() => ln(l), [l]), [I, H] = O(null);
|
|
2013
|
+
A(() => {
|
|
2014
|
+
u || F(!0);
|
|
2015
|
+
}, [u]);
|
|
2016
|
+
const P = () => {
|
|
2017
|
+
if (!T.current || !V.current || !u)
|
|
2018
|
+
return;
|
|
2019
|
+
const p = V.current.getBoundingClientRect(), Y = T.current.getBoundingClientRect();
|
|
2020
|
+
T.current.style.left = window.innerWidth < p.left + Y.width ? `${p.left - Y.width + p.width}px` : `${p.left}px`, T.current.style.top = p.top + Y.height > window.innerHeight ? `${p.y - (p.height + Y.height - 28)}px` : `${p.y + p.height}px`;
|
|
2021
|
+
};
|
|
2022
|
+
A(() => {
|
|
2023
|
+
P();
|
|
2024
|
+
}, [L]), A(() => (window.addEventListener("scroll", P, !0), window.addEventListener("resize", P), () => {
|
|
2025
|
+
window.removeEventListener("scroll", P, !0), window.removeEventListener("resize", P);
|
|
2026
|
+
}), []);
|
|
2027
|
+
const _ = (p) => {
|
|
2028
|
+
const Y = W(p);
|
|
2029
|
+
return !($ && Y < W($) || x && Y > W(x));
|
|
2030
|
+
}, N = (p) => {
|
|
2031
|
+
e(Xn(p, t)), H(null);
|
|
2032
|
+
}, j = (p) => {
|
|
2033
|
+
N({ ...b ?? { h: 0, m: 0, s: 0 }, ...p });
|
|
2034
|
+
}, hn = () => {
|
|
2035
|
+
if (I == null)
|
|
2036
|
+
return;
|
|
2037
|
+
if (I.trim() === "") {
|
|
2038
|
+
e(null), H(null);
|
|
2039
|
+
return;
|
|
2040
|
+
}
|
|
2041
|
+
const p = ee(I, r, t);
|
|
2042
|
+
p && _(p) ? N(p) : H(null);
|
|
2043
|
+
}, Nn = b ? ne(b, r, t) : "", Mn = I ?? Nn, Cn = c && !!b && !s, nn = b && b.h >= 12 ? "PM" : "AM", $n = G(() => r === "12h" ? en(12).map((p) => {
|
|
2044
|
+
const Y = p === 0 ? 12 : p, Q = nn === "PM" ? Y % 12 + 12 : Y % 12;
|
|
2045
|
+
return {
|
|
2046
|
+
value: Y,
|
|
2047
|
+
label: R(Y),
|
|
2048
|
+
disabled: $ && Q * 60 + 59 < W($) || x && Q * 60 > W(x) || !1
|
|
2049
|
+
};
|
|
2050
|
+
}) : en(24).map((p) => ({
|
|
2051
|
+
value: p,
|
|
2052
|
+
label: R(p),
|
|
2053
|
+
disabled: $ && p * 60 + 59 < W($) || x && p * 60 > W(x) || !1
|
|
2054
|
+
})), [r, nn, $, x]), zn = G(() => {
|
|
2055
|
+
const p = (b == null ? void 0 : b.h) ?? 0;
|
|
2056
|
+
return en(60, o).map((Y) => ({
|
|
2057
|
+
value: Y,
|
|
2058
|
+
label: R(Y),
|
|
2059
|
+
disabled: $ && p * 60 + Y < W($) || x && p * 60 + Y > W(x) || !1
|
|
2060
|
+
}));
|
|
2061
|
+
}, [o, b == null ? void 0 : b.h, $, x]), Dn = G(
|
|
2062
|
+
() => en(60).map((p) => ({ value: p, label: R(p) })),
|
|
2063
|
+
[]
|
|
2064
|
+
), Yn = b == null ? null : r === "12h" ? b.h % 12 === 0 ? 12 : b.h % 12 : b.h, Ln = (p) => {
|
|
2065
|
+
if (r === "12h") {
|
|
2066
|
+
const Y = nn === "PM" ? p % 12 + 12 : p % 12;
|
|
2067
|
+
j({ h: Y });
|
|
2068
|
+
} else
|
|
2069
|
+
j({ h: p });
|
|
2070
|
+
}, Fn = (p) => {
|
|
2071
|
+
const Y = b ?? { h: 0, m: 0, s: 0 }, Q = Y.h % 12 === 0 ? 12 : Y.h % 12, In = p === "PM" ? Q % 12 + 12 : Q % 12;
|
|
2072
|
+
N({ ...Y, h: In });
|
|
2073
|
+
}, En = () => {
|
|
2074
|
+
const p = /* @__PURE__ */ new Date(), Y = Math.floor(p.getMinutes() / o) * o;
|
|
2075
|
+
N({ h: p.getHours(), m: Y, s: t ? p.getSeconds() : 0 });
|
|
2076
|
+
}, sn = ae(y), Sn = /* @__PURE__ */ z(
|
|
2077
|
+
"div",
|
|
2078
|
+
{
|
|
2079
|
+
className: "sa-calendar-wrapper",
|
|
2080
|
+
style: { height: u ? "auto" : "100%" },
|
|
2081
|
+
ref: u ? V : null,
|
|
2082
|
+
children: [
|
|
2083
|
+
u ? /* @__PURE__ */ z(
|
|
2084
|
+
"div",
|
|
2085
|
+
{
|
|
2086
|
+
className: `sa-calendar-input-container sa-calendar-input-${M} sa-calendar-input-container-${B || "default"} ${y}`,
|
|
2087
|
+
onClick: () => !s && F(!0),
|
|
2088
|
+
children: [
|
|
2089
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(vn, { s: sn }) }),
|
|
2090
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
|
|
2091
|
+
"input",
|
|
2092
|
+
{
|
|
2093
|
+
className: "sa-calendar-input",
|
|
2094
|
+
value: Mn,
|
|
2095
|
+
placeholder: h,
|
|
2096
|
+
disabled: s,
|
|
2097
|
+
onChange: (p) => H(p.target.value),
|
|
2098
|
+
onFocus: () => F(!0),
|
|
2099
|
+
onBlur: hn,
|
|
2100
|
+
onKeyDown: (p) => {
|
|
2101
|
+
p.key === "Enter" && (hn(), F(!1)), p.key === "Escape" && (H(null), F(!1));
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
) }),
|
|
2105
|
+
Cn ? /* @__PURE__ */ a(
|
|
2106
|
+
"button",
|
|
2107
|
+
{
|
|
2108
|
+
type: "button",
|
|
2109
|
+
"aria-label": "Clear time",
|
|
2110
|
+
className: "sa-calendar-input-clear",
|
|
2111
|
+
onClick: (p) => {
|
|
2112
|
+
p.stopPropagation(), e(null), H(null);
|
|
2113
|
+
},
|
|
2114
|
+
children: /* @__PURE__ */ a(re, { s: sn })
|
|
2115
|
+
}
|
|
2116
|
+
) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(vn, { s: sn }) })
|
|
2117
|
+
]
|
|
2118
|
+
}
|
|
2119
|
+
) : null,
|
|
2120
|
+
L ? /* @__PURE__ */ z(
|
|
2121
|
+
"div",
|
|
2122
|
+
{
|
|
2123
|
+
ref: T,
|
|
2124
|
+
className: `sa-calendar sa-calendar-size-${y} ${u ? "" : "sa-calendar-no-input"} ${v ? "" : "sa-calendar-no-padding"}`,
|
|
2125
|
+
style: s ? { pointerEvents: "none" } : void 0,
|
|
2126
|
+
children: [
|
|
2127
|
+
/* @__PURE__ */ z("div", { className: "sa-time-columns", children: [
|
|
2128
|
+
/* @__PURE__ */ a(
|
|
2129
|
+
an,
|
|
2130
|
+
{
|
|
2131
|
+
label: "Jam",
|
|
2132
|
+
options: $n,
|
|
2133
|
+
active: Yn,
|
|
2134
|
+
onPick: Ln
|
|
2135
|
+
}
|
|
2136
|
+
),
|
|
2137
|
+
/* @__PURE__ */ a("div", { className: "sa-time-divider" }),
|
|
2138
|
+
/* @__PURE__ */ a(
|
|
2139
|
+
an,
|
|
2140
|
+
{
|
|
2141
|
+
label: "Menit",
|
|
2142
|
+
options: zn,
|
|
2143
|
+
active: (b == null ? void 0 : b.m) ?? null,
|
|
2144
|
+
onPick: (p) => j({ m: p })
|
|
2145
|
+
}
|
|
2146
|
+
),
|
|
2147
|
+
t && /* @__PURE__ */ z(rn, { children: [
|
|
2148
|
+
/* @__PURE__ */ a("div", { className: "sa-time-divider" }),
|
|
2149
|
+
/* @__PURE__ */ a(
|
|
2150
|
+
an,
|
|
2151
|
+
{
|
|
2152
|
+
label: "Detik",
|
|
2153
|
+
options: Dn,
|
|
2154
|
+
active: (b == null ? void 0 : b.s) ?? null,
|
|
2155
|
+
onPick: (p) => j({ s: p })
|
|
2156
|
+
}
|
|
2157
|
+
)
|
|
2158
|
+
] }),
|
|
2159
|
+
r === "12h" && /* @__PURE__ */ z(rn, { children: [
|
|
2160
|
+
/* @__PURE__ */ a("div", { className: "sa-time-divider" }),
|
|
2161
|
+
/* @__PURE__ */ a(
|
|
2162
|
+
an,
|
|
2163
|
+
{
|
|
2164
|
+
label: "",
|
|
2165
|
+
options: [
|
|
2166
|
+
{ value: 0, label: "AM" },
|
|
2167
|
+
{ value: 1, label: "PM" }
|
|
2168
|
+
],
|
|
2169
|
+
active: b == null ? null : nn === "PM" ? 1 : 0,
|
|
2170
|
+
onPick: (p) => Fn(p === 1 ? "PM" : "AM")
|
|
2171
|
+
}
|
|
2172
|
+
)
|
|
2173
|
+
] })
|
|
2174
|
+
] }),
|
|
2175
|
+
/* @__PURE__ */ z("div", { className: "sa-time-footer", children: [
|
|
2176
|
+
/* @__PURE__ */ a(
|
|
2177
|
+
"button",
|
|
2178
|
+
{
|
|
2179
|
+
type: "button",
|
|
2180
|
+
className: "sa-time-footer-btn",
|
|
2181
|
+
onClick: En,
|
|
2182
|
+
children: "Sekarang"
|
|
2183
|
+
}
|
|
2184
|
+
),
|
|
2185
|
+
/* @__PURE__ */ a(
|
|
2186
|
+
"button",
|
|
2187
|
+
{
|
|
2188
|
+
type: "button",
|
|
2189
|
+
className: "sa-time-footer-btn sa-time-footer-btn-muted",
|
|
2190
|
+
onClick: () => {
|
|
2191
|
+
e(null), H(null);
|
|
2192
|
+
},
|
|
2193
|
+
children: "Hapus"
|
|
2194
|
+
}
|
|
2195
|
+
)
|
|
2196
|
+
] })
|
|
2197
|
+
]
|
|
2198
|
+
}
|
|
2199
|
+
) : null
|
|
2200
|
+
]
|
|
2201
|
+
}
|
|
2202
|
+
);
|
|
2203
|
+
return /* @__PURE__ */ a(
|
|
2204
|
+
pn,
|
|
2205
|
+
{
|
|
2206
|
+
label: m,
|
|
2207
|
+
labelPosition: i,
|
|
2208
|
+
required: C,
|
|
2209
|
+
optional: S,
|
|
2210
|
+
description: g,
|
|
2211
|
+
helperText: k,
|
|
2212
|
+
errorText: f,
|
|
2213
|
+
fullWidth: E,
|
|
2214
|
+
size: y,
|
|
2215
|
+
children: Sn
|
|
2216
|
+
}
|
|
2217
|
+
);
|
|
1762
2218
|
}
|
|
1763
2219
|
);
|
|
2220
|
+
te.displayName = "StarasiaTime";
|
|
1764
2221
|
export {
|
|
1765
|
-
|
|
2222
|
+
le as StarasiaDate,
|
|
2223
|
+
te as StarasiaTime
|
|
1766
2224
|
};
|