@nice2dev/ui 1.4.23 → 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.
@@ -1,7 +1,8 @@
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 = [
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)",
@@ -13,333 +14,333 @@ const ze = [], Ie = [], De = [], ye = [
13
14
  "var(--nice-color-warning, #f59e0b)",
14
15
  "var(--nice-color-accent, #6366f1)"
15
16
  ], 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,
17
+ /* @__PURE__ */ ye((A, Y) => {
18
+ const { t: S } = ue(), {
19
+ levels: x = ze,
20
+ initialLevelId: Q,
21
+ levelId: B,
22
+ chartType: ee = "bar",
23
+ width: w = 600,
24
+ height: D = 400,
25
+ showBreadcrumbs: re = !0,
25
26
  showBackButton: K = !0,
26
- animationDuration: F = 300,
27
+ animationDuration: E = 300,
27
28
  onLevelChange: j,
28
- onItemClick: ae,
29
- colors: X = ye,
30
- showValues: G = !0,
31
- showLegend: q = !0,
32
- className: Z,
29
+ onItemClick: ie,
30
+ colors: P = Re,
31
+ showValues: _ = !0,
32
+ showLegend: ce = !0,
33
+ className: V,
33
34
  style: T,
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(
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(
38
39
  (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];
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
- [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(
49
+ [x]
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(
56
57
  (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));
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
- [b, r, F, j, h, P]
62
- ), L = W(() => {
62
+ [x, r, E, j, F, k]
63
+ ), C = R(() => {
63
64
  if (r.length <= 1)
64
65
  return;
65
- w("out"), u(!0);
66
- const e = r.slice(0, -1), n = e[e.length - 1];
66
+ b("out"), h(!0);
67
+ const e = r.slice(0, -1), a = e[e.length - 1];
67
68
  setTimeout(() => {
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,
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: I,
80
- drillUp: L,
81
- resetToRoot: R,
82
- getCurrentLevel: () => l,
80
+ drillDown: y,
81
+ drillUp: C,
82
+ resetToRoot: f,
83
+ getCurrentLevel: () => z,
83
84
  getPath: () => r
84
85
  }),
85
- [I, L, R, l, r]
86
+ [y, C, f, z, r]
86
87
  );
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);
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);
92
93
  },
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)
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)
102
103
  return null;
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(
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;
107
+ return /* @__PURE__ */ u(
107
108
  "div",
108
109
  {
109
110
  role: "button",
110
111
  tabIndex: 0,
111
- onKeyDown: ue,
112
+ onKeyDown: xe,
112
113
  className: "nice-drilldown-bar-row",
113
- onClick: () => t(c, p),
114
+ onClick: () => O(s, c),
114
115
  children: [
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(
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(
117
118
  "div",
118
119
  {
119
120
  className: "nice-drilldown-bar-fill",
120
121
  style: {
121
- width: `${s}%`,
122
- backgroundColor: c.color || X[p % X.length],
123
- height: i
122
+ width: `${i}%`,
123
+ backgroundColor: s.color || P[c % P.length],
124
+ height: o
124
125
  }
125
126
  }
126
127
  ) }),
127
- G && /* @__PURE__ */ a("span", { className: "nice-drilldown-bar-value", children: c.value.toLocaleString() })
128
+ _ && /* @__PURE__ */ t("span", { className: "nice-drilldown-bar-value", children: s.value.toLocaleString() })
128
129
  ]
129
130
  },
130
- p
131
+ c
131
132
  );
132
133
  }) });
