@gravitee/graphene-charts 2.36.2 → 2.36.3-feat-password-input.efed5fc

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 (66) hide show
  1. package/USAGE_GUIDE.md +0 -38
  2. package/dist/base/ChartLegend/ChartLegend.d.ts +1 -7
  3. package/dist/base/ChartLegend/ChartLegend.d.ts.map +1 -1
  4. package/dist/base/ChartTooltip/ChartTooltip.d.ts +1 -7
  5. package/dist/base/ChartTooltip/ChartTooltip.d.ts.map +1 -1
  6. package/dist/charts/DoughnutChart/DoughnutChart.d.ts.map +1 -1
  7. package/dist/dashboard-grid/DashboardGrid.d.ts.map +1 -1
  8. package/dist/dashboard-grid/DashboardWidget.d.ts.map +1 -1
  9. package/dist/dashboard-grid/index.js +47 -49
  10. package/dist/index.d.ts +1 -4
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1767 -4399
  13. package/dist/primitives/Axis.d.ts +2 -10
  14. package/dist/primitives/Axis.d.ts.map +1 -1
  15. package/dist/primitives/CartesianChart.d.ts.map +1 -1
  16. package/dist/primitives/CartesianContext.d.ts +0 -8
  17. package/dist/primitives/CartesianContext.d.ts.map +1 -1
  18. package/dist/primitives/ReferenceLine.d.ts +1 -3
  19. package/dist/primitives/ReferenceLine.d.ts.map +1 -1
  20. package/dist/series/AreaSeries.d.ts +1 -3
  21. package/dist/series/AreaSeries.d.ts.map +1 -1
  22. package/dist/series/BarSeries.d.ts +1 -3
  23. package/dist/series/BarSeries.d.ts.map +1 -1
  24. package/dist/series/LineSeries.d.ts +1 -3
  25. package/dist/series/LineSeries.d.ts.map +1 -1
  26. package/dist/types/index.d.ts +0 -2
  27. package/dist/types/index.d.ts.map +1 -1
  28. package/package.json +4 -15
  29. package/dist/charts/TraceWaterfall/TraceWaterfall.d.ts +0 -22
  30. package/dist/charts/TraceWaterfall/TraceWaterfall.d.ts.map +0 -1
  31. package/dist/charts/TraceWaterfall/fixtures.d.ts +0 -12
  32. package/dist/charts/TraceWaterfall/fixtures.d.ts.map +0 -1
  33. package/dist/charts/TraceWaterfall/formatDuration.d.ts +0 -24
  34. package/dist/charts/TraceWaterfall/formatDuration.d.ts.map +0 -1
  35. package/dist/charts/TraceWaterfall/index.d.ts +0 -5
  36. package/dist/charts/TraceWaterfall/index.d.ts.map +0 -1
  37. package/dist/charts/TraceWaterfall/types.d.ts +0 -20
  38. package/dist/charts/TraceWaterfall/types.d.ts.map +0 -1
  39. package/dist/lib/format.d.ts +0 -18
  40. package/dist/lib/format.d.ts.map +0 -1
  41. package/dist/lib/surface.d.ts +0 -8
  42. package/dist/lib/surface.d.ts.map +0 -1
  43. package/dist/lineage/AnimatedEdge.d.ts +0 -12
  44. package/dist/lineage/AnimatedEdge.d.ts.map +0 -1
  45. package/dist/lineage/BaseNode.d.ts +0 -6
  46. package/dist/lineage/BaseNode.d.ts.map +0 -1
  47. package/dist/lineage/LineageSkeleton.d.ts +0 -13
  48. package/dist/lineage/LineageSkeleton.d.ts.map +0 -1
  49. package/dist/lineage/LineageViewer.d.ts +0 -3
  50. package/dist/lineage/LineageViewer.d.ts.map +0 -1
  51. package/dist/lineage/StatusLegend.d.ts +0 -2
  52. package/dist/lineage/StatusLegend.d.ts.map +0 -1
  53. package/dist/lineage/highlight.d.ts +0 -21
  54. package/dist/lineage/highlight.d.ts.map +0 -1
  55. package/dist/lineage/index.d.ts +0 -10
  56. package/dist/lineage/index.d.ts.map +0 -1
  57. package/dist/lineage/index.js +0 -624
  58. package/dist/lineage/layout.d.ts +0 -7
  59. package/dist/lineage/layout.d.ts.map +0 -1
  60. package/dist/lineage/styles.css +0 -1139
  61. package/dist/lineage/types.d.ts +0 -114
  62. package/dist/lineage/types.d.ts.map +0 -1
  63. package/dist/primitives/TooltipPortal.d.ts +0 -17
  64. package/dist/primitives/TooltipPortal.d.ts.map +0 -1
  65. package/dist/primitives-Bp_ciIfm.js +0 -1036
  66. package/dist/surface-k4U7sG_T.js +0 -5
