@thebuoyant-tsdev/mui-ts-library 3.21.0 → 3.22.0

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.
@@ -8,17 +8,17 @@ function m(e, t = 0, n = ".", r = ",") {
8
8
  let [i, a] = e.toFixed(Math.max(0, t)).split("."), o = i.replace(/\B(?=(\d{3})+(?!\d))/g, r);
9
9
  return a ? `${o}${n}${a}` : o;
10
10
  }
11
- function ee(e) {
11
+ function h(e) {
12
12
  return Math.abs(e) >= 1e9 ? `${(e / 1e9).toFixed(1).replace(/\.0$/, "")}B` : Math.abs(e) >= 1e6 ? `${(e / 1e6).toFixed(1).replace(/\.0$/, "")}M` : Math.abs(e) >= 1e3 ? `${(e / 1e3).toFixed(1).replace(/\.0$/, "")}k` : String(e);
13
13
  }
14
- function te(e) {
14
+ function g(e) {
15
15
  return e.map((e) => typeof e == "string" ? {
16
16
  key: e,
17
17
  label: e
18
18
  } : e);
19
19
  }
20
- function ne({ barData: e, seriesKey: t, seriesLabel: n, decimals: r, decimalSep: i, thousandSep: a }) {
21
- let s = e.values[t] ?? 0, l = p.sum(Object.values(e.values)), u = l > 0 ? Math.round(s / l * 1e3) / 10 : 0;
20
+ function ee({ barData: e, seriesKey: t, seriesLabel: n, decimals: r, decimalSep: i, thousandSep: a, valueFormatter: s }) {
21
+ let l = e.values[t] ?? 0, u = p.sum(Object.values(e.values)), h = u > 0 ? Math.round(l / u * 1e3) / 10 : 0, g = (e, t) => s ? s(e, t) : m(e, r, i, a);
22
22
  return /* @__PURE__ */ f(o, {
23
23
  sx: { py: .25 },
24
24
  children: [
@@ -39,7 +39,7 @@ function ne({ barData: e, seriesKey: t, seriesLabel: n, decimals: r, decimalSep:
39
39
  children: [
40
40
  n,
41
41
  ": ",
42
- m(s, r, i, a)
42
+ g(l, t)
43
43
  ]
44
44
  }),
45
45
  /* @__PURE__ */ f(c, {
@@ -50,48 +50,48 @@ function ne({ barData: e, seriesKey: t, seriesLabel: n, decimals: r, decimalSep:
50
50
  mt: .25
51
51
  },
52
52
  children: [
53
- u,
53
+ h,
54
54
  "% · Total: ",
55
- m(l, r, i, a)
55
+ g(u, "")
56
56
  ]
57
57
  })
58
58
  ]
59
59
  });
60
60
  }
61
- function h({ data: c, keys: m, size: h = 500, innerRadius: g, barPadding: _ = .12, chartColors: v, colorConfig: y, showLabels: b = !0, showGridLines: x = !0, gridLineCount: S = 3, showGridValues: re = !0, showLegend: C = !0, sortBy: w = "none", valueDecimalCount: ie = 0, valueDecimalSeparator: ae = ".", valueThousandsSeparator: oe = ",", gridValueFormatter: se, zoomable: T = !1, onBarClick: ce, disabled: E = !1, translation: D }) {
62
- let O = l(), k = {
61
+ function _({ data: c, keys: m, size: _ = 500, innerRadius: v, barPadding: y = .12, chartColors: b, colorConfig: x, showLabels: S = !0, showGridLines: C = !0, gridLineCount: w = 3, showGridValues: T = !0, showLegend: te = !0, sortBy: E = "none", valueDecimalCount: ne = 0, valueDecimalSeparator: re = ".", valueThousandsSeparator: ie = ",", valueFormatter: ae, gridValueFormatter: oe, zoomable: D = !1, onBarClick: O, disabled: k = !1, translation: se }) {
62
+ let A = l(), ce = {
63
63
  ...e,
64
- ...D
65
- }, A = r(() => te(m), [m]), j = r(() => A.map((e) => e.key), [A]), M = c.length === 0 || A.length === 0, le = b ? 63 : 16, N = h / 2 - le, P = g == null ? Math.round(h * .18) : Math.max(0, Math.min(g, N - 1)), ue = [
66
- O.palette.primary.main,
67
- O.palette.secondary.main,
68
- O.palette.success.main,
69
- O.palette.warning.main,
70
- O.palette.error.main,
71
- O.palette.info.main,
64
+ ...se
65
+ }, j = r(() => g(m), [m]), M = r(() => j.map((e) => e.key), [j]), N = c.length === 0 || j.length === 0, le = S ? 63 : 16, P = _ / 2 - le, F = v == null ? Math.round(_ * .18) : Math.max(0, Math.min(v, P - 1)), ue = [
66
+ A.palette.primary.main,
67
+ A.palette.secondary.main,
68
+ A.palette.success.main,
69
+ A.palette.warning.main,
70
+ A.palette.error.main,
71
+ A.palette.info.main,
72
72
  "#8e24aa",
73
73
  "#00897b",
74
74
  "#f06292",
75
75
  "#a1887f"
76
- ], F = v && v.length > 0 ? v : ue, I = t((e, t) => {
77
- let n = y?.[e];
78
- return n?.fill ? n.fill : F[t % F.length];
79
- }, [y, F]), L = r(() => w === "value" ? [...c].sort((e, t) => p.sum(j, (e) => t.values[e] ?? 0) - p.sum(j, (t) => e.values[t] ?? 0)) : w === "label" ? [...c].sort((e, t) => e.label.localeCompare(t.label, void 0, {
76
+ ], I = b && b.length > 0 ? b : ue, L = t((e, t) => {
77
+ let n = x?.[e];
78
+ return n?.fill ? n.fill : I[t % I.length];
79
+ }, [x, I]), R = r(() => E === "value" ? [...c].sort((e, t) => p.sum(M, (e) => t.values[e] ?? 0) - p.sum(M, (t) => e.values[t] ?? 0)) : E === "label" ? [...c].sort((e, t) => e.label.localeCompare(t.label, void 0, {
80
80
  numeric: !0,
81
81
  sensitivity: "base"
82
82
  })) : c, [
83
83
  c,
84
- w,
85
- j
86
- ]), R = r(() => p.max(L, (e) => p.sum(j, (t) => e.values[t] ?? 0)) ?? 0, [L, j]), z = r(() => p.scaleBand().domain(L.map((e) => e.id)).range([0, 2 * Math.PI]).padding(_), [L, _]), B = r(() => p.scaleLinear().domain([0, R]).range([P, N]), [
84
+ E,
85
+ M
86
+ ]), z = r(() => p.max(R, (e) => p.sum(M, (t) => e.values[t] ?? 0)) ?? 0, [R, M]), B = r(() => p.scaleBand().domain(R.map((e) => e.id)).range([0, 2 * Math.PI]).padding(y), [R, y]), V = r(() => p.scaleLinear().domain([0, z]).range([F, P]), [
87
+ F,
87
88
  P,
89
+ z
90
+ ]), H = r(() => N ? [] : p.stack().keys(M).value((e, t) => e.values[t] ?? 0).order(p.stackOrderNone).offset(p.stackOffsetNone)(R), [
88
91
  N,
89
- R
90
- ]), V = r(() => M ? [] : p.stack().keys(j).value((e, t) => e.values[t] ?? 0).order(p.stackOrderNone).offset(p.stackOffsetNone)(L), [
91
- M,
92
- L,
93
- j
94
- ]), H = r(() => p.arc().startAngle((e) => e.x0).endAngle((e) => e.x1).innerRadius((e) => e.y0).outerRadius((e) => e.y1).padAngle(.008).padRadius(P + 10), [P]), U = r(() => R > 0 ? p.ticks(0, R, S).filter((e) => e > 0) : [], [R, S]), de = se ?? ee, [W, G] = a(1), K = i(null), [q, J] = a(`-${h / 2} -${h / 2} ${h} ${h}`), fe = r(() => {
92
+ R,
93
+ M
94
+ ]), de = r(() => p.arc().startAngle((e) => e.x0).endAngle((e) => e.x1).innerRadius((e) => e.y0).outerRadius((e) => e.y1).padAngle(.008).padRadius(F + 10), [F]), U = r(() => z > 0 ? p.ticks(0, z, w).filter((e) => e > 0) : [], [z, w]), fe = oe ?? h, [W, G] = a(1), K = i(null), [q, J] = a(`-${_ / 2} -${_ / 2} ${_} ${_}`), pe = r(() => {
95
95
  if (W === 1) return q;
96
96
  let [e, t, n, r] = q.split(" ").map(Number), i = n / W, a = r / W;
97
97
  return `${e + (n - i) / 2} ${t + (r - a) / 2} ${i} ${a}`;
@@ -104,125 +104,126 @@ function h({ data: c, keys: m, size: h = 500, innerRadius: g, barPadding: _ = .1
104
104
  let t = e.getBBox();
105
105
  J(`${t.x - 4} ${t.y - 4} ${t.width + 8} ${t.height + 8}`);
106
106
  } catch {
107
- J(`-${h / 2} -${h / 2} ${h} ${h}`);
107
+ J(`-${_ / 2} -${_ / 2} ${_} ${_}`);
108
108
  }
109
109
  });
110
110
  return () => cancelAnimationFrame(t);
111
111
  }, [
112
- h,
112
+ _,
113
113
  c,
114
114
  m,
115
+ F,
115
116
  P,
116
- N,
117
- b,
118
- x
117
+ S,
118
+ C
119
119
  ]), n(() => {
120
- if (E) return;
120
+ if (k) return;
121
121
  let e = (e) => {
122
122
  e.key === "Escape" && G(1);
123
123
  };
124
124
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
125
- }, [E]);
126
- let pe = t((e) => {
127
- if (!T || E || !e.ctrlKey) return;
125
+ }, [k]);
126
+ let me = t((e) => {
127
+ if (!D || k || !e.ctrlKey) return;
128
128
  e.preventDefault();
129
129
  let t = e.deltaY < 0 ? 1.15 : 1 / 1.15;
130
130
  G((e) => Math.max(.25, Math.min(8, e * t)));
131
- }, [T, E]), me = -(A.length * 16) / 2, Y = Math.max(0, P * 2 - 10 - 5 - 10), X = 9 * .57, he = A.reduce((e, t) => Math.max(e, (t.label ?? t.key).length), 0), ge = -((15 + Math.min(he * X, Y)) / 2), Z = Math.max(1, Math.floor(Y / X)), _e = (e) => e.length <= Z ? e : `${e.slice(0, Z - 1)}…`, ve = {
131
+ }, [D, k]), he = -(j.length * 16) / 2, Y = Math.max(0, F * 2 - 10 - 5 - 10), X = 9 * .57, ge = j.reduce((e, t) => Math.max(e, (t.label ?? t.key).length), 0), _e = -((15 + Math.min(ge * X, Y)) / 2), Z = Math.max(1, Math.floor(Y / X)), ve = (e) => e.length <= Z ? e : `${e.slice(0, Z - 1)}…`, ye = {
132
132
  followCursor: !0,
133
133
  enterDelay: 50,
134
134
  enterNextDelay: 0,
135
- disableHoverListener: E,
135
+ disableHoverListener: k,
136
136
  slotProps: { tooltip: { sx: { maxWidth: 240 } } }
137
- }, Q = O.palette.text.primary, $ = O.palette.divider, ye = O.typography.fontFamily;
137
+ }, Q = A.palette.text.primary, $ = A.palette.divider, be = A.typography.fontFamily;
138
138
  return /* @__PURE__ */ d(o, {
139
- style: { opacity: E ? .5 : 1 },
139
+ style: { opacity: k ? .5 : 1 },
140
140
  sx: {
141
141
  display: "inline-flex",
142
- cursor: E ? "not-allowed" : "default",
142
+ cursor: k ? "not-allowed" : "default",
143
143
  userSelect: "none"
144
144
  },
145
145
  children: /* @__PURE__ */ d("svg", {
146
- width: h,
147
- height: h,
148
- viewBox: fe,
149
- onWheel: pe,
146
+ width: _,
147
+ height: _,
148
+ viewBox: pe,
149
+ onWheel: me,
150
150
  style: {
151
- fontFamily: ye ?? "sans-serif",
152
- overflow: T && W > 1 ? "hidden" : "visible"
151
+ fontFamily: be ?? "sans-serif",
152
+ overflow: D && W > 1 ? "hidden" : "visible"
153
153
  },
154
154
  role: "img",
155
155
  "aria-label": "Radial stacked bar chart",
156
156
  children: /* @__PURE__ */ f("g", {
157
157
  ref: K,
158
- children: [M && /* @__PURE__ */ d("text", {
158
+ children: [N && /* @__PURE__ */ d("text", {
159
159
  textAnchor: "middle",
160
160
  dy: "0.35em",
161
161
  fontSize: 13,
162
- fill: O.palette.text.secondary,
163
- children: k.noData
164
- }), !M && /* @__PURE__ */ f(u, { children: [
165
- x && U.map((e) => /* @__PURE__ */ d("circle", {
166
- r: B(e),
162
+ fill: A.palette.text.secondary,
163
+ children: ce.noData
164
+ }), !N && /* @__PURE__ */ f(u, { children: [
165
+ C && U.map((e) => /* @__PURE__ */ d("circle", {
166
+ r: V(e),
167
167
  fill: "none",
168
168
  stroke: $,
169
169
  strokeWidth: .5,
170
170
  strokeDasharray: "3 2"
171
171
  }, `grid-${e}`)),
172
- x && /* @__PURE__ */ d("circle", {
173
- r: P,
172
+ C && /* @__PURE__ */ d("circle", {
173
+ r: F,
174
174
  fill: "none",
175
175
  stroke: $,
176
176
  strokeWidth: .75
177
177
  }),
178
- x && re && U.map((e) => /* @__PURE__ */ d("text", {
178
+ C && T && U.map((e) => /* @__PURE__ */ d("text", {
179
179
  x: 0,
180
- y: -B(e),
180
+ y: -V(e),
181
181
  textAnchor: "middle",
182
182
  dy: "-3",
183
183
  fontSize: 9,
184
- fill: O.palette.text.secondary,
184
+ fill: A.palette.text.secondary,
185
185
  pointerEvents: "none",
186
- children: de(e)
186
+ children: fe(e)
187
187
  }, `gv-${e}`)),
188
- V.map((e, t) => {
189
- let n = e.key, r = A[t]?.label ?? n, i = I(n, t);
188
+ H.map((e, t) => {
189
+ let n = e.key, r = j[t]?.label ?? n, i = L(n, t);
190
190
  return e.map((e, t) => {
191
- let a = e.data, o = z(a.id) ?? 0, c = o + z.bandwidth(), l = B(e[0]), u = B(e[1]);
191
+ let a = e.data, o = B(a.id) ?? 0, c = o + B.bandwidth(), l = V(e[0]), u = V(e[1]);
192
192
  if (u - l < .5) return null;
193
- let f = H({
193
+ let f = de({
194
194
  x0: o,
195
195
  x1: c,
196
196
  y0: l,
197
197
  y1: u
198
198
  }) ?? "";
199
199
  return /* @__PURE__ */ d(s, {
200
- ...ve,
200
+ ...ye,
201
201
  placement: "top",
202
- title: /* @__PURE__ */ d(ne, {
202
+ title: /* @__PURE__ */ d(ee, {
203
203
  barData: a,
204
204
  seriesKey: n,
205
205
  seriesLabel: r,
206
- decimals: ie,
207
- decimalSep: ae,
208
- thousandSep: oe
206
+ decimals: ne,
207
+ decimalSep: re,
208
+ thousandSep: ie,
209
+ valueFormatter: ae
209
210
  }),
210
211
  children: /* @__PURE__ */ d("path", {
211
212
  d: f,
212
213
  fill: i,
213
214
  style: {
214
- cursor: E ? "not-allowed" : "pointer",
215
+ cursor: k ? "not-allowed" : "pointer",
215
216
  transition: "opacity 0.15s"
216
217
  },
217
218
  onMouseEnter: (e) => {
218
- E || (e.currentTarget.style.opacity = "0.75");
219
+ k || (e.currentTarget.style.opacity = "0.75");
219
220
  },
220
221
  onMouseLeave: (e) => {
221
222
  e.currentTarget.style.opacity = "1";
222
223
  },
223
224
  onClick: (e) => {
224
- if (E) return;
225
- let t = p.sum(j, (e) => a.values[e] ?? 0), r = {
225
+ if (k) return;
226
+ let t = p.sum(M, (e) => a.values[e] ?? 0), r = {
226
227
  id: a.id,
227
228
  label: a.label,
228
229
  seriesKey: n,
@@ -230,14 +231,14 @@ function h({ data: c, keys: m, size: h = 500, innerRadius: g, barPadding: _ = .1
230
231
  total: t,
231
232
  values: a.values
232
233
  };
233
- ce?.(r, e);
234
+ O?.(r, e);
234
235
  }
235
236
  })
236
237
  }, `${n}-${t}`);
237
238
  });
238
239
  }),
239
- b && L.map((e) => {
240
- let t = (z(e.id) ?? 0) + z.bandwidth() / 2, n = N + 8, r = n * Math.sin(t), i = -n * Math.cos(t), a = t * 180 / Math.PI;
240
+ S && R.map((e) => {
241
+ let t = (B(e.id) ?? 0) + B.bandwidth() / 2, n = P + 8, r = n * Math.sin(t), i = -n * Math.cos(t), a = t * 180 / Math.PI;
241
242
  return /* @__PURE__ */ d("text", {
242
243
  x: r,
243
244
  y: i,
@@ -250,11 +251,11 @@ function h({ data: c, keys: m, size: h = 500, innerRadius: g, barPadding: _ = .1
250
251
  children: e.label
251
252
  }, `lbl-${e.id}`);
252
253
  }),
253
- C && /* @__PURE__ */ d("g", {
254
+ te && /* @__PURE__ */ d("g", {
254
255
  pointerEvents: "none",
255
- transform: `translate(${ge},0)`,
256
- children: A.map((e, t) => {
257
- let n = I(e.key, t), r = me + t * 16, i = _e(e.label ?? e.key);
256
+ transform: `translate(${_e},0)`,
257
+ children: j.map((e, t) => {
258
+ let n = L(e.key, t), r = he + t * 16, i = ve(e.label ?? e.key);
258
259
  return /* @__PURE__ */ f("g", {
259
260
  transform: `translate(0,${r})`,
260
261
  children: [/* @__PURE__ */ d("rect", {
@@ -280,6 +281,6 @@ function h({ data: c, keys: m, size: h = 500, innerRadius: g, barPadding: _ = .1
280
281
  })
281
282
  });
282
283
  }
283
- h.displayName = "RadialStackedBarChart";
284
+ _.displayName = "RadialStackedBarChart";
284
285
  //#endregion
285
- export { h as RadialStackedBarChart };
286
+ export { _ as RadialStackedBarChart };
@@ -74,6 +74,14 @@ export type RadialStackedBarChartProps = {
74
74
  valueDecimalSeparator?: string;
75
75
  /** Thousands separator for values (default: ',') */
76
76
  valueThousandsSeparator?: string;
77
+ /**
78
+ * Custom formatter for tooltip bar values. Overrides `valueDecimalCount`,
79
+ * `valueDecimalSeparator`, and `valueThousandsSeparator` when provided.
80
+ * `seriesKey` is the key from `series` — use it to format different series differently.
81
+ * Example: `(v, key) => key === 'revenue' ? \`$${v.toFixed(0)}\` : \`${v} kg\``
82
+ * @since 3.22.0
83
+ */
84
+ valueFormatter?: (value: number, seriesKey: string) => string;
77
85
  /**
78
86
  * Custom formatter for the grid ring value labels.
79
87
  * Defaults to compact notation (e.g. 30000 → "30k", 3000000 → "3M").
@@ -1,5 +1,5 @@
1
1
  import { type SunburstChartProps } from "./SunburstChart.types";
2
- export declare function SunburstChart({ data, size, showSegmentLabels, innerRadius, sortBy, chartColors, showRootLabel, onSegmentClick, onZoomChange, valueDecimalCount, valueDecimalSeparator, valueThousandsSeparator, zoomable, duration, disabled, translation, }: SunburstChartProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function SunburstChart({ data, size, showSegmentLabels, innerRadius, sortBy, chartColors, showRootLabel, onSegmentClick, onZoomChange, valueDecimalCount, valueDecimalSeparator, valueThousandsSeparator, valueFormatter, zoomable, duration, disabled, translation, }: SunburstChartProps): import("react/jsx-runtime").JSX.Element;
3
3
  export declare namespace SunburstChart {
4
4
  var displayName: string;
5
5
  }
@@ -14,8 +14,8 @@ function te(e, t) {
14
14
  let n = Math.floor(t / h);
15
15
  return n <= 0 ? "" : e.length <= n ? e : n < g ? "" : e.slice(0, n - 1) + "…";
16
16
  }
17
- function ne({ node: e, valueDecimalCount: t, valueDecimalSep: n, valueThousandsSep: r }) {
18
- let i = (e.value ?? 0) > 0, a = e.ancestors().map((e) => e.data.name).reverse().join(" › ");
17
+ function ne({ node: e, valueDecimalCount: t, valueDecimalSep: n, valueThousandsSep: r, valueFormatter: i }) {
18
+ let a = (e.value ?? 0) > 0, o = e.ancestors().map((e) => e.data.name).reverse().join(" › ");
19
19
  return /* @__PURE__ */ d(s, {
20
20
  sx: { py: .25 },
21
21
  children: [
@@ -27,13 +27,13 @@ function ne({ node: e, valueDecimalCount: t, valueDecimalSep: n, valueThousandsS
27
27
  },
28
28
  children: e.data.name
29
29
  }),
30
- i && /* @__PURE__ */ u(l, {
30
+ a && /* @__PURE__ */ u(l, {
31
31
  variant: "caption",
32
32
  sx: {
33
33
  display: "block",
34
34
  opacity: .85
35
35
  },
36
- children: _(e.value ?? 0, t, n, r)
36
+ children: ((e) => i ? i(e) : _(e, t, n, r))(e.value ?? 0)
37
37
  }),
38
38
  e.depth > 0 && /* @__PURE__ */ u(l, {
39
39
  variant: "caption",
@@ -42,27 +42,27 @@ function ne({ node: e, valueDecimalCount: t, valueDecimalSep: n, valueThousandsS
42
42
  opacity: .65,
43
43
  mt: .25
44
44
  },
45
- children: a
45
+ children: o
46
46
  })
47
47
  ]
48
48
  });
49
49
  }
50
- function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ = 0, sortBy: v = "value", chartColors: y, showRootLabel: b = !0, onSegmentClick: x, onZoomChange: S, valueDecimalCount: re = 0, valueDecimalSeparator: ie = ".", valueThousandsSeparator: ae = ",", zoomable: C = !1, duration: w = 750, disabled: T = !1, translation: oe }) {
51
- let E = ee(), se = {
50
+ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ = 0, sortBy: v = "value", chartColors: y, showRootLabel: b = !0, onSegmentClick: x, onZoomChange: S, valueDecimalCount: re = 0, valueDecimalSeparator: ie = ".", valueThousandsSeparator: ae = ",", valueFormatter: oe, zoomable: C = !1, duration: w = 750, disabled: T = !1, translation: se }) {
51
+ let E = ee(), ce = {
52
52
  ...e,
53
- ...oe
54
- }, D = !l.children?.length && !l.value, O = a(null), [k, A] = o(`-${h / 2} -${h / 2} ${h} ${h}`), [j, M] = o(1), ce = i(() => {
53
+ ...se
54
+ }, D = !l.children?.length && !l.value, O = a(null), [k, A] = o(`-${h / 2} -${h / 2} ${h} ${h}`), [j, M] = o(1), le = i(() => {
55
55
  if (j === 1) return k;
56
56
  let [e, t, n, r] = k.split(" ").map(Number), i = n / j, a = r / j;
57
57
  return `${e + (n - i) / 2} ${t + (r - a) / 2} ${i} ${a}`;
58
- }, [k, j]), N = h / 2, P = Math.max(0, Math.min(_, Math.max(0, N - 1))), F = Math.max(1, N - P), le = [
58
+ }, [k, j]), N = h / 2, P = Math.max(0, Math.min(_, Math.max(0, N - 1))), F = Math.max(1, N - P), ue = [
59
59
  E.palette.primary.main,
60
60
  E.palette.secondary.main,
61
61
  E.palette.error.main,
62
62
  E.palette.warning.main,
63
63
  E.palette.success.main,
64
64
  E.palette.info.main
65
- ], I = y && y.length > 0 ? y : le, { root: L, ringThickness: R } = i(() => {
65
+ ], I = y && y.length > 0 ? y : ue, { root: L, ringThickness: R } = i(() => {
66
66
  let e = f.hierarchy(l).sum((e) => e.value ?? 0);
67
67
  v === "value" ? e.sort((e, t) => (t.value ?? 0) - (e.value ?? 0)) : e.sort((e, t) => String(e.data.name).localeCompare(String(t.data.name), void 0, {
68
68
  numeric: !0,
@@ -79,22 +79,22 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
79
79
  l,
80
80
  F,
81
81
  v
82
- ]), [z, B] = o(L), [ue, de] = o(L), V = (e) => ({
82
+ ]), [z, B] = o(L), [de, fe] = o(L), V = (e) => ({
83
83
  x0: e.x0,
84
84
  x1: e.x1,
85
85
  yShift: e.depth === 0 ? 0 : (e.depth - 1) * R
86
86
  }), [H, U] = o(() => V(L)), W = a(H);
87
- if (ue !== L) {
88
- de(L), B(L);
87
+ if (de !== L) {
88
+ fe(L), B(L);
89
89
  let e = V(L);
90
90
  W.current = e, U(e);
91
91
  }
92
- let G = i(() => L.children?.map((e) => e.data.name) ?? [L.data.name], [L]), fe = i(() => f.scaleOrdinal().domain(G).range(I), [I, G]), pe = (e) => {
92
+ let G = i(() => L.children?.map((e) => e.data.name) ?? [L.data.name], [L]), pe = i(() => f.scaleOrdinal().domain(G).range(I), [I, G]), me = (e) => {
93
93
  if (e.data.colorConfig?.fill) return e.data.colorConfig.fill;
94
94
  let t = e;
95
95
  for (; t.depth > 1;) t = t.parent;
96
- return fe(t.data.name);
97
- }, me = i(() => f.arc().startAngle((e) => e.x0).endAngle((e) => e.x1).padAngle((e) => Math.min((e.x1 - e.x0) / 2, .005)).padRadius(N / 2).innerRadius((e) => P + e.y0).outerRadius((e) => P + e.y1 - 1), [N, P]), K = t((e) => {
96
+ return pe(t.data.name);
97
+ }, he = i(() => f.arc().startAngle((e) => e.x0).endAngle((e) => e.x1).padAngle((e) => Math.min((e.x1 - e.x0) / 2, .005)).padRadius(N / 2).innerRadius((e) => P + e.y0).outerRadius((e) => P + e.y1 - 1), [N, P]), K = t((e) => {
98
98
  let t = p / (H.x1 - H.x0);
99
99
  return {
100
100
  x0: Math.max(0, Math.min(p, (e.x0 - H.x0) * t)),
@@ -126,10 +126,10 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
126
126
  R,
127
127
  w
128
128
  ]);
129
- let he = (e) => e.x1 > e.x0 && e.y1 > e.y0, ge = (e) => (P + (e.y0 + e.y1) / 2) * (e.x1 - e.x0) > 12, _e = (e) => {
129
+ let ge = (e) => e.x1 > e.x0 && e.y1 > e.y0, _e = (e) => (P + (e.y0 + e.y1) / 2) * (e.x1 - e.x0) > 12, ve = (e) => {
130
130
  let t = (e.x0 + e.x1) / 2 * 180 / Math.PI, n = P + (e.y0 + e.y1) / 2, r = t < 180 ? 0 : 180;
131
131
  return `rotate(${t - 90}) translate(${n},0) rotate(${r})`;
132
- }, ve = t((e) => e.ancestors().includes(z), [z]), q = t((e) => {
132
+ }, ye = t((e) => e.ancestors().includes(z), [z]), q = t((e) => {
133
133
  let t = e.ancestors().reverse(), n = e.value ?? 0, r = L.value ?? 0;
134
134
  return {
135
135
  id: e.data.id,
@@ -172,7 +172,7 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
172
172
  R,
173
173
  b
174
174
  ]);
175
- let Y = a(null), ye = (e) => {
175
+ let Y = a(null), be = (e) => {
176
176
  Y.current &&= (clearTimeout(Y.current), null), Y.current = setTimeout(() => {
177
177
  e(), Y.current = null;
178
178
  }, 250);
@@ -190,22 +190,22 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
190
190
  L,
191
191
  J
192
192
  ]);
193
- let be = t((e) => {
193
+ let xe = t((e) => {
194
194
  if (!C || T || !e.ctrlKey) return;
195
195
  e.preventDefault();
196
196
  let t = e.deltaY < 0 ? 1.15 : 1 / 1.15;
197
197
  M((e) => Math.max(.25, Math.min(8, e * t)));
198
- }, [C, T]), Z = L.descendants().filter((e) => e.depth > 0), xe = (e) => {
198
+ }, [C, T]), Z = L.descendants().filter((e) => e.depth > 0), Se = (e) => {
199
199
  if (T) return;
200
200
  let t = Z[Number(e.currentTarget.getAttribute("data-idx"))];
201
201
  if (t) {
202
202
  if (e.ctrlKey || e.metaKey) {
203
- t.children && ye(() => J(t));
203
+ t.children && be(() => J(t));
204
204
  return;
205
205
  }
206
206
  x?.(q(t), e);
207
207
  }
208
- }, Se = (e) => {
208
+ }, Ce = (e) => {
209
209
  T || (e.ctrlKey || e.metaKey) && (X(), J(z.parent ?? L));
210
210
  }, Q = (e) => {
211
211
  if (!T) {
@@ -221,7 +221,7 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
221
221
  enterNextDelay: 0,
222
222
  disableHoverListener: T,
223
223
  slotProps: { tooltip: { sx: { maxWidth: 260 } } }
224
- }, Ce = E.palette.text.primary, we = E.typography.fontFamily;
224
+ }, we = E.palette.text.primary, Te = E.typography.fontFamily;
225
225
  return /* @__PURE__ */ u(s, {
226
226
  sx: {
227
227
  display: "inline-flex",
@@ -232,10 +232,10 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
232
232
  children: /* @__PURE__ */ u("svg", {
233
233
  width: h,
234
234
  height: h,
235
- viewBox: ce,
236
- onWheel: be,
235
+ viewBox: le,
236
+ onWheel: xe,
237
237
  style: {
238
- fontFamily: we ?? "sans-serif",
238
+ fontFamily: Te ?? "sans-serif",
239
239
  overflow: C && j > 1 ? "hidden" : "visible"
240
240
  },
241
241
  role: "img",
@@ -248,7 +248,7 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
248
248
  dy: "0.35em",
249
249
  fontSize: 13,
250
250
  fill: E.palette.text.secondary,
251
- children: se.noData
251
+ children: ce.noData
252
252
  }),
253
253
  P > 0 && /* @__PURE__ */ u(c, {
254
254
  ...$,
@@ -265,7 +265,7 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
265
265
  })
266
266
  }),
267
267
  /* @__PURE__ */ u("g", { children: Z.map((e, t) => {
268
- let n = K(e), r = he(n), i = !!e.children;
268
+ let n = K(e), r = ge(n), i = !!e.children;
269
269
  return /* @__PURE__ */ u(c, {
270
270
  ...$,
271
271
  placement: "top",
@@ -273,34 +273,35 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
273
273
  node: e,
274
274
  valueDecimalCount: re,
275
275
  valueDecimalSep: ie,
276
- valueThousandsSep: ae
276
+ valueThousandsSep: ae,
277
+ valueFormatter: oe
277
278
  }) : "",
278
279
  children: /* @__PURE__ */ u("path", {
279
280
  "data-idx": t,
280
- d: me(n) || "",
281
- fill: pe(e),
281
+ d: he(n) || "",
282
+ fill: me(e),
282
283
  fillOpacity: r ? i ? .75 : .5 : 0,
283
284
  style: {
284
285
  pointerEvents: r && !T ? "auto" : "none",
285
286
  cursor: i && !T ? "pointer" : "default",
286
287
  transition: "fill-opacity 0.15s"
287
288
  },
288
- onClick: xe,
289
- onDoubleClick: Se
289
+ onClick: Se,
290
+ onDoubleClick: Ce
290
291
  })
291
292
  }, `tt-${e.data.id}-${t}`);
292
293
  }) }),
293
294
  g && /* @__PURE__ */ u("g", {
294
295
  pointerEvents: "none",
295
296
  textAnchor: "middle",
296
- fill: Ce,
297
+ fill: we,
297
298
  children: Z.map((e, t) => {
298
- if (!ve(e)) return null;
299
+ if (!ye(e)) return null;
299
300
  let n = K(e);
300
- if (!ge(n)) return null;
301
+ if (!_e(n)) return null;
301
302
  let r = (P + (n.y0 + n.y1) / 2) * (n.x1 - n.x0) * .88, i = te(e.data.name, r);
302
303
  return i ? /* @__PURE__ */ u("text", {
303
- transform: _e(n),
304
+ transform: ve(n),
304
305
  dy: "0.35em",
305
306
  fontSize: m,
306
307
  children: i
@@ -313,7 +314,7 @@ function v({ data: l, size: h = 500, showSegmentLabels: g = !0, innerRadius: _ =
313
314
  title: "",
314
315
  children: /* @__PURE__ */ u("g", {
315
316
  textAnchor: "middle",
316
- fill: Ce,
317
+ fill: we,
317
318
  pointerEvents: T ? "none" : "auto",
318
319
  onClick: Q,
319
320
  style: { cursor: z !== L && !T ? "pointer" : "default" },
@@ -64,6 +64,13 @@ export type SunburstChartProps = {
64
64
  valueDecimalSeparator?: string;
65
65
  /** Thousands separator for values (default: ',') */
66
66
  valueThousandsSeparator?: string;
67
+ /**
68
+ * Custom formatter for numeric values in tooltips. Overrides `valueDecimalCount`,
69
+ * `valueDecimalSeparator`, and `valueThousandsSeparator`.
70
+ * Example: `(v) => \`${v.toLocaleString('de-DE')} MB\``
71
+ * @since 3.22.0
72
+ */
73
+ valueFormatter?: (value: number) => string;
67
74
  /** Enable Ctrl+Scroll zoom — content outside `size` is clipped (default: false) */
68
75
  zoomable?: boolean;
69
76
  /** Drill-down/out transition duration in ms — set to 0 to disable animation (default: 750) */