133
- }, y = `nice-drill-gaps-${Se().replace(/[^a-zA-Z0-9_-]/g, "")}`, V = () => {
134
- if (!o)
134
+ }, X = `nice-drill-gaps-${Le().replace(/[^a-zA-Z0-9_-]/g, "")}`, U = () => {
135
+ if (!l)
135
136
  return null;
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, {
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, {
141
142
  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
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
- }), 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(
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(
156
157
  "mask",
157
158
  {
158
- id: y,
159
+ id: X,
159
160
  maskUnits: "userSpaceOnUse",
160
161
  x: 0,
161
162
  y: 0,
162
- width: k,
163
- height: n,
163
+ width: w,
164
+ height: a,
164
165
  children: [
165
- /* @__PURE__ */ a("rect", { x: 0, y: 0, width: k, height: n, fill: "white" }),
166
- U.map((f, re) => /* @__PURE__ */ a(
166
+ /* @__PURE__ */ t("rect", { x: 0, y: 0, width: w, height: a, fill: "white" }),
167
+ I.map((p, G) => /* @__PURE__ */ t(
167
168
  "line",
168
169
  {
169
- x1: i,
170
- y1: c,
171
- x2: i + (p + 2) * Math.cos(f),
172
- y2: c + (p + 2) * Math.sin(f),
170
+ x1: o,
171
+ y1: s,
172
+ x2: o + (c + 2) * Math.cos(p),
173
+ y2: s + (c + 2) * Math.sin(p),
173
174
  stroke: "black",
174
175
  strokeWidth: 2
175
176
  },
176
- re
177
+ G
177
178
  ))
178
179
  ]
179
180
  }
180
181
  ) }),
181
- /* @__PURE__ */ a("g", { mask: U.length > 0 ? `url(#${y})` : void 0, children: B.map((f, re) => /* @__PURE__ */ a(
182
+ /* @__PURE__ */ t("g", { mask: I.length > 0 ? `url(#${X})` : void 0, children: N.map((p, G) => /* @__PURE__ */ t(
182
183
  "path",
183
184
  {
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}%)` })
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}%)` })
189
190
  },
190
- re
191
+ G
191
192
  )) }),
192
- G && B.map(
193
- (f, re) => parseFloat(f.percentage) > 5 ? /* @__PURE__ */ m(
193
+ _ && N.map(
194
+ (p, G) => parseFloat(p.percentage) > 5 ? /* @__PURE__ */ u(
194
195
  "text",
195
196
  {
196
- x: f.labelX,
197
- y: f.labelY,
197
+ x: p.labelX,
198
+ y: p.labelY,
198
199
  textAnchor: "middle",
199
200
  dominantBaseline: "middle",
200
201
  className: "nice-piechart__label",
201
202
  style: { fontSize: 13, pointerEvents: "none" },
202
203
  children: [
203
- f.percentage,
204
+ p.percentage,
204
205
  "%"
205
206
  ]
206
207
  },
207
- re
208
+ G
208
209
  ) : null
209
210
  )
210
211
  ] });
211
- }, D = () => {
212
- if (!o)
212
+ }, q = () => {
213
+ if (!l)
213
214
  return null;
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(
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(
218
219
  "line",
219
220
  {
220
221
  x1: 0,
221
- y1: c * (1 - p),
222
- x2: k - 80,
223
- y2: c * (1 - p),
222
+ y1: s * (1 - c),
223
+ x2: w - 80,
224
+ y2: s * (1 - c),
224
225
  stroke: "var(--nice-border-color, #e5e7eb)",
225
- strokeDasharray: p === 0 ? void 0 : "4"
226
+ strokeDasharray: c === 0 ? void 0 : "4"
226
227
  }
227
228
  ),
228
- /* @__PURE__ */ a(
229
+ /* @__PURE__ */ t(
229
230
  "text",
230
231
  {
231
232
  x: -8,
232
- y: c * (1 - p),
233
+ y: s * (1 - c),
233
234
  textAnchor: "end",
234
235
  dominantBaseline: "middle",
235
236
  fontSize: "11",
236
237
  fill: "var(--nice-text-secondary, #6b7280)",
237
- children: Math.round(n * p).toLocaleString()
238
+ children: Math.round(a * c).toLocaleString()
238
239
  }
239
240
  )
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(
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(
245
246
  "rect",
246
247
  {
247
- x: U,
248
- y: c - B,
249
- width: i,
250
- height: B,
251
- fill: p.color || X[s % X.length],
248
+ x: I,
249
+ y: s - N,
250
+ width: o,
251
+ height: N,
252
+ fill: c.color || P[i % P.length],
252
253
  rx: 4,
253
254
  className: "nice-drilldown-column-bar"
254
255
  }
255
256
  ),
256
- /* @__PURE__ */ a(
257
+ /* @__PURE__ */ t(
257
258
  "text",
258
259
  {
259
- x: U + i / 2,
260
- y: c + 16,
260
+ x: I + o / 2,
261
+ y: s + 16,
261
262
  textAnchor: "middle",
262
263
  fontSize: "11",
263
264
  fill: "var(--nice-text-primary, #374151)",
264
- children: (p.label || `${s + 1}`).slice(0, 10)
265
+ children: (c.label || `${i + 1}`).slice(0, 10)
265
266
  }
266
267
  ),
267
- G && /* @__PURE__ */ a(
268
+ _ && /* @__PURE__ */ t(
268
269
  "text",
269
270
  {
270
- x: U + i / 2,
271
- y: c - B - 8,
271
+ x: I + o / 2,
272
+ y: s - N - 8,
272
273
  textAnchor: "middle",
273
274
  fontSize: "11",
274
275
  fill: "var(--nice-text-primary, #374151)",
275
276
  fontWeight: "500",
276
- children: p.value.toLocaleString()
277
+ children: c.value.toLocaleString()
277
278
  }
278
279
  )
279
- ] }, s);
280
+ ] }, i);
280
281
  })
281
282
  ] }) });
282
283
  };