@@ -1,1036 +0,0 @@
1
- import { t as e } from "./utils-ySutDPYb.js";
2
- import { Empty as t, EmptyDescription as n, EmptyHeader as r, EmptyTitle as i } from "@gravitee/graphene-core";
3
- import * as a from "react";
4
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
- import { scaleBand as c, scaleLinear as l, scalePoint as u } from "d3-scale";
6
- import { stack as d, stackOffsetNone as f, stackOrderNone as p } from "d3-shape";
7
- import { createPortal as m } from "react-dom";
8
- //#region src/lib/format.ts
9
- var h = [
10
- [0xe8d4a51000, "T"],
11
- [1e9, "G"],
12
- [1e6, "M"],
13
- [1e3, "k"]
14
- ];
15
- function g(e) {
16
- if (e === 0) return "0";
17
- let t = Math.abs(e);
18
- for (let [n, r] of h) if (t >= n) {
19
- let t = Math.round(e / n * 10) / 10;
20
- return (t % 1 == 0 ? String(t) : t.toFixed(1)) + r;
21
- }
22
- return String(e);
23
- }
24
- //#endregion
25
- //#region src/types/index.ts
26
- var _ = {
27
- light: "",
28
- dark: ".dark"
29
- }, v = {
30
- top: 20,
31
- right: 20,
32
- bottom: 30,
33
- left: 40
34
- }, y = a.createContext(null);
35
- function b() {
36
- let e = a.useContext(y);
37
- if (!e) throw Error("useChartConfig must be used within a <ChartContainer>");
38
- return e;
39
- }
40
- function x(e, t) {
41
- return t && (t.height !== void 0 || t.minHeight !== void 0 || t.maxHeight !== void 0) ? !0 : e ? /(?:^|\s)!?(?:min-|max-)?h-[^\s]+/.test(e) : !1;
42
- }
43
- var S = 10;
44
- function C({ id: t, config: n, className: r, children: i, style: c, ...l }) {
45
- let u = a.useId(), d = `chart-${t ?? u.replace(/:/g, "")}`, f = a.useMemo(() => {
46
- let e = Object.entries(n), t = {};
47
- for (let n = 0; n < e.length; n++) {
48
- let [r, i] = e[n];
49
- i.color || i.theme ? t[r] = i : t[r] = {
50
- ...i,
51
- color: `var(--chart-${n % S + 1})`
52
- };
53
- }
54
- return t;
55
- }, [n]), p = a.useMemo(() => Object.entries(f).filter(([, e]) => e.color || e.theme), [f]), m = x(r, c);
56
- return /* @__PURE__ */ o(y.Provider, {
57
- value: {
58
- config: f,
59
- id: d
60
- },
61
- children: /* @__PURE__ */ s("div", {
62
- "data-chart": d,
63
- "data-slot": "chart",
64
- className: e("flex w-full justify-center text-xs", !m && "aspect-video", r),
65
- style: c,
66
- ...l,
67
- children: [p.length > 0 && /* @__PURE__ */ o(E, {
68
- id: d,
69
- config: f
70
- }), i]
71
- })
72
- });
73
- }
74
- var w = /[^a-zA-Z0-9_-]/g;
75
- function T(e) {
76
- return e.replace(w, "");
77
- }
78
- function E({ id: e, config: t }) {
79
- let n = T(e);
80
- return /* @__PURE__ */ o("style", { dangerouslySetInnerHTML: { __html: Object.entries(_).map(([e, r]) => `${r} [data-chart=${n}] {\n${Object.entries(t).map(([t, n]) => {
81
- let r = n.theme?.[e] ?? n.color, i = T(t);
82
- return !r || !i ? null : ` --color-${i}: ${r};`;
83
- }).filter(Boolean).join("\n")}\n}`).join("\n") } });
84
- }
85
- //#endregion
86
- //#region src/primitives/useChartDimensions.ts
87
- function D(e) {
88
- let [t, n] = a.useState({
89
- width: 0,
90
- height: 0
91
- });
92
- return a.useEffect(() => {
93
- let t = e.current;
94
- if (!t) return;
95
- let r = new ResizeObserver(([e]) => {
96
- let { width: t, height: r } = e.contentRect;
97
- n({
98
- width: t,
99
- height: r
100
- });
101
- });
102
- return r.observe(t), () => r.disconnect();
103
- }, [e]), t;
104
- }
105
- //#endregion
106
- //#region src/primitives/useTooltipState.ts
107
- var O = 12, k = -12;
108
- function A(e, t) {
109
- return {
110
- x: e.clientX - t.left + O,
111
- y: e.clientY - t.top + k
112
- };
113
- }
114
- function ee() {
115
- let [e, t] = a.useState(null);
116
- return {
117
- state: e,
118
- show: a.useCallback((e, n, r, i) => {
119
- let { x: a, y: o } = A(r, i);
120
- t({
121
- items: e,
122
- label: n,
123
- x: a,
124
- y: o
125
- });
126
- }, []),
127
- move: a.useCallback((e, n) => {
128
- t((t) => {
129
- if (!t) return t;
130
- let { x: r, y: i } = A(e, n);
131
- return {
132
- ...t,
133
- x: r,
134
- y: i
135
- };
136
- });
137
- }, []),
138
- hide: a.useCallback(() => t(null), [])
139
- };
140
- }
141
- //#endregion
142
- //#region src/primitives/CartesianContext.tsx
143
- var j = a.createContext(null);
144
- function M() {
145
- let e = a.useContext(j);
146
- if (!e) throw Error("useCartesianContext must be used within a <CartesianChart>");
147
- return e;
148
- }
149
- //#endregion
150
- //#region src/primitives/Grid.tsx
151
- function te({ scale: e, length: t, orientation: n, tickCount: r = 5 }) {
152
- let i = a.useContext(j), s = e ?? i?.valueScale, c = i?.layout === "vertical", l = n ?? (c ? "horizontal" : "vertical"), u = t ?? (l === "horizontal" ? i?.innerWidth : i?.innerHeight) ?? 0;
153
- if (!s) return null;
154
- let d = s.ticks(r), f = l === "horizontal";
155
- return /* @__PURE__ */ o("g", {
156
- "aria-hidden": "true",
157
- children: d.map((e) => f ? /* @__PURE__ */ o("line", {
158
- x1: 0,
159
- x2: u,
160
- y1: s(e),
161
- y2: s(e),
162
- className: "stroke-border",
163
- strokeDasharray: "4 4",
164
- strokeOpacity: .5
165
- }, e) : /* @__PURE__ */ o("line", {
166
- x1: s(e),
167
- x2: s(e),
168
- y1: 0,
169
- y2: u,
170
- className: "stroke-border",
171
- strokeDasharray: "4 4",
172
- strokeOpacity: .5
173
- }, e))
174
- });
175
- }
176
- //#endregion
177
- //#region src/primitives/ReferenceLine.tsx
178
- var N = 6, P = 20, F = 6.2, I = 12, ne = "\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";
179
- function L({ x: e, y: t, axisId: n, stroke: r = "currentColor", strokeDasharray: i, strokeWidth: c = 1.5, label: l, labelPosition: u = "end", pulse: d = !1 }) {
180
- let f = a.useContext(j);
181
- if (!f) return null;
182
- let { categoryScale: p, resolveValueScale: m, innerWidth: h, innerHeight: g, layout: _ } = f, v = m(n), y = _ === "vertical", b = e !== void 0, x = t !== void 0;
183
- if (!b && !x) return null;
184
- let S = -1, C = -1, w = !1, T = !1;
185
- if (b) {
186
- let t = p(e);
187
- if (t !== void 0) {
188
- let e = t + p.bandwidth() / 2;
189
- y ? (S = e, w = !0) : (C = e, T = !0);
190
- }
191
- }
192
- if (x) {
193
- let e = v(t);
194
- y ? (C = e, T = !0) : (S = e, w = !0);
195
- }
196
- let E = w && S >= 0 && S <= h, D = T && C >= 0 && C <= g;
197
- if (!E && !D) return null;
198
- let O = d ? .7 : .8, k = l ? re(u, {
199
- xPos: S,
200
- yPos: C,
201
- xInBounds: E,
202
- yInBounds: D,
203
- hasX: w,
204
- hasY: T,
205
- innerWidth: h,
206
- innerHeight: g,
207
- labelLength: l.length
208
- }) : null;
209
- return /* @__PURE__ */ s("g", {
210
- "aria-hidden": "true",
211
- "data-graphene-refline": !0,
212
- style: { "--_refline-opacity": O },
213
- children: [
214
- /* @__PURE__ */ o("style", {
215
- precedence: "graphene-charts",
216
- children: ne
217
- }),
218
- E && /* @__PURE__ */ o("line", {
219
- x1: S,
220
- x2: S,
221
- y1: 0,
222
- y2: g,
223
- stroke: r,
224
- strokeWidth: c,
225
- strokeDasharray: i,
226
- strokeLinecap: "round",
227
- strokeOpacity: O,
228
- ...d ? { "data-graphene-refline-pulse": "" } : {}
229
- }),
230
- D && /* @__PURE__ */ o("line", {
231
- x1: 0,
232
- x2: h,
233
- y1: C,
234
- y2: C,
235
- stroke: r,
236
- strokeWidth: c,
237
- strokeDasharray: i,
238
- strokeLinecap: "round",
239
- strokeOpacity: O,
240
- ...d ? { "data-graphene-refline-pulse": "" } : {}
241
- }),
242
- l && k && /* @__PURE__ */ o("foreignObject", {
243
- x: k.x,
244
- y: k.y,
245
- width: k.width,
246
- height: P,
247
- overflow: "visible",
248
- children: /* @__PURE__ */ o("span", {
249
- className: "inline-flex items-center rounded-md border px-1.5 py-0.5 text-[10px] leading-none font-medium",
250
- style: {
251
- color: r,
252
- borderColor: r,
253
- backgroundColor: `color-mix(in srgb, ${r} 10%, var(--background))`
254
- },
255
- children: l
256
- })
257
- })
258
- ]
259
- });
260
- }
261
- function R(e) {
262
- return e * F + I;
263
- }
264
- function re(e, t) {
265
- let { xPos: n, yPos: r, xInBounds: i, yInBounds: a, hasX: o, hasY: s, innerWidth: c, innerHeight: l, labelLength: u } = t, d = R(u);
266
- if (o && s && i && a) {
267
- let e = n + N + d > c, t = r + N + P > l;
268
- return {
269
- x: e ? n - N - d : n + N,
270
- y: t ? r - N - P : r + N,
271
- width: d
272
- };
273
- }
274
- if (s && a) {
275
- let t = r - N - P < 0;
276
- return {
277
- x: z(e, c, d),
278
- y: t ? r + N : r - N - P,
279
- width: d
280
- };
281
- }
282
- return o && i ? {
283
- x: n + N + d > c ? n - N - d : n + N,
284
- y: ie(e, l),
285
- width: d
286
- } : null;
287
- }
288
- function ie(e, t) {
289
- return e === "start" ? N : e === "center" ? t / 2 - P / 2 : t - P - N;
290
- }
291
- function z(e, t, n) {
292
- return e === "start" ? N : e === "center" ? t / 2 - n / 2 : t - n - N;
293
- }
294
- //#endregion
295
- //#region src/primitives/Axis.tsx
296
- var B = 7, V = 16, H = 8, U = "…";
297
- function W(e, t, n) {
298
- let r = e.length;
299
- if (r <= 1) return new Set(Array.from({ length: r }, (e, t) => t));
300
- let i = n ? Math.max(...e.map((e) => e.length * B)) : V, a = Math.max(1, Math.floor(t / (i + H)));
301
- if (a >= r) return new Set(Array.from({ length: r }, (e, t) => t));
302
- let o = Math.ceil(r / a), s = /* @__PURE__ */ new Set();
303
- for (let e = 0; e < r; e += o) s.add(e);
304
- let c = r - 1;
305
- return c - Math.floor((c - 1) / o) * o >= o && s.add(c), s;
306
- }
307
- function ae(e, t) {
308
- let n = Math.floor(t / B);
309
- return n <= 1 ? U : e.length <= n ? e : e.slice(0, n - 1) + U;
310
- }
311
- function G(e, t, n, r) {
312
- if (t) return Math.max(1, Math.floor(e / (V + H)));
313
- let i = Math.max(...n.map((e) => r(e).length)) * B;
314
- return Math.max(1, Math.floor(e / (i + H)));
315
- }
316
- function K({ scale: e, orientation: t, length: n }) {
317
- let r = a.useContext(j), i = e ?? r?.categoryScale, s = r?.layout !== "horizontal", c = t ?? (s ? "bottom" : "left"), l = n ?? (c === "bottom" ? r?.innerHeight : 0) ?? 0, u = r?.categoryTickFormatter ?? ((e) => e);
318
- if (!i) return null;
319
- let d = i.domain(), f = d.map(u), p = W(f, c === "bottom" ? r?.innerWidth ?? 0 : r?.innerHeight ?? 0, c === "bottom");
320
- if (c === "bottom") return /* @__PURE__ */ o("g", {
321
- transform: `translate(0,${l})`,
322
- "aria-hidden": "true",
323
- children: d.map((e, t) => p.has(t) ? /* @__PURE__ */ o("text", {
324
- x: (i(e) ?? 0) + i.bandwidth() / 2,
325
- y: 20,
326
- textAnchor: "middle",
327
- className: "fill-muted-foreground text-xs",
328
- children: f[t]
329
- }, e) : null)
330
- });
331
- let m = r?.marginLeft ?? 40, h = Math.max(0, m - H);
332
- return /* @__PURE__ */ o("g", {
333
- "aria-hidden": "true",
334
- children: d.map((e, t) => p.has(t) ? /* @__PURE__ */ o("text", {
335
- x: -H,
336
- y: (i(e) ?? 0) + i.bandwidth() / 2,
337
- textAnchor: "end",
338
- dominantBaseline: "middle",
339
- className: "fill-muted-foreground text-xs",
340
- children: ae(f[t], h)
341
- }, e) : null)
342
- });
343
- }
344
- function q({ scale: e, orientation: t, axisId: n, unit: r, length: i, tickCount: s = 5, tickFormatter: c }) {
345
- 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"];
346
- if (!d) return null;
347
- let _ = d.ticks(s), v = p === "left" || p === "right", y = G(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) => {
348
- let t = h(e);
349
- return g && e === x ? `${t} ${g}` : t;
350
- };
351
- if (p === "left") return /* @__PURE__ */ o("g", {
352
- "aria-hidden": "true",
353
- children: b.map((e) => /* @__PURE__ */ o("text", {
354
- x: -H,
355
- y: d(e),
356
- textAnchor: "end",
357
- dominantBaseline: "middle",
358
- className: "fill-muted-foreground text-xs",
359
- children: S(e)
360
- }, e))
361
- });
362
- if (p === "right") {
363
- let e = l?.innerWidth ?? 0;
364
- return /* @__PURE__ */ o("g", {
365
- "aria-hidden": "true",
366
- children: b.map((t) => /* @__PURE__ */ o("text", {
367
- x: e + H,
368
- y: d(t),
369
- textAnchor: "start",
370
- dominantBaseline: "middle",
371
- className: "fill-muted-foreground text-xs",
372
- children: S(t)
373
- }, t))
374
- });
375
- }
376
- return /* @__PURE__ */ o("g", {
377
- "aria-hidden": "true",
378
- children: b.map((e) => /* @__PURE__ */ o("text", {
379
- x: d(e),
380
- y: m + 20,
381
- textAnchor: "middle",
382
- className: "fill-muted-foreground text-xs",
383
- children: S(e)
384
- }, e))
385
- });
386
- }
387
- //#endregion
388
- //#region src/primitives/roundedRect.ts
389
- function J(e, t, n, r, i) {
390
- 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);
391
- return [
392
- `M${e + a},${t}`,
393
- `H${e + n - o}`,
394
- o ? `A${o},${o},0,0,1,${e + n},${t + o}` : `L${e + n},${t}`,
395
- `V${t + r - s}`,
396
- s ? `A${s},${s},0,0,1,${e + n - s},${t + r}` : `L${e + n},${t + r}`,
397
- `H${e + c}`,
398
- c ? `A${c},${c},0,0,1,${e},${t + r - c}` : `L${e},${t + r}`,
399
- `V${t + a}`,
400
- a ? `A${a},${a},0,0,1,${e + a},${t}` : `L${e},${t}`,
401
- "Z"
402
- ].join("");
403
- }
404
- //#endregion
405
- //#region src/primitives/ChartSlots.tsx
406
- var Y = a.createContext(null);
407
- function oe() {
408
- return a.useContext(Y) || {
409
- tooltip: null,
410
- legend: null,
411
- setTooltip: () => void 0,
412
- setLegend: () => void 0
413
- };
414
- }
415
- function X({ children: e }) {
416
- let [t, n] = a.useState(null), [r, i] = a.useState(null), s = a.useMemo(() => ({
417
- tooltip: t,
418
- legend: r,
419
- setTooltip: n,
420
- setLegend: i
421
- }), [t, r]);
422
- return /* @__PURE__ */ o(Y.Provider, {
423
- value: s,
424
- children: e
425
- });
426
- }
427
- //#endregion
428
- //#region src/primitives/useResolvedCssLength.tsx
429
- function se(e, t) {
430
- let n = a.useRef(null), [r, i] = a.useState(t), s = a.useCallback(() => {
431
- let e = n.current;
432
- if (!e) return;
433
- let t = getComputedStyle(e).borderTopLeftRadius, r = Number.parseFloat(t);
434
- Number.isNaN(r) || i((e) => e === r ? e : r);
435
- }, []);
436
- return a.useLayoutEffect(() => {
437
- s();
438
- }, [e, s]), a.useEffect(() => {
439
- if (typeof MutationObserver > "u") return;
440
- let e = new MutationObserver(() => s()), t = {
441
- attributes: !0,
442
- attributeFilter: ["class", "data-theme"]
443
- };
444
- return e.observe(document.documentElement, t), document.body && e.observe(document.body, t), () => e.disconnect();
445
- }, [s]), [r, /* @__PURE__ */ o("span", {
446
- ref: n,
447
- "aria-hidden": "true",
448
- className: "pointer-events-none absolute h-0 w-0 opacity-0",
449
- style: { borderTopLeftRadius: e }
450
- })];
451
- }
452
- //#endregion
453
- //#region src/lib/resolveChartState.ts
454
- function Z(e, t) {
455
- return e ?? (t === 0 ? "empty" : "ready");
456
- }
457
- //#endregion
458
- //#region src/primitives/BarChartSkeleton.tsx
459
- var Q = [
460
- {
461
- x: 55,
462
- height: 120
463
- },
464
- {
465
- x: 110,
466
- height: 75
467
- },
468
- {
469
- x: 165,
470
- height: 155
471
- },
472
- {
473
- x: 220,
474
- height: 95
475
- },
476
- {
477
- x: 275,
478
- height: 135
479
- },
480
- {
481
- x: 330,
482
- height: 85
483
- }
484
- ];
485
- function $({ ariaLabel: t = "Loading chart", className: n, ...r }) {
486
- return /* @__PURE__ */ o("div", {
487
- role: "img",
488
- "aria-label": t,
489
- "aria-busy": "true",
490
- className: e("flex h-full w-full flex-col", n),
491
- ...r,
492
- children: /* @__PURE__ */ o("div", {
493
- className: "flex min-h-0 flex-1 items-end gap-2 px-8 py-4",
494
- children: Q.map((e) => /* @__PURE__ */ o("div", {
495
- className: "flex-1 animate-pulse rounded-t-sm bg-muted",
496
- style: { height: `${e.height / 200 * 100}%` }
497
- }, e.x))
498
- })
499
- });
500
- }
501
- //#endregion
502
- //#region src/primitives/LineChartSkeleton.tsx
503
- function ce({ ariaLabel: t = "Loading chart", className: n, ...r }) {
504
- return /* @__PURE__ */ o("div", {
505
- role: "img",
506
- "aria-label": t,
507
- "aria-busy": "true",
508
- className: e("flex h-full w-full flex-col", n),
509
- ...r,
510
- children: /* @__PURE__ */ o("div", {
511
- className: "relative min-h-0 flex-1 animate-pulse",
512
- children: /* @__PURE__ */ s("svg", {
513
- viewBox: "0 0 400 200",
514
- className: "absolute inset-0 h-full w-full",
515
- "aria-hidden": "true",
516
- preserveAspectRatio: "none",
517
- children: [/* @__PURE__ */ o("path", {
518
- d: "M0,60 C80,80 120,150 200,110 C280,70 340,30 400,80",
519
- stroke: "var(--muted)",
520
- strokeWidth: "2.5",
521
- fill: "none",
522
- strokeLinecap: "round"
523
- }), /* @__PURE__ */ o("path", {
524
- d: "M0,150 C80,120 160,30 240,70 C320,110 360,140 400,120",
525
- stroke: "var(--muted)",
526
- strokeWidth: "2.5",
527
- fill: "none",
528
- strokeLinecap: "round"
529
- })]
530
- })
531
- })
532
- });
533
- }
534
- //#endregion
535
- //#region src/primitives/CartesianChartSkeleton.tsx
536
- function le({ ariaLabel: t = "Loading chart", className: n, ...r }) {
537
- return /* @__PURE__ */ s("div", {
538
- role: "img",
539
- "aria-label": t,
540
- "aria-busy": "true",
541
- className: e("relative flex h-full w-full overflow-hidden", n),
542
- ...r,
543
- children: [/* @__PURE__ */ o($, {
544
- "aria-hidden": "true",
545
- className: "absolute inset-0"
546
- }), /* @__PURE__ */ o(ce, {
547
- "aria-hidden": "true",
548
- className: "absolute inset-0"
549
- })]
550
- });
551
- }
552
- //#endregion
553
- //#region src/primitives/ChartEmptyState.tsx
554
- function ue({ ariaLabel: a, className: c, ...l }) {
555
- return /* @__PURE__ */ o("div", {
556
- role: "img",
557
- "aria-label": a,
558
- className: e("flex h-full w-full items-center justify-center", c),
559
- ...l,
560
- children: /* @__PURE__ */ o(t, { children: /* @__PURE__ */ s(r, { children: [/* @__PURE__ */ o(i, { children: "No data to display" }), /* @__PURE__ */ o(n, { children: "This chart will render as soon as data becomes available." })] }) })
561
- });
562
- }
563
- //#endregion
564
- //#region src/primitives/TooltipPortal.tsx
565
- function de({ state: e, containerRef: t, chartId: n, children: r }) {
566
- let i = a.useRef(null), [s, c] = a.useState({
567
- x: 0,
568
- y: 0,
569
- visible: !1
570
- });
571
- return a.useLayoutEffect(() => {
572
- let n = t.current, r = i.current;
573
- if (!n || !r) {
574
- c((e) => e.visible ? {
575
- ...e,
576
- visible: !1
577
- } : e);
578
- return;
579
- }
580
- let a = n.getBoundingClientRect(), o = r.getBoundingClientRect(), s = a.left + e.x, l = a.top + e.y, u = Math.max(4, Math.min(s, window.innerWidth - o.width - 4)), d = Math.max(4, Math.min(l, window.innerHeight - o.height - 4));
581
- c((e) => e.x === u && e.y === d && e.visible ? e : {
582
- x: u,
583
- y: d,
584
- visible: !0
585
- });
586
- }, [
587
- e.x,
588
- e.y,
589
- t
590
- ]), m(/* @__PURE__ */ o("div", {
591
- ref: i,
592
- role: "tooltip",
593
- "data-chart": n,
594
- className: "pointer-events-none fixed z-50 transition-[left,top] duration-75 ease-out",
595
- style: {
596
- left: s.x,
597
- top: s.y,
598
- visibility: s.visible ? "visible" : "hidden"
599
- },
600
- children: r
601
- }), document.body);
602
- }
603
- //#endregion
604
- //#region src/primitives/CartesianChart.tsx
605
- function fe(e) {
606
- let t = [], n = (e) => {
607
- a.Children.forEach(e, (e) => {
608
- if (!a.isValidElement(e)) return;
609
- let r = e.props;
610
- if (e.type === a.Fragment) {
611
- n(r.children);
612
- return;
613
- }
614
- if ("dataKey" in r && typeof r.dataKey == "string") {
615
- let n = e.type;
616
- t.push({
617
- dataKey: r.dataKey,
618
- stackId: typeof r.stackId == "string" ? r.stackId : void 0,
619
- axisId: typeof r.axisId == "string" ? r.axisId : void 0,
620
- seriesType: n.seriesType ?? "unknown"
621
- });
622
- }
623
- });
624
- };
625
- return n(e), t;
626
- }
627
- function pe(e) {
628
- let t = !1, n = (e) => {
629
- a.Children.forEach(e, (e) => {
630
- if (t || !a.isValidElement(e)) return;
631
- let r = e.props;
632
- if (e.type === a.Fragment) {
633
- n(r.children);
634
- return;
635
- }
636
- r.orientation === "right" && (t = !0);
637
- });
638
- };
639
- return n(e), t;
640
- }
641
- function me({ state: e, className: t, data: n, margin: r, categoryPadding: i, categoryScaleType: a, layout: s, animated: c, ariaLabel: l, valueTickFormatter: u, categoryTickFormatter: d, onPointHover: f, onPointLeave: p, children: m, ...h }) {
642
- let g = Z(e, n.length);
643
- return g === "loading" ? /* @__PURE__ */ o(le, {
644
- ariaLabel: l,
645
- className: t,
646
- ...h
647
- }) : g === "empty" ? /* @__PURE__ */ o(ue, {
648
- ariaLabel: l ?? "No data",
649
- className: t,
650
- ...h
651
- }) : /* @__PURE__ */ o(X, { children: /* @__PURE__ */ o(he, {
652
- data: n,
653
- margin: r,
654
- categoryPadding: i,
655
- categoryScaleType: a,
656
- layout: s,
657
- animated: c,
658
- ariaLabel: l,
659
- valueTickFormatter: u,
660
- categoryTickFormatter: d,
661
- onPointHover: f,
662
- onPointLeave: p,
663
- className: t,
664
- ...h,
665
- children: m
666
- }) });
667
- }
668
- function he({ data: t, margin: n, categoryPadding: r = .1, categoryScaleType: i = "band", layout: m = "vertical", animated: h = !0, ariaLabel: _, valueTickFormatter: y = g, categoryTickFormatter: x = String, onPointHover: S, onPointLeave: C, className: w, children: T, ...E }) {
669
- let { config: O, id: k } = b(), { tooltip: A, legend: M } = oe(), te = a.useMemo(() => pe(T), [T]), N = a.useMemo(() => {
670
- let e = fe(T), n = {};
671
- for (let r of ["left", "right"]) {
672
- let i = e.filter((e) => (e.axisId ?? "left") === r).map((e) => e.dataKey);
673
- if (i.length === 0) continue;
674
- let a = 0;
675
- for (let e of t) for (let t of i) {
676
- let n = e[t];
677
- if (n == null) continue;
678
- let r = Number(n);
679
- Number.isFinite(r) && Math.abs(r) > a && (a = Math.abs(r));
680
- }
681
- let o = y(Math.ceil(a * 1.1)), s = "";
682
- for (let t of e) if ((t.axisId ?? "left") === r) {
683
- let e = O[t.dataKey]?.unit;
684
- if (e) {
685
- s = e;
686
- break;
687
- }
688
- }
689
- n[r] = (s ? `${o} ${s}` : o).length * 8 + 10;
690
- }
691
- return n;
692
- }, [
693
- T,
694
- t,
695
- O,
696
- y
697
- ]), P = {
698
- ...v,
699
- ...n
700
- };
701
- N.left !== void 0 && n?.left === void 0 && (P.left = Math.max(P.left, N.left)), te && n?.right === void 0 && (P.right = Math.max(P.right, N.right ?? 40));
702
- let F = m === "vertical", I = a.useRef(null), ne = a.useRef(null), L = D(ne), R = ee(), [re, ie] = a.useState(null), [z, B] = a.useState(null), V = a.useCallback((e) => B(e), []), H = a.useCallback(() => B(null), []), U = Math.max(0, L.width - P.left - P.right), W = Math.max(0, L.height - P.top - P.bottom), ae = P.left, G = a.useMemo(() => t.map((e) => e.category), [t]), K = a.useMemo(() => fe(T), [T]), q = a.useMemo(() => K.map((e) => e.dataKey), [K]), J = a.useMemo(() => {
703
- let e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
704
- for (let e of K) {
705
- if (!e.stackId) continue;
706
- let t = n.get(e.stackId) ?? [];
707
- t.push(e.dataKey), n.set(e.stackId, t);
708
- }
709
- for (let [r, i] of n) {
710
- let n = d().keys(i).value((e, t) => {
711
- let n = e[t];
712
- if (n == null) return 0;
713
- let r = Number(n);
714
- return Number.isFinite(r) ? r : 0;
715
- }).order(p).offset(f);
716
- e.set(r, n(t));
717
- }
718
- return e;
719
- }, [t, K]), Y = a.useMemo(() => K.filter((e) => e.seriesType === "BarSeries" && !e.stackId).map((e) => e.dataKey), [K]), X = a.useMemo(() => {
720
- let e = /* @__PURE__ */ new Map();
721
- for (let t of K) {
722
- let n = t.axisId ?? "left", r = e.get(n) ?? [];
723
- r.push(t.dataKey), e.set(n, r);
724
- }
725
- return e;
726
- }, [K]), se = a.useMemo(() => {
727
- let e = /* @__PURE__ */ new Map();
728
- for (let [n, r] of X) {
729
- let i = new Set(r), a = K.some((e) => e.stackId && i.has(e.dataKey)), o = r.filter((e) => !K.find((t) => t.dataKey === e && t.stackId));
730
- if (a) {
731
- let r = -Infinity;
732
- for (let e of J.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]);
733
- for (let e of t) for (let t of o) {
734
- let n = e[t];
735
- if (n == null) continue;
736
- let i = Number(n);
737
- Number.isFinite(i) && i > r && (r = i);
738
- }
739
- e.set(n, [0, r === -Infinity ? 0 : r]);
740
- } else {
741
- let i = Infinity, a = -Infinity;
742
- for (let e of t) for (let t of r) {
743
- let n = e[t];
744
- if (n == null) continue;
745
- let r = Number(n);
746
- Number.isFinite(r) && (r < i && (i = r), r > a && (a = r));
747
- }
748
- e.set(n, [i === Infinity ? 0 : i, a === -Infinity ? 0 : a]);
749
- }
750
- }
751
- return e;
752
- }, [
753
- X,
754
- t,
755
- J,
756
- K
757
- ]), Z = a.useMemo(() => i === "point" ? Object.assign(u().domain(G).range([0, F ? U : W]).padding(0), { bandwidth: () => 0 }) : c().domain(G).range([0, F ? U : W]).padding(r), [
758
- G,
759
- i,
760
- r,
761
- F,
762
- U,
763
- W
764
- ]), Q = a.useMemo(() => {
765
- let e = {};
766
- for (let [t, [n, r]] of se) e[t] = l().domain([Math.min(0, n), r * 1.1 || 1]).nice().range(F ? [W, 0] : [0, U]);
767
- return e.left ||= l().domain([0, 1]).nice().range(F ? [W, 0] : [0, U]), e;
768
- }, [
769
- se,
770
- F,
771
- W,
772
- U
773
- ]), $ = Q.left, ce = a.useCallback((e) => e ? Q[e] ?? $ : $, [$, Q]), le = a.useMemo(() => {
774
- let e = {};
775
- for (let t of K) {
776
- let n = t.axisId ?? "left";
777
- if (e[n]) continue;
778
- let r = O[t.dataKey]?.unit;
779
- r && (e[n] = r);
780
- }
781
- return e;
782
- }, [K, O]), ue = a.useMemo(() => Y.length <= 1 ? null : c().domain(Y).range([0, Z.bandwidth()]).padding(.05), [Y, Z]), me = q.map((e) => ({
783
- dataKey: e,
784
- value: e
785
- }));
786
- function he(e) {
787
- return q.filter((t) => e[t] !== null && e[t] !== void 0).map((t) => ({
788
- dataKey: t,
789
- name: t,
790
- value: Number(e[t]) || 0
791
- }));
792
- }
793
- function ge(e) {
794
- let n = I.current?.getBoundingClientRect();
795
- if (!n) return;
796
- let r = F ? e.clientX - n.left - P.left : e.clientY - n.top - P.top, i = 0, a = Infinity;
797
- for (let e = 0; e < G.length; e++) {
798
- let t = (Z(G[e]) ?? 0) + Z.bandwidth() / 2, n = Math.abs(r - t);
799
- n < a && (a = n, i = e);
800
- }
801
- let o = t[i];
802
- if (!o) return;
803
- ie(o.category);
804
- let s = he(o), c = (Z(o.category) ?? 0) + Z.bandwidth() / 2, l = F ? {
805
- clientX: n.left + P.left + c,
806
- clientY: e.clientY
807
- } : {
808
- clientX: e.clientX,
809
- clientY: n.top + P.top + c
810
- };
811
- A && R.show(s, o.category, l, n), S?.(s, o.category, e);
812
- }
813
- function _e() {
814
- ie(null), R.hide(), C?.();
815
- }
816
- let ve = a.useCallback((e, n) => {
817
- if (!A) return;
818
- let r = I.current?.getBoundingClientRect();
819
- if (!r) return;
820
- let i = t.find((t) => t.category === e);
821
- if (!i) return;
822
- let a = q.filter((e) => i[e] !== null && i[e] !== void 0).map((e) => ({
823
- dataKey: e,
824
- name: e,
825
- value: Number(i[e]) || 0
826
- })), o = {
827
- clientX: n.left + n.width / 2,
828
- clientY: n.top + n.height / 2
829
- };
830
- R.show(a, e, o, r);
831
- }, [
832
- A,
833
- t,
834
- q,
835
- R
836
- ]), ye = a.useCallback(() => {
837
- R.hide();
838
- }, [R]), be = M?.verticalAlign ?? "bottom", xe = _ ?? `Chart with ${t.length} categor${t.length === 1 ? "y" : "ies"} and ${q.length} series`, Se = a.useMemo(() => ({
839
- data: t,
840
- dataKeys: q,
841
- categoryScale: Z,
842
- valueScale: $,
843
- valueScales: Q,
844
- resolveValueScale: ce,
845
- axisUnits: le,
846
- innerWidth: U,
847
- innerHeight: W,
848
- marginLeft: ae,
849
- layout: m,
850
- animated: h,
851
- hoveredCategory: re,
852
- hoveredLegendKey: z,
853
- config: O,
854
- stackedLayers: J,
855
- barGroupScale: ue,
856
- valueTickFormatter: y,
857
- categoryTickFormatter: x,
858
- chartWrapperRef: I,
859
- chartId: k,
860
- showTooltipAt: ve,
861
- hideTooltip: ye
862
- }), [
863
- t,
864
- q,
865
- Z,
866
- $,
867
- Q,
868
- ce,
869
- le,
870
- U,
871
- W,
872
- ae,
873
- m,
874
- h,
875
- re,
876
- z,
877
- O,
878
- J,
879
- ue,
880
- y,
881
- x,
882
- k,
883
- ve,
884
- ye
885
- ]);
886
- return /* @__PURE__ */ o(j.Provider, {
887
- value: Se,
888
- children: /* @__PURE__ */ s("div", {
889
- className: e("flex h-full w-full flex-col", w),
890
- ...E,
891
- children: [
892
- M && be === "top" && a.cloneElement(M.content, {
893
- items: me,
894
- verticalAlign: "top",
895
- onItemHover: V,
896
- onItemLeave: H,
897
- hoveredLegendKey: z
898
- }),
899
- /* @__PURE__ */ s("div", {
900
- ref: I,
901
- className: "relative min-h-0 flex-1",
902
- onMouseMove: ge,
903
- onMouseLeave: _e,
904
- children: [
905
- /* @__PURE__ */ o("svg", {
906
- ref: ne,
907
- role: "img",
908
- "aria-label": xe,
909
- className: "h-full w-full",
910
- overflow: "visible",
911
- children: L.width > 0 && L.height > 0 && /* @__PURE__ */ o("g", {
912
- transform: `translate(${P.left},${P.top})`,
913
- children: T
914
- })
915
- }),
916
- /* @__PURE__ */ o("div", {
917
- className: "sr-only",
918
- children: /* @__PURE__ */ s("table", { children: [
919
- /* @__PURE__ */ o("caption", { children: xe }),
920
- /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", {
921
- scope: "col",
922
- children: "Category"
923
- }), q.map((e) => /* @__PURE__ */ o("th", {
924
- scope: "col",
925
- children: typeof O[e]?.label == "string" ? O[e]?.label : e
926
- }, e))] }) }),
927
- /* @__PURE__ */ o("tbody", { children: t.map((e) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", {
928
- scope: "row",
929
- children: e.category
930
- }), q.map((t) => /* @__PURE__ */ o("td", { children: e[t] !== null && e[t] !== void 0 ? y(Number(e[t]) || 0) : "—" }, t))] }, e.category)) })
931
- ] })
932
- }),
933
- A && R.state && /* @__PURE__ */ o(de, {
934
- state: R.state,
935
- containerRef: I,
936
- chartId: k,
937
- children: a.cloneElement(A.content, {
938
- label: R.state.label,
939
- items: R.state.items,
940
- active: !0
941
- })
942
- })
943
- ]
944
- }),
945
- M && be === "bottom" && a.cloneElement(M.content, {
946
- items: me,
947
- verticalAlign: "bottom",
948
- onItemHover: V,
949
- onItemLeave: H,
950
- hoveredLegendKey: z
951
- })
952
- ]
953
- })
954
- });
955
- }
956
- //#endregion
957
- //#region src/primitives/AreaChartSkeleton.tsx
958
- function ge({ ariaLabel: t = "Loading chart", className: n, ...r }) {
959
- return /* @__PURE__ */ o("div", {
960
- role: "img",
961
- "aria-label": t,
962
- "aria-busy": "true",
963
- className: e("flex h-full w-full flex-col", n),
964
- ...r,
965
- children: /* @__PURE__ */ o("div", {
966
- className: "relative min-h-0 flex-1 animate-pulse",
967
- children: /* @__PURE__ */ s("svg", {
968
- viewBox: "0 0 400 200",
969
- className: "absolute inset-0 h-full w-full",
970
- "aria-hidden": "true",
971
- preserveAspectRatio: "none",
972
- children: [
973
- /* @__PURE__ */ o("path", {
974
- d: "M0,60 C80,80 120,150 200,110 C280,70 340,30 400,80 L400,200 L0,200 Z",
975
- fill: "var(--muted)",
976
- opacity: .4
977
- }),
978
- /* @__PURE__ */ o("path", {
979
- d: "M0,150 C80,120 160,30 240,70 C320,110 360,140 400,120 L400,200 L0,200 Z",
980
- fill: "var(--muted)",
981
- opacity: .4
982
- }),
983
- /* @__PURE__ */ o("path", {
984
- d: "M0,60 C80,80 120,150 200,110 C280,70 340,30 400,80",
985
- stroke: "var(--muted)",
986
- strokeWidth: "2",
987
- fill: "none",
988
- strokeLinecap: "round"
989
- }),
990
- /* @__PURE__ */ o("path", {
991
- d: "M0,150 C80,120 160,30 240,70 C320,110 360,140 400,120",
992
- stroke: "var(--muted)",
993
- strokeWidth: "2",
994
- fill: "none",
995
- strokeLinecap: "round"
996
- })
997
- ]
998
- })
999
- })
1000
- });
1001
- }
1002
- //#endregion
1003
- //#region src/primitives/SkeletonBlock.tsx
1004
- function _e({ className: t, ...n }) {
1005
- return /* @__PURE__ */ o("div", {
1006
- className: e("animate-pulse rounded-md bg-muted", t),
1007
- ...n
1008
- });
1009
- }
1010
- //#endregion
1011
- //#region src/primitives/DoughnutChartSkeleton.tsx
1012
- function ve({ ariaLabel: t = "Loading chart", className: n, ...r }) {
1013
- return /* @__PURE__ */ o("div", {
1014
- role: "img",
1015
- "aria-label": t,
1016
- "aria-busy": "true",
1017
- className: e("flex h-full w-full animate-pulse items-center justify-center", n),
1018
- ...r,
1019
- children: /* @__PURE__ */ o("svg", {
1020
- viewBox: "0 0 200 200",
1021
- className: "h-full w-full",
1022
- preserveAspectRatio: "xMidYMid meet",
1023
- "aria-hidden": "true",
1024
- children: /* @__PURE__ */ o("circle", {
1025
- cx: "100",
1026
- cy: "100",
1027
- r: "72",
1028
- fill: "none",
1029
- stroke: "var(--muted)",
1030
- strokeWidth: "36"
1031
- })
1032
- })
1033
- });
1034
- }
1035
- //#endregion
1036
- export { b as C, g as E, E as S, v as T, te as _, de as a, D as b, $ as c, X as d, oe as f, L as g, q as h, me as i, Z as l, K as m, _e as n, ue as o, J as p, ge as r, ce as s, ve as t, se as u, M as v, _ as w, C as x, ee as y };