@object-ui/plugin-charts 6.0.3 → 6.1.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/dist/index.js CHANGED
@@ -1,28 +1,28 @@
1
- import { ComponentRegistry as e, computeDrillFilter as t, extractRecords as n, isDrillEnabled as r, resolveDateMacros as i, resolveDrillTitle as a } from "@object-ui/core";
2
- import * as o from "react";
3
- import s, { Suspense as c, useCallback as l, useContext as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
4
- import { Dialog as h, DialogContent as g, DialogHeader as _, DialogTitle as ee, RefreshIndicator as v, Sheet as y, SheetContent as te, SheetHeader as b, SheetTitle as ne, Skeleton as x } from "@object-ui/components";
5
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
6
- import { Area as T, AreaChart as re, Bar as E, BarChart as D, CartesianGrid as O, Cell as k, Funnel as ie, FunnelChart as A, LabelList as j, Legend as M, Line as N, LineChart as P, Pie as F, PieChart as I, PolarAngleAxis as L, PolarGrid as R, PolarRadiusAxis as z, Radar as ae, RadarChart as oe, ResponsiveContainer as se, Scatter as ce, ScatterChart as le, Tooltip as ue, XAxis as B, YAxis as V, ZAxis as de } from "recharts";
7
- import { SchemaRenderer as fe, SchemaRendererContext as pe, useDataScope as me } from "@object-ui/react";
8
- import { AlertCircle as he } from "lucide-react";
9
- import { useSafeFieldLabel as ge } from "@object-ui/i18n";
1
+ import { ComponentRegistry as e, compareToTrendLabelKey as t, computeDrillFilter as n, extractRecords as r, isDrillEnabled as i, resolveDateMacros as a, resolveDrillTitle as o, shiftFilterByCompareTo as s } from "@object-ui/core";
2
+ import * as c from "react";
3
+ import l, { Suspense as u, useCallback as d, useContext as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
4
+ import { Dialog as _, DialogContent as ee, DialogHeader as v, DialogTitle as y, RefreshIndicator as te, Sheet as ne, SheetContent as re, SheetHeader as ie, SheetTitle as ae, Skeleton as b } from "@object-ui/components";
5
+ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
6
+ import { Area as w, AreaChart as oe, Bar as T, BarChart as E, CartesianGrid as D, Cell as O, Funnel as se, FunnelChart as k, LabelList as A, Legend as j, Line as M, LineChart as ce, Pie as le, PieChart as N, PolarAngleAxis as ue, PolarGrid as de, PolarRadiusAxis as P, Radar as F, RadarChart as I, ResponsiveContainer as L, Scatter as R, ScatterChart as z, Tooltip as B, XAxis as V, YAxis as H, ZAxis as fe } from "recharts";
7
+ import { SchemaRenderer as pe, SchemaRendererContext as me, useDataScope as he } from "@object-ui/react";
8
+ import { AlertCircle as ge } from "lucide-react";
9
+ import { useSafeFieldLabel as _e } from "@object-ui/i18n";
10
10
  //#region \0rolldown/runtime.js
11
- var _e = Object.defineProperty, H = (e, t) => () => (e && (t = e(e = 0)), t), ve = (e, t) => {
11
+ var ve = Object.defineProperty, ye = (e, t) => () => (e && (t = e(e = 0)), t), be = (e, t) => {
12
12
  let n = {};
13
- for (var r in e) _e(n, r, {
13
+ for (var r in e) ve(n, r, {
14
14
  get: e[r],
15
15
  enumerable: !0
16
16
  });
17
- return t || _e(n, Symbol.toStringTag, { value: "Module" }), n;
18
- }, ye = /* @__PURE__ */ ve({ default: () => be });
19
- function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
20
- return /* @__PURE__ */ C("div", {
17
+ return t || ve(n, Symbol.toStringTag, { value: "Module" }), n;
18
+ }, xe = /* @__PURE__ */ be({ default: () => Se });
19
+ function Se({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
20
+ return /* @__PURE__ */ S("div", {
21
21
  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}`,
22
- children: /* @__PURE__ */ C(se, {
22
+ children: /* @__PURE__ */ S(L, {
23
23
  width: "100%",
24
24
  height: r,
25
- children: /* @__PURE__ */ w(D, {
25
+ children: /* @__PURE__ */ C(E, {
26
26
  data: e,
27
27
  margin: {
28
28
  top: 10,
@@ -31,64 +31,64 @@ function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
31
31
  bottom: 5
32
32
  },
33
33
  children: [
34
- /* @__PURE__ */ w("defs", { children: [/* @__PURE__ */ w("linearGradient", {
34
+ /* @__PURE__ */ C("defs", { children: [/* @__PURE__ */ C("linearGradient", {
35
35
  id: "barGradient",
36
36
  x1: "0",
37
37
  y1: "0",
38
38
  x2: "0",
39
39
  y2: "1",
40
40
  children: [
41
- /* @__PURE__ */ C("stop", {
41
+ /* @__PURE__ */ S("stop", {
42
42
  offset: "0%",
43
43
  stopColor: a,
44
44
  stopOpacity: 1
45
45
  }),
46
- /* @__PURE__ */ C("stop", {
46
+ /* @__PURE__ */ S("stop", {
47
47
  offset: "90%",
48
48
  stopColor: a,
49
49
  stopOpacity: .6
50
50
  }),
51
- /* @__PURE__ */ C("stop", {
51
+ /* @__PURE__ */ S("stop", {
52
52
  offset: "100%",
53
53
  stopColor: a,
54
54
  stopOpacity: .3
55
55
  })
56
56
  ]
57
- }), /* @__PURE__ */ w("filter", {
57
+ }), /* @__PURE__ */ C("filter", {
58
58
  id: "glow",
59
59
  height: "130%",
60
60
  children: [
61
- /* @__PURE__ */ C("feGaussianBlur", {
61
+ /* @__PURE__ */ S("feGaussianBlur", {
62
62
  in: "SourceAlpha",
63
63
  stdDeviation: "3",
64
64
  result: "blur"
65
65
  }),
66
- /* @__PURE__ */ C("feOffset", {
66
+ /* @__PURE__ */ S("feOffset", {
67
67
  in: "blur",
68
68
  dx: "0",
69
69
  dy: "0",
70
70
  result: "offsetBlur"
71
71
  }),
72
- /* @__PURE__ */ C("feFlood", {
72
+ /* @__PURE__ */ S("feFlood", {
73
73
  floodColor: a,
74
74
  floodOpacity: "0.5",
75
75
  result: "offsetColor"
76
76
  }),
77
- /* @__PURE__ */ C("feComposite", {
77
+ /* @__PURE__ */ S("feComposite", {
78
78
  in: "offsetColor",
79
79
  in2: "offsetBlur",
80
80
  operator: "in",
81
81
  result: "offsetBlur"
82
82
  }),
83
- /* @__PURE__ */ w("feMerge", { children: [/* @__PURE__ */ C("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ C("feMergeNode", { in: "SourceGraphic" })] })
83
+ /* @__PURE__ */ C("feMerge", { children: [/* @__PURE__ */ S("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ S("feMergeNode", { in: "SourceGraphic" })] })
84
84
  ]
85
85
  })] }),
86
- /* @__PURE__ */ C(O, {
86
+ /* @__PURE__ */ S(D, {
87
87
  strokeDasharray: "3 3",
88
88
  stroke: "hsl(var(--border))",
89
89
  vertical: !1
90
90
  }),
91
- /* @__PURE__ */ C(B, {
91
+ /* @__PURE__ */ S(V, {
92
92
  dataKey: n,
93
93
  tick: {
94
94
  fill: "hsl(var(--muted-foreground))",
@@ -99,7 +99,7 @@ function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
99
99
  axisLine: { stroke: "hsl(var(--border))" },
100
100
  dy: 10
101
101
  }),
102
- /* @__PURE__ */ C(V, {
102
+ /* @__PURE__ */ S(H, {
103
103
  tick: {
104
104
  fill: "hsl(var(--muted-foreground))",
105
105
  fontSize: 12,
@@ -108,7 +108,7 @@ function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
108
108
  tickLine: !1,
109
109
  axisLine: !1
110
110
  }),
111
- /* @__PURE__ */ C(ue, {
111
+ /* @__PURE__ */ S(B, {
112
112
  cursor: {
113
113
  fill: "hsl(var(--muted))",
114
114
  opacity: .2
@@ -123,11 +123,11 @@ function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
123
123
  },
124
124
  itemStyle: { color: "hsl(var(--primary))" }
125
125
  }),
126
- /* @__PURE__ */ C(M, { wrapperStyle: {
126
+ /* @__PURE__ */ S(j, { wrapperStyle: {
127
127
  paddingTop: "20px",
128
128
  fontFamily: "monospace"
129
129
  } }),
130
- /* @__PURE__ */ C(E, {
130
+ /* @__PURE__ */ S(T, {
131
131
  dataKey: t,
132
132
  fill: "url(#barGradient)",
133
133
  radius: [
@@ -144,21 +144,21 @@ function be({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height:
144
144
  })
145
145
  });
146
146
  }
147
- var xe = H((() => {}));
147
+ var Ce = ye((() => {}));
148
148
  //#endregion
149
149
  //#region src/ChartContainerImpl.tsx
150
- function Se() {
151
- let e = o.useContext(Te);
150
+ function we() {
151
+ let e = c.useContext(De);
152
152
  if (!e) throw Error("useChart must be used within a <ChartContainer />");
153
153
  return e;
154
154
  }
155
155
  function U({ id: e, className: t, children: n, config: r, ...i }) {
156
- let a = o.useId(), s = `chart-${e || a.replace(/:/g, "")}`;
157
- return /* @__PURE__ */ C(Te.Provider, {
156
+ let a = c.useId(), o = `chart-${e || a.replace(/:/g, "")}`;
157
+ return /* @__PURE__ */ S(De.Provider, {
158
158
  value: { config: r },
159
- children: /* @__PURE__ */ w("div", {
159
+ children: /* @__PURE__ */ C("div", {
160
160
  "data-slot": "chart",
161
- "data-chart": s,
161
+ "data-chart": o,
162
162
  className: K("flex w-full h-[350px] justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
163
163
  style: {
164
164
  minHeight: 280,
@@ -166,10 +166,10 @@ function U({ id: e, className: t, children: n, config: r, ...i }) {
166
166
  ...i.style
167
167
  },
168
168
  ...i,
169
- children: [/* @__PURE__ */ C(Ee, {
170
- id: s,
169
+ children: [/* @__PURE__ */ S(Oe, {
170
+ id: o,
171
171
  config: r
172
- }), /* @__PURE__ */ C(se, {
172
+ }), /* @__PURE__ */ S(L, {
173
173
  width: "100%",
174
174
  height: "100%",
175
175
  children: n
@@ -177,20 +177,20 @@ function U({ id: e, className: t, children: n, config: r, ...i }) {
177
177
  })
178
178
  });
179
179
  }
180
- function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: s, labelFormatter: c, labelClassName: l, formatter: u, color: d, nameKey: f, labelKey: p }) {
181
- let { config: m } = Se(), h = o.useMemo(() => {
180
+ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabel: i = !1, hideIndicator: a = !1, label: o, labelFormatter: s, labelClassName: l, formatter: u, color: d, nameKey: f, labelKey: p }) {
181
+ let { config: m } = we(), h = c.useMemo(() => {
182
182
  if (i || !t?.length) return null;
183
- let [e] = t, n = Ce(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof s == "string" ? m[s]?.label || s : n?.label;
184
- return c ? /* @__PURE__ */ C("div", {
183
+ let [e] = t, n = Te(m, e, `${p || e?.dataKey || e?.name || "value"}`), r = !p && typeof o == "string" ? m[o]?.label || o : n?.label;
184
+ return s ? /* @__PURE__ */ S("div", {
185
185
  className: K("font-medium", l),
186
- children: c(r, t)
187
- }) : r ? /* @__PURE__ */ C("div", {
186
+ children: s(r, t)
187
+ }) : r ? /* @__PURE__ */ S("div", {
188
188
  className: K("font-medium", l),
189
189
  children: r
190
190
  }) : null;
191
191
  }, [
192
+ o,
192
193
  s,
193
- c,
194
194
  t,
195
195
  i,
196
196
  l,
@@ -199,29 +199,29 @@ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
199
199
  ]);
200
200
  if (!e || !t?.length) return null;
201
201
  let g = t.length === 1 && r !== "dot";
202
- return /* @__PURE__ */ w("div", {
202
+ return /* @__PURE__ */ C("div", {
203
203
  className: K("border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl", n),
204
- children: [g ? null : h, /* @__PURE__ */ C("div", {
204
+ children: [g ? null : h, /* @__PURE__ */ S("div", {
205
205
  className: "grid gap-1.5",
206
206
  children: t.filter((e) => e.type !== "none").map((e, t) => {
207
- let n = Ce(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
208
- return /* @__PURE__ */ C("div", {
207
+ let n = Te(m, e, `${f || e.name || e.dataKey || "value"}`), i = d || e.payload.fill || e.color;
208
+ return /* @__PURE__ */ S("div", {
209
209
  className: K("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", r === "dot" ? "items-center" : ""),
210
- children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ w(S, { children: [n?.icon ? /* @__PURE__ */ C(n.icon, {}) : !a && /* @__PURE__ */ C("div", {
210
+ children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ C(x, { children: [n?.icon ? /* @__PURE__ */ S(n.icon, {}) : !a && /* @__PURE__ */ S("div", {
211
211
  className: K("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", r === "dot" ? "h-2.5 w-2.5" : "", r === "line" ? "w-1" : "", r === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", g && r === "dashed" ? "my-0.5" : ""),
212
212
  style: {
213
213
  "--color-bg": i,
214
214
  "--color-border": i
215
215
  }
216
- }), /* @__PURE__ */ w("div", {
216
+ }), /* @__PURE__ */ C("div", {
217
217
  className: K("flex flex-1 justify-between leading-none", g ? "items-end" : "items-center"),
218
- children: [/* @__PURE__ */ w("div", {
218
+ children: [/* @__PURE__ */ C("div", {
219
219
  className: "grid gap-1.5",
220
- children: [g ? h : null, /* @__PURE__ */ C("span", {
220
+ children: [g ? h : null, /* @__PURE__ */ S("span", {
221
221
  className: "text-muted-foreground",
222
222
  children: n?.label || e.name
223
223
  })]
224
- }), e.value && /* @__PURE__ */ C("span", {
224
+ }), e.value && /* @__PURE__ */ S("span", {
225
225
  className: "text-foreground font-mono font-medium tabular-nums",
226
226
  children: e.value.toLocaleString()
227
227
  })]
@@ -232,14 +232,14 @@ function W({ active: e, payload: t, className: n, indicator: r = "dot", hideLabe
232
232
  });
233
233
  }
234
234
  function G({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
235
- let { config: a } = Se();
236
- return n?.length ? /* @__PURE__ */ C("div", {
235
+ let { config: a } = we();
236
+ return n?.length ? /* @__PURE__ */ S("div", {
237
237
  className: K("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
238
238
  children: n.filter((e) => e.type !== "none").map((e) => {
239
- let n = Ce(a, e, `${i || e.dataKey || "value"}`);
240
- return /* @__PURE__ */ w("div", {
239
+ let n = Te(a, e, `${i || e.dataKey || "value"}`);
240
+ return /* @__PURE__ */ C("div", {
241
241
  className: K("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
242
- children: [n?.icon && !t ? /* @__PURE__ */ C(n.icon, {}) : /* @__PURE__ */ C("div", {
242
+ children: [n?.icon && !t ? /* @__PURE__ */ S(n.icon, {}) : /* @__PURE__ */ S("div", {
243
243
  className: "h-2 w-2 shrink-0 rounded-[2px]",
244
244
  style: { backgroundColor: e.color }
245
245
  }), n?.label]
@@ -247,18 +247,18 @@ function G({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bot
247
247
  })
248
248
  }) : null;
249
249
  }
250
- function Ce(e, t, n) {
250
+ function Te(e, t, n) {
251
251
  if (typeof t != "object" || !t) return;
252
252
  let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
253
253
  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];
254
254
  }
255
- var K, we, Te, Ee, q, J, De = H((() => {
256
- K = (...e) => e.filter(Boolean).join(" "), we = {
255
+ var K, Ee, De, Oe, q, J, ke = ye((() => {
256
+ K = (...e) => e.filter(Boolean).join(" "), Ee = {
257
257
  light: "",
258
258
  dark: ".dark"
259
- }, Te = o.createContext(null), Ee = ({ id: e, config: t }) => {
259
+ }, De = c.createContext(null), Oe = ({ id: e, config: t }) => {
260
260
  let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
261
- return n.length ? /* @__PURE__ */ C("style", { dangerouslySetInnerHTML: { __html: Object.entries(we).map(([t, r]) => `
261
+ return n.length ? /* @__PURE__ */ S("style", { dangerouslySetInnerHTML: { __html: Object.entries(Ee).map(([t, r]) => `
262
262
  ${r} [data-chart=${e}] {
263
263
  ${n.map(([e, n]) => {
264
264
  let r = n.theme?.[t] || n.color;
@@ -266,52 +266,52 @@ ${n.map(([e, n]) => {
266
266
  }).join("\n")}
267
267
  }
268
268
  `).join("\n") } }) : null;
269
- }, q = ue, J = M;
270
- })), Oe = /* @__PURE__ */ ve({ default: () => ke });
271
- function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", onChartClick: s }) {
272
- let c = e === "column" ? "bar" : e, l = Array.isArray(t) ? t : [], [u, d] = o.useState(!1), f = o.useCallback((e) => {
273
- if (!s || !e) return;
269
+ }, q = B, J = j;
270
+ })), Ae = /* @__PURE__ */ be({ default: () => je });
271
+ function je({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r = "name", series: i = [], className: a = "", onChartClick: o }) {
272
+ let s = e === "column" ? "bar" : e, l = Array.isArray(t) ? t : [], [u, d] = c.useState(!1), f = c.useCallback((e) => {
273
+ if (!o || !e) return;
274
274
  let t = Array.isArray(e.activePayload) ? e.activePayload[0] : void 0;
275
- s({
275
+ o({
276
276
  category: e.activeLabel == null ? void 0 : String(e.activeLabel),
277
277
  series: t?.dataKey ? String(t.dataKey) : void 0,
278
278
  value: typeof t?.value == "number" ? t.value : void 0
279
279
  });
280
- }, [s]), p = o.useCallback((e) => {
281
- if (!s || !e) return;
280
+ }, [o]), p = c.useCallback((e) => {
281
+ if (!o || !e) return;
282
282
  let t = e.payload?.[r], n = i[0]?.dataKey || "value";
283
- s({
283
+ o({
284
284
  category: t == null ? void 0 : String(t),
285
285
  series: n,
286
286
  value: typeof e.payload?.[n] == "number" ? e.payload[n] : void 0
287
287
  });
288
288
  }, [
289
- s,
289
+ o,
290
290
  r,
291
291
  i
292
- ]), m = s ? {
292
+ ]), m = o ? {
293
293
  onClick: f,
294
294
  style: { cursor: "pointer" }
295
- } : {}, h = s ? {
295
+ } : {}, h = o ? {
296
296
  onClick: p,
297
297
  style: { cursor: "pointer" }
298
298
  } : {};
299
- o.useEffect(() => {
299
+ c.useEffect(() => {
300
300
  let e = () => d(window.innerWidth < 640);
301
301
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
302
302
  }, []);
303
303
  let g = {
304
- bar: D,
305
- "horizontal-bar": D,
306
- line: P,
307
- area: re,
308
- pie: I,
309
- donut: I,
310
- radar: oe,
311
- scatter: le,
312
- funnel: A,
313
- combo: D
314
- }[c] || D, _ = o.useCallback((e) => {
304
+ bar: E,
305
+ "horizontal-bar": E,
306
+ line: ce,
307
+ area: oe,
308
+ pie: N,
309
+ donut: N,
310
+ radar: I,
311
+ scatter: z,
312
+ funnel: k,
313
+ combo: E
314
+ }[s] || E, _ = c.useCallback((e) => {
315
315
  if (e == null || e === "") return "";
316
316
  let t = typeof e == "string" ? e : String(e);
317
317
  if (/^\d{4}-\d{2}-\d{2}/.test(t)) {
@@ -336,13 +336,13 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
336
336
  l,
337
337
  r,
338
338
  u
339
- ]), ee = o.useMemo(() => l.some((e) => String(e[r] || "").length > 5), [l, r]), v = () => [
339
+ ]), ee = c.useMemo(() => l.some((e) => String(e[r] || "").length > 5), [l, r]), v = () => [
340
340
  "hsl(var(--chart-1))",
341
341
  "hsl(var(--chart-2))",
342
342
  "hsl(var(--chart-3))",
343
343
  "hsl(var(--chart-4))",
344
344
  "hsl(var(--chart-5))"
345
- ], y = o.useCallback((e) => {
345
+ ], y = c.useCallback((e) => {
346
346
  if (e == null || e === "") return "";
347
347
  let t = typeof e == "number" ? e : Number(e);
348
348
  if (!Number.isFinite(t)) return String(e);
@@ -354,7 +354,7 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
354
354
  } catch {
355
355
  return String(t);
356
356
  }
357
- }, []), te = o.useMemo(() => ({
357
+ }, []), te = c.useMemo(() => ({
358
358
  tickLine: !1,
359
359
  tickMargin: 10,
360
360
  axisLine: !1,
@@ -371,8 +371,8 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
371
371
  ee,
372
372
  _
373
373
  ]);
374
- if (c === "pie" || c === "donut") {
375
- let e = c === "donut" ? 60 : 0, t = v(), o = { ...n };
374
+ if (s === "pie" || s === "donut") {
375
+ let e = s === "donut" ? 60 : 0, t = v(), o = { ...n };
376
376
  return l.forEach((e, n) => {
377
377
  let i = e?.[r];
378
378
  if (i == null || i === "") return;
@@ -381,15 +381,15 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
381
381
  label: a,
382
382
  color: t[n % t.length]
383
383
  });
384
- }), /* @__PURE__ */ C(U, {
384
+ }), /* @__PURE__ */ S(U, {
385
385
  config: o,
386
386
  className: a,
387
- children: /* @__PURE__ */ w(I, { children: [
388
- /* @__PURE__ */ C(q, {
387
+ children: /* @__PURE__ */ C(N, { children: [
388
+ /* @__PURE__ */ S(q, {
389
389
  cursor: !1,
390
- content: /* @__PURE__ */ C(W, { hideLabel: !0 })
390
+ content: /* @__PURE__ */ S(W, { hideLabel: !0 })
391
391
  }),
392
- /* @__PURE__ */ C(F, {
392
+ /* @__PURE__ */ S(le, {
393
393
  data: l,
394
394
  dataKey: i[0]?.dataKey || "value",
395
395
  nameKey: r || "name",
@@ -400,16 +400,16 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
400
400
  ...h,
401
401
  children: l.map((e, n) => {
402
402
  let i = o[String(e[r])]?.color;
403
- return i ||= t[n % t.length], /* @__PURE__ */ C(k, { fill: X(i) }, `cell-${n}`);
403
+ return i ||= t[n % t.length], /* @__PURE__ */ S(O, { fill: X(i) }, `cell-${n}`);
404
404
  })
405
405
  }),
406
- /* @__PURE__ */ C(J, {
406
+ /* @__PURE__ */ S(J, {
407
407
  verticalAlign: "bottom",
408
408
  wrapperStyle: {
409
409
  fontSize: u ? "11px" : "12px",
410
410
  paddingTop: "8px"
411
411
  },
412
- content: /* @__PURE__ */ C(G, {
412
+ content: /* @__PURE__ */ S(G, {
413
413
  nameKey: r,
414
414
  className: "flex-wrap"
415
415
  })
@@ -417,49 +417,49 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
417
417
  ] })
418
418
  });
419
419
  }
420
- if (c === "funnel") {
421
- let e = i[0]?.dataKey || "value", t = v(), o = s ? (t) => {
422
- t && s({
420
+ if (s === "funnel") {
421
+ let e = i[0]?.dataKey || "value", t = v(), s = o ? (t) => {
422
+ t && o({
423
423
  category: t?.payload?.[r] ?? t?.[r],
424
424
  value: t?.payload?.[e] ?? t?.[e]
425
425
  });
426
- } : void 0, c = o ? {
427
- onClick: o,
426
+ } : void 0, c = s ? {
427
+ onClick: s,
428
428
  style: { cursor: "pointer" }
429
429
  } : {}, u = [...l].sort((t, n) => {
430
430
  let r = Number(t?.[e] ?? 0);
431
431
  return Number(n?.[e] ?? 0) - r;
432
432
  });
433
- return /* @__PURE__ */ C(U, {
433
+ return /* @__PURE__ */ S(U, {
434
434
  config: n,
435
435
  className: a,
436
- children: /* @__PURE__ */ w(A, { children: [/* @__PURE__ */ C(q, { content: /* @__PURE__ */ C(W, {}) }), /* @__PURE__ */ w(ie, {
436
+ children: /* @__PURE__ */ C(k, { children: [/* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }), /* @__PURE__ */ C(se, {
437
437
  dataKey: e,
438
438
  data: u,
439
439
  nameKey: r,
440
440
  isAnimationActive: !0,
441
441
  ...c,
442
- children: [/* @__PURE__ */ C(j, {
442
+ children: [/* @__PURE__ */ S(A, {
443
443
  position: "right",
444
444
  fill: "hsl(var(--foreground))",
445
445
  stroke: "none",
446
446
  dataKey: r
447
- }), u.map((e, n) => /* @__PURE__ */ C(k, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
447
+ }), u.map((e, n) => /* @__PURE__ */ S(O, { fill: X(t[n % t.length]) }, `funnel-cell-${n}`))]
448
448
  })] })
449
449
  });
450
450
  }
451
- if (c === "radar") return /* @__PURE__ */ C(U, {
451
+ if (s === "radar") return /* @__PURE__ */ S(U, {
452
452
  config: n,
453
453
  className: a,
454
- children: /* @__PURE__ */ w(oe, {
454
+ children: /* @__PURE__ */ C(I, {
455
455
  data: l,
456
456
  children: [
457
- /* @__PURE__ */ C(R, {}),
458
- /* @__PURE__ */ C(L, { dataKey: r }),
459
- /* @__PURE__ */ C(z, {}),
460
- /* @__PURE__ */ C(q, { content: /* @__PURE__ */ C(W, {}) }),
461
- /* @__PURE__ */ C(J, {
462
- content: /* @__PURE__ */ C(G, {}),
457
+ /* @__PURE__ */ S(de, {}),
458
+ /* @__PURE__ */ S(ue, { dataKey: r }),
459
+ /* @__PURE__ */ S(P, {}),
460
+ /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
461
+ /* @__PURE__ */ S(J, {
462
+ content: /* @__PURE__ */ S(G, {}),
463
463
  ...u && {
464
464
  verticalAlign: "bottom",
465
465
  wrapperStyle: {
@@ -470,7 +470,7 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
470
470
  }),
471
471
  i.map((e) => {
472
472
  let t = X(n[e.dataKey]?.color || Y);
473
- return /* @__PURE__ */ C(ae, {
473
+ return /* @__PURE__ */ S(F, {
474
474
  dataKey: e.dataKey,
475
475
  stroke: t,
476
476
  fill: t,
@@ -480,12 +480,12 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
480
480
  ]
481
481
  })
482
482
  });
483
- if (c === "scatter") return /* @__PURE__ */ C(U, {
483
+ if (s === "scatter") return /* @__PURE__ */ S(U, {
484
484
  config: n,
485
485
  className: a,
486
- children: /* @__PURE__ */ w(le, { children: [
487
- /* @__PURE__ */ C(O, { vertical: !1 }),
488
- /* @__PURE__ */ C(B, {
486
+ children: /* @__PURE__ */ C(z, { children: [
487
+ /* @__PURE__ */ S(D, { vertical: !1 }),
488
+ /* @__PURE__ */ S(V, {
489
489
  type: "number",
490
490
  dataKey: r,
491
491
  name: String(n[r]?.label || r),
@@ -493,7 +493,7 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
493
493
  axisLine: !1,
494
494
  minTickGap: u ? 32 : 48
495
495
  }),
496
- /* @__PURE__ */ C(V, {
496
+ /* @__PURE__ */ S(H, {
497
497
  type: "number",
498
498
  dataKey: i[0]?.dataKey || "value",
499
499
  name: String(n[i[0]?.dataKey]?.label || i[0]?.dataKey),
@@ -502,13 +502,13 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
502
502
  tickFormatter: y,
503
503
  width: 48
504
504
  }),
505
- /* @__PURE__ */ C(de, {
505
+ /* @__PURE__ */ S(fe, {
506
506
  type: "number",
507
507
  range: [60, 400]
508
508
  }),
509
- /* @__PURE__ */ C(q, { content: /* @__PURE__ */ C(W, {}) }),
510
- /* @__PURE__ */ C(J, {
511
- content: /* @__PURE__ */ C(G, {}),
509
+ /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
510
+ /* @__PURE__ */ S(J, {
511
+ content: /* @__PURE__ */ S(G, {}),
512
512
  ...u && {
513
513
  verticalAlign: "bottom",
514
514
  wrapperStyle: {
@@ -518,34 +518,35 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
518
518
  }
519
519
  }),
520
520
  i.map((e, t) => {
521
- let r = v(), i = X(n[e.dataKey]?.color || r[t % r.length]);
522
- return /* @__PURE__ */ C(ce, {
521
+ let r = v(), i = X(n[e.dataKey]?.color || r[t % r.length]), a = Z(e, "scatter");
522
+ return /* @__PURE__ */ S(R, {
523
523
  name: n[e.dataKey]?.label || e.dataKey,
524
524
  data: l,
525
- fill: i
525
+ fill: i,
526
+ fillOpacity: a?.fillOpacity
526
527
  }, e.dataKey);
527
528
  })
528
529
  ] })
529
530
  });
530
- if (c === "combo") return /* @__PURE__ */ C(U, {
531
+ if (s === "combo") return /* @__PURE__ */ S(U, {
531
532
  config: n,
532
533
  className: a,
533
- children: /* @__PURE__ */ w(D, {
534
+ children: /* @__PURE__ */ C(E, {
534
535
  data: l,
535
536
  children: [
536
- /* @__PURE__ */ C(O, { vertical: !1 }),
537
- /* @__PURE__ */ C(B, {
537
+ /* @__PURE__ */ S(D, { vertical: !1 }),
538
+ /* @__PURE__ */ S(V, {
538
539
  dataKey: r,
539
540
  ...te
540
541
  }),
541
- /* @__PURE__ */ C(V, {
542
+ /* @__PURE__ */ S(H, {
542
543
  yAxisId: "left",
543
544
  tickLine: !1,
544
545
  axisLine: !1,
545
546
  tickFormatter: y,
546
547
  width: 48
547
548
  }),
548
- /* @__PURE__ */ C(V, {
549
+ /* @__PURE__ */ S(H, {
549
550
  yAxisId: "right",
550
551
  orientation: "right",
551
552
  tickLine: !1,
@@ -553,9 +554,9 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
553
554
  tickFormatter: y,
554
555
  width: 48
555
556
  }),
556
- /* @__PURE__ */ C(q, { content: /* @__PURE__ */ C(W, {}) }),
557
- /* @__PURE__ */ C(J, {
558
- content: /* @__PURE__ */ C(G, {}),
557
+ /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
558
+ /* @__PURE__ */ S(J, {
559
+ content: /* @__PURE__ */ S(G, {}),
559
560
  ...u && {
560
561
  verticalAlign: "bottom",
561
562
  wrapperStyle: {
@@ -565,65 +566,70 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
565
566
  }
566
567
  }),
567
568
  i.map((e, t) => {
568
- let r = X(n[e.dataKey]?.color || Y), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right";
569
- return i === "line" ? /* @__PURE__ */ C(N, {
569
+ let r = X(n[e.dataKey]?.color || Y), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right", o = Z(e, i);
570
+ return i === "line" ? /* @__PURE__ */ S(M, {
570
571
  yAxisId: a,
571
572
  type: "monotone",
572
573
  dataKey: e.dataKey,
573
574
  stroke: r,
574
575
  strokeWidth: 2,
575
- dot: !1
576
- }, e.dataKey) : i === "area" ? /* @__PURE__ */ C(T, {
576
+ dot: !1,
577
+ strokeOpacity: o?.strokeOpacity,
578
+ strokeDasharray: o?.strokeDasharray
579
+ }, e.dataKey) : i === "area" ? /* @__PURE__ */ S(w, {
577
580
  yAxisId: a,
578
581
  type: "monotone",
579
582
  dataKey: e.dataKey,
580
583
  fill: r,
581
584
  stroke: r,
582
- fillOpacity: .4
583
- }, e.dataKey) : /* @__PURE__ */ C(E, {
585
+ fillOpacity: o?.fillOpacity ?? .4,
586
+ strokeOpacity: o?.strokeOpacity,
587
+ strokeDasharray: o?.strokeDasharray
588
+ }, e.dataKey) : /* @__PURE__ */ S(T, {
584
589
  yAxisId: a,
585
590
  dataKey: e.dataKey,
586
591
  fill: r,
587
- radius: 4
592
+ radius: 4,
593
+ fillOpacity: o?.fillOpacity
588
594
  }, e.dataKey);
589
595
  })
590
596
  ]
591
597
  })
592
598
  });
593
- let b = c === "horizontal-bar";
594
- return /* @__PURE__ */ C(U, {
599
+ let ne = s === "horizontal-bar";
600
+ return /* @__PURE__ */ S(U, {
595
601
  config: n,
596
602
  className: a,
597
- children: /* @__PURE__ */ w(g, {
603
+ children: /* @__PURE__ */ C(g, {
598
604
  data: l,
599
- layout: b ? "vertical" : "horizontal",
605
+ layout: ne ? "vertical" : "horizontal",
600
606
  ...m,
601
607
  children: [
602
- /* @__PURE__ */ C(O, { vertical: !1 }),
603
- b ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(B, {
608
+ /* @__PURE__ */ S(D, { vertical: !1 }),
609
+ ne ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(V, {
604
610
  type: "number",
605
611
  tickLine: !1,
606
612
  axisLine: !1,
607
613
  tickFormatter: y
608
- }), /* @__PURE__ */ C(V, {
614
+ }), /* @__PURE__ */ S(H, {
609
615
  type: "category",
610
616
  dataKey: r,
611
617
  tickLine: !1,
612
618
  axisLine: !1,
613
619
  width: Math.min(140, Math.max(60, Math.max(...l.map((e) => String(e[r] ?? "").length)) * 7)),
614
620
  tickFormatter: _
615
- })] }) : /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(B, {
621
+ })] }) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(V, {
616
622
  dataKey: r,
617
623
  ...te
618
- }), /* @__PURE__ */ C(V, {
624
+ }), /* @__PURE__ */ S(H, {
619
625
  tickLine: !1,
620
626
  axisLine: !1,
621
627
  tickFormatter: y,
622
628
  width: 48
623
629
  })] }),
624
- /* @__PURE__ */ C(q, { content: /* @__PURE__ */ C(W, {}) }),
625
- /* @__PURE__ */ C(J, {
626
- content: /* @__PURE__ */ C(G, {}),
630
+ /* @__PURE__ */ S(q, { content: /* @__PURE__ */ S(W, {}) }),
631
+ /* @__PURE__ */ S(J, {
632
+ content: /* @__PURE__ */ S(G, {}),
627
633
  ...u && {
628
634
  verticalAlign: "bottom",
629
635
  wrapperStyle: {
@@ -633,36 +639,49 @@ function ke({ chartType: e = "bar", data: t = [], config: n = {}, xAxisKey: r =
633
639
  }
634
640
  }),
635
641
  i.map((e, t) => {
636
- let r = v(), a = X(n[e.dataKey]?.color || r[t % r.length] || Y);
637
- if (c === "bar" || c === "horizontal-bar") {
638
- let t = i.length === 1 && l.length > 1;
639
- return /* @__PURE__ */ C(E, {
642
+ let r = v(), a = e.variant === "comparison", o = a ? i.slice(0, t).find((e) => e.variant !== "comparison") || i[0] : e, c = a ? i.indexOf(o) : t, u = X(n[o.dataKey]?.color || r[c % r.length] || Y);
643
+ if (s === "bar" || s === "horizontal-bar") {
644
+ let t = i.filter((e) => e.variant !== "comparison").length === 1 && !a && i.length === 1 && l.length > 1, n = Z(e, "bar");
645
+ return /* @__PURE__ */ S(T, {
640
646
  dataKey: e.dataKey,
641
- fill: a,
647
+ fill: u,
642
648
  radius: 4,
643
- children: t && l.map((e, t) => /* @__PURE__ */ C(k, { fill: X(r[t % r.length]) }, `cell-${t}`))
649
+ fillOpacity: n?.fillOpacity,
650
+ children: t && l.map((e, t) => /* @__PURE__ */ S(O, { fill: X(r[t % r.length]) }, `cell-${t}`))
644
651
  }, e.dataKey);
645
652
  }
646
- return c === "line" ? /* @__PURE__ */ C(N, {
647
- type: "monotone",
648
- dataKey: e.dataKey,
649
- stroke: a,
650
- strokeWidth: 2,
651
- dot: !1
652
- }, e.dataKey) : c === "area" ? /* @__PURE__ */ C(T, {
653
- type: "monotone",
654
- dataKey: e.dataKey,
655
- fill: a,
656
- stroke: a,
657
- fillOpacity: .4
658
- }, e.dataKey) : null;
653
+ if (s === "line") {
654
+ let t = Z(e, "line");
655
+ return /* @__PURE__ */ S(M, {
656
+ type: "monotone",
657
+ dataKey: e.dataKey,
658
+ stroke: u,
659
+ strokeWidth: 2,
660
+ dot: !1,
661
+ strokeOpacity: t?.strokeOpacity,
662
+ strokeDasharray: t?.strokeDasharray
663
+ }, e.dataKey);
664
+ }
665
+ if (s === "area") {
666
+ let t = Z(e, "area");
667
+ return /* @__PURE__ */ S(w, {
668
+ type: "monotone",
669
+ dataKey: e.dataKey,
670
+ fill: u,
671
+ stroke: u,
672
+ fillOpacity: t?.fillOpacity ?? .4,
673
+ strokeOpacity: t?.strokeOpacity,
674
+ strokeDasharray: t?.strokeDasharray
675
+ }, e.dataKey);
676
+ }
677
+ return null;
659
678
  })
660
679
  ]
661
680
  })
662
681
  });
663
682
  }
664
- var Y, Ae, X, je = H((() => {
665
- De(), Y = "hsl(var(--primary))", Ae = {
683
+ var Y, Me, X, Z, Ne = ye((() => {
684
+ ke(), Y = "hsl(var(--primary))", Me = {
666
685
  slate: "#64748b",
667
686
  gray: "#6b7280",
668
687
  zinc: "#71717a",
@@ -685,10 +704,14 @@ var Y, Ae, X, je = H((() => {
685
704
  fuchsia: "#d946ef",
686
705
  pink: "#ec4899",
687
706
  rose: "#f43f5e"
688
- }, X = (e) => Ae[e] || e;
689
- })), Me = s.lazy(() => Promise.resolve().then(() => (xe(), ye))), Ne = s.lazy(() => Promise.resolve().then(() => (je(), Oe))), Pe = ({ schema: e }) => /* @__PURE__ */ C(c, {
690
- fallback: /* @__PURE__ */ C(x, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
691
- children: /* @__PURE__ */ C(Me, {
707
+ }, X = (e) => Me[e] || e, Z = (e, t) => e?.variant === "comparison" ? {
708
+ strokeOpacity: typeof e.opacity == "number" ? e.opacity : t === "line" || t === "scatter" ? .5 : .6,
709
+ fillOpacity: typeof e.opacity == "number" ? e.opacity : t === "bar" ? .4 : t === "area" ? .2 : .5,
710
+ strokeDasharray: e.dashArray ?? (t === "line" || t === "area" ? "4 4" : void 0)
711
+ } : null;
712
+ })), Pe = l.lazy(() => Promise.resolve().then(() => (Ce(), xe))), Fe = l.lazy(() => Promise.resolve().then(() => (Ne(), Ae))), Ie = ({ schema: e }) => /* @__PURE__ */ S(u, {
713
+ fallback: /* @__PURE__ */ S(b, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
714
+ children: /* @__PURE__ */ S(Pe, {
692
715
  data: e.data,
693
716
  dataKey: e.dataKey,
694
717
  xAxisKey: e.xAxisKey,
@@ -696,8 +719,8 @@ var Y, Ae, X, je = H((() => {
696
719
  className: e.className,
697
720
  color: e.color
698
721
  })
699
- }), Z = ({ schema: e, onChartClick: t }) => {
700
- let n = s.useMemo(() => {
722
+ }), Q = ({ schema: e, onChartClick: t }) => {
723
+ let n = l.useMemo(() => {
701
724
  let t = e.series, n = e.xAxisKey, r = e.config;
702
725
  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) {
703
726
  let n = e.colors || [
@@ -721,9 +744,9 @@ var Y, Ae, X, je = H((() => {
721
744
  className: e.className
722
745
  };
723
746
  }, [e]);
724
- return /* @__PURE__ */ C(c, {
725
- fallback: /* @__PURE__ */ C(x, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
726
- children: /* @__PURE__ */ C(Ne, {
747
+ return /* @__PURE__ */ S(u, {
748
+ fallback: /* @__PURE__ */ S(b, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
749
+ children: /* @__PURE__ */ S(Fe, {
727
750
  chartType: n.chartType,
728
751
  data: n.data,
729
752
  config: n.config,
@@ -736,10 +759,10 @@ var Y, Ae, X, je = H((() => {
736
759
  };
737
760
  //#endregion
738
761
  //#region src/ObjectChart.tsx
739
- function Q(e) {
762
+ function $(e) {
740
763
  return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
741
764
  }
742
- function Fe(e, t) {
765
+ function Le(e, t) {
743
766
  let { field: n, function: r, groupBy: i } = t, a = {};
744
767
  for (let t of e) {
745
768
  let e = String(t[i] ?? "Unknown");
@@ -770,13 +793,13 @@ function Fe(e, t) {
770
793
  };
771
794
  });
772
795
  }
773
- async function Ie(e, t, r, i, a) {
796
+ async function Re(e, t, n, i, a) {
774
797
  if (!e.length || !t) return e;
775
- let o = a || ((e, t) => t), s = `__raw_${t}`, c = r?.fields?.[t];
798
+ let o = a || ((e, t) => t), s = `__raw_${t}`, c = n?.fields?.[t];
776
799
  if (!c) {
777
800
  let n = /^\d{4}-\d{2}-\d{2}/;
778
801
  return e.map((e) => {
779
- let r = e[t], i = String(r ?? ""), a = n.test(i) ? i : Q(i);
802
+ let r = e[t], i = String(r ?? ""), a = n.test(i) ? i : $(i);
780
803
  return {
781
804
  ...e,
782
805
  [t]: o(i, a),
@@ -788,7 +811,7 @@ async function Ie(e, t, r, i, a) {
788
811
  if (l === "select" || l === "picklist" || l === "dropdown") {
789
812
  let n = c.options || [];
790
813
  if (n.length === 0) return e.map((e) => {
791
- let n = e[t], r = String(n ?? ""), i = Q(r);
814
+ let n = e[t], r = String(n ?? ""), i = $(r);
792
815
  return {
793
816
  ...e,
794
817
  [t]: o(r, i),
@@ -798,7 +821,7 @@ async function Ie(e, t, r, i, a) {
798
821
  let r = {};
799
822
  for (let e of n) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
800
823
  return e.map((e) => {
801
- let n = e[t], i = String(n ?? ""), a = r[i] || Q(i);
824
+ let n = e[t], i = String(n ?? ""), a = r[i] || $(i);
802
825
  return {
803
826
  ...e,
804
827
  [t]: o(i, a),
@@ -807,8 +830,8 @@ async function Ie(e, t, r, i, a) {
807
830
  });
808
831
  }
809
832
  if (l === "lookup" || l === "master_detail") {
810
- let r = c.reference_to || c.reference;
811
- if (!r || !i || typeof i.find != "function") return e.map((e) => ({
833
+ let n = c.reference_to || c.reference;
834
+ if (!n || !i || typeof i.find != "function") return e.map((e) => ({
812
835
  ...e,
813
836
  [s]: e[t]
814
837
  }));
@@ -819,7 +842,7 @@ async function Ie(e, t, r, i, a) {
819
842
  }));
820
843
  let o = c.id_field || "id";
821
844
  try {
822
- let l = n(await i.find(r, {
845
+ let l = r(await i.find(n, {
823
846
  $filter: { [o]: { $in: a } },
824
847
  $top: a.length
825
848
  })), u = c.reference_field || c.display_field || "name", d = {};
@@ -851,173 +874,260 @@ async function Ie(e, t, r, i, a) {
851
874
  let n = e[t], r = String(n ?? "");
852
875
  return {
853
876
  ...e,
854
- [t]: u.test(r) ? r : Q(r),
877
+ [t]: u.test(r) ? r : $(r),
855
878
  [s]: n
856
879
  };
857
880
  });
858
881
  }
859
- var $ = (e) => {
860
- let { schema: o } = e, s = u(pe), c = e.dataSource || s?.dataSource, x = me(o.bind), { fieldOptionLabel: S } = ge(), T = p(S);
861
- d(() => {
862
- T.current = S;
863
- }, [S]);
864
- let [re, E] = m([]), [D, O] = m(() => !(Array.isArray(o.data) && o.data.length > 0) && !!o.objectName), [k, ie] = m(null), [A, j] = m(null), M = f(() => o.aggregate ? JSON.stringify(o.aggregate) : "", [o.aggregate]), N = f(() => o.filter ? JSON.stringify(o.filter) : "", [o.filter]), P = l(async (e, t) => {
865
- if (!e || !o.objectName) {
866
- t.current && O(!1);
882
+ var ze = (e) => {
883
+ let { schema: c } = e, l = f(me), u = e.dataSource || l?.dataSource, b = he(c.bind), { fieldOptionLabel: x } = _e(), w = h(x);
884
+ p(() => {
885
+ w.current = x;
886
+ }, [x]);
887
+ let [oe, T] = g([]), [E, D] = g(() => !(Array.isArray(c.data) && c.data.length > 0) && !!c.objectName), [O, se] = g(null), [k, A] = g(null), j = m(() => c.aggregate ? JSON.stringify(c.aggregate) : "", [c.aggregate]), M = m(() => c.filter ? JSON.stringify(c.filter) : "", [c.filter]), ce = m(() => c.compareTo ? JSON.stringify(c.compareTo) : "", [c.compareTo]), le = (e) => e !== "pie" && e !== "donut" && e !== "funnel", N = d(async (e, t) => {
888
+ if (c.aggregate && typeof e.aggregate == "function") {
889
+ let n = c.aggregate.groupBy;
890
+ if (n && typeof n == "object" && !Array.isArray(n)) {
891
+ let r = c.aggregate.field, i = c.aggregate.function, a = {
892
+ function: i,
893
+ alias: r || i
894
+ };
895
+ i !== "count" && r && (a.field = r);
896
+ let o = await e.aggregate(c.objectName, {
897
+ groupBy: [n],
898
+ aggregations: [a],
899
+ where: t
900
+ });
901
+ return Array.isArray(o) ? o : [];
902
+ }
903
+ let r = await e.aggregate(c.objectName, {
904
+ field: c.aggregate.field,
905
+ function: c.aggregate.function,
906
+ groupBy: n,
907
+ filter: t
908
+ });
909
+ return Array.isArray(r) ? r : [];
910
+ }
911
+ if (typeof e.find == "function") {
912
+ let n = r(await e.find(c.objectName, { $filter: t }));
913
+ return c.aggregate && n.length > 0 && (n = Le(n, c.aggregate)), n;
914
+ }
915
+ return [];
916
+ }, [c.objectName, j]), ue = d(async (e, t) => {
917
+ if (!e || !c.objectName) {
918
+ t.current && D(!1);
867
919
  return;
868
920
  }
869
- t.current && (O(!0), ie(null));
921
+ t.current && (D(!0), se(null));
870
922
  try {
871
- let r, a = i(o.filter);
872
- if (o.aggregate && typeof e.aggregate == "function") {
873
- let t = await e.aggregate(o.objectName, {
874
- field: o.aggregate.field,
875
- function: o.aggregate.function,
876
- groupBy: o.aggregate.groupBy,
877
- filter: a
878
- });
879
- r = Array.isArray(t) ? t : [];
880
- } else if (typeof e.find == "function") r = n(await e.find(o.objectName, { $filter: a })), o.aggregate && r.length > 0 && (r = Fe(r, o.aggregate));
881
- else return;
882
- let s = o.aggregate?.groupBy || o.xAxisKey;
883
- if (s && typeof e.getObjectSchema == "function") try {
884
- let t = await e.getObjectSchema(o.objectName);
885
- r = await Ie(r, s, t, e, (e, t) => T.current(o.objectName, s, e, t));
923
+ let n = a(c.filter), r = c.compareTo, i = !!r && le(c.chartType), o = i ? s(c.filter, r) : null, [l, u] = await Promise.all([N(e, n), o ? N(e, o) : Promise.resolve([])]), d = l, f = c.aggregate?.groupBy, p = f && typeof f == "object" && !Array.isArray(f) ? f.alias || f.field : f || c.xAxisKey;
924
+ if (i && u.length > 0 && c.aggregate) {
925
+ let e = c.aggregate.field, t = c.aggregate.function, n = (n) => {
926
+ if (n == null) return null;
927
+ let r = `${e}_${t}`;
928
+ 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;
929
+ }, r = `${e}__comparison`, i = p;
930
+ if (i && d.some((e) => e[i] != null) && u.some((e) => e[i] != null)) {
931
+ let e = /* @__PURE__ */ new Map();
932
+ for (let t of u) {
933
+ let r = String(t[i] ?? "");
934
+ e.set(r, n(t));
935
+ }
936
+ d = d.map((t) => {
937
+ let n = String(t[i] ?? ""), a = e.get(n);
938
+ return a == null ? t : {
939
+ ...t,
940
+ [r]: a
941
+ };
942
+ });
943
+ let t = new Set(d.map((e) => String(e[i] ?? "")));
944
+ for (let e of u) {
945
+ let a = String(e[i] ?? "");
946
+ t.has(a) || d.push({
947
+ [i]: a,
948
+ [r]: n(e)
949
+ });
950
+ }
951
+ } else {
952
+ let e = Math.max(d.length, u.length), t = [];
953
+ for (let i = 0; i < e; i++) {
954
+ let e = d[i] || {}, a = u[i];
955
+ t.push(a ? {
956
+ ...e,
957
+ [r]: n(a)
958
+ } : e);
959
+ }
960
+ d = t;
961
+ }
962
+ }
963
+ if (p && typeof e.getObjectSchema == "function") try {
964
+ let t = await e.getObjectSchema(c.objectName);
965
+ d = await Re(d, p, t, e, (e, t) => w.current(c.objectName, p, e, t));
886
966
  } catch {}
887
- t.current && E(r);
967
+ t.current && T(d);
888
968
  } catch (e) {
889
- console.error("[ObjectChart] Fetch error:", e), t.current && ie(e instanceof Error ? e.message : "Failed to load chart data");
969
+ console.error("[ObjectChart] Fetch error:", e), t.current && se(e instanceof Error ? e.message : "Failed to load chart data");
890
970
  } finally {
891
- t.current && O(!1);
971
+ t.current && D(!1);
892
972
  }
893
973
  }, [
894
- o.objectName,
974
+ c.objectName,
975
+ j,
895
976
  M,
896
- N,
897
- o.xAxisKey
977
+ ce,
978
+ c.xAxisKey,
979
+ c.chartType,
980
+ N
898
981
  ]);
899
- d(() => {
982
+ p(() => {
900
983
  let e = { current: !0 };
901
- return o.objectName && !x && !o.data ? P(c, e) : e.current && O(!1), () => {
984
+ return c.objectName && !b && !c.data ? ue(u, e) : e.current && D(!1), () => {
902
985
  e.current = !1;
903
986
  };
904
987
  }, [
905
- o.objectName,
906
- c,
907
- x,
908
- o.data,
909
- N,
988
+ c.objectName,
989
+ u,
990
+ b,
991
+ c.data,
910
992
  M,
911
- P
993
+ j,
994
+ ce,
995
+ ue
912
996
  ]);
913
- let F = x || o.data || re, I = Array.isArray(F) ? F : [], L = o.drillDown, R = o.aggregate?.groupBy || o.xAxisKey, z = f(() => {
914
- if (!R) return /* @__PURE__ */ new Map();
915
- let e = /* @__PURE__ */ new Map(), t = `__raw_${R}`;
916
- for (let n of I) {
917
- let r = n?.[R];
997
+ let de = b || c.data || oe, P = Array.isArray(de) ? de : [], F = c.drillDown, I = c.aggregate?.groupBy || c.xAxisKey, L = m(() => {
998
+ if (!I) return /* @__PURE__ */ new Map();
999
+ let e = /* @__PURE__ */ new Map(), t = `__raw_${I}`;
1000
+ for (let n of P) {
1001
+ let r = n?.[I];
918
1002
  if (r == null) continue;
919
1003
  let i = t in (n || {}) ? n[t] : r;
920
1004
  e.set(String(r), i);
921
1005
  }
922
1006
  return e;
923
- }, [I, R]), ae = {
924
- ...o,
925
- data: I
1007
+ }, [P, I]), R = c.compareTo, z = !!R && le(c.chartType) && !!c.aggregate && P.some((e) => e[`${c.aggregate.field}__comparison`] != null), B = m(() => {
1008
+ let e = Array.isArray(c.series) ? c.series : null;
1009
+ if (!z) return e;
1010
+ let n = e || [{ dataKey: c.aggregate.field }], r = {
1011
+ vsLastWeek: "Previous week",
1012
+ vsLastMonth: "Previous month",
1013
+ vsLastQuarter: "Previous quarter",
1014
+ vsLastYear: "Previous year",
1015
+ vsYesterday: "Yesterday",
1016
+ vsPreviousPeriod: "Previous period"
1017
+ }[t(R, c.filter)] || "Previous period";
1018
+ return [...n.map((e) => ({
1019
+ ...e,
1020
+ variant: e.variant || "current"
1021
+ })), {
1022
+ dataKey: `${c.aggregate.field}__comparison`,
1023
+ label: r,
1024
+ variant: "comparison"
1025
+ }];
1026
+ }, [
1027
+ z,
1028
+ c.series,
1029
+ c.aggregate,
1030
+ c.filter,
1031
+ R
1032
+ ]), V = {
1033
+ ...c,
1034
+ data: P,
1035
+ ...B ? { series: B } : {}
926
1036
  };
927
- if (D && I.length === 0) return /* @__PURE__ */ C("div", {
928
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (o.className || ""),
1037
+ if (E && P.length === 0) return /* @__PURE__ */ S("div", {
1038
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (c.className || ""),
929
1039
  "data-testid": "chart-loading",
930
1040
  children: "Loading chart data…"
931
1041
  });
932
- if (k) return /* @__PURE__ */ w("div", {
933
- className: "flex flex-col items-center justify-center gap-2 p-4 " + (o.className || ""),
1042
+ if (O) return /* @__PURE__ */ C("div", {
1043
+ className: "flex flex-col items-center justify-center gap-2 p-4 " + (c.className || ""),
934
1044
  "data-testid": "chart-error",
935
1045
  role: "alert",
936
1046
  children: [
937
- /* @__PURE__ */ C(he, { className: "h-6 w-6 text-destructive opacity-60" }),
938
- /* @__PURE__ */ C("p", {
1047
+ /* @__PURE__ */ S(ge, { className: "h-6 w-6 text-destructive opacity-60" }),
1048
+ /* @__PURE__ */ S("p", {
939
1049
  className: "text-xs text-destructive font-medium",
940
1050
  children: "Failed to load chart data"
941
1051
  }),
942
- /* @__PURE__ */ C("p", {
1052
+ /* @__PURE__ */ S("p", {
943
1053
  className: "text-xs text-muted-foreground max-w-xs text-center",
944
- children: k
1054
+ children: O
945
1055
  })
946
1056
  ]
947
1057
  });
948
- if (!c && o.objectName && I.length === 0) return /* @__PURE__ */ w("div", {
949
- className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (o.className || ""),
1058
+ if (!u && c.objectName && P.length === 0) return /* @__PURE__ */ C("div", {
1059
+ className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (c.className || ""),
950
1060
  "data-testid": "chart-no-datasource",
951
1061
  children: [
952
1062
  "No data source available for “",
953
- o.objectName,
1063
+ c.objectName,
954
1064
  "”"
955
1065
  ]
956
1066
  });
957
- let oe = r(L) ? (e) => {
958
- let t = e.category, n = t != null && z.has(String(t)) ? z.get(String(t)) : t;
959
- j({
1067
+ let H = i(F) ? (e) => {
1068
+ let t = e.category, n = t != null && L.has(String(t)) ? L.get(String(t)) : t;
1069
+ A({
960
1070
  ...e,
961
1071
  category: n,
962
1072
  categoryLabel: t,
963
1073
  scope: "cell"
964
1074
  });
965
- } : void 0, se = A && o.objectName ? (() => {
966
- let e = t(L, A, { groupByField: R }), n = {
967
- ...o.filter || {},
1075
+ } : void 0, fe = k && c.objectName ? (() => {
1076
+ let e = n(F, k, { groupByField: I }), t = {
1077
+ ...c.filter || {},
968
1078
  ...e
969
- }, r = a(L, A, o.title || "Details"), i = L?.target ?? "drawer", s = /* @__PURE__ */ C("div", {
1079
+ }, r = o(F, k, c.title || "Details"), i = F?.target ?? "drawer", a = /* @__PURE__ */ S("div", {
970
1080
  className: "overflow-auto",
971
1081
  "data-testid": "chart-drill-body",
972
- children: /* @__PURE__ */ C(fe, {
1082
+ children: /* @__PURE__ */ S(pe, {
973
1083
  schema: {
974
1084
  type: "object-data-table",
975
- objectName: o.objectName,
976
- filter: n,
1085
+ objectName: c.objectName,
1086
+ filter: t,
977
1087
  pagination: !0,
978
- pageSize: L?.maxRows,
979
- columns: L?.columns?.map((e) => ({
1088
+ pageSize: F?.maxRows,
1089
+ columns: F?.columns?.map((e) => ({
980
1090
  accessorKey: e,
981
1091
  header: e
982
1092
  }))
983
1093
  },
984
- dataSource: c
1094
+ dataSource: u
985
1095
  })
986
1096
  });
987
- return i === "dialog" ? /* @__PURE__ */ C(h, {
1097
+ return i === "dialog" ? /* @__PURE__ */ S(_, {
988
1098
  open: !0,
989
- onOpenChange: (e) => !e && j(null),
990
- children: /* @__PURE__ */ w(g, {
1099
+ onOpenChange: (e) => !e && A(null),
1100
+ children: /* @__PURE__ */ C(ee, {
991
1101
  className: "max-w-4xl",
992
- children: [/* @__PURE__ */ C(_, { children: /* @__PURE__ */ C(ee, { children: r }) }), s]
1102
+ children: [/* @__PURE__ */ S(v, { children: /* @__PURE__ */ S(y, { children: r }) }), a]
993
1103
  })
994
- }) : /* @__PURE__ */ C(y, {
1104
+ }) : /* @__PURE__ */ S(ne, {
995
1105
  open: !0,
996
- onOpenChange: (e) => !e && j(null),
997
- children: /* @__PURE__ */ w(te, {
1106
+ onOpenChange: (e) => !e && A(null),
1107
+ children: /* @__PURE__ */ C(re, {
998
1108
  side: "right",
999
1109
  className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
1000
- children: [/* @__PURE__ */ C(b, { children: /* @__PURE__ */ C(ne, { children: r }) }), /* @__PURE__ */ C("div", {
1110
+ children: [/* @__PURE__ */ S(ie, { children: /* @__PURE__ */ S(ae, { children: r }) }), /* @__PURE__ */ S("div", {
1001
1111
  className: "flex-1 overflow-hidden mt-2",
1002
- children: s
1112
+ children: a
1003
1113
  })]
1004
1114
  })
1005
1115
  });
1006
1116
  })() : null;
1007
- return /* @__PURE__ */ w("div", {
1117
+ return /* @__PURE__ */ C("div", {
1008
1118
  className: "relative",
1009
1119
  children: [
1010
- /* @__PURE__ */ C(v, { active: D && I.length > 0 }),
1011
- /* @__PURE__ */ C(Z, {
1120
+ /* @__PURE__ */ S(te, { active: E && P.length > 0 }),
1121
+ /* @__PURE__ */ S(Q, {
1012
1122
  ...e,
1013
- schema: ae,
1014
- onChartClick: oe
1123
+ schema: V,
1124
+ onChartClick: H
1015
1125
  }),
1016
- se
1126
+ fe
1017
1127
  ]
1018
1128
  });
1019
1129
  };
1020
- e.register("object-chart", $, {
1130
+ e.register("object-chart", ze, {
1021
1131
  namespace: "plugin-charts",
1022
1132
  label: "Object Chart",
1023
1133
  category: "view",
@@ -1049,11 +1159,11 @@ e.register("object-chart", $, {
1049
1159
  });
1050
1160
  //#endregion
1051
1161
  //#region src/index.tsx
1052
- var Le = {
1053
- "bar-chart": Pe,
1054
- chart: Z
1162
+ var Be = {
1163
+ "bar-chart": Ie,
1164
+ chart: Q
1055
1165
  };
1056
- e.register("bar-chart", Pe, {
1166
+ e.register("bar-chart", Ie, {
1057
1167
  namespace: "plugin-charts",
1058
1168
  label: "Bar Chart",
1059
1169
  category: "plugin",
@@ -1117,7 +1227,7 @@ e.register("bar-chart", Pe, {
1117
1227
  height: 400,
1118
1228
  color: "#8884d8"
1119
1229
  }
1120
- }), e.register("chart", $, {
1230
+ }), e.register("chart", ze, {
1121
1231
  namespace: "view",
1122
1232
  category: "view",
1123
1233
  label: "Chart",
@@ -1144,7 +1254,7 @@ e.register("bar-chart", Pe, {
1144
1254
  label: "Value Field"
1145
1255
  }
1146
1256
  ]
1147
- }), e.register("chart", Z, {
1257
+ }), e.register("chart", Q, {
1148
1258
  namespace: "plugin-charts",
1149
1259
  label: "Chart",
1150
1260
  category: "plugin",
@@ -1256,31 +1366,31 @@ e.register("bar-chart", Pe, {
1256
1366
  xAxisKey: "name",
1257
1367
  series: [{ dataKey: "sales" }, { dataKey: "revenue" }]
1258
1368
  }
1259
- }), e.register("chart:bar", Z, {
1369
+ }), e.register("chart:bar", Q, {
1260
1370
  namespace: "plugin-charts",
1261
1371
  label: "Bar Chart (Alias)",
1262
1372
  category: "plugin",
1263
1373
  defaultProps: { chartType: "bar" }
1264
- }), e.register("pie-chart", Z, {
1374
+ }), e.register("pie-chart", Q, {
1265
1375
  namespace: "plugin-charts",
1266
1376
  label: "Pie Chart",
1267
1377
  category: "plugin",
1268
1378
  defaultProps: { chartType: "pie" }
1269
- }), e.register("donut-chart", Z, {
1379
+ }), e.register("donut-chart", Q, {
1270
1380
  namespace: "plugin-charts",
1271
1381
  label: "Donut Chart",
1272
1382
  category: "plugin",
1273
1383
  defaultProps: { chartType: "donut" }
1274
- }), e.register("radar-chart", Z, {
1384
+ }), e.register("radar-chart", Q, {
1275
1385
  namespace: "plugin-charts",
1276
1386
  label: "Radar Chart",
1277
1387
  category: "plugin",
1278
1388
  defaultProps: { chartType: "radar" }
1279
- }), e.register("scatter-chart", Z, {
1389
+ }), e.register("scatter-chart", Q, {
1280
1390
  namespace: "plugin-charts",
1281
1391
  label: "Scatter Chart",
1282
1392
  category: "plugin",
1283
1393
  defaultProps: { chartType: "scatter" }
1284
1394
  });
1285
1395
  //#endregion
1286
- export { Pe as ChartBarRenderer, Z as ChartRenderer, $ as ObjectChart, Le as chartComponents };
1396
+ export { Ie as ChartBarRenderer, Q as ChartRenderer, ze as ObjectChart, Be as chartComponents };