283
- return /* @__PURE__ */ m(
284
+ return /* @__PURE__ */ u(
284
285
  "div",
285
286
  {
286
- className: `nice-drilldown-chart ${v ? `animating ${C}` : ""} ${Z || ""}`,
287
- style: { width: k, ...T },
288
- "data-testid": Q ?? S,
289
- ...x,
287
+ className: `nice-drilldown-chart ${m ? `animating ${$}` : ""} ${V || ""}`,
288
+ style: { width: w, ...T },
289
+ "data-testid": te ?? H,
290
+ ...ne,
290
291
  children: [
291
- /* @__PURE__ */ m("div", { className: "nice-drilldown-header", children: [
292
- K && /* @__PURE__ */ m(
292
+ /* @__PURE__ */ u("div", { className: "nice-drilldown-header", children: [
293
+ K && /* @__PURE__ */ u(
293
294
  "button",
294
295
  {
295
296
  type: "button",
296
297
  className: "nice-drilldown-back",
297
- onClick: L,
298
+ onClick: C,
298
299
  disabled: r.length <= 1,
299
300
  children: [
300
- /* @__PURE__ */ a(de, { name: "arrow-left", size: 14 }),
301
+ /* @__PURE__ */ t(ge, { name: "arrow-left", size: 14 }),
301
302
  " ",
302
- $("charts.back", "Back")
303
+ S("charts.back", "Back")
303
304
  ]
304
305
  }
305
306
  ),
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(
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(
309
310
  "span",
310
311
  {
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" : ""}`,
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" : ""}`,
316
317
  onClick: () => {
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);
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);
320
321
  }
321
322
  },
322
323
  children: e
323
324
  }
324
325
  )
325
- ] }, n)) })
326
+ ] }, a)) })
326
327
  ] }),
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()
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()
331
332
  ] }),
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(
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(
334
335
  "span",
335
336
  {
336
337
  className: "nice-drilldown-legend-color",
337
- style: { backgroundColor: e.color || X[n % X.length] }
338
+ style: { backgroundColor: e.color || P[a % P.length] }
338
339
  }
339
340
  ),
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: `
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: `
343
344
  .nice-drilldown-chart {
344
345
  font-family: inherit;
345
346
  color: var(--nice-text-primary, #111827);
@@ -526,188 +527,205 @@ const ze = [], Ie = [], De = [], ye = [
526
527
  );
527
528
  }),
528
529
  { displayName: "NiceDrillDownChart" }
529
- ), Ae = [
530
- "var(--nice-info-bg, #dbeafe)",
531
- "var(--nice-color-primary-light, #93c5fd)",
532
- "var(--nice-color-primary, #3b82f6)",
533
- "var(--nice-color-primary-active, #1d4ed8)",
534
- "var(--nice-color-primary, #6366f1)"
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,
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 = [],
536
+ width: x = 800,
537
+ height: Q = 500,
538
+ viewBox: B = "0 0 800 500",
539
+ colorScale: ee,
543
540
  // The documented alias of `colorScale`. It was never destructured, so it did nothing
544
541
  // and fell through `...rest` onto the root div (React warned about an unknown prop).
545
- colorRange: k,
546
- minValue: O,
547
- maxValue: ne,
542
+ colorRange: w,
543
+ minValue: D,
544
+ maxValue: re,
548
545
  showTooltip: K = !0,
549
- showLegend: F = !0,
546
+ showLegend: E = !0,
550
547
  onRegionClick: j,
551
- onBubbleClick: ae,
552
- onRegionHover: X,
553
- title: G,
554
- mapSvg: q,
555
- zoomable: Z = !1,
556
- className: T,
557
- style: S,
558
- testId: Q,
559
- "data-testid": x,
560
- ...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
561
560
  }) => {
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(
563
- (e) => {
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)];
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)];
566
573
  },
567
- [o, I, g]
568
- ), R = W(
569
- (e) => {
570
- if (!K || !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)
571
586
  return;
572
- const n = u.current?.getBoundingClientRect();
573
- n && _(
574
- (i) => i ? { ...i, x: e.clientX - n.left, y: e.clientY - n.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
575
590
  );
576
591
  },
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,
584
- content: `${e.name}: ${e.value.toLocaleString()}`
585
- }), X?.(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);
586
601
  },
587
- [K, X]
588
- ), M = W(() => {
589
- _(null), X?.(null);
590
- }, [X]), N = W(
591
- (e) => {
592
- if (!Z)
602
+ [K, P]
603
+ ), i = R(() => {
604
+ z(null), P?.(null);
605
+ }, [P]), N = R(
606
+ (n) => {
607
+ if (!V)
593
608
  return;
594
- e.preventDefault();
595
- const n = e.deltaY > 0 ? 0.9 : 1.1;
596
- l((i) => Math.min(Math.max(i * n, 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));
597
612
  },
598
- [Z]
599
- ), J = W(
600
- (e) => {
601
- Z && (C.current = !0, w.current = { x: e.clientX - r.x, y: e.clientY - r.y });
613
+ [V]
614
+ ), I = R(
615
+ (n) => {
616
+ V && (l.current = !0, y.current = { x: n.clientX, y: n.clientY }, C.current = h);
602
617
  },
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
610
- });
611
- }, []), D = ie(() => A.length > 0 ? A : [
612
- {
613
- id: "mazowieckie",
614
- name: "Mazowieckie",
615
- value: 100,
616
- 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
+ });
617
630
  },
