@object-ui/plugin-report 17.2.0 → 17.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +443 -0
- package/README.md +0 -12
- package/dist/index.js +374 -356
- package/dist/index.umd.cjs +2 -2
- package/dist/useDatasetDimensionLabels.d.ts +71 -0
- package/package.json +17 -17
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, pivotDimensionValue as c, relabelDimensions as l } from "@object-ui/core";
|
|
2
|
+
import * as u from "react";
|
|
3
|
+
import d from "react";
|
|
4
|
+
import { isSpecReport as f, specReportToPresentation as p } from "@object-ui/types";
|
|
5
|
+
import { SchemaRenderer as m, SchemaRendererContext as h, toRenderableSchema as g, useDatasetDimensionLabels as _ } from "@object-ui/react";
|
|
6
|
+
import { Badge as v, Button as y, Card as b, CardContent as x, CardDescription as S, CardHeader as C, CardTitle as w, Skeleton as T } from "@object-ui/components";
|
|
7
|
+
import { jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
8
|
+
import { AlertTriangle as O, Download as k, Loader2 as A, Printer as j, RefreshCw as M, Table2 as N } from "lucide-react";
|
|
9
|
+
import { getCellRenderer as ee, resolveCellRendererType as P } from "@object-ui/fields";
|
|
10
|
+
import { useDisplayLocale as F, useSafeFieldLabel as I, useSafeTranslate as L } from "@object-ui/i18n";
|
|
11
11
|
//#region src/LegacyReportRenderer.tsx
|
|
12
|
-
var
|
|
12
|
+
var R = ({ 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__ */ D(b, {
|
|
17
17
|
className: `h-full flex flex-col ${t.className || ""}`,
|
|
18
|
-
children: [/* @__PURE__ */
|
|
18
|
+
children: [/* @__PURE__ */ D(C, { children: [n && /* @__PURE__ */ E(w, { children: n }), r && /* @__PURE__ */ E(S, { children: r })] }), /* @__PURE__ */ D(x, {
|
|
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__ */ E("div", {
|
|
23
23
|
className: "min-h-[300px] border rounded-lg p-4 bg-background/50",
|
|
24
|
-
children: /* @__PURE__ */
|
|
24
|
+
children: /* @__PURE__ */ E(r, { schema: {
|
|
25
25
|
...t.chart,
|
|
26
26
|
data: t.chart.data || i
|
|
27
27
|
} })
|
|
28
|
-
}) : /* @__PURE__ */
|
|
28
|
+
}) : /* @__PURE__ */ D("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__ */ E("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__ */ E(t, { schema: {
|
|
37
37
|
type: "grid",
|
|
38
38
|
rowData: i,
|
|
39
39
|
columnDefs: a,
|
|
40
40
|
domLayout: "autoHeight"
|
|
41
|
-
} }) : /* @__PURE__ */
|
|
41
|
+
} }) : /* @__PURE__ */ E("div", {
|
|
42
42
|
className: "overflow-x-auto",
|
|
43
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ D("table", {
|
|
44
44
|
className: "w-full text-sm text-left",
|
|
45
|
-
children: [/* @__PURE__ */
|
|
45
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
46
46
|
className: "text-xs uppercase bg-muted",
|
|
47
|
-
children: /* @__PURE__ */
|
|
47
|
+
children: /* @__PURE__ */ E("tr", { children: a?.map((e) => /* @__PURE__ */ E("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__ */ E("tbody", { children: i.map((e, t) => /* @__PURE__ */ E("tr", {
|
|
52
52
|
className: "bg-background border-b",
|
|
53
|
-
children: a?.map((t) => /* @__PURE__ */
|
|
53
|
+
children: a?.map((t) => /* @__PURE__ */ E("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 te(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 = ie(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
|
|
71
71
|
}));
|
|
72
|
-
|
|
72
|
+
U([...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 ne(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
|
+
U(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 z(e, t, n) {
|
|
84
|
+
let r = e.fields || [], i = oe(n?.orientation), a = ae(n?.pageSize);
|
|
85
|
+
U(`<!DOCTYPE html>
|
|
86
86
|
<html>
|
|
87
87
|
<head>
|
|
88
88
|
<meta charset="utf-8">
|
|
89
|
-
<title>${
|
|
89
|
+
<title>${H(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>${H(e.title || "Report")}</h1>
|
|
104
|
+
${e.description ? `<p class="description">${H(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>${H(e.label || e.name)}</th>`).join("")}</tr></thead>
|
|
108
|
+
<tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${H(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 re(e, t, n) {
|
|
114
|
+
let r = e.fields || [], i = oe(n?.orientation), a = ae(n?.pageSize), o = window.open("", "_blank");
|
|
115
115
|
if (!o) {
|
|
116
|
-
|
|
116
|
+
z(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>${H(e.title || "Report")}</title>
|
|
128
128
|
<style>
|
|
129
129
|
@page { size: ${a} ${i}; margin: 20mm; }
|
|
130
130
|
@media print { .no-print { display: none; } }
|
|
@@ -139,56 +139,56 @@ function te(e, t, n) {
|
|
|
139
139
|
</style>
|
|
140
140
|
</head>
|
|
141
141
|
<body>
|
|
142
|
-
<h1>${
|
|
143
|
-
${e.description ? `<p class="description">${
|
|
142
|
+
<h1>${H(e.title || "Report")}</h1>
|
|
143
|
+
${e.description ? `<p class="description">${H(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>${H(e.label || e.name)}</th>`).join("")}</tr></thead>
|
|
147
|
+
<tbody>${t.map((e) => `<tr>${r.map((t) => `<td>${H(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 B(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 = ie(n), typeof n == "string" && (n.includes(",") || n.includes("\"") || n.includes("\n") || n.includes(" ")) ? `"${n.replace(/"/g, "\"\"")}"` : n ?? "";
|
|
158
158
|
}));
|
|
159
|
-
|
|
159
|
+
U("" + [...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 V(e, t, n, r) {
|
|
162
162
|
switch (e) {
|
|
163
163
|
case "csv":
|
|
164
|
-
|
|
164
|
+
te(t, n, r);
|
|
165
165
|
break;
|
|
166
166
|
case "json":
|
|
167
|
-
|
|
167
|
+
ne(t, n, r);
|
|
168
168
|
break;
|
|
169
169
|
case "html":
|
|
170
|
-
|
|
170
|
+
z(t, n, r);
|
|
171
171
|
break;
|
|
172
172
|
case "pdf":
|
|
173
|
-
|
|
173
|
+
re(t, n, r);
|
|
174
174
|
break;
|
|
175
175
|
case "excel":
|
|
176
|
-
|
|
176
|
+
B(t, n, r);
|
|
177
177
|
break;
|
|
178
178
|
default: console.warn(`Unsupported export format: ${e}`);
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function H(e) {
|
|
182
182
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function ie(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}`;
|
|
188
188
|
}
|
|
189
189
|
return e;
|
|
190
190
|
}
|
|
191
|
-
function
|
|
191
|
+
function ae(e) {
|
|
192
192
|
return [
|
|
193
193
|
"A4",
|
|
194
194
|
"A3",
|
|
@@ -196,19 +196,19 @@ function ne(e) {
|
|
|
196
196
|
"Legal"
|
|
197
197
|
].includes(e || "") ? e : "A4";
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
function oe(e) {
|
|
200
200
|
return e === "landscape" ? "landscape" : "portrait";
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function U(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 W(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" || se(e)) return ce(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 se(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 ce(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 le(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 ue(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 G = ({ schema: e, onRefresh: t }) => {
|
|
270
|
+
let { report: n, data: r, showToolbar: i = !0, allowExport: a = !0, allowPrint: o = !0, loading: s = !1 } = e, c = L(), l = (e) => {
|
|
271
271
|
if (!n) {
|
|
272
272
|
console.warn("ReportViewer: Cannot export, no report defined");
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
|
|
276
|
-
},
|
|
275
|
+
V(e, n, r || [], n.exportConfigs?.[e]);
|
|
276
|
+
}, u = c("common.printDialogHint", "Opens your browser’s print dialog (not a PDF export)"), f = () => {
|
|
277
277
|
window.print();
|
|
278
|
-
},
|
|
278
|
+
}, p = () => {
|
|
279
279
|
t?.();
|
|
280
|
-
},
|
|
280
|
+
}, h = (e, t) => ue(r, e, t), _ = (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,156 @@ 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
|
+
}, O = (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__ */ E(v, {
|
|
310
|
+
className: n,
|
|
311
|
+
children: String(e)
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (t.aggregation) return W(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 = ee(P(n));
|
|
323
|
+
return /* @__PURE__ */ E(r, {
|
|
321
324
|
value: e,
|
|
322
325
|
field: n
|
|
323
326
|
});
|
|
324
327
|
}
|
|
325
|
-
return
|
|
328
|
+
return W(e, t);
|
|
326
329
|
};
|
|
327
|
-
return n ? /* @__PURE__ */
|
|
330
|
+
return n ? /* @__PURE__ */ D("div", {
|
|
328
331
|
className: "space-y-4",
|
|
329
|
-
children: [i && /* @__PURE__ */
|
|
332
|
+
children: [i && /* @__PURE__ */ D("div", {
|
|
330
333
|
className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
|
|
331
|
-
children: [/* @__PURE__ */
|
|
334
|
+
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("h2", {
|
|
332
335
|
className: "text-lg font-semibold",
|
|
333
336
|
children: n.title
|
|
334
|
-
}), n.description && /* @__PURE__ */
|
|
337
|
+
}), n.description && /* @__PURE__ */ E("p", {
|
|
335
338
|
className: "text-sm text-muted-foreground",
|
|
336
339
|
children: n.description
|
|
337
|
-
})] }), /* @__PURE__ */
|
|
340
|
+
})] }), /* @__PURE__ */ D("div", {
|
|
338
341
|
className: "flex items-center gap-2",
|
|
342
|
+
"data-print-hide": !0,
|
|
339
343
|
children: [
|
|
340
|
-
n.refreshInterval && /* @__PURE__ */
|
|
344
|
+
n.refreshInterval && /* @__PURE__ */ D(y, {
|
|
341
345
|
variant: "outline",
|
|
342
346
|
size: "sm",
|
|
343
|
-
onClick:
|
|
344
|
-
children: [/* @__PURE__ */
|
|
347
|
+
onClick: p,
|
|
348
|
+
children: [/* @__PURE__ */ E(M, { className: "h-4 w-4 mr-2" }), "Refresh"]
|
|
345
349
|
}),
|
|
346
|
-
o && /* @__PURE__ */
|
|
350
|
+
o && /* @__PURE__ */ D(y, {
|
|
347
351
|
variant: "outline",
|
|
348
352
|
size: "sm",
|
|
349
|
-
onClick:
|
|
350
|
-
|
|
353
|
+
onClick: f,
|
|
354
|
+
"aria-label": `Print: ${u}`,
|
|
355
|
+
title: u,
|
|
356
|
+
children: [/* @__PURE__ */ E(j, { className: "h-4 w-4 mr-2" }), "Print"]
|
|
351
357
|
}),
|
|
352
|
-
a && n.showExportButtons && /* @__PURE__ */
|
|
358
|
+
a && n.showExportButtons && /* @__PURE__ */ D("div", {
|
|
353
359
|
className: "flex items-center gap-1",
|
|
354
360
|
children: [
|
|
355
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ D(y, {
|
|
356
362
|
variant: "outline",
|
|
357
363
|
size: "sm",
|
|
358
364
|
onClick: () => l("pdf"),
|
|
359
|
-
children: [/* @__PURE__ */
|
|
365
|
+
children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "PDF"]
|
|
360
366
|
}),
|
|
361
|
-
/* @__PURE__ */
|
|
367
|
+
/* @__PURE__ */ D(y, {
|
|
362
368
|
variant: "outline",
|
|
363
369
|
size: "sm",
|
|
364
370
|
onClick: () => l("excel"),
|
|
365
|
-
children: [/* @__PURE__ */
|
|
371
|
+
children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "Excel"]
|
|
366
372
|
}),
|
|
367
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ D(y, {
|
|
368
374
|
variant: "outline",
|
|
369
375
|
size: "sm",
|
|
370
376
|
onClick: () => l("csv"),
|
|
371
|
-
children: [/* @__PURE__ */
|
|
377
|
+
children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "CSV"]
|
|
372
378
|
})
|
|
373
379
|
]
|
|
374
380
|
})
|
|
375
381
|
]
|
|
376
382
|
})]
|
|
377
|
-
}), /* @__PURE__ */
|
|
383
|
+
}), /* @__PURE__ */ D(b, { children: [/* @__PURE__ */ D(C, { children: [!i && n.title && /* @__PURE__ */ E(w, { children: n.title }), !i && n.description && /* @__PURE__ */ E(S, { children: n.description })] }), /* @__PURE__ */ D(x, {
|
|
378
384
|
className: "space-y-6",
|
|
379
385
|
children: [
|
|
380
|
-
|
|
386
|
+
s && /* @__PURE__ */ D("div", {
|
|
381
387
|
className: "space-y-6",
|
|
382
|
-
children: [/* @__PURE__ */
|
|
388
|
+
children: [/* @__PURE__ */ E("div", {
|
|
383
389
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
384
390
|
children: [
|
|
385
391
|
1,
|
|
386
392
|
2,
|
|
387
393
|
3
|
|
388
|
-
].map((e) => /* @__PURE__ */ b
|
|
394
|
+
].map((e) => /* @__PURE__ */ E(b, { children: /* @__PURE__ */ D(x, {
|
|
389
395
|
className: "p-4 space-y-2",
|
|
390
|
-
children: [/* @__PURE__ */
|
|
396
|
+
children: [/* @__PURE__ */ E(T, { className: "h-4 w-20" }), /* @__PURE__ */ E(T, { className: "h-8 w-28" })]
|
|
391
397
|
}) }, e))
|
|
392
|
-
}), /* @__PURE__ */
|
|
398
|
+
}), /* @__PURE__ */ D("div", {
|
|
393
399
|
className: "space-y-2",
|
|
394
|
-
children: [/* @__PURE__ */
|
|
400
|
+
children: [/* @__PURE__ */ E(T, { className: "h-10 w-full" }), [
|
|
395
401
|
1,
|
|
396
402
|
2,
|
|
397
403
|
3,
|
|
398
404
|
4,
|
|
399
405
|
5
|
|
400
|
-
].map((e) => /* @__PURE__ */
|
|
406
|
+
].map((e) => /* @__PURE__ */ E(T, { className: "h-8 w-full" }, e))]
|
|
401
407
|
})]
|
|
402
408
|
}),
|
|
403
|
-
!
|
|
409
|
+
!s && n.sections?.map((e, t) => e.visible === !1 ? null : /* @__PURE__ */ D("div", {
|
|
404
410
|
className: "space-y-2",
|
|
405
411
|
children: [
|
|
406
|
-
e.title && e.type !== "header" && /* @__PURE__ */
|
|
412
|
+
e.title && e.type !== "header" && /* @__PURE__ */ E("h3", {
|
|
407
413
|
className: "text-lg font-semibold border-b pb-2",
|
|
408
414
|
children: e.title
|
|
409
415
|
}),
|
|
410
|
-
e.type === "header" && e.title && /* @__PURE__ */
|
|
416
|
+
e.type === "header" && e.title && /* @__PURE__ */ E("div", {
|
|
411
417
|
className: "text-2xl font-bold py-4",
|
|
412
418
|
children: e.title
|
|
413
419
|
}),
|
|
414
|
-
e.type === "summary" && /* @__PURE__ */
|
|
420
|
+
e.type === "summary" && /* @__PURE__ */ E("div", {
|
|
415
421
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
416
|
-
children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ b
|
|
422
|
+
children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ E(b, { children: /* @__PURE__ */ D(x, {
|
|
417
423
|
className: "p-4",
|
|
418
|
-
children: [/* @__PURE__ */
|
|
424
|
+
children: [/* @__PURE__ */ E("div", {
|
|
419
425
|
className: "text-sm text-muted-foreground",
|
|
420
426
|
children: e.label || e.name
|
|
421
|
-
}), /* @__PURE__ */
|
|
427
|
+
}), /* @__PURE__ */ E("div", {
|
|
422
428
|
className: "text-2xl font-bold",
|
|
423
|
-
children:
|
|
429
|
+
children: W(h(e.name, e.aggregation), e)
|
|
424
430
|
})]
|
|
425
431
|
}) }, t))
|
|
426
432
|
}),
|
|
427
|
-
e.type === "table" && /* @__PURE__ */
|
|
433
|
+
e.type === "table" && /* @__PURE__ */ E("div", {
|
|
428
434
|
className: "border rounded-lg overflow-x-auto",
|
|
429
|
-
children: /* @__PURE__ */
|
|
435
|
+
children: /* @__PURE__ */ D("table", {
|
|
430
436
|
className: "w-full text-sm min-w-[600px]",
|
|
431
|
-
children: [/* @__PURE__ */
|
|
437
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
432
438
|
className: "bg-muted",
|
|
433
|
-
children: /* @__PURE__ */
|
|
439
|
+
children: /* @__PURE__ */ E("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ E("th", {
|
|
434
440
|
className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
|
|
435
441
|
children: e.label || e.name
|
|
436
442
|
}, t)) })
|
|
437
|
-
}), /* @__PURE__ */
|
|
438
|
-
let t =
|
|
439
|
-
return t ? t.map((t) => /* @__PURE__ */
|
|
443
|
+
}), /* @__PURE__ */ E("tbody", { children: (() => {
|
|
444
|
+
let t = le(r || [], n.groupBy || []);
|
|
445
|
+
return t ? t.map((t) => /* @__PURE__ */ D(d.Fragment, { children: [/* @__PURE__ */ E("tr", {
|
|
440
446
|
className: "bg-muted/60",
|
|
441
|
-
children: /* @__PURE__ */
|
|
447
|
+
children: /* @__PURE__ */ D("td", {
|
|
442
448
|
colSpan: e.columns?.length || 1,
|
|
443
449
|
className: "px-4 py-2 font-semibold text-sm",
|
|
444
450
|
children: [
|
|
@@ -448,73 +454,73 @@ var V = ({ schema: e, onRefresh: t }) => {
|
|
|
448
454
|
")"
|
|
449
455
|
]
|
|
450
456
|
})
|
|
451
|
-
}), t.rows.map((t, n) => /* @__PURE__ */
|
|
457
|
+
}), t.rows.map((t, n) => /* @__PURE__ */ E("tr", {
|
|
452
458
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
453
|
-
children: e.columns?.map((e, n) => /* @__PURE__ */
|
|
459
|
+
children: e.columns?.map((e, n) => /* @__PURE__ */ E("td", {
|
|
454
460
|
className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
455
|
-
style:
|
|
456
|
-
children:
|
|
461
|
+
style: _(e.name, t[e.name]),
|
|
462
|
+
children: O(t[e.name], e)
|
|
457
463
|
}, n))
|
|
458
|
-
}, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */
|
|
464
|
+
}, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */ E("tr", {
|
|
459
465
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
460
|
-
children: e.columns?.map((e, n) => /* @__PURE__ */
|
|
466
|
+
children: e.columns?.map((e, n) => /* @__PURE__ */ E("td", {
|
|
461
467
|
className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
462
|
-
style:
|
|
463
|
-
children:
|
|
468
|
+
style: _(e.name, t[e.name]),
|
|
469
|
+
children: O(t[e.name], e)
|
|
464
470
|
}, n))
|
|
465
471
|
}, n));
|
|
466
472
|
})() })]
|
|
467
473
|
})
|
|
468
474
|
}),
|
|
469
|
-
e.type === "text" && e.text && /* @__PURE__ */
|
|
475
|
+
e.type === "text" && e.text && /* @__PURE__ */ E("div", {
|
|
470
476
|
className: "prose max-w-none",
|
|
471
|
-
children: /* @__PURE__ */
|
|
477
|
+
children: /* @__PURE__ */ E("p", { children: e.text })
|
|
472
478
|
}),
|
|
473
|
-
e.type === "page-break" && /* @__PURE__ */
|
|
474
|
-
e.content && /* @__PURE__ */
|
|
479
|
+
e.type === "page-break" && /* @__PURE__ */ E("div", { className: "border-t-2 border-dashed my-8 print:page-break-after-always" }),
|
|
480
|
+
Array.isArray(e.content) ? e.content.map((e, t) => /* @__PURE__ */ E(m, { schema: g(e) }, t)) : e.content && /* @__PURE__ */ E(m, { schema: g(e.content) })
|
|
475
481
|
]
|
|
476
482
|
}, t)),
|
|
477
|
-
!n.sections && r && r.length > 0 && /* @__PURE__ */
|
|
483
|
+
!n.sections && r && r.length > 0 && /* @__PURE__ */ E("div", {
|
|
478
484
|
className: "border rounded-lg overflow-x-auto",
|
|
479
|
-
children: /* @__PURE__ */
|
|
485
|
+
children: /* @__PURE__ */ D("table", {
|
|
480
486
|
className: "w-full text-sm min-w-[600px]",
|
|
481
|
-
children: [/* @__PURE__ */
|
|
487
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
482
488
|
className: "bg-muted",
|
|
483
|
-
children: /* @__PURE__ */
|
|
489
|
+
children: /* @__PURE__ */ E("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ E("th", {
|
|
484
490
|
className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
|
|
485
491
|
children: e.label || e.name
|
|
486
492
|
}, t)) })
|
|
487
|
-
}), /* @__PURE__ */
|
|
493
|
+
}), /* @__PURE__ */ E("tbody", { children: r.map((e, t) => /* @__PURE__ */ E("tr", {
|
|
488
494
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
489
|
-
children: n.fields?.map((t, n) => /* @__PURE__ */
|
|
495
|
+
children: n.fields?.map((t, n) => /* @__PURE__ */ E("td", {
|
|
490
496
|
className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
491
|
-
style:
|
|
492
|
-
children:
|
|
497
|
+
style: _(t.name, e[t.name]),
|
|
498
|
+
children: O(e[t.name], t)
|
|
493
499
|
}, n))
|
|
494
500
|
}, t)) })]
|
|
495
501
|
})
|
|
496
502
|
})
|
|
497
503
|
]
|
|
498
504
|
})] })]
|
|
499
|
-
}) : /* @__PURE__ */ b
|
|
505
|
+
}) : /* @__PURE__ */ E(b, { children: /* @__PURE__ */ E(x, {
|
|
500
506
|
className: "p-8 text-center text-muted-foreground",
|
|
501
507
|
children: "No report to display"
|
|
502
508
|
}) });
|
|
503
509
|
};
|
|
504
510
|
//#endregion
|
|
505
511
|
//#region src/DatasetReportRenderer.tsx
|
|
506
|
-
function
|
|
512
|
+
function K(e) {
|
|
507
513
|
if (!e || typeof e != "object") return !1;
|
|
508
514
|
let t = e;
|
|
509
515
|
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
516
|
}
|
|
511
|
-
function
|
|
517
|
+
function de(e, t) {
|
|
512
518
|
return e ? typeof e == "string" ? e : typeof e == "object" && typeof e.default == "string" ? e.default : t : t;
|
|
513
519
|
}
|
|
514
|
-
function
|
|
520
|
+
function q(e) {
|
|
515
521
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && !!e) : [];
|
|
516
522
|
}
|
|
517
|
-
function
|
|
523
|
+
function fe(e) {
|
|
518
524
|
if (!Array.isArray(e)) return;
|
|
519
525
|
let t = {};
|
|
520
526
|
for (let n of e) {
|
|
@@ -523,21 +529,21 @@ function G(e) {
|
|
|
523
529
|
}
|
|
524
530
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
525
531
|
}
|
|
526
|
-
function
|
|
532
|
+
function pe(e, t, n) {
|
|
527
533
|
if (!e) return;
|
|
528
534
|
let r = /* @__PURE__ */ new Set([...t, ...n]), i = {};
|
|
529
535
|
for (let [t, n] of Object.entries(e)) r.has(t) && (i[t] = n);
|
|
530
536
|
return Object.keys(i).length > 0 ? i : void 0;
|
|
531
537
|
}
|
|
532
|
-
function
|
|
533
|
-
let [
|
|
538
|
+
function J(e, t, n, r, i, a, o) {
|
|
539
|
+
let [s, c] = u.useState({
|
|
534
540
|
status: "idle",
|
|
535
541
|
rows: []
|
|
536
|
-
}),
|
|
537
|
-
return
|
|
542
|
+
}), l = pe(o, t, n), d = JSON.stringify(r ?? null), f = JSON.stringify(a ?? null), p = JSON.stringify(l ?? null), m = `${e}|${t.join(",")}|${n.join(",")}|${d}|${f}|${p}`;
|
|
543
|
+
return u.useEffect(() => {
|
|
538
544
|
let o = i;
|
|
539
545
|
if (!o || typeof o.queryDataset != "function") {
|
|
540
|
-
|
|
546
|
+
c({
|
|
541
547
|
status: "error",
|
|
542
548
|
rows: [],
|
|
543
549
|
error: "This data source does not support dataset queries."
|
|
@@ -545,14 +551,14 @@ function K(e, t, n, r, i, a, s) {
|
|
|
545
551
|
return;
|
|
546
552
|
}
|
|
547
553
|
if (!e || n.length === 0) {
|
|
548
|
-
|
|
554
|
+
c({
|
|
549
555
|
status: "idle",
|
|
550
556
|
rows: []
|
|
551
557
|
});
|
|
552
558
|
return;
|
|
553
559
|
}
|
|
554
560
|
let s = !1;
|
|
555
|
-
return
|
|
561
|
+
return c({
|
|
556
562
|
status: "loading",
|
|
557
563
|
rows: []
|
|
558
564
|
}), o.queryDataset(e, {
|
|
@@ -560,9 +566,9 @@ function K(e, t, n, r, i, a, s) {
|
|
|
560
566
|
measures: n,
|
|
561
567
|
...r && Object.keys(r).length > 0 ? { runtimeFilter: r } : {},
|
|
562
568
|
...a ? { totals: { groupings: a } } : {},
|
|
563
|
-
...
|
|
569
|
+
...l ? { order: l } : {}
|
|
564
570
|
}).then((e) => {
|
|
565
|
-
s ||
|
|
571
|
+
s || c({
|
|
566
572
|
status: "ok",
|
|
567
573
|
rows: Array.isArray(e?.rows) ? e.rows : [],
|
|
568
574
|
fields: Array.isArray(e?.fields) ? e.fields : [],
|
|
@@ -573,7 +579,7 @@ function K(e, t, n, r, i, a, s) {
|
|
|
573
579
|
totals: Array.isArray(e?.totals) ? e.totals : void 0
|
|
574
580
|
});
|
|
575
581
|
}).catch((e) => {
|
|
576
|
-
s ||
|
|
582
|
+
s || c({
|
|
577
583
|
status: "error",
|
|
578
584
|
rows: [],
|
|
579
585
|
error: String(e?.message ?? e)
|
|
@@ -581,10 +587,10 @@ function K(e, t, n, r, i, a, s) {
|
|
|
581
587
|
}), () => {
|
|
582
588
|
s = !0;
|
|
583
589
|
};
|
|
584
|
-
}, [m]),
|
|
590
|
+
}, [m]), s;
|
|
585
591
|
}
|
|
586
|
-
function
|
|
587
|
-
return /* @__PURE__ */
|
|
592
|
+
function me({ dataset: e }) {
|
|
593
|
+
return /* @__PURE__ */ D("div", {
|
|
588
594
|
className: "flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
589
595
|
children: [
|
|
590
596
|
"This report binds the “",
|
|
@@ -593,81 +599,81 @@ function q({ dataset: e }) {
|
|
|
593
599
|
]
|
|
594
600
|
});
|
|
595
601
|
}
|
|
596
|
-
function
|
|
597
|
-
return e === "error" ? /* @__PURE__ */
|
|
602
|
+
function Y({ status: e, error: t }) {
|
|
603
|
+
return e === "error" ? /* @__PURE__ */ D("div", {
|
|
598
604
|
role: "alert",
|
|
599
605
|
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__ */
|
|
606
|
+
children: [/* @__PURE__ */ E(O, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ E("span", {
|
|
601
607
|
className: "break-words",
|
|
602
608
|
children: t
|
|
603
609
|
})]
|
|
604
|
-
}) : /* @__PURE__ */
|
|
610
|
+
}) : /* @__PURE__ */ D("div", {
|
|
605
611
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
606
|
-
children: [/* @__PURE__ */
|
|
612
|
+
children: [/* @__PURE__ */ E(A, { className: "h-4 w-4 animate-spin" }), " Running report…"]
|
|
607
613
|
});
|
|
608
614
|
}
|
|
609
|
-
function
|
|
610
|
-
return /* @__PURE__ */
|
|
615
|
+
function he() {
|
|
616
|
+
return /* @__PURE__ */ D("div", {
|
|
611
617
|
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__ */
|
|
618
|
+
children: [/* @__PURE__ */ E(N, { className: "h-6 w-6" }), " The dataset returned no rows for this report’s scope."]
|
|
613
619
|
});
|
|
614
620
|
}
|
|
615
|
-
var
|
|
616
|
-
function
|
|
617
|
-
let
|
|
618
|
-
if (o.length === 0) return /* @__PURE__ */
|
|
619
|
-
if (
|
|
620
|
-
if (
|
|
621
|
+
var ge = "cursor-pointer hover:bg-accent/40";
|
|
622
|
+
function _e({ dataset: e, rows: a, values: o, runtimeFilter: s, dataSource: c, onDrill: u, order: d, withTotals: f }) {
|
|
623
|
+
let p = J(e, a, o, s, c, f && a.length > 0 ? [[]] : void 0, d), { fieldLabel: m } = I(), h = L(), g = F(), v = _(p.object, p.dimensionFields, a);
|
|
624
|
+
if (o.length === 0) return /* @__PURE__ */ E(me, { dataset: e });
|
|
625
|
+
if (p.status === "loading" || p.status === "idle") return /* @__PURE__ */ E(Y, { status: p.status });
|
|
626
|
+
if (p.status === "error") return /* @__PURE__ */ E(Y, {
|
|
621
627
|
status: "error",
|
|
622
|
-
error:
|
|
628
|
+
error: p.error
|
|
623
629
|
});
|
|
624
|
-
if (
|
|
625
|
-
let
|
|
630
|
+
if (p.rows.length === 0) return /* @__PURE__ */ E(he, {});
|
|
631
|
+
let y = !!u && a.length > 0, b = p.dimensionFields ? a.filter((e) => e in p.dimensionFields) : [], x = (n, r) => {
|
|
626
632
|
let i = {};
|
|
627
633
|
for (let e of a) i[e] = n[e];
|
|
628
|
-
let o =
|
|
629
|
-
|
|
634
|
+
let o = p.drillRanges?.[r], c = !!o && Object.keys(o).length > 0, l = p.object && (b.length > 0 || c) ? t(p.drillRawRows?.[r], b, p.dimensionFields ?? {}, s, o) : void 0;
|
|
635
|
+
u({
|
|
630
636
|
dataset: e,
|
|
631
637
|
groupKey: i,
|
|
632
638
|
runtimeFilter: s,
|
|
633
|
-
object:
|
|
634
|
-
objectFilter:
|
|
639
|
+
object: p.object,
|
|
640
|
+
objectFilter: l
|
|
635
641
|
});
|
|
636
|
-
}, { measureField:
|
|
637
|
-
return /* @__PURE__ */
|
|
642
|
+
}, { measureField: S, headerLabel: C } = n(p.fields, p.object, m), w = [...a, ...o], T = l(p.rows, v), O = f ? p.totals?.find((e) => Array.isArray(e.dimensions) && e.dimensions.length === 0)?.rows?.[0] : void 0, k = h("report.total", "Total");
|
|
643
|
+
return /* @__PURE__ */ E("div", {
|
|
638
644
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
639
|
-
children: /* @__PURE__ */
|
|
645
|
+
children: /* @__PURE__ */ D("table", {
|
|
640
646
|
className: "w-full text-xs",
|
|
641
|
-
children: [/* @__PURE__ */
|
|
647
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
642
648
|
className: "bg-muted/40",
|
|
643
|
-
children: /* @__PURE__ */
|
|
649
|
+
children: /* @__PURE__ */ E("tr", { children: w.map((e) => /* @__PURE__ */ E("th", {
|
|
644
650
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
645
|
-
children:
|
|
651
|
+
children: C(e)
|
|
646
652
|
}, e)) })
|
|
647
|
-
}), /* @__PURE__ */
|
|
648
|
-
className: `border-t${
|
|
649
|
-
"data-testid":
|
|
650
|
-
onClick:
|
|
651
|
-
children:
|
|
653
|
+
}), /* @__PURE__ */ D("tbody", { children: [T.map((e, t) => /* @__PURE__ */ E("tr", {
|
|
654
|
+
className: `border-t${y ? ` ${ge}` : ""}`,
|
|
655
|
+
"data-testid": y ? "dataset-drill-row" : void 0,
|
|
656
|
+
onClick: y ? () => x(p.rows[t], t) : void 0,
|
|
657
|
+
children: w.map((t) => /* @__PURE__ */ E("td", {
|
|
652
658
|
className: "px-2 py-1 tabular-nums whitespace-nowrap",
|
|
653
|
-
children: o.includes(t) ? i(e[t],
|
|
659
|
+
children: o.includes(t) ? i(e[t], S(t)?.format, S(t)?.currency, S(t)?.percentScale, g) : r(e[t], g)
|
|
654
660
|
}, t))
|
|
655
|
-
}, t)),
|
|
661
|
+
}, t)), O && /* @__PURE__ */ D("tr", {
|
|
656
662
|
className: "border-t bg-muted/30 font-medium",
|
|
657
663
|
"data-testid": "dataset-report-total-row",
|
|
658
|
-
children: [a.length > 0 && /* @__PURE__ */
|
|
664
|
+
children: [a.length > 0 && /* @__PURE__ */ E("td", {
|
|
659
665
|
colSpan: a.length,
|
|
660
666
|
className: "px-2 py-1 whitespace-nowrap",
|
|
661
|
-
children:
|
|
662
|
-
}), o.map((e) => /* @__PURE__ */
|
|
667
|
+
children: k
|
|
668
|
+
}), o.map((e) => /* @__PURE__ */ E("td", {
|
|
663
669
|
className: "px-2 py-1 tabular-nums whitespace-nowrap",
|
|
664
|
-
children: i(
|
|
670
|
+
children: i(O[e], S(e)?.format, S(e)?.currency, S(e)?.percentScale, g)
|
|
665
671
|
}, e))]
|
|
666
672
|
})] })]
|
|
667
673
|
})
|
|
668
674
|
});
|
|
669
675
|
}
|
|
670
|
-
function
|
|
676
|
+
function ve(e) {
|
|
671
677
|
switch (e) {
|
|
672
678
|
case "summary": return "summary";
|
|
673
679
|
case "matrix": return "matrix";
|
|
@@ -675,7 +681,7 @@ function de(e) {
|
|
|
675
681
|
default: return "tabular";
|
|
676
682
|
}
|
|
677
683
|
}
|
|
678
|
-
function
|
|
684
|
+
function ye(e) {
|
|
679
685
|
switch (e) {
|
|
680
686
|
case "bar":
|
|
681
687
|
case "column":
|
|
@@ -706,9 +712,9 @@ function fe(e) {
|
|
|
706
712
|
};
|
|
707
713
|
}
|
|
708
714
|
}
|
|
709
|
-
function
|
|
710
|
-
let [, n] =
|
|
711
|
-
return
|
|
715
|
+
function be(t) {
|
|
716
|
+
let [, n] = u.useReducer((e) => e + 1, 0);
|
|
717
|
+
return u.useEffect(() => {
|
|
712
718
|
if (e.get(t)) return;
|
|
713
719
|
let r = typeof e.subscribe == "function" ? e.subscribe(() => {
|
|
714
720
|
e.get(t) && n();
|
|
@@ -716,53 +722,53 @@ function pe(t) {
|
|
|
716
722
|
return i && typeof i.then == "function" && i.then(() => n()).catch(() => {}), r;
|
|
717
723
|
}, [t]), e.get(t);
|
|
718
724
|
}
|
|
719
|
-
function
|
|
720
|
-
let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "",
|
|
721
|
-
if (
|
|
722
|
-
if (
|
|
725
|
+
function xe({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o }) {
|
|
726
|
+
let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "", d = ye(t.type), f = d.kind === "series" || d.kind === "single_value", p = J(e, d.kind === "series" && s ? [s] : [], f && c ? [c] : [], r, a, void 0, o), m = be("chart"), { fieldLabel: h } = I(), g = F(), v = u.useMemo(() => s ? [s] : [], [s]), y = _(p.object, p.dimensionFields, v), b = typeof t.title == "string" ? t.title : void 0;
|
|
727
|
+
if (d.kind === "tabular") return null;
|
|
728
|
+
if (d.kind === "unsupported") return /* @__PURE__ */ D("div", {
|
|
723
729
|
className: "rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
|
|
724
730
|
"data-testid": "dataset-report-chart-unsupported",
|
|
725
731
|
children: [
|
|
726
732
|
"Chart type “",
|
|
727
|
-
|
|
733
|
+
d.type,
|
|
728
734
|
"” is not a spec chart type — the grouped table below carries this report’s numbers."
|
|
729
735
|
]
|
|
730
736
|
});
|
|
731
|
-
if (
|
|
732
|
-
if (
|
|
737
|
+
if (d.kind === "series" && !s || !c) return null;
|
|
738
|
+
if (p.status === "loading" || p.status === "idle") return /* @__PURE__ */ D("div", {
|
|
733
739
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
734
|
-
children: [/* @__PURE__ */
|
|
740
|
+
children: [/* @__PURE__ */ E(A, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
|
|
735
741
|
});
|
|
736
|
-
if (
|
|
737
|
-
if (
|
|
738
|
-
let { measureField: e, headerLabel: t } = n(
|
|
739
|
-
return /* @__PURE__ */
|
|
742
|
+
if (p.status === "error" || p.rows.length === 0) return null;
|
|
743
|
+
if (d.kind === "single_value") {
|
|
744
|
+
let { measureField: e, headerLabel: t } = n(p.fields, p.object, h), r = e(c);
|
|
745
|
+
return /* @__PURE__ */ D("div", {
|
|
740
746
|
className: "rounded-md border bg-card p-3",
|
|
741
747
|
"data-testid": "dataset-report-metric",
|
|
742
|
-
children: [
|
|
748
|
+
children: [b ? /* @__PURE__ */ E("h3", {
|
|
743
749
|
className: "mb-2 text-sm font-semibold",
|
|
744
|
-
children:
|
|
745
|
-
}) : null, /* @__PURE__ */
|
|
750
|
+
children: b
|
|
751
|
+
}) : null, /* @__PURE__ */ D("div", {
|
|
746
752
|
className: "flex flex-col gap-0.5 py-2",
|
|
747
|
-
children: [/* @__PURE__ */
|
|
753
|
+
children: [/* @__PURE__ */ E("span", {
|
|
748
754
|
className: "text-2xl font-semibold tabular-nums",
|
|
749
|
-
children: i(
|
|
750
|
-
}), /* @__PURE__ */
|
|
755
|
+
children: i(p.rows[0]?.[c], r?.format, r?.currency, r?.percentScale, g)
|
|
756
|
+
}), /* @__PURE__ */ E("span", {
|
|
751
757
|
className: "text-xs text-muted-foreground",
|
|
752
758
|
children: t(c)
|
|
753
759
|
})]
|
|
754
760
|
})]
|
|
755
761
|
});
|
|
756
762
|
}
|
|
757
|
-
return
|
|
763
|
+
return m ? /* @__PURE__ */ D("div", {
|
|
758
764
|
className: "rounded-md border bg-card p-3",
|
|
759
765
|
"data-testid": "dataset-report-chart",
|
|
760
|
-
children: [
|
|
766
|
+
children: [b ? /* @__PURE__ */ E("h3", {
|
|
761
767
|
className: "mb-2 text-sm font-semibold",
|
|
762
|
-
children:
|
|
763
|
-
}) : null, /* @__PURE__ */
|
|
764
|
-
chartType:
|
|
765
|
-
data:
|
|
768
|
+
children: b
|
|
769
|
+
}) : null, /* @__PURE__ */ E(m, { schema: {
|
|
770
|
+
chartType: d.chartType,
|
|
771
|
+
data: l(p.rows, y),
|
|
766
772
|
xAxisKey: s,
|
|
767
773
|
series: [{ dataKey: c }],
|
|
768
774
|
height: typeof t.height == "number" ? t.height : 280,
|
|
@@ -771,44 +777,46 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
|
|
|
771
777
|
}) : null;
|
|
772
778
|
}
|
|
773
779
|
function X(e, t) {
|
|
774
|
-
return e.map((e) =>
|
|
780
|
+
return o(e.map((e) => c(t[e])));
|
|
775
781
|
}
|
|
776
|
-
function
|
|
777
|
-
return e.map((e) => r(t[e])).join(" / ");
|
|
782
|
+
function Se(e, t, n) {
|
|
783
|
+
return e.map((e) => r(t[e], n)).join(" / ");
|
|
778
784
|
}
|
|
779
|
-
function Z({ dataset: e, rows: a, columnsAcross:
|
|
780
|
-
let
|
|
785
|
+
function Z({ dataset: e, rows: a, columnsAcross: o, values: c, runtimeFilter: d, dataSource: f, onDrill: p, order: m }) {
|
|
786
|
+
let h = J(e, [...a, ...o], c, d, f, [
|
|
781
787
|
a,
|
|
782
|
-
|
|
788
|
+
o,
|
|
783
789
|
[]
|
|
784
|
-
],
|
|
785
|
-
if (
|
|
790
|
+
], m), g = L(), { fieldLabel: v } = I(), y = F(), b = _(h.object, h.dimensionFields, [...a, ...o]), x = u.useMemo(() => {
|
|
791
|
+
if (h.status !== "ok") return null;
|
|
786
792
|
let e = [], t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
787
|
-
return
|
|
788
|
-
let l = X(a,
|
|
789
|
-
if (!n.has(
|
|
790
|
-
n.add(
|
|
791
|
-
let t = {};
|
|
792
|
-
for (let e of a) t[e] =
|
|
793
|
+
return l(h.rows, b).forEach((c, l) => {
|
|
794
|
+
let u = h.rows[l], d = X(a, c), f = X(o, c);
|
|
795
|
+
if (!n.has(d)) {
|
|
796
|
+
n.add(d);
|
|
797
|
+
let t = {}, r = {};
|
|
798
|
+
for (let e of a) t[e] = u[e], r[e] = c[e];
|
|
793
799
|
e.push({
|
|
794
|
-
id:
|
|
795
|
-
label:
|
|
796
|
-
key: t
|
|
800
|
+
id: d,
|
|
801
|
+
label: Se(a, c, y),
|
|
802
|
+
key: t,
|
|
803
|
+
display: r
|
|
797
804
|
});
|
|
798
805
|
}
|
|
799
|
-
if (!r.has(
|
|
800
|
-
r.add(
|
|
801
|
-
let e = {};
|
|
802
|
-
for (let t of
|
|
806
|
+
if (!r.has(f)) {
|
|
807
|
+
r.add(f);
|
|
808
|
+
let e = {}, n = {};
|
|
809
|
+
for (let t of o) e[t] = u[t], n[t] = c[t];
|
|
803
810
|
t.push({
|
|
804
|
-
id:
|
|
805
|
-
label:
|
|
806
|
-
key: e
|
|
811
|
+
id: f,
|
|
812
|
+
label: Se(o, c, y),
|
|
813
|
+
key: e,
|
|
814
|
+
display: n
|
|
807
815
|
});
|
|
808
816
|
}
|
|
809
|
-
i.set(
|
|
810
|
-
row:
|
|
811
|
-
index:
|
|
817
|
+
i.set(s(d, f), {
|
|
818
|
+
row: u,
|
|
819
|
+
index: l
|
|
812
820
|
});
|
|
813
821
|
}), {
|
|
814
822
|
rowHeaders: e,
|
|
@@ -816,108 +824,113 @@ function Z({ dataset: e, rows: a, columnsAcross: s, values: c, runtimeFilter: l,
|
|
|
816
824
|
cells: i
|
|
817
825
|
};
|
|
818
826
|
}, [
|
|
819
|
-
|
|
827
|
+
h,
|
|
820
828
|
a,
|
|
821
|
-
|
|
829
|
+
o,
|
|
830
|
+
b,
|
|
831
|
+
y
|
|
822
832
|
]);
|
|
823
|
-
if (c.length === 0) return /* @__PURE__ */
|
|
824
|
-
if (
|
|
825
|
-
if (
|
|
833
|
+
if (c.length === 0) return /* @__PURE__ */ E(me, { dataset: e });
|
|
834
|
+
if (h.status === "loading" || h.status === "idle") return /* @__PURE__ */ E(Y, { status: h.status });
|
|
835
|
+
if (h.status === "error") return /* @__PURE__ */ E(Y, {
|
|
826
836
|
status: "error",
|
|
827
|
-
error:
|
|
837
|
+
error: h.error
|
|
828
838
|
});
|
|
829
|
-
if (!
|
|
830
|
-
let { measureField:
|
|
831
|
-
let a =
|
|
832
|
-
|
|
839
|
+
if (!x || x.rowHeaders.length === 0) return /* @__PURE__ */ E(he, {});
|
|
840
|
+
let { measureField: S, headerLabel: C } = n(h.fields, h.object, v), w = g("report.total", "Total"), T = !!p, O = h.dimensionFields ? [...a, ...o].filter((e) => e in h.dimensionFields) : [], k = (n, r, i) => {
|
|
841
|
+
let a = h.drillRanges?.[i], o = !!a && Object.keys(a).length > 0, s = h.object && (O.length > 0 || o) ? t(h.drillRawRows?.[i], O, h.dimensionFields ?? {}, d, a) : void 0;
|
|
842
|
+
p({
|
|
833
843
|
dataset: e,
|
|
834
844
|
groupKey: {
|
|
835
845
|
...n,
|
|
836
846
|
...r
|
|
837
847
|
},
|
|
838
|
-
runtimeFilter:
|
|
839
|
-
object:
|
|
848
|
+
runtimeFilter: d,
|
|
849
|
+
object: h.object,
|
|
840
850
|
objectFilter: s
|
|
841
851
|
});
|
|
842
|
-
},
|
|
852
|
+
}, A = x.colHeaders.flatMap((e) => c.map((t) => ({
|
|
843
853
|
col: e,
|
|
844
854
|
measure: t,
|
|
845
|
-
header: c.length === 1 ? e.label : `${e.label} · ${
|
|
846
|
-
}))),
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
let
|
|
851
|
-
|
|
855
|
+
header: c.length === 1 ? e.label : `${e.label} · ${C(t)}`
|
|
856
|
+
}))), j = (e) => {
|
|
857
|
+
let t = h.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows;
|
|
858
|
+
return t && l(t, b);
|
|
859
|
+
}, M = /* @__PURE__ */ new Map();
|
|
860
|
+
for (let e of j(a) ?? []) M.set(X(a, e), e);
|
|
861
|
+
let N = /* @__PURE__ */ new Map();
|
|
862
|
+
for (let e of j(o) ?? []) N.set(X(o, e), e);
|
|
863
|
+
let ee = j([])?.[0], P = M.size > 0, R = N.size > 0;
|
|
864
|
+
return /* @__PURE__ */ E("div", {
|
|
852
865
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
853
866
|
"data-testid": "dataset-matrix",
|
|
854
|
-
children: /* @__PURE__ */
|
|
867
|
+
children: /* @__PURE__ */ D("table", {
|
|
855
868
|
className: "w-full text-xs",
|
|
856
|
-
children: [/* @__PURE__ */
|
|
869
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
857
870
|
className: "bg-muted/40",
|
|
858
|
-
children: /* @__PURE__ */
|
|
859
|
-
a.map((e) => /* @__PURE__ */
|
|
871
|
+
children: /* @__PURE__ */ D("tr", { children: [
|
|
872
|
+
a.map((e) => /* @__PURE__ */ E("th", {
|
|
860
873
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
861
|
-
children:
|
|
874
|
+
children: C(e)
|
|
862
875
|
}, e)),
|
|
863
|
-
|
|
876
|
+
A.map((e) => /* @__PURE__ */ E("th", {
|
|
864
877
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
865
878
|
children: e.header
|
|
866
879
|
}, `${e.col.id}-${e.measure}`)),
|
|
867
|
-
|
|
880
|
+
P && c.map((e) => /* @__PURE__ */ E("th", {
|
|
868
881
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
869
882
|
"data-testid": "matrix-total-col-header",
|
|
870
|
-
children: c.length === 1 ?
|
|
883
|
+
children: c.length === 1 ? w : `${w} · ${C(e)}`
|
|
871
884
|
}, `total-${e}`))
|
|
872
885
|
] })
|
|
873
|
-
}), /* @__PURE__ */
|
|
886
|
+
}), /* @__PURE__ */ D("tbody", { children: [x.rowHeaders.map((e) => /* @__PURE__ */ D("tr", {
|
|
874
887
|
className: "border-t",
|
|
875
888
|
children: [
|
|
876
|
-
a.map((t) => /* @__PURE__ */
|
|
889
|
+
a.map((t) => /* @__PURE__ */ E("td", {
|
|
877
890
|
className: "px-2 py-1 whitespace-nowrap font-medium",
|
|
878
|
-
children: r(e.
|
|
891
|
+
children: r(e.display[t], y)
|
|
879
892
|
}, t)),
|
|
880
|
-
|
|
881
|
-
let n =
|
|
882
|
-
return /* @__PURE__ */
|
|
883
|
-
className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${a ? ` ${
|
|
893
|
+
A.map((t) => {
|
|
894
|
+
let n = x.cells.get(s(e.id, t.col.id)), r = n?.row[t.measure], a = T && n != null;
|
|
895
|
+
return /* @__PURE__ */ E("td", {
|
|
896
|
+
className: `px-2 py-1 text-right tabular-nums whitespace-nowrap${a ? ` ${ge}` : ""}`,
|
|
884
897
|
"data-testid": a ? "dataset-drill-cell" : void 0,
|
|
885
|
-
onClick: a ? () =>
|
|
886
|
-
children: i(r,
|
|
898
|
+
onClick: a ? () => k(e.key, t.col.key, n.index) : void 0,
|
|
899
|
+
children: i(r, S(t.measure)?.format, S(t.measure)?.currency, S(t.measure)?.percentScale, y)
|
|
887
900
|
}, `${t.col.id}-${t.measure}`);
|
|
888
901
|
}),
|
|
889
|
-
|
|
902
|
+
P && c.map((t) => /* @__PURE__ */ E("td", {
|
|
890
903
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
891
904
|
"data-testid": "matrix-row-total",
|
|
892
|
-
children: i(
|
|
905
|
+
children: i(M.get(e.id)?.[t], S(t)?.format, S(t)?.currency, S(t)?.percentScale, y)
|
|
893
906
|
}, `total-${t}`))
|
|
894
907
|
]
|
|
895
|
-
}, e.id)),
|
|
908
|
+
}, e.id)), R && /* @__PURE__ */ D("tr", {
|
|
896
909
|
className: "border-t bg-muted/30 font-medium",
|
|
897
910
|
"data-testid": "matrix-total-row",
|
|
898
911
|
children: [
|
|
899
|
-
a.length > 0 && /* @__PURE__ */
|
|
912
|
+
a.length > 0 && /* @__PURE__ */ E("td", {
|
|
900
913
|
colSpan: a.length,
|
|
901
914
|
className: "px-2 py-1 whitespace-nowrap",
|
|
902
|
-
children:
|
|
915
|
+
children: w
|
|
903
916
|
}),
|
|
904
|
-
|
|
917
|
+
A.map((e) => /* @__PURE__ */ E("td", {
|
|
905
918
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
906
|
-
children: i(
|
|
919
|
+
children: i(N.get(e.col.id)?.[e.measure], S(e.measure)?.format, S(e.measure)?.currency, S(e.measure)?.percentScale, y)
|
|
907
920
|
}, `${e.col.id}-${e.measure}`)),
|
|
908
|
-
|
|
921
|
+
P && c.map((e) => /* @__PURE__ */ E("td", {
|
|
909
922
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
910
923
|
"data-testid": "matrix-grand-total",
|
|
911
|
-
children: i(ee?.[e],
|
|
924
|
+
children: i(ee?.[e], S(e)?.format, S(e)?.currency, S(e)?.percentScale, y)
|
|
912
925
|
}, `grand-${e}`))
|
|
913
926
|
]
|
|
914
927
|
})] })]
|
|
915
928
|
})
|
|
916
929
|
});
|
|
917
930
|
}
|
|
918
|
-
var
|
|
919
|
-
let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c =
|
|
920
|
-
if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */
|
|
931
|
+
var Ce = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i }) => {
|
|
932
|
+
let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c = ve(e.type);
|
|
933
|
+
if (c === "joined" && Array.isArray(e.blocks)) return /* @__PURE__ */ E("div", {
|
|
921
934
|
className: i,
|
|
922
935
|
"data-testid": "dataset-joined-report",
|
|
923
936
|
"data-report-name": e.name,
|
|
@@ -927,52 +940,52 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
927
940
|
gap: 24
|
|
928
941
|
},
|
|
929
942
|
children: e.blocks.map((e, n) => {
|
|
930
|
-
let r = a(o, e.runtimeFilter ?? e.filter), i =
|
|
943
|
+
let r = a(o, e.runtimeFilter ?? e.filter), i = q(e.columns), c = fe(e.order), l = ve(e.type), u = l === "matrix" && i.length > 0 ? /* @__PURE__ */ E(Z, {
|
|
931
944
|
dataset: String(e.dataset ?? ""),
|
|
932
|
-
rows:
|
|
945
|
+
rows: q(e.rows),
|
|
933
946
|
columnsAcross: i,
|
|
934
|
-
values:
|
|
947
|
+
values: q(e.values),
|
|
935
948
|
runtimeFilter: r,
|
|
936
949
|
dataSource: t,
|
|
937
950
|
onDrill: s,
|
|
938
951
|
order: c
|
|
939
|
-
}) : /* @__PURE__ */
|
|
952
|
+
}) : /* @__PURE__ */ E(_e, {
|
|
940
953
|
dataset: String(e.dataset ?? ""),
|
|
941
|
-
rows:
|
|
942
|
-
values:
|
|
954
|
+
rows: q(e.rows),
|
|
955
|
+
values: q(e.values),
|
|
943
956
|
runtimeFilter: r,
|
|
944
957
|
dataSource: t,
|
|
945
958
|
onDrill: s,
|
|
946
959
|
order: c,
|
|
947
960
|
withTotals: l === "summary" || l === "matrix"
|
|
948
961
|
});
|
|
949
|
-
return /* @__PURE__ */
|
|
962
|
+
return /* @__PURE__ */ D("section", {
|
|
950
963
|
"data-testid": "dataset-report-block",
|
|
951
964
|
"data-block-id": e.name ?? `block-${n}`,
|
|
952
965
|
className: "flex flex-col gap-2 rounded-lg border bg-card p-4",
|
|
953
|
-
children: [/* @__PURE__ */
|
|
966
|
+
children: [/* @__PURE__ */ D("header", {
|
|
954
967
|
className: "flex flex-col gap-0.5",
|
|
955
|
-
children: [/* @__PURE__ */
|
|
968
|
+
children: [/* @__PURE__ */ E("h3", {
|
|
956
969
|
className: "text-sm font-semibold",
|
|
957
|
-
children:
|
|
958
|
-
}), e.description ? /* @__PURE__ */
|
|
970
|
+
children: de(e.label, e.name ?? `Block ${n + 1}`)
|
|
971
|
+
}), e.description ? /* @__PURE__ */ E("p", {
|
|
959
972
|
className: "text-xs text-muted-foreground",
|
|
960
|
-
children:
|
|
973
|
+
children: de(e.description, "")
|
|
961
974
|
}) : null]
|
|
962
975
|
}), u]
|
|
963
976
|
}, e.name ?? `block-${n}`);
|
|
964
977
|
})
|
|
965
978
|
});
|
|
966
|
-
let l =
|
|
967
|
-
if (c === "matrix" && l.length > 0) return /* @__PURE__ */
|
|
979
|
+
let l = q(e.columns), u = fe(e.order);
|
|
980
|
+
if (c === "matrix" && l.length > 0) return /* @__PURE__ */ E("div", {
|
|
968
981
|
className: i,
|
|
969
982
|
"data-testid": "dataset-report",
|
|
970
983
|
"data-report-name": e.name,
|
|
971
|
-
children: /* @__PURE__ */
|
|
984
|
+
children: /* @__PURE__ */ E(Z, {
|
|
972
985
|
dataset: String(e.dataset ?? ""),
|
|
973
|
-
rows:
|
|
986
|
+
rows: q(e.rows),
|
|
974
987
|
columnsAcross: l,
|
|
975
|
-
values:
|
|
988
|
+
values: q(e.values),
|
|
976
989
|
runtimeFilter: o,
|
|
977
990
|
dataSource: t,
|
|
978
991
|
onDrill: s,
|
|
@@ -980,21 +993,21 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
980
993
|
})
|
|
981
994
|
});
|
|
982
995
|
let d = e.chart && typeof e.chart == "object" && e.chart.type ? e.chart : null;
|
|
983
|
-
return /* @__PURE__ */
|
|
996
|
+
return /* @__PURE__ */ D("div", {
|
|
984
997
|
className: `${i ?? ""} flex flex-col gap-3`,
|
|
985
998
|
"data-testid": "dataset-report",
|
|
986
999
|
"data-report-name": e.name,
|
|
987
1000
|
"data-report-presentation": c,
|
|
988
|
-
children: [d ? /* @__PURE__ */
|
|
1001
|
+
children: [d ? /* @__PURE__ */ E(xe, {
|
|
989
1002
|
dataset: String(e.dataset ?? ""),
|
|
990
1003
|
chart: d,
|
|
991
1004
|
runtimeFilter: o,
|
|
992
1005
|
dataSource: t,
|
|
993
1006
|
order: u
|
|
994
|
-
}) : null, /* @__PURE__ */
|
|
1007
|
+
}) : null, /* @__PURE__ */ E(_e, {
|
|
995
1008
|
dataset: String(e.dataset ?? ""),
|
|
996
|
-
rows:
|
|
997
|
-
values:
|
|
1009
|
+
rows: q(e.rows),
|
|
1010
|
+
values: q(e.values),
|
|
998
1011
|
runtimeFilter: o,
|
|
999
1012
|
dataSource: t,
|
|
1000
1013
|
onDrill: s,
|
|
@@ -1003,23 +1016,28 @@ var ge = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
1003
1016
|
})]
|
|
1004
1017
|
});
|
|
1005
1018
|
}, Q = (e) => {
|
|
1006
|
-
let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e,
|
|
1007
|
-
|
|
1008
|
-
report:
|
|
1009
|
-
dataSource:
|
|
1019
|
+
let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e, o = u.useContext(h), s = t ?? o?.dataSource, c = e.schema;
|
|
1020
|
+
if (c && typeof c == "object" && c.type === "spec-report" && c.report && typeof c.report == "object" && (c = c.report), K(c)) return /* @__PURE__ */ E(Ce, {
|
|
1021
|
+
report: c,
|
|
1022
|
+
dataSource: s,
|
|
1010
1023
|
runtimeFilter: r,
|
|
1011
1024
|
onDrill: i,
|
|
1012
1025
|
className: a
|
|
1013
|
-
})
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
children: /* @__PURE__ */ b(V, { schema: {
|
|
1026
|
+
});
|
|
1027
|
+
if (f(c)) {
|
|
1028
|
+
let e = {
|
|
1017
1029
|
type: "report-viewer",
|
|
1018
|
-
report:
|
|
1030
|
+
report: p(c),
|
|
1019
1031
|
data: n ?? [],
|
|
1020
1032
|
showToolbar: !1
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1033
|
+
};
|
|
1034
|
+
return /* @__PURE__ */ E("div", {
|
|
1035
|
+
className: a,
|
|
1036
|
+
"data-testid": "report-presentation-bridge",
|
|
1037
|
+
children: /* @__PURE__ */ E(G, { schema: e })
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
return /* @__PURE__ */ E(R, { schema: c });
|
|
1023
1041
|
};
|
|
1024
1042
|
//#endregion
|
|
1025
1043
|
//#region src/LiveReportExporter.ts
|
|
@@ -1027,7 +1045,7 @@ async function $(e, t) {
|
|
|
1027
1045
|
let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
|
|
1028
1046
|
try {
|
|
1029
1047
|
let t = (await n.find(r, i)).data || [];
|
|
1030
|
-
return
|
|
1048
|
+
return V(s, e, t, {
|
|
1031
1049
|
format: s,
|
|
1032
1050
|
...e.exportConfigs?.[s],
|
|
1033
1051
|
...o
|
|
@@ -1045,17 +1063,17 @@ async function $(e, t) {
|
|
|
1045
1063
|
};
|
|
1046
1064
|
}
|
|
1047
1065
|
}
|
|
1048
|
-
function
|
|
1049
|
-
let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(
|
|
1066
|
+
function we(e, t, n = {}) {
|
|
1067
|
+
let { columns: r, filename: i, includeAggregationRow: a = !1 } = n, o = r || (e.fields || []).map(Ee), s = o.map((e) => e.header), c = t.map((e, t) => o.map((n) => {
|
|
1050
1068
|
if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
|
|
1051
1069
|
let r = e[n.name];
|
|
1052
|
-
return
|
|
1070
|
+
return De(r, n.numberFormat);
|
|
1053
1071
|
}));
|
|
1054
1072
|
if (a && t.length > 0) {
|
|
1055
1073
|
let n = o.map((n, r) => {
|
|
1056
1074
|
let i = (e.fields || []).find((e) => e.name === n.name);
|
|
1057
1075
|
if (i?.aggregation) {
|
|
1058
|
-
let e =
|
|
1076
|
+
let e = ke(r), n = t.length + 1;
|
|
1059
1077
|
switch (i.aggregation) {
|
|
1060
1078
|
case "sum": return `=SUM(${e}2:${e}${n})`;
|
|
1061
1079
|
case "avg": return `=AVERAGE(${e}2:${e}${n})`;
|
|
@@ -1069,9 +1087,9 @@ function _e(e, t, n = {}) {
|
|
|
1069
1087
|
});
|
|
1070
1088
|
c.push(n);
|
|
1071
1089
|
}
|
|
1072
|
-
|
|
1090
|
+
je("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
|
|
1073
1091
|
}
|
|
1074
|
-
function
|
|
1092
|
+
function Te(e, t, n, r) {
|
|
1075
1093
|
return async () => {
|
|
1076
1094
|
let i = e.schedule;
|
|
1077
1095
|
if (!i?.enabled) return [];
|
|
@@ -1087,16 +1105,16 @@ function ve(e, t, n, r) {
|
|
|
1087
1105
|
return r(e, i), o;
|
|
1088
1106
|
};
|
|
1089
1107
|
}
|
|
1090
|
-
function
|
|
1108
|
+
function Ee(e) {
|
|
1091
1109
|
return {
|
|
1092
1110
|
name: e.name,
|
|
1093
1111
|
header: e.label || e.name
|
|
1094
1112
|
};
|
|
1095
1113
|
}
|
|
1096
|
-
function
|
|
1097
|
-
return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US",
|
|
1114
|
+
function De(e, t) {
|
|
1115
|
+
return e == null ? "" : typeof e == "number" && t ? e.toLocaleString("en-US", Oe(t)) : Ae(String(e));
|
|
1098
1116
|
}
|
|
1099
|
-
function
|
|
1117
|
+
function Oe(e) {
|
|
1100
1118
|
if (e.includes("%")) return {
|
|
1101
1119
|
style: "percent",
|
|
1102
1120
|
minimumFractionDigits: 0
|
|
@@ -1107,19 +1125,19 @@ function xe(e) {
|
|
|
1107
1125
|
maximumFractionDigits: Math.max(0, t - 1)
|
|
1108
1126
|
};
|
|
1109
1127
|
}
|
|
1110
|
-
function
|
|
1128
|
+
function ke(e) {
|
|
1111
1129
|
let t = "", n = e;
|
|
1112
1130
|
for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
|
|
1113
1131
|
return t;
|
|
1114
1132
|
}
|
|
1115
|
-
function
|
|
1133
|
+
function Ae(e) {
|
|
1116
1134
|
if (e.length > 0) {
|
|
1117
1135
|
let t = e.charAt(0);
|
|
1118
1136
|
if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
|
|
1119
1137
|
}
|
|
1120
1138
|
return e;
|
|
1121
1139
|
}
|
|
1122
|
-
function
|
|
1140
|
+
function je(e, t, n) {
|
|
1123
1141
|
let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
1124
1142
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1125
1143
|
}
|
|
@@ -1157,7 +1175,7 @@ e.register("report", Q, {
|
|
|
1157
1175
|
type: "string",
|
|
1158
1176
|
label: "Report Type"
|
|
1159
1177
|
}]
|
|
1160
|
-
}), e.register("report-viewer",
|
|
1178
|
+
}), e.register("report-viewer", G, {
|
|
1161
1179
|
namespace: "report",
|
|
1162
1180
|
label: "Report Viewer",
|
|
1163
1181
|
category: "Report",
|
|
@@ -1172,4 +1190,4 @@ e.register("report", Q, {
|
|
|
1172
1190
|
}]
|
|
1173
1191
|
});
|
|
1174
1192
|
//#endregion
|
|
1175
|
-
export {
|
|
1193
|
+
export { Ce as DatasetReportRenderer, R as LegacyReportRenderer, Q as ReportRenderer, G as ReportViewer, Te as createScheduleTrigger, te as exportAsCSV, B as exportAsExcel, z as exportAsHTML, ne as exportAsJSON, re as exportAsPDF, we as exportExcelWithFormulas, V as exportReport, $ as exportWithLiveData, W as formatValue, K as isDatasetReport, a as mergeFilters };
|