@object-ui/plugin-report 17.1.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 +197 -0
- package/dist/DatasetReportRenderer.d.ts +5 -0
- package/dist/index.js +332 -323
- 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
|
-
children: o.includes(t) ? i(e[t], v(t)?.format, v(t)?.currency) : r(e[t])
|
|
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
|
})
|
|
@@ -688,7 +691,8 @@ function fe(e) {
|
|
|
688
691
|
case "scatter":
|
|
689
692
|
case "treemap":
|
|
690
693
|
case "sankey":
|
|
691
|
-
case "radar":
|
|
694
|
+
case "radar":
|
|
695
|
+
case "combo": return {
|
|
692
696
|
kind: "series",
|
|
693
697
|
chartType: e
|
|
694
698
|
};
|
|
@@ -706,8 +710,8 @@ function fe(e) {
|
|
|
706
710
|
}
|
|
707
711
|
}
|
|
708
712
|
function pe(t) {
|
|
709
|
-
let [, n] =
|
|
710
|
-
return
|
|
713
|
+
let [, n] = c.useReducer((e) => e + 1, 0);
|
|
714
|
+
return c.useEffect(() => {
|
|
711
715
|
if (e.get(t)) return;
|
|
712
716
|
let r = typeof e.subscribe == "function" ? e.subscribe(() => {
|
|
713
717
|
e.get(t) && n();
|
|
@@ -716,9 +720,9 @@ function pe(t) {
|
|
|
716
720
|
}, [t]), e.get(t);
|
|
717
721
|
}
|
|
718
722
|
function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o }) {
|
|
719
|
-
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;
|
|
720
724
|
if (l.kind === "tabular") return null;
|
|
721
|
-
if (l.kind === "unsupported") return /* @__PURE__ */
|
|
725
|
+
if (l.kind === "unsupported") return /* @__PURE__ */ C("div", {
|
|
722
726
|
className: "rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
|
|
723
727
|
"data-testid": "dataset-report-chart-unsupported",
|
|
724
728
|
children: [
|
|
@@ -728,38 +732,38 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
|
|
|
728
732
|
]
|
|
729
733
|
});
|
|
730
734
|
if (l.kind === "series" && !s || !c) return null;
|
|
731
|
-
if (d.status === "loading" || d.status === "idle") return /* @__PURE__ */
|
|
735
|
+
if (d.status === "loading" || d.status === "idle") return /* @__PURE__ */ C("div", {
|
|
732
736
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
733
|
-
children: [/* @__PURE__ */
|
|
737
|
+
children: [/* @__PURE__ */ S(E, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
|
|
734
738
|
});
|
|
735
739
|
if (d.status === "error" || d.rows.length === 0) return null;
|
|
736
740
|
if (l.kind === "single_value") {
|
|
737
741
|
let { measureField: e, headerLabel: t } = n(d.fields, d.object, p), r = e(c);
|
|
738
|
-
return /* @__PURE__ */
|
|
742
|
+
return /* @__PURE__ */ C("div", {
|
|
739
743
|
className: "rounded-md border bg-card p-3",
|
|
740
744
|
"data-testid": "dataset-report-metric",
|
|
741
|
-
children: [m ? /* @__PURE__ */
|
|
745
|
+
children: [m ? /* @__PURE__ */ S("h3", {
|
|
742
746
|
className: "mb-2 text-sm font-semibold",
|
|
743
747
|
children: m
|
|
744
|
-
}) : null, /* @__PURE__ */
|
|
748
|
+
}) : null, /* @__PURE__ */ C("div", {
|
|
745
749
|
className: "flex flex-col gap-0.5 py-2",
|
|
746
|
-
children: [/* @__PURE__ */
|
|
750
|
+
children: [/* @__PURE__ */ S("span", {
|
|
747
751
|
className: "text-2xl font-semibold tabular-nums",
|
|
748
|
-
children: i(d.rows[0]?.[c], r?.format, r?.currency)
|
|
749
|
-
}), /* @__PURE__ */
|
|
752
|
+
children: i(d.rows[0]?.[c], r?.format, r?.currency, r?.percentScale)
|
|
753
|
+
}), /* @__PURE__ */ S("span", {
|
|
750
754
|
className: "text-xs text-muted-foreground",
|
|
751
755
|
children: t(c)
|
|
752
756
|
})]
|
|
753
757
|
})]
|
|
754
758
|
});
|
|
755
759
|
}
|
|
756
|
-
return f ? /* @__PURE__ */
|
|
760
|
+
return f ? /* @__PURE__ */ C("div", {
|
|
757
761
|
className: "rounded-md border bg-card p-3",
|
|
758
762
|
"data-testid": "dataset-report-chart",
|
|
759
|
-
children: [m ? /* @__PURE__ */
|
|
763
|
+
children: [m ? /* @__PURE__ */ S("h3", {
|
|
760
764
|
className: "mb-2 text-sm font-semibold",
|
|
761
765
|
children: m
|
|
762
|
-
}) : null, /* @__PURE__ */
|
|
766
|
+
}) : null, /* @__PURE__ */ S(f, { schema: {
|
|
763
767
|
chartType: l.chartType,
|
|
764
768
|
data: d.rows,
|
|
765
769
|
xAxisKey: s,
|
|
@@ -769,45 +773,45 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
|
|
|
769
773
|
} })]
|
|
770
774
|
}) : null;
|
|
771
775
|
}
|
|
772
|
-
function
|
|
773
|
-
return e.map((e) => String(t[e] ?? "∅"))
|
|
776
|
+
function Q(e, t) {
|
|
777
|
+
return o(e.map((e) => String(t[e] ?? "∅")));
|
|
774
778
|
}
|
|
775
779
|
function he(e, t) {
|
|
776
780
|
return e.map((e) => r(t[e])).join(" / ");
|
|
777
781
|
}
|
|
778
|
-
function
|
|
779
|
-
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, [
|
|
780
784
|
a,
|
|
781
|
-
|
|
785
|
+
o,
|
|
782
786
|
[]
|
|
783
|
-
],
|
|
784
|
-
if (
|
|
787
|
+
], p), h = ee(), { fieldLabel: g } = M(), _ = c.useMemo(() => {
|
|
788
|
+
if (m.status !== "ok") return null;
|
|
785
789
|
let e = [], t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
786
|
-
return
|
|
787
|
-
let
|
|
788
|
-
if (!n.has(
|
|
789
|
-
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);
|
|
790
794
|
let t = {};
|
|
791
|
-
for (let e of a) t[e] =
|
|
795
|
+
for (let e of a) t[e] = c[e];
|
|
792
796
|
e.push({
|
|
793
|
-
id:
|
|
794
|
-
label: he(a,
|
|
797
|
+
id: u,
|
|
798
|
+
label: he(a, c),
|
|
795
799
|
key: t
|
|
796
800
|
});
|
|
797
801
|
}
|
|
798
|
-
if (!r.has(
|
|
799
|
-
r.add(
|
|
802
|
+
if (!r.has(d)) {
|
|
803
|
+
r.add(d);
|
|
800
804
|
let e = {};
|
|
801
|
-
for (let t of
|
|
805
|
+
for (let t of o) e[t] = c[t];
|
|
802
806
|
t.push({
|
|
803
|
-
id:
|
|
804
|
-
label: he(
|
|
807
|
+
id: d,
|
|
808
|
+
label: he(o, c),
|
|
805
809
|
key: e
|
|
806
810
|
});
|
|
807
811
|
}
|
|
808
|
-
i.set(
|
|
809
|
-
row:
|
|
810
|
-
index:
|
|
812
|
+
i.set(s(u, d), {
|
|
813
|
+
row: c,
|
|
814
|
+
index: l
|
|
811
815
|
});
|
|
812
816
|
}), {
|
|
813
817
|
rowHeaders: e,
|
|
@@ -815,108 +819,108 @@ function Z({ dataset: e, rows: a, columnsAcross: s, values: c, runtimeFilter: l,
|
|
|
815
819
|
cells: i
|
|
816
820
|
};
|
|
817
821
|
}, [
|
|
818
|
-
|
|
822
|
+
m,
|
|
819
823
|
a,
|
|
820
|
-
|
|
824
|
+
o
|
|
821
825
|
]);
|
|
822
|
-
if (
|
|
823
|
-
if (
|
|
824
|
-
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, {
|
|
825
829
|
status: "error",
|
|
826
|
-
error:
|
|
830
|
+
error: m.error
|
|
827
831
|
});
|
|
828
|
-
if (!
|
|
829
|
-
let { measureField:
|
|
830
|
-
let a =
|
|
831
|
-
|
|
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({
|
|
832
836
|
dataset: e,
|
|
833
837
|
groupKey: {
|
|
834
838
|
...n,
|
|
835
839
|
...r
|
|
836
840
|
},
|
|
837
|
-
runtimeFilter:
|
|
838
|
-
object:
|
|
841
|
+
runtimeFilter: u,
|
|
842
|
+
object: m.object,
|
|
839
843
|
objectFilter: s
|
|
840
844
|
});
|
|
841
|
-
},
|
|
845
|
+
}, E = _.colHeaders.flatMap((e) => l.map((t) => ({
|
|
842
846
|
col: e,
|
|
843
847
|
measure: t,
|
|
844
|
-
header:
|
|
845
|
-
}))),
|
|
846
|
-
for (let e of
|
|
847
|
-
let
|
|
848
|
-
for (let e of
|
|
849
|
-
let
|
|
850
|
-
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", {
|
|
851
855
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
852
856
|
"data-testid": "dataset-matrix",
|
|
853
|
-
children: /* @__PURE__ */
|
|
857
|
+
children: /* @__PURE__ */ C("table", {
|
|
854
858
|
className: "w-full text-xs",
|
|
855
|
-
children: [/* @__PURE__ */
|
|
859
|
+
children: [/* @__PURE__ */ S("thead", {
|
|
856
860
|
className: "bg-muted/40",
|
|
857
|
-
children: /* @__PURE__ */
|
|
858
|
-
a.map((e) => /* @__PURE__ */
|
|
861
|
+
children: /* @__PURE__ */ C("tr", { children: [
|
|
862
|
+
a.map((e) => /* @__PURE__ */ S("th", {
|
|
859
863
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
860
|
-
children:
|
|
864
|
+
children: y(e)
|
|
861
865
|
}, e)),
|
|
862
|
-
|
|
866
|
+
E.map((e) => /* @__PURE__ */ S("th", {
|
|
863
867
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
864
868
|
children: e.header
|
|
865
869
|
}, `${e.col.id}-${e.measure}`)),
|
|
866
|
-
j &&
|
|
870
|
+
j && l.map((e) => /* @__PURE__ */ S("th", {
|
|
867
871
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
868
872
|
"data-testid": "matrix-total-col-header",
|
|
869
|
-
children:
|
|
873
|
+
children: l.length === 1 ? b : `${b} · ${y(e)}`
|
|
870
874
|
}, `total-${e}`))
|
|
871
875
|
] })
|
|
872
|
-
}), /* @__PURE__ */
|
|
876
|
+
}), /* @__PURE__ */ C("tbody", { children: [_.rowHeaders.map((e) => /* @__PURE__ */ C("tr", {
|
|
873
877
|
className: "border-t",
|
|
874
878
|
children: [
|
|
875
|
-
a.map((t) => /* @__PURE__ */
|
|
879
|
+
a.map((t) => /* @__PURE__ */ S("td", {
|
|
876
880
|
className: "px-2 py-1 whitespace-nowrap font-medium",
|
|
877
881
|
children: r(e.key[t])
|
|
878
882
|
}, t)),
|
|
879
|
-
|
|
880
|
-
let n =
|
|
881
|
-
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", {
|
|
882
886
|
className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${a ? ` ${le}` : ""}`,
|
|
883
887
|
"data-testid": a ? "dataset-drill-cell" : void 0,
|
|
884
|
-
onClick: a ? () =>
|
|
885
|
-
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)
|
|
886
890
|
}, `${t.col.id}-${t.measure}`);
|
|
887
891
|
}),
|
|
888
|
-
j &&
|
|
892
|
+
j && l.map((t) => /* @__PURE__ */ S("td", {
|
|
889
893
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
890
894
|
"data-testid": "matrix-row-total",
|
|
891
|
-
children: i(
|
|
895
|
+
children: i(O.get(e.id)?.[t], v(t)?.format, v(t)?.currency, v(t)?.percentScale)
|
|
892
896
|
}, `total-${t}`))
|
|
893
897
|
]
|
|
894
|
-
}, e.id)),
|
|
898
|
+
}, e.id)), N && /* @__PURE__ */ C("tr", {
|
|
895
899
|
className: "border-t bg-muted/30 font-medium",
|
|
896
900
|
"data-testid": "matrix-total-row",
|
|
897
901
|
children: [
|
|
898
|
-
a.length > 0 && /* @__PURE__ */
|
|
902
|
+
a.length > 0 && /* @__PURE__ */ S("td", {
|
|
899
903
|
colSpan: a.length,
|
|
900
904
|
className: "px-2 py-1 whitespace-nowrap",
|
|
901
|
-
children:
|
|
905
|
+
children: b
|
|
902
906
|
}),
|
|
903
|
-
|
|
907
|
+
E.map((e) => /* @__PURE__ */ S("td", {
|
|
904
908
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
905
|
-
children: i(
|
|
909
|
+
children: i(k.get(e.col.id)?.[e.measure], v(e.measure)?.format, v(e.measure)?.currency, v(e.measure)?.percentScale)
|
|
906
910
|
}, `${e.col.id}-${e.measure}`)),
|
|
907
|
-
j &&
|
|
911
|
+
j && l.map((e) => /* @__PURE__ */ S("td", {
|
|
908
912
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
909
913
|
"data-testid": "matrix-grand-total",
|
|
910
|
-
children: i(
|
|
914
|
+
children: i(A?.[e], v(e)?.format, v(e)?.currency, v(e)?.percentScale)
|
|
911
915
|
}, `grand-${e}`))
|
|
912
916
|
]
|
|
913
917
|
})] })]
|
|
914
918
|
})
|
|
915
919
|
});
|
|
916
920
|
}
|
|
917
|
-
var
|
|
921
|
+
var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i }) => {
|
|
918
922
|
let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c = de(e.type);
|
|
919
|
-
if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */
|
|
923
|
+
if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */ S("div", {
|
|
920
924
|
className: i,
|
|
921
925
|
"data-testid": "dataset-joined-report",
|
|
922
926
|
"data-report-name": e.name,
|
|
@@ -926,52 +930,52 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
926
930
|
gap: 24
|
|
927
931
|
},
|
|
928
932
|
children: e.blocks.map((e, n) => {
|
|
929
|
-
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, {
|
|
930
934
|
dataset: String(e.dataset ?? ""),
|
|
931
|
-
rows:
|
|
935
|
+
rows: q(e.rows),
|
|
932
936
|
columnsAcross: i,
|
|
933
|
-
values:
|
|
937
|
+
values: q(e.values),
|
|
934
938
|
runtimeFilter: r,
|
|
935
939
|
dataSource: t,
|
|
936
940
|
onDrill: s,
|
|
937
941
|
order: c
|
|
938
|
-
}) : /* @__PURE__ */
|
|
942
|
+
}) : /* @__PURE__ */ S(ue, {
|
|
939
943
|
dataset: String(e.dataset ?? ""),
|
|
940
|
-
rows:
|
|
941
|
-
values:
|
|
944
|
+
rows: q(e.rows),
|
|
945
|
+
values: q(e.values),
|
|
942
946
|
runtimeFilter: r,
|
|
943
947
|
dataSource: t,
|
|
944
948
|
onDrill: s,
|
|
945
949
|
order: c,
|
|
946
950
|
withTotals: l === "summary" || l === "matrix"
|
|
947
951
|
});
|
|
948
|
-
return /* @__PURE__ */
|
|
952
|
+
return /* @__PURE__ */ C("section", {
|
|
949
953
|
"data-testid": "dataset-report-block",
|
|
950
954
|
"data-block-id": e.name ?? `block-${n}`,
|
|
951
955
|
className: "flex flex-col gap-2 rounded-lg border bg-card p-4",
|
|
952
|
-
children: [/* @__PURE__ */
|
|
956
|
+
children: [/* @__PURE__ */ C("header", {
|
|
953
957
|
className: "flex flex-col gap-0.5",
|
|
954
|
-
children: [/* @__PURE__ */
|
|
958
|
+
children: [/* @__PURE__ */ S("h3", {
|
|
955
959
|
className: "text-sm font-semibold",
|
|
956
|
-
children:
|
|
957
|
-
}), e.description ? /* @__PURE__ */
|
|
960
|
+
children: K(e.label, e.name ?? `Block ${n + 1}`)
|
|
961
|
+
}), e.description ? /* @__PURE__ */ S("p", {
|
|
958
962
|
className: "text-xs text-muted-foreground",
|
|
959
|
-
children:
|
|
963
|
+
children: K(e.description, "")
|
|
960
964
|
}) : null]
|
|
961
965
|
}), u]
|
|
962
966
|
}, e.name ?? `block-${n}`);
|
|
963
967
|
})
|
|
964
968
|
});
|
|
965
|
-
let l =
|
|
966
|
-
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", {
|
|
967
971
|
className: i,
|
|
968
972
|
"data-testid": "dataset-report",
|
|
969
973
|
"data-report-name": e.name,
|
|
970
|
-
children: /* @__PURE__ */
|
|
974
|
+
children: /* @__PURE__ */ S(ge, {
|
|
971
975
|
dataset: String(e.dataset ?? ""),
|
|
972
|
-
rows:
|
|
976
|
+
rows: q(e.rows),
|
|
973
977
|
columnsAcross: l,
|
|
974
|
-
values:
|
|
978
|
+
values: q(e.values),
|
|
975
979
|
runtimeFilter: o,
|
|
976
980
|
dataSource: t,
|
|
977
981
|
onDrill: s,
|
|
@@ -979,21 +983,21 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
979
983
|
})
|
|
980
984
|
});
|
|
981
985
|
let d = e.chart && typeof e.chart == "object" && e.chart.type ? e.chart : null;
|
|
982
|
-
return /* @__PURE__ */
|
|
986
|
+
return /* @__PURE__ */ C("div", {
|
|
983
987
|
className: `${i ?? ""} flex flex-col gap-3`,
|
|
984
988
|
"data-testid": "dataset-report",
|
|
985
989
|
"data-report-name": e.name,
|
|
986
990
|
"data-report-presentation": c,
|
|
987
|
-
children: [d ? /* @__PURE__ */
|
|
991
|
+
children: [d ? /* @__PURE__ */ S(me, {
|
|
988
992
|
dataset: String(e.dataset ?? ""),
|
|
989
993
|
chart: d,
|
|
990
994
|
runtimeFilter: o,
|
|
991
995
|
dataSource: t,
|
|
992
996
|
order: u
|
|
993
|
-
}) : null, /* @__PURE__ */
|
|
997
|
+
}) : null, /* @__PURE__ */ S(ue, {
|
|
994
998
|
dataset: String(e.dataset ?? ""),
|
|
995
|
-
rows:
|
|
996
|
-
values:
|
|
999
|
+
rows: q(e.rows),
|
|
1000
|
+
values: q(e.values),
|
|
997
1001
|
runtimeFilter: o,
|
|
998
1002
|
dataSource: t,
|
|
999
1003
|
onDrill: s,
|
|
@@ -1001,32 +1005,37 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
1001
1005
|
withTotals: c === "summary" || c === "matrix"
|
|
1002
1006
|
})]
|
|
1003
1007
|
});
|
|
1004
|
-
},
|
|
1005
|
-
let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e,
|
|
1006
|
-
|
|
1007
|
-
report:
|
|
1008
|
-
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,
|
|
1009
1013
|
runtimeFilter: r,
|
|
1010
1014
|
onDrill: i,
|
|
1011
1015
|
className: a
|
|
1012
|
-
})
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
children: /* @__PURE__ */ b(V, { schema: {
|
|
1016
|
+
});
|
|
1017
|
+
if (u(l)) {
|
|
1018
|
+
let e = {
|
|
1016
1019
|
type: "report-viewer",
|
|
1017
|
-
report: l
|
|
1020
|
+
report: d(l),
|
|
1018
1021
|
data: n ?? [],
|
|
1019
1022
|
showToolbar: !1
|
|
1020
|
-
}
|
|
1021
|
-
|
|
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 });
|
|
1022
1031
|
};
|
|
1023
1032
|
//#endregion
|
|
1024
1033
|
//#region src/LiveReportExporter.ts
|
|
1025
|
-
async function
|
|
1034
|
+
async function ve(e, t) {
|
|
1026
1035
|
let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
|
|
1027
1036
|
try {
|
|
1028
1037
|
let t = (await n.find(r, i)).data || [];
|
|
1029
|
-
return
|
|
1038
|
+
return R(s, e, t, {
|
|
1030
1039
|
format: s,
|
|
1031
1040
|
...e.exportConfigs?.[s],
|
|
1032
1041
|
...o
|
|
@@ -1044,17 +1053,17 @@ async function $(e, t) {
|
|
|
1044
1053
|
};
|
|
1045
1054
|
}
|
|
1046
1055
|
}
|
|
1047
|
-
function
|
|
1048
|
-
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) => {
|
|
1049
1058
|
if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
|
|
1050
1059
|
let r = e[n.name];
|
|
1051
|
-
return
|
|
1060
|
+
return Se(r, n.numberFormat);
|
|
1052
1061
|
}));
|
|
1053
1062
|
if (a && t.length > 0) {
|
|
1054
1063
|
let n = o.map((n, r) => {
|
|
1055
1064
|
let i = (e.fields || []).find((e) => e.name === n.name);
|
|
1056
1065
|
if (i?.aggregation) {
|
|
1057
|
-
let e =
|
|
1066
|
+
let e = we(r), n = t.length + 1;
|
|
1058
1067
|
switch (i.aggregation) {
|
|
1059
1068
|
case "sum": return `=SUM(${e}2:${e}${n})`;
|
|
1060
1069
|
case "avg": return `=AVERAGE(${e}2:${e}${n})`;
|
|
@@ -1068,15 +1077,15 @@ function _e(e, t, n = {}) {
|
|
|
1068
1077
|
});
|
|
1069
1078
|
c.push(n);
|
|
1070
1079
|
}
|
|
1071
|
-
|
|
1080
|
+
Ee("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
|
|
1072
1081
|
}
|
|
1073
|
-
function
|
|
1082
|
+
function be(e, t, n, r) {
|
|
1074
1083
|
return async () => {
|
|
1075
1084
|
let i = e.schedule;
|
|
1076
1085
|
if (!i?.enabled) return [];
|
|
1077
1086
|
let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
|
|
1078
1087
|
for (let r of a) {
|
|
1079
|
-
let i = await
|
|
1088
|
+
let i = await ve(e, {
|
|
1080
1089
|
dataSource: t,
|
|
1081
1090
|
resource: n,
|
|
1082
1091
|
format: r
|
|
@@ -1086,16 +1095,16 @@ function ve(e, t, n, r) {
|
|
|
1086
1095
|
return r(e, i), o;
|
|
1087
1096
|
};
|
|
1088
1097
|
}
|
|
1089
|
-
function
|
|
1098
|
+
function xe(e) {
|
|
1090
1099
|
return {
|
|
1091
1100
|
name: e.name,
|
|
1092
1101
|
header: e.label || e.name
|
|
1093
1102
|
};
|
|
1094
1103
|
}
|
|
1095
|
-
function
|
|
1096
|
-
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));
|
|
1097
1106
|
}
|
|
1098
|
-
function
|
|
1107
|
+
function Ce(e) {
|
|
1099
1108
|
if (e.includes("%")) return {
|
|
1100
1109
|
style: "percent",
|
|
1101
1110
|
minimumFractionDigits: 0
|
|
@@ -1106,23 +1115,23 @@ function xe(e) {
|
|
|
1106
1115
|
maximumFractionDigits: Math.max(0, t - 1)
|
|
1107
1116
|
};
|
|
1108
1117
|
}
|
|
1109
|
-
function
|
|
1118
|
+
function we(e) {
|
|
1110
1119
|
let t = "", n = e;
|
|
1111
1120
|
for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
|
|
1112
1121
|
return t;
|
|
1113
1122
|
}
|
|
1114
|
-
function
|
|
1123
|
+
function Te(e) {
|
|
1115
1124
|
if (e.length > 0) {
|
|
1116
1125
|
let t = e.charAt(0);
|
|
1117
1126
|
if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
|
|
1118
1127
|
}
|
|
1119
1128
|
return e;
|
|
1120
1129
|
}
|
|
1121
|
-
function
|
|
1130
|
+
function Ee(e, t, n) {
|
|
1122
1131
|
let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
1123
1132
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1124
1133
|
}
|
|
1125
|
-
e.register("report",
|
|
1134
|
+
e.register("report", $, {
|
|
1126
1135
|
namespace: "report",
|
|
1127
1136
|
label: "Report",
|
|
1128
1137
|
category: "Report",
|
|
@@ -1143,7 +1152,7 @@ e.register("report", Q, {
|
|
|
1143
1152
|
label: "Chart Configuration"
|
|
1144
1153
|
}
|
|
1145
1154
|
]
|
|
1146
|
-
}), e.register("spec-report",
|
|
1155
|
+
}), e.register("spec-report", $, {
|
|
1147
1156
|
namespace: "report",
|
|
1148
1157
|
label: "Spec Report",
|
|
1149
1158
|
category: "Report",
|
|
@@ -1156,7 +1165,7 @@ e.register("report", Q, {
|
|
|
1156
1165
|
type: "string",
|
|
1157
1166
|
label: "Report Type"
|
|
1158
1167
|
}]
|
|
1159
|
-
}), e.register("report-viewer",
|
|
1168
|
+
}), e.register("report-viewer", W, {
|
|
1160
1169
|
namespace: "report",
|
|
1161
1170
|
label: "Report Viewer",
|
|
1162
1171
|
category: "Report",
|
|
@@ -1171,4 +1180,4 @@ e.register("report", Q, {
|
|
|
1171
1180
|
}]
|
|
1172
1181
|
});
|
|
1173
1182
|
//#endregion
|
|
1174
|
-
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 };
|