618
- { id: "slaskie", name: "Śląskie", value: 80, path: "M350,280 L400,280 L390,330 L340,320 Z" },
619
- {
620
- id: "wielkopolskie",
621
- name: "Wielkopolskie",
622
- value: 70,
623
- path: "M300,200 L350,200 L360,260 L310,270 L280,230 Z"
624
- }
625
- ], [A]);
626
- return /* @__PURE__ */ m(
631
+ [e]
632
+ ), me = Y;
633
+ return /* @__PURE__ */ u(
627
634
  "div",
628
635
  {
629
- className: `nice-map-chart ${T || ""}`,
630
- style: { width: b, ...S },
631
- "data-testid": x ?? Q,
632
- ...h,
636
+ className: `nice-map-chart ${te || ""}`,
637
+ style: { width: x, ...ne },
638
+ "data-testid": le ?? F,
639
+ ...ae,
633
640
  children: [
634
- G && /* @__PURE__ */ a("div", { className: "nice-map-title", children: G }),
635
- /* @__PURE__ */ a(
641
+ _ && /* @__PURE__ */ t("div", { className: "nice-map-title", children: _ }),
642
+ /* @__PURE__ */ t(
636
643
  "svg",
637
644
  {
638
- ref: u,
639
- width: b,
640
- height: H,
641
- viewBox: Y,
645
+ ref: b,
646
+ width: x,
647
+ height: Q,
648
+ viewBox: B,
642
649
  className: "nice-map-svg",
643
650
  onWheel: N,
644
- onMouseDown: J,
645
- onMouseUp: y,
646
- onMouseLeave: y,
647
- onMouseMove: (e) => {
648
- R(e), V(e);
651
+ onMouseDown: I,
652
+ onMouseUp: p,
653
+ onMouseLeave: p,
654
+ onMouseMove: (n) => {
655
+ s(n), G(n);
649
656
  },
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(
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(
653
670
  "path",
654
671
  {
655
- d: e.path,
656
- fill: e.color || L(e.value),
657
- stroke: "var(--nice-bg-primary, #ffffff)",
658
- 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,
659
677
  className: "nice-map-region",
660
- onClick: () => j?.(e),
661
- onMouseEnter: (n) => t(e, n),
662
- onMouseLeave: M
678
+ onClick: () => j?.(n),
679
+ onMouseEnter: (v) => c(n, v),
680
+ onMouseLeave: i
663
681
  },
664
- e.id
682
+ n.id
665
683
  )),
666
- (E === "bubble" || $.length > 0) && $.map((e) => {
667
- const n = Math.sqrt((e.value - o) / (I - o)) * 30 + 5;
668
- return /* @__PURE__ */ a(
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(
669
687
  "circle",
670
688
  {
671
- cx: e.lng,
672
- cy: e.lat,
673
- r: n,
674
- 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)",
675
693
  fillOpacity: 0.7,
676
694
  stroke: "var(--nice-bg-primary, #ffffff)",
677
695
  strokeWidth: 1,
678
696
  className: "nice-map-bubble",
679
- onClick: () => ae?.(e),
680
- onMouseEnter: (i) => {
681
- const c = u.current?.getBoundingClientRect();
682
- c && K && _({
683
- x: i.clientX - c.left,
684
- y: i.clientY - c.top,
685
- 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()}`
686
704
  });
687
705
  },
688
- onMouseLeave: M,
689
- children: e.label && /* @__PURE__ */ m("title", { children: [
690
- e.label,
706
+ onMouseLeave: i,
707
+ children: n.label && /* @__PURE__ */ u("title", { children: [
708
+ n.label,
691
709
  ": ",
692
- e.value
710
+ n.value
693
711
  ] })
694
712
  },
695
- e.id
713
+ n.id
696
714
  );
697
715
  })
698
716
  ] })
699
717
  }
700
718
  ),
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() })
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)) }),
723
+ /* @__PURE__ */ u("div", { className: "nice-map-legend-labels", children: [
724
+ /* @__PURE__ */ t("span", { children: f.toLocaleString() }),
725
+ /* @__PURE__ */ t("span", { children: O.toLocaleString() })
708
726
  ] })
709
727
  ] }),
710
- /* @__PURE__ */ a("style", { children: `
728
+ /* @__PURE__ */ t("style", { children: `
711
729
  .nice-map-chart {
712
730
  font-family: system-ui, -apple-system, sans-serif;
713
731
  background: var(--nice-bg-primary, #ffffff);
@@ -807,382 +825,172 @@ const ze = [], Ie = [], De = [], ye = [
807
825
  ]
808
826
  }
809
827
  );
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,
823
- style: j,
824
- testId: ae,
825
- "data-testid": X,
826
- ...G
827
- }) => {
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);
840
- });
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;
848
- });
849
- });
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)
854
- return;
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}
868
- Z
869
- `;
870
- I.push({
871
- path: c,
872
- link: t,
873
- sourcePos: M,
874
- targetPos: N
875
- });
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
884
- });
885
- },
886
- [k]
887
- );
888
- return /* @__PURE__ */ m(
889
- "div",
890
- {
891
- className: `nice-sankey-chart ${F || ""}`,
892
- style: { width: $, ...j },
893
- "data-testid": X ?? ae,
894
- ...G,
895
- children: [
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(
900
- "stop",
901
- {
902
- offset: "0%",
903
- stopColor: S.nodeMap.get(x.link.source)?.color || "var(--nice-color-primary, #3b82f6)"
904
- }
905
- ),
906
- /* @__PURE__ */ a(
907
- "stop",
908
- {
909
- offset: "100%",
910
- stopColor: S.nodeMap.get(x.link.target)?.color || "var(--nice-color-error, #ef4444)"
911
- }
912
- )
913
- ] }, h)) }),
914
- /* @__PURE__ */ a("g", { className: "nice-sankey-links", children: S.linkPaths.map((x, h) => /* @__PURE__ */ a(
915
- "path",
916
- {
917
- d: x.path,
918
- fill: x.link.color || `url(#sankey-gradient-${h})`,
919
- fillOpacity: 0.4,
920
- className: "nice-sankey-link",
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
925
- ),
926
- onMouseLeave: () => Z(null)
927
- },
928
- h
929
- )) }),
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(
934
- "rect",
935
- {
936
- x: h.x,
937
- y: h.y,
938
- width: H,
939
- height: h.height,
940
- fill: g.color || "var(--nice-color-primary, #3b82f6)",
941
- rx: 2,
942
- className: "nice-sankey-node",
943
- onClick: () => O?.(g),
944
- onMouseEnter: (z) => Q(
945
- `${g.label ?? g.name ?? g.id}: ${S.nodeValues.get(x)?.toLocaleString() || 0}`,
946
- z
947
- ),
948
- onMouseLeave: () => Z(null)
949
- }
950
- ),
951
- /* @__PURE__ */ m(
952
- "text",
953
- {
954
- x: h.x + H + 6,
955
- y: h.y + h.height / 2,
956
- dominantBaseline: "middle",
957
- fontSize: "12",
958
- fill: "var(--nice-text-primary, #0f172a)",
959
- children: [
960
- g.label ?? g.name ?? g.id,
961
- te && ` (${S.nodeValues.get(x)?.toLocaleString() || 0})`
962
- ]
963
- }
964
- )
965
- ] }, x) : null;
966
- }) })
967
- ] }),
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: `
970
- .nice-sankey-chart {
971
- font-family: system-ui, -apple-system, sans-serif;
972
- background: var(--nice-bg-primary, #ffffff);
973
- border-radius: var(--nice-radius-lg, 8px);
974
- position: relative;
975
- }
976
-
977
- .nice-sankey-title {
978
- padding: var(--nice-space-3, 12px) var(--nice-space-4, 16px);
979
- font-size: 16px;
980
- font-weight: 600;
981
- color: var(--nice-text-primary, #0f172a);
982
- border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
983
- }
984
-
985
- .nice-sankey-link {
986
- cursor: pointer;
987
- transition: fill-opacity 0.2s;
988
- }
989
-
990
- .nice-sankey-link:hover {
991
- fill-opacity: 0.7;
992
- }
993
-
994
- .nice-sankey-node {
995
- cursor: pointer;
996
- transition: opacity 0.2s;
997
- }
998
-
999
- .nice-sankey-node:hover {
1000
- opacity: 0.8;
1001
- }
1002
-
1003
- .nice-sankey-tooltip {
1004
- position: absolute;
1005
- /* audit-allow: token-role — inverted chip like .nice-tooltip: the text colour is the
1006
- fill and the label uses --nice-text-inverse, so the pair flips together. */
1007
- background: var(--nice-text-primary, #0f172a);
1008
- color: var(--nice-text-inverse, #ffffff);
1009
- padding: var(--nice-space-1-5, 6px) var(--nice-space-2-5, 10px);
1010
- border-radius: var(--nice-radius-sm, 4px);
1011
- font-size: 12px;
1012
- pointer-events: none;
1013
- z-index: 10;
1014
- white-space: nowrap;
1015
- }
1016
- ` })
1017
- ]
1018
- }
1019
- );
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,
828
+ }, Fe = /* @__PURE__ */ Object.assign(
829
+ /* @__PURE__ */ ye((A, Y) => {
830
+ const { t: S } = ue(), {
831
+ initialData: x,
832
+ data: Q,
833
+ maxPoints: B = 60,
834
+ updateInterval: ee = 1e3,
835
+ fetchData: w,
836
+ width: D = 600,
837
+ height: re = 200,
1030
838
  chartType: K = "line",
1031
- color: F = "var(--nice-color-primary, #3b82f6)",
839
+ color: E = "var(--nice-color-primary, #3b82f6)",
1032
840
  showGrid: j = !0,
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(),
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(),
1038
846
  onDataUpdate: T,
1039
- paused: S,
1040
- className: Q,
1041
- style: x,
1042
- testId: h,
1043
- "data-testid": g,
1044
- ...z
1045
- } = E, [d, _] = ee(b ?? H ?? []), [P, l] = ee(S || !1), r = oe(void 0);
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);
1046
854
  fe(() => {
1047
- S !== void 0 && l(S);
1048
- }, [S]), fe(() => {
1049
- if (P || !k)
855
+ H !== void 0 && z(H);
856
+ }, [H]), fe(() => {
857
+ if (k || !w)
1050
858
  return;
1051
- const s = async () => {
859
+ const i = async () => {
1052
860
  try {
1053
- const B = await k();
1054
- _((U) => {
1055
- const f = [...U, B].slice(-Y);
1056
- return T?.(f), f;
861
+ const N = await w();
862
+ Z((I) => {
863
+ const p = [...I, N].slice(-B);
864
+ return T?.(p), p;
1057
865
  });
1058
- } catch (B) {
1059
- console.error("Failed to fetch realtime data:", B);
866
+ } catch (N) {
867
+ console.error("Failed to fetch realtime data:", N);
1060
868
  }
1061
869
  };
1062
- return r.current = setInterval(s, te), () => {
870
+ return r.current = setInterval(i, ee), () => {
1063
871
  r.current && clearInterval(r.current);
1064
872
  };
1065
- }, [P, k, te, Y, T]);
1066
- const v = W(
1067
- (s) => {
1068
- _((B) => {
1069
- const U = [...B, s].slice(-Y);
1070
- return T?.(U), U;
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;
1071
879
  });
1072
880
  },
1073
- [Y, T]
1074
- ), u = W(() => {
1075
- _([]), T?.([]);
1076
- }, [T]), C = W(() => l(!0), []), w = W(() => l(!1), []);
1077
- xe(
1078
- A,
881
+ [B, T]
882
+ ), h = R(() => {
883
+ Z([]), T?.([]);
884
+ }, [T]), $ = R(() => z(!0), []), b = R(() => z(!1), []);
885
+ we(
886
+ Y,
1079
887
  () => ({
1080
- addDataPoint: v,
1081
- clearData: u,
1082
- pause: C,
1083
- resume: w,
888
+ addDataPoint: m,
889
+ clearData: h,
890
+ pause: $,
891
+ resume: b,
1084
892
  getData: () => d
1085
893
  }),
1086
- [v, u, C, w, d]
894
+ [m, h, $, b, d]
1087
895
  );
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(
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;
900
+ return /* @__PURE__ */ u(
1093
901
  "div",
1094
902
  {
1095
- className: `nice-realtime-chart ${Q || ""}`,
1096
- style: { width: O, ...x },
1097
- "data-testid": g ?? h,
1098
- ...z,
903
+ className: `nice-realtime-chart ${te || ""}`,
904
+ style: { width: D, ...ne },
905
+ "data-testid": le ?? F,
906
+ ...ae,
1099
907
  children: [
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") })
908
+ /* @__PURE__ */ u("div", { className: "nice-realtime-header", children: [
909
+ /* @__PURE__ */ t("span", { className: "nice-realtime-title", children: _ }),
910
+ /* @__PURE__ */ u("div", { className: "nice-realtime-controls", children: [
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") })
1106
914
  ] }),
1107
- /* @__PURE__ */ a(
915
+ /* @__PURE__ */ t(
1108
916
  "button",
1109
917
  {
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 })
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 })
1114
922
  }
1115
923
  ),
1116
- X && p !== null && /* @__PURE__ */ a("span", { className: "nice-realtime-value", children: q(p) })
924
+ P && c !== null && /* @__PURE__ */ t("span", { className: "nice-realtime-value", children: ce(c) })
1117
925
  ] })
1118
926
  ] }),
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(
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;
930
+ return /* @__PURE__ */ u("g", { children: [
931
+ /* @__PURE__ */ t(
1124
932
  "line",
1125
933
  {
1126
- x1: o.left,
1127
- y1: U,
1128
- x2: O - o.right,
1129
- y2: U,
934
+ x1: l.left,
935
+ y1: I,
936
+ x2: D - l.right,
937
+ y2: I,
1130
938
  stroke: "var(--nice-border-color, #e5e7eb)",
1131
- strokeDasharray: s === 0 ? void 0 : "3"
939
+ strokeDasharray: i === 0 ? void 0 : "3"
1132
940
  }
1133
941
  ),
1134
- /* @__PURE__ */ a(
942
+ /* @__PURE__ */ t(
1135
943
  "text",
1136
944
  {
1137
- x: o.left - 8,
1138
- y: U,
945
+ x: l.left - 8,
946
+ y: I,
1139
947
  textAnchor: "end",
1140
948
  dominantBaseline: "middle",
1141
949
  fontSize: "10",
1142
950
  fill: "var(--nice-text-secondary, #6b7280)",
1143
- children: Math.round(f).toLocaleString()
951
+ children: Math.round(p).toLocaleString()
1144
952
  }
1145
953
  )
1146
- ] }, B);
954
+ ] }, N);
1147
955
  }) }),
