@object-ui/plugin-charts 11.4.0 → 11.5.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.
- package/CHANGELOG.md +23 -0
- package/dist/index.js +136 -132
- package/dist/index.umd.cjs +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @object-ui/plugin-charts
|
|
2
2
|
|
|
3
|
+
## 11.5.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fae75e2: Fix two bugs verified still-present after #2254 claimed to resolve them (framework#2620 / framework#2616 Showcase UX pass, tracked in #2268):
|
|
8
|
+
|
|
9
|
+
- **Wizard/form `submitBehavior: 'thank-you'` allowed duplicate resubmission.** #2254 fixed the spec-bridge dropping `submitBehavior` before it reached the renderer, so the configured toast message started appearing — but `WizardForm`'s last step and `ObjectForm`'s submit handler only ever called `toast.success(...)` for `thank-you`/`next-record`; the form stayed mounted and fully filled with its submit button re-enabled once the request settled, so a second click created a second record. Both components now track a terminal `submitted` state and, when set, replace the form with a confirmation panel (using the behavior's `title`/`message`, which were also never read before) — mirroring the pattern `apps/console/src/components/FormPage.tsx` already used for its own standalone forms.
|
|
10
|
+
|
|
11
|
+
- **Command Center-style 3-up chart bands stayed collapsed to ~100-130px, and a dataset-bound chart's measure leaked its raw field name.**
|
|
12
|
+
- `responsiveStyles` (and `style`) were declared on the page-spec `PageComponent` bridge input type but never copied onto the `SchemaNode` in `spec-bridge/bridges/page.ts::mapComponent()` — so a page author's ADR-0065 layout override (e.g. forcing `display: 'grid'` on a `type: 'flex'` band) never reached `SchemaRenderer`, and the node silently fell back to its default flex layout. Both fields are now mapped through.
|
|
13
|
+
- `ObjectChart`'s dataset-bound fetch path (`schema.dataset` + `ds.queryDataset(...)`) discarded the response's `fields` array (which carries each measure's `label`, e.g. `{ name: 'task_count', label: 'Tasks' }`) before it ever reached `buildChartSeries()` — whose `fields` param already resolves this correctly (see `chart-series.test.ts`) — so the legend/tooltip always fell back to the raw field name. The fetched `fields` are now captured and threaded through.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [544d8eb]
|
|
16
|
+
- Updated dependencies [6fffd3d]
|
|
17
|
+
- Updated dependencies [9255686]
|
|
18
|
+
- Updated dependencies [fae75e2]
|
|
19
|
+
- Updated dependencies [1072701]
|
|
20
|
+
- @object-ui/i18n@11.5.0
|
|
21
|
+
- @object-ui/react@11.5.0
|
|
22
|
+
- @object-ui/components@11.5.0
|
|
23
|
+
- @object-ui/types@11.5.0
|
|
24
|
+
- @object-ui/core@11.5.0
|
|
25
|
+
|
|
3
26
|
## 11.4.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -3,31 +3,31 @@ import * as f from "react";
|
|
|
3
3
|
import p, { Suspense as m, useCallback as h, useContext as g, useEffect as ee, useMemo as _, useRef as te, useState as v } from "react";
|
|
4
4
|
import { Button as ne, ChartSkeleton as re, Dialog as ie, DialogContent as ae, DialogHeader as oe, DialogTitle as se, RefreshIndicator as ce, Sheet as le, SheetContent as ue, SheetHeader as y, SheetTitle as b, Skeleton as x } from "@object-ui/components";
|
|
5
5
|
import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
6
|
-
import { Area as T, AreaChart as de, Bar as fe, BarChart as E, CartesianGrid as D, Cell as
|
|
7
|
-
import { SchemaRenderer as
|
|
8
|
-
import { AlertCircle as
|
|
9
|
-
import { useSafeFieldLabel as
|
|
6
|
+
import { Area as T, AreaChart as de, Bar as fe, BarChart as E, CartesianGrid as D, Cell as pe, Funnel as me, FunnelChart as O, LabelList as he, Legend as k, Line as A, LineChart as j, Pie as ge, PieChart as M, PolarAngleAxis as _e, PolarGrid as ve, PolarRadiusAxis as ye, Radar as be, RadarChart as N, ResponsiveContainer as P, Sankey as xe, Scatter as Se, ScatterChart as Ce, Tooltip as F, Treemap as we, XAxis as I, YAxis as L, ZAxis as R } from "recharts";
|
|
7
|
+
import { SchemaRenderer as Te, SchemaRendererContext as Ee, useDataScope as z, useDrillNavigation as De } from "@object-ui/react";
|
|
8
|
+
import { AlertCircle as Oe, ArrowUpRight as ke } from "lucide-react";
|
|
9
|
+
import { useSafeFieldLabel as Ae, useSafeTranslate as je } from "@object-ui/i18n";
|
|
10
10
|
//#region \0rolldown/runtime.js
|
|
11
|
-
var
|
|
11
|
+
var B = Object.defineProperty, V = (e, t, n) => () => {
|
|
12
12
|
if (n) throw n[0];
|
|
13
13
|
try {
|
|
14
14
|
return e && (t = e(e = 0)), t;
|
|
15
15
|
} catch (e) {
|
|
16
16
|
throw n = [e], e;
|
|
17
17
|
}
|
|
18
|
-
},
|
|
18
|
+
}, H = (e, t) => {
|
|
19
19
|
let n = {};
|
|
20
|
-
for (var r in e)
|
|
20
|
+
for (var r in e) B(n, r, {
|
|
21
21
|
get: e[r],
|
|
22
22
|
enumerable: !0
|
|
23
23
|
});
|
|
24
|
-
return t ||
|
|
25
|
-
},
|
|
26
|
-
function
|
|
24
|
+
return t || B(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
25
|
+
}, Me = /* @__PURE__ */ H({ default: () => Pe });
|
|
26
|
+
function Ne(e, t = 14) {
|
|
27
27
|
return e.length > t ? `${e.slice(0, t - 1)}…` : e;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
let r = String(n?.value ?? ""), i =
|
|
29
|
+
function U({ x: e, y: t, payload: n }) {
|
|
30
|
+
let r = String(n?.value ?? ""), i = Ne(r);
|
|
31
31
|
return /* @__PURE__ */ C("g", {
|
|
32
32
|
transform: `translate(${e},${t})`,
|
|
33
33
|
children: /* @__PURE__ */ w("text", {
|
|
@@ -45,7 +45,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
45
45
|
let o = e.map((e) => String(e?.[n] ?? "")), s = o.length > 4 || o.some((e) => e.length > 8);
|
|
46
46
|
return /* @__PURE__ */ C("div", {
|
|
47
47
|
className: `p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${i}`,
|
|
48
|
-
children: /* @__PURE__ */ C(
|
|
48
|
+
children: /* @__PURE__ */ C(P, {
|
|
49
49
|
width: "100%",
|
|
50
50
|
height: r,
|
|
51
51
|
children: /* @__PURE__ */ w(E, {
|
|
@@ -114,9 +114,9 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
114
114
|
stroke: "hsl(var(--border))",
|
|
115
115
|
vertical: !1
|
|
116
116
|
}),
|
|
117
|
-
/* @__PURE__ */ C(
|
|
117
|
+
/* @__PURE__ */ C(I, {
|
|
118
118
|
dataKey: n,
|
|
119
|
-
tick: s ? /* @__PURE__ */ C(
|
|
119
|
+
tick: s ? /* @__PURE__ */ C(U, {}) : {
|
|
120
120
|
fill: "hsl(var(--muted-foreground))",
|
|
121
121
|
fontSize: 12,
|
|
122
122
|
fontFamily: "monospace"
|
|
@@ -127,7 +127,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
127
127
|
height: s ? 56 : void 0,
|
|
128
128
|
dy: s ? void 0 : 10
|
|
129
129
|
}),
|
|
130
|
-
/* @__PURE__ */ C(
|
|
130
|
+
/* @__PURE__ */ C(L, {
|
|
131
131
|
tick: {
|
|
132
132
|
fill: "hsl(var(--muted-foreground))",
|
|
133
133
|
fontSize: 12,
|
|
@@ -136,7 +136,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
136
136
|
tickLine: !1,
|
|
137
137
|
axisLine: !1
|
|
138
138
|
}),
|
|
139
|
-
/* @__PURE__ */ C(
|
|
139
|
+
/* @__PURE__ */ C(F, {
|
|
140
140
|
cursor: {
|
|
141
141
|
fill: "hsl(var(--muted))",
|
|
142
142
|
opacity: .2
|
|
@@ -172,7 +172,7 @@ function Pe({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
|
|
|
172
172
|
})
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
var Fe =
|
|
175
|
+
var Fe = V((() => {}));
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/ChartContainerImpl.tsx
|
|
178
178
|
function Ie() {
|
|
@@ -197,7 +197,7 @@ function W({ id: e, className: t, children: n, config: r, ...i }) {
|
|
|
197
197
|
children: [/* @__PURE__ */ C(Be, {
|
|
198
198
|
id: o,
|
|
199
199
|
config: r
|
|
200
|
-
}), /* @__PURE__ */ C(
|
|
200
|
+
}), /* @__PURE__ */ C(P, {
|
|
201
201
|
width: "100%",
|
|
202
202
|
height: "100%",
|
|
203
203
|
children: n
|
|
@@ -280,7 +280,7 @@ function Le(e, t, n) {
|
|
|
280
280
|
let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
|
|
281
281
|
return n in t && typeof t[n] == "string" ? i = t[n] : r && n in r && typeof r[n] == "string" && (i = r[n]), i in e ? e[i] : e[n];
|
|
282
282
|
}
|
|
283
|
-
var q, Re, ze, Be, J, Y, Ve =
|
|
283
|
+
var q, Re, ze, Be, J, Y, Ve = V((() => {
|
|
284
284
|
q = (...e) => e.filter(Boolean).join(" "), Re = {
|
|
285
285
|
light: "",
|
|
286
286
|
dark: ".dark"
|
|
@@ -294,7 +294,7 @@ ${n.map(([e, n]) => {
|
|
|
294
294
|
}).join("\n")}
|
|
295
295
|
}
|
|
296
296
|
`).join("\n") } }) : null;
|
|
297
|
-
}, J =
|
|
297
|
+
}, J = F, Y = k;
|
|
298
298
|
}));
|
|
299
299
|
//#endregion
|
|
300
300
|
//#region src/chartDrillEvents.ts
|
|
@@ -332,7 +332,7 @@ function Ge(e, t) {
|
|
|
332
332
|
value: typeof n?.value == "number" ? n.value : void 0
|
|
333
333
|
};
|
|
334
334
|
}
|
|
335
|
-
var Ke =
|
|
335
|
+
var Ke = V((() => {})), qe = /* @__PURE__ */ H({ default: () => Je });
|
|
336
336
|
function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", colors: o, categoryColors: s, onChartClick: c, isAnimationActive: l }) {
|
|
337
337
|
let u = e === "column" ? "bar" : e, d = Array.isArray(t) ? t : [], p = l === !1 ? { isAnimationActive: !1 } : {}, [m, h] = f.useState(!1), g = f.useCallback((e) => {
|
|
338
338
|
if (!c || !e) return;
|
|
@@ -393,21 +393,23 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
393
393
|
let ce = {
|
|
394
394
|
bar: E,
|
|
395
395
|
"horizontal-bar": E,
|
|
396
|
-
line:
|
|
396
|
+
line: j,
|
|
397
397
|
area: de,
|
|
398
|
-
pie:
|
|
399
|
-
donut:
|
|
400
|
-
radar:
|
|
401
|
-
scatter:
|
|
402
|
-
funnel:
|
|
398
|
+
pie: M,
|
|
399
|
+
donut: M,
|
|
400
|
+
radar: N,
|
|
401
|
+
scatter: Ce,
|
|
402
|
+
funnel: O,
|
|
403
403
|
combo: E,
|
|
404
404
|
treemap: E,
|
|
405
405
|
sankey: E
|
|
406
406
|
}[u] || E, le = f.useCallback((e) => {
|
|
407
407
|
if (e == null || e === "") return "";
|
|
408
|
-
let t =
|
|
409
|
-
if (
|
|
410
|
-
|
|
408
|
+
let t = n?.[String(e)]?.label;
|
|
409
|
+
if (t != null) return String(t);
|
|
410
|
+
let i = typeof e == "string" ? e : String(e);
|
|
411
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(i)) {
|
|
412
|
+
let e = new Date(i);
|
|
411
413
|
if (!Number.isNaN(e.getTime())) {
|
|
412
414
|
let t = (d.length > 1 ? Math.abs(new Date(String(d[d.length - 1][r] ?? "")).getTime() - new Date(String(d[0][r] ?? "")).getTime()) : 0) / (1e3 * 60 * 60 * 24);
|
|
413
415
|
try {
|
|
@@ -423,11 +425,12 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
|
-
return m &&
|
|
428
|
+
return m && i.length > 8 ? i.slice(0, 8) + "…" : i;
|
|
427
429
|
}, [
|
|
428
430
|
d,
|
|
429
431
|
r,
|
|
430
|
-
m
|
|
432
|
+
m,
|
|
433
|
+
n
|
|
431
434
|
]), ue = f.useMemo(() => d.some((e) => String(e[r] || "").length > 5), [d, r]), y = () => Array.isArray(o) && o.length > 0 ? o : [
|
|
432
435
|
"hsl(var(--chart-1))",
|
|
433
436
|
"hsl(var(--chart-2))",
|
|
@@ -476,12 +479,12 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
476
479
|
}), /* @__PURE__ */ C(W, {
|
|
477
480
|
config: o,
|
|
478
481
|
className: a,
|
|
479
|
-
children: /* @__PURE__ */ w(
|
|
482
|
+
children: /* @__PURE__ */ w(M, { children: [
|
|
480
483
|
/* @__PURE__ */ C(J, {
|
|
481
484
|
cursor: !1,
|
|
482
485
|
content: /* @__PURE__ */ C(G, { hideLabel: !0 })
|
|
483
486
|
}),
|
|
484
|
-
/* @__PURE__ */ C(
|
|
487
|
+
/* @__PURE__ */ C(ge, {
|
|
485
488
|
data: d,
|
|
486
489
|
dataKey: i[0]?.dataKey || "value",
|
|
487
490
|
nameKey: r || "name",
|
|
@@ -491,7 +494,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
491
494
|
outerRadius: "85%",
|
|
492
495
|
...p,
|
|
493
496
|
...te,
|
|
494
|
-
children: d.map((e, n) => /* @__PURE__ */ C(
|
|
497
|
+
children: d.map((e, n) => /* @__PURE__ */ C(pe, { fill: Z(v(e?.[r], n, t)) }, `cell-${n}`))
|
|
495
498
|
}),
|
|
496
499
|
/* @__PURE__ */ C(Y, {
|
|
497
500
|
verticalAlign: "bottom",
|
|
@@ -523,7 +526,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
523
526
|
return /* @__PURE__ */ C(W, {
|
|
524
527
|
config: n,
|
|
525
528
|
className: a,
|
|
526
|
-
children: /* @__PURE__ */ w(
|
|
529
|
+
children: /* @__PURE__ */ w(O, { children: [/* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }), /* @__PURE__ */ w(me, {
|
|
527
530
|
dataKey: e,
|
|
528
531
|
data: l,
|
|
529
532
|
nameKey: r,
|
|
@@ -534,7 +537,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
534
537
|
fill: "hsl(var(--foreground))",
|
|
535
538
|
stroke: "none",
|
|
536
539
|
dataKey: r
|
|
537
|
-
}), l.map((e, n) => /* @__PURE__ */ C(
|
|
540
|
+
}), l.map((e, n) => /* @__PURE__ */ C(pe, { fill: Z(t[n % t.length]) }, `funnel-cell-${n}`))]
|
|
538
541
|
})] })
|
|
539
542
|
});
|
|
540
543
|
}
|
|
@@ -543,7 +546,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
543
546
|
return /* @__PURE__ */ C(W, {
|
|
544
547
|
config: n,
|
|
545
548
|
className: a,
|
|
546
|
-
children: /* @__PURE__ */ C(
|
|
549
|
+
children: /* @__PURE__ */ C(we, {
|
|
547
550
|
data: d.map((n, i) => ({
|
|
548
551
|
name: String(n?.[r] ?? ""),
|
|
549
552
|
size: Number(n?.[e]) || 0,
|
|
@@ -572,7 +575,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
572
575
|
}) : null] });
|
|
573
576
|
}, {}),
|
|
574
577
|
...oe,
|
|
575
|
-
children: /* @__PURE__ */ C(
|
|
578
|
+
children: /* @__PURE__ */ C(F, {})
|
|
576
579
|
})
|
|
577
580
|
});
|
|
578
581
|
}
|
|
@@ -585,7 +588,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
585
588
|
return c.length === 0 ? /* @__PURE__ */ C("div", { className: a }) : /* @__PURE__ */ C(W, {
|
|
586
589
|
config: n,
|
|
587
590
|
className: a,
|
|
588
|
-
children: /* @__PURE__ */ C(
|
|
591
|
+
children: /* @__PURE__ */ C(xe, {
|
|
589
592
|
data: {
|
|
590
593
|
nodes: s,
|
|
591
594
|
links: c
|
|
@@ -597,19 +600,19 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
597
600
|
},
|
|
598
601
|
node: { fill: "hsl(var(--chart-1))" },
|
|
599
602
|
...se,
|
|
600
|
-
children: /* @__PURE__ */ C(
|
|
603
|
+
children: /* @__PURE__ */ C(F, {})
|
|
601
604
|
})
|
|
602
605
|
});
|
|
603
606
|
}
|
|
604
607
|
if (u === "radar") return /* @__PURE__ */ C(W, {
|
|
605
608
|
config: n,
|
|
606
609
|
className: a,
|
|
607
|
-
children: /* @__PURE__ */ w(
|
|
610
|
+
children: /* @__PURE__ */ w(N, {
|
|
608
611
|
data: d,
|
|
609
612
|
children: [
|
|
610
|
-
/* @__PURE__ */ C(
|
|
611
|
-
/* @__PURE__ */ C(
|
|
612
|
-
/* @__PURE__ */ C(
|
|
613
|
+
/* @__PURE__ */ C(ve, {}),
|
|
614
|
+
/* @__PURE__ */ C(_e, { dataKey: r }),
|
|
615
|
+
/* @__PURE__ */ C(ye, {}),
|
|
613
616
|
/* @__PURE__ */ C(J, { content: /* @__PURE__ */ C(G, {}) }),
|
|
614
617
|
/* @__PURE__ */ C(Y, {
|
|
615
618
|
content: /* @__PURE__ */ C(K, {}),
|
|
@@ -623,7 +626,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
623
626
|
}),
|
|
624
627
|
i.map((e) => {
|
|
625
628
|
let t = Z(n[e.dataKey]?.color || X);
|
|
626
|
-
return /* @__PURE__ */ C(
|
|
629
|
+
return /* @__PURE__ */ C(be, {
|
|
627
630
|
dataKey: e.dataKey,
|
|
628
631
|
stroke: t,
|
|
629
632
|
fill: t,
|
|
@@ -636,9 +639,9 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
636
639
|
if (u === "scatter") return /* @__PURE__ */ C(W, {
|
|
637
640
|
config: n,
|
|
638
641
|
className: a,
|
|
639
|
-
children: /* @__PURE__ */ w(
|
|
642
|
+
children: /* @__PURE__ */ w(Ce, { children: [
|
|
640
643
|
/* @__PURE__ */ C(D, { vertical: !1 }),
|
|
641
|
-
/* @__PURE__ */ C(
|
|
644
|
+
/* @__PURE__ */ C(I, {
|
|
642
645
|
type: "number",
|
|
643
646
|
dataKey: r,
|
|
644
647
|
name: String(n[r]?.label || r),
|
|
@@ -646,7 +649,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
646
649
|
axisLine: !1,
|
|
647
650
|
minTickGap: m ? 32 : 48
|
|
648
651
|
}),
|
|
649
|
-
/* @__PURE__ */ C(
|
|
652
|
+
/* @__PURE__ */ C(L, {
|
|
650
653
|
type: "number",
|
|
651
654
|
dataKey: i[0]?.dataKey || "value",
|
|
652
655
|
name: String(n[i[0]?.dataKey]?.label || i[0]?.dataKey),
|
|
@@ -655,7 +658,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
655
658
|
tickFormatter: b,
|
|
656
659
|
width: 48
|
|
657
660
|
}),
|
|
658
|
-
/* @__PURE__ */ C(
|
|
661
|
+
/* @__PURE__ */ C(R, {
|
|
659
662
|
type: "number",
|
|
660
663
|
range: [60, 400]
|
|
661
664
|
}),
|
|
@@ -672,7 +675,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
672
675
|
}),
|
|
673
676
|
i.map((e, t) => {
|
|
674
677
|
let r = y(), i = Z(n[e.dataKey]?.color || r[t % r.length]), a = Q(e, "scatter");
|
|
675
|
-
return /* @__PURE__ */ C(
|
|
678
|
+
return /* @__PURE__ */ C(Se, {
|
|
676
679
|
name: n[e.dataKey]?.label || e.dataKey,
|
|
677
680
|
data: d,
|
|
678
681
|
fill: i,
|
|
@@ -689,18 +692,18 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
689
692
|
data: d,
|
|
690
693
|
children: [
|
|
691
694
|
/* @__PURE__ */ C(D, { vertical: !1 }),
|
|
692
|
-
/* @__PURE__ */ C(
|
|
695
|
+
/* @__PURE__ */ C(I, {
|
|
693
696
|
dataKey: r,
|
|
694
697
|
...x
|
|
695
698
|
}),
|
|
696
|
-
/* @__PURE__ */ C(
|
|
699
|
+
/* @__PURE__ */ C(L, {
|
|
697
700
|
yAxisId: "left",
|
|
698
701
|
tickLine: !1,
|
|
699
702
|
axisLine: !1,
|
|
700
703
|
tickFormatter: b,
|
|
701
704
|
width: 48
|
|
702
705
|
}),
|
|
703
|
-
/* @__PURE__ */ C(
|
|
706
|
+
/* @__PURE__ */ C(L, {
|
|
704
707
|
yAxisId: "right",
|
|
705
708
|
orientation: "right",
|
|
706
709
|
tickLine: !1,
|
|
@@ -721,7 +724,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
721
724
|
}),
|
|
722
725
|
i.map((e, t) => {
|
|
723
726
|
let r = Z(n[e.dataKey]?.color || X), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right", o = Q(e, i);
|
|
724
|
-
return i === "line" ? /* @__PURE__ */ C(
|
|
727
|
+
return i === "line" ? /* @__PURE__ */ C(A, {
|
|
725
728
|
yAxisId: a,
|
|
726
729
|
type: "monotone",
|
|
727
730
|
dataKey: e.dataKey,
|
|
@@ -753,11 +756,11 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
753
756
|
]
|
|
754
757
|
})
|
|
755
758
|
});
|
|
756
|
-
let k = u === "horizontal-bar",
|
|
757
|
-
...
|
|
758
|
-
...
|
|
759
|
-
...i.map((e, t) => Z(n[e.dataKey]?.color ||
|
|
760
|
-
])),
|
|
759
|
+
let k = u === "horizontal-bar", P = y(), Te = s ? Object.values(s).map((e) => Z(String(e))) : [], Ee = Array.from(/* @__PURE__ */ new Set([
|
|
760
|
+
...P,
|
|
761
|
+
...Te,
|
|
762
|
+
...i.map((e, t) => Z(n[e.dataKey]?.color || P[t % P.length] || X))
|
|
763
|
+
])), z = (e) => "g" + e.replace(/[^a-zA-Z0-9]/g, "");
|
|
761
764
|
return /* @__PURE__ */ C(W, {
|
|
762
765
|
config: n,
|
|
763
766
|
className: a,
|
|
@@ -766,8 +769,8 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
766
769
|
layout: k ? "vertical" : "horizontal",
|
|
767
770
|
..._,
|
|
768
771
|
children: [
|
|
769
|
-
/* @__PURE__ */ C("defs", { children:
|
|
770
|
-
id: `bg-${
|
|
772
|
+
/* @__PURE__ */ C("defs", { children: Ee.map((e) => /* @__PURE__ */ w(f.Fragment, { children: [/* @__PURE__ */ w("linearGradient", {
|
|
773
|
+
id: `bg-${z(e)}`,
|
|
771
774
|
x1: "0",
|
|
772
775
|
y1: "0",
|
|
773
776
|
x2: "0",
|
|
@@ -782,7 +785,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
782
785
|
stopOpacity: .5
|
|
783
786
|
})]
|
|
784
787
|
}), /* @__PURE__ */ w("linearGradient", {
|
|
785
|
-
id: `ag-${
|
|
788
|
+
id: `ag-${z(e)}`,
|
|
786
789
|
x1: "0",
|
|
787
790
|
y1: "0",
|
|
788
791
|
x2: "0",
|
|
@@ -796,24 +799,24 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
796
799
|
style: { stopColor: e },
|
|
797
800
|
stopOpacity: .05
|
|
798
801
|
})]
|
|
799
|
-
})] },
|
|
802
|
+
})] }, z(e))) }),
|
|
800
803
|
/* @__PURE__ */ C(D, { vertical: !1 }),
|
|
801
|
-
k ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(
|
|
804
|
+
k ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(I, {
|
|
802
805
|
type: "number",
|
|
803
806
|
tickLine: !1,
|
|
804
807
|
axisLine: !1,
|
|
805
808
|
tickFormatter: b
|
|
806
|
-
}), /* @__PURE__ */ C(
|
|
809
|
+
}), /* @__PURE__ */ C(L, {
|
|
807
810
|
type: "category",
|
|
808
811
|
dataKey: r,
|
|
809
812
|
tickLine: !1,
|
|
810
813
|
axisLine: !1,
|
|
811
814
|
width: Math.min(140, Math.max(60, Math.max(...d.map((e) => String(e[r] ?? "").length)) * 7)),
|
|
812
815
|
tickFormatter: le
|
|
813
|
-
})] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(
|
|
816
|
+
})] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(I, {
|
|
814
817
|
dataKey: r,
|
|
815
818
|
...x
|
|
816
|
-
}), /* @__PURE__ */ C(
|
|
819
|
+
}), /* @__PURE__ */ C(L, {
|
|
817
820
|
tickLine: !1,
|
|
818
821
|
axisLine: !1,
|
|
819
822
|
tickFormatter: b,
|
|
@@ -836,16 +839,16 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
836
839
|
let t = i.filter((e) => e.variant !== "comparison").length === 1 && !o && i.length === 1 && d.length > 1, n = Q(e, "bar");
|
|
837
840
|
return /* @__PURE__ */ C(fe, {
|
|
838
841
|
dataKey: e.dataKey,
|
|
839
|
-
fill: `url(#bg-${
|
|
842
|
+
fill: `url(#bg-${z(l)})`,
|
|
840
843
|
radius: 4,
|
|
841
844
|
fillOpacity: n?.fillOpacity,
|
|
842
845
|
...p,
|
|
843
|
-
children: t && d.map((e, t) => /* @__PURE__ */ C(
|
|
846
|
+
children: t && d.map((e, t) => /* @__PURE__ */ C(pe, { fill: `url(#bg-${z(Z(v(e?.[r], t, a)))})` }, `cell-${t}`))
|
|
844
847
|
}, e.dataKey);
|
|
845
848
|
}
|
|
846
849
|
if (u === "line") {
|
|
847
850
|
let t = Q(e, "line");
|
|
848
|
-
return /* @__PURE__ */ C(
|
|
851
|
+
return /* @__PURE__ */ C(A, {
|
|
849
852
|
type: "monotone",
|
|
850
853
|
dataKey: e.dataKey,
|
|
851
854
|
stroke: l,
|
|
@@ -861,7 +864,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
861
864
|
return /* @__PURE__ */ C(T, {
|
|
862
865
|
type: "monotone",
|
|
863
866
|
dataKey: e.dataKey,
|
|
864
|
-
fill: `url(#ag-${
|
|
867
|
+
fill: `url(#ag-${z(l)})`,
|
|
865
868
|
stroke: l,
|
|
866
869
|
strokeWidth: 2,
|
|
867
870
|
fillOpacity: t?.fillOpacity ?? 1,
|
|
@@ -876,7 +879,7 @@ function Je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
|
|
|
876
879
|
})
|
|
877
880
|
});
|
|
878
881
|
}
|
|
879
|
-
var X, Ye, Z, Q, Xe =
|
|
882
|
+
var X, Ye, Z, Q, Xe = V((() => {
|
|
880
883
|
Ve(), Ke(), X = "hsl(var(--primary))", Ye = {
|
|
881
884
|
slate: "#64748b",
|
|
882
885
|
gray: "#6b7280",
|
|
@@ -905,7 +908,7 @@ var X, Ye, Z, Q, Xe = H((() => {
|
|
|
905
908
|
fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
|
|
906
909
|
strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
|
|
907
910
|
} : null;
|
|
908
|
-
})), Ze = p.lazy(() => Promise.resolve().then(() => (Fe(),
|
|
911
|
+
})), Ze = p.lazy(() => Promise.resolve().then(() => (Fe(), Me))), Qe = p.lazy(() => Promise.resolve().then(() => (Xe(), qe))), $e = ({ schema: e }) => /* @__PURE__ */ C(m, {
|
|
909
912
|
fallback: /* @__PURE__ */ C(x, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
|
|
910
913
|
children: /* @__PURE__ */ C(Ze, {
|
|
911
914
|
data: e.data,
|
|
@@ -1079,11 +1082,11 @@ async function nt(e, t, n, r, i) {
|
|
|
1079
1082
|
});
|
|
1080
1083
|
}
|
|
1081
1084
|
var rt = (e) => {
|
|
1082
|
-
let { schema: f } = e, p = e.onSegmentClick, m = g(
|
|
1085
|
+
let { schema: f } = e, p = e.onSegmentClick, m = g(Ee), x = e.dataSource || m?.dataSource, S = z(f.bind), { fieldOptionLabel: T } = Ae(), de = te(T);
|
|
1083
1086
|
ee(() => {
|
|
1084
1087
|
de.current = T;
|
|
1085
1088
|
}, [T]);
|
|
1086
|
-
let [fe, E] = v([]), [D, O] = v(() => !(Array.isArray(f.data) && f.data.length > 0) && (!!f.objectName || !!f.dataset)), [
|
|
1089
|
+
let [fe, E] = v([]), [D, pe] = v(null), [me, O] = v(() => !(Array.isArray(f.data) && f.data.length > 0) && (!!f.objectName || !!f.dataset)), [he, k] = v(null), [A, j] = v(null), [ge, M] = v(null), [_e, ve] = v(null), { openRecordList: ye } = De(), be = je(), N = _(() => f.aggregate ? JSON.stringify(f.aggregate) : "", [f.aggregate]), P = _(() => f.filter ? JSON.stringify(f.filter) : "", [f.filter]), xe = _(() => f.compareTo ? JSON.stringify(f.compareTo) : "", [f.compareTo]), Se = _(() => f.dataset ? JSON.stringify({
|
|
1087
1090
|
d: f.dataset,
|
|
1088
1091
|
dim: f.dimensions ?? [],
|
|
1089
1092
|
val: f.values ?? []
|
|
@@ -1091,7 +1094,7 @@ var rt = (e) => {
|
|
|
1091
1094
|
f.dataset,
|
|
1092
1095
|
f.dimensions,
|
|
1093
1096
|
f.values
|
|
1094
|
-
]),
|
|
1097
|
+
]), Ce = (e) => e !== "pie" && e !== "donut" && e !== "funnel";
|
|
1095
1098
|
ee(() => {
|
|
1096
1099
|
let e = !1;
|
|
1097
1100
|
return (async () => {
|
|
@@ -1106,7 +1109,7 @@ var rt = (e) => {
|
|
|
1106
1109
|
o = n?.item ?? n?.data ?? n, i = o?.object, a = ((o?.dimensions || []).find((t) => t?.name === e) ?? (o?.dimensions || [])[0])?.field ?? e;
|
|
1107
1110
|
}
|
|
1108
1111
|
if (!i || !a) {
|
|
1109
|
-
e || (
|
|
1112
|
+
e || (M(null), ve(null));
|
|
1110
1113
|
return;
|
|
1111
1114
|
}
|
|
1112
1115
|
let c = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(i)}`, t)).json().catch(() => null), l = c?.item ?? c?.data ?? c, u = r(l?.fields?.[a]?.options), d = null;
|
|
@@ -1118,9 +1121,9 @@ var rt = (e) => {
|
|
|
1118
1121
|
}
|
|
1119
1122
|
Object.keys(e).length > 0 && (d = e);
|
|
1120
1123
|
}
|
|
1121
|
-
e || (
|
|
1124
|
+
e || (M(u), ve(d));
|
|
1122
1125
|
} catch {
|
|
1123
|
-
e || (
|
|
1126
|
+
e || (M(null), ve(null));
|
|
1124
1127
|
}
|
|
1125
1128
|
})(), () => {
|
|
1126
1129
|
e = !0;
|
|
@@ -1128,11 +1131,11 @@ var rt = (e) => {
|
|
|
1128
1131
|
}, [
|
|
1129
1132
|
f.objectName,
|
|
1130
1133
|
f.dataset,
|
|
1134
|
+
Se,
|
|
1131
1135
|
N,
|
|
1132
|
-
j,
|
|
1133
1136
|
f.xAxisKey
|
|
1134
1137
|
]);
|
|
1135
|
-
let
|
|
1138
|
+
let F = h(async (e, t) => {
|
|
1136
1139
|
if (f.aggregate && typeof e.aggregate == "function") {
|
|
1137
1140
|
let n = f.aggregate.groupBy;
|
|
1138
1141
|
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
@@ -1161,12 +1164,12 @@ var rt = (e) => {
|
|
|
1161
1164
|
return f.aggregate && n.length > 0 && (n = tt(n, f.aggregate)), n;
|
|
1162
1165
|
}
|
|
1163
1166
|
return [];
|
|
1164
|
-
}, [f.objectName,
|
|
1167
|
+
}, [f.objectName, N]), we = h(async (e, t) => {
|
|
1165
1168
|
if (!e || !f.objectName && !f.dataset) {
|
|
1166
1169
|
t.current && O(!1);
|
|
1167
1170
|
return;
|
|
1168
1171
|
}
|
|
1169
|
-
t.current && (O(!0),
|
|
1172
|
+
t.current && (O(!0), k(null));
|
|
1170
1173
|
try {
|
|
1171
1174
|
if (f.dataset && typeof e.queryDataset == "function") {
|
|
1172
1175
|
let n = l(f.filter), r = await e.queryDataset(f.dataset, {
|
|
@@ -1174,10 +1177,10 @@ var rt = (e) => {
|
|
|
1174
1177
|
measures: Array.isArray(f.values) ? f.values : [],
|
|
1175
1178
|
...n ? { runtimeFilter: n } : {}
|
|
1176
1179
|
});
|
|
1177
|
-
t.current && E(Array.isArray(r?.rows) ? r.rows : []);
|
|
1180
|
+
t.current && (E(Array.isArray(r?.rows) ? r.rows : []), pe(Array.isArray(r?.fields) ? r.fields : null));
|
|
1178
1181
|
return;
|
|
1179
1182
|
}
|
|
1180
|
-
let n = l(f.filter), r = f.compareTo, i = !!r &&
|
|
1183
|
+
let n = l(f.filter), r = f.compareTo, i = !!r && Ce(f.chartType), a = i ? d(f.filter, r) : null, [o, s] = await Promise.all([F(e, n), a ? F(e, a) : Promise.resolve([])]), c = o, u = f.aggregate?.groupBy, p = u && typeof u == "object" && !Array.isArray(u) ? u.alias || u.field : u || f.xAxisKey;
|
|
1181
1184
|
if (i && s.length > 0 && f.aggregate) {
|
|
1182
1185
|
let e = f.aggregate.field, t = f.aggregate.function, n = (n) => {
|
|
1183
1186
|
if (n == null) return null;
|
|
@@ -1223,49 +1226,49 @@ var rt = (e) => {
|
|
|
1223
1226
|
} catch {}
|
|
1224
1227
|
t.current && E(c);
|
|
1225
1228
|
} catch (e) {
|
|
1226
|
-
console.error("[ObjectChart] Fetch error:", e), t.current &&
|
|
1229
|
+
console.error("[ObjectChart] Fetch error:", e), t.current && k(e instanceof Error ? e.message : "Failed to load chart data");
|
|
1227
1230
|
} finally {
|
|
1228
1231
|
t.current && O(!1);
|
|
1229
1232
|
}
|
|
1230
1233
|
}, [
|
|
1231
1234
|
f.objectName,
|
|
1235
|
+
Se,
|
|
1232
1236
|
N,
|
|
1233
|
-
|
|
1237
|
+
P,
|
|
1234
1238
|
xe,
|
|
1235
|
-
M,
|
|
1236
1239
|
f.xAxisKey,
|
|
1237
1240
|
f.chartType,
|
|
1238
|
-
|
|
1241
|
+
F
|
|
1239
1242
|
]);
|
|
1240
1243
|
ee(() => {
|
|
1241
1244
|
let e = { current: !0 };
|
|
1242
|
-
return (f.objectName || f.dataset) && !S && !f.data ?
|
|
1245
|
+
return (f.objectName || f.dataset) && !S && !f.data ? we(x, e) : e.current && O(!1), () => {
|
|
1243
1246
|
e.current = !1;
|
|
1244
1247
|
};
|
|
1245
1248
|
}, [
|
|
1246
1249
|
f.objectName,
|
|
1247
|
-
|
|
1250
|
+
Se,
|
|
1248
1251
|
x,
|
|
1249
1252
|
S,
|
|
1250
1253
|
f.data,
|
|
1254
|
+
P,
|
|
1255
|
+
N,
|
|
1251
1256
|
xe,
|
|
1252
|
-
|
|
1253
|
-
M,
|
|
1254
|
-
F
|
|
1257
|
+
we
|
|
1255
1258
|
]);
|
|
1256
|
-
let I = S || f.data || fe, L = Array.isArray(I) ? I : [], R = f.drillDown,
|
|
1257
|
-
if (!
|
|
1258
|
-
let e = /* @__PURE__ */ new Map(), t = `__raw_${
|
|
1259
|
+
let I = S || f.data || fe, L = Array.isArray(I) ? I : [], R = f.drillDown, B = f.aggregate?.groupBy || f.xAxisKey, V = _(() => {
|
|
1260
|
+
if (!B) return /* @__PURE__ */ new Map();
|
|
1261
|
+
let e = /* @__PURE__ */ new Map(), t = `__raw_${B}`;
|
|
1259
1262
|
for (let n of L) {
|
|
1260
|
-
let r = n?.[
|
|
1263
|
+
let r = n?.[B];
|
|
1261
1264
|
if (r == null) continue;
|
|
1262
1265
|
let i = t in (n || {}) ? n[t] : r;
|
|
1263
1266
|
e.set(String(r), i);
|
|
1264
1267
|
}
|
|
1265
1268
|
return e;
|
|
1266
|
-
}, [L,
|
|
1269
|
+
}, [L, B]), H = f.compareTo, Me = !!H && Ce(f.chartType) && !!f.aggregate && L.some((e) => e[`${f.aggregate.field}__comparison`] != null), Ne = _(() => {
|
|
1267
1270
|
let e = Array.isArray(f.series) ? f.series : null;
|
|
1268
|
-
if (!
|
|
1271
|
+
if (!Me) return e;
|
|
1269
1272
|
let t = e || [{ dataKey: f.aggregate.field }], n = {
|
|
1270
1273
|
vsLastWeek: "Previous week",
|
|
1271
1274
|
vsLastMonth: "Previous month",
|
|
@@ -1273,7 +1276,7 @@ var rt = (e) => {
|
|
|
1273
1276
|
vsLastYear: "Previous year",
|
|
1274
1277
|
vsYesterday: "Yesterday",
|
|
1275
1278
|
vsPreviousPeriod: "Previous period"
|
|
1276
|
-
}[i(
|
|
1279
|
+
}[i(H, f.filter)] || "Previous period";
|
|
1277
1280
|
return [...t.map((e) => ({
|
|
1278
1281
|
...e,
|
|
1279
1282
|
variant: e.variant || "current"
|
|
@@ -1283,12 +1286,12 @@ var rt = (e) => {
|
|
|
1283
1286
|
variant: "comparison"
|
|
1284
1287
|
}];
|
|
1285
1288
|
}, [
|
|
1286
|
-
|
|
1289
|
+
Me,
|
|
1287
1290
|
f.series,
|
|
1288
1291
|
f.aggregate,
|
|
1289
1292
|
f.filter,
|
|
1290
|
-
|
|
1291
|
-
]), U = f.dataset ? t(c(L,
|
|
1293
|
+
H
|
|
1294
|
+
]), U = f.dataset ? t(c(L, _e), f.dimensions, f.values, D) : null, Pe = U ? {
|
|
1292
1295
|
...f,
|
|
1293
1296
|
data: U.data,
|
|
1294
1297
|
xAxisKey: U.xAxisKey,
|
|
@@ -1296,16 +1299,16 @@ var rt = (e) => {
|
|
|
1296
1299
|
} : {
|
|
1297
1300
|
...f,
|
|
1298
1301
|
data: L,
|
|
1299
|
-
...
|
|
1300
|
-
},
|
|
1302
|
+
...Ne ? { series: Ne } : {}
|
|
1303
|
+
}, Fe = f.colors && !Array.isArray(f.colors) && typeof f.colors == "object" ? f.colors : null, Ie = Array.isArray(f.colors) ? f.colors : void 0, W = ge || Fe ? {
|
|
1301
1304
|
...ge || {},
|
|
1302
|
-
...
|
|
1303
|
-
} : void 0,
|
|
1304
|
-
...
|
|
1305
|
-
colors:
|
|
1306
|
-
...
|
|
1305
|
+
...Fe || {}
|
|
1306
|
+
} : void 0, G = {
|
|
1307
|
+
...Pe,
|
|
1308
|
+
colors: Ie,
|
|
1309
|
+
...W ? { categoryColors: W } : {}
|
|
1307
1310
|
};
|
|
1308
|
-
if (
|
|
1311
|
+
if (me && L.length === 0) return /* @__PURE__ */ w("div", {
|
|
1309
1312
|
className: "p-2 " + (f.className || ""),
|
|
1310
1313
|
"data-testid": "chart-loading",
|
|
1311
1314
|
role: "status",
|
|
@@ -1316,19 +1319,19 @@ var rt = (e) => {
|
|
|
1316
1319
|
children: "Loading chart data…"
|
|
1317
1320
|
}), /* @__PURE__ */ C(re, { className: "h-full" })]
|
|
1318
1321
|
});
|
|
1319
|
-
if (
|
|
1322
|
+
if (he) return /* @__PURE__ */ w("div", {
|
|
1320
1323
|
className: "flex flex-col items-center justify-center gap-2 p-4 " + (f.className || ""),
|
|
1321
1324
|
"data-testid": "chart-error",
|
|
1322
1325
|
role: "alert",
|
|
1323
1326
|
children: [
|
|
1324
|
-
/* @__PURE__ */ C(
|
|
1327
|
+
/* @__PURE__ */ C(Oe, { className: "h-6 w-6 text-destructive opacity-60" }),
|
|
1325
1328
|
/* @__PURE__ */ C("p", {
|
|
1326
1329
|
className: "text-xs text-destructive font-medium",
|
|
1327
1330
|
children: "Failed to load chart data"
|
|
1328
1331
|
}),
|
|
1329
1332
|
/* @__PURE__ */ C("p", {
|
|
1330
1333
|
className: "text-xs text-muted-foreground max-w-xs text-center",
|
|
1331
|
-
children:
|
|
1334
|
+
children: he
|
|
1332
1335
|
})
|
|
1333
1336
|
]
|
|
1334
1337
|
});
|
|
@@ -1341,22 +1344,22 @@ var rt = (e) => {
|
|
|
1341
1344
|
"”"
|
|
1342
1345
|
]
|
|
1343
1346
|
});
|
|
1344
|
-
let
|
|
1345
|
-
let t = e.category, n = t != null &&
|
|
1346
|
-
|
|
1347
|
+
let K = s(R) ? (e) => {
|
|
1348
|
+
let t = e.category, n = t != null && V.has(String(t)) ? V.get(String(t)) : t;
|
|
1349
|
+
j({
|
|
1347
1350
|
...e,
|
|
1348
1351
|
category: n,
|
|
1349
1352
|
categoryLabel: t,
|
|
1350
1353
|
scope: "cell"
|
|
1351
1354
|
});
|
|
1352
|
-
} : void 0,
|
|
1353
|
-
let e = a(R,
|
|
1355
|
+
} : void 0, Le = p ?? K, q = !p && A && f.objectName ? (() => {
|
|
1356
|
+
let e = a(R, A, { groupByField: B }), t = {
|
|
1354
1357
|
...f.filter || {},
|
|
1355
1358
|
...e
|
|
1356
|
-
}, n = u(R,
|
|
1359
|
+
}, n = u(R, A, f.title || "Details"), r = R?.target ?? "drawer", i = /* @__PURE__ */ C("div", {
|
|
1357
1360
|
className: "overflow-auto",
|
|
1358
1361
|
"data-testid": "chart-drill-body",
|
|
1359
|
-
children: /* @__PURE__ */ C(
|
|
1362
|
+
children: /* @__PURE__ */ C(Te, {
|
|
1360
1363
|
schema: {
|
|
1361
1364
|
type: "object-data-table",
|
|
1362
1365
|
objectName: f.objectName,
|
|
@@ -1381,13 +1384,13 @@ var rt = (e) => {
|
|
|
1381
1384
|
size: "sm",
|
|
1382
1385
|
"data-testid": "drill-open-in-list",
|
|
1383
1386
|
onClick: () => {
|
|
1384
|
-
ye(f.objectName, t),
|
|
1387
|
+
ye(f.objectName, t), j(null);
|
|
1385
1388
|
},
|
|
1386
|
-
children: [be("dashboard.openInList", "Open in list"), /* @__PURE__ */ C(
|
|
1389
|
+
children: [be("dashboard.openInList", "Open in list"), /* @__PURE__ */ C(ke, { className: "ml-1 h-3.5 w-3.5" })]
|
|
1387
1390
|
}) : null;
|
|
1388
1391
|
return r === "dialog" ? /* @__PURE__ */ C(ie, {
|
|
1389
1392
|
open: !0,
|
|
1390
|
-
onOpenChange: (e) => !e &&
|
|
1393
|
+
onOpenChange: (e) => !e && j(null),
|
|
1391
1394
|
children: /* @__PURE__ */ w(ae, {
|
|
1392
1395
|
className: "max-w-4xl",
|
|
1393
1396
|
children: [/* @__PURE__ */ w(oe, {
|
|
@@ -1397,7 +1400,7 @@ var rt = (e) => {
|
|
|
1397
1400
|
})
|
|
1398
1401
|
}) : /* @__PURE__ */ C(le, {
|
|
1399
1402
|
open: !0,
|
|
1400
|
-
onOpenChange: (e) => !e &&
|
|
1403
|
+
onOpenChange: (e) => !e && j(null),
|
|
1401
1404
|
children: /* @__PURE__ */ w(ue, {
|
|
1402
1405
|
side: "right",
|
|
1403
1406
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
@@ -1414,13 +1417,13 @@ var rt = (e) => {
|
|
|
1414
1417
|
return /* @__PURE__ */ w("div", {
|
|
1415
1418
|
className: "relative",
|
|
1416
1419
|
children: [
|
|
1417
|
-
/* @__PURE__ */ C(ce, { active:
|
|
1420
|
+
/* @__PURE__ */ C(ce, { active: me && L.length > 0 }),
|
|
1418
1421
|
/* @__PURE__ */ C($, {
|
|
1419
1422
|
...e,
|
|
1420
|
-
schema:
|
|
1421
|
-
onChartClick:
|
|
1423
|
+
schema: G,
|
|
1424
|
+
onChartClick: Le
|
|
1422
1425
|
}),
|
|
1423
|
-
|
|
1426
|
+
q
|
|
1424
1427
|
]
|
|
1425
1428
|
});
|
|
1426
1429
|
};
|
|
@@ -1528,6 +1531,7 @@ e.register("bar-chart", $e, {
|
|
|
1528
1531
|
namespace: "view",
|
|
1529
1532
|
category: "view",
|
|
1530
1533
|
label: "Chart",
|
|
1534
|
+
skipFallback: !0,
|
|
1531
1535
|
inputs: [
|
|
1532
1536
|
{
|
|
1533
1537
|
name: "objectName",
|
package/dist/index.umd.cjs
CHANGED
|
@@ -4,4 +4,4 @@ ${n.map(([e,n])=>{let r=n.theme?.[t]||n.color;return r?` --color-${e}: ${r};`:n
|
|
|
4
4
|
`)}
|
|
5
5
|
}
|
|
6
6
|
`).join(`
|
|
7
|
-
`)}}):null},M=a.Tooltip,N=a.Legend}));function F(e){return e?.[0]?.dataKey||`value`}function I(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=F(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function L(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:F(t),value:typeof r==`number`?r:void 0}}function R(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:F(t),value:typeof n?.value==`number`?n.value:void 0}}var z=h((()=>{})),B=g({default:()=>V});function V({chartType:e=`bar`,data:t=[],config:r={},xAxisKey:o=`name`,series:s=[],className:c=``,colors:l,categoryColors:u,onChartClick:d,isAnimationActive:f}){let p=e===`column`?`bar`:e,m=Array.isArray(t)?t:[],h=f===!1?{isAnimationActive:!1}:{},[g,_]=n.useState(!1),v=n.useCallback(e=>{if(!d||!e)return;let t=Array.isArray(e.activePayload)?e.activePayload[0]:void 0;d({category:e.activeLabel==null?void 0:String(e.activeLabel),series:t?.dataKey?String(t.dataKey):void 0,value:typeof t?.value==`number`?t.value:void 0})},[d]),y=n.useCallback(e=>{if(!d||!e)return;let t=e.payload?.[o],n=s[0]?.dataKey||`value`;d({category:t==null?void 0:String(t),series:n,value:typeof e.payload?.[n]==`number`?e.payload[n]:void 0})},[d,o,s]),b=d?{onClick:v,style:{cursor:`pointer`}}:{},x=d?{onClick:y,style:{cursor:`pointer`}}:{},S=n.useCallback((e,t,n)=>u&&u[e==null?``:String(e)]||n[t%n.length],[u]),C=n.useCallback(e=>{if(!d)return;let t=I(e,o,s);t&&d(t)},[d,o,s]),D=n.useCallback(e=>{if(!d)return;let t=L(e,s);t&&d(t)},[d,s]),O=n.useCallback(e=>{if(!d)return;let t=R(e,s);t&&d(t)},[d,s]),k=d?{onClick:C,cursor:`pointer`}:{},A=d?{onClick:D,style:{cursor:`pointer`}}:{},j=d?{onClick:O,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>_(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let P={bar:a.BarChart,"horizontal-bar":a.BarChart,line:a.LineChart,area:a.AreaChart,pie:a.PieChart,donut:a.PieChart,radar:a.RadarChart,scatter:a.ScatterChart,funnel:a.FunnelChart,combo:a.BarChart,treemap:a.BarChart,sankey:a.BarChart}[p]||a.BarChart,F=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(t)){let e=new Date(t);if(!Number.isNaN(e.getTime())){let t=(m.length>1?Math.abs(new Date(String(m[m.length-1][o]??``)).getTime()-new Date(String(m[0][o]??``)).getTime()):0)/(1e3*60*60*24);try{return t<=62?e.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e.toLocaleDateString(void 0,{month:`short`,year:`numeric`})}catch{return e.toISOString().slice(0,10)}}}return g&&t.length>8?t.slice(0,8)+`…`:t},[m,o,g]),z=n.useMemo(()=>m.some(e=>String(e[o]||``).length>5),[m,o]),B=()=>Array.isArray(l)&&l.length>0?l:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],V=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[]),U=n.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,interval:`preserveStartEnd`,minTickGap:g?32:48,tickFormatter:F,...!g&&z&&{angle:-35,textAnchor:`end`,height:60}}),[g,z,F]);if(p===`pie`||p===`donut`){let e=p===`donut`?`52%`:0,t=B(),n={...r};return m.forEach((e,r)=>{let i=e?.[o];if(i==null||i===``)return;let a=String(i);n[a]||(n[a]={label:a,color:S(i,r,t)})}),(0,i.jsx)(w,{config:n,className:c,children:(0,i.jsxs)(a.PieChart,{children:[(0,i.jsx)(M,{cursor:!1,content:(0,i.jsx)(T,{hideLabel:!0})}),(0,i.jsx)(a.Pie,{data:m,dataKey:s[0]?.dataKey||`value`,nameKey:o||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...h,...x,children:m.map((e,n)=>(0,i.jsx)(a.Cell,{fill:W(S(e?.[o],n,t))},`cell-${n}`))}),(0,i.jsx)(N,{verticalAlign:`bottom`,wrapperStyle:{fontSize:g?`11px`:`12px`,paddingTop:`8px`},content:(0,i.jsx)(E,{nameKey:o,className:`flex-wrap`})})]})})}if(p===`funnel`){let e=s[0]?.dataKey||`value`,t=B(),n=d?t=>{t&&d({category:t?.payload?.[o]??t?.[o],value:t?.payload?.[e]??t?.[e]})}:void 0,l=n?{onClick:n,style:{cursor:`pointer`}}:{},u=[...m].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r});return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.FunnelChart,{children:[(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsxs)(a.Funnel,{dataKey:e,data:u,nameKey:o,isAnimationActive:!0,...l,children:[(0,i.jsx)(a.LabelList,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:o}),u.map((e,n)=>(0,i.jsx)(a.Cell,{fill:W(t[n%t.length])},`funnel-cell-${n}`))]})]})})}if(p===`treemap`){let e=s[0]?.dataKey||`value`,t=B(),n=m.map((n,r)=>({name:String(n?.[o]??``),size:Number(n?.[e])||0,fill:W(t[r%t.length])}));return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsx)(a.Treemap,{data:n,dataKey:`size`,nameKey:`name`,isAnimationActive:!0,content:(0,i.jsx)(e=>{let{x:t,y:n,width:r,height:a,name:o,fill:s}=e;return r<=0||a<=0?null:(0,i.jsxs)(`g`,{children:[(0,i.jsx)(`rect`,{x:t,y:n,width:r,height:a,fill:s,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&a>18?(0,i.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:o}):null]})},{}),...A,children:(0,i.jsx)(a.Tooltip,{})})})}if(p===`sankey`){let e=s[0]?.dataKey||`value`,t=s[0]?.label||e,n=m.filter(t=>(Number(t?.[e])||0)>0),l=[{name:t},...n.map(e=>({name:String(e?.[o]??``)}))],u=n.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));return u.length===0?(0,i.jsx)(`div`,{className:c}):(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsx)(a.Sankey,{data:{nodes:l,links:u},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...j,children:(0,i.jsx)(a.Tooltip,{})})})}if(p===`radar`)return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.RadarChart,{data:m,children:[(0,i.jsx)(a.PolarGrid,{}),(0,i.jsx)(a.PolarAngleAxis,{dataKey:o}),(0,i.jsx)(a.PolarRadiusAxis,{}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map(e=>{let t=W(r[e.dataKey]?.color||H);return(0,i.jsx)(a.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6},e.dataKey)})]})});if(p===`scatter`)return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.ScatterChart,{children:[(0,i.jsx)(a.CartesianGrid,{vertical:!1}),(0,i.jsx)(a.XAxis,{type:`number`,dataKey:o,name:String(r[o]?.label||o),tickLine:!1,axisLine:!1,minTickGap:g?32:48}),(0,i.jsx)(a.YAxis,{type:`number`,dataKey:s[0]?.dataKey||`value`,name:String(r[s[0]?.dataKey]?.label||s[0]?.dataKey),tickLine:!1,axisLine:!1,tickFormatter:V,width:48}),(0,i.jsx)(a.ZAxis,{type:`number`,range:[60,400]}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map((e,t)=>{let n=B(),o=W(r[e.dataKey]?.color||n[t%n.length]),s=G(e,`scatter`);return(0,i.jsx)(a.Scatter,{name:r[e.dataKey]?.label||e.dataKey,data:m,fill:o,fillOpacity:s?.fillOpacity,...k},e.dataKey)})]})});if(p===`combo`)return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.BarChart,{data:m,children:[(0,i.jsx)(a.CartesianGrid,{vertical:!1}),(0,i.jsx)(a.XAxis,{dataKey:o,...U}),(0,i.jsx)(a.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:V,width:48}),(0,i.jsx)(a.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:V,width:48}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map((e,t)=>{let n=W(r[e.dataKey]?.color||H),o=e.chartType||(t===0?`bar`:`line`),s=o===`bar`?`left`:`right`,c=G(e,o);return o===`line`?(0,i.jsx)(a.Line,{yAxisId:s,type:`monotone`,dataKey:e.dataKey,stroke:n,strokeWidth:2,dot:!1,strokeOpacity:c?.strokeOpacity,strokeDasharray:c?.strokeDasharray,...h},e.dataKey):o===`area`?(0,i.jsx)(a.Area,{yAxisId:s,type:`monotone`,dataKey:e.dataKey,fill:n,stroke:n,fillOpacity:c?.fillOpacity??.4,strokeOpacity:c?.strokeOpacity,strokeDasharray:c?.strokeDasharray,...h},e.dataKey):(0,i.jsx)(a.Bar,{yAxisId:s,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c?.fillOpacity,...h},e.dataKey)})]})});let K=p===`horizontal-bar`,q=B(),J=u?Object.values(u).map(e=>W(String(e))):[],Y=Array.from(new Set([...q,...J,...s.map((e,t)=>W(r[e.dataKey]?.color||q[t%q.length]||H))])),X=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(P,{data:m,layout:K?`vertical`:`horizontal`,...b,children:[(0,i.jsx)(`defs`,{children:Y.map(e=>(0,i.jsxs)(n.Fragment,{children:[(0,i.jsxs)(`linearGradient`,{id:`bg-${X(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,i.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,i.jsxs)(`linearGradient`,{id:`ag-${X(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,i.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},X(e)))}),(0,i.jsx)(a.CartesianGrid,{vertical:!1}),K?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:V}),(0,i.jsx)(a.YAxis,{type:`category`,dataKey:o,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...m.map(e=>String(e[o]??``).length))*7)),tickFormatter:F})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{dataKey:o,...U}),(0,i.jsx)(a.YAxis,{tickLine:!1,axisLine:!1,tickFormatter:V,width:48})]}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map((e,t)=>{let n=B(),c=e.variant===`comparison`,l=c?s.slice(0,t).find(e=>e.variant!==`comparison`)||s[0]:e,u=c?s.indexOf(l):t,d=W(r[l.dataKey]?.color||n[u%n.length]||H);if(p===`bar`||p===`horizontal-bar`){let t=s.filter(e=>e.variant!==`comparison`).length===1&&!c&&s.length===1&&m.length>1,r=G(e,`bar`);return(0,i.jsx)(a.Bar,{dataKey:e.dataKey,fill:`url(#bg-${X(d)})`,radius:4,fillOpacity:r?.fillOpacity,...h,children:t&&m.map((e,t)=>(0,i.jsx)(a.Cell,{fill:`url(#bg-${X(W(S(e?.[o],t,n)))})`},`cell-${t}`))},e.dataKey)}if(p===`line`){let t=G(e,`line`);return(0,i.jsx)(a.Line,{type:`monotone`,dataKey:e.dataKey,stroke:d,strokeWidth:2,dot:!1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...h},e.dataKey)}if(p===`area`){let t=G(e,`area`);return(0,i.jsx)(a.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${X(d)})`,stroke:d,strokeWidth:2,fillOpacity:t?.fillOpacity??1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...h},e.dataKey)}return null})]})})}var H,U,W,G,K=h((()=>{P(),z(),H=`hsl(var(--primary))`,U={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},W=e=>U[e]||e,G=(e,t)=>e?.variant===`comparison`?{strokeOpacity:typeof e.opacity==`number`?e.opacity:t===`line`||t===`scatter`?.5:.6,fillOpacity:typeof e.opacity==`number`?e.opacity:t===`bar`?.4:t===`area`?.2:.5,strokeDasharray:e.dashArray??(t===`line`||t===`area`?`4 4`:void 0)}:null})),q=n.default.lazy(()=>Promise.resolve().then(()=>(S(),v))),J=n.default.lazy(()=>Promise.resolve().then(()=>(K(),B))),Y=({schema:e})=>(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,i.jsx)(q,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),X=({schema:e,onChartClick:t})=>{let a=n.default.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,i.jsx)(J,{chartType:a.chartType,data:a.data,config:a.config,xAxisKey:a.xAxisKey,series:a.series,className:a.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,isAnimationActive:e.isAnimationActive,onChartClick:t})})};function Z(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ee(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0);break}return{[i]:e,[n]:o}})}async function te(e,n,r,i,a){if(!e.length||!n)return e;let o=a||((e,t)=>t),s=`__raw_${n}`,c=r?.fields?.[n];if(!c){let t=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[n],i=String(r??``),a=t.test(i)?i:Z(i);return{...e,[n]:o(i,a),[s]:r}})}let l=c.type;if(l===`select`||l===`picklist`||l===`dropdown`){let t=c.options||[];if(t.length===0)return e.map(e=>{let t=e[n],r=String(t??``),i=Z(r);return{...e,[n]:o(r,i),[s]:t}});let r={};for(let e of t)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let t=e[n],i=String(t??``),a=r[i]||Z(i);return{...e,[n]:o(i,a),[s]:t}})}if(l===`lookup`||l===`master_detail`){let r=c.reference_to||c.reference;if(!r||!i||typeof i.find!=`function`)return e.map(e=>({...e,[s]:e[n]}));let a=[...new Set(e.map(e=>e[n]).filter(e=>e!=null))];if(a.length===0)return e.map(e=>({...e,[s]:e[n]}));let o=c.id_field||`id`;try{let l=(0,t.extractRecords)(await i.find(r,{$filter:{[o]:{$in:a}},$top:a.length})),u=c.reference_field||c.display_field||`name`,d={};for(let e of l){let t=String(e[o]??e.id??e._id??``),n=e[u]||e.name||e.label||e.title||t;t&&(d[t]=String(n))}return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:d[r]||r,[s]:t}})}catch(t){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,t),e.map(e=>({...e,[s]:e[n]}))}}if(l===`date`||l===`datetime`||l===`date_time`||l===`timestamp`||l===`time`)return e.map(e=>({...e,[s]:e[n]}));let u=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:u.test(r)?r:Z(r),[s]:t}})}var Q=e=>{let{schema:a}=e,l=e.onSegmentClick,u=(0,n.useContext)(o.SchemaRendererContext),d=e.dataSource||u?.dataSource,f=(0,o.useDataScope)(a.bind),{fieldOptionLabel:p}=(0,c.useSafeFieldLabel)(),m=(0,n.useRef)(p);(0,n.useEffect)(()=>{m.current=p},[p]);let[h,g]=(0,n.useState)([]),[_,v]=(0,n.useState)(()=>!(Array.isArray(a.data)&&a.data.length>0)&&(!!a.objectName||!!a.dataset)),[y,b]=(0,n.useState)(null),[x,S]=(0,n.useState)(null),[C,w]=(0,n.useState)(null),[T,E]=(0,n.useState)(null),{openRecordList:D}=(0,o.useDrillNavigation)(),O=(0,c.useSafeTranslate)(),k=(0,n.useMemo)(()=>a.aggregate?JSON.stringify(a.aggregate):``,[a.aggregate]),A=(0,n.useMemo)(()=>a.filter?JSON.stringify(a.filter):``,[a.filter]),j=(0,n.useMemo)(()=>a.compareTo?JSON.stringify(a.compareTo):``,[a.compareTo]),M=(0,n.useMemo)(()=>a.dataset?JSON.stringify({d:a.dataset,dim:a.dimensions??[],val:a.values??[]}):``,[a.dataset,a.dimensions,a.values]),N=e=>e!==`pie`&&e!==`donut`&&e!==`funnel`;(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let n={headers:{accept:`application/json`},credentials:`include`},r=a.objectName,i,o=null,s=a.aggregate?.groupBy;if(r)i=s&&typeof s==`object`&&!Array.isArray(s)?s.field:typeof s==`string`?s:a.xAxisKey;else if(a.dataset){let e=Array.isArray(a.dimensions)&&a.dimensions.length?a.dimensions[0]:void 0,t=await(await fetch(`/api/v1/meta/dataset/${encodeURIComponent(a.dataset)}`,n)).json().catch(()=>null);o=t?.item??t?.data??t,r=o?.object,i=((o?.dimensions||[]).find(t=>t?.name===e)??(o?.dimensions||[])[0])?.field??e}if(!r||!i){e||(w(null),E(null));return}let c=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`,n)).json().catch(()=>null),l=c?.item??c?.data??c,u=(0,t.buildOptionColorMap)(l?.fields?.[i]?.options),d=null;if(a.dataset&&Array.isArray(a.dimensions)){let e={};for(let n of a.dimensions){let r=(o?.dimensions||[]).find(e=>e?.name===n)?.field??n,i=(0,t.buildDimensionLabelMap)(l?.fields?.[r]?.options);i&&(e[n]=i)}Object.keys(e).length>0&&(d=e)}e||(w(u),E(d))}catch{e||(w(null),E(null))}})(),()=>{e=!0}},[a.objectName,a.dataset,M,k,a.xAxisKey]);let P=(0,n.useCallback)(async(e,n)=>{if(a.aggregate&&typeof e.aggregate==`function`){let t=a.aggregate.groupBy;if(t&&typeof t==`object`&&!Array.isArray(t)){let r=a.aggregate.field,i=a.aggregate.function,o={function:i,alias:r||i};i!==`count`&&r&&(o.field=r);let s=await e.aggregate(a.objectName,{groupBy:[t],aggregations:[o],where:n});return Array.isArray(s)?s:[]}let r=await e.aggregate(a.objectName,{field:a.aggregate.field,function:a.aggregate.function,groupBy:t,filter:n});return Array.isArray(r)?r:[]}if(typeof e.find==`function`){let r=(0,t.extractRecords)(await e.find(a.objectName,{$filter:n}));return a.aggregate&&r.length>0&&(r=ee(r,a.aggregate)),r}return[]},[a.objectName,k]),F=(0,n.useCallback)(async(e,n)=>{if(!e||!a.objectName&&!a.dataset){n.current&&v(!1);return}n.current&&(v(!0),b(null));try{if(a.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveDateMacros)(a.filter),i=await e.queryDataset(a.dataset,{dimensions:Array.isArray(a.dimensions)?a.dimensions:[],measures:Array.isArray(a.values)?a.values:[],...r?{runtimeFilter:r}:{}});n.current&&g(Array.isArray(i?.rows)?i.rows:[]);return}let r=(0,t.resolveDateMacros)(a.filter),i=a.compareTo,o=!!i&&N(a.chartType),s=o?(0,t.shiftFilterByCompareTo)(a.filter,i):null,[c,l]=await Promise.all([P(e,r),s?P(e,s):Promise.resolve([])]),u=c,d=a.aggregate?.groupBy,f=d&&typeof d==`object`&&!Array.isArray(d)?d.alias||d.field:d||a.xAxisKey;if(o&&l.length>0&&a.aggregate){let e=a.aggregate.field,t=a.aggregate.function,n=n=>{if(n==null)return null;let r=`${e}_${t}`;return r in n?Number(n[r]):t===`count`&&`${e}_count`in n?Number(n[`${e}_count`]):e in n?Number(n[e]):`value`in n?Number(n.value):`count`in n?Number(n.count):null},r=`${e}__comparison`,i=f;if(i&&u.some(e=>e[i]!=null)&&l.some(e=>e[i]!=null)){let e=new Map;for(let t of l){let r=String(t[i]??``);e.set(r,n(t))}u=u.map(t=>{let n=String(t[i]??``),a=e.get(n);return a==null?t:{...t,[r]:a}});let t=new Set(u.map(e=>String(e[i]??``)));for(let e of l){let a=String(e[i]??``);t.has(a)||u.push({[i]:a,[r]:n(e)})}}else{let e=Math.max(u.length,l.length),t=[];for(let i=0;i<e;i++){let e=u[i]||{},a=l[i];t.push(a?{...e,[r]:n(a)}:e)}u=t}}if(f&&typeof e.getObjectSchema==`function`)try{let t=await e.getObjectSchema(a.objectName);u=await te(u,f,t,e,(e,t)=>m.current(a.objectName,f,e,t))}catch{}n.current&&g(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&b(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&v(!1)}},[a.objectName,M,k,A,j,a.xAxisKey,a.chartType,P]);(0,n.useEffect)(()=>{let e={current:!0};return(a.objectName||a.dataset)&&!f&&!a.data?F(d,e):e.current&&v(!1),()=>{e.current=!1}},[a.objectName,M,d,f,a.data,A,k,j,F]);let I=f||a.data||h,L=Array.isArray(I)?I:[],R=a.drillDown,z=a.aggregate?.groupBy||a.xAxisKey,B=(0,n.useMemo)(()=>{if(!z)return new Map;let e=new Map,t=`__raw_${z}`;for(let n of L){let r=n?.[z];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[L,z]),V=a.compareTo,H=!!V&&N(a.chartType)&&!!a.aggregate&&L.some(e=>e[`${a.aggregate.field}__comparison`]!=null),U=(0,n.useMemo)(()=>{let e=Array.isArray(a.series)?a.series:null;if(!H)return e;let n=e||[{dataKey:a.aggregate.field}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(V,a.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:`${a.aggregate.field}__comparison`,label:r,variant:`comparison`}]},[H,a.series,a.aggregate,a.filter,V]),W=a.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(L,T),a.dimensions,a.values):null,G=W?{...a,data:W.data,xAxisKey:W.xAxisKey,series:W.series}:{...a,data:L,...U?{series:U}:{}},K=a.colors&&!Array.isArray(a.colors)&&typeof a.colors==`object`?a.colors:null,q=Array.isArray(a.colors)?a.colors:void 0,J=C||K?{...C||{},...K||{}}:void 0,Y={...G,colors:q,...J?{categoryColors:J}:{}};if(_&&L.length===0)return(0,i.jsxs)(`div`,{className:`p-2 `+(a.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,i.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,i.jsx)(r.ChartSkeleton,{className:`h-full`})]});if(y)return(0,i.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(a.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,i.jsx)(s.AlertCircle,{className:`h-6 w-6 text-destructive opacity-60`}),(0,i.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:y})]});if(!d&&a.objectName&&L.length===0)return(0,i.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(a.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,a.objectName,`”`]});let Z=(0,t.isDrillEnabled)(R)?e=>{let t=e.category,n=t!=null&&B.has(String(t))?B.get(String(t)):t;S({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,Q=l??Z,$=!l&&x&&a.objectName?(()=>{let e=(0,t.computeDrillFilter)(R,x,{groupByField:z}),n={...a.filter||{},...e},c=(0,t.resolveDrillTitle)(R,x,a.title||`Details`),l=R?.target??`drawer`,u=(0,i.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,i.jsx)(o.SchemaRenderer,{schema:{type:`object-data-table`,objectName:a.objectName,filter:n,pagination:!0,pageSize:R?.maxRows,columns:R?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:d})}),f=D&&a.objectName?(0,i.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{D(a.objectName,n),S(null)},children:[O(`dashboard.openInList`,`Open in list`),(0,i.jsx)(s.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]}):null;return l===`dialog`?(0,i.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&S(null),children:(0,i.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,i.jsxs)(r.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,i.jsx)(r.DialogTitle,{children:c}),f]}),u]})}):(0,i.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&S(null),children:(0,i.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,i.jsxs)(r.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,i.jsx)(r.SheetTitle,{children:c}),f]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:u})]})})})():null;return(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(r.RefreshIndicator,{active:_&&L.length>0}),(0,i.jsx)(X,{...e,schema:Y,onChartClick:Q}),$]})};t.ComponentRegistry.register(`object-chart`,Q,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]});var $={"bar-chart":Y,chart:X};t.ComponentRegistry.register(`bar-chart`,Y,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),t.ComponentRegistry.register(`chart`,Q,{namespace:`view`,category:`view`,label:`Chart`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),t.ComponentRegistry.register(`chart`,X,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),t.ComponentRegistry.register(`chart:bar`,X,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),t.ComponentRegistry.register(`pie-chart`,X,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),t.ComponentRegistry.register(`donut-chart`,X,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),t.ComponentRegistry.register(`radar-chart`,X,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),t.ComponentRegistry.register(`scatter-chart`,X,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}}),e.ChartBarRenderer=Y,e.ChartRenderer=X,e.ObjectChart=Q,e.chartComponents=$});
|
|
7
|
+
`)}}):null},M=a.Tooltip,N=a.Legend}));function F(e){return e?.[0]?.dataKey||`value`}function I(e,t,n){if(!e)return null;let r=e.payload??e,i=r?.[t];if(i==null)return null;let a=F(n);return{category:String(i),series:a,value:typeof r?.[a]==`number`?r[a]:void 0}}function L(e,t){if(!e)return null;let n=e.name??e.payload?.name??e.root?.name;if(n==null)return null;let r=e.value??e.size??e.payload?.size;return{category:String(n),series:F(t),value:typeof r==`number`?r:void 0}}function R(e,t){if(!e)return null;let n=e.payload??e,r=n?.name;return r==null||n?.depth===0?null:{category:String(r),series:F(t),value:typeof n?.value==`number`?n.value:void 0}}var z=h((()=>{})),B=g({default:()=>V});function V({chartType:e=`bar`,data:t=[],config:r={},xAxisKey:o=`name`,series:s=[],className:c=``,colors:l,categoryColors:u,onChartClick:d,isAnimationActive:f}){let p=e===`column`?`bar`:e,m=Array.isArray(t)?t:[],h=f===!1?{isAnimationActive:!1}:{},[g,_]=n.useState(!1),v=n.useCallback(e=>{if(!d||!e)return;let t=Array.isArray(e.activePayload)?e.activePayload[0]:void 0;d({category:e.activeLabel==null?void 0:String(e.activeLabel),series:t?.dataKey?String(t.dataKey):void 0,value:typeof t?.value==`number`?t.value:void 0})},[d]),y=n.useCallback(e=>{if(!d||!e)return;let t=e.payload?.[o],n=s[0]?.dataKey||`value`;d({category:t==null?void 0:String(t),series:n,value:typeof e.payload?.[n]==`number`?e.payload[n]:void 0})},[d,o,s]),b=d?{onClick:v,style:{cursor:`pointer`}}:{},x=d?{onClick:y,style:{cursor:`pointer`}}:{},S=n.useCallback((e,t,n)=>u&&u[e==null?``:String(e)]||n[t%n.length],[u]),C=n.useCallback(e=>{if(!d)return;let t=I(e,o,s);t&&d(t)},[d,o,s]),D=n.useCallback(e=>{if(!d)return;let t=L(e,s);t&&d(t)},[d,s]),O=n.useCallback(e=>{if(!d)return;let t=R(e,s);t&&d(t)},[d,s]),k=d?{onClick:C,cursor:`pointer`}:{},A=d?{onClick:D,style:{cursor:`pointer`}}:{},j=d?{onClick:O,style:{cursor:`pointer`}}:{};n.useEffect(()=>{let e=()=>_(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let P={bar:a.BarChart,"horizontal-bar":a.BarChart,line:a.LineChart,area:a.AreaChart,pie:a.PieChart,donut:a.PieChart,radar:a.RadarChart,scatter:a.ScatterChart,funnel:a.FunnelChart,combo:a.BarChart,treemap:a.BarChart,sankey:a.BarChart}[p]||a.BarChart,F=n.useCallback(e=>{if(e==null||e===``)return``;let t=r?.[String(e)]?.label;if(t!=null)return String(t);let n=typeof e==`string`?e:String(e);if(/^\d{4}-\d{2}-\d{2}/.test(n)){let e=new Date(n);if(!Number.isNaN(e.getTime())){let t=(m.length>1?Math.abs(new Date(String(m[m.length-1][o]??``)).getTime()-new Date(String(m[0][o]??``)).getTime()):0)/(1e3*60*60*24);try{return t<=62?e.toLocaleDateString(void 0,{month:`short`,day:`numeric`}):e.toLocaleDateString(void 0,{month:`short`,year:`numeric`})}catch{return e.toISOString().slice(0,10)}}}return g&&n.length>8?n.slice(0,8)+`…`:n},[m,o,g,r]),z=n.useMemo(()=>m.some(e=>String(e[o]||``).length>5),[m,o]),B=()=>Array.isArray(l)&&l.length>0?l:[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],V=n.useCallback(e=>{if(e==null||e===``)return``;let t=typeof e==`number`?e:Number(e);if(!Number.isFinite(t))return String(e);try{return new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1}).format(t)}catch{return String(t)}},[]),U=n.useMemo(()=>({tickLine:!1,tickMargin:10,axisLine:!1,interval:`preserveStartEnd`,minTickGap:g?32:48,tickFormatter:F,...!g&&z&&{angle:-35,textAnchor:`end`,height:60}}),[g,z,F]);if(p===`pie`||p===`donut`){let e=p===`donut`?`52%`:0,t=B(),n={...r};return m.forEach((e,r)=>{let i=e?.[o];if(i==null||i===``)return;let a=String(i);n[a]||(n[a]={label:a,color:S(i,r,t)})}),(0,i.jsx)(w,{config:n,className:c,children:(0,i.jsxs)(a.PieChart,{children:[(0,i.jsx)(M,{cursor:!1,content:(0,i.jsx)(T,{hideLabel:!0})}),(0,i.jsx)(a.Pie,{data:m,dataKey:s[0]?.dataKey||`value`,nameKey:o||`name`,innerRadius:e,strokeWidth:5,paddingAngle:2,outerRadius:`85%`,...h,...x,children:m.map((e,n)=>(0,i.jsx)(a.Cell,{fill:W(S(e?.[o],n,t))},`cell-${n}`))}),(0,i.jsx)(N,{verticalAlign:`bottom`,wrapperStyle:{fontSize:g?`11px`:`12px`,paddingTop:`8px`},content:(0,i.jsx)(E,{nameKey:o,className:`flex-wrap`})})]})})}if(p===`funnel`){let e=s[0]?.dataKey||`value`,t=B(),n=d?t=>{t&&d({category:t?.payload?.[o]??t?.[o],value:t?.payload?.[e]??t?.[e]})}:void 0,l=n?{onClick:n,style:{cursor:`pointer`}}:{},u=[...m].sort((t,n)=>{let r=Number(t?.[e]??0);return Number(n?.[e]??0)-r});return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.FunnelChart,{children:[(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsxs)(a.Funnel,{dataKey:e,data:u,nameKey:o,isAnimationActive:!0,...l,children:[(0,i.jsx)(a.LabelList,{position:`right`,fill:`hsl(var(--foreground))`,stroke:`none`,dataKey:o}),u.map((e,n)=>(0,i.jsx)(a.Cell,{fill:W(t[n%t.length])},`funnel-cell-${n}`))]})]})})}if(p===`treemap`){let e=s[0]?.dataKey||`value`,t=B(),n=m.map((n,r)=>({name:String(n?.[o]??``),size:Number(n?.[e])||0,fill:W(t[r%t.length])}));return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsx)(a.Treemap,{data:n,dataKey:`size`,nameKey:`name`,isAnimationActive:!0,content:(0,i.jsx)(e=>{let{x:t,y:n,width:r,height:a,name:o,fill:s}=e;return r<=0||a<=0?null:(0,i.jsxs)(`g`,{children:[(0,i.jsx)(`rect`,{x:t,y:n,width:r,height:a,fill:s,stroke:`hsl(var(--background))`,strokeWidth:2}),r>48&&a>18?(0,i.jsx)(`text`,{x:t+6,y:n+18,fill:`#fff`,fontSize:12,className:`pointer-events-none`,children:o}):null]})},{}),...A,children:(0,i.jsx)(a.Tooltip,{})})})}if(p===`sankey`){let e=s[0]?.dataKey||`value`,t=s[0]?.label||e,n=m.filter(t=>(Number(t?.[e])||0)>0),l=[{name:t},...n.map(e=>({name:String(e?.[o]??``)}))],u=n.map((t,n)=>({source:0,target:n+1,value:Number(t?.[e])||0}));return u.length===0?(0,i.jsx)(`div`,{className:c}):(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsx)(a.Sankey,{data:{nodes:l,links:u},nodePadding:24,link:{stroke:`hsl(var(--muted-foreground))`,strokeOpacity:.25},node:{fill:`hsl(var(--chart-1))`},...j,children:(0,i.jsx)(a.Tooltip,{})})})}if(p===`radar`)return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.RadarChart,{data:m,children:[(0,i.jsx)(a.PolarGrid,{}),(0,i.jsx)(a.PolarAngleAxis,{dataKey:o}),(0,i.jsx)(a.PolarRadiusAxis,{}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map(e=>{let t=W(r[e.dataKey]?.color||H);return(0,i.jsx)(a.Radar,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6},e.dataKey)})]})});if(p===`scatter`)return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.ScatterChart,{children:[(0,i.jsx)(a.CartesianGrid,{vertical:!1}),(0,i.jsx)(a.XAxis,{type:`number`,dataKey:o,name:String(r[o]?.label||o),tickLine:!1,axisLine:!1,minTickGap:g?32:48}),(0,i.jsx)(a.YAxis,{type:`number`,dataKey:s[0]?.dataKey||`value`,name:String(r[s[0]?.dataKey]?.label||s[0]?.dataKey),tickLine:!1,axisLine:!1,tickFormatter:V,width:48}),(0,i.jsx)(a.ZAxis,{type:`number`,range:[60,400]}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map((e,t)=>{let n=B(),o=W(r[e.dataKey]?.color||n[t%n.length]),s=G(e,`scatter`);return(0,i.jsx)(a.Scatter,{name:r[e.dataKey]?.label||e.dataKey,data:m,fill:o,fillOpacity:s?.fillOpacity,...k},e.dataKey)})]})});if(p===`combo`)return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(a.BarChart,{data:m,children:[(0,i.jsx)(a.CartesianGrid,{vertical:!1}),(0,i.jsx)(a.XAxis,{dataKey:o,...U}),(0,i.jsx)(a.YAxis,{yAxisId:`left`,tickLine:!1,axisLine:!1,tickFormatter:V,width:48}),(0,i.jsx)(a.YAxis,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1,tickFormatter:V,width:48}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map((e,t)=>{let n=W(r[e.dataKey]?.color||H),o=e.chartType||(t===0?`bar`:`line`),s=o===`bar`?`left`:`right`,c=G(e,o);return o===`line`?(0,i.jsx)(a.Line,{yAxisId:s,type:`monotone`,dataKey:e.dataKey,stroke:n,strokeWidth:2,dot:!1,strokeOpacity:c?.strokeOpacity,strokeDasharray:c?.strokeDasharray,...h},e.dataKey):o===`area`?(0,i.jsx)(a.Area,{yAxisId:s,type:`monotone`,dataKey:e.dataKey,fill:n,stroke:n,fillOpacity:c?.fillOpacity??.4,strokeOpacity:c?.strokeOpacity,strokeDasharray:c?.strokeDasharray,...h},e.dataKey):(0,i.jsx)(a.Bar,{yAxisId:s,dataKey:e.dataKey,fill:n,radius:4,fillOpacity:c?.fillOpacity,...h},e.dataKey)})]})});let K=p===`horizontal-bar`,q=B(),J=u?Object.values(u).map(e=>W(String(e))):[],Y=Array.from(new Set([...q,...J,...s.map((e,t)=>W(r[e.dataKey]?.color||q[t%q.length]||H))])),X=e=>`g`+e.replace(/[^a-zA-Z0-9]/g,``);return(0,i.jsx)(w,{config:r,className:c,children:(0,i.jsxs)(P,{data:m,layout:K?`vertical`:`horizontal`,...b,children:[(0,i.jsx)(`defs`,{children:Y.map(e=>(0,i.jsxs)(n.Fragment,{children:[(0,i.jsxs)(`linearGradient`,{id:`bg-${X(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.95}),(0,i.jsx)(`stop`,{offset:`100%`,style:{stopColor:e},stopOpacity:.5})]}),(0,i.jsxs)(`linearGradient`,{id:`ag-${X(e)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,i.jsx)(`stop`,{offset:`0%`,style:{stopColor:e},stopOpacity:.5}),(0,i.jsx)(`stop`,{offset:`95%`,style:{stopColor:e},stopOpacity:.05})]})]},X(e)))}),(0,i.jsx)(a.CartesianGrid,{vertical:!1}),K?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{type:`number`,tickLine:!1,axisLine:!1,tickFormatter:V}),(0,i.jsx)(a.YAxis,{type:`category`,dataKey:o,tickLine:!1,axisLine:!1,width:Math.min(140,Math.max(60,Math.max(...m.map(e=>String(e[o]??``).length))*7)),tickFormatter:F})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(a.XAxis,{dataKey:o,...U}),(0,i.jsx)(a.YAxis,{tickLine:!1,axisLine:!1,tickFormatter:V,width:48})]}),(0,i.jsx)(M,{content:(0,i.jsx)(T,{})}),(0,i.jsx)(N,{content:(0,i.jsx)(E,{}),...g&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),s.map((e,t)=>{let n=B(),c=e.variant===`comparison`,l=c?s.slice(0,t).find(e=>e.variant!==`comparison`)||s[0]:e,u=c?s.indexOf(l):t,d=W(r[l.dataKey]?.color||n[u%n.length]||H);if(p===`bar`||p===`horizontal-bar`){let t=s.filter(e=>e.variant!==`comparison`).length===1&&!c&&s.length===1&&m.length>1,r=G(e,`bar`);return(0,i.jsx)(a.Bar,{dataKey:e.dataKey,fill:`url(#bg-${X(d)})`,radius:4,fillOpacity:r?.fillOpacity,...h,children:t&&m.map((e,t)=>(0,i.jsx)(a.Cell,{fill:`url(#bg-${X(W(S(e?.[o],t,n)))})`},`cell-${t}`))},e.dataKey)}if(p===`line`){let t=G(e,`line`);return(0,i.jsx)(a.Line,{type:`monotone`,dataKey:e.dataKey,stroke:d,strokeWidth:2,dot:!1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...h},e.dataKey)}if(p===`area`){let t=G(e,`area`);return(0,i.jsx)(a.Area,{type:`monotone`,dataKey:e.dataKey,fill:`url(#ag-${X(d)})`,stroke:d,strokeWidth:2,fillOpacity:t?.fillOpacity??1,strokeOpacity:t?.strokeOpacity,strokeDasharray:t?.strokeDasharray,...h},e.dataKey)}return null})]})})}var H,U,W,G,K=h((()=>{P(),z(),H=`hsl(var(--primary))`,U={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},W=e=>U[e]||e,G=(e,t)=>e?.variant===`comparison`?{strokeOpacity:typeof e.opacity==`number`?e.opacity:t===`line`||t===`scatter`?.5:.6,fillOpacity:typeof e.opacity==`number`?e.opacity:t===`bar`?.4:t===`area`?.2:.5,strokeDasharray:e.dashArray??(t===`line`||t===`area`?`4 4`:void 0)}:null})),q=n.default.lazy(()=>Promise.resolve().then(()=>(S(),v))),J=n.default.lazy(()=>Promise.resolve().then(()=>(K(),B))),Y=({schema:e})=>(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,i.jsx)(q,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),X=({schema:e,onChartClick:t})=>{let a=n.default.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,i.jsx)(n.Suspense,{fallback:(0,i.jsx)(r.Skeleton,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,i.jsx)(J,{chartType:a.chartType,data:a.data,config:a.config,xAxisKey:a.xAxisKey,series:a.series,className:a.className,colors:Array.isArray(e.colors)?e.colors:void 0,categoryColors:e.categoryColors,isAnimationActive:e.isAnimationActive,onChartClick:t})})};function Z(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ee(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0);break}return{[i]:e,[n]:o}})}async function te(e,n,r,i,a){if(!e.length||!n)return e;let o=a||((e,t)=>t),s=`__raw_${n}`,c=r?.fields?.[n];if(!c){let t=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[n],i=String(r??``),a=t.test(i)?i:Z(i);return{...e,[n]:o(i,a),[s]:r}})}let l=c.type;if(l===`select`||l===`picklist`||l===`dropdown`){let t=c.options||[];if(t.length===0)return e.map(e=>{let t=e[n],r=String(t??``),i=Z(r);return{...e,[n]:o(r,i),[s]:t}});let r={};for(let e of t)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let t=e[n],i=String(t??``),a=r[i]||Z(i);return{...e,[n]:o(i,a),[s]:t}})}if(l===`lookup`||l===`master_detail`){let r=c.reference_to||c.reference;if(!r||!i||typeof i.find!=`function`)return e.map(e=>({...e,[s]:e[n]}));let a=[...new Set(e.map(e=>e[n]).filter(e=>e!=null))];if(a.length===0)return e.map(e=>({...e,[s]:e[n]}));let o=c.id_field||`id`;try{let l=(0,t.extractRecords)(await i.find(r,{$filter:{[o]:{$in:a}},$top:a.length})),u=c.reference_field||c.display_field||`name`,d={};for(let e of l){let t=String(e[o]??e.id??e._id??``),n=e[u]||e.name||e.label||e.title||t;t&&(d[t]=String(n))}return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:d[r]||r,[s]:t}})}catch(t){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,t),e.map(e=>({...e,[s]:e[n]}))}}if(l===`date`||l===`datetime`||l===`date_time`||l===`timestamp`||l===`time`)return e.map(e=>({...e,[s]:e[n]}));let u=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let t=e[n],r=String(t??``);return{...e,[n]:u.test(r)?r:Z(r),[s]:t}})}var Q=e=>{let{schema:a}=e,l=e.onSegmentClick,u=(0,n.useContext)(o.SchemaRendererContext),d=e.dataSource||u?.dataSource,f=(0,o.useDataScope)(a.bind),{fieldOptionLabel:p}=(0,c.useSafeFieldLabel)(),m=(0,n.useRef)(p);(0,n.useEffect)(()=>{m.current=p},[p]);let[h,g]=(0,n.useState)([]),[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)(()=>!(Array.isArray(a.data)&&a.data.length>0)&&(!!a.objectName||!!a.dataset)),[x,S]=(0,n.useState)(null),[C,w]=(0,n.useState)(null),[T,E]=(0,n.useState)(null),[D,O]=(0,n.useState)(null),{openRecordList:k}=(0,o.useDrillNavigation)(),A=(0,c.useSafeTranslate)(),j=(0,n.useMemo)(()=>a.aggregate?JSON.stringify(a.aggregate):``,[a.aggregate]),M=(0,n.useMemo)(()=>a.filter?JSON.stringify(a.filter):``,[a.filter]),N=(0,n.useMemo)(()=>a.compareTo?JSON.stringify(a.compareTo):``,[a.compareTo]),P=(0,n.useMemo)(()=>a.dataset?JSON.stringify({d:a.dataset,dim:a.dimensions??[],val:a.values??[]}):``,[a.dataset,a.dimensions,a.values]),F=e=>e!==`pie`&&e!==`donut`&&e!==`funnel`;(0,n.useEffect)(()=>{let e=!1;return(async()=>{try{let n={headers:{accept:`application/json`},credentials:`include`},r=a.objectName,i,o=null,s=a.aggregate?.groupBy;if(r)i=s&&typeof s==`object`&&!Array.isArray(s)?s.field:typeof s==`string`?s:a.xAxisKey;else if(a.dataset){let e=Array.isArray(a.dimensions)&&a.dimensions.length?a.dimensions[0]:void 0,t=await(await fetch(`/api/v1/meta/dataset/${encodeURIComponent(a.dataset)}`,n)).json().catch(()=>null);o=t?.item??t?.data??t,r=o?.object,i=((o?.dimensions||[]).find(t=>t?.name===e)??(o?.dimensions||[])[0])?.field??e}if(!r||!i){e||(E(null),O(null));return}let c=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(r)}`,n)).json().catch(()=>null),l=c?.item??c?.data??c,u=(0,t.buildOptionColorMap)(l?.fields?.[i]?.options),d=null;if(a.dataset&&Array.isArray(a.dimensions)){let e={};for(let n of a.dimensions){let r=(o?.dimensions||[]).find(e=>e?.name===n)?.field??n,i=(0,t.buildDimensionLabelMap)(l?.fields?.[r]?.options);i&&(e[n]=i)}Object.keys(e).length>0&&(d=e)}e||(E(u),O(d))}catch{e||(E(null),O(null))}})(),()=>{e=!0}},[a.objectName,a.dataset,P,j,a.xAxisKey]);let I=(0,n.useCallback)(async(e,n)=>{if(a.aggregate&&typeof e.aggregate==`function`){let t=a.aggregate.groupBy;if(t&&typeof t==`object`&&!Array.isArray(t)){let r=a.aggregate.field,i=a.aggregate.function,o={function:i,alias:r||i};i!==`count`&&r&&(o.field=r);let s=await e.aggregate(a.objectName,{groupBy:[t],aggregations:[o],where:n});return Array.isArray(s)?s:[]}let r=await e.aggregate(a.objectName,{field:a.aggregate.field,function:a.aggregate.function,groupBy:t,filter:n});return Array.isArray(r)?r:[]}if(typeof e.find==`function`){let r=(0,t.extractRecords)(await e.find(a.objectName,{$filter:n}));return a.aggregate&&r.length>0&&(r=ee(r,a.aggregate)),r}return[]},[a.objectName,j]),L=(0,n.useCallback)(async(e,n)=>{if(!e||!a.objectName&&!a.dataset){n.current&&b(!1);return}n.current&&(b(!0),S(null));try{if(a.dataset&&typeof e.queryDataset==`function`){let r=(0,t.resolveDateMacros)(a.filter),i=await e.queryDataset(a.dataset,{dimensions:Array.isArray(a.dimensions)?a.dimensions:[],measures:Array.isArray(a.values)?a.values:[],...r?{runtimeFilter:r}:{}});n.current&&(g(Array.isArray(i?.rows)?i.rows:[]),v(Array.isArray(i?.fields)?i.fields:null));return}let r=(0,t.resolveDateMacros)(a.filter),i=a.compareTo,o=!!i&&F(a.chartType),s=o?(0,t.shiftFilterByCompareTo)(a.filter,i):null,[c,l]=await Promise.all([I(e,r),s?I(e,s):Promise.resolve([])]),u=c,d=a.aggregate?.groupBy,f=d&&typeof d==`object`&&!Array.isArray(d)?d.alias||d.field:d||a.xAxisKey;if(o&&l.length>0&&a.aggregate){let e=a.aggregate.field,t=a.aggregate.function,n=n=>{if(n==null)return null;let r=`${e}_${t}`;return r in n?Number(n[r]):t===`count`&&`${e}_count`in n?Number(n[`${e}_count`]):e in n?Number(n[e]):`value`in n?Number(n.value):`count`in n?Number(n.count):null},r=`${e}__comparison`,i=f;if(i&&u.some(e=>e[i]!=null)&&l.some(e=>e[i]!=null)){let e=new Map;for(let t of l){let r=String(t[i]??``);e.set(r,n(t))}u=u.map(t=>{let n=String(t[i]??``),a=e.get(n);return a==null?t:{...t,[r]:a}});let t=new Set(u.map(e=>String(e[i]??``)));for(let e of l){let a=String(e[i]??``);t.has(a)||u.push({[i]:a,[r]:n(e)})}}else{let e=Math.max(u.length,l.length),t=[];for(let i=0;i<e;i++){let e=u[i]||{},a=l[i];t.push(a?{...e,[r]:n(a)}:e)}u=t}}if(f&&typeof e.getObjectSchema==`function`)try{let t=await e.getObjectSchema(a.objectName);u=await te(u,f,t,e,(e,t)=>m.current(a.objectName,f,e,t))}catch{}n.current&&g(u)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&S(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&b(!1)}},[a.objectName,P,j,M,N,a.xAxisKey,a.chartType,I]);(0,n.useEffect)(()=>{let e={current:!0};return(a.objectName||a.dataset)&&!f&&!a.data?L(d,e):e.current&&b(!1),()=>{e.current=!1}},[a.objectName,P,d,f,a.data,M,j,N,L]);let R=f||a.data||h,z=Array.isArray(R)?R:[],B=a.drillDown,V=a.aggregate?.groupBy||a.xAxisKey,H=(0,n.useMemo)(()=>{if(!V)return new Map;let e=new Map,t=`__raw_${V}`;for(let n of z){let r=n?.[V];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[z,V]),U=a.compareTo,W=!!U&&F(a.chartType)&&!!a.aggregate&&z.some(e=>e[`${a.aggregate.field}__comparison`]!=null),G=(0,n.useMemo)(()=>{let e=Array.isArray(a.series)?a.series:null;if(!W)return e;let n=e||[{dataKey:a.aggregate.field}],r={vsLastWeek:`Previous week`,vsLastMonth:`Previous month`,vsLastQuarter:`Previous quarter`,vsLastYear:`Previous year`,vsYesterday:`Yesterday`,vsPreviousPeriod:`Previous period`}[(0,t.compareToTrendLabelKey)(U,a.filter)]||`Previous period`;return[...n.map(e=>({...e,variant:e.variant||`current`})),{dataKey:`${a.aggregate.field}__comparison`,label:r,variant:`comparison`}]},[W,a.series,a.aggregate,a.filter,U]),K=a.dataset?(0,t.buildChartSeries)((0,t.relabelDimensions)(z,D),a.dimensions,a.values,_):null,q=K?{...a,data:K.data,xAxisKey:K.xAxisKey,series:K.series}:{...a,data:z,...G?{series:G}:{}},J=a.colors&&!Array.isArray(a.colors)&&typeof a.colors==`object`?a.colors:null,Y=Array.isArray(a.colors)?a.colors:void 0,Z=T||J?{...T||{},...J||{}}:void 0,Q={...q,colors:Y,...Z?{categoryColors:Z}:{}};if(y&&z.length===0)return(0,i.jsxs)(`div`,{className:`p-2 `+(a.className||``),"data-testid":`chart-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,i.jsx)(`span`,{className:`sr-only`,children:`Loading chart data…`}),(0,i.jsx)(r.ChartSkeleton,{className:`h-full`})]});if(x)return(0,i.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(a.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,i.jsx)(s.AlertCircle,{className:`h-6 w-6 text-destructive opacity-60`}),(0,i.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,i.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:x})]});if(!d&&a.objectName&&z.length===0)return(0,i.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(a.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,a.objectName,`”`]});let $=(0,t.isDrillEnabled)(B)?e=>{let t=e.category,n=t!=null&&H.has(String(t))?H.get(String(t)):t;w({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,ne=l??$,re=!l&&C&&a.objectName?(()=>{let e=(0,t.computeDrillFilter)(B,C,{groupByField:V}),n={...a.filter||{},...e},c=(0,t.resolveDrillTitle)(B,C,a.title||`Details`),l=B?.target??`drawer`,u=(0,i.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,i.jsx)(o.SchemaRenderer,{schema:{type:`object-data-table`,objectName:a.objectName,filter:n,pagination:!0,pageSize:B?.maxRows,columns:B?.columns?.map(e=>({accessorKey:e,header:e})),drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:d})}),f=k&&a.objectName?(0,i.jsxs)(r.Button,{type:`button`,variant:`ghost`,size:`sm`,"data-testid":`drill-open-in-list`,onClick:()=>{k(a.objectName,n),w(null)},children:[A(`dashboard.openInList`,`Open in list`),(0,i.jsx)(s.ArrowUpRight,{className:`ml-1 h-3.5 w-3.5`})]}):null;return l===`dialog`?(0,i.jsx)(r.Dialog,{open:!0,onOpenChange:e=>!e&&w(null),children:(0,i.jsxs)(r.DialogContent,{className:`max-w-4xl`,children:[(0,i.jsxs)(r.DialogHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,i.jsx)(r.DialogTitle,{children:c}),f]}),u]})}):(0,i.jsx)(r.Sheet,{open:!0,onOpenChange:e=>!e&&w(null),children:(0,i.jsxs)(r.SheetContent,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,i.jsxs)(r.SheetHeader,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,i.jsx)(r.SheetTitle,{children:c}),f]}),(0,i.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:u})]})})})():null;return(0,i.jsxs)(`div`,{className:`relative`,children:[(0,i.jsx)(r.RefreshIndicator,{active:y&&z.length>0}),(0,i.jsx)(X,{...e,schema:Q,onChartClick:ne}),re]})};t.ComponentRegistry.register(`object-chart`,Q,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]});var $={"bar-chart":Y,chart:X};t.ComponentRegistry.register(`bar-chart`,Y,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),t.ComponentRegistry.register(`chart`,Q,{namespace:`view`,category:`view`,label:`Chart`,skipFallback:!0,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),t.ComponentRegistry.register(`chart`,X,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),t.ComponentRegistry.register(`chart:bar`,X,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),t.ComponentRegistry.register(`pie-chart`,X,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),t.ComponentRegistry.register(`donut-chart`,X,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),t.ComponentRegistry.register(`radar-chart`,X,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),t.ComponentRegistry.register(`scatter-chart`,X,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}}),e.ChartBarRenderer=Y,e.ChartRenderer=X,e.ObjectChart=Q,e.chartComponents=$});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@object-ui/plugin-charts",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Chart components plugin for Object UI, powered by Recharts",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"lucide-react": "^1.22.0",
|
|
28
28
|
"recharts": "^3.9.0",
|
|
29
|
-
"@object-ui/components": "11.
|
|
30
|
-
"@object-ui/core": "11.
|
|
31
|
-
"@object-ui/i18n": "11.
|
|
32
|
-
"@object-ui/react": "11.
|
|
33
|
-
"@object-ui/types": "11.
|
|
29
|
+
"@object-ui/components": "11.5.0",
|
|
30
|
+
"@object-ui/core": "11.5.0",
|
|
31
|
+
"@object-ui/i18n": "11.5.0",
|
|
32
|
+
"@object-ui/react": "11.5.0",
|
|
33
|
+
"@object-ui/types": "11.5.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "^18.0.0 || ^19.0.0",
|