@starasia/date 5.0.2 → 5.0.3
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 +408 -392
- package/dist/date.umd.js +2 -2
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as z, useRef as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as F, jsx as r, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as z, useRef as P, useEffect as S, forwardRef as G } from "react";
|
|
3
|
+
const J = `@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;
|
|
@@ -358,7 +358,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
358
358
|
outline: 2px solid var(--sa-date-brand);
|
|
359
359
|
outline-offset: 1px;
|
|
360
360
|
}
|
|
361
|
-
`, ee = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
361
|
+
`, ee = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], W = [
|
|
362
362
|
"January",
|
|
363
363
|
"February",
|
|
364
364
|
"March",
|
|
@@ -386,10 +386,10 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
386
386
|
"Dec"
|
|
387
387
|
];
|
|
388
388
|
function ne(a) {
|
|
389
|
-
const [n, t] = z(a), s =
|
|
390
|
-
s.current && !s.current.contains(
|
|
389
|
+
const [n, t] = z(a), s = P(null), l = (h) => {
|
|
390
|
+
s.current && !s.current.contains(h.target) && t(!1);
|
|
391
391
|
};
|
|
392
|
-
return
|
|
392
|
+
return S(() => (document.addEventListener("click", l, !0), () => {
|
|
393
393
|
document.removeEventListener("click", l, !0);
|
|
394
394
|
}), []), { ref: s, isComponentVisible: n, setIsComponentVisible: t };
|
|
395
395
|
}
|
|
@@ -399,8 +399,8 @@ const K = "sa-calendar-input-styles", oe = (a) => {
|
|
|
399
399
|
n.id = K, n.textContent = a, document.head.appendChild(n);
|
|
400
400
|
}
|
|
401
401
|
};
|
|
402
|
-
oe(
|
|
403
|
-
const
|
|
402
|
+
oe(J);
|
|
403
|
+
const H = (a) => {
|
|
404
404
|
if (a === "sm")
|
|
405
405
|
return 16;
|
|
406
406
|
if (a === "md")
|
|
@@ -413,25 +413,25 @@ const W = (a) => {
|
|
|
413
413
|
status: t = "default",
|
|
414
414
|
variant: s = "outline",
|
|
415
415
|
clearable: l,
|
|
416
|
-
onClear:
|
|
417
|
-
...
|
|
418
|
-
} = a, g =
|
|
419
|
-
g.current &&
|
|
420
|
-
}, e = t === "disable" ||
|
|
421
|
-
|
|
416
|
+
onClear: h,
|
|
417
|
+
...i
|
|
418
|
+
} = a, g = P(null), f = () => {
|
|
419
|
+
g.current && i.onClick && (g.current.focus(), i.onClick(""));
|
|
420
|
+
}, e = t === "disable" || i.disabled, p = !!i.value, v = l && p && !e, x = (D) => {
|
|
421
|
+
D.stopPropagation(), h == null || h();
|
|
422
422
|
};
|
|
423
|
-
return /* @__PURE__ */
|
|
423
|
+
return /* @__PURE__ */ F(
|
|
424
424
|
"div",
|
|
425
425
|
{
|
|
426
426
|
className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${n} `,
|
|
427
|
-
onClick:
|
|
427
|
+
onClick: f,
|
|
428
428
|
children: [
|
|
429
429
|
/* @__PURE__ */ r("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ r(
|
|
430
430
|
"svg",
|
|
431
431
|
{
|
|
432
432
|
xmlns: "http://www.w3.org/2000/svg",
|
|
433
|
-
width:
|
|
434
|
-
height:
|
|
433
|
+
width: H(n),
|
|
434
|
+
height: H(n),
|
|
435
435
|
viewBox: "0 0 20 20",
|
|
436
436
|
fill: "none",
|
|
437
437
|
children: /* @__PURE__ */ r(
|
|
@@ -450,9 +450,9 @@ const W = (a) => {
|
|
|
450
450
|
"input",
|
|
451
451
|
{
|
|
452
452
|
className: "sa-calendar-input",
|
|
453
|
-
...
|
|
453
|
+
...i,
|
|
454
454
|
disabled: e,
|
|
455
|
-
value:
|
|
455
|
+
value: i.value,
|
|
456
456
|
ref: g
|
|
457
457
|
}
|
|
458
458
|
) }),
|
|
@@ -462,13 +462,13 @@ const W = (a) => {
|
|
|
462
462
|
type: "button",
|
|
463
463
|
"aria-label": "Clear date",
|
|
464
464
|
className: "sa-calendar-input-clear",
|
|
465
|
-
onClick:
|
|
465
|
+
onClick: x,
|
|
466
466
|
children: /* @__PURE__ */ r(
|
|
467
467
|
"svg",
|
|
468
468
|
{
|
|
469
469
|
xmlns: "http://www.w3.org/2000/svg",
|
|
470
|
-
width:
|
|
471
|
-
height:
|
|
470
|
+
width: H(n),
|
|
471
|
+
height: H(n),
|
|
472
472
|
viewBox: "0 0 20 20",
|
|
473
473
|
fill: "none",
|
|
474
474
|
children: /* @__PURE__ */ r(
|
|
@@ -488,8 +488,8 @@ const W = (a) => {
|
|
|
488
488
|
"svg",
|
|
489
489
|
{
|
|
490
490
|
xmlns: "http://www.w3.org/2000/svg",
|
|
491
|
-
width:
|
|
492
|
-
height:
|
|
491
|
+
width: H(n),
|
|
492
|
+
height: H(n),
|
|
493
493
|
viewBox: "0 0 20 20",
|
|
494
494
|
fill: "none",
|
|
495
495
|
children: /* @__PURE__ */ r(
|
|
@@ -513,109 +513,125 @@ const W = (a) => {
|
|
|
513
513
|
dateRange: t,
|
|
514
514
|
setDateRange: s,
|
|
515
515
|
onChange: l,
|
|
516
|
-
minDate:
|
|
517
|
-
maxDate:
|
|
516
|
+
minDate: h,
|
|
517
|
+
maxDate: i,
|
|
518
518
|
input: g
|
|
519
519
|
}) => {
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
520
|
+
var Y, u, y;
|
|
521
|
+
const [f, e] = z(null);
|
|
522
|
+
let p = new Date(a.getFullYear(), a.getMonth(), 1), v = p.getDay(), x = [];
|
|
523
|
+
const D = a.getMonth(), m = !!(t.from && !t.to), o = m && f ? f : null;
|
|
524
|
+
for (let d = 0; d < 42; d++) {
|
|
525
|
+
d === 0 && v === 0 ? p.setDate(p.getDate() - 7) : d === 0 ? p.setDate(
|
|
526
|
+
p.getDate() + (d - v)
|
|
527
|
+
) : p.setDate(p.getDate() + 1);
|
|
528
|
+
let w = {
|
|
529
|
+
currentMonth: p.getMonth() === D,
|
|
530
|
+
date: new Date(p),
|
|
531
|
+
month: p.getMonth(),
|
|
532
|
+
number: p.getDate(),
|
|
533
|
+
selected: p.toDateString() === ((Y = t.from) == null ? void 0 : Y.toDateString()) || p.toDateString() === (((u = t.to) == null ? void 0 : u.toDateString()) || ((y = t.from) == null ? void 0 : y.toDateString())),
|
|
534
|
+
year: p.getFullYear(),
|
|
535
|
+
isDisabled: h && p < h || i && p > i
|
|
535
536
|
};
|
|
536
|
-
|
|
537
|
+
x.push(w);
|
|
537
538
|
}
|
|
538
|
-
const
|
|
539
|
-
n(
|
|
540
|
-
},
|
|
541
|
-
var
|
|
542
|
-
let
|
|
543
|
-
if (
|
|
544
|
-
|
|
539
|
+
const c = (d) => {
|
|
540
|
+
n(d);
|
|
541
|
+
}, k = (d) => {
|
|
542
|
+
var N;
|
|
543
|
+
let w = { ...t };
|
|
544
|
+
if (w.from && w.to)
|
|
545
|
+
w = { from: d, to: null };
|
|
545
546
|
else {
|
|
546
|
-
const
|
|
547
|
-
|
|
547
|
+
const M = ((N = w.from) == null ? void 0 : N.getTime()) || 0;
|
|
548
|
+
d.getTime() > M ? w = { from: w.from, to: d } : w = { from: d, to: w.from };
|
|
548
549
|
}
|
|
549
|
-
s(
|
|
550
|
+
s(w), l(w);
|
|
550
551
|
};
|
|
551
|
-
return /* @__PURE__ */
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
"p",
|
|
558
|
-
{
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
552
|
+
return /* @__PURE__ */ F(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
className: "sa-calendar-days-preivew",
|
|
556
|
+
onMouseLeave: () => e(null),
|
|
557
|
+
children: [
|
|
558
|
+
/* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((d, w) => /* @__PURE__ */ r("p", { children: d }, w)) }),
|
|
559
|
+
/* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: x.map((d, w) => {
|
|
560
|
+
const N = t.from && t.to && d.date.getTime() > t.from.getTime() && d.date.getTime() < t.to.getTime(), M = (() => {
|
|
561
|
+
if (!o || !t.from)
|
|
562
|
+
return !1;
|
|
563
|
+
const C = d.date.getTime(), L = t.from.getTime(), j = o.getTime();
|
|
564
|
+
return j > L ? C > L && C < j : C < L && C > j;
|
|
565
|
+
})(), T = m && f && d.date.toDateString() === f.toDateString(), $ = d.isDisabled, E = () => N || M ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", I = () => $ ? "var(--sa-color-gray-400, #b7b9be)" : N || M ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
566
|
+
return /* @__PURE__ */ r(
|
|
567
|
+
"p",
|
|
568
|
+
{
|
|
569
|
+
className: `${d.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${d.selected || T ? "sa-calendar-days-active" : ""}`,
|
|
570
|
+
style: {
|
|
571
|
+
backgroundColor: E(),
|
|
572
|
+
pointerEvents: $ ? "none" : void 0,
|
|
573
|
+
cursor: $ ? "not-allowed" : "pointer",
|
|
574
|
+
color: I(),
|
|
575
|
+
opacity: T && !d.selected ? 0.75 : 1,
|
|
576
|
+
...g ? {} : { width: "100%" }
|
|
577
|
+
},
|
|
578
|
+
onClick: () => {
|
|
579
|
+
$ || (c(d.date), k(d.date));
|
|
580
|
+
},
|
|
581
|
+
onMouseEnter: () => {
|
|
582
|
+
$ || e(d.date);
|
|
583
|
+
},
|
|
584
|
+
children: d.number
|
|
585
|
+
},
|
|
586
|
+
w
|
|
587
|
+
);
|
|
588
|
+
}) })
|
|
589
|
+
]
|
|
590
|
+
}
|
|
591
|
+
);
|
|
576
592
|
}, de = ({
|
|
577
593
|
date: a,
|
|
578
594
|
setDate: n,
|
|
579
595
|
filter: t,
|
|
580
596
|
setViews: s,
|
|
581
597
|
dateRange: l,
|
|
582
|
-
setDateRange:
|
|
583
|
-
onChange:
|
|
598
|
+
setDateRange: h,
|
|
599
|
+
onChange: i,
|
|
584
600
|
minDate: g,
|
|
585
|
-
maxDate:
|
|
601
|
+
maxDate: f,
|
|
586
602
|
input: e
|
|
587
603
|
}) => {
|
|
588
|
-
const
|
|
589
|
-
t ? (
|
|
590
|
-
},
|
|
604
|
+
const p = l.from.getFullYear(), v = a.getFullYear(), x = (m) => {
|
|
605
|
+
t ? (D(m), n(m)) : (s("days"), n(m));
|
|
606
|
+
}, D = (m) => {
|
|
591
607
|
var c;
|
|
592
608
|
let o = { ...l };
|
|
593
609
|
if (o.from && o.to)
|
|
594
|
-
o = { from:
|
|
610
|
+
o = { from: m, to: null };
|
|
595
611
|
else {
|
|
596
|
-
const
|
|
597
|
-
|
|
612
|
+
const k = ((c = o.from) == null ? void 0 : c.getTime()) || 0;
|
|
613
|
+
m.getTime() > k ? o = { from: o.from, to: m } : o = { from: m, to: o.from };
|
|
598
614
|
}
|
|
599
|
-
|
|
615
|
+
h(o), i(o);
|
|
600
616
|
};
|
|
601
|
-
return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children:
|
|
602
|
-
var
|
|
603
|
-
const c = new Date(v, o).getTime() > l.from.getTime() && new Date(v, o).getTime() < (((
|
|
617
|
+
return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: W.map((m, o) => {
|
|
618
|
+
var Y, u, y;
|
|
619
|
+
const c = new Date(v, o).getTime() > l.from.getTime() && new Date(v, o).getTime() < (((Y = l.to) == null ? void 0 : Y.getTime()) || l.from.getTime()), k = g && new Date(v, o) < g || f && new Date(v, o) > f;
|
|
604
620
|
return /* @__PURE__ */ r(
|
|
605
621
|
"p",
|
|
606
622
|
{
|
|
607
|
-
className:
|
|
623
|
+
className: p === v && (o === ((u = l.from) == null ? void 0 : u.getMonth()) || o === ((y = l.to) == null ? void 0 : y.getMonth())) ? "sa-calendar-months-active" : "",
|
|
608
624
|
style: {
|
|
609
625
|
backgroundColor: c ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
610
|
-
pointerEvents:
|
|
611
|
-
cursor:
|
|
612
|
-
color:
|
|
626
|
+
pointerEvents: k ? "none" : void 0,
|
|
627
|
+
cursor: k ? "not-allowed" : "pointer",
|
|
628
|
+
color: k ? "var(--sa-color-gray-400, #b7b9be)" : c ? "var(--sa-color-gray-500, #8c8f97)" : "",
|
|
613
629
|
...e ? {} : { width: "100%" }
|
|
614
630
|
},
|
|
615
631
|
onClick: () => {
|
|
616
|
-
|
|
632
|
+
k || x(new Date(v, o));
|
|
617
633
|
},
|
|
618
|
-
children:
|
|
634
|
+
children: m.slice(0, 3)
|
|
619
635
|
},
|
|
620
636
|
o
|
|
621
637
|
);
|
|
@@ -629,54 +645,54 @@ const W = (a) => {
|
|
|
629
645
|
setViews: t,
|
|
630
646
|
setDate: s,
|
|
631
647
|
dateRange: l,
|
|
632
|
-
setDateRange:
|
|
633
|
-
onChange:
|
|
648
|
+
setDateRange: h,
|
|
649
|
+
onChange: i,
|
|
634
650
|
minDate: g,
|
|
635
|
-
maxDate:
|
|
651
|
+
maxDate: f,
|
|
636
652
|
input: e
|
|
637
653
|
}) => {
|
|
638
|
-
var
|
|
639
|
-
let
|
|
640
|
-
const v = a.getFullYear(), { start:
|
|
641
|
-
for (let
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
year:
|
|
645
|
-
active:
|
|
646
|
-
highlight:
|
|
647
|
-
disabled: !
|
|
654
|
+
var Y;
|
|
655
|
+
let p = [];
|
|
656
|
+
const v = a.getFullYear(), { start: x, end: D } = U(v), m = l.from.getFullYear(), o = (Y = l.to) == null ? void 0 : Y.getFullYear();
|
|
657
|
+
for (let u = x; u < D; u++) {
|
|
658
|
+
const y = new Date(u, 0), d = (!g || y >= g) && (!f || y <= f), w = u === m || u === o, N = y > l.from && y < l.to;
|
|
659
|
+
p.push({
|
|
660
|
+
year: u,
|
|
661
|
+
active: w && d,
|
|
662
|
+
highlight: N && d,
|
|
663
|
+
disabled: !d
|
|
648
664
|
});
|
|
649
665
|
}
|
|
650
|
-
const c = (
|
|
651
|
-
n ? (u
|
|
652
|
-
},
|
|
653
|
-
var
|
|
654
|
-
let
|
|
655
|
-
if (
|
|
656
|
-
|
|
666
|
+
const c = (u) => {
|
|
667
|
+
n ? (k(u), s(u)) : (s(u), t("months"));
|
|
668
|
+
}, k = (u) => {
|
|
669
|
+
var d;
|
|
670
|
+
let y = { ...l };
|
|
671
|
+
if (y.from && y.to)
|
|
672
|
+
y = { from: u, to: null };
|
|
657
673
|
else {
|
|
658
|
-
const
|
|
659
|
-
|
|
674
|
+
const w = ((d = y.from) == null ? void 0 : d.getTime()) || 0;
|
|
675
|
+
u.getTime() > w ? y = { from: y.from, to: u } : y = { from: u, to: y.from };
|
|
660
676
|
}
|
|
661
|
-
|
|
677
|
+
h(y), i(y);
|
|
662
678
|
};
|
|
663
|
-
return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children:
|
|
679
|
+
return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: p.map((u, y) => /* @__PURE__ */ r(
|
|
664
680
|
"p",
|
|
665
681
|
{
|
|
666
|
-
className: `${
|
|
682
|
+
className: `${u.active ? "sa-calendar-months-active" : ""} ${u.highlight ? "sa-calendar-months-highlight" : ""} ${u.disabled ? "sa-calendar-disabled" : ""}`,
|
|
667
683
|
onClick: () => {
|
|
668
|
-
|
|
684
|
+
u.disabled || c(new Date(u.year, 0));
|
|
669
685
|
},
|
|
670
686
|
style: {
|
|
671
|
-
backgroundColor:
|
|
672
|
-
color:
|
|
673
|
-
cursor:
|
|
674
|
-
pointerEvents:
|
|
687
|
+
backgroundColor: u.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
688
|
+
color: u.highlight ? "var(--sa-color-gray-500, #8c8f97)" : u.active ? "" : u.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
|
|
689
|
+
cursor: u.disabled ? "not-allowed" : "pointer",
|
|
690
|
+
pointerEvents: u.disbled ? "none" : "all",
|
|
675
691
|
...e ? {} : { width: "100%" }
|
|
676
692
|
},
|
|
677
|
-
children:
|
|
693
|
+
children: u.year
|
|
678
694
|
},
|
|
679
|
-
|
|
695
|
+
y
|
|
680
696
|
)) });
|
|
681
697
|
}, ae = ({ ...a }) => /* @__PURE__ */ r(
|
|
682
698
|
"svg",
|
|
@@ -725,9 +741,9 @@ const W = (a) => {
|
|
|
725
741
|
date: s,
|
|
726
742
|
setDate: l
|
|
727
743
|
}) => {
|
|
728
|
-
const
|
|
744
|
+
const h = () => {
|
|
729
745
|
t || a((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
|
|
730
|
-
},
|
|
746
|
+
}, i = () => {
|
|
731
747
|
if (n === "years") {
|
|
732
748
|
l((e) => new Date(e.getFullYear() + 10, 0));
|
|
733
749
|
return;
|
|
@@ -753,20 +769,20 @@ const W = (a) => {
|
|
|
753
769
|
)
|
|
754
770
|
);
|
|
755
771
|
};
|
|
756
|
-
return /* @__PURE__ */
|
|
772
|
+
return /* @__PURE__ */ F("div", { className: "sa-calendar-header", children: [
|
|
757
773
|
/* @__PURE__ */ r(ae, { onClick: () => g() }),
|
|
758
|
-
/* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick:
|
|
774
|
+
/* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick: h, children: (() => {
|
|
759
775
|
if (n === "days")
|
|
760
|
-
return `${
|
|
776
|
+
return `${W[s.getMonth()]} ${s.getFullYear()}`;
|
|
761
777
|
if (n === "months")
|
|
762
778
|
return `${s.getFullYear()}`;
|
|
763
779
|
if (n === "years")
|
|
764
780
|
return `${U(s.getFullYear()).start} ~ ${U(s.getFullYear()).end}`;
|
|
765
781
|
})() }),
|
|
766
|
-
/* @__PURE__ */ r(re, { onClick: () =>
|
|
782
|
+
/* @__PURE__ */ r(re, { onClick: () => i() })
|
|
767
783
|
] });
|
|
768
784
|
};
|
|
769
|
-
function
|
|
785
|
+
function A(a) {
|
|
770
786
|
const n = new Date(a), t = n.getFullYear(), s = n.getMonth();
|
|
771
787
|
return `${n.getDate().toString().padStart(2, "0")} ${se[s]} ${t}`;
|
|
772
788
|
}
|
|
@@ -776,39 +792,39 @@ const te = ({
|
|
|
776
792
|
required: t,
|
|
777
793
|
optional: s,
|
|
778
794
|
description: l,
|
|
779
|
-
helperText:
|
|
780
|
-
errorText:
|
|
795
|
+
helperText: h,
|
|
796
|
+
errorText: i,
|
|
781
797
|
fullWidth: g,
|
|
782
|
-
children:
|
|
798
|
+
children: f
|
|
783
799
|
}) => {
|
|
784
800
|
const e = [
|
|
785
801
|
"sa-date-field",
|
|
786
802
|
g ? "sa-date-field-fullwidth" : ""
|
|
787
|
-
].filter(Boolean).join(" "),
|
|
803
|
+
].filter(Boolean).join(" "), p = a ? /* @__PURE__ */ F("div", { className: "sa-date-field-label-row", children: [
|
|
788
804
|
/* @__PURE__ */ r("span", { className: "sa-date-field-label-text", children: a }),
|
|
789
805
|
s && /* @__PURE__ */ r("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
|
|
790
806
|
t && /* @__PURE__ */ r("span", { className: "sa-date-field-required", children: "*" })
|
|
791
|
-
] }) : null, v = /* @__PURE__ */
|
|
792
|
-
|
|
793
|
-
|
|
807
|
+
] }) : null, v = /* @__PURE__ */ F(_, { children: [
|
|
808
|
+
h && !i && /* @__PURE__ */ r("p", { className: "sa-date-field-helper", children: h }),
|
|
809
|
+
i && /* @__PURE__ */ r("p", { className: "sa-date-field-error-msg", children: i })
|
|
794
810
|
] });
|
|
795
|
-
return a ? n === "outside-left" ? /* @__PURE__ */
|
|
796
|
-
/* @__PURE__ */
|
|
797
|
-
|
|
811
|
+
return a ? n === "outside-left" ? /* @__PURE__ */ F("div", { className: `${e} sa-date-field-left`, children: [
|
|
812
|
+
/* @__PURE__ */ F("div", { className: "sa-date-field-left-label", children: [
|
|
813
|
+
p,
|
|
798
814
|
l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l })
|
|
799
815
|
] }),
|
|
800
|
-
/* @__PURE__ */
|
|
801
|
-
|
|
816
|
+
/* @__PURE__ */ F("div", { className: "sa-date-field-input-wrap", children: [
|
|
817
|
+
f,
|
|
802
818
|
v
|
|
803
819
|
] })
|
|
804
|
-
] }) : /* @__PURE__ */
|
|
805
|
-
|
|
820
|
+
] }) : /* @__PURE__ */ F("div", { className: e, children: [
|
|
821
|
+
p,
|
|
806
822
|
l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l }),
|
|
807
|
-
|
|
823
|
+
f,
|
|
808
824
|
v
|
|
809
|
-
] }) : /* @__PURE__ */
|
|
825
|
+
] }) : /* @__PURE__ */ F("div", { className: e, children: [
|
|
810
826
|
l && /* @__PURE__ */ r("p", { className: "sa-date-field-helper-top", children: l }),
|
|
811
|
-
|
|
827
|
+
f,
|
|
812
828
|
v
|
|
813
829
|
] });
|
|
814
830
|
}, Q = "sa-calendar-styles", he = (a) => {
|
|
@@ -817,7 +833,7 @@ const te = ({
|
|
|
817
833
|
n.id = Q, n.textContent = a, document.head.appendChild(n);
|
|
818
834
|
}
|
|
819
835
|
};
|
|
820
|
-
he(
|
|
836
|
+
he(J);
|
|
821
837
|
const pe = G(
|
|
822
838
|
({
|
|
823
839
|
value: a,
|
|
@@ -825,147 +841,147 @@ const pe = G(
|
|
|
825
841
|
filter: t,
|
|
826
842
|
input: s = !0,
|
|
827
843
|
disabled: l,
|
|
828
|
-
minDate:
|
|
829
|
-
maxDate:
|
|
844
|
+
minDate: h,
|
|
845
|
+
maxDate: i,
|
|
830
846
|
placeholder: g,
|
|
831
|
-
size:
|
|
847
|
+
size: f,
|
|
832
848
|
status: e,
|
|
833
|
-
clearable:
|
|
849
|
+
clearable: p,
|
|
834
850
|
fullWidth: v = !0,
|
|
835
|
-
label:
|
|
836
|
-
labelPosition:
|
|
837
|
-
required:
|
|
851
|
+
label: x,
|
|
852
|
+
labelPosition: D,
|
|
853
|
+
required: m,
|
|
838
854
|
optional: o,
|
|
839
855
|
description: c,
|
|
840
|
-
helperText:
|
|
841
|
-
errorText:
|
|
842
|
-
},
|
|
843
|
-
const
|
|
856
|
+
helperText: k,
|
|
857
|
+
errorText: Y
|
|
858
|
+
}, u) => {
|
|
859
|
+
const y = Y ? "error" : e, { ref: d, isComponentVisible: w, setIsComponentVisible: N } = ne(!1), M = P(null), [T, $] = z("days"), [E, I] = z(/* @__PURE__ */ new Date()), [C, L] = z({
|
|
844
860
|
from: (a == null ? void 0 : a.from) || /* @__PURE__ */ new Date(),
|
|
845
861
|
to: (a == null ? void 0 : a.to) || /* @__PURE__ */ new Date()
|
|
846
862
|
});
|
|
847
|
-
|
|
848
|
-
a ? (
|
|
863
|
+
S(() => {
|
|
864
|
+
a ? (I(a.from), L(a)) : (I(/* @__PURE__ */ new Date()), L({
|
|
849
865
|
from: /* @__PURE__ */ new Date(),
|
|
850
866
|
to: /* @__PURE__ */ new Date()
|
|
851
867
|
}));
|
|
852
|
-
}, [a]),
|
|
853
|
-
t &&
|
|
854
|
-
}, [t]),
|
|
855
|
-
t ||
|
|
856
|
-
}, [
|
|
857
|
-
s ||
|
|
868
|
+
}, [a]), S(() => {
|
|
869
|
+
t && $(t);
|
|
870
|
+
}, [t]), S(() => {
|
|
871
|
+
t || $("days");
|
|
872
|
+
}, [w]), S(() => {
|
|
873
|
+
s || N(!0);
|
|
858
874
|
}, [s]);
|
|
859
|
-
const
|
|
860
|
-
var b,
|
|
875
|
+
const j = () => {
|
|
876
|
+
var b, B;
|
|
861
877
|
if (!a)
|
|
862
878
|
return "";
|
|
863
879
|
if (t) {
|
|
864
|
-
if (
|
|
865
|
-
return `${
|
|
866
|
-
if (
|
|
867
|
-
return `${
|
|
868
|
-
if (
|
|
869
|
-
return `${(b =
|
|
880
|
+
if (T === "days")
|
|
881
|
+
return `${A(C.from)} ~ ${A(C.to || C.from) || "-"}`;
|
|
882
|
+
if (T === "months")
|
|
883
|
+
return `${W[C.from.getMonth()]} ~ ${C.to ? W[C.to.getMonth()] : "-"}`;
|
|
884
|
+
if (T === "years")
|
|
885
|
+
return `${(b = C.from) == null ? void 0 : b.getFullYear()} ~ ${((B = C.to) == null ? void 0 : B.getFullYear()) || "-"}`;
|
|
870
886
|
} else
|
|
871
|
-
return `${
|
|
872
|
-
},
|
|
873
|
-
if (
|
|
874
|
-
const b =
|
|
875
|
-
window.innerWidth < b.left +
|
|
887
|
+
return `${A(C.from)} ~ ${A(C.to || C.from) || "-"}`;
|
|
888
|
+
}, V = () => {
|
|
889
|
+
if (M.current && d.current && s) {
|
|
890
|
+
const b = d.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
|
|
891
|
+
window.innerWidth < b.left + B.width ? M.current.style.left = `${b.left - B.width + b.width}px` : M.current.style.left = `${b.left}px`, b.top + B.height > window.innerHeight ? M.current.style.top = `${b.y - (b.height + B.height - 28)}px` : M.current.style.top = `${b.y + b.height}px`;
|
|
876
892
|
}
|
|
877
893
|
};
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}, [
|
|
881
|
-
const b =
|
|
882
|
-
return b && b.addEventListener("scroll",
|
|
883
|
-
b && b.removeEventListener("scroll",
|
|
894
|
+
S(() => {
|
|
895
|
+
M.current && d.current && s && V();
|
|
896
|
+
}, [M, d, w]), S(() => {
|
|
897
|
+
const b = u == null ? void 0 : u.current;
|
|
898
|
+
return b && b.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
|
|
899
|
+
b && b.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
|
|
884
900
|
};
|
|
885
901
|
}, []);
|
|
886
|
-
const R = /* @__PURE__ */
|
|
902
|
+
const R = /* @__PURE__ */ F(
|
|
887
903
|
"div",
|
|
888
904
|
{
|
|
889
905
|
className: "sa-calendar-wrapper",
|
|
890
906
|
style: { height: s ? "auto" : "100%" },
|
|
891
|
-
ref: s ?
|
|
907
|
+
ref: s ? d : null,
|
|
892
908
|
children: [
|
|
893
909
|
s ? /* @__PURE__ */ r(
|
|
894
910
|
le,
|
|
895
911
|
{
|
|
896
|
-
value:
|
|
912
|
+
value: j(),
|
|
897
913
|
inputMode: "none",
|
|
898
914
|
onClick: () => {
|
|
899
|
-
|
|
915
|
+
N(!0);
|
|
900
916
|
},
|
|
901
917
|
onChange: () => {
|
|
902
918
|
},
|
|
903
919
|
disabled: l,
|
|
904
920
|
placeholder: g,
|
|
905
|
-
size:
|
|
906
|
-
status:
|
|
907
|
-
clearable:
|
|
921
|
+
size: f,
|
|
922
|
+
status: y,
|
|
923
|
+
clearable: p,
|
|
908
924
|
onClear: () => n(void 0)
|
|
909
925
|
}
|
|
910
926
|
) : null,
|
|
911
|
-
|
|
927
|
+
w ? /* @__PURE__ */ F(
|
|
912
928
|
"div",
|
|
913
929
|
{
|
|
914
930
|
className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
|
|
915
|
-
ref:
|
|
931
|
+
ref: M,
|
|
916
932
|
children: [
|
|
917
933
|
/* @__PURE__ */ r(
|
|
918
934
|
ue,
|
|
919
935
|
{
|
|
920
|
-
setViews:
|
|
921
|
-
views:
|
|
936
|
+
setViews: $,
|
|
937
|
+
views: T,
|
|
922
938
|
filter: t,
|
|
923
|
-
date:
|
|
924
|
-
setDate:
|
|
939
|
+
date: E,
|
|
940
|
+
setDate: I
|
|
925
941
|
}
|
|
926
942
|
),
|
|
927
|
-
/* @__PURE__ */ r("div", { className: "sa-calendar-body", children:
|
|
943
|
+
/* @__PURE__ */ r("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ r(
|
|
928
944
|
ie,
|
|
929
945
|
{
|
|
930
|
-
date:
|
|
931
|
-
setDate:
|
|
932
|
-
setIsComponentVisible:
|
|
933
|
-
dateRange:
|
|
934
|
-
setDateRange:
|
|
946
|
+
date: E,
|
|
947
|
+
setDate: I,
|
|
948
|
+
setIsComponentVisible: N,
|
|
949
|
+
dateRange: C,
|
|
950
|
+
setDateRange: L,
|
|
935
951
|
input: s,
|
|
936
952
|
onChange: n,
|
|
937
|
-
minDate:
|
|
938
|
-
maxDate:
|
|
953
|
+
minDate: h,
|
|
954
|
+
maxDate: i
|
|
939
955
|
}
|
|
940
|
-
) :
|
|
956
|
+
) : T === "months" ? /* @__PURE__ */ r(
|
|
941
957
|
de,
|
|
942
958
|
{
|
|
943
|
-
date:
|
|
944
|
-
setDate:
|
|
959
|
+
date: E,
|
|
960
|
+
setDate: I,
|
|
945
961
|
filter: t,
|
|
946
|
-
setViews:
|
|
947
|
-
dateRange:
|
|
948
|
-
setDateRange:
|
|
949
|
-
setIsComponentVisible:
|
|
962
|
+
setViews: $,
|
|
963
|
+
dateRange: C,
|
|
964
|
+
setDateRange: L,
|
|
965
|
+
setIsComponentVisible: N,
|
|
950
966
|
input: s,
|
|
951
967
|
onChange: n,
|
|
952
|
-
minDate:
|
|
953
|
-
maxDate:
|
|
968
|
+
minDate: h,
|
|
969
|
+
maxDate: i
|
|
954
970
|
}
|
|
955
971
|
) : /* @__PURE__ */ r(
|
|
956
972
|
ce,
|
|
957
973
|
{
|
|
958
|
-
date:
|
|
959
|
-
setDate:
|
|
974
|
+
date: E,
|
|
975
|
+
setDate: I,
|
|
960
976
|
filter: t,
|
|
961
|
-
setViews:
|
|
962
|
-
dateRange:
|
|
963
|
-
setDateRange:
|
|
964
|
-
setIsComponentVisible:
|
|
977
|
+
setViews: $,
|
|
978
|
+
dateRange: C,
|
|
979
|
+
setDateRange: L,
|
|
980
|
+
setIsComponentVisible: N,
|
|
965
981
|
input: s,
|
|
966
982
|
onChange: n,
|
|
967
|
-
minDate:
|
|
968
|
-
maxDate:
|
|
983
|
+
minDate: h,
|
|
984
|
+
maxDate: i
|
|
969
985
|
}
|
|
970
986
|
) })
|
|
971
987
|
]
|
|
@@ -977,13 +993,13 @@ const pe = G(
|
|
|
977
993
|
return /* @__PURE__ */ r(
|
|
978
994
|
te,
|
|
979
995
|
{
|
|
980
|
-
label:
|
|
981
|
-
labelPosition:
|
|
982
|
-
required:
|
|
996
|
+
label: x,
|
|
997
|
+
labelPosition: D,
|
|
998
|
+
required: m,
|
|
983
999
|
optional: o,
|
|
984
1000
|
description: c,
|
|
985
|
-
helperText:
|
|
986
|
-
errorText:
|
|
1001
|
+
helperText: k,
|
|
1002
|
+
errorText: Y,
|
|
987
1003
|
fullWidth: v,
|
|
988
1004
|
children: R
|
|
989
1005
|
}
|
|
@@ -995,7 +1011,7 @@ const pe = G(
|
|
|
995
1011
|
n.id = X, n.textContent = a, document.head.appendChild(n);
|
|
996
1012
|
}
|
|
997
1013
|
};
|
|
998
|
-
ge(
|
|
1014
|
+
ge(J);
|
|
999
1015
|
const O = (a) => {
|
|
1000
1016
|
if (a === "sm")
|
|
1001
1017
|
return 16;
|
|
@@ -1009,18 +1025,18 @@ const O = (a) => {
|
|
|
1009
1025
|
status: t = "default",
|
|
1010
1026
|
variant: s = "outline",
|
|
1011
1027
|
clearable: l,
|
|
1012
|
-
onClear:
|
|
1013
|
-
...
|
|
1014
|
-
} = a, g =
|
|
1015
|
-
g.current &&
|
|
1016
|
-
}, e = t === "disable" ||
|
|
1017
|
-
|
|
1028
|
+
onClear: h,
|
|
1029
|
+
...i
|
|
1030
|
+
} = a, g = P(null), f = () => {
|
|
1031
|
+
g.current && i.onClick && (g.current.focus(), i.onClick(""));
|
|
1032
|
+
}, e = t === "disable" || i.disabled, p = !!i.value, v = l && p && !e, x = (D) => {
|
|
1033
|
+
D.stopPropagation(), h == null || h();
|
|
1018
1034
|
};
|
|
1019
|
-
return /* @__PURE__ */
|
|
1035
|
+
return /* @__PURE__ */ F(
|
|
1020
1036
|
"div",
|
|
1021
1037
|
{
|
|
1022
1038
|
className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${n} `,
|
|
1023
|
-
onClick:
|
|
1039
|
+
onClick: f,
|
|
1024
1040
|
children: [
|
|
1025
1041
|
/* @__PURE__ */ r("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ r(
|
|
1026
1042
|
"svg",
|
|
@@ -1046,9 +1062,9 @@ const O = (a) => {
|
|
|
1046
1062
|
"input",
|
|
1047
1063
|
{
|
|
1048
1064
|
className: "sa-calendar-input",
|
|
1049
|
-
...
|
|
1065
|
+
...i,
|
|
1050
1066
|
disabled: e,
|
|
1051
|
-
value:
|
|
1067
|
+
value: i.value,
|
|
1052
1068
|
ref: g
|
|
1053
1069
|
}
|
|
1054
1070
|
) }),
|
|
@@ -1058,7 +1074,7 @@ const O = (a) => {
|
|
|
1058
1074
|
type: "button",
|
|
1059
1075
|
"aria-label": "Clear date",
|
|
1060
1076
|
className: "sa-calendar-input-clear",
|
|
1061
|
-
onClick:
|
|
1077
|
+
onClick: x,
|
|
1062
1078
|
children: /* @__PURE__ */ r(
|
|
1063
1079
|
"svg",
|
|
1064
1080
|
{
|
|
@@ -1109,51 +1125,51 @@ const O = (a) => {
|
|
|
1109
1125
|
previewDate: t,
|
|
1110
1126
|
setPreviewDate: s,
|
|
1111
1127
|
setIsComponentVisible: l,
|
|
1112
|
-
minDate:
|
|
1113
|
-
maxDate:
|
|
1128
|
+
minDate: h,
|
|
1129
|
+
maxDate: i,
|
|
1114
1130
|
input: g,
|
|
1115
|
-
onChange:
|
|
1131
|
+
onChange: f
|
|
1116
1132
|
}) => {
|
|
1117
1133
|
let e = new Date(
|
|
1118
1134
|
t.getFullYear(),
|
|
1119
1135
|
t.getMonth(),
|
|
1120
1136
|
1
|
|
1121
|
-
),
|
|
1122
|
-
const
|
|
1137
|
+
), p = e.getDay(), v = [];
|
|
1138
|
+
const x = a.toDateString(), D = t.getMonth();
|
|
1123
1139
|
for (let o = 0; o < 42; o++) {
|
|
1124
|
-
o === 0 &&
|
|
1125
|
-
e.getDate() + (o -
|
|
1140
|
+
o === 0 && p === 0 ? e.setDate(e.getDate() - 7) : o === 0 ? e.setDate(
|
|
1141
|
+
e.getDate() + (o - p)
|
|
1126
1142
|
) : e.setDate(e.getDate() + 1);
|
|
1127
1143
|
let c = {
|
|
1128
|
-
currentMonth: e.getMonth() ===
|
|
1144
|
+
currentMonth: e.getMonth() === D,
|
|
1129
1145
|
date: new Date(e),
|
|
1130
1146
|
month: e.getMonth(),
|
|
1131
1147
|
number: e.getDate(),
|
|
1132
|
-
selected: e.toDateString() ===
|
|
1148
|
+
selected: e.toDateString() === x,
|
|
1133
1149
|
year: e.getFullYear(),
|
|
1134
|
-
isDisabled:
|
|
1150
|
+
isDisabled: h && e < h || i && e > i
|
|
1135
1151
|
};
|
|
1136
1152
|
v.push(c);
|
|
1137
1153
|
}
|
|
1138
|
-
const
|
|
1139
|
-
(!
|
|
1154
|
+
const m = (o) => {
|
|
1155
|
+
(!h || o >= h) && (!i || o <= i) && (n(o), f(o), s(o), g && l(!1));
|
|
1140
1156
|
};
|
|
1141
|
-
return /* @__PURE__ */
|
|
1157
|
+
return /* @__PURE__ */ F("div", { className: "sa-calendar-days-preivew", children: [
|
|
1142
1158
|
/* @__PURE__ */ r("div", { className: "sa-calendar-days-name-preivew", children: ee.map((o, c) => /* @__PURE__ */ r("p", { children: o }, c)) }),
|
|
1143
1159
|
/* @__PURE__ */ r("div", { className: "sa-calendar-days-number-preivew", children: v.map((o, c) => {
|
|
1144
|
-
const
|
|
1160
|
+
const k = o.isDisabled;
|
|
1145
1161
|
return /* @__PURE__ */ r(
|
|
1146
1162
|
"p",
|
|
1147
1163
|
{
|
|
1148
1164
|
className: `${o.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${o.selected ? "sa-calendar-days-active" : ""}`,
|
|
1149
1165
|
style: {
|
|
1150
|
-
color:
|
|
1151
|
-
pointerEvents:
|
|
1152
|
-
cursor:
|
|
1166
|
+
color: k ? "#ccc" : void 0,
|
|
1167
|
+
pointerEvents: k ? "none" : void 0,
|
|
1168
|
+
cursor: k ? "not-allowed" : "pointer",
|
|
1153
1169
|
...g ? {} : { width: "100%" }
|
|
1154
1170
|
},
|
|
1155
1171
|
onClick: () => {
|
|
1156
|
-
|
|
1172
|
+
k || m(o.date);
|
|
1157
1173
|
},
|
|
1158
1174
|
children: o.number
|
|
1159
1175
|
},
|
|
@@ -1161,27 +1177,27 @@ const O = (a) => {
|
|
|
1161
1177
|
);
|
|
1162
1178
|
}) })
|
|
1163
1179
|
] });
|
|
1164
|
-
},
|
|
1180
|
+
}, ve = ({
|
|
1165
1181
|
date: a,
|
|
1166
1182
|
setDate: n,
|
|
1167
1183
|
filter: t,
|
|
1168
1184
|
setViews: s,
|
|
1169
1185
|
onChange: l,
|
|
1170
|
-
previewDate:
|
|
1171
|
-
setPreviewDate:
|
|
1186
|
+
previewDate: h,
|
|
1187
|
+
setPreviewDate: i,
|
|
1172
1188
|
minDate: g,
|
|
1173
|
-
maxDate:
|
|
1189
|
+
maxDate: f,
|
|
1174
1190
|
input: e
|
|
1175
1191
|
}) => {
|
|
1176
|
-
const
|
|
1177
|
-
(!g ||
|
|
1192
|
+
const p = a.getMonth(), v = a.getFullYear(), x = h.getFullYear(), D = (m) => {
|
|
1193
|
+
(!g || m >= g) && (!f || m <= f) && (t ? (l(m), n(m), i(m)) : (s("days"), i(m)));
|
|
1178
1194
|
};
|
|
1179
|
-
return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children:
|
|
1180
|
-
const c = g && new Date(
|
|
1195
|
+
return /* @__PURE__ */ r("div", { className: "sa-calendar-months-preview", children: W.map((m, o) => {
|
|
1196
|
+
const c = g && new Date(x, o, 1) < g || f && new Date(x, o + 1, 0) > f;
|
|
1181
1197
|
return /* @__PURE__ */ r(
|
|
1182
1198
|
"p",
|
|
1183
1199
|
{
|
|
1184
|
-
className: o ===
|
|
1200
|
+
className: o === p && x === v ? "sa-calendar-months-active" : "",
|
|
1185
1201
|
style: {
|
|
1186
1202
|
color: c ? "#ccc" : void 0,
|
|
1187
1203
|
pointerEvents: c ? "none" : void 0,
|
|
@@ -1189,9 +1205,9 @@ const O = (a) => {
|
|
|
1189
1205
|
...e ? {} : { width: "100%" }
|
|
1190
1206
|
},
|
|
1191
1207
|
onClick: () => {
|
|
1192
|
-
c ||
|
|
1208
|
+
c || D(new Date(x, o));
|
|
1193
1209
|
},
|
|
1194
|
-
children:
|
|
1210
|
+
children: m.slice(0, 3)
|
|
1195
1211
|
},
|
|
1196
1212
|
o
|
|
1197
1213
|
);
|
|
@@ -1199,28 +1215,28 @@ const O = (a) => {
|
|
|
1199
1215
|
}, q = (a) => {
|
|
1200
1216
|
const n = Math.floor(a / 10) * 10, t = n + 10;
|
|
1201
1217
|
return { start: n, end: t };
|
|
1202
|
-
},
|
|
1218
|
+
}, be = ({
|
|
1203
1219
|
date: a,
|
|
1204
1220
|
filter: n,
|
|
1205
1221
|
setViews: t,
|
|
1206
1222
|
setDate: s,
|
|
1207
1223
|
onChange: l,
|
|
1208
|
-
previewDate:
|
|
1209
|
-
setPreviewDate:
|
|
1224
|
+
previewDate: h,
|
|
1225
|
+
setPreviewDate: i,
|
|
1210
1226
|
minDate: g,
|
|
1211
|
-
maxDate:
|
|
1227
|
+
maxDate: f,
|
|
1212
1228
|
input: e
|
|
1213
1229
|
}) => {
|
|
1214
|
-
let
|
|
1215
|
-
const v =
|
|
1216
|
-
for (let c =
|
|
1217
|
-
let
|
|
1218
|
-
|
|
1230
|
+
let p = [];
|
|
1231
|
+
const v = h.getFullYear(), { start: x, end: D } = q(v), m = a.getFullYear();
|
|
1232
|
+
for (let c = x; c < D; c++) {
|
|
1233
|
+
let k = g && new Date(c, 0, 1) < g || f && new Date(c, 11, 31) > f;
|
|
1234
|
+
p.push({ year: c, active: c === m, isDisabled: k });
|
|
1219
1235
|
}
|
|
1220
1236
|
const o = (c) => {
|
|
1221
|
-
(!g || c >= g) && (!
|
|
1237
|
+
(!g || c >= g) && (!f || c <= f) && (n ? (l(c), s(c), i(c)) : (t("months"), i(c)));
|
|
1222
1238
|
};
|
|
1223
|
-
return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children:
|
|
1239
|
+
return /* @__PURE__ */ r("div", { className: "sa-calendar-years-preview", children: p.map((c, k) => /* @__PURE__ */ r(
|
|
1224
1240
|
"p",
|
|
1225
1241
|
{
|
|
1226
1242
|
className: c.active ? "sa-calendar-months-active" : "",
|
|
@@ -1235,7 +1251,7 @@ const O = (a) => {
|
|
|
1235
1251
|
},
|
|
1236
1252
|
children: c.year
|
|
1237
1253
|
},
|
|
1238
|
-
|
|
1254
|
+
k
|
|
1239
1255
|
)) });
|
|
1240
1256
|
}, ye = ({
|
|
1241
1257
|
setViews: a,
|
|
@@ -1244,9 +1260,9 @@ const O = (a) => {
|
|
|
1244
1260
|
previewDate: s,
|
|
1245
1261
|
setPreviewDate: l
|
|
1246
1262
|
}) => {
|
|
1247
|
-
const
|
|
1263
|
+
const h = () => {
|
|
1248
1264
|
t || a((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
|
|
1249
|
-
},
|
|
1265
|
+
}, i = () => {
|
|
1250
1266
|
if (n === "years") {
|
|
1251
1267
|
l((e) => new Date(e.getFullYear() + 10, 0));
|
|
1252
1268
|
return;
|
|
@@ -1276,17 +1292,17 @@ const O = (a) => {
|
|
|
1276
1292
|
)
|
|
1277
1293
|
);
|
|
1278
1294
|
};
|
|
1279
|
-
return /* @__PURE__ */
|
|
1295
|
+
return /* @__PURE__ */ F("div", { className: "sa-calendar-header", children: [
|
|
1280
1296
|
/* @__PURE__ */ r(ae, { onClick: () => g() }),
|
|
1281
|
-
/* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick:
|
|
1297
|
+
/* @__PURE__ */ r("div", { style: { cursor: "pointer" }, onClick: h, children: (() => {
|
|
1282
1298
|
if (n === "days")
|
|
1283
|
-
return `${
|
|
1299
|
+
return `${W[s.getMonth()]} ${s.getFullYear()}`;
|
|
1284
1300
|
if (n === "months")
|
|
1285
1301
|
return `${s.getFullYear()}`;
|
|
1286
1302
|
if (n === "years")
|
|
1287
1303
|
return `${q(s.getFullYear()).start} ~ ${q(s.getFullYear()).end}`;
|
|
1288
1304
|
})() }),
|
|
1289
|
-
/* @__PURE__ */ r(re, { onClick: () =>
|
|
1305
|
+
/* @__PURE__ */ r(re, { onClick: () => i() })
|
|
1290
1306
|
] });
|
|
1291
1307
|
}, Z = "sa-calendar-styles", we = (a) => {
|
|
1292
1308
|
if (!document.getElementById(Z)) {
|
|
@@ -1294,7 +1310,7 @@ const O = (a) => {
|
|
|
1294
1310
|
n.id = Z, n.textContent = a, document.head.appendChild(n);
|
|
1295
1311
|
}
|
|
1296
1312
|
};
|
|
1297
|
-
we(
|
|
1313
|
+
we(J);
|
|
1298
1314
|
const xe = G(
|
|
1299
1315
|
({
|
|
1300
1316
|
value: a,
|
|
@@ -1302,124 +1318,124 @@ const xe = G(
|
|
|
1302
1318
|
filter: t,
|
|
1303
1319
|
input: s = !0,
|
|
1304
1320
|
disabled: l,
|
|
1305
|
-
minDate:
|
|
1306
|
-
maxDate:
|
|
1321
|
+
minDate: h,
|
|
1322
|
+
maxDate: i,
|
|
1307
1323
|
placeholder: g,
|
|
1308
|
-
size:
|
|
1324
|
+
size: f,
|
|
1309
1325
|
status: e,
|
|
1310
|
-
clearable:
|
|
1326
|
+
clearable: p,
|
|
1311
1327
|
fullWidth: v = !0,
|
|
1312
|
-
label:
|
|
1313
|
-
labelPosition:
|
|
1314
|
-
required:
|
|
1328
|
+
label: x,
|
|
1329
|
+
labelPosition: D,
|
|
1330
|
+
required: m,
|
|
1315
1331
|
optional: o,
|
|
1316
1332
|
description: c,
|
|
1317
|
-
helperText:
|
|
1318
|
-
errorText:
|
|
1319
|
-
},
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1322
|
-
a ? (
|
|
1323
|
-
}, [a]),
|
|
1324
|
-
t &&
|
|
1325
|
-
}, [t]),
|
|
1326
|
-
t ||
|
|
1327
|
-
}, [
|
|
1328
|
-
s ||
|
|
1333
|
+
helperText: k,
|
|
1334
|
+
errorText: Y
|
|
1335
|
+
}, u) => {
|
|
1336
|
+
const y = Y ? "error" : e, { ref: d, isComponentVisible: w, setIsComponentVisible: N } = ne(!1), M = P(null), [T, $] = z("days"), [E, I] = z(/* @__PURE__ */ new Date()), [C, L] = z(/* @__PURE__ */ new Date());
|
|
1337
|
+
S(() => {
|
|
1338
|
+
a ? (I(a), L(a)) : (I(/* @__PURE__ */ new Date()), L(/* @__PURE__ */ new Date()));
|
|
1339
|
+
}, [a]), S(() => {
|
|
1340
|
+
t && $(t);
|
|
1341
|
+
}, [t]), S(() => {
|
|
1342
|
+
t || $("days");
|
|
1343
|
+
}, [w]), S(() => {
|
|
1344
|
+
s || N(!0);
|
|
1329
1345
|
}, [s]);
|
|
1330
|
-
const
|
|
1331
|
-
if (
|
|
1332
|
-
const b =
|
|
1333
|
-
window.innerWidth < b.left +
|
|
1346
|
+
const j = () => a ? t === "days" ? A(E) : t === "months" ? `${W[E.getMonth()]} ${E.getFullYear()}` : t === "years" ? E.getFullYear() : A(E) : "", V = () => {
|
|
1347
|
+
if (M.current && d.current && s) {
|
|
1348
|
+
const b = d.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
|
|
1349
|
+
window.innerWidth < b.left + B.width ? M.current.style.left = `${b.left - B.width + b.width}px` : M.current.style.left = `${b.left}px`, b.top + B.height > window.innerHeight ? M.current.style.top = `${b.y - (b.height + B.height - 28)}px` : M.current.style.top = `${b.y + b.height}px`;
|
|
1334
1350
|
}
|
|
1335
1351
|
};
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}, [
|
|
1339
|
-
const b =
|
|
1340
|
-
return b && b.addEventListener("scroll",
|
|
1341
|
-
b && b.removeEventListener("scroll",
|
|
1352
|
+
S(() => {
|
|
1353
|
+
M.current && d.current && s && V();
|
|
1354
|
+
}, [M, d, w]), S(() => {
|
|
1355
|
+
const b = u == null ? void 0 : u.current;
|
|
1356
|
+
return b && b.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
|
|
1357
|
+
b && b.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
|
|
1342
1358
|
};
|
|
1343
1359
|
}, []);
|
|
1344
|
-
const R = /* @__PURE__ */
|
|
1360
|
+
const R = /* @__PURE__ */ F(
|
|
1345
1361
|
"div",
|
|
1346
1362
|
{
|
|
1347
1363
|
className: "sa-calendar-wrapper",
|
|
1348
1364
|
style: { height: s ? "auto" : "100%" },
|
|
1349
|
-
ref: s ?
|
|
1365
|
+
ref: s ? d : null,
|
|
1350
1366
|
children: [
|
|
1351
1367
|
s ? /* @__PURE__ */ r(
|
|
1352
1368
|
fe,
|
|
1353
1369
|
{
|
|
1354
|
-
value:
|
|
1355
|
-
onClick: () =>
|
|
1370
|
+
value: j(),
|
|
1371
|
+
onClick: () => N(!0),
|
|
1356
1372
|
onChange: () => {
|
|
1357
1373
|
},
|
|
1358
1374
|
placeholder: g,
|
|
1359
1375
|
disabled: l,
|
|
1360
|
-
size:
|
|
1361
|
-
status:
|
|
1376
|
+
size: f,
|
|
1377
|
+
status: y,
|
|
1362
1378
|
inputMode: "none",
|
|
1363
|
-
clearable:
|
|
1379
|
+
clearable: p,
|
|
1364
1380
|
onClear: () => n(void 0)
|
|
1365
1381
|
}
|
|
1366
1382
|
) : null,
|
|
1367
|
-
|
|
1383
|
+
w ? /* @__PURE__ */ F(
|
|
1368
1384
|
"div",
|
|
1369
1385
|
{
|
|
1370
1386
|
className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
|
|
1371
|
-
ref:
|
|
1387
|
+
ref: M,
|
|
1372
1388
|
children: [
|
|
1373
1389
|
/* @__PURE__ */ r(
|
|
1374
1390
|
ye,
|
|
1375
1391
|
{
|
|
1376
|
-
setViews:
|
|
1377
|
-
views:
|
|
1392
|
+
setViews: $,
|
|
1393
|
+
views: T,
|
|
1378
1394
|
filter: t,
|
|
1379
|
-
previewDate:
|
|
1380
|
-
setPreviewDate:
|
|
1381
|
-
isComponentVisible:
|
|
1395
|
+
previewDate: C,
|
|
1396
|
+
setPreviewDate: L,
|
|
1397
|
+
isComponentVisible: w
|
|
1382
1398
|
}
|
|
1383
1399
|
),
|
|
1384
|
-
/* @__PURE__ */ r("div", { className: "sa-calendar-body", children:
|
|
1400
|
+
/* @__PURE__ */ r("div", { className: "sa-calendar-body", children: T === "days" ? /* @__PURE__ */ r(
|
|
1385
1401
|
me,
|
|
1386
1402
|
{
|
|
1387
|
-
date:
|
|
1388
|
-
setDate:
|
|
1389
|
-
previewDate:
|
|
1390
|
-
setPreviewDate:
|
|
1391
|
-
setIsComponentVisible:
|
|
1403
|
+
date: E,
|
|
1404
|
+
setDate: I,
|
|
1405
|
+
previewDate: C,
|
|
1406
|
+
setPreviewDate: L,
|
|
1407
|
+
setIsComponentVisible: N,
|
|
1392
1408
|
input: s,
|
|
1393
|
-
minDate:
|
|
1394
|
-
maxDate:
|
|
1409
|
+
minDate: h,
|
|
1410
|
+
maxDate: i,
|
|
1395
1411
|
onChange: n
|
|
1396
1412
|
}
|
|
1397
|
-
) :
|
|
1398
|
-
|
|
1413
|
+
) : T === "months" ? /* @__PURE__ */ r(
|
|
1414
|
+
ve,
|
|
1399
1415
|
{
|
|
1400
|
-
date:
|
|
1401
|
-
setDate:
|
|
1402
|
-
previewDate:
|
|
1403
|
-
setPreviewDate:
|
|
1416
|
+
date: E,
|
|
1417
|
+
setDate: I,
|
|
1418
|
+
previewDate: C,
|
|
1419
|
+
setPreviewDate: L,
|
|
1404
1420
|
filter: t,
|
|
1405
|
-
setViews:
|
|
1421
|
+
setViews: $,
|
|
1406
1422
|
onChange: n,
|
|
1407
|
-
minDate:
|
|
1408
|
-
maxDate:
|
|
1423
|
+
minDate: h,
|
|
1424
|
+
maxDate: i,
|
|
1409
1425
|
input: s
|
|
1410
1426
|
}
|
|
1411
1427
|
) : /* @__PURE__ */ r(
|
|
1412
|
-
|
|
1428
|
+
be,
|
|
1413
1429
|
{
|
|
1414
|
-
date:
|
|
1415
|
-
setDate:
|
|
1416
|
-
previewDate:
|
|
1417
|
-
setPreviewDate:
|
|
1430
|
+
date: E,
|
|
1431
|
+
setDate: I,
|
|
1432
|
+
previewDate: C,
|
|
1433
|
+
setPreviewDate: L,
|
|
1418
1434
|
filter: t,
|
|
1419
|
-
setViews:
|
|
1435
|
+
setViews: $,
|
|
1420
1436
|
onChange: n,
|
|
1421
|
-
minDate:
|
|
1422
|
-
maxDate:
|
|
1437
|
+
minDate: h,
|
|
1438
|
+
maxDate: i,
|
|
1423
1439
|
input: s
|
|
1424
1440
|
}
|
|
1425
1441
|
) })
|
|
@@ -1432,13 +1448,13 @@ const xe = G(
|
|
|
1432
1448
|
return /* @__PURE__ */ r(
|
|
1433
1449
|
te,
|
|
1434
1450
|
{
|
|
1435
|
-
label:
|
|
1436
|
-
labelPosition:
|
|
1437
|
-
required:
|
|
1451
|
+
label: x,
|
|
1452
|
+
labelPosition: D,
|
|
1453
|
+
required: m,
|
|
1438
1454
|
optional: o,
|
|
1439
1455
|
description: c,
|
|
1440
|
-
helperText:
|
|
1441
|
-
errorText:
|
|
1456
|
+
helperText: k,
|
|
1457
|
+
errorText: Y,
|
|
1442
1458
|
fullWidth: v,
|
|
1443
1459
|
children: R
|
|
1444
1460
|
}
|
|
@@ -1451,44 +1467,44 @@ const xe = G(
|
|
|
1451
1467
|
filter: t,
|
|
1452
1468
|
input: s = !0,
|
|
1453
1469
|
rangedDate: l,
|
|
1454
|
-
disabled:
|
|
1455
|
-
minDate:
|
|
1470
|
+
disabled: h,
|
|
1471
|
+
minDate: i,
|
|
1456
1472
|
maxDate: g,
|
|
1457
|
-
placeholder:
|
|
1473
|
+
placeholder: f,
|
|
1458
1474
|
size: e,
|
|
1459
|
-
status:
|
|
1475
|
+
status: p,
|
|
1460
1476
|
clearable: v,
|
|
1461
|
-
fullWidth:
|
|
1462
|
-
label:
|
|
1463
|
-
labelPosition:
|
|
1477
|
+
fullWidth: x,
|
|
1478
|
+
label: D,
|
|
1479
|
+
labelPosition: m,
|
|
1464
1480
|
required: o,
|
|
1465
1481
|
optional: c,
|
|
1466
|
-
description:
|
|
1467
|
-
helperText:
|
|
1468
|
-
errorText:
|
|
1469
|
-
},
|
|
1470
|
-
const
|
|
1482
|
+
description: k,
|
|
1483
|
+
helperText: Y,
|
|
1484
|
+
errorText: u
|
|
1485
|
+
}, y) => {
|
|
1486
|
+
const d = {
|
|
1471
1487
|
onChange: n,
|
|
1472
1488
|
value: a,
|
|
1473
1489
|
input: s,
|
|
1474
1490
|
filter: t,
|
|
1475
|
-
disabled:
|
|
1476
|
-
minDate:
|
|
1491
|
+
disabled: h,
|
|
1492
|
+
minDate: i,
|
|
1477
1493
|
maxDate: g,
|
|
1478
|
-
placeholder:
|
|
1494
|
+
placeholder: f,
|
|
1479
1495
|
size: e,
|
|
1480
|
-
status:
|
|
1496
|
+
status: p,
|
|
1481
1497
|
clearable: v,
|
|
1482
|
-
fullWidth:
|
|
1483
|
-
label:
|
|
1484
|
-
labelPosition:
|
|
1498
|
+
fullWidth: x,
|
|
1499
|
+
label: D,
|
|
1500
|
+
labelPosition: m,
|
|
1485
1501
|
required: o,
|
|
1486
1502
|
optional: c,
|
|
1487
|
-
description:
|
|
1488
|
-
helperText:
|
|
1489
|
-
errorText:
|
|
1503
|
+
description: k,
|
|
1504
|
+
helperText: Y,
|
|
1505
|
+
errorText: u
|
|
1490
1506
|
};
|
|
1491
|
-
return /* @__PURE__ */ r(_, { children: l ? /* @__PURE__ */ r(pe, { ...
|
|
1507
|
+
return /* @__PURE__ */ r(_, { children: l ? /* @__PURE__ */ r(pe, { ...d, ref: y }) : /* @__PURE__ */ r(xe, { ...d, ref: y }) });
|
|
1492
1508
|
}
|
|
1493
1509
|
);
|
|
1494
1510
|
export {
|