1148
- K === "area" && d.length > 0 && /* @__PURE__ */ a("path", { d: c, fill: F, fillOpacity: 0.2 }),
1149
- d.length > 1 && /* @__PURE__ */ a(
956
+ K === "area" && d.length > 0 && /* @__PURE__ */ t("path", { d: s, fill: E, fillOpacity: 0.2 }),
957
+ d.length > 1 && /* @__PURE__ */ t(
1150
958
  "polyline",
1151
959
  {
1152
- points: i,
960
+ points: o,
1153
961
  fill: "none",
1154
- stroke: F,
962
+ stroke: E,
1155
963
  strokeWidth: 2,
1156
964
  strokeLinecap: "round",
1157
965
  strokeLinejoin: "round"
1158
966
  }
1159
967
  ),
1160
- d.length > 0 && /* @__PURE__ */ a(
968
+ d.length > 0 && /* @__PURE__ */ t(
1161
969
  "circle",
1162
970
  {
1163
971
  cx: e(d.length - 1),
1164
- cy: n(d[d.length - 1].value),
972
+ cy: a(d[d.length - 1].value),
1165
973
  r: 3,
1166
- fill: F,
974
+ fill: E,
1167
975
  className: "nice-realtime-point"
1168
976
  }
1169
977
  ),
1170
- ae && d.length > 0 && /* @__PURE__ */ a("g", { className: "nice-realtime-time-axis", children: Array.from(
1171
- new Set([0, Math.floor(d.length / 2), d.length - 1].filter((s) => d[s]))
1172
- ).map((s) => /* @__PURE__ */ a(
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(
1173
981
  "text",
1174
982
  {
1175
- x: e(s),
1176
- y: ne - 8,
983
+ x: e(i),
984
+ y: re - 8,
1177
985
  textAnchor: "middle",
1178
986
  fontSize: "10",
1179
987
  fill: "var(--nice-text-secondary, #6b7280)",
1180
- children: Z(d[s].timestamp)
988
+ children: V(d[i].timestamp)
1181
989
  },
1182
- `tx-${s}`
990
+ `tx-${i}`
1183
991
  )) })
1184
992
  ] }),
