@starasia/date 1.0.2 → 1.0.4

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, rgba(74, 106, 148, 1));
53
+ --starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
54
+ --starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary, rgba(144, 176, 218, 1));
55
+ --starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary, rgba(227, 237, 248, 1));
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, 144, 176, 218), 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(e) {
352
+ const [a, t] = F(e), 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 = (e) => {
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 = e, document.head.appendChild(a);
375
363
  }
376
364
  };
377
365
  U(I);
378
- const T = (n) => {
379
- if (n === "sm")
366
+ const T = (e) => {
367
+ if (e === "sm")
380
368
  return 16;
381
- if (n === "md")
369
+ if (e === "md")
382
370
  return 16;
383
- if (n === "lg")
371
+ if (e === "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 = (e) => {
374
+ const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, 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: e,
450
438
  setDate: a,
451
439
  dateRange: t,
452
440
  setDateRange: s,
@@ -455,19 +443,19 @@ 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(e.getFullYear(), e.getMonth(), 1), r = h.getDay(), w = [];
448
+ const b = e.getMonth();
461
449
  for (let d = 0; d < 42; d++) {
462
- d === 0 && e === 0 ? h.setDate(h.getDate() - 7) : d === 0 ? h.setDate(
463
- h.getDate() + (d - e)
450
+ d === 0 && r === 0 ? h.setDate(h.getDate() - 7) : d === 0 ? h.setDate(
451
+ h.getDate() + (d - r)
464
452
  ) : h.setDate(h.getDate() + 1);
465
453
  let y = {
466
454
  currentMonth: h.getMonth() === b,
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: e,
516
504
  setDate: a,
517
505
  filter: t,
518
506
  setViews: s,
@@ -521,48 +509,48 @@ const T = (n) => {
521
509
  onChange: f,
522
510
  minDate: v,
523
511
  maxDate: h,
524
- input: e
512
+ input: r
525
513
  }) => {
526
- const w = i.from.getFullYear(), b = n.getFullYear(), k = (u) => {
514
+ const w = i.from.getFullYear(), b = e.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,
549
537
  cursor: d ? "not-allowed" : "pointer",
550
538
  color: d ? "#ccc" : c ? "#b0b0b0" : "",
551
- ...e ? {} : { width: "100%" }
539
+ ...r ? {} : { 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 = (e) => {
550
+ const a = Math.floor(e / 10) * 10, t = a + 10;
563
551
  return { start: a, end: t };
564
552
  }, Z = ({
565
- date: n,
553
+ date: e,
566
554
  filter: a,
567
555
  setViews: t,
568
556
  setDate: s,
@@ -571,13 +559,13 @@ const T = (n) => {
571
559
  onChange: f,
572
560
  minDate: v,
573
561
  maxDate: h,
574
- input: e
562
+ input: r
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 = e.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,
@@ -610,13 +598,13 @@ const T = (n) => {
610
598
  color: o.highlight ? "#b0b0b0" : o.active ? "" : o.disabled ? "#ccc" : "",
611
599
  cursor: o.disabled ? "not-allowed" : "pointer",
612
600
  pointerEvents: o.disbled ? "none" : "all",
613
- ...e ? {} : { width: "100%" }
601
+ ...r ? {} : { width: "100%" }
614
602
  },
615
603
  children: o.year
616
604
  },
617
605
  p
618
606
  )) });
619
- }, q = ({ ...n }) => /* @__PURE__ */ l(
607
+ }, q = ({ ...e }) => /* @__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
+ ...e,
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 = ({ ...e }) => /* @__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
+ ...e,
648
636
  children: /* @__PURE__ */ l(
649
637
  "path",
650
638
  {
@@ -657,37 +645,37 @@ const T = (n) => {
657
645
  )
658
646
  }
659
647
  ), _ = ({
660
- setViews: n,
648
+ setViews: e,
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 || e((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
668
656
  }, f = () => {
669
657
  if (a === "years") {
670
- i((e) => new Date(e.getFullYear() + 10, 0));
658
+ i((r) => new Date(r.getFullYear() + 10, 0));
671
659
  return;
672
660
  }
673
661
  if (a === "months") {
674
- i((e) => new Date(e.getFullYear() + 1, e.getMonth()));
662
+ i((r) => new Date(r.getFullYear() + 1, r.getMonth()));
675
663
  return;
676
664
  }
677
- i((e) => new Date(e.getFullYear(), e.getMonth() + 1));
665
+ i((r) => new Date(r.getFullYear(), r.getMonth() + 1));
678
666
  }, v = () => {
679
667
  if (a === "years") {
680
- i((e) => new Date(e.getFullYear() - 10, 0));
668
+ i((r) => new Date(r.getFullYear() - 10, 0));
681
669
  return;
682
670
  }
683
671
  if (a === "months") {
684
- i((e) => new Date(e.getFullYear() - 1, e.getMonth()));
672
+ i((r) => new Date(r.getFullYear() - 1, r.getMonth()));
685
673
  return;
686
674
  }
687
675
  i(
688
- (e) => new Date(
689
- e.getMonth() === 0 ? e.getFullYear() - 1 : e.getFullYear(),
690
- e.getMonth() === 0 ? 11 : e.getMonth() - 1
676
+ (r) => new Date(
677
+ r.getMonth() === 0 ? r.getFullYear() - 1 : r.getFullYear(),
678
+ r.getMonth() === 0 ? 11 : r.getMonth() - 1
691
679
  )
692
680
  );
693
681
  };
@@ -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(e) {
696
+ const a = new Date(e), 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 = (e) => {
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 = e, document.head.appendChild(a);
715
703
  }
716
704
  };
717
705
  aa(I);
718
- const ea = W(
706
+ const ra = W(
719
707
  ({
720
- value: n,
708
+ value: e,
721
709
  onChange: a,
722
710
  filter: t,
723
711
  input: s = !0,
@@ -726,18 +714,18 @@ const ea = W(
726
714
  maxDate: f,
727
715
  placeholder: v,
728
716
  size: h,
729
- status: e
717
+ status: r
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: (e == null ? void 0 : e.from) || /* @__PURE__ */ new Date(),
721
+ to: (e == null ? void 0 : e.to) || /* @__PURE__ */ new Date()
734
722
  });
735
723
  D(() => {
736
- n ? (y(n.from), p(n)) : (y(/* @__PURE__ */ new Date()), p({
724
+ e ? (y(e.from), p(e)) : (y(/* @__PURE__ */ new Date()), p({
737
725
  from: /* @__PURE__ */ new Date(),
738
726
  to: /* @__PURE__ */ new Date()
739
727
  }));
740
- }, [n]), D(() => {
728
+ }, [e]), 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 (!e)
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) || "-"}`;
@@ -790,7 +778,7 @@ const ea = W(
790
778
  disabled: i,
791
779
  placeholder: v,
792
780
  size: h,
793
- status: e
781
+ status: r
794
782
  }
795
783
  ) : null,
796
784
  k ? /* @__PURE__ */ $(
@@ -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", ea = (e) => {
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 = e, document.head.appendChild(a);
867
855
  }
868
856
  };
869
- na(I);
870
- const S = (n) => {
871
- if (n === "sm")
857
+ ea(I);
858
+ const S = (e) => {
859
+ if (e === "sm")
872
860
  return 16;
873
- if (n === "md")
861
+ if (e === "md")
874
862
  return 16;
875
- if (n === "lg")
863
+ if (e === "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 = (e) => {
866
+ const { size: a = "md", status: t = "default", variant: s = "outline", ...i } = e, 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: e,
942
930
  setDate: a,
943
931
  previewDate: t,
944
932
  setPreviewDate: s,
@@ -948,38 +936,38 @@ const S = (n) => {
948
936
  input: v,
949
937
  onChange: h
950
938
  }) => {
951
- let e = new Date(
939
+ let r = new Date(
952
940
  t.getFullYear(),
953
941
  t.getMonth(),
954
942
  1
955
- ), 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)
960
- ) : e.setDate(e.getDate() + 1);
943
+ ), w = r.getDay(), b = [];
944
+ const k = e.toDateString(), M = t.getMonth();
945
+ for (let n = 0; n < 42; n++) {
946
+ n === 0 && w === 0 ? r.setDate(r.getDate() - 7) : n === 0 ? r.setDate(
947
+ r.getDate() + (n - w)
948
+ ) : r.setDate(r.getDate() + 1);
961
949
  let c = {
962
- currentMonth: e.getMonth() === M,
963
- date: new Date(e),
964
- month: e.getMonth(),
965
- number: e.getDate(),
966
- selected: e.toDateString() === k,
967
- year: e.getFullYear(),
968
- isDisabled: g && e < g || f && e > f
950
+ currentMonth: r.getMonth() === M,
951
+ date: new Date(r),
952
+ month: r.getMonth(),
953
+ number: r.getDate(),
954
+ selected: r.toDateString() === k,
955
+ year: r.getFullYear(),
956
+ isDisabled: g && r < g || f && r > f
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: e,
1000
988
  setDate: a,
1001
989
  filter: t,
1002
990
  setViews: s,
@@ -1005,36 +993,36 @@ const S = (n) => {
1005
993
  setPreviewDate: f,
1006
994
  minDate: v,
1007
995
  maxDate: h,
1008
- input: e
996
+ input: r
1009
997
  }) => {
1010
- const w = n.getMonth(), b = n.getFullYear(), k = g.getFullYear(), M = (u) => {
998
+ const w = e.getMonth(), b = e.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,
1022
1010
  cursor: c ? "not-allowed" : "pointer",
1023
- ...e ? {} : { width: "100%" }
1011
+ ...r ? {} : { 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 = (e) => {
1022
+ const a = Math.floor(e / 10) * 10, t = a + 10;
1035
1023
  return { start: a, end: t };
1036
1024
  }, ia = ({
1037
- date: n,
1025
+ date: e,
1038
1026
  filter: a,
1039
1027
  setViews: t,
1040
1028
  setDate: s,
@@ -1043,15 +1031,15 @@ const S = (n) => {
1043
1031
  setPreviewDate: f,
1044
1032
  minDate: v,
1045
1033
  maxDate: h,
1046
- input: e
1034
+ input: r
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 = e.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(
@@ -1062,51 +1050,51 @@ const S = (n) => {
1062
1050
  color: c.isDisabled ? "#ccc" : void 0,
1063
1051
  pointerEvents: c.isDisabled ? "none" : void 0,
1064
1052
  cursor: c.isDisabled ? "not-allowed" : "pointer",
1065
- ...e ? {} : { width: "100%" }
1053
+ ...r ? {} : { 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: e,
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 || e((r) => r === "days" ? "months" : r === "months" ? "years" : "days");
1083
1071
  }, f = () => {
1084
1072
  if (a === "years") {
1085
- i((e) => new Date(e.getFullYear() + 10, 0));
1073
+ i((r) => new Date(r.getFullYear() + 10, 0));
1086
1074
  return;
1087
1075
  }
1088
1076
  if (a === "months") {
1089
1077
  i(
1090
- (e) => new Date(e.getFullYear() + 1, e.getMonth())
1078
+ (r) => new Date(r.getFullYear() + 1, r.getMonth())
1091
1079
  );
1092
1080
  return;
1093
1081
  }
1094
- i((e) => new Date(e.getFullYear(), e.getMonth() + 1));
1082
+ i((r) => new Date(r.getFullYear(), r.getMonth() + 1));
1095
1083
  }, v = () => {
1096
1084
  if (a === "years") {
1097
- i((e) => new Date(e.getFullYear() - 10, 0));
1085
+ i((r) => new Date(r.getFullYear() - 10, 0));
1098
1086
  return;
1099
1087
  }
1100
1088
  if (a === "months") {
1101
1089
  i(
1102
- (e) => new Date(e.getFullYear() - 1, e.getMonth())
1090
+ (r) => new Date(r.getFullYear() - 1, r.getMonth())
1103
1091
  );
1104
1092
  return;
1105
1093
  }
1106
1094
  i(
1107
- (e) => new Date(
1108
- e.getMonth() === 0 ? e.getFullYear() - 1 : e.getFullYear(),
1109
- e.getMonth() === 0 ? 11 : e.getMonth() - 1
1095
+ (r) => new Date(
1096
+ r.getMonth() === 0 ? r.getFullYear() - 1 : r.getFullYear(),
1097
+ r.getMonth() === 0 ? 11 : r.getMonth() - 1
1110
1098
  )
1111
1099
  );
1112
1100
  };
@@ -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 = (e) => {
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 = e, document.head.appendChild(a);
1129
1117
  }
1130
1118
  };
1131
1119
  la(I);
1132
1120
  const ca = W(
1133
1121
  ({
1134
- value: n,
1122
+ value: e,
1135
1123
  onChange: a,
1136
1124
  filter: t,
1137
1125
  input: s = !0,
@@ -1140,19 +1128,19 @@ const ca = W(
1140
1128
  maxDate: f,
1141
1129
  placeholder: v,
1142
1130
  size: h,
1143
- status: e
1131
+ status: r
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
+ e ? (y(e), p(e)) : (y(/* @__PURE__ */ new Date()), p(/* @__PURE__ */ new Date()));
1136
+ }, [e]), 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 = () => e ? 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),
@@ -1182,7 +1170,7 @@ const ca = W(
1182
1170
  placeholder: v,
1183
1171
  disabled: i,
1184
1172
  size: h,
1185
- status: e,
1173
+ status: r,
1186
1174
  inputMode: "none"
1187
1175
  }
1188
1176
  ) : null,
@@ -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: e,
1258
1246
  onChange: a,
1259
1247
  filter: t,
1260
1248
  input: s = !0,
@@ -1263,13 +1251,13 @@ const ca = W(
1263
1251
  minDate: f,
1264
1252
  maxDate: v,
1265
1253
  placeholder: h,
1266
- size: e,
1254
+ size: r,
1267
1255
  status: w
1268
1256
  }, b) => /* @__PURE__ */ l(R, { children: i ? /* @__PURE__ */ l(
1269
- ea,
1257
+ ra,
1270
1258
  {
1271
1259
  onChange: a,
1272
- value: n,
1260
+ value: e,
1273
1261
  input: s,
1274
1262
  filter: t,
1275
1263
  disabled: g,
@@ -1277,14 +1265,14 @@ const ca = W(
1277
1265
  minDate: f,
1278
1266
  maxDate: v,
1279
1267
  placeholder: h,
1280
- size: e,
1268
+ size: r,
1281
1269
  status: w
1282
1270
  }
1283
1271
  ) : /* @__PURE__ */ l(
1284
1272
  ca,
1285
1273
  {
1286
1274
  onChange: a,
1287
- value: n,
1275
+ value: e,
1288
1276
  input: s,
1289
1277
  filter: t,
1290
1278
  disabled: g,
@@ -1292,7 +1280,7 @@ const ca = W(
1292
1280
  minDate: f,
1293
1281
  maxDate: v,
1294
1282
  placeholder: h,
1295
- size: e,
1283
+ size: r,
1296
1284
  status: w
1297
1285
  }
1298
1286
  ) })
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, rgba(74, 106, 148, 1));
51
+ --starasia-ui-date-color-secondary-blue: var(--starasia-ui-brand-primary-default, rgba(74, 106, 148, 1));
52
+ --starasia-ui-date-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary, rgba(144, 176, 218, 1));
53
+ --starasia-ui-date-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary, rgba(227, 237, 248, 1));
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, 144, 176, 218), 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.4",
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
+ }