@starasia/date 5.0.0 → 5.0.3

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