1185
- /* @__PURE__ */ a("style", { children: `
993
+ /* @__PURE__ */ t("style", { children: `
1186
994
  .nice-realtime-chart {
1187
995
  font-family: inherit;
1188
996
  color: var(--nice-text-primary, #111827);
@@ -1224,7 +1032,7 @@ const ze = [], Ie = [], De = [], ye = [
1224
1032
  .nice-realtime-value {
1225
1033
  font-size: 18px;
1226
1034
  font-weight: 600;
1227
- color: ${F};
1035
+ color: ${E};
1228
1036
  font-variant-numeric: tabular-nums;
1229
1037
  }
1230
1038
 
@@ -1267,178 +1075,184 @@ const ze = [], Ie = [], De = [], ye = [
1267
1075
  );
1268
1076
  }),
1269
1077
  { displayName: "NiceRealtimeChart" }
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,
1078
+ ), _e = ({
1079
+ data: A,
1080
+ width: Y = 600,
1081
+ height: S = 400,
1082
+ showLabels: x = !0,
1083
+ showValues: Q = !0,
1084
+ onNodeClick: B,
1085
+ drilldownEnabled: ee = !0,
1086
+ colors: w = Ie,
1087
+ tilePadding: D = 2,
1088
+ className: re,
1281
1089
  style: K,
1282
- testId: F,
1090
+ testId: E,
1283
1091
  "data-testid": j,
1284
- ...ae
1092
+ ...ie
1285
1093
  }) => {
1286
- const { t: X } = ce(), G = ie(() => Array.isArray(E) ? {
1094
+ const { t: P } = ue(), _ = de(() => Array.isArray(A) ? {
1287
1095
  id: "root",
1288
1096
  name: "Root",
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}`,
1293
- value: l.value,
1294
- 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
1295
1103
  }))
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)
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)
1299
1118
  return [];
1300
- const v = r.reduce((t, M) => t + M.value, 0), u = r.map((t) => ({
1301
- node: t,
1302
- area: t.value / v * A * $
1119
+ const h = m.reduce((g, L) => g + L.value, 0), $ = m.map((g) => ({
1120
+ node: g,
1121
+ area: g.value / h * Y * S
1303
1122
  }));
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;
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;
1315
1134
  else {
1316
- const c = z(N, M, J);
1317
- if (i <= c)
1318
- N = e, M = n;
1135
+ const c = d(W, L, X);
1136
+ if (s <= c)
1137
+ W = a, L = o;
1319
1138
  else
1320
1139
  break;
1321
1140
  }
1322
1141
  }
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;
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;
1336
1155
  }
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);
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);
1345
1164
  }
1346
- return C;
1165
+ return b;
1347
1166
  }
1348
- const d = (l) => {
1349
- Y?.(l, [...T, l.name]), te && l.children && l.children.length > 0 && (Z(l), S((r) => [...r, l.name]));
1350
- }, _ = () => {
1351
- if (T.length <= 1)
1352
- return;
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);
1358
- }
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,
1365
- 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
1366
1177
  });
1367
1178
  };
1368
- return /* @__PURE__ */ m(
1179
+ return /* @__PURE__ */ u(
1369
1180
  "div",
1370
1181
  {
1371
- className: `nice-treemap-chart ${ne || ""}`,
1372
- style: { width: A, ...K },
1373
- "data-testid": j ?? F,
1374
- ...ae,
1182
+ className: `nice-treemap-chart ${re || ""}`,
1183
+ style: { width: Y, ...K },
1184
+ "data-testid": j ?? E,
1185
+ ...ie,
1375
1186
  children: [
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 }),
1187
+ /* @__PURE__ */ u("div", { className: "nice-treemap-nav", children: [
1188
+ te.length > 1 && /* @__PURE__ */ u("button", { className: "nice-treemap-back", onClick: k, children: [
1189
+ /* @__PURE__ */ t(ge, { name: "arrow-left", size: 14 }),
1379
1190
  " ",
1380
- X("charts.back", "Back")
1191
+ P("charts.back", "Back")
1381
1192
  ] }),
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)) })
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)) })
1386
1197
  ] }),
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(
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;
1200
+ return /* @__PURE__ */ u(
1390
1201
  "g",
1391
1202
  {
1392
- onClick: () => d(v),
1393
- onMouseEnter: (t) => P(`${v.name}: ${v.value.toLocaleString()}`, t),
1394
- onMouseLeave: () => x(null),
1203
+ onClick: () => Z(h),
1204
+ onMouseEnter: (g) => z(`${h.name}: ${h.value.toLocaleString()}`, g),
1205
+ onMouseLeave: () => F(null),
1395
1206
  children: [
1396
- /* @__PURE__ */ a(
1207
+ /* @__PURE__ */ t(
1397
1208
  "rect",
1398
1209
  {
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,
1404
- 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,
1405
1215
  className: "nice-treemap-tile"
1406
1216
  }
1407
1217
  ),
1408
- b && R && /* @__PURE__ */ a(
1218
+ x && O && /* @__PURE__ */ t(
1409
1219
  "text",
1410
1220
  {
1411
- x: u + w / 2,
1412
- y: C + o / 2 - (H ? 6 : 0),
1221
+ x: $ + l / 2,
1222
+ y: b + y / 2 - (Q ? f * 0.5 : 0),
1413
1223
  textAnchor: "middle",
1414
1224
  dominantBaseline: "middle",
1415
- fontSize: L,
1416
- fill: "white",
1417
- fontWeight: "500",
1418
- style: { pointerEvents: "none" },
1419
- children: v.name.length > w / L + 2 ? v.name.slice(0, Math.floor(w / L)) + "..." : v.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
1420
1229
  }
1421
1230
  ),
1422
- H && R && /* @__PURE__ */ a(
1231
+ Q && O && /* @__PURE__ */ t(
1423
1232
  "text",
1424
1233
  {
1425
- x: u + w / 2,
1426
- y: C + o / 2 + 10,
1234
+ x: $ + l / 2,
1235
+ y: b + y / 2 + f * 0.75,
1427
1236
  textAnchor: "middle",
1428
1237
  dominantBaseline: "middle",
1429
- fontSize: L - 2,
1430
- fill: "var(--nice-overlay-light-80, rgba(255, 255, 255, 0.8))",
1431
- style: { pointerEvents: "none" },
1432
- children: v.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()
1433
1247
  }
1434
1248
  )
1435
1249
  ]
1436
1250
  },
1437
- r
1251
+ m
1438
1252
  );
1439
1253
  }) }),
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: `
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: `
1442
1256
  .nice-treemap-chart {
1443
1257
  font-family: system-ui, -apple-system, sans-serif;
1444
1258
  background: var(--nice-bg-primary, #ffffff);
@@ -1514,8 +1328,7 @@ const ze = [], Ie = [], De = [], ye = [
1514
1328
  };
1515
1329
  export {
1516
1330
  Te as NiceDrillDownChart,
1517
- Be as NiceMapChart,
1518
- Oe as NiceRealtimeChart,
1519
- Ye as NiceSankeyChart,
1520
- Xe as NiceTreeMapChart
1331
+ Ee as NiceMapChart,
1332
+ Fe as NiceRealtimeChart,
1333
+ _e as NiceTreeMap
1521
1334
  };