1mpacto-react-ui 2.0.22 → 2.0.24

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.
@@ -1,94 +1,111 @@
1
- import { jsxs as w, jsx as b } from "react/jsx-runtime";
2
- import { Chart as k, ArcElement as I, Tooltip as E } from "chart.js";
3
- import m from "react";
4
- import { Pie as S } from "react-chartjs-2";
5
- import { mergeObjects as A, formatNumber as y } from "../../utils/common.mjs";
6
- import B from "../PortalComponent/PortalComponent.mjs";
7
- k.register(I, E);
8
- const x = (t, l, n) => {
9
- const r = l > 0 ? t / l * 100 : 0;
10
- switch (n) {
1
+ import { jsxs as T, jsx as y } from "react/jsx-runtime";
2
+ import { Chart as j, ArcElement as k, Tooltip as B } from "chart.js";
3
+ import h from "react";
4
+ import { Pie as K } from "react-chartjs-2";
5
+ import { mergeObjects as S, formatNumber as D } from "../../utils/common.mjs";
6
+ import R from "../PortalComponent/PortalComponent.mjs";
7
+ j.register(k, B);
8
+ const C = (t, s, e) => {
9
+ const a = s > 0 ? t / s * 100 : 0;
10
+ switch (e) {
11
11
  case "decimal":
12
- return y(t, "decimal");
12
+ return D(t, "decimal");
13
13
  case "currency":
14
- return y(t, "currency");
14
+ return D(t, "currency");
15
15
  default:
16
- return `${Math.round(r)}%`;
16
+ return `${Math.round(a)}%`;
17
17
  }
18
- }, h = () => {
19
- const t = Math.floor(Math.random() * 360), l = 60 + Math.floor(Math.random() * 30), n = 45 + Math.floor(Math.random() * 20);
20
- return ((o, a, c) => {
21
- a /= 100, c /= 100;
22
- const s = a * Math.min(c, 1 - c), u = (d) => {
23
- const i = (d + o / 30) % 12, e = c - s * Math.max(Math.min(i - 3, 9 - i, 1), -1);
24
- return Math.round(255 * e).toString(16).padStart(2, "0");
18
+ }, v = () => {
19
+ const t = Math.floor(Math.random() * 360), s = 60 + Math.floor(Math.random() * 30), e = 45 + Math.floor(Math.random() * 20);
20
+ return ((r, o, n) => {
21
+ o /= 100, n /= 100;
22
+ const c = o * Math.min(n, 1 - n), d = (u) => {
23
+ const i = (u + r / 30) % 12, l = n - c * Math.max(Math.min(i - 3, 9 - i, 1), -1);
24
+ return Math.round(255 * l).toString(16).padStart(2, "0");
25
25
  };
26
- return `#${u(0)}${u(8)}${u(4)}`;
27
- })(t, l, n);
28
- }, T = (t, l) => Array.isArray(t) ? t[l] || h() : typeof t == "string" ? t : h(), F = (t) => {
29
- const l = t.labels ?? [], n = t.datasets[0];
30
- return n ? (n.data ?? []).map((o, a) => ({
31
- label: l[a] ?? "",
26
+ return `#${d(0)}${d(8)}${d(4)}`;
27
+ })(t, s, e);
28
+ }, F = (t, s) => Array.isArray(t) ? t[s] || v() : typeof t == "string" ? t : v(), M = (t) => t !== "data" && t.startsWith("data"), L = (t) => {
29
+ const s = t.data?.length ?? 0;
30
+ return Object.keys(t).filter((e) => {
31
+ const a = t[e];
32
+ return M(e) && Array.isArray(a) && a.length === s;
33
+ });
34
+ }, O = (t, s, e) => s.reduce((a, r) => {
35
+ const o = t[r];
36
+ return Array.isArray(o) && (a[r] = o[e]), a;
37
+ }, {}), E = (t) => Object.keys(t[0] ?? {}).filter(M).reduce((e, a) => (e[a] = t.map((r) => r[a]), e), {}), P = (t, s = {}) => ({
38
+ labels: t.map((e) => e.label),
39
+ values: t.map((e) => e.value),
40
+ colors: t.map((e) => e.backgroundColor || v()),
41
+ extraDatasetData: E(t),
42
+ mergedMap: s
43
+ }), V = (t) => {
44
+ const s = t.labels ?? [], e = t.datasets[0];
45
+ if (!e) return [];
46
+ const a = e.data ?? [], r = L(e);
47
+ return a.map((o, n) => ({
48
+ label: s[n] ?? "",
32
49
  value: o,
33
- backgroundColor: T(n.backgroundColor, a)
34
- })) : [];
35
- }, R = (t, l) => {
36
- if (!l)
37
- return {
38
- labels: t.map((e) => e.label),
39
- values: t.map((e) => e.value),
40
- colors: t.map((e) => e.backgroundColor || h()),
41
- mergedMap: {}
42
- };
43
- const { mode: n, value: r, otherLabel: o = "Other", otherBackgroundColor: a = "#B0BEC5" } = l, c = t.reduce((e, p) => e + p.value, 0), s = [], u = [];
44
- let d = 0;
45
- t.forEach((e) => {
46
- (n === "percentage" ? e.value / c * 100 < r : e.value < r) ? (d += e.value, u.push(e)) : s.push({
47
- label: e.label,
48
- value: e.value,
49
- color: e.backgroundColor || h()
50
- });
50
+ backgroundColor: F(e.backgroundColor, n),
51
+ ...O(e, r, n)
52
+ }));
53
+ }, $ = (t, s) => {
54
+ if (!s) return P(t);
55
+ const { mode: e, value: a, otherLabel: r = "Other", otherBackgroundColor: o = "#B0BEC5" } = s, n = t.reduce((l, f) => l + f.value, 0), c = [], d = [];
56
+ let u = 0;
57
+ t.forEach((l) => {
58
+ (e === "percentage" ? l.value / n * 100 < a : l.value < a) ? (u += l.value, d.push(l)) : c.push(l);
51
59
  });
52
60
  const i = {};
53
- return d > 0 && (s.push({ label: o, value: d, color: a }), i[s.length - 1] = u), {
54
- labels: s.map((e) => e.label),
55
- values: s.map((e) => e.value),
56
- colors: s.map((e) => e.color),
57
- mergedMap: i
58
- };
59
- }, V = (t, l, n) => ({ chart: r, tooltip: o }) => {
60
- const a = {};
61
- if (o.opacity === 0) {
62
- t((f) => ({ ...f, style: { ...f.style, opacity: 0, pointerEvents: "none" } }));
61
+ if (u > 0) {
62
+ const l = E(d);
63
+ c.push({
64
+ ...l,
65
+ label: r,
66
+ value: u,
67
+ backgroundColor: o
68
+ }), i[c.length - 1] = d;
69
+ }
70
+ return P(c, i);
71
+ }, W = (t, s, e) => ({ chart: a, tooltip: r }) => {
72
+ const o = {};
73
+ if (r.opacity === 0) {
74
+ t((p) => ({ ...p, style: { ...p.style, opacity: 0, pointerEvents: "none" } }));
63
75
  return;
64
76
  }
65
- if (!o.dataPoints || o.dataPoints.length === 0) return;
66
- a.opacity = "1", a.position = "absolute", a.pointerEvents = "none";
67
- const c = r.canvas.getBoundingClientRect();
68
- a.left = c.left + window.pageXOffset + o.caretX + "px", a.top = c.top + window.pageYOffset + o.caretY + "px";
69
- const s = o.dataPoints[0].dataIndex, u = o.dataPoints?.[0]?.label ?? "", d = o.dataPoints?.[0]?.raw ?? 0, i = o.dataPoints?.[0]?.dataset.backgroundColor?.[s] ?? "", e = o.dataPoints?.[0]?.dataset.data?.reduce((f, g) => f + g, 0) || 1, p = e > 0 ? d / e * 100 : 0;
77
+ if (!r.dataPoints || r.dataPoints.length === 0) return;
78
+ o.opacity = "1", o.position = "absolute", o.pointerEvents = "none";
79
+ const n = a.canvas.getBoundingClientRect();
80
+ o.left = n.left + window.pageXOffset + r.caretX + "px", o.top = n.top + window.pageYOffset + r.caretY + "px";
81
+ const c = r.dataPoints[0].dataIndex, d = r.dataPoints[0].dataset, u = r.dataPoints?.[0]?.label ?? "", i = r.dataPoints?.[0]?.raw ?? 0, l = d.backgroundColor?.[c] ?? "", f = d.data?.reduce((p, x) => p + x, 0) || 1, g = f > 0 ? i / f * 100 : 0, m = Object.keys(d).filter(M), b = O(
82
+ d,
83
+ m,
84
+ c
85
+ );
70
86
  t({
71
87
  label: u,
72
- value: d,
73
- percentage: p,
74
- formattedValue: x(d, e, l),
75
- backgroundColor: typeof i == "string" ? i : "#000",
76
- mergedItems: n[s] ?? [],
77
- style: a,
78
- dataPoints: o.dataPoints
88
+ value: i,
89
+ percentage: g,
90
+ formattedValue: C(i, f, s),
91
+ backgroundColor: typeof l == "string" ? l : "#000",
92
+ mergedItems: e[c] ?? [],
93
+ style: o,
94
+ dataPoints: r.dataPoints,
95
+ ...b
79
96
  });
80
- }, $ = (t, l) => ({
97
+ }, G = (t, s) => ({
81
98
  id: "pieLabelPlugin",
82
- afterDraw(n) {
83
- const { ctx: r } = n, o = n.getDatasetMeta(0), a = n.data.datasets[0].data.reduce((c, s) => c + s, 0);
84
- o.data.forEach((c, s) => {
85
- const d = n.data.datasets[0].data[s] ?? 0;
86
- if ((a > 0 ? d / a * 100 : 0) < l) return;
87
- const { x: e, y: p } = c.tooltipPosition(!1), f = n.data.labels?.[s];
88
- r.save(), r.textAlign = "center", r.textBaseline = "middle", r.fillStyle = "#FFFFFF", r.font = "bold 10px Inter, sans-serif", r.fillText(f, e || 0, (p || 0) - 6), r.fillText(x(d, a, t), e || 0, (p || 0) + 8), r.restore();
99
+ afterDraw(e) {
100
+ const { ctx: a } = e, r = e.getDatasetMeta(0), o = e.data.datasets[0].data.reduce((n, c) => n + c, 0);
101
+ r.data.forEach((n, c) => {
102
+ const u = e.data.datasets[0].data[c] ?? 0;
103
+ if ((o > 0 ? u / o * 100 : 0) < s) return;
104
+ const { x: l, y: f } = n.tooltipPosition(!1), g = e.data.labels?.[c];
105
+ a.save(), a.textAlign = "center", a.textBaseline = "middle", a.fillStyle = "#FFFFFF", a.font = "bold 10px Inter, sans-serif", a.fillText(g, l || 0, (f || 0) - 6), a.fillText(C(u, o, t), l || 0, (f || 0) + 8), a.restore();
89
106
  });
90
107
  }
91
- }), j = {
108
+ }), H = {
92
109
  responsive: !0,
93
110
  maintainAspectRatio: !1,
94
111
  plugins: {
@@ -105,18 +122,18 @@ const x = (t, l, n) => {
105
122
  borderWidth: 0
106
123
  }
107
124
  }
108
- }, Y = ({
125
+ }, U = ({
109
126
  data: t,
110
- height: l,
111
- classNameContainer: n,
112
- id: r,
113
- options: o,
114
- CustomTooltip: a,
115
- threshold: c,
116
- valueFormat: s,
117
- hideLabelBelowPercentage: u = 5
127
+ height: s,
128
+ classNameContainer: e,
129
+ id: a,
130
+ options: r,
131
+ CustomTooltip: o,
132
+ threshold: n,
133
+ valueFormat: c,
134
+ hideLabelBelowPercentage: d = 5
118
135
  }) => {
119
- const [d, i] = m.useState({
136
+ const [u, i] = h.useState({
120
137
  style: { opacity: 0, position: "absolute", left: 0, top: 0 },
121
138
  label: "",
122
139
  value: 0,
@@ -125,45 +142,47 @@ const x = (t, l, n) => {
125
142
  backgroundColor: "",
126
143
  mergedItems: [],
127
144
  dataPoints: []
128
- }), e = m.useMemo(() => F(t), [t]), {
129
- labels: p,
130
- values: f,
131
- colors: g,
132
- mergedMap: v
133
- } = m.useMemo(() => R(e, c), [e, c]), M = m.useMemo(
145
+ }), l = h.useMemo(() => V(t), [t]), {
146
+ labels: f,
147
+ values: g,
148
+ colors: m,
149
+ extraDatasetData: b,
150
+ mergedMap: p
151
+ } = h.useMemo(() => $(l, n), [l, n]), x = h.useMemo(
134
152
  () => ({
135
- labels: p,
153
+ labels: f,
136
154
  datasets: [
137
155
  {
138
156
  ...t.datasets[0],
139
- data: f,
140
- backgroundColor: g,
157
+ ...b,
158
+ data: g,
159
+ backgroundColor: m,
141
160
  hoverOffset: 8,
142
161
  borderWidth: 0
143
162
  }
144
163
  ]
145
164
  }),
146
- [p, f, g, t.datasets]
147
- ), P = m.useMemo(() => A(j, {
165
+ [f, g, m, b, t.datasets]
166
+ ), w = h.useMemo(() => S(H, {
148
167
  plugins: {
149
168
  tooltip: {
150
- enabled: !a,
151
- external: a ? ({ chart: C, tooltip: O }) => V(i, s, v)({ chart: C, tooltip: O }) : void 0
169
+ enabled: !o,
170
+ external: o ? ({ chart: A, tooltip: I }) => W(i, c, p)({ chart: A, tooltip: I }) : void 0
152
171
  }
153
172
  }
154
- }, o ?? {}), [o, a, s, v]);
155
- return /* @__PURE__ */ w("div", { id: r, className: n, style: { height: l || "300px" }, children: [
156
- a && /* @__PURE__ */ b(B, { selector: "body", children: /* @__PURE__ */ b(a, { ...d }) }),
157
- /* @__PURE__ */ b(
158
- S,
173
+ }, r ?? {}), [r, o, c, p]);
174
+ return /* @__PURE__ */ T("div", { id: a, className: e, style: { height: s || "300px" }, children: [
175
+ o && /* @__PURE__ */ y(R, { selector: "body", children: /* @__PURE__ */ y(o, { ...u }) }),
176
+ /* @__PURE__ */ y(
177
+ K,
159
178
  {
160
- data: M,
161
- options: P,
162
- plugins: [$(s, u)]
179
+ data: x,
180
+ options: w,
181
+ plugins: [G(c, d)]
163
182
  }
164
183
  )
165
184
  ] });
166
185
  };
167
186
  export {
168
- Y as default
187
+ U as default
169
188
  };
@@ -1,12 +1,12 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),g=require("react"),$=require("../Button/Button.cjs"),n=require("./UploadImage.module.scss.cjs"),R=({className:s})=>t.jsx("svg",{viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",className:`iru-h-5 iru-w-5 iru-text-red-600 ${s??""}`,fill:"currentColor",children:t.jsx("g",{id:"x",children:t.jsx("path",{id:"Vector",fillRule:"evenodd",clipRule:"evenodd",d:`M6.19544 6.19126C6.32045 6.06628 6.48999 5.99607 6.66677 5.99607C6.84354 5.99607 7.01308 6.06628 7.1381
2
- 6.19126L10.0001 9.05326L12.8621 6.19126C12.9236 6.12758 12.9972 6.0768 13.0785 6.04186C13.1598 6.00692 13.2473
3
- 5.98853 13.3358 5.98776C13.4244 5.98699 13.5121 6.00386 13.5941 6.03738C13.676 6.0709 13.7504 6.1204 13.813
4
- 6.18299C13.8756 6.24559 13.9251 6.32002 13.9587 6.40195C13.9922 6.48389 14.009 6.57167 14.0083 6.66019C14.0075
5
- 6.74871 13.9891 6.83619 13.9542 6.91753C13.9192 6.99886 13.8684 7.07243 13.8048 7.13392L10.9428 9.99592L13.8048
6
- 12.8579C13.9262 12.9837 13.9934 13.1521 13.9919 13.3269C13.9904 13.5017 13.9203 13.6689 13.7966 13.7925C13.673
7
- 13.9161 13.5058 13.9862 13.331 13.9877C13.1562 13.9892 12.9878 13.922 12.8621 13.8006L10.0001 10.9386L7.1381
8
- 13.8006C7.01237 13.922 6.84397 13.9892 6.66917 13.9877C6.49437 13.9862 6.32716 13.9161 6.20356 13.7925C6.07995
9
- 13.6689 6.00984 13.5017 6.00832 13.3269C6.0068 13.1521 6.074 12.9837 6.19544 12.8579L9.05744 9.99592L6.19544
10
- 7.13392C6.07045 7.00891 6.00024 6.83937 6.00024 6.66259C6.00024 6.48581 6.07045 6.31628 6.19544 6.19126Z`})})}),N=({className:s})=>t.jsx("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:`iru-h-5 iru-w-5 ${s??""}`,children:t.jsx("g",{id:"upload",children:t.jsx("path",{id:"Vector",d:`M3.83337 13.3333V14.1666C3.83337 14.8297 4.09677 15.4656 4.56561 15.9344C5.03445 16.4033 5.67033
11
- 16.6666 6.33337 16.6666H14.6667C15.3297 16.6666 15.9656 16.4033 16.4345 15.9344C16.9033 15.4656 17.1667
12
- 14.8297 17.1667 14.1666V13.3333M13.8334 6.66665L10.5 3.33331M10.5 3.33331L7.16671 6.66665M10.5 3.33331V13.3333`,stroke:"#1976D2",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),y=({onChange:s,valueUrl:i,validateFile:p,validateFileDesc:k="Max 2MB (.jpg, .jpeg, .png, .svg)",maxSize:h=2,icon:D,desc:o,classNameContainer:L,classNameImage:c,classNameAction:w,id:l})=>{const r=g.useRef(null),m=p||["image/png","image/jpeg","image/jpg"],[a,x]=g.useState(""),[j,u]=g.useState(""),v=e=>{if(e?.length){const d=e[0],b=d.size/1024/1024;if(!m.some(f=>e[0].type?.includes(f)))u("Berkas tidak didukung, silahkan pilih file kembali.");else if(b>h){const f=`${e.length>1?"Jumlah u":"U"}kuran berkas tidak boleh melebihi ${h}MB.`;u(f)}else{if(!r?.current)return;u(""),s(d),x(URL.createObjectURL(d)),r.current.value=""}}},C=e=>{e.preventDefault(),v(e.dataTransfer.files)},M=e=>{e.preventDefault(),r?.current&&(typeof s=="function"&&s(null),x(""),r.current.value="")};return t.jsxs("div",{className:`${n.default.container} ${L}`,children:[t.jsx("input",{accept:m?.join(", "),ref:r,hidden:!0,type:"file",multiple:!1,onChange:e=>{e.target.files&&v(e.target.files)}}),a||i?t.jsx("div",{id:`${l}-exist`,className:`${n.default["image-content"]} ${c}`,onDrop:C,onDragOver:e=>e.preventDefault(),onDragLeave:e=>e.preventDefault(),children:t.jsx("img",{src:a||i,alt:"upload-image",className:`${n.default.image} ${c}`})}):t.jsxs("div",{id:l,className:`${n.default["image-content"]} ${c}`,onDrop:C,onDragOver:e=>e.preventDefault(),onDragLeave:e=>e.preventDefault(),children:[D,t.jsx("div",{className:n.default["text-desc"],children:typeof o=="function"?o():o})]}),t.jsxs("div",{className:n.default["action-content"],children:[t.jsxs("div",{className:`${n.default["button-content"]} ${w}`,children:[(a||i)&&t.jsx($.default,{id:`${l}-delete-img`,variants:"tertiary-red-600",size:"xs",startIcon:t.jsx(R,{}),onClick:e=>M(e),children:"Hapus"}),t.jsxs($.default,{id:`${l}-change-img`,variants:"tertiary-blue-700",size:"xs",onClick:()=>r.current?.click(),startIcon:t.jsx(N,{}),children:[a||i?"Ganti":"Pilih"," Gambar"]})]}),t.jsx("p",{className:n.default["text-desc"],children:k}),j&&t.jsx("p",{className:n.default["text-error"],children:j})]})]})};exports.default=y;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),g=require("react"),$=require("../Button/Button.cjs"),n=require("./UploadImage.module.scss.cjs"),R=({className:r})=>t.jsx("svg",{viewBox:"0 0 20 20",xmlns:"http://www.w3.org/2000/svg",className:`iru-h-5 iru-w-5 iru-text-red-600 ${r??""}`,fill:"currentColor",children:t.jsx("g",{id:"x",children:t.jsx("path",{id:"Vector",fillRule:"evenodd",clipRule:"evenodd",d:`M6.19544 6.19126C6.32045 6.06628 6.48999 5.99607 6.66677 5.99607C6.84354 5.99607 7.01308 6.06628 7.1381 \r
2
+ 6.19126L10.0001 9.05326L12.8621 6.19126C12.9236 6.12758 12.9972 6.0768 13.0785 6.04186C13.1598 6.00692 13.2473 \r
3
+ 5.98853 13.3358 5.98776C13.4244 5.98699 13.5121 6.00386 13.5941 6.03738C13.676 6.0709 13.7504 6.1204 13.813 \r
4
+ 6.18299C13.8756 6.24559 13.9251 6.32002 13.9587 6.40195C13.9922 6.48389 14.009 6.57167 14.0083 6.66019C14.0075 \r
5
+ 6.74871 13.9891 6.83619 13.9542 6.91753C13.9192 6.99886 13.8684 7.07243 13.8048 7.13392L10.9428 9.99592L13.8048 \r
6
+ 12.8579C13.9262 12.9837 13.9934 13.1521 13.9919 13.3269C13.9904 13.5017 13.9203 13.6689 13.7966 13.7925C13.673 \r
7
+ 13.9161 13.5058 13.9862 13.331 13.9877C13.1562 13.9892 12.9878 13.922 12.8621 13.8006L10.0001 10.9386L7.1381 \r
8
+ 13.8006C7.01237 13.922 6.84397 13.9892 6.66917 13.9877C6.49437 13.9862 6.32716 13.9161 6.20356 13.7925C6.07995 \r
9
+ 13.6689 6.00984 13.5017 6.00832 13.3269C6.0068 13.1521 6.074 12.9837 6.19544 12.8579L9.05744 9.99592L6.19544 \r
10
+ 7.13392C6.07045 7.00891 6.00024 6.83937 6.00024 6.66259C6.00024 6.48581 6.07045 6.31628 6.19544 6.19126Z`})})}),N=({className:r})=>t.jsx("svg",{viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:`iru-h-5 iru-w-5 ${r??""}`,children:t.jsx("g",{id:"upload",children:t.jsx("path",{id:"Vector",d:`M3.83337 13.3333V14.1666C3.83337 14.8297 4.09677 15.4656 4.56561 15.9344C5.03445 16.4033 5.67033 \r
11
+ 16.6666 6.33337 16.6666H14.6667C15.3297 16.6666 15.9656 16.4033 16.4345 15.9344C16.9033 15.4656 17.1667 \r
12
+ 14.8297 17.1667 14.1666V13.3333M13.8334 6.66665L10.5 3.33331M10.5 3.33331L7.16671 6.66665M10.5 3.33331V13.3333`,stroke:"#1976D2",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),y=({onChange:r,valueUrl:i,validateFile:p,validateFileDesc:k="Max 2MB (.jpg, .jpeg, .png, .svg)",maxSize:h=2,icon:D,desc:o,classNameContainer:L,classNameImage:c,classNameAction:w,id:l})=>{const s=g.useRef(null),m=p||["image/png","image/jpeg","image/jpg"],[a,x]=g.useState(""),[j,u]=g.useState(""),v=e=>{if(e?.length){const d=e[0],b=d.size/1024/1024;if(!m.some(f=>e[0].type?.includes(f)))u("Berkas tidak didukung, silahkan pilih file kembali.");else if(b>h){const f=`${e.length>1?"Jumlah u":"U"}kuran berkas tidak boleh melebihi ${h}MB.`;u(f)}else{if(!s?.current)return;u(""),r(d),x(URL.createObjectURL(d)),s.current.value=""}}},C=e=>{e.preventDefault(),v(e.dataTransfer.files)},M=e=>{e.preventDefault(),s?.current&&(typeof r=="function"&&r(null),x(""),s.current.value="")};return t.jsxs("div",{className:`${n.default.container} ${L}`,children:[t.jsx("input",{accept:m?.join(", "),ref:s,hidden:!0,type:"file",multiple:!1,onChange:e=>{e.target.files&&v(e.target.files)}}),a||i?t.jsx("div",{id:`${l}-exist`,className:`${n.default["image-content"]} ${c}`,onDrop:C,onDragOver:e=>e.preventDefault(),onDragLeave:e=>e.preventDefault(),children:t.jsx("img",{src:a||i,alt:"upload-image",className:`${n.default.image} ${c}`})}):t.jsxs("div",{id:l,className:`${n.default["image-content"]} ${c}`,onDrop:C,onDragOver:e=>e.preventDefault(),onDragLeave:e=>e.preventDefault(),children:[D,t.jsx("div",{className:n.default["text-desc"],children:typeof o=="function"?o():o})]}),t.jsxs("div",{className:n.default["action-content"],children:[t.jsxs("div",{className:`${n.default["button-content"]} ${w}`,children:[(a||i)&&t.jsx($.default,{id:`${l}-delete-img`,variants:"tertiary-red-600",size:"xs",startIcon:t.jsx(R,{}),onClick:e=>M(e),children:"Hapus"}),t.jsxs($.default,{id:`${l}-change-img`,variants:"tertiary-blue-700",size:"xs",onClick:()=>s.current?.click(),startIcon:t.jsx(N,{}),children:[a||i?"Ganti":"Pilih"," Gambar"]})]}),t.jsx("p",{className:n.default["text-desc"],children:k}),j&&t.jsx("p",{className:n.default["text-error"],children:j})]})]})};exports.default=y;
@@ -1,13 +1,13 @@
1
1
  import { jsxs as l, jsx as t } from "react/jsx-runtime";
2
2
  import g from "react";
3
3
  import L from "../Button/Button.mjs";
4
- import n from "./UploadImage.module.scss.mjs";
5
- const b = ({ className: r }) => /* @__PURE__ */ t(
4
+ import r from "./UploadImage.module.scss.mjs";
5
+ const b = ({ className: n }) => /* @__PURE__ */ t(
6
6
  "svg",
7
7
  {
8
8
  viewBox: "0 0 20 20",
9
9
  xmlns: "http://www.w3.org/2000/svg",
10
- className: `iru-h-5 iru-w-5 iru-text-red-600 ${r ?? ""}`,
10
+ className: `iru-h-5 iru-w-5 iru-text-red-600 ${n ?? ""}`,
11
11
  fill: "currentColor",
12
12
  children: /* @__PURE__ */ t("g", { id: "x", children: /* @__PURE__ */ t(
13
13
  "path",
@@ -15,32 +15,32 @@ const b = ({ className: r }) => /* @__PURE__ */ t(
15
15
  id: "Vector",
16
16
  fillRule: "evenodd",
17
17
  clipRule: "evenodd",
18
- d: `M6.19544 6.19126C6.32045 6.06628 6.48999 5.99607 6.66677 5.99607C6.84354 5.99607 7.01308 6.06628 7.1381
19
- 6.19126L10.0001 9.05326L12.8621 6.19126C12.9236 6.12758 12.9972 6.0768 13.0785 6.04186C13.1598 6.00692 13.2473
20
- 5.98853 13.3358 5.98776C13.4244 5.98699 13.5121 6.00386 13.5941 6.03738C13.676 6.0709 13.7504 6.1204 13.813
21
- 6.18299C13.8756 6.24559 13.9251 6.32002 13.9587 6.40195C13.9922 6.48389 14.009 6.57167 14.0083 6.66019C14.0075
22
- 6.74871 13.9891 6.83619 13.9542 6.91753C13.9192 6.99886 13.8684 7.07243 13.8048 7.13392L10.9428 9.99592L13.8048
23
- 12.8579C13.9262 12.9837 13.9934 13.1521 13.9919 13.3269C13.9904 13.5017 13.9203 13.6689 13.7966 13.7925C13.673
24
- 13.9161 13.5058 13.9862 13.331 13.9877C13.1562 13.9892 12.9878 13.922 12.8621 13.8006L10.0001 10.9386L7.1381
25
- 13.8006C7.01237 13.922 6.84397 13.9892 6.66917 13.9877C6.49437 13.9862 6.32716 13.9161 6.20356 13.7925C6.07995
26
- 13.6689 6.00984 13.5017 6.00832 13.3269C6.0068 13.1521 6.074 12.9837 6.19544 12.8579L9.05744 9.99592L6.19544
18
+ d: `M6.19544 6.19126C6.32045 6.06628 6.48999 5.99607 6.66677 5.99607C6.84354 5.99607 7.01308 6.06628 7.1381 \r
19
+ 6.19126L10.0001 9.05326L12.8621 6.19126C12.9236 6.12758 12.9972 6.0768 13.0785 6.04186C13.1598 6.00692 13.2473 \r
20
+ 5.98853 13.3358 5.98776C13.4244 5.98699 13.5121 6.00386 13.5941 6.03738C13.676 6.0709 13.7504 6.1204 13.813 \r
21
+ 6.18299C13.8756 6.24559 13.9251 6.32002 13.9587 6.40195C13.9922 6.48389 14.009 6.57167 14.0083 6.66019C14.0075 \r
22
+ 6.74871 13.9891 6.83619 13.9542 6.91753C13.9192 6.99886 13.8684 7.07243 13.8048 7.13392L10.9428 9.99592L13.8048 \r
23
+ 12.8579C13.9262 12.9837 13.9934 13.1521 13.9919 13.3269C13.9904 13.5017 13.9203 13.6689 13.7966 13.7925C13.673 \r
24
+ 13.9161 13.5058 13.9862 13.331 13.9877C13.1562 13.9892 12.9878 13.922 12.8621 13.8006L10.0001 10.9386L7.1381 \r
25
+ 13.8006C7.01237 13.922 6.84397 13.9892 6.66917 13.9877C6.49437 13.9862 6.32716 13.9161 6.20356 13.7925C6.07995 \r
26
+ 13.6689 6.00984 13.5017 6.00832 13.3269C6.0068 13.1521 6.074 12.9837 6.19544 12.8579L9.05744 9.99592L6.19544 \r
27
27
  7.13392C6.07045 7.00891 6.00024 6.83937 6.00024 6.66259C6.00024 6.48581 6.07045 6.31628 6.19544 6.19126Z`
28
28
  }
29
29
  ) })
30
30
  }
31
- ), y = ({ className: r }) => /* @__PURE__ */ t(
31
+ ), y = ({ className: n }) => /* @__PURE__ */ t(
32
32
  "svg",
33
33
  {
34
34
  viewBox: "0 0 20 20",
35
35
  fill: "none",
36
36
  xmlns: "http://www.w3.org/2000/svg",
37
- className: `iru-h-5 iru-w-5 ${r ?? ""}`,
37
+ className: `iru-h-5 iru-w-5 ${n ?? ""}`,
38
38
  children: /* @__PURE__ */ t("g", { id: "upload", children: /* @__PURE__ */ t(
39
39
  "path",
40
40
  {
41
41
  id: "Vector",
42
- d: `M3.83337 13.3333V14.1666C3.83337 14.8297 4.09677 15.4656 4.56561 15.9344C5.03445 16.4033 5.67033
43
- 16.6666 6.33337 16.6666H14.6667C15.3297 16.6666 15.9656 16.4033 16.4345 15.9344C16.9033 15.4656 17.1667
42
+ d: `M3.83337 13.3333V14.1666C3.83337 14.8297 4.09677 15.4656 4.56561 15.9344C5.03445 16.4033 5.67033 \r
43
+ 16.6666 6.33337 16.6666H14.6667C15.3297 16.6666 15.9656 16.4033 16.4345 15.9344C16.9033 15.4656 17.1667 \r
44
44
  14.8297 17.1667 14.1666V13.3333M13.8334 6.66665L10.5 3.33331M10.5 3.33331L7.16671 6.66665M10.5 3.33331V13.3333`,
45
45
  stroke: "#1976D2",
46
46
  strokeWidth: "1.5",
@@ -50,7 +50,7 @@ const b = ({ className: r }) => /* @__PURE__ */ t(
50
50
  ) })
51
51
  }
52
52
  ), z = ({
53
- onChange: r,
53
+ onChange: n,
54
54
  valueUrl: a,
55
55
  validateFile: m,
56
56
  validateFileDesc: x = "Max 2MB (.jpg, .jpeg, .png, .svg)",
@@ -72,15 +72,15 @@ const b = ({ className: r }) => /* @__PURE__ */ t(
72
72
  u(f);
73
73
  } else {
74
74
  if (!i?.current) return;
75
- u(""), r(p), v(URL.createObjectURL(p)), i.current.value = "";
75
+ u(""), n(p), v(URL.createObjectURL(p)), i.current.value = "";
76
76
  }
77
77
  }
78
78
  }, D = (e) => {
79
79
  e.preventDefault(), k(e.dataTransfer.files);
80
80
  }, N = (e) => {
81
- e.preventDefault(), i?.current && (typeof r == "function" && r(null), v(""), i.current.value = "");
81
+ e.preventDefault(), i?.current && (typeof n == "function" && n(null), v(""), i.current.value = "");
82
82
  };
83
- return /* @__PURE__ */ l("div", { className: `${n.container} ${M}`, children: [
83
+ return /* @__PURE__ */ l("div", { className: `${r.container} ${M}`, children: [
84
84
  /* @__PURE__ */ t(
85
85
  "input",
86
86
  {
@@ -98,28 +98,28 @@ const b = ({ className: r }) => /* @__PURE__ */ t(
98
98
  "div",
99
99
  {
100
100
  id: `${s}-exist`,
101
- className: `${n["image-content"]} ${d}`,
101
+ className: `${r["image-content"]} ${d}`,
102
102
  onDrop: D,
103
103
  onDragOver: (e) => e.preventDefault(),
104
104
  onDragLeave: (e) => e.preventDefault(),
105
- children: /* @__PURE__ */ t("img", { src: o || a, alt: "upload-image", className: `${n.image} ${d}` })
105
+ children: /* @__PURE__ */ t("img", { src: o || a, alt: "upload-image", className: `${r.image} ${d}` })
106
106
  }
107
107
  ) : /* @__PURE__ */ l(
108
108
  "div",
109
109
  {
110
110
  id: s,
111
- className: `${n["image-content"]} ${d}`,
111
+ className: `${r["image-content"]} ${d}`,
112
112
  onDrop: D,
113
113
  onDragOver: (e) => e.preventDefault(),
114
114
  onDragLeave: (e) => e.preventDefault(),
115
115
  children: [
116
116
  w,
117
- /* @__PURE__ */ t("div", { className: n["text-desc"], children: typeof c == "function" ? c() : c })
117
+ /* @__PURE__ */ t("div", { className: r["text-desc"], children: typeof c == "function" ? c() : c })
118
118
  ]
119
119
  }
120
120
  ),
121
- /* @__PURE__ */ l("div", { className: n["action-content"], children: [
122
- /* @__PURE__ */ l("div", { className: `${n["button-content"]} ${j}`, children: [
121
+ /* @__PURE__ */ l("div", { className: r["action-content"], children: [
122
+ /* @__PURE__ */ l("div", { className: `${r["button-content"]} ${j}`, children: [
123
123
  (o || a) && /* @__PURE__ */ t(
124
124
  L,
125
125
  {
@@ -146,8 +146,8 @@ const b = ({ className: r }) => /* @__PURE__ */ t(
146
146
  }
147
147
  )
148
148
  ] }),
149
- /* @__PURE__ */ t("p", { className: n["text-desc"], children: x }),
150
- $ && /* @__PURE__ */ t("p", { className: n["text-error"], children: $ })
149
+ /* @__PURE__ */ t("p", { className: r["text-desc"], children: x }),
150
+ $ && /* @__PURE__ */ t("p", { className: r["text-error"], children: $ })
151
151
  ] })
152
152
  ] });
153
153
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="2.0.22",o={version:e};exports.default=o;exports.version=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e="2.0.24",o={version:e};exports.default=o;exports.version=e;