@starasia/date 1.0.3 → 1.0.5
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 +184 -180
- package/dist/date.umd.js +24 -20
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -19,8 +19,12 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
19
19
|
/* color */
|
|
20
20
|
--starasia-ui-date-color-black-secondary: var(
|
|
21
21
|
--starasia-ui-color-gray-50,
|
|
22
|
-
|
|
22
|
+
rgba(249, 250, 251, 1)
|
|
23
23
|
);
|
|
24
|
+
--starasia-ui-date-color-white: var(--starasia-ui-color-gray-50, rgba(255, 254, 255, 1));
|
|
25
|
+
--starasia-ui-date-color-border: rgba(120, 134, 127, 0.2);
|
|
26
|
+
--starasia-ui-date-color-disabled-border: rgba(120, 134, 127, 0.2);
|
|
27
|
+
--starasia-ui-date-color-disabled-bg: rgba(120, 134, 127, 0.1);
|
|
24
28
|
|
|
25
29
|
/* box shadow */
|
|
26
30
|
--starasia-ui-date-box-shadow: var(
|
|
@@ -33,26 +37,26 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
33
37
|
/* gray / black */
|
|
34
38
|
--starasia-ui-date-color-primary-black: var(
|
|
35
39
|
--starasia-ui-color-gray-700,
|
|
36
|
-
|
|
40
|
+
rgba(55, 65, 81, 1)
|
|
37
41
|
);
|
|
38
42
|
--starasia-ui-date-color-secondary-black: var(
|
|
39
43
|
--starasia-ui-color-gray-500,
|
|
40
|
-
|
|
44
|
+
rgba(107, 114, 128, 1)
|
|
41
45
|
);
|
|
42
46
|
--starasia-ui-date-color-tertiary-black: var(
|
|
43
47
|
--starasia-ui-color-gray-300,
|
|
44
|
-
|
|
48
|
+
rgba(209, 213, 219, 1)
|
|
45
49
|
);
|
|
46
50
|
--starasia-ui-date-color-quaternary-black: var(
|
|
47
51
|
--starasia-ui-color-gray-50,
|
|
48
|
-
|
|
52
|
+
rgba(249, 250, 251, 1)
|
|
49
53
|
);
|
|
50
54
|
|
|
51
55
|
/* brand */
|
|
52
|
-
--starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default);
|
|
53
|
-
--starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default);
|
|
54
|
-
--starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
|
|
55
|
-
--starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
56
|
+
--starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
|
|
57
|
+
--starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
|
|
58
|
+
--starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary, rgba(144, 176, 218, 1));
|
|
59
|
+
--starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary, rgba(227, 237, 248, 1));
|
|
56
60
|
|
|
57
61
|
/* spacing */
|
|
58
62
|
--starasia-ui-date-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
|
|
@@ -70,12 +74,12 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
70
74
|
/* color */
|
|
71
75
|
--starasia-ui-input-color-tertiary-gray: var(
|
|
72
76
|
--starasia-ui-color-gray-300,
|
|
73
|
-
|
|
77
|
+
rgba(209, 213, 219, 1)
|
|
74
78
|
);
|
|
75
79
|
|
|
76
80
|
--starasia-ui-date-placholder-color: var(
|
|
77
81
|
--starasia-ui-color-gray-200,
|
|
78
|
-
|
|
82
|
+
rgba(201, 206, 204, 1)
|
|
79
83
|
);
|
|
80
84
|
--starasia-ui-date-placholder-fontWeight: var(
|
|
81
85
|
--starasia-ui-fontWeights-normal,
|
|
@@ -84,11 +88,11 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
84
88
|
|
|
85
89
|
--starasia-ui-input-color-secondary-red: var(
|
|
86
90
|
--starasia-ui-color-red-500,
|
|
87
|
-
|
|
91
|
+
rgba(239, 68, 68, 1)
|
|
88
92
|
);
|
|
89
93
|
--starasia-ui-input-color-secondary-yellow: var(
|
|
90
94
|
--starasia-ui-color-yellow-500,
|
|
91
|
-
|
|
95
|
+
rgba(234, 179, 8, 1)
|
|
92
96
|
);
|
|
93
97
|
}
|
|
94
98
|
.starasia-calendar-wrapper {
|
|
@@ -118,7 +122,7 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
118
122
|
width: 100%;
|
|
119
123
|
box-shadow: unset;
|
|
120
124
|
border: none;
|
|
121
|
-
background-color: white;
|
|
125
|
+
background-color: var(--starasia-ui-date-color-white);
|
|
122
126
|
/* background-color: white; */
|
|
123
127
|
height: 100%;
|
|
124
128
|
border-radius: 0;
|
|
@@ -244,18 +248,18 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
244
248
|
|
|
245
249
|
.starasia-calendar-input-container:has(input:focus) {
|
|
246
250
|
border-color: var(--starasia-ui-date-color-primary-blue);
|
|
247
|
-
box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary), 0.2);
|
|
251
|
+
box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary, 144, 176, 218), 0.2);
|
|
248
252
|
}
|
|
249
253
|
.starasia-calendar-input-container:has(input:disabled) {
|
|
250
254
|
/* border-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
251
255
|
/* background-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
252
|
-
border-color:
|
|
253
|
-
background-color:
|
|
256
|
+
border-color: var(--starasia-ui-date-color-disabled-border);
|
|
257
|
+
background-color: var(--starasia-ui-date-color-disabled-bg);
|
|
254
258
|
pointer-events: none;
|
|
255
259
|
}
|
|
256
260
|
|
|
257
261
|
.starasia-calendar-input-outline {
|
|
258
|
-
border-color:
|
|
262
|
+
border-color: var(--starasia-ui-date-color-border);
|
|
259
263
|
/* border-color: var(--starasia-ui-date-color-tertiary-black); */
|
|
260
264
|
background-color: transparent;
|
|
261
265
|
border-width: var(--starasia-ui-border, 1px);
|
|
@@ -348,37 +352,37 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
348
352
|
"Nov",
|
|
349
353
|
"Dec"
|
|
350
354
|
];
|
|
351
|
-
function J(
|
|
352
|
-
const [a, t] = F(
|
|
355
|
+
function J(e) {
|
|
356
|
+
const [a, t] = F(e), s = E(null), i = (g) => {
|
|
353
357
|
s.current && !s.current.contains(g.target) && t(!1);
|
|
354
358
|
};
|
|
355
359
|
return D(() => (document.addEventListener("click", i, !0), () => {
|
|
356
360
|
document.removeEventListener("click", i, !0);
|
|
357
361
|
}), []), { ref: s, isComponentVisible: a, setIsComponentVisible: t };
|
|
358
362
|
}
|
|
359
|
-
const j = "starasia-calendar-input-styles", U = (
|
|
363
|
+
const j = "starasia-calendar-input-styles", U = (e) => {
|
|
360
364
|
if (!document.getElementById(j)) {
|
|
361
365
|
const a = document.createElement("style");
|
|
362
|
-
a.id = j, a.textContent =
|
|
366
|
+
a.id = j, a.textContent = e, document.head.appendChild(a);
|
|
363
367
|
}
|
|
364
368
|
};
|
|
365
369
|
U(I);
|
|
366
|
-
const T = (
|
|
367
|
-
if (
|
|
370
|
+
const T = (e) => {
|
|
371
|
+
if (e === "sm")
|
|
368
372
|
return 16;
|
|
369
|
-
if (
|
|
373
|
+
if (e === "md")
|
|
370
374
|
return 16;
|
|
371
|
-
if (
|
|
375
|
+
if (e === "lg")
|
|
372
376
|
return 20;
|
|
373
|
-
}, K = (
|
|
374
|
-
const { size: a = "md", status: t = "default", variant: s = "outline", ...i } =
|
|
377
|
+
}, K = (e) => {
|
|
378
|
+
const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, g = E(null), y = () => {
|
|
375
379
|
g.current && i.onClick && (g.current.focus(), i.onClick(""));
|
|
376
380
|
};
|
|
377
381
|
return /* @__PURE__ */ $(
|
|
378
382
|
"div",
|
|
379
383
|
{
|
|
380
384
|
className: `starasia-calendar-input-container starasia-calendar-input-${s} starasia-calendar-input-container-${t} ${a} `,
|
|
381
|
-
onClick:
|
|
385
|
+
onClick: y,
|
|
382
386
|
children: [
|
|
383
387
|
/* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-left", children: /* @__PURE__ */ l(
|
|
384
388
|
"svg",
|
|
@@ -434,49 +438,49 @@ const T = (r) => {
|
|
|
434
438
|
}
|
|
435
439
|
);
|
|
436
440
|
}, Q = ({
|
|
437
|
-
date:
|
|
441
|
+
date: e,
|
|
438
442
|
setDate: a,
|
|
439
443
|
dateRange: t,
|
|
440
444
|
setDateRange: s,
|
|
441
445
|
onChange: i,
|
|
442
446
|
minDate: g,
|
|
443
|
-
maxDate:
|
|
447
|
+
maxDate: y,
|
|
444
448
|
input: v
|
|
445
449
|
}) => {
|
|
446
450
|
var u, n, c;
|
|
447
|
-
let h = new Date(
|
|
448
|
-
const b =
|
|
451
|
+
let h = new Date(e.getFullYear(), e.getMonth(), 1), r = h.getDay(), w = [];
|
|
452
|
+
const b = e.getMonth();
|
|
449
453
|
for (let d = 0; d < 42; d++) {
|
|
450
|
-
d === 0 &&
|
|
451
|
-
h.getDate() + (d -
|
|
454
|
+
d === 0 && r === 0 ? h.setDate(h.getDate() - 7) : d === 0 ? h.setDate(
|
|
455
|
+
h.getDate() + (d - r)
|
|
452
456
|
) : h.setDate(h.getDate() + 1);
|
|
453
|
-
let
|
|
457
|
+
let f = {
|
|
454
458
|
currentMonth: h.getMonth() === b,
|
|
455
459
|
date: new Date(h),
|
|
456
460
|
month: h.getMonth(),
|
|
457
461
|
number: h.getDate(),
|
|
458
462
|
selected: h.toDateString() === ((u = t.from) == null ? void 0 : u.toDateString()) || h.toDateString() === (((n = t.to) == null ? void 0 : n.toDateString()) || ((c = t.from) == null ? void 0 : c.toDateString())),
|
|
459
463
|
year: h.getFullYear(),
|
|
460
|
-
isDisabled: g && h < g ||
|
|
464
|
+
isDisabled: g && h < g || y && h > y
|
|
461
465
|
};
|
|
462
|
-
w.push(
|
|
466
|
+
w.push(f);
|
|
463
467
|
}
|
|
464
468
|
const k = (d) => {
|
|
465
469
|
a(d);
|
|
466
470
|
}, M = (d) => {
|
|
467
471
|
var o;
|
|
468
|
-
let
|
|
469
|
-
if (
|
|
470
|
-
|
|
472
|
+
let f = { ...t };
|
|
473
|
+
if (f.from && f.to)
|
|
474
|
+
f = { from: d, to: null };
|
|
471
475
|
else {
|
|
472
|
-
const p = ((o =
|
|
473
|
-
d.getTime() > p ?
|
|
476
|
+
const p = ((o = f.from) == null ? void 0 : o.getTime()) || 0;
|
|
477
|
+
d.getTime() > p ? f = { from: f.from, to: d } : f = { from: d, to: f.from };
|
|
474
478
|
}
|
|
475
|
-
s(
|
|
479
|
+
s(f), i(f);
|
|
476
480
|
};
|
|
477
481
|
return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
|
|
478
|
-
/* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((d,
|
|
479
|
-
/* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: w.map((d,
|
|
482
|
+
/* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((d, f) => /* @__PURE__ */ l("p", { children: d }, f)) }),
|
|
483
|
+
/* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: w.map((d, f) => {
|
|
480
484
|
var C;
|
|
481
485
|
const o = d.date.getTime() > t.from.getTime() && d.date.getTime() < (((C = t.to) == null ? void 0 : C.getTime()) || t.from.getTime()), p = d.isDisabled;
|
|
482
486
|
return /* @__PURE__ */ l(
|
|
@@ -495,23 +499,23 @@ const T = (r) => {
|
|
|
495
499
|
},
|
|
496
500
|
children: d.number
|
|
497
501
|
},
|
|
498
|
-
|
|
502
|
+
f
|
|
499
503
|
);
|
|
500
504
|
}) })
|
|
501
505
|
] });
|
|
502
506
|
}, X = ({
|
|
503
|
-
date:
|
|
507
|
+
date: e,
|
|
504
508
|
setDate: a,
|
|
505
509
|
filter: t,
|
|
506
510
|
setViews: s,
|
|
507
511
|
dateRange: i,
|
|
508
512
|
setDateRange: g,
|
|
509
|
-
onChange:
|
|
513
|
+
onChange: y,
|
|
510
514
|
minDate: v,
|
|
511
515
|
maxDate: h,
|
|
512
|
-
input:
|
|
516
|
+
input: r
|
|
513
517
|
}) => {
|
|
514
|
-
const w = i.from.getFullYear(), b =
|
|
518
|
+
const w = i.from.getFullYear(), b = e.getFullYear(), k = (u) => {
|
|
515
519
|
t ? (M(u), a(u)) : (s("days"), a(u));
|
|
516
520
|
}, M = (u) => {
|
|
517
521
|
var c;
|
|
@@ -522,11 +526,11 @@ const T = (r) => {
|
|
|
522
526
|
const d = ((c = n.from) == null ? void 0 : c.getTime()) || 0;
|
|
523
527
|
u.getTime() > d ? n = { from: n.from, to: u } : n = { from: u, to: n.from };
|
|
524
528
|
}
|
|
525
|
-
g(n),
|
|
529
|
+
g(n), y(n);
|
|
526
530
|
};
|
|
527
531
|
return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, n) => {
|
|
528
|
-
var
|
|
529
|
-
const c = new Date(b, n).getTime() > i.from.getTime() && new Date(b, n).getTime() < (((
|
|
532
|
+
var f, o, p;
|
|
533
|
+
const c = new Date(b, n).getTime() > i.from.getTime() && new Date(b, n).getTime() < (((f = i.to) == null ? void 0 : f.getTime()) || i.from.getTime()), d = v && new Date(b, n) < v || h && new Date(b, n) > h;
|
|
530
534
|
return /* @__PURE__ */ l(
|
|
531
535
|
"p",
|
|
532
536
|
{
|
|
@@ -536,7 +540,7 @@ const T = (r) => {
|
|
|
536
540
|
pointerEvents: d ? "none" : void 0,
|
|
537
541
|
cursor: d ? "not-allowed" : "pointer",
|
|
538
542
|
color: d ? "#ccc" : c ? "#b0b0b0" : "",
|
|
539
|
-
...
|
|
543
|
+
...r ? {} : { width: "100%" }
|
|
540
544
|
},
|
|
541
545
|
onClick: () => {
|
|
542
546
|
d || k(new Date(b, n));
|
|
@@ -546,24 +550,24 @@ const T = (r) => {
|
|
|
546
550
|
n
|
|
547
551
|
);
|
|
548
552
|
}) });
|
|
549
|
-
}, B = (
|
|
550
|
-
const a = Math.floor(
|
|
553
|
+
}, B = (e) => {
|
|
554
|
+
const a = Math.floor(e / 10) * 10, t = a + 10;
|
|
551
555
|
return { start: a, end: t };
|
|
552
556
|
}, Z = ({
|
|
553
|
-
date:
|
|
557
|
+
date: e,
|
|
554
558
|
filter: a,
|
|
555
559
|
setViews: t,
|
|
556
560
|
setDate: s,
|
|
557
561
|
dateRange: i,
|
|
558
562
|
setDateRange: g,
|
|
559
|
-
onChange:
|
|
563
|
+
onChange: y,
|
|
560
564
|
minDate: v,
|
|
561
565
|
maxDate: h,
|
|
562
|
-
input:
|
|
566
|
+
input: r
|
|
563
567
|
}) => {
|
|
564
|
-
var
|
|
568
|
+
var f;
|
|
565
569
|
let w = [];
|
|
566
|
-
const b =
|
|
570
|
+
const b = e.getFullYear(), { start: k, end: M } = B(b), u = i.from.getFullYear(), n = (f = i.to) == null ? void 0 : f.getFullYear();
|
|
567
571
|
for (let o = k; o < M; o++) {
|
|
568
572
|
const p = new Date(o, 0), C = (!v || p >= v) && (!h || p <= h), x = o === u || o === n, m = p > i.from && p < i.to;
|
|
569
573
|
w.push({
|
|
@@ -584,7 +588,7 @@ const T = (r) => {
|
|
|
584
588
|
const x = ((C = p.from) == null ? void 0 : C.getTime()) || 0;
|
|
585
589
|
o.getTime() > x ? p = { from: p.from, to: o } : p = { from: o, to: p.from };
|
|
586
590
|
}
|
|
587
|
-
g(p),
|
|
591
|
+
g(p), y(p);
|
|
588
592
|
};
|
|
589
593
|
return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((o, p) => /* @__PURE__ */ l(
|
|
590
594
|
"p",
|
|
@@ -598,13 +602,13 @@ const T = (r) => {
|
|
|
598
602
|
color: o.highlight ? "#b0b0b0" : o.active ? "" : o.disabled ? "#ccc" : "",
|
|
599
603
|
cursor: o.disabled ? "not-allowed" : "pointer",
|
|
600
604
|
pointerEvents: o.disbled ? "none" : "all",
|
|
601
|
-
...
|
|
605
|
+
...r ? {} : { width: "100%" }
|
|
602
606
|
},
|
|
603
607
|
children: o.year
|
|
604
608
|
},
|
|
605
609
|
p
|
|
606
610
|
)) });
|
|
607
|
-
}, q = ({ ...
|
|
611
|
+
}, q = ({ ...e }) => /* @__PURE__ */ l(
|
|
608
612
|
"svg",
|
|
609
613
|
{
|
|
610
614
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -612,7 +616,7 @@ const T = (r) => {
|
|
|
612
616
|
height: "20",
|
|
613
617
|
viewBox: "0 0 20 20",
|
|
614
618
|
fill: "none",
|
|
615
|
-
...
|
|
619
|
+
...e,
|
|
616
620
|
children: /* @__PURE__ */ l(
|
|
617
621
|
"path",
|
|
618
622
|
{
|
|
@@ -624,7 +628,7 @@ const T = (r) => {
|
|
|
624
628
|
}
|
|
625
629
|
)
|
|
626
630
|
}
|
|
627
|
-
), P = ({ ...
|
|
631
|
+
), P = ({ ...e }) => /* @__PURE__ */ l(
|
|
628
632
|
"svg",
|
|
629
633
|
{
|
|
630
634
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -632,7 +636,7 @@ const T = (r) => {
|
|
|
632
636
|
height: "20",
|
|
633
637
|
viewBox: "0 0 20 20",
|
|
634
638
|
fill: "none",
|
|
635
|
-
...
|
|
639
|
+
...e,
|
|
636
640
|
children: /* @__PURE__ */ l(
|
|
637
641
|
"path",
|
|
638
642
|
{
|
|
@@ -645,37 +649,37 @@ const T = (r) => {
|
|
|
645
649
|
)
|
|
646
650
|
}
|
|
647
651
|
), _ = ({
|
|
648
|
-
setViews:
|
|
652
|
+
setViews: e,
|
|
649
653
|
views: a,
|
|
650
654
|
filter: t,
|
|
651
655
|
date: s,
|
|
652
656
|
setDate: i
|
|
653
657
|
}) => {
|
|
654
658
|
const g = () => {
|
|
655
|
-
t ||
|
|
656
|
-
},
|
|
659
|
+
t || e((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
|
|
660
|
+
}, y = () => {
|
|
657
661
|
if (a === "years") {
|
|
658
|
-
i((
|
|
662
|
+
i((r) => new Date(r.getFullYear() + 10, 0));
|
|
659
663
|
return;
|
|
660
664
|
}
|
|
661
665
|
if (a === "months") {
|
|
662
|
-
i((
|
|
666
|
+
i((r) => new Date(r.getFullYear() + 1, r.getMonth()));
|
|
663
667
|
return;
|
|
664
668
|
}
|
|
665
|
-
i((
|
|
669
|
+
i((r) => new Date(r.getFullYear(), r.getMonth() + 1));
|
|
666
670
|
}, v = () => {
|
|
667
671
|
if (a === "years") {
|
|
668
|
-
i((
|
|
672
|
+
i((r) => new Date(r.getFullYear() - 10, 0));
|
|
669
673
|
return;
|
|
670
674
|
}
|
|
671
675
|
if (a === "months") {
|
|
672
|
-
i((
|
|
676
|
+
i((r) => new Date(r.getFullYear() - 1, r.getMonth()));
|
|
673
677
|
return;
|
|
674
678
|
}
|
|
675
679
|
i(
|
|
676
|
-
(
|
|
677
|
-
|
|
678
|
-
|
|
680
|
+
(r) => new Date(
|
|
681
|
+
r.getMonth() === 0 ? r.getFullYear() - 1 : r.getFullYear(),
|
|
682
|
+
r.getMonth() === 0 ? 11 : r.getMonth() - 1
|
|
679
683
|
)
|
|
680
684
|
);
|
|
681
685
|
};
|
|
@@ -689,43 +693,43 @@ const T = (r) => {
|
|
|
689
693
|
if (a === "years")
|
|
690
694
|
return `${B(s.getFullYear()).start} ~ ${B(s.getFullYear()).end}`;
|
|
691
695
|
})() }),
|
|
692
|
-
/* @__PURE__ */ l(P, { onClick: () =>
|
|
696
|
+
/* @__PURE__ */ l(P, { onClick: () => y() })
|
|
693
697
|
] });
|
|
694
698
|
};
|
|
695
|
-
function L(
|
|
696
|
-
const a = new Date(
|
|
699
|
+
function L(e) {
|
|
700
|
+
const a = new Date(e), t = a.getFullYear(), s = a.getMonth();
|
|
697
701
|
return `${a.getDate().toString().padStart(2, "0")} ${G[s]} ${t}`;
|
|
698
702
|
}
|
|
699
|
-
const z = "starasia-calendar-styles", aa = (
|
|
703
|
+
const z = "starasia-calendar-styles", aa = (e) => {
|
|
700
704
|
if (!document.getElementById(z)) {
|
|
701
705
|
const a = document.createElement("style");
|
|
702
|
-
a.id = z, a.textContent =
|
|
706
|
+
a.id = z, a.textContent = e, document.head.appendChild(a);
|
|
703
707
|
}
|
|
704
708
|
};
|
|
705
709
|
aa(I);
|
|
706
|
-
const
|
|
710
|
+
const ra = W(
|
|
707
711
|
({
|
|
708
|
-
value:
|
|
712
|
+
value: e,
|
|
709
713
|
onChange: a,
|
|
710
714
|
filter: t,
|
|
711
715
|
input: s = !0,
|
|
712
716
|
disabled: i,
|
|
713
717
|
minDate: g,
|
|
714
|
-
maxDate:
|
|
718
|
+
maxDate: y,
|
|
715
719
|
placeholder: v,
|
|
716
720
|
size: h,
|
|
717
|
-
status:
|
|
721
|
+
status: r
|
|
718
722
|
}, w) => {
|
|
719
|
-
const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d,
|
|
720
|
-
from: (
|
|
721
|
-
to: (
|
|
723
|
+
const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d, f] = F(/* @__PURE__ */ new Date()), [o, p] = F({
|
|
724
|
+
from: (e == null ? void 0 : e.from) || /* @__PURE__ */ new Date(),
|
|
725
|
+
to: (e == null ? void 0 : e.to) || /* @__PURE__ */ new Date()
|
|
722
726
|
});
|
|
723
727
|
D(() => {
|
|
724
|
-
|
|
728
|
+
e ? (f(e.from), p(e)) : (f(/* @__PURE__ */ new Date()), p({
|
|
725
729
|
from: /* @__PURE__ */ new Date(),
|
|
726
730
|
to: /* @__PURE__ */ new Date()
|
|
727
731
|
}));
|
|
728
|
-
}, [
|
|
732
|
+
}, [e]), D(() => {
|
|
729
733
|
t && c(t);
|
|
730
734
|
}, [t]), D(() => {
|
|
731
735
|
t || c("days");
|
|
@@ -734,7 +738,7 @@ const ea = W(
|
|
|
734
738
|
}, [s]);
|
|
735
739
|
const C = () => {
|
|
736
740
|
var m, Y;
|
|
737
|
-
if (!
|
|
741
|
+
if (!e)
|
|
738
742
|
return "";
|
|
739
743
|
if (t) {
|
|
740
744
|
if (n === "days")
|
|
@@ -778,7 +782,7 @@ const ea = W(
|
|
|
778
782
|
disabled: i,
|
|
779
783
|
placeholder: v,
|
|
780
784
|
size: h,
|
|
781
|
-
status:
|
|
785
|
+
status: r
|
|
782
786
|
}
|
|
783
787
|
) : null,
|
|
784
788
|
k ? /* @__PURE__ */ $(
|
|
@@ -794,27 +798,27 @@ const ea = W(
|
|
|
794
798
|
views: n,
|
|
795
799
|
filter: t,
|
|
796
800
|
date: d,
|
|
797
|
-
setDate:
|
|
801
|
+
setDate: f
|
|
798
802
|
}
|
|
799
803
|
),
|
|
800
804
|
/* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: n === "days" ? /* @__PURE__ */ l(
|
|
801
805
|
Q,
|
|
802
806
|
{
|
|
803
807
|
date: d,
|
|
804
|
-
setDate:
|
|
808
|
+
setDate: f,
|
|
805
809
|
setIsComponentVisible: M,
|
|
806
810
|
dateRange: o,
|
|
807
811
|
setDateRange: p,
|
|
808
812
|
input: s,
|
|
809
813
|
onChange: a,
|
|
810
814
|
minDate: g,
|
|
811
|
-
maxDate:
|
|
815
|
+
maxDate: y
|
|
812
816
|
}
|
|
813
817
|
) : n === "months" ? /* @__PURE__ */ l(
|
|
814
818
|
X,
|
|
815
819
|
{
|
|
816
820
|
date: d,
|
|
817
|
-
setDate:
|
|
821
|
+
setDate: f,
|
|
818
822
|
filter: t,
|
|
819
823
|
setViews: c,
|
|
820
824
|
dateRange: o,
|
|
@@ -823,13 +827,13 @@ const ea = W(
|
|
|
823
827
|
input: s,
|
|
824
828
|
onChange: a,
|
|
825
829
|
minDate: g,
|
|
826
|
-
maxDate:
|
|
830
|
+
maxDate: y
|
|
827
831
|
}
|
|
828
832
|
) : /* @__PURE__ */ l(
|
|
829
833
|
Z,
|
|
830
834
|
{
|
|
831
835
|
date: d,
|
|
832
|
-
setDate:
|
|
836
|
+
setDate: f,
|
|
833
837
|
filter: t,
|
|
834
838
|
setViews: c,
|
|
835
839
|
dateRange: o,
|
|
@@ -838,7 +842,7 @@ const ea = W(
|
|
|
838
842
|
input: s,
|
|
839
843
|
onChange: a,
|
|
840
844
|
minDate: g,
|
|
841
|
-
maxDate:
|
|
845
|
+
maxDate: y
|
|
842
846
|
}
|
|
843
847
|
) })
|
|
844
848
|
]
|
|
@@ -848,29 +852,29 @@ const ea = W(
|
|
|
848
852
|
}
|
|
849
853
|
);
|
|
850
854
|
}
|
|
851
|
-
), O = "starasia-calendar-input-styles",
|
|
855
|
+
), O = "starasia-calendar-input-styles", ea = (e) => {
|
|
852
856
|
if (!document.getElementById(O)) {
|
|
853
857
|
const a = document.createElement("style");
|
|
854
|
-
a.id = O, a.textContent =
|
|
858
|
+
a.id = O, a.textContent = e, document.head.appendChild(a);
|
|
855
859
|
}
|
|
856
860
|
};
|
|
857
|
-
|
|
858
|
-
const S = (
|
|
859
|
-
if (
|
|
861
|
+
ea(I);
|
|
862
|
+
const S = (e) => {
|
|
863
|
+
if (e === "sm")
|
|
860
864
|
return 16;
|
|
861
|
-
if (
|
|
865
|
+
if (e === "md")
|
|
862
866
|
return 16;
|
|
863
|
-
if (
|
|
867
|
+
if (e === "lg")
|
|
864
868
|
return 20;
|
|
865
|
-
}, na = (
|
|
866
|
-
const { size: a = "md", status: t = "default", variant: s = "outline", ...i } =
|
|
869
|
+
}, na = (e) => {
|
|
870
|
+
const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, g = E(null), y = () => {
|
|
867
871
|
g.current && i.onClick && (g.current.focus(), i.onClick(""));
|
|
868
872
|
};
|
|
869
873
|
return /* @__PURE__ */ $(
|
|
870
874
|
"div",
|
|
871
875
|
{
|
|
872
876
|
className: `starasia-calendar-input-container starasia-calendar-input-${s} starasia-calendar-input-container-${t} ${a} `,
|
|
873
|
-
onClick:
|
|
877
|
+
onClick: y,
|
|
874
878
|
children: [
|
|
875
879
|
/* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-left", children: /* @__PURE__ */ l(
|
|
876
880
|
"svg",
|
|
@@ -926,39 +930,39 @@ const S = (r) => {
|
|
|
926
930
|
}
|
|
927
931
|
);
|
|
928
932
|
}, ta = ({
|
|
929
|
-
date:
|
|
933
|
+
date: e,
|
|
930
934
|
setDate: a,
|
|
931
935
|
previewDate: t,
|
|
932
936
|
setPreviewDate: s,
|
|
933
937
|
setIsComponentVisible: i,
|
|
934
938
|
minDate: g,
|
|
935
|
-
maxDate:
|
|
939
|
+
maxDate: y,
|
|
936
940
|
input: v,
|
|
937
941
|
onChange: h
|
|
938
942
|
}) => {
|
|
939
|
-
let
|
|
943
|
+
let r = new Date(
|
|
940
944
|
t.getFullYear(),
|
|
941
945
|
t.getMonth(),
|
|
942
946
|
1
|
|
943
|
-
), w =
|
|
944
|
-
const k =
|
|
947
|
+
), w = r.getDay(), b = [];
|
|
948
|
+
const k = e.toDateString(), M = t.getMonth();
|
|
945
949
|
for (let n = 0; n < 42; n++) {
|
|
946
|
-
n === 0 && w === 0 ?
|
|
947
|
-
|
|
948
|
-
) :
|
|
950
|
+
n === 0 && w === 0 ? r.setDate(r.getDate() - 7) : n === 0 ? r.setDate(
|
|
951
|
+
r.getDate() + (n - w)
|
|
952
|
+
) : r.setDate(r.getDate() + 1);
|
|
949
953
|
let c = {
|
|
950
|
-
currentMonth:
|
|
951
|
-
date: new Date(
|
|
952
|
-
month:
|
|
953
|
-
number:
|
|
954
|
-
selected:
|
|
955
|
-
year:
|
|
956
|
-
isDisabled: g &&
|
|
954
|
+
currentMonth: r.getMonth() === M,
|
|
955
|
+
date: new Date(r),
|
|
956
|
+
month: r.getMonth(),
|
|
957
|
+
number: r.getDate(),
|
|
958
|
+
selected: r.toDateString() === k,
|
|
959
|
+
year: r.getFullYear(),
|
|
960
|
+
isDisabled: g && r < g || y && r > y
|
|
957
961
|
};
|
|
958
962
|
b.push(c);
|
|
959
963
|
}
|
|
960
964
|
const u = (n) => {
|
|
961
|
-
(!g || n >= g) && (!
|
|
965
|
+
(!g || n >= g) && (!y || n <= y) && (a(n), h(n), s(n), v && i(!1));
|
|
962
966
|
};
|
|
963
967
|
return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
|
|
964
968
|
/* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((n, c) => /* @__PURE__ */ l("p", { children: n }, c)) }),
|
|
@@ -984,19 +988,19 @@ const S = (r) => {
|
|
|
984
988
|
}) })
|
|
985
989
|
] });
|
|
986
990
|
}, sa = ({
|
|
987
|
-
date:
|
|
991
|
+
date: e,
|
|
988
992
|
setDate: a,
|
|
989
993
|
filter: t,
|
|
990
994
|
setViews: s,
|
|
991
995
|
onChange: i,
|
|
992
996
|
previewDate: g,
|
|
993
|
-
setPreviewDate:
|
|
997
|
+
setPreviewDate: y,
|
|
994
998
|
minDate: v,
|
|
995
999
|
maxDate: h,
|
|
996
|
-
input:
|
|
1000
|
+
input: r
|
|
997
1001
|
}) => {
|
|
998
|
-
const w =
|
|
999
|
-
(!v || u >= v) && (!h || u <= h) && (t ? (i(u), a(u),
|
|
1002
|
+
const w = e.getMonth(), b = e.getFullYear(), k = g.getFullYear(), M = (u) => {
|
|
1003
|
+
(!v || u >= v) && (!h || u <= h) && (t ? (i(u), a(u), y(u)) : (s("days"), y(u)));
|
|
1000
1004
|
};
|
|
1001
1005
|
return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, n) => {
|
|
1002
1006
|
const c = v && new Date(k, n, 1) < v || h && new Date(k, n + 1, 0) > h;
|
|
@@ -1008,7 +1012,7 @@ const S = (r) => {
|
|
|
1008
1012
|
color: c ? "#ccc" : void 0,
|
|
1009
1013
|
pointerEvents: c ? "none" : void 0,
|
|
1010
1014
|
cursor: c ? "not-allowed" : "pointer",
|
|
1011
|
-
...
|
|
1015
|
+
...r ? {} : { width: "100%" }
|
|
1012
1016
|
},
|
|
1013
1017
|
onClick: () => {
|
|
1014
1018
|
c || M(new Date(k, n));
|
|
@@ -1018,29 +1022,29 @@ const S = (r) => {
|
|
|
1018
1022
|
n
|
|
1019
1023
|
);
|
|
1020
1024
|
}) });
|
|
1021
|
-
}, V = (
|
|
1022
|
-
const a = Math.floor(
|
|
1025
|
+
}, V = (e) => {
|
|
1026
|
+
const a = Math.floor(e / 10) * 10, t = a + 10;
|
|
1023
1027
|
return { start: a, end: t };
|
|
1024
1028
|
}, ia = ({
|
|
1025
|
-
date:
|
|
1029
|
+
date: e,
|
|
1026
1030
|
filter: a,
|
|
1027
1031
|
setViews: t,
|
|
1028
1032
|
setDate: s,
|
|
1029
1033
|
onChange: i,
|
|
1030
1034
|
previewDate: g,
|
|
1031
|
-
setPreviewDate:
|
|
1035
|
+
setPreviewDate: y,
|
|
1032
1036
|
minDate: v,
|
|
1033
1037
|
maxDate: h,
|
|
1034
|
-
input:
|
|
1038
|
+
input: r
|
|
1035
1039
|
}) => {
|
|
1036
1040
|
let w = [];
|
|
1037
|
-
const b = g.getFullYear(), { start: k, end: M } = V(b), u =
|
|
1041
|
+
const b = g.getFullYear(), { start: k, end: M } = V(b), u = e.getFullYear();
|
|
1038
1042
|
for (let c = k; c < M; c++) {
|
|
1039
1043
|
let d = v && new Date(c, 0, 1) < v || h && new Date(c, 11, 31) > h;
|
|
1040
1044
|
w.push({ year: c, active: c === u, isDisabled: d });
|
|
1041
1045
|
}
|
|
1042
1046
|
const n = (c) => {
|
|
1043
|
-
(!v || c >= v) && (!h || c <= h) && (a ? (i(c), s(c),
|
|
1047
|
+
(!v || c >= v) && (!h || c <= h) && (a ? (i(c), s(c), y(c)) : (t("months"), y(c)));
|
|
1044
1048
|
};
|
|
1045
1049
|
return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((c, d) => /* @__PURE__ */ l(
|
|
1046
1050
|
"p",
|
|
@@ -1050,7 +1054,7 @@ const S = (r) => {
|
|
|
1050
1054
|
color: c.isDisabled ? "#ccc" : void 0,
|
|
1051
1055
|
pointerEvents: c.isDisabled ? "none" : void 0,
|
|
1052
1056
|
cursor: c.isDisabled ? "not-allowed" : "pointer",
|
|
1053
|
-
...
|
|
1057
|
+
...r ? {} : { width: "100%" }
|
|
1054
1058
|
},
|
|
1055
1059
|
onClick: () => {
|
|
1056
1060
|
c.isDisabled || n(new Date(c.year, 0));
|
|
@@ -1060,41 +1064,41 @@ const S = (r) => {
|
|
|
1060
1064
|
d
|
|
1061
1065
|
)) });
|
|
1062
1066
|
}, oa = ({
|
|
1063
|
-
setViews:
|
|
1067
|
+
setViews: e,
|
|
1064
1068
|
views: a,
|
|
1065
1069
|
filter: t,
|
|
1066
1070
|
previewDate: s,
|
|
1067
1071
|
setPreviewDate: i
|
|
1068
1072
|
}) => {
|
|
1069
1073
|
const g = () => {
|
|
1070
|
-
t ||
|
|
1071
|
-
},
|
|
1074
|
+
t || e((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
|
|
1075
|
+
}, y = () => {
|
|
1072
1076
|
if (a === "years") {
|
|
1073
|
-
i((
|
|
1077
|
+
i((r) => new Date(r.getFullYear() + 10, 0));
|
|
1074
1078
|
return;
|
|
1075
1079
|
}
|
|
1076
1080
|
if (a === "months") {
|
|
1077
1081
|
i(
|
|
1078
|
-
(
|
|
1082
|
+
(r) => new Date(r.getFullYear() + 1, r.getMonth())
|
|
1079
1083
|
);
|
|
1080
1084
|
return;
|
|
1081
1085
|
}
|
|
1082
|
-
i((
|
|
1086
|
+
i((r) => new Date(r.getFullYear(), r.getMonth() + 1));
|
|
1083
1087
|
}, v = () => {
|
|
1084
1088
|
if (a === "years") {
|
|
1085
|
-
i((
|
|
1089
|
+
i((r) => new Date(r.getFullYear() - 10, 0));
|
|
1086
1090
|
return;
|
|
1087
1091
|
}
|
|
1088
1092
|
if (a === "months") {
|
|
1089
1093
|
i(
|
|
1090
|
-
(
|
|
1094
|
+
(r) => new Date(r.getFullYear() - 1, r.getMonth())
|
|
1091
1095
|
);
|
|
1092
1096
|
return;
|
|
1093
1097
|
}
|
|
1094
1098
|
i(
|
|
1095
|
-
(
|
|
1096
|
-
|
|
1097
|
-
|
|
1099
|
+
(r) => new Date(
|
|
1100
|
+
r.getMonth() === 0 ? r.getFullYear() - 1 : r.getFullYear(),
|
|
1101
|
+
r.getMonth() === 0 ? 11 : r.getMonth() - 1
|
|
1098
1102
|
)
|
|
1099
1103
|
);
|
|
1100
1104
|
};
|
|
@@ -1108,39 +1112,39 @@ const S = (r) => {
|
|
|
1108
1112
|
if (a === "years")
|
|
1109
1113
|
return `${V(s.getFullYear()).start} ~ ${V(s.getFullYear()).end}`;
|
|
1110
1114
|
})() }),
|
|
1111
|
-
/* @__PURE__ */ l(P, { onClick: () =>
|
|
1115
|
+
/* @__PURE__ */ l(P, { onClick: () => y() })
|
|
1112
1116
|
] });
|
|
1113
|
-
}, H = "starasia-calendar-styles", la = (
|
|
1117
|
+
}, H = "starasia-calendar-styles", la = (e) => {
|
|
1114
1118
|
if (!document.getElementById(H)) {
|
|
1115
1119
|
const a = document.createElement("style");
|
|
1116
|
-
a.id = H, a.textContent =
|
|
1120
|
+
a.id = H, a.textContent = e, document.head.appendChild(a);
|
|
1117
1121
|
}
|
|
1118
1122
|
};
|
|
1119
1123
|
la(I);
|
|
1120
1124
|
const ca = W(
|
|
1121
1125
|
({
|
|
1122
|
-
value:
|
|
1126
|
+
value: e,
|
|
1123
1127
|
onChange: a,
|
|
1124
1128
|
filter: t,
|
|
1125
1129
|
input: s = !0,
|
|
1126
1130
|
disabled: i,
|
|
1127
1131
|
minDate: g,
|
|
1128
|
-
maxDate:
|
|
1132
|
+
maxDate: y,
|
|
1129
1133
|
placeholder: v,
|
|
1130
1134
|
size: h,
|
|
1131
|
-
status:
|
|
1135
|
+
status: r
|
|
1132
1136
|
}, w) => {
|
|
1133
|
-
const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d,
|
|
1137
|
+
const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d, f] = F(/* @__PURE__ */ new Date()), [o, p] = F(/* @__PURE__ */ new Date());
|
|
1134
1138
|
D(() => {
|
|
1135
|
-
|
|
1136
|
-
}, [
|
|
1139
|
+
e ? (f(e), p(e)) : (f(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
|
|
1140
|
+
}, [e]), D(() => {
|
|
1137
1141
|
t && c(t);
|
|
1138
1142
|
}, [t]), D(() => {
|
|
1139
1143
|
t || c("days");
|
|
1140
1144
|
}, [k]), D(() => {
|
|
1141
1145
|
s || M(!0);
|
|
1142
1146
|
}, [s]);
|
|
1143
|
-
const C = () =>
|
|
1147
|
+
const C = () => e ? t === "days" ? L(d) : t === "months" ? `${N[d.getMonth()]} ${d.getFullYear()}` : t === "years" ? d.getFullYear() : L(d) : "", x = () => {
|
|
1144
1148
|
if (u.current && b.current && s) {
|
|
1145
1149
|
const m = b.current.getBoundingClientRect(), Y = u.current.getBoundingClientRect();
|
|
1146
1150
|
window.innerWidth < m.left + Y.width ? u.current.style.left = `${m.left - Y.width + m.width}px` : u.current.style.left = `${m.left}px`, m.top + Y.height > window.innerHeight ? u.current.style.top = `${m.y - (m.height + Y.height - 28)}px` : u.current.style.top = `${m.y + m.height}px`;
|
|
@@ -1170,7 +1174,7 @@ const ca = W(
|
|
|
1170
1174
|
placeholder: v,
|
|
1171
1175
|
disabled: i,
|
|
1172
1176
|
size: h,
|
|
1173
|
-
status:
|
|
1177
|
+
status: r,
|
|
1174
1178
|
inputMode: "none"
|
|
1175
1179
|
}
|
|
1176
1180
|
) : null,
|
|
@@ -1195,41 +1199,41 @@ const ca = W(
|
|
|
1195
1199
|
ta,
|
|
1196
1200
|
{
|
|
1197
1201
|
date: d,
|
|
1198
|
-
setDate:
|
|
1202
|
+
setDate: f,
|
|
1199
1203
|
previewDate: o,
|
|
1200
1204
|
setPreviewDate: p,
|
|
1201
1205
|
setIsComponentVisible: M,
|
|
1202
1206
|
input: s,
|
|
1203
1207
|
minDate: g,
|
|
1204
|
-
maxDate:
|
|
1208
|
+
maxDate: y,
|
|
1205
1209
|
onChange: a
|
|
1206
1210
|
}
|
|
1207
1211
|
) : n === "months" ? /* @__PURE__ */ l(
|
|
1208
1212
|
sa,
|
|
1209
1213
|
{
|
|
1210
1214
|
date: d,
|
|
1211
|
-
setDate:
|
|
1215
|
+
setDate: f,
|
|
1212
1216
|
previewDate: o,
|
|
1213
1217
|
setPreviewDate: p,
|
|
1214
1218
|
filter: t,
|
|
1215
1219
|
setViews: c,
|
|
1216
1220
|
onChange: a,
|
|
1217
1221
|
minDate: g,
|
|
1218
|
-
maxDate:
|
|
1222
|
+
maxDate: y,
|
|
1219
1223
|
input: s
|
|
1220
1224
|
}
|
|
1221
1225
|
) : /* @__PURE__ */ l(
|
|
1222
1226
|
ia,
|
|
1223
1227
|
{
|
|
1224
1228
|
date: d,
|
|
1225
|
-
setDate:
|
|
1229
|
+
setDate: f,
|
|
1226
1230
|
previewDate: o,
|
|
1227
1231
|
setPreviewDate: p,
|
|
1228
1232
|
filter: t,
|
|
1229
1233
|
setViews: c,
|
|
1230
1234
|
onChange: a,
|
|
1231
1235
|
minDate: g,
|
|
1232
|
-
maxDate:
|
|
1236
|
+
maxDate: y,
|
|
1233
1237
|
input: s
|
|
1234
1238
|
}
|
|
1235
1239
|
) })
|
|
@@ -1242,45 +1246,45 @@ const ca = W(
|
|
|
1242
1246
|
}
|
|
1243
1247
|
), ha = W(
|
|
1244
1248
|
({
|
|
1245
|
-
value:
|
|
1249
|
+
value: e,
|
|
1246
1250
|
onChange: a,
|
|
1247
1251
|
filter: t,
|
|
1248
1252
|
input: s = !0,
|
|
1249
1253
|
rangedDate: i,
|
|
1250
1254
|
disabled: g,
|
|
1251
|
-
minDate:
|
|
1255
|
+
minDate: y,
|
|
1252
1256
|
maxDate: v,
|
|
1253
1257
|
placeholder: h,
|
|
1254
|
-
size:
|
|
1258
|
+
size: r,
|
|
1255
1259
|
status: w
|
|
1256
1260
|
}, b) => /* @__PURE__ */ l(R, { children: i ? /* @__PURE__ */ l(
|
|
1257
|
-
|
|
1261
|
+
ra,
|
|
1258
1262
|
{
|
|
1259
1263
|
onChange: a,
|
|
1260
|
-
value:
|
|
1264
|
+
value: e,
|
|
1261
1265
|
input: s,
|
|
1262
1266
|
filter: t,
|
|
1263
1267
|
disabled: g,
|
|
1264
1268
|
ref: b,
|
|
1265
|
-
minDate:
|
|
1269
|
+
minDate: y,
|
|
1266
1270
|
maxDate: v,
|
|
1267
1271
|
placeholder: h,
|
|
1268
|
-
size:
|
|
1272
|
+
size: r,
|
|
1269
1273
|
status: w
|
|
1270
1274
|
}
|
|
1271
1275
|
) : /* @__PURE__ */ l(
|
|
1272
1276
|
ca,
|
|
1273
1277
|
{
|
|
1274
1278
|
onChange: a,
|
|
1275
|
-
value:
|
|
1279
|
+
value: e,
|
|
1276
1280
|
input: s,
|
|
1277
1281
|
filter: t,
|
|
1278
1282
|
disabled: g,
|
|
1279
1283
|
ref: b,
|
|
1280
|
-
minDate:
|
|
1284
|
+
minDate: y,
|
|
1281
1285
|
maxDate: v,
|
|
1282
1286
|
placeholder: h,
|
|
1283
|
-
size:
|
|
1287
|
+
size: r,
|
|
1284
1288
|
status: w
|
|
1285
1289
|
}
|
|
1286
1290
|
) })
|
package/dist/date.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(Y,
|
|
1
|
+
(function(Y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(Y=typeof globalThis<"u"?globalThis:Y||self,e(Y.Date={},Y.jsxRuntime,Y.React))})(this,function(Y,e,m){"use strict";const N=`@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");
|
|
2
2
|
|
|
3
3
|
* {
|
|
4
4
|
margin: 0;
|
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
/* color */
|
|
18
18
|
--starasia-ui-date-color-black-secondary: var(
|
|
19
19
|
--starasia-ui-color-gray-50,
|
|
20
|
-
|
|
20
|
+
rgba(249, 250, 251, 1)
|
|
21
21
|
);
|
|
22
|
+
--starasia-ui-date-color-white: var(--starasia-ui-color-gray-50, rgba(255, 254, 255, 1));
|
|
23
|
+
--starasia-ui-date-color-border: rgba(120, 134, 127, 0.2);
|
|
24
|
+
--starasia-ui-date-color-disabled-border: rgba(120, 134, 127, 0.2);
|
|
25
|
+
--starasia-ui-date-color-disabled-bg: rgba(120, 134, 127, 0.1);
|
|
22
26
|
|
|
23
27
|
/* box shadow */
|
|
24
28
|
--starasia-ui-date-box-shadow: var(
|
|
@@ -31,26 +35,26 @@
|
|
|
31
35
|
/* gray / black */
|
|
32
36
|
--starasia-ui-date-color-primary-black: var(
|
|
33
37
|
--starasia-ui-color-gray-700,
|
|
34
|
-
|
|
38
|
+
rgba(55, 65, 81, 1)
|
|
35
39
|
);
|
|
36
40
|
--starasia-ui-date-color-secondary-black: var(
|
|
37
41
|
--starasia-ui-color-gray-500,
|
|
38
|
-
|
|
42
|
+
rgba(107, 114, 128, 1)
|
|
39
43
|
);
|
|
40
44
|
--starasia-ui-date-color-tertiary-black: var(
|
|
41
45
|
--starasia-ui-color-gray-300,
|
|
42
|
-
|
|
46
|
+
rgba(209, 213, 219, 1)
|
|
43
47
|
);
|
|
44
48
|
--starasia-ui-date-color-quaternary-black: var(
|
|
45
49
|
--starasia-ui-color-gray-50,
|
|
46
|
-
|
|
50
|
+
rgba(249, 250, 251, 1)
|
|
47
51
|
);
|
|
48
52
|
|
|
49
53
|
/* brand */
|
|
50
|
-
--starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default);
|
|
51
|
-
--starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default);
|
|
52
|
-
--starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
|
|
53
|
-
--starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
54
|
+
--starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
|
|
55
|
+
--starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
|
|
56
|
+
--starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary, rgba(144, 176, 218, 1));
|
|
57
|
+
--starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary, rgba(227, 237, 248, 1));
|
|
54
58
|
|
|
55
59
|
/* spacing */
|
|
56
60
|
--starasia-ui-date-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
|
|
@@ -68,12 +72,12 @@
|
|
|
68
72
|
/* color */
|
|
69
73
|
--starasia-ui-input-color-tertiary-gray: var(
|
|
70
74
|
--starasia-ui-color-gray-300,
|
|
71
|
-
|
|
75
|
+
rgba(209, 213, 219, 1)
|
|
72
76
|
);
|
|
73
77
|
|
|
74
78
|
--starasia-ui-date-placholder-color: var(
|
|
75
79
|
--starasia-ui-color-gray-200,
|
|
76
|
-
|
|
80
|
+
rgba(201, 206, 204, 1)
|
|
77
81
|
);
|
|
78
82
|
--starasia-ui-date-placholder-fontWeight: var(
|
|
79
83
|
--starasia-ui-fontWeights-normal,
|
|
@@ -82,11 +86,11 @@
|
|
|
82
86
|
|
|
83
87
|
--starasia-ui-input-color-secondary-red: var(
|
|
84
88
|
--starasia-ui-color-red-500,
|
|
85
|
-
|
|
89
|
+
rgba(239, 68, 68, 1)
|
|
86
90
|
);
|
|
87
91
|
--starasia-ui-input-color-secondary-yellow: var(
|
|
88
92
|
--starasia-ui-color-yellow-500,
|
|
89
|
-
|
|
93
|
+
rgba(234, 179, 8, 1)
|
|
90
94
|
);
|
|
91
95
|
}
|
|
92
96
|
.starasia-calendar-wrapper {
|
|
@@ -116,7 +120,7 @@
|
|
|
116
120
|
width: 100%;
|
|
117
121
|
box-shadow: unset;
|
|
118
122
|
border: none;
|
|
119
|
-
background-color: white;
|
|
123
|
+
background-color: var(--starasia-ui-date-color-white);
|
|
120
124
|
/* background-color: white; */
|
|
121
125
|
height: 100%;
|
|
122
126
|
border-radius: 0;
|
|
@@ -242,18 +246,18 @@
|
|
|
242
246
|
|
|
243
247
|
.starasia-calendar-input-container:has(input:focus) {
|
|
244
248
|
border-color: var(--starasia-ui-date-color-primary-blue);
|
|
245
|
-
box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary), 0.2);
|
|
249
|
+
box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary, 144, 176, 218), 0.2);
|
|
246
250
|
}
|
|
247
251
|
.starasia-calendar-input-container:has(input:disabled) {
|
|
248
252
|
/* border-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
249
253
|
/* background-color: var(--starasia-ui-input-color-tertiary-gray); */
|
|
250
|
-
border-color:
|
|
251
|
-
background-color:
|
|
254
|
+
border-color: var(--starasia-ui-date-color-disabled-border);
|
|
255
|
+
background-color: var(--starasia-ui-date-color-disabled-bg);
|
|
252
256
|
pointer-events: none;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
.starasia-calendar-input-outline {
|
|
256
|
-
border-color:
|
|
260
|
+
border-color: var(--starasia-ui-date-color-border);
|
|
257
261
|
/* border-color: var(--starasia-ui-date-color-tertiary-black); */
|
|
258
262
|
background-color: transparent;
|
|
259
263
|
border-width: var(--starasia-ui-border, 1px);
|
|
@@ -319,4 +323,4 @@
|
|
|
319
323
|
.starasia-calendar-input-container-warning {
|
|
320
324
|
border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
|
|
321
325
|
}
|
|
322
|
-
`,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(n){const[a,s]=m.useState(n),i=m.useRef(null),o=g=>{i.current&&!i.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:i,isComponentVisible:a,setIsComponentVisible:s}}const V="starasia-calendar-input-styles";(n=>{if(!document.getElementById(V)){const a=document.createElement("style");a.id=V,a.textContent=n,document.head.appendChild(a)}})(N);const S=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},J=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return r.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[r.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("div",{className:"starasia-calendar-input-preview-container",children:r.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),r.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},P=({date:n,setDate:a,dateRange:s,setDateRange:i,onChange:o,minDate:g,maxDate:f,input:w})=>{var u,t,c;let h=new Date(n.getFullYear(),n.getMonth(),1),e=h.getDay(),k=[];const v=n.getMonth();for(let d=0;d<42;d++){d===0&&e===0?h.setDate(h.getDate()-7):d===0?h.setDate(h.getDate()+(d-e)):h.setDate(h.getDate()+1);let y={currentMonth:h.getMonth()===v,date:new Date(h),month:h.getMonth(),number:h.getDate(),selected:h.toDateString()===((u=s.from)==null?void 0:u.toDateString())||h.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((c=s.from)==null?void 0:c.toDateString())),year:h.getFullYear(),isDisabled:g&&h<g||f&&h>f};k.push(y)}const M=d=>{a(d)},x=d=>{var l;let y={...s};if(y.from&&y.to)y={from:d,to:null};else{const p=((l=y.from)==null?void 0:l.getTime())||0;d.getTime()>p?y={from:y.from,to:d}:y={from:d,to:y.from}}i(y),o(y)};return r.jsxs("div",{className:"starasia-calendar-days-preivew",children:[r.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((d,y)=>r.jsx("p",{children:d},y))}),r.jsx("div",{className:"starasia-calendar-days-number-preivew",children:k.map((d,y)=>{var D;const l=d.date.getTime()>s.from.getTime()&&d.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),p=d.isDisabled;return r.jsx("p",{className:`${d.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${d.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:l?"rgba(100, 181, 246, 0.1)":"",pointerEvents:p?"none":void 0,cursor:p?"not-allowed":"pointer",color:p?"#ccc":l?"#b0b0b0":"",...w?{}:{width:"100%"}},onClick:()=>{p||(M(d.date),x(d.date))},children:d.number},y)})})]})},G=({date:n,setDate:a,filter:s,setViews:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:e})=>{const k=o.from.getFullYear(),v=n.getFullYear(),M=u=>{s?(x(u),a(u)):(i("days"),a(u))},x=u=>{var c;let t={...o};if(t.from&&t.to)t={from:u,to:null};else{const d=((c=t.from)==null?void 0:c.getTime())||0;u.getTime()>d?t={from:t.from,to:u}:t={from:u,to:t.from}}g(t),f(t)};return r.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{var y,l,p;const c=new Date(v,t).getTime()>o.from.getTime()&&new Date(v,t).getTime()<(((y=o.to)==null?void 0:y.getTime())||o.from.getTime()),d=w&&new Date(v,t)<w||h&&new Date(v,t)>h;return r.jsx("p",{className:k===v&&(t===((l=o.from)==null?void 0:l.getMonth())||t===((p=o.to)==null?void 0:p.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:c?"rgba(100, 181, 246, 0.1)":"",pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",color:d?"#ccc":c?"#b0b0b0":"",...e?{}:{width:"100%"}},onClick:()=>{d||M(new Date(v,t))},children:u.slice(0,3)},t)})})},T=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},U=({date:n,filter:a,setViews:s,setDate:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:e})=>{var y;let k=[];const v=n.getFullYear(),{start:M,end:x}=T(v),u=o.from.getFullYear(),t=(y=o.to)==null?void 0:y.getFullYear();for(let l=M;l<x;l++){const p=new Date(l,0),D=(!w||p>=w)&&(!h||p<=h),C=l===u||l===t,b=p>o.from&&p<o.to;k.push({year:l,active:C&&D,highlight:b&&D,disabled:!D})}const c=l=>{a?(d(l),i(l)):(i(l),s("months"))},d=l=>{var D;let p={...o};if(p.from&&p.to)p={from:l,to:null};else{const C=((D=p.from)==null?void 0:D.getTime())||0;l.getTime()>C?p={from:p.from,to:l}:p={from:l,to:p.from}}g(p),f(p)};return r.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((l,p)=>r.jsx("p",{className:`${l.active?"starasia-calendar-months-active":""} ${l.highlight?"starasia-calendar-months-highlight":""} ${l.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{l.disabled||c(new Date(l.year,0))},style:{backgroundColor:l.highlight?"rgba(100, 181, 246, 0.1)":"",color:l.highlight?"#b0b0b0":l.active?"":l.disabled?"#ccc":"",cursor:l.disabled?"not-allowed":"pointer",pointerEvents:l.disbled?"none":"all",...e?{}:{width:"100%"}},children:l.year},p))})},W=({...n})=>r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:r.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),z=({...n})=>r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:r.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:n,views:a,filter:s,date:i,setDate:o})=>{const g=()=>{s||n(e=>e==="days"?"months":e==="months"?"years":"days")},f=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()+10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()+1,e.getMonth()));return}o(e=>new Date(e.getFullYear(),e.getMonth()+1))},w=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()-10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()-1,e.getMonth()));return}o(e=>new Date(e.getMonth()===0?e.getFullYear()-1:e.getFullYear(),e.getMonth()===0?11:e.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${T(i.getFullYear()).start} ~ ${T(i.getFullYear()).end}`};return r.jsxs("div",{className:"starasia-calendar-header",children:[r.jsx(W,{onClick:()=>w()}),r.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),r.jsx(z,{onClick:()=>f()})]})};function E(n){const a=new Date(n),s=a.getFullYear(),i=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${q[i]} ${s}`}const O="starasia-calendar-styles";(n=>{if(!document.getElementById(O)){const a=document.createElement("style");a.id=O,a.textContent=n,document.head.appendChild(a)}})(N);const Q=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:e},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState({from:(n==null?void 0:n.from)||new Date,to:(n==null?void 0:n.to)||new Date});m.useEffect(()=>{n?(y(n.from),p(n)):(y(new Date),p({from:new Date,to:new Date}))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>{var b,$;if(!n)return"";if(s){if(t==="days")return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`;if(t==="months")return`${F[l.from.getMonth()]} ~ ${l.to?F[l.to.getMonth()]:"-"}`;if(t==="years")return`${(b=l.from)==null?void 0:b.getFullYear()} ~ ${(($=l.to)==null?void 0:$.getFullYear())||"-"}`}else return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`},C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),r.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?r.jsx(J,{value:D(),inputMode:"none",onClick:()=>{x(!0)},onChange:()=>{},disabled:o,placeholder:w,size:h,status:e}):null,M?r.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[r.jsx(K,{setViews:c,views:t,filter:s,date:d,setDate:y}),r.jsx("div",{className:"starasia-calendar-body",children:t==="days"?r.jsx(P,{date:d,setDate:y,setIsComponentVisible:x,dateRange:l,setDateRange:p,input:i,onChange:a,minDate:g,maxDate:f}):t==="months"?r.jsx(G,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f}):r.jsx(U,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f})})]}):null]})}),H="starasia-calendar-input-styles";(n=>{if(!document.getElementById(H)){const a=document.createElement("style");a.id=H,a.textContent=n,document.head.appendChild(a)}})(N);const L=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},X=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return r.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[r.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("div",{className:"starasia-calendar-input-preview-container",children:r.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),r.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:n,setDate:a,previewDate:s,setPreviewDate:i,setIsComponentVisible:o,minDate:g,maxDate:f,input:w,onChange:h})=>{let e=new Date(s.getFullYear(),s.getMonth(),1),k=e.getDay(),v=[];const M=n.toDateString(),x=s.getMonth();for(let t=0;t<42;t++){t===0&&k===0?e.setDate(e.getDate()-7):t===0?e.setDate(e.getDate()+(t-k)):e.setDate(e.getDate()+1);let c={currentMonth:e.getMonth()===x,date:new Date(e),month:e.getMonth(),number:e.getDate(),selected:e.toDateString()===M,year:e.getFullYear(),isDisabled:g&&e<g||f&&e>f};v.push(c)}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(a(t),h(t),i(t),w&&o(!1))};return r.jsxs("div",{className:"starasia-calendar-days-preivew",children:[r.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((t,c)=>r.jsx("p",{children:t},c))}),r.jsx("div",{className:"starasia-calendar-days-number-preivew",children:v.map((t,c)=>{const d=t.isDisabled;return r.jsx("p",{className:`${t.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${t.selected?"starasia-calendar-days-active":""}`,style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{d||u(t.date)},children:t.number},c)})})]})},_=({date:n,setDate:a,filter:s,setViews:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:e})=>{const k=n.getMonth(),v=n.getFullYear(),M=g.getFullYear(),x=u=>{(!w||u>=w)&&(!h||u<=h)&&(s?(o(u),a(u),f(u)):(i("days"),f(u)))};return r.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{const c=w&&new Date(M,t,1)<w||h&&new Date(M,t+1,0)>h;return r.jsx("p",{className:t===k&&M===v?"starasia-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...e?{}:{width:"100%"}},onClick:()=>{c||x(new Date(M,t))},children:u.slice(0,3)},t)})})},I=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},R=({date:n,filter:a,setViews:s,setDate:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:e})=>{let k=[];const v=g.getFullYear(),{start:M,end:x}=I(v),u=n.getFullYear();for(let c=M;c<x;c++){let d=w&&new Date(c,0,1)<w||h&&new Date(c,11,31)>h;k.push({year:c,active:c===u,isDisabled:d})}const t=c=>{(!w||c>=w)&&(!h||c<=h)&&(a?(o(c),i(c),f(c)):(s("months"),f(c)))};return r.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((c,d)=>r.jsx("p",{className:c.active?"starasia-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...e?{}:{width:"100%"}},onClick:()=>{c.isDisabled||t(new Date(c.year,0))},children:c.year},d))})},aa=({setViews:n,views:a,filter:s,previewDate:i,setPreviewDate:o})=>{const g=()=>{s||n(e=>e==="days"?"months":e==="months"?"years":"days")},f=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()+10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()+1,e.getMonth()));return}o(e=>new Date(e.getFullYear(),e.getMonth()+1))},w=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()-10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()-1,e.getMonth()));return}o(e=>new Date(e.getMonth()===0?e.getFullYear()-1:e.getFullYear(),e.getMonth()===0?11:e.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${I(i.getFullYear()).start} ~ ${I(i.getFullYear()).end}`};return r.jsxs("div",{className:"starasia-calendar-header",children:[r.jsx(W,{onClick:()=>w()}),r.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),r.jsx(z,{onClick:()=>f()})]})},A="starasia-calendar-styles";(n=>{if(!document.getElementById(A)){const a=document.createElement("style");a.id=A,a.textContent=n,document.head.appendChild(a)}})(N);const ea=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:e},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState(new Date);m.useEffect(()=>{n?(y(n),p(n)):(y(new Date),p(new Date))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>n?s==="days"?E(d):s==="months"?`${F[d.getMonth()]} ${d.getFullYear()}`:s==="years"?d.getFullYear():E(d):"",C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),r.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?r.jsx(X,{value:D(),onClick:()=>x(!0),onChange:()=>{},placeholder:w,disabled:o,size:h,status:e,inputMode:"none"}):null,M?r.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[r.jsx(aa,{setViews:c,views:t,filter:s,previewDate:l,setPreviewDate:p,isComponentVisible:M}),r.jsx("div",{className:"starasia-calendar-body",children:t==="days"?r.jsx(Z,{date:d,setDate:y,previewDate:l,setPreviewDate:p,setIsComponentVisible:x,input:i,minDate:g,maxDate:f,onChange:a}):t==="months"?r.jsx(_,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i}):r.jsx(R,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i})})]}):null]})}),ra=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,rangedDate:o,disabled:g,minDate:f,maxDate:w,placeholder:h,size:e,status:k},v)=>r.jsx(r.Fragment,{children:o?r.jsx(Q,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:e,status:k}):r.jsx(ea,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:e,status:k})}));Y.StarasiaDate=ra,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|
|
326
|
+
`,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(n){const[a,s]=m.useState(n),i=m.useRef(null),o=g=>{i.current&&!i.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:i,isComponentVisible:a,setIsComponentVisible:s}}const V="starasia-calendar-input-styles";(n=>{if(!document.getElementById(V)){const a=document.createElement("style");a.id=V,a.textContent=n,document.head.appendChild(a)}})(N);const S=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},J=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return e.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[e.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"starasia-calendar-input-preview-container",children:e.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),e.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},P=({date:n,setDate:a,dateRange:s,setDateRange:i,onChange:o,minDate:g,maxDate:f,input:w})=>{var u,t,c;let h=new Date(n.getFullYear(),n.getMonth(),1),r=h.getDay(),k=[];const v=n.getMonth();for(let d=0;d<42;d++){d===0&&r===0?h.setDate(h.getDate()-7):d===0?h.setDate(h.getDate()+(d-r)):h.setDate(h.getDate()+1);let y={currentMonth:h.getMonth()===v,date:new Date(h),month:h.getMonth(),number:h.getDate(),selected:h.toDateString()===((u=s.from)==null?void 0:u.toDateString())||h.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((c=s.from)==null?void 0:c.toDateString())),year:h.getFullYear(),isDisabled:g&&h<g||f&&h>f};k.push(y)}const M=d=>{a(d)},x=d=>{var l;let y={...s};if(y.from&&y.to)y={from:d,to:null};else{const p=((l=y.from)==null?void 0:l.getTime())||0;d.getTime()>p?y={from:y.from,to:d}:y={from:d,to:y.from}}i(y),o(y)};return e.jsxs("div",{className:"starasia-calendar-days-preivew",children:[e.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((d,y)=>e.jsx("p",{children:d},y))}),e.jsx("div",{className:"starasia-calendar-days-number-preivew",children:k.map((d,y)=>{var D;const l=d.date.getTime()>s.from.getTime()&&d.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),p=d.isDisabled;return e.jsx("p",{className:`${d.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${d.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:l?"rgba(100, 181, 246, 0.1)":"",pointerEvents:p?"none":void 0,cursor:p?"not-allowed":"pointer",color:p?"#ccc":l?"#b0b0b0":"",...w?{}:{width:"100%"}},onClick:()=>{p||(M(d.date),x(d.date))},children:d.number},y)})})]})},G=({date:n,setDate:a,filter:s,setViews:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:r})=>{const k=o.from.getFullYear(),v=n.getFullYear(),M=u=>{s?(x(u),a(u)):(i("days"),a(u))},x=u=>{var c;let t={...o};if(t.from&&t.to)t={from:u,to:null};else{const d=((c=t.from)==null?void 0:c.getTime())||0;u.getTime()>d?t={from:t.from,to:u}:t={from:u,to:t.from}}g(t),f(t)};return e.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{var y,l,p;const c=new Date(v,t).getTime()>o.from.getTime()&&new Date(v,t).getTime()<(((y=o.to)==null?void 0:y.getTime())||o.from.getTime()),d=w&&new Date(v,t)<w||h&&new Date(v,t)>h;return e.jsx("p",{className:k===v&&(t===((l=o.from)==null?void 0:l.getMonth())||t===((p=o.to)==null?void 0:p.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:c?"rgba(100, 181, 246, 0.1)":"",pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",color:d?"#ccc":c?"#b0b0b0":"",...r?{}:{width:"100%"}},onClick:()=>{d||M(new Date(v,t))},children:u.slice(0,3)},t)})})},T=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},U=({date:n,filter:a,setViews:s,setDate:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:r})=>{var y;let k=[];const v=n.getFullYear(),{start:M,end:x}=T(v),u=o.from.getFullYear(),t=(y=o.to)==null?void 0:y.getFullYear();for(let l=M;l<x;l++){const p=new Date(l,0),D=(!w||p>=w)&&(!h||p<=h),C=l===u||l===t,b=p>o.from&&p<o.to;k.push({year:l,active:C&&D,highlight:b&&D,disabled:!D})}const c=l=>{a?(d(l),i(l)):(i(l),s("months"))},d=l=>{var D;let p={...o};if(p.from&&p.to)p={from:l,to:null};else{const C=((D=p.from)==null?void 0:D.getTime())||0;l.getTime()>C?p={from:p.from,to:l}:p={from:l,to:p.from}}g(p),f(p)};return e.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((l,p)=>e.jsx("p",{className:`${l.active?"starasia-calendar-months-active":""} ${l.highlight?"starasia-calendar-months-highlight":""} ${l.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{l.disabled||c(new Date(l.year,0))},style:{backgroundColor:l.highlight?"rgba(100, 181, 246, 0.1)":"",color:l.highlight?"#b0b0b0":l.active?"":l.disabled?"#ccc":"",cursor:l.disabled?"not-allowed":"pointer",pointerEvents:l.disbled?"none":"all",...r?{}:{width:"100%"}},children:l.year},p))})},W=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),z=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:n,views:a,filter:s,date:i,setDate:o})=>{const g=()=>{s||n(r=>r==="days"?"months":r==="months"?"years":"days")},f=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()+10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()+1,r.getMonth()));return}o(r=>new Date(r.getFullYear(),r.getMonth()+1))},w=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()-10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()-1,r.getMonth()));return}o(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${T(i.getFullYear()).start} ~ ${T(i.getFullYear()).end}`};return e.jsxs("div",{className:"starasia-calendar-header",children:[e.jsx(W,{onClick:()=>w()}),e.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),e.jsx(z,{onClick:()=>f()})]})};function E(n){const a=new Date(n),s=a.getFullYear(),i=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${q[i]} ${s}`}const O="starasia-calendar-styles";(n=>{if(!document.getElementById(O)){const a=document.createElement("style");a.id=O,a.textContent=n,document.head.appendChild(a)}})(N);const Q=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:r},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState({from:(n==null?void 0:n.from)||new Date,to:(n==null?void 0:n.to)||new Date});m.useEffect(()=>{n?(y(n.from),p(n)):(y(new Date),p({from:new Date,to:new Date}))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>{var b,$;if(!n)return"";if(s){if(t==="days")return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`;if(t==="months")return`${F[l.from.getMonth()]} ~ ${l.to?F[l.to.getMonth()]:"-"}`;if(t==="years")return`${(b=l.from)==null?void 0:b.getFullYear()} ~ ${(($=l.to)==null?void 0:$.getFullYear())||"-"}`}else return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`},C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),e.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?e.jsx(J,{value:D(),inputMode:"none",onClick:()=>{x(!0)},onChange:()=>{},disabled:o,placeholder:w,size:h,status:r}):null,M?e.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[e.jsx(K,{setViews:c,views:t,filter:s,date:d,setDate:y}),e.jsx("div",{className:"starasia-calendar-body",children:t==="days"?e.jsx(P,{date:d,setDate:y,setIsComponentVisible:x,dateRange:l,setDateRange:p,input:i,onChange:a,minDate:g,maxDate:f}):t==="months"?e.jsx(G,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f}):e.jsx(U,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f})})]}):null]})}),H="starasia-calendar-input-styles";(n=>{if(!document.getElementById(H)){const a=document.createElement("style");a.id=H,a.textContent=n,document.head.appendChild(a)}})(N);const L=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},X=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return e.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[e.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"starasia-calendar-input-preview-container",children:e.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),e.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:n,setDate:a,previewDate:s,setPreviewDate:i,setIsComponentVisible:o,minDate:g,maxDate:f,input:w,onChange:h})=>{let r=new Date(s.getFullYear(),s.getMonth(),1),k=r.getDay(),v=[];const M=n.toDateString(),x=s.getMonth();for(let t=0;t<42;t++){t===0&&k===0?r.setDate(r.getDate()-7):t===0?r.setDate(r.getDate()+(t-k)):r.setDate(r.getDate()+1);let c={currentMonth:r.getMonth()===x,date:new Date(r),month:r.getMonth(),number:r.getDate(),selected:r.toDateString()===M,year:r.getFullYear(),isDisabled:g&&r<g||f&&r>f};v.push(c)}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(a(t),h(t),i(t),w&&o(!1))};return e.jsxs("div",{className:"starasia-calendar-days-preivew",children:[e.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((t,c)=>e.jsx("p",{children:t},c))}),e.jsx("div",{className:"starasia-calendar-days-number-preivew",children:v.map((t,c)=>{const d=t.isDisabled;return e.jsx("p",{className:`${t.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${t.selected?"starasia-calendar-days-active":""}`,style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{d||u(t.date)},children:t.number},c)})})]})},_=({date:n,setDate:a,filter:s,setViews:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:r})=>{const k=n.getMonth(),v=n.getFullYear(),M=g.getFullYear(),x=u=>{(!w||u>=w)&&(!h||u<=h)&&(s?(o(u),a(u),f(u)):(i("days"),f(u)))};return e.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{const c=w&&new Date(M,t,1)<w||h&&new Date(M,t+1,0)>h;return e.jsx("p",{className:t===k&&M===v?"starasia-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{c||x(new Date(M,t))},children:u.slice(0,3)},t)})})},I=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},R=({date:n,filter:a,setViews:s,setDate:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:r})=>{let k=[];const v=g.getFullYear(),{start:M,end:x}=I(v),u=n.getFullYear();for(let c=M;c<x;c++){let d=w&&new Date(c,0,1)<w||h&&new Date(c,11,31)>h;k.push({year:c,active:c===u,isDisabled:d})}const t=c=>{(!w||c>=w)&&(!h||c<=h)&&(a?(o(c),i(c),f(c)):(s("months"),f(c)))};return e.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((c,d)=>e.jsx("p",{className:c.active?"starasia-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{c.isDisabled||t(new Date(c.year,0))},children:c.year},d))})},aa=({setViews:n,views:a,filter:s,previewDate:i,setPreviewDate:o})=>{const g=()=>{s||n(r=>r==="days"?"months":r==="months"?"years":"days")},f=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()+10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()+1,r.getMonth()));return}o(r=>new Date(r.getFullYear(),r.getMonth()+1))},w=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()-10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()-1,r.getMonth()));return}o(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${I(i.getFullYear()).start} ~ ${I(i.getFullYear()).end}`};return e.jsxs("div",{className:"starasia-calendar-header",children:[e.jsx(W,{onClick:()=>w()}),e.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),e.jsx(z,{onClick:()=>f()})]})},A="starasia-calendar-styles";(n=>{if(!document.getElementById(A)){const a=document.createElement("style");a.id=A,a.textContent=n,document.head.appendChild(a)}})(N);const ra=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:r},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState(new Date);m.useEffect(()=>{n?(y(n),p(n)):(y(new Date),p(new Date))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>n?s==="days"?E(d):s==="months"?`${F[d.getMonth()]} ${d.getFullYear()}`:s==="years"?d.getFullYear():E(d):"",C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),e.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?e.jsx(X,{value:D(),onClick:()=>x(!0),onChange:()=>{},placeholder:w,disabled:o,size:h,status:r,inputMode:"none"}):null,M?e.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[e.jsx(aa,{setViews:c,views:t,filter:s,previewDate:l,setPreviewDate:p,isComponentVisible:M}),e.jsx("div",{className:"starasia-calendar-body",children:t==="days"?e.jsx(Z,{date:d,setDate:y,previewDate:l,setPreviewDate:p,setIsComponentVisible:x,input:i,minDate:g,maxDate:f,onChange:a}):t==="months"?e.jsx(_,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i}):e.jsx(R,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i})})]}):null]})}),ea=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,rangedDate:o,disabled:g,minDate:f,maxDate:w,placeholder:h,size:r,status:k},v)=>e.jsx(e.Fragment,{children:o?e.jsx(Q,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:r,status:k}):e.jsx(ra,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:r,status:k})}));Y.StarasiaDate=ea,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
|