@object-ui/plugin-report 17.2.0 → 17.3.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/CHANGELOG.md +77 -0
- package/dist/index.js +328 -320
- package/dist/index.umd.cjs +2 -2
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { ComponentRegistry as e, buildDatasetDrillFilter as t, buildDatasetFieldHelpers as n, formatDimensionValue as r, formatMeasure as i, mergeFilters as a } from "@object-ui/core";
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import { isSpecReport as
|
|
5
|
-
import { SchemaRenderer as
|
|
6
|
-
import { Badge as
|
|
7
|
-
import { jsx as
|
|
8
|
-
import { AlertTriangle as
|
|
9
|
-
import { getCellRenderer as
|
|
10
|
-
import { useSafeFieldLabel as
|
|
1
|
+
import { ComponentRegistry as e, buildDatasetDrillFilter as t, buildDatasetFieldHelpers as n, formatDimensionValue as r, formatMeasure as i, mergeFilters as a, pivotBucketId as o, pivotCellKey as s } from "@object-ui/core";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import l from "react";
|
|
4
|
+
import { isSpecReport as u, specReportToPresentation as d } from "@object-ui/types";
|
|
5
|
+
import { SchemaRenderer as f, SchemaRendererContext as p } from "@object-ui/react";
|
|
6
|
+
import { Badge as m, Button as h, Card as g, CardContent as _, CardDescription as v, CardHeader as y, CardTitle as b, Skeleton as x } from "@object-ui/components";
|
|
7
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
8
|
+
import { AlertTriangle as w, Download as T, Loader2 as E, Printer as D, RefreshCw as O, Table2 as k } from "lucide-react";
|
|
9
|
+
import { getCellRenderer as A, resolveCellRendererType as j } from "@object-ui/fields";
|
|
10
|
+
import { useSafeFieldLabel as M, useSafeTranslate as ee } from "@object-ui/i18n";
|
|
11
11
|
//#region src/LegacyReportRenderer.tsx
|
|
12
|
-
var
|
|
12
|
+
var N = ({ schema: t }) => {
|
|
13
13
|
let { title: n, description: r, data: i, columns: a } = t;
|
|
14
14
|
t.chart?.type;
|
|
15
15
|
let o = !!t.chart;
|
|
16
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ C(g, {
|
|
17
17
|
className: `h-full flex flex-col ${t.className || ""}`,
|
|
18
|
-
children: [/* @__PURE__ */
|
|
18
|
+
children: [/* @__PURE__ */ C(y, { children: [n && /* @__PURE__ */ S(b, { children: n }), r && /* @__PURE__ */ S(v, { children: r })] }), /* @__PURE__ */ C(_, {
|
|
19
19
|
className: "flex-1 overflow-auto space-y-4",
|
|
20
20
|
children: [o && (() => {
|
|
21
21
|
let n = t.chart?.type, r = n ? e.get(n) : null;
|
|
22
|
-
return r ||= e.get("chart"), r ? /* @__PURE__ */
|
|
22
|
+
return r ||= e.get("chart"), r ? /* @__PURE__ */ S("div", {
|
|
23
23
|
className: "min-h-[300px] border rounded-lg p-4 bg-background/50",
|
|
24
|
-
children: /* @__PURE__ */
|
|
24
|
+
children: /* @__PURE__ */ S(r, { schema: {
|
|
25
25
|
...t.chart,
|
|
26
26
|
data: t.chart.data || i
|
|
27
27
|
} })
|
|
28
|
-
}) : /* @__PURE__ */
|
|
28
|
+
}) : /* @__PURE__ */ C("div", {
|
|
29
29
|
className: "min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center",
|
|
30
30
|
children: ["Unknown component type: ", n || "chart"]
|
|
31
31
|
});
|
|
32
|
-
})(), i && i.length > 0 && /* @__PURE__ */
|
|
32
|
+
})(), i && i.length > 0 && /* @__PURE__ */ S("div", {
|
|
33
33
|
className: "border rounded-lg",
|
|
34
34
|
children: (() => {
|
|
35
35
|
let t = e.get("grid") || e.get("table");
|
|
36
|
-
return t ? /* @__PURE__ */
|
|
36
|
+
return t ? /* @__PURE__ */ S(t, { schema: {
|
|
37
37
|
type: "grid",
|
|
38
38
|
rowData: i,
|
|
39
39
|
columnDefs: a,
|
|
40
40
|
domLayout: "autoHeight"
|
|
41
|
-
} }) : /* @__PURE__ */
|
|
41
|
+
} }) : /* @__PURE__ */ S("div", {
|
|
42
42
|
className: "overflow-x-auto",
|
|
43
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ C("table", {
|
|
44
44
|
className: "w-full text-sm text-left",
|
|
45
|
-
children: [/* @__PURE__ */
|
|
45
|
+
children: [/* @__PURE__ */ S("thead", {
|
|
46
46
|
className: "text-xs uppercase bg-muted",
|
|
47
|
-
children: /* @__PURE__ */
|
|
47
|
+
children: /* @__PURE__ */ S("tr", { children: a?.map((e) => /* @__PURE__ */ S("th", {
|
|
48
48
|
className: "px-6 py-3",
|
|
49
49
|
children: e.headerName || e.label || e.field
|
|
50
50
|
}, e.field)) })
|
|
51
|
-
}), /* @__PURE__ */
|
|
51
|
+
}), /* @__PURE__ */ S("tbody", { children: i.map((e, t) => /* @__PURE__ */ S("tr", {
|
|
52
52
|
className: "bg-background border-b",
|
|
53
|
-
children: a?.map((t) => /* @__PURE__ */
|
|
53
|
+
children: a?.map((t) => /* @__PURE__ */ S("td", {
|
|
54
54
|
className: "px-6 py-4",
|
|
55
55
|
children: e[t.field]
|
|
56
56
|
}, t.field))
|
|
@@ -64,29 +64,29 @@ var j = ({ schema: t }) => {
|
|
|
64
64
|
};
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/ReportExportEngine.ts
|
|
67
|
-
function
|
|
67
|
+
function P(e, t, n) {
|
|
68
68
|
let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
|
|
69
69
|
let n = e[t.name];
|
|
70
|
-
return n =
|
|
70
|
+
return n = B(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
|
|
71
71
|
}));
|
|
72
|
-
|
|
72
|
+
H([...n?.includeHeaders === !1 ? [] : [i.join(",")], ...a.map((e) => e.join(","))].join("\n"), n?.filename || `${e.title || "report"}.csv`, "text/csv");
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function te(e, t, n) {
|
|
75
75
|
let r = {
|
|
76
76
|
title: e.title,
|
|
77
77
|
description: e.description,
|
|
78
78
|
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
79
79
|
data: t
|
|
80
80
|
};
|
|
81
|
-
|
|
81
|
+
H(JSON.stringify(r, null, 2), n?.filename || `${e.title || "report"}.json`, "application/json");
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
let r = e.fields || [], i =
|
|
85
|
-
|
|
83
|
+
function F(e, t, n) {
|
|
84
|
+
let r = e.fields || [], i = V(n?.orientation), a = ne(n?.pageSize);
|
|
85
|
+
H(`<!DOCTYPE html>
|
|
86
86
|
<html>
|
|
87
87
|
<head>
|
|
88
88
|
<meta charset="utf-8">
|
|
89
|
-
<title>${
|
|
89
|
+
<title>${z(e.title || "Report")}</title>
|
|
90
90
|
<style>
|
|
91
91
|
@page { size: ${a} ${i}; margin: 20mm; }
|
|
92
92
|
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
@@ -100,20 +100,20 @@ function P(e, t, n) {
|
|
|
100
100
|
</style>
|
|
101
101
|
</head>
|
|
102
102
|
<body>
|
|
103
|
-
<h1>${
|
|
104
|
-
${e.description ? `<p class="description">${
|
|
103
|
+
<h1>${z(e.title || "Report")}</h1>
|
|
104
|
+
${e.description ? `<p class="description">${z(e.description)}</p>` : ""}
|
|
105
105
|
<p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
|
|
106
106
|
<table>
|
|
107
|
-
<thead><tr>${r.map((e) => `<th>${
|
|
108
|
-
<tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${
|
|
107
|
+
<thead><tr>${r.map((e) => `<th>${z(e.label || e.name)}</th>`).join("")}</tr></thead>
|
|
108
|
+
<tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${z(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
|
|
109
109
|
</table>
|
|
110
110
|
</body>
|
|
111
111
|
</html>`, n?.filename || `${e.title || "report"}.html`, "text/html");
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
let r = e.fields || [], i =
|
|
113
|
+
function I(e, t, n) {
|
|
114
|
+
let r = e.fields || [], i = V(n?.orientation), a = ne(n?.pageSize), o = window.open("", "_blank");
|
|
115
115
|
if (!o) {
|
|
116
|
-
|
|
116
|
+
F(e, t, {
|
|
117
117
|
...n,
|
|
118
118
|
format: "html",
|
|
119
119
|
filename: n?.filename?.replace(/\.pdf$/, ".html") || `${e.title || "report"}.html`
|
|
@@ -124,7 +124,7 @@ function te(e, t, n) {
|
|
|
124
124
|
<html>
|
|
125
125
|
<head>
|
|
126
126
|
<meta charset="utf-8">
|
|
127
|
-
<title>${
|
|
127
|
+
<title>${z(e.title || "Report")}</title>
|
|
128
128
|
<style>
|
|
129
129
|
@page { size: ${a} ${i}; margin: 20mm; }
|
|
130
130
|
@media print { .no-print { display: none; } }
|
|
@@ -139,49 +139,49 @@ function te(e, t, n) {
|
|
|
139
139
|
</style>
|
|
140
140
|
</head>
|
|
141
141
|
<body>
|
|
142
|
-
<h1>${
|
|
143
|
-
${e.description ? `<p class="description">${
|
|
142
|
+
<h1>${z(e.title || "Report")}</h1>
|
|
143
|
+
${e.description ? `<p class="description">${z(e.description)}</p>` : ""}
|
|
144
144
|
<p class="meta">Generated: ${(/* @__PURE__ */ new Date()).toLocaleString()}</p>
|
|
145
145
|
<table>
|
|
146
|
-
<thead><tr>${r.map((e) => `<th>${
|
|
147
|
-
<tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${
|
|
146
|
+
<thead><tr>${r.map((e) => `<th>${z(e.label || e.name)}</th>`).join("")}</tr></thead>
|
|
147
|
+
<tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${z(String(e[t.name] ?? ""))}</td>`).join("")}</tr>`).join("")}</tbody>
|
|
148
148
|
</table>
|
|
149
149
|
</body>
|
|
150
150
|
</html>`), o.document.close(), o.onload = () => {
|
|
151
151
|
o.print();
|
|
152
152
|
};
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function L(e, t, n) {
|
|
155
155
|
let r = e.fields || [], i = r.map((e) => e.label || e.name), a = t.map((e) => r.map((t) => {
|
|
156
156
|
let n = e[t.name];
|
|
157
|
-
return n =
|
|
157
|
+
return n = B(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
|
|
158
158
|
}));
|
|
159
|
-
|
|
159
|
+
H("" + [...n?.includeHeaders === !1 ? [] : [i.join(" ")], ...a.map((e) => e.join(" "))].join("\n"), n?.filename || `${e.title || "report"}.tsv`, "text/tab-separated-values");
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function R(e, t, n, r) {
|
|
162
162
|
switch (e) {
|
|
163
163
|
case "csv":
|
|
164
|
-
|
|
164
|
+
P(t, n, r);
|
|
165
165
|
break;
|
|
166
166
|
case "json":
|
|
167
|
-
|
|
167
|
+
te(t, n, r);
|
|
168
168
|
break;
|
|
169
169
|
case "html":
|
|
170
|
-
|
|
170
|
+
F(t, n, r);
|
|
171
171
|
break;
|
|
172
172
|
case "pdf":
|
|
173
|
-
|
|
173
|
+
I(t, n, r);
|
|
174
174
|
break;
|
|
175
175
|
case "excel":
|
|
176
|
-
|
|
176
|
+
L(t, n, r);
|
|
177
177
|
break;
|
|
178
178
|
default: console.warn(`Unsupported export format: ${e}`);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function z(e) {
|
|
182
182
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function B(e) {
|
|
185
185
|
if (typeof e == "string" && e.length > 0) {
|
|
186
186
|
let t = e.charAt(0);
|
|
187
187
|
if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `\t${e}`;
|
|
@@ -196,19 +196,19 @@ function ne(e) {
|
|
|
196
196
|
"Legal"
|
|
197
197
|
].includes(e || "") ? e : "A4";
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function V(e) {
|
|
200
200
|
return e === "landscape" ? "landscape" : "portrait";
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function H(e, t, n) {
|
|
203
203
|
let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
204
204
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
205
205
|
}
|
|
206
206
|
//#endregion
|
|
207
207
|
//#region src/formatValue.ts
|
|
208
|
-
function
|
|
208
|
+
function U(e, t) {
|
|
209
209
|
if (e == null || e === "") return "";
|
|
210
210
|
let n = t?.type, r = t?.format;
|
|
211
|
-
if (n === "date" || r === "date" ||
|
|
211
|
+
if (n === "date" || r === "date" || re(e)) return ie(e);
|
|
212
212
|
if (n === "number" || typeof e == "number") {
|
|
213
213
|
let t = typeof e == "number" ? e : Number(e);
|
|
214
214
|
return isNaN(t) ? String(e) : r === "currency" || r === "currency_cny" ? `¥${t.toLocaleString("en-US", {
|
|
@@ -224,10 +224,10 @@ function B(e, t) {
|
|
|
224
224
|
}
|
|
225
225
|
return String(e);
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function re(e) {
|
|
228
228
|
return typeof e == "string" && /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e);
|
|
229
229
|
}
|
|
230
|
-
function
|
|
230
|
+
function ie(e) {
|
|
231
231
|
try {
|
|
232
232
|
let t = new Date(e);
|
|
233
233
|
return isNaN(t.getTime()) ? String(e) : `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;
|
|
@@ -237,7 +237,7 @@ function ae(e) {
|
|
|
237
237
|
}
|
|
238
238
|
//#endregion
|
|
239
239
|
//#region src/ReportViewer.tsx
|
|
240
|
-
function
|
|
240
|
+
function ae(e, t) {
|
|
241
241
|
if (!t || t.length === 0 || !e || e.length === 0) return null;
|
|
242
242
|
let n = t[0], r = n.field, i = /* @__PURE__ */ new Map();
|
|
243
243
|
for (let t of e) {
|
|
@@ -253,7 +253,7 @@ function oe(e, t) {
|
|
|
253
253
|
let o = n.sort === "desc" ? -1 : 1;
|
|
254
254
|
return a.sort((e, t) => e.key.localeCompare(t.key) * o), a;
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function oe(e, t, n) {
|
|
257
257
|
if (!e) return 0;
|
|
258
258
|
let r = e.map((e) => Number(e[t]) || 0);
|
|
259
259
|
switch (n) {
|
|
@@ -266,18 +266,18 @@ function se(e, t, n) {
|
|
|
266
266
|
default: return "";
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
var
|
|
270
|
-
let { report: n, data: r, showToolbar: i = !0, allowExport: a = !0, allowPrint: o = !0, loading:
|
|
269
|
+
var W = ({ schema: e, onRefresh: t }) => {
|
|
270
|
+
let { report: n, data: r, showToolbar: i = !0, allowExport: a = !0, allowPrint: o = !0, loading: s = !1 } = e, c = (e) => {
|
|
271
271
|
if (!n) {
|
|
272
272
|
console.warn("ReportViewer: Cannot export, no report defined");
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
|
|
276
|
-
},
|
|
275
|
+
R(e, n, r || [], n.exportConfigs?.[e]);
|
|
276
|
+
}, u = () => {
|
|
277
277
|
window.print();
|
|
278
|
-
},
|
|
278
|
+
}, d = () => {
|
|
279
279
|
t?.();
|
|
280
|
-
},
|
|
280
|
+
}, p = (e, t) => oe(r, e, t), w = (e, t) => {
|
|
281
281
|
let r = n?.conditionalFormatting;
|
|
282
282
|
if (!(!r || !Array.isArray(r))) for (let n of r) {
|
|
283
283
|
if (n.field !== e) continue;
|
|
@@ -295,150 +295,153 @@ var V = ({ schema: e, onRefresh: t }) => {
|
|
|
295
295
|
case "greater_than":
|
|
296
296
|
a = Number(t) > Number(n.value);
|
|
297
297
|
break;
|
|
298
|
-
case "less_than":
|
|
299
|
-
a = Number(t) < Number(n.value);
|
|
300
|
-
break;
|
|
298
|
+
case "less_than": a = Number(t) < Number(n.value);
|
|
301
299
|
}
|
|
302
300
|
if (a) {
|
|
303
301
|
let e = {};
|
|
304
302
|
return n.backgroundColor && (e.backgroundColor = n.backgroundColor), n.textColor && (e.color = n.textColor), e;
|
|
305
303
|
}
|
|
306
304
|
}
|
|
307
|
-
},
|
|
305
|
+
}, E = (e, t) => {
|
|
308
306
|
if (e == null || e === "") return "";
|
|
309
|
-
if (t.renderAs === "badge" && (!t.type || t.type === "string" || t.type === "text"))
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
307
|
+
if (t.renderAs === "badge" && (!t.type || t.type === "string" || t.type === "text")) {
|
|
308
|
+
let n = t.colorMap?.[String(e)] || "";
|
|
309
|
+
return /* @__PURE__ */ S(m, {
|
|
310
|
+
className: n,
|
|
311
|
+
children: String(e)
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (t.aggregation) return U(e, t);
|
|
314
315
|
if (t.type) {
|
|
315
316
|
let n = { ...t };
|
|
316
|
-
|
|
317
|
+
t.colorMap && !n.options && (n.options = Object.entries(t.colorMap).map(([e, t]) => ({
|
|
317
318
|
value: e,
|
|
318
319
|
label: e,
|
|
319
320
|
color: t
|
|
320
|
-
})))
|
|
321
|
+
})));
|
|
322
|
+
let r = A(j(n));
|
|
323
|
+
return /* @__PURE__ */ S(r, {
|
|
321
324
|
value: e,
|
|
322
325
|
field: n
|
|
323
326
|
});
|
|
324
327
|
}
|
|
325
|
-
return
|
|
328
|
+
return U(e, t);
|
|
326
329
|
};
|
|
327
|
-
return n ? /* @__PURE__ */
|
|
330
|
+
return n ? /* @__PURE__ */ C("div", {
|
|
328
331
|
className: "space-y-4",
|
|
329
|
-
children: [i && /* @__PURE__ */
|
|
332
|
+
children: [i && /* @__PURE__ */ C("div", {
|
|
330
333
|
className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
|
|
331
|
-
children: [/* @__PURE__ */
|
|
334
|
+
children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h2", {
|
|
332
335
|
className: "text-lg font-semibold",
|
|
333
336
|
children: n.title
|
|
334
|
-
}), n.description && /* @__PURE__ */
|
|
337
|
+
}), n.description && /* @__PURE__ */ S("p", {
|
|
335
338
|
className: "text-sm text-muted-foreground",
|
|
336
339
|
children: n.description
|
|
337
|
-
})] }), /* @__PURE__ */
|
|
340
|
+
})] }), /* @__PURE__ */ C("div", {
|
|
338
341
|
className: "flex items-center gap-2",
|
|
339
342
|
children: [
|
|
340
|
-
n.refreshInterval && /* @__PURE__ */
|
|
343
|
+
n.refreshInterval && /* @__PURE__ */ C(h, {
|
|
341
344
|
variant: "outline",
|
|
342
345
|
size: "sm",
|
|
343
|
-
onClick:
|
|
344
|
-
children: [/* @__PURE__ */
|
|
346
|
+
onClick: d,
|
|
347
|
+
children: [/* @__PURE__ */ S(O, { className: "h-4 w-4 mr-2" }), "Refresh"]
|
|
345
348
|
}),
|
|
346
|
-
o && /* @__PURE__ */
|
|
349
|
+
o && /* @__PURE__ */ C(h, {
|
|
347
350
|
variant: "outline",
|
|
348
351
|
size: "sm",
|
|
349
|
-
onClick:
|
|
350
|
-
children: [/* @__PURE__ */
|
|
352
|
+
onClick: u,
|
|
353
|
+
children: [/* @__PURE__ */ S(D, { className: "h-4 w-4 mr-2" }), "Print"]
|
|
351
354
|
}),
|
|
352
|
-
a && n.showExportButtons && /* @__PURE__ */
|
|
355
|
+
a && n.showExportButtons && /* @__PURE__ */ C("div", {
|
|
353
356
|
className: "flex items-center gap-1",
|
|
354
357
|
children: [
|
|
355
|
-
/* @__PURE__ */
|
|
358
|
+
/* @__PURE__ */ C(h, {
|
|
356
359
|
variant: "outline",
|
|
357
360
|
size: "sm",
|
|
358
|
-
onClick: () =>
|
|
359
|
-
children: [/* @__PURE__ */
|
|
361
|
+
onClick: () => c("pdf"),
|
|
362
|
+
children: [/* @__PURE__ */ S(T, { className: "h-4 w-4 mr-2" }), "PDF"]
|
|
360
363
|
}),
|
|
361
|
-
/* @__PURE__ */
|
|
364
|
+
/* @__PURE__ */ C(h, {
|
|
362
365
|
variant: "outline",
|
|
363
366
|
size: "sm",
|
|
364
|
-
onClick: () =>
|
|
365
|
-
children: [/* @__PURE__ */
|
|
367
|
+
onClick: () => c("excel"),
|
|
368
|
+
children: [/* @__PURE__ */ S(T, { className: "h-4 w-4 mr-2" }), "Excel"]
|
|
366
369
|
}),
|
|
367
|
-
/* @__PURE__ */
|
|
370
|
+
/* @__PURE__ */ C(h, {
|
|
368
371
|
variant: "outline",
|
|
369
372
|
size: "sm",
|
|
370
|
-
onClick: () =>
|
|
371
|
-
children: [/* @__PURE__ */
|
|
373
|
+
onClick: () => c("csv"),
|
|
374
|
+
children: [/* @__PURE__ */ S(T, { className: "h-4 w-4 mr-2" }), "CSV"]
|
|
372
375
|
})
|
|
373
376
|
]
|
|
374
377
|
})
|
|
375
378
|
]
|
|
376
379
|
})]
|
|
377
|
-
}), /* @__PURE__ */
|
|
380
|
+
}), /* @__PURE__ */ C(g, { children: [/* @__PURE__ */ C(y, { children: [!i && n.title && /* @__PURE__ */ S(b, { children: n.title }), !i && n.description && /* @__PURE__ */ S(v, { children: n.description })] }), /* @__PURE__ */ C(_, {
|
|
378
381
|
className: "space-y-6",
|
|
379
382
|
children: [
|
|
380
|
-
|
|
383
|
+
s && /* @__PURE__ */ C("div", {
|
|
381
384
|
className: "space-y-6",
|
|
382
|
-
children: [/* @__PURE__ */
|
|
385
|
+
children: [/* @__PURE__ */ S("div", {
|
|
383
386
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
384
387
|
children: [
|
|
385
388
|
1,
|
|
386
389
|
2,
|
|
387
390
|
3
|
|
388
|
-
].map((e) => /* @__PURE__ */
|
|
391
|
+
].map((e) => /* @__PURE__ */ S(g, { children: /* @__PURE__ */ C(_, {
|
|
389
392
|
className: "p-4 space-y-2",
|
|
390
|
-
children: [/* @__PURE__ */
|
|
393
|
+
children: [/* @__PURE__ */ S(x, { className: "h-4 w-20" }), /* @__PURE__ */ S(x, { className: "h-8 w-28" })]
|
|
391
394
|
}) }, e))
|
|
392
|
-
}), /* @__PURE__ */
|
|
395
|
+
}), /* @__PURE__ */ C("div", {
|
|
393
396
|
className: "space-y-2",
|
|
394
|
-
children: [/* @__PURE__ */
|
|
397
|
+
children: [/* @__PURE__ */ S(x, { className: "h-10 w-full" }), [
|
|
395
398
|
1,
|
|
396
399
|
2,
|
|
397
400
|
3,
|
|
398
401
|
4,
|
|
399
402
|
5
|
|
400
|
-
].map((e) => /* @__PURE__ */
|
|
403
|
+
].map((e) => /* @__PURE__ */ S(x, { className: "h-8 w-full" }, e))]
|
|
401
404
|
})]
|
|
402
405
|
}),
|
|
403
|
-
!
|
|
406
|
+
!s && n.sections?.map((e, t) => e.visible === !1 ? null : /* @__PURE__ */ C("div", {
|
|
404
407
|
className: "space-y-2",
|
|
405
408
|
children: [
|
|
406
|
-
e.title && e.type !== "header" && /* @__PURE__ */
|
|
409
|
+
e.title && e.type !== "header" && /* @__PURE__ */ S("h3", {
|
|
407
410
|
className: "text-lg font-semibold border-b pb-2",
|
|
408
411
|
children: e.title
|
|
409
412
|
}),
|
|
410
|
-
e.type === "header" && e.title && /* @__PURE__ */
|
|
413
|
+
e.type === "header" && e.title && /* @__PURE__ */ S("div", {
|
|
411
414
|
className: "text-2xl font-bold py-4",
|
|
412
415
|
children: e.title
|
|
413
416
|
}),
|
|
414
|
-
e.type === "summary" && /* @__PURE__ */
|
|
417
|
+
e.type === "summary" && /* @__PURE__ */ S("div", {
|
|
415
418
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
416
|
-
children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */
|
|
419
|
+
children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ S(g, { children: /* @__PURE__ */ C(_, {
|
|
417
420
|
className: "p-4",
|
|
418
|
-
children: [/* @__PURE__ */
|
|
421
|
+
children: [/* @__PURE__ */ S("div", {
|
|
419
422
|
className: "text-sm text-muted-foreground",
|
|
420
423
|
children: e.label || e.name
|
|
421
|
-
}), /* @__PURE__ */
|
|
424
|
+
}), /* @__PURE__ */ S("div", {
|
|
422
425
|
className: "text-2xl font-bold",
|
|
423
|
-
children:
|
|
426
|
+
children: U(p(e.name, e.aggregation), e)
|
|
424
427
|
})]
|
|
425
428
|
}) }, t))
|
|
426
429
|
}),
|
|
427
|
-
e.type === "table" && /* @__PURE__ */
|
|
430
|
+
e.type === "table" && /* @__PURE__ */ S("div", {
|
|
428
431
|
className: "border rounded-lg overflow-x-auto",
|
|
429
|
-
children: /* @__PURE__ */
|
|
432
|
+
children: /* @__PURE__ */ C("table", {
|
|
430
433
|
className: "w-full text-sm min-w-[600px]",
|
|
431
|
-
children: [/* @__PURE__ */
|
|
434
|
+
children: [/* @__PURE__ */ S("thead", {
|
|
432
435
|
className: "bg-muted",
|
|
433
|
-
children: /* @__PURE__ */
|
|
436
|
+
children: /* @__PURE__ */ S("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ S("th", {
|
|
434
437
|
className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
|
|
435
438
|
children: e.label || e.name
|
|
436
439
|
}, t)) })
|
|
437
|
-
}), /* @__PURE__ */
|
|
438
|
-
let t =
|
|
439
|
-
return t ? t.map((t) => /* @__PURE__ */
|
|
440
|
+
}), /* @__PURE__ */ S("tbody", { children: (() => {
|
|
441
|
+
let t = ae(r || [], n.groupBy || []);
|
|
442
|
+
return t ? t.map((t) => /* @__PURE__ */ C(l.Fragment, { children: [/* @__PURE__ */ S("tr", {
|
|
440
443
|
className: "bg-muted/60",
|
|
441
|
-
children: /* @__PURE__ */
|
|
444
|
+
children: /* @__PURE__ */ C("td", {
|
|
442
445
|
colSpan: e.columns?.length || 1,
|
|
443
446
|
className: "px-4 py-2 font-semibold text-sm",
|
|
444
447
|
children: [
|
|
@@ -448,73 +451,73 @@ var V = ({ schema: e, onRefresh: t }) => {
|
|
|
448
451
|
")"
|
|
449
452
|
]
|
|
450
453
|
})
|
|
451
|
-
}), t.rows.map((t, n) => /* @__PURE__ */
|
|
454
|
+
}), t.rows.map((t, n) => /* @__PURE__ */ S("tr", {
|
|
452
455
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
453
|
-
children: e.columns?.map((e, n) => /* @__PURE__ */
|
|
456
|
+
children: e.columns?.map((e, n) => /* @__PURE__ */ S("td", {
|
|
454
457
|
className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
455
|
-
style:
|
|
456
|
-
children:
|
|
458
|
+
style: w(e.name, t[e.name]),
|
|
459
|
+
children: E(t[e.name], e)
|
|
457
460
|
}, n))
|
|
458
|
-
}, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */
|
|
461
|
+
}, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */ S("tr", {
|
|
459
462
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
460
|
-
children: e.columns?.map((e, n) => /* @__PURE__ */
|
|
463
|
+
children: e.columns?.map((e, n) => /* @__PURE__ */ S("td", {
|
|
461
464
|
className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
462
|
-
style:
|
|
463
|
-
children:
|
|
465
|
+
style: w(e.name, t[e.name]),
|
|
466
|
+
children: E(t[e.name], e)
|
|
464
467
|
}, n))
|
|
465
468
|
}, n));
|
|
466
469
|
})() })]
|
|
467
470
|
})
|
|
468
471
|
}),
|
|
469
|
-
e.type === "text" && e.text && /* @__PURE__ */
|
|
472
|
+
e.type === "text" && e.text && /* @__PURE__ */ S("div", {
|
|
470
473
|
className: "prose max-w-none",
|
|
471
|
-
children: /* @__PURE__ */
|
|
474
|
+
children: /* @__PURE__ */ S("p", { children: e.text })
|
|
472
475
|
}),
|
|
473
|
-
e.type === "page-break" && /* @__PURE__ */
|
|
474
|
-
e.content && /* @__PURE__ */
|
|
476
|
+
e.type === "page-break" && /* @__PURE__ */ S("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
|
|
477
|
+
e.content && /* @__PURE__ */ S(f, { schema: e.content })
|
|
475
478
|
]
|
|
476
479
|
}, t)),
|
|
477
|
-
!n.sections && r && r.length > 0 && /* @__PURE__ */
|
|
480
|
+
!n.sections && r && r.length > 0 && /* @__PURE__ */ S("div", {
|
|
478
481
|
className: "border rounded-lg overflow-x-auto",
|
|
479
|
-
children: /* @__PURE__ */
|
|
482
|
+
children: /* @__PURE__ */ C("table", {
|
|
480
483
|
className: "w-full text-sm min-w-[600px]",
|
|
481
|
-
children: [/* @__PURE__ */
|
|
484
|
+
children: [/* @__PURE__ */ S("thead", {
|
|
482
485
|
className: "bg-muted",
|
|
483
|
-
children: /* @__PURE__ */
|
|
486
|
+
children: /* @__PURE__ */ S("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ S("th", {
|
|
484
487
|
className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
|
|
485
488
|
children: e.label || e.name
|
|
486
489
|
}, t)) })
|
|
487
|
-
}), /* @__PURE__ */
|
|
490
|
+
}), /* @__PURE__ */ S("tbody", { children: r.map((e, t) => /* @__PURE__ */ S("tr", {
|
|
488
491
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
489
|
-
children: n.fields?.map((t, n) => /* @__PURE__ */
|
|
492
|
+
children: n.fields?.map((t, n) => /* @__PURE__ */ S("td", {
|
|
490
493
|
className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
491
|
-
style:
|
|
492
|
-
children:
|
|
494
|
+
style: w(t.name, e[t.name]),
|
|
495
|
+
children: E(e[t.name], t)
|
|
493
496
|
}, n))
|
|
494
497
|
}, t)) })]
|
|
495
498
|
})
|
|
496
499
|
})
|
|
497
500
|
]
|
|
498
501
|
})] })]
|
|
499
|
-
}) : /* @__PURE__ */
|
|
502
|
+
}) : /* @__PURE__ */ S(g, { children: /* @__PURE__ */ S(_, {
|
|
500
503
|
className: "p-8 text-center text-muted-foreground",
|
|
501
504
|
children: "No report to display"
|
|
502
505
|
}) });
|
|
503
506
|
};
|
|
504
507
|
//#endregion
|
|
505
508
|
//#region src/DatasetReportRenderer.tsx
|
|
506
|
-
function
|
|
509
|
+
function G(e) {
|
|
507
510
|
if (!e || typeof e != "object") return !1;
|
|
508
511
|
let t = e;
|
|
509
512
|
return typeof t.dataset == "string" && t.dataset.length > 0 || t.type === "joined" && Array.isArray(t.blocks) && t.blocks.some((e) => typeof e?.dataset == "string");
|
|
510
513
|
}
|
|
511
|
-
function
|
|
514
|
+
function K(e, t) {
|
|
512
515
|
return e ? typeof e == "string" ? e : typeof e == "object" && typeof e.default == "string" ? e.default : t : t;
|
|
513
516
|
}
|
|
514
|
-
function
|
|
517
|
+
function q(e) {
|
|
515
518
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && !!e) : [];
|
|
516
519
|
}
|
|
517
|
-
function
|
|
520
|
+
function J(e) {
|
|
518
521
|
if (!Array.isArray(e)) return;
|
|
519
522
|
let t = {};
|
|
520
523
|
for (let n of e) {
|
|
@@ -523,18 +526,18 @@ function G(e) {
|
|
|
523
526
|
}
|
|
524
527
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
525
528
|
}
|
|
526
|
-
function
|
|
529
|
+
function se(e, t, n) {
|
|
527
530
|
if (!e) return;
|
|
528
531
|
let r = /* @__PURE__ */ new Set([...t, ...n]), i = {};
|
|
529
532
|
for (let [t, n] of Object.entries(e)) r.has(t) && (i[t] = n);
|
|
530
533
|
return Object.keys(i).length > 0 ? i : void 0;
|
|
531
534
|
}
|
|
532
|
-
function
|
|
533
|
-
let [
|
|
535
|
+
function Y(e, t, n, r, i, a, o) {
|
|
536
|
+
let [s, l] = c.useState({
|
|
534
537
|
status: "idle",
|
|
535
538
|
rows: []
|
|
536
|
-
}), u =
|
|
537
|
-
return
|
|
539
|
+
}), u = se(o, t, n), d = JSON.stringify(r ?? null), f = JSON.stringify(a ?? null), p = JSON.stringify(u ?? null), m = `${e}|${t.join(",")}|${n.join(",")}|${d}|${f}|${p}`;
|
|
540
|
+
return c.useEffect(() => {
|
|
538
541
|
let o = i;
|
|
539
542
|
if (!o || typeof o.queryDataset != "function") {
|
|
540
543
|
l({
|
|
@@ -581,10 +584,10 @@ function K(e, t, n, r, i, a, s) {
|
|
|
581
584
|
}), () => {
|
|
582
585
|
s = !0;
|
|
583
586
|
};
|
|
584
|
-
}, [m]),
|
|
587
|
+
}, [m]), s;
|
|
585
588
|
}
|
|
586
|
-
function
|
|
587
|
-
return /* @__PURE__ */
|
|
589
|
+
function X({ dataset: e }) {
|
|
590
|
+
return /* @__PURE__ */ C("div", {
|
|
588
591
|
className: "flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
589
592
|
children: [
|
|
590
593
|
"This report binds the “",
|
|
@@ -593,35 +596,35 @@ function q({ dataset: e }) {
|
|
|
593
596
|
]
|
|
594
597
|
});
|
|
595
598
|
}
|
|
596
|
-
function
|
|
597
|
-
return e === "error" ? /* @__PURE__ */
|
|
599
|
+
function Z({ status: e, error: t }) {
|
|
600
|
+
return e === "error" ? /* @__PURE__ */ C("div", {
|
|
598
601
|
role: "alert",
|
|
599
602
|
className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",
|
|
600
|
-
children: [/* @__PURE__ */
|
|
603
|
+
children: [/* @__PURE__ */ S(w, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ S("span", {
|
|
601
604
|
className: "break-words",
|
|
602
605
|
children: t
|
|
603
606
|
})]
|
|
604
|
-
}) : /* @__PURE__ */
|
|
607
|
+
}) : /* @__PURE__ */ C("div", {
|
|
605
608
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
606
|
-
children: [/* @__PURE__ */
|
|
609
|
+
children: [/* @__PURE__ */ S(E, { className: "h-4 w-4 animate-spin" }), " Running report…"]
|
|
607
610
|
});
|
|
608
611
|
}
|
|
609
|
-
function
|
|
610
|
-
return /* @__PURE__ */
|
|
612
|
+
function ce() {
|
|
613
|
+
return /* @__PURE__ */ C("div", {
|
|
611
614
|
className: "flex flex-col items-center justify-center gap-2 rounded-md border border-dashed bg-muted/20 p-6 text-xs text-muted-foreground",
|
|
612
|
-
children: [/* @__PURE__ */
|
|
615
|
+
children: [/* @__PURE__ */ S(k, { className: "h-6 w-6" }), " The dataset returned no rows for this report’s scope."]
|
|
613
616
|
});
|
|
614
617
|
}
|
|
615
618
|
var le = "cursor-pointer hover:bg-accent/40";
|
|
616
619
|
function ue({ dataset: e, rows: a, values: o, runtimeFilter: s, dataSource: c, onDrill: l, order: u, withTotals: d }) {
|
|
617
|
-
let f =
|
|
618
|
-
if (o.length === 0) return /* @__PURE__ */
|
|
619
|
-
if (f.status === "loading" || f.status === "idle") return /* @__PURE__ */
|
|
620
|
-
if (f.status === "error") return /* @__PURE__ */
|
|
620
|
+
let f = Y(e, a, o, s, c, d && a.length > 0 ? [[]] : void 0, u), { fieldLabel: p } = M(), m = ee();
|
|
621
|
+
if (o.length === 0) return /* @__PURE__ */ S(X, { dataset: e });
|
|
622
|
+
if (f.status === "loading" || f.status === "idle") return /* @__PURE__ */ S(Z, { status: f.status });
|
|
623
|
+
if (f.status === "error") return /* @__PURE__ */ S(Z, {
|
|
621
624
|
status: "error",
|
|
622
625
|
error: f.error
|
|
623
626
|
});
|
|
624
|
-
if (f.rows.length === 0) return /* @__PURE__ */
|
|
627
|
+
if (f.rows.length === 0) return /* @__PURE__ */ S(ce, {});
|
|
625
628
|
let h = !!l && a.length > 0, g = f.dimensionFields ? a.filter((e) => e in f.dimensionFields) : [], _ = (n, r) => {
|
|
626
629
|
let i = {};
|
|
627
630
|
for (let e of a) i[e] = n[e];
|
|
@@ -633,35 +636,35 @@ function ue({ dataset: e, rows: a, values: o, runtimeFilter: s, dataSource: c, o
|
|
|
633
636
|
object: f.object,
|
|
634
637
|
objectFilter: u
|
|
635
638
|
});
|
|
636
|
-
}, { measureField: v, headerLabel: y } = n(f.fields, f.object, p),
|
|
637
|
-
return /* @__PURE__ */
|
|
639
|
+
}, { measureField: v, headerLabel: y } = n(f.fields, f.object, p), b = [...a, ...o], x = d ? f.totals?.find((e) => Array.isArray(e.dimensions) && e.dimensions.length === 0)?.rows?.[0] : void 0, w = m("report.total", "Total");
|
|
640
|
+
return /* @__PURE__ */ S("div", {
|
|
638
641
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
639
|
-
children: /* @__PURE__ */
|
|
642
|
+
children: /* @__PURE__ */ C("table", {
|
|
640
643
|
className: "w-full text-xs",
|
|
641
|
-
children: [/* @__PURE__ */
|
|
644
|
+
children: [/* @__PURE__ */ S("thead", {
|
|
642
645
|
className: "bg-muted/40",
|
|
643
|
-
children: /* @__PURE__ */
|
|
646
|
+
children: /* @__PURE__ */ S("tr", { children: b.map((e) => /* @__PURE__ */ S("th", {
|
|
644
647
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
645
648
|
children: y(e)
|
|
646
649
|
}, e)) })
|
|
647
|
-
}), /* @__PURE__ */
|
|
650
|
+
}), /* @__PURE__ */ C("tbody", { children: [f.rows.map((e, t) => /* @__PURE__ */ S("tr", {
|
|
648
651
|
className: `border-t${h ? ` ${le}` : ""}`,
|
|
649
652
|
"data-testid": h ? "dataset-drill-row" : void 0,
|
|
650
653
|
onClick: h ? () => _(e, t) : void 0,
|
|
651
|
-
children:
|
|
654
|
+
children: b.map((t) => /* @__PURE__ */ S("td", {
|
|
652
655
|
className: "px-2 py-1 tabular-nums whitespace-nowrap",
|
|
653
656
|
children: o.includes(t) ? i(e[t], v(t)?.format, v(t)?.currency, v(t)?.percentScale) : r(e[t])
|
|
654
657
|
}, t))
|
|
655
|
-
}, t)),
|
|
658
|
+
}, t)), x && /* @__PURE__ */ C("tr", {
|
|
656
659
|
className: "border-t bg-muted/30 font-medium",
|
|
657
660
|
"data-testid": "dataset-report-total-row",
|
|
658
|
-
children: [a.length > 0 && /* @__PURE__ */
|
|
661
|
+
children: [a.length > 0 && /* @__PURE__ */ S("td", {
|
|
659
662
|
colSpan: a.length,
|
|
660
663
|
className: "px-2 py-1 whitespace-nowrap",
|
|
661
664
|
children: w
|
|
662
|
-
}), o.map((e) => /* @__PURE__ */
|
|
665
|
+
}), o.map((e) => /* @__PURE__ */ S("td", {
|
|
663
666
|
className: "px-2 py-1 tabular-nums whitespace-nowrap",
|
|
664
|
-
children: i(
|
|
667
|
+
children: i(x[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
|
|
665
668
|
}, e))]
|
|
666
669
|
})] })]
|
|
667
670
|
})
|
|
@@ -707,8 +710,8 @@ function fe(e) {
|
|
|
707
710
|
}
|
|
708
711
|
}
|
|
709
712
|
function pe(t) {
|
|
710
|
-
let [, n] =
|
|
711
|
-
return
|
|
713
|
+
let [, n] = c.useReducer((e) => e + 1, 0);
|
|
714
|
+
return c.useEffect(() => {
|
|
712
715
|
if (e.get(t)) return;
|
|
713
716
|
let r = typeof e.subscribe == "function" ? e.subscribe(() => {
|
|
714
717
|
e.get(t) && n();
|
|
@@ -717,9 +720,9 @@ function pe(t) {
|
|
|
717
720
|
}, [t]), e.get(t);
|
|
718
721
|
}
|
|
719
722
|
function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o }) {
|
|
720
|
-
let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "", l = fe(t.type), u = l.kind === "series" || l.kind === "single_value", d =
|
|
723
|
+
let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "", l = fe(t.type), u = l.kind === "series" || l.kind === "single_value", d = Y(e, l.kind === "series" && s ? [s] : [], u && c ? [c] : [], r, a, void 0, o), f = pe("chart"), { fieldLabel: p } = M(), m = typeof t.title == "string" ? t.title : void 0;
|
|
721
724
|
if (l.kind === "tabular") return null;
|
|
722
|
-
if (l.kind === "unsupported") return /* @__PURE__ */
|
|
725
|
+
if (l.kind === "unsupported") return /* @__PURE__ */ C("div", {
|
|
723
726
|
className: "rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
|
|
724
727
|
"data-testid": "dataset-report-chart-unsupported",
|
|
725
728
|
children: [
|
|
@@ -729,38 +732,38 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
|
|
|
729
732
|
]
|
|
730
733
|
});
|
|
731
734
|
if (l.kind === "series" && !s || !c) return null;
|
|
732
|
-
if (d.status === "loading" || d.status === "idle") return /* @__PURE__ */
|
|
735
|
+
if (d.status === "loading" || d.status === "idle") return /* @__PURE__ */ C("div", {
|
|
733
736
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
734
|
-
children: [/* @__PURE__ */
|
|
737
|
+
children: [/* @__PURE__ */ S(E, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
|
|
735
738
|
});
|
|
736
739
|
if (d.status === "error" || d.rows.length === 0) return null;
|
|
737
740
|
if (l.kind === "single_value") {
|
|
738
741
|
let { measureField: e, headerLabel: t } = n(d.fields, d.object, p), r = e(c);
|
|
739
|
-
return /* @__PURE__ */
|
|
742
|
+
return /* @__PURE__ */ C("div", {
|
|
740
743
|
className: "rounded-md border bg-card p-3",
|
|
741
744
|
"data-testid": "dataset-report-metric",
|
|
742
|
-
children: [m ? /* @__PURE__ */
|
|
745
|
+
children: [m ? /* @__PURE__ */ S("h3", {
|
|
743
746
|
className: "mb-2 text-sm font-semibold",
|
|
744
747
|
children: m
|
|
745
|
-
}) : null, /* @__PURE__ */
|
|
748
|
+
}) : null, /* @__PURE__ */ C("div", {
|
|
746
749
|
className: "flex flex-col gap-0.5 py-2",
|
|
747
|
-
children: [/* @__PURE__ */
|
|
750
|
+
children: [/* @__PURE__ */ S("span", {
|
|
748
751
|
className: "text-2xl font-semibold tabular-nums",
|
|
749
752
|
children: i(d.rows[0]?.[c], r?.format, r?.currency, r?.percentScale)
|
|
750
|
-
}), /* @__PURE__ */
|
|
753
|
+
}), /* @__PURE__ */ S("span", {
|
|
751
754
|
className: "text-xs text-muted-foreground",
|
|
752
755
|
children: t(c)
|
|
753
756
|
})]
|
|
754
757
|
})]
|
|
755
758
|
});
|
|
756
759
|
}
|
|
757
|
-
return f ? /* @__PURE__ */
|
|
760
|
+
return f ? /* @__PURE__ */ C("div", {
|
|
758
761
|
className: "rounded-md border bg-card p-3",
|
|
759
762
|
"data-testid": "dataset-report-chart",
|
|
760
|
-
children: [m ? /* @__PURE__ */
|
|
763
|
+
children: [m ? /* @__PURE__ */ S("h3", {
|
|
761
764
|
className: "mb-2 text-sm font-semibold",
|
|
762
765
|
children: m
|
|
763
|
-
}) : null, /* @__PURE__ */
|
|
766
|
+
}) : null, /* @__PURE__ */ S(f, { schema: {
|
|
764
767
|
chartType: l.chartType,
|
|
765
768
|
data: d.rows,
|
|
766
769
|
xAxisKey: s,
|
|
@@ -770,45 +773,45 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
|
|
|
770
773
|
} })]
|
|
771
774
|
}) : null;
|
|
772
775
|
}
|
|
773
|
-
function
|
|
774
|
-
return e.map((e) => String(t[e] ?? "∅"))
|
|
776
|
+
function Q(e, t) {
|
|
777
|
+
return o(e.map((e) => String(t[e] ?? "∅")));
|
|
775
778
|
}
|
|
776
779
|
function he(e, t) {
|
|
777
780
|
return e.map((e) => r(t[e])).join(" / ");
|
|
778
781
|
}
|
|
779
|
-
function
|
|
780
|
-
let
|
|
782
|
+
function ge({ dataset: e, rows: a, columnsAcross: o, values: l, runtimeFilter: u, dataSource: d, onDrill: f, order: p }) {
|
|
783
|
+
let m = Y(e, [...a, ...o], l, u, d, [
|
|
781
784
|
a,
|
|
782
|
-
|
|
785
|
+
o,
|
|
783
786
|
[]
|
|
784
|
-
],
|
|
785
|
-
if (
|
|
787
|
+
], p), h = ee(), { fieldLabel: g } = M(), _ = c.useMemo(() => {
|
|
788
|
+
if (m.status !== "ok") return null;
|
|
786
789
|
let e = [], t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
787
|
-
return
|
|
788
|
-
let
|
|
789
|
-
if (!n.has(
|
|
790
|
-
n.add(
|
|
790
|
+
return m.rows.forEach((c, l) => {
|
|
791
|
+
let u = Q(a, c), d = Q(o, c);
|
|
792
|
+
if (!n.has(u)) {
|
|
793
|
+
n.add(u);
|
|
791
794
|
let t = {};
|
|
792
|
-
for (let e of a) t[e] =
|
|
795
|
+
for (let e of a) t[e] = c[e];
|
|
793
796
|
e.push({
|
|
794
|
-
id:
|
|
795
|
-
label: he(a,
|
|
797
|
+
id: u,
|
|
798
|
+
label: he(a, c),
|
|
796
799
|
key: t
|
|
797
800
|
});
|
|
798
801
|
}
|
|
799
|
-
if (!r.has(
|
|
800
|
-
r.add(
|
|
802
|
+
if (!r.has(d)) {
|
|
803
|
+
r.add(d);
|
|
801
804
|
let e = {};
|
|
802
|
-
for (let t of
|
|
805
|
+
for (let t of o) e[t] = c[t];
|
|
803
806
|
t.push({
|
|
804
|
-
id:
|
|
805
|
-
label: he(
|
|
807
|
+
id: d,
|
|
808
|
+
label: he(o, c),
|
|
806
809
|
key: e
|
|
807
810
|
});
|
|
808
811
|
}
|
|
809
|
-
i.set(
|
|
810
|
-
row:
|
|
811
|
-
index:
|
|
812
|
+
i.set(s(u, d), {
|
|
813
|
+
row: c,
|
|
814
|
+
index: l
|
|
812
815
|
});
|
|
813
816
|
}), {
|
|
814
817
|
rowHeaders: e,
|
|
@@ -816,108 +819,108 @@ function Z({ dataset: e, rows: a, columnsAcross: s, values: c, runtimeFilter: l,
|
|
|
816
819
|
cells: i
|
|
817
820
|
};
|
|
818
821
|
}, [
|
|
819
|
-
|
|
822
|
+
m,
|
|
820
823
|
a,
|
|
821
|
-
|
|
824
|
+
o
|
|
822
825
|
]);
|
|
823
|
-
if (
|
|
824
|
-
if (
|
|
825
|
-
if (
|
|
826
|
+
if (l.length === 0) return /* @__PURE__ */ S(X, { dataset: e });
|
|
827
|
+
if (m.status === "loading" || m.status === "idle") return /* @__PURE__ */ S(Z, { status: m.status });
|
|
828
|
+
if (m.status === "error") return /* @__PURE__ */ S(Z, {
|
|
826
829
|
status: "error",
|
|
827
|
-
error:
|
|
830
|
+
error: m.error
|
|
828
831
|
});
|
|
829
|
-
if (!
|
|
830
|
-
let { measureField:
|
|
831
|
-
let a =
|
|
832
|
-
|
|
832
|
+
if (!_ || _.rowHeaders.length === 0) return /* @__PURE__ */ S(ce, {});
|
|
833
|
+
let { measureField: v, headerLabel: y } = n(m.fields, m.object, g), b = h("report.total", "Total"), x = !!f, w = m.dimensionFields ? [...a, ...o].filter((e) => e in m.dimensionFields) : [], T = (n, r, i) => {
|
|
834
|
+
let a = m.drillRanges?.[i], o = !!a && Object.keys(a).length > 0, s = m.object && (w.length > 0 || o) ? t(m.drillRawRows?.[i], w, m.dimensionFields ?? {}, u, a) : void 0;
|
|
835
|
+
f({
|
|
833
836
|
dataset: e,
|
|
834
837
|
groupKey: {
|
|
835
838
|
...n,
|
|
836
839
|
...r
|
|
837
840
|
},
|
|
838
|
-
runtimeFilter:
|
|
839
|
-
object:
|
|
841
|
+
runtimeFilter: u,
|
|
842
|
+
object: m.object,
|
|
840
843
|
objectFilter: s
|
|
841
844
|
});
|
|
842
|
-
},
|
|
845
|
+
}, E = _.colHeaders.flatMap((e) => l.map((t) => ({
|
|
843
846
|
col: e,
|
|
844
847
|
measure: t,
|
|
845
|
-
header:
|
|
846
|
-
}))),
|
|
847
|
-
for (let e of
|
|
848
|
-
let
|
|
849
|
-
for (let e of
|
|
850
|
-
let
|
|
851
|
-
return /* @__PURE__ */
|
|
848
|
+
header: l.length === 1 ? e.label : `${e.label} · ${y(t)}`
|
|
849
|
+
}))), D = (e) => m.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows, O = /* @__PURE__ */ new Map();
|
|
850
|
+
for (let e of D(a) ?? []) O.set(Q(a, e), e);
|
|
851
|
+
let k = /* @__PURE__ */ new Map();
|
|
852
|
+
for (let e of D(o) ?? []) k.set(Q(o, e), e);
|
|
853
|
+
let A = D([])?.[0], j = O.size > 0, N = k.size > 0;
|
|
854
|
+
return /* @__PURE__ */ S("div", {
|
|
852
855
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
853
856
|
"data-testid": "dataset-matrix",
|
|
854
|
-
children: /* @__PURE__ */
|
|
857
|
+
children: /* @__PURE__ */ C("table", {
|
|
855
858
|
className: "w-full text-xs",
|
|
856
|
-
children: [/* @__PURE__ */
|
|
859
|
+
children: [/* @__PURE__ */ S("thead", {
|
|
857
860
|
className: "bg-muted/40",
|
|
858
|
-
children: /* @__PURE__ */
|
|
859
|
-
a.map((e) => /* @__PURE__ */
|
|
861
|
+
children: /* @__PURE__ */ C("tr", { children: [
|
|
862
|
+
a.map((e) => /* @__PURE__ */ S("th", {
|
|
860
863
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
861
|
-
children:
|
|
864
|
+
children: y(e)
|
|
862
865
|
}, e)),
|
|
863
|
-
|
|
866
|
+
E.map((e) => /* @__PURE__ */ S("th", {
|
|
864
867
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
865
868
|
children: e.header
|
|
866
869
|
}, `${e.col.id}-${e.measure}`)),
|
|
867
|
-
j &&
|
|
870
|
+
j && l.map((e) => /* @__PURE__ */ S("th", {
|
|
868
871
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
869
872
|
"data-testid": "matrix-total-col-header",
|
|
870
|
-
children:
|
|
873
|
+
children: l.length === 1 ? b : `${b} · ${y(e)}`
|
|
871
874
|
}, `total-${e}`))
|
|
872
875
|
] })
|
|
873
|
-
}), /* @__PURE__ */
|
|
876
|
+
}), /* @__PURE__ */ C("tbody", { children: [_.rowHeaders.map((e) => /* @__PURE__ */ C("tr", {
|
|
874
877
|
className: "border-t",
|
|
875
878
|
children: [
|
|
876
|
-
a.map((t) => /* @__PURE__ */
|
|
879
|
+
a.map((t) => /* @__PURE__ */ S("td", {
|
|
877
880
|
className: "px-2 py-1 whitespace-nowrap font-medium",
|
|
878
881
|
children: r(e.key[t])
|
|
879
882
|
}, t)),
|
|
880
|
-
|
|
881
|
-
let n =
|
|
882
|
-
return /* @__PURE__ */
|
|
883
|
+
E.map((t) => {
|
|
884
|
+
let n = _.cells.get(s(e.id, t.col.id)), r = n?.row[t.measure], a = x && n != null;
|
|
885
|
+
return /* @__PURE__ */ S("td", {
|
|
883
886
|
className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${a ? ` ${le}` : ""}`,
|
|
884
887
|
"data-testid": a ? "dataset-drill-cell" : void 0,
|
|
885
|
-
onClick: a ? () =>
|
|
886
|
-
children: i(r,
|
|
888
|
+
onClick: a ? () => T(e.key, t.col.key, n.index) : void 0,
|
|
889
|
+
children: i(r, v(t.measure)?.format, v(t.measure)?.currency, v(t.measure)?.percentScale)
|
|
887
890
|
}, `${t.col.id}-${t.measure}`);
|
|
888
891
|
}),
|
|
889
|
-
j &&
|
|
892
|
+
j && l.map((t) => /* @__PURE__ */ S("td", {
|
|
890
893
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
891
894
|
"data-testid": "matrix-row-total",
|
|
892
|
-
children: i(
|
|
895
|
+
children: i(O.get(e.id)?.[t], v(t)?.format, v(t)?.currency, v(t)?.percentScale)
|
|
893
896
|
}, `total-${t}`))
|
|
894
897
|
]
|
|
895
|
-
}, e.id)),
|
|
898
|
+
}, e.id)), N && /* @__PURE__ */ C("tr", {
|
|
896
899
|
className: "border-t bg-muted/30 font-medium",
|
|
897
900
|
"data-testid": "matrix-total-row",
|
|
898
901
|
children: [
|
|
899
|
-
a.length > 0 && /* @__PURE__ */
|
|
902
|
+
a.length > 0 && /* @__PURE__ */ S("td", {
|
|
900
903
|
colSpan: a.length,
|
|
901
904
|
className: "px-2 py-1 whitespace-nowrap",
|
|
902
|
-
children:
|
|
905
|
+
children: b
|
|
903
906
|
}),
|
|
904
|
-
|
|
907
|
+
E.map((e) => /* @__PURE__ */ S("td", {
|
|
905
908
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
906
|
-
children: i(
|
|
909
|
+
children: i(k.get(e.col.id)?.[e.measure], v(e.measure)?.format, v(e.measure)?.currency, v(e.measure)?.percentScale)
|
|
907
910
|
}, `${e.col.id}-${e.measure}`)),
|
|
908
|
-
j &&
|
|
911
|
+
j && l.map((e) => /* @__PURE__ */ S("td", {
|
|
909
912
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
910
913
|
"data-testid": "matrix-grand-total",
|
|
911
|
-
children: i(
|
|
914
|
+
children: i(A?.[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
|
|
912
915
|
}, `grand-${e}`))
|
|
913
916
|
]
|
|
914
917
|
})] })]
|
|
915
918
|
})
|
|
916
919
|
});
|
|
917
920
|
}
|
|
918
|
-
var
|
|
921
|
+
var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i }) => {
|
|
919
922
|
let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c = de(e.type);
|
|
920
|
-
if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */
|
|
923
|
+
if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */ S("div", {
|
|
921
924
|
className: i,
|
|
922
925
|
"data-testid": "dataset-joined-report",
|
|
923
926
|
"data-report-name": e.name,
|
|
@@ -927,52 +930,52 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
927
930
|
gap: 24
|
|
928
931
|
},
|
|
929
932
|
children: e.blocks.map((e, n) => {
|
|
930
|
-
let r = a(o, e.runtimeFilter ?? e.filter), i =
|
|
933
|
+
let r = a(o, e.runtimeFilter ?? e.filter), i = q(e.columns), c = J(e.order), l = de(e.type), u = l === "matrix" && i.length > 0 ? /* @__PURE__ */ S(ge, {
|
|
931
934
|
dataset: String(e.dataset ?? ""),
|
|
932
|
-
rows:
|
|
935
|
+
rows: q(e.rows),
|
|
933
936
|
columnsAcross: i,
|
|
934
|
-
values:
|
|
937
|
+
values: q(e.values),
|
|
935
938
|
runtimeFilter: r,
|
|
936
939
|
dataSource: t,
|
|
937
940
|
onDrill: s,
|
|
938
941
|
order: c
|
|
939
|
-
}) : /* @__PURE__ */
|
|
942
|
+
}) : /* @__PURE__ */ S(ue, {
|
|
940
943
|
dataset: String(e.dataset ?? ""),
|
|
941
|
-
rows:
|
|
942
|
-
values:
|
|
944
|
+
rows: q(e.rows),
|
|
945
|
+
values: q(e.values),
|
|
943
946
|
runtimeFilter: r,
|
|
944
947
|
dataSource: t,
|
|
945
948
|
onDrill: s,
|
|
946
949
|
order: c,
|
|
947
950
|
withTotals: l === "summary" || l === "matrix"
|
|
948
951
|
});
|
|
949
|
-
return /* @__PURE__ */
|
|
952
|
+
return /* @__PURE__ */ C("section", {
|
|
950
953
|
"data-testid": "dataset-report-block",
|
|
951
954
|
"data-block-id": e.name ?? `block-${n}`,
|
|
952
955
|
className: "flex flex-col gap-2 rounded-lg border bg-card p-4",
|
|
953
|
-
children: [/* @__PURE__ */
|
|
956
|
+
children: [/* @__PURE__ */ C("header", {
|
|
954
957
|
className: "flex flex-col gap-0.5",
|
|
955
|
-
children: [/* @__PURE__ */
|
|
958
|
+
children: [/* @__PURE__ */ S("h3", {
|
|
956
959
|
className: "text-sm font-semibold",
|
|
957
|
-
children:
|
|
958
|
-
}), e.description ? /* @__PURE__ */
|
|
960
|
+
children: K(e.label, e.name ?? `Block ${n + 1}`)
|
|
961
|
+
}), e.description ? /* @__PURE__ */ S("p", {
|
|
959
962
|
className: "text-xs text-muted-foreground",
|
|
960
|
-
children:
|
|
963
|
+
children: K(e.description, "")
|
|
961
964
|
}) : null]
|
|
962
965
|
}), u]
|
|
963
966
|
}, e.name ?? `block-${n}`);
|
|
964
967
|
})
|
|
965
968
|
});
|
|
966
|
-
let l =
|
|
967
|
-
if (c === "matrix" && l.length > 0) return /* @__PURE__ */
|
|
969
|
+
let l = q(e.columns), u = J(e.order);
|
|
970
|
+
if (c === "matrix" && l.length > 0) return /* @__PURE__ */ S("div", {
|
|
968
971
|
className: i,
|
|
969
972
|
"data-testid": "dataset-report",
|
|
970
973
|
"data-report-name": e.name,
|
|
971
|
-
children: /* @__PURE__ */
|
|
974
|
+
children: /* @__PURE__ */ S(ge, {
|
|
972
975
|
dataset: String(e.dataset ?? ""),
|
|
973
|
-
rows:
|
|
976
|
+
rows: q(e.rows),
|
|
974
977
|
columnsAcross: l,
|
|
975
|
-
values:
|
|
978
|
+
values: q(e.values),
|
|
976
979
|
runtimeFilter: o,
|
|
977
980
|
dataSource: t,
|
|
978
981
|
onDrill: s,
|
|
@@ -980,21 +983,21 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
980
983
|
})
|
|
981
984
|
});
|
|
982
985
|
let d = e.chart && typeof e.chart == "object" && e.chart.type ? e.chart : null;
|
|
983
|
-
return /* @__PURE__ */
|
|
986
|
+
return /* @__PURE__ */ C("div", {
|
|
984
987
|
className: `${i ?? ""} flex flex-col gap-3`,
|
|
985
988
|
"data-testid": "dataset-report",
|
|
986
989
|
"data-report-name": e.name,
|
|
987
990
|
"data-report-presentation": c,
|
|
988
|
-
children: [d ? /* @__PURE__ */
|
|
991
|
+
children: [d ? /* @__PURE__ */ S(me, {
|
|
989
992
|
dataset: String(e.dataset ?? ""),
|
|
990
993
|
chart: d,
|
|
991
994
|
runtimeFilter: o,
|
|
992
995
|
dataSource: t,
|
|
993
996
|
order: u
|
|
994
|
-
}) : null, /* @__PURE__ */
|
|
997
|
+
}) : null, /* @__PURE__ */ S(ue, {
|
|
995
998
|
dataset: String(e.dataset ?? ""),
|
|
996
|
-
rows:
|
|
997
|
-
values:
|
|
999
|
+
rows: q(e.rows),
|
|
1000
|
+
values: q(e.values),
|
|
998
1001
|
runtimeFilter: o,
|
|
999
1002
|
dataSource: t,
|
|
1000
1003
|
onDrill: s,
|
|
@@ -1002,32 +1005,37 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
1002
1005
|
withTotals: c === "summary" || c === "matrix"
|
|
1003
1006
|
})]
|
|
1004
1007
|
});
|
|
1005
|
-
},
|
|
1006
|
-
let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e,
|
|
1007
|
-
|
|
1008
|
-
report:
|
|
1009
|
-
dataSource:
|
|
1008
|
+
}, $ = (e) => {
|
|
1009
|
+
let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e, o = c.useContext(p), s = t ?? o?.dataSource, l = e.schema;
|
|
1010
|
+
if (l && typeof l == "object" && l.type === "spec-report" && l.report && typeof l.report == "object" && (l = l.report), G(l)) return /* @__PURE__ */ S(_e, {
|
|
1011
|
+
report: l,
|
|
1012
|
+
dataSource: s,
|
|
1010
1013
|
runtimeFilter: r,
|
|
1011
1014
|
onDrill: i,
|
|
1012
1015
|
className: a
|
|
1013
|
-
})
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
children: /* @__PURE__ */ b(V, { schema: {
|
|
1016
|
+
});
|
|
1017
|
+
if (u(l)) {
|
|
1018
|
+
let e = {
|
|
1017
1019
|
type: "report-viewer",
|
|
1018
|
-
report: l
|
|
1020
|
+
report: d(l),
|
|
1019
1021
|
data: n ?? [],
|
|
1020
1022
|
showToolbar: !1
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
+
};
|
|
1024
|
+
return /* @__PURE__ */ S("div", {
|
|
1025
|
+
className: a,
|
|
1026
|
+
"data-testid": "report-presentation-bridge",
|
|
1027
|
+
children: /* @__PURE__ */ S(W, { schema: e })
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
return /* @__PURE__ */ S(N, { schema: l });
|
|
1023
1031
|
};
|
|
1024
1032
|
//#endregion
|
|
1025
1033
|
//#region src/LiveReportExporter.ts
|
|
1026
|
-
async function
|
|
1034
|
+
async function ve(e, t) {
|
|
1027
1035
|
let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
|
|
1028
1036
|
try {
|
|
1029
1037
|
let t = (await n.find(r, i)).data || [];
|
|
1030
|
-
return
|
|
1038
|
+
return R(s, e, t, {
|
|
1031
1039
|
format: s,
|
|
1032
1040
|
...e.exportConfigs?.[s],
|
|
1033
1041
|
...o
|
|
@@ -1045,17 +1053,17 @@ async function $(e, t) {
|
|
|
1045
1053
|
};
|
|
1046
1054
|
}
|
|
1047
1055
|
}
|
|
1048
|
-
function
|
|
1049
|
-
let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(
|
|
1056
|
+
function ye(e, t, n = {}) {
|
|
1057
|
+
let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(xe), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
|
|
1050
1058
|
if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
|
|
1051
1059
|
let r = e[n.name];
|
|
1052
|
-
return
|
|
1060
|
+
return Se(r, n.numberFormat);
|
|
1053
1061
|
}));
|
|
1054
1062
|
if (a && t.length > 0) {
|
|
1055
1063
|
let n = o.map((n, r) => {
|
|
1056
1064
|
let i = (e.fields || []).find((e) => e.name === n.name);
|
|
1057
1065
|
if (i?.aggregation) {
|
|
1058
|
-
let e =
|
|
1066
|
+
let e = we(r), n = t.length + 1;
|
|
1059
1067
|
switch (i.aggregation) {
|
|
1060
1068
|
case "sum": return `=SUM(${e}2:${e}${n})`;
|
|
1061
1069
|
case "avg": return `=AVERAGE(${e}2:${e}${n})`;
|
|
@@ -1069,15 +1077,15 @@ function _e(e, t, n = {}) {
|
|
|
1069
1077
|
});
|
|
1070
1078
|
c.push(n);
|
|
1071
1079
|
}
|
|
1072
|
-
|
|
1080
|
+
Ee("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
|
|
1073
1081
|
}
|
|
1074
|
-
function
|
|
1082
|
+
function be(e, t, n, r) {
|
|
1075
1083
|
return async () => {
|
|
1076
1084
|
let i = e.schedule;
|
|
1077
1085
|
if (!i?.enabled) return [];
|
|
1078
1086
|
let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
|
|
1079
1087
|
for (let r of a) {
|
|
1080
|
-
let i = await
|
|
1088
|
+
let i = await ve(e, {
|
|
1081
1089
|
dataSource: t,
|
|
1082
1090
|
resource: n,
|
|
1083
1091
|
format: r
|
|
@@ -1087,16 +1095,16 @@ function ve(e, t, n, r) {
|
|
|
1087
1095
|
return r(e, i), o;
|
|
1088
1096
|
};
|
|
1089
1097
|
}
|
|
1090
|
-
function
|
|
1098
|
+
function xe(e) {
|
|
1091
1099
|
return {
|
|
1092
1100
|
name: e.name,
|
|
1093
1101
|
header: e.label || e.name
|
|
1094
1102
|
};
|
|
1095
1103
|
}
|
|
1096
|
-
function
|
|
1097
|
-
return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US",
|
|
1104
|
+
function Se(e, t) {
|
|
1105
|
+
return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", Ce(t)) : Te(String(e));
|
|
1098
1106
|
}
|
|
1099
|
-
function
|
|
1107
|
+
function Ce(e) {
|
|
1100
1108
|
if (e.includes("%")) return {
|
|
1101
1109
|
style: "percent",
|
|
1102
1110
|
minimumFractionDigits: 0
|
|
@@ -1107,23 +1115,23 @@ function xe(e) {
|
|
|
1107
1115
|
maximumFractionDigits: Math.max(0, t - 1)
|
|
1108
1116
|
};
|
|
1109
1117
|
}
|
|
1110
|
-
function
|
|
1118
|
+
function we(e) {
|
|
1111
1119
|
let t = "", n = e;
|
|
1112
1120
|
for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
|
|
1113
1121
|
return t;
|
|
1114
1122
|
}
|
|
1115
|
-
function
|
|
1123
|
+
function Te(e) {
|
|
1116
1124
|
if (e.length > 0) {
|
|
1117
1125
|
let t = e.charAt(0);
|
|
1118
1126
|
if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
|
|
1119
1127
|
}
|
|
1120
1128
|
return e;
|
|
1121
1129
|
}
|
|
1122
|
-
function
|
|
1130
|
+
function Ee(e, t, n) {
|
|
1123
1131
|
let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
1124
1132
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1125
1133
|
}
|
|
1126
|
-
e.register("report",
|
|
1134
|
+
e.register("report", $, {
|
|
1127
1135
|
namespace: "report",
|
|
1128
1136
|
label: "Report",
|
|
1129
1137
|
category: "Report",
|
|
@@ -1144,7 +1152,7 @@ e.register("report", Q, {
|
|
|
1144
1152
|
label: "Chart Configuration"
|
|
1145
1153
|
}
|
|
1146
1154
|
]
|
|
1147
|
-
}), e.register("spec-report",
|
|
1155
|
+
}), e.register("spec-report", $, {
|
|
1148
1156
|
namespace: "report",
|
|
1149
1157
|
label: "Spec Report",
|
|
1150
1158
|
category: "Report",
|
|
@@ -1157,7 +1165,7 @@ e.register("report", Q, {
|
|
|
1157
1165
|
type: "string",
|
|
1158
1166
|
label: "Report Type"
|
|
1159
1167
|
}]
|
|
1160
|
-
}), e.register("report-viewer",
|
|
1168
|
+
}), e.register("report-viewer", W, {
|
|
1161
1169
|
namespace: "report",
|
|
1162
1170
|
label: "Report Viewer",
|
|
1163
1171
|
category: "Report",
|
|
@@ -1172,4 +1180,4 @@ e.register("report", Q, {
|
|
|
1172
1180
|
}]
|
|
1173
1181
|
});
|
|
1174
1182
|
//#endregion
|
|
1175
|
-
export {
|
|
1183
|
+
export { _e as DatasetReportRenderer, N as LegacyReportRenderer, $ as ReportRenderer, W as ReportViewer, be as createScheduleTrigger, P as exportAsCSV, L as exportAsExcel, F as exportAsHTML, te as exportAsJSON, I as exportAsPDF, ye as exportExcelWithFormulas, R as exportReport, ve as exportWithLiveData, U as formatValue, G as isDatasetReport, a as mergeFilters };
|