@starasia/date 5.0.2 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/date.es.js +762 -594
- package/dist/date.umd.js +148 -6
- package/dist/interfaces.d.ts +1 -0
- package/package.json +1 -1
package/dist/date.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as N, jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as N, jsx as a, Fragment as nn } from "react/jsx-runtime";
|
|
2
|
+
import { useState as j, useRef as P, useEffect as S, forwardRef as Z } 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;
|
|
@@ -147,6 +147,50 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
147
147
|
gap: var(--sa-spacing-xs, 4px);
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
+
.sa-calendar-header-title {
|
|
151
|
+
font-size: 15px;
|
|
152
|
+
font-weight: 600;
|
|
153
|
+
cursor: pointer;
|
|
154
|
+
color: var(--sa-date-text-primary);
|
|
155
|
+
flex: 1;
|
|
156
|
+
line-height: 1.3;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.sa-calendar-header-nav {
|
|
160
|
+
display: flex;
|
|
161
|
+
align-items: center;
|
|
162
|
+
gap: 2px;
|
|
163
|
+
flex-shrink: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.sa-calendar-nav-btn {
|
|
167
|
+
display: inline-flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
width: 28px;
|
|
171
|
+
height: 28px;
|
|
172
|
+
border: 0;
|
|
173
|
+
padding: 0;
|
|
174
|
+
background: transparent;
|
|
175
|
+
border-radius: var(--sa-date-radius);
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
color: var(--sa-date-brand);
|
|
178
|
+
transition: background-color 120ms ease;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.sa-calendar-nav-btn:hover {
|
|
182
|
+
background: var(--sa-date-brand-subtle);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.sa-calendar-nav-btn:active {
|
|
186
|
+
background: var(--sa-date-brand-secondary);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.sa-calendar-nav-btn:focus-visible {
|
|
190
|
+
outline: 2px solid var(--sa-date-brand);
|
|
191
|
+
outline-offset: 1px;
|
|
192
|
+
}
|
|
193
|
+
|
|
150
194
|
.sa-calendar-days-name-preivew {
|
|
151
195
|
display: flex;
|
|
152
196
|
gap: var(--sa-spacing-sm, 8px);
|
|
@@ -270,13 +314,9 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
270
314
|
|
|
271
315
|
.sa-calendar-input-outline {
|
|
272
316
|
border-color: var(--sa-date-border-color);
|
|
273
|
-
/* border-color: var(--sa-date-text-muted); */
|
|
274
317
|
background-color: transparent;
|
|
275
318
|
border-width: var(--sa-border, 1px);
|
|
276
319
|
border-style: solid;
|
|
277
|
-
/* height: var(--sa-h-10, 40px); */
|
|
278
|
-
/* border-radius: var(--sa-date-radius); */
|
|
279
|
-
/* padding-inline: var(--sa-spacing-3, 12px); */
|
|
280
320
|
}
|
|
281
321
|
|
|
282
322
|
.sa-calendar-input-container.sm {
|
|
@@ -298,6 +338,40 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
298
338
|
padding-inline: var(--sa-spacing-3, 12px);
|
|
299
339
|
}
|
|
300
340
|
|
|
341
|
+
/* filled variant — gray background, no visible border */
|
|
342
|
+
.sa-calendar-input-container.sa-calendar-input-filled {
|
|
343
|
+
background-color: var(--sa-date-accent-subtle, #f0f1f2);
|
|
344
|
+
border-color: transparent;
|
|
345
|
+
border-width: 1px;
|
|
346
|
+
border-style: solid;
|
|
347
|
+
}
|
|
348
|
+
.sa-calendar-input-container.sa-calendar-input-filled:has(input:focus) {
|
|
349
|
+
border-color: var(--sa-date-brand);
|
|
350
|
+
background-color: var(--sa-date-accent-subtle, #f0f1f2);
|
|
351
|
+
box-shadow: 0px 0px 0px 2px var(--sa-date-brand-subtle);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/* flushed variant — bottom border only */
|
|
355
|
+
.sa-calendar-input-container.sa-calendar-input-flushed {
|
|
356
|
+
background-color: transparent;
|
|
357
|
+
border-top: none;
|
|
358
|
+
border-left: none;
|
|
359
|
+
border-right: none;
|
|
360
|
+
border-bottom: 1px solid var(--sa-date-border-color);
|
|
361
|
+
border-radius: 0;
|
|
362
|
+
padding-inline: 0;
|
|
363
|
+
}
|
|
364
|
+
.sa-calendar-input-container.sa-calendar-input-flushed:has(input:focus) {
|
|
365
|
+
border-bottom-color: var(--sa-date-brand);
|
|
366
|
+
box-shadow: none;
|
|
367
|
+
}
|
|
368
|
+
.sa-calendar-input-container.sa-calendar-input-flushed.sa-calendar-input-container-error {
|
|
369
|
+
border-bottom-color: var(--sa-date-border-error) !important;
|
|
370
|
+
}
|
|
371
|
+
.sa-calendar-input-container.sa-calendar-input-flushed.sa-calendar-input-container-warning {
|
|
372
|
+
border-bottom-color: var(--sa-date-border-warning) !important;
|
|
373
|
+
}
|
|
374
|
+
|
|
301
375
|
.sa-calendar-input-preview-container {
|
|
302
376
|
width: 100%;
|
|
303
377
|
position: relative;
|
|
@@ -358,7 +432,75 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
358
432
|
outline: 2px solid var(--sa-date-brand);
|
|
359
433
|
outline-offset: 1px;
|
|
360
434
|
}
|
|
361
|
-
|
|
435
|
+
|
|
436
|
+
/* === CALENDAR PANEL SIZE VARIANTS === */
|
|
437
|
+
/* sa-calendar-size-md is the default — no override needed */
|
|
438
|
+
|
|
439
|
+
.sa-calendar.sa-calendar-size-sm {
|
|
440
|
+
padding: 16px 12px;
|
|
441
|
+
gap: 8px;
|
|
442
|
+
}
|
|
443
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-days-name-preivew {
|
|
444
|
+
gap: 4px;
|
|
445
|
+
}
|
|
446
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-days-name-preivew p {
|
|
447
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
448
|
+
}
|
|
449
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-days-number-preivew {
|
|
450
|
+
gap: 4px;
|
|
451
|
+
}
|
|
452
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-days-number-preivew p {
|
|
453
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
454
|
+
width: 28px;
|
|
455
|
+
height: 26px;
|
|
456
|
+
}
|
|
457
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-months-preview p,
|
|
458
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-years-preview p {
|
|
459
|
+
font-size: var(--sa-font-size-sm, 12px);
|
|
460
|
+
width: 76px;
|
|
461
|
+
height: 38px;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
.sa-calendar.sa-calendar-size-lg {
|
|
465
|
+
padding: 28px 20px;
|
|
466
|
+
gap: 16px;
|
|
467
|
+
}
|
|
468
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-days-name-preivew {
|
|
469
|
+
gap: 10px;
|
|
470
|
+
}
|
|
471
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-days-name-preivew p {
|
|
472
|
+
font-size: 16px;
|
|
473
|
+
}
|
|
474
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-days-number-preivew {
|
|
475
|
+
gap: 10px;
|
|
476
|
+
}
|
|
477
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-days-number-preivew p {
|
|
478
|
+
font-size: 16px;
|
|
479
|
+
width: 40px;
|
|
480
|
+
height: 36px;
|
|
481
|
+
}
|
|
482
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-months-preview p,
|
|
483
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-years-preview p {
|
|
484
|
+
font-size: 16px;
|
|
485
|
+
width: 110px;
|
|
486
|
+
height: 54px;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-header-title {
|
|
490
|
+
font-size: 13px;
|
|
491
|
+
}
|
|
492
|
+
.sa-calendar.sa-calendar-size-sm .sa-calendar-nav-btn {
|
|
493
|
+
width: 24px;
|
|
494
|
+
height: 24px;
|
|
495
|
+
}
|
|
496
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-header-title {
|
|
497
|
+
font-size: 16px;
|
|
498
|
+
}
|
|
499
|
+
.sa-calendar.sa-calendar-size-lg .sa-calendar-nav-btn {
|
|
500
|
+
width: 32px;
|
|
501
|
+
height: 32px;
|
|
502
|
+
}
|
|
503
|
+
`, en = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], A = [
|
|
362
504
|
"January",
|
|
363
505
|
"February",
|
|
364
506
|
"March",
|
|
@@ -371,7 +513,7 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
371
513
|
"October",
|
|
372
514
|
"November",
|
|
373
515
|
"December"
|
|
374
|
-
],
|
|
516
|
+
], on = [
|
|
375
517
|
"Jan",
|
|
376
518
|
"Feb",
|
|
377
519
|
"Mar",
|
|
@@ -385,56 +527,56 @@ const P = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
|
|
|
385
527
|
"Nov",
|
|
386
528
|
"Dec"
|
|
387
529
|
];
|
|
388
|
-
function
|
|
389
|
-
const [
|
|
390
|
-
s.current && !s.current.contains(
|
|
530
|
+
function an(r) {
|
|
531
|
+
const [e, t] = j(r), s = P(null), l = (c) => {
|
|
532
|
+
s.current && !s.current.contains(c.target) && t(!1);
|
|
391
533
|
};
|
|
392
|
-
return
|
|
534
|
+
return S(() => (document.addEventListener("click", l, !0), () => {
|
|
393
535
|
document.removeEventListener("click", l, !0);
|
|
394
|
-
}), []), { ref: s, isComponentVisible:
|
|
536
|
+
}), []), { ref: s, isComponentVisible: e, setIsComponentVisible: t };
|
|
395
537
|
}
|
|
396
|
-
const K = "sa-calendar-input-styles",
|
|
538
|
+
const K = "sa-calendar-input-styles", ln = (r) => {
|
|
397
539
|
if (!document.getElementById(K)) {
|
|
398
|
-
const
|
|
399
|
-
|
|
540
|
+
const e = document.createElement("style");
|
|
541
|
+
e.id = K, e.textContent = r, document.head.appendChild(e);
|
|
400
542
|
}
|
|
401
543
|
};
|
|
402
|
-
|
|
403
|
-
const W = (
|
|
404
|
-
if (
|
|
544
|
+
ln(J);
|
|
545
|
+
const W = (r) => {
|
|
546
|
+
if (r === "sm")
|
|
405
547
|
return 16;
|
|
406
|
-
if (
|
|
548
|
+
if (r === "md")
|
|
407
549
|
return 16;
|
|
408
|
-
if (
|
|
550
|
+
if (r === "lg")
|
|
409
551
|
return 20;
|
|
410
|
-
},
|
|
552
|
+
}, dn = (r) => {
|
|
411
553
|
const {
|
|
412
|
-
size:
|
|
554
|
+
size: e = "md",
|
|
413
555
|
status: t = "default",
|
|
414
556
|
variant: s = "outline",
|
|
415
557
|
clearable: l,
|
|
416
|
-
onClear:
|
|
558
|
+
onClear: c,
|
|
417
559
|
...d
|
|
418
|
-
} =
|
|
560
|
+
} = r, g = P(null), f = () => {
|
|
419
561
|
g.current && d.onClick && (g.current.focus(), d.onClick(""));
|
|
420
|
-
},
|
|
421
|
-
|
|
562
|
+
}, n = t === "disable" || d.disabled, u = !!d.value, y = l && u && !n, x = (D) => {
|
|
563
|
+
D.stopPropagation(), c == null || c();
|
|
422
564
|
};
|
|
423
565
|
return /* @__PURE__ */ N(
|
|
424
566
|
"div",
|
|
425
567
|
{
|
|
426
|
-
className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${
|
|
427
|
-
onClick:
|
|
568
|
+
className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${e} `,
|
|
569
|
+
onClick: f,
|
|
428
570
|
children: [
|
|
429
|
-
/* @__PURE__ */
|
|
571
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
|
|
430
572
|
"svg",
|
|
431
573
|
{
|
|
432
574
|
xmlns: "http://www.w3.org/2000/svg",
|
|
433
|
-
width: W(
|
|
434
|
-
height: W(
|
|
575
|
+
width: W(e),
|
|
576
|
+
height: W(e),
|
|
435
577
|
viewBox: "0 0 20 20",
|
|
436
578
|
fill: "none",
|
|
437
|
-
children: /* @__PURE__ */
|
|
579
|
+
children: /* @__PURE__ */ a(
|
|
438
580
|
"path",
|
|
439
581
|
{
|
|
440
582
|
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",
|
|
@@ -446,32 +588,32 @@ const W = (a) => {
|
|
|
446
588
|
)
|
|
447
589
|
}
|
|
448
590
|
) }),
|
|
449
|
-
/* @__PURE__ */
|
|
591
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
|
|
450
592
|
"input",
|
|
451
593
|
{
|
|
452
594
|
className: "sa-calendar-input",
|
|
453
595
|
...d,
|
|
454
|
-
disabled:
|
|
596
|
+
disabled: n,
|
|
455
597
|
value: d.value,
|
|
456
598
|
ref: g
|
|
457
599
|
}
|
|
458
600
|
) }),
|
|
459
|
-
|
|
601
|
+
y ? /* @__PURE__ */ a(
|
|
460
602
|
"button",
|
|
461
603
|
{
|
|
462
604
|
type: "button",
|
|
463
605
|
"aria-label": "Clear date",
|
|
464
606
|
className: "sa-calendar-input-clear",
|
|
465
|
-
onClick:
|
|
466
|
-
children: /* @__PURE__ */
|
|
607
|
+
onClick: x,
|
|
608
|
+
children: /* @__PURE__ */ a(
|
|
467
609
|
"svg",
|
|
468
610
|
{
|
|
469
611
|
xmlns: "http://www.w3.org/2000/svg",
|
|
470
|
-
width: W(
|
|
471
|
-
height: W(
|
|
612
|
+
width: W(e),
|
|
613
|
+
height: W(e),
|
|
472
614
|
viewBox: "0 0 20 20",
|
|
473
615
|
fill: "none",
|
|
474
|
-
children: /* @__PURE__ */
|
|
616
|
+
children: /* @__PURE__ */ a(
|
|
475
617
|
"path",
|
|
476
618
|
{
|
|
477
619
|
d: "M5 5L15 15M15 5L5 15",
|
|
@@ -484,15 +626,15 @@ const W = (a) => {
|
|
|
484
626
|
}
|
|
485
627
|
)
|
|
486
628
|
}
|
|
487
|
-
) : /* @__PURE__ */
|
|
629
|
+
) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(
|
|
488
630
|
"svg",
|
|
489
631
|
{
|
|
490
632
|
xmlns: "http://www.w3.org/2000/svg",
|
|
491
|
-
width: W(
|
|
492
|
-
height: W(
|
|
633
|
+
width: W(e),
|
|
634
|
+
height: W(e),
|
|
493
635
|
viewBox: "0 0 20 20",
|
|
494
636
|
fill: "none",
|
|
495
|
-
children: /* @__PURE__ */
|
|
637
|
+
children: /* @__PURE__ */ a(
|
|
496
638
|
"path",
|
|
497
639
|
{
|
|
498
640
|
d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
|
|
@@ -507,178 +649,194 @@ const W = (a) => {
|
|
|
507
649
|
]
|
|
508
650
|
}
|
|
509
651
|
);
|
|
510
|
-
},
|
|
511
|
-
date:
|
|
512
|
-
setDate:
|
|
652
|
+
}, cn = ({
|
|
653
|
+
date: r,
|
|
654
|
+
setDate: e,
|
|
513
655
|
dateRange: t,
|
|
514
656
|
setDateRange: s,
|
|
515
657
|
onChange: l,
|
|
516
|
-
minDate:
|
|
658
|
+
minDate: c,
|
|
517
659
|
maxDate: d,
|
|
518
660
|
input: g
|
|
519
661
|
}) => {
|
|
520
|
-
var
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
662
|
+
var L, h, v;
|
|
663
|
+
const [f, n] = j(null);
|
|
664
|
+
let u = new Date(r.getFullYear(), r.getMonth(), 1), y = u.getDay(), x = [];
|
|
665
|
+
const D = r.getMonth(), m = !!(t.from && !t.to), o = m && f ? f : null;
|
|
666
|
+
for (let p = 0; p < 42; p++) {
|
|
667
|
+
p === 0 && y === 0 ? u.setDate(u.getDate() - 7) : p === 0 ? u.setDate(
|
|
668
|
+
u.getDate() + (p - y)
|
|
669
|
+
) : u.setDate(u.getDate() + 1);
|
|
670
|
+
let b = {
|
|
671
|
+
currentMonth: u.getMonth() === D,
|
|
672
|
+
date: new Date(u),
|
|
673
|
+
month: u.getMonth(),
|
|
674
|
+
number: u.getDate(),
|
|
675
|
+
selected: u.toDateString() === ((L = t.from) == null ? void 0 : L.toDateString()) || u.toDateString() === (((h = t.to) == null ? void 0 : h.toDateString()) || ((v = t.from) == null ? void 0 : v.toDateString())),
|
|
676
|
+
year: u.getFullYear(),
|
|
677
|
+
isDisabled: c && u < c || d && u > d
|
|
535
678
|
};
|
|
536
|
-
|
|
679
|
+
x.push(b);
|
|
537
680
|
}
|
|
538
|
-
const
|
|
539
|
-
|
|
540
|
-
},
|
|
541
|
-
var
|
|
542
|
-
let
|
|
543
|
-
if (
|
|
544
|
-
|
|
681
|
+
const i = (p) => {
|
|
682
|
+
e(p);
|
|
683
|
+
}, k = (p) => {
|
|
684
|
+
var $;
|
|
685
|
+
let b = { ...t };
|
|
686
|
+
if (b.from && b.to)
|
|
687
|
+
b = { from: p, to: null };
|
|
545
688
|
else {
|
|
546
|
-
const
|
|
547
|
-
|
|
689
|
+
const T = (($ = b.from) == null ? void 0 : $.getTime()) || 0;
|
|
690
|
+
p.getTime() > T ? b = { from: b.from, to: p } : b = { from: p, to: b.from };
|
|
548
691
|
}
|
|
549
|
-
s(
|
|
692
|
+
s(b), l(b);
|
|
550
693
|
};
|
|
551
|
-
return /* @__PURE__ */ N(
|
|
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
|
-
|
|
576
|
-
},
|
|
577
|
-
|
|
578
|
-
|
|
694
|
+
return /* @__PURE__ */ N(
|
|
695
|
+
"div",
|
|
696
|
+
{
|
|
697
|
+
className: "sa-calendar-days-preivew",
|
|
698
|
+
onMouseLeave: () => n(null),
|
|
699
|
+
children: [
|
|
700
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((p, b) => /* @__PURE__ */ a("p", { children: p }, b)) }),
|
|
701
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: x.map((p, b) => {
|
|
702
|
+
const $ = t.from && t.to && p.date.getTime() > t.from.getTime() && p.date.getTime() < t.to.getTime(), T = (() => {
|
|
703
|
+
if (!o || !t.from)
|
|
704
|
+
return !1;
|
|
705
|
+
const Y = p.date.getTime(), C = t.from.getTime(), z = o.getTime();
|
|
706
|
+
return z > C ? Y > C && Y < z : Y < C && Y > z;
|
|
707
|
+
})(), M = m && f && p.date.toDateString() === f.toDateString(), F = p.isDisabled, I = () => $ || T ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "", E = () => F ? "var(--sa-color-gray-400, #b7b9be)" : $ || T ? "var(--sa-color-gray-500, #8c8f97)" : "";
|
|
708
|
+
return /* @__PURE__ */ a(
|
|
709
|
+
"p",
|
|
710
|
+
{
|
|
711
|
+
className: `${p.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${p.selected || M ? "sa-calendar-days-active" : ""}`,
|
|
712
|
+
style: {
|
|
713
|
+
backgroundColor: I(),
|
|
714
|
+
pointerEvents: F ? "none" : void 0,
|
|
715
|
+
cursor: F ? "not-allowed" : "pointer",
|
|
716
|
+
color: E(),
|
|
717
|
+
opacity: M && !p.selected ? 0.75 : 1,
|
|
718
|
+
...g ? {} : { width: "100%" }
|
|
719
|
+
},
|
|
720
|
+
onClick: () => {
|
|
721
|
+
F || (i(p.date), k(p.date));
|
|
722
|
+
},
|
|
723
|
+
onMouseEnter: () => {
|
|
724
|
+
F || n(p.date);
|
|
725
|
+
},
|
|
726
|
+
children: p.number
|
|
727
|
+
},
|
|
728
|
+
b
|
|
729
|
+
);
|
|
730
|
+
}) })
|
|
731
|
+
]
|
|
732
|
+
}
|
|
733
|
+
);
|
|
734
|
+
}, un = ({
|
|
735
|
+
date: r,
|
|
736
|
+
setDate: e,
|
|
579
737
|
filter: t,
|
|
580
738
|
setViews: s,
|
|
581
739
|
dateRange: l,
|
|
582
|
-
setDateRange:
|
|
740
|
+
setDateRange: c,
|
|
583
741
|
onChange: d,
|
|
584
742
|
minDate: g,
|
|
585
|
-
maxDate:
|
|
586
|
-
input:
|
|
743
|
+
maxDate: f,
|
|
744
|
+
input: n
|
|
587
745
|
}) => {
|
|
588
|
-
const
|
|
589
|
-
t ? (
|
|
590
|
-
},
|
|
591
|
-
var
|
|
746
|
+
const u = l.from.getFullYear(), y = r.getFullYear(), x = (m) => {
|
|
747
|
+
t ? (D(m), e(m)) : (s("days"), e(m));
|
|
748
|
+
}, D = (m) => {
|
|
749
|
+
var i;
|
|
592
750
|
let o = { ...l };
|
|
593
751
|
if (o.from && o.to)
|
|
594
|
-
o = { from:
|
|
752
|
+
o = { from: m, to: null };
|
|
595
753
|
else {
|
|
596
|
-
const
|
|
597
|
-
|
|
754
|
+
const k = ((i = o.from) == null ? void 0 : i.getTime()) || 0;
|
|
755
|
+
m.getTime() > k ? o = { from: o.from, to: m } : o = { from: m, to: o.from };
|
|
598
756
|
}
|
|
599
|
-
|
|
757
|
+
c(o), d(o);
|
|
600
758
|
};
|
|
601
|
-
return /* @__PURE__ */
|
|
602
|
-
var
|
|
603
|
-
const
|
|
604
|
-
return /* @__PURE__ */
|
|
759
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: A.map((m, o) => {
|
|
760
|
+
var L, h, v;
|
|
761
|
+
const i = new Date(y, o).getTime() > l.from.getTime() && new Date(y, o).getTime() < (((L = l.to) == null ? void 0 : L.getTime()) || l.from.getTime()), k = g && new Date(y, o) < g || f && new Date(y, o) > f;
|
|
762
|
+
return /* @__PURE__ */ a(
|
|
605
763
|
"p",
|
|
606
764
|
{
|
|
607
|
-
className:
|
|
765
|
+
className: u === y && (o === ((h = l.from) == null ? void 0 : h.getMonth()) || o === ((v = l.to) == null ? void 0 : v.getMonth())) ? "sa-calendar-months-active" : "",
|
|
608
766
|
style: {
|
|
609
|
-
backgroundColor:
|
|
610
|
-
pointerEvents:
|
|
611
|
-
cursor:
|
|
612
|
-
color:
|
|
613
|
-
...
|
|
767
|
+
backgroundColor: i ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
768
|
+
pointerEvents: k ? "none" : void 0,
|
|
769
|
+
cursor: k ? "not-allowed" : "pointer",
|
|
770
|
+
color: k ? "var(--sa-color-gray-400, #b7b9be)" : i ? "var(--sa-color-gray-500, #8c8f97)" : "",
|
|
771
|
+
...n ? {} : { width: "100%" }
|
|
614
772
|
},
|
|
615
773
|
onClick: () => {
|
|
616
|
-
|
|
774
|
+
k || x(new Date(y, o));
|
|
617
775
|
},
|
|
618
|
-
children:
|
|
776
|
+
children: m.slice(0, 3)
|
|
619
777
|
},
|
|
620
778
|
o
|
|
621
779
|
);
|
|
622
780
|
}) });
|
|
623
|
-
},
|
|
624
|
-
const
|
|
625
|
-
return { start:
|
|
626
|
-
},
|
|
627
|
-
date:
|
|
628
|
-
filter:
|
|
781
|
+
}, q = (r) => {
|
|
782
|
+
const e = Math.floor(r / 10) * 10, t = e + 10;
|
|
783
|
+
return { start: e, end: t };
|
|
784
|
+
}, hn = ({
|
|
785
|
+
date: r,
|
|
786
|
+
filter: e,
|
|
629
787
|
setViews: t,
|
|
630
788
|
setDate: s,
|
|
631
789
|
dateRange: l,
|
|
632
|
-
setDateRange:
|
|
790
|
+
setDateRange: c,
|
|
633
791
|
onChange: d,
|
|
634
792
|
minDate: g,
|
|
635
|
-
maxDate:
|
|
636
|
-
input:
|
|
793
|
+
maxDate: f,
|
|
794
|
+
input: n
|
|
637
795
|
}) => {
|
|
638
|
-
var
|
|
639
|
-
let
|
|
640
|
-
const
|
|
641
|
-
for (let h =
|
|
642
|
-
const
|
|
643
|
-
|
|
796
|
+
var L;
|
|
797
|
+
let u = [];
|
|
798
|
+
const y = r.getFullYear(), { start: x, end: D } = q(y), m = l.from.getFullYear(), o = (L = l.to) == null ? void 0 : L.getFullYear();
|
|
799
|
+
for (let h = x; h < D; h++) {
|
|
800
|
+
const v = new Date(h, 0), p = (!g || v >= g) && (!f || v <= f), b = h === m || h === o, $ = v > l.from && v < l.to;
|
|
801
|
+
u.push({
|
|
644
802
|
year: h,
|
|
645
|
-
active:
|
|
646
|
-
highlight:
|
|
647
|
-
disabled: !
|
|
803
|
+
active: b && p,
|
|
804
|
+
highlight: $ && p,
|
|
805
|
+
disabled: !p
|
|
648
806
|
});
|
|
649
807
|
}
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
},
|
|
653
|
-
var
|
|
654
|
-
let
|
|
655
|
-
if (
|
|
656
|
-
|
|
808
|
+
const i = (h) => {
|
|
809
|
+
e ? (k(h), s(h)) : (s(h), t("months"));
|
|
810
|
+
}, k = (h) => {
|
|
811
|
+
var p;
|
|
812
|
+
let v = { ...l };
|
|
813
|
+
if (v.from && v.to)
|
|
814
|
+
v = { from: h, to: null };
|
|
657
815
|
else {
|
|
658
|
-
const
|
|
659
|
-
h.getTime() >
|
|
816
|
+
const b = ((p = v.from) == null ? void 0 : p.getTime()) || 0;
|
|
817
|
+
h.getTime() > b ? v = { from: v.from, to: h } : v = { from: h, to: v.from };
|
|
660
818
|
}
|
|
661
|
-
|
|
819
|
+
c(v), d(v);
|
|
662
820
|
};
|
|
663
|
-
return /* @__PURE__ */
|
|
821
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: u.map((h, v) => /* @__PURE__ */ a(
|
|
664
822
|
"p",
|
|
665
823
|
{
|
|
666
824
|
className: `${h.active ? "sa-calendar-months-active" : ""} ${h.highlight ? "sa-calendar-months-highlight" : ""} ${h.disabled ? "sa-calendar-disabled" : ""}`,
|
|
667
825
|
onClick: () => {
|
|
668
|
-
h.disabled ||
|
|
826
|
+
h.disabled || i(new Date(h.year, 0));
|
|
669
827
|
},
|
|
670
828
|
style: {
|
|
671
829
|
backgroundColor: h.highlight ? "var(--sa-color-info-alpha-a10, #64b5f61a)" : "",
|
|
672
830
|
color: h.highlight ? "var(--sa-color-gray-500, #8c8f97)" : h.active ? "" : h.disabled ? "var(--sa-color-gray-400, #b7b9be)" : "",
|
|
673
831
|
cursor: h.disabled ? "not-allowed" : "pointer",
|
|
674
832
|
pointerEvents: h.disbled ? "none" : "all",
|
|
675
|
-
...
|
|
833
|
+
...n ? {} : { width: "100%" }
|
|
676
834
|
},
|
|
677
835
|
children: h.year
|
|
678
836
|
},
|
|
679
|
-
|
|
837
|
+
v
|
|
680
838
|
)) });
|
|
681
|
-
},
|
|
839
|
+
}, rn = ({ ...r }) => /* @__PURE__ */ a(
|
|
682
840
|
"svg",
|
|
683
841
|
{
|
|
684
842
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -686,8 +844,8 @@ const W = (a) => {
|
|
|
686
844
|
height: "20",
|
|
687
845
|
viewBox: "0 0 20 20",
|
|
688
846
|
fill: "none",
|
|
689
|
-
...
|
|
690
|
-
children: /* @__PURE__ */
|
|
847
|
+
...r,
|
|
848
|
+
children: /* @__PURE__ */ a(
|
|
691
849
|
"path",
|
|
692
850
|
{
|
|
693
851
|
d: "M12.5 3.33334L5.83337 10L12.5 16.6667",
|
|
@@ -698,7 +856,7 @@ const W = (a) => {
|
|
|
698
856
|
}
|
|
699
857
|
)
|
|
700
858
|
}
|
|
701
|
-
),
|
|
859
|
+
), tn = ({ ...r }) => /* @__PURE__ */ a(
|
|
702
860
|
"svg",
|
|
703
861
|
{
|
|
704
862
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -706,8 +864,8 @@ const W = (a) => {
|
|
|
706
864
|
height: "20",
|
|
707
865
|
viewBox: "0 0 20 20",
|
|
708
866
|
fill: "none",
|
|
709
|
-
...
|
|
710
|
-
children: /* @__PURE__ */
|
|
867
|
+
...r,
|
|
868
|
+
children: /* @__PURE__ */ a(
|
|
711
869
|
"path",
|
|
712
870
|
{
|
|
713
871
|
d: "M7.5 16.6667L14.1667 10L7.5 3.33334",
|
|
@@ -718,253 +876,257 @@ const W = (a) => {
|
|
|
718
876
|
}
|
|
719
877
|
)
|
|
720
878
|
}
|
|
721
|
-
),
|
|
722
|
-
setViews:
|
|
723
|
-
views:
|
|
879
|
+
), pn = ({
|
|
880
|
+
setViews: r,
|
|
881
|
+
views: e,
|
|
724
882
|
filter: t,
|
|
725
883
|
date: s,
|
|
726
884
|
setDate: l
|
|
727
885
|
}) => {
|
|
728
|
-
const
|
|
729
|
-
t ||
|
|
886
|
+
const c = () => {
|
|
887
|
+
t || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
|
|
730
888
|
}, d = () => {
|
|
731
|
-
if (
|
|
732
|
-
l((
|
|
889
|
+
if (e === "years") {
|
|
890
|
+
l((n) => new Date(n.getFullYear() + 10, 0));
|
|
733
891
|
return;
|
|
734
892
|
}
|
|
735
|
-
if (
|
|
736
|
-
l((
|
|
893
|
+
if (e === "months") {
|
|
894
|
+
l((n) => new Date(n.getFullYear() + 1, n.getMonth()));
|
|
737
895
|
return;
|
|
738
896
|
}
|
|
739
|
-
l((
|
|
897
|
+
l((n) => new Date(n.getFullYear(), n.getMonth() + 1));
|
|
740
898
|
}, g = () => {
|
|
741
|
-
if (
|
|
742
|
-
l((
|
|
899
|
+
if (e === "years") {
|
|
900
|
+
l((n) => new Date(n.getFullYear() - 10, 0));
|
|
743
901
|
return;
|
|
744
902
|
}
|
|
745
|
-
if (
|
|
746
|
-
l((
|
|
903
|
+
if (e === "months") {
|
|
904
|
+
l((n) => new Date(n.getFullYear() - 1, n.getMonth()));
|
|
747
905
|
return;
|
|
748
906
|
}
|
|
749
907
|
l(
|
|
750
|
-
(
|
|
751
|
-
|
|
752
|
-
|
|
908
|
+
(n) => new Date(
|
|
909
|
+
n.getMonth() === 0 ? n.getFullYear() - 1 : n.getFullYear(),
|
|
910
|
+
n.getMonth() === 0 ? 11 : n.getMonth() - 1
|
|
753
911
|
)
|
|
754
912
|
);
|
|
755
913
|
};
|
|
756
914
|
return /* @__PURE__ */ N("div", { className: "sa-calendar-header", children: [
|
|
757
|
-
/* @__PURE__ */
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
if (n === "months")
|
|
915
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: c, children: (() => {
|
|
916
|
+
if (e === "days")
|
|
917
|
+
return `${A[s.getMonth()]} ${s.getFullYear()}`;
|
|
918
|
+
if (e === "months")
|
|
762
919
|
return `${s.getFullYear()}`;
|
|
763
|
-
if (
|
|
764
|
-
return `${
|
|
920
|
+
if (e === "years")
|
|
921
|
+
return `${q(s.getFullYear()).start} ~ ${q(s.getFullYear()).end}`;
|
|
765
922
|
})() }),
|
|
766
|
-
/* @__PURE__ */
|
|
923
|
+
/* @__PURE__ */ N("div", { className: "sa-calendar-header-nav", children: [
|
|
924
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(rn, {}) }),
|
|
925
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: d, children: /* @__PURE__ */ a(tn, {}) })
|
|
926
|
+
] })
|
|
767
927
|
] });
|
|
768
928
|
};
|
|
769
|
-
function
|
|
770
|
-
const
|
|
771
|
-
return `${
|
|
929
|
+
function O(r) {
|
|
930
|
+
const e = new Date(r), t = e.getFullYear(), s = e.getMonth();
|
|
931
|
+
return `${e.getDate().toString().padStart(2, "0")} ${on[s]} ${t}`;
|
|
772
932
|
}
|
|
773
|
-
const
|
|
774
|
-
label:
|
|
775
|
-
labelPosition:
|
|
933
|
+
const sn = ({
|
|
934
|
+
label: r,
|
|
935
|
+
labelPosition: e = "outside-top",
|
|
776
936
|
required: t,
|
|
777
937
|
optional: s,
|
|
778
938
|
description: l,
|
|
779
|
-
helperText:
|
|
939
|
+
helperText: c,
|
|
780
940
|
errorText: d,
|
|
781
941
|
fullWidth: g,
|
|
782
|
-
children:
|
|
942
|
+
children: f
|
|
783
943
|
}) => {
|
|
784
|
-
const
|
|
944
|
+
const n = [
|
|
785
945
|
"sa-date-field",
|
|
786
946
|
g ? "sa-date-field-fullwidth" : ""
|
|
787
|
-
].filter(Boolean).join(" "),
|
|
788
|
-
/* @__PURE__ */
|
|
789
|
-
s && /* @__PURE__ */
|
|
790
|
-
t && /* @__PURE__ */
|
|
791
|
-
] }) : null,
|
|
792
|
-
|
|
793
|
-
d && /* @__PURE__ */
|
|
947
|
+
].filter(Boolean).join(" "), u = r ? /* @__PURE__ */ N("div", { className: "sa-date-field-label-row", children: [
|
|
948
|
+
/* @__PURE__ */ a("span", { className: "sa-date-field-label-text", children: r }),
|
|
949
|
+
s && /* @__PURE__ */ a("span", { className: "sa-date-field-optional-badge", children: "Optional" }),
|
|
950
|
+
t && /* @__PURE__ */ a("span", { className: "sa-date-field-required", children: "*" })
|
|
951
|
+
] }) : null, y = /* @__PURE__ */ N(nn, { children: [
|
|
952
|
+
c && !d && /* @__PURE__ */ a("p", { className: "sa-date-field-helper", children: c }),
|
|
953
|
+
d && /* @__PURE__ */ a("p", { className: "sa-date-field-error-msg", children: d })
|
|
794
954
|
] });
|
|
795
|
-
return
|
|
955
|
+
return r ? e === "outside-left" ? /* @__PURE__ */ N("div", { className: `${n} sa-date-field-left`, children: [
|
|
796
956
|
/* @__PURE__ */ N("div", { className: "sa-date-field-left-label", children: [
|
|
797
|
-
|
|
798
|
-
l && /* @__PURE__ */
|
|
957
|
+
u,
|
|
958
|
+
l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l })
|
|
799
959
|
] }),
|
|
800
960
|
/* @__PURE__ */ N("div", { className: "sa-date-field-input-wrap", children: [
|
|
801
|
-
|
|
802
|
-
|
|
961
|
+
f,
|
|
962
|
+
y
|
|
803
963
|
] })
|
|
804
|
-
] }) : /* @__PURE__ */ N("div", { className:
|
|
805
|
-
|
|
806
|
-
l && /* @__PURE__ */
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
] }) : /* @__PURE__ */ N("div", { className:
|
|
810
|
-
l && /* @__PURE__ */
|
|
811
|
-
|
|
812
|
-
|
|
964
|
+
] }) : /* @__PURE__ */ N("div", { className: n, children: [
|
|
965
|
+
u,
|
|
966
|
+
l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
|
|
967
|
+
f,
|
|
968
|
+
y
|
|
969
|
+
] }) : /* @__PURE__ */ N("div", { className: n, children: [
|
|
970
|
+
l && /* @__PURE__ */ a("p", { className: "sa-date-field-helper-top", children: l }),
|
|
971
|
+
f,
|
|
972
|
+
y
|
|
813
973
|
] });
|
|
814
|
-
}, Q = "sa-calendar-styles",
|
|
974
|
+
}, Q = "sa-calendar-styles", gn = (r) => {
|
|
815
975
|
if (!document.getElementById(Q)) {
|
|
816
|
-
const
|
|
817
|
-
|
|
976
|
+
const e = document.createElement("style");
|
|
977
|
+
e.id = Q, e.textContent = r, document.head.appendChild(e);
|
|
818
978
|
}
|
|
819
979
|
};
|
|
820
|
-
|
|
821
|
-
const
|
|
980
|
+
gn(J);
|
|
981
|
+
const fn = Z(
|
|
822
982
|
({
|
|
823
|
-
value:
|
|
824
|
-
onChange:
|
|
983
|
+
value: r,
|
|
984
|
+
onChange: e,
|
|
825
985
|
filter: t,
|
|
826
986
|
input: s = !0,
|
|
827
987
|
disabled: l,
|
|
828
|
-
minDate:
|
|
988
|
+
minDate: c,
|
|
829
989
|
maxDate: d,
|
|
830
990
|
placeholder: g,
|
|
831
|
-
size:
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
991
|
+
size: f,
|
|
992
|
+
variant: n,
|
|
993
|
+
status: u,
|
|
994
|
+
clearable: y,
|
|
995
|
+
fullWidth: x = !0,
|
|
996
|
+
label: D,
|
|
997
|
+
labelPosition: m,
|
|
998
|
+
required: o,
|
|
999
|
+
optional: i,
|
|
1000
|
+
description: k,
|
|
1001
|
+
helperText: L,
|
|
1002
|
+
errorText: h
|
|
1003
|
+
}, v) => {
|
|
1004
|
+
const p = h ? "error" : u, { ref: b, isComponentVisible: $, setIsComponentVisible: T } = an(!1), M = P(null), [F, I] = j("days"), [E, Y] = j(/* @__PURE__ */ new Date()), [C, z] = j({
|
|
1005
|
+
from: (r == null ? void 0 : r.from) || /* @__PURE__ */ new Date(),
|
|
1006
|
+
to: (r == null ? void 0 : r.to) || /* @__PURE__ */ new Date()
|
|
846
1007
|
});
|
|
847
|
-
|
|
848
|
-
|
|
1008
|
+
S(() => {
|
|
1009
|
+
r ? (Y(r.from), z(r)) : (Y(/* @__PURE__ */ new Date()), z({
|
|
849
1010
|
from: /* @__PURE__ */ new Date(),
|
|
850
1011
|
to: /* @__PURE__ */ new Date()
|
|
851
1012
|
}));
|
|
852
|
-
}, [
|
|
853
|
-
t &&
|
|
854
|
-
}, [t]),
|
|
855
|
-
t ||
|
|
856
|
-
}, [
|
|
857
|
-
s ||
|
|
1013
|
+
}, [r]), S(() => {
|
|
1014
|
+
t && I(t);
|
|
1015
|
+
}, [t]), S(() => {
|
|
1016
|
+
t || I("days");
|
|
1017
|
+
}, [$]), S(() => {
|
|
1018
|
+
s || T(!0);
|
|
858
1019
|
}, [s]);
|
|
859
|
-
const
|
|
860
|
-
var
|
|
861
|
-
if (!
|
|
1020
|
+
const R = () => {
|
|
1021
|
+
var w, B;
|
|
1022
|
+
if (!r)
|
|
862
1023
|
return "";
|
|
863
1024
|
if (t) {
|
|
864
|
-
if (
|
|
865
|
-
return `${
|
|
866
|
-
if (
|
|
867
|
-
return `${
|
|
868
|
-
if (
|
|
869
|
-
return `${(
|
|
1025
|
+
if (F === "days")
|
|
1026
|
+
return `${O(C.from)} ~ ${O(C.to || C.from) || "-"}`;
|
|
1027
|
+
if (F === "months")
|
|
1028
|
+
return `${A[C.from.getMonth()]} ~ ${C.to ? A[C.to.getMonth()] : "-"}`;
|
|
1029
|
+
if (F === "years")
|
|
1030
|
+
return `${(w = C.from) == null ? void 0 : w.getFullYear()} ~ ${((B = C.to) == null ? void 0 : B.getFullYear()) || "-"}`;
|
|
870
1031
|
} else
|
|
871
|
-
return `${
|
|
872
|
-
},
|
|
873
|
-
if (
|
|
874
|
-
const
|
|
875
|
-
window.innerWidth <
|
|
1032
|
+
return `${O(C.from)} ~ ${O(C.to || C.from) || "-"}`;
|
|
1033
|
+
}, V = () => {
|
|
1034
|
+
if (M.current && b.current && s) {
|
|
1035
|
+
const w = b.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
|
|
1036
|
+
window.innerWidth < w.left + B.width ? M.current.style.left = `${w.left - B.width + w.width}px` : M.current.style.left = `${w.left}px`, w.top + B.height > window.innerHeight ? M.current.style.top = `${w.y - (w.height + B.height - 28)}px` : M.current.style.top = `${w.y + w.height}px`;
|
|
876
1037
|
}
|
|
877
1038
|
};
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}, [
|
|
881
|
-
const
|
|
882
|
-
return
|
|
883
|
-
|
|
1039
|
+
S(() => {
|
|
1040
|
+
M.current && b.current && s && V();
|
|
1041
|
+
}, [M, b, $]), S(() => {
|
|
1042
|
+
const w = v == null ? void 0 : v.current;
|
|
1043
|
+
return w && w.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
|
|
1044
|
+
w && w.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
|
|
884
1045
|
};
|
|
885
1046
|
}, []);
|
|
886
|
-
const
|
|
1047
|
+
const U = /* @__PURE__ */ N(
|
|
887
1048
|
"div",
|
|
888
1049
|
{
|
|
889
1050
|
className: "sa-calendar-wrapper",
|
|
890
1051
|
style: { height: s ? "auto" : "100%" },
|
|
891
|
-
ref: s ?
|
|
1052
|
+
ref: s ? b : null,
|
|
892
1053
|
children: [
|
|
893
|
-
s ? /* @__PURE__ */
|
|
894
|
-
|
|
1054
|
+
s ? /* @__PURE__ */ a(
|
|
1055
|
+
dn,
|
|
895
1056
|
{
|
|
896
|
-
value:
|
|
1057
|
+
value: R(),
|
|
897
1058
|
inputMode: "none",
|
|
898
1059
|
onClick: () => {
|
|
899
|
-
|
|
1060
|
+
T(!0);
|
|
900
1061
|
},
|
|
901
1062
|
onChange: () => {
|
|
902
1063
|
},
|
|
903
1064
|
disabled: l,
|
|
904
1065
|
placeholder: g,
|
|
905
|
-
size:
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
1066
|
+
size: f,
|
|
1067
|
+
variant: n,
|
|
1068
|
+
status: p,
|
|
1069
|
+
clearable: y,
|
|
1070
|
+
onClear: () => e(void 0)
|
|
909
1071
|
}
|
|
910
1072
|
) : null,
|
|
911
|
-
|
|
1073
|
+
$ ? /* @__PURE__ */ N(
|
|
912
1074
|
"div",
|
|
913
1075
|
{
|
|
914
|
-
className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
|
|
915
|
-
ref:
|
|
1076
|
+
className: `sa-calendar sa-calendar-size-${f || "md"} ${s ? "" : "sa-calendar-no-input"}`,
|
|
1077
|
+
ref: M,
|
|
916
1078
|
children: [
|
|
917
|
-
/* @__PURE__ */
|
|
918
|
-
|
|
1079
|
+
/* @__PURE__ */ a(
|
|
1080
|
+
pn,
|
|
919
1081
|
{
|
|
920
|
-
setViews:
|
|
921
|
-
views:
|
|
1082
|
+
setViews: I,
|
|
1083
|
+
views: F,
|
|
922
1084
|
filter: t,
|
|
923
|
-
date:
|
|
924
|
-
setDate:
|
|
1085
|
+
date: E,
|
|
1086
|
+
setDate: Y
|
|
925
1087
|
}
|
|
926
1088
|
),
|
|
927
|
-
/* @__PURE__ */
|
|
928
|
-
|
|
1089
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ a(
|
|
1090
|
+
cn,
|
|
929
1091
|
{
|
|
930
|
-
date:
|
|
931
|
-
setDate:
|
|
932
|
-
setIsComponentVisible:
|
|
933
|
-
dateRange:
|
|
934
|
-
setDateRange:
|
|
1092
|
+
date: E,
|
|
1093
|
+
setDate: Y,
|
|
1094
|
+
setIsComponentVisible: T,
|
|
1095
|
+
dateRange: C,
|
|
1096
|
+
setDateRange: z,
|
|
935
1097
|
input: s,
|
|
936
|
-
onChange:
|
|
937
|
-
minDate:
|
|
1098
|
+
onChange: e,
|
|
1099
|
+
minDate: c,
|
|
938
1100
|
maxDate: d
|
|
939
1101
|
}
|
|
940
|
-
) :
|
|
941
|
-
|
|
1102
|
+
) : F === "months" ? /* @__PURE__ */ a(
|
|
1103
|
+
un,
|
|
942
1104
|
{
|
|
943
|
-
date:
|
|
944
|
-
setDate:
|
|
1105
|
+
date: E,
|
|
1106
|
+
setDate: Y,
|
|
945
1107
|
filter: t,
|
|
946
|
-
setViews:
|
|
947
|
-
dateRange:
|
|
948
|
-
setDateRange:
|
|
949
|
-
setIsComponentVisible:
|
|
1108
|
+
setViews: I,
|
|
1109
|
+
dateRange: C,
|
|
1110
|
+
setDateRange: z,
|
|
1111
|
+
setIsComponentVisible: T,
|
|
950
1112
|
input: s,
|
|
951
|
-
onChange:
|
|
952
|
-
minDate:
|
|
1113
|
+
onChange: e,
|
|
1114
|
+
minDate: c,
|
|
953
1115
|
maxDate: d
|
|
954
1116
|
}
|
|
955
|
-
) : /* @__PURE__ */
|
|
956
|
-
|
|
1117
|
+
) : /* @__PURE__ */ a(
|
|
1118
|
+
hn,
|
|
957
1119
|
{
|
|
958
|
-
date:
|
|
959
|
-
setDate:
|
|
1120
|
+
date: E,
|
|
1121
|
+
setDate: Y,
|
|
960
1122
|
filter: t,
|
|
961
|
-
setViews:
|
|
962
|
-
dateRange:
|
|
963
|
-
setDateRange:
|
|
964
|
-
setIsComponentVisible:
|
|
1123
|
+
setViews: I,
|
|
1124
|
+
dateRange: C,
|
|
1125
|
+
setDateRange: z,
|
|
1126
|
+
setIsComponentVisible: T,
|
|
965
1127
|
input: s,
|
|
966
|
-
onChange:
|
|
967
|
-
minDate:
|
|
1128
|
+
onChange: e,
|
|
1129
|
+
minDate: c,
|
|
968
1130
|
maxDate: d
|
|
969
1131
|
}
|
|
970
1132
|
) })
|
|
@@ -974,63 +1136,63 @@ const pe = G(
|
|
|
974
1136
|
]
|
|
975
1137
|
}
|
|
976
1138
|
);
|
|
977
|
-
return /* @__PURE__ */
|
|
978
|
-
|
|
1139
|
+
return /* @__PURE__ */ a(
|
|
1140
|
+
sn,
|
|
979
1141
|
{
|
|
980
|
-
label:
|
|
981
|
-
labelPosition:
|
|
982
|
-
required:
|
|
983
|
-
optional:
|
|
984
|
-
description:
|
|
985
|
-
helperText:
|
|
986
|
-
errorText:
|
|
987
|
-
fullWidth:
|
|
988
|
-
children:
|
|
1142
|
+
label: D,
|
|
1143
|
+
labelPosition: m,
|
|
1144
|
+
required: o,
|
|
1145
|
+
optional: i,
|
|
1146
|
+
description: k,
|
|
1147
|
+
helperText: L,
|
|
1148
|
+
errorText: h,
|
|
1149
|
+
fullWidth: x,
|
|
1150
|
+
children: U
|
|
989
1151
|
}
|
|
990
1152
|
);
|
|
991
1153
|
}
|
|
992
|
-
), X = "sa-calendar-input-styles",
|
|
1154
|
+
), X = "sa-calendar-input-styles", bn = (r) => {
|
|
993
1155
|
if (!document.getElementById(X)) {
|
|
994
|
-
const
|
|
995
|
-
|
|
1156
|
+
const e = document.createElement("style");
|
|
1157
|
+
e.id = X, e.textContent = r, document.head.appendChild(e);
|
|
996
1158
|
}
|
|
997
1159
|
};
|
|
998
|
-
|
|
999
|
-
const
|
|
1000
|
-
if (
|
|
1160
|
+
bn(J);
|
|
1161
|
+
const H = (r) => {
|
|
1162
|
+
if (r === "sm")
|
|
1001
1163
|
return 16;
|
|
1002
|
-
if (
|
|
1164
|
+
if (r === "md")
|
|
1003
1165
|
return 16;
|
|
1004
|
-
if (
|
|
1166
|
+
if (r === "lg")
|
|
1005
1167
|
return 20;
|
|
1006
|
-
},
|
|
1168
|
+
}, mn = (r) => {
|
|
1007
1169
|
const {
|
|
1008
|
-
size:
|
|
1170
|
+
size: e = "md",
|
|
1009
1171
|
status: t = "default",
|
|
1010
1172
|
variant: s = "outline",
|
|
1011
1173
|
clearable: l,
|
|
1012
|
-
onClear:
|
|
1174
|
+
onClear: c,
|
|
1013
1175
|
...d
|
|
1014
|
-
} =
|
|
1176
|
+
} = r, g = P(null), f = () => {
|
|
1015
1177
|
g.current && d.onClick && (g.current.focus(), d.onClick(""));
|
|
1016
|
-
},
|
|
1017
|
-
|
|
1178
|
+
}, n = t === "disable" || d.disabled, u = !!d.value, y = l && u && !n, x = (D) => {
|
|
1179
|
+
D.stopPropagation(), c == null || c();
|
|
1018
1180
|
};
|
|
1019
1181
|
return /* @__PURE__ */ N(
|
|
1020
1182
|
"div",
|
|
1021
1183
|
{
|
|
1022
|
-
className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${
|
|
1023
|
-
onClick:
|
|
1184
|
+
className: `sa-calendar-input-container sa-calendar-input-${s} sa-calendar-input-container-${t} ${e} `,
|
|
1185
|
+
onClick: f,
|
|
1024
1186
|
children: [
|
|
1025
|
-
/* @__PURE__ */
|
|
1187
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-left", children: /* @__PURE__ */ a(
|
|
1026
1188
|
"svg",
|
|
1027
1189
|
{
|
|
1028
1190
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1029
|
-
width:
|
|
1030
|
-
height:
|
|
1191
|
+
width: H(e),
|
|
1192
|
+
height: H(e),
|
|
1031
1193
|
viewBox: "0 0 20 20",
|
|
1032
1194
|
fill: "none",
|
|
1033
|
-
children: /* @__PURE__ */
|
|
1195
|
+
children: /* @__PURE__ */ a(
|
|
1034
1196
|
"path",
|
|
1035
1197
|
{
|
|
1036
1198
|
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",
|
|
@@ -1042,32 +1204,32 @@ const O = (a) => {
|
|
|
1042
1204
|
)
|
|
1043
1205
|
}
|
|
1044
1206
|
) }),
|
|
1045
|
-
/* @__PURE__ */
|
|
1207
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-input-preview-container", children: /* @__PURE__ */ a(
|
|
1046
1208
|
"input",
|
|
1047
1209
|
{
|
|
1048
1210
|
className: "sa-calendar-input",
|
|
1049
1211
|
...d,
|
|
1050
|
-
disabled:
|
|
1212
|
+
disabled: n,
|
|
1051
1213
|
value: d.value,
|
|
1052
1214
|
ref: g
|
|
1053
1215
|
}
|
|
1054
1216
|
) }),
|
|
1055
|
-
|
|
1217
|
+
y ? /* @__PURE__ */ a(
|
|
1056
1218
|
"button",
|
|
1057
1219
|
{
|
|
1058
1220
|
type: "button",
|
|
1059
1221
|
"aria-label": "Clear date",
|
|
1060
1222
|
className: "sa-calendar-input-clear",
|
|
1061
|
-
onClick:
|
|
1062
|
-
children: /* @__PURE__ */
|
|
1223
|
+
onClick: x,
|
|
1224
|
+
children: /* @__PURE__ */ a(
|
|
1063
1225
|
"svg",
|
|
1064
1226
|
{
|
|
1065
1227
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1066
|
-
width:
|
|
1067
|
-
height:
|
|
1228
|
+
width: H(e),
|
|
1229
|
+
height: H(e),
|
|
1068
1230
|
viewBox: "0 0 20 20",
|
|
1069
1231
|
fill: "none",
|
|
1070
|
-
children: /* @__PURE__ */
|
|
1232
|
+
children: /* @__PURE__ */ a(
|
|
1071
1233
|
"path",
|
|
1072
1234
|
{
|
|
1073
1235
|
d: "M5 5L15 15M15 5L5 15",
|
|
@@ -1080,15 +1242,15 @@ const O = (a) => {
|
|
|
1080
1242
|
}
|
|
1081
1243
|
)
|
|
1082
1244
|
}
|
|
1083
|
-
) : /* @__PURE__ */
|
|
1245
|
+
) : /* @__PURE__ */ a("div", { className: "sa-calendar-input-container-icon-right", children: /* @__PURE__ */ a(
|
|
1084
1246
|
"svg",
|
|
1085
1247
|
{
|
|
1086
1248
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1087
|
-
width:
|
|
1088
|
-
height:
|
|
1249
|
+
width: H(e),
|
|
1250
|
+
height: H(e),
|
|
1089
1251
|
viewBox: "0 0 20 20",
|
|
1090
1252
|
fill: "none",
|
|
1091
|
-
children: /* @__PURE__ */
|
|
1253
|
+
children: /* @__PURE__ */ a(
|
|
1092
1254
|
"path",
|
|
1093
1255
|
{
|
|
1094
1256
|
d: "M3.33331 7.5L9.99998 14.1667L16.6666 7.5",
|
|
@@ -1103,322 +1265,326 @@ const O = (a) => {
|
|
|
1103
1265
|
]
|
|
1104
1266
|
}
|
|
1105
1267
|
);
|
|
1106
|
-
},
|
|
1107
|
-
date:
|
|
1108
|
-
setDate:
|
|
1268
|
+
}, vn = ({
|
|
1269
|
+
date: r,
|
|
1270
|
+
setDate: e,
|
|
1109
1271
|
previewDate: t,
|
|
1110
1272
|
setPreviewDate: s,
|
|
1111
1273
|
setIsComponentVisible: l,
|
|
1112
|
-
minDate:
|
|
1274
|
+
minDate: c,
|
|
1113
1275
|
maxDate: d,
|
|
1114
1276
|
input: g,
|
|
1115
|
-
onChange:
|
|
1277
|
+
onChange: f
|
|
1116
1278
|
}) => {
|
|
1117
|
-
let
|
|
1279
|
+
let n = new Date(
|
|
1118
1280
|
t.getFullYear(),
|
|
1119
1281
|
t.getMonth(),
|
|
1120
1282
|
1
|
|
1121
|
-
),
|
|
1122
|
-
const
|
|
1283
|
+
), u = n.getDay(), y = [];
|
|
1284
|
+
const x = r.toDateString(), D = t.getMonth();
|
|
1123
1285
|
for (let o = 0; o < 42; o++) {
|
|
1124
|
-
o === 0 &&
|
|
1125
|
-
|
|
1126
|
-
) :
|
|
1127
|
-
let
|
|
1128
|
-
currentMonth:
|
|
1129
|
-
date: new Date(
|
|
1130
|
-
month:
|
|
1131
|
-
number:
|
|
1132
|
-
selected:
|
|
1133
|
-
year:
|
|
1134
|
-
isDisabled:
|
|
1286
|
+
o === 0 && u === 0 ? n.setDate(n.getDate() - 7) : o === 0 ? n.setDate(
|
|
1287
|
+
n.getDate() + (o - u)
|
|
1288
|
+
) : n.setDate(n.getDate() + 1);
|
|
1289
|
+
let i = {
|
|
1290
|
+
currentMonth: n.getMonth() === D,
|
|
1291
|
+
date: new Date(n),
|
|
1292
|
+
month: n.getMonth(),
|
|
1293
|
+
number: n.getDate(),
|
|
1294
|
+
selected: n.toDateString() === x,
|
|
1295
|
+
year: n.getFullYear(),
|
|
1296
|
+
isDisabled: c && n < c || d && n > d
|
|
1135
1297
|
};
|
|
1136
|
-
|
|
1298
|
+
y.push(i);
|
|
1137
1299
|
}
|
|
1138
|
-
const
|
|
1139
|
-
(!
|
|
1300
|
+
const m = (o) => {
|
|
1301
|
+
(!c || o >= c) && (!d || o <= d) && (e(o), f(o), s(o), g && l(!1));
|
|
1140
1302
|
};
|
|
1141
1303
|
return /* @__PURE__ */ N("div", { className: "sa-calendar-days-preivew", children: [
|
|
1142
|
-
/* @__PURE__ */
|
|
1143
|
-
/* @__PURE__ */
|
|
1144
|
-
const
|
|
1145
|
-
return /* @__PURE__ */
|
|
1304
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-name-preivew", children: en.map((o, i) => /* @__PURE__ */ a("p", { children: o }, i)) }),
|
|
1305
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-days-number-preivew", children: y.map((o, i) => {
|
|
1306
|
+
const k = o.isDisabled;
|
|
1307
|
+
return /* @__PURE__ */ a(
|
|
1146
1308
|
"p",
|
|
1147
1309
|
{
|
|
1148
1310
|
className: `${o.currentMonth ? "sa-calendar-days-current" : "sa-calendar-days"} ${o.selected ? "sa-calendar-days-active" : ""}`,
|
|
1149
1311
|
style: {
|
|
1150
|
-
color:
|
|
1151
|
-
pointerEvents:
|
|
1152
|
-
cursor:
|
|
1312
|
+
color: k ? "#ccc" : void 0,
|
|
1313
|
+
pointerEvents: k ? "none" : void 0,
|
|
1314
|
+
cursor: k ? "not-allowed" : "pointer",
|
|
1153
1315
|
...g ? {} : { width: "100%" }
|
|
1154
1316
|
},
|
|
1155
1317
|
onClick: () => {
|
|
1156
|
-
|
|
1318
|
+
k || m(o.date);
|
|
1157
1319
|
},
|
|
1158
1320
|
children: o.number
|
|
1159
1321
|
},
|
|
1160
|
-
|
|
1322
|
+
i
|
|
1161
1323
|
);
|
|
1162
1324
|
}) })
|
|
1163
1325
|
] });
|
|
1164
|
-
},
|
|
1165
|
-
date:
|
|
1166
|
-
setDate:
|
|
1326
|
+
}, yn = ({
|
|
1327
|
+
date: r,
|
|
1328
|
+
setDate: e,
|
|
1167
1329
|
filter: t,
|
|
1168
1330
|
setViews: s,
|
|
1169
1331
|
onChange: l,
|
|
1170
|
-
previewDate:
|
|
1332
|
+
previewDate: c,
|
|
1171
1333
|
setPreviewDate: d,
|
|
1172
1334
|
minDate: g,
|
|
1173
|
-
maxDate:
|
|
1174
|
-
input:
|
|
1335
|
+
maxDate: f,
|
|
1336
|
+
input: n
|
|
1175
1337
|
}) => {
|
|
1176
|
-
const
|
|
1177
|
-
(!g ||
|
|
1338
|
+
const u = r.getMonth(), y = r.getFullYear(), x = c.getFullYear(), D = (m) => {
|
|
1339
|
+
(!g || m >= g) && (!f || m <= f) && (t ? (l(m), e(m), d(m)) : (s("days"), d(m)));
|
|
1178
1340
|
};
|
|
1179
|
-
return /* @__PURE__ */
|
|
1180
|
-
const
|
|
1181
|
-
return /* @__PURE__ */
|
|
1341
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-months-preview", children: A.map((m, o) => {
|
|
1342
|
+
const i = g && new Date(x, o, 1) < g || f && new Date(x, o + 1, 0) > f;
|
|
1343
|
+
return /* @__PURE__ */ a(
|
|
1182
1344
|
"p",
|
|
1183
1345
|
{
|
|
1184
|
-
className: o ===
|
|
1346
|
+
className: o === u && x === y ? "sa-calendar-months-active" : "",
|
|
1185
1347
|
style: {
|
|
1186
|
-
color:
|
|
1187
|
-
pointerEvents:
|
|
1188
|
-
cursor:
|
|
1189
|
-
...
|
|
1348
|
+
color: i ? "#ccc" : void 0,
|
|
1349
|
+
pointerEvents: i ? "none" : void 0,
|
|
1350
|
+
cursor: i ? "not-allowed" : "pointer",
|
|
1351
|
+
...n ? {} : { width: "100%" }
|
|
1190
1352
|
},
|
|
1191
1353
|
onClick: () => {
|
|
1192
|
-
|
|
1354
|
+
i || D(new Date(x, o));
|
|
1193
1355
|
},
|
|
1194
|
-
children:
|
|
1356
|
+
children: m.slice(0, 3)
|
|
1195
1357
|
},
|
|
1196
1358
|
o
|
|
1197
1359
|
);
|
|
1198
1360
|
}) });
|
|
1199
|
-
},
|
|
1200
|
-
const
|
|
1201
|
-
return { start:
|
|
1202
|
-
},
|
|
1203
|
-
date:
|
|
1204
|
-
filter:
|
|
1361
|
+
}, G = (r) => {
|
|
1362
|
+
const e = Math.floor(r / 10) * 10, t = e + 10;
|
|
1363
|
+
return { start: e, end: t };
|
|
1364
|
+
}, wn = ({
|
|
1365
|
+
date: r,
|
|
1366
|
+
filter: e,
|
|
1205
1367
|
setViews: t,
|
|
1206
1368
|
setDate: s,
|
|
1207
1369
|
onChange: l,
|
|
1208
|
-
previewDate:
|
|
1370
|
+
previewDate: c,
|
|
1209
1371
|
setPreviewDate: d,
|
|
1210
1372
|
minDate: g,
|
|
1211
|
-
maxDate:
|
|
1212
|
-
input:
|
|
1373
|
+
maxDate: f,
|
|
1374
|
+
input: n
|
|
1213
1375
|
}) => {
|
|
1214
|
-
let
|
|
1215
|
-
const
|
|
1216
|
-
for (let
|
|
1217
|
-
let
|
|
1218
|
-
|
|
1376
|
+
let u = [];
|
|
1377
|
+
const y = c.getFullYear(), { start: x, end: D } = G(y), m = r.getFullYear();
|
|
1378
|
+
for (let i = x; i < D; i++) {
|
|
1379
|
+
let k = g && new Date(i, 0, 1) < g || f && new Date(i, 11, 31) > f;
|
|
1380
|
+
u.push({ year: i, active: i === m, isDisabled: k });
|
|
1219
1381
|
}
|
|
1220
|
-
const o = (
|
|
1221
|
-
(!g ||
|
|
1382
|
+
const o = (i) => {
|
|
1383
|
+
(!g || i >= g) && (!f || i <= f) && (e ? (l(i), s(i), d(i)) : (t("months"), d(i)));
|
|
1222
1384
|
};
|
|
1223
|
-
return /* @__PURE__ */
|
|
1385
|
+
return /* @__PURE__ */ a("div", { className: "sa-calendar-years-preview", children: u.map((i, k) => /* @__PURE__ */ a(
|
|
1224
1386
|
"p",
|
|
1225
1387
|
{
|
|
1226
|
-
className:
|
|
1388
|
+
className: i.active ? "sa-calendar-months-active" : "",
|
|
1227
1389
|
style: {
|
|
1228
|
-
color:
|
|
1229
|
-
pointerEvents:
|
|
1230
|
-
cursor:
|
|
1231
|
-
...
|
|
1390
|
+
color: i.isDisabled ? "#ccc" : void 0,
|
|
1391
|
+
pointerEvents: i.isDisabled ? "none" : void 0,
|
|
1392
|
+
cursor: i.isDisabled ? "not-allowed" : "pointer",
|
|
1393
|
+
...n ? {} : { width: "100%" }
|
|
1232
1394
|
},
|
|
1233
1395
|
onClick: () => {
|
|
1234
|
-
|
|
1396
|
+
i.isDisabled || o(new Date(i.year, 0));
|
|
1235
1397
|
},
|
|
1236
|
-
children:
|
|
1398
|
+
children: i.year
|
|
1237
1399
|
},
|
|
1238
|
-
|
|
1400
|
+
k
|
|
1239
1401
|
)) });
|
|
1240
|
-
},
|
|
1241
|
-
setViews:
|
|
1242
|
-
views:
|
|
1402
|
+
}, xn = ({
|
|
1403
|
+
setViews: r,
|
|
1404
|
+
views: e,
|
|
1243
1405
|
filter: t,
|
|
1244
1406
|
previewDate: s,
|
|
1245
1407
|
setPreviewDate: l
|
|
1246
1408
|
}) => {
|
|
1247
|
-
const
|
|
1248
|
-
t ||
|
|
1409
|
+
const c = () => {
|
|
1410
|
+
t || r((n) => n === "days" ? "months" : n === "months" ? "years" : "days");
|
|
1249
1411
|
}, d = () => {
|
|
1250
|
-
if (
|
|
1251
|
-
l((
|
|
1412
|
+
if (e === "years") {
|
|
1413
|
+
l((n) => new Date(n.getFullYear() + 10, 0));
|
|
1252
1414
|
return;
|
|
1253
1415
|
}
|
|
1254
|
-
if (
|
|
1416
|
+
if (e === "months") {
|
|
1255
1417
|
l(
|
|
1256
|
-
(
|
|
1418
|
+
(n) => new Date(n.getFullYear() + 1, n.getMonth())
|
|
1257
1419
|
);
|
|
1258
1420
|
return;
|
|
1259
1421
|
}
|
|
1260
|
-
l((
|
|
1422
|
+
l((n) => new Date(n.getFullYear(), n.getMonth() + 1));
|
|
1261
1423
|
}, g = () => {
|
|
1262
|
-
if (
|
|
1263
|
-
l((
|
|
1424
|
+
if (e === "years") {
|
|
1425
|
+
l((n) => new Date(n.getFullYear() - 10, 0));
|
|
1264
1426
|
return;
|
|
1265
1427
|
}
|
|
1266
|
-
if (
|
|
1428
|
+
if (e === "months") {
|
|
1267
1429
|
l(
|
|
1268
|
-
(
|
|
1430
|
+
(n) => new Date(n.getFullYear() - 1, n.getMonth())
|
|
1269
1431
|
);
|
|
1270
1432
|
return;
|
|
1271
1433
|
}
|
|
1272
1434
|
l(
|
|
1273
|
-
(
|
|
1274
|
-
|
|
1275
|
-
|
|
1435
|
+
(n) => new Date(
|
|
1436
|
+
n.getMonth() === 0 ? n.getFullYear() - 1 : n.getFullYear(),
|
|
1437
|
+
n.getMonth() === 0 ? 11 : n.getMonth() - 1
|
|
1276
1438
|
)
|
|
1277
1439
|
);
|
|
1278
1440
|
};
|
|
1279
1441
|
return /* @__PURE__ */ N("div", { className: "sa-calendar-header", children: [
|
|
1280
|
-
/* @__PURE__ */
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
if (n === "months")
|
|
1442
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-header-title", onClick: c, children: (() => {
|
|
1443
|
+
if (e === "days")
|
|
1444
|
+
return `${A[s.getMonth()]} ${s.getFullYear()}`;
|
|
1445
|
+
if (e === "months")
|
|
1285
1446
|
return `${s.getFullYear()}`;
|
|
1286
|
-
if (
|
|
1287
|
-
return `${
|
|
1447
|
+
if (e === "years")
|
|
1448
|
+
return `${G(s.getFullYear()).start} ~ ${G(s.getFullYear()).end}`;
|
|
1288
1449
|
})() }),
|
|
1289
|
-
/* @__PURE__ */
|
|
1450
|
+
/* @__PURE__ */ N("div", { className: "sa-calendar-header-nav", children: [
|
|
1451
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: g, children: /* @__PURE__ */ a(rn, {}) }),
|
|
1452
|
+
/* @__PURE__ */ a("button", { className: "sa-calendar-nav-btn", onClick: d, children: /* @__PURE__ */ a(tn, {}) })
|
|
1453
|
+
] })
|
|
1290
1454
|
] });
|
|
1291
|
-
},
|
|
1292
|
-
if (!document.getElementById(
|
|
1293
|
-
const
|
|
1294
|
-
|
|
1455
|
+
}, _ = "sa-calendar-styles", kn = (r) => {
|
|
1456
|
+
if (!document.getElementById(_)) {
|
|
1457
|
+
const e = document.createElement("style");
|
|
1458
|
+
e.id = _, e.textContent = r, document.head.appendChild(e);
|
|
1295
1459
|
}
|
|
1296
1460
|
};
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1461
|
+
kn(J);
|
|
1462
|
+
const Mn = Z(
|
|
1299
1463
|
({
|
|
1300
|
-
value:
|
|
1301
|
-
onChange:
|
|
1464
|
+
value: r,
|
|
1465
|
+
onChange: e,
|
|
1302
1466
|
filter: t,
|
|
1303
1467
|
input: s = !0,
|
|
1304
1468
|
disabled: l,
|
|
1305
|
-
minDate:
|
|
1469
|
+
minDate: c,
|
|
1306
1470
|
maxDate: d,
|
|
1307
1471
|
placeholder: g,
|
|
1308
|
-
size:
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1472
|
+
size: f,
|
|
1473
|
+
variant: n,
|
|
1474
|
+
status: u,
|
|
1475
|
+
clearable: y,
|
|
1476
|
+
fullWidth: x = !0,
|
|
1477
|
+
label: D,
|
|
1478
|
+
labelPosition: m,
|
|
1479
|
+
required: o,
|
|
1480
|
+
optional: i,
|
|
1481
|
+
description: k,
|
|
1482
|
+
helperText: L,
|
|
1483
|
+
errorText: h
|
|
1484
|
+
}, v) => {
|
|
1485
|
+
const p = h ? "error" : u, { ref: b, isComponentVisible: $, setIsComponentVisible: T } = an(!1), M = P(null), [F, I] = j("days"), [E, Y] = j(/* @__PURE__ */ new Date()), [C, z] = j(/* @__PURE__ */ new Date());
|
|
1486
|
+
S(() => {
|
|
1487
|
+
r ? (Y(r), z(r)) : (Y(/* @__PURE__ */ new Date()), z(/* @__PURE__ */ new Date()));
|
|
1488
|
+
}, [r]), S(() => {
|
|
1489
|
+
t && I(t);
|
|
1490
|
+
}, [t]), S(() => {
|
|
1491
|
+
t || I("days");
|
|
1492
|
+
}, [$]), S(() => {
|
|
1493
|
+
s || T(!0);
|
|
1329
1494
|
}, [s]);
|
|
1330
|
-
const
|
|
1331
|
-
if (
|
|
1332
|
-
const
|
|
1333
|
-
window.innerWidth <
|
|
1495
|
+
const R = () => r ? t === "days" ? O(E) : t === "months" ? `${A[E.getMonth()]} ${E.getFullYear()}` : t === "years" ? E.getFullYear() : O(E) : "", V = () => {
|
|
1496
|
+
if (M.current && b.current && s) {
|
|
1497
|
+
const w = b.current.getBoundingClientRect(), B = M.current.getBoundingClientRect();
|
|
1498
|
+
window.innerWidth < w.left + B.width ? M.current.style.left = `${w.left - B.width + w.width}px` : M.current.style.left = `${w.left}px`, w.top + B.height > window.innerHeight ? M.current.style.top = `${w.y - (w.height + B.height - 28)}px` : M.current.style.top = `${w.y + w.height}px`;
|
|
1334
1499
|
}
|
|
1335
1500
|
};
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}, [
|
|
1339
|
-
const
|
|
1340
|
-
return
|
|
1341
|
-
|
|
1501
|
+
S(() => {
|
|
1502
|
+
M.current && b.current && s && V();
|
|
1503
|
+
}, [M, b, $]), S(() => {
|
|
1504
|
+
const w = v == null ? void 0 : v.current;
|
|
1505
|
+
return w && w.addEventListener("scroll", V), window.addEventListener("scroll", V), () => {
|
|
1506
|
+
w && w.removeEventListener("scroll", V), window.removeEventListener("scroll", V);
|
|
1342
1507
|
};
|
|
1343
1508
|
}, []);
|
|
1344
|
-
const
|
|
1509
|
+
const U = /* @__PURE__ */ N(
|
|
1345
1510
|
"div",
|
|
1346
1511
|
{
|
|
1347
1512
|
className: "sa-calendar-wrapper",
|
|
1348
1513
|
style: { height: s ? "auto" : "100%" },
|
|
1349
|
-
ref: s ?
|
|
1514
|
+
ref: s ? b : null,
|
|
1350
1515
|
children: [
|
|
1351
|
-
s ? /* @__PURE__ */
|
|
1352
|
-
|
|
1516
|
+
s ? /* @__PURE__ */ a(
|
|
1517
|
+
mn,
|
|
1353
1518
|
{
|
|
1354
|
-
value:
|
|
1355
|
-
onClick: () =>
|
|
1519
|
+
value: R(),
|
|
1520
|
+
onClick: () => T(!0),
|
|
1356
1521
|
onChange: () => {
|
|
1357
1522
|
},
|
|
1358
1523
|
placeholder: g,
|
|
1359
1524
|
disabled: l,
|
|
1360
|
-
size:
|
|
1361
|
-
|
|
1525
|
+
size: f,
|
|
1526
|
+
variant: n,
|
|
1527
|
+
status: p,
|
|
1362
1528
|
inputMode: "none",
|
|
1363
|
-
clearable:
|
|
1364
|
-
onClear: () =>
|
|
1529
|
+
clearable: y,
|
|
1530
|
+
onClear: () => e(void 0)
|
|
1365
1531
|
}
|
|
1366
1532
|
) : null,
|
|
1367
|
-
|
|
1533
|
+
$ ? /* @__PURE__ */ N(
|
|
1368
1534
|
"div",
|
|
1369
1535
|
{
|
|
1370
|
-
className: `sa-calendar ${s ? "" : "sa-calendar-no-input"}`,
|
|
1371
|
-
ref:
|
|
1536
|
+
className: `sa-calendar sa-calendar-size-${f || "md"} ${s ? "" : "sa-calendar-no-input"}`,
|
|
1537
|
+
ref: M,
|
|
1372
1538
|
children: [
|
|
1373
|
-
/* @__PURE__ */
|
|
1374
|
-
|
|
1539
|
+
/* @__PURE__ */ a(
|
|
1540
|
+
xn,
|
|
1375
1541
|
{
|
|
1376
|
-
setViews:
|
|
1377
|
-
views:
|
|
1542
|
+
setViews: I,
|
|
1543
|
+
views: F,
|
|
1378
1544
|
filter: t,
|
|
1379
|
-
previewDate:
|
|
1380
|
-
setPreviewDate:
|
|
1381
|
-
isComponentVisible:
|
|
1545
|
+
previewDate: C,
|
|
1546
|
+
setPreviewDate: z,
|
|
1547
|
+
isComponentVisible: $
|
|
1382
1548
|
}
|
|
1383
1549
|
),
|
|
1384
|
-
/* @__PURE__ */
|
|
1385
|
-
|
|
1550
|
+
/* @__PURE__ */ a("div", { className: "sa-calendar-body", children: F === "days" ? /* @__PURE__ */ a(
|
|
1551
|
+
vn,
|
|
1386
1552
|
{
|
|
1387
|
-
date:
|
|
1388
|
-
setDate:
|
|
1389
|
-
previewDate:
|
|
1390
|
-
setPreviewDate:
|
|
1391
|
-
setIsComponentVisible:
|
|
1553
|
+
date: E,
|
|
1554
|
+
setDate: Y,
|
|
1555
|
+
previewDate: C,
|
|
1556
|
+
setPreviewDate: z,
|
|
1557
|
+
setIsComponentVisible: T,
|
|
1392
1558
|
input: s,
|
|
1393
|
-
minDate:
|
|
1559
|
+
minDate: c,
|
|
1394
1560
|
maxDate: d,
|
|
1395
|
-
onChange:
|
|
1561
|
+
onChange: e
|
|
1396
1562
|
}
|
|
1397
|
-
) :
|
|
1398
|
-
|
|
1563
|
+
) : F === "months" ? /* @__PURE__ */ a(
|
|
1564
|
+
yn,
|
|
1399
1565
|
{
|
|
1400
|
-
date:
|
|
1401
|
-
setDate:
|
|
1402
|
-
previewDate:
|
|
1403
|
-
setPreviewDate:
|
|
1566
|
+
date: E,
|
|
1567
|
+
setDate: Y,
|
|
1568
|
+
previewDate: C,
|
|
1569
|
+
setPreviewDate: z,
|
|
1404
1570
|
filter: t,
|
|
1405
|
-
setViews:
|
|
1406
|
-
onChange:
|
|
1407
|
-
minDate:
|
|
1571
|
+
setViews: I,
|
|
1572
|
+
onChange: e,
|
|
1573
|
+
minDate: c,
|
|
1408
1574
|
maxDate: d,
|
|
1409
1575
|
input: s
|
|
1410
1576
|
}
|
|
1411
|
-
) : /* @__PURE__ */
|
|
1412
|
-
|
|
1577
|
+
) : /* @__PURE__ */ a(
|
|
1578
|
+
wn,
|
|
1413
1579
|
{
|
|
1414
|
-
date:
|
|
1415
|
-
setDate:
|
|
1416
|
-
previewDate:
|
|
1417
|
-
setPreviewDate:
|
|
1580
|
+
date: E,
|
|
1581
|
+
setDate: Y,
|
|
1582
|
+
previewDate: C,
|
|
1583
|
+
setPreviewDate: z,
|
|
1418
1584
|
filter: t,
|
|
1419
|
-
setViews:
|
|
1420
|
-
onChange:
|
|
1421
|
-
minDate:
|
|
1585
|
+
setViews: I,
|
|
1586
|
+
onChange: e,
|
|
1587
|
+
minDate: c,
|
|
1422
1588
|
maxDate: d,
|
|
1423
1589
|
input: s
|
|
1424
1590
|
}
|
|
@@ -1429,68 +1595,70 @@ const xe = G(
|
|
|
1429
1595
|
]
|
|
1430
1596
|
}
|
|
1431
1597
|
);
|
|
1432
|
-
return /* @__PURE__ */
|
|
1433
|
-
|
|
1598
|
+
return /* @__PURE__ */ a(
|
|
1599
|
+
sn,
|
|
1434
1600
|
{
|
|
1435
|
-
label:
|
|
1436
|
-
labelPosition:
|
|
1437
|
-
required:
|
|
1438
|
-
optional:
|
|
1439
|
-
description:
|
|
1440
|
-
helperText:
|
|
1441
|
-
errorText:
|
|
1442
|
-
fullWidth:
|
|
1443
|
-
children:
|
|
1601
|
+
label: D,
|
|
1602
|
+
labelPosition: m,
|
|
1603
|
+
required: o,
|
|
1604
|
+
optional: i,
|
|
1605
|
+
description: k,
|
|
1606
|
+
helperText: L,
|
|
1607
|
+
errorText: h,
|
|
1608
|
+
fullWidth: x,
|
|
1609
|
+
children: U
|
|
1444
1610
|
}
|
|
1445
1611
|
);
|
|
1446
1612
|
}
|
|
1447
|
-
),
|
|
1613
|
+
), Nn = Z(
|
|
1448
1614
|
({
|
|
1449
|
-
value:
|
|
1450
|
-
onChange:
|
|
1615
|
+
value: r,
|
|
1616
|
+
onChange: e,
|
|
1451
1617
|
filter: t,
|
|
1452
1618
|
input: s = !0,
|
|
1453
1619
|
rangedDate: l,
|
|
1454
|
-
disabled:
|
|
1620
|
+
disabled: c,
|
|
1455
1621
|
minDate: d,
|
|
1456
1622
|
maxDate: g,
|
|
1457
|
-
placeholder:
|
|
1458
|
-
size:
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1623
|
+
placeholder: f,
|
|
1624
|
+
size: n,
|
|
1625
|
+
variant: u,
|
|
1626
|
+
status: y,
|
|
1627
|
+
clearable: x,
|
|
1628
|
+
fullWidth: D,
|
|
1629
|
+
label: m,
|
|
1630
|
+
labelPosition: o,
|
|
1631
|
+
required: i,
|
|
1632
|
+
optional: k,
|
|
1633
|
+
description: L,
|
|
1634
|
+
helperText: h,
|
|
1635
|
+
errorText: v
|
|
1636
|
+
}, p) => {
|
|
1637
|
+
const b = {
|
|
1638
|
+
onChange: e,
|
|
1639
|
+
value: r,
|
|
1473
1640
|
input: s,
|
|
1474
1641
|
filter: t,
|
|
1475
|
-
disabled:
|
|
1642
|
+
disabled: c,
|
|
1476
1643
|
minDate: d,
|
|
1477
1644
|
maxDate: g,
|
|
1478
|
-
placeholder:
|
|
1479
|
-
size:
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1645
|
+
placeholder: f,
|
|
1646
|
+
size: n,
|
|
1647
|
+
variant: u,
|
|
1648
|
+
status: y,
|
|
1649
|
+
clearable: x,
|
|
1650
|
+
fullWidth: D,
|
|
1651
|
+
label: m,
|
|
1652
|
+
labelPosition: o,
|
|
1653
|
+
required: i,
|
|
1654
|
+
optional: k,
|
|
1655
|
+
description: L,
|
|
1656
|
+
helperText: h,
|
|
1657
|
+
errorText: v
|
|
1490
1658
|
};
|
|
1491
|
-
return /* @__PURE__ */
|
|
1659
|
+
return /* @__PURE__ */ a(nn, { children: l ? /* @__PURE__ */ a(fn, { ...b, ref: p }) : /* @__PURE__ */ a(Mn, { ...b, ref: p }) });
|
|
1492
1660
|
}
|
|
1493
1661
|
);
|
|
1494
1662
|
export {
|
|
1495
|
-
|
|
1663
|
+
Nn as StarasiaDate
|
|
1496
1664
|
};
|