@nice2dev/ui 1.4.22 → 1.4.24

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