@nice2dev/ui 1.4.21 → 1.4.23
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/CHANGELOG.md +79 -0
- package/dist/NiceCodeEditor-CBgbzwjx.cjs +297 -0
- package/dist/{NiceMention-DhaTUqvR.cjs → NiceMention-D330ovOt.cjs} +1 -1
- package/dist/{NicePivotGrid-BshofJh1.cjs → NicePivotGrid-B5Fgi5E_.cjs} +1 -1
- package/dist/charts/NiceAdvancedCharts.mjs +657 -613
- package/dist/charts/NiceBarGauge.mjs +100 -65
- package/dist/charts/NiceBullet.mjs +103 -98
- package/dist/charts/NiceChart.mjs +269 -266
- package/dist/charts/NiceCircularGauge.mjs +99 -70
- package/dist/charts/NiceLinearGauge.mjs +168 -119
- package/dist/charts/NicePieChart.mjs +94 -49
- package/dist/charts/NicePolarChart.mjs +2 -2
- package/dist/charts-C9B548D2.cjs +924 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.d.ts +24 -2
- package/dist/{core-lazy-DirbU7jp.cjs → core-lazy-B54FdghB.cjs} +1 -1
- package/dist/data.cjs +1 -1
- package/dist/editors/rich/NiceCodeEditor.mjs +525 -504
- package/dist/editors.cjs +1 -1
- package/dist/index.cjs +8 -3
- package/dist/index.d.ts +29 -2
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +8 -0
- package/dist/style.css +1 -1
- package/dist/tools/NiceGitManager.mjs +5 -0
- package/dist/workflow/NiceTaskInbox.mjs +14 -12
- package/package.json +4 -4
- package/dist/NiceCodeEditor-DhdjnDLV.cjs +0 -289
- package/dist/charts-C3Q3r8Yz.cjs +0 -918
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useNiceTranslation as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { jsxs as m, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useNiceTranslation as ce, NiceIcon as de, clickOnActivationKey as ue } from "@nice2dev/ui-core";
|
|
3
|
+
import ge, { forwardRef as ve, useState as ee, useCallback as W, useMemo as ie, useImperativeHandle as xe, useId as Se, useRef as oe, useEffect as fe } from "react";
|
|
4
|
+
const ze = [], Ie = [], De = [], ye = [
|
|
5
5
|
"var(--nice-color-primary, #3b82f6)",
|
|
6
6
|
"var(--nice-color-error, #ef4444)",
|
|
7
7
|
"var(--nice-color-success, #22c55e)",
|
|
@@ -12,234 +12,263 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
12
12
|
"var(--nice-color-success, #10b981)",
|
|
13
13
|
"var(--nice-color-warning, #f59e0b)",
|
|
14
14
|
"var(--nice-color-accent, #6366f1)"
|
|
15
|
-
],
|
|
16
|
-
/* @__PURE__ */
|
|
17
|
-
const { t:
|
|
18
|
-
levels:
|
|
19
|
-
initialLevelId:
|
|
20
|
-
levelId:
|
|
21
|
-
chartType:
|
|
22
|
-
width:
|
|
23
|
-
height:
|
|
24
|
-
showBreadcrumbs:
|
|
25
|
-
showBackButton:
|
|
26
|
-
animationDuration:
|
|
15
|
+
], Te = /* @__PURE__ */ Object.assign(
|
|
16
|
+
/* @__PURE__ */ ve((E, A) => {
|
|
17
|
+
const { t: $ } = ce(), {
|
|
18
|
+
levels: b = De,
|
|
19
|
+
initialLevelId: H,
|
|
20
|
+
levelId: Y,
|
|
21
|
+
chartType: te = "bar",
|
|
22
|
+
width: k = 600,
|
|
23
|
+
height: O = 400,
|
|
24
|
+
showBreadcrumbs: ne = !0,
|
|
25
|
+
showBackButton: K = !0,
|
|
26
|
+
animationDuration: F = 300,
|
|
27
27
|
onLevelChange: j,
|
|
28
|
-
onItemClick:
|
|
29
|
-
colors:
|
|
30
|
-
showValues:
|
|
31
|
-
showLegend:
|
|
32
|
-
className:
|
|
28
|
+
onItemClick: ae,
|
|
29
|
+
colors: X = ye,
|
|
30
|
+
showValues: G = !0,
|
|
31
|
+
showLegend: q = !0,
|
|
32
|
+
className: Z,
|
|
33
33
|
style: T,
|
|
34
|
-
testId:
|
|
35
|
-
"data-testid":
|
|
36
|
-
...
|
|
37
|
-
} =
|
|
38
|
-
(
|
|
39
|
-
const
|
|
40
|
-
let
|
|
41
|
-
for (;
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return
|
|
34
|
+
testId: S,
|
|
35
|
+
"data-testid": Q,
|
|
36
|
+
...x
|
|
37
|
+
} = E, h = Y !== void 0, [g, z] = ee(H || b[0]?.id), [d, _] = ee([H || b[0]?.id]), P = W(
|
|
38
|
+
(e) => {
|
|
39
|
+
const n = [];
|
|
40
|
+
let i = b.find((c) => c.id === e);
|
|
41
|
+
for (; i && !n.includes(i.id); ) {
|
|
42
|
+
n.unshift(i.id);
|
|
43
|
+
const c = i.parentId;
|
|
44
|
+
i = c ? b.find((p) => p.id === c) : void 0;
|
|
45
|
+
}
|
|
46
|
+
return n.length > 0 ? n : [e];
|
|
47
47
|
},
|
|
48
|
-
[
|
|
49
|
-
), l =
|
|
50
|
-
() =>
|
|
51
|
-
[
|
|
52
|
-
), [
|
|
53
|
-
() =>
|
|
54
|
-
[
|
|
55
|
-
),
|
|
56
|
-
(
|
|
57
|
-
|
|
58
|
-
h || (
|
|
59
|
-
},
|
|
48
|
+
[b]
|
|
49
|
+
), l = Y ?? g, r = ie(
|
|
50
|
+
() => Y !== void 0 ? P(Y) : d,
|
|
51
|
+
[Y, d, P]
|
|
52
|
+
), [v, u] = ee(!1), [C, w] = ee("in"), o = ie(
|
|
53
|
+
() => b.find((e) => e.id === l),
|
|
54
|
+
[b, l]
|
|
55
|
+
), I = W(
|
|
56
|
+
(e) => {
|
|
57
|
+
b.find((i) => i.id === e) && (w("in"), u(!0), setTimeout(() => {
|
|
58
|
+
h || (z(e), _((i) => [...i, e])), j?.(e, h ? P(e) : [...r, e]), u(!1);
|
|
59
|
+
}, F / 2));
|
|
60
60
|
},
|
|
61
|
-
[
|
|
62
|
-
),
|
|
63
|
-
if (
|
|
61
|
+
[b, r, F, j, h, P]
|
|
62
|
+
), L = W(() => {
|
|
63
|
+
if (r.length <= 1)
|
|
64
64
|
return;
|
|
65
|
-
|
|
66
|
-
const
|
|
65
|
+
w("out"), u(!0);
|
|
66
|
+
const e = r.slice(0, -1), n = e[e.length - 1];
|
|
67
67
|
setTimeout(() => {
|
|
68
|
-
h || (
|
|
69
|
-
},
|
|
70
|
-
}, [
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
h || (
|
|
74
|
-
},
|
|
75
|
-
}, [
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
h || (z(n), _(e)), j?.(n, e), u(!1);
|
|
69
|
+
}, F / 2);
|
|
70
|
+
}, [r, F, j, h]), R = W(() => {
|
|
71
|
+
const e = b[0]?.id;
|
|
72
|
+
e && (w("out"), u(!0), setTimeout(() => {
|
|
73
|
+
h || (z(e), _([e])), j?.(e, [e]), u(!1);
|
|
74
|
+
}, F / 2));
|
|
75
|
+
}, [b, F, j, h]);
|
|
76
|
+
xe(
|
|
77
|
+
A,
|
|
78
78
|
() => ({
|
|
79
|
-
drillDown:
|
|
80
|
-
drillUp:
|
|
81
|
-
resetToRoot:
|
|
79
|
+
drillDown: I,
|
|
80
|
+
drillUp: L,
|
|
81
|
+
resetToRoot: R,
|
|
82
82
|
getCurrentLevel: () => l,
|
|
83
|
-
getPath: () =>
|
|
83
|
+
getPath: () => r
|
|
84
84
|
}),
|
|
85
|
-
[
|
|
85
|
+
[I, L, R, l, r]
|
|
86
86
|
);
|
|
87
|
-
const t =
|
|
88
|
-
(
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
);
|
|
93
|
-
r && z(r.id);
|
|
87
|
+
const t = W(
|
|
88
|
+
(e, n) => {
|
|
89
|
+
ae?.(e, l);
|
|
90
|
+
const i = e.drillDownId ?? e.metadata?.childLevelId, c = i ? b.find((p) => p.id === i) : void 0;
|
|
91
|
+
c && I(c.id);
|
|
94
92
|
},
|
|
95
|
-
[l,
|
|
96
|
-
),
|
|
97
|
-
() =>
|
|
98
|
-
[
|
|
99
|
-
),
|
|
100
|
-
() =>
|
|
101
|
-
[
|
|
102
|
-
),
|
|
103
|
-
if (!
|
|
93
|
+
[l, b, I, ae]
|
|
94
|
+
), M = ie(
|
|
95
|
+
() => o?.data.reduce((e, n) => e + n.value, 0) || 0,
|
|
96
|
+
[o]
|
|
97
|
+
), N = ie(
|
|
98
|
+
() => r.map((e) => b.find((n) => n.id === e)?.label || e),
|
|
99
|
+
[r, b]
|
|
100
|
+
), J = () => {
|
|
101
|
+
if (!o)
|
|
104
102
|
return null;
|
|
105
|
-
const
|
|
106
|
-
return /* @__PURE__ */
|
|
107
|
-
const
|
|
108
|
-
return /* @__PURE__ */
|
|
103
|
+
const e = o.data, n = Math.max(...e.map((c) => c.value)), i = Math.min(40, (O - 100) / e.length - 8);
|
|
104
|
+
return /* @__PURE__ */ a("div", { className: "nice-drilldown-bars", children: e.map((c, p) => {
|
|
105
|
+
const s = c.value / n * 100;
|
|
106
|
+
return /* @__PURE__ */ m(
|
|
109
107
|
"div",
|
|
110
108
|
{
|
|
111
109
|
role: "button",
|
|
112
110
|
tabIndex: 0,
|
|
113
|
-
onKeyDown:
|
|
111
|
+
onKeyDown: ue,
|
|
114
112
|
className: "nice-drilldown-bar-row",
|
|
115
|
-
onClick: () => t(
|
|
113
|
+
onClick: () => t(c, p),
|
|
116
114
|
children: [
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ a("span", { className: "nice-drilldown-bar-label", children: c.label || $("charts.item", "Item {i}").replace("{i}", String(p + 1)) }),
|
|
116
|
+
/* @__PURE__ */ a("div", { className: "nice-drilldown-bar-track", children: /* @__PURE__ */ a(
|
|
119
117
|
"div",
|
|
120
118
|
{
|
|
121
119
|
className: "nice-drilldown-bar-fill",
|
|
122
120
|
style: {
|
|
123
|
-
width: `${
|
|
124
|
-
backgroundColor:
|
|
125
|
-
height:
|
|
121
|
+
width: `${s}%`,
|
|
122
|
+
backgroundColor: c.color || X[p % X.length],
|
|
123
|
+
height: i
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
126
|
) }),
|
|
129
|
-
|
|
127
|
+
G && /* @__PURE__ */ a("span", { className: "nice-drilldown-bar-value", children: c.value.toLocaleString() })
|
|
130
128
|
]
|
|
131
129
|
},
|
|
132
130
|
p
|
|
133
131
|
);
|
|
134
132
|
}) });
|
|
135
|
-
},
|
|
136
|
-
if (!
|
|
133
|
+
}, y = `nice-drill-gaps-${Se().replace(/[^a-zA-Z0-9_-]/g, "")}`, V = () => {
|
|
134
|
+
if (!o)
|
|
137
135
|
return null;
|
|
138
|
-
const
|
|
139
|
-
let
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
return
|
|
143
|
-
path:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
136
|
+
const e = o.data, n = O - 40, i = k / 2, c = n / 2, p = Math.max(10, Math.min(k, n) / 2 - 16);
|
|
137
|
+
let s = -90;
|
|
138
|
+
const B = e.map((f, re) => {
|
|
139
|
+
const le = f.value / M * 360, pe = s + le, be = le > 180 ? 1 : 0, se = s * Math.PI / 180, he = pe * Math.PI / 180, we = i + p * Math.cos(se), ke = c + p * Math.sin(se), Me = i + p * Math.cos(he), Ne = c + p * Math.sin(he), me = (s + le / 2) * Math.PI / 180, $e = i + p * 0.7 * Math.cos(me), Le = c + p * 0.7 * Math.sin(me), Ce = `M ${i} ${c} L ${we} ${ke} A ${p} ${p} 0 ${be} 1 ${Me} ${Ne} Z`;
|
|
140
|
+
return s = pe, {
|
|
141
|
+
path: Ce,
|
|
142
|
+
startRad: se,
|
|
143
|
+
drillable: !!(f.drillDownId ?? f.metadata?.childLevelId),
|
|
144
|
+
color: f.color || X[re % X.length],
|
|
145
|
+
label: f.label || $("charts.item", "Item {i}").replace("{i}", String(re + 1)),
|
|
146
|
+
value: f.value,
|
|
147
|
+
percentage: (f.value / M * 100).toFixed(1),
|
|
148
|
+
labelX: $e,
|
|
149
|
+
labelY: Le,
|
|
150
|
+
item: f,
|
|
151
|
+
index: re
|
|
152
152
|
};
|
|
153
|
-
});
|
|
154
|
-
return /* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
"
|
|
157
|
-
{
|
|
158
|
-
d: s.path,
|
|
159
|
-
fill: s.color,
|
|
160
|
-
stroke: "white",
|
|
161
|
-
strokeWidth: 2,
|
|
162
|
-
className: "nice-drilldown-pie-slice"
|
|
163
|
-
}
|
|
164
|
-
),
|
|
165
|
-
H && parseFloat(s.percentage) > 5 && /* @__PURE__ */ u(
|
|
166
|
-
"text",
|
|
153
|
+
}), U = B.length > 1 ? B.map((f) => f.startRad) : [];
|
|
154
|
+
return /* @__PURE__ */ m("svg", { width: k, height: n, className: "nice-drilldown-pie", children: [
|
|
155
|
+
U.length > 0 && /* @__PURE__ */ a("defs", { children: /* @__PURE__ */ m(
|
|
156
|
+
"mask",
|
|
167
157
|
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
fontWeight: "600",
|
|
158
|
+
id: y,
|
|
159
|
+
maskUnits: "userSpaceOnUse",
|
|
160
|
+
x: 0,
|
|
161
|
+
y: 0,
|
|
162
|
+
width: k,
|
|
163
|
+
height: n,
|
|
175
164
|
children: [
|
|
176
|
-
|
|
177
|
-
|
|
165
|
+
/* @__PURE__ */ a("rect", { x: 0, y: 0, width: k, height: n, fill: "white" }),
|
|
166
|
+
U.map((f, re) => /* @__PURE__ */ a(
|
|
167
|
+
"line",
|
|
168
|
+
{
|
|
169
|
+
x1: i,
|
|
170
|
+
y1: c,
|
|
171
|
+
x2: i + (p + 2) * Math.cos(f),
|
|
172
|
+
y2: c + (p + 2) * Math.sin(f),
|
|
173
|
+
stroke: "black",
|
|
174
|
+
strokeWidth: 2
|
|
175
|
+
},
|
|
176
|
+
re
|
|
177
|
+
))
|
|
178
178
|
]
|
|
179
179
|
}
|
|
180
|
+
) }),
|
|
181
|
+
/* @__PURE__ */ a("g", { mask: U.length > 0 ? `url(#${y})` : void 0, children: B.map((f, re) => /* @__PURE__ */ a(
|
|
182
|
+
"path",
|
|
183
|
+
{
|
|
184
|
+
d: f.path,
|
|
185
|
+
fill: f.color,
|
|
186
|
+
className: `nice-drilldown-pie-slice${f.drillable ? " nice-drilldown-pie-slice--drillable" : ""}`,
|
|
187
|
+
onClick: () => t(f.item, f.index),
|
|
188
|
+
children: /* @__PURE__ */ a("title", { children: `${f.label}: ${f.value} (${f.percentage}%)` })
|
|
189
|
+
},
|
|
190
|
+
re
|
|
191
|
+
)) }),
|
|
192
|
+
G && B.map(
|
|
193
|
+
(f, re) => parseFloat(f.percentage) > 5 ? /* @__PURE__ */ m(
|
|
194
|
+
"text",
|
|
195
|
+
{
|
|
196
|
+
x: f.labelX,
|
|
197
|
+
y: f.labelY,
|
|
198
|
+
textAnchor: "middle",
|
|
199
|
+
dominantBaseline: "middle",
|
|
200
|
+
className: "nice-piechart__label",
|
|
201
|
+
style: { fontSize: 13, pointerEvents: "none" },
|
|
202
|
+
children: [
|
|
203
|
+
f.percentage,
|
|
204
|
+
"%"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
re
|
|
208
|
+
) : null
|
|
180
209
|
)
|
|
181
|
-
] }
|
|
182
|
-
},
|
|
183
|
-
if (!
|
|
210
|
+
] });
|
|
211
|
+
}, D = () => {
|
|
212
|
+
if (!o)
|
|
184
213
|
return null;
|
|
185
|
-
const
|
|
186
|
-
return /* @__PURE__ */
|
|
187
|
-
[0, 0.25, 0.5, 0.75, 1].map((p,
|
|
188
|
-
/* @__PURE__ */
|
|
214
|
+
const e = o.data, n = Math.max(...e.map((p) => p.value)), i = Math.min(60, (k - 100) / e.length - 8), c = O - 100;
|
|
215
|
+
return /* @__PURE__ */ a("svg", { width: k, height: O - 40, className: "nice-drilldown-columns", children: /* @__PURE__ */ m("g", { transform: "translate(50, 20)", children: [
|
|
216
|
+
[0, 0.25, 0.5, 0.75, 1].map((p, s) => /* @__PURE__ */ m("g", { children: [
|
|
217
|
+
/* @__PURE__ */ a(
|
|
189
218
|
"line",
|
|
190
219
|
{
|
|
191
220
|
x1: 0,
|
|
192
|
-
y1:
|
|
193
|
-
x2:
|
|
194
|
-
y2:
|
|
221
|
+
y1: c * (1 - p),
|
|
222
|
+
x2: k - 80,
|
|
223
|
+
y2: c * (1 - p),
|
|
195
224
|
stroke: "var(--nice-border-color, #e5e7eb)",
|
|
196
225
|
strokeDasharray: p === 0 ? void 0 : "4"
|
|
197
226
|
}
|
|
198
227
|
),
|
|
199
|
-
/* @__PURE__ */
|
|
228
|
+
/* @__PURE__ */ a(
|
|
200
229
|
"text",
|
|
201
230
|
{
|
|
202
231
|
x: -8,
|
|
203
|
-
y:
|
|
232
|
+
y: c * (1 - p),
|
|
204
233
|
textAnchor: "end",
|
|
205
234
|
dominantBaseline: "middle",
|
|
206
235
|
fontSize: "11",
|
|
207
236
|
fill: "var(--nice-text-secondary, #6b7280)",
|
|
208
|
-
children: Math.round(
|
|
237
|
+
children: Math.round(n * p).toLocaleString()
|
|
209
238
|
}
|
|
210
239
|
)
|
|
211
|
-
] },
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
return /* @__PURE__ */
|
|
215
|
-
/* @__PURE__ */
|
|
240
|
+
] }, s)),
|
|
241
|
+
e.map((p, s) => {
|
|
242
|
+
const B = p.value / n * c, U = s * ((k - 100) / e.length) + ((k - 100) / e.length - i) / 2;
|
|
243
|
+
return /* @__PURE__ */ m("g", { onClick: () => t(p, s), children: [
|
|
244
|
+
/* @__PURE__ */ a(
|
|
216
245
|
"rect",
|
|
217
246
|
{
|
|
218
|
-
x:
|
|
219
|
-
y:
|
|
220
|
-
width:
|
|
221
|
-
height:
|
|
222
|
-
fill: p.color ||
|
|
247
|
+
x: U,
|
|
248
|
+
y: c - B,
|
|
249
|
+
width: i,
|
|
250
|
+
height: B,
|
|
251
|
+
fill: p.color || X[s % X.length],
|
|
223
252
|
rx: 4,
|
|
224
253
|
className: "nice-drilldown-column-bar"
|
|
225
254
|
}
|
|
226
255
|
),
|
|
227
|
-
/* @__PURE__ */
|
|
256
|
+
/* @__PURE__ */ a(
|
|
228
257
|
"text",
|
|
229
258
|
{
|
|
230
|
-
x:
|
|
231
|
-
y:
|
|
259
|
+
x: U + i / 2,
|
|
260
|
+
y: c + 16,
|
|
232
261
|
textAnchor: "middle",
|
|
233
262
|
fontSize: "11",
|
|
234
263
|
fill: "var(--nice-text-primary, #374151)",
|
|
235
|
-
children: (p.label || `${
|
|
264
|
+
children: (p.label || `${s + 1}`).slice(0, 10)
|
|
236
265
|
}
|
|
237
266
|
),
|
|
238
|
-
|
|
267
|
+
G && /* @__PURE__ */ a(
|
|
239
268
|
"text",
|
|
240
269
|
{
|
|
241
|
-
x:
|
|
242
|
-
y:
|
|
270
|
+
x: U + i / 2,
|
|
271
|
+
y: c - B - 8,
|
|
243
272
|
textAnchor: "middle",
|
|
244
273
|
fontSize: "11",
|
|
245
274
|
fill: "var(--nice-text-primary, #374151)",
|
|
@@ -247,61 +276,70 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
247
276
|
children: p.value.toLocaleString()
|
|
248
277
|
}
|
|
249
278
|
)
|
|
250
|
-
] },
|
|
279
|
+
] }, s);
|
|
251
280
|
})
|
|
252
281
|
] }) });
|
|
253
282
|
};
|
|
254
|
-
return /* @__PURE__ */
|
|
283
|
+
return /* @__PURE__ */ m(
|
|
255
284
|
"div",
|
|
256
285
|
{
|
|
257
|
-
className: `nice-drilldown-chart ${
|
|
258
|
-
style: { width:
|
|
259
|
-
"data-testid":
|
|
260
|
-
...
|
|
286
|
+
className: `nice-drilldown-chart ${v ? `animating ${C}` : ""} ${Z || ""}`,
|
|
287
|
+
style: { width: k, ...T },
|
|
288
|
+
"data-testid": Q ?? S,
|
|
289
|
+
...x,
|
|
261
290
|
children: [
|
|
262
|
-
/* @__PURE__ */
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
291
|
+
/* @__PURE__ */ m("div", { className: "nice-drilldown-header", children: [
|
|
292
|
+
K && /* @__PURE__ */ m(
|
|
293
|
+
"button",
|
|
294
|
+
{
|
|
295
|
+
type: "button",
|
|
296
|
+
className: "nice-drilldown-back",
|
|
297
|
+
onClick: L,
|
|
298
|
+
disabled: r.length <= 1,
|
|
299
|
+
children: [
|
|
300
|
+
/* @__PURE__ */ a(de, { name: "arrow-left", size: 14 }),
|
|
301
|
+
" ",
|
|
302
|
+
$("charts.back", "Back")
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
ne && /* @__PURE__ */ a("div", { className: "nice-drilldown-breadcrumbs", children: N.map((e, n) => /* @__PURE__ */ m(ge.Fragment, { children: [
|
|
307
|
+
n > 0 && /* @__PURE__ */ a("span", { className: "nice-drilldown-separator", children: "/" }),
|
|
308
|
+
/* @__PURE__ */ a(
|
|
271
309
|
"span",
|
|
272
310
|
{
|
|
273
|
-
role:
|
|
274
|
-
tabIndex:
|
|
275
|
-
"aria-current":
|
|
276
|
-
onKeyDown:
|
|
277
|
-
className: `nice-drilldown-crumb ${
|
|
311
|
+
role: n < N.length - 1 ? "button" : void 0,
|
|
312
|
+
tabIndex: n < N.length - 1 ? 0 : void 0,
|
|
313
|
+
"aria-current": n === N.length - 1 ? "location" : void 0,
|
|
314
|
+
onKeyDown: n < N.length - 1 ? ue : void 0,
|
|
315
|
+
className: `nice-drilldown-crumb ${n === N.length - 1 ? "active" : ""}`,
|
|
278
316
|
onClick: () => {
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
281
|
-
h || (
|
|
317
|
+
if (n < N.length - 1) {
|
|
318
|
+
const i = r.slice(0, n + 1), c = i[i.length - 1];
|
|
319
|
+
h || (_(i), z(c)), j?.(c, i);
|
|
282
320
|
}
|
|
283
321
|
},
|
|
284
|
-
children:
|
|
322
|
+
children: e
|
|
285
323
|
}
|
|
286
324
|
)
|
|
287
|
-
] },
|
|
325
|
+
] }, n)) })
|
|
288
326
|
] }),
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
327
|
+
/* @__PURE__ */ m("div", { className: "nice-drilldown-content", style: { height: O - 40 }, children: [
|
|
328
|
+
te === "bar" && J(),
|
|
329
|
+
te === "pie" && V(),
|
|
330
|
+
te === "column" && D()
|
|
293
331
|
] }),
|
|
294
|
-
|
|
295
|
-
/* @__PURE__ */
|
|
332
|
+
q && o && /* @__PURE__ */ a("div", { className: "nice-drilldown-legend", children: o.data.map((e, n) => /* @__PURE__ */ m("div", { className: "nice-drilldown-legend-item", children: [
|
|
333
|
+
/* @__PURE__ */ a(
|
|
296
334
|
"span",
|
|
297
335
|
{
|
|
298
336
|
className: "nice-drilldown-legend-color",
|
|
299
|
-
style: { backgroundColor:
|
|
337
|
+
style: { backgroundColor: e.color || X[n % X.length] }
|
|
300
338
|
}
|
|
301
339
|
),
|
|
302
|
-
/* @__PURE__ */
|
|
303
|
-
] },
|
|
304
|
-
/* @__PURE__ */
|
|
340
|
+
/* @__PURE__ */ a("span", { className: "nice-drilldown-legend-label", children: e.label || $("charts.item", "Item {i}").replace("{i}", String(n + 1)) })
|
|
341
|
+
] }, n)) }),
|
|
342
|
+
/* @__PURE__ */ a("style", { children: `
|
|
305
343
|
.nice-drilldown-chart {
|
|
306
344
|
font-family: inherit;
|
|
307
345
|
color: var(--nice-text-primary, #111827);
|
|
@@ -439,7 +477,13 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
439
477
|
|
|
440
478
|
.nice-drilldown-pie-slice:hover {
|
|
441
479
|
opacity: 0.85;
|
|
442
|
-
|
|
480
|
+
}
|
|
481
|
+
.nice-drilldown-pie-slice--drillable {
|
|
482
|
+
cursor: zoom-in;
|
|
483
|
+
}
|
|
484
|
+
.nice-drilldown-back:disabled {
|
|
485
|
+
opacity: 0.45;
|
|
486
|
+
cursor: default;
|
|
443
487
|
}
|
|
444
488
|
|
|
445
489
|
.nice-drilldown-column-bar {
|
|
@@ -482,89 +526,89 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
482
526
|
);
|
|
483
527
|
}),
|
|
484
528
|
{ displayName: "NiceDrillDownChart" }
|
|
485
|
-
),
|
|
529
|
+
), Ae = [
|
|
486
530
|
"var(--nice-info-bg, #dbeafe)",
|
|
487
531
|
"var(--nice-color-primary-light, #93c5fd)",
|
|
488
532
|
"var(--nice-color-primary, #3b82f6)",
|
|
489
533
|
"var(--nice-color-primary-active, #1d4ed8)",
|
|
490
534
|
"var(--nice-color-primary, #6366f1)"
|
|
491
|
-
],
|
|
492
|
-
type:
|
|
493
|
-
regions:
|
|
494
|
-
bubbles:
|
|
495
|
-
width:
|
|
496
|
-
height:
|
|
497
|
-
viewBox:
|
|
498
|
-
colorScale:
|
|
535
|
+
], Be = ({
|
|
536
|
+
type: E = "choropleth",
|
|
537
|
+
regions: A = [],
|
|
538
|
+
bubbles: $ = [],
|
|
539
|
+
width: b = 800,
|
|
540
|
+
height: H = 500,
|
|
541
|
+
viewBox: Y = "0 0 800 500",
|
|
542
|
+
colorScale: te,
|
|
499
543
|
// The documented alias of `colorScale`. It was never destructured, so it did nothing
|
|
500
544
|
// and fell through `...rest` onto the root div (React warned about an unknown prop).
|
|
501
|
-
colorRange:
|
|
502
|
-
minValue:
|
|
503
|
-
maxValue:
|
|
504
|
-
showTooltip:
|
|
505
|
-
showLegend:
|
|
545
|
+
colorRange: k,
|
|
546
|
+
minValue: O,
|
|
547
|
+
maxValue: ne,
|
|
548
|
+
showTooltip: K = !0,
|
|
549
|
+
showLegend: F = !0,
|
|
506
550
|
onRegionClick: j,
|
|
507
|
-
onBubbleClick:
|
|
508
|
-
onRegionHover:
|
|
509
|
-
title:
|
|
510
|
-
mapSvg:
|
|
511
|
-
zoomable:
|
|
551
|
+
onBubbleClick: ae,
|
|
552
|
+
onRegionHover: X,
|
|
553
|
+
title: G,
|
|
554
|
+
mapSvg: q,
|
|
555
|
+
zoomable: Z = !1,
|
|
512
556
|
className: T,
|
|
513
|
-
style:
|
|
514
|
-
testId:
|
|
515
|
-
"data-testid":
|
|
557
|
+
style: S,
|
|
558
|
+
testId: Q,
|
|
559
|
+
"data-testid": x,
|
|
516
560
|
...h
|
|
517
561
|
}) => {
|
|
518
|
-
const
|
|
562
|
+
const g = te ?? k ?? Ae, { t: z } = ce(), [d, _] = ee(null), [P, l] = ee(1), [r, v] = ee({ x: 0, y: 0 }), u = oe(null), C = oe(!1), w = oe({ x: 0, y: 0 }), o = O ?? Math.min(...A.map((e) => e.value), ...$.map((e) => e.value)), I = ne ?? Math.max(...A.map((e) => e.value), ...$.map((e) => e.value)), L = W(
|
|
519
563
|
(e) => {
|
|
520
|
-
const
|
|
521
|
-
return
|
|
564
|
+
const n = (e - o) / (I - o), i = Math.min(Math.floor(n * g.length), g.length - 1);
|
|
565
|
+
return g[Math.max(0, i)];
|
|
522
566
|
},
|
|
523
|
-
[
|
|
524
|
-
),
|
|
567
|
+
[o, I, g]
|
|
568
|
+
), R = W(
|
|
525
569
|
(e) => {
|
|
526
|
-
if (!
|
|
570
|
+
if (!K || !d)
|
|
527
571
|
return;
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
(i) => i ? { ...i, x: e.clientX -
|
|
572
|
+
const n = u.current?.getBoundingClientRect();
|
|
573
|
+
n && _(
|
|
574
|
+
(i) => i ? { ...i, x: e.clientX - n.left, y: e.clientY - n.top } : null
|
|
531
575
|
);
|
|
532
576
|
},
|
|
533
|
-
[
|
|
534
|
-
), t =
|
|
535
|
-
(e,
|
|
536
|
-
const i =
|
|
537
|
-
i &&
|
|
538
|
-
x:
|
|
539
|
-
y:
|
|
577
|
+
[K, d]
|
|
578
|
+
), t = W(
|
|
579
|
+
(e, n) => {
|
|
580
|
+
const i = u.current?.getBoundingClientRect();
|
|
581
|
+
i && K && _({
|
|
582
|
+
x: n.clientX - i.left,
|
|
583
|
+
y: n.clientY - i.top,
|
|
540
584
|
content: `${e.name}: ${e.value.toLocaleString()}`
|
|
541
|
-
}),
|
|
585
|
+
}), X?.(e);
|
|
542
586
|
},
|
|
543
|
-
[
|
|
544
|
-
),
|
|
545
|
-
|
|
546
|
-
}, [
|
|
587
|
+
[K, X]
|
|
588
|
+
), M = W(() => {
|
|
589
|
+
_(null), X?.(null);
|
|
590
|
+
}, [X]), N = W(
|
|
547
591
|
(e) => {
|
|
548
|
-
if (!
|
|
592
|
+
if (!Z)
|
|
549
593
|
return;
|
|
550
594
|
e.preventDefault();
|
|
551
|
-
const
|
|
552
|
-
l((i) => Math.min(Math.max(i *
|
|
595
|
+
const n = e.deltaY > 0 ? 0.9 : 1.1;
|
|
596
|
+
l((i) => Math.min(Math.max(i * n, 0.5), 4));
|
|
553
597
|
},
|
|
554
|
-
[
|
|
555
|
-
),
|
|
598
|
+
[Z]
|
|
599
|
+
), J = W(
|
|
556
600
|
(e) => {
|
|
557
|
-
|
|
601
|
+
Z && (C.current = !0, w.current = { x: e.clientX - r.x, y: e.clientY - r.y });
|
|
558
602
|
},
|
|
559
|
-
[
|
|
560
|
-
),
|
|
561
|
-
|
|
562
|
-
}, []),
|
|
563
|
-
|
|
564
|
-
x: e.clientX -
|
|
565
|
-
y: e.clientY -
|
|
603
|
+
[Z, r]
|
|
604
|
+
), y = W(() => {
|
|
605
|
+
C.current = !1;
|
|
606
|
+
}, []), V = W((e) => {
|
|
607
|
+
C.current && v({
|
|
608
|
+
x: e.clientX - w.current.x,
|
|
609
|
+
y: e.clientY - w.current.y
|
|
566
610
|
});
|
|
567
|
-
}, []),
|
|
611
|
+
}, []), D = ie(() => A.length > 0 ? A : [
|
|
568
612
|
{
|
|
569
613
|
id: "mazowieckie",
|
|
570
614
|
name: "Mazowieckie",
|
|
@@ -578,71 +622,71 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
578
622
|
value: 70,
|
|
579
623
|
path: "M300,200 L350,200 L360,260 L310,270 L280,230 Z"
|
|
580
624
|
}
|
|
581
|
-
], [
|
|
582
|
-
return /* @__PURE__ */
|
|
625
|
+
], [A]);
|
|
626
|
+
return /* @__PURE__ */ m(
|
|
583
627
|
"div",
|
|
584
628
|
{
|
|
585
629
|
className: `nice-map-chart ${T || ""}`,
|
|
586
|
-
style: { width:
|
|
587
|
-
"data-testid":
|
|
630
|
+
style: { width: b, ...S },
|
|
631
|
+
"data-testid": x ?? Q,
|
|
588
632
|
...h,
|
|
589
633
|
children: [
|
|
590
|
-
|
|
591
|
-
/* @__PURE__ */
|
|
634
|
+
G && /* @__PURE__ */ a("div", { className: "nice-map-title", children: G }),
|
|
635
|
+
/* @__PURE__ */ a(
|
|
592
636
|
"svg",
|
|
593
637
|
{
|
|
594
|
-
ref:
|
|
595
|
-
width:
|
|
596
|
-
height:
|
|
597
|
-
viewBox:
|
|
638
|
+
ref: u,
|
|
639
|
+
width: b,
|
|
640
|
+
height: H,
|
|
641
|
+
viewBox: Y,
|
|
598
642
|
className: "nice-map-svg",
|
|
599
|
-
onWheel:
|
|
600
|
-
onMouseDown:
|
|
601
|
-
onMouseUp:
|
|
602
|
-
onMouseLeave:
|
|
643
|
+
onWheel: N,
|
|
644
|
+
onMouseDown: J,
|
|
645
|
+
onMouseUp: y,
|
|
646
|
+
onMouseLeave: y,
|
|
603
647
|
onMouseMove: (e) => {
|
|
604
|
-
|
|
648
|
+
R(e), V(e);
|
|
605
649
|
},
|
|
606
|
-
children: /* @__PURE__ */
|
|
607
|
-
|
|
608
|
-
|
|
650
|
+
children: /* @__PURE__ */ m("g", { transform: `translate(${r.x}, ${r.y}) scale(${P})`, children: [
|
|
651
|
+
q && /* @__PURE__ */ a("g", { dangerouslySetInnerHTML: { __html: q } }),
|
|
652
|
+
E === "choropleth" && D.map((e) => /* @__PURE__ */ a(
|
|
609
653
|
"path",
|
|
610
654
|
{
|
|
611
655
|
d: e.path,
|
|
612
|
-
fill: e.color ||
|
|
656
|
+
fill: e.color || L(e.value),
|
|
613
657
|
stroke: "var(--nice-bg-primary, #ffffff)",
|
|
614
658
|
strokeWidth: 1,
|
|
615
659
|
className: "nice-map-region",
|
|
616
660
|
onClick: () => j?.(e),
|
|
617
|
-
onMouseEnter: (
|
|
618
|
-
onMouseLeave:
|
|
661
|
+
onMouseEnter: (n) => t(e, n),
|
|
662
|
+
onMouseLeave: M
|
|
619
663
|
},
|
|
620
664
|
e.id
|
|
621
665
|
)),
|
|
622
|
-
(
|
|
623
|
-
const
|
|
624
|
-
return /* @__PURE__ */
|
|
666
|
+
(E === "bubble" || $.length > 0) && $.map((e) => {
|
|
667
|
+
const n = Math.sqrt((e.value - o) / (I - o)) * 30 + 5;
|
|
668
|
+
return /* @__PURE__ */ a(
|
|
625
669
|
"circle",
|
|
626
670
|
{
|
|
627
671
|
cx: e.lng,
|
|
628
672
|
cy: e.lat,
|
|
629
|
-
r,
|
|
673
|
+
r: n,
|
|
630
674
|
fill: e.color || "var(--nice-color-primary, #3b82f6)",
|
|
631
675
|
fillOpacity: 0.7,
|
|
632
676
|
stroke: "var(--nice-bg-primary, #ffffff)",
|
|
633
677
|
strokeWidth: 1,
|
|
634
678
|
className: "nice-map-bubble",
|
|
635
|
-
onClick: () =>
|
|
679
|
+
onClick: () => ae?.(e),
|
|
636
680
|
onMouseEnter: (i) => {
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
x: i.clientX -
|
|
640
|
-
y: i.clientY -
|
|
681
|
+
const c = u.current?.getBoundingClientRect();
|
|
682
|
+
c && K && _({
|
|
683
|
+
x: i.clientX - c.left,
|
|
684
|
+
y: i.clientY - c.top,
|
|
641
685
|
content: `${e.label || e.id}: ${e.value.toLocaleString()}`
|
|
642
686
|
});
|
|
643
687
|
},
|
|
644
|
-
onMouseLeave:
|
|
645
|
-
children: e.label && /* @__PURE__ */
|
|
688
|
+
onMouseLeave: M,
|
|
689
|
+
children: e.label && /* @__PURE__ */ m("title", { children: [
|
|
646
690
|
e.label,
|
|
647
691
|
": ",
|
|
648
692
|
e.value
|
|
@@ -654,16 +698,16 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
654
698
|
] })
|
|
655
699
|
}
|
|
656
700
|
),
|
|
657
|
-
d && /* @__PURE__ */
|
|
658
|
-
|
|
659
|
-
/* @__PURE__ */
|
|
660
|
-
/* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */
|
|
662
|
-
/* @__PURE__ */
|
|
663
|
-
/* @__PURE__ */
|
|
701
|
+
d && /* @__PURE__ */ a("div", { className: "nice-map-tooltip", style: { left: d.x + 10, top: d.y - 30 }, children: d.content }),
|
|
702
|
+
F && /* @__PURE__ */ m("div", { className: "nice-map-legend", children: [
|
|
703
|
+
/* @__PURE__ */ a("span", { className: "nice-map-legend-title", children: z("charts.value", "Value") }),
|
|
704
|
+
/* @__PURE__ */ a("div", { className: "nice-map-legend-scale", children: g.map((e, n) => /* @__PURE__ */ a("div", { className: "nice-map-legend-item", style: { backgroundColor: e } }, n)) }),
|
|
705
|
+
/* @__PURE__ */ m("div", { className: "nice-map-legend-labels", children: [
|
|
706
|
+
/* @__PURE__ */ a("span", { children: o.toLocaleString() }),
|
|
707
|
+
/* @__PURE__ */ a("span", { children: I.toLocaleString() })
|
|
664
708
|
] })
|
|
665
709
|
] }),
|
|
666
|
-
/* @__PURE__ */
|
|
710
|
+
/* @__PURE__ */ a("style", { children: `
|
|
667
711
|
.nice-map-chart {
|
|
668
712
|
font-family: system-ui, -apple-system, sans-serif;
|
|
669
713
|
background: var(--nice-bg-primary, #ffffff);
|
|
@@ -763,166 +807,166 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
763
807
|
]
|
|
764
808
|
}
|
|
765
809
|
);
|
|
766
|
-
},
|
|
767
|
-
nodes:
|
|
768
|
-
links:
|
|
769
|
-
width:
|
|
770
|
-
height:
|
|
771
|
-
nodeWidth:
|
|
772
|
-
nodePadding:
|
|
773
|
-
showValues:
|
|
774
|
-
showTooltip:
|
|
775
|
-
onNodeClick:
|
|
776
|
-
onLinkClick:
|
|
777
|
-
title:
|
|
778
|
-
className:
|
|
810
|
+
}, Ye = ({
|
|
811
|
+
nodes: E = ze,
|
|
812
|
+
links: A = Ie,
|
|
813
|
+
width: $ = 800,
|
|
814
|
+
height: b = 500,
|
|
815
|
+
nodeWidth: H = 20,
|
|
816
|
+
nodePadding: Y = 10,
|
|
817
|
+
showValues: te = !0,
|
|
818
|
+
showTooltip: k = !0,
|
|
819
|
+
onNodeClick: O,
|
|
820
|
+
onLinkClick: ne,
|
|
821
|
+
title: K,
|
|
822
|
+
className: F,
|
|
779
823
|
style: j,
|
|
780
|
-
testId:
|
|
781
|
-
"data-testid":
|
|
782
|
-
...
|
|
824
|
+
testId: ae,
|
|
825
|
+
"data-testid": X,
|
|
826
|
+
...G
|
|
783
827
|
}) => {
|
|
784
|
-
const [
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
const h = new Set(
|
|
788
|
-
|
|
789
|
-
const
|
|
790
|
-
|
|
791
|
-
const l =
|
|
792
|
-
l.length > 0 && (
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
828
|
+
const [q, Z] = ee(null), T = oe(null), S = ie(() => {
|
|
829
|
+
const x = /* @__PURE__ */ new Map();
|
|
830
|
+
E.forEach((t) => x.set(t.id, t));
|
|
831
|
+
const h = new Set(A.map((t) => t.target)), g = new Set(A.map((t) => t.source)), z = [], d = /* @__PURE__ */ new Map(), _ = E.filter((t) => g.has(t.id) && !h.has(t.id));
|
|
832
|
+
_.length > 0 && (z.push(_.map((t) => t.id)), _.forEach((t) => d.set(t.id, 0)));
|
|
833
|
+
const P = E.filter((t) => g.has(t.id) && h.has(t.id));
|
|
834
|
+
P.length > 0 && (z.push(P.map((t) => t.id)), P.forEach((t) => d.set(t.id, 1)));
|
|
835
|
+
const l = E.filter((t) => !g.has(t.id) && h.has(t.id));
|
|
836
|
+
l.length > 0 && (z.push(l.map((t) => t.id)), l.forEach((t) => d.set(t.id, 2))), z.length === 0 && (z.push(E.map((t) => t.id)), E.forEach((t) => d.set(t.id, 0)));
|
|
837
|
+
const r = /* @__PURE__ */ new Map();
|
|
838
|
+
A.forEach((t) => {
|
|
839
|
+
r.set(t.source, (r.get(t.source) || 0) + t.value), r.set(t.target, (r.get(t.target) || 0) + t.value);
|
|
796
840
|
});
|
|
797
|
-
const
|
|
798
|
-
Math.max(...Array.from(
|
|
799
|
-
const
|
|
800
|
-
let
|
|
801
|
-
t.forEach((
|
|
802
|
-
const e = (
|
|
803
|
-
|
|
841
|
+
const v = 40, u = $ - v * 2, C = b - v * 2, w = z.length > 1 ? u / (z.length - 1) : u, o = /* @__PURE__ */ new Map();
|
|
842
|
+
Math.max(...Array.from(r.values())), z.forEach((t, M) => {
|
|
843
|
+
const N = t.reduce((V, D) => V + (r.get(D) || 0), 0), J = (C - (t.length - 1) * Y) / N;
|
|
844
|
+
let y = v;
|
|
845
|
+
t.forEach((V) => {
|
|
846
|
+
const e = (r.get(V) || 0) * J, n = v + M * w;
|
|
847
|
+
o.set(V, { x: n, y, height: e }), y += e + Y;
|
|
804
848
|
});
|
|
805
849
|
});
|
|
806
|
-
const
|
|
807
|
-
return
|
|
808
|
-
const
|
|
809
|
-
if (!
|
|
850
|
+
const I = [], L = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new Map();
|
|
851
|
+
return A.forEach((t) => {
|
|
852
|
+
const M = o.get(t.source), N = o.get(t.target);
|
|
853
|
+
if (!M || !N)
|
|
810
854
|
return;
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
const
|
|
814
|
-
|
|
815
|
-
const e =
|
|
816
|
-
M ${e} ${
|
|
817
|
-
C ${e + i} ${
|
|
818
|
-
${
|
|
819
|
-
${
|
|
820
|
-
L ${
|
|
821
|
-
C ${
|
|
822
|
-
${e + i} ${
|
|
823
|
-
${e} ${
|
|
855
|
+
const J = r.get(t.source) || 1;
|
|
856
|
+
r.get(t.target);
|
|
857
|
+
const y = t.value / J * M.height, V = M.y + (L.get(t.source) || 0), D = N.y + (R.get(t.target) || 0);
|
|
858
|
+
L.set(t.source, (L.get(t.source) || 0) + y), R.set(t.target, (R.get(t.target) || 0) + y);
|
|
859
|
+
const e = M.x + H, n = N.x, i = (n - e) * 0.5, c = `
|
|
860
|
+
M ${e} ${V}
|
|
861
|
+
C ${e + i} ${V},
|
|
862
|
+
${n - i} ${D},
|
|
863
|
+
${n} ${D}
|
|
864
|
+
L ${n} ${D + y}
|
|
865
|
+
C ${n - i} ${D + y},
|
|
866
|
+
${e + i} ${V + y},
|
|
867
|
+
${e} ${V + y}
|
|
824
868
|
Z
|
|
825
869
|
`;
|
|
826
|
-
|
|
827
|
-
path:
|
|
870
|
+
I.push({
|
|
871
|
+
path: c,
|
|
828
872
|
link: t,
|
|
829
|
-
sourcePos:
|
|
830
|
-
targetPos:
|
|
873
|
+
sourcePos: M,
|
|
874
|
+
targetPos: N
|
|
831
875
|
});
|
|
832
|
-
}), { nodePositions:
|
|
833
|
-
}, [
|
|
834
|
-
(
|
|
835
|
-
const
|
|
836
|
-
|
|
837
|
-
x: h.clientX -
|
|
838
|
-
y: h.clientY -
|
|
839
|
-
content:
|
|
876
|
+
}), { nodePositions: o, linkPaths: I, nodeMap: x, nodeValues: r };
|
|
877
|
+
}, [E, A, $, b, H, Y]), Q = W(
|
|
878
|
+
(x, h) => {
|
|
879
|
+
const g = T.current?.getBoundingClientRect();
|
|
880
|
+
g && k && Z({
|
|
881
|
+
x: h.clientX - g.left,
|
|
882
|
+
y: h.clientY - g.top,
|
|
883
|
+
content: x
|
|
840
884
|
});
|
|
841
885
|
},
|
|
842
|
-
[
|
|
886
|
+
[k]
|
|
843
887
|
);
|
|
844
|
-
return /* @__PURE__ */
|
|
888
|
+
return /* @__PURE__ */ m(
|
|
845
889
|
"div",
|
|
846
890
|
{
|
|
847
|
-
className: `nice-sankey-chart ${
|
|
848
|
-
style: { width:
|
|
849
|
-
"data-testid":
|
|
850
|
-
...
|
|
891
|
+
className: `nice-sankey-chart ${F || ""}`,
|
|
892
|
+
style: { width: $, ...j },
|
|
893
|
+
"data-testid": X ?? ae,
|
|
894
|
+
...G,
|
|
851
895
|
children: [
|
|
852
|
-
|
|
853
|
-
/* @__PURE__ */
|
|
854
|
-
/* @__PURE__ */
|
|
855
|
-
/* @__PURE__ */
|
|
896
|
+
K && /* @__PURE__ */ a("div", { className: "nice-sankey-title", children: K }),
|
|
897
|
+
/* @__PURE__ */ m("svg", { ref: T, width: $, height: b, className: "nice-sankey-svg", children: [
|
|
898
|
+
/* @__PURE__ */ a("defs", { children: S.linkPaths.map((x, h) => /* @__PURE__ */ m("linearGradient", { id: `sankey-gradient-${h}`, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: [
|
|
899
|
+
/* @__PURE__ */ a(
|
|
856
900
|
"stop",
|
|
857
901
|
{
|
|
858
902
|
offset: "0%",
|
|
859
|
-
stopColor:
|
|
903
|
+
stopColor: S.nodeMap.get(x.link.source)?.color || "var(--nice-color-primary, #3b82f6)"
|
|
860
904
|
}
|
|
861
905
|
),
|
|
862
|
-
/* @__PURE__ */
|
|
906
|
+
/* @__PURE__ */ a(
|
|
863
907
|
"stop",
|
|
864
908
|
{
|
|
865
909
|
offset: "100%",
|
|
866
|
-
stopColor:
|
|
910
|
+
stopColor: S.nodeMap.get(x.link.target)?.color || "var(--nice-color-error, #ef4444)"
|
|
867
911
|
}
|
|
868
912
|
)
|
|
869
913
|
] }, h)) }),
|
|
870
|
-
/* @__PURE__ */
|
|
914
|
+
/* @__PURE__ */ a("g", { className: "nice-sankey-links", children: S.linkPaths.map((x, h) => /* @__PURE__ */ a(
|
|
871
915
|
"path",
|
|
872
916
|
{
|
|
873
|
-
d:
|
|
874
|
-
fill:
|
|
917
|
+
d: x.path,
|
|
918
|
+
fill: x.link.color || `url(#sankey-gradient-${h})`,
|
|
875
919
|
fillOpacity: 0.4,
|
|
876
920
|
className: "nice-sankey-link",
|
|
877
|
-
onClick: () =>
|
|
878
|
-
onMouseEnter: (
|
|
879
|
-
`${
|
|
880
|
-
|
|
921
|
+
onClick: () => ne?.(x.link),
|
|
922
|
+
onMouseEnter: (g) => Q(
|
|
923
|
+
`${S.nodeMap.get(x.link.source)?.name} → ${S.nodeMap.get(x.link.target)?.name}: ${x.link.value.toLocaleString()}`,
|
|
924
|
+
g
|
|
881
925
|
),
|
|
882
|
-
onMouseLeave: () =>
|
|
926
|
+
onMouseLeave: () => Z(null)
|
|
883
927
|
},
|
|
884
928
|
h
|
|
885
929
|
)) }),
|
|
886
|
-
/* @__PURE__ */
|
|
887
|
-
const
|
|
888
|
-
return
|
|
889
|
-
/* @__PURE__ */
|
|
930
|
+
/* @__PURE__ */ a("g", { className: "nice-sankey-nodes", children: Array.from(S.nodePositions.entries()).map(([x, h]) => {
|
|
931
|
+
const g = S.nodeMap.get(x);
|
|
932
|
+
return g ? /* @__PURE__ */ m("g", { children: [
|
|
933
|
+
/* @__PURE__ */ a(
|
|
890
934
|
"rect",
|
|
891
935
|
{
|
|
892
936
|
x: h.x,
|
|
893
937
|
y: h.y,
|
|
894
|
-
width:
|
|
938
|
+
width: H,
|
|
895
939
|
height: h.height,
|
|
896
|
-
fill:
|
|
940
|
+
fill: g.color || "var(--nice-color-primary, #3b82f6)",
|
|
897
941
|
rx: 2,
|
|
898
942
|
className: "nice-sankey-node",
|
|
899
|
-
onClick: () =>
|
|
900
|
-
onMouseEnter: (
|
|
901
|
-
`${
|
|
902
|
-
|
|
943
|
+
onClick: () => O?.(g),
|
|
944
|
+
onMouseEnter: (z) => Q(
|
|
945
|
+
`${g.label ?? g.name ?? g.id}: ${S.nodeValues.get(x)?.toLocaleString() || 0}`,
|
|
946
|
+
z
|
|
903
947
|
),
|
|
904
|
-
onMouseLeave: () =>
|
|
948
|
+
onMouseLeave: () => Z(null)
|
|
905
949
|
}
|
|
906
950
|
),
|
|
907
|
-
/* @__PURE__ */
|
|
951
|
+
/* @__PURE__ */ m(
|
|
908
952
|
"text",
|
|
909
953
|
{
|
|
910
|
-
x: h.x +
|
|
954
|
+
x: h.x + H + 6,
|
|
911
955
|
y: h.y + h.height / 2,
|
|
912
956
|
dominantBaseline: "middle",
|
|
913
957
|
fontSize: "12",
|
|
914
958
|
fill: "var(--nice-text-primary, #0f172a)",
|
|
915
959
|
children: [
|
|
916
|
-
|
|
917
|
-
|
|
960
|
+
g.label ?? g.name ?? g.id,
|
|
961
|
+
te && ` (${S.nodeValues.get(x)?.toLocaleString() || 0})`
|
|
918
962
|
]
|
|
919
963
|
}
|
|
920
964
|
)
|
|
921
|
-
] },
|
|
965
|
+
] }, x) : null;
|
|
922
966
|
}) })
|
|
923
967
|
] }),
|
|
924
|
-
|
|
925
|
-
/* @__PURE__ */
|
|
968
|
+
q && /* @__PURE__ */ a("div", { className: "nice-sankey-tooltip", style: { left: q.x + 10, top: q.y - 30 }, children: q.content }),
|
|
969
|
+
/* @__PURE__ */ a("style", { children: `
|
|
926
970
|
.nice-sankey-chart {
|
|
927
971
|
font-family: system-ui, -apple-system, sans-serif;
|
|
928
972
|
background: var(--nice-bg-primary, #ffffff);
|
|
@@ -973,172 +1017,172 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
973
1017
|
]
|
|
974
1018
|
}
|
|
975
1019
|
);
|
|
976
|
-
},
|
|
977
|
-
/* @__PURE__ */
|
|
978
|
-
const { t:
|
|
979
|
-
initialData:
|
|
980
|
-
data:
|
|
981
|
-
maxPoints:
|
|
982
|
-
updateInterval:
|
|
983
|
-
fetchData:
|
|
984
|
-
width:
|
|
985
|
-
height:
|
|
986
|
-
chartType:
|
|
987
|
-
color:
|
|
1020
|
+
}, Oe = /* @__PURE__ */ Object.assign(
|
|
1021
|
+
/* @__PURE__ */ ve((E, A) => {
|
|
1022
|
+
const { t: $ } = ce(), {
|
|
1023
|
+
initialData: b,
|
|
1024
|
+
data: H,
|
|
1025
|
+
maxPoints: Y = 60,
|
|
1026
|
+
updateInterval: te = 1e3,
|
|
1027
|
+
fetchData: k,
|
|
1028
|
+
width: O = 600,
|
|
1029
|
+
height: ne = 200,
|
|
1030
|
+
chartType: K = "line",
|
|
1031
|
+
color: F = "var(--nice-color-primary, #3b82f6)",
|
|
988
1032
|
showGrid: j = !0,
|
|
989
|
-
showTimeAxis:
|
|
990
|
-
showCurrentValue:
|
|
991
|
-
title:
|
|
992
|
-
valueFormatter:
|
|
993
|
-
timeFormatter:
|
|
1033
|
+
showTimeAxis: ae = !0,
|
|
1034
|
+
showCurrentValue: X = !0,
|
|
1035
|
+
title: G,
|
|
1036
|
+
valueFormatter: q = (s) => s.toFixed(2),
|
|
1037
|
+
timeFormatter: Z = (s) => new Date(s).toLocaleTimeString(),
|
|
994
1038
|
onDataUpdate: T,
|
|
995
|
-
paused:
|
|
996
|
-
className:
|
|
997
|
-
style:
|
|
1039
|
+
paused: S,
|
|
1040
|
+
className: Q,
|
|
1041
|
+
style: x,
|
|
998
1042
|
testId: h,
|
|
999
|
-
"data-testid":
|
|
1000
|
-
...
|
|
1001
|
-
} =
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
}, [
|
|
1005
|
-
if (
|
|
1043
|
+
"data-testid": g,
|
|
1044
|
+
...z
|
|
1045
|
+
} = E, [d, _] = ee(b ?? H ?? []), [P, l] = ee(S || !1), r = oe(void 0);
|
|
1046
|
+
fe(() => {
|
|
1047
|
+
S !== void 0 && l(S);
|
|
1048
|
+
}, [S]), fe(() => {
|
|
1049
|
+
if (P || !k)
|
|
1006
1050
|
return;
|
|
1007
1051
|
const s = async () => {
|
|
1008
1052
|
try {
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
const
|
|
1012
|
-
return T?.(
|
|
1053
|
+
const B = await k();
|
|
1054
|
+
_((U) => {
|
|
1055
|
+
const f = [...U, B].slice(-Y);
|
|
1056
|
+
return T?.(f), f;
|
|
1013
1057
|
});
|
|
1014
|
-
} catch (
|
|
1015
|
-
console.error("Failed to fetch realtime data:",
|
|
1058
|
+
} catch (B) {
|
|
1059
|
+
console.error("Failed to fetch realtime data:", B);
|
|
1016
1060
|
}
|
|
1017
1061
|
};
|
|
1018
|
-
return
|
|
1019
|
-
|
|
1062
|
+
return r.current = setInterval(s, te), () => {
|
|
1063
|
+
r.current && clearInterval(r.current);
|
|
1020
1064
|
};
|
|
1021
|
-
}, [
|
|
1022
|
-
const
|
|
1065
|
+
}, [P, k, te, Y, T]);
|
|
1066
|
+
const v = W(
|
|
1023
1067
|
(s) => {
|
|
1024
|
-
|
|
1025
|
-
const
|
|
1026
|
-
return T?.(
|
|
1068
|
+
_((B) => {
|
|
1069
|
+
const U = [...B, s].slice(-Y);
|
|
1070
|
+
return T?.(U), U;
|
|
1027
1071
|
});
|
|
1028
1072
|
},
|
|
1029
|
-
[
|
|
1030
|
-
),
|
|
1031
|
-
|
|
1032
|
-
}, [T]),
|
|
1033
|
-
|
|
1034
|
-
|
|
1073
|
+
[Y, T]
|
|
1074
|
+
), u = W(() => {
|
|
1075
|
+
_([]), T?.([]);
|
|
1076
|
+
}, [T]), C = W(() => l(!0), []), w = W(() => l(!1), []);
|
|
1077
|
+
xe(
|
|
1078
|
+
A,
|
|
1035
1079
|
() => ({
|
|
1036
|
-
addDataPoint:
|
|
1037
|
-
clearData:
|
|
1038
|
-
pause:
|
|
1039
|
-
resume:
|
|
1080
|
+
addDataPoint: v,
|
|
1081
|
+
clearData: u,
|
|
1082
|
+
pause: C,
|
|
1083
|
+
resume: w,
|
|
1040
1084
|
getData: () => d
|
|
1041
1085
|
}),
|
|
1042
|
-
[
|
|
1086
|
+
[v, u, C, w, d]
|
|
1043
1087
|
);
|
|
1044
|
-
const
|
|
1045
|
-
const
|
|
1046
|
-
return
|
|
1047
|
-
},
|
|
1048
|
-
return /* @__PURE__ */
|
|
1088
|
+
const o = { top: 20, right: 60, bottom: ae ? 40 : 20, left: 50 }, I = O - o.left - o.right, L = ne - o.top - o.bottom, R = d.map((s) => s.value), t = R.length ? Math.min(...R) : 0, M = R.length ? Math.max(...R) : 100, J = (M - t || 1) * 0.1, y = t - J, D = M + J - y, e = (s) => {
|
|
1089
|
+
const B = k ? Y - 1 : Math.max(1, d.length - 1);
|
|
1090
|
+
return o.left + s / B * I;
|
|
1091
|
+
}, n = (s) => o.top + L - (s - y) / D * L, i = d.map((s, B) => `${e(B)},${n(s.value)}`).join(" "), c = d.length > 0 ? `M ${e(0)},${o.top + L} L ${i} L ${e(d.length - 1)},${o.top + L} Z` : "", p = d.length > 0 ? d[d.length - 1].value : null;
|
|
1092
|
+
return /* @__PURE__ */ m(
|
|
1049
1093
|
"div",
|
|
1050
1094
|
{
|
|
1051
|
-
className: `nice-realtime-chart ${
|
|
1052
|
-
style: { width:
|
|
1053
|
-
"data-testid":
|
|
1054
|
-
...
|
|
1095
|
+
className: `nice-realtime-chart ${Q || ""}`,
|
|
1096
|
+
style: { width: O, ...x },
|
|
1097
|
+
"data-testid": g ?? h,
|
|
1098
|
+
...z,
|
|
1055
1099
|
children: [
|
|
1056
|
-
/* @__PURE__ */
|
|
1057
|
-
/* @__PURE__ */
|
|
1058
|
-
/* @__PURE__ */
|
|
1059
|
-
/* @__PURE__ */
|
|
1060
|
-
/* @__PURE__ */
|
|
1061
|
-
/* @__PURE__ */
|
|
1100
|
+
/* @__PURE__ */ m("div", { className: "nice-realtime-header", children: [
|
|
1101
|
+
/* @__PURE__ */ a("span", { className: "nice-realtime-title", children: G }),
|
|
1102
|
+
/* @__PURE__ */ m("div", { className: "nice-realtime-controls", children: [
|
|
1103
|
+
/* @__PURE__ */ m("span", { className: `nice-realtime-status ${P ? "paused" : "live"}`, children: [
|
|
1104
|
+
/* @__PURE__ */ a("span", { className: "nice-realtime-status-dot" }),
|
|
1105
|
+
/* @__PURE__ */ a("span", { children: P ? $("charts.paused", "Paused") : $("charts.live", "Live") })
|
|
1062
1106
|
] }),
|
|
1063
|
-
/* @__PURE__ */
|
|
1107
|
+
/* @__PURE__ */ a(
|
|
1064
1108
|
"button",
|
|
1065
1109
|
{
|
|
1066
|
-
className: `nice-realtime-btn ${
|
|
1067
|
-
onClick: () => l(!
|
|
1068
|
-
"aria-label":
|
|
1069
|
-
children: /* @__PURE__ */
|
|
1110
|
+
className: `nice-realtime-btn ${P ? "paused" : ""}`,
|
|
1111
|
+
onClick: () => l(!P),
|
|
1112
|
+
"aria-label": P ? $("charts.resume", "Resume") : $("charts.pause", "Pause"),
|
|
1113
|
+
children: /* @__PURE__ */ a(de, { name: P ? "play" : "pause", size: 14 })
|
|
1070
1114
|
}
|
|
1071
1115
|
),
|
|
1072
|
-
|
|
1116
|
+
X && p !== null && /* @__PURE__ */ a("span", { className: "nice-realtime-value", children: q(p) })
|
|
1073
1117
|
] })
|
|
1074
1118
|
] }),
|
|
1075
|
-
/* @__PURE__ */
|
|
1076
|
-
j && /* @__PURE__ */
|
|
1077
|
-
const
|
|
1078
|
-
return /* @__PURE__ */
|
|
1079
|
-
/* @__PURE__ */
|
|
1119
|
+
/* @__PURE__ */ m("svg", { width: O, height: ne, className: "nice-realtime-svg", children: [
|
|
1120
|
+
j && /* @__PURE__ */ a("g", { className: "nice-realtime-grid", children: [0, 0.25, 0.5, 0.75, 1].map((s, B) => {
|
|
1121
|
+
const U = o.top + L * (1 - s), f = y + D * s;
|
|
1122
|
+
return /* @__PURE__ */ m("g", { children: [
|
|
1123
|
+
/* @__PURE__ */ a(
|
|
1080
1124
|
"line",
|
|
1081
1125
|
{
|
|
1082
|
-
x1:
|
|
1083
|
-
y1:
|
|
1084
|
-
x2:
|
|
1085
|
-
y2:
|
|
1126
|
+
x1: o.left,
|
|
1127
|
+
y1: U,
|
|
1128
|
+
x2: O - o.right,
|
|
1129
|
+
y2: U,
|
|
1086
1130
|
stroke: "var(--nice-border-color, #e5e7eb)",
|
|
1087
1131
|
strokeDasharray: s === 0 ? void 0 : "3"
|
|
1088
1132
|
}
|
|
1089
1133
|
),
|
|
1090
|
-
/* @__PURE__ */
|
|
1134
|
+
/* @__PURE__ */ a(
|
|
1091
1135
|
"text",
|
|
1092
1136
|
{
|
|
1093
|
-
x:
|
|
1094
|
-
y:
|
|
1137
|
+
x: o.left - 8,
|
|
1138
|
+
y: U,
|
|
1095
1139
|
textAnchor: "end",
|
|
1096
1140
|
dominantBaseline: "middle",
|
|
1097
1141
|
fontSize: "10",
|
|
1098
1142
|
fill: "var(--nice-text-secondary, #6b7280)",
|
|
1099
|
-
children: Math.round(
|
|
1143
|
+
children: Math.round(f).toLocaleString()
|
|
1100
1144
|
}
|
|
1101
1145
|
)
|
|
1102
|
-
] },
|
|
1146
|
+
] }, B);
|
|
1103
1147
|
}) }),
|
|
1104
|
-
|
|
1105
|
-
d.length > 1 && /* @__PURE__ */
|
|
1148
|
+
K === "area" && d.length > 0 && /* @__PURE__ */ a("path", { d: c, fill: F, fillOpacity: 0.2 }),
|
|
1149
|
+
d.length > 1 && /* @__PURE__ */ a(
|
|
1106
1150
|
"polyline",
|
|
1107
1151
|
{
|
|
1108
1152
|
points: i,
|
|
1109
1153
|
fill: "none",
|
|
1110
|
-
stroke:
|
|
1154
|
+
stroke: F,
|
|
1111
1155
|
strokeWidth: 2,
|
|
1112
1156
|
strokeLinecap: "round",
|
|
1113
1157
|
strokeLinejoin: "round"
|
|
1114
1158
|
}
|
|
1115
1159
|
),
|
|
1116
|
-
d.length > 0 && /* @__PURE__ */
|
|
1160
|
+
d.length > 0 && /* @__PURE__ */ a(
|
|
1117
1161
|
"circle",
|
|
1118
1162
|
{
|
|
1119
1163
|
cx: e(d.length - 1),
|
|
1120
|
-
cy:
|
|
1164
|
+
cy: n(d[d.length - 1].value),
|
|
1121
1165
|
r: 3,
|
|
1122
|
-
fill:
|
|
1166
|
+
fill: F,
|
|
1123
1167
|
className: "nice-realtime-point"
|
|
1124
1168
|
}
|
|
1125
1169
|
),
|
|
1126
|
-
|
|
1170
|
+
ae && d.length > 0 && /* @__PURE__ */ a("g", { className: "nice-realtime-time-axis", children: Array.from(
|
|
1127
1171
|
new Set([0, Math.floor(d.length / 2), d.length - 1].filter((s) => d[s]))
|
|
1128
|
-
).map((s) => /* @__PURE__ */
|
|
1172
|
+
).map((s) => /* @__PURE__ */ a(
|
|
1129
1173
|
"text",
|
|
1130
1174
|
{
|
|
1131
1175
|
x: e(s),
|
|
1132
|
-
y:
|
|
1176
|
+
y: ne - 8,
|
|
1133
1177
|
textAnchor: "middle",
|
|
1134
1178
|
fontSize: "10",
|
|
1135
1179
|
fill: "var(--nice-text-secondary, #6b7280)",
|
|
1136
|
-
children:
|
|
1180
|
+
children: Z(d[s].timestamp)
|
|
1137
1181
|
},
|
|
1138
1182
|
`tx-${s}`
|
|
1139
1183
|
)) })
|
|
1140
1184
|
] }),
|
|
1141
|
-
/* @__PURE__ */
|
|
1185
|
+
/* @__PURE__ */ a("style", { children: `
|
|
1142
1186
|
.nice-realtime-chart {
|
|
1143
1187
|
font-family: inherit;
|
|
1144
1188
|
color: var(--nice-text-primary, #111827);
|
|
@@ -1180,7 +1224,7 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
1180
1224
|
.nice-realtime-value {
|
|
1181
1225
|
font-size: 18px;
|
|
1182
1226
|
font-weight: 600;
|
|
1183
|
-
color: ${
|
|
1227
|
+
color: ${F};
|
|
1184
1228
|
font-variant-numeric: tabular-nums;
|
|
1185
1229
|
}
|
|
1186
1230
|
|
|
@@ -1223,178 +1267,178 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
1223
1267
|
);
|
|
1224
1268
|
}),
|
|
1225
1269
|
{ displayName: "NiceRealtimeChart" }
|
|
1226
|
-
),
|
|
1227
|
-
data:
|
|
1228
|
-
width:
|
|
1229
|
-
height:
|
|
1230
|
-
showLabels:
|
|
1231
|
-
showValues:
|
|
1232
|
-
onNodeClick:
|
|
1233
|
-
drilldownEnabled:
|
|
1234
|
-
colors:
|
|
1235
|
-
tilePadding:
|
|
1236
|
-
className:
|
|
1237
|
-
style:
|
|
1238
|
-
testId:
|
|
1270
|
+
), Xe = ({
|
|
1271
|
+
data: E,
|
|
1272
|
+
width: A = 600,
|
|
1273
|
+
height: $ = 400,
|
|
1274
|
+
showLabels: b = !0,
|
|
1275
|
+
showValues: H = !0,
|
|
1276
|
+
onNodeClick: Y,
|
|
1277
|
+
drilldownEnabled: te = !0,
|
|
1278
|
+
colors: k = ye,
|
|
1279
|
+
tilePadding: O = 2,
|
|
1280
|
+
className: ne,
|
|
1281
|
+
style: K,
|
|
1282
|
+
testId: F,
|
|
1239
1283
|
"data-testid": j,
|
|
1240
|
-
...
|
|
1284
|
+
...ae
|
|
1241
1285
|
}) => {
|
|
1242
|
-
const { t:
|
|
1286
|
+
const { t: X } = ce(), G = ie(() => Array.isArray(E) ? {
|
|
1243
1287
|
id: "root",
|
|
1244
1288
|
name: "Root",
|
|
1245
|
-
value:
|
|
1246
|
-
children:
|
|
1247
|
-
id: `${
|
|
1248
|
-
name: l.label ?? l.name ?? `Item ${
|
|
1289
|
+
value: E.reduce((l, r) => l + (r.value || 0), 0),
|
|
1290
|
+
children: E.map((l, r) => ({
|
|
1291
|
+
id: `${r}`,
|
|
1292
|
+
name: l.label ?? l.name ?? `Item ${r + 1}`,
|
|
1249
1293
|
value: l.value,
|
|
1250
1294
|
color: l.color
|
|
1251
1295
|
}))
|
|
1252
|
-
} :
|
|
1253
|
-
const
|
|
1254
|
-
if (
|
|
1296
|
+
} : E, [E]), [q, Z] = ee(G), [T, S] = ee([G.name]), [Q, x] = ee(null), h = oe(null), g = ie(() => {
|
|
1297
|
+
const r = q.children || [];
|
|
1298
|
+
if (r.length === 0)
|
|
1255
1299
|
return [];
|
|
1256
|
-
const
|
|
1300
|
+
const v = r.reduce((t, M) => t + M.value, 0), u = r.map((t) => ({
|
|
1257
1301
|
node: t,
|
|
1258
|
-
area: t.value /
|
|
1302
|
+
area: t.value / v * A * $
|
|
1259
1303
|
}));
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1262
|
-
let
|
|
1263
|
-
for (;
|
|
1264
|
-
const t =
|
|
1265
|
-
let
|
|
1266
|
-
const
|
|
1267
|
-
for (let
|
|
1268
|
-
const e = [...
|
|
1269
|
-
if (
|
|
1270
|
-
|
|
1304
|
+
u.sort((t, M) => M.area - t.area);
|
|
1305
|
+
const C = [];
|
|
1306
|
+
let w = 0, o = 0, I = A, L = $, R = 0;
|
|
1307
|
+
for (; R < u.length; ) {
|
|
1308
|
+
const t = I < L;
|
|
1309
|
+
let M = 0, N = [];
|
|
1310
|
+
const J = t ? L : I;
|
|
1311
|
+
for (let D = R; D < u.length; D++) {
|
|
1312
|
+
const e = [...N, u[D]], n = e.reduce((c, p) => c + p.area, 0), i = z(e, n, J);
|
|
1313
|
+
if (N.length === 0)
|
|
1314
|
+
N = e, M = n;
|
|
1271
1315
|
else {
|
|
1272
|
-
const
|
|
1273
|
-
if (i <=
|
|
1274
|
-
|
|
1316
|
+
const c = z(N, M, J);
|
|
1317
|
+
if (i <= c)
|
|
1318
|
+
N = e, M = n;
|
|
1275
1319
|
else
|
|
1276
1320
|
break;
|
|
1277
1321
|
}
|
|
1278
1322
|
}
|
|
1279
|
-
const
|
|
1280
|
-
let
|
|
1281
|
-
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1284
|
-
node:
|
|
1285
|
-
x: t ?
|
|
1286
|
-
y: t ?
|
|
1287
|
-
w: t ?
|
|
1288
|
-
h: t ?
|
|
1289
|
-
color:
|
|
1290
|
-
}),
|
|
1291
|
-
}), t ? (
|
|
1323
|
+
const y = M / J;
|
|
1324
|
+
let V = 0;
|
|
1325
|
+
N.forEach((D, e) => {
|
|
1326
|
+
const n = D.area / y;
|
|
1327
|
+
C.push({
|
|
1328
|
+
node: D.node,
|
|
1329
|
+
x: t ? w : w + V,
|
|
1330
|
+
y: t ? o + V : o,
|
|
1331
|
+
w: t ? y : n,
|
|
1332
|
+
h: t ? n : y,
|
|
1333
|
+
color: D.node.color || k[(R + e) % k.length]
|
|
1334
|
+
}), V += n;
|
|
1335
|
+
}), t ? (w += y, I -= y) : (o += y, L -= y), R += N.length;
|
|
1292
1336
|
}
|
|
1293
|
-
return
|
|
1294
|
-
}, [
|
|
1295
|
-
function
|
|
1296
|
-
const
|
|
1297
|
-
let
|
|
1298
|
-
for (const
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1337
|
+
return C;
|
|
1338
|
+
}, [q, A, $, k]);
|
|
1339
|
+
function z(l, r, v) {
|
|
1340
|
+
const u = r / v;
|
|
1341
|
+
let C = 0;
|
|
1342
|
+
for (const w of l) {
|
|
1343
|
+
const o = w.area / u, I = Math.max(u / o, o / u);
|
|
1344
|
+
C = Math.max(C, I);
|
|
1301
1345
|
}
|
|
1302
|
-
return
|
|
1346
|
+
return C;
|
|
1303
1347
|
}
|
|
1304
1348
|
const d = (l) => {
|
|
1305
|
-
|
|
1306
|
-
},
|
|
1349
|
+
Y?.(l, [...T, l.name]), te && l.children && l.children.length > 0 && (Z(l), S((r) => [...r, l.name]));
|
|
1350
|
+
}, _ = () => {
|
|
1307
1351
|
if (T.length <= 1)
|
|
1308
1352
|
return;
|
|
1309
|
-
let l =
|
|
1310
|
-
const
|
|
1311
|
-
for (let
|
|
1312
|
-
const
|
|
1313
|
-
|
|
1353
|
+
let l = G;
|
|
1354
|
+
const r = T.slice(0, -1);
|
|
1355
|
+
for (let v = 1; v < r.length; v++) {
|
|
1356
|
+
const u = l.children?.find((C) => C.name === r[v]);
|
|
1357
|
+
u && (l = u);
|
|
1314
1358
|
}
|
|
1315
|
-
|
|
1316
|
-
},
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
x:
|
|
1320
|
-
y:
|
|
1359
|
+
Z(l), S(r);
|
|
1360
|
+
}, P = (l, r) => {
|
|
1361
|
+
const v = h.current?.getBoundingClientRect();
|
|
1362
|
+
v && x({
|
|
1363
|
+
x: r.clientX - v.left,
|
|
1364
|
+
y: r.clientY - v.top,
|
|
1321
1365
|
content: l
|
|
1322
1366
|
});
|
|
1323
1367
|
};
|
|
1324
|
-
return /* @__PURE__ */
|
|
1368
|
+
return /* @__PURE__ */ m(
|
|
1325
1369
|
"div",
|
|
1326
1370
|
{
|
|
1327
|
-
className: `nice-treemap-chart ${
|
|
1328
|
-
style: { width:
|
|
1329
|
-
"data-testid": j ??
|
|
1330
|
-
...
|
|
1371
|
+
className: `nice-treemap-chart ${ne || ""}`,
|
|
1372
|
+
style: { width: A, ...K },
|
|
1373
|
+
"data-testid": j ?? F,
|
|
1374
|
+
...ae,
|
|
1331
1375
|
children: [
|
|
1332
|
-
/* @__PURE__ */
|
|
1333
|
-
T.length > 1 && /* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1376
|
+
/* @__PURE__ */ m("div", { className: "nice-treemap-nav", children: [
|
|
1377
|
+
T.length > 1 && /* @__PURE__ */ m("button", { className: "nice-treemap-back", onClick: _, children: [
|
|
1378
|
+
/* @__PURE__ */ a(de, { name: "arrow-left", size: 14 }),
|
|
1335
1379
|
" ",
|
|
1336
|
-
|
|
1380
|
+
X("charts.back", "Back")
|
|
1337
1381
|
] }),
|
|
1338
|
-
/* @__PURE__ */
|
|
1339
|
-
|
|
1340
|
-
/* @__PURE__ */
|
|
1341
|
-
] },
|
|
1382
|
+
/* @__PURE__ */ a("div", { className: "nice-treemap-breadcrumbs", children: T.map((l, r) => /* @__PURE__ */ m(ge.Fragment, { children: [
|
|
1383
|
+
r > 0 && /* @__PURE__ */ a("span", { className: "nice-treemap-sep", children: "/" }),
|
|
1384
|
+
/* @__PURE__ */ a("span", { className: r === T.length - 1 ? "current" : "", children: l })
|
|
1385
|
+
] }, r)) })
|
|
1342
1386
|
] }),
|
|
1343
|
-
/* @__PURE__ */
|
|
1344
|
-
const { node:
|
|
1345
|
-
return /* @__PURE__ */
|
|
1387
|
+
/* @__PURE__ */ a("svg", { ref: h, width: A, height: $, className: "nice-treemap-svg", children: g.map((l, r) => {
|
|
1388
|
+
const { node: v, x: u, y: C, w, h: o, color: I } = l, L = Math.min(14, Math.max(10, Math.min(w, o) / 6)), R = w > 40 && o > 30;
|
|
1389
|
+
return /* @__PURE__ */ m(
|
|
1346
1390
|
"g",
|
|
1347
1391
|
{
|
|
1348
|
-
onClick: () => d(
|
|
1349
|
-
onMouseEnter: (t) =>
|
|
1350
|
-
onMouseLeave: () =>
|
|
1392
|
+
onClick: () => d(v),
|
|
1393
|
+
onMouseEnter: (t) => P(`${v.name}: ${v.value.toLocaleString()}`, t),
|
|
1394
|
+
onMouseLeave: () => x(null),
|
|
1351
1395
|
children: [
|
|
1352
|
-
/* @__PURE__ */
|
|
1396
|
+
/* @__PURE__ */ a(
|
|
1353
1397
|
"rect",
|
|
1354
1398
|
{
|
|
1355
|
-
x:
|
|
1356
|
-
y:
|
|
1357
|
-
width: Math.max(0,
|
|
1358
|
-
height: Math.max(0,
|
|
1359
|
-
fill:
|
|
1399
|
+
x: u + O / 2,
|
|
1400
|
+
y: C + O / 2,
|
|
1401
|
+
width: Math.max(0, w - O),
|
|
1402
|
+
height: Math.max(0, o - O),
|
|
1403
|
+
fill: I,
|
|
1360
1404
|
rx: 4,
|
|
1361
1405
|
className: "nice-treemap-tile"
|
|
1362
1406
|
}
|
|
1363
1407
|
),
|
|
1364
|
-
|
|
1408
|
+
b && R && /* @__PURE__ */ a(
|
|
1365
1409
|
"text",
|
|
1366
1410
|
{
|
|
1367
|
-
x:
|
|
1368
|
-
y:
|
|
1411
|
+
x: u + w / 2,
|
|
1412
|
+
y: C + o / 2 - (H ? 6 : 0),
|
|
1369
1413
|
textAnchor: "middle",
|
|
1370
1414
|
dominantBaseline: "middle",
|
|
1371
|
-
fontSize:
|
|
1415
|
+
fontSize: L,
|
|
1372
1416
|
fill: "white",
|
|
1373
1417
|
fontWeight: "500",
|
|
1374
1418
|
style: { pointerEvents: "none" },
|
|
1375
|
-
children:
|
|
1419
|
+
children: v.name.length > w / L + 2 ? v.name.slice(0, Math.floor(w / L)) + "..." : v.name
|
|
1376
1420
|
}
|
|
1377
1421
|
),
|
|
1378
|
-
|
|
1422
|
+
H && R && /* @__PURE__ */ a(
|
|
1379
1423
|
"text",
|
|
1380
1424
|
{
|
|
1381
|
-
x:
|
|
1382
|
-
y:
|
|
1425
|
+
x: u + w / 2,
|
|
1426
|
+
y: C + o / 2 + 10,
|
|
1383
1427
|
textAnchor: "middle",
|
|
1384
1428
|
dominantBaseline: "middle",
|
|
1385
|
-
fontSize:
|
|
1429
|
+
fontSize: L - 2,
|
|
1386
1430
|
fill: "var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",
|
|
1387
1431
|
style: { pointerEvents: "none" },
|
|
1388
|
-
children:
|
|
1432
|
+
children: v.value.toLocaleString()
|
|
1389
1433
|
}
|
|
1390
1434
|
)
|
|
1391
1435
|
]
|
|
1392
1436
|
},
|
|
1393
|
-
|
|
1437
|
+
r
|
|
1394
1438
|
);
|
|
1395
1439
|
}) }),
|
|
1396
|
-
|
|
1397
|
-
/* @__PURE__ */
|
|
1440
|
+
Q && /* @__PURE__ */ a("div", { className: "nice-treemap-tooltip", style: { left: Q.x + 10, top: Q.y - 30 }, children: Q.content }),
|
|
1441
|
+
/* @__PURE__ */ a("style", { children: `
|
|
1398
1442
|
.nice-treemap-chart {
|
|
1399
1443
|
font-family: system-ui, -apple-system, sans-serif;
|
|
1400
1444
|
background: var(--nice-bg-primary, #ffffff);
|
|
@@ -1469,9 +1513,9 @@ const $e = [], Le = [], Ce = [], ge = [
|
|
|
1469
1513
|
);
|
|
1470
1514
|
};
|
|
1471
1515
|
export {
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1516
|
+
Te as NiceDrillDownChart,
|
|
1517
|
+
Be as NiceMapChart,
|
|
1518
|
+
Oe as NiceRealtimeChart,
|
|
1519
|
+
Ye as NiceSankeyChart,
|
|
1520
|
+
Xe as NiceTreeMapChart
|
|
1477
1521
|
};
|