@starasia/date 1.0.2 → 1.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
@@ -48,23 +48,11 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
48
48
  #f9fafb
49
49
  );
50
50
 
51
- /* gray / blue */
52
- --starasia-ui-date-color-primary-blue: var(
53
- --starasia-ui-color-blue-500,
54
- #3b82f6
55
- );
56
- --starasia-ui-date-color-secondary-blue: var(
57
- --starasia-ui-color-blue-500,
58
- #3b82f6
59
- );
60
- --starasia-ui-date-color-tertiary-blue: var(
61
- --starasia-ui-color-blue-300,
62
- #93c5fd
63
- );
64
- --starasia-ui-date-color-quaternary-blue: var(
65
- --starasia-ui-color-blue-50,
66
- #eff6ff
67
- );
51
+ /* brand */
52
+ --starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default);
53
+ --starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default);
54
+ --starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
55
+ --starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
68
56
 
69
57
  /* spacing */
70
58
  --starasia-ui-date-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
@@ -256,7 +244,7 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
256
244
 
257
245
  .starasia-calendar-input-container:has(input:focus) {
258
246
  border-color: var(--starasia-ui-date-color-primary-blue);
259
- box-shadow: 0px 0px 0px 2px rgba(100, 181, 246, 0.2);
247
+ box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary), 0.2);
260
248
  }
