1mpacto-react-ui 2.0.20 → 2.0.21
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/assets/style.css +1 -1
- package/dist/components/Alert/index.cjs +1 -1
- package/dist/components/Alert/index.mjs +40 -40
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +3 -3
- package/dist/components/Breadcrumbs/Breadcrumbs.mjs +43 -43
- package/dist/components/ButtonPopover/ButtonPopover.cjs +1 -1
- package/dist/components/ButtonPopover/ButtonPopover.mjs +28 -31
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.mjs +98 -100
- package/dist/components/Calendar/CalendarMonth.cjs +1 -1
- package/dist/components/Calendar/CalendarMonth.mjs +41 -42
- package/dist/components/Calendar/CalendarRange.cjs +1 -1
- package/dist/components/Calendar/CalendarRange.mjs +59 -61
- package/dist/components/Calendar/CalendarYear.cjs +2 -2
- package/dist/components/Calendar/CalendarYear.mjs +37 -38
- package/dist/components/Chart/DoughnutChart.cjs +1 -1
- package/dist/components/Chart/DoughnutChart.mjs +93 -96
- package/dist/components/Chart/GradientBarChart.cjs +1 -1
- package/dist/components/Chart/GradientBarChart.mjs +80 -81
- package/dist/components/Chart/GradientLineChart.cjs +1 -1
- package/dist/components/Chart/GradientLineChart.mjs +50 -51
- package/dist/components/Chart/LineChart.cjs +1 -1
- package/dist/components/Chart/LineChart.mjs +23 -23
- package/dist/components/Chart/PieChart.cjs +1 -1
- package/dist/components/Chart/PieChart.mjs +45 -48
- package/dist/components/Collapse/Collapse.cjs +1 -1
- package/dist/components/Collapse/Collapse.mjs +23 -24
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.mjs +86 -89
- package/dist/components/DatePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DatePicker/DateRangePicker.mjs +91 -92
- package/dist/components/DatePicker/FilterDate.cjs +1 -1
- package/dist/components/DatePicker/FilterDate.mjs +107 -110
- package/dist/components/DatePicker/MonthYearPicker.cjs +1 -1
- package/dist/components/DatePicker/MonthYearPicker.mjs +51 -53
- package/dist/components/FilterContainer/FilterContainer.cjs +1 -1
- package/dist/components/FilterContainer/FilterContainer.mjs +27 -27
- package/dist/components/Input/InputFloatingInner.cjs +5 -5
- package/dist/components/Input/InputFloatingInner.mjs +24 -25
- package/dist/components/NumberFormat/NumberFormat.cjs +1 -1
- package/dist/components/NumberFormat/NumberFormat.mjs +12 -13
- package/dist/components/Pagination/Pagination.cjs +2 -2
- package/dist/components/Pagination/Pagination.mjs +76 -80
- package/dist/components/SelectDropdownContainer/SelectDropdownContainer.cjs +1 -1
- package/dist/components/SelectDropdownContainer/SelectDropdownContainer.mjs +98 -102
- package/dist/components/Sidebar/ItemSidebar.cjs +8 -8
- package/dist/components/Sidebar/ItemSidebar.mjs +71 -72
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.mjs +65 -68
- package/dist/components/Step/Step.cjs +5 -5
- package/dist/components/Step/Step.mjs +52 -52
- package/dist/components/Table/Table.cjs +3 -3
- package/dist/components/Table/Table.mjs +275 -298
- package/dist/components/Table/TableSubMobile.cjs +1 -1
- package/dist/components/Table/TableSubMobile.mjs +32 -35
- package/dist/components/Tabs/Tabs.cjs +8 -8
- package/dist/components/Tabs/Tabs.mjs +66 -70
- package/dist/components/Textarea/Textarea.cjs +7 -7
- package/dist/components/Textarea/Textarea.mjs +47 -50
- package/dist/components/Textarea/TextareaFloatingInner.cjs +6 -6
- package/dist/components/Textarea/TextareaFloatingInner.mjs +56 -61
- package/dist/components/Textarea/TextareaInnerLabel.cjs +6 -6
- package/dist/components/Textarea/TextareaInnerLabel.mjs +47 -50
- package/dist/components/TimeRange/TimeRange.cjs +1 -1
- package/dist/components/TimeRange/TimeRange.mjs +88 -91
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.mjs +44 -46
- package/dist/components/Upload/UploadFile.cjs +1 -1
- package/dist/components/Upload/UploadFile.mjs +50 -54
- package/dist/components/Upload/UploadImage.cjs +3 -3
- package/dist/components/Upload/UploadImage.mjs +62 -68
- package/dist/components/Upload/UploadMultipleFile.cjs +1 -1
- package/dist/components/Upload/UploadMultipleFile.mjs +61 -62
- package/dist/components/Virtualization/ListVirtualization.cjs +1 -1
- package/dist/components/Virtualization/ListVirtualization.mjs +52 -55
- package/dist/components/Virtualization/TableVirtualization.cjs +1 -1
- package/dist/components/Virtualization/TableVirtualization.mjs +56 -59
- package/dist/config/components/tinymce.cjs +2 -2
- package/dist/config/components/tinymce.mjs +3 -3
- package/dist/hooks/useCountdown.cjs +1 -1
- package/dist/hooks/useCountdown.mjs +15 -15
- package/dist/hooks/useDebounce.cjs +1 -1
- package/dist/hooks/useDebounce.mjs +19 -19
- package/dist/hooks/useOtpInput.cjs +1 -1
- package/dist/hooks/useOtpInput.mjs +47 -51
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.d.ts +5 -4
- package/dist/package.json.mjs +1 -1
- package/dist/utils/common.cjs +1 -1
- package/dist/utils/common.mjs +172 -173
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const B=require("react/jsx-runtime"),h=require("chart.js"),v=require("react"),m=require("react-chartjs-2"),D=require("../../utils/common.cjs"),j=require("../PortalComponent/PortalComponent.cjs");h.Chart.register(h.CategoryScale,h.LinearScale,h.BarElement,h.Tooltip,h.PointElement,h.Filler,h.Tooltip);const w=a=>({chart:r,tooltip:n})=>{const s={};if(n.opacity===0){a(y=>({...y,style:{...y.style,opacity:0,pointerEvents:"none"}}));return}if(!n.dataPoints||n.dataPoints.length===0)return;s.opacity="1",s.position="absolute",s.pointerEvents="none";const i=r.canvas.getBoundingClientRect();s.left=i.left+window.pageXOffset+n.caretX+"px",s.top=i.top+window.pageYOffset+n.caretY+"px";const d=n.dataPoints?.[0]?.label??"",o=n.dataPoints?.[0]?.raw??"",l=n.dataPoints?.[0]?.dataset.label??"";a({dataset:l,label:d,value:o,style:s,dataPoints:n.dataPoints})},E={id:"labelplugin",afterDatasetsDraw(a){const{ctx:r,chartArea:{top:n,bottom:s}}=a;r.save(),a.data.datasets.forEach((i,d)=>{const o=a.getDatasetMeta(d);o.visible&&o.data.forEach((l,y)=>{const C=i.data[y]||0,S=i?.setDigit?D.setDigit(String(C)):String(C);r.font="12px Lato",r.textAlign="center";let f,P=!1;typeof C=="number"&&C>=0?(r.textBaseline="bottom",r.fillStyle=i?.colorTextLabelPositive||l.options.borderColor,f=l.y-5,f>n&&(P=!0)):(r.textBaseline="top",r.fillStyle=i?.colorTextLabelNegative||l.options.borderColor,f=l.y+5,f<s&&(P=!0)),P&&r.fillText(S,l.x,f)})}),r.restore()}},F={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1}},scales:{y:{grace:"15%",position:"left",border:{display:!1,dash:[5,3],color:"#CFD8DC"},ticks:{callback:function(a){return D.setDigit(a)??0},font:{size:10,weight:"normal"},padding:10,color:"#898989"}},x:{grid:{display:!1},border:{dash:[5,3],color:"#CFD8DC"},ticks:{font:{size:10,weight:"normal"},color:"#898989"}}},interaction:{mode:"index",intersect:!1}},O=({data:a,classNameContainer:r,height:n,id:s,options:i,CustomTooltip:d})=>{const o=v.useRef(void 0),l=v.useRef(0),y=v.useRef(0),[C,S]=v.useState({dataset:"",label:"",value:0,style:{opacity:0,position:"absolute",left:0,bottom:0},dataPoints:[]}),f=v.useCallback(function({ctx:x,chartArea:t,scales:c,chartHeight:u,gradientFor:p,item:e}){let b=(c.y.getPixelForValue(0)-t.top)/u;b=b<0?0:b>1?1:b,o.current=x.createLinearGradient(0,t.top,0,u+t.top),p==="background"?(o.current.addColorStop(0,e?.colorBackgroundPositiveZero||"#9FD2FF"),o.current.addColorStop(b,e?.colorBackgroundPositivePercentage||"rgba(115, 235, 163, 0.1)"),o.current.addColorStop(b,e?.colorBackgroundNegativePercentage||"rgba(235, 107, 107, 0.1)"),o.current.addColorStop(1,e?.colorBackgroundNegativeOne||"#EB6B6B")):(o.current.addColorStop(b,e?.colorBorderPositive||"#80CBC4"),o.current.addColorStop(b,e?.colorBorderNegative||"#EB6B6B"))},[]),P=v.useCallback(function({ctx:x,chartArea:t,scales:c,gradientFor:u,item:p}){const e=t.right-t.left,g=t.bottom-t.top;return(!o.current||l.current!==e||y.current!==g)&&(l.current=e,y.current=g,f({ctx:x,chartArea:t,scales:c,chartHeight:g,gradientFor:u,item:p})),f({ctx:x,chartArea:t,scales:c,chartHeight:g,gradientFor:u,item:p}),o.current},[]),k=v.useMemo(()=>({...a,datasets:a.datasets.map(t=>({fill:!0,backgroundColor:function(c){const u=c.chart,{ctx:p,chartArea:e,scales:g}=u;if(e)return P({ctx:p,chartArea:e,scales:g,gradientFor:"background",item:t})},borderColor:function(c){const u=c.chart,{ctx:p,chartArea:e,scales:g}=u;if(e)return P({ctx:p,chartArea:e,scales:g,gradientFor:"border",item:t})},borderWidth:0,tension:0,pointRadius:0,pointHoverRadius:4,setDigit:!0,...t,data:t.data}))}),[a]),R=v.useMemo(()=>{const x={plugins:{tooltip:{enabled:!d,external:({chart:t,tooltip:c})=>d?w(S)({chart:t,tooltip:c}):void 0}}};return D.mergeObjects(F,x,i??{})},[i,d]);return B.jsxs("div",{id:s,className:r,style:{height:n||"300px"},children:[d&&B.jsx(j.default,{selector:"body",children:B.jsx(d,{...C})}),B.jsx(m.Bar,{data:k,options:R,plugins:[E]})]})};exports.default=O;
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Chart as
|
|
3
|
-
import
|
|
4
|
-
import { Bar as
|
|
5
|
-
import { mergeObjects as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
s((S) => ({ ...S, style: { ...S.style, opacity: 0, pointerEvents: "none" } }));
|
|
1
|
+
import { jsxs as R, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { Chart as w, CategoryScale as E, LinearScale as F, BarElement as O, Tooltip as B, PointElement as L, Filler as Z } from "chart.js";
|
|
3
|
+
import y from "react";
|
|
4
|
+
import { Bar as N } from "react-chartjs-2";
|
|
5
|
+
import { mergeObjects as G, setDigit as S } from "../../utils/common.mjs";
|
|
6
|
+
import j from "../PortalComponent/PortalComponent.mjs";
|
|
7
|
+
w.register(E, F, O, B, L, Z, B);
|
|
8
|
+
const H = (a) => ({ chart: r, tooltip: n }) => {
|
|
9
|
+
const s = {};
|
|
10
|
+
if (n.opacity === 0) {
|
|
11
|
+
a((h) => ({ ...h, style: { ...h.style, opacity: 0, pointerEvents: "none" } }));
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
if (!
|
|
14
|
+
if (!n.dataPoints || n.dataPoints.length === 0)
|
|
16
15
|
return;
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
dataset:
|
|
23
|
-
label:
|
|
24
|
-
value:
|
|
25
|
-
style:
|
|
26
|
-
dataPoints:
|
|
16
|
+
s.opacity = "1", s.position = "absolute", s.pointerEvents = "none";
|
|
17
|
+
const i = r.canvas.getBoundingClientRect();
|
|
18
|
+
s.left = i.left + window.pageXOffset + n.caretX + "px", s.top = i.top + window.pageYOffset + n.caretY + "px";
|
|
19
|
+
const d = n.dataPoints?.[0]?.label ?? "", o = n.dataPoints?.[0]?.raw ?? "", l = n.dataPoints?.[0]?.dataset.label ?? "";
|
|
20
|
+
a({
|
|
21
|
+
dataset: l,
|
|
22
|
+
label: d,
|
|
23
|
+
value: o,
|
|
24
|
+
style: s,
|
|
25
|
+
dataPoints: n.dataPoints
|
|
27
26
|
});
|
|
28
|
-
},
|
|
27
|
+
}, M = {
|
|
29
28
|
id: "labelplugin",
|
|
30
|
-
afterDatasetsDraw(
|
|
29
|
+
afterDatasetsDraw(a) {
|
|
31
30
|
const {
|
|
32
|
-
ctx:
|
|
33
|
-
chartArea: { top:
|
|
34
|
-
} =
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
typeof
|
|
31
|
+
ctx: r,
|
|
32
|
+
chartArea: { top: n, bottom: s }
|
|
33
|
+
} = a;
|
|
34
|
+
r.save(), a.data.datasets.forEach((i, d) => {
|
|
35
|
+
const o = a.getDatasetMeta(d);
|
|
36
|
+
o.visible && o.data.forEach((l, h) => {
|
|
37
|
+
const v = i.data[h] || 0, P = i?.setDigit ? S(String(v)) : String(v);
|
|
38
|
+
r.font = "12px Lato", r.textAlign = "center";
|
|
39
|
+
let p, C = !1;
|
|
40
|
+
typeof v == "number" && v >= 0 ? (r.textBaseline = "bottom", r.fillStyle = i?.colorTextLabelPositive || l.options.borderColor, p = l.y - 5, p > n && (C = !0)) : (r.textBaseline = "top", r.fillStyle = i?.colorTextLabelNegative || l.options.borderColor, p = l.y + 5, p < s && (C = !0)), C && r.fillText(P, l.x, p);
|
|
42
41
|
});
|
|
43
|
-
}),
|
|
42
|
+
}), r.restore();
|
|
44
43
|
}
|
|
45
|
-
},
|
|
44
|
+
}, z = {
|
|
46
45
|
responsive: !0,
|
|
47
46
|
maintainAspectRatio: !1,
|
|
48
47
|
plugins: {
|
|
@@ -56,8 +55,8 @@ const M = (s) => ({ chart: n, tooltip: a }) => {
|
|
|
56
55
|
position: "left",
|
|
57
56
|
border: { display: !1, dash: [5, 3], color: "#CFD8DC" },
|
|
58
57
|
ticks: {
|
|
59
|
-
callback: function(
|
|
60
|
-
return
|
|
58
|
+
callback: function(a) {
|
|
59
|
+
return S(a) ?? 0;
|
|
61
60
|
},
|
|
62
61
|
font: {
|
|
63
62
|
size: 10,
|
|
@@ -85,51 +84,51 @@ const M = (s) => ({ chart: n, tooltip: a }) => {
|
|
|
85
84
|
mode: "index",
|
|
86
85
|
intersect: !1
|
|
87
86
|
}
|
|
88
|
-
},
|
|
89
|
-
const
|
|
87
|
+
}, J = ({ data: a, classNameContainer: r, height: n, id: s, options: i, CustomTooltip: d }) => {
|
|
88
|
+
const o = y.useRef(void 0), l = y.useRef(0), h = y.useRef(0), [v, P] = y.useState({
|
|
90
89
|
dataset: "",
|
|
91
90
|
label: "",
|
|
92
91
|
value: 0,
|
|
93
92
|
style: { opacity: 0, position: "absolute", left: 0, bottom: 0 },
|
|
94
93
|
dataPoints: []
|
|
95
|
-
}),
|
|
96
|
-
ctx:
|
|
94
|
+
}), p = y.useCallback(function({
|
|
95
|
+
ctx: x,
|
|
97
96
|
chartArea: t,
|
|
98
|
-
scales:
|
|
99
|
-
chartHeight:
|
|
100
|
-
gradientFor:
|
|
101
|
-
item:
|
|
97
|
+
scales: c,
|
|
98
|
+
chartHeight: u,
|
|
99
|
+
gradientFor: g,
|
|
100
|
+
item: e
|
|
102
101
|
}) {
|
|
103
|
-
let
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
),
|
|
111
|
-
}, []),
|
|
112
|
-
ctx:
|
|
102
|
+
let b = (c.y.getPixelForValue(0) - t.top) / u;
|
|
103
|
+
b = b < 0 ? 0 : b > 1 ? 1 : b, o.current = x.createLinearGradient(0, t.top, 0, u + t.top), g === "background" ? (o.current.addColorStop(0, e?.colorBackgroundPositiveZero || "#9FD2FF"), o.current.addColorStop(
|
|
104
|
+
b,
|
|
105
|
+
e?.colorBackgroundPositivePercentage || "rgba(115, 235, 163, 0.1)"
|
|
106
|
+
), o.current.addColorStop(
|
|
107
|
+
b,
|
|
108
|
+
e?.colorBackgroundNegativePercentage || "rgba(235, 107, 107, 0.1)"
|
|
109
|
+
), o.current.addColorStop(1, e?.colorBackgroundNegativeOne || "#EB6B6B")) : (o.current.addColorStop(b, e?.colorBorderPositive || "#80CBC4"), o.current.addColorStop(b, e?.colorBorderNegative || "#EB6B6B"));
|
|
110
|
+
}, []), C = y.useCallback(function({
|
|
111
|
+
ctx: x,
|
|
113
112
|
chartArea: t,
|
|
114
|
-
scales:
|
|
115
|
-
gradientFor:
|
|
116
|
-
item:
|
|
113
|
+
scales: c,
|
|
114
|
+
gradientFor: u,
|
|
115
|
+
item: g
|
|
117
116
|
}) {
|
|
118
|
-
const
|
|
119
|
-
return (!
|
|
120
|
-
}, []),
|
|
121
|
-
...
|
|
122
|
-
datasets:
|
|
117
|
+
const e = t.right - t.left, f = t.bottom - t.top;
|
|
118
|
+
return (!o.current || l.current !== e || h.current !== f) && (l.current = e, h.current = f, p({ ctx: x, chartArea: t, scales: c, chartHeight: f, gradientFor: u, item: g })), p({ ctx: x, chartArea: t, scales: c, chartHeight: f, gradientFor: u, item: g }), o.current;
|
|
119
|
+
}, []), k = y.useMemo(() => ({
|
|
120
|
+
...a,
|
|
121
|
+
datasets: a.datasets.map((t) => ({
|
|
123
122
|
fill: !0,
|
|
124
|
-
backgroundColor: function(
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
return
|
|
123
|
+
backgroundColor: function(c) {
|
|
124
|
+
const u = c.chart, { ctx: g, chartArea: e, scales: f } = u;
|
|
125
|
+
if (e)
|
|
126
|
+
return C({ ctx: g, chartArea: e, scales: f, gradientFor: "background", item: t });
|
|
128
127
|
},
|
|
129
|
-
borderColor: function(
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
return
|
|
128
|
+
borderColor: function(c) {
|
|
129
|
+
const u = c.chart, { ctx: g, chartArea: e, scales: f } = u;
|
|
130
|
+
if (e)
|
|
131
|
+
return C({ ctx: g, chartArea: e, scales: f, gradientFor: "border", item: t });
|
|
133
132
|
},
|
|
134
133
|
borderWidth: 0,
|
|
135
134
|
tension: 0,
|
|
@@ -139,19 +138,19 @@ const M = (s) => ({ chart: n, tooltip: a }) => {
|
|
|
139
138
|
...t,
|
|
140
139
|
data: t.data
|
|
141
140
|
}))
|
|
142
|
-
}), [
|
|
141
|
+
}), [a]), D = y.useMemo(() => G(z, {
|
|
143
142
|
plugins: {
|
|
144
143
|
tooltip: {
|
|
145
|
-
enabled: !
|
|
146
|
-
external: ({ chart: t, tooltip:
|
|
144
|
+
enabled: !d,
|
|
145
|
+
external: ({ chart: t, tooltip: c }) => d ? H(P)({ chart: t, tooltip: c }) : void 0
|
|
147
146
|
}
|
|
148
147
|
}
|
|
149
|
-
},
|
|
150
|
-
return /* @__PURE__ */
|
|
151
|
-
|
|
152
|
-
/* @__PURE__ */
|
|
148
|
+
}, i ?? {}), [i, d]);
|
|
149
|
+
return /* @__PURE__ */ R("div", { id: s, className: r, style: { height: n || "300px" }, children: [
|
|
150
|
+
d && /* @__PURE__ */ m(j, { selector: "body", children: /* @__PURE__ */ m(d, { ...v }) }),
|
|
151
|
+
/* @__PURE__ */ m(N, { data: k, options: D, plugins: [M] })
|
|
153
152
|
] });
|
|
154
153
|
};
|
|
155
154
|
export {
|
|
156
|
-
|
|
155
|
+
J as default
|
|
157
156
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=require("react/jsx-runtime"),P=require("chart.js"),p=require("react"),m=require("react-chartjs-2"),j=require("../../utils/common.cjs"),w=require("../PortalComponent/PortalComponent.cjs");P.Chart.register(P.CategoryScale,P.LinearScale,P.PointElement,P.LineElement,P.Filler,P.Tooltip);const D=r=>({chart:u,tooltip:e})=>{const s={};if(e.opacity===0){r(v=>({...v,style:{...v.style,opacity:0,pointerEvents:"none"}}));return}if(!e.dataPoints||e.dataPoints.length===0)return;s.opacity="1",s.position="absolute",s.pointerEvents="none";const b=u.canvas.getBoundingClientRect();s.left=b.left+window.pageXOffset+e.caretX+"px",s.top=b.top+window.pageYOffset+e.caretY+"px";const i=e.dataPoints?.[0]?.label??"",n=e.dataPoints?.[0]?.raw??"",c=e.dataPoints?.[0]?.dataset.label??"";r({dataset:c,label:i,value:n,style:s,dataPoints:e.dataPoints})},F={id:"hairlinePlugin",beforeDatasetsDraw:r=>{const u=r.scales.y;if(!u)return;const{ctx:e}=r,{top:s,bottom:b,left:i,right:n}=r.chartArea;if(u.min>0||u.max<0)return;const c=u.getPixelForValue(0);c<s||c>b||(e.save(),e.beginPath(),e.moveTo(i,c),e.lineTo(n,c),e.lineWidth=2,e.strokeStyle="rgb(207, 216, 220)",e.setLineDash([4,3]),e.stroke(),e.restore())}},O={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1}},scales:{y:{grace:"15%",position:"right",border:{display:!1,dash:[5,3],color:"#CFD8DC"},ticks:{font:{size:10,weight:"normal"},padding:10,color:"#898989"}},x:{border:{dash:[5,3],color:"#CFD8DC"},ticks:{font:{size:10,weight:"normal"},color:"#898989"}}},interaction:{mode:"index",intersect:!1}},q=({data:r,height:u,classNameContainer:e,id:s,options:b,CustomTooltip:i})=>{const n=p.useRef(void 0),c=p.useRef(0),v=p.useRef(0),[B,S]=p.useState({dataset:"",label:"",value:0,style:{opacity:0,position:"absolute",left:0,bottom:0},dataPoints:[]}),C=p.useCallback(function({ctx:h,chartArea:t,scales:a,chartHeight:l,gradientFor:g,item:o}){let f=(a.y.getPixelForValue(0)-t.top)/l;f=f<0?0:f>1?1:f,n.current=h.createLinearGradient(0,t.top,0,l+t.top),g==="background"?(n.current.addColorStop(0,o?.colorBackgroundPositiveZero||"#9FD2FF"),n.current.addColorStop(f,o?.colorBackgroundPositivePercentage||"rgba(115, 235, 163, 0.1)"),n.current.addColorStop(f,o?.colorBackgroundNegativePercentage||"rgba(235, 107, 107, 0.1)"),n.current.addColorStop(1,o?.colorBackgroundNegativeOne||"#EB6B6B")):(n.current.addColorStop(f,o?.colorBorderPositive||"#80CBC4"),n.current.addColorStop(f,o?.colorBorderNegative||"#EB6B6B"))},[]),x=p.useCallback(function({ctx:h,chartArea:t,scales:a,gradientFor:l,item:g}){const o=t.right-t.left,d=t.bottom-t.top;return(!n.current||c.current!==o||v.current!==d)&&(c.current=o,v.current=d,C({ctx:h,chartArea:t,scales:a,chartHeight:d,gradientFor:l,item:g})),C({ctx:h,chartArea:t,scales:a,chartHeight:d,gradientFor:l,item:g}),n.current},[]),k=p.useMemo(()=>({...r,datasets:r.datasets.map(t=>({fill:!0,backgroundColor:function(a){const l=a.chart,{ctx:g,chartArea:o,scales:d}=l;if(o)return x({ctx:g,chartArea:o,scales:d,gradientFor:"background",item:t})},borderColor:function(a){const l=a.chart,{ctx:g,chartArea:o,scales:d}=l;if(o)return x({ctx:g,chartArea:o,scales:d,gradientFor:"border",item:t})},borderWidth:3,tension:0,pointRadius:0,pointHoverRadius:4,...t,data:t.data}))}),[r]),R=p.useMemo(()=>{const h={plugins:{tooltip:{enabled:!i,external:({chart:t,tooltip:a})=>i?D(S)({chart:t,tooltip:a}):void 0}}};return j.mergeObjects(O,h,b??{})},[b,i]);return y.jsxs("div",{id:s,className:e,style:{height:u||"300px"},children:[i&&y.jsx(w.default,{selector:"body",children:y.jsx(i,{...B})}),y.jsx(m.Line,{data:k,options:R,plugins:[F]})]})};exports.default=q;
|
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Chart as
|
|
1
|
+
import { jsxs as S, jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import { Chart as R, CategoryScale as w, LinearScale as D, PointElement as F, LineElement as O, Filler as E, Tooltip as L } from "chart.js";
|
|
3
3
|
import f from "react";
|
|
4
|
-
import { Line as
|
|
5
|
-
import { mergeObjects as
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
var P, C, x, y, v, B;
|
|
4
|
+
import { Line as Z } from "react-chartjs-2";
|
|
5
|
+
import { mergeObjects as G } from "../../utils/common.mjs";
|
|
6
|
+
import N from "../PortalComponent/PortalComponent.mjs";
|
|
7
|
+
R.register(w, D, F, O, E, L);
|
|
8
|
+
const j = (r) => ({ chart: u, tooltip: t }) => {
|
|
10
9
|
const a = {};
|
|
11
|
-
if (
|
|
12
|
-
r((
|
|
10
|
+
if (t.opacity === 0) {
|
|
11
|
+
r((P) => ({ ...P, style: { ...P.style, opacity: 0, pointerEvents: "none" } }));
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
if (!
|
|
14
|
+
if (!t.dataPoints || t.dataPoints.length === 0)
|
|
16
15
|
return;
|
|
17
16
|
a.opacity = "1", a.position = "absolute", a.pointerEvents = "none";
|
|
18
17
|
const b = u.canvas.getBoundingClientRect();
|
|
19
|
-
a.left = b.left + window.pageXOffset +
|
|
20
|
-
const
|
|
18
|
+
a.left = b.left + window.pageXOffset + t.caretX + "px", a.top = b.top + window.pageYOffset + t.caretY + "px";
|
|
19
|
+
const i = t.dataPoints?.[0]?.label ?? "", n = t.dataPoints?.[0]?.raw ?? "", c = t.dataPoints?.[0]?.dataset.label ?? "";
|
|
21
20
|
r({
|
|
22
|
-
dataset:
|
|
23
|
-
label:
|
|
21
|
+
dataset: c,
|
|
22
|
+
label: i,
|
|
24
23
|
value: n,
|
|
25
24
|
style: a,
|
|
26
|
-
dataPoints:
|
|
25
|
+
dataPoints: t.dataPoints
|
|
27
26
|
});
|
|
28
|
-
},
|
|
27
|
+
}, H = {
|
|
29
28
|
id: "hairlinePlugin",
|
|
30
29
|
beforeDatasetsDraw: (r) => {
|
|
31
30
|
const u = r.scales.y;
|
|
32
31
|
if (!u) return;
|
|
33
|
-
const { ctx:
|
|
32
|
+
const { ctx: t } = r, { top: a, bottom: b, left: i, right: n } = r.chartArea;
|
|
34
33
|
if (u.min > 0 || u.max < 0) return;
|
|
35
|
-
const
|
|
36
|
-
|
|
34
|
+
const c = u.getPixelForValue(0);
|
|
35
|
+
c < a || c > b || (t.save(), t.beginPath(), t.moveTo(i, c), t.lineTo(n, c), t.lineWidth = 2, t.strokeStyle = "rgb(207, 216, 220)", t.setLineDash([4, 3]), t.stroke(), t.restore());
|
|
37
36
|
}
|
|
38
|
-
},
|
|
37
|
+
}, W = {
|
|
39
38
|
responsive: !0,
|
|
40
39
|
maintainAspectRatio: !1,
|
|
41
40
|
plugins: {
|
|
@@ -72,72 +71,72 @@ const H = (r) => ({ chart: u, tooltip: e }) => {
|
|
|
72
71
|
mode: "index",
|
|
73
72
|
intersect: !1
|
|
74
73
|
}
|
|
75
|
-
},
|
|
76
|
-
const n = f.useRef(void 0),
|
|
74
|
+
}, I = ({ data: r, height: u, classNameContainer: t, id: a, options: b, CustomTooltip: i }) => {
|
|
75
|
+
const n = f.useRef(void 0), c = f.useRef(0), P = f.useRef(0), [C, x] = f.useState({
|
|
77
76
|
dataset: "",
|
|
78
77
|
label: "",
|
|
79
78
|
value: 0,
|
|
80
79
|
style: { opacity: 0, position: "absolute", left: 0, bottom: 0 },
|
|
81
80
|
dataPoints: []
|
|
82
|
-
}),
|
|
81
|
+
}), m = f.useCallback(function({
|
|
83
82
|
ctx: h,
|
|
84
|
-
chartArea:
|
|
83
|
+
chartArea: e,
|
|
85
84
|
scales: s,
|
|
86
85
|
chartHeight: l,
|
|
87
86
|
gradientFor: g,
|
|
88
|
-
item:
|
|
87
|
+
item: o
|
|
89
88
|
}) {
|
|
90
|
-
let p = (s.y.getPixelForValue(0) -
|
|
91
|
-
p = p < 0 ? 0 : p > 1 ? 1 : p, n.current = h.createLinearGradient(0,
|
|
89
|
+
let p = (s.y.getPixelForValue(0) - e.top) / l;
|
|
90
|
+
p = p < 0 ? 0 : p > 1 ? 1 : p, n.current = h.createLinearGradient(0, e.top, 0, l + e.top), g === "background" ? (n.current.addColorStop(0, o?.colorBackgroundPositiveZero || "#9FD2FF"), n.current.addColorStop(
|
|
92
91
|
p,
|
|
93
|
-
|
|
92
|
+
o?.colorBackgroundPositivePercentage || "rgba(115, 235, 163, 0.1)"
|
|
94
93
|
), n.current.addColorStop(
|
|
95
94
|
p,
|
|
96
|
-
|
|
97
|
-
), n.current.addColorStop(1,
|
|
95
|
+
o?.colorBackgroundNegativePercentage || "rgba(235, 107, 107, 0.1)"
|
|
96
|
+
), n.current.addColorStop(1, o?.colorBackgroundNegativeOne || "#EB6B6B")) : (n.current.addColorStop(p, o?.colorBorderPositive || "#80CBC4"), n.current.addColorStop(p, o?.colorBorderNegative || "#EB6B6B"));
|
|
98
97
|
}, []), v = f.useCallback(function({
|
|
99
98
|
ctx: h,
|
|
100
|
-
chartArea:
|
|
99
|
+
chartArea: e,
|
|
101
100
|
scales: s,
|
|
102
101
|
gradientFor: l,
|
|
103
102
|
item: g
|
|
104
103
|
}) {
|
|
105
|
-
const
|
|
106
|
-
return (!n.current ||
|
|
104
|
+
const o = e.right - e.left, d = e.bottom - e.top;
|
|
105
|
+
return (!n.current || c.current !== o || P.current !== d) && (c.current = o, P.current = d, m({ ctx: h, chartArea: e, scales: s, chartHeight: d, gradientFor: l, item: g })), m({ ctx: h, chartArea: e, scales: s, chartHeight: d, gradientFor: l, item: g }), n.current;
|
|
107
106
|
}, []), B = f.useMemo(() => ({
|
|
108
107
|
...r,
|
|
109
|
-
datasets: r.datasets.map((
|
|
108
|
+
datasets: r.datasets.map((e) => ({
|
|
110
109
|
fill: !0,
|
|
111
110
|
backgroundColor: function(s) {
|
|
112
|
-
const l = s.chart, { ctx: g, chartArea:
|
|
113
|
-
if (
|
|
114
|
-
return v({ ctx: g, chartArea:
|
|
111
|
+
const l = s.chart, { ctx: g, chartArea: o, scales: d } = l;
|
|
112
|
+
if (o)
|
|
113
|
+
return v({ ctx: g, chartArea: o, scales: d, gradientFor: "background", item: e });
|
|
115
114
|
},
|
|
116
115
|
borderColor: function(s) {
|
|
117
|
-
const l = s.chart, { ctx: g, chartArea:
|
|
118
|
-
if (
|
|
119
|
-
return v({ ctx: g, chartArea:
|
|
116
|
+
const l = s.chart, { ctx: g, chartArea: o, scales: d } = l;
|
|
117
|
+
if (o)
|
|
118
|
+
return v({ ctx: g, chartArea: o, scales: d, gradientFor: "border", item: e });
|
|
120
119
|
},
|
|
121
120
|
borderWidth: 3,
|
|
122
121
|
tension: 0,
|
|
123
122
|
pointRadius: 0,
|
|
124
123
|
pointHoverRadius: 4,
|
|
125
|
-
...
|
|
126
|
-
data:
|
|
124
|
+
...e,
|
|
125
|
+
data: e.data
|
|
127
126
|
}))
|
|
128
|
-
}), [r]), k = f.useMemo(() =>
|
|
127
|
+
}), [r]), k = f.useMemo(() => G(W, {
|
|
129
128
|
plugins: {
|
|
130
129
|
tooltip: {
|
|
131
|
-
enabled: !
|
|
132
|
-
external: ({ chart:
|
|
130
|
+
enabled: !i,
|
|
131
|
+
external: ({ chart: e, tooltip: s }) => i ? j(x)({ chart: e, tooltip: s }) : void 0
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
|
-
}, b ?? {}), [b,
|
|
136
|
-
return /* @__PURE__ */
|
|
137
|
-
|
|
138
|
-
/* @__PURE__ */
|
|
134
|
+
}, b ?? {}), [b, i]);
|
|
135
|
+
return /* @__PURE__ */ S("div", { id: a, className: t, style: { height: u || "300px" }, children: [
|
|
136
|
+
i && /* @__PURE__ */ y(N, { selector: "body", children: /* @__PURE__ */ y(i, { ...C }) }),
|
|
137
|
+
/* @__PURE__ */ y(Z, { data: B, options: k, plugins: [H] })
|
|
139
138
|
] });
|
|
140
139
|
};
|
|
141
140
|
export {
|
|
142
|
-
|
|
141
|
+
I as default
|
|
143
142
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("react/jsx-runtime"),y=require("react"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("react/jsx-runtime"),y=require("react"),a=require("chart.js"),B=require("react-chartjs-2"),L=require("date-fns"),S=require("date-fns/locale"),E=require("../../utils/common.cjs");a.Chart.register(a.CategoryScale,a.LinearScale,a.PointElement,a.LineElement,a.Title,a.Tooltip,a.Legend);const R=(s,f,b)=>{const i=s,g=f||new Date().getMonth(),c=b||new Date().getFullYear();return new Date(`${g}/${i}/${c}`)},$=({data:s,className:f,height:b=65})=>{const i=y.useRef(null),g=s.map(t=>L.formatDate(R(1,t.label,t.year),"MMM yy",{locale:S.id}))||[],[c,x]=y.useState(""),[h,M]=y.useState(""),D=t=>{const e=[],o=[];let u=!t.find(n=>n.isCurrent);return t.forEach(n=>{u?(o.push(n.value),e.push(null)):(e.push(n.value),n.isCurrent?(u=!0,o.push(n.value)):o.push(null))}),{passed:e,notPassed:o}},k={labels:g,datasets:[{label:"",fill:"blue",backgroundColor:"rgba(75,192,192,1)",borderColor:c,borderCapStyle:"butt",borderDashOffset:0,borderJoinStyle:"miter",pointBackgroundColor:function(t){const e=s[t.dataIndex];let o=h;return e.isCurrent&&(o="#ED0019"),o},pointBorderWidth:.1,pointHoverRadius:4,pointRadius:5,pointBorderColor:h,pointHoverBorderColor:c,data:D(s).passed||[]},{label:"",fill:"grey",backgroundColor:"rgba(75,192,192,1)",borderColor:"#D6D6D6",borderCapStyle:"butt",borderDashOffset:0,pointRadius:5,borderJoinStyle:"miter",pointBackgroundColor:h,pointBorderWidth:.1,pointHoverRadius:4,borderDash:[15,5],data:D(s).notPassed||[]}]},j={interaction:{mode:"index",intersect:!1},plugins:{legend:{display:!1,labels:{usePointStyle:!0}},tooltip:{external:function(t){let e=document.getElementById("chartjs-tooltip");e||(e=document.createElement("div"),e.id="chartjs-tooltip",e.innerHTML="<table></table>",document.body.appendChild(e));const o=t.tooltip;if(o.opacity===0){e.style.opacity="0";return}e.classList.remove("above","below","no-transform"),o.yAlign?e.classList.add(o.yAlign):e.classList.add("no-transform");function u(m){return m.lines}if(o.body){const m=o.title||[];let l=o.body.map(u),d="<thead>";m.forEach(C=>{let r="";r+="display: flex",r+="; justify-content: center",r+="; font-weight: 600",r+="; font-size: 12px",r+="; padding: 0px 14px",d+=`<tr><span style="${r}">${C}</span></tr>`}),d+="</thead><tbody>",l.length>1&&l[0][0]===l[1][0]&&(l=[l[0]]),l.forEach(C=>{let r="";r+="display: flex",r+="; justify-content: center",r+="; color: #0163C8",r+="; padding: 0px 14px",r+="; font-size: 12px";const w=`<span style="${r}">${C}</span>`;d+=`<tr><td>${w}</td></tr>`}),d+="</tbody>";const v=e.querySelector("table");v&&(v.innerHTML=d)}const n=t.chart.canvas.getBoundingClientRect();e.style.opacity="1",e.style.border="solid 1px #0163C8",e.style.background="white",e.style.height="fit-content",e.style.borderRadius="10px",e.style.position="absolute",e.style.zIndex="10",e.style.padding="4px 0",e.style.left=n.left+window.pageXOffset+o.caretX-30+"px",e.style.top=n.top+window.pageYOffset+o.caretY-60+"px",e.style.pointerEvents="none"},displayColors:!0,enabled:!1,callbacks:{title:function(t){const e=s[t[0].dataIndex];return L.formatDate(new Date(`1/${e.label}/${e.year}`),"MMMM yyyy",{locale:S.id})},label:function(t){let e=t.dataset.label??"";return e&&(e+=": "),t.parsed.y!==null&&(e+=new Intl.NumberFormat("id-ID",{style:"currency",currency:"IDR"}).format(t.parsed.y)),e}}}},scales:{x:{grid:{display:!1},beginAtZero:!0,ticks:{autoSkip:!0,maxTicksLimit:20}},y:{min:0,grid:{display:!1},beginAtZero:!0,ticks:{maxTicksLimit:6,callback:function(t){return E.setDigit(t)??0}}}}};return y.useEffect(()=>{if(i.current){const t=i.current.getContext("2d"),e=t?.createLinearGradient(0,100,500,-500);e?.addColorStop(0,"rgba(237, 0, 25, 0)"),e?.addColorStop(1,"rgba(237, 0, 25, 20)");const o=t.fillStyle="rgba(255, 255, 255, 0)";M(o),x(e)}},[]),p.jsxs("div",{className:f??"",children:[p.jsx(B.Line,{options:j,data:k,height:b}),p.jsx("div",{className:"iru-h-5",children:p.jsx("canvas",{ref:i})})]})};exports.default=$;
|
|
@@ -3,20 +3,20 @@ import p from "react";
|
|
|
3
3
|
import { Chart as E, CategoryScale as R, LinearScale as $, PointElement as I, LineElement as T, Title as j, Tooltip as H, Legend as O } from "chart.js";
|
|
4
4
|
import { Line as A } from "react-chartjs-2";
|
|
5
5
|
import { formatDate as L } from "date-fns";
|
|
6
|
-
import { id as
|
|
6
|
+
import { id as v } from "date-fns/locale";
|
|
7
7
|
import { setDigit as P } from "../../utils/common.mjs";
|
|
8
8
|
E.register(R, $, I, T, j, H, O);
|
|
9
|
-
const Y = (
|
|
10
|
-
const s =
|
|
9
|
+
const Y = (a, u, f) => {
|
|
10
|
+
const s = a, y = u || (/* @__PURE__ */ new Date()).getMonth(), d = f || (/* @__PURE__ */ new Date()).getFullYear();
|
|
11
11
|
return /* @__PURE__ */ new Date(`${y}/${s}/${d}`);
|
|
12
|
-
}, q = ({ data:
|
|
13
|
-
const s = p.useRef(null), y =
|
|
12
|
+
}, q = ({ data: a, className: u, height: f = 65 }) => {
|
|
13
|
+
const s = p.useRef(null), y = a.map((e) => L(Y(1, e.label, e.year), "MMM yy", { locale: v })) || [], [d, C] = p.useState(""), [b, S] = p.useState(""), x = (e) => {
|
|
14
14
|
const t = [], o = [];
|
|
15
15
|
let c = !e.find((n) => n.isCurrent);
|
|
16
16
|
return e.forEach((n) => {
|
|
17
17
|
c ? (o.push(n.value), t.push(null)) : (t.push(n.value), n.isCurrent ? (c = !0, o.push(n.value)) : o.push(null));
|
|
18
18
|
}), { passed: t, notPassed: o };
|
|
19
|
-
},
|
|
19
|
+
}, k = {
|
|
20
20
|
labels: y,
|
|
21
21
|
datasets: [
|
|
22
22
|
{
|
|
@@ -28,7 +28,7 @@ const Y = (l, u, f) => {
|
|
|
28
28
|
borderDashOffset: 0,
|
|
29
29
|
borderJoinStyle: "miter",
|
|
30
30
|
pointBackgroundColor: function(e) {
|
|
31
|
-
const t =
|
|
31
|
+
const t = a[e.dataIndex];
|
|
32
32
|
let o = b;
|
|
33
33
|
return t.isCurrent && (o = "#ED0019"), o;
|
|
34
34
|
},
|
|
@@ -37,7 +37,7 @@ const Y = (l, u, f) => {
|
|
|
37
37
|
pointRadius: 5,
|
|
38
38
|
pointBorderColor: b,
|
|
39
39
|
pointHoverBorderColor: d,
|
|
40
|
-
data: x(
|
|
40
|
+
data: x(a).passed || []
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
label: "",
|
|
@@ -53,7 +53,7 @@ const Y = (l, u, f) => {
|
|
|
53
53
|
pointBorderWidth: 0.1,
|
|
54
54
|
pointHoverRadius: 4,
|
|
55
55
|
borderDash: [15, 5],
|
|
56
|
-
data: x(
|
|
56
|
+
data: x(a).notPassed || []
|
|
57
57
|
}
|
|
58
58
|
]
|
|
59
59
|
}, w = {
|
|
@@ -78,19 +78,19 @@ const Y = (l, u, f) => {
|
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
t.classList.remove("above", "below", "no-transform"), o.yAlign ? t.classList.add(o.yAlign) : t.classList.add("no-transform");
|
|
81
|
-
function c(
|
|
82
|
-
return
|
|
81
|
+
function c(g) {
|
|
82
|
+
return g.lines;
|
|
83
83
|
}
|
|
84
84
|
if (o.body) {
|
|
85
|
-
const
|
|
86
|
-
let
|
|
87
|
-
|
|
85
|
+
const g = o.title || [];
|
|
86
|
+
let l = o.body.map(c), i = "<thead>";
|
|
87
|
+
g.forEach((m) => {
|
|
88
88
|
let r = "";
|
|
89
|
-
r += "display: flex", r += "; justify-content: center", r += "; font-weight: 600", r += "; font-size: 12px", r += "; padding: 0px 14px", i += `<tr><span style="${r}">${
|
|
90
|
-
}), i += "</thead><tbody>",
|
|
89
|
+
r += "display: flex", r += "; justify-content: center", r += "; font-weight: 600", r += "; font-size: 12px", r += "; padding: 0px 14px", i += `<tr><span style="${r}">${m}</span></tr>`;
|
|
90
|
+
}), i += "</thead><tbody>", l.length > 1 && l[0][0] === l[1][0] && (l = [l[0]]), l.forEach((m) => {
|
|
91
91
|
let r = "";
|
|
92
92
|
r += "display: flex", r += "; justify-content: center", r += "; color: #0163C8", r += "; padding: 0px 14px", r += "; font-size: 12px";
|
|
93
|
-
const M = `<span style="${r}">${
|
|
93
|
+
const M = `<span style="${r}">${m}</span>`;
|
|
94
94
|
i += `<tr><td>${M}</td></tr>`;
|
|
95
95
|
}), i += "</tbody>";
|
|
96
96
|
const D = t.querySelector("table");
|
|
@@ -103,8 +103,8 @@ const Y = (l, u, f) => {
|
|
|
103
103
|
enabled: !1,
|
|
104
104
|
callbacks: {
|
|
105
105
|
title: function(e) {
|
|
106
|
-
const t =
|
|
107
|
-
return L(/* @__PURE__ */ new Date(`1/${t.label}/${t.year}`), "MMMM yyyy", { locale:
|
|
106
|
+
const t = a[e[0].dataIndex];
|
|
107
|
+
return L(/* @__PURE__ */ new Date(`1/${t.label}/${t.year}`), "MMMM yyyy", { locale: v });
|
|
108
108
|
},
|
|
109
109
|
label: function(e) {
|
|
110
110
|
let t = e.dataset.label ?? "";
|
|
@@ -143,13 +143,13 @@ const Y = (l, u, f) => {
|
|
|
143
143
|
};
|
|
144
144
|
return p.useEffect(() => {
|
|
145
145
|
if (s.current) {
|
|
146
|
-
const e = s.current.getContext("2d"), t = e
|
|
147
|
-
t
|
|
146
|
+
const e = s.current.getContext("2d"), t = e?.createLinearGradient(0, 100, 500, -500);
|
|
147
|
+
t?.addColorStop(0, "rgba(237, 0, 25, 0)"), t?.addColorStop(1, "rgba(237, 0, 25, 20)");
|
|
148
148
|
const o = e.fillStyle = "rgba(255, 255, 255, 0)";
|
|
149
|
-
|
|
149
|
+
S(o), C(t);
|
|
150
150
|
}
|
|
151
151
|
}, []), /* @__PURE__ */ B("div", { className: u ?? "", children: [
|
|
152
|
-
/* @__PURE__ */ h(A, { options: w, data:
|
|
152
|
+
/* @__PURE__ */ h(A, { options: w, data: k, height: f }),
|
|
153
153
|
/* @__PURE__ */ h("div", { className: "iru-h-5", children: /* @__PURE__ */ h("canvas", { ref: s }) })
|
|
154
154
|
] });
|
|
155
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const h=require("react/jsx-runtime"),v=require("chart.js"),g=require("react"),S=require("react-chartjs-2"),x=require("../../utils/common.cjs"),k=require("../PortalComponent/PortalComponent.cjs");v.Chart.register(v.ArcElement,v.Tooltip);const M=(t,l,n)=>{const r=l>0?t/l*100:0;switch(n){case"decimal":return x.formatNumber(t,"decimal");case"currency":return x.formatNumber(t,"currency");default:return`${Math.round(r)}%`}},m=()=>{const t=Math.floor(Math.random()*360),l=60+Math.floor(Math.random()*30),n=45+Math.floor(Math.random()*20);return((o,a,c)=>{a/=100,c/=100;const s=a*Math.min(c,1-c),d=u=>{const i=(u+o/30)%12,e=c-s*Math.max(Math.min(i-3,9-i,1),-1);return Math.round(255*e).toString(16).padStart(2,"0")};return`#${d(0)}${d(8)}${d(4)}`})(t,l,n)},I=(t,l)=>Array.isArray(t)?t[l]||m():typeof t=="string"?t:m(),q=t=>{const l=t.labels??[],n=t.datasets[0];return n?(n.data??[]).map((o,a)=>({label:l[a]??"",value:o,backgroundColor:I(n.backgroundColor,a)})):[]},E=(t,l)=>{if(!l)return{labels:t.map(e=>e.label),values:t.map(e=>e.value),colors:t.map(e=>e.backgroundColor||m()),mergedMap:{}};const{mode:n,value:r,otherLabel:o="Other",otherBackgroundColor:a="#B0BEC5"}=l,c=t.reduce((e,p)=>e+p.value,0),s=[],d=[];let u=0;t.forEach(e=>{(n==="percentage"?e.value/c*100<r:e.value<r)?(u+=e.value,d.push(e)):s.push({label:e.label,value:e.value,color:e.backgroundColor||m()})});const i={};return u>0&&(s.push({label:o,value:u,color:a}),i[s.length-1]=d),{labels:s.map(e=>e.label),values:s.map(e=>e.value),colors:s.map(e=>e.color),mergedMap:i}},T=(t,l,n)=>({chart:r,tooltip:o})=>{const a={};if(o.opacity===0){t(f=>({...f,style:{...f.style,opacity:0,pointerEvents:"none"}}));return}if(!o.dataPoints||o.dataPoints.length===0)return;a.opacity="1",a.position="absolute",a.pointerEvents="none";const c=r.canvas.getBoundingClientRect();a.left=c.left+window.pageXOffset+o.caretX+"px",a.top=c.top+window.pageYOffset+o.caretY+"px";const s=o.dataPoints[0].dataIndex,d=o.dataPoints?.[0]?.label??"",u=o.dataPoints?.[0]?.raw??0,i=o.dataPoints?.[0]?.dataset.backgroundColor?.[s]??"",e=o.dataPoints?.[0]?.dataset.data?.reduce((f,b)=>f+b,0)||1,p=e>0?u/e*100:0;t({label:d,value:u,percentage:p,formattedValue:M(u,e,l),backgroundColor:typeof i=="string"?i:"#000",mergedItems:n[s]??[],style:a,dataPoints:o.dataPoints})},A=(t,l)=>({id:"pieLabelPlugin",afterDraw(n){const{ctx:r}=n,o=n.getDatasetMeta(0),a=n.data.datasets[0].data.reduce((c,s)=>c+s,0);o.data.forEach((c,s)=>{const u=n.data.datasets[0].data[s]??0;if((a>0?u/a*100:0)<l)return;const{x:e,y:p}=c.tooltipPosition(!1),f=n.data.labels?.[s];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(M(u,a,t),e||0,(p||0)+8),r.restore()})}}),B={responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{enabled:!0}},elements:{arc:{hoverOffset:8,borderWidth:0}}},R=({data:t,height:l,classNameContainer:n,id:r,options:o,CustomTooltip:a,threshold:c,valueFormat:s,hideLabelBelowPercentage:d=5})=>{const[u,i]=g.useState({style:{opacity:0,position:"absolute",left:0,top:0},label:"",value:0,percentage:0,formattedValue:"",backgroundColor:"",mergedItems:[],dataPoints:[]}),e=g.useMemo(()=>q(t),[t]),{labels:p,values:f,colors:b,mergedMap:y}=g.useMemo(()=>E(e,c),[e,c]),P=g.useMemo(()=>({labels:p,datasets:[{...t.datasets[0],data:f,backgroundColor:b,hoverOffset:8,borderWidth:0}]}),[p,f,b,t.datasets]),C=g.useMemo(()=>{const O={plugins:{tooltip:{enabled:!a,external:a?({chart:j,tooltip:w})=>T(i,s,y)({chart:j,tooltip:w}):void 0}}};return x.mergeObjects(B,O,o??{})},[o,a,s,y]);return h.jsxs("div",{id:r,className:n,style:{height:l||"300px"},children:[a&&h.jsx(k.default,{selector:"body",children:h.jsx(a,{...u})}),h.jsx(S.Pie,{data:P,options:C,plugins:[A(s,d)]})]})};exports.default=R;
|