1mpacto-react-ui 2.0.20 → 2.0.22
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/_mixins.scss +72 -72
- package/dist/assets/icons/arrow-narrow-down.svg +3 -3
- 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/Button/Button.cjs +12 -12
- package/dist/components/Button/Button.config.cjs +1 -1
- package/dist/components/Button/Button.config.mjs +3 -1
- package/dist/components/Button/Button.mjs +24 -24
- package/dist/components/Button/style.module.scss.cjs +1 -1
- package/dist/components/Button/style.module.scss.mjs +57 -55
- package/dist/components/ButtonIcon/ButtonIcon.cjs +12 -12
- package/dist/components/ButtonIcon/ButtonIcon.mjs +20 -20
- 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 +3 -3
- package/dist/components/Calendar/CalendarYear.mjs +39 -40
- 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/Slider/Slider.cjs +1 -0
- package/dist/components/Slider/Slider.mjs +61 -0
- package/dist/components/Slider/style.module.scss.cjs +1 -0
- package/dist/components/Slider/style.module.scss.mjs +14 -0
- 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 +12 -12
- package/dist/components/Upload/UploadImage.mjs +73 -79
- 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/index.cjs +1 -1
- package/dist/index.mjs +48 -46
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.d.ts +129 -128
- package/dist/package.json.mjs +1 -1
- package/dist/src/components/Button/Button.config.d.ts +2 -0
- package/dist/src/components/Slider/Slider.d.ts +3 -0
- package/dist/src/components/Slider/Slider.stories.d.ts +6 -0
- package/dist/src/components/index.d.ts +4 -2
- package/dist/src/interfaces/components/Button/index.d.ts +1 -1
- package/dist/src/interfaces/components/Slider/index.d.ts +51 -0
- package/dist/types-external/table.d.ts +15 -15
- package/dist/utils/common.cjs +1 -1
- package/dist/utils/common.mjs +172 -173
- package/package.json +128 -128
|
@@ -1,125 +1,122 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as H, jsx as A } from "react/jsx-runtime";
|
|
2
2
|
import { Doughnut as T } from "react-chartjs-2";
|
|
3
|
-
import { Chart as
|
|
4
|
-
|
|
5
|
-
const j = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
height: p,
|
|
17
|
-
width: r
|
|
3
|
+
import { Chart as L, CategoryScale as R, LinearScale as F, PointElement as M, LineElement as Y, ArcElement as O, Title as k, Tooltip as N, Legend as P } from "chart.js";
|
|
4
|
+
L.register(R, F, M, Y, O, k, N, P);
|
|
5
|
+
const j = (d, e) => {
|
|
6
|
+
const I = d.getVisibleDatasetCount(), f = d.getDatasetMeta(I - 1).data.at(0);
|
|
7
|
+
if (f) {
|
|
8
|
+
const { innerRadius: m } = f.getProps(["innerRadius"]), { ctx: s } = d, v = () => {
|
|
9
|
+
const t = [].concat(e), o = t.length, r = s.font;
|
|
10
|
+
let p = 0, h = 0, l;
|
|
11
|
+
for (l = 0; l < o; ++l)
|
|
12
|
+
s.font = t[l].font, p = Math.max(s.measureText(t[l].text).width, p), h += t[l].font?.lineHeight;
|
|
13
|
+
return s.font = r, {
|
|
14
|
+
height: h,
|
|
15
|
+
width: p
|
|
18
16
|
};
|
|
19
|
-
},
|
|
20
|
-
let
|
|
21
|
-
document.body.appendChild(
|
|
22
|
-
const
|
|
23
|
-
width:
|
|
24
|
-
height:
|
|
17
|
+
}, g = (t, o) => {
|
|
18
|
+
let r = document.createElement("div");
|
|
19
|
+
document.body.appendChild(r), r.style.fontSize = `${o}px`, r.style.position = "absolute", r.style.left = "-10", r.style.top = "-10", r.textContent = t;
|
|
20
|
+
const p = {
|
|
21
|
+
width: r.clientWidth,
|
|
22
|
+
height: r.clientHeight
|
|
25
23
|
};
|
|
26
|
-
return document.body.removeChild(
|
|
27
|
-
},
|
|
24
|
+
return document.body.removeChild(r), r = null, p;
|
|
25
|
+
}, b = v(), x = parseFloat(parseFloat(m).toFixed(2));
|
|
28
26
|
s.textAlign = "center", s.textBaseline = "middle";
|
|
29
|
-
const
|
|
30
|
-
let
|
|
31
|
-
const
|
|
32
|
-
let
|
|
33
|
-
for (
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
for (;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
n
|
|
41
|
-
) : n
|
|
42
|
-
let l = n
|
|
43
|
-
if (n
|
|
44
|
-
const
|
|
45
|
-
|
|
27
|
+
const w = (d.chartArea.left + d.chartArea.right) / 2, E = (d.chartArea.top + d.chartArea.bottom) / 2 - b.height / 2;
|
|
28
|
+
let n;
|
|
29
|
+
const D = e.length;
|
|
30
|
+
let i = 0;
|
|
31
|
+
for (n = 0; n < D; ++n) {
|
|
32
|
+
let t = e[n].font?.size, o = e[n].font?.lineHeight;
|
|
33
|
+
const r = typeof e[n].text == "number" ? e[n].text.toString() : e[n].text;
|
|
34
|
+
for (; g(r, t).width > x + (e[n].id === "value" ? 50 : 0); )
|
|
35
|
+
t -= 1, o = g(r, t).height;
|
|
36
|
+
r.length > 22 && o < 14 && (o = 18);
|
|
37
|
+
const p = E + o / 2 + i, h = typeof e[n].text == "number" ? new Intl.NumberFormat("id-ID", { style: "currency", currency: "IDR" }).format(
|
|
38
|
+
e[n].text
|
|
39
|
+
) : e[n].text;
|
|
40
|
+
let l = e[n].urlIconDesc ? " " : "";
|
|
41
|
+
if (e[n].percentage !== void 0 ? l += `${e[n].percentage}% ${e[n].text}` : l += h, s.fillStyle = e[n].color, s.font = `${t < 10 ? 10 : t}px sans-serif`, i += o, e[n].percentage !== void 0 && e[n].urlIconDesc) {
|
|
42
|
+
const u = e[n]?.percentage?.length ?? 0, c = new Image();
|
|
43
|
+
c.src = e[n].urlIconDesc, s.drawImage(c, 45 - (u > 6 ? u + 2 : u - 2.5), p - 8, 16, 14);
|
|
46
44
|
}
|
|
47
|
-
s.fillText(l,
|
|
45
|
+
s.fillText(l, w, p);
|
|
48
46
|
}
|
|
49
47
|
s.restore(), s.save();
|
|
50
48
|
}
|
|
51
49
|
}, V = ({
|
|
52
|
-
labels:
|
|
53
|
-
data:
|
|
54
|
-
backgroundColor:
|
|
55
|
-
options:
|
|
50
|
+
labels: d,
|
|
51
|
+
data: e,
|
|
52
|
+
backgroundColor: I,
|
|
53
|
+
options: f = {},
|
|
56
54
|
redraw: m,
|
|
57
|
-
widthInnerDoughnut:
|
|
58
|
-
innerLabels:
|
|
59
|
-
open:
|
|
60
|
-
keyRemoveDataOpen:
|
|
61
|
-
keyLabel:
|
|
55
|
+
widthInnerDoughnut: s,
|
|
56
|
+
innerLabels: v,
|
|
57
|
+
open: g = !0,
|
|
58
|
+
keyRemoveDataOpen: b = "gap",
|
|
59
|
+
keyLabel: x = "title",
|
|
62
60
|
keyValue: w = "originalValue",
|
|
63
|
-
keyBackground:
|
|
64
|
-
className:
|
|
61
|
+
keyBackground: S = "backgroundColor",
|
|
62
|
+
className: E
|
|
65
63
|
}) => {
|
|
66
|
-
const
|
|
67
|
-
labels:
|
|
64
|
+
const n = {
|
|
65
|
+
labels: d || e.map((i) => i[x]),
|
|
68
66
|
datasets: [
|
|
69
67
|
{
|
|
70
|
-
data:
|
|
71
|
-
backgroundColor:
|
|
68
|
+
data: e.map((i) => i[w]),
|
|
69
|
+
backgroundColor: I || e.map((i) => i[S])
|
|
72
70
|
}
|
|
73
71
|
]
|
|
74
|
-
},
|
|
75
|
-
cutout:
|
|
72
|
+
}, D = {
|
|
73
|
+
cutout: s,
|
|
76
74
|
animation: { duration: m ? 400 : 0 },
|
|
77
75
|
plugins: {
|
|
78
76
|
legend: { display: !1 },
|
|
79
77
|
tooltip: {
|
|
80
78
|
external(i) {
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
|
|
79
|
+
let t = document.getElementById("chartjs-tooltip");
|
|
80
|
+
t || (t = document.createElement("div"), t.id = "chartjs-tooltip", t.innerHTML = "<table></table>", document.body.appendChild(t));
|
|
81
|
+
const o = i.tooltip;
|
|
82
|
+
if (o.opacity === 0) {
|
|
83
|
+
t.style.opacity = "0";
|
|
86
84
|
return;
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
function c
|
|
92
|
-
return
|
|
86
|
+
t.classList.remove("above", "below", "no-transform"), o.yAlign ? t.classList.add(o.yAlign) : t.classList.add("no-transform");
|
|
87
|
+
const r = e.filter((c) => !c[x]), p = e.filter((c) => c[w] > 0 && c[w] < 1);
|
|
88
|
+
if (r.length === 1 && p.length === 1) return;
|
|
89
|
+
function h(c) {
|
|
90
|
+
return c.lines;
|
|
93
91
|
}
|
|
94
|
-
if (
|
|
95
|
-
const
|
|
96
|
-
let
|
|
97
|
-
|
|
92
|
+
if (o.body) {
|
|
93
|
+
const c = o.title || [];
|
|
94
|
+
let y = o.body.map(h), C = "<thead>";
|
|
95
|
+
c.forEach(($) => {
|
|
98
96
|
let a = "";
|
|
99
|
-
a += "display: flex", a += "; justify-content: center", a += "; font-weight: 600", a += "; font-size: 12px", a += "; padding: 0px 14px",
|
|
100
|
-
}),
|
|
97
|
+
a += "display: flex", a += "; justify-content: center", a += "; font-weight: 600", a += "; font-size: 12px", a += "; padding: 0px 14px", C += `<tr><span style="${a}">${$}</span></tr>`;
|
|
98
|
+
}), C += "</thead><tbody>", y.length > 1 && y[0][0] === y[1][0] && (y = [y[0]]), y.forEach(($) => {
|
|
101
99
|
let a = "";
|
|
102
100
|
a += "display: flex", a += "; justify-content: center", a += "; color: #0163C8", a += "; padding: 0px 14px", a += "; font-size: 12px";
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
}),
|
|
106
|
-
const
|
|
107
|
-
|
|
101
|
+
const B = `<span style="${a}">${$}</span>`;
|
|
102
|
+
C += `<tr><td>${B}</td></tr>`;
|
|
103
|
+
}), C += "</tbody>";
|
|
104
|
+
const z = t.querySelector("table");
|
|
105
|
+
z && (z.innerHTML = C);
|
|
108
106
|
}
|
|
109
|
-
const
|
|
110
|
-
|
|
107
|
+
const l = i.chart.canvas.getBoundingClientRect(), u = l.top + window.pageYOffset + o.caretY;
|
|
108
|
+
t.style.opacity = "1", t.style.border = "solid 1px #0163C8", t.style.background = "white", t.style.height = "fit-content", t.style.borderRadius = "10px", t.style.position = "absolute", t.style.zIndex = "10", t.style.padding = "4px 0", t.style.left = `${l.left + window.pageXOffset + o.caretX - 80}px`, t.style.top = `${u > 300 && !g ? 280 : u}px`, t.style.pointerEvents = "none";
|
|
111
109
|
},
|
|
112
110
|
displayColors: !0,
|
|
113
111
|
enabled: !1,
|
|
114
112
|
callbacks: {
|
|
115
113
|
title(i) {
|
|
116
|
-
|
|
117
|
-
return e == null ? void 0 : e[s];
|
|
114
|
+
return e[i[0].dataIndex]?.[x];
|
|
118
115
|
},
|
|
119
116
|
label(i) {
|
|
120
|
-
const
|
|
121
|
-
let
|
|
122
|
-
return
|
|
117
|
+
const t = e?.[i.dataIndex];
|
|
118
|
+
let o = "Nilai: ";
|
|
119
|
+
return t && (o += t.value), o;
|
|
123
120
|
}
|
|
124
121
|
}
|
|
125
122
|
}
|
|
@@ -130,27 +127,27 @@ const j = (f, n) => {
|
|
|
130
127
|
}
|
|
131
128
|
}
|
|
132
129
|
};
|
|
133
|
-
return /* @__PURE__ */
|
|
134
|
-
!
|
|
130
|
+
return /* @__PURE__ */ H("div", { className: E ?? "", children: [
|
|
131
|
+
!g && /* @__PURE__ */ A(
|
|
135
132
|
T,
|
|
136
133
|
{
|
|
137
|
-
data:
|
|
134
|
+
data: n,
|
|
138
135
|
redraw: m,
|
|
139
136
|
plugins: [
|
|
140
137
|
{
|
|
141
138
|
id: "draw",
|
|
142
139
|
beforeDraw(i) {
|
|
143
|
-
j(i,
|
|
140
|
+
j(i, v);
|
|
144
141
|
}
|
|
145
142
|
}
|
|
146
143
|
],
|
|
147
|
-
options: Object.keys(
|
|
144
|
+
options: Object.keys(f).length > 1 ? f : D
|
|
148
145
|
}
|
|
149
146
|
),
|
|
150
|
-
|
|
147
|
+
g && /* @__PURE__ */ A(
|
|
151
148
|
T,
|
|
152
149
|
{
|
|
153
|
-
data:
|
|
150
|
+
data: n,
|
|
154
151
|
redraw: m,
|
|
155
152
|
plugins: [
|
|
156
153
|
{
|
|
@@ -158,12 +155,12 @@ const j = (f, n) => {
|
|
|
158
155
|
beforeDraw(i) {
|
|
159
156
|
j(
|
|
160
157
|
i,
|
|
161
|
-
|
|
158
|
+
v.filter((t) => t.id !== b)
|
|
162
159
|
);
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
],
|
|
166
|
-
options: Object.keys(
|
|
163
|
+
options: Object.keys(f).length > 1 ? f : D
|
|
167
164
|
}
|
|
168
165
|
)
|
|
169
166
|
] });
|
|
@@ -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;
|