@object-ui/plugin-charts 4.0.4 → 4.0.5

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,14 +1,560 @@
1
1
  import { ComponentRegistry as e, extractRecords as t } from "@object-ui/core";
2
- import n, { Suspense as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
3
- import { Skeleton as u } from "@object-ui/components";
4
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
5
- import { SchemaRendererContext as p, useDataScope as m } from "@object-ui/react";
6
- import { AlertCircle as h } from "lucide-react";
7
- import { useSafeFieldLabel as g } from "@object-ui/i18n";
8
- //#region src/ChartRenderer.tsx
9
- var _ = n.lazy(() => import("./ChartImpl-ZGY2c86F.js")), v = n.lazy(() => import("./AdvancedChartImpl-DkX8ZQ5Y.js")), y = ({ schema: e }) => /* @__PURE__ */ d(r, {
10
- fallback: /* @__PURE__ */ d(u, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
11
- children: /* @__PURE__ */ d(_, {
2
+ import * as n from "react";
3
+ import r, { Suspense as i, useCallback as a, useContext as o, useEffect as s, useMemo as c, useRef as l, useState as u } from "react";
4
+ import { Skeleton as d } from "@object-ui/components";
5
+ import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
6
+ import { Area as h, AreaChart as g, Bar as _, BarChart as v, CartesianGrid as y, Cell as b, Legend as x, Line as S, LineChart as C, Pie as w, PieChart as T, PolarAngleAxis as E, PolarGrid as D, PolarRadiusAxis as ee, Radar as te, RadarChart as O, ResponsiveContainer as k, Scatter as ne, ScatterChart as A, Tooltip as j, XAxis as M, YAxis as N, ZAxis as re } from "recharts";
7
+ import { SchemaRendererContext as ie, useDataScope as ae } from "@object-ui/react";
8
+ import { AlertCircle as oe } from "lucide-react";
9
+ import { useSafeFieldLabel as se } from "@object-ui/i18n";
10
+ //#region \0rolldown/runtime.js
11
+ var P = Object.defineProperty, F = (e, t) => () => (e && (t = e(e = 0)), t), I = (e, t) => {
12
+ let n = {};
13
+ for (var r in e) P(n, r, {
14
+ get: e[r],
15
+ enumerable: !0
16
+ });
17
+ return t || P(n, Symbol.toStringTag, { value: "Module" }), n;
18
+ }, ce = /* @__PURE__ */ I({ default: () => le });
19
+ function le({ data: e = [], dataKey: t = "value", xAxisKey: n = "name", height: r = 400, className: i = "", color: a = "hsl(var(--primary))" }) {
20
+ return /* @__PURE__ */ p("div", {
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__ */ p(k, {
23
+ width: "100%",
24
+ height: r,
25
+ children: /* @__PURE__ */ m(v, {
26
+ data: e,
27
+ margin: {
28
+ top: 10,
29
+ right: 10,
30
+ left: 10,
31
+ bottom: 5
32
+ },
33
+ children: [
34
+ /* @__PURE__ */ m("defs", { children: [/* @__PURE__ */ m("linearGradient", {
35
+ id: "barGradient",
36
+ x1: "0",
37
+ y1: "0",
38
+ x2: "0",
39
+ y2: "1",
40
+ children: [
41
+ /* @__PURE__ */ p("stop", {
42
+ offset: "0%",
43
+ stopColor: a,
44
+ stopOpacity: 1
45
+ }),
46
+ /* @__PURE__ */ p("stop", {
47
+ offset: "90%",
48
+ stopColor: a,
49
+ stopOpacity: .6
50
+ }),
51
+ /* @__PURE__ */ p("stop", {
52
+ offset: "100%",
53
+ stopColor: a,
54
+ stopOpacity: .3
55
+ })
56
+ ]
57
+ }), /* @__PURE__ */ m("filter", {
58
+ id: "glow",
59
+ height: "130%",
60
+ children: [
61
+ /* @__PURE__ */ p("feGaussianBlur", {
62
+ in: "SourceAlpha",
63
+ stdDeviation: "3",
64
+ result: "blur"
65
+ }),
66
+ /* @__PURE__ */ p("feOffset", {
67
+ in: "blur",
68
+ dx: "0",
69
+ dy: "0",
70
+ result: "offsetBlur"
71
+ }),
72
+ /* @__PURE__ */ p("feFlood", {
73
+ floodColor: a,
74
+ floodOpacity: "0.5",
75
+ result: "offsetColor"
76
+ }),
77
+ /* @__PURE__ */ p("feComposite", {
78
+ in: "offsetColor",
79
+ in2: "offsetBlur",
80
+ operator: "in",
81
+ result: "offsetBlur"
82
+ }),
83
+ /* @__PURE__ */ m("feMerge", { children: [/* @__PURE__ */ p("feMergeNode", { in: "offsetBlur" }), /* @__PURE__ */ p("feMergeNode", { in: "SourceGraphic" })] })
84
+ ]
85
+ })] }),
86
+ /* @__PURE__ */ p(y, {
87
+ strokeDasharray: "3 3",
88
+ stroke: "hsl(var(--border))",
89
+ vertical: !1
90
+ }),
91
+ /* @__PURE__ */ p(M, {
92
+ dataKey: n,
93
+ tick: {
94
+ fill: "hsl(var(--muted-foreground))",
95
+ fontSize: 12,
96
+ fontFamily: "monospace"
97
+ },
98
+ tickLine: !1,
99
+ axisLine: { stroke: "hsl(var(--border))" },
100
+ dy: 10
101
+ }),
102
+ /* @__PURE__ */ p(N, {
103
+ tick: {
104
+ fill: "hsl(var(--muted-foreground))",
105
+ fontSize: 12,
106
+ fontFamily: "monospace"
107
+ },
108
+ tickLine: !1,
109
+ axisLine: !1
110
+ }),
111
+ /* @__PURE__ */ p(j, {
112
+ cursor: {
113
+ fill: "hsl(var(--muted))",
114
+ opacity: .2
115
+ },
116
+ contentStyle: {
117
+ backgroundColor: "hsl(var(--popover))",
118
+ borderColor: "hsl(var(--border))",
119
+ color: "hsl(var(--popover-foreground))",
120
+ borderRadius: "8px",
121
+ fontFamily: "monospace",
122
+ boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)"
123
+ },
124
+ itemStyle: { color: "hsl(var(--primary))" }
125
+ }),
126
+ /* @__PURE__ */ p(x, { wrapperStyle: {
127
+ paddingTop: "20px",
128
+ fontFamily: "monospace"
129
+ } }),
130
+ /* @__PURE__ */ p(_, {
131
+ dataKey: t,
132
+ fill: "url(#barGradient)",
133
+ radius: [
134
+ 4,
135
+ 4,
136
+ 0,
137
+ 0
138
+ ],
139
+ filter: "url(#glow)",
140
+ animationDuration: 1500
141
+ })
142
+ ]
143
+ })
144
+ })
145
+ });
146
+ }
147
+ var ue = F((() => {}));
148
+ //#endregion
149
+ //#region src/ChartContainerImpl.tsx
150
+ function L() {
151
+ let e = n.useContext(W);
152
+ if (!e) throw Error("useChart must be used within a <ChartContainer />");
153
+ return e;
154
+ }
155
+ function R({ id: e, className: t, children: r, config: i, ...a }) {
156
+ let o = n.useId(), s = `chart-${e || o.replace(/:/g, "")}`;
157
+ return /* @__PURE__ */ p(W.Provider, {
158
+ value: { config: i },
159
+ children: /* @__PURE__ */ m("div", {
160
+ "data-slot": "chart",
161
+ "data-chart": s,
162
+ className: H("flex w-full h-[350px] justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground", t),
163
+ ...a,
164
+ children: [/* @__PURE__ */ p(G, {
165
+ id: s,
166
+ config: i
167
+ }), /* @__PURE__ */ p(k, {
168
+ width: "100%",
169
+ height: "100%",
170
+ children: r
171
+ })]
172
+ })
173
+ });
174
+ }
175
+ function z({ active: e, payload: t, className: r, indicator: i = "dot", hideLabel: a = !1, hideIndicator: o = !1, label: s, labelFormatter: c, labelClassName: l, formatter: u, color: d, nameKey: h, labelKey: g }) {
176
+ let { config: _ } = L(), v = n.useMemo(() => {
177
+ if (a || !t?.length) return null;
178
+ let [e] = t, n = V(_, e, `${g || e?.dataKey || e?.name || "value"}`), r = !g && typeof s == "string" ? _[s]?.label || s : n?.label;
179
+ return c ? /* @__PURE__ */ p("div", {
180
+ className: H("font-medium", l),
181
+ children: c(r, t)
182
+ }) : r ? /* @__PURE__ */ p("div", {
183
+ className: H("font-medium", l),
184
+ children: r
185
+ }) : null;
186
+ }, [
187
+ s,
188
+ c,
189
+ t,
190
+ a,
191
+ l,
192
+ _,
193
+ g
194
+ ]);
195
+ if (!e || !t?.length) return null;
196
+ let y = t.length === 1 && i !== "dot";
197
+ return /* @__PURE__ */ m("div", {
198
+ className: H("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", r),
199
+ children: [y ? null : v, /* @__PURE__ */ p("div", {
200
+ className: "grid gap-1.5",
201
+ children: t.filter((e) => e.type !== "none").map((e, t) => {
202
+ let n = V(_, e, `${h || e.name || e.dataKey || "value"}`), r = d || e.payload.fill || e.color;
203
+ return /* @__PURE__ */ p("div", {
204
+ className: H("[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5", i === "dot" ? "items-center" : ""),
205
+ children: u && e?.value !== void 0 && e.name ? u(e.value, e.name, e, t, e.payload) : /* @__PURE__ */ m(f, { children: [n?.icon ? /* @__PURE__ */ p(n.icon, {}) : !o && /* @__PURE__ */ p("div", {
206
+ className: H("shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)", i === "dot" ? "h-2.5 w-2.5" : "", i === "line" ? "w-1" : "", i === "dashed" ? "w-0 border-[1.5px] border-dashed bg-transparent" : "", y && i === "dashed" ? "my-0.5" : ""),
207
+ style: {
208
+ "--color-bg": r,
209
+ "--color-border": r
210
+ }
211
+ }), /* @__PURE__ */ m("div", {
212
+ className: H("flex flex-1 justify-between leading-none", y ? "items-end" : "items-center"),
213
+ children: [/* @__PURE__ */ m("div", {
214
+ className: "grid gap-1.5",
215
+ children: [y ? v : null, /* @__PURE__ */ p("span", {
216
+ className: "text-muted-foreground",
217
+ children: n?.label || e.name
218
+ })]
219
+ }), e.value && /* @__PURE__ */ p("span", {
220
+ className: "text-foreground font-mono font-medium tabular-nums",
221
+ children: e.value.toLocaleString()
222
+ })]
223
+ })] })
224
+ }, e.dataKey);
225
+ })
226
+ })]
227
+ });
228
+ }
229
+ function B({ className: e, hideIcon: t = !1, payload: n, verticalAlign: r = "bottom", nameKey: i }) {
230
+ let { config: a } = L();
231
+ return n?.length ? /* @__PURE__ */ p("div", {
232
+ className: H("flex items-center justify-center gap-4", r === "top" ? "pb-3" : "pt-3", e),
233
+ children: n.filter((e) => e.type !== "none").map((e) => {
234
+ let n = V(a, e, `${i || e.dataKey || "value"}`);
235
+ return /* @__PURE__ */ m("div", {
236
+ className: H("[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"),
237
+ children: [n?.icon && !t ? /* @__PURE__ */ p(n.icon, {}) : /* @__PURE__ */ p("div", {
238
+ className: "h-2 w-2 shrink-0 rounded-[2px]",
239
+ style: { backgroundColor: e.color }
240
+ }), n?.label]
241
+ }, e.value);
242
+ })
243
+ }) : null;
244
+ }
245
+ function V(e, t, n) {
246
+ if (typeof t != "object" || !t) return;
247
+ let r = "payload" in t && typeof t.payload == "object" && t.payload !== null ? t.payload : void 0, i = n;
248
+ 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];
249
+ }
250
+ var H, U, W, G, K, q, de = F((() => {
251
+ H = (...e) => e.filter(Boolean).join(" "), U = {
252
+ light: "",
253
+ dark: ".dark"
254
+ }, W = n.createContext(null), G = ({ id: e, config: t }) => {
255
+ let n = Object.entries(t).filter(([, e]) => e.theme || e.color);
256
+ return n.length ? /* @__PURE__ */ p("style", { dangerouslySetInnerHTML: { __html: Object.entries(U).map(([t, r]) => `
257
+ ${r} [data-chart=${e}] {
258
+ ${n.map(([e, n]) => {
259
+ let r = n.theme?.[t] || n.color;
260
+ return r ? ` --color-${e}: ${r};` : null;
261
+ }).join("\n")}
262
+ }
263
+ `).join("\n") } }) : null;
264
+ }, K = j, q = x;
265
+ })), fe = /* @__PURE__ */ I({ default: () => pe });
266
+ function pe({ chartType: e = "bar", data: t = [], config: r = {}, xAxisKey: i = "name", series: a = [], className: o = "" }) {
267
+ let s = Array.isArray(t) ? t : [], [c, l] = n.useState(!1);
268
+ n.useEffect(() => {
269
+ let e = () => l(window.innerWidth < 640);
270
+ return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
271
+ }, []);
272
+ let u = {
273
+ bar: v,
274
+ line: C,
275
+ area: g,
276
+ pie: T,
277
+ donut: T,
278
+ radar: O,
279
+ scatter: A,
280
+ combo: v
281
+ }[e] || v, d = n.useMemo(() => s.some((e) => String(e[i] || "").length > 5), [s, i]), f = () => [
282
+ "hsl(var(--chart-1))",
283
+ "hsl(var(--chart-2))",
284
+ "hsl(var(--chart-3))",
285
+ "hsl(var(--chart-4))",
286
+ "hsl(var(--chart-5))"
287
+ ];
288
+ if (e === "pie" || e === "donut") {
289
+ let t = e === "donut" ? 60 : 0;
290
+ return /* @__PURE__ */ p(R, {
291
+ config: r,
292
+ className: o,
293
+ children: /* @__PURE__ */ m(T, { children: [
294
+ /* @__PURE__ */ p(K, {
295
+ cursor: !1,
296
+ content: /* @__PURE__ */ p(z, { hideLabel: !0 })
297
+ }),
298
+ /* @__PURE__ */ p(w, {
299
+ data: s,
300
+ dataKey: a[0]?.dataKey || "value",
301
+ nameKey: i || "name",
302
+ innerRadius: t,
303
+ strokeWidth: 5,
304
+ paddingAngle: 2,
305
+ outerRadius: 80,
306
+ children: s.map((e, t) => {
307
+ let n = r[e[i]]?.color;
308
+ if (!n) {
309
+ let e = f();
310
+ n = e[t % e.length];
311
+ }
312
+ return /* @__PURE__ */ p(b, { fill: Y(n) }, `cell-${t}`);
313
+ })
314
+ }),
315
+ /* @__PURE__ */ p(q, {
316
+ content: /* @__PURE__ */ p(B, { nameKey: i }),
317
+ ...c && {
318
+ verticalAlign: "bottom",
319
+ wrapperStyle: {
320
+ fontSize: "11px",
321
+ paddingTop: "8px"
322
+ }
323
+ }
324
+ })
325
+ ] })
326
+ });
327
+ }
328
+ return e === "radar" ? /* @__PURE__ */ p(R, {
329
+ config: r,
330
+ className: o,
331
+ children: /* @__PURE__ */ m(O, {
332
+ data: s,
333
+ children: [
334
+ /* @__PURE__ */ p(D, {}),
335
+ /* @__PURE__ */ p(E, { dataKey: i }),
336
+ /* @__PURE__ */ p(ee, {}),
337
+ /* @__PURE__ */ p(K, { content: /* @__PURE__ */ p(z, {}) }),
338
+ /* @__PURE__ */ p(q, {
339
+ content: /* @__PURE__ */ p(B, {}),
340
+ ...c && {
341
+ verticalAlign: "bottom",
342
+ wrapperStyle: {
343
+ fontSize: "11px",
344
+ paddingTop: "8px"
345
+ }
346
+ }
347
+ }),
348
+ a.map((e) => {
349
+ let t = Y(r[e.dataKey]?.color || J);
350
+ return /* @__PURE__ */ p(te, {
351
+ dataKey: e.dataKey,
352
+ stroke: t,
353
+ fill: t,
354
+ fillOpacity: .6
355
+ }, e.dataKey);
356
+ })
357
+ ]
358
+ })
359
+ }) : e === "scatter" ? /* @__PURE__ */ p(R, {
360
+ config: r,
361
+ className: o,
362
+ children: /* @__PURE__ */ m(A, { children: [
363
+ /* @__PURE__ */ p(y, { vertical: !1 }),
364
+ /* @__PURE__ */ p(M, {
365
+ type: "number",
366
+ dataKey: i,
367
+ name: String(r[i]?.label || i),
368
+ tickLine: !1,
369
+ axisLine: !1,
370
+ interval: c ? Math.ceil(s.length / 5) : 0
371
+ }),
372
+ /* @__PURE__ */ p(N, {
373
+ type: "number",
374
+ dataKey: a[0]?.dataKey || "value",
375
+ name: String(r[a[0]?.dataKey]?.label || a[0]?.dataKey),
376
+ tickLine: !1,
377
+ axisLine: !1
378
+ }),
379
+ /* @__PURE__ */ p(re, {
380
+ type: "number",
381
+ range: [60, 400]
382
+ }),
383
+ /* @__PURE__ */ p(K, { content: /* @__PURE__ */ p(z, {}) }),
384
+ /* @__PURE__ */ p(q, {
385
+ content: /* @__PURE__ */ p(B, {}),
386
+ ...c && {
387
+ verticalAlign: "bottom",
388
+ wrapperStyle: {
389
+ fontSize: "11px",
390
+ paddingTop: "8px"
391
+ }
392
+ }
393
+ }),
394
+ a.map((e, t) => {
395
+ let n = f(), i = Y(r[e.dataKey]?.color || n[t % n.length]);
396
+ return /* @__PURE__ */ p(ne, {
397
+ name: r[e.dataKey]?.label || e.dataKey,
398
+ data: s,
399
+ fill: i
400
+ }, e.dataKey);
401
+ })
402
+ ] })
403
+ }) : e === "combo" ? /* @__PURE__ */ p(R, {
404
+ config: r,
405
+ className: o,
406
+ children: /* @__PURE__ */ m(v, {
407
+ data: s,
408
+ children: [
409
+ /* @__PURE__ */ p(y, { vertical: !1 }),
410
+ /* @__PURE__ */ p(M, {
411
+ dataKey: i,
412
+ tickLine: !1,
413
+ tickMargin: 10,
414
+ axisLine: !1,
415
+ interval: c ? Math.ceil(s.length / 5) : 0,
416
+ tickFormatter: (e) => !e || typeof e != "string" ? e : c && e.length > 8 ? e.slice(0, 8) + "…" : e,
417
+ ...!c && d && {
418
+ angle: -35,
419
+ textAnchor: "end",
420
+ height: 60
421
+ }
422
+ }),
423
+ /* @__PURE__ */ p(N, {
424
+ yAxisId: "left",
425
+ tickLine: !1,
426
+ axisLine: !1
427
+ }),
428
+ /* @__PURE__ */ p(N, {
429
+ yAxisId: "right",
430
+ orientation: "right",
431
+ tickLine: !1,
432
+ axisLine: !1
433
+ }),
434
+ /* @__PURE__ */ p(K, { content: /* @__PURE__ */ p(z, {}) }),
435
+ /* @__PURE__ */ p(q, {
436
+ content: /* @__PURE__ */ p(B, {}),
437
+ ...c && {
438
+ verticalAlign: "bottom",
439
+ wrapperStyle: {
440
+ fontSize: "11px",
441
+ paddingTop: "8px"
442
+ }
443
+ }
444
+ }),
445
+ a.map((e, t) => {
446
+ let n = Y(r[e.dataKey]?.color || J), i = e.chartType || (t === 0 ? "bar" : "line"), a = i === "bar" ? "left" : "right";
447
+ return i === "line" ? /* @__PURE__ */ p(S, {
448
+ yAxisId: a,
449
+ type: "monotone",
450
+ dataKey: e.dataKey,
451
+ stroke: n,
452
+ strokeWidth: 2,
453
+ dot: !1
454
+ }, e.dataKey) : i === "area" ? /* @__PURE__ */ p(h, {
455
+ yAxisId: a,
456
+ type: "monotone",
457
+ dataKey: e.dataKey,
458
+ fill: n,
459
+ stroke: n,
460
+ fillOpacity: .4
461
+ }, e.dataKey) : /* @__PURE__ */ p(_, {
462
+ yAxisId: a,
463
+ dataKey: e.dataKey,
464
+ fill: n,
465
+ radius: 4
466
+ }, e.dataKey);
467
+ })
468
+ ]
469
+ })
470
+ }) : /* @__PURE__ */ p(R, {
471
+ config: r,
472
+ className: o,
473
+ children: /* @__PURE__ */ m(u, {
474
+ data: s,
475
+ children: [
476
+ /* @__PURE__ */ p(y, { vertical: !1 }),
477
+ /* @__PURE__ */ p(M, {
478
+ dataKey: i,
479
+ tickLine: !1,
480
+ tickMargin: 10,
481
+ axisLine: !1,
482
+ interval: c ? Math.ceil(s.length / 5) : 0,
483
+ tickFormatter: (e) => !e || typeof e != "string" ? e : c && e.length > 8 ? e.slice(0, 8) + "…" : e,
484
+ ...!c && d && {
485
+ angle: -35,
486
+ textAnchor: "end",
487
+ height: 60
488
+ }
489
+ }),
490
+ /* @__PURE__ */ p(K, { content: /* @__PURE__ */ p(z, {}) }),
491
+ /* @__PURE__ */ p(q, {
492
+ content: /* @__PURE__ */ p(B, {}),
493
+ ...c && {
494
+ verticalAlign: "bottom",
495
+ wrapperStyle: {
496
+ fontSize: "11px",
497
+ paddingTop: "8px"
498
+ }
499
+ }
500
+ }),
501
+ a.map((t, n) => {
502
+ let i = f(), o = Y(r[t.dataKey]?.color || i[n % i.length] || J);
503
+ if (e === "bar") {
504
+ let e = a.length === 1 && s.length > 1;
505
+ return /* @__PURE__ */ p(_, {
506
+ dataKey: t.dataKey,
507
+ fill: o,
508
+ radius: 4,
509
+ children: e && s.map((e, t) => /* @__PURE__ */ p(b, { fill: Y(i[t % i.length]) }, `cell-${t}`))
510
+ }, t.dataKey);
511
+ }
512
+ return e === "line" ? /* @__PURE__ */ p(S, {
513
+ type: "monotone",
514
+ dataKey: t.dataKey,
515
+ stroke: o,
516
+ strokeWidth: 2,
517
+ dot: !1
518
+ }, t.dataKey) : e === "area" ? /* @__PURE__ */ p(h, {
519
+ type: "monotone",
520
+ dataKey: t.dataKey,
521
+ fill: o,
522
+ stroke: o,
523
+ fillOpacity: .4
524
+ }, t.dataKey) : null;
525
+ })
526
+ ]
527
+ })
528
+ });
529
+ }
530
+ var J, me, Y, he = F((() => {
531
+ de(), J = "hsl(var(--primary))", me = {
532
+ slate: "#64748b",
533
+ gray: "#6b7280",
534
+ zinc: "#71717a",
535
+ neutral: "#737373",
536
+ stone: "#78716c",
537
+ red: "#ef4444",
538
+ orange: "#f97316",
539
+ amber: "#f59e0b",
540
+ yellow: "#eab308",
541
+ lime: "#84cc16",
542
+ green: "#22c55e",
543
+ emerald: "#10b981",
544
+ teal: "#14b8a6",
545
+ cyan: "#06b6d4",
546
+ sky: "#0ea5e9",
547
+ blue: "#3b82f6",
548
+ indigo: "#6366f1",
549
+ violet: "#8b5cf6",
550
+ purple: "#a855f7",
551
+ fuchsia: "#d946ef",
552
+ pink: "#ec4899",
553
+ rose: "#f43f5e"
554
+ }, Y = (e) => me[e] || e;
555
+ })), ge = r.lazy(() => Promise.resolve().then(() => (ue(), ce))), _e = r.lazy(() => Promise.resolve().then(() => (he(), fe))), X = ({ schema: e }) => /* @__PURE__ */ p(i, {
556
+ fallback: /* @__PURE__ */ p(d, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
557
+ children: /* @__PURE__ */ p(ge, {
12
558
  data: e.data,
13
559
  dataKey: e.dataKey,
14
560
  xAxisKey: e.xAxisKey,
@@ -16,8 +562,8 @@ var _ = n.lazy(() => import("./ChartImpl-ZGY2c86F.js")), v = n.lazy(() => import
16
562
  className: e.className,
17
563
  color: e.color
18
564
  })
19
- }), b = ({ schema: e }) => {
20
- let t = n.useMemo(() => {
565
+ }), Z = ({ schema: e }) => {
566
+ let t = r.useMemo(() => {
21
567
  let t = e.series, n = e.xAxisKey, r = e.config;
22
568
  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) {
23
569
  let n = e.colors || [
@@ -41,9 +587,9 @@ var _ = n.lazy(() => import("./ChartImpl-ZGY2c86F.js")), v = n.lazy(() => import
41
587
  className: e.className
42
588
  };
43
589
  }, [e]);
44
- return /* @__PURE__ */ d(r, {
45
- fallback: /* @__PURE__ */ d(u, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
46
- children: /* @__PURE__ */ d(v, {
590
+ return /* @__PURE__ */ p(i, {
591
+ fallback: /* @__PURE__ */ p(d, { className: "w-full h-48 sm:h-64 md:h-80 lg:h-[400px]" }),
592
+ children: /* @__PURE__ */ p(_e, {
47
593
  chartType: t.chartType,
48
594
  data: t.data,
49
595
  config: t.config,
@@ -55,10 +601,10 @@ var _ = n.lazy(() => import("./ChartImpl-ZGY2c86F.js")), v = n.lazy(() => import
55
601
  };
56
602
  //#endregion
57
603
  //#region src/ObjectChart.tsx
58
- function x(e) {
604
+ function Q(e) {
59
605
  return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
60
606
  }
61
- function S(e, t) {
607
+ function ve(e, t) {
62
608
  let { field: n, function: r, groupBy: i } = t, a = {};
63
609
  for (let t of e) {
64
610
  let e = String(t[i] ?? "Unknown");
@@ -89,11 +635,11 @@ function S(e, t) {
89
635
  };
90
636
  });
91
637
  }
92
- async function C(e, n, r, i, a) {
638
+ async function ye(e, n, r, i, a) {
93
639
  if (!e.length || !n) return e;
94
640
  let o = a || ((e, t) => t), s = r?.fields?.[n];
95
641
  if (!s) return e.map((e) => {
96
- let t = String(e[n] ?? ""), r = x(t);
642
+ let t = String(e[n] ?? ""), r = Q(t);
97
643
  return {
98
644
  ...e,
99
645
  [n]: o(t, r)
@@ -103,7 +649,7 @@ async function C(e, n, r, i, a) {
103
649
  if (c === "select" || c === "picklist" || c === "dropdown") {
104
650
  let t = s.options || [];
105
651
  if (t.length === 0) return e.map((e) => {
106
- let t = String(e[n] ?? ""), r = x(t);
652
+ let t = String(e[n] ?? ""), r = Q(t);
107
653
  return {
108
654
  ...e,
109
655
  [n]: o(t, r)
@@ -112,7 +658,7 @@ async function C(e, n, r, i, a) {
112
658
  let r = {};
113
659
  for (let e of t) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
114
660
  return e.map((e) => {
115
- let t = String(e[n] ?? ""), i = r[t] || x(t);
661
+ let t = String(e[n] ?? ""), i = r[t] || Q(t);
116
662
  return {
117
663
  ...e,
118
664
  [n]: o(t, i)
@@ -147,17 +693,17 @@ async function C(e, n, r, i, a) {
147
693
  }
148
694
  return e.map((e) => ({
149
695
  ...e,
150
- [n]: x(String(e[n] ?? ""))
696
+ [n]: Q(String(e[n] ?? ""))
151
697
  }));
152
698
  }
153
- var w = (e) => {
154
- let { schema: n } = e, r = a(p), u = e.dataSource || r?.dataSource, _ = m(n.bind), { fieldOptionLabel: v } = g(), y = c(v);
155
- o(() => {
156
- y.current = v;
157
- }, [v]);
158
- let [x, w] = l([]), [T, E] = l(!1), [D, O] = l(null), k = s(() => n.aggregate ? JSON.stringify(n.aggregate) : "", [n.aggregate]), A = s(() => n.filter ? JSON.stringify(n.filter) : "", [n.filter]), j = i(async (e, r) => {
699
+ var $ = (e) => {
700
+ let { schema: n } = e, r = o(ie), i = e.dataSource || r?.dataSource, d = ae(n.bind), { fieldOptionLabel: f } = se(), h = l(f);
701
+ s(() => {
702
+ h.current = f;
703
+ }, [f]);
704
+ let [g, _] = u([]), [v, y] = u(!1), [b, x] = u(null), S = c(() => n.aggregate ? JSON.stringify(n.aggregate) : "", [n.aggregate]), C = c(() => n.filter ? JSON.stringify(n.filter) : "", [n.filter]), w = a(async (e, r) => {
159
705
  if (!(!e || !n.objectName)) {
160
- r.current && (E(!0), O(null));
706
+ r.current && (y(!0), x(null));
161
707
  try {
162
708
  let i;
163
709
  if (n.aggregate && typeof e.aggregate == "function") {
@@ -168,64 +714,64 @@ var w = (e) => {
168
714
  filter: n.filter
169
715
  });
170
716
  i = Array.isArray(t) ? t : [];
171
- } else if (typeof e.find == "function") i = t(await e.find(n.objectName, { $filter: n.filter })), n.aggregate && i.length > 0 && (i = S(i, n.aggregate));
717
+ } else if (typeof e.find == "function") i = t(await e.find(n.objectName, { $filter: n.filter })), n.aggregate && i.length > 0 && (i = ve(i, n.aggregate));
172
718
  else return;
173
719
  let a = n.aggregate?.groupBy || n.xAxisKey;
174
720
  if (a && typeof e.getObjectSchema == "function") try {
175
721
  let t = await e.getObjectSchema(n.objectName);
176
- i = await C(i, a, t, e, (e, t) => y.current(n.objectName, a, e, t));
722
+ i = await ye(i, a, t, e, (e, t) => h.current(n.objectName, a, e, t));
177
723
  } catch {}
178
- r.current && w(i);
724
+ r.current && _(i);
179
725
  } catch (e) {
180
- console.error("[ObjectChart] Fetch error:", e), r.current && O(e instanceof Error ? e.message : "Failed to load chart data");
726
+ console.error("[ObjectChart] Fetch error:", e), r.current && x(e instanceof Error ? e.message : "Failed to load chart data");
181
727
  } finally {
182
- r.current && E(!1);
728
+ r.current && y(!1);
183
729
  }
184
730
  }
185
731
  }, [
186
732
  n.objectName,
187
- k,
188
- A,
733
+ S,
734
+ C,
189
735
  n.xAxisKey
190
736
  ]);
191
- o(() => {
737
+ s(() => {
192
738
  let e = { current: !0 };
193
- return n.objectName && !_ && !n.data && j(u, e), () => {
739
+ return n.objectName && !d && !n.data && w(i, e), () => {
194
740
  e.current = !1;
195
741
  };
196
742
  }, [
197
743
  n.objectName,
198
- u,
199
- _,
744
+ i,
745
+ d,
200
746
  n.data,
201
- A,
202
- k,
203
- j
747
+ C,
748
+ S,
749
+ w
204
750
  ]);
205
- let M = _ || n.data || x, N = Array.isArray(M) ? M : [], P = {
751
+ let T = d || n.data || g, E = Array.isArray(T) ? T : [], D = {
206
752
  ...n,
207
- data: N
753
+ data: E
208
754
  };
209
- return T && N.length === 0 ? /* @__PURE__ */ d("div", {
755
+ return v && E.length === 0 ? /* @__PURE__ */ p("div", {
210
756
  className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (n.className || ""),
211
757
  "data-testid": "chart-loading",
212
758
  children: "Loading chart data…"
213
- }) : D ? /* @__PURE__ */ f("div", {
759
+ }) : b ? /* @__PURE__ */ m("div", {
214
760
  className: "flex flex-col items-center justify-center gap-2 p-4 " + (n.className || ""),
215
761
  "data-testid": "chart-error",
216
762
  role: "alert",
217
763
  children: [
218
- /* @__PURE__ */ d(h, { className: "h-6 w-6 text-destructive opacity-60" }),
219
- /* @__PURE__ */ d("p", {
764
+ /* @__PURE__ */ p(oe, { className: "h-6 w-6 text-destructive opacity-60" }),
765
+ /* @__PURE__ */ p("p", {
220
766
  className: "text-xs text-destructive font-medium",
221
767
  children: "Failed to load chart data"
222
768
  }),
223
- /* @__PURE__ */ d("p", {
769
+ /* @__PURE__ */ p("p", {
224
770
  className: "text-xs text-muted-foreground max-w-xs text-center",
225
- children: D
771
+ children: b
226
772
  })
227
773
  ]
228
- }) : !u && n.objectName && N.length === 0 ? /* @__PURE__ */ f("div", {
774
+ }) : !i && n.objectName && E.length === 0 ? /* @__PURE__ */ m("div", {
229
775
  className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (n.className || ""),
230
776
  "data-testid": "chart-no-datasource",
231
777
  children: [
@@ -233,12 +779,12 @@ var w = (e) => {
233
779
  n.objectName,
234
780
  "”"
235
781
  ]
236
- }) : /* @__PURE__ */ d(b, {
782
+ }) : /* @__PURE__ */ p(Z, {
237
783
  ...e,
238
- schema: P
784
+ schema: D
239
785
  });
240
786
  };
241
- e.register("object-chart", w, {
787
+ e.register("object-chart", $, {
242
788
  namespace: "plugin-charts",
243
789
  label: "Object Chart",
244
790
  category: "view",
@@ -270,11 +816,11 @@ e.register("object-chart", w, {
270
816
  });
271
817
  //#endregion
272
818
  //#region src/index.tsx
273
- var T = {
274
- "bar-chart": y,
275
- chart: b
819
+ var be = {
820
+ "bar-chart": X,
821
+ chart: Z
276
822
  };
277
- e.register("bar-chart", y, {
823
+ e.register("bar-chart", X, {
278
824
  namespace: "plugin-charts",
279
825
  label: "Bar Chart",
280
826
  category: "plugin",
@@ -338,7 +884,7 @@ e.register("bar-chart", y, {
338
884
  height: 400,
339
885
  color: "#8884d8"
340
886
  }
341
- }), e.register("chart", w, {
887
+ }), e.register("chart", $, {
342
888
  namespace: "view",
343
889
  category: "view",
344
890
  label: "Chart",
@@ -365,7 +911,7 @@ e.register("bar-chart", y, {
365
911
  label: "Value Field"
366
912
  }
367
913
  ]
368
- }), e.register("chart", b, {
914
+ }), e.register("chart", Z, {
369
915
  namespace: "plugin-charts",
370
916
  label: "Chart",
371
917
  category: "plugin",
@@ -477,31 +1023,31 @@ e.register("bar-chart", y, {
477
1023
  xAxisKey: "name",
478
1024
  series: [{ dataKey: "sales" }, { dataKey: "revenue" }]
479
1025
  }
480
- }), e.register("chart:bar", b, {
1026
+ }), e.register("chart:bar", Z, {
481
1027
  namespace: "plugin-charts",
482
1028
  label: "Bar Chart (Alias)",
483
1029
  category: "plugin",
484
1030
  defaultProps: { chartType: "bar" }
485
- }), e.register("pie-chart", b, {
1031
+ }), e.register("pie-chart", Z, {
486
1032
  namespace: "plugin-charts",
487
1033
  label: "Pie Chart",
488
1034
  category: "plugin",
489
1035
  defaultProps: { chartType: "pie" }
490
- }), e.register("donut-chart", b, {
1036
+ }), e.register("donut-chart", Z, {
491
1037
  namespace: "plugin-charts",
492
1038
  label: "Donut Chart",
493
1039
  category: "plugin",
494
1040
  defaultProps: { chartType: "donut" }
495
- }), e.register("radar-chart", b, {
1041
+ }), e.register("radar-chart", Z, {
496
1042
  namespace: "plugin-charts",
497
1043
  label: "Radar Chart",
498
1044
  category: "plugin",
499
1045
  defaultProps: { chartType: "radar" }
500
- }), e.register("scatter-chart", b, {
1046
+ }), e.register("scatter-chart", Z, {
501
1047
  namespace: "plugin-charts",
502
1048
  label: "Scatter Chart",
503
1049
  category: "plugin",
504
1050
  defaultProps: { chartType: "scatter" }
505
1051
  });
506
1052
  //#endregion
507
- export { y as ChartBarRenderer, b as ChartRenderer, w as ObjectChart, T as chartComponents };
1053
+ export { X as ChartBarRenderer, Z as ChartRenderer, $ as ObjectChart, be as chartComponents };