@object-ui/plugin-charts 4.0.3 → 4.0.4
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 +20 -0
- package/dist/AdvancedChartImpl-DkX8ZQ5Y.js +412 -0
- package/dist/{ChartImpl-AHzX3Kht.js → ChartImpl-ZGY2c86F.js} +31 -32
- package/dist/index.js +101 -448
- package/dist/index.umd.cjs +2 -56
- package/package.json +6 -6
- package/dist/AdvancedChartImpl-BLyJ4LaI.js +0 -3981
- package/dist/BarChart-C9W1kOQ6.js +0 -16506
- package/dist/shim-oa8knWTF.js +0 -284
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { SchemaRendererContext as
|
|
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";
|
|
6
8
|
//#region src/ChartRenderer.tsx
|
|
7
|
-
var
|
|
8
|
-
fallback: /* @__PURE__ */ (
|
|
9
|
-
children: /* @__PURE__ */ (
|
|
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(_, {
|
|
10
12
|
data: e.data,
|
|
11
13
|
dataKey: e.dataKey,
|
|
12
14
|
xAxisKey: e.xAxisKey,
|
|
@@ -14,8 +16,8 @@ var v = e(), y = i.lazy(() => import("./ChartImpl-AHzX3Kht.js")), b = i.lazy(()
|
|
|
14
16
|
className: e.className,
|
|
15
17
|
color: e.color
|
|
16
18
|
})
|
|
17
|
-
}),
|
|
18
|
-
let t =
|
|
19
|
+
}), b = ({ schema: e }) => {
|
|
20
|
+
let t = n.useMemo(() => {
|
|
19
21
|
let t = e.series, n = e.xAxisKey, r = e.config;
|
|
20
22
|
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) {
|
|
21
23
|
let n = e.colors || [
|
|
@@ -39,9 +41,9 @@ var v = e(), y = i.lazy(() => import("./ChartImpl-AHzX3Kht.js")), b = i.lazy(()
|
|
|
39
41
|
className: e.className
|
|
40
42
|
};
|
|
41
43
|
}, [e]);
|
|
42
|
-
return /* @__PURE__ */ (
|
|
43
|
-
fallback: /* @__PURE__ */ (
|
|
44
|
-
children: /* @__PURE__ */ (
|
|
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, {
|
|
45
47
|
chartType: t.chartType,
|
|
46
48
|
data: t.data,
|
|
47
49
|
config: t.config,
|
|
@@ -50,362 +52,13 @@ var v = e(), y = i.lazy(() => import("./ChartImpl-AHzX3Kht.js")), b = i.lazy(()
|
|
|
50
52
|
className: t.className
|
|
51
53
|
})
|
|
52
54
|
});
|
|
53
|
-
}
|
|
54
|
-
let t = T(e);
|
|
55
|
-
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
56
|
-
}, D = {
|
|
57
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
58
|
-
width: 24,
|
|
59
|
-
height: 24,
|
|
60
|
-
viewBox: "0 0 24 24",
|
|
61
|
-
fill: "none",
|
|
62
|
-
stroke: "currentColor",
|
|
63
|
-
strokeWidth: 2,
|
|
64
|
-
strokeLinecap: "round",
|
|
65
|
-
strokeLinejoin: "round"
|
|
66
|
-
}, O = (e) => {
|
|
67
|
-
for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
|
|
68
|
-
return !1;
|
|
69
|
-
}, k = o({}), A = () => u(k), j = c(({ color: e, size: t, strokeWidth: n, absoluteStrokeWidth: r, className: i = "", children: a, iconNode: o, ...c }, l) => {
|
|
70
|
-
let { size: u = 24, strokeWidth: d = 2, absoluteStrokeWidth: f = !1, color: p = "currentColor", className: m = "" } = A() ?? {}, h = r ?? f ? Number(n ?? d) * 24 / Number(t ?? u) : n ?? d;
|
|
71
|
-
return s("svg", {
|
|
72
|
-
ref: l,
|
|
73
|
-
...D,
|
|
74
|
-
width: t ?? u ?? D.width,
|
|
75
|
-
height: t ?? u ?? D.height,
|
|
76
|
-
stroke: e ?? p,
|
|
77
|
-
strokeWidth: h,
|
|
78
|
-
className: C("lucide", m, i),
|
|
79
|
-
...!a && !O(c) && { "aria-hidden": "true" },
|
|
80
|
-
...c
|
|
81
|
-
}, [...o.map(([e, t]) => s(e, t)), ...Array.isArray(a) ? a : [a]]);
|
|
82
|
-
}), ee = ((e, t) => {
|
|
83
|
-
let n = c(({ className: n, ...r }, i) => s(j, {
|
|
84
|
-
ref: i,
|
|
85
|
-
iconNode: t,
|
|
86
|
-
className: C(`lucide-${w(E(e))}`, `lucide-${e}`, n),
|
|
87
|
-
...r
|
|
88
|
-
}));
|
|
89
|
-
return n.displayName = E(e), n;
|
|
90
|
-
})("circle-alert", [
|
|
91
|
-
["circle", {
|
|
92
|
-
cx: "12",
|
|
93
|
-
cy: "12",
|
|
94
|
-
r: "10",
|
|
95
|
-
key: "1mglay"
|
|
96
|
-
}],
|
|
97
|
-
["line", {
|
|
98
|
-
x1: "12",
|
|
99
|
-
x2: "12",
|
|
100
|
-
y1: "8",
|
|
101
|
-
y2: "12",
|
|
102
|
-
key: "1pkeuh"
|
|
103
|
-
}],
|
|
104
|
-
["line", {
|
|
105
|
-
x1: "12",
|
|
106
|
-
x2: "12.01",
|
|
107
|
-
y1: "16",
|
|
108
|
-
y2: "16",
|
|
109
|
-
key: "4dfq90"
|
|
110
|
-
}]
|
|
111
|
-
]), te = (e, t, n, r) => {
|
|
112
|
-
let i = [n, {
|
|
113
|
-
code: t,
|
|
114
|
-
...r || {}
|
|
115
|
-
}];
|
|
116
|
-
if (e?.services?.logger?.forward) return e.services.logger.forward(i, "warn", "react-i18next::", !0);
|
|
117
|
-
L(i[0]) && (i[0] = `react-i18next:: ${i[0]}`), e?.services?.logger?.warn ? e.services.logger.warn(...i) : console?.warn && console.warn(...i);
|
|
118
|
-
}, M = {}, N = (e, t, n, r) => {
|
|
119
|
-
L(n) && M[n] || (L(n) && (M[n] = /* @__PURE__ */ new Date()), te(e, t, n, r));
|
|
120
|
-
}, P = (e, t) => () => {
|
|
121
|
-
if (e.isInitialized) t();
|
|
122
|
-
else {
|
|
123
|
-
let n = () => {
|
|
124
|
-
setTimeout(() => {
|
|
125
|
-
e.off("initialized", n);
|
|
126
|
-
}, 0), t();
|
|
127
|
-
};
|
|
128
|
-
e.on("initialized", n);
|
|
129
|
-
}
|
|
130
|
-
}, F = (e, t, n) => {
|
|
131
|
-
e.loadNamespaces(t, P(e, n));
|
|
132
|
-
}, I = (e, t, n, r) => {
|
|
133
|
-
if (L(n) && (n = [n]), e.options.preload && e.options.preload.indexOf(t) > -1) return F(e, n, r);
|
|
134
|
-
n.forEach((t) => {
|
|
135
|
-
e.options.ns.indexOf(t) < 0 && e.options.ns.push(t);
|
|
136
|
-
}), e.loadLanguages(t, P(e, r));
|
|
137
|
-
}, ne = (e, t, n = {}) => !t.languages || !t.languages.length ? (N(t, "NO_LANGUAGES", "i18n.languages were undefined or empty", { languages: t.languages }), !0) : t.hasLoadedNamespace(e, {
|
|
138
|
-
lng: n.lng,
|
|
139
|
-
precheck: (t, r) => {
|
|
140
|
-
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && t.services.backendConnector.backend && t.isLanguageChangingTo && !r(t.isLanguageChangingTo, e)) return !1;
|
|
141
|
-
}
|
|
142
|
-
}), L = (e) => typeof e == "string", R = (e) => typeof e == "object" && !!e, z = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, B = {
|
|
143
|
-
"&": "&",
|
|
144
|
-
"&": "&",
|
|
145
|
-
"<": "<",
|
|
146
|
-
"<": "<",
|
|
147
|
-
">": ">",
|
|
148
|
-
">": ">",
|
|
149
|
-
"'": "'",
|
|
150
|
-
"'": "'",
|
|
151
|
-
""": "\"",
|
|
152
|
-
""": "\"",
|
|
153
|
-
" ": " ",
|
|
154
|
-
" ": " ",
|
|
155
|
-
"©": "©",
|
|
156
|
-
"©": "©",
|
|
157
|
-
"®": "®",
|
|
158
|
-
"®": "®",
|
|
159
|
-
"…": "…",
|
|
160
|
-
"…": "…",
|
|
161
|
-
"/": "/",
|
|
162
|
-
"/": "/"
|
|
163
|
-
}, V = (e) => B[e], H = {
|
|
164
|
-
bindI18n: "languageChanged",
|
|
165
|
-
bindI18nStore: "",
|
|
166
|
-
transEmptyNodeValue: "",
|
|
167
|
-
transSupportBasicHtmlNodes: !0,
|
|
168
|
-
transWrapTextNodes: "",
|
|
169
|
-
transKeepBasicHtmlNodesFor: [
|
|
170
|
-
"br",
|
|
171
|
-
"strong",
|
|
172
|
-
"i",
|
|
173
|
-
"p"
|
|
174
|
-
],
|
|
175
|
-
useSuspense: !0,
|
|
176
|
-
unescape: (e) => e.replace(z, V),
|
|
177
|
-
transDefaultProps: void 0
|
|
178
|
-
}, U = () => H, W, G = () => W, K = o(), q = class {
|
|
179
|
-
constructor() {
|
|
180
|
-
this.usedNamespaces = {};
|
|
181
|
-
}
|
|
182
|
-
addUsedNamespaces(e) {
|
|
183
|
-
e.forEach((e) => {
|
|
184
|
-
this.usedNamespaces[e] || (this.usedNamespaces[e] = !0);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
getUsedNamespaces() {
|
|
188
|
-
return Object.keys(this.usedNamespaces);
|
|
189
|
-
}
|
|
190
|
-
}, J = t(), Y = {
|
|
191
|
-
t: (e, t) => {
|
|
192
|
-
if (L(t)) return t;
|
|
193
|
-
if (R(t) && L(t.defaultValue)) return t.defaultValue;
|
|
194
|
-
if (typeof e == "function") return "";
|
|
195
|
-
if (Array.isArray(e)) {
|
|
196
|
-
let t = e[e.length - 1];
|
|
197
|
-
return typeof t == "function" ? "" : t;
|
|
198
|
-
}
|
|
199
|
-
return e;
|
|
200
|
-
},
|
|
201
|
-
ready: !1
|
|
202
|
-
}, X = () => () => {}, re = (e, t = {}) => {
|
|
203
|
-
let { i18n: n } = t, { i18n: r, defaultNS: i } = u(K) || {}, a = n || r || G();
|
|
204
|
-
a && !a.reportNamespaces && (a.reportNamespaces = new q()), a || N(a, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
|
|
205
|
-
let o = f(() => ({
|
|
206
|
-
...U(),
|
|
207
|
-
...a?.options?.react,
|
|
208
|
-
...t
|
|
209
|
-
}), [a, t]), { useSuspense: s, keyPrefix: c } = o, h = e || i || a?.options?.defaultNS, g = L(h) ? [h] : h || ["translation"], _ = f(() => g, g);
|
|
210
|
-
a?.reportNamespaces?.addUsedNamespaces?.(_);
|
|
211
|
-
let v = p(0), y = l((e) => {
|
|
212
|
-
if (!a) return X;
|
|
213
|
-
let { bindI18n: t, bindI18nStore: n } = o, r = () => {
|
|
214
|
-
v.current += 1, e();
|
|
215
|
-
};
|
|
216
|
-
return t && a.on(t, r), n && a.store.on(n, r), () => {
|
|
217
|
-
t && t.split(" ").forEach((e) => a.off(e, r)), n && n.split(" ").forEach((e) => a.store.off(e, r));
|
|
218
|
-
};
|
|
219
|
-
}, [a, o]), b = p(), x = l(() => {
|
|
220
|
-
if (!a) return Y;
|
|
221
|
-
let e = !!(a.isInitialized || a.initializedStoreOnce) && _.every((e) => ne(e, a, o)), n = t.lng || a.language, r = v.current, i = b.current;
|
|
222
|
-
if (i && i.ready === e && i.lng === n && i.keyPrefix === c && i.revision === r) return i;
|
|
223
|
-
let s = {
|
|
224
|
-
t: a.getFixedT(n, o.nsMode === "fallback" ? _ : _[0], c),
|
|
225
|
-
ready: e,
|
|
226
|
-
lng: n,
|
|
227
|
-
keyPrefix: c,
|
|
228
|
-
revision: r
|
|
229
|
-
};
|
|
230
|
-
return b.current = s, s;
|
|
231
|
-
}, [
|
|
232
|
-
a,
|
|
233
|
-
_,
|
|
234
|
-
c,
|
|
235
|
-
o,
|
|
236
|
-
t.lng
|
|
237
|
-
]), [S, C] = m(0), { t: w, ready: T } = (0, J.useSyncExternalStore)(y, x, x);
|
|
238
|
-
d(() => {
|
|
239
|
-
if (a && !T && !s) {
|
|
240
|
-
let e = () => C((e) => e + 1);
|
|
241
|
-
t.lng ? I(a, t.lng, _, e) : F(a, _, e);
|
|
242
|
-
}
|
|
243
|
-
}, [
|
|
244
|
-
a,
|
|
245
|
-
t.lng,
|
|
246
|
-
_,
|
|
247
|
-
T,
|
|
248
|
-
s,
|
|
249
|
-
S
|
|
250
|
-
]);
|
|
251
|
-
let E = a || {}, D = p(null), O = p(), k = (e) => {
|
|
252
|
-
let t = Object.getOwnPropertyDescriptors(e);
|
|
253
|
-
t.__original && delete t.__original;
|
|
254
|
-
let n = Object.create(Object.getPrototypeOf(e), t);
|
|
255
|
-
if (!Object.prototype.hasOwnProperty.call(n, "__original")) try {
|
|
256
|
-
Object.defineProperty(n, "__original", {
|
|
257
|
-
value: e,
|
|
258
|
-
writable: !1,
|
|
259
|
-
enumerable: !1,
|
|
260
|
-
configurable: !1
|
|
261
|
-
});
|
|
262
|
-
} catch {}
|
|
263
|
-
return n;
|
|
264
|
-
}, A = f(() => {
|
|
265
|
-
let e = E, t = e?.language, n = e;
|
|
266
|
-
e && (D.current && D.current.__original === e && O.current === t ? n = D.current : (n = k(e), D.current = n, O.current = t));
|
|
267
|
-
let r = !T && !s ? (...e) => (N(a, "USE_T_BEFORE_READY", "useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."), w(...e)) : w, i = [
|
|
268
|
-
r,
|
|
269
|
-
n,
|
|
270
|
-
T
|
|
271
|
-
];
|
|
272
|
-
return i.t = r, i.i18n = n, i.ready = T, i;
|
|
273
|
-
}, [
|
|
274
|
-
w,
|
|
275
|
-
E,
|
|
276
|
-
T,
|
|
277
|
-
E.resolvedLanguage,
|
|
278
|
-
E.language,
|
|
279
|
-
E.languages
|
|
280
|
-
]);
|
|
281
|
-
if (a && s && !T) throw new Promise((e) => {
|
|
282
|
-
let n = () => e();
|
|
283
|
-
t.lng ? I(a, t.lng, _, n) : F(a, _, n);
|
|
284
|
-
});
|
|
285
|
-
return A;
|
|
286
|
-
}, ie = o(null);
|
|
287
|
-
function ae(e) {
|
|
288
|
-
let t = u(ie), { t: n, i18n: r } = re(e);
|
|
289
|
-
return {
|
|
290
|
-
t: n,
|
|
291
|
-
language: t?.language || r.language || "en",
|
|
292
|
-
changeLanguage: t?.changeLanguage || (async (e) => {
|
|
293
|
-
await r.changeLanguage(e);
|
|
294
|
-
}),
|
|
295
|
-
direction: t?.direction || "ltr",
|
|
296
|
-
i18n: r
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
//#endregion
|
|
300
|
-
//#region ../i18n/dist/useObjectLabel.js
|
|
301
|
-
var oe = new Set([
|
|
302
|
-
"common",
|
|
303
|
-
"validation",
|
|
304
|
-
"form",
|
|
305
|
-
"table",
|
|
306
|
-
"grid",
|
|
307
|
-
"calendar",
|
|
308
|
-
"list",
|
|
309
|
-
"kanban",
|
|
310
|
-
"chart",
|
|
311
|
-
"dashboard",
|
|
312
|
-
"configPanel",
|
|
313
|
-
"appDesigner",
|
|
314
|
-
"console",
|
|
315
|
-
"errors",
|
|
316
|
-
"detail"
|
|
317
|
-
]);
|
|
318
|
-
function Z() {
|
|
319
|
-
let { t: e, i18n: t } = ae(), n = () => {
|
|
320
|
-
if (!t || typeof t.getResourceBundle != "function") return [];
|
|
321
|
-
let e = t.language || "en", n = t.getResourceBundle(e, "translation");
|
|
322
|
-
return n ? Object.keys(n).filter((e) => !oe.has(e) && n[e] && typeof n[e] == "object" && (n[e].objects || n[e].fields || n[e].apps || n[e].dashboards || n[e].pages || n[e].reports)) : [];
|
|
323
|
-
}, r = (e) => {
|
|
324
|
-
let t = e.indexOf("__");
|
|
325
|
-
return t > 0 ? e.slice(t + 2) : e;
|
|
326
|
-
}, i = (t, r) => {
|
|
327
|
-
let i = Array.isArray(t) ? t : [t];
|
|
328
|
-
try {
|
|
329
|
-
let t = n();
|
|
330
|
-
for (let n of t) for (let t of i) {
|
|
331
|
-
let r = `${n}.${t}`, i = e(r, { defaultValue: "" });
|
|
332
|
-
if (i && i !== r && i !== "") return i;
|
|
333
|
-
}
|
|
334
|
-
} catch {}
|
|
335
|
-
return r;
|
|
336
|
-
}, a = (e, t) => {
|
|
337
|
-
let n = r(e);
|
|
338
|
-
return n === e ? [`objects.${e}.${t}`] : [`objects.${e}.${t}`, `objects.${n}.${t}`];
|
|
339
|
-
}, o = (e, t) => {
|
|
340
|
-
let n = r(e);
|
|
341
|
-
return n === e ? [`fields.${e}.${t}`] : [`fields.${e}.${t}`, `fields.${n}.${t}`];
|
|
342
|
-
}, s = (e, t, n) => {
|
|
343
|
-
let i = r(e);
|
|
344
|
-
return i === e ? [`fieldOptions.${e}.${t}.${n}`] : [`fieldOptions.${e}.${t}.${n}`, `fieldOptions.${i}.${t}.${n}`];
|
|
345
|
-
}, c = (e, t) => {
|
|
346
|
-
let n = r(e);
|
|
347
|
-
return n === e ? [`dashboards.${e}.${t}`] : [`dashboards.${e}.${t}`, `dashboards.${n}.${t}`];
|
|
348
|
-
}, l = (e, t) => {
|
|
349
|
-
let n = r(e);
|
|
350
|
-
return n === e ? [`pages.${e}.${t}`] : [`pages.${e}.${t}`, `pages.${n}.${t}`];
|
|
351
|
-
}, u = (e, t) => {
|
|
352
|
-
let n = r(e);
|
|
353
|
-
return n === e ? [`reports.${e}.${t}`] : [`reports.${e}.${t}`, `reports.${n}.${t}`];
|
|
354
|
-
};
|
|
355
|
-
return {
|
|
356
|
-
objectLabel: (e) => i(a(e.name, "label"), e.label),
|
|
357
|
-
objectDescription: (e) => {
|
|
358
|
-
if (e.description) return i(a(e.name, "description"), e.description);
|
|
359
|
-
},
|
|
360
|
-
fieldLabel: (e, t, n) => i(o(e, t), n),
|
|
361
|
-
fieldOptionLabel: (e, t, n, r) => i(s(e, t, n), r),
|
|
362
|
-
translateOptions: (e, t, n) => n.map((n) => ({
|
|
363
|
-
...n,
|
|
364
|
-
label: i(s(e, t, n.value), n.label)
|
|
365
|
-
})),
|
|
366
|
-
appLabel: (e) => i(`apps.${e.name}.label`, e.label ?? e.name),
|
|
367
|
-
appDescription: (e) => {
|
|
368
|
-
let t = e.description ?? "";
|
|
369
|
-
return i(`apps.${e.name}.description`, t) || void 0;
|
|
370
|
-
},
|
|
371
|
-
navGroupLabel: (e, t, n) => i(`apps.${e}.navigation.${t}.label`, n),
|
|
372
|
-
dashboardLabel: (e) => i(c(e.name, "label"), e.label ?? e.name),
|
|
373
|
-
dashboardDescription: (e) => {
|
|
374
|
-
let t = e.description ?? "";
|
|
375
|
-
return i(c(e.name, "description"), t) || void 0;
|
|
376
|
-
},
|
|
377
|
-
dashboardActionLabel: (e, t, n) => i(c(e, `actions.${t}.label`), n),
|
|
378
|
-
widgetTitle: (e, t, n) => i(c(e, `widgets.${t}.title`), n),
|
|
379
|
-
widgetDescription: (e, t, n) => {
|
|
380
|
-
let r = n ?? "";
|
|
381
|
-
return i(c(e, `widgets.${t}.description`), r) || void 0;
|
|
382
|
-
},
|
|
383
|
-
pageLabel: (e) => i(l(e.name, "label"), e.label ?? e.name),
|
|
384
|
-
reportLabel: (e) => i(u(e.name, "label"), e.label ?? e.name)
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
function se() {
|
|
388
|
-
try {
|
|
389
|
-
let { fieldLabel: e, translateOptions: t, fieldOptionLabel: n } = Z();
|
|
390
|
-
return {
|
|
391
|
-
fieldLabel: e,
|
|
392
|
-
translateOptions: t,
|
|
393
|
-
fieldOptionLabel: n
|
|
394
|
-
};
|
|
395
|
-
} catch {
|
|
396
|
-
return {
|
|
397
|
-
fieldLabel: (e, t, n) => n,
|
|
398
|
-
translateOptions: (e, t, n) => n,
|
|
399
|
-
fieldOptionLabel: (e, t, n, r) => r
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
}
|
|
55
|
+
};
|
|
403
56
|
//#endregion
|
|
404
57
|
//#region src/ObjectChart.tsx
|
|
405
|
-
function
|
|
58
|
+
function x(e) {
|
|
406
59
|
return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
407
60
|
}
|
|
408
|
-
function
|
|
61
|
+
function S(e, t) {
|
|
409
62
|
let { field: n, function: r, groupBy: i } = t, a = {};
|
|
410
63
|
for (let t of e) {
|
|
411
64
|
let e = String(t[i] ?? "Unknown");
|
|
@@ -436,44 +89,44 @@ function ce(e, t) {
|
|
|
436
89
|
};
|
|
437
90
|
});
|
|
438
91
|
}
|
|
439
|
-
async function
|
|
440
|
-
if (!e.length || !
|
|
441
|
-
let o = a || ((e, t) => t), s =
|
|
92
|
+
async function C(e, n, r, i, a) {
|
|
93
|
+
if (!e.length || !n) return e;
|
|
94
|
+
let o = a || ((e, t) => t), s = r?.fields?.[n];
|
|
442
95
|
if (!s) return e.map((e) => {
|
|
443
|
-
let
|
|
96
|
+
let t = String(e[n] ?? ""), r = x(t);
|
|
444
97
|
return {
|
|
445
98
|
...e,
|
|
446
|
-
[
|
|
99
|
+
[n]: o(t, r)
|
|
447
100
|
};
|
|
448
101
|
});
|
|
449
102
|
let c = s.type;
|
|
450
103
|
if (c === "select" || c === "picklist" || c === "dropdown") {
|
|
451
|
-
let
|
|
452
|
-
if (
|
|
453
|
-
let
|
|
104
|
+
let t = s.options || [];
|
|
105
|
+
if (t.length === 0) return e.map((e) => {
|
|
106
|
+
let t = String(e[n] ?? ""), r = x(t);
|
|
454
107
|
return {
|
|
455
108
|
...e,
|
|
456
|
-
[
|
|
109
|
+
[n]: o(t, r)
|
|
457
110
|
};
|
|
458
111
|
});
|
|
459
112
|
let r = {};
|
|
460
|
-
for (let e of
|
|
113
|
+
for (let e of t) typeof e == "string" ? r[e] = e : e && typeof e == "object" && (r[String(e.value)] = e.label || String(e.value));
|
|
461
114
|
return e.map((e) => {
|
|
462
|
-
let
|
|
115
|
+
let t = String(e[n] ?? ""), i = r[t] || x(t);
|
|
463
116
|
return {
|
|
464
117
|
...e,
|
|
465
|
-
[
|
|
118
|
+
[n]: o(t, i)
|
|
466
119
|
};
|
|
467
120
|
});
|
|
468
121
|
}
|
|
469
122
|
if (c === "lookup" || c === "master_detail") {
|
|
470
|
-
let
|
|
471
|
-
if (!
|
|
472
|
-
let a = [...new Set(e.map((e) => e[
|
|
123
|
+
let r = s.reference_to || s.reference;
|
|
124
|
+
if (!r || !i || typeof i.find != "function") return e;
|
|
125
|
+
let a = [...new Set(e.map((e) => e[n]).filter((e) => e != null))];
|
|
473
126
|
if (a.length === 0) return e;
|
|
474
127
|
let o = s.id_field || "id";
|
|
475
128
|
try {
|
|
476
|
-
let c =
|
|
129
|
+
let c = t(await i.find(r, {
|
|
477
130
|
$filter: { [o]: { $in: a } },
|
|
478
131
|
$top: a.length
|
|
479
132
|
})), l = s.reference_field || s.display_field || "name", u = {};
|
|
@@ -482,10 +135,10 @@ async function le(e, t, n, i, a) {
|
|
|
482
135
|
t && (u[t] = String(n));
|
|
483
136
|
}
|
|
484
137
|
return e.map((e) => {
|
|
485
|
-
let
|
|
138
|
+
let t = String(e[n] ?? "");
|
|
486
139
|
return {
|
|
487
140
|
...e,
|
|
488
|
-
[
|
|
141
|
+
[n]: u[t] || t
|
|
489
142
|
};
|
|
490
143
|
});
|
|
491
144
|
} catch (t) {
|
|
@@ -494,98 +147,98 @@ async function le(e, t, n, i, a) {
|
|
|
494
147
|
}
|
|
495
148
|
return e.map((e) => ({
|
|
496
149
|
...e,
|
|
497
|
-
[
|
|
150
|
+
[n]: x(String(e[n] ?? ""))
|
|
498
151
|
}));
|
|
499
152
|
}
|
|
500
|
-
var
|
|
501
|
-
let { schema:
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}, [
|
|
505
|
-
let [
|
|
506
|
-
if (!(!e || !
|
|
507
|
-
|
|
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) => {
|
|
159
|
+
if (!(!e || !n.objectName)) {
|
|
160
|
+
r.current && (E(!0), O(null));
|
|
508
161
|
try {
|
|
509
162
|
let i;
|
|
510
|
-
if (
|
|
511
|
-
let
|
|
512
|
-
field:
|
|
513
|
-
function:
|
|
514
|
-
groupBy:
|
|
515
|
-
filter:
|
|
163
|
+
if (n.aggregate && typeof e.aggregate == "function") {
|
|
164
|
+
let t = await e.aggregate(n.objectName, {
|
|
165
|
+
field: n.aggregate.field,
|
|
166
|
+
function: n.aggregate.function,
|
|
167
|
+
groupBy: n.aggregate.groupBy,
|
|
168
|
+
filter: n.filter
|
|
516
169
|
});
|
|
517
|
-
i = Array.isArray(
|
|
518
|
-
} else if (typeof e.find == "function") i =
|
|
170
|
+
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));
|
|
519
172
|
else return;
|
|
520
|
-
let a =
|
|
173
|
+
let a = n.aggregate?.groupBy || n.xAxisKey;
|
|
521
174
|
if (a && typeof e.getObjectSchema == "function") try {
|
|
522
|
-
let
|
|
523
|
-
i = await
|
|
175
|
+
let t = await e.getObjectSchema(n.objectName);
|
|
176
|
+
i = await C(i, a, t, e, (e, t) => y.current(n.objectName, a, e, t));
|
|
524
177
|
} catch {}
|
|
525
|
-
|
|
178
|
+
r.current && w(i);
|
|
526
179
|
} catch (e) {
|
|
527
|
-
console.error("[ObjectChart] Fetch error:", e),
|
|
180
|
+
console.error("[ObjectChart] Fetch error:", e), r.current && O(e instanceof Error ? e.message : "Failed to load chart data");
|
|
528
181
|
} finally {
|
|
529
|
-
|
|
182
|
+
r.current && E(!1);
|
|
530
183
|
}
|
|
531
184
|
}
|
|
532
185
|
}, [
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
186
|
+
n.objectName,
|
|
187
|
+
k,
|
|
188
|
+
A,
|
|
189
|
+
n.xAxisKey
|
|
537
190
|
]);
|
|
538
|
-
|
|
191
|
+
o(() => {
|
|
539
192
|
let e = { current: !0 };
|
|
540
|
-
return
|
|
193
|
+
return n.objectName && !_ && !n.data && j(u, e), () => {
|
|
541
194
|
e.current = !1;
|
|
542
195
|
};
|
|
543
196
|
}, [
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
197
|
+
n.objectName,
|
|
198
|
+
u,
|
|
199
|
+
_,
|
|
200
|
+
n.data,
|
|
201
|
+
A,
|
|
202
|
+
k,
|
|
203
|
+
j
|
|
551
204
|
]);
|
|
552
|
-
let
|
|
553
|
-
...
|
|
554
|
-
data:
|
|
205
|
+
let M = _ || n.data || x, N = Array.isArray(M) ? M : [], P = {
|
|
206
|
+
...n,
|
|
207
|
+
data: N
|
|
555
208
|
};
|
|
556
|
-
return
|
|
557
|
-
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (
|
|
209
|
+
return T && N.length === 0 ? /* @__PURE__ */ d("div", {
|
|
210
|
+
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (n.className || ""),
|
|
558
211
|
"data-testid": "chart-loading",
|
|
559
212
|
children: "Loading chart data…"
|
|
560
|
-
}) :
|
|
561
|
-
className: "flex flex-col items-center justify-center gap-2 p-4 " + (
|
|
213
|
+
}) : D ? /* @__PURE__ */ f("div", {
|
|
214
|
+
className: "flex flex-col items-center justify-center gap-2 p-4 " + (n.className || ""),
|
|
562
215
|
"data-testid": "chart-error",
|
|
563
216
|
role: "alert",
|
|
564
217
|
children: [
|
|
565
|
-
/* @__PURE__ */ (
|
|
566
|
-
/* @__PURE__ */ (
|
|
218
|
+
/* @__PURE__ */ d(h, { className: "h-6 w-6 text-destructive opacity-60" }),
|
|
219
|
+
/* @__PURE__ */ d("p", {
|
|
567
220
|
className: "text-xs text-destructive font-medium",
|
|
568
221
|
children: "Failed to load chart data"
|
|
569
222
|
}),
|
|
570
|
-
/* @__PURE__ */ (
|
|
223
|
+
/* @__PURE__ */ d("p", {
|
|
571
224
|
className: "text-xs text-muted-foreground max-w-xs text-center",
|
|
572
|
-
children:
|
|
225
|
+
children: D
|
|
573
226
|
})
|
|
574
227
|
]
|
|
575
|
-
}) : !
|
|
576
|
-
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (
|
|
228
|
+
}) : !u && n.objectName && N.length === 0 ? /* @__PURE__ */ f("div", {
|
|
229
|
+
className: "flex items-center justify-center text-muted-foreground text-sm p-4 " + (n.className || ""),
|
|
577
230
|
"data-testid": "chart-no-datasource",
|
|
578
231
|
children: [
|
|
579
232
|
"No data source available for “",
|
|
580
|
-
|
|
233
|
+
n.objectName,
|
|
581
234
|
"”"
|
|
582
235
|
]
|
|
583
|
-
}) : /* @__PURE__ */ (
|
|
236
|
+
}) : /* @__PURE__ */ d(b, {
|
|
584
237
|
...e,
|
|
585
|
-
schema:
|
|
238
|
+
schema: P
|
|
586
239
|
});
|
|
587
240
|
};
|
|
588
|
-
|
|
241
|
+
e.register("object-chart", w, {
|
|
589
242
|
namespace: "plugin-charts",
|
|
590
243
|
label: "Object Chart",
|
|
591
244
|
category: "view",
|
|
@@ -617,11 +270,11 @@ n.register("object-chart", $, {
|
|
|
617
270
|
});
|
|
618
271
|
//#endregion
|
|
619
272
|
//#region src/index.tsx
|
|
620
|
-
var
|
|
621
|
-
"bar-chart":
|
|
622
|
-
chart:
|
|
273
|
+
var T = {
|
|
274
|
+
"bar-chart": y,
|
|
275
|
+
chart: b
|
|
623
276
|
};
|
|
624
|
-
|
|
277
|
+
e.register("bar-chart", y, {
|
|
625
278
|
namespace: "plugin-charts",
|
|
626
279
|
label: "Bar Chart",
|
|
627
280
|
category: "plugin",
|
|
@@ -685,7 +338,7 @@ n.register("bar-chart", x, {
|
|
|
685
338
|
height: 400,
|
|
686
339
|
color: "#8884d8"
|
|
687
340
|
}
|
|
688
|
-
}),
|
|
341
|
+
}), e.register("chart", w, {
|
|
689
342
|
namespace: "view",
|
|
690
343
|
category: "view",
|
|
691
344
|
label: "Chart",
|
|
@@ -712,7 +365,7 @@ n.register("bar-chart", x, {
|
|
|
712
365
|
label: "Value Field"
|
|
713
366
|
}
|
|
714
367
|
]
|
|
715
|
-
}),
|
|
368
|
+
}), e.register("chart", b, {
|
|
716
369
|
namespace: "plugin-charts",
|
|
717
370
|
label: "Chart",
|
|
718
371
|
category: "plugin",
|
|
@@ -824,31 +477,31 @@ n.register("bar-chart", x, {
|
|
|
824
477
|
xAxisKey: "name",
|
|
825
478
|
series: [{ dataKey: "sales" }, { dataKey: "revenue" }]
|
|
826
479
|
}
|
|
827
|
-
}),
|
|
480
|
+
}), e.register("chart:bar", b, {
|
|
828
481
|
namespace: "plugin-charts",
|
|
829
482
|
label: "Bar Chart (Alias)",
|
|
830
483
|
category: "plugin",
|
|
831
484
|
defaultProps: { chartType: "bar" }
|
|
832
|
-
}),
|
|
485
|
+
}), e.register("pie-chart", b, {
|
|
833
486
|
namespace: "plugin-charts",
|
|
834
487
|
label: "Pie Chart",
|
|
835
488
|
category: "plugin",
|
|
836
489
|
defaultProps: { chartType: "pie" }
|
|
837
|
-
}),
|
|
490
|
+
}), e.register("donut-chart", b, {
|
|
838
491
|
namespace: "plugin-charts",
|
|
839
492
|
label: "Donut Chart",
|
|
840
493
|
category: "plugin",
|
|
841
494
|
defaultProps: { chartType: "donut" }
|
|
842
|
-
}),
|
|
495
|
+
}), e.register("radar-chart", b, {
|
|
843
496
|
namespace: "plugin-charts",
|
|
844
497
|
label: "Radar Chart",
|
|
845
498
|
category: "plugin",
|
|
846
499
|
defaultProps: { chartType: "radar" }
|
|
847
|
-
}),
|
|
500
|
+
}), e.register("scatter-chart", b, {
|
|
848
501
|
namespace: "plugin-charts",
|
|
849
502
|
label: "Scatter Chart",
|
|
850
503
|
category: "plugin",
|
|
851
504
|
defaultProps: { chartType: "scatter" }
|
|
852
505
|
});
|
|
853
506
|
//#endregion
|
|
854
|
-
export {
|
|
507
|
+
export { y as ChartBarRenderer, b as ChartRenderer, w as ObjectChart, T as chartComponents };
|