@object-ui/plugin-charts 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { j as r } from "./index-BcjHuFVN.js";
2
- import { R as l, B as n, C as d, X as f, Y as p, T as x, L as u, a as c } from "./BarChart-CRc8MAtI.js";
1
+ import { j as r } from "./index-DgxI83zT.js";
2
+ import { R as l, B as n, C as d, X as f, Y as p, T as x, L as u, a as c } from "./BarChart-C_I0OFbj.js";
3
3
  function j({
4
4
  data: e = [],
5
5
  dataKey: s = "value",
@@ -0,0 +1,478 @@
1
+ import { ComponentRegistry as m } from "@object-ui/core";
2
+ import k, { Suspense as W, useState as L, useEffect as se } from "react";
3
+ import { Skeleton as q } from "@object-ui/components";
4
+ import { useSchemaContext as ce, useDataScope as ue } from "@object-ui/react";
5
+ var j = { exports: {} }, E = {};
6
+ var V;
7
+ function ie() {
8
+ if (V) return E;
9
+ V = 1;
10
+ var a = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
11
+ function u(i, l, c) {
12
+ var d = null;
13
+ if (c !== void 0 && (d = "" + c), l.key !== void 0 && (d = "" + l.key), "key" in l) {
14
+ c = {};
15
+ for (var p in l)
16
+ p !== "key" && (c[p] = l[p]);
17
+ } else c = l;
18
+ return l = c.ref, {
19
+ $$typeof: a,
20
+ type: i,
21
+ key: d,
22
+ ref: l !== void 0 ? l : null,
23
+ props: c
24
+ };
25
+ }
26
+ return E.Fragment = t, E.jsx = u, E.jsxs = u, E;
27
+ }
28
+ var R = {};
29
+ var J;
30
+ function fe() {
31
+ return J || (J = 1, process.env.NODE_ENV !== "production" && (function() {
32
+ function a(e) {
33
+ if (e == null) return null;
34
+ if (typeof e == "function")
35
+ return e.$$typeof === ne ? null : e.displayName || e.name || null;
36
+ if (typeof e == "string") return e;
37
+ switch (e) {
38
+ case O:
39
+ return "Fragment";
40
+ case G:
41
+ return "Profiler";
42
+ case B:
43
+ return "StrictMode";
44
+ case ee:
45
+ return "Suspense";
46
+ case re:
47
+ return "SuspenseList";
48
+ case te:
49
+ return "Activity";
50
+ }
51
+ if (typeof e == "object")
52
+ switch (typeof e.tag == "number" && console.error(
53
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
54
+ ), e.$$typeof) {
55
+ case X:
56
+ return "Portal";
57
+ case Z:
58
+ return e.displayName || "Context";
59
+ case H:
60
+ return (e._context.displayName || "Context") + ".Consumer";
61
+ case Q:
62
+ var r = e.render;
63
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
64
+ case ae:
65
+ return r = e.displayName || null, r !== null ? r : a(e.type) || "Memo";
66
+ case C:
67
+ r = e._payload, e = e._init;
68
+ try {
69
+ return a(e(r));
70
+ } catch {
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ function t(e) {
76
+ return "" + e;
77
+ }
78
+ function u(e) {
79
+ try {
80
+ t(e);
81
+ var r = !1;
82
+ } catch {
83
+ r = !0;
84
+ }
85
+ if (r) {
86
+ r = console;
87
+ var n = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
88
+ return n.call(
89
+ r,
90
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
91
+ o
92
+ ), t(e);
93
+ }
94
+ }
95
+ function i(e) {
96
+ if (e === O) return "<>";
97
+ if (typeof e == "object" && e !== null && e.$$typeof === C)
98
+ return "<...>";
99
+ try {
100
+ var r = a(e);
101
+ return r ? "<" + r + ">" : "<...>";
102
+ } catch {
103
+ return "<...>";
104
+ }
105
+ }
106
+ function l() {
107
+ var e = P.A;
108
+ return e === null ? null : e.getOwner();
109
+ }
110
+ function c() {
111
+ return Error("react-stack-top-frame");
112
+ }
113
+ function d(e) {
114
+ if (K.call(e, "key")) {
115
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
116
+ if (r && r.isReactWarning) return !1;
117
+ }
118
+ return e.key !== void 0;
119
+ }
120
+ function p(e, r) {
121
+ function n() {
122
+ Y || (Y = !0, console.error(
123
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
124
+ r
125
+ ));
126
+ }
127
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
128
+ get: n,
129
+ configurable: !0
130
+ });
131
+ }
132
+ function g() {
133
+ var e = a(this.type);
134
+ return F[e] || (F[e] = !0, console.error(
135
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
136
+ )), e = this.props.ref, e !== void 0 ? e : null;
137
+ }
138
+ function x(e, r, n, o, S, w) {
139
+ var s = n.ref;
140
+ return e = {
141
+ $$typeof: h,
142
+ type: e,
143
+ key: r,
144
+ props: n,
145
+ _owner: o
146
+ }, (s !== void 0 ? s : null) !== null ? Object.defineProperty(e, "ref", {
147
+ enumerable: !1,
148
+ get: g
149
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
150
+ configurable: !1,
151
+ enumerable: !1,
152
+ writable: !0,
153
+ value: 0
154
+ }), Object.defineProperty(e, "_debugInfo", {
155
+ configurable: !1,
156
+ enumerable: !1,
157
+ writable: !0,
158
+ value: null
159
+ }), Object.defineProperty(e, "_debugStack", {
160
+ configurable: !1,
161
+ enumerable: !1,
162
+ writable: !0,
163
+ value: S
164
+ }), Object.defineProperty(e, "_debugTask", {
165
+ configurable: !1,
166
+ enumerable: !1,
167
+ writable: !0,
168
+ value: w
169
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
170
+ }
171
+ function T(e, r, n, o, S, w) {
172
+ var s = r.children;
173
+ if (s !== void 0)
174
+ if (o)
175
+ if (le(s)) {
176
+ for (o = 0; o < s.length; o++)
177
+ y(s[o]);
178
+ Object.freeze && Object.freeze(s);
179
+ } else
180
+ console.error(
181
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
182
+ );
183
+ else y(s);
184
+ if (K.call(r, "key")) {
185
+ s = a(e);
186
+ var _ = Object.keys(r).filter(function(oe) {
187
+ return oe !== "key";
188
+ });
189
+ o = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", I[s + o] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
190
+ `A props object containing a "key" prop is being spread into JSX:
191
+ let props = %s;
192
+ <%s {...props} />
193
+ React keys must be passed directly to JSX without using spread:
194
+ let props = %s;
195
+ <%s key={someKey} {...props} />`,
196
+ o,
197
+ s,
198
+ _,
199
+ s
200
+ ), I[s + o] = !0);
201
+ }
202
+ if (s = null, n !== void 0 && (u(n), s = "" + n), d(r) && (u(r.key), s = "" + r.key), "key" in r) {
203
+ n = {};
204
+ for (var D in r)
205
+ D !== "key" && (n[D] = r[D]);
206
+ } else n = r;
207
+ return s && p(
208
+ n,
209
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
210
+ ), x(
211
+ e,
212
+ s,
213
+ n,
214
+ l(),
215
+ S,
216
+ w
217
+ );
218
+ }
219
+ function y(e) {
220
+ A(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === C && (e._payload.status === "fulfilled" ? A(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
221
+ }
222
+ function A(e) {
223
+ return typeof e == "object" && e !== null && e.$$typeof === h;
224
+ }
225
+ var f = k, h = /* @__PURE__ */ Symbol.for("react.transitional.element"), X = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), B = /* @__PURE__ */ Symbol.for("react.strict_mode"), G = /* @__PURE__ */ Symbol.for("react.profiler"), H = /* @__PURE__ */ Symbol.for("react.consumer"), Z = /* @__PURE__ */ Symbol.for("react.context"), Q = /* @__PURE__ */ Symbol.for("react.forward_ref"), ee = /* @__PURE__ */ Symbol.for("react.suspense"), re = /* @__PURE__ */ Symbol.for("react.suspense_list"), ae = /* @__PURE__ */ Symbol.for("react.memo"), C = /* @__PURE__ */ Symbol.for("react.lazy"), te = /* @__PURE__ */ Symbol.for("react.activity"), ne = /* @__PURE__ */ Symbol.for("react.client.reference"), P = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, K = Object.prototype.hasOwnProperty, le = Array.isArray, N = console.createTask ? console.createTask : function() {
226
+ return null;
227
+ };
228
+ f = {
229
+ react_stack_bottom_frame: function(e) {
230
+ return e();
231
+ }
232
+ };
233
+ var Y, F = {}, M = f.react_stack_bottom_frame.bind(
234
+ f,
235
+ c
236
+ )(), $ = N(i(c)), I = {};
237
+ R.Fragment = O, R.jsx = function(e, r, n) {
238
+ var o = 1e4 > P.recentlyCreatedOwnerStacks++;
239
+ return T(
240
+ e,
241
+ r,
242
+ n,
243
+ !1,
244
+ o ? Error("react-stack-top-frame") : M,
245
+ o ? N(i(e)) : $
246
+ );
247
+ }, R.jsxs = function(e, r, n) {
248
+ var o = 1e4 > P.recentlyCreatedOwnerStacks++;
249
+ return T(
250
+ e,
251
+ r,
252
+ n,
253
+ !0,
254
+ o ? Error("react-stack-top-frame") : M,
255
+ o ? N(i(e)) : $
256
+ );
257
+ };
258
+ })()), R;
259
+ }
260
+ var z;
261
+ function de() {
262
+ return z || (z = 1, process.env.NODE_ENV === "production" ? j.exports = ie() : j.exports = fe()), j.exports;
263
+ }
264
+ var v = de();
265
+ const pe = k.lazy(() => import("./ChartImpl-CU5lEzui.js")), me = k.lazy(() => import("./AdvancedChartImpl-DcIHnCct.js")), U = ({ schema: a }) => /* @__PURE__ */ v.jsx(W, { fallback: /* @__PURE__ */ v.jsx(q, { className: "w-full h-[400px]" }), children: /* @__PURE__ */ v.jsx(
266
+ pe,
267
+ {
268
+ data: a.data,
269
+ dataKey: a.dataKey,
270
+ xAxisKey: a.xAxisKey,
271
+ height: a.height,
272
+ className: a.className,
273
+ color: a.color
274
+ }
275
+ ) }), b = ({ schema: a }) => {
276
+ const t = k.useMemo(() => {
277
+ let u = a.series, i = a.xAxisKey, l = a.config;
278
+ if (i || (a.index ? i = a.index : a.category && (i = a.category)), u || (a.categories ? u = a.categories.map((c) => ({ dataKey: c })) : a.value && (u = [{ dataKey: a.value }])), !l && u) {
279
+ const c = a.colors || ["hsl(var(--chart-1))", "hsl(var(--chart-2))", "hsl(var(--chart-3))"], d = {};
280
+ u.forEach((p, g) => {
281
+ d[p.dataKey] = { label: p.dataKey, color: c[g % c.length] };
282
+ }), l = d;
283
+ }
284
+ return {
285
+ chartType: a.chartType,
286
+ data: a.data,
287
+ config: l,
288
+ xAxisKey: i,
289
+ series: u,
290
+ className: a.className
291
+ };
292
+ }, [a]);
293
+ return /* @__PURE__ */ v.jsx(W, { fallback: /* @__PURE__ */ v.jsx(q, { className: "w-full h-[400px]" }), children: /* @__PURE__ */ v.jsx(
294
+ me,
295
+ {
296
+ chartType: t.chartType,
297
+ data: t.data,
298
+ config: t.config,
299
+ xAxisKey: t.xAxisKey,
300
+ series: t.series,
301
+ className: t.className
302
+ }
303
+ ) });
304
+ }, be = (a) => {
305
+ const { schema: t } = a, u = ce(), i = a.dataSource || u.dataSource, l = ue(t.bind), [c, d] = L([]), [p, g] = L(!1);
306
+ se(() => {
307
+ let y = !0;
308
+ const A = async () => {
309
+ if (!(!i || !t.objectName)) {
310
+ y && g(!0);
311
+ try {
312
+ const f = await i.find(t.objectName, {
313
+ $filter: t.filter
314
+ });
315
+ let h = [];
316
+ Array.isArray(f) ? h = f : f && typeof f == "object" && Array.isArray(f.value) && (h = f.value), y && d(h);
317
+ } catch (f) {
318
+ console.error("[ObjectChart] Fetch error:", f);
319
+ } finally {
320
+ y && g(!1);
321
+ }
322
+ }
323
+ };
324
+ return t.objectName && !l && !t.data && A(), () => {
325
+ y = !1;
326
+ };
327
+ }, [t.objectName, i, l, t.data, t.filter]);
328
+ const x = l || t.data || c || [], T = {
329
+ ...t,
330
+ data: x
331
+ };
332
+ return p && x.length, /* @__PURE__ */ v.jsx(b, { ...a, schema: T });
333
+ };
334
+ m.register("object-chart", be, {
335
+ namespace: "plugin-charts",
336
+ label: "Object Chart",
337
+ category: "view"
338
+ });
339
+ const _e = {
340
+ "bar-chart": U,
341
+ chart: b
342
+ };
343
+ m.register(
344
+ "bar-chart",
345
+ U,
346
+ {
347
+ namespace: "plugin-charts",
348
+ label: "Bar Chart",
349
+ category: "plugin",
350
+ inputs: [
351
+ { name: "data", type: "array", label: "Data", required: !0 },
352
+ { name: "dataKey", type: "string", label: "Data Key", defaultValue: "value" },
353
+ { name: "xAxisKey", type: "string", label: "X-Axis Key", defaultValue: "name" },
354
+ { name: "height", type: "number", label: "Height", defaultValue: 400 },
355
+ { name: "color", type: "color", label: "Color", defaultValue: "#8884d8" }
356
+ ],
357
+ defaultProps: {
358
+ data: [
359
+ { name: "Jan", value: 400 },
360
+ { name: "Feb", value: 300 },
361
+ { name: "Mar", value: 600 },
362
+ { name: "Apr", value: 800 },
363
+ { name: "May", value: 500 }
364
+ ],
365
+ dataKey: "value",
366
+ xAxisKey: "name",
367
+ height: 400,
368
+ color: "#8884d8"
369
+ }
370
+ }
371
+ );
372
+ m.register(
373
+ "chart",
374
+ b,
375
+ {
376
+ namespace: "plugin-charts",
377
+ label: "Chart",
378
+ category: "plugin",
379
+ inputs: [
380
+ {
381
+ name: "chartType",
382
+ type: "enum",
383
+ label: "Chart Type",
384
+ enum: [
385
+ { label: "Bar", value: "bar" },
386
+ { label: "Line", value: "line" },
387
+ { label: "Area", value: "area" },
388
+ { label: "Pie", value: "pie" },
389
+ { label: "Donut", value: "donut" },
390
+ { label: "Radar", value: "radar" },
391
+ { label: "Scatter", value: "scatter" }
392
+ ],
393
+ defaultValue: "bar"
394
+ },
395
+ { name: "data", type: "code", label: "Data (JSON)", required: !0 },
396
+ { name: "config", type: "code", label: "Config (JSON)" },
397
+ { name: "xAxisKey", type: "string", label: "X Axis Key", defaultValue: "name" },
398
+ { name: "series", type: "code", label: "Series (JSON Array)", required: !0 },
399
+ { name: "className", type: "string", label: "CSS Class" }
400
+ ],
401
+ defaultProps: {
402
+ chartType: "bar",
403
+ data: [
404
+ { name: "Jan", sales: 400, revenue: 240 },
405
+ { name: "Feb", sales: 300, revenue: 139 },
406
+ { name: "Mar", sales: 600, revenue: 380 },
407
+ { name: "Apr", sales: 800, revenue: 430 },
408
+ { name: "May", sales: 500, revenue: 220 }
409
+ ],
410
+ config: {
411
+ sales: { label: "Sales", color: "#8884d8" },
412
+ revenue: { label: "Revenue", color: "#82ca9d" }
413
+ },
414
+ xAxisKey: "name",
415
+ series: [
416
+ { dataKey: "sales" },
417
+ { dataKey: "revenue" }
418
+ ]
419
+ }
420
+ }
421
+ );
422
+ m.register(
423
+ "chart:bar",
424
+ b,
425
+ {
426
+ namespace: "plugin-charts",
427
+ label: "Bar Chart (Alias)",
428
+ category: "plugin",
429
+ defaultProps: { chartType: "bar" }
430
+ }
431
+ );
432
+ m.register(
433
+ "pie-chart",
434
+ b,
435
+ {
436
+ namespace: "plugin-charts",
437
+ label: "Pie Chart",
438
+ category: "plugin",
439
+ defaultProps: { chartType: "pie" }
440
+ }
441
+ );
442
+ m.register(
443
+ "donut-chart",
444
+ b,
445
+ {
446
+ namespace: "plugin-charts",
447
+ label: "Donut Chart",
448
+ category: "plugin",
449
+ defaultProps: { chartType: "donut" }
450
+ }
451
+ );
452
+ m.register(
453
+ "radar-chart",
454
+ b,
455
+ {
456
+ namespace: "plugin-charts",
457
+ label: "Radar Chart",
458
+ category: "plugin",
459
+ defaultProps: { chartType: "radar" }
460
+ }
461
+ );
462
+ m.register(
463
+ "scatter-chart",
464
+ b,
465
+ {
466
+ namespace: "plugin-charts",
467
+ label: "Scatter Chart",
468
+ category: "plugin",
469
+ defaultProps: { chartType: "scatter" }
470
+ }
471
+ );
472
+ export {
473
+ U as C,
474
+ be as O,
475
+ b as a,
476
+ _e as c,
477
+ v as j
478
+ };
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
- import { C as m, a as p, c as n } from "./index-BcjHuFVN.js";
2
- import "react";
3
1
  import "@object-ui/core";
4
- import "@object-ui/components";
2
+ import { C as t, a as o, O as s, c as C } from "./index-DgxI83zT.js";
5
3
  export {
6
- m as ChartBarRenderer,
7
- p as ChartRenderer,
8
- n as chartComponents
4
+ t as ChartBarRenderer,
5
+ o as ChartRenderer,
6
+ s as ObjectChart,
7
+ C as chartComponents
9
8
  };