261
249
  .starasia-calendar-input-container:has(input:disabled) {
262
250
  /* border-color: var(--starasia-ui-input-color-tertiary-gray); */
@@ -360,30 +348,30 @@ const I = `@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wg
360
348
  "Nov",
361
349
  "Dec"
362
350
  ];
363
- function J(n) {
364
- const [a, t] = F(n), s = E(null), i = (g) => {
351
+ function J(r) {
352
+ const [a, t] = F(r), s = E(null), i = (g) => {
365
353
  s.current && !s.current.contains(g.target) && t(!1);
366
354
  };
367
355
  return D(() => (document.addEventListener("click", i, !0), () => {
368
356
  document.removeEventListener("click", i, !0);
369
357
  }), []), { ref: s, isComponentVisible: a, setIsComponentVisible: t };
370
358
  }
371
- const j = "starasia-calendar-input-styles", U = (n) => {
359
+ const j = "starasia-calendar-input-styles", U = (r) => {
372
360
  if (!document.getElementById(j)) {
373
361
  const a = document.createElement("style");
374
- a.id = j, a.textContent = n, document.head.appendChild(a);
362
+ a.id = j, a.textContent = r, document.head.appendChild(a);
375
363
  }
376
364
  };
377
365
  U(I);
378
- const T = (n) => {
379
- if (n === "sm")
366
+ const T = (r) => {
367
+ if (r === "sm")
380
368
  return 16;
381
- if (n === "md")
369
+ if (r === "md")
382
370
  return 16;
383
- if (n === "lg")
371
+ if (r === "lg")
384
372
  return 20;
385
- }, K = (n) => {
386
- const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = n, g = E(null), f = () => {
373
+ }, K = (r) => {
374
+ const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = r, g = E(null), f = () => {
387
375
  g.current && i.onClick && (g.current.focus(), i.onClick(""));
388
376
  };
389
377
  return /* @__PURE__ */ $(
@@ -446,7 +434,7 @@ const T = (n) => {
446
434
  }
447
435
  );
448
436
  }, Q = ({
449
- date: n,
437
+ date: r,
450
438
  setDate: a,
451
439
  dateRange: t,
452
440
  setDateRange: s,
@@ -455,9 +443,9 @@ const T = (n) => {
455
443
  maxDate: f,
456
444
  input: v
457
445
  }) => {
458
- var u, r, c;
459
- let h = new Date(n.getFullYear(), n.getMonth(), 1), e = h.getDay(), w = [];
460
- const b = n.getMonth();
446
+ var u, n, c;
447
+ let h = new Date(r.getFullYear(), r.getMonth(), 1), e = h.getDay(), w = [];
448
+ const b = r.getMonth();
461
449
  for (let d = 0; d < 42; d++) {
462
450
  d === 0 && e === 0 ? h.setDate(h.getDate() - 7) : d === 0 ? h.setDate(
463
451
  h.getDate() + (d - e)
@@ -467,7 +455,7 @@ const T = (n) => {
467
455
  date: new Date(h),
468
456
  month: h.getMonth(),
469
457
  number: h.getDate(),
470
- selected: h.toDateString() === ((u = t.from) == null ? void 0 : u.toDateString()) || h.toDateString() === (((r = t.to) == null ? void 0 : r.toDateString()) || ((c = t.from) == null ? void 0 : c.toDateString())),
458
+ 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())),
471
459
  year: h.getFullYear(),
472
460
  isDisabled: g && h < g || f && h > f
473
461
  };
@@ -512,7 +500,7 @@ const T = (n) => {
512
500
  }) })
513
501
  ] });
514
502
  }, X = ({
515
- date: n,
503
+ date: r,
516
504
  setDate: a,
517
505
  filter: t,
518
506
  setViews: s,
@@ -523,26 +511,26 @@ const T = (n) => {
523
511
  maxDate: h,
524
512
  input: e
525
513
  }) => {
526
- const w = i.from.getFullYear(), b = n.getFullYear(), k = (u) => {
514
+ const w = i.from.getFullYear(), b = r.getFullYear(), k = (u) => {
527
515
  t ? (M(u), a(u)) : (s("days"), a(u));
528
516
  }, M = (u) => {
529
517
  var c;
530
- let r = { ...i };
531
- if (r.from && r.to)
532
- r = { from: u, to: null };
518
+ let n = { ...i };
519
+ if (n.from && n.to)
520
+ n = { from: u, to: null };
533
521
  else {
534
- const d = ((c = r.from) == null ? void 0 : c.getTime()) || 0;
535
- u.getTime() > d ? r = { from: r.from, to: u } : r = { from: u, to: r.from };
522
+ const d = ((c = n.from) == null ? void 0 : c.getTime()) || 0;
523
+ u.getTime() > d ? n = { from: n.from, to: u } : n = { from: u, to: n.from };
536
524
  }
537
- g(r), f(r);
525
+ g(n), f(n);
538
526
  };
539
- return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, r) => {
527
+ return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, n) => {
540
528
  var y, o, p;
541
- const c = new Date(b, r).getTime() > i.from.getTime() && new Date(b, r).getTime() < (((y = i.to) == null ? void 0 : y.getTime()) || i.from.getTime()), d = v && new Date(b, r) < v || h && new Date(b, r) > h;
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;
542
530
  return /* @__PURE__ */ l(
543
531
  "p",
544
532
  {
545
- className: w === b && (r === ((o = i.from) == null ? void 0 : o.getMonth()) || r === ((p = i.to) == null ? void 0 : p.getMonth())) ? "starasia-calendar-months-active" : "",
533
+ className: w === b && (n === ((o = i.from) == null ? void 0 : o.getMonth()) || n === ((p = i.to) == null ? void 0 : p.getMonth())) ? "starasia-calendar-months-active" : "",
546
534
  style: {
547
535
  backgroundColor: c ? "rgba(100, 181, 246, 0.1)" : "",
548
536
  pointerEvents: d ? "none" : void 0,
@@ -551,18 +539,18 @@ const T = (n) => {
551
539
  ...e ? {} : { width: "100%" }
552
540
  },
553
541
  onClick: () => {
554
- d || k(new Date(b, r));
542
+ d || k(new Date(b, n));
555
543
  },
556
544
  children: u.slice(0, 3)
557
545
  },
558
- r
546
+ n
559
547
  );
560
548
  }) });
561
- }, B = (n) => {
562
- const a = Math.floor(n / 10) * 10, t = a + 10;
549
+ }, B = (r) => {
550
+ const a = Math.floor(r / 10) * 10, t = a + 10;
563
551
  return { start: a, end: t };
564
552
  }, Z = ({
565
- date: n,
553
+ date: r,
566
554
  filter: a,
567
555
  setViews: t,
568
556
  setDate: s,
@@ -575,9 +563,9 @@ const T = (n) => {
575
563
  }) => {
576
564
  var y;
577
565
  let w = [];
578
- const b = n.getFullYear(), { start: k, end: M } = B(b), u = i.from.getFullYear(), r = (y = i.to) == null ? void 0 : y.getFullYear();
566
+ const b = r.getFullYear(), { start: k, end: M } = B(b), u = i.from.getFullYear(), n = (y = i.to) == null ? void 0 : y.getFullYear();
579
567
  for (let o = k; o < M; o++) {
580
- const p = new Date(o, 0), C = (!v || p >= v) && (!h || p <= h), x = o === u || o === r, m = p > i.from && p < i.to;
568
+ 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;
581
569
  w.push({
582
570
  year: o,
583
571
  active: x && C,
@@ -616,7 +604,7 @@ const T = (n) => {
616
604
  },
617
605
  p
618
606
  )) });
619
- }, q = ({ ...n }) => /* @__PURE__ */ l(
607
+ }, q = ({ ...r }) => /* @__PURE__ */ l(
620
608
  "svg",
621
609
  {
622
610
  xmlns: "http://www.w3.org/2000/svg",
@@ -624,7 +612,7 @@ const T = (n) => {
624
612
  height: "20",
625
613
  viewBox: "0 0 20 20",
626
614
  fill: "none",
627
- ...n,
615
+ ...r,
628
616
  children: /* @__PURE__ */ l(
629
617
  "path",
630
618
  {
@@ -636,7 +624,7 @@ const T = (n) => {
636
624
  }
637
625
  )
638
626
  }
639
- ), P = ({ ...n }) => /* @__PURE__ */ l(
627
+ ), P = ({ ...r }) => /* @__PURE__ */ l(
640
628
  "svg",
641
629
  {
642
630
  xmlns: "http://www.w3.org/2000/svg",
@@ -644,7 +632,7 @@ const T = (n) => {
644
632
  height: "20",
645
633
  viewBox: "0 0 20 20",
646
634
  fill: "none",
647
- ...n,
635
+ ...r,
648
636
  children: /* @__PURE__ */ l(
649
637
  "path",
650
638
  {
@@ -657,14 +645,14 @@ const T = (n) => {
657
645
  )
658
646
  }
659
647
  ), _ = ({
660
- setViews: n,
648
+ setViews: r,
661
649
  views: a,
662
650
  filter: t,
663
651
  date: s,
664
652
  setDate: i
665
653
  }) => {
666
654
  const g = () => {
667
- t || n((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
655
+ t || r((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
668
656
  }, f = () => {
669
657
  if (a === "years") {
670
658
  i((e) => new Date(e.getFullYear() + 10, 0));
@@ -704,20 +692,20 @@ const T = (n) => {
704
692
  /* @__PURE__ */ l(P, { onClick: () => f() })
705
693
  ] });
706
694
  };
707
- function L(n) {
708
- const a = new Date(n), t = a.getFullYear(), s = a.getMonth();
695
+ function L(r) {
696
+ const a = new Date(r), t = a.getFullYear(), s = a.getMonth();
709
697
  return `${a.getDate().toString().padStart(2, "0")} ${G[s]} ${t}`;
710
698
  }
711
- const z = "starasia-calendar-styles", aa = (n) => {
699
+ const z = "starasia-calendar-styles", aa = (r) => {
712
700
  if (!document.getElementById(z)) {
713
701
  const a = document.createElement("style");
714
- a.id = z, a.textContent = n, document.head.appendChild(a);
702
+ a.id = z, a.textContent = r, document.head.appendChild(a);
715
703
  }
716
704
  };
717
705
  aa(I);
718
706
  const ea = W(
719
707
  ({
720
- value: n,
708
+ value: r,
721
709
  onChange: a,
722
710
  filter: t,
723
711
  input: s = !0,
@@ -728,16 +716,16 @@ const ea = W(
728
716
  size: h,
729
717
  status: e
730
718
  }, w) => {
731
- const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [r, c] = F("days"), [d, y] = F(/* @__PURE__ */ new Date()), [o, p] = F({
732
- from: (n == null ? void 0 : n.from) || /* @__PURE__ */ new Date(),
733
- to: (n == null ? void 0 : n.to) || /* @__PURE__ */ new Date()
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({
720
+ from: (r == null ? void 0 : r.from) || /* @__PURE__ */ new Date(),
721
+ to: (r == null ? void 0 : r.to) || /* @__PURE__ */ new Date()
734
722
  });
735
723
  D(() => {
736
- n ? (y(n.from), p(n)) : (y(/* @__PURE__ */ new Date()), p({
724
+ r ? (y(r.from), p(r)) : (y(/* @__PURE__ */ new Date()), p({
737
725
  from: /* @__PURE__ */ new Date(),
738
726
  to: /* @__PURE__ */ new Date()
739
727
  }));
740
- }, [n]), D(() => {
728
+ }, [r]), D(() => {
741
729
  t && c(t);
742
730
  }, [t]), D(() => {
743
731
  t || c("days");
@@ -746,14 +734,14 @@ const ea = W(
746
734
  }, [s]);
747
735
  const C = () => {
748
736
  var m, Y;
749
- if (!n)
737
+ if (!r)
750
738
  return "";
751
739
  if (t) {
752
- if (r === "days")
740
+ if (n === "days")
753
741
  return `${L(o.from)} ~ ${L(o.to || o.from) || "-"}`;
754
- if (r === "months")
742
+ if (n === "months")
755
743
  return `${N[o.from.getMonth()]} ~ ${o.to ? N[o.to.getMonth()] : "-"}`;
756
- if (r === "years")
744
+ if (n === "years")
757
745
  return `${(m = o.from) == null ? void 0 : m.getFullYear()} ~ ${((Y = o.to) == null ? void 0 : Y.getFullYear()) || "-"}`;
758
746
  } else
759
747
  return `${L(o.from)} ~ ${L(o.to || o.from) || "-"}`;
@@ -803,13 +791,13 @@ const ea = W(
803
791
  _,
804
792
  {
805
793
  setViews: c,
806
- views: r,
794
+ views: n,
807
795
  filter: t,
808
796
  date: d,
809
797
  setDate: y
810
798
  }
811
799
  ),
812
- /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: r === "days" ? /* @__PURE__ */ l(
800
+ /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: n === "days" ? /* @__PURE__ */ l(
813
801
  Q,
814
802
  {
815
803
  date: d,
@@ -822,7 +810,7 @@ const ea = W(
822
810
  minDate: g,
823
811
  maxDate: f
824
812
  }
825
- ) : r === "months" ? /* @__PURE__ */ l(
813
+ ) : n === "months" ? /* @__PURE__ */ l(
826
814
  X,
827
815
  {
828
816
  date: d,
@@ -860,22 +848,22 @@ const ea = W(
860
848
  }
861
849
  );
862
850
  }
863
- ), O = "starasia-calendar-input-styles", na = (n) => {
851
+ ), O = "starasia-calendar-input-styles", ra = (r) => {
864
852
  if (!document.getElementById(O)) {
865
853
  const a = document.createElement("style");
866
- a.id = O, a.textContent = n, document.head.appendChild(a);
854
+ a.id = O, a.textContent = r, document.head.appendChild(a);
867
855
  }
868
856
  };
869
- na(I);
870
- const S = (n) => {
871
- if (n === "sm")
857
+ ra(I);
858
+ const S = (r) => {
859
+ if (r === "sm")
872
860
  return 16;
873
- if (n === "md")
861
+ if (r === "md")
874
862
  return 16;
875
- if (n === "lg")
863
+ if (r === "lg")
876
864
  return 20;
877
- }, ra = (n) => {
878
- const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = n, g = E(null), f = () => {
865
+ }, na = (r) => {
866
+ const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = r, g = E(null), f = () => {
879
867
  g.current && i.onClick && (g.current.focus(), i.onClick(""));
880
868
  };
881
869
  return /* @__PURE__ */ $(
@@ -938,7 +926,7 @@ const S = (n) => {
938
926
  }
939
927
  );
940
928
  }, ta = ({
941
- date: n,
929
+ date: r,
942
930
  setDate: a,
943
931
  previewDate: t,
944
932
  setPreviewDate: s,
@@ -953,10 +941,10 @@ const S = (n) => {
953
941
  t.getMonth(),
954
942
  1
955
943
  ), w = e.getDay(), b = [];
956
- const k = n.toDateString(), M = t.getMonth();
957
- for (let r = 0; r < 42; r++) {
958
- r === 0 && w === 0 ? e.setDate(e.getDate() - 7) : r === 0 ? e.setDate(
959
- e.getDate() + (r - w)
944
+ const k = r.toDateString(), M = t.getMonth();
945
+ for (let n = 0; n < 42; n++) {
946
+ n === 0 && w === 0 ? e.setDate(e.getDate() - 7) : n === 0 ? e.setDate(
947
+ e.getDate() + (n - w)
960
948
  ) : e.setDate(e.getDate() + 1);
961
949
  let c = {
962
950
  currentMonth: e.getMonth() === M,
@@ -969,17 +957,17 @@ const S = (n) => {
969
957
  };
970
958
  b.push(c);
971
959
  }
972
- const u = (r) => {
973
- (!g || r >= g) && (!f || r <= f) && (a(r), h(r), s(r), v && i(!1));
960
+ const u = (n) => {
961
+ (!g || n >= g) && (!f || n <= f) && (a(n), h(n), s(n), v && i(!1));
974
962
  };
975
963
  return /* @__PURE__ */ $("div", { className: "starasia-calendar-days-preivew", children: [
976
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((r, c) => /* @__PURE__ */ l("p", { children: r }, c)) }),
977
- /* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: b.map((r, c) => {
978
- const d = r.isDisabled;
964
+ /* @__PURE__ */ l("div", { className: "starasia-calendar-days-name-preivew", children: A.map((n, c) => /* @__PURE__ */ l("p", { children: n }, c)) }),
965
+ /* @__PURE__ */ l("div", { className: "starasia-calendar-days-number-preivew", children: b.map((n, c) => {
966
+ const d = n.isDisabled;
979
967
  return /* @__PURE__ */ l(
980
968
  "p",
981
969
  {
982
- className: `${r.currentMonth ? "starasia-calendar-days-current" : "starasia-calendar-days"} ${r.selected ? "starasia-calendar-days-active" : ""}`,
970
+ className: `${n.currentMonth ? "starasia-calendar-days-current" : "starasia-calendar-days"} ${n.selected ? "starasia-calendar-days-active" : ""}`,
983
971
  style: {
984
972
  color: d ? "#ccc" : void 0,
985
973
  pointerEvents: d ? "none" : void 0,
@@ -987,16 +975,16 @@ const S = (n) => {
987
975
  ...v ? {} : { width: "100%" }
988
976
  },
989
977
  onClick: () => {
990
- d || u(r.date);
978
+ d || u(n.date);
991
979
  },
992
- children: r.number
980
+ children: n.number
993
981
  },
994
982
  c
995
983
  );
996
984
  }) })
997
985
  ] });
998
986
  }, sa = ({
999
- date: n,
987
+ date: r,
1000
988
  setDate: a,
1001
989
  filter: t,
1002
990
  setViews: s,
@@ -1007,15 +995,15 @@ const S = (n) => {
1007
995
  maxDate: h,
1008
996
  input: e
1009
997
  }) => {
1010
- const w = n.getMonth(), b = n.getFullYear(), k = g.getFullYear(), M = (u) => {
998
+ const w = r.getMonth(), b = r.getFullYear(), k = g.getFullYear(), M = (u) => {
1011
999
  (!v || u >= v) && (!h || u <= h) && (t ? (i(u), a(u), f(u)) : (s("days"), f(u)));
1012
1000
  };
1013
- return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, r) => {
1014
- const c = v && new Date(k, r, 1) < v || h && new Date(k, r + 1, 0) > h;
1001
+ return /* @__PURE__ */ l("div", { className: "starasia-calendar-months-preview", children: N.map((u, n) => {
1002
+ const c = v && new Date(k, n, 1) < v || h && new Date(k, n + 1, 0) > h;
1015
1003
  return /* @__PURE__ */ l(
1016
1004
  "p",
1017
1005
  {
1018
- className: r === w && k === b ? "starasia-calendar-months-active" : "",
1006
+ className: n === w && k === b ? "starasia-calendar-months-active" : "",
1019
1007
  style: {
1020
1008
  color: c ? "#ccc" : void 0,
1021
1009
  pointerEvents: c ? "none" : void 0,
@@ -1023,18 +1011,18 @@ const S = (n) => {
1023
1011
  ...e ? {} : { width: "100%" }
1024
1012
  },
1025
1013
  onClick: () => {
1026
- c || M(new Date(k, r));
1014
+ c || M(new Date(k, n));
1027
1015
  },
1028
1016
  children: u.slice(0, 3)
1029
1017
  },
1030
- r
1018
+ n
1031
1019
  );
1032
1020
  }) });
1033
- }, V = (n) => {
1034
- const a = Math.floor(n / 10) * 10, t = a + 10;
1021
+ }, V = (r) => {
1022
+ const a = Math.floor(r / 10) * 10, t = a + 10;
1035
1023
  return { start: a, end: t };
1036
1024
  }, ia = ({
1037
- date: n,
1025
+ date: r,
1038
1026
  filter: a,
1039
1027
  setViews: t,
1040
1028
  setDate: s,
@@ -1046,12 +1034,12 @@ const S = (n) => {
1046
1034
  input: e
1047
1035
  }) => {
1048
1036
  let w = [];
1049
- const b = g.getFullYear(), { start: k, end: M } = V(b), u = n.getFullYear();
1037
+ const b = g.getFullYear(), { start: k, end: M } = V(b), u = r.getFullYear();
1050
1038
  for (let c = k; c < M; c++) {
1051
1039
  let d = v && new Date(c, 0, 1) < v || h && new Date(c, 11, 31) > h;
1052
1040
  w.push({ year: c, active: c === u, isDisabled: d });
1053
1041
  }
1054
- const r = (c) => {
1042
+ const n = (c) => {
1055
1043
  (!v || c >= v) && (!h || c <= h) && (a ? (i(c), s(c), f(c)) : (t("months"), f(c)));
1056
1044
  };
1057
1045
  return /* @__PURE__ */ l("div", { className: "starasia-calendar-years-preview", children: w.map((c, d) => /* @__PURE__ */ l(
@@ -1065,21 +1053,21 @@ const S = (n) => {
1065
1053
  ...e ? {} : { width: "100%" }
1066
1054
  },
1067
1055
  onClick: () => {
1068
- c.isDisabled || r(new Date(c.year, 0));
1056
+ c.isDisabled || n(new Date(c.year, 0));
1069
1057
  },
1070
1058
  children: c.year
1071
1059
  },
1072
1060
  d
1073
1061
  )) });
1074
1062
  }, oa = ({
1075
- setViews: n,
1063
+ setViews: r,
1076
1064
  views: a,
1077
1065
  filter: t,
1078
1066
  previewDate: s,
1079
1067
  setPreviewDate: i
1080
1068
  }) => {
1081
1069
  const g = () => {
1082
- t || n((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
1070
+ t || r((e) => e === "days" ? "months" : e === "months" ? "years" : "days");
1083
1071
  }, f = () => {
1084
1072
  if (a === "years") {
1085
1073
  i((e) => new Date(e.getFullYear() + 10, 0));
@@ -1122,16 +1110,16 @@ const S = (n) => {
1122
1110
  })() }),
1123
1111
  /* @__PURE__ */ l(P, { onClick: () => f() })
1124
1112
  ] });
1125
- }, H = "starasia-calendar-styles", la = (n) => {
1113
+ }, H = "starasia-calendar-styles", la = (r) => {
1126
1114
  if (!document.getElementById(H)) {
1127
1115
  const a = document.createElement("style");
1128
- a.id = H, a.textContent = n, document.head.appendChild(a);
1116
+ a.id = H, a.textContent = r, document.head.appendChild(a);
1129
1117
  }
1130
1118
  };
1131
1119
  la(I);
1132
1120
  const ca = W(
1133
1121
  ({
1134
- value: n,
1122
+ value: r,
1135
1123
  onChange: a,
1136
1124
  filter: t,
1137
1125
  input: s = !0,
@@ -1142,17 +1130,17 @@ const ca = W(
1142
1130
  size: h,
1143
1131
  status: e
1144
1132
  }, w) => {
1145
- const { ref: b, isComponentVisible: k, setIsComponentVisible: M } = J(!1), u = E(null), [r, c] = F("days"), [d, y] = F(/* @__PURE__ */ new Date()), [o, p] = F(/* @__PURE__ */ new Date());
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());
1146
1134
  D(() => {
1147
- n ? (y(n), p(n)) : (y(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
1148
- }, [n]), D(() => {
1135
+ r ? (y(r), p(r)) : (y(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
1136
+ }, [r]), D(() => {
1149
1137
  t && c(t);
1150
1138
  }, [t]), D(() => {
1151
1139
  t || c("days");
1152
1140
  }, [k]), D(() => {
1153
1141
  s || M(!0);
1154
1142
  }, [s]);
1155
- const C = () => n ? t === "days" ? L(d) : t === "months" ? `${N[d.getMonth()]} ${d.getFullYear()}` : t === "years" ? d.getFullYear() : L(d) : "", x = () => {
1143
+ const C = () => r ? t === "days" ? L(d) : t === "months" ? `${N[d.getMonth()]} ${d.getFullYear()}` : t === "years" ? d.getFullYear() : L(d) : "", x = () => {
1156
1144
  if (u.current && b.current && s) {
1157
1145
  const m = b.current.getBoundingClientRect(), Y = u.current.getBoundingClientRect();
1158
1146
  window.innerWidth < m.left + Y.width ? u.current.style.left = `${m.left - Y.width + m.width}px` : u.current.style.left = `${m.left}px`, m.top + Y.height > window.innerHeight ? u.current.style.top = `${m.y - (m.height + Y.height - 28)}px` : u.current.style.top = `${m.y + m.height}px`;
@@ -1173,7 +1161,7 @@ const ca = W(
1173
1161
  ref: s ? b : null,
1174
1162
  children: [
1175
1163
  s ? /* @__PURE__ */ l(
1176
- ra,
1164
+ na,
1177
1165
  {
1178
1166
  value: C(),
1179
1167
  onClick: () => M(!0),
@@ -1196,14 +1184,14 @@ const ca = W(
1196
1184
  oa,
1197
1185
  {
1198
1186
  setViews: c,
1199
- views: r,
1187
+ views: n,
1200
1188
  filter: t,
1201
1189
  previewDate: o,
1202
1190
  setPreviewDate: p,
1203
1191
  isComponentVisible: k
1204
1192
  }
1205
1193
  ),
1206
- /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: r === "days" ? /* @__PURE__ */ l(
1194
+ /* @__PURE__ */ l("div", { className: "starasia-calendar-body", children: n === "days" ? /* @__PURE__ */ l(
1207
1195
  ta,
1208
1196
  {
1209
1197
  date: d,
@@ -1216,7 +1204,7 @@ const ca = W(
1216
1204
  maxDate: f,
1217
1205
  onChange: a
1218
1206
  }
1219
- ) : r === "months" ? /* @__PURE__ */ l(
1207
+ ) : n === "months" ? /* @__PURE__ */ l(
1220
1208
  sa,
1221
1209
  {
1222
1210
  date: d,
@@ -1254,7 +1242,7 @@ const ca = W(
1254
1242
  }
1255
1243
  ), ha = W(
1256
1244
  ({
1257
- value: n,
1245
+ value: r,
1258
1246
  onChange: a,
1259
1247
  filter: t,
1260
1248
  input: s = !0,
@@ -1269,7 +1257,7 @@ const ca = W(
1269
1257
  ea,
1270
1258
  {
1271
1259
  onChange: a,
1272
- value: n,
1260
+ value: r,
1273
1261
  input: s,
1274
1262
  filter: t,
1275
1263
  disabled: g,
@@ -1284,7 +1272,7 @@ const ca = W(
1284
1272
  ca,
1285
1273
  {
1286
1274
  onChange: a,
1287
- value: n,
1275
+ value: r,
1288
1276
  input: s,
1289
1277
  filter: t,
1290
1278
  disabled: g,
package/dist/date.umd.js CHANGED
@@ -46,23 +46,11 @@
46
46
  #f9fafb
47
47
  );
48
48
 
49
- /* gray / blue */
50
- --starasia-ui-date-color-primary-blue: var(
51
- --starasia-ui-color-blue-500,
52
- #3b82f6
53
- );
54
- --starasia-ui-date-color-secondary-blue: var(
55
- --starasia-ui-color-blue-500,
56
- #3b82f6
57
- );
58
- --starasia-ui-date-color-tertiary-blue: var(
59
- --starasia-ui-color-blue-300,
60
- #93c5fd
61
- );
62
- --starasia-ui-date-color-quaternary-blue: var(
63
- --starasia-ui-color-blue-50,
64
- #eff6ff
65
- );
49
+ /* brand */
50
+ --starasia-ui-date-color-primary-blue: var(--starasia-ui-brand-primary-default);
51
+ --starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default);
52
+ --starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
53
+ --starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
66
54
 
67
55
  /* spacing */
68
56
  --starasia-ui-date-spacing-xs: var(--starasia-ui-spacing-xs, 4px);
@@ -254,7 +242,7 @@
254
242
 
255
243
  .starasia-calendar-input-container:has(input:focus) {
256
244
  border-color: var(--starasia-ui-date-color-primary-blue);
257
- box-shadow: 0px 0px 0px 2px rgba(100, 181, 246, 0.2);
245
+ box-shadow: 0px 0px 0px 2px rgba(var(--starasia-ui-raw-color-brand-secondary), 0.2);
258
246
  }
259
247
  .starasia-calendar-input-container:has(input:disabled) {
260
248
  /* border-color: var(--starasia-ui-input-color-tertiary-gray); */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starasia/date",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "date component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/date.umd.js",
@@ -12,6 +12,10 @@
12
12
  "dist/*.map",
13
13
  "dist/*.css"
14
14
  ],
15
+ "scripts": {
16
+ "dev": "vite --config vite.config.ts --port 3000",
17
+ "build": "vite build --config vite.config.ts"
18
+ },
15
19
  "keywords": [],
16
20
  "license": "ISC",
17
21
  "type": "module",
@@ -33,9 +37,5 @@
33
37
  "react-dom": "^18.2.0",
34
38
  "@types/react": "^18.2.55",
35
39
  "@types/react-dom": "^18.2.19"
36
- },
37
- "scripts": {
38
- "dev": "vite --config vite.config.ts --port 3000",
39
- "build": "vite build --config vite.config.ts"
40
40
  }
41
- }
41
+ }