1mpacto-react-ui 2.0.25 → 2.0.26

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.
Files changed (84) hide show
  1. package/dist/assets/_colors.scss +42 -0
  2. package/dist/assets/_typography.scss +32 -2
  3. package/dist/assets/core.css +1 -1
  4. package/dist/assets/fontfamily.css +1 -1
  5. package/dist/assets/style.css +1 -1
  6. package/dist/components/Button/Button.config.cjs +1 -1
  7. package/dist/components/Button/Button.config.mjs +58 -55
  8. package/dist/components/Button/style.module.scss.cjs +1 -1
  9. package/dist/components/Button/style.module.scss.mjs +60 -57
  10. package/dist/components/Calendar/Calendar.cjs +1 -1
  11. package/dist/components/Calendar/Calendar.config.cjs +1 -0
  12. package/dist/components/Calendar/Calendar.config.mjs +22 -0
  13. package/dist/components/Calendar/Calendar.mjs +221 -133
  14. package/dist/components/Calendar/CalendarCell.cjs +1 -1
  15. package/dist/components/Calendar/CalendarCell.mjs +9 -9
  16. package/dist/components/Calendar/CalendarMonth.cjs +1 -1
  17. package/dist/components/Calendar/CalendarMonth.mjs +23 -21
  18. package/dist/components/Calendar/CalendarRange.cjs +1 -1
  19. package/dist/components/Calendar/CalendarRange.mjs +100 -98
  20. package/dist/components/Calendar/CalendarYear.cjs +2 -2
  21. package/dist/components/Calendar/CalendarYear.mjs +25 -23
  22. package/dist/components/Calendar/style.module.scss.cjs +1 -1
  23. package/dist/components/Calendar/style.module.scss.mjs +35 -33
  24. package/dist/components/Chart/LineChart.cjs +1 -1
  25. package/dist/components/Chart/LineChart.mjs +1 -1
  26. package/dist/components/DatePicker/DatePicker.cjs +1 -1
  27. package/dist/components/DatePicker/DatePicker.mjs +78 -69
  28. package/dist/components/DatePicker/DateRangePicker.cjs +1 -1
  29. package/dist/components/DatePicker/DateRangePicker.mjs +91 -79
  30. package/dist/components/DatePicker/FilterDate.cjs +1 -1
  31. package/dist/components/DatePicker/FilterDate.mjs +181 -127
  32. package/dist/components/DatePicker/MonthYearPicker.cjs +1 -1
  33. package/dist/components/DatePicker/MonthYearPicker.mjs +58 -49
  34. package/dist/components/Input/InputInnerLabel.cjs +6 -6
  35. package/dist/components/Input/InputInnerLabel.config.cjs +1 -1
  36. package/dist/components/Input/InputInnerLabel.config.mjs +9 -5
  37. package/dist/components/Input/InputInnerLabel.mjs +36 -35
  38. package/dist/components/Input/InputInnerLabel.module.scss.cjs +1 -1
  39. package/dist/components/Input/InputInnerLabel.module.scss.mjs +19 -17
  40. package/dist/components/Sidebar/ItemSidebar.config.cjs +1 -1
  41. package/dist/components/Sidebar/ItemSidebar.config.mjs +6 -2
  42. package/dist/components/Sidebar/Sidebar.cjs +1 -1
  43. package/dist/components/Sidebar/Sidebar.config.cjs +1 -1
  44. package/dist/components/Sidebar/Sidebar.config.mjs +14 -12
  45. package/dist/components/Sidebar/Sidebar.mjs +78 -77
  46. package/dist/components/Sidebar/Sidebar.module.scss.cjs +1 -1
  47. package/dist/components/Sidebar/Sidebar.module.scss.mjs +22 -20
  48. package/dist/components/Sidebar/itemSidebar.module.scss.cjs +1 -1
  49. package/dist/components/Sidebar/itemSidebar.module.scss.mjs +25 -24
  50. package/dist/config/resources/index.cjs +1 -1
  51. package/dist/config/resources/index.mjs +1 -1
  52. package/dist/config/tailwind/colors.cjs +1 -1
  53. package/dist/config/tailwind/colors.mjs +22 -1
  54. package/dist/config/tailwind/typography.cjs +1 -1
  55. package/dist/config/tailwind/typography.mjs +70 -3
  56. package/dist/package.json.cjs +1 -1
  57. package/dist/package.json.d.ts +1 -1
  58. package/dist/package.json.mjs +1 -1
  59. package/dist/src/components/Button/Button.config.d.ts +3 -0
  60. package/dist/src/components/Calendar/Calendar.config.d.ts +19 -0
  61. package/dist/src/components/Calendar/Calendar.d.ts +5 -3
  62. package/dist/src/components/Calendar/Calendar.stories.d.ts +21 -5
  63. package/dist/src/components/Calendar/CalendarMonth.d.ts +1 -1
  64. package/dist/src/components/Calendar/CalendarRange.d.ts +1 -1
  65. package/dist/src/components/Calendar/CalendarYear.d.ts +1 -1
  66. package/dist/src/components/DatePicker/DatePicker.stories.d.ts +28 -0
  67. package/dist/src/components/DatePicker/FilterDate.d.ts +1 -1
  68. package/dist/src/components/DatePicker/FilterDate.stories.d.ts +29 -1
  69. package/dist/src/components/DatePicker/MonthYearPicker.d.ts +1 -1
  70. package/dist/src/components/DatePicker/MonthYearPicker.stories.d.ts +29 -1
  71. package/dist/src/components/Input/InputInnerLabel.config.d.ts +5 -1
  72. package/dist/src/components/Input/InputInnerLabel.stories.d.ts +16 -0
  73. package/dist/src/components/Sidebar/ItemSidebar.config.d.ts +4 -0
  74. package/dist/src/components/Sidebar/Sidebar.config.d.ts +2 -0
  75. package/dist/src/config/resources/index.d.ts +2 -2
  76. package/dist/src/config/tailwind/typography.d.ts +1 -0
  77. package/dist/src/interfaces/components/Button/index.d.ts +1 -1
  78. package/dist/src/interfaces/components/Calendar/index.d.ts +41 -0
  79. package/dist/src/interfaces/components/DatePicker/index.d.ts +41 -1
  80. package/dist/src/interfaces/components/Input/index.d.ts +10 -0
  81. package/dist/src/interfaces/components/Sidebar/index.d.ts +6 -1
  82. package/dist/utils/common.cjs +1 -1
  83. package/dist/utils/common.mjs +7 -7
  84. package/package.json +1 -1
