@starasia/date 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/date.es.js CHANGED
@@ -19,8 +19,12 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
19
19
  /* color */
20
20
  --starasia-ui-date-color-black-secondary: var(
21
21
  --starasia-ui-color-gray-50,
22
- #f9fafb
22
+ rgba(249, 250, 251, 1)
23
23
  );
24
+ --starasia-ui-date-color-white: var(--starasia-ui-color-gray-50, rgba(255, 254, 255, 1));
25
+ --starasia-ui-date-color-border: rgba(120, 134, 127, 0.2);
26
+ --starasia-ui-date-color-disabled-border: rgba(120, 134, 127, 0.2);
27
+ --starasia-ui-date-color-disabled-bg: rgba(120, 134, 127, 0.1);
24
28
 
25
29
  /* box shadow */
26
30
  --starasia-ui-date-box-shadow: var(
@@ -33,19 +37,19 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
33
37
  /* gray / black */
34
38
  --starasia-ui-date-color-primary-black: var(
35
39
  --starasia-ui-color-gray-700,
36
- #374151
40
+ rgba(55, 65, 81, 1)
37
41
  );
38
42
  --starasia-ui-date-color-secondary-black: var(
39
43
  --starasia-ui-color-gray-500,
40
- #6b7280
44
+ rgba(107, 114, 128, 1)
41
45
  );
42
46
  --starasia-ui-date-color-tertiary-black: var(
43
47
  --starasia-ui-color-gray-300,
44
- #d1d5db
48
+ rgba(209, 213, 219, 1)
45
49
  );
46
50
  --starasia-ui-date-color-quaternary-black: var(
47
51
  --starasia-ui-color-gray-50,
48
- #f9fafb
52
+ rgba(249, 250, 251, 1)
49
53
  );
50
54
 
51
55
  /* brand */
@@ -70,12 +74,12 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
70
74
  /* color */
71
75
  --starasia-ui-input-color-tertiary-gray: var(
72
76
  --starasia-ui-color-gray-300,
73
- #d1d5db
77
+ rgba(209, 213, 219, 1)
74
78
  );
75
79
 
76
80
  --starasia-ui-date-placholder-color: var(
77
81
  --starasia-ui-color-gray-200,
78
- #c9cecc
82
+ rgba(201, 206, 204, 1)
79
83
  );
80
84
  --starasia-ui-date-placholder-fontWeight: var(
81
85
  --starasia-ui-fontWeights-normal,
@@ -84,11 +88,11 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
84
88
 
85
89
  --starasia-ui-input-color-secondary-red: var(
86
90
  --starasia-ui-color-red-500,
87
- #ef4444
91
+ rgba(239, 68, 68, 1)
88
92
  );
89
93
  --starasia-ui-input-color-secondary-yellow: var(
90
94
  --starasia-ui-color-yellow-500,
91
- #eab308
95
+ rgba(234, 179, 8, 1)
92
96
  );
93
97
  }
94
98
  .starasia-calendar-wrapper {
@@ -118,7 +122,7 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
118
122
  width: 100%;
119
123
  box-shadow: unset;
120
124
  border: none;
121
- background-color: white;
125
+ background-color: var(--starasia-ui-date-color-white);
122
126
  /* background-color: white; */
123
127
  height: 100%;
124
128
  border-radius: 0;
@@ -249,13 +253,13 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
249
253
  .starasia-calendar-input-container:has(input:disabled) {
250
254
  /* border-color: var(--starasia-ui-input-color-tertiary-gray); */
251
255
  /* background-color: var(--starasia-ui-input-color-tertiary-gray); */
252
- border-color: rgba(120, 134, 127, 0.2);
253
- background-color: rgba(120, 134, 127, 0.1);
256
+ border-color: var(--starasia-ui-date-color-disabled-border);
257
+ background-color: var(--starasia-ui-date-color-disabled-bg);
254
258
  pointer-events: none;
255
259
  }
256
260
 
257
261
  .starasia-calendar-input-outline {
258
- border-color: rgba(120, 134, 127, 0.2);
262
+ border-color: var(--starasia-ui-date-color-border);
259
263
  /* border-color: var(--starasia-ui-date-color-tertiary-black); */
260
264
  background-color: transparent;
261
265
  border-width: var(--starasia-ui-border, 1px);
@@ -371,14 +375,14 @@ const T = (e) => {
371
375
  if (e === "lg")
372
376
  return 20;
373
377
  }, K = (e) => {
374
- const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, g = E(null), f = () => {
378
+ const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, g = E(null), y = () => {
375
379
  g.current && i.onClick && (g.current.focus(), i.onClick(""));
376
380
  };
377
381
  return /* @__PURE__ */ $(
378
382
  "div",
379
383
  {
380
384
  className: `starasia-calendar-input-container starasia-calendar-input-${s} starasia-calendar-input-container-${t} ${a} `,
381
- onClick: f,
385
+ onClick: y,
382
386
  children: [
383
387
  /* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-left", children: /* @__PURE__ */ l(
384
388
  "svg",
@@ -440,7 +444,7 @@ const T = (e) => {
440
444
  setDateRange: s,
441
445
  onChange: i,
442
446
  minDate: g,
443
- maxDate: f,
447
+ maxDate: y,
444
448
  input: v
445
449
  }) => {
446
450
  var u, n, c;
@@ -450,33 +454,33 @@ const T = (e) => {
450
454
  d === 0 && r === 0 ? h.setDate(h.getDate() - 7) : d === 0 ? h.setDate(
451
455
  h.getDate() + (d - r)
452
456
  ) : h.setDate(h.getDate() + 1);
453
- let y = {
457
+ let f = {
454
458
  currentMonth: h.getMonth() === b,
455
459
  date: new Date(h),
456
460
  month: h.getMonth(),
457
461
  number: h.getDate(),
458
462
  selected: h.toDateString() === ((u = t.from) == null ? void 0 : u.toDateString()) || h.toDateString() === (((n = t.to) == null ? void 0 : n.toDateString()) || ((c = t.from) == null ? void 0 : c.toDateString())),
459
463
  year: h.getFullYear(),
460
- isDisabled: g && h < g || f && h > f
464
+ isDisabled: g && h < g || y && h > y
461
465
  };
462
- w.push(y);
466
+ w.push(f);
463
467
  }
464
468
  const k = (d) => {
465
469
  a(d);
466
470
  }, M = (d) => {
467
471
  var o;
468
- let y = { ...t };
469
- if (y.from && y.to)
470
- y = { from: d, to: null };
472
+ let f = { ...t };
473
+ if (f.from && f.to)
474
+ f = { from: d, to: null };
471
475
  else {
472
- const p = ((o = y.from) == null ? void 0 : o.getTime()) || 0;
473
- d.getTime() > p ? y = { from: y.from, to: d } : y = { from: d, to: y.from };
476
+ const p = ((o = f.from) == null ? void 0 : o.getTime()) || 0;
477
+ d.getTime() > p ? f = { from: f.from, to: d } : f = { from: d, to: f.from };
474
478
  }
475
- s(y), i(y);
479
+ s(f), i(f);
476
480
  };
477
481
  return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
478
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((d, y) => /* @__PURE__ */ l("p", { children: d }, y)) }),
479
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: w.map((d, y) => {
482
+ /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((d, f) => /* @__PURE__ */ l("p", { children: d }, f)) }),
483
+ /* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: w.map((d, f) => {
480
484
  var C;
481
485
  const o = d.date.getTime() > t.from.getTime() && d.date.getTime() < (((C = t.to) == null ? void 0 : C.getTime()) || t.from.getTime()), p = d.isDisabled;
482
486
  return /* @__PURE__ */ l(
@@ -495,7 +499,7 @@ const T = (e) => {
495
499
  },
496
500
  children: d.number
497
501
  },
498
- y
502
+ f
499
503
  );
500
504
  }) })
501
505
  ] });
