@gravitee/graphene-charts 3.17.0 → 3.18.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.
Files changed (38) hide show
  1. package/USAGE_GUIDE.md +71 -1
  2. package/dist/base/ChartBrush/ChartBrush.d.ts +47 -0
  3. package/dist/base/ChartBrush/ChartBrush.d.ts.map +1 -0
  4. package/dist/base/ChartBrush/index.d.ts +3 -0
  5. package/dist/base/ChartBrush/index.d.ts.map +1 -0
  6. package/dist/charts/AreaChart/AreaChart.d.ts +8 -1
  7. package/dist/charts/AreaChart/AreaChart.d.ts.map +1 -1
  8. package/dist/charts/LineChart/LineChart.d.ts +7 -1
  9. package/dist/charts/LineChart/LineChart.d.ts.map +1 -1
  10. package/dist/dashboard-grid/DashboardGrid.d.ts.map +1 -1
  11. package/dist/dashboard-grid/DashboardWidget.d.ts.map +1 -1
  12. package/dist/dashboard-grid/index.js +42 -31
  13. package/dist/index.d.ts +2 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1684 -1632
  16. package/dist/lineage/index.js +12 -12
  17. package/dist/primitives/CartesianChart.d.ts.map +1 -1
  18. package/dist/primitives/ChartBrushOverlay.d.ts +24 -0
  19. package/dist/primitives/ChartBrushOverlay.d.ts.map +1 -0
  20. package/dist/primitives/ChartSlots.d.ts +17 -2
  21. package/dist/primitives/ChartSlots.d.ts.map +1 -1
  22. package/dist/primitives/ReferenceLine.d.ts.map +1 -1
  23. package/dist/primitives/cartesianGeometry.d.ts +98 -0
  24. package/dist/primitives/cartesianGeometry.d.ts.map +1 -0
  25. package/dist/primitives/chartBadge.d.ts +13 -0
  26. package/dist/primitives/chartBadge.d.ts.map +1 -0
  27. package/dist/primitives/index.d.ts +2 -1
  28. package/dist/primitives/index.d.ts.map +1 -1
  29. package/dist/primitives/useChartBrush.d.ts +51 -0
  30. package/dist/primitives/useChartBrush.d.ts.map +1 -0
  31. package/dist/primitives/useDevWarning.d.ts +21 -0
  32. package/dist/primitives/useDevWarning.d.ts.map +1 -0
  33. package/dist/{primitives-DxLTufiI.js → primitives-BvnyBVmf.js} +525 -252
  34. package/dist/series/AreaSeries.d.ts +9 -1
  35. package/dist/series/AreaSeries.d.ts.map +1 -1
  36. package/dist/series/LineSeries.d.ts +8 -1
  37. package/dist/series/LineSeries.d.ts.map +1 -1
  38. package/package.json +1 -1
@@ -47,7 +47,7 @@ function w(e, t) {
47
47
  return t && (t.height !== void 0 || t.minHeight !== void 0 || t.maxHeight !== void 0) ? !0 : e ? /(?:^|\s)!?(?:min-|max-)?h-[^\s]+/.test(e) : !1;
48
48
  }
49
49
  var T = 10;