@@ -1,42 +1,50 @@
1
- import { jsxs as q, Fragment as A, jsx as c } from "react/jsx-runtime";
2
- import p from "react";
1
+ import { jsxs as q, Fragment as A, jsx as l } from "react/jsx-runtime";
2
+ import v from "react";
3
3
  import { createCalendar as J, parseDate as K, getLocalTimeZone as Q } from "@internationalized/date";
4
4
  import U from "../Calendar/Calendar.mjs";
5
- import { useDateFormatter as W, useLocale as X, I18nProvider as Y } from "react-aria";
6
- import _ from "../Popover/Popover.mjs";
7
- const g = (u) => {
8
- let s;
9
- const r = new Date(u ?? /* @__PURE__ */ new Date());
10
- return u && (s = K(new Date(r.setHours(r.getHours() + 7)).toISOString().slice(0, 10))), s;
11
- }, se = (u) => {
5
+ import { useDateFormatter as W, I18nProvider as X } from "react-aria";
6
+ import Y from "../Popover/Popover.mjs";
7
+ const w = (f, m) => {
8
+ let r;
9
+ if (f) {
10
+ const u = new Intl.DateTimeFormat(m, {
11
+ year: "numeric",
12
+ month: "2-digit",
13
+ day: "2-digit"
14
+ }).formatToParts(new Date(f)), g = u.find((i) => i.type === "year")?.value, d = u.find((i) => i.type === "month")?.value, T = u.find((i) => i.type === "day")?.value;
15
+ return r = K(`${g}-${d}-${T}`), r;
16
+ }
17
+ }, re = (f) => {
12
18
  const {
13
- minDate: s,
19
+ minDate: m,
14
20
  maxDate: r,
15
- value: i,
16
- defaultValue: v,
17
- withConfirm: h = !1,
18
- isCustomTime: D = !1,
19
- className: x,
20
- classNameButton: I,
21
- buttonClick: w,
22
- buttonReset: P,
21
+ value: s,
22
+ defaultValue: u,
23
+ withConfirm: g = !1,
24
+ isCustomTime: d = !1,
25
+ className: T,
26
+ classNameButton: i,
27
+ buttonClick: H,
28
+ buttonReset: I,
23
29
  buttonSubmit: b,
24
- prevIcon: y,
25
- nextIcon: M,
26
- onChange: m,
27
- id: k = "date-picker",
28
- idPopover: N = "date-picker-popover",
29
- floatingOptions: R = {},
30
- offsetPopover: V = 5,
31
- zIndexPopper: L = 1,
32
- hiddenHeader: O
33
- } = u, l = W(), { locale: j } = X(), z = g(s), F = g(r), d = p.useRef(null), [S, T] = p.useState(), [f, H] = p.useState(), B = (a) => {
30
+ prevIcon: M,
31
+ nextIcon: k,
32
+ onChange: D,
33
+ id: N = "date-picker",
34
+ idPopover: R = "date-picker-popover",
35
+ floatingOptions: V = {},
36
+ offsetPopover: F = 5,
37
+ zIndexPopper: $ = 1,
38
+ hiddenHeader: j,
39
+ variants: z,
40
+ locale: c = "id-ID"
41
+ } = f, p = W(), L = w(m, c), O = w(r, c), h = v.useRef(null), [y, C] = v.useState(), [S, x] = v.useState(), B = (a) => {
34
42
  const o = /* @__PURE__ */ new Date();
35
43
  let e = a.toDate(Q());
36
44
  e.setHours(o.getHours(), o.getMinutes(), o.getSeconds());
37
- const t = s ? new Date(s) : null, n = r ? new Date(r) : null;
38
- if (D) {
39
- if (e = new Date(new Date(e).setHours(f?.hour ?? 0, f?.minut, f?.second)), t && t?.toDateString() === new Date(e).toDateString() && t?.toTimeString() >= e?.toTimeString()) {
45
+ const t = m ? new Date(m) : null, n = r ? new Date(r) : null;
46
+ if (d) {
47
+ if (e = new Date(new Date(e).setHours(S?.hour ?? 0, S?.minut, S?.second)), t && t?.toDateString() === new Date(e).toDateString() && t?.toTimeString() >= e?.toTimeString()) {
40
48
  if (t && (t.getHours() > e.getHours() || t.getHours() === e.getHours() && t.getMinutes() > e.getMinutes()))
41
49
  return;
42
50
  e = new Date(t.setSeconds(t.getSeconds() + 1));
@@ -47,70 +55,71 @@ const g = (u) => {
47
55
  e = new Date(n.setSeconds(n.getSeconds() - 1));
48
56
  }
49
57
  } else
50
- t && l.format(e) === l.format(t) && t.getTime() >= e.getTime() ? e = new Date(t.setSeconds(t.getSeconds() + 1)) : n && l.format(e) === l.format(n) && n.getTime() <= e.getTime() && (e = new Date(n.setSeconds(n.getSeconds() - 1)));
51
- typeof m == "function" && (m(e), d.current?.setShow(!1));
52
- }, C = (a, o) => {
53
- T(a), (o ?? (!h && !D)) && B(a);
58
+ t && p.format(e) === p.format(t) && t.getTime() >= e.getTime() ? e = new Date(t.setSeconds(t.getSeconds() + 1)) : n && p.format(e) === p.format(n) && n.getTime() <= e.getTime() && (e = new Date(n.setSeconds(n.getSeconds() - 1)));
59
+ typeof D == "function" && (D(e), h.current?.setShow(!1));
60
+ }, P = (a, o) => {
61
+ C(a), (o ?? (!g && !d)) && B(a);
54
62
  }, E = (a) => {
55
63
  const { start: o } = a;
56
- H(o);
64
+ x(o);
57
65
  }, G = (a) => {
58
- const o = new Date(i ?? /* @__PURE__ */ new Date());
59
- H({
66
+ const o = new Date(s ?? /* @__PURE__ */ new Date());
67
+ x({
60
68
  hour: o.getHours(),
61
69
  minut: o.getMinutes(),
62
70
  second: o.getSeconds()
63
- }), T(g(i));
71
+ }), C(w(s, c));
64
72
  }, Z = () => {
65
- S && C(S, !0);
73
+ y && P(y, !0);
66
74
  };
67
75
  return /* @__PURE__ */ q(A, { children: [
68
- /* @__PURE__ */ c(
76
+ /* @__PURE__ */ l(
69
77
  "div",
70
78
  {
71
- id: k,
79
+ id: N,
72
80
  onClick: (a) => {
73
- d.current?.handlerShow(a), G();
81
+ h.current?.handlerShow(a), G();
74
82
  },
75
- className: I,
76
- children: typeof w == "function" ? w(i) : i ? new Date(i).toDateString() : "Pilih Tanggal"
83
+ className: i,
84
+ children: typeof H == "function" ? H(s) : s ? new Date(s).toDateString() : "Pilih Tanggal"
77
85
  }
78
86
  ),
79
- /* @__PURE__ */ c(
80
- _,
87
+ /* @__PURE__ */ l(
88
+ Y,
81
89
  {
82
- zIndex: L,
83
- ref: d,
84
- offset: V,
85
- id: N,
86
- floatingOptions: { placement: "bottom-end", ...R },
87
- children: /* @__PURE__ */ c("div", { className: x ?? "", children: /* @__PURE__ */ c(Y, { locale: "id-ID", children: /* @__PURE__ */ c(
90
+ zIndex: $,
91
+ ref: h,
92
+ offset: F,
93
+ id: R,
94
+ floatingOptions: { placement: "bottom-end", ...V },
95
+ children: /* @__PURE__ */ l("div", { className: T ?? "", children: /* @__PURE__ */ l(X, { locale: c, children: /* @__PURE__ */ l(
88
96
  U,
89
97
  {
90
- minValue: z,
91
- maxValue: F,
92
- minDate: s,
98
+ minValue: L,
99
+ maxValue: O,
100
+ minDate: m,
93
101
  maxDate: r,
94
- time: { start: f },
95
- locale: j,
96
- value: S,
102
+ time: { start: S },
103
+ locale: c,
104
+ value: y,
97
105
  typeTime: "SINGLE",
98
- buttonReset: P,
106
+ buttonReset: I,
99
107
  buttonSubmit: b,
100
- prevIcon: y,
101
- nextIcon: M,
108
+ prevIcon: M,
109
+ nextIcon: k,
102
110
  createCalendar: J,
103
- defaultValue: g(i),
104
- onChange: C,
111
+ defaultValue: w(s, c),
112
+ onChange: P,
105
113
  handlerReset: () => {
106
- typeof m == "function" && (m(v), d.current?.setShow(!1));
114
+ typeof D == "function" && (D(u), h.current?.setShow(!1));
107
115
  },
108
116
  handlerSubmit: Z,
109
117
  handlerChangeTime: E,
110
- withConfirm: h,
111
- isCustomTime: D,
118
+ withConfirm: g,
119
+ isCustomTime: d,
112
120
  type: ["date", "month", "year"],
113
- hiddenHeader: O
121
+ hiddenHeader: j,
122
+ variants: z
114
123
  }
115
124
  ) }) })
116
125
  }
@@ -118,5 +127,5 @@ const g = (u) => {
118
127
  ] });
119
128
  };
120
129
  export {
121
- se as default
130
+ re as default
122
131
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const m=require("react/jsx-runtime"),R=require("react"),V=require("react-aria"),O=require("../Calendar/CalendarRange.cjs"),t=require("@internationalized/date"),Y=require("../Calendar/Calendar.cjs"),x=r=>{let n;const a=new Date(r??new Date);return r&&(n=t.parseDate(new Date(a.setHours(a.getHours()+7)).toISOString().slice(0,10))),n},A=r=>{const n=new Date(r?.startDate??new Date),a=new Date(r?.endDate??new Date),i=new t.CalendarDate(n.getFullYear(),n.getMonth()+1,n.getDate()),d=new t.CalendarDate(a.getFullYear(),a.getMonth()+1,a.getDate());return r?{start:i,end:d}:void 0},k=r=>{const{minDate:n,maxDate:a,defaultValue:i,withConfirm:d,prevIcon:y,nextIcon:H,buttonReset:M,buttonSubmit:p,typePicker:L="RANGE",onChange:b,value:u,onReset:j,isCustomTime:f}=r,{locale:F}=V.useLocale(),q=x(n),E=x(a),[s,h]=R.useState(),[w,C]=R.useState({start:void 0,end:void 0}),I=e=>{typeof b=="function"&&b(e)},S=(e,o)=>{const c=e.start.toDate(t.getLocalTimeZone()),D=e.end.toDate(t.getLocalTimeZone());h(e),C({start:{hour:0,minut:0,second:0},end:{hour:23,minut:59,second:59}}),(o??!d)&&I({startDate:c,endDate:new Date(D.setHours(23,59,59))})},T=(e,o)=>{if(s?.start&&s?.end&&(C(e),e.start?.hour?.toString()&&e.start?.minut?.toString()&&e.end?.hour?.toString()&&e.end?.minut?.toString()&&(o??!d))){const c=s.start.toDate(t.getLocalTimeZone()),D=s.end.toDate(t.getLocalTimeZone()),l=new Date(c.setHours(e.start.hour,e.start.minut)),g=new Date(D.setHours(e.end.hour,e.end.minut,59));l.getTime()<g.getTime()&&I({startDate:l,endDate:g})}},N=e=>{if(typeof j=="function")j();else if(i&&e){const o=new Date(i.endDate??new Date),c=e.focusedDate.set({month:o.getMonth()+1,year:o.getFullYear()});e.setFocusedDate(c)}h(A(i))},Z=()=>{s&&(f?T(w,!0):S(s,!0))};return R.useEffect(()=>{if(u?.endDate&&u?.startDate){const e=new Date(u.startDate),o=new Date(u.endDate),c=e.getHours(),D=e.getMinutes(),l=o.getHours(),g=o.getMinutes(),G=t.toCalendarDate(t.fromDate(e,t.getLocalTimeZone())),P=t.toCalendarDate(t.fromDate(o,t.getLocalTimeZone()));h({start:G,end:P}),C({start:{hour:c,minut:D},end:{hour:l,minut:g}})}},[JSON.stringify(u)]),m.jsx("div",{className:"iru-flex iru-flex-col",children:m.jsxs(V.I18nProvider,{locale:"id-ID",children:[L==="RANGE"&&m.jsx(O.default,{defaultValue:A(i),value:s,minValue:q,maxValue:E,withConfirm:d,prevIcon:y,nextIcon:H,buttonReset:M,buttonSubmit:p,onChange:e=>S(e),isCustomTime:f,handlerReset:N,handlerSubmit:Z,time:w,minDate:n,maxDate:a,handlerChangeTimeRange:T}),L==="SINGLE"&&m.jsx(Y.default,{defaultValue:x(i?.endDate),value:s?.end,minValue:q,maxValue:E,minDate:n,maxDate:a,withConfirm:d,prevIcon:y,nextIcon:H,buttonReset:M,buttonSubmit:p,locale:F,time:w,typeTime:"RANGE",handlerChangeTime:T,isCustomTime:f,createCalendar:t.createCalendar,onChange:e=>S({start:e,end:e}),handlerReset:N,handlerSubmit:Z,type:["date","month","year"]})]})})};exports.default=k;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("react/jsx-runtime"),b=require("react"),$=require("react-aria"),Y=require("../Calendar/CalendarRange.cjs"),e=require("@internationalized/date"),k=require("../Calendar/Calendar.cjs"),H=(r,s)=>{let n;if(r){const a=new Intl.DateTimeFormat(s,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(r)),f=a.find(d=>d.type==="year")?.value,g=a.find(d=>d.type==="month")?.value,h=a.find(d=>d.type==="day")?.value;return n=e.parseDate(`${f}-${g}-${h}`),n}},V=r=>{if(!r?.startDate||!r?.endDate)return;const s=new Date(r.startDate),n=new Date(r.endDate),i=new e.CalendarDate(s.getFullYear(),s.getMonth()+1,s.getDate()),a=new e.CalendarDate(n.getFullYear(),n.getMonth()+1,n.getDate());return{start:i,end:a}},O=r=>{const{minDate:s,maxDate:n,defaultValue:i,withConfirm:a,prevIcon:f,nextIcon:g,buttonReset:h,buttonSubmit:d,typePicker:L="RANGE",onChange:j,value:l,onReset:q,isCustomTime:T,variants:E="laba-blue-10",locale:D="id-ID"}=r,I=H(s,D),N=H(n,D),[c,S]=b.useState(),[p,R]=b.useState({start:void 0,end:void 0}),Z=t=>{typeof j=="function"&&j(t)},x=(t,o)=>{const u=t.start.toDate(e.getLocalTimeZone()),m=t.end.toDate(e.getLocalTimeZone());S(t),R({start:{hour:0,minut:0,second:0},end:{hour:23,minut:59,second:59}}),(o??!a)&&Z({startDate:u,endDate:new Date(m.setHours(23,59,59))})},M=(t,o)=>{if(c?.start&&c?.end&&(R(t),t.start?.hour?.toString()&&t.start?.minut?.toString()&&t.end?.hour?.toString()&&t.end?.minut?.toString()&&(o??!a))){const u=c.start.toDate(e.getLocalTimeZone()),m=c.end.toDate(e.getLocalTimeZone()),y=new Date(u.setHours(t.start.hour,t.start.minut)),C=new Date(m.setHours(t.end.hour,t.end.minut,59));y.getTime()<C.getTime()&&Z({startDate:y,endDate:C})}},F=t=>{if(typeof q=="function")q();else if(i&&t){const o=new Date(i.endDate??new Date),u=t.focusedDate.set({month:o.getMonth()+1,year:o.getFullYear()});t.setFocusedDate(u)}S(V(i))},P=()=>{c&&(T?M(p,!0):x(c,!0))};return b.useEffect(()=>{if(l?.endDate&&l?.startDate){const t=new Date(l.startDate),o=new Date(l.endDate),u=t.getHours(),m=t.getMinutes(),y=o.getHours(),C=o.getMinutes(),A=e.toCalendarDate(e.fromDate(t,e.getLocalTimeZone())),G=e.toCalendarDate(e.fromDate(o,e.getLocalTimeZone()));S({start:A,end:G}),R({start:{hour:u,minut:m},end:{hour:y,minut:C}})}},[JSON.stringify(l)]),w.jsx("div",{className:"iru-flex iru-flex-col",children:w.jsxs($.I18nProvider,{locale:D,children:[L==="RANGE"&&w.jsx(Y.default,{defaultValue:V(i),value:c,minValue:I,maxValue:N,withConfirm:a,prevIcon:f,nextIcon:g,buttonReset:h,buttonSubmit:d,onChange:t=>x(t),isCustomTime:T,handlerReset:F,handlerSubmit:P,time:p,minDate:s,maxDate:n,handlerChangeTimeRange:M,variants:E,locale:D}),L==="SINGLE"&&w.jsx(k.default,{defaultValue:H(i?.endDate,D),value:c?.end,minValue:I,maxValue:N,minDate:s,maxDate:n,withConfirm:a,prevIcon:f,nextIcon:g,buttonReset:h,buttonSubmit:d,locale:D,time:p,typeTime:"RANGE",handlerChangeTime:M,isCustomTime:T,createCalendar:e.createCalendar,onChange:t=>x({start:t,end:t}),handlerReset:F,handlerSubmit:P,type:["date","month","year"],variants:E})]})})};exports.default=O;
@@ -1,107 +1,119 @@
1
- import { jsx as S, jsxs as Z } from "react/jsx-runtime";
2
- import A, { useEffect as q } from "react";
3
- import { useLocale as z, I18nProvider as B } from "react-aria";
4
- import K from "../Calendar/CalendarRange.mjs";
5
- import { toCalendarDate as L, fromDate as P, getLocalTimeZone as c, createCalendar as Q, parseDate as U, CalendarDate as Y } from "@internationalized/date";
6
- import W from "../Calendar/Calendar.mjs";
7
- const R = (o) => {
1
+ import { jsx as H, jsxs as Z } from "react/jsx-runtime";
2
+ import Y, { useEffect as q } from "react";
3
+ import { I18nProvider as z } from "react-aria";
4
+ import B from "../Calendar/CalendarRange.mjs";
5
+ import { toCalendarDate as $, fromDate as j, getLocalTimeZone as D, createCalendar as K, parseDate as Q, CalendarDate as k } from "@internationalized/date";
6
+ import U from "../Calendar/Calendar.mjs";
7
+ const M = (o, r) => {
8
8
  let e;
9
- const n = new Date(o ?? /* @__PURE__ */ new Date());
10
- return o && (e = U(new Date(n.setHours(n.getHours() + 7)).toISOString().slice(0, 10))), e;
11
- }, j = (o) => {
12
- const e = new Date(o?.startDate ?? /* @__PURE__ */ new Date()), n = new Date(o?.endDate ?? /* @__PURE__ */ new Date()), s = new Y(e.getFullYear(), e.getMonth() + 1, e.getDate()), d = new Y(n.getFullYear(), n.getMonth() + 1, n.getDate());
13
- return o ? { start: s, end: d } : void 0;
9
+ if (o) {
10
+ const n = new Intl.DateTimeFormat(r, {
11
+ year: "numeric",
12
+ month: "2-digit",
13
+ day: "2-digit"
14
+ }).formatToParts(new Date(o)), l = n.find((i) => i.type === "year")?.value, g = n.find((i) => i.type === "month")?.value, h = n.find((i) => i.type === "day")?.value;
15
+ return e = Q(`${l}-${g}-${h}`), e;
16
+ }
17
+ }, L = (o) => {
18
+ if (!o?.startDate || !o?.endDate) return;
19
+ const r = new Date(o.startDate), e = new Date(o.endDate), s = new k(r.getFullYear(), r.getMonth() + 1, r.getDate()), n = new k(e.getFullYear(), e.getMonth() + 1, e.getDate());
20
+ return { start: s, end: n };
14
21
  }, nt = (o) => {
15
22
  const {
16
- minDate: e,
17
- maxDate: n,
23
+ minDate: r,
24
+ maxDate: e,
18
25
  defaultValue: s,
19
- withConfirm: d,
20
- prevIcon: H,
21
- nextIcon: x,
22
- buttonReset: y,
23
- buttonSubmit: T,
24
- typePicker: M = "RANGE",
26
+ withConfirm: n,
27
+ prevIcon: l,
28
+ nextIcon: g,
29
+ buttonReset: h,
30
+ buttonSubmit: i,
31
+ typePicker: b = "RANGE",
25
32
  onChange: E,
26
- value: D,
33
+ value: m,
27
34
  onReset: I,
28
- isCustomTime: l
29
- } = o, { locale: k } = z(), N = R(e), V = R(n), [r, g] = A.useState(), [h, w] = A.useState({ start: void 0, end: void 0 }), b = (t) => {
35
+ isCustomTime: w,
36
+ variants: N = "laba-blue-10",
37
+ locale: u = "id-ID"
38
+ } = o, F = M(r, u), V = M(e, u), [d, C] = Y.useState(), [R, S] = Y.useState({ start: void 0, end: void 0 }), G = (t) => {
30
39
  typeof E == "function" && E(t);
31
- }, p = (t, a) => {
32
- const i = t.start.toDate(c()), u = t.end.toDate(c());
33
- g(t), w({ start: { hour: 0, minut: 0, second: 0 }, end: { hour: 23, minut: 59, second: 59 } }), (a ?? !d) && b({ startDate: i, endDate: new Date(u.setHours(23, 59, 59)) });
34
- }, C = (t, a) => {
35
- if (r?.start && r?.end && (w(t), t.start?.hour?.toString() && t.start?.minut?.toString() && t.end?.hour?.toString() && t.end?.minut?.toString() && (a ?? !d))) {
36
- const i = r.start.toDate(c()), u = r.end.toDate(c()), m = new Date(i.setHours(t.start.hour, t.start.minut)), f = new Date(u.setHours(t.end.hour, t.end.minut, 59));
37
- m.getTime() < f.getTime() && b({ startDate: m, endDate: f });
40
+ }, T = (t, a) => {
41
+ const c = t.start.toDate(D()), f = t.end.toDate(D());
42
+ C(t), S({ start: { hour: 0, minut: 0, second: 0 }, end: { hour: 23, minut: 59, second: 59 } }), (a ?? !n) && G({ startDate: c, endDate: new Date(f.setHours(23, 59, 59)) });
43
+ }, x = (t, a) => {
44
+ if (d?.start && d?.end && (S(t), t.start?.hour?.toString() && t.start?.minut?.toString() && t.end?.hour?.toString() && t.end?.minut?.toString() && (a ?? !n))) {
45
+ const c = d.start.toDate(D()), f = d.end.toDate(D()), p = new Date(c.setHours(t.start.hour, t.start.minut)), y = new Date(f.setHours(t.end.hour, t.end.minut, 59));
46
+ p.getTime() < y.getTime() && G({ startDate: p, endDate: y });
38
47
  }
39
- }, F = (t) => {
48
+ }, P = (t) => {
40
49
  if (typeof I == "function")
41
50
  I();
42
51
  else if (s && t) {
43
- const a = new Date(s.endDate ?? /* @__PURE__ */ new Date()), i = t.focusedDate.set({
52
+ const a = new Date(s.endDate ?? /* @__PURE__ */ new Date()), c = t.focusedDate.set({
44
53
  month: a.getMonth() + 1,
45
54
  year: a.getFullYear()
46
55
  });
47
- t.setFocusedDate(i);
56
+ t.setFocusedDate(c);
48
57
  }
49
- g(j(s));
50
- }, G = () => {
51
- r && (l ? C(h, !0) : p(r, !0));
58
+ C(L(s));
59
+ }, A = () => {
60
+ d && (w ? x(R, !0) : T(d, !0));
52
61
  };
53
62
  return q(() => {
54
- if (D?.endDate && D?.startDate) {
55
- const t = new Date(D.startDate), a = new Date(D.endDate), i = t.getHours(), u = t.getMinutes(), m = a.getHours(), f = a.getMinutes(), O = L(P(t, c())), J = L(P(a, c()));
56
- g({ start: O, end: J }), w({ start: { hour: i, minut: u }, end: { hour: m, minut: f } });
63
+ if (m?.endDate && m?.startDate) {
64
+ const t = new Date(m.startDate), a = new Date(m.endDate), c = t.getHours(), f = t.getMinutes(), p = a.getHours(), y = a.getMinutes(), J = $(j(t, D())), O = $(j(a, D()));
65
+ C({ start: J, end: O }), S({ start: { hour: c, minut: f }, end: { hour: p, minut: y } });
57
66
  }
58
- }, [JSON.stringify(D)]), /* @__PURE__ */ S("div", { className: "iru-flex iru-flex-col", children: /* @__PURE__ */ Z(B, { locale: "id-ID", children: [
59
- M === "RANGE" && /* @__PURE__ */ S(
60
- K,
67
+ }, [JSON.stringify(m)]), /* @__PURE__ */ H("div", { className: "iru-flex iru-flex-col", children: /* @__PURE__ */ Z(z, { locale: u, children: [
68
+ b === "RANGE" && /* @__PURE__ */ H(
69
+ B,
61
70
  {
62
- defaultValue: j(s),
63
- value: r,
64
- minValue: N,
71
+ defaultValue: L(s),
72
+ value: d,
73
+ minValue: F,
65
74
  maxValue: V,
66
- withConfirm: d,
67
- prevIcon: H,
68
- nextIcon: x,
69
- buttonReset: y,
70
- buttonSubmit: T,
71
- onChange: (t) => p(t),
72
- isCustomTime: l,
73
- handlerReset: F,
74
- handlerSubmit: G,
75
- time: h,
76
- minDate: e,
77
- maxDate: n,
78
- handlerChangeTimeRange: C
75
+ withConfirm: n,
76
+ prevIcon: l,
77
+ nextIcon: g,
78
+ buttonReset: h,
79
+ buttonSubmit: i,
80
+ onChange: (t) => T(t),
81
+ isCustomTime: w,
82
+ handlerReset: P,
83
+ handlerSubmit: A,
84
+ time: R,
85
+ minDate: r,
86
+ maxDate: e,
87
+ handlerChangeTimeRange: x,
88
+ variants: N,
89
+ locale: u
79
90
  }
80
91
  ),
81
- M === "SINGLE" && /* @__PURE__ */ S(
82
- W,
92
+ b === "SINGLE" && /* @__PURE__ */ H(
93
+ U,
83
94
  {
84
- defaultValue: R(s?.endDate),
85
- value: r?.end,
86
- minValue: N,
95
+ defaultValue: M(s?.endDate, u),
96
+ value: d?.end,
97
+ minValue: F,
87
98
  maxValue: V,
88
- minDate: e,
89
- maxDate: n,
90
- withConfirm: d,
91
- prevIcon: H,
92
- nextIcon: x,
93
- buttonReset: y,
94
- buttonSubmit: T,
95
- locale: k,
96
- time: h,
99
+ minDate: r,
100
+ maxDate: e,
101
+ withConfirm: n,
102
+ prevIcon: l,
103
+ nextIcon: g,
104
+ buttonReset: h,
105
+ buttonSubmit: i,
106
+ locale: u,
107
+ time: R,
97
108
  typeTime: "RANGE",
98
- handlerChangeTime: C,
99
- isCustomTime: l,
100
- createCalendar: Q,
101
- onChange: (t) => p({ start: t, end: t }),
102
- handlerReset: F,
103
- handlerSubmit: G,
104
- type: ["date", "month", "year"]
109
+ handlerChangeTime: x,
110
+ isCustomTime: w,
111
+ createCalendar: K,
112
+ onChange: (t) => T({ start: t, end: t }),
113
+ handlerReset: P,
114
+ handlerSubmit: A,
115
+ type: ["date", "month", "year"],
116
+ variants: N
105
117
  }
106
118
  )
107
119
  ] }) });
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const s=require("react/jsx-runtime"),n=require("react"),L=require("./DateRangePicker.cjs"),Q=require("../Popover/Popover.cjs"),h=require("../Calendar/style.module.scss.cjs"),m=require("../../utils/common.cjs"),U=require("../Button/Button.cjs"),X=({value:r,prevIcon:v,nextIcon:F,buttonReset:k,buttonSubmit:T,className:K,classNameButton:q,buttonClick:i,buttonList:g,typePicker:H="RANGE",onChange:j,idPopover:N="filter-date-popover",id:R="filter-date",floatingOptions:W={},offsetPopover:P=5,zIndexPopper:B=0,defaultValueLabel:c,isCustomTime:E=!1,mountedExecuteChange:O=!0,formatingDate:u})=>{const w=[{key:"thisDay",value:"Hari ini"},{key:"thisWeek",value:"Minggu ini"},{key:"thisMonth",value:"Bulan ini"},{key:"thisYear",value:"Tahun ini"},{key:"yesterday",value:"Kemarin"},{key:"lastWeek",value:"Minggu lalu"},{key:"lastMonth",value:"Bulan lalu"},{key:"lastYear",value:"Tahun lalu"},{key:"custom",value:"Kustom"}],S=n.useRef(null),[b,M]=n.useState(),[$,o]=n.useState(),[x,Y]=n.useState(),D=(e,t)=>{const a=new Date(e??new Date);return t==="start"?new Date(a.setHours(0,0,0)):new Date(a.setHours(23,59,59))},_=()=>{const e=new Date;return{startDate:e,endDate:e}},z=()=>{const e=new Date;e.setDate(e.getDate()-e.getDay());const t=new Date;return t.setDate(t.getDate()+(6-t.getDay())),{startDate:e,endDate:t}},V=()=>{const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1),a=new Date(e.getFullYear(),e.getMonth()+1,0);return{startDate:t,endDate:a}},A=()=>{const e=new Date(new Date().getFullYear(),0,1),t=new Date(new Date().getFullYear(),11,31);return{startDate:e,endDate:t}},G=()=>{const e=new Date(new Date().setDate(new Date().getDate()-1));return{startDate:e,endDate:e}},I=()=>{const e=new Date;e.setDate(e.getDate()-(7+e.getDay()));const t=new Date;return t.setDate(t.getDate()-(t.getDay()+1)),{startDate:e,endDate:t}},J=()=>{const e=new Date,t=new Date(e.getFullYear(),e.getMonth()-1,1),a=new Date(e.getFullYear(),e.getMonth(),0);return{startDate:t,endDate:a}},C=()=>{const e=new Date(new Date().getFullYear()-1,0,1),t=new Date(new Date().getFullYear()-1,11,31);return{startDate:e,endDate:t}},d=(e,t,a)=>{if(Y(e),typeof j=="function"){let l=e;u==="string"&&e?l={startDate:m.formatDate(e.startDate,u),endDate:m.formatDate(e.endDate,u)}:typeof u=="boolean"&&e&&(l={startDate:m.formatDate(e.startDate,"yyyy-MM-dd'T'HH:mm:ss.SSSxxx"),endDate:m.formatDate(e.endDate,"yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}),S.current?.setShow(!1),j(l,t??"",a)}},f=(e,t)=>{M(e);let a;if(e?.key!=="custom"){switch(o(e),e?.key){case"thisDay":a=_();break;case"thisWeek":a=z();break;case"thisMonth":a=V();break;case"thisYear":a=A();break;case"yesterday":a=G();break;case"lastWeek":a=I();break;case"lastMonth":a=J();break;case"lastYear":a=C();break}a&&t&&d({startDate:D(a.startDate,"start"),endDate:D(a.endDate,"end")},e?.value,e)}},y=(e,t)=>{const a=(g??w).find(l=>l.key===e);!e&&!a?(t&&d(),f(void 0,t),o(void 0)):typeof e=="object"?(t&&d({startDate:D(e.startDate,"start"),endDate:D(e.endDate,"end")},"Kustom",{key:"custom",value:"Kustom"}),f({key:"custom",value:"Kustom"},t),o({key:"custom",value:"Kustom"})):(f(a,t),o(a))},p=()=>{if(r){Y(r);const e=(g??w)?.find(t=>t.key===r.label||t.value===r.label);Object.keys(e||{}).length>0&&M(e)}else M(void 0),o(void 0)};return n.useEffect(()=>{p()},[JSON.stringify(r)]),n.useEffect(()=>{y(c??r,O)},[]),s.jsxs(s.Fragment,{children:[s.jsxs("div",{onClick:e=>{S.current?.handlerShow(e),p()},className:q,id:R,children:[n.isValidElement(i)&&i,typeof i=="function"?i(x,$):"Pilih Filter"]}),s.jsx(Q.default,{zIndex:B,ref:S,offset:P,id:N,floatingOptions:{placement:"bottom-end",...W},children:s.jsxs("div",{className:`${h.default["container-filter-date"]} ${K}`,children:[s.jsxs("div",{children:[(g??w).map((e,t)=>s.jsx("div",{className:`${h.default["button-filter-date"]} hover:iru-bg-laba-blue-01 ${b?.key===e.key?"iru-text-laba-blue-10":""}`,onClick:()=>f(e,!0),children:e.value},t)),b?.key!=="custom"&&s.jsx(s.Fragment,{children:typeof k=="function"?s.jsx("div",{className:h.default["button-filter-date-custome"],onClick:()=>y(c,!0),children:k()}):s.jsx(U.default,{className:h.default["button-reset-filter-date"],variants:"nude-laba-blue-10",size:"small",onClick:()=>y(c,!0),children:"Reset"})})]}),b?.key==="custom"&&s.jsx("div",{children:s.jsx(L.default,{defaultValue:x,value:x,prevIcon:v,nextIcon:F,buttonReset:k,buttonSubmit:T,isCustomTime:E,onChange:e=>{d(e,"Kustom",{key:"custom",value:"Kustom"}),o({key:"custom",value:"Kustom"})},onReset:()=>{y(c,!0)},typePicker:H,withConfirm:!0})})]})})]})};exports.default=X;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),o=require("react"),Z=require("./DateRangePicker.cjs"),ee=require("../Popover/Popover.cjs"),k=require("../Calendar/style.module.scss.cjs"),w=require("../../utils/common.cjs"),te=require("../Button/Button.cjs"),R=require("../Calendar/Calendar.config.cjs"),n={"en-US":{Today:"Today","This week":"This week","This month":"This month","This year":"This year",Yesterday:"Yesterday","Last week":"Last week","Last month":"Last month","Last year":"Last year",Custom:"Custom",Reset:"Reset"},"id-ID":{Today:"Hari ini","This week":"Minggu ini","This month":"Bulan ini","This year":"Tahun ini",Yesterday:"Kemarin","Last week":"Minggu lalu","Last month":"Bulan lalu","Last year":"Tahun lalu",Custom:"Kustom",Reset:"Reset"},"zh-CN":{Today:"今天","This week":"本周","This month":"本月","This year":"今年",Yesterday:"昨天","Last week":"上周","Last month":"上个月","Last year":"去年",Custom:"自定义",Reset:"重置"},"nl-NL":{Today:"Vandaag","This week":"Deze week","This month":"Deze maand","This year":"Dit jaar",Yesterday:"Gisteren","Last week":"Vorige week","Last month":"Vorige maand","Last year":"Vorig jaar",Custom:"Aangepast",Reset:"Reset"}},ae=({value:i,prevIcon:F,nextIcon:v,buttonReset:g,buttonSubmit:N,className:q,classNameButton:V,buttonClick:D,buttonList:T,typePicker:H="RANGE",onChange:C,idPopover:W="filter-date-popover",id:z="filter-date",floatingOptions:B={},offsetPopover:P=5,zIndexPopper:E=0,defaultValueLabel:c,isCustomTime:O=!1,mountedExecuteChange:_=!0,formatingDate:l,variants:Y="laba-blue-10",locale:s="id-ID"})=>{const S=[{key:"thisDay",value:n[s].Today},{key:"thisWeek",value:n[s]["This week"]},{key:"thisMonth",value:n[s]["This month"]},{key:"thisYear",value:n[s]["This year"]},{key:"yesterday",value:n[s].Yesterday},{key:"lastWeek",value:n[s]["Last week"]},{key:"lastMonth",value:n[s]["Last month"]},{key:"lastYear",value:n[s]["Last year"]},{key:"custom",value:n[s].Custom}],L=o.useRef(null),[M,j]=o.useState(),[$,d]=o.useState(),[b,x]=o.useState(),h=(e,t)=>{const a=new Date(e??new Date);return t==="start"?new Date(a.setHours(0,0,0)):new Date(a.setHours(23,59,59))},I=()=>{const e=new Date;return{startDate:e,endDate:e}},K=()=>{const e=new Date;e.setDate(e.getDate()-e.getDay());const t=new Date;return t.setDate(t.getDate()+(6-t.getDay())),{startDate:e,endDate:t}},A=()=>{const e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1),a=new Date(e.getFullYear(),e.getMonth()+1,0);return{startDate:t,endDate:a}},G=()=>{const e=new Date(new Date().getFullYear(),0,1),t=new Date(new Date().getFullYear(),11,31);return{startDate:e,endDate:t}},J=()=>{const e=new Date(new Date().setDate(new Date().getDate()-1));return{startDate:e,endDate:e}},U=()=>{const e=new Date;e.setDate(e.getDate()-(7+e.getDay()));const t=new Date;return t.setDate(t.getDate()-(t.getDay()+1)),{startDate:e,endDate:t}},Q=()=>{const e=new Date,t=new Date(e.getFullYear(),e.getMonth()-1,1),a=new Date(e.getFullYear(),e.getMonth(),0);return{startDate:t,endDate:a}},X=()=>{const e=new Date(new Date().getFullYear()-1,0,1),t=new Date(new Date().getFullYear()-1,11,31);return{startDate:e,endDate:t}},y=(e,t,a)=>{if(x(e),typeof C=="function"){let u=e;l==="string"&&e?u={startDate:w.formatDate(e.startDate,l),endDate:w.formatDate(e.endDate,l)}:typeof l=="boolean"&&e&&(u={startDate:w.formatDate(e.startDate,"yyyy-MM-dd'T'HH:mm:ss.SSSxxx"),endDate:w.formatDate(e.endDate,"yyyy-MM-dd'T'HH:mm:ss.SSSxxx")}),L.current?.setShow(!1),C(u,t??"",a)}},m=(e,t)=>{j(e);let a;if(e?.key!=="custom"){switch(d(e),e?.key){case"thisDay":a=I();break;case"thisWeek":a=K();break;case"thisMonth":a=A();break;case"thisYear":a=G();break;case"yesterday":a=J();break;case"lastWeek":a=U();break;case"lastMonth":a=Q();break;case"lastYear":a=X();break}a&&t&&y({startDate:h(a.startDate,"start"),endDate:h(a.endDate,"end")},e?.value,e)}},f=(e,t)=>{const a=(T??S).find(u=>u.key===e);!e&&!a?(t&&y(),m(void 0,t),d(void 0)):typeof e=="object"?(t&&y({startDate:h(e.startDate,"start"),endDate:h(e.endDate,"end")},"Kustom",{key:"custom",value:n[s].Custom}),m({key:"custom",value:n[s].Custom},t),d({key:"custom",value:n[s].Custom})):(m(a,t),d(a))},p=()=>{if(i){x(i);const e=(T??S)?.find(t=>t.key===i.label||t.value===i.label);Object.keys(e||{}).length>0&&j(e)}else j(void 0),d(void 0)};return o.useEffect(()=>{p()},[JSON.stringify(i)]),o.useEffect(()=>{f(c??i,_)},[]),r.jsxs(r.Fragment,{children:[r.jsxs("div",{onClick:e=>{L.current?.handlerShow(e),p()},className:V,id:z,children:[o.isValidElement(D)&&D,typeof D=="function"?D(b,$):"Pilih Filter"]}),r.jsx(ee.default,{zIndex:E,ref:L,offset:P,id:W,floatingOptions:{placement:"bottom-end",...B},children:r.jsxs("div",{className:`${R.configCalendar.selectedVariants[Y]} ${q}`,children:[r.jsxs("div",{children:[(T??S).map((e,t)=>r.jsx("div",{className:`${k.default["button-filter-date"]} hover:iru-bg-laba-blue-01 ${M?.key===e.key?k.default.selected:""}`,onClick:()=>m(e,!0),children:e.value},t)),M?.key!=="custom"&&r.jsx(r.Fragment,{children:typeof g=="function"?r.jsx("div",{className:k.default["button-filter-date-custome"],onClick:()=>f(c,!0),children:g()}):r.jsx(te.default,{className:k.default["button-reset-filter-date"],variants:R.configCalendar.resetButtonVariant[Y],size:"small",onClick:()=>f(c,!0),children:n[s].Reset})})]}),M?.key==="custom"&&r.jsx("div",{children:r.jsx(Z.default,{defaultValue:b,value:b,prevIcon:F,nextIcon:v,buttonReset:g,buttonSubmit:N,isCustomTime:O,variants:Y,onChange:e=>{y(e,n[s].Custom,{key:"custom",value:n[s].Custom}),d({key:"custom",value:n[s].Custom})},onReset:()=>{f(c,!0)},typePicker:H,locale:s,withConfirm:!0})})]})})]})};exports.default=ae;