@@ -506,7 +510,7 @@ const T = (e) => {
506
510
  setViews: s,
507
511
  dateRange: i,
508
512
  setDateRange: g,
509
- onChange: f,
513
+ onChange: y,
510
514
  minDate: v,
511
515
  maxDate: h,
512
516
  input: r
@@ -522,11 +526,11 @@ const T = (e) => {
522
526
  const d = ((c = n.from) == null ? void 0 : c.getTime()) || 0;
523
527
  u.getTime() > d ? n = { from: n.from, to: u } : n = { from: u, to: n.from };
524
528
  }
525
- g(n), f(n);
529
+ g(n), y(n);
526
530
  };
527
531
  return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, n) => {
528
- var y, o, p;
529
- const c = new Date(b, n).getTime() > i.from.getTime() && new Date(b, n).getTime() < (((y = i.to) == null ? void 0 : y.getTime()) || i.from.getTime()), d = v && new Date(b, n) < v || h && new Date(b, n) > h;
532
+ var f, o, p;
533
+ const c = new Date(b, n).getTime() > i.from.getTime() && new Date(b, n).getTime() < (((f = i.to) == null ? void 0 : f.getTime()) || i.from.getTime()), d = v && new Date(b, n) < v || h && new Date(b, n) > h;
530
534
  return /* @__PURE__ */ l(
531
535
  "p",
532
536
  {
@@ -556,14 +560,14 @@ const T = (e) => {
556
560
  setDate: s,
557
561
  dateRange: i,
558
562
  setDateRange: g,
559
- onChange: f,
563
+ onChange: y,
560
564
  minDate: v,
561
565
  maxDate: h,
562
566
  input: r
563
567
  }) => {
564
- var y;
568
+ var f;
565
569
  let w = [];
566
- const b = e.getFullYear(), { start: k, end: M } = B(b), u = i.from.getFullYear(), n = (y = i.to) == null ? void 0 : y.getFullYear();
570
+ const b = e.getFullYear(), { start: k, end: M } = B(b), u = i.from.getFullYear(), n = (f = i.to) == null ? void 0 : f.getFullYear();
567
571
  for (let o = k; o < M; o++) {
568
572
  const p = new Date(o, 0), C = (!v || p >= v) && (!h || p <= h), x = o === u || o === n, m = p > i.from && p < i.to;
569
573
  w.push({
@@ -584,7 +588,7 @@ const T = (e) => {
584
588
  const x = ((C = p.from) == null ? void 0 : C.getTime()) || 0;
585
589
  o.getTime() > x ? p = { from: p.from, to: o } : p = { from: o, to: p.from };
586
590
  }
587
- g(p), f(p);
591
+ g(p), y(p);
588
592
  };
589
593
  return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((o, p) => /* @__PURE__ */ l(
590
594
  "p",
@@ -653,7 +657,7 @@ const T = (e) => {
653
657
  }) => {
654
658
  const g = () => {
655
659
  t || e((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
656
- }, f = () => {
660
+ }, y = () => {
657
661
  if (a === "years") {
658
662
  i((r) => new Date(r.getFullYear() + 10, 0));
659
663
  return;
@@ -689,7 +693,7 @@ const T = (e) => {
689
693
  if (a === "years")
690
694
  return `${B(s.getFullYear()).start} ~ ${B(s.getFullYear()).end}`;
691
695
  })() }),
692
- /* @__PURE__ */ l(P, { onClick: () => f() })
696
+ /* @__PURE__ */ l(P, { onClick: () => y() })
693
697
  ] });
694
698
  };
695
699
  function L(e) {
@@ -711,17 +715,17 @@ const ra = W(
711
715
  input: s = !0,
712
716
  disabled: i,
713
717
  minDate: g,
714
- maxDate: f,
718
+ maxDate: y,
715
719
  placeholder: v,
716
720
  size: h,
717
721
  status: r
718
722
  }, w) => {
719
- const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d, y] = F(/* @__PURE__ */ new Date()), [o, p] = F({
723
+ const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d, f] = F(/* @__PURE__ */ new Date()), [o, p] = F({
720
724
  from: (e == null ? void 0 : e.from) || /* @__PURE__ */ new Date(),
721
725
  to: (e == null ? void 0 : e.to) || /* @__PURE__ */ new Date()
722
726
  });
723
727
  D(() => {
724
- e ? (y(e.from), p(e)) : (y(/* @__PURE__ */ new Date()), p({
728
+ e ? (f(e.from), p(e)) : (f(/* @__PURE__ */ new Date()), p({
725
729
  from: /* @__PURE__ */ new Date(),
726
730
  to: /* @__PURE__ */ new Date()
727
731
  }));
@@ -794,27 +798,27 @@ const ra = W(
794
798
  views: n,
795
799
  filter: t,
796
800
  date: d,
797
- setDate: y
801
+ setDate: f
798
802
  }
799
803
  ),
800
804
  /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: n === "days" ? /* @__PURE__ */ l(
801
805
  Q,
802
806
  {
803
807
  date: d,
804
- setDate: y,
808
+ setDate: f,
805
809
  setIsComponentVisible: M,
806
810
  dateRange: o,
807
811
  setDateRange: p,
808
812
  input: s,
809
813
  onChange: a,
810
814
  minDate: g,
811
- maxDate: f
815
+ maxDate: y
812
816
  }
813
817
  ) : n === "months" ? /* @__PURE__ */ l(
814
818
  X,
815
819
  {
816
820
  date: d,
817
- setDate: y,
821
+ setDate: f,
818
822
  filter: t,
819
823
  setViews: c,
820
824
  dateRange: o,
@@ -823,13 +827,13 @@ const ra = W(
823
827
  input: s,
824
828
  onChange: a,
825
829
  minDate: g,
826
- maxDate: f
830
+ maxDate: y
827
831
  }
828
832
  ) : /* @__PURE__ */ l(
829
833
  Z,
830
834
  {
831
835
  date: d,
832
- setDate: y,
836
+ setDate: f,
833
837
  filter: t,
834
838
  setViews: c,
835
839
  dateRange: o,
@@ -838,7 +842,7 @@ const ra = W(
838
842
  input: s,
839
843
  onChange: a,
840
844
  minDate: g,
841
- maxDate: f
845
+ maxDate: y
842
846
  }
843
847
  ) })
844
848
  ]
@@ -863,14 +867,14 @@ const S = (e) => {
863
867
  if (e === "lg")
864
868
  return 20;
865
869
  }, na = (e) => {
866
- const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, g = E(null), f = () => {
870
+ const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, g = E(null), y = () => {
867
871
  g.current && i.onClick && (g.current.focus(), i.onClick(""));
868
872
  };
869
873
  return /* @__PURE__ */ $(
870
874
  "div",
871
875
  {
872
876
  className: `starasia-calendar-input-container starasia-calendar-input-${s} starasia-calendar-input-container-${t} ${a} `,
873
- onClick: f,
877
+ onClick: y,
874
878
  children: [
875
879
  /* @__PURE__ */ l("div", { className: "starasia-calendar-input-container-icon-left", children: /* @__PURE__ */ l(
876
880
  "svg",
@@ -932,7 +936,7 @@ const S = (e) => {
932
936
  setPreviewDate: s,
933
937
  setIsComponentVisible: i,
934
938
  minDate: g,
935
- maxDate: f,
939
+ maxDate: y,
936
940
  input: v,
937
941
  onChange: h
938
942
  }) => {
@@ -953,12 +957,12 @@ const S = (e) => {
953
957
  number: r.getDate(),
954
958
  selected: r.toDateString() === k,
955
959
  year: r.getFullYear(),
956
- isDisabled: g && r < g || f && r > f
960
+ isDisabled: g && r < g || y && r > y
957
961
  };
958
962
  b.push(c);
959
963
  }
960
964
  const u = (n) => {
961
- (!g || n >= g) && (!f || n <= f) && (a(n), h(n), s(n), v && i(!1));
965
+ (!g || n >= g) && (!y || n <= y) && (a(n), h(n), s(n), v && i(!1));
962
966
  };
963
967
  return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
964
968
  /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((n, c) => /* @__PURE__ */ l("p", { children: n }, c)) }),
@@ -990,13 +994,13 @@ const S = (e) => {
990
994
  setViews: s,
991
995
  onChange: i,
992
996
  previewDate: g,
993
- setPreviewDate: f,
997
+ setPreviewDate: y,
994
998
  minDate: v,
995
999
  maxDate: h,
996
1000
  input: r
997
1001
  }) => {
998
1002
  const w = e.getMonth(), b = e.getFullYear(), k = g.getFullYear(), M = (u) => {
999
- (!v || u >= v) && (!h || u <= h) && (t ? (i(u), a(u), f(u)) : (s("days"), f(u)));
1003
+ (!v || u >= v) && (!h || u <= h) && (t ? (i(u), a(u), y(u)) : (s("days"), y(u)));
1000
1004
  };
1001
1005
  return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, n) => {
1002
1006
  const c = v && new Date(k, n, 1) < v || h && new Date(k, n + 1, 0) > h;
@@ -1028,7 +1032,7 @@ const S = (e) => {
1028
1032
  setDate: s,
1029
1033
  onChange: i,
1030
1034
  previewDate: g,
1031
- setPreviewDate: f,
1035
+ setPreviewDate: y,
1032
1036
  minDate: v,
1033
1037
  maxDate: h,
1034
1038
  input: r
@@ -1040,7 +1044,7 @@ const S = (e) => {
1040
1044
  w.push({ year: c, active: c === u, isDisabled: d });
1041
1045
  }
1042
1046
  const n = (c) => {
1043
- (!v || c >= v) && (!h || c <= h) && (a ? (i(c), s(c), f(c)) : (t("months"), f(c)));
1047
+ (!v || c >= v) && (!h || c <= h) && (a ? (i(c), s(c), y(c)) : (t("months"), y(c)));
1044
1048
  };
1045
1049
  return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((c, d) => /* @__PURE__ */ l(
1046
1050
  "p",
@@ -1068,7 +1072,7 @@ const S = (e) => {
1068
1072
  }) => {
1069
1073
  const g = () => {
1070
1074
  t || e((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
1071
- }, f = () => {
1075
+ }, y = () => {
1072
1076
  if (a === "years") {
1073
1077
  i((r) => new Date(r.getFullYear() + 10, 0));
1074
1078
  return;
@@ -1108,7 +1112,7 @@ const S = (e) => {
1108
1112
  if (a === "years")
1109
1113
  return `${V(s.getFullYear()).start} ~ ${V(s.getFullYear()).end}`;
1110
1114
  })() }),
1111
- /* @__PURE__ */ l(P, { onClick: () => f() })
1115
+ /* @__PURE__ */ l(P, { onClick: () => y() })
1112
1116
  ] });
1113
1117
  }, H = "starasia-calendar-styles", la = (e) => {
1114
1118
  if (!document.getElementById(H)) {
@@ -1125,14 +1129,14 @@ const ca = W(
1125
1129
  input: s = !0,
1126
1130
  disabled: i,
1127
1131
  minDate: g,
1128
- maxDate: f,
1132
+ maxDate: y,
1129
1133
  placeholder: v,
1130
1134
  size: h,
1131
1135
  status: r
1132
1136
  }, w) => {
1133
- const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d, y] = F(/* @__PURE__ */ new Date()), [o, p] = F(/* @__PURE__ */ new Date());
1137
+ const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [n, c] = F("days"), [d, f] = F(/* @__PURE__ */ new Date()), [o, p] = F(/* @__PURE__ */ new Date());
1134
1138
  D(() => {
1135
- e ? (y(e), p(e)) : (y(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
1139
+ e ? (f(e), p(e)) : (f(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
1136
1140
  }, [e]), D(() => {
1137
1141
  t && c(t);
1138
1142
  }, [t]), D(() => {
@@ -1195,41 +1199,41 @@ const ca = W(
1195
1199
  ta,
1196
1200
  {
1197
1201
  date: d,
1198
- setDate: y,
1202
+ setDate: f,
1199
1203
  previewDate: o,
1200
1204
  setPreviewDate: p,
1201
1205
  setIsComponentVisible: M,
1202
1206
  input: s,
1203
1207
  minDate: g,
1204
- maxDate: f,
1208
+ maxDate: y,
1205
1209
  onChange: a
1206
1210
  }
1207
1211
  ) : n === "months" ? /* @__PURE__ */ l(
1208
1212
  sa,
1209
1213
  {
1210
1214
  date: d,
1211
- setDate: y,
1215
+ setDate: f,
1212
1216
  previewDate: o,
1213
1217
  setPreviewDate: p,
1214
1218
  filter: t,
1215
1219
  setViews: c,
1216
1220
  onChange: a,
1217
1221
  minDate: g,
1218
- maxDate: f,
1222
+ maxDate: y,
1219
1223
  input: s
1220
1224
  }
1221
1225
  ) : /* @__PURE__ */ l(
1222
1226
  ia,
1223
1227
  {
1224
1228
  date: d,
1225
- setDate: y,
1229
+ setDate: f,
1226
1230
  previewDate: o,
1227
1231
  setPreviewDate: p,
1228
1232
  filter: t,
1229
1233
  setViews: c,
1230
1234
  onChange: a,
1231
1235
  minDate: g,
1232
- maxDate: f,
1236
+ maxDate: y,
1233
1237
  input: s
1234
1238
  }
1235
1239
  ) })
@@ -1248,7 +1252,7 @@ const ca = W(
1248
1252
  input: s = !0,
1249
1253
  rangedDate: i,
1250
1254
  disabled: g,
1251
- minDate: f,
1255
+ minDate: y,
1252
1256
  maxDate: v,
1253
1257
  placeholder: h,
1254
1258
  size: r,
@@ -1262,7 +1266,7 @@ const ca = W(
1262
1266
  filter: t,
1263
1267
  disabled: g,
1264
1268
  ref: b,
1265
- minDate: f,
1269
+ minDate: y,
1266
1270
  maxDate: v,
1267
1271
  placeholder: h,
1268
1272
  size: r,
@@ -1277,7 +1281,7 @@ const ca = W(
1277
1281
  filter: t,
1278
1282
  disabled: g,
1279
1283
  ref: b,
1280
- minDate: f,
1284
+ minDate: y,
1281
1285
  maxDate: v,
1282
1286
  placeholder: h,
1283
1287
  size: r,
package/dist/date.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Y,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],r):(Y=typeof globalThis<"u"?globalThis:Y||self,r(Y.Date={},Y.jsxRuntime,Y.React))})(this,function(Y,r,m){"use strict";const N=`@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
1
+ (function(Y,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],e):(Y=typeof globalThis<"u"?globalThis:Y||self,e(Y.Date={},Y.jsxRuntime,Y.React))})(this,function(Y,e,m){"use strict";const N=`@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
2
2
 
3
3
  * {
4
4
  margin: 0;
@@ -17,8 +17,12 @@
17
17
  /* color */
18
18
  --starasia-ui-date-color-black-secondary: var(
19
19
  --starasia-ui-color-gray-50,
20
- #f9fafb
20
+ rgba(249, 250, 251, 1)
21
21
  );
22
+ --starasia-ui-date-color-white: var(--starasia-ui-color-gray-50, rgba(255, 254, 255, 1));
23
+ --starasia-ui-date-color-border: rgba(120, 134, 127, 0.2);
24
+ --starasia-ui-date-color-disabled-border: rgba(120, 134, 127, 0.2);
25
+ --starasia-ui-date-color-disabled-bg: rgba(120, 134, 127, 0.1);
22
26
 
23
27
  /* box shadow */
24
28
  --starasia-ui-date-box-shadow: var(
@@ -31,19 +35,19 @@
31
35
  /* gray / black */
32
36
  --starasia-ui-date-color-primary-black: var(
33
37
  --starasia-ui-color-gray-700,
34
- #374151
38
+ rgba(55, 65, 81, 1)
35
39
  );
36
40
  --starasia-ui-date-color-secondary-black: var(
37
41
  --starasia-ui-color-gray-500,
38
- #6b7280
42
+ rgba(107, 114, 128, 1)
39
43
  );
40
44
  --starasia-ui-date-color-tertiary-black: var(
41
45
  --starasia-ui-color-gray-300,
42
- #d1d5db
46
+ rgba(209, 213, 219, 1)
43
47
  );
44
48
  --starasia-ui-date-color-quaternary-black: var(
45
49
  --starasia-ui-color-gray-50,
46
- #f9fafb
50
+ rgba(249, 250, 251, 1)
47
51
  );
48
52
 
49
53
  /* brand */
@@ -68,12 +72,12 @@
68
72
  /* color */
69
73
  --starasia-ui-input-color-tertiary-gray: var(
70
74
  --starasia-ui-color-gray-300,
71
- #d1d5db
75
+ rgba(209, 213, 219, 1)
72
76
  );
73
77
 
74
78
  --starasia-ui-date-placholder-color: var(
75
79
  --starasia-ui-color-gray-200,
76
- #c9cecc
80
+ rgba(201, 206, 204, 1)
77
81
  );
78
82
  --starasia-ui-date-placholder-fontWeight: var(
79
83
  --starasia-ui-fontWeights-normal,
@@ -82,11 +86,11 @@
82
86
 
83
87
  --starasia-ui-input-color-secondary-red: var(
84
88
  --starasia-ui-color-red-500,
85
- #ef4444
89
+ rgba(239, 68, 68, 1)
86
90
  );
87
91
  --starasia-ui-input-color-secondary-yellow: var(
88
92
  --starasia-ui-color-yellow-500,
89
- #eab308
93
+ rgba(234, 179, 8, 1)
90
94
  );
91
95
  }
92
96
  .starasia-calendar-wrapper {
@@ -116,7 +120,7 @@
116
120
  width: 100%;
117
121
  box-shadow: unset;
118
122
  border: none;
119
- background-color: white;
123
+ background-color: var(--starasia-ui-date-color-white);
120
124
  /* background-color: white; */
121
125
  height: 100%;
122
126
  border-radius: 0;
@@ -247,13 +251,13 @@
247
251
  .starasia-calendar-input-container:has(input:disabled) {
248
252
  /* border-color: var(--starasia-ui-input-color-tertiary-gray); */
249
253
  /* background-color: var(--starasia-ui-input-color-tertiary-gray); */
250
- border-color: rgba(120, 134, 127, 0.2);
251
- background-color: rgba(120, 134, 127, 0.1);
254
+ border-color: var(--starasia-ui-date-color-disabled-border);
255
+ background-color: var(--starasia-ui-date-color-disabled-bg);
252
256
  pointer-events: none;
253
257
  }
254
258
 
255
259
  .starasia-calendar-input-outline {
256
- border-color: rgba(120, 134, 127, 0.2);
260
+ border-color: var(--starasia-ui-date-color-border);
257
261
  /* border-color: var(--starasia-ui-date-color-tertiary-black); */
258
262
  background-color: transparent;
259
263
  border-width: var(--starasia-ui-border, 1px);
@@ -319,4 +323,4 @@
319
323
  .starasia-calendar-input-container-warning {
320
324
  border-color: var(--starasia-ui-input-color-secondary-yellow) !important;
321
325
  }
322
- `,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(n){const[a,s]=m.useState(n),i=m.useRef(null),o=g=>{i.current&&!i.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:i,isComponentVisible:a,setIsComponentVisible:s}}const V="starasia-calendar-input-styles";(n=>{if(!document.getElementById(V)){const a=document.createElement("style");a.id=V,a.textContent=n,document.head.appendChild(a)}})(N);const S=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},J=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return r.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[r.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("div",{className:"starasia-calendar-input-preview-container",children:r.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),r.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},P=({date:n,setDate:a,dateRange:s,setDateRange:i,onChange:o,minDate:g,maxDate:f,input:w})=>{var u,t,c;let h=new Date(n.getFullYear(),n.getMonth(),1),e=h.getDay(),k=[];const v=n.getMonth();for(let d=0;d<42;d++){d===0&&e===0?h.setDate(h.getDate()-7):d===0?h.setDate(h.getDate()+(d-e)):h.setDate(h.getDate()+1);let y={currentMonth:h.getMonth()===v,date:new Date(h),month:h.getMonth(),number:h.getDate(),selected:h.toDateString()===((u=s.from)==null?void 0:u.toDateString())||h.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((c=s.from)==null?void 0:c.toDateString())),year:h.getFullYear(),isDisabled:g&&h<g||f&&h>f};k.push(y)}const M=d=>{a(d)},x=d=>{var l;let y={...s};if(y.from&&y.to)y={from:d,to:null};else{const p=((l=y.from)==null?void 0:l.getTime())||0;d.getTime()>p?y={from:y.from,to:d}:y={from:d,to:y.from}}i(y),o(y)};return r.jsxs("div",{className:"starasia-calendar-days-preivew",children:[r.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((d,y)=>r.jsx("p",{children:d},y))}),r.jsx("div",{className:"starasia-calendar-days-number-preivew",children:k.map((d,y)=>{var D;const l=d.date.getTime()>s.from.getTime()&&d.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),p=d.isDisabled;return r.jsx("p",{className:`${d.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${d.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:l?"rgba(100, 181, 246, 0.1)":"",pointerEvents:p?"none":void 0,cursor:p?"not-allowed":"pointer",color:p?"#ccc":l?"#b0b0b0":"",...w?{}:{width:"100%"}},onClick:()=>{p||(M(d.date),x(d.date))},children:d.number},y)})})]})},G=({date:n,setDate:a,filter:s,setViews:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:e})=>{const k=o.from.getFullYear(),v=n.getFullYear(),M=u=>{s?(x(u),a(u)):(i("days"),a(u))},x=u=>{var c;let t={...o};if(t.from&&t.to)t={from:u,to:null};else{const d=((c=t.from)==null?void 0:c.getTime())||0;u.getTime()>d?t={from:t.from,to:u}:t={from:u,to:t.from}}g(t),f(t)};return r.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{var y,l,p;const c=new Date(v,t).getTime()>o.from.getTime()&&new Date(v,t).getTime()<(((y=o.to)==null?void 0:y.getTime())||o.from.getTime()),d=w&&new Date(v,t)<w||h&&new Date(v,t)>h;return r.jsx("p",{className:k===v&&(t===((l=o.from)==null?void 0:l.getMonth())||t===((p=o.to)==null?void 0:p.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:c?"rgba(100, 181, 246, 0.1)":"",pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",color:d?"#ccc":c?"#b0b0b0":"",...e?{}:{width:"100%"}},onClick:()=>{d||M(new Date(v,t))},children:u.slice(0,3)},t)})})},T=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},U=({date:n,filter:a,setViews:s,setDate:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:e})=>{var y;let k=[];const v=n.getFullYear(),{start:M,end:x}=T(v),u=o.from.getFullYear(),t=(y=o.to)==null?void 0:y.getFullYear();for(let l=M;l<x;l++){const p=new Date(l,0),D=(!w||p>=w)&&(!h||p<=h),C=l===u||l===t,b=p>o.from&&p<o.to;k.push({year:l,active:C&&D,highlight:b&&D,disabled:!D})}const c=l=>{a?(d(l),i(l)):(i(l),s("months"))},d=l=>{var D;let p={...o};if(p.from&&p.to)p={from:l,to:null};else{const C=((D=p.from)==null?void 0:D.getTime())||0;l.getTime()>C?p={from:p.from,to:l}:p={from:l,to:p.from}}g(p),f(p)};return r.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((l,p)=>r.jsx("p",{className:`${l.active?"starasia-calendar-months-active":""} ${l.highlight?"starasia-calendar-months-highlight":""} ${l.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{l.disabled||c(new Date(l.year,0))},style:{backgroundColor:l.highlight?"rgba(100, 181, 246, 0.1)":"",color:l.highlight?"#b0b0b0":l.active?"":l.disabled?"#ccc":"",cursor:l.disabled?"not-allowed":"pointer",pointerEvents:l.disbled?"none":"all",...e?{}:{width:"100%"}},children:l.year},p))})},W=({...n})=>r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:r.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),z=({...n})=>r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:r.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:n,views:a,filter:s,date:i,setDate:o})=>{const g=()=>{s||n(e=>e==="days"?"months":e==="months"?"years":"days")},f=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()+10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()+1,e.getMonth()));return}o(e=>new Date(e.getFullYear(),e.getMonth()+1))},w=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()-10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()-1,e.getMonth()));return}o(e=>new Date(e.getMonth()===0?e.getFullYear()-1:e.getFullYear(),e.getMonth()===0?11:e.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${T(i.getFullYear()).start} ~ ${T(i.getFullYear()).end}`};return r.jsxs("div",{className:"starasia-calendar-header",children:[r.jsx(W,{onClick:()=>w()}),r.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),r.jsx(z,{onClick:()=>f()})]})};function E(n){const a=new Date(n),s=a.getFullYear(),i=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${q[i]} ${s}`}const O="starasia-calendar-styles";(n=>{if(!document.getElementById(O)){const a=document.createElement("style");a.id=O,a.textContent=n,document.head.appendChild(a)}})(N);const Q=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:e},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState({from:(n==null?void 0:n.from)||new Date,to:(n==null?void 0:n.to)||new Date});m.useEffect(()=>{n?(y(n.from),p(n)):(y(new Date),p({from:new Date,to:new Date}))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>{var b,$;if(!n)return"";if(s){if(t==="days")return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`;if(t==="months")return`${F[l.from.getMonth()]} ~ ${l.to?F[l.to.getMonth()]:"-"}`;if(t==="years")return`${(b=l.from)==null?void 0:b.getFullYear()} ~ ${(($=l.to)==null?void 0:$.getFullYear())||"-"}`}else return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`},C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),r.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?r.jsx(J,{value:D(),inputMode:"none",onClick:()=>{x(!0)},onChange:()=>{},disabled:o,placeholder:w,size:h,status:e}):null,M?r.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[r.jsx(K,{setViews:c,views:t,filter:s,date:d,setDate:y}),r.jsx("div",{className:"starasia-calendar-body",children:t==="days"?r.jsx(P,{date:d,setDate:y,setIsComponentVisible:x,dateRange:l,setDateRange:p,input:i,onChange:a,minDate:g,maxDate:f}):t==="months"?r.jsx(G,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f}):r.jsx(U,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f})})]}):null]})}),H="starasia-calendar-input-styles";(n=>{if(!document.getElementById(H)){const a=document.createElement("style");a.id=H,a.textContent=n,document.head.appendChild(a)}})(N);const L=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},X=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return r.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[r.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r.jsx("div",{className:"starasia-calendar-input-preview-container",children:r.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),r.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:r.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:r.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:n,setDate:a,previewDate:s,setPreviewDate:i,setIsComponentVisible:o,minDate:g,maxDate:f,input:w,onChange:h})=>{let e=new Date(s.getFullYear(),s.getMonth(),1),k=e.getDay(),v=[];const M=n.toDateString(),x=s.getMonth();for(let t=0;t<42;t++){t===0&&k===0?e.setDate(e.getDate()-7):t===0?e.setDate(e.getDate()+(t-k)):e.setDate(e.getDate()+1);let c={currentMonth:e.getMonth()===x,date:new Date(e),month:e.getMonth(),number:e.getDate(),selected:e.toDateString()===M,year:e.getFullYear(),isDisabled:g&&e<g||f&&e>f};v.push(c)}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(a(t),h(t),i(t),w&&o(!1))};return r.jsxs("div",{className:"starasia-calendar-days-preivew",children:[r.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((t,c)=>r.jsx("p",{children:t},c))}),r.jsx("div",{className:"starasia-calendar-days-number-preivew",children:v.map((t,c)=>{const d=t.isDisabled;return r.jsx("p",{className:`${t.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${t.selected?"starasia-calendar-days-active":""}`,style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{d||u(t.date)},children:t.number},c)})})]})},_=({date:n,setDate:a,filter:s,setViews:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:e})=>{const k=n.getMonth(),v=n.getFullYear(),M=g.getFullYear(),x=u=>{(!w||u>=w)&&(!h||u<=h)&&(s?(o(u),a(u),f(u)):(i("days"),f(u)))};return r.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{const c=w&&new Date(M,t,1)<w||h&&new Date(M,t+1,0)>h;return r.jsx("p",{className:t===k&&M===v?"starasia-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...e?{}:{width:"100%"}},onClick:()=>{c||x(new Date(M,t))},children:u.slice(0,3)},t)})})},I=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},R=({date:n,filter:a,setViews:s,setDate:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:e})=>{let k=[];const v=g.getFullYear(),{start:M,end:x}=I(v),u=n.getFullYear();for(let c=M;c<x;c++){let d=w&&new Date(c,0,1)<w||h&&new Date(c,11,31)>h;k.push({year:c,active:c===u,isDisabled:d})}const t=c=>{(!w||c>=w)&&(!h||c<=h)&&(a?(o(c),i(c),f(c)):(s("months"),f(c)))};return r.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((c,d)=>r.jsx("p",{className:c.active?"starasia-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...e?{}:{width:"100%"}},onClick:()=>{c.isDisabled||t(new Date(c.year,0))},children:c.year},d))})},aa=({setViews:n,views:a,filter:s,previewDate:i,setPreviewDate:o})=>{const g=()=>{s||n(e=>e==="days"?"months":e==="months"?"years":"days")},f=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()+10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()+1,e.getMonth()));return}o(e=>new Date(e.getFullYear(),e.getMonth()+1))},w=()=>{if(a==="years"){o(e=>new Date(e.getFullYear()-10,0));return}if(a==="months"){o(e=>new Date(e.getFullYear()-1,e.getMonth()));return}o(e=>new Date(e.getMonth()===0?e.getFullYear()-1:e.getFullYear(),e.getMonth()===0?11:e.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${I(i.getFullYear()).start} ~ ${I(i.getFullYear()).end}`};return r.jsxs("div",{className:"starasia-calendar-header",children:[r.jsx(W,{onClick:()=>w()}),r.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),r.jsx(z,{onClick:()=>f()})]})},A="starasia-calendar-styles";(n=>{if(!document.getElementById(A)){const a=document.createElement("style");a.id=A,a.textContent=n,document.head.appendChild(a)}})(N);const ea=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:e},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState(new Date);m.useEffect(()=>{n?(y(n),p(n)):(y(new Date),p(new Date))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>n?s==="days"?E(d):s==="months"?`${F[d.getMonth()]} ${d.getFullYear()}`:s==="years"?d.getFullYear():E(d):"",C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),r.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?r.jsx(X,{value:D(),onClick:()=>x(!0),onChange:()=>{},placeholder:w,disabled:o,size:h,status:e,inputMode:"none"}):null,M?r.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[r.jsx(aa,{setViews:c,views:t,filter:s,previewDate:l,setPreviewDate:p,isComponentVisible:M}),r.jsx("div",{className:"starasia-calendar-body",children:t==="days"?r.jsx(Z,{date:d,setDate:y,previewDate:l,setPreviewDate:p,setIsComponentVisible:x,input:i,minDate:g,maxDate:f,onChange:a}):t==="months"?r.jsx(_,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i}):r.jsx(R,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i})})]}):null]})}),ra=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,rangedDate:o,disabled:g,minDate:f,maxDate:w,placeholder:h,size:e,status:k},v)=>r.jsx(r.Fragment,{children:o?r.jsx(Q,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:e,status:k}):r.jsx(ea,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:e,status:k})}));Y.StarasiaDate=ra,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
326
+ `,j=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],F=["January","February","March","April","May","June","July","August","September","October","November","December"],q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function B(n){const[a,s]=m.useState(n),i=m.useRef(null),o=g=>{i.current&&!i.current.contains(g.target)&&s(!1)};return m.useEffect(()=>(document.addEventListener("click",o,!0),()=>{document.removeEventListener("click",o,!0)}),[]),{ref:i,isComponentVisible:a,setIsComponentVisible:s}}const V="starasia-calendar-input-styles";(n=>{if(!document.getElementById(V)){const a=document.createElement("style");a.id=V,a.textContent=n,document.head.appendChild(a)}})(N);const S=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},J=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return e.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[e.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"starasia-calendar-input-preview-container",children:e.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),e.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:S(a),height:S(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},P=({date:n,setDate:a,dateRange:s,setDateRange:i,onChange:o,minDate:g,maxDate:f,input:w})=>{var u,t,c;let h=new Date(n.getFullYear(),n.getMonth(),1),r=h.getDay(),k=[];const v=n.getMonth();for(let d=0;d<42;d++){d===0&&r===0?h.setDate(h.getDate()-7):d===0?h.setDate(h.getDate()+(d-r)):h.setDate(h.getDate()+1);let y={currentMonth:h.getMonth()===v,date:new Date(h),month:h.getMonth(),number:h.getDate(),selected:h.toDateString()===((u=s.from)==null?void 0:u.toDateString())||h.toDateString()===(((t=s.to)==null?void 0:t.toDateString())||((c=s.from)==null?void 0:c.toDateString())),year:h.getFullYear(),isDisabled:g&&h<g||f&&h>f};k.push(y)}const M=d=>{a(d)},x=d=>{var l;let y={...s};if(y.from&&y.to)y={from:d,to:null};else{const p=((l=y.from)==null?void 0:l.getTime())||0;d.getTime()>p?y={from:y.from,to:d}:y={from:d,to:y.from}}i(y),o(y)};return e.jsxs("div",{className:"starasia-calendar-days-preivew",children:[e.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((d,y)=>e.jsx("p",{children:d},y))}),e.jsx("div",{className:"starasia-calendar-days-number-preivew",children:k.map((d,y)=>{var D;const l=d.date.getTime()>s.from.getTime()&&d.date.getTime()<(((D=s.to)==null?void 0:D.getTime())||s.from.getTime()),p=d.isDisabled;return e.jsx("p",{className:`${d.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${d.selected?"starasia-calendar-days-active":""}`,style:{backgroundColor:l?"rgba(100, 181, 246, 0.1)":"",pointerEvents:p?"none":void 0,cursor:p?"not-allowed":"pointer",color:p?"#ccc":l?"#b0b0b0":"",...w?{}:{width:"100%"}},onClick:()=>{p||(M(d.date),x(d.date))},children:d.number},y)})})]})},G=({date:n,setDate:a,filter:s,setViews:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:r})=>{const k=o.from.getFullYear(),v=n.getFullYear(),M=u=>{s?(x(u),a(u)):(i("days"),a(u))},x=u=>{var c;let t={...o};if(t.from&&t.to)t={from:u,to:null};else{const d=((c=t.from)==null?void 0:c.getTime())||0;u.getTime()>d?t={from:t.from,to:u}:t={from:u,to:t.from}}g(t),f(t)};return e.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{var y,l,p;const c=new Date(v,t).getTime()>o.from.getTime()&&new Date(v,t).getTime()<(((y=o.to)==null?void 0:y.getTime())||o.from.getTime()),d=w&&new Date(v,t)<w||h&&new Date(v,t)>h;return e.jsx("p",{className:k===v&&(t===((l=o.from)==null?void 0:l.getMonth())||t===((p=o.to)==null?void 0:p.getMonth()))?"starasia-calendar-months-active":"",style:{backgroundColor:c?"rgba(100, 181, 246, 0.1)":"",pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",color:d?"#ccc":c?"#b0b0b0":"",...r?{}:{width:"100%"}},onClick:()=>{d||M(new Date(v,t))},children:u.slice(0,3)},t)})})},T=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},U=({date:n,filter:a,setViews:s,setDate:i,dateRange:o,setDateRange:g,onChange:f,minDate:w,maxDate:h,input:r})=>{var y;let k=[];const v=n.getFullYear(),{start:M,end:x}=T(v),u=o.from.getFullYear(),t=(y=o.to)==null?void 0:y.getFullYear();for(let l=M;l<x;l++){const p=new Date(l,0),D=(!w||p>=w)&&(!h||p<=h),C=l===u||l===t,b=p>o.from&&p<o.to;k.push({year:l,active:C&&D,highlight:b&&D,disabled:!D})}const c=l=>{a?(d(l),i(l)):(i(l),s("months"))},d=l=>{var D;let p={...o};if(p.from&&p.to)p={from:l,to:null};else{const C=((D=p.from)==null?void 0:D.getTime())||0;l.getTime()>C?p={from:p.from,to:l}:p={from:l,to:p.from}}g(p),f(p)};return e.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((l,p)=>e.jsx("p",{className:`${l.active?"starasia-calendar-months-active":""} ${l.highlight?"starasia-calendar-months-highlight":""} ${l.disabled?"starasia-calendar-disabled":""}`,onClick:()=>{l.disabled||c(new Date(l.year,0))},style:{backgroundColor:l.highlight?"rgba(100, 181, 246, 0.1)":"",color:l.highlight?"#b0b0b0":l.active?"":l.disabled?"#ccc":"",cursor:l.disabled?"not-allowed":"pointer",pointerEvents:l.disbled?"none":"all",...r?{}:{width:"100%"}},children:l.year},p))})},W=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M12.5 3.33334L5.83337 10L12.5 16.6667",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),z=({...n})=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",...n,children:e.jsx("path",{d:"M7.5 16.6667L14.1667 10L7.5 3.33334",stroke:"#001A72",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})}),K=({setViews:n,views:a,filter:s,date:i,setDate:o})=>{const g=()=>{s||n(r=>r==="days"?"months":r==="months"?"years":"days")},f=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()+10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()+1,r.getMonth()));return}o(r=>new Date(r.getFullYear(),r.getMonth()+1))},w=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()-10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()-1,r.getMonth()));return}o(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${T(i.getFullYear()).start} ~ ${T(i.getFullYear()).end}`};return e.jsxs("div",{className:"starasia-calendar-header",children:[e.jsx(W,{onClick:()=>w()}),e.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),e.jsx(z,{onClick:()=>f()})]})};function E(n){const a=new Date(n),s=a.getFullYear(),i=a.getMonth();return`${a.getDate().toString().padStart(2,"0")} ${q[i]} ${s}`}const O="starasia-calendar-styles";(n=>{if(!document.getElementById(O)){const a=document.createElement("style");a.id=O,a.textContent=n,document.head.appendChild(a)}})(N);const Q=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:r},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState({from:(n==null?void 0:n.from)||new Date,to:(n==null?void 0:n.to)||new Date});m.useEffect(()=>{n?(y(n.from),p(n)):(y(new Date),p({from:new Date,to:new Date}))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>{var b,$;if(!n)return"";if(s){if(t==="days")return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`;if(t==="months")return`${F[l.from.getMonth()]} ~ ${l.to?F[l.to.getMonth()]:"-"}`;if(t==="years")return`${(b=l.from)==null?void 0:b.getFullYear()} ~ ${(($=l.to)==null?void 0:$.getFullYear())||"-"}`}else return`${E(l.from)} ~ ${E(l.to||l.from)||"-"}`},C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),e.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?e.jsx(J,{value:D(),inputMode:"none",onClick:()=>{x(!0)},onChange:()=>{},disabled:o,placeholder:w,size:h,status:r}):null,M?e.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[e.jsx(K,{setViews:c,views:t,filter:s,date:d,setDate:y}),e.jsx("div",{className:"starasia-calendar-body",children:t==="days"?e.jsx(P,{date:d,setDate:y,setIsComponentVisible:x,dateRange:l,setDateRange:p,input:i,onChange:a,minDate:g,maxDate:f}):t==="months"?e.jsx(G,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f}):e.jsx(U,{date:d,setDate:y,filter:s,setViews:c,dateRange:l,setDateRange:p,setIsComponentVisible:x,input:i,onChange:a,minDate:g,maxDate:f})})]}):null]})}),H="starasia-calendar-input-styles";(n=>{if(!document.getElementById(H)){const a=document.createElement("style");a.id=H,a.textContent=n,document.head.appendChild(a)}})(N);const L=n=>{if(n==="sm")return 16;if(n==="md")return 16;if(n==="lg")return 20},X=n=>{const{size:a="md",status:s="default",variant:i="outline",...o}=n,g=m.useRef(null),f=()=>{g.current&&o.onClick&&(g.current.focus(),o.onClick(""))};return e.jsxs("div",{className:`starasia-calendar-input-container starasia-calendar-input-${i} starasia-calendar-input-container-${s} ${a} `,onClick:f,children:[e.jsx("div",{className:"starasia-calendar-input-container-icon-left",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M12.5 2.08301V5.41634M7.50002 2.08301V5.41634M17.0688 9.58301H2.93113M17.0688 9.58301C16.8953 4.82698 15.1284 3.33301 10 3.33301C4.87165 3.33301 3.10469 4.82698 2.93113 9.58301M17.0688 9.58301C17.0786 9.85037 17.0834 10.128 17.0834 10.4163C17.0834 15.833 15.4167 17.4997 10 17.4997C4.58335 17.4997 2.91669 15.833 2.91669 10.4163C2.91669 10.128 2.92138 9.85037 2.93113 9.58301",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("div",{className:"starasia-calendar-input-preview-container",children:e.jsx("input",{className:"starasia-calendar-input",...o,disabled:s==="disable"?!0:o.disabled,value:o.value,ref:g})}),e.jsx("div",{className:"starasia-calendar-input-container-icon-right",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:L(a),height:L(a),viewBox:"0 0 20 20",fill:"none",children:e.jsx("path",{d:"M3.33331 7.5L9.99998 14.1667L16.6666 7.5",stroke:"#939E99",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})},Z=({date:n,setDate:a,previewDate:s,setPreviewDate:i,setIsComponentVisible:o,minDate:g,maxDate:f,input:w,onChange:h})=>{let r=new Date(s.getFullYear(),s.getMonth(),1),k=r.getDay(),v=[];const M=n.toDateString(),x=s.getMonth();for(let t=0;t<42;t++){t===0&&k===0?r.setDate(r.getDate()-7):t===0?r.setDate(r.getDate()+(t-k)):r.setDate(r.getDate()+1);let c={currentMonth:r.getMonth()===x,date:new Date(r),month:r.getMonth(),number:r.getDate(),selected:r.toDateString()===M,year:r.getFullYear(),isDisabled:g&&r<g||f&&r>f};v.push(c)}const u=t=>{(!g||t>=g)&&(!f||t<=f)&&(a(t),h(t),i(t),w&&o(!1))};return e.jsxs("div",{className:"starasia-calendar-days-preivew",children:[e.jsx("div",{className:"starasia-calendar-days-name-preivew",children:j.map((t,c)=>e.jsx("p",{children:t},c))}),e.jsx("div",{className:"starasia-calendar-days-number-preivew",children:v.map((t,c)=>{const d=t.isDisabled;return e.jsx("p",{className:`${t.currentMonth?"starasia-calendar-days-current":"starasia-calendar-days"} ${t.selected?"starasia-calendar-days-active":""}`,style:{color:d?"#ccc":void 0,pointerEvents:d?"none":void 0,cursor:d?"not-allowed":"pointer",...w?{}:{width:"100%"}},onClick:()=>{d||u(t.date)},children:t.number},c)})})]})},_=({date:n,setDate:a,filter:s,setViews:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:r})=>{const k=n.getMonth(),v=n.getFullYear(),M=g.getFullYear(),x=u=>{(!w||u>=w)&&(!h||u<=h)&&(s?(o(u),a(u),f(u)):(i("days"),f(u)))};return e.jsx("div",{className:"starasia-calendar-months-preview",children:F.map((u,t)=>{const c=w&&new Date(M,t,1)<w||h&&new Date(M,t+1,0)>h;return e.jsx("p",{className:t===k&&M===v?"starasia-calendar-months-active":"",style:{color:c?"#ccc":void 0,pointerEvents:c?"none":void 0,cursor:c?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{c||x(new Date(M,t))},children:u.slice(0,3)},t)})})},I=n=>{const a=Math.floor(n/10)*10,s=a+10;return{start:a,end:s}},R=({date:n,filter:a,setViews:s,setDate:i,onChange:o,previewDate:g,setPreviewDate:f,minDate:w,maxDate:h,input:r})=>{let k=[];const v=g.getFullYear(),{start:M,end:x}=I(v),u=n.getFullYear();for(let c=M;c<x;c++){let d=w&&new Date(c,0,1)<w||h&&new Date(c,11,31)>h;k.push({year:c,active:c===u,isDisabled:d})}const t=c=>{(!w||c>=w)&&(!h||c<=h)&&(a?(o(c),i(c),f(c)):(s("months"),f(c)))};return e.jsx("div",{className:"starasia-calendar-years-preview",children:k.map((c,d)=>e.jsx("p",{className:c.active?"starasia-calendar-months-active":"",style:{color:c.isDisabled?"#ccc":void 0,pointerEvents:c.isDisabled?"none":void 0,cursor:c.isDisabled?"not-allowed":"pointer",...r?{}:{width:"100%"}},onClick:()=>{c.isDisabled||t(new Date(c.year,0))},children:c.year},d))})},aa=({setViews:n,views:a,filter:s,previewDate:i,setPreviewDate:o})=>{const g=()=>{s||n(r=>r==="days"?"months":r==="months"?"years":"days")},f=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()+10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()+1,r.getMonth()));return}o(r=>new Date(r.getFullYear(),r.getMonth()+1))},w=()=>{if(a==="years"){o(r=>new Date(r.getFullYear()-10,0));return}if(a==="months"){o(r=>new Date(r.getFullYear()-1,r.getMonth()));return}o(r=>new Date(r.getMonth()===0?r.getFullYear()-1:r.getFullYear(),r.getMonth()===0?11:r.getMonth()-1))},h=()=>{if(a==="days")return`${F[i.getMonth()]} ${i.getFullYear()}`;if(a==="months")return`${i.getFullYear()}`;if(a==="years")return`${I(i.getFullYear()).start} ~ ${I(i.getFullYear()).end}`};return e.jsxs("div",{className:"starasia-calendar-header",children:[e.jsx(W,{onClick:()=>w()}),e.jsx("div",{style:{cursor:"pointer"},onClick:g,children:h()}),e.jsx(z,{onClick:()=>f()})]})},A="starasia-calendar-styles";(n=>{if(!document.getElementById(A)){const a=document.createElement("style");a.id=A,a.textContent=n,document.head.appendChild(a)}})(N);const ra=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,disabled:o,minDate:g,maxDate:f,placeholder:w,size:h,status:r},k)=>{const{ref:v,isComponentVisible:M,setIsComponentVisible:x}=B(!1),u=m.useRef(null),[t,c]=m.useState("days"),[d,y]=m.useState(new Date),[l,p]=m.useState(new Date);m.useEffect(()=>{n?(y(n),p(n)):(y(new Date),p(new Date))},[n]),m.useEffect(()=>{s&&c(s)},[s]),m.useEffect(()=>{s||c("days")},[M]),m.useEffect(()=>{i||x(!0)},[i]);const D=()=>n?s==="days"?E(d):s==="months"?`${F[d.getMonth()]} ${d.getFullYear()}`:s==="years"?d.getFullYear():E(d):"",C=()=>{if(u.current&&v.current&&i){const b=v.current.getBoundingClientRect(),$=u.current.getBoundingClientRect();window.innerWidth<b.left+$.width?u.current.style.left=`${b.left-$.width+b.width}px`:u.current.style.left=`${b.left}px`,b.top+$.height>window.innerHeight?u.current.style.top=`${b.y-(b.height+$.height-28)}px`:u.current.style.top=`${b.y+b.height}px`}};return m.useEffect(()=>{u.current&&v.current&&i&&C()},[u,v,M]),m.useEffect(()=>{const b=k==null?void 0:k.current;return b&&b.addEventListener("scroll",C),window.addEventListener("scroll",C),()=>{b&&b.removeEventListener("scroll",C),window.removeEventListener("scroll",C)}},[]),e.jsxs("div",{className:"starasia-calendar-wrapper",style:{height:i?"auto":"100%"},ref:i?v:null,children:[i?e.jsx(X,{value:D(),onClick:()=>x(!0),onChange:()=>{},placeholder:w,disabled:o,size:h,status:r,inputMode:"none"}):null,M?e.jsxs("div",{className:`starasia-calendar ${i?"":"starasia-calendar-no-input"}`,ref:u,children:[e.jsx(aa,{setViews:c,views:t,filter:s,previewDate:l,setPreviewDate:p,isComponentVisible:M}),e.jsx("div",{className:"starasia-calendar-body",children:t==="days"?e.jsx(Z,{date:d,setDate:y,previewDate:l,setPreviewDate:p,setIsComponentVisible:x,input:i,minDate:g,maxDate:f,onChange:a}):t==="months"?e.jsx(_,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i}):e.jsx(R,{date:d,setDate:y,previewDate:l,setPreviewDate:p,filter:s,setViews:c,onChange:a,minDate:g,maxDate:f,input:i})})]}):null]})}),ea=m.forwardRef(({value:n,onChange:a,filter:s,input:i=!0,rangedDate:o,disabled:g,minDate:f,maxDate:w,placeholder:h,size:r,status:k},v)=>e.jsx(e.Fragment,{children:o?e.jsx(Q,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:r,status:k}):e.jsx(ra,{onChange:a,value:n,input:i,filter:s,disabled:g,ref:v,minDate:f,maxDate:w,placeholder:h,size:r,status:k})}));Y.StarasiaDate=ea,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",