@object-ui/plugin-report 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ObjectQL
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ export * from './src/index'
package/dist/index.js ADDED
@@ -0,0 +1,1011 @@
1
+ import { ComponentRegistry as P } from "@object-ui/core";
2
+ import fe, { useState as W } from "react";
3
+ import { Card as z, CardHeader as ee, CardTitle as se, CardDescription as de, CardContent as Y, Button as E, Tabs as je, TabsList as ve, TabsTrigger as q, TabsContent as H, Label as x, Input as D } from "@object-ui/components";
4
+ import { SchemaRenderer as ue } from "@object-ui/react";
5
+ import { RefreshCw as ge, Printer as be, Download as Ne, Settings as ye, Layers as oe, Filter as we, Plus as I, Trash2 as Q, Save as Re } from "lucide-react";
6
+ var ce = { exports: {} }, J = {};
7
+ /**
8
+ * @license React
9
+ * react-jsx-runtime.production.js
10
+ *
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ var he;
17
+ function Ee() {
18
+ if (he) return J;
19
+ he = 1;
20
+ var v = Symbol.for("react.transitional.element"), c = Symbol.for("react.fragment");
21
+ function u(d, m, N) {
22
+ var S = null;
23
+ if (N !== void 0 && (S = "" + N), m.key !== void 0 && (S = "" + m.key), "key" in m) {
24
+ N = {};
25
+ for (var i in m)
26
+ i !== "key" && (N[i] = m[i]);
27
+ } else N = m;
28
+ return m = N.ref, {
29
+ $$typeof: v,
30
+ type: d,
31
+ key: S,
32
+ ref: m !== void 0 ? m : null,
33
+ props: N
34
+ };
35
+ }
36
+ return J.Fragment = c, J.jsx = u, J.jsxs = u, J;
37
+ }
38
+ var X = {};
39
+ /**
40
+ * @license React
41
+ * react-jsx-runtime.development.js
42
+ *
43
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE file in the root directory of this source tree.
47
+ */
48
+ var me;
49
+ function Ce() {
50
+ return me || (me = 1, process.env.NODE_ENV !== "production" && function() {
51
+ function v(s) {
52
+ if (s == null) return null;
53
+ if (typeof s == "function")
54
+ return s.$$typeof === ae ? null : s.displayName || s.name || null;
55
+ if (typeof s == "string") return s;
56
+ switch (s) {
57
+ case o:
58
+ return "Fragment";
59
+ case k:
60
+ return "Profiler";
61
+ case _:
62
+ return "StrictMode";
63
+ case B:
64
+ return "Suspense";
65
+ case re:
66
+ return "SuspenseList";
67
+ case M:
68
+ return "Activity";
69
+ }
70
+ if (typeof s == "object")
71
+ switch (typeof s.tag == "number" && console.error(
72
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
73
+ ), s.$$typeof) {
74
+ case C:
75
+ return "Portal";
76
+ case O:
77
+ return s.displayName || "Context";
78
+ case A:
79
+ return (s._context.displayName || "Context") + ".Consumer";
80
+ case $:
81
+ var n = s.render;
82
+ return s = s.displayName, s || (s = n.displayName || n.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
83
+ case te:
84
+ return n = s.displayName || null, n !== null ? n : v(s.type) || "Memo";
85
+ case L:
86
+ n = s._payload, s = s._init;
87
+ try {
88
+ return v(s(n));
89
+ } catch {
90
+ }
91
+ }
92
+ return null;
93
+ }
94
+ function c(s) {
95
+ return "" + s;
96
+ }
97
+ function u(s) {
98
+ try {
99
+ c(s);
100
+ var n = !1;
101
+ } catch {
102
+ n = !0;
103
+ }
104
+ if (n) {
105
+ n = console;
106
+ var p = n.error, g = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
107
+ return p.call(
108
+ n,
109
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
110
+ g
111
+ ), c(s);
112
+ }
113
+ }
114
+ function d(s) {
115
+ if (s === o) return "<>";
116
+ if (typeof s == "object" && s !== null && s.$$typeof === L)
117
+ return "<...>";
118
+ try {
119
+ var n = v(s);
120
+ return n ? "<" + n + ">" : "<...>";
121
+ } catch {
122
+ return "<...>";
123
+ }
124
+ }
125
+ function m() {
126
+ var s = F.A;
127
+ return s === null ? null : s.getOwner();
128
+ }
129
+ function N() {
130
+ return Error("react-stack-top-frame");
131
+ }
132
+ function S(s) {
133
+ if (Z.call(s, "key")) {
134
+ var n = Object.getOwnPropertyDescriptor(s, "key").get;
135
+ if (n && n.isReactWarning) return !1;
136
+ }
137
+ return s.key !== void 0;
138
+ }
139
+ function i(s, n) {
140
+ function p() {
141
+ t || (t = !0, console.error(
142
+ "%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)",
143
+ n
144
+ ));
145
+ }
146
+ p.isReactWarning = !0, Object.defineProperty(s, "key", {
147
+ get: p,
148
+ configurable: !0
149
+ });
150
+ }
151
+ function h() {
152
+ var s = v(this.type);
153
+ return a[s] || (a[s] = !0, console.error(
154
+ "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."
155
+ )), s = this.props.ref, s !== void 0 ? s : null;
156
+ }
157
+ function j(s, n, p, g, K, ne) {
158
+ var b = p.ref;
159
+ return s = {
160
+ $$typeof: T,
161
+ type: s,
162
+ key: n,
163
+ props: p,
164
+ _owner: g
165
+ }, (b !== void 0 ? b : null) !== null ? Object.defineProperty(s, "ref", {
166
+ enumerable: !1,
167
+ get: h
168
+ }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
169
+ configurable: !1,
170
+ enumerable: !1,
171
+ writable: !0,
172
+ value: 0
173
+ }), Object.defineProperty(s, "_debugInfo", {
174
+ configurable: !1,
175
+ enumerable: !1,
176
+ writable: !0,
177
+ value: null
178
+ }), Object.defineProperty(s, "_debugStack", {
179
+ configurable: !1,
180
+ enumerable: !1,
181
+ writable: !0,
182
+ value: K
183
+ }), Object.defineProperty(s, "_debugTask", {
184
+ configurable: !1,
185
+ enumerable: !1,
186
+ writable: !0,
187
+ value: ne
188
+ }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
189
+ }
190
+ function f(s, n, p, g, K, ne) {
191
+ var b = n.children;
192
+ if (b !== void 0)
193
+ if (g)
194
+ if (le(b)) {
195
+ for (g = 0; g < b.length; g++)
196
+ y(b[g]);
197
+ Object.freeze && Object.freeze(b);
198
+ } else
199
+ console.error(
200
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
201
+ );
202
+ else y(b);
203
+ if (Z.call(n, "key")) {
204
+ b = v(s);
205
+ var G = Object.keys(n).filter(function(pe) {
206
+ return pe !== "key";
207
+ });
208
+ g = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", U[b + g] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
209
+ `A props object containing a "key" prop is being spread into JSX:
210
+ let props = %s;
211
+ <%s {...props} />
212
+ React keys must be passed directly to JSX without using spread:
213
+ let props = %s;
214
+ <%s key={someKey} {...props} />`,
215
+ g,
216
+ b,
217
+ G,
218
+ b
219
+ ), U[b + g] = !0);
220
+ }
221
+ if (b = null, p !== void 0 && (u(p), b = "" + p), S(n) && (u(n.key), b = "" + n.key), "key" in n) {
222
+ p = {};
223
+ for (var ie in n)
224
+ ie !== "key" && (p[ie] = n[ie]);
225
+ } else p = n;
226
+ return b && i(
227
+ p,
228
+ typeof s == "function" ? s.displayName || s.name || "Unknown" : s
229
+ ), j(
230
+ s,
231
+ b,
232
+ p,
233
+ m(),
234
+ K,
235
+ ne
236
+ );
237
+ }
238
+ function y(s) {
239
+ l(s) ? s._store && (s._store.validated = 1) : typeof s == "object" && s !== null && s.$$typeof === L && (s._payload.status === "fulfilled" ? l(s._payload.value) && s._payload.value._store && (s._payload.value._store.validated = 1) : s._store && (s._store.validated = 1));
240
+ }
241
+ function l(s) {
242
+ return typeof s == "object" && s !== null && s.$$typeof === T;
243
+ }
244
+ var w = fe, T = Symbol.for("react.transitional.element"), C = Symbol.for("react.portal"), o = Symbol.for("react.fragment"), _ = Symbol.for("react.strict_mode"), k = Symbol.for("react.profiler"), A = Symbol.for("react.consumer"), O = Symbol.for("react.context"), $ = Symbol.for("react.forward_ref"), B = Symbol.for("react.suspense"), re = Symbol.for("react.suspense_list"), te = Symbol.for("react.memo"), L = Symbol.for("react.lazy"), M = Symbol.for("react.activity"), ae = Symbol.for("react.client.reference"), F = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Z = Object.prototype.hasOwnProperty, le = Array.isArray, r = console.createTask ? console.createTask : function() {
245
+ return null;
246
+ };
247
+ w = {
248
+ react_stack_bottom_frame: function(s) {
249
+ return s();
250
+ }
251
+ };
252
+ var t, a = {}, R = w.react_stack_bottom_frame.bind(
253
+ w,
254
+ N
255
+ )(), V = r(d(N)), U = {};
256
+ X.Fragment = o, X.jsx = function(s, n, p) {
257
+ var g = 1e4 > F.recentlyCreatedOwnerStacks++;
258
+ return f(
259
+ s,
260
+ n,
261
+ p,
262
+ !1,
263
+ g ? Error("react-stack-top-frame") : R,
264
+ g ? r(d(s)) : V
265
+ );
266
+ }, X.jsxs = function(s, n, p) {
267
+ var g = 1e4 > F.recentlyCreatedOwnerStacks++;
268
+ return f(
269
+ s,
270
+ n,
271
+ p,
272
+ !0,
273
+ g ? Error("react-stack-top-frame") : R,
274
+ g ? r(d(s)) : V
275
+ );
276
+ };
277
+ }()), X;
278
+ }
279
+ process.env.NODE_ENV === "production" ? ce.exports = Ee() : ce.exports = Ce();
280
+ var e = ce.exports;
281
+ const Te = ({ schema: v }) => {
282
+ var h;
283
+ const { title: c, description: u, data: d, columns: m } = v;
284
+ (h = v.chart) != null && h.type;
285
+ const N = !!v.chart, i = !(process.env.NODE_ENV === "test");
286
+ return /* @__PURE__ */ e.jsxs(z, { className: `h-full flex flex-col ${v.className || ""}`, children: [
287
+ /* @__PURE__ */ e.jsxs(ee, { children: [
288
+ c && /* @__PURE__ */ e.jsx(se, { children: c }),
289
+ u && /* @__PURE__ */ e.jsx(de, { children: u })
290
+ ] }),
291
+ /* @__PURE__ */ e.jsxs(Y, { className: "flex-1 overflow-auto space-y-4", children: [
292
+ N && (() => {
293
+ var y;
294
+ const j = (y = v.chart) == null ? void 0 : y.type;
295
+ let f = j ? P.get(j) : null;
296
+ return f || (f = P.get("chart")), f ? /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px] border rounded-md p-4 bg-white/50", children: /* @__PURE__ */ e.jsx(f, { schema: { ...v.chart, data: v.chart.data || d } }) }) : /* @__PURE__ */ e.jsxs("div", { className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center", children: [
297
+ "Unknown component type: ",
298
+ j || "chart"
299
+ ] });
300
+ })(),
301
+ d && d.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-md", children: (() => {
302
+ const j = i ? P.get("aggrid") || P.get("table") : null;
303
+ return j ? /* @__PURE__ */ e.jsx(
304
+ j,
305
+ {
306
+ schema: {
307
+ type: "aggrid",
308
+ rowData: d,
309
+ columnDefs: m,
310
+ domLayout: "autoHeight"
311
+ }
312
+ }
313
+ ) : (
314
+ // Simple Fallback Table if Grid plugin missing
315
+ /* @__PURE__ */ e.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm text-left", children: [
316
+ /* @__PURE__ */ e.jsx("thead", { className: "text-xs uppercase bg-gray-50", children: /* @__PURE__ */ e.jsx("tr", { children: m == null ? void 0 : m.map((f) => /* @__PURE__ */ e.jsx("th", { className: "px-6 py-3", children: f.headerName || f.label || f.field }, f.field)) }) }),
317
+ /* @__PURE__ */ e.jsx("tbody", { children: d.map((f, y) => /* @__PURE__ */ e.jsx("tr", { className: "bg-white border-b", children: m == null ? void 0 : m.map((l) => /* @__PURE__ */ e.jsx("td", { className: "px-6 py-4", children: f[l.field] }, l.field)) }, y)) })
318
+ ] }) })
319
+ );
320
+ })() })
321
+ ] })
322
+ ] });
323
+ }, xe = ({ schema: v }) => {
324
+ var f, y;
325
+ const {
326
+ report: c,
327
+ data: u,
328
+ showToolbar: d = !0,
329
+ allowExport: m = !0,
330
+ allowPrint: N = !0,
331
+ loading: S = !1
332
+ } = v, i = (l) => {
333
+ console.log("Export report as:", l), alert(`Export to ${l.toUpperCase()} - Feature coming soon!`);
334
+ }, h = () => {
335
+ console.log("Print report"), window.print();
336
+ }, j = () => {
337
+ console.log("Refresh report");
338
+ };
339
+ return c ? /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
340
+ d && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border", children: [
341
+ /* @__PURE__ */ e.jsxs("div", { children: [
342
+ /* @__PURE__ */ e.jsx("h2", { className: "text-lg font-semibold", children: c.title }),
343
+ c.description && /* @__PURE__ */ e.jsx("p", { className: "text-sm text-muted-foreground", children: c.description })
344
+ ] }),
345
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
346
+ c.refreshInterval && /* @__PURE__ */ e.jsxs(E, { variant: "outline", size: "sm", onClick: j, children: [
347
+ /* @__PURE__ */ e.jsx(ge, { className: "h-4 w-4 mr-2" }),
348
+ "Refresh"
349
+ ] }),
350
+ N && /* @__PURE__ */ e.jsxs(E, { variant: "outline", size: "sm", onClick: h, children: [
351
+ /* @__PURE__ */ e.jsx(be, { className: "h-4 w-4 mr-2" }),
352
+ "Print"
353
+ ] }),
354
+ m && c.showExportButtons && /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(
355
+ E,
356
+ {
357
+ variant: "outline",
358
+ size: "sm",
359
+ onClick: () => i(c.defaultExportFormat || "pdf"),
360
+ children: [
361
+ /* @__PURE__ */ e.jsx(Ne, { className: "h-4 w-4 mr-2" }),
362
+ "Export"
363
+ ]
364
+ }
365
+ ) })
366
+ ] })
367
+ ] }),
368
+ /* @__PURE__ */ e.jsxs(z, { children: [
369
+ /* @__PURE__ */ e.jsxs(ee, { children: [
370
+ !d && c.title && /* @__PURE__ */ e.jsx(se, { children: c.title }),
371
+ !d && c.description && /* @__PURE__ */ e.jsx(de, { children: c.description })
372
+ ] }),
373
+ /* @__PURE__ */ e.jsxs(Y, { className: "space-y-6", children: [
374
+ S && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground", children: "Loading report data..." }),
375
+ !S && ((f = c.sections) == null ? void 0 : f.map((l, w) => {
376
+ var T, C;
377
+ return l.visible === !1 ? null : /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
378
+ l.title && /* @__PURE__ */ e.jsx("h3", { className: "text-lg font-semibold border-b pb-2", children: l.title }),
379
+ l.type === "header" && l.title && /* @__PURE__ */ e.jsx("div", { className: "text-2xl font-bold py-4", children: l.title }),
380
+ l.type === "summary" && /* @__PURE__ */ e.jsx("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-4", children: (T = c.fields) == null ? void 0 : T.filter((o) => o.showInSummary).map((o, _) => /* @__PURE__ */ e.jsx(z, { children: /* @__PURE__ */ e.jsxs(Y, { className: "p-4", children: [
381
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground", children: o.label || o.name }),
382
+ /* @__PURE__ */ e.jsxs("div", { className: "text-2xl font-bold", children: [
383
+ o.aggregation === "count" && (u == null ? void 0 : u.length),
384
+ o.aggregation === "sum" && (u == null ? void 0 : u.reduce((k, A) => k + (A[o.name] || 0), 0))
385
+ ] })
386
+ ] }) }, _)) }),
387
+ l.type === "chart" && l.chart && /* @__PURE__ */ e.jsx("div", { className: "min-h-[300px]", children: (() => {
388
+ let o = l.chart.type;
389
+ const _ = !!l.chart.chartType;
390
+ !o && _ && (o = "chart"), o && !!P.get(o) || (o = "chart");
391
+ const O = o === "chart" ? {
392
+ xAxisKey: l.chart.xAxisKey || l.chart.xAxisField || "name",
393
+ series: l.chart.series || (l.chart.yAxisFields ? l.chart.yAxisFields.map((B) => ({ dataKey: B })) : []),
394
+ // Ensure chartType is passed if we are using the generic renderer
395
+ chartType: l.chart.chartType || "bar"
396
+ } : {}, $ = {
397
+ ...l.chart,
398
+ type: o,
399
+ ...O,
400
+ data: u || l.chart.data,
401
+ // Force explicit height to preventing Recharts "height(-1)" error
402
+ className: l.chart.className || "w-full h-[350px]"
403
+ };
404
+ return /* @__PURE__ */ e.jsx(ue, { schema: $ });
405
+ })() }),
406
+ l.type === "table" && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
407
+ /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (C = l.columns) == null ? void 0 : C.map((o, _) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-2 text-left font-medium", children: o.label || o.name }, _)) }) }),
408
+ /* @__PURE__ */ e.jsx("tbody", { children: u == null ? void 0 : u.map((o, _) => {
409
+ var k;
410
+ return /* @__PURE__ */ e.jsx("tr", { className: "border-t", children: (k = l.columns) == null ? void 0 : k.map((A, O) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-2", children: o[A.name] }, O)) }, _);
411
+ }) })
412
+ ] }) }),
413
+ l.type === "text" && l.text && /* @__PURE__ */ e.jsx("div", { className: "prose max-w-none", children: /* @__PURE__ */ e.jsx("p", { children: l.text }) }),
414
+ l.type === "page-break" && /* @__PURE__ */ e.jsx("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
415
+ l.content && /* @__PURE__ */ e.jsx(ue, { schema: l.content })
416
+ ] }, w);
417
+ })),
418
+ !c.sections && u && u.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "border rounded-lg overflow-hidden", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
419
+ /* @__PURE__ */ e.jsx("thead", { className: "bg-muted", children: /* @__PURE__ */ e.jsx("tr", { children: (y = c.fields) == null ? void 0 : y.map((l, w) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-2 text-left font-medium", children: l.label || l.name }, w)) }) }),
420
+ /* @__PURE__ */ e.jsx("tbody", { children: u.map((l, w) => {
421
+ var T;
422
+ return /* @__PURE__ */ e.jsx("tr", { className: "border-t", children: (T = c.fields) == null ? void 0 : T.map((C, o) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-2", children: l[C.name] }, o)) }, w);
423
+ }) })
424
+ ] }) })
425
+ ] })
426
+ ] })
427
+ ] }) : /* @__PURE__ */ e.jsx(z, { children: /* @__PURE__ */ e.jsx(Y, { className: "p-8 text-center text-muted-foreground", children: "No report to display" }) });
428
+ }, _e = ({ schema: v }) => {
429
+ const {
430
+ report: c,
431
+ dataSources: u = [],
432
+ availableFields: d = [],
433
+ showPreview: m = !0,
434
+ onSave: N,
435
+ onCancel: S
436
+ } = v, [i, h] = W(c || {
437
+ type: "report",
438
+ title: "New Report",
439
+ fields: [],
440
+ filters: [],
441
+ groupBy: [],
442
+ sections: [],
443
+ showExportButtons: !0,
444
+ showPrintButton: !0
445
+ }), [j, f] = W(i.fields || []), [y, l] = W(i.filters || []), [w, T] = W(i.groupBy || []), [C, o] = W(i.sections || []), _ = () => {
446
+ if (d.length > 0 && j.length < d.length) {
447
+ const r = d.find(
448
+ (t) => !j.some((a) => a.name === t.name)
449
+ );
450
+ if (r) {
451
+ const t = [...j, r];
452
+ f(t), h({ ...i, fields: t });
453
+ }
454
+ }
455
+ }, k = (r) => {
456
+ const t = j.filter((a, R) => R !== r);
457
+ f(t), h({ ...i, fields: t });
458
+ }, A = (r, t) => {
459
+ const a = [...j];
460
+ a[r] = t, f(a), h({ ...i, fields: a });
461
+ }, O = () => {
462
+ var a;
463
+ const r = {
464
+ field: ((a = d[0]) == null ? void 0 : a.name) || "",
465
+ operator: "equals",
466
+ value: ""
467
+ }, t = [...y, r];
468
+ l(t), h({ ...i, filters: t });
469
+ }, $ = (r) => {
470
+ const t = y.filter((a, R) => R !== r);
471
+ l(t), h({ ...i, filters: t });
472
+ }, B = (r, t) => {
473
+ const a = [...y];
474
+ a[r] = t, l(a), h({ ...i, filters: a });
475
+ }, re = () => {
476
+ var a;
477
+ const r = {
478
+ field: ((a = d[0]) == null ? void 0 : a.name) || "",
479
+ sort: "asc"
480
+ }, t = [...w, r];
481
+ T(t), h({ ...i, groupBy: t });
482
+ }, te = (r) => {
483
+ const t = w.filter((a, R) => R !== r);
484
+ T(t), h({ ...i, groupBy: t });
485
+ }, L = (r, t) => {
486
+ const a = [...w];
487
+ a[r] = t, T(a), h({ ...i, groupBy: a });
488
+ }, M = (r) => {
489
+ const t = {
490
+ type: r,
491
+ title: `New ${r} Section`
492
+ }, a = [...C, t];
493
+ o(a), h({ ...i, sections: a });
494
+ }, ae = (r) => {
495
+ const t = C.filter((a, R) => R !== r);
496
+ o(t), h({ ...i, sections: t });
497
+ }, F = (r, t) => {
498
+ const a = [...C];
499
+ a[r] = t, o(a), h({ ...i, sections: a });
500
+ }, Z = () => {
501
+ console.log("Saving report:", i), N && alert("Report saved! (Handler: " + N + ")");
502
+ }, le = () => {
503
+ console.log("Canceling report builder");
504
+ };
505
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
506
+ /* @__PURE__ */ e.jsxs(z, { children: [
507
+ /* @__PURE__ */ e.jsxs(ee, { children: [
508
+ /* @__PURE__ */ e.jsx(se, { children: "Report Builder" }),
509
+ /* @__PURE__ */ e.jsx(de, { children: "Configure your report settings, fields, filters, and sections" })
510
+ ] }),
511
+ /* @__PURE__ */ e.jsxs(Y, { children: [
512
+ /* @__PURE__ */ e.jsxs(je, { defaultValue: "basic", className: "w-full", children: [
513
+ /* @__PURE__ */ e.jsxs(ve, { className: "grid w-full grid-cols-5", children: [
514
+ /* @__PURE__ */ e.jsxs(q, { value: "basic", children: [
515
+ /* @__PURE__ */ e.jsx(ye, { className: "h-4 w-4 mr-2" }),
516
+ "Basic"
517
+ ] }),
518
+ /* @__PURE__ */ e.jsxs(q, { value: "fields", children: [
519
+ /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4 mr-2" }),
520
+ "Fields"
521
+ ] }),
522
+ /* @__PURE__ */ e.jsxs(q, { value: "filters", children: [
523
+ /* @__PURE__ */ e.jsx(we, { className: "h-4 w-4 mr-2" }),
524
+ "Filters"
525
+ ] }),
526
+ /* @__PURE__ */ e.jsxs(q, { value: "grouping", children: [
527
+ /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4 mr-2" }),
528
+ "Group By"
529
+ ] }),
530
+ /* @__PURE__ */ e.jsxs(q, { value: "sections", children: [
531
+ /* @__PURE__ */ e.jsx(oe, { className: "h-4 w-4 mr-2" }),
532
+ "Sections"
533
+ ] })
534
+ ] }),
535
+ /* @__PURE__ */ e.jsx(H, { value: "basic", className: "space-y-4 mt-4", children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
536
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
537
+ /* @__PURE__ */ e.jsx(x, { htmlFor: "report-title", children: "Report Title" }),
538
+ /* @__PURE__ */ e.jsx(
539
+ D,
540
+ {
541
+ id: "report-title",
542
+ value: i.title || "",
543
+ onChange: (r) => h({ ...i, title: r.target.value }),
544
+ placeholder: "Enter report title"
545
+ }
546
+ )
547
+ ] }),
548
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
549
+ /* @__PURE__ */ e.jsx(x, { htmlFor: "report-description", children: "Description" }),
550
+ /* @__PURE__ */ e.jsx(
551
+ D,
552
+ {
553
+ id: "report-description",
554
+ value: i.description || "",
555
+ onChange: (r) => h({ ...i, description: r.target.value }),
556
+ placeholder: "Enter report description"
557
+ }
558
+ )
559
+ ] }),
560
+ u.length > 0 && /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
561
+ /* @__PURE__ */ e.jsx(x, { children: "Data Source" }),
562
+ /* @__PURE__ */ e.jsxs("select", { className: "w-full border rounded-md p-2", children: [
563
+ /* @__PURE__ */ e.jsx("option", { value: "", children: "Select a data source" }),
564
+ u.map((r, t) => /* @__PURE__ */ e.jsxs("option", { value: t, children: [
565
+ "Data Source ",
566
+ t + 1
567
+ ] }, t))
568
+ ] })
569
+ ] }),
570
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
571
+ /* @__PURE__ */ e.jsx(x, { children: "Export Options" }),
572
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-4", children: [
573
+ /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2", children: [
574
+ /* @__PURE__ */ e.jsx(
575
+ "input",
576
+ {
577
+ type: "checkbox",
578
+ checked: i.showExportButtons || !1,
579
+ onChange: (r) => h({ ...i, showExportButtons: r.target.checked })
580
+ }
581
+ ),
582
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "Show Export Buttons" })
583
+ ] }),
584
+ /* @__PURE__ */ e.jsxs("label", { className: "flex items-center gap-2", children: [
585
+ /* @__PURE__ */ e.jsx(
586
+ "input",
587
+ {
588
+ type: "checkbox",
589
+ checked: i.showPrintButton || !1,
590
+ onChange: (r) => h({ ...i, showPrintButton: r.target.checked })
591
+ }
592
+ ),
593
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "Show Print Button" })
594
+ ] })
595
+ ] })
596
+ ] }),
597
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
598
+ /* @__PURE__ */ e.jsx(x, { htmlFor: "export-format", children: "Default Export Format" }),
599
+ /* @__PURE__ */ e.jsxs(
600
+ "select",
601
+ {
602
+ id: "export-format",
603
+ className: "w-full border rounded-md p-2",
604
+ value: i.defaultExportFormat || "pdf",
605
+ onChange: (r) => h({ ...i, defaultExportFormat: r.target.value }),
606
+ children: [
607
+ /* @__PURE__ */ e.jsx("option", { value: "pdf", children: "PDF" }),
608
+ /* @__PURE__ */ e.jsx("option", { value: "excel", children: "Excel" }),
609
+ /* @__PURE__ */ e.jsx("option", { value: "csv", children: "CSV" }),
610
+ /* @__PURE__ */ e.jsx("option", { value: "json", children: "JSON" }),
611
+ /* @__PURE__ */ e.jsx("option", { value: "html", children: "HTML" })
612
+ ]
613
+ }
614
+ )
615
+ ] })
616
+ ] }) }),
617
+ /* @__PURE__ */ e.jsxs(H, { value: "fields", className: "space-y-4 mt-4", children: [
618
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
619
+ /* @__PURE__ */ e.jsx(x, { children: "Report Fields" }),
620
+ /* @__PURE__ */ e.jsxs(
621
+ E,
622
+ {
623
+ size: "sm",
624
+ variant: "outline",
625
+ onClick: _,
626
+ disabled: j.length >= d.length,
627
+ children: [
628
+ /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
629
+ "Add Field"
630
+ ]
631
+ }
632
+ )
633
+ ] }),
634
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
635
+ j.map((r, t) => /* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-4 gap-2", children: [
636
+ /* @__PURE__ */ e.jsxs("div", { children: [
637
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Field Name" }),
638
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm font-medium", children: r.name })
639
+ ] }),
640
+ /* @__PURE__ */ e.jsxs("div", { children: [
641
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Label" }),
642
+ /* @__PURE__ */ e.jsx(
643
+ D,
644
+ {
645
+ className: "h-8 text-sm",
646
+ value: r.label || r.name,
647
+ onChange: (a) => A(t, { ...r, label: a.target.value })
648
+ }
649
+ )
650
+ ] }),
651
+ /* @__PURE__ */ e.jsxs("div", { children: [
652
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Aggregation" }),
653
+ /* @__PURE__ */ e.jsxs(
654
+ "select",
655
+ {
656
+ className: "w-full border rounded-md h-8 text-sm px-2",
657
+ value: r.aggregation || "",
658
+ onChange: (a) => A(t, { ...r, aggregation: a.target.value }),
659
+ children: [
660
+ /* @__PURE__ */ e.jsx("option", { value: "", children: "None" }),
661
+ /* @__PURE__ */ e.jsx("option", { value: "sum", children: "Sum" }),
662
+ /* @__PURE__ */ e.jsx("option", { value: "count", children: "Count" }),
663
+ /* @__PURE__ */ e.jsx("option", { value: "avg", children: "Average" }),
664
+ /* @__PURE__ */ e.jsx("option", { value: "min", children: "Min" }),
665
+ /* @__PURE__ */ e.jsx("option", { value: "max", children: "Max" })
666
+ ]
667
+ }
668
+ )
669
+ ] }),
670
+ /* @__PURE__ */ e.jsx("div", { className: "flex items-end justify-end", children: /* @__PURE__ */ e.jsx(
671
+ E,
672
+ {
673
+ size: "sm",
674
+ variant: "ghost",
675
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50",
676
+ onClick: () => k(t),
677
+ children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
678
+ }
679
+ ) })
680
+ ] }) }, t)),
681
+ j.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: 'No fields selected. Click "Add Field" to begin.' })
682
+ ] })
683
+ ] }),
684
+ /* @__PURE__ */ e.jsxs(H, { value: "filters", className: "space-y-4 mt-4", children: [
685
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
686
+ /* @__PURE__ */ e.jsx(x, { children: "Report Filters" }),
687
+ /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: O, children: [
688
+ /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
689
+ "Add Filter"
690
+ ] })
691
+ ] }),
692
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
693
+ y.map((r, t) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
694
+ /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-3 gap-2", children: [
695
+ /* @__PURE__ */ e.jsxs("div", { children: [
696
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Field" }),
697
+ /* @__PURE__ */ e.jsx(
698
+ "select",
699
+ {
700
+ className: "w-full border rounded-md h-8 text-sm px-2",
701
+ value: r.field,
702
+ onChange: (a) => B(t, { ...r, field: a.target.value }),
703
+ children: d.map((a, R) => /* @__PURE__ */ e.jsx("option", { value: a.name, children: a.label || a.name }, R))
704
+ }
705
+ )
706
+ ] }),
707
+ /* @__PURE__ */ e.jsxs("div", { children: [
708
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Operator" }),
709
+ /* @__PURE__ */ e.jsxs(
710
+ "select",
711
+ {
712
+ className: "w-full border rounded-md h-8 text-sm px-2",
713
+ value: r.operator,
714
+ onChange: (a) => B(t, { ...r, operator: a.target.value }),
715
+ children: [
716
+ /* @__PURE__ */ e.jsx("option", { value: "equals", children: "Equals" }),
717
+ /* @__PURE__ */ e.jsx("option", { value: "contains", children: "Contains" }),
718
+ /* @__PURE__ */ e.jsx("option", { value: "gt", children: "Greater Than" }),
719
+ /* @__PURE__ */ e.jsx("option", { value: "lt", children: "Less Than" }),
720
+ /* @__PURE__ */ e.jsx("option", { value: "between", children: "Between" })
721
+ ]
722
+ }
723
+ )
724
+ ] }),
725
+ /* @__PURE__ */ e.jsxs("div", { children: [
726
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Value" }),
727
+ /* @__PURE__ */ e.jsx(
728
+ D,
729
+ {
730
+ className: "h-8 text-sm",
731
+ value: String(r.value),
732
+ onChange: (a) => B(t, { ...r, value: a.target.value })
733
+ }
734
+ )
735
+ ] })
736
+ ] }),
737
+ /* @__PURE__ */ e.jsx(
738
+ E,
739
+ {
740
+ size: "sm",
741
+ variant: "ghost",
742
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
743
+ onClick: () => $(t),
744
+ children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
745
+ }
746
+ )
747
+ ] }, t)),
748
+ y.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No filters defined." })
749
+ ] })
750
+ ] }),
751
+ /* @__PURE__ */ e.jsxs(H, { value: "grouping", className: "space-y-4 mt-4", children: [
752
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
753
+ /* @__PURE__ */ e.jsx(x, { children: "Grouping Rules" }),
754
+ /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: re, children: [
755
+ /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
756
+ "Add Group"
757
+ ] })
758
+ ] }),
759
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
760
+ w.map((r, t) => /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 p-3 border rounded-lg", children: [
761
+ /* @__PURE__ */ e.jsxs("div", { className: "flex-1 grid grid-cols-2 gap-2", children: [
762
+ /* @__PURE__ */ e.jsxs("div", { children: [
763
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Field" }),
764
+ /* @__PURE__ */ e.jsx(
765
+ "select",
766
+ {
767
+ className: "w-full border rounded-md h-8 text-sm px-2",
768
+ value: r.field,
769
+ onChange: (a) => L(t, { ...r, field: a.target.value }),
770
+ children: d.map((a, R) => /* @__PURE__ */ e.jsx("option", { value: a.name, children: a.label || a.name }, R))
771
+ }
772
+ )
773
+ ] }),
774
+ /* @__PURE__ */ e.jsxs("div", { children: [
775
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Sort Order" }),
776
+ /* @__PURE__ */ e.jsxs(
777
+ "select",
778
+ {
779
+ className: "w-full border rounded-md h-8 text-sm px-2",
780
+ value: r.sort || "asc",
781
+ onChange: (a) => L(t, { ...r, sort: a.target.value }),
782
+ children: [
783
+ /* @__PURE__ */ e.jsx("option", { value: "asc", children: "Ascending" }),
784
+ /* @__PURE__ */ e.jsx("option", { value: "desc", children: "Descending" })
785
+ ]
786
+ }
787
+ )
788
+ ] })
789
+ ] }),
790
+ /* @__PURE__ */ e.jsx(
791
+ E,
792
+ {
793
+ size: "sm",
794
+ variant: "ghost",
795
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50 self-end",
796
+ onClick: () => te(t),
797
+ children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
798
+ }
799
+ )
800
+ ] }, t)),
801
+ w.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No grouping rules applied." })
802
+ ] })
803
+ ] }),
804
+ /* @__PURE__ */ e.jsxs(H, { value: "sections", className: "space-y-4 mt-4", children: [
805
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
806
+ /* @__PURE__ */ e.jsx(x, { children: "Report Sections" }),
807
+ /* @__PURE__ */ e.jsxs("div", { className: "flex gap-2", children: [
808
+ /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => M("header"), children: [
809
+ /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
810
+ "Header"
811
+ ] }),
812
+ /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => M("chart"), children: [
813
+ /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
814
+ "Chart"
815
+ ] }),
816
+ /* @__PURE__ */ e.jsxs(E, { size: "sm", variant: "outline", onClick: () => M("table"), children: [
817
+ /* @__PURE__ */ e.jsx(I, { className: "h-4 w-4 mr-2" }),
818
+ "Table"
819
+ ] })
820
+ ] })
821
+ ] }),
822
+ /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
823
+ C.map((r, t) => {
824
+ var a, R, V, U;
825
+ return /* @__PURE__ */ e.jsxs("div", { className: "p-3 border rounded-lg space-y-2", children: [
826
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between", children: [
827
+ /* @__PURE__ */ e.jsxs("div", { className: "font-medium flex items-center gap-2", children: [
828
+ /* @__PURE__ */ e.jsx("div", { className: "text-xs bg-muted px-2 py-0.5 rounded uppercase", children: r.type }),
829
+ r.title
830
+ ] }),
831
+ /* @__PURE__ */ e.jsx(
832
+ E,
833
+ {
834
+ size: "sm",
835
+ variant: "ghost",
836
+ className: "text-red-500 hover:text-red-700 hover:bg-red-50",
837
+ onClick: () => ae(t),
838
+ children: /* @__PURE__ */ e.jsx(Q, { className: "h-4 w-4" })
839
+ }
840
+ )
841
+ ] }),
842
+ /* @__PURE__ */ e.jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
843
+ /* @__PURE__ */ e.jsxs("div", { children: [
844
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Title" }),
845
+ /* @__PURE__ */ e.jsx(
846
+ D,
847
+ {
848
+ className: "h-8 text-sm",
849
+ value: r.title || "",
850
+ onChange: (s) => F(t, { ...r, title: s.target.value })
851
+ }
852
+ )
853
+ ] }),
854
+ r.type === "text" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
855
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Content" }),
856
+ /* @__PURE__ */ e.jsx(
857
+ D,
858
+ {
859
+ className: "h-8 text-sm",
860
+ value: r.text || "",
861
+ onChange: (s) => F(t, { ...r, text: s.target.value })
862
+ }
863
+ )
864
+ ] }),
865
+ r.type === "chart" && /* @__PURE__ */ e.jsxs("div", { className: "col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded", children: [
866
+ /* @__PURE__ */ e.jsx("div", { className: "col-span-2", children: /* @__PURE__ */ e.jsx(x, { className: "text-xs font-semibold", children: "Chart Configuration" }) }),
867
+ /* @__PURE__ */ e.jsxs("div", { children: [
868
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Chart Type" }),
869
+ /* @__PURE__ */ e.jsxs(
870
+ "select",
871
+ {
872
+ className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
873
+ value: ((a = r.chart) == null ? void 0 : a.chartType) || "bar",
874
+ onChange: (s) => F(t, {
875
+ ...r,
876
+ chart: { ...r.chart, type: "chart", chartType: s.target.value }
877
+ }),
878
+ children: [
879
+ /* @__PURE__ */ e.jsx("option", { value: "bar", children: "Bar" }),
880
+ /* @__PURE__ */ e.jsx("option", { value: "line", children: "Line" }),
881
+ /* @__PURE__ */ e.jsx("option", { value: "area", children: "Area" }),
882
+ /* @__PURE__ */ e.jsx("option", { value: "pie", children: "Pie" })
883
+ ]
884
+ }
885
+ )
886
+ ] }),
887
+ /* @__PURE__ */ e.jsxs("div", { children: [
888
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "X-Axis Field" }),
889
+ /* @__PURE__ */ e.jsxs(
890
+ "select",
891
+ {
892
+ className: "flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
893
+ value: ((R = r.chart) == null ? void 0 : R.xAxisField) || "",
894
+ onChange: (s) => F(t, {
895
+ ...r,
896
+ chart: { ...r.chart, type: "chart", xAxisField: s.target.value }
897
+ }),
898
+ children: [
899
+ /* @__PURE__ */ e.jsx("option", { value: "", children: "Select Field..." }),
900
+ d.map((s) => /* @__PURE__ */ e.jsx("option", { value: s.name, children: s.label || s.name }, s.name)),
901
+ d.length === 0 && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
902
+ /* @__PURE__ */ e.jsx("option", { value: "name", children: "Name" }),
903
+ /* @__PURE__ */ e.jsx("option", { value: "month", children: "Month" })
904
+ ] })
905
+ ]
906
+ }
907
+ )
908
+ ] }),
909
+ /* @__PURE__ */ e.jsxs("div", { className: "col-span-2", children: [
910
+ /* @__PURE__ */ e.jsx(x, { className: "text-xs", children: "Y-Axis Fields (comma separated)" }),
911
+ /* @__PURE__ */ e.jsx(
912
+ D,
913
+ {
914
+ className: "h-8 text-sm",
915
+ placeholder: "e.g. value, count",
916
+ value: ((U = (V = r.chart) == null ? void 0 : V.yAxisFields) == null ? void 0 : U.join(", ")) || "",
917
+ onChange: (s) => F(t, {
918
+ ...r,
919
+ chart: {
920
+ ...r.chart,
921
+ type: "chart",
922
+ yAxisFields: s.target.value.split(",").map((n) => n.trim()).filter(Boolean)
923
+ }
924
+ })
925
+ }
926
+ )
927
+ ] })
928
+ ] })
929
+ ] })
930
+ ] }, t);
931
+ }),
932
+ C.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg", children: "No customized sections. The default report layout will be used." })
933
+ ] })
934
+ ] })
935
+ ] }),
936
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-end gap-2 mt-6 pt-4 border-t", children: [
937
+ /* @__PURE__ */ e.jsx(E, { variant: "outline", onClick: le, children: "Cancel" }),
938
+ /* @__PURE__ */ e.jsxs(E, { onClick: Z, children: [
939
+ /* @__PURE__ */ e.jsx(Re, { className: "h-4 w-4 mr-2" }),
940
+ "Save Report"
941
+ ] })
942
+ ] })
943
+ ] })
944
+ ] }),
945
+ m && /* @__PURE__ */ e.jsxs(z, { className: "mt-8 border-2 border-blue-100", children: [
946
+ /* @__PURE__ */ e.jsx(ee, { className: "bg-blue-50/50", children: /* @__PURE__ */ e.jsx(se, { className: "text-blue-900 text-sm uppercase tracking-wide", children: "Live Preview" }) }),
947
+ /* @__PURE__ */ e.jsx(Y, { className: "pt-6", children: /* @__PURE__ */ e.jsx(
948
+ xe,
949
+ {
950
+ schema: {
951
+ type: "report-viewer",
952
+ report: {
953
+ ...i,
954
+ fields: j,
955
+ filters: y,
956
+ groupBy: w,
957
+ sections: C
958
+ },
959
+ // Mock data for preview
960
+ data: [
961
+ { id: 1, name: "Sample Item A", value: 100, status: "New" },
962
+ { id: 2, name: "Sample Item B", value: 250, status: "Active" },
963
+ { id: 3, name: "Sample Item C", value: 75, status: "Closed" }
964
+ ]
965
+ }
966
+ }
967
+ ) })
968
+ ] })
969
+ ] });
970
+ };
971
+ P.register(
972
+ "report",
973
+ Te,
974
+ {
975
+ label: "Report",
976
+ category: "Report",
977
+ inputs: [
978
+ { name: "title", type: "string", label: "Title" },
979
+ { name: "description", type: "string", label: "Description" },
980
+ { name: "chart", type: "code", label: "Chart Configuration" }
981
+ ]
982
+ }
983
+ );
984
+ P.register(
985
+ "report-viewer",
986
+ xe,
987
+ {
988
+ label: "Report Viewer",
989
+ category: "Report",
990
+ inputs: [
991
+ { name: "report", type: "code", label: "Report Definition" },
992
+ { name: "showToolbar", type: "boolean", label: "Show Toolbar" }
993
+ ]
994
+ }
995
+ );
996
+ P.register(
997
+ "report-builder",
998
+ _e,
999
+ {
1000
+ label: "Report Builder",
1001
+ category: "Report",
1002
+ inputs: [
1003
+ { name: "report", type: "code", label: "Initial Report" }
1004
+ ]
1005
+ }
1006
+ );
1007
+ export {
1008
+ _e as ReportBuilder,
1009
+ Te as ReportRenderer,
1010
+ xe as ReportViewer
1011
+ };
@@ -0,0 +1,22 @@
1
+ (function(R,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("@object-ui/core"),require("react"),require("@object-ui/components"),require("@object-ui/react"),require("lucide-react")):typeof define=="function"&&define.amd?define(["exports","@object-ui/core","react","@object-ui/components","@object-ui/react","lucide-react"],S):(R=typeof globalThis<"u"?globalThis:R||self,S(R.ObjectUIPluginReport={},R.ObjectUICore,R.React,R.ObjectUIComponents,R.ObjectUIReact,R.lucideReact))})(this,function(R,S,I,s,se,g){"use strict";var $={exports:{}},z={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var te;function ie(){if(te)return z;te=1;var v=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function h(u,m,y){var A=null;if(y!==void 0&&(A=""+y),m.key!==void 0&&(A=""+m.key),"key"in m){y={};for(var d in m)d!=="key"&&(y[d]=m[d])}else y=m;return m=y.ref,{$$typeof:v,type:u,key:A,ref:m!==void 0?m:null,props:y}}return z.Fragment=o,z.jsx=h,z.jsxs=h,z}var Y={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var ae;function de(){return ae||(ae=1,process.env.NODE_ENV!=="production"&&function(){function v(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===K?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case c:return"Fragment";case F:return"Profiler";case k:return"StrictMode";case L:return"Suspense";case X:return"SuspenseList";case U:return"Activity"}if(typeof r=="object")switch(typeof r.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),r.$$typeof){case E:return"Portal";case B:return r.displayName||"Context";case P:return(r._context.displayName||"Context")+".Consumer";case M:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case Z:return i=r.displayName||null,i!==null?i:v(r.type)||"Memo";case D:i=r._payload,r=r._init;try{return v(r(i))}catch{}}return null}function o(r){return""+r}function h(r){try{o(r);var i=!1}catch{i=!0}if(i){i=console;var p=i.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&r[Symbol.toStringTag]||r.constructor.name||"Object";return p.call(i,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),o(r)}}function u(r){if(r===c)return"<>";if(typeof r=="object"&&r!==null&&r.$$typeof===D)return"<...>";try{var i=v(r);return i?"<"+i+">":"<...>"}catch{return"<...>"}}function m(){var r=O.A;return r===null?null:r.getOwner()}function y(){return Error("react-stack-top-frame")}function A(r){if(H.call(r,"key")){var i=Object.getOwnPropertyDescriptor(r,"key").get;if(i&&i.isReactWarning)return!1}return r.key!==void 0}function d(r,i){function p(){a||(a=!0,console.error("%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)",i))}p.isReactWarning=!0,Object.defineProperty(r,"key",{get:p,configurable:!0})}function x(){var r=v(this.type);return l[r]||(l[r]=!0,console.error("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.")),r=this.props.ref,r!==void 0?r:null}function j(r,i,p,b,q,ee){var N=p.ref;return r={$$typeof:_,type:r,key:i,props:p,_owner:b},(N!==void 0?N:null)!==null?Object.defineProperty(r,"ref",{enumerable:!1,get:x}):Object.defineProperty(r,"ref",{enumerable:!1,value:null}),r._store={},Object.defineProperty(r._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(r,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(r,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:q}),Object.defineProperty(r,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(r.props),Object.freeze(r)),r}function f(r,i,p,b,q,ee){var N=i.children;if(N!==void 0)if(b)if(Q(N)){for(b=0;b<N.length;b++)w(N[b]);Object.freeze&&Object.freeze(N)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else w(N);if(H.call(i,"key")){N=v(r);var G=Object.keys(i).filter(function(ce){return ce!=="key"});b=0<G.length?"{key: someKey, "+G.join(": ..., ")+": ...}":"{key: someKey}",W[N+b]||(G=0<G.length?"{"+G.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,b,N,G,N),W[N+b]=!0)}if(N=null,p!==void 0&&(h(p),N=""+p),A(i)&&(h(i.key),N=""+i.key),"key"in i){p={};for(var re in i)re!=="key"&&(p[re]=i[re])}else p=i;return N&&d(p,typeof r=="function"?r.displayName||r.name||"Unknown":r),j(r,N,p,m(),q,ee)}function w(r){n(r)?r._store&&(r._store.validated=1):typeof r=="object"&&r!==null&&r.$$typeof===D&&(r._payload.status==="fulfilled"?n(r._payload.value)&&r._payload.value._store&&(r._payload.value._store.validated=1):r._store&&(r._store.validated=1))}function n(r){return typeof r=="object"&&r!==null&&r.$$typeof===_}var C=I,_=Symbol.for("react.transitional.element"),E=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),F=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),B=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),X=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),O=C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H=Object.prototype.hasOwnProperty,Q=Array.isArray,t=console.createTask?console.createTask:function(){return null};C={react_stack_bottom_frame:function(r){return r()}};var a,l={},T=C.react_stack_bottom_frame.bind(C,y)(),V=t(u(y)),W={};Y.Fragment=c,Y.jsx=function(r,i,p){var b=1e4>O.recentlyCreatedOwnerStacks++;return f(r,i,p,!1,b?Error("react-stack-top-frame"):T,b?t(u(r)):V)},Y.jsxs=function(r,i,p){var b=1e4>O.recentlyCreatedOwnerStacks++;return f(r,i,p,!0,b?Error("react-stack-top-frame"):T,b?t(u(r)):V)}}()),Y}process.env.NODE_ENV==="production"?$.exports=ie():$.exports=de();var e=$.exports;const le=({schema:v})=>{var x;const{title:o,description:h,data:u,columns:m}=v;(x=v.chart)!=null&&x.type;const y=!!v.chart,d=!(process.env.NODE_ENV==="test");return e.jsxs(s.Card,{className:`h-full flex flex-col ${v.className||""}`,children:[e.jsxs(s.CardHeader,{children:[o&&e.jsx(s.CardTitle,{children:o}),h&&e.jsx(s.CardDescription,{children:h})]}),e.jsxs(s.CardContent,{className:"flex-1 overflow-auto space-y-4",children:[y&&(()=>{var w;const j=(w=v.chart)==null?void 0:w.type;let f=j?S.ComponentRegistry.get(j):null;return f||(f=S.ComponentRegistry.get("chart")),f?e.jsx("div",{className:"min-h-[300px] border rounded-md p-4 bg-white/50",children:e.jsx(f,{schema:{...v.chart,data:v.chart.data||u}})}):e.jsxs("div",{className:"min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center",children:["Unknown component type: ",j||"chart"]})})(),u&&u.length>0&&e.jsx("div",{className:"border rounded-md",children:(()=>{const j=d?S.ComponentRegistry.get("aggrid")||S.ComponentRegistry.get("table"):null;return j?e.jsx(j,{schema:{type:"aggrid",rowData:u,columnDefs:m,domLayout:"autoHeight"}}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm text-left",children:[e.jsx("thead",{className:"text-xs uppercase bg-gray-50",children:e.jsx("tr",{children:m==null?void 0:m.map(f=>e.jsx("th",{className:"px-6 py-3",children:f.headerName||f.label||f.field},f.field))})}),e.jsx("tbody",{children:u.map((f,w)=>e.jsx("tr",{className:"bg-white border-b",children:m==null?void 0:m.map(n=>e.jsx("td",{className:"px-6 py-4",children:f[n.field]},n.field))},w))})]})})})()})]})]})},J=({schema:v})=>{var f,w;const{report:o,data:h,showToolbar:u=!0,allowExport:m=!0,allowPrint:y=!0,loading:A=!1}=v,d=n=>{console.log("Export report as:",n),alert(`Export to ${n.toUpperCase()} - Feature coming soon!`)},x=()=>{console.log("Print report"),window.print()},j=()=>{console.log("Refresh report")};return o?e.jsxs("div",{className:"space-y-4",children:[u&&e.jsxs("div",{className:"flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:o.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[o.refreshInterval&&e.jsxs(s.Button,{variant:"outline",size:"sm",onClick:j,children:[e.jsx(g.RefreshCw,{className:"h-4 w-4 mr-2"}),"Refresh"]}),y&&e.jsxs(s.Button,{variant:"outline",size:"sm",onClick:x,children:[e.jsx(g.Printer,{className:"h-4 w-4 mr-2"}),"Print"]}),m&&o.showExportButtons&&e.jsx(e.Fragment,{children:e.jsxs(s.Button,{variant:"outline",size:"sm",onClick:()=>d(o.defaultExportFormat||"pdf"),children:[e.jsx(g.Download,{className:"h-4 w-4 mr-2"}),"Export"]})})]})]}),e.jsxs(s.Card,{children:[e.jsxs(s.CardHeader,{children:[!u&&o.title&&e.jsx(s.CardTitle,{children:o.title}),!u&&o.description&&e.jsx(s.CardDescription,{children:o.description})]}),e.jsxs(s.CardContent,{className:"space-y-6",children:[A&&e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading report data..."}),!A&&((f=o.sections)==null?void 0:f.map((n,C)=>{var _,E;return n.visible===!1?null:e.jsxs("div",{className:"space-y-2",children:[n.title&&e.jsx("h3",{className:"text-lg font-semibold border-b pb-2",children:n.title}),n.type==="header"&&n.title&&e.jsx("div",{className:"text-2xl font-bold py-4",children:n.title}),n.type==="summary"&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:(_=o.fields)==null?void 0:_.filter(c=>c.showInSummary).map((c,k)=>e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"p-4",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:c.label||c.name}),e.jsxs("div",{className:"text-2xl font-bold",children:[c.aggregation==="count"&&(h==null?void 0:h.length),c.aggregation==="sum"&&(h==null?void 0:h.reduce((F,P)=>F+(P[c.name]||0),0))]})]})},k))}),n.type==="chart"&&n.chart&&e.jsx("div",{className:"min-h-[300px]",children:(()=>{let c=n.chart.type;const k=!!n.chart.chartType;!c&&k&&(c="chart"),c&&!!S.ComponentRegistry.get(c)||(c="chart");const B=c==="chart"?{xAxisKey:n.chart.xAxisKey||n.chart.xAxisField||"name",series:n.chart.series||(n.chart.yAxisFields?n.chart.yAxisFields.map(L=>({dataKey:L})):[]),chartType:n.chart.chartType||"bar"}:{},M={...n.chart,type:c,...B,data:h||n.chart.data,className:n.chart.className||"w-full h-[350px]"};return e.jsx(se.SchemaRenderer,{schema:M})})()}),n.type==="table"&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted",children:e.jsx("tr",{children:(E=n.columns)==null?void 0:E.map((c,k)=>e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:c.label||c.name},k))})}),e.jsx("tbody",{children:h==null?void 0:h.map((c,k)=>{var F;return e.jsx("tr",{className:"border-t",children:(F=n.columns)==null?void 0:F.map((P,B)=>e.jsx("td",{className:"px-4 py-2",children:c[P.name]},B))},k)})})]})}),n.type==="text"&&n.text&&e.jsx("div",{className:"prose max-w-none",children:e.jsx("p",{children:n.text})}),n.type==="page-break"&&e.jsx("div",{className:"border-t-2 border-dashed my-8 print:page-break-after-always"}),n.content&&e.jsx(se.SchemaRenderer,{schema:n.content})]},C)})),!o.sections&&h&&h.length>0&&e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted",children:e.jsx("tr",{children:(w=o.fields)==null?void 0:w.map((n,C)=>e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:n.label||n.name},C))})}),e.jsx("tbody",{children:h.map((n,C)=>{var _;return e.jsx("tr",{className:"border-t",children:(_=o.fields)==null?void 0:_.map((E,c)=>e.jsx("td",{className:"px-4 py-2",children:n[E.name]},c))},C)})})]})})]})]})]}):e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-8 text-center text-muted-foreground",children:"No report to display"})})},ne=({schema:v})=>{const{report:o,dataSources:h=[],availableFields:u=[],showPreview:m=!0,onSave:y,onCancel:A}=v,[d,x]=I.useState(o||{type:"report",title:"New Report",fields:[],filters:[],groupBy:[],sections:[],showExportButtons:!0,showPrintButton:!0}),[j,f]=I.useState(d.fields||[]),[w,n]=I.useState(d.filters||[]),[C,_]=I.useState(d.groupBy||[]),[E,c]=I.useState(d.sections||[]),k=()=>{if(u.length>0&&j.length<u.length){const t=u.find(a=>!j.some(l=>l.name===a.name));if(t){const a=[...j,t];f(a),x({...d,fields:a})}}},F=t=>{const a=j.filter((l,T)=>T!==t);f(a),x({...d,fields:a})},P=(t,a)=>{const l=[...j];l[t]=a,f(l),x({...d,fields:l})},B=()=>{var l;const t={field:((l=u[0])==null?void 0:l.name)||"",operator:"equals",value:""},a=[...w,t];n(a),x({...d,filters:a})},M=t=>{const a=w.filter((l,T)=>T!==t);n(a),x({...d,filters:a})},L=(t,a)=>{const l=[...w];l[t]=a,n(l),x({...d,filters:l})},X=()=>{var l;const t={field:((l=u[0])==null?void 0:l.name)||"",sort:"asc"},a=[...C,t];_(a),x({...d,groupBy:a})},Z=t=>{const a=C.filter((l,T)=>T!==t);_(a),x({...d,groupBy:a})},D=(t,a)=>{const l=[...C];l[t]=a,_(l),x({...d,groupBy:l})},U=t=>{const a={type:t,title:`New ${t} Section`},l=[...E,a];c(l),x({...d,sections:l})},K=t=>{const a=E.filter((l,T)=>T!==t);c(a),x({...d,sections:a})},O=(t,a)=>{const l=[...E];l[t]=a,c(l),x({...d,sections:l})},H=()=>{console.log("Saving report:",d),y&&alert("Report saved! (Handler: "+y+")")},Q=()=>{console.log("Canceling report builder")};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(s.Card,{children:[e.jsxs(s.CardHeader,{children:[e.jsx(s.CardTitle,{children:"Report Builder"}),e.jsx(s.CardDescription,{children:"Configure your report settings, fields, filters, and sections"})]}),e.jsxs(s.CardContent,{children:[e.jsxs(s.Tabs,{defaultValue:"basic",className:"w-full",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-5",children:[e.jsxs(s.TabsTrigger,{value:"basic",children:[e.jsx(g.Settings,{className:"h-4 w-4 mr-2"}),"Basic"]}),e.jsxs(s.TabsTrigger,{value:"fields",children:[e.jsx(g.Layers,{className:"h-4 w-4 mr-2"}),"Fields"]}),e.jsxs(s.TabsTrigger,{value:"filters",children:[e.jsx(g.Filter,{className:"h-4 w-4 mr-2"}),"Filters"]}),e.jsxs(s.TabsTrigger,{value:"grouping",children:[e.jsx(g.Layers,{className:"h-4 w-4 mr-2"}),"Group By"]}),e.jsxs(s.TabsTrigger,{value:"sections",children:[e.jsx(g.Layers,{className:"h-4 w-4 mr-2"}),"Sections"]})]}),e.jsx(s.TabsContent,{value:"basic",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"report-title",children:"Report Title"}),e.jsx(s.Input,{id:"report-title",value:d.title||"",onChange:t=>x({...d,title:t.target.value}),placeholder:"Enter report title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"report-description",children:"Description"}),e.jsx(s.Input,{id:"report-description",value:d.description||"",onChange:t=>x({...d,description:t.target.value}),placeholder:"Enter report description"})]}),h.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Data Source"}),e.jsxs("select",{className:"w-full border rounded-md p-2",children:[e.jsx("option",{value:"",children:"Select a data source"}),h.map((t,a)=>e.jsxs("option",{value:a,children:["Data Source ",a+1]},a))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{children:"Export Options"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:d.showExportButtons||!1,onChange:t=>x({...d,showExportButtons:t.target.checked})}),e.jsx("span",{className:"text-sm",children:"Show Export Buttons"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:d.showPrintButton||!1,onChange:t=>x({...d,showPrintButton:t.target.checked})}),e.jsx("span",{className:"text-sm",children:"Show Print Button"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"export-format",children:"Default Export Format"}),e.jsxs("select",{id:"export-format",className:"w-full border rounded-md p-2",value:d.defaultExportFormat||"pdf",onChange:t=>x({...d,defaultExportFormat:t.target.value}),children:[e.jsx("option",{value:"pdf",children:"PDF"}),e.jsx("option",{value:"excel",children:"Excel"}),e.jsx("option",{value:"csv",children:"CSV"}),e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"html",children:"HTML"})]})]})]})}),e.jsxs(s.TabsContent,{value:"fields",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{children:"Report Fields"}),e.jsxs(s.Button,{size:"sm",variant:"outline",onClick:k,disabled:j.length>=u.length,children:[e.jsx(g.Plus,{className:"h-4 w-4 mr-2"}),"Add Field"]})]}),e.jsxs("div",{className:"space-y-2",children:[j.map((t,a)=>e.jsx("div",{className:"flex items-center gap-2 p-3 border rounded-lg",children:e.jsxs("div",{className:"flex-1 grid grid-cols-4 gap-2",children:[e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Field Name"}),e.jsx("div",{className:"text-sm font-medium",children:t.name})]}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Label"}),e.jsx(s.Input,{className:"h-8 text-sm",value:t.label||t.name,onChange:l=>P(a,{...t,label:l.target.value})})]}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Aggregation"}),e.jsxs("select",{className:"w-full border rounded-md h-8 text-sm px-2",value:t.aggregation||"",onChange:l=>P(a,{...t,aggregation:l.target.value}),children:[e.jsx("option",{value:"",children:"None"}),e.jsx("option",{value:"sum",children:"Sum"}),e.jsx("option",{value:"count",children:"Count"}),e.jsx("option",{value:"avg",children:"Average"}),e.jsx("option",{value:"min",children:"Min"}),e.jsx("option",{value:"max",children:"Max"})]})]}),e.jsx("div",{className:"flex items-end justify-end",children:e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>F(a),children:e.jsx(g.Trash2,{className:"h-4 w-4"})})})]})},a)),j.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",children:'No fields selected. Click "Add Field" to begin.'})]})]}),e.jsxs(s.TabsContent,{value:"filters",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{children:"Report Filters"}),e.jsxs(s.Button,{size:"sm",variant:"outline",onClick:B,children:[e.jsx(g.Plus,{className:"h-4 w-4 mr-2"}),"Add Filter"]})]}),e.jsxs("div",{className:"space-y-2",children:[w.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-3 gap-2",children:[e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Field"}),e.jsx("select",{className:"w-full border rounded-md h-8 text-sm px-2",value:t.field,onChange:l=>L(a,{...t,field:l.target.value}),children:u.map((l,T)=>e.jsx("option",{value:l.name,children:l.label||l.name},T))})]}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Operator"}),e.jsxs("select",{className:"w-full border rounded-md h-8 text-sm px-2",value:t.operator,onChange:l=>L(a,{...t,operator:l.target.value}),children:[e.jsx("option",{value:"equals",children:"Equals"}),e.jsx("option",{value:"contains",children:"Contains"}),e.jsx("option",{value:"gt",children:"Greater Than"}),e.jsx("option",{value:"lt",children:"Less Than"}),e.jsx("option",{value:"between",children:"Between"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Value"}),e.jsx(s.Input,{className:"h-8 text-sm",value:String(t.value),onChange:l=>L(a,{...t,value:l.target.value})})]})]}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-red-500 hover:text-red-700 hover:bg-red-50 self-end",onClick:()=>M(a),children:e.jsx(g.Trash2,{className:"h-4 w-4"})})]},a)),w.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",children:"No filters defined."})]})]}),e.jsxs(s.TabsContent,{value:"grouping",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{children:"Grouping Rules"}),e.jsxs(s.Button,{size:"sm",variant:"outline",onClick:X,children:[e.jsx(g.Plus,{className:"h-4 w-4 mr-2"}),"Add Group"]})]}),e.jsxs("div",{className:"space-y-2",children:[C.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-2 p-3 border rounded-lg",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Field"}),e.jsx("select",{className:"w-full border rounded-md h-8 text-sm px-2",value:t.field,onChange:l=>D(a,{...t,field:l.target.value}),children:u.map((l,T)=>e.jsx("option",{value:l.name,children:l.label||l.name},T))})]}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Sort Order"}),e.jsxs("select",{className:"w-full border rounded-md h-8 text-sm px-2",value:t.sort||"asc",onChange:l=>D(a,{...t,sort:l.target.value}),children:[e.jsx("option",{value:"asc",children:"Ascending"}),e.jsx("option",{value:"desc",children:"Descending"})]})]})]}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-red-500 hover:text-red-700 hover:bg-red-50 self-end",onClick:()=>Z(a),children:e.jsx(g.Trash2,{className:"h-4 w-4"})})]},a)),C.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",children:"No grouping rules applied."})]})]}),e.jsxs(s.TabsContent,{value:"sections",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{children:"Report Sections"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(s.Button,{size:"sm",variant:"outline",onClick:()=>U("header"),children:[e.jsx(g.Plus,{className:"h-4 w-4 mr-2"}),"Header"]}),e.jsxs(s.Button,{size:"sm",variant:"outline",onClick:()=>U("chart"),children:[e.jsx(g.Plus,{className:"h-4 w-4 mr-2"}),"Chart"]}),e.jsxs(s.Button,{size:"sm",variant:"outline",onClick:()=>U("table"),children:[e.jsx(g.Plus,{className:"h-4 w-4 mr-2"}),"Table"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[E.map((t,a)=>{var l,T,V,W;return e.jsxs("div",{className:"p-3 border rounded-lg space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx("div",{className:"text-xs bg-muted px-2 py-0.5 rounded uppercase",children:t.type}),t.title]}),e.jsx(s.Button,{size:"sm",variant:"ghost",className:"text-red-500 hover:text-red-700 hover:bg-red-50",onClick:()=>K(a),children:e.jsx(g.Trash2,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Title"}),e.jsx(s.Input,{className:"h-8 text-sm",value:t.title||"",onChange:r=>O(a,{...t,title:r.target.value})})]}),t.type==="text"&&e.jsxs("div",{className:"col-span-2",children:[e.jsx(s.Label,{className:"text-xs",children:"Content"}),e.jsx(s.Input,{className:"h-8 text-sm",value:t.text||"",onChange:r=>O(a,{...t,text:r.target.value})})]}),t.type==="chart"&&e.jsxs("div",{className:"col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded",children:[e.jsx("div",{className:"col-span-2",children:e.jsx(s.Label,{className:"text-xs font-semibold",children:"Chart Configuration"})}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"Chart Type"}),e.jsxs("select",{className:"flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",value:((l=t.chart)==null?void 0:l.chartType)||"bar",onChange:r=>O(a,{...t,chart:{...t.chart,type:"chart",chartType:r.target.value}}),children:[e.jsx("option",{value:"bar",children:"Bar"}),e.jsx("option",{value:"line",children:"Line"}),e.jsx("option",{value:"area",children:"Area"}),e.jsx("option",{value:"pie",children:"Pie"})]})]}),e.jsxs("div",{children:[e.jsx(s.Label,{className:"text-xs",children:"X-Axis Field"}),e.jsxs("select",{className:"flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",value:((T=t.chart)==null?void 0:T.xAxisField)||"",onChange:r=>O(a,{...t,chart:{...t.chart,type:"chart",xAxisField:r.target.value}}),children:[e.jsx("option",{value:"",children:"Select Field..."}),u.map(r=>e.jsx("option",{value:r.name,children:r.label||r.name},r.name)),u.length===0&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"name",children:"Name"}),e.jsx("option",{value:"month",children:"Month"})]})]})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx(s.Label,{className:"text-xs",children:"Y-Axis Fields (comma separated)"}),e.jsx(s.Input,{className:"h-8 text-sm",placeholder:"e.g. value, count",value:((W=(V=t.chart)==null?void 0:V.yAxisFields)==null?void 0:W.join(", "))||"",onChange:r=>O(a,{...t,chart:{...t.chart,type:"chart",yAxisFields:r.target.value.split(",").map(i=>i.trim()).filter(Boolean)}})})]})]})]})]},a)}),E.length===0&&e.jsx("div",{className:"text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg",children:"No customized sections. The default report layout will be used."})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-6 pt-4 border-t",children:[e.jsx(s.Button,{variant:"outline",onClick:Q,children:"Cancel"}),e.jsxs(s.Button,{onClick:H,children:[e.jsx(g.Save,{className:"h-4 w-4 mr-2"}),"Save Report"]})]})]})]}),m&&e.jsxs(s.Card,{className:"mt-8 border-2 border-blue-100",children:[e.jsx(s.CardHeader,{className:"bg-blue-50/50",children:e.jsx(s.CardTitle,{className:"text-blue-900 text-sm uppercase tracking-wide",children:"Live Preview"})}),e.jsx(s.CardContent,{className:"pt-6",children:e.jsx(J,{schema:{type:"report-viewer",report:{...d,fields:j,filters:w,groupBy:C,sections:E},data:[{id:1,name:"Sample Item A",value:100,status:"New"},{id:2,name:"Sample Item B",value:250,status:"Active"},{id:3,name:"Sample Item C",value:75,status:"Closed"}]}})})]})]})};S.ComponentRegistry.register("report",le,{label:"Report",category:"Report",inputs:[{name:"title",type:"string",label:"Title"},{name:"description",type:"string",label:"Description"},{name:"chart",type:"code",label:"Chart Configuration"}]}),S.ComponentRegistry.register("report-viewer",J,{label:"Report Viewer",category:"Report",inputs:[{name:"report",type:"code",label:"Report Definition"},{name:"showToolbar",type:"boolean",label:"Show Toolbar"}]}),S.ComponentRegistry.register("report-builder",ne,{label:"Report Builder",category:"Report",inputs:[{name:"report",type:"code",label:"Initial Report"}]}),R.ReportBuilder=ne,R.ReportRenderer=le,R.ReportViewer=J,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { ReportBuilderSchema } from '../../types/src';
3
+
4
+ export interface ReportBuilderProps {
5
+ schema: ReportBuilderSchema;
6
+ }
7
+ /**
8
+ * ReportBuilder - Interactive report builder component
9
+ * Allows users to configure report fields, filters, grouping, sections, and export settings
10
+ */
11
+ export declare const ReportBuilder: React.FC<ReportBuilderProps>;
12
+ //# sourceMappingURL=ReportBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportBuilder.d.ts","sourceRoot":"","sources":["../../src/ReportBuilder.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,mBAAmB,EAAyE,MAAM,kBAAkB,CAAC;AAInI,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,mBAAmB,CAAC;CAC7B;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAsmBtD,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+
3
+ export interface ReportRendererProps {
4
+ schema: {
5
+ type: string;
6
+ id?: string;
7
+ title?: string;
8
+ description?: string;
9
+ chart?: any;
10
+ data?: any[];
11
+ columns?: any[];
12
+ className?: string;
13
+ };
14
+ }
15
+ export declare const ReportRenderer: React.FC<ReportRendererProps>;
16
+ //# sourceMappingURL=ReportRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportRenderer.d.ts","sourceRoot":"","sources":["../../src/ReportRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,GAAG,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwFxD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { ReportViewerSchema } from '../../types/src';
3
+
4
+ export interface ReportViewerProps {
5
+ schema: ReportViewerSchema;
6
+ }
7
+ /**
8
+ * ReportViewer - Display a generated report with optional toolbar
9
+ * Supports rendering report sections, charts, tables, and export functionality
10
+ */
11
+ export declare const ReportViewer: React.FC<ReportViewerProps>;
12
+ //# sourceMappingURL=ReportViewer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReportViewer.d.ts","sourceRoot":"","sources":["../../src/ReportViewer.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,kBAAkB,EAAiB,MAAM,kBAAkB,CAAC;AAG1E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAwPpD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ReportRenderer } from './ReportRenderer';
2
+ import { ReportViewer } from './ReportViewer';
3
+ import { ReportBuilder } from './ReportBuilder';
4
+
5
+ export { ReportRenderer, ReportViewer, ReportBuilder };
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@object-ui/plugin-report",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "dist/index.umd.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.umd.cjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "peerDependencies": {
19
+ "react": "^18.0.0",
20
+ "react-dom": "^18.0.0",
21
+ "@object-ui/core": "0.5.0",
22
+ "@object-ui/types": "0.5.0",
23
+ "@object-ui/components": "0.5.0",
24
+ "@object-ui/react": "0.5.0",
25
+ "@object-ui/fields": "0.5.0"
26
+ },
27
+ "dependencies": {
28
+ "clsx": "^2.1.0",
29
+ "lucide-react": "^0.344.0",
30
+ "tailwind-merge": "^2.2.1"
31
+ },
32
+ "devDependencies": {
33
+ "@types/node": "^20.11.24",
34
+ "@types/react": "^18.2.61",
35
+ "@types/react-dom": "^18.2.19",
36
+ "@vitejs/plugin-react": "^4.2.1",
37
+ "vite": "^5.1.4",
38
+ "vite-plugin-dts": "^3.7.3",
39
+ "vitest": "^1.3.1"
40
+ },
41
+ "scripts": {
42
+ "build": "vite build",
43
+ "clean": "rm -rf dist",
44
+ "test": "vitest run",
45
+ "lint": "eslint ."
46
+ }
47
+ }