50
- function E({ id: t, config: n, className: r, children: i, style: o, ...l }) {
50
+ function ee({ id: t, config: n, className: r, children: i, style: o, ...l }) {
51
51
  let u = a.useId(), d = `chart-${t ?? u.replace(/:/g, "")}`, f = a.useMemo(() => {
52
52
  let e = Object.entries(n), t = {};
53
53
  for (let n = 0; n < e.length; n++) {
@@ -70,14 +70,14 @@ function E({ id: t, config: n, className: r, children: i, style: o, ...l }) {
70
70
  className: e("flex w-full justify-center text-xs", !m && "aspect-video", r),
71
71
  style: o,
72
72
  ...l,
73
- children: [p.length > 0 && /* @__PURE__ */ s(D, {
73
+ children: [p.length > 0 && /* @__PURE__ */ s(E, {
74
74
  id: d,
75
75
  config: f
76
76
  }), i]
77
77
  })
78
78
  });
79
79
  }
80
- function D({ id: e, config: t }) {
80
+ function E({ id: e, config: t }) {
81
81
  let n = x(e);
82
82
  return /* @__PURE__ */ s("style", { dangerouslySetInnerHTML: { __html: Object.entries(v).map(([e, r]) => `${r} [data-chart=${n}] {\n${Object.entries(t).map(([t, n]) => {
83
83
  let r = n.theme?.[e] ?? n.color, i = x(t);
@@ -86,7 +86,7 @@ function D({ id: e, config: t }) {
86
86
  }
87
87
  //#endregion
88
88
  //#region src/primitives/useChartDimensions.ts
89
- function O(e) {
89
+ function D(e) {
90
90
  let [t, n] = a.useState({
91
91
  width: 0,
92
92
  height: 0
@@ -106,19 +106,19 @@ function O(e) {
106
106
  }
107
107
  //#endregion
108
108
  //#region src/primitives/useTooltipState.ts
109
- var k = 12, A = -12;
110
- function j(e, t) {
109
+ var O = 12, k = -12;
110
+ function A(e, t) {
111
111
  return {
112
- x: e.clientX - t.left + k,
113
- y: e.clientY - t.top + A
112
+ x: e.clientX - t.left + O,
113
+ y: e.clientY - t.top + k
114
114
  };
115
115
  }
116
- function ee() {
116
+ function te() {
117
117
  let [e, t] = a.useState(null);
118
118
  return {
119
119
  state: e,
120
120
  show: a.useCallback((e, n, r, i) => {
121
- let { x: a, y: o } = j(r, i);
121
+ let { x: a, y: o } = A(r, i);
122
122
  t({
123
123
  items: e,
124
124
  label: n,
@@ -129,7 +129,7 @@ function ee() {
129
129
  move: a.useCallback((e, n) => {
130
130
  t((t) => {
131
131
  if (!t) return t;
132
- let { x: r, y: i } = j(e, n);
132
+ let { x: r, y: i } = A(e, n);
133
133
  return {
134
134
  ...t,
135
135
  x: r,
@@ -142,16 +142,16 @@ function ee() {
142
142
  }
143
143
  //#endregion
144
144
  //#region src/primitives/CartesianContext.tsx
145
- var M = a.createContext(null);
146
- function N() {
147
- let e = a.useContext(M);
145
+ var j = a.createContext(null);
146
+ function M() {
147
+ let e = a.useContext(j);
148
148
  if (!e) throw Error("useCartesianContext must be used within a <CartesianChart>");
149
149
  return e;
150
150
  }
151
151
  //#endregion
152
152
  //#region src/primitives/Grid.tsx
153
- function P({ scale: e, length: t, orientation: n, tickCount: r = 5 }) {
154
- let i = a.useContext(M), o = e ?? i?.valueScale, c = i?.layout === "vertical", l = n ?? (c ? "horizontal" : "vertical"), u = t ?? (l === "horizontal" ? i?.innerWidth : i?.innerHeight) ?? 0;
153
+ function N({ scale: e, length: t, orientation: n, tickCount: r = 5 }) {
154
+ let i = a.useContext(j), o = e ?? i?.valueScale, c = i?.layout === "vertical", l = n ?? (c ? "horizontal" : "vertical"), u = t ?? (l === "horizontal" ? i?.innerWidth : i?.innerHeight) ?? 0;
155
155
  if (!o) return null;
156
156
  let d = o.ticks(r), f = l === "horizontal";
157
157
  return /* @__PURE__ */ s("g", {
@@ -176,10 +176,23 @@ function P({ scale: e, length: t, orientation: n, tickCount: r = 5 }) {
176
176
  });
177
177
  }
178
178
  //#endregion
179
+ //#region src/primitives/chartBadge.ts
180
+ var ne = 6.2, re = 12, ie = "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] leading-none font-medium";
181
+ function P(e) {
182
+ return e * ne + re;
183
+ }
184
+ function F(e) {
185
+ return {
186
+ color: e,
187
+ borderColor: e,
188
+ backgroundColor: `color-mix(in srgb, ${e} 10%, var(--background))`
189
+ };
190
+ }
191
+ //#endregion
179
192
  //#region src/primitives/ReferenceLine.tsx
180
- var F = 6, I = 20, L = 6.2, R = 12, z = "\n@keyframes graphene-refline-fadein {\n from { opacity: 0; }\n to { opacity: var(--_refline-opacity); }\n}\n@keyframes graphene-refline-pulse {\n 0%, 100% { stroke-opacity: 0.7; }\n 50% { stroke-opacity: 0.3; }\n}\n[data-graphene-refline] {\n animation: graphene-refline-fadein 300ms ease-out forwards;\n}\n[data-graphene-refline-pulse] {\n animation: graphene-refline-pulse 2s ease-in-out infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n [data-graphene-refline] {\n animation: none;\n opacity: var(--_refline-opacity);\n }\n [data-graphene-refline-pulse] {\n animation: none;\n }\n}\n";
181
- function te({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray: i, strokeWidth: o = 1.5, label: l, labelPosition: u = "end", pulse: d = !1 }) {
182
- let f = a.useContext(M);
193
+ var I = 6, L = 20, R = "\n@keyframes graphene-refline-fadein {\n from { opacity: 0; }\n to { opacity: var(--_refline-opacity); }\n}\n@keyframes graphene-refline-pulse {\n 0%, 100% { stroke-opacity: 0.7; }\n 50% { stroke-opacity: 0.3; }\n}\n[data-graphene-refline] {\n animation: graphene-refline-fadein 300ms ease-out forwards;\n}\n[data-graphene-refline-pulse] {\n animation: graphene-refline-pulse 2s ease-in-out infinite;\n}\n@media (prefers-reduced-motion: reduce) {\n [data-graphene-refline] {\n animation: none;\n opacity: var(--_refline-opacity);\n }\n [data-graphene-refline-pulse] {\n animation: none;\n }\n}\n";
194
+ function z({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray: i, strokeWidth: o = 1.5, label: l, labelPosition: u = "end", pulse: d = !1 }) {
195
+ let f = a.useContext(j);
183
196
  if (!f) return null;
184
197
  let { categoryScale: p, resolveValueScale: m, innerWidth: h, innerHeight: g, layout: _ } = f, v = m(n), y = _ === "vertical", b = e !== void 0, x = t !== void 0;
185
198
  if (!b && !x) return null;
@@ -195,13 +208,13 @@ function te({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray
195
208
  let e = v(t);
196
209
  y ? (C = e, T = !0) : (S = e, w = !0);
197
210
  }
198
- let E = w && S >= 0 && S <= h, D = T && C >= 0 && C <= g;
199
- if (!E && !D) return null;
200
- let O = d ? .7 : .8, k = l ? V(u, {
211
+ let ee = w && S >= 0 && S <= h, E = T && C >= 0 && C <= g;
212
+ if (!ee && !E) return null;
213
+ let D = d ? .7 : .8, O = l ? ae(u, {
201
214
  xPos: S,
202
215
  yPos: C,
203
- xInBounds: E,
204
- yInBounds: D,
216
+ xInBounds: ee,
217
+ yInBounds: E,
205
218
  hasX: w,
206
219
  hasY: T,
207
220
  innerWidth: h,
@@ -211,13 +224,13 @@ function te({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray
211
224
  return /* @__PURE__ */ c("g", {
212
225
  "aria-hidden": "true",
213
226
  "data-graphene-refline": !0,
214
- style: { "--_refline-opacity": O },
227
+ style: { "--_refline-opacity": D },
215
228
  children: [
216
229
  /* @__PURE__ */ s("style", {
217
230
  precedence: "graphene-charts",
218
- children: z
231
+ children: R
219
232
  }),
220
- E && /* @__PURE__ */ s("line", {
233
+ ee && /* @__PURE__ */ s("line", {
221
234
  x1: S,
222
235
  x2: S,
223
236
  y1: 0,
@@ -226,10 +239,10 @@ function te({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray
226
239
  strokeWidth: o,
227
240
  strokeDasharray: i,
228
241
  strokeLinecap: "round",
229
- strokeOpacity: O,
242
+ strokeOpacity: D,
230
243
  ...d ? { "data-graphene-refline-pulse": "" } : {}
231
244
  }),
232
- D && /* @__PURE__ */ s("line", {
245
+ E && /* @__PURE__ */ s("line", {
233
246
  x1: 0,
234
247
  x2: h,
235
248
  y1: C,
@@ -238,107 +251,100 @@ function te({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray
238
251
  strokeWidth: o,
239
252
  strokeDasharray: i,
240
253
  strokeLinecap: "round",
241
- strokeOpacity: O,
254
+ strokeOpacity: D,
242
255
  ...d ? { "data-graphene-refline-pulse": "" } : {}
243
256
  }),
244
- l && k && /* @__PURE__ */ s("foreignObject", {
245
- x: k.x,
246
- y: k.y,
247
- width: k.width,
248
- height: I,
257
+ l && O && /* @__PURE__ */ s("foreignObject", {
258
+ x: O.x,
259
+ y: O.y,
260
+ width: O.width,
261
+ height: L,
249
262
  overflow: "visible",
250
263
  children: /* @__PURE__ */ s("span", {
251
264
  className: "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] leading-none font-medium",
252
- style: {
253
- color: r,
254
- borderColor: r,
255
- backgroundColor: `color-mix(in srgb, ${r} 10%, var(--background))`
256
- },
265
+ style: F(r),
257
266
  children: l
258
267
  })
259
268
  })
260
269
  ]
261
270
  });
262
271
  }
263
- function B(e) {
264
- return e * L + R;
265
- }
266
- function V(e, t) {
267
- let { xPos: n, yPos: r, xInBounds: i, yInBounds: a, hasX: o, hasY: s, innerWidth: c, innerHeight: l, labelLength: u } = t, d = B(u);
272
+ function ae(e, t) {
273
+ let { xPos: n, yPos: r, xInBounds: i, yInBounds: a, hasX: o, hasY: s, innerWidth: c, innerHeight: l, labelLength: u } = t, d = P(u);
268
274
  if (o && s && i && a) {
269
- let e = n + F + d > c, t = r + F + I > l;
275
+ let e = n + I + d > c, t = r + I + L > l;
270
276
  return {
271
- x: e ? n - F - d : n + F,
272
- y: t ? r - F - I : r + F,
277
+ x: e ? n - I - d : n + I,
278
+ y: t ? r - I - L : r + I,
273
279
  width: d
274
280
  };
275
281
  }
276
282
  if (s && a) {
277
- let t = r - F - I < 0;
283
+ let t = r - I - L < 0;
278
284
  return {
279
- x: re(e, c, d),
280
- y: t ? r + F : r - F - I,
285
+ x: se(e, c, d),
286
+ y: t ? r + I : r - I - L,
281
287
  width: d
282
288
  };
283
289
  }
284
290
  return o && i ? {
285
- x: n + F + d > c ? n - F - d : n + F,
286
- y: ne(e, l),
291
+ x: n + I + d > c ? n - I - d : n + I,
292
+ y: oe(e, l),
287
293
  width: d
288
294
  } : null;
289
295
  }
290
- function ne(e, t) {
291
- return e === "start" ? F : e === "center" ? t / 2 - I / 2 : t - I - F;
296
+ function oe(e, t) {
297
+ return e === "start" ? I : e === "center" ? t / 2 - L / 2 : t - L - I;
292
298
  }
293
- function re(e, t, n) {
294
- return e === "start" ? F : e === "center" ? t / 2 - n / 2 : t - n - F;
299
+ function se(e, t, n) {
300
+ return e === "start" ? I : e === "center" ? t / 2 - n / 2 : t - n - I;
295
301
  }
296
302
  //#endregion
297
303
  //#region src/primitives/Axis.tsx
298
- var H = 7, U = 8, W = "…", ie = 4;
299
- function G(e) {
304
+ var B = 7, V = 8, ce = "…", H = 4;
305
+ function U(e) {
300
306
  return new Set(Array.from({ length: e }, (e, t) => t));
301
307
  }
302
- function K(e, t) {
308
+ function le(e, t) {
303
309
  let n = /* @__PURE__ */ new Set();
304
310
  for (let r = 0; r < e; r += t) n.add(r);
305
311
  let r = e - 1;
306
312
  return r - Math.floor((r - 1) / t) * t >= t && n.add(r), n;
307
313
  }
308
- function ae(e, t) {
314
+ function W(e, t) {
309
315
  let n = e.domain();
310
316
  return n.length < 2 ? t : Math.abs((e(n[1]) ?? 0) - (e(n[0]) ?? 0));
311
317
  }
312
- function q(e, t, n, r) {
313
- let i = Math.max(0, t - U);
314
- if (r ? i >= ie * H : n <= i) return {
315
- visible: G(e),
318
+ function G(e, t, n, r) {
319
+ let i = Math.max(0, t - V);
320
+ if (r ? i >= H * B : n <= i) return {
321
+ visible: U(e),
316
322
  maxWidth: i
317
323
  };
318
- let a = t > 0 ? Math.max(1, Math.ceil((n + U) / t)) : e;
324
+ let a = t > 0 ? Math.max(1, Math.ceil((n + V) / t)) : e;
319
325
  return {
320
- visible: K(e, a),
321
- maxWidth: Math.max(0, t * a - U)
326
+ visible: le(e, a),
327
+ maxWidth: Math.max(0, t * a - V)
322
328
  };
323
329
  }
324
- function J(e, t) {
325
- let n = Math.floor(t / H);
326
- return n <= 1 ? W : e.length <= n ? e : e.slice(0, n - 1) + W;
330
+ function K(e, t) {
331
+ let n = Math.floor(t / B);
332
+ return n <= 1 ? ce : e.length <= n ? e : e.slice(0, n - 1) + ce;
327
333
  }
328
- function Y(e, t, n, r) {
334
+ function q(e, t, n, r) {
329
335
  if (t) return Math.max(1, Math.floor(e / 24));
330
- let i = Math.max(...n.map((e) => r(e).length)) * H;
331
- return Math.max(1, Math.floor(e / (i + U)));
336
+ let i = Math.max(...n.map((e) => r(e).length)) * B;
337
+ return Math.max(1, Math.floor(e / (i + V)));
332
338
  }
333
- function X({ scale: e, orientation: t, length: n }) {
334
- let r = a.useContext(M), i = e ?? r?.categoryScale, l = r?.layout !== "horizontal", u = t ?? (l ? "bottom" : "left"), d = n ?? (u === "bottom" ? r?.innerHeight : 0) ?? 0, f = r?.categoryTickFormatter ?? ((e) => e);
339
+ function ue({ scale: e, orientation: t, length: n }) {
340
+ let r = a.useContext(j), i = e ?? r?.categoryScale, l = r?.layout !== "horizontal", u = t ?? (l ? "bottom" : "left"), d = n ?? (u === "bottom" ? r?.innerHeight : 0) ?? 0, f = r?.categoryTickFormatter ?? ((e) => e);
335
341
  if (!i) return null;
336
- let p = i.domain(), m = p.map(f), h = ae(i, u === "bottom" ? r?.innerWidth ?? 0 : r?.innerHeight ?? 0), g = (e, t) => {
337
- let n = m[e], r = J(n, t);
342
+ let p = i.domain(), m = p.map(f), h = W(i, u === "bottom" ? r?.innerWidth ?? 0 : r?.innerHeight ?? 0), g = (e, t) => {
343
+ let n = m[e], r = K(n, t);
338
344
  return /* @__PURE__ */ c(o, { children: [r !== n && /* @__PURE__ */ s("title", { children: n }), r] });
339
345
  };
340
346
  if (u === "bottom") {
341
- let e = Math.max(...m.map((e) => e.length * H)), { visible: t, maxWidth: n } = q(p.length, h, e, i.bandwidth() > 0);
347
+ let e = Math.max(...m.map((e) => e.length * B)), { visible: t, maxWidth: n } = G(p.length, h, e, i.bandwidth() > 0);
342
348
  return /* @__PURE__ */ s("g", {
343
349
  transform: `translate(0,${d})`,
344
350
  "aria-hidden": "true",
@@ -351,7 +357,7 @@ function X({ scale: e, orientation: t, length: n }) {
351
357
  }, e) : null)
352
358
  });
353
359
  }
354
- let _ = r?.marginLeft ?? 40, v = Math.max(0, _ - U), y = h > 0 ? Math.max(1, Math.ceil(24 / h)) : p.length, b = K(p.length, y);
360
+ let _ = r?.marginLeft ?? 40, v = Math.max(0, _ - V), y = h > 0 ? Math.max(1, Math.ceil(24 / h)) : p.length, b = le(p.length, y);
355
361
  return /* @__PURE__ */ s("g", {
356
362
  "aria-hidden": "true",
357
363
  children: p.map((e, t) => b.has(t) ? /* @__PURE__ */ s("text", {
@@ -364,10 +370,10 @@ function X({ scale: e, orientation: t, length: n }) {
364
370
  }, e) : null)
365
371
  });
366
372
  }
367
- function oe({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount: o = 5, tickFormatter: c }) {
368
- let l = a.useContext(M), u = n && l?.resolveValueScale ? l.resolveValueScale(n) : l?.valueScale, d = e ?? u, f = l?.layout !== "horizontal", p = t ?? (f ? "left" : "bottom"), m = i ?? (p === "bottom" ? l?.innerHeight : 0) ?? 0, h = c ?? l?.valueTickFormatter ?? String, g = r ?? l?.axisUnits?.[n ?? "left"];
373
+ function de({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount: o = 5, tickFormatter: c }) {
374
+ let l = a.useContext(j), u = n && l?.resolveValueScale ? l.resolveValueScale(n) : l?.valueScale, d = e ?? u, f = l?.layout !== "horizontal", p = t ?? (f ? "left" : "bottom"), m = i ?? (p === "bottom" ? l?.innerHeight : 0) ?? 0, h = c ?? l?.valueTickFormatter ?? String, g = r ?? l?.axisUnits?.[n ?? "left"];
369
375
  if (!d) return null;
370
- let _ = d.ticks(o), v = p === "left" || p === "right", y = Y(v ? l?.innerHeight ?? 0 : l?.innerWidth ?? 0, v, _, h), b = y >= _.length ? _ : d.ticks(y), x = b.length > 0 ? Math.max(...b) : void 0, S = (e) => {
376
+ let _ = d.ticks(o), v = p === "left" || p === "right", y = q(v ? l?.innerHeight ?? 0 : l?.innerWidth ?? 0, v, _, h), b = y >= _.length ? _ : d.ticks(y), x = b.length > 0 ? Math.max(...b) : void 0, S = (e) => {
371
377
  let t = h(e);
372
378
  return g && e === x ? `${t} ${g}` : t;
373
379
  };
@@ -387,7 +393,7 @@ function oe({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount
387
393
  return /* @__PURE__ */ s("g", {
388
394
  "aria-hidden": "true",
389
395
  children: b.map((t) => /* @__PURE__ */ s("text", {
390
- x: e + U,
396
+ x: e + V,
391
397
  y: d(t),
392
398
  textAnchor: "start",
393
399
  dominantBaseline: "middle",
@@ -409,7 +415,7 @@ function oe({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount
409
415
  }
410
416
  //#endregion
411
417
  //#region src/primitives/roundedRect.ts
412
- function se(e, t, n, r, i) {
418
+ function fe(e, t, n, r, i) {
413
419
  let a = Math.min(i.tl, n / 2, r / 2), o = Math.min(i.tr, n / 2, r / 2), s = Math.min(i.br, n / 2, r / 2), c = Math.min(i.bl, n / 2, r / 2);
414
420
  return [
415
421
  `M${e + a},${t}`,
@@ -426,30 +432,38 @@ function se(e, t, n, r, i) {
426
432
  }
427
433
  //#endregion
428
434
  //#region src/primitives/ChartSlots.tsx
429
- var ce = a.createContext(null);
430
- function le() {
431
- return a.useContext(ce) || {
435
+ var J = a.createContext(null);
436
+ function pe() {
437
+ return a.useContext(J) || {
432
438
  tooltip: null,
433
439
  legend: null,
440
+ brush: null,
434
441
  setTooltip: () => void 0,
435
- setLegend: () => void 0
442
+ setLegend: () => void 0,
443
+ setBrush: () => void 0
436
444
  };
437
445
  }
438
- function Z({ children: e }) {
439
- let [t, n] = a.useState(null), [r, i] = a.useState(null), o = a.useMemo(() => ({
446
+ function Y({ children: e }) {
447
+ let [t, n] = a.useState(null), [r, i] = a.useState(null), [o, c] = a.useState(null), l = a.useMemo(() => ({
440
448
  tooltip: t,
441
449
  legend: r,
450
+ brush: o,
442
451
  setTooltip: n,
443
- setLegend: i
444
- }), [t, r]);
445
- return /* @__PURE__ */ s(ce.Provider, {
446
- value: o,
452
+ setLegend: i,
453
+ setBrush: c
454
+ }), [
455
+ t,
456
+ r,
457
+ o
458
+ ]);
459
+ return /* @__PURE__ */ s(J.Provider, {
460
+ value: l,
447
461
  children: e
448
462
  });
449
463
  }
450
464
  //#endregion
451
465
  //#region src/primitives/useResolvedCssLength.tsx
452
- function Q(e, t) {
466
+ function me(e, t) {
453
467
  let n = a.useRef(null), [r, i] = a.useState(t), o = a.useCallback(() => {
454
468
  let e = n.current;
455
469
  if (!e) return;
@@ -473,13 +487,18 @@ function Q(e, t) {
473
487
  })];
474
488
  }
475
489
  //#endregion
490
+ //#region src/primitives/useDevWarning.ts
491
+ function he(e) {
492
+ a.useRef(null), a.useEffect(() => {}, [e]);
493
+ }
494
+ //#endregion
476
495
  //#region src/lib/resolveChartState.ts
477
- function $(e, t) {
496
+ function ge(e, t) {
478
497
  return e ?? (t === 0 ? "empty" : "ready");
479
498
  }
480
499
  //#endregion
481
500
  //#region src/primitives/BarChartSkeleton.tsx
482
- var ue = [
501
+ var X = [
483
502
  {
484
503
  x: 55,
485
504
  height: 120
@@ -505,7 +524,7 @@ var ue = [
505
524
  height: 85
506
525
  }
507
526
  ];
508
- function de({ ariaLabel: t = "Loading chart", className: n, ...r }) {
527
+ function Z({ ariaLabel: t = "Loading chart", className: n, ...r }) {
509
528
  return /* @__PURE__ */ s("div", {
510
529
  role: "img",
511
530
  "aria-label": t,
@@ -514,7 +533,7 @@ function de({ ariaLabel: t = "Loading chart", className: n, ...r }) {
514
533
  ...r,
515
534
  children: /* @__PURE__ */ s("div", {
516
535
  className: "flex min-h-0 flex-1 items-end gap-2 px-8 py-4",
517
- children: ue.map((e) => /* @__PURE__ */ s("div", {
536
+ children: X.map((e) => /* @__PURE__ */ s("div", {
518
537
  className: "flex-1 animate-pulse rounded-t-sm bg-muted",
519
538
  style: { height: `${e.height / 200 * 100}%` }
520
539
  }, e.x))
@@ -523,7 +542,7 @@ function de({ ariaLabel: t = "Loading chart", className: n, ...r }) {
523
542
  }
524
543
  //#endregion
525
544
  //#region src/primitives/LineChartSkeleton.tsx
526
- function fe({ ariaLabel: t = "Loading chart", className: n, ...r }) {
545
+ function _e({ ariaLabel: t = "Loading chart", className: n, ...r }) {
527
546
  return /* @__PURE__ */ s("div", {
528
547
  role: "img",
529
548
  "aria-label": t,
@@ -556,25 +575,165 @@ function fe({ ariaLabel: t = "Loading chart", className: n, ...r }) {
556
575
  }
557
576
  //#endregion
558
577
  //#region src/primitives/CartesianChartSkeleton.tsx
559
- function pe({ ariaLabel: t = "Loading chart", className: n, ...r }) {
578
+ function ve({ ariaLabel: t = "Loading chart", className: n, ...r }) {
560
579
  return /* @__PURE__ */ c("div", {
561
580
  role: "img",
562
581
  "aria-label": t,
563
582
  "aria-busy": "true",
564
583
  className: e("relative flex h-full w-full overflow-hidden", n),
565
584
  ...r,
566
- children: [/* @__PURE__ */ s(de, {
585
+ children: [/* @__PURE__ */ s(Z, {
567
586
  "aria-hidden": "true",
568
587
  className: "absolute inset-0"
569
- }), /* @__PURE__ */ s(fe, {
588
+ }), /* @__PURE__ */ s(_e, {
570
589
  "aria-hidden": "true",
571
590
  className: "absolute inset-0"
572
591
  })]
573
592
  });
574
593
  }
575
594
  //#endregion
595
+ //#region src/primitives/cartesianGeometry.ts
596
+ function ye(e, t) {
597
+ let n = t.bandwidth() / 2;
598
+ return e.map((e) => (t(e) ?? 0) + n);
599
+ }
600
+ function be(e, t, n, r) {
601
+ return r === "vertical" ? e.clientX - t.left - n.left : e.clientY - t.top - n.top;
602
+ }
603
+ function Q(e, t) {
604
+ return Math.min(Math.max(e, 0), t);
605
+ }
606
+ function xe(e, t) {
607
+ if (t.length === 0) return -1;
608
+ let n = 0, r = Infinity;
609
+ for (let i = 0; i < t.length; i++) {
610
+ let a = Math.abs(e - t[i]);
611
+ a < r && (r = a, n = i);
612
+ }
613
+ return n;
614
+ }
615
+ function Se(e, t) {
616
+ return e <= t ? {
617
+ startIndex: e,
618
+ endIndex: t
619
+ } : {
620
+ startIndex: t,
621
+ endIndex: e
622
+ };
623
+ }
624
+ function Ce(e, t) {
625
+ return e.startIndex === t.startIndex && e.endIndex === t.endIndex;
626
+ }
627
+ function we(e) {
628
+ return e.endIndex - e.startIndex + 1;
629
+ }
630
+ function $(e, t, n) {
631
+ let r = e > 0 ? (t[e - 1] + t[e]) / 2 : 0, i = e < t.length - 1 ? (t[e] + t[e + 1]) / 2 : n;
632
+ return {
633
+ start: Q(r, n),
634
+ end: Q(i, n)
635
+ };
636
+ }
637
+ function Te(e, t, n) {
638
+ return {
639
+ start: $(e.startIndex, t, n).start,
640
+ end: $(e.endIndex, t, n).end
641
+ };
642
+ }
643
+ function Ee(e, t, n) {
644
+ return Math.abs(t - e) >= n;
645
+ }
646
+ function De(e, t) {
647
+ return t < 2 ? !0 : e === "auto" ? t <= 4 : e;
648
+ }
649
+ //#endregion
650
+ //#region src/primitives/ChartBrushOverlay.tsx
651
+ var Oe = "var(--primary)", ke = "var(--muted-foreground)", Ae = "var(--background)", je = .1, Me = .45, Ne = 6;
652
+ function Pe({ draft: e, centers: t, extent: n, crossExtent: r, layout: i, label: a }) {
653
+ let { start: l, end: u } = Te(e.range, t, n), d = i === "vertical", f = (e, t) => d ? {
654
+ x: e,
655
+ y: 0,
656
+ width: Math.max(0, t - e),
657
+ height: r
658
+ } : {
659
+ x: 0,
660
+ y: e,
661
+ width: r,
662
+ height: Math.max(0, t - e)
663
+ }, p = (e) => d ? {
664
+ x1: e,
665
+ x2: e,
666
+ y1: 0,
667
+ y2: r
668
+ } : {
669
+ x1: 0,
670
+ x2: r,
671
+ y1: e,
672
+ y2: e
673
+ }, m = e.tooNarrow ? ke : Oe, h = P(a.length), g = (l + u) / 2, _ = d ? {
674
+ x: Q(g - h / 2, Math.max(0, n - h)),
675
+ y: Ne
676
+ } : {
677
+ x: Ne,
678
+ y: Q(g - 20 / 2, Math.max(0, n - 20))
679
+ };
680
+ return /* @__PURE__ */ c("g", {
681
+ "aria-hidden": "true",
682
+ "data-slot": "chart-brush",
683
+ "data-state": e.tooNarrow ? "too-narrow" : "selecting",
684
+ className: "pointer-events-none",
685
+ children: [
686
+ !e.tooNarrow && /* @__PURE__ */ c(o, { children: [
687
+ /* @__PURE__ */ s("rect", {
688
+ ...f(0, l),
689
+ fill: Ae,
690
+ fillOpacity: Me
691
+ }),
692
+ /* @__PURE__ */ s("rect", {
693
+ ...f(u, n),
694
+ fill: Ae,
695
+ fillOpacity: Me
696
+ }),
697
+ /* @__PURE__ */ s("rect", {
698
+ ...f(l, u),
699
+ "data-slot": "chart-brush-band",
700
+ fill: Oe,
701
+ fillOpacity: je
702
+ })
703
+ ] }),
704
+ /* @__PURE__ */ s("line", {
705
+ ...p(l),
706
+ "data-slot": "chart-brush-edge",
707
+ stroke: m,
708
+ strokeWidth: 1,
709
+ shapeRendering: "crispEdges"
710
+ }),
711
+ /* @__PURE__ */ s("line", {
712
+ ...p(u),
713
+ "data-slot": "chart-brush-edge",
714
+ stroke: m,
715
+ strokeWidth: 1,
716
+ shapeRendering: "crispEdges"
717
+ }),
718
+ /* @__PURE__ */ s("foreignObject", {
719
+ x: _.x,
720
+ y: _.y,
721
+ width: h,
722
+ height: 20,
723
+ overflow: "visible",
724
+ children: /* @__PURE__ */ s("span", {
725
+ "data-slot": "chart-brush-label",
726
+ className: ie,
727
+ style: F(m),
728
+ children: a
729
+ })
730
+ })
731
+ ]
732
+ });
733
+ }
734
+ //#endregion
576
735
  //#region src/primitives/ChartEmptyState.tsx
577
- function me({ ariaLabel: a, className: o, ...l }) {
736
+ function Fe({ ariaLabel: a, className: o, ...l }) {
578
737
  return /* @__PURE__ */ s("div", {
579
738
  role: "img",
580
739
  "aria-label": a,
@@ -585,7 +744,7 @@ function me({ ariaLabel: a, className: o, ...l }) {
585
744
  }
586
745
  //#endregion
587
746
  //#region src/primitives/TooltipPortal.tsx
588
- function he({ state: e, containerRef: t, chartId: n, children: r }) {
747
+ function Ie({ state: e, containerRef: t, chartId: n, children: r }) {
589
748
  let i = a.useRef(null), [o, c] = a.useState({
590
749
  x: 0,
591
750
  y: 0,
@@ -628,9 +787,101 @@ function he({ state: e, containerRef: t, chartId: n, children: r }) {
628
787
  children: r
629
788
  }), document.body);
630
789
  }
790
+ var Le = { status: "idle" };
791
+ function Re(e, t, n) {
792
+ try {
793
+ n === "set" ? e.setPointerCapture(t) : e.releasePointerCapture(t);
794
+ } catch {}
795
+ }
796
+ function ze(e) {
797
+ return Math.max(1, Math.floor(e) || 1);
798
+ }
799
+ function Be(e) {
800
+ let { slot: t, extent: n, layout: r, categoryKey: i } = e, o = t !== null && !t.disabled, s = a.useRef(e), c = a.useRef(t);
801
+ a.useLayoutEffect(() => {
802
+ s.current = e, e.slot && (c.current = e.slot);
803
+ });
804
+ let l = a.useRef(Le), u = a.useRef(null), [d, f] = a.useState(null), p = a.useMemo(() => {
805
+ let e = (e) => {
806
+ let { plotRef: t, margin: n, layout: r, extent: i } = s.current, a = t.current?.getBoundingClientRect();
807
+ return a ? Q(be(e, a, n, r), i) : null;
808
+ }, t = (e) => {
809
+ let t = l.current;
810
+ if (l.current = Le, u.current &&= (document.removeEventListener("keydown", u.current), null), t.status !== "dragging") return;
811
+ f(null);
812
+ let n = s.current.slot ?? c.current;
813
+ n && (e === "commit" && we(t.range) >= ze(n.minCategories) ? n.onBrushEnd(t.range) : n.onBrushCancel?.());
814
+ }, n = (n) => {
815
+ let { slot: r, centers: i } = s.current;
816
+ if (!r || r.disabled || n.button !== 0 || l.current.status !== "idle") return;
817
+ let a = e(n);
818
+ if (a === null) return;
819
+ let o = xe(a, i);
820
+ if (o < 0) return;
821
+ Re(n.currentTarget, n.pointerId, "set"), l.current = {
822
+ status: "pending",
823
+ pointerId: n.pointerId,
824
+ origin: a,
825
+ originIndex: o
826
+ };
827
+ let c = (e) => {
828
+ e.key === "Escape" && t("cancel");
829
+ };
830
+ u.current = c, document.addEventListener("keydown", c);
831
+ }, r = (t) => {
832
+ let n = l.current;
833
+ if (n.status === "idle" || t.pointerId !== n.pointerId) return;
834
+ let r = e(t);
835
+ if (r === null || n.status === "pending" && !Ee(n.origin, r, 4)) return;
836
+ let { centers: i, slot: a, onDragStart: o } = s.current, c = xe(r, i);
837
+ if (c < 0) return;
838
+ let u = Se(n.originIndex, c);
839
+ n.status === "dragging" && Ce(n.range, u) || (n.status === "pending" && o(), l.current = {
840
+ status: "dragging",
841
+ pointerId: n.pointerId,
842
+ originIndex: n.originIndex,
843
+ range: u
844
+ }, f({
845
+ range: u,
846
+ tooNarrow: we(u) < ze(a?.minCategories ?? 1)
847
+ }), a?.onBrushChange?.(u));
848
+ }, i = (e) => {
849
+ let n = l.current;
850
+ n.status === "idle" || e.pointerId !== n.pointerId || (Re(e.currentTarget, e.pointerId, "release"), t("commit"));
851
+ }, a = (e) => {
852
+ let n = l.current;
853
+ n.status === "idle" || e.pointerId !== n.pointerId || t("cancel");
854
+ };
855
+ return {
856
+ handlers: {
857
+ onPointerDown: n,
858
+ onPointerMove: r,
859
+ onPointerUp: i,
860
+ onPointerCancel: a,
861
+ onLostPointerCapture: a
862
+ },
863
+ cancel: () => t("cancel"),
864
+ isDragging: () => l.current.status === "dragging"
865
+ };
866
+ }, []);
867
+ return a.useEffect(() => {
868
+ l.current.status !== "idle" && p.cancel();
869
+ }, [
870
+ i,
871
+ n,
872
+ r,
873
+ o,
874
+ p
875
+ ]), a.useEffect(() => () => p.cancel(), [p]), {
876
+ active: o,
877
+ draft: d,
878
+ isDragging: p.isDragging,
879
+ handlers: p.handlers
880
+ };
881
+ }
631
882
  //#endregion
632
883
  //#region src/primitives/CartesianChart.tsx
633
- function ge(e) {
884
+ function Ve(e) {
634
885
  let t = [], n = (e) => {
635
886
  a.Children.forEach(e, (e) => {
636
887
  if (!a.isValidElement(e)) return;
@@ -652,7 +903,11 @@ function ge(e) {
652
903
  };
653
904
  return n(e), t;
654
905
  }
655
- function _e(e) {
906
+ function He(e, t, n) {
907
+ let r = n(t[e.startIndex] ?? ""), i = n(t[e.endIndex] ?? "");
908
+ return e.startIndex === e.endIndex ? r : `${r} – ${i}`;
909
+ }
910
+ function Ue(e) {
656
911
  let t = !1, n = (e) => {
657
912
  a.Children.forEach(e, (e) => {
658
913
  if (t || !a.isValidElement(e)) return;
@@ -666,17 +921,17 @@ function _e(e) {
666
921
  };
667
922
  return n(e), t;
668
923
  }
669
- function ve({ state: e, className: t, data: n, margin: r, categoryPadding: i, categoryScaleType: a, layout: o, colorMode: c, animated: l, ariaLabel: u, valueTickFormatter: d, categoryTickFormatter: f, onPointHover: p, onPointLeave: m, children: h, ...g }) {
670
- let _ = $(e, n.length);
671
- return _ === "loading" ? /* @__PURE__ */ s(pe, {
924
+ function We({ state: e, className: t, data: n, margin: r, categoryPadding: i, categoryScaleType: a, layout: o, colorMode: c, animated: l, ariaLabel: u, valueTickFormatter: d, categoryTickFormatter: f, onPointHover: p, onPointLeave: m, children: h, ...g }) {
925
+ let _ = ge(e, n.length);
926
+ return _ === "loading" ? /* @__PURE__ */ s(ve, {
672
927
  ariaLabel: u,
673
928
  className: t,
674
929
  ...g
675
- }) : _ === "empty" ? /* @__PURE__ */ s(me, {
930
+ }) : _ === "empty" ? /* @__PURE__ */ s(Fe, {
676
931
  ariaLabel: u ?? "No data",
677
932
  className: t,
678
933
  ...g
679
- }) : /* @__PURE__ */ s(Z, { children: /* @__PURE__ */ s(ye, {
934
+ }) : /* @__PURE__ */ s(Y, { children: /* @__PURE__ */ s(Ge, {
680
935
  data: n,
681
936
  margin: r,
682
937
  categoryPadding: i,
@@ -694,9 +949,9 @@ function ve({ state: e, className: t, data: n, margin: r, categoryPadding: i, ca
694
949
  children: h
695
950
  }) });
696
951
  }
697
- function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i = "band", layout: o = "vertical", colorMode: h = "series", animated: g = !0, ariaLabel: v, valueTickFormatter: b = _, categoryTickFormatter: S = String, onPointHover: w, onPointLeave: T, className: E, children: D, ...k }) {
698
- let { config: A, id: j } = C(), { tooltip: N, legend: P } = le(), F = a.useMemo(() => _e(D), [D]), I = a.useMemo(() => {
699
- let e = ge(D), n = {};
952
+ function Ge({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i = "band", layout: o = "vertical", colorMode: h = "series", animated: g = !0, ariaLabel: v, valueTickFormatter: b = _, categoryTickFormatter: S = String, onPointHover: w, onPointLeave: T, className: ee, children: E, ...O }) {
953
+ let { config: k, id: A } = C(), { tooltip: M, legend: N, brush: ne } = pe(), re = a.useMemo(() => Ue(E), [E]), ie = a.useMemo(() => {
954
+ let e = Ve(E), n = {};
700
955
  for (let r of ["left", "right"]) {
701
956
  let i = e.filter((e) => (e.axisId ?? "left") === r).map((e) => e.dataKey);
702
957
  if (i.length === 0) continue;
@@ -709,7 +964,7 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
709
964
  }
710
965
  let o = b(Math.ceil(a * 1.1)), s = "";
711
966
  for (let t of e) if ((t.axisId ?? "left") === r) {
712
- let e = A[t.dataKey]?.unit;
967
+ let e = k[t.dataKey]?.unit;
713
968
  if (e) {
714
969
  s = e;
715
970
  break;
@@ -719,18 +974,18 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
719
974
  }
720
975
  return n;
721
976
  }, [
722
- D,
977
+ E,
723
978
  t,
724
- A,
979
+ k,
725
980
  b
726
- ]), L = {
981
+ ]), P = {
727
982
  ...y,
728
983
  ...n
729
984
  };
730
- I.left !== void 0 && n?.left === void 0 && (L.left = Math.max(L.left, I.left)), F && n?.right === void 0 && (L.right = Math.max(L.right, I.right ?? 40));
731
- let R = o === "vertical", z = a.useRef(null), te = a.useRef(null), B = O(te), V = ee(), [ne, re] = a.useState(null), [H, U] = a.useState(null), W = a.useCallback((e) => U(e), []), ie = a.useCallback(() => U(null), []), G = Math.max(0, B.width - L.left - L.right), K = Math.max(0, B.height - L.top - L.bottom), ae = L.left, q = a.useMemo(() => t.map((e) => e.category), [t]), J = a.useMemo(() => ge(D), [D]), Y = a.useMemo(() => J.map((e) => e.dataKey), [J]), X = a.useMemo(() => {
985
+ ie.left !== void 0 && n?.left === void 0 && (P.left = Math.max(P.left, ie.left)), re && n?.right === void 0 && (P.right = Math.max(P.right, ie.right ?? 40));
986
+ let F = o === "vertical", I = a.useRef(null), L = a.useRef(null), R = D(L), z = te(), [ae, oe] = a.useState(null), [se, B] = a.useState(null), V = a.useCallback((e) => B(e), []), ce = a.useCallback(() => B(null), []), H = Math.max(0, R.width - P.left - P.right), U = Math.max(0, R.height - P.top - P.bottom), le = P.left, W = a.useMemo(() => t.map((e) => e.category), [t]), G = a.useMemo(() => Ve(E), [E]), K = a.useMemo(() => G.map((e) => e.dataKey), [G]), q = a.useMemo(() => {
732
987
  let e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
733
- for (let e of J) {
988
+ for (let e of G) {
734
989
  if (!e.stackId) continue;
735
990
  let t = n.get(e.stackId) ?? [];
736
991
  t.push(e.dataKey), n.set(e.stackId, t);
@@ -745,20 +1000,20 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
745
1000
  e.set(r, n(t));
746
1001
  }
747
1002
  return e;
748
- }, [t, J]), oe = a.useMemo(() => J.filter((e) => e.seriesType === "BarSeries" && !e.stackId).map((e) => e.dataKey), [J]), se = a.useMemo(() => {
1003
+ }, [t, G]), ue = a.useMemo(() => G.filter((e) => e.seriesType === "BarSeries" && !e.stackId).map((e) => e.dataKey), [G]), de = a.useMemo(() => {
749
1004
  let e = /* @__PURE__ */ new Map();
750
- for (let t of J) {
1005
+ for (let t of G) {
751
1006
  let n = t.axisId ?? "left", r = e.get(n) ?? [];
752
1007
  r.push(t.dataKey), e.set(n, r);
753
1008
  }
754
1009
  return e;
755
- }, [J]), ce = a.useMemo(() => {
1010
+ }, [G]), fe = a.useMemo(() => {
756
1011
  let e = /* @__PURE__ */ new Map();
757
- for (let [n, r] of se) {
758
- let i = new Set(r), a = J.some((e) => e.stackId && i.has(e.dataKey)), o = r.filter((e) => !J.find((t) => t.dataKey === e && t.stackId));
1012
+ for (let [n, r] of de) {
1013
+ let i = new Set(r), a = G.some((e) => e.stackId && i.has(e.dataKey)), o = r.filter((e) => !G.find((t) => t.dataKey === e && t.stackId));
759
1014
  if (a) {
760
1015
  let r = -Infinity;
761
- for (let e of X.values()) if (e.some((e) => i.has(e.key))) for (let t of e) for (let e of t) e[1] > r && (r = e[1]);
1016
+ for (let e of q.values()) if (e.some((e) => i.has(e.key))) for (let t of e) for (let e of t) e[1] > r && (r = e[1]);
762
1017
  for (let e of t) for (let t of o) {
763
1018
  let n = e[t];
764
1019
  if (n == null) continue;
@@ -779,45 +1034,47 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
779
1034
  }
780
1035
  return e;
781
1036
  }, [
782
- se,
1037
+ de,
783
1038
  t,
784
- X,
785
- J
786
- ]), Z = a.useMemo(() => i === "point" ? Object.assign(d().domain(q).range([0, R ? G : K]).padding(0), { bandwidth: () => 0 }) : l().domain(q).range([0, R ? G : K]).padding(r), [
787
1039
  q,
1040
+ G
1041
+ ]), J = a.useMemo(() => i === "point" ? Object.assign(d().domain(W).range([0, F ? H : U]).padding(0), { bandwidth: () => 0 }) : l().domain(W).range([0, F ? H : U]).padding(r), [
1042
+ W,
788
1043
  i,
789
1044
  r,
790
- R,
791
- G,
792
- K
793
- ]), Q = a.useMemo(() => {
1045
+ F,
1046
+ H,
1047
+ U
1048
+ ]), Y = a.useMemo(() => ye(W, J), [W, J]), me = F ? H : U, ge = a.useMemo(() => W.join(""), [W]);
1049
+ he(a.useMemo(() => null, [W])), he(a.useMemo(() => null, [ne?.minCategories, t.length]));
1050
+ let X = a.useMemo(() => {
794
1051
  let e = {};
795
- for (let [t, [n, r]] of ce) e[t] = u().domain([Math.min(0, n), r * 1.1 || 1]).nice().range(R ? [K, 0] : [0, G]);
796
- return e.left ||= u().domain([0, 1]).nice().range(R ? [K, 0] : [0, G]), e;
1052
+ for (let [t, [n, r]] of fe) e[t] = u().domain([Math.min(0, n), r * 1.1 || 1]).nice().range(F ? [U, 0] : [0, H]);
1053
+ return e.left ||= u().domain([0, 1]).nice().range(F ? [U, 0] : [0, H]), e;
797
1054
  }, [
798
- ce,
799
- R,
800
- K,
801
- G
802
- ]), $ = Q.left, ue = a.useCallback((e) => e ? Q[e] ?? $ : $, [$, Q]), de = a.useMemo(() => {
1055
+ fe,
1056
+ F,
1057
+ U,
1058
+ H
1059
+ ]), Z = X.left, _e = a.useCallback((e) => e ? X[e] ?? Z : Z, [Z, X]), ve = a.useMemo(() => {
803
1060
  let e = {};
804
- for (let t of J) {
1061
+ for (let t of G) {
805
1062
  let n = t.axisId ?? "left";
806
1063
  if (e[n]) continue;
807
- let r = A[t.dataKey]?.unit;
1064
+ let r = k[t.dataKey]?.unit;
808
1065
  r && (e[n] = r);
809
1066
  }
810
1067
  return e;
811
- }, [J, A]), fe = a.useMemo(() => oe.length <= 1 ? null : l().domain(oe).range([0, Z.bandwidth()]).padding(.05), [oe, Z]), pe = h === "category" ? q.map((e) => ({
1068
+ }, [G, k]), Q = a.useMemo(() => ue.length <= 1 ? null : l().domain(ue).range([0, J.bandwidth()]).padding(.05), [ue, J]), Se = h === "category" ? W.map((e) => ({
812
1069
  dataKey: e,
813
1070
  value: e
814
- })) : Y.map((e) => ({
1071
+ })) : K.map((e) => ({
815
1072
  dataKey: e,
816
1073
  value: e
817
1074
  }));
818
- function me(e) {
1075
+ function Ce(e) {
819
1076
  if (h === "category") {
820
- let t = Y[0], n = t === void 0 ? 0 : Number(e[t]) || 0;
1077
+ let t = K[0], n = t === void 0 ? 0 : Number(e[t]) || 0;
821
1078
  return [{
822
1079
  dataKey: e.category,
823
1080
  name: e.category,
@@ -825,47 +1082,53 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
825
1082
  color: `var(--color-${x(e.category)})`
826
1083
  }];
827
1084
  }
828
- return Y.filter((t) => e[t] !== null && e[t] !== void 0).map((t) => ({
1085
+ return K.filter((t) => e[t] !== null && e[t] !== void 0).map((t) => ({
829
1086
  dataKey: t,
830
1087
  name: t,
831
1088
  value: Number(e[t]) || 0
832
1089
  }));
833
1090
  }
834
- function ve(e) {
835
- let n = z.current?.getBoundingClientRect();
1091
+ function we() {
1092
+ oe(null), z.hide(), T?.();
1093
+ }
1094
+ let $ = Be({
1095
+ slot: ne,
1096
+ centers: Y,
1097
+ extent: me,
1098
+ layout: o,
1099
+ margin: P,
1100
+ plotRef: I,
1101
+ onDragStart: we,
1102
+ categoryKey: ge
1103
+ }), Te = $.draft ? He($.draft.range, W, S) : "";
1104
+ function Ee(e) {
1105
+ if ($.isDragging()) return;
1106
+ let n = I.current?.getBoundingClientRect();
836
1107
  if (!n) return;
837
- let r = R ? e.clientX - n.left - L.left : e.clientY - n.top - L.top, i = 0, a = Infinity;
838
- for (let e = 0; e < q.length; e++) {
839
- let t = (Z(q[e]) ?? 0) + Z.bandwidth() / 2, n = Math.abs(r - t);
840
- n < a && (a = n, i = e);
841
- }
842
- let o = t[i];
843
- if (!o) return;
844
- re(o.category);
845
- let s = me(o), c = (Z(o.category) ?? 0) + Z.bandwidth() / 2, l = R ? {
846
- clientX: n.left + L.left + c,
1108
+ let r = xe(be(e, n, P, o), Y), i = t[r];
1109
+ if (!i) return;
1110
+ oe(i.category);
1111
+ let a = Ce(i), s = Y[r], c = F ? {
1112
+ clientX: n.left + P.left + s,
847
1113
  clientY: e.clientY
848
1114
  } : {
849
1115
  clientX: e.clientX,
850
- clientY: n.top + L.top + c
1116
+ clientY: n.top + P.top + s
851
1117
  };
852
- N && V.show(s, o.category, l, n), w?.(s, o.category, e);
853
- }
854
- function ye() {
855
- re(null), V.hide(), T?.();
1118
+ M && z.show(a, i.category, c, n), w?.(a, i.category, e);
856
1119
  }
857
- let be = a.useCallback((e, n) => {
858
- if (!N) return;
859
- let r = z.current?.getBoundingClientRect();
1120
+ let De = a.useCallback((e, n) => {
1121
+ if (!M) return;
1122
+ let r = I.current?.getBoundingClientRect();
860
1123
  if (!r) return;
861
1124
  let i = t.find((t) => t.category === e);
862
1125
  if (!i) return;
863
1126
  let a = h === "category" ? [{
864
1127
  dataKey: e,
865
1128
  name: e,
866
- value: Y[0] === void 0 ? 0 : Number(i[Y[0]]) || 0,
1129
+ value: K[0] === void 0 ? 0 : Number(i[K[0]]) || 0,
867
1130
  color: `var(--color-${x(e)})`
868
- }] : Y.filter((e) => i[e] !== null && i[e] !== void 0).map((e) => ({
1131
+ }] : K.filter((e) => i[e] !== null && i[e] !== void 0).map((e) => ({
869
1132
  dataKey: e,
870
1133
  name: e,
871
1134
  value: Number(i[e]) || 0
@@ -873,130 +1136,140 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
873
1136
  clientX: n.left + n.width / 2,
874
1137
  clientY: n.top + n.height / 2
875
1138
  };
876
- V.show(a, e, o, r);
1139
+ z.show(a, e, o, r);
877
1140
  }, [
878
- N,
1141
+ M,
879
1142
  t,
880
- Y,
1143
+ K,
881
1144
  h,
882
- V
883
- ]), xe = a.useCallback(() => {
884
- V.hide();
885
- }, [V]), Se = P?.verticalAlign ?? "bottom", Ce = v ?? `Chart with ${t.length} categor${t.length === 1 ? "y" : "ies"} and ${Y.length} series`, we = a.useMemo(() => ({
1145
+ z
1146
+ ]), Oe = a.useCallback(() => {
1147
+ z.hide();
1148
+ }, [z]), ke = N?.verticalAlign ?? "bottom", Ae = v ?? `Chart with ${t.length} categor${t.length === 1 ? "y" : "ies"} and ${K.length} series`, je = a.useMemo(() => ({
886
1149
  data: t,
887
- dataKeys: Y,
1150
+ dataKeys: K,
888
1151
  colorMode: h,
889
- categoryScale: Z,
890
- valueScale: $,
891
- valueScales: Q,
892
- resolveValueScale: ue,
893
- axisUnits: de,
894
- innerWidth: G,
895
- innerHeight: K,
896
- marginLeft: ae,
1152
+ categoryScale: J,
1153
+ valueScale: Z,
1154
+ valueScales: X,
1155
+ resolveValueScale: _e,
1156
+ axisUnits: ve,
1157
+ innerWidth: H,
1158
+ innerHeight: U,
1159
+ marginLeft: le,
897
1160
  layout: o,
898
1161
  animated: g,
899
- hoveredCategory: ne,
900
- hoveredLegendKey: H,
901
- config: A,
902
- stackedLayers: X,
903
- barGroupScale: fe,
1162
+ hoveredCategory: ae,
1163
+ hoveredLegendKey: se,
1164
+ config: k,
1165
+ stackedLayers: q,
1166
+ barGroupScale: Q,
904
1167
  valueTickFormatter: b,
905
1168
  categoryTickFormatter: S,
906
- chartWrapperRef: z,
907
- chartId: j,
908
- showTooltipAt: be,
909
- hideTooltip: xe
1169
+ chartWrapperRef: I,
1170
+ chartId: A,
1171
+ showTooltipAt: De,
1172
+ hideTooltip: Oe
910
1173
  }), [
911
1174
  t,
912
- Y,
1175
+ K,
913
1176
  h,
1177
+ J,
914
1178
  Z,
915
- $,
916
- Q,
917
- ue,
918
- de,
919
- G,
920
- K,
921
- ae,
1179
+ X,
1180
+ _e,
1181
+ ve,
1182
+ H,
1183
+ U,
1184
+ le,
922
1185
  o,
923
1186
  g,
924
- ne,
925
- H,
926
- A,
927
- X,
928
- fe,
1187
+ ae,
1188
+ se,
1189
+ k,
1190
+ q,
1191
+ Q,
929
1192
  b,
930
1193
  S,
931
- j,
932
- be,
933
- xe
1194
+ A,
1195
+ De,
1196
+ Oe
934
1197
  ]);
935
- return /* @__PURE__ */ s(M.Provider, {
936
- value: we,
1198
+ return /* @__PURE__ */ s(j.Provider, {
1199
+ value: je,
937
1200
  children: /* @__PURE__ */ c("div", {
938
- className: e("flex h-full w-full flex-col", E),
939
- ...k,
1201
+ className: e("flex h-full w-full flex-col", ee),
1202
+ ...O,
940
1203
  children: [
941
- P && Se === "top" && a.cloneElement(P.content, {
942
- items: pe,
1204
+ N && ke === "top" && a.cloneElement(N.content, {
1205
+ items: Se,
943
1206
  verticalAlign: "top",
944
- onItemHover: W,
945
- onItemLeave: ie,
946
- hoveredLegendKey: H
1207
+ onItemHover: V,
1208
+ onItemLeave: ce,
1209
+ hoveredLegendKey: se
947
1210
  }),
948
1211
  /* @__PURE__ */ c("div", {
949
- ref: z,
950
- className: "relative min-h-0 flex-1",
951
- onMouseMove: ve,
952
- onMouseLeave: ye,
1212
+ ref: I,
1213
+ "data-slot": "chart-plot",
1214
+ "data-dashboard-grid-no-drag": $.active ? "" : void 0,
1215
+ className: e("relative min-h-0 flex-1", $.active && "cursor-crosshair select-none", $.active && (F ? "touch-pan-y" : "touch-pan-x")),
1216
+ onMouseMove: Ee,
1217
+ onMouseLeave: we,
1218
+ ...$.handlers,
953
1219
  children: [
954
1220
  /* @__PURE__ */ s("svg", {
955
- ref: te,
1221
+ ref: L,
956
1222
  role: "img",
957
- "aria-label": Ce,
1223
+ "aria-label": Ae,
958
1224
  className: "h-full w-full",
959
1225
  overflow: "visible",
960
- children: B.width > 0 && B.height > 0 && /* @__PURE__ */ s("g", {
961
- transform: `translate(${L.left},${L.top})`,
962
- children: D
1226
+ children: R.width > 0 && R.height > 0 && /* @__PURE__ */ c("g", {
1227
+ transform: `translate(${P.left},${P.top})`,
1228
+ children: [E, $.draft && /* @__PURE__ */ s(Pe, {
1229
+ draft: $.draft,
1230
+ centers: Y,
1231
+ extent: me,
1232
+ crossExtent: F ? U : H,
1233
+ layout: o,
1234
+ label: Te
1235
+ })]
963
1236
  })
964
1237
  }),
965
1238
  /* @__PURE__ */ s("div", {
966
1239
  className: "sr-only",
967
1240
  children: /* @__PURE__ */ c("table", { children: [
968
- /* @__PURE__ */ s("caption", { children: Ce }),
1241
+ /* @__PURE__ */ s("caption", { children: Ae }),
969
1242
  /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
970
1243
  scope: "col",
971
1244
  children: "Category"
972
- }), Y.map((e) => /* @__PURE__ */ s("th", {
1245
+ }), K.map((e) => /* @__PURE__ */ s("th", {
973
1246
  scope: "col",
974
- children: typeof A[e]?.label == "string" ? A[e]?.label : e
1247
+ children: typeof k[e]?.label == "string" ? k[e]?.label : e
975
1248
  }, e))] }) }),
976
1249
  /* @__PURE__ */ s("tbody", { children: t.map((e) => /* @__PURE__ */ c("tr", { children: [/* @__PURE__ */ s("th", {
977
1250
  scope: "row",
978
1251
  children: e.category
979
- }), Y.map((t) => /* @__PURE__ */ s("td", { children: e[t] !== null && e[t] !== void 0 ? b(Number(e[t]) || 0) : "—" }, t))] }, e.category)) })
1252
+ }), K.map((t) => /* @__PURE__ */ s("td", { children: e[t] !== null && e[t] !== void 0 ? b(Number(e[t]) || 0) : "—" }, t))] }, e.category)) })
980
1253
  ] })
981
1254
  }),
982
- N && V.state && /* @__PURE__ */ s(he, {
983
- state: V.state,
984
- containerRef: z,
985
- chartId: j,
986
- children: a.cloneElement(N.content, {
987
- label: V.state.label,
988
- items: V.state.items,
1255
+ M && z.state && /* @__PURE__ */ s(Ie, {
1256
+ state: z.state,
1257
+ containerRef: I,
1258
+ chartId: A,
1259
+ children: a.cloneElement(M.content, {
1260
+ label: z.state.label,
1261
+ items: z.state.items,
989
1262
  active: !0
990
1263
  })
991
1264
  })
992
1265
  ]
993
1266
  }),
994
- P && Se === "bottom" && a.cloneElement(P.content, {
995
- items: pe,
1267
+ N && ke === "bottom" && a.cloneElement(N.content, {
1268
+ items: Se,
996
1269
  verticalAlign: "bottom",
997
- onItemHover: W,
998
- onItemLeave: ie,
999
- hoveredLegendKey: H
1270
+ onItemHover: V,
1271
+ onItemLeave: ce,
1272
+ hoveredLegendKey: se
1000
1273
  })
1001
1274
  ]
1002
1275
  })
@@ -1004,7 +1277,7 @@ function ye({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i
1004
1277
  }
1005
1278
  //#endregion
1006
1279
  //#region src/primitives/AreaChartSkeleton.tsx
1007
- function be({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1280
+ function Ke({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1008
1281
  return /* @__PURE__ */ s("div", {
1009
1282
  role: "img",
1010
1283
  "aria-label": t,
@@ -1050,7 +1323,7 @@ function be({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1050
1323
  }
1051
1324
  //#endregion
1052
1325
  //#region src/primitives/SkeletonBlock.tsx
1053
- function xe({ className: t, ...n }) {
1326
+ function qe({ className: t, ...n }) {
1054
1327
  return /* @__PURE__ */ s("div", {
1055
1328
  className: e("animate-pulse rounded-md bg-muted", t),
1056
1329
  ...n
@@ -1058,7 +1331,7 @@ function xe({ className: t, ...n }) {
1058
1331
  }
1059
1332
  //#endregion
1060
1333
  //#region src/primitives/DoughnutChartSkeleton.tsx
1061
- function Se({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1334
+ function Je({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1062
1335
  return /* @__PURE__ */ s("div", {
1063
1336
  role: "img",
1064
1337
  "aria-label": t,
@@ -1082,4 +1355,4 @@ function Se({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1082
1355
  });
1083
1356
  }
1084
1357
  //#endregion
1085
- export { C, _ as D, y as E, D as S, v as T, P as _, he as a, O as b, de as c, Z as d, le as f, te as g, oe as h, ve as i, $ as l, X as m, xe as n, me as o, se as p, be as r, fe as s, Se as t, Q as u, N as v, x as w, E as x, ee as y };
1358
+ export { _ as A, D as C, x as D, C as E, v as O, te as S, E as T, de as _, Ie as a, j as b, _e as c, he as d, me as f, ue as g, fe as h, We as i, y as k, Z as l, pe as m, qe as n, Fe as o, Y as p, Ke as r, De as s, Je as t, ge as u, z as v, ee as w, M as x, N as y };