@object-ui/plugin-report 17.3.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 +366 -0
- package/README.md +0 -12
- package/dist/index.js +354 -344
- package/dist/index.umd.cjs +1 -1
- package/dist/useDatasetDimensionLabels.d.ts +71 -0
- package/package.json +13 -13
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, pivotBucketId as o, pivotCellKey as s } 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__ */ C
|
|
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 N = ({ 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 F(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 I(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 I(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 U(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 ie(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 ae(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 oe(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: s = !1 } = e, c = (e) => {
|
|
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
|
-
}, u = () => {
|
|
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;
|
|
@@ -302,16 +302,16 @@ var W = ({ schema: e, onRefresh: t }) => {
|
|
|
302
302
|
return n.backgroundColor && (e.backgroundColor = n.backgroundColor), n.textColor && (e.color = n.textColor), e;
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
|
-
},
|
|
305
|
+
}, O = (e, t) => {
|
|
306
306
|
if (e == null || e === "") return "";
|
|
307
307
|
if (t.renderAs === "badge" && (!t.type || t.type === "string" || t.type === "text")) {
|
|
308
308
|
let n = t.colorMap?.[String(e)] || "";
|
|
309
|
-
return /* @__PURE__ */
|
|
309
|
+
return /* @__PURE__ */ E(v, {
|
|
310
310
|
className: n,
|
|
311
311
|
children: String(e)
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
if (t.aggregation) return
|
|
314
|
+
if (t.aggregation) return W(e, t);
|
|
315
315
|
if (t.type) {
|
|
316
316
|
let n = { ...t };
|
|
317
317
|
t.colorMap && !n.options && (n.options = Object.entries(t.colorMap).map(([e, t]) => ({
|
|
@@ -319,129 +319,132 @@ var W = ({ schema: e, onRefresh: t }) => {
|
|
|
319
319
|
label: e,
|
|
320
320
|
color: t
|
|
321
321
|
})));
|
|
322
|
-
let r =
|
|
323
|
-
return /* @__PURE__ */
|
|
322
|
+
let r = ee(P(n));
|
|
323
|
+
return /* @__PURE__ */ E(r, {
|
|
324
324
|
value: e,
|
|
325
325
|
field: n
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
|
-
return
|
|
328
|
+
return W(e, t);
|
|
329
329
|
};
|
|
330
|
-
return n ? /* @__PURE__ */
|
|
330
|
+
return n ? /* @__PURE__ */ D("div", {
|
|
331
331
|
className: "space-y-4",
|
|
332
|
-
children: [i && /* @__PURE__ */
|
|
332
|
+
children: [i && /* @__PURE__ */ D("div", {
|
|
333
333
|
className: "flex items-center justify-between gap-2 p-4 bg-card rounded-lg border",
|
|
334
|
-
children: [/* @__PURE__ */
|
|
334
|
+
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("h2", {
|
|
335
335
|
className: "text-lg font-semibold",
|
|
336
336
|
children: n.title
|
|
337
|
-
}), n.description && /* @__PURE__ */
|
|
337
|
+
}), n.description && /* @__PURE__ */ E("p", {
|
|
338
338
|
className: "text-sm text-muted-foreground",
|
|
339
339
|
children: n.description
|
|
340
|
-
})] }), /* @__PURE__ */
|
|
340
|
+
})] }), /* @__PURE__ */ D("div", {
|
|
341
341
|
className: "flex items-center gap-2",
|
|
342
|
+
"data-print-hide": !0,
|
|
342
343
|
children: [
|
|
343
|
-
n.refreshInterval && /* @__PURE__ */
|
|
344
|
+
n.refreshInterval && /* @__PURE__ */ D(y, {
|
|
344
345
|
variant: "outline",
|
|
345
346
|
size: "sm",
|
|
346
|
-
onClick:
|
|
347
|
-
children: [/* @__PURE__ */
|
|
347
|
+
onClick: p,
|
|
348
|
+
children: [/* @__PURE__ */ E(M, { className: "h-4 w-4 mr-2" }), "Refresh"]
|
|
348
349
|
}),
|
|
349
|
-
o && /* @__PURE__ */
|
|
350
|
+
o && /* @__PURE__ */ D(y, {
|
|
350
351
|
variant: "outline",
|
|
351
352
|
size: "sm",
|
|
352
|
-
onClick:
|
|
353
|
-
|
|
353
|
+
onClick: f,
|
|
354
|
+
"aria-label": `Print: ${u}`,
|
|
355
|
+
title: u,
|
|
356
|
+
children: [/* @__PURE__ */ E(j, { className: "h-4 w-4 mr-2" }), "Print"]
|
|
354
357
|
}),
|
|
355
|
-
a && n.showExportButtons && /* @__PURE__ */
|
|
358
|
+
a && n.showExportButtons && /* @__PURE__ */ D("div", {
|
|
356
359
|
className: "flex items-center gap-1",
|
|
357
360
|
children: [
|
|
358
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ D(y, {
|
|
359
362
|
variant: "outline",
|
|
360
363
|
size: "sm",
|
|
361
|
-
onClick: () =>
|
|
362
|
-
children: [/* @__PURE__ */
|
|
364
|
+
onClick: () => l("pdf"),
|
|
365
|
+
children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "PDF"]
|
|
363
366
|
}),
|
|
364
|
-
/* @__PURE__ */
|
|
367
|
+
/* @__PURE__ */ D(y, {
|
|
365
368
|
variant: "outline",
|
|
366
369
|
size: "sm",
|
|
367
|
-
onClick: () =>
|
|
368
|
-
children: [/* @__PURE__ */
|
|
370
|
+
onClick: () => l("excel"),
|
|
371
|
+
children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "Excel"]
|
|
369
372
|
}),
|
|
370
|
-
/* @__PURE__ */
|
|
373
|
+
/* @__PURE__ */ D(y, {
|
|
371
374
|
variant: "outline",
|
|
372
375
|
size: "sm",
|
|
373
|
-
onClick: () =>
|
|
374
|
-
children: [/* @__PURE__ */
|
|
376
|
+
onClick: () => l("csv"),
|
|
377
|
+
children: [/* @__PURE__ */ E(k, { className: "h-4 w-4 mr-2" }), "CSV"]
|
|
375
378
|
})
|
|
376
379
|
]
|
|
377
380
|
})
|
|
378
381
|
]
|
|
379
382
|
})]
|
|
380
|
-
}), /* @__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, {
|
|
381
384
|
className: "space-y-6",
|
|
382
385
|
children: [
|
|
383
|
-
s && /* @__PURE__ */
|
|
386
|
+
s && /* @__PURE__ */ D("div", {
|
|
384
387
|
className: "space-y-6",
|
|
385
|
-
children: [/* @__PURE__ */
|
|
388
|
+
children: [/* @__PURE__ */ E("div", {
|
|
386
389
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
387
390
|
children: [
|
|
388
391
|
1,
|
|
389
392
|
2,
|
|
390
393
|
3
|
|
391
|
-
].map((e) => /* @__PURE__ */
|
|
394
|
+
].map((e) => /* @__PURE__ */ E(b, { children: /* @__PURE__ */ D(x, {
|
|
392
395
|
className: "p-4 space-y-2",
|
|
393
|
-
children: [/* @__PURE__ */
|
|
396
|
+
children: [/* @__PURE__ */ E(T, { className: "h-4 w-20" }), /* @__PURE__ */ E(T, { className: "h-8 w-28" })]
|
|
394
397
|
}) }, e))
|
|
395
|
-
}), /* @__PURE__ */
|
|
398
|
+
}), /* @__PURE__ */ D("div", {
|
|
396
399
|
className: "space-y-2",
|
|
397
|
-
children: [/* @__PURE__ */
|
|
400
|
+
children: [/* @__PURE__ */ E(T, { className: "h-10 w-full" }), [
|
|
398
401
|
1,
|
|
399
402
|
2,
|
|
400
403
|
3,
|
|
401
404
|
4,
|
|
402
405
|
5
|
|
403
|
-
].map((e) => /* @__PURE__ */
|
|
406
|
+
].map((e) => /* @__PURE__ */ E(T, { className: "h-8 w-full" }, e))]
|
|
404
407
|
})]
|
|
405
408
|
}),
|
|
406
|
-
!s && n.sections?.map((e, t) => e.visible === !1 ? null : /* @__PURE__ */
|
|
409
|
+
!s && n.sections?.map((e, t) => e.visible === !1 ? null : /* @__PURE__ */ D("div", {
|
|
407
410
|
className: "space-y-2",
|
|
408
411
|
children: [
|
|
409
|
-
e.title && e.type !== "header" && /* @__PURE__ */
|
|
412
|
+
e.title && e.type !== "header" && /* @__PURE__ */ E("h3", {
|
|
410
413
|
className: "text-lg font-semibold border-b pb-2",
|
|
411
414
|
children: e.title
|
|
412
415
|
}),
|
|
413
|
-
e.type === "header" && e.title && /* @__PURE__ */
|
|
416
|
+
e.type === "header" && e.title && /* @__PURE__ */ E("div", {
|
|
414
417
|
className: "text-2xl font-bold py-4",
|
|
415
418
|
children: e.title
|
|
416
419
|
}),
|
|
417
|
-
e.type === "summary" && /* @__PURE__ */
|
|
420
|
+
e.type === "summary" && /* @__PURE__ */ E("div", {
|
|
418
421
|
className: "grid grid-cols-1 md:grid-cols-3 gap-4",
|
|
419
|
-
children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */
|
|
422
|
+
children: n.fields?.filter((e) => e.showInSummary).map((e, t) => /* @__PURE__ */ E(b, { children: /* @__PURE__ */ D(x, {
|
|
420
423
|
className: "p-4",
|
|
421
|
-
children: [/* @__PURE__ */
|
|
424
|
+
children: [/* @__PURE__ */ E("div", {
|
|
422
425
|
className: "text-sm text-muted-foreground",
|
|
423
426
|
children: e.label || e.name
|
|
424
|
-
}), /* @__PURE__ */
|
|
427
|
+
}), /* @__PURE__ */ E("div", {
|
|
425
428
|
className: "text-2xl font-bold",
|
|
426
|
-
children:
|
|
429
|
+
children: W(h(e.name, e.aggregation), e)
|
|
427
430
|
})]
|
|
428
431
|
}) }, t))
|
|
429
432
|
}),
|
|
430
|
-
e.type === "table" && /* @__PURE__ */
|
|
433
|
+
e.type === "table" && /* @__PURE__ */ E("div", {
|
|
431
434
|
className: "border rounded-lg overflow-x-auto",
|
|
432
|
-
children: /* @__PURE__ */
|
|
435
|
+
children: /* @__PURE__ */ D("table", {
|
|
433
436
|
className: "w-full text-sm min-w-[600px]",
|
|
434
|
-
children: [/* @__PURE__ */
|
|
437
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
435
438
|
className: "bg-muted",
|
|
436
|
-
children: /* @__PURE__ */
|
|
439
|
+
children: /* @__PURE__ */ E("tr", { children: e.columns?.map((e, t) => /* @__PURE__ */ E("th", {
|
|
437
440
|
className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
|
|
438
441
|
children: e.label || e.name
|
|
439
442
|
}, t)) })
|
|
440
|
-
}), /* @__PURE__ */
|
|
441
|
-
let t =
|
|
442
|
-
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", {
|
|
443
446
|
className: "bg-muted/60",
|
|
444
|
-
children: /* @__PURE__ */
|
|
447
|
+
children: /* @__PURE__ */ D("td", {
|
|
445
448
|
colSpan: e.columns?.length || 1,
|
|
446
449
|
className: "px-4 py-2 font-semibold text-sm",
|
|
447
450
|
children: [
|
|
@@ -451,73 +454,73 @@ var W = ({ schema: e, onRefresh: t }) => {
|
|
|
451
454
|
")"
|
|
452
455
|
]
|
|
453
456
|
})
|
|
454
|
-
}), t.rows.map((t, n) => /* @__PURE__ */
|
|
457
|
+
}), t.rows.map((t, n) => /* @__PURE__ */ E("tr", {
|
|
455
458
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
456
|
-
children: e.columns?.map((e, n) => /* @__PURE__ */
|
|
459
|
+
children: e.columns?.map((e, n) => /* @__PURE__ */ E("td", {
|
|
457
460
|
className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
458
|
-
style:
|
|
459
|
-
children:
|
|
461
|
+
style: _(e.name, t[e.name]),
|
|
462
|
+
children: O(t[e.name], e)
|
|
460
463
|
}, n))
|
|
461
|
-
}, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */
|
|
464
|
+
}, n))] }, t.key)) : r?.map((t, n) => /* @__PURE__ */ E("tr", {
|
|
462
465
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
463
|
-
children: e.columns?.map((e, n) => /* @__PURE__ */
|
|
466
|
+
children: e.columns?.map((e, n) => /* @__PURE__ */ E("td", {
|
|
464
467
|
className: `px-4 py-2 ${e.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
465
|
-
style:
|
|
466
|
-
children:
|
|
468
|
+
style: _(e.name, t[e.name]),
|
|
469
|
+
children: O(t[e.name], e)
|
|
467
470
|
}, n))
|
|
468
471
|
}, n));
|
|
469
472
|
})() })]
|
|
470
473
|
})
|
|
471
474
|
}),
|
|
472
|
-
e.type === "text" && e.text && /* @__PURE__ */
|
|
475
|
+
e.type === "text" && e.text && /* @__PURE__ */ E("div", {
|
|
473
476
|
className: "prose max-w-none",
|
|
474
|
-
children: /* @__PURE__ */
|
|
477
|
+
children: /* @__PURE__ */ E("p", { children: e.text })
|
|
475
478
|
}),
|
|
476
|
-
e.type === "page-break" && /* @__PURE__ */
|
|
477
|
-
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) })
|
|
478
481
|
]
|
|
479
482
|
}, t)),
|
|
480
|
-
!n.sections && r && r.length > 0 && /* @__PURE__ */
|
|
483
|
+
!n.sections && r && r.length > 0 && /* @__PURE__ */ E("div", {
|
|
481
484
|
className: "border rounded-lg overflow-x-auto",
|
|
482
|
-
children: /* @__PURE__ */
|
|
485
|
+
children: /* @__PURE__ */ D("table", {
|
|
483
486
|
className: "w-full text-sm min-w-[600px]",
|
|
484
|
-
children: [/* @__PURE__ */
|
|
487
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
485
488
|
className: "bg-muted",
|
|
486
|
-
children: /* @__PURE__ */
|
|
489
|
+
children: /* @__PURE__ */ E("tr", { children: n.fields?.map((e, t) => /* @__PURE__ */ E("th", {
|
|
487
490
|
className: `px-4 py-2 font-medium ${e.type === "number" ? "text-right" : "text-left"}`,
|
|
488
491
|
children: e.label || e.name
|
|
489
492
|
}, t)) })
|
|
490
|
-
}), /* @__PURE__ */
|
|
493
|
+
}), /* @__PURE__ */ E("tbody", { children: r.map((e, t) => /* @__PURE__ */ E("tr", {
|
|
491
494
|
className: "border-t hover:bg-muted/50 even:bg-muted/20",
|
|
492
|
-
children: n.fields?.map((t, n) => /* @__PURE__ */
|
|
495
|
+
children: n.fields?.map((t, n) => /* @__PURE__ */ E("td", {
|
|
493
496
|
className: `px-4 py-2 ${t.type === "number" ? "text-right tabular-nums" : ""}`,
|
|
494
|
-
style:
|
|
495
|
-
children:
|
|
497
|
+
style: _(t.name, e[t.name]),
|
|
498
|
+
children: O(e[t.name], t)
|
|
496
499
|
}, n))
|
|
497
500
|
}, t)) })]
|
|
498
501
|
})
|
|
499
502
|
})
|
|
500
503
|
]
|
|
501
504
|
})] })]
|
|
502
|
-
}) : /* @__PURE__ */
|
|
505
|
+
}) : /* @__PURE__ */ E(b, { children: /* @__PURE__ */ E(x, {
|
|
503
506
|
className: "p-8 text-center text-muted-foreground",
|
|
504
507
|
children: "No report to display"
|
|
505
508
|
}) });
|
|
506
509
|
};
|
|
507
510
|
//#endregion
|
|
508
511
|
//#region src/DatasetReportRenderer.tsx
|
|
509
|
-
function
|
|
512
|
+
function K(e) {
|
|
510
513
|
if (!e || typeof e != "object") return !1;
|
|
511
514
|
let t = e;
|
|
512
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");
|
|
513
516
|
}
|
|
514
|
-
function
|
|
517
|
+
function de(e, t) {
|
|
515
518
|
return e ? typeof e == "string" ? e : typeof e == "object" && typeof e.default == "string" ? e.default : t : t;
|
|
516
519
|
}
|
|
517
520
|
function q(e) {
|
|
518
521
|
return Array.isArray(e) ? e.filter((e) => typeof e == "string" && !!e) : [];
|
|
519
522
|
}
|
|
520
|
-
function
|
|
523
|
+
function fe(e) {
|
|
521
524
|
if (!Array.isArray(e)) return;
|
|
522
525
|
let t = {};
|
|
523
526
|
for (let n of e) {
|
|
@@ -526,21 +529,21 @@ function J(e) {
|
|
|
526
529
|
}
|
|
527
530
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
528
531
|
}
|
|
529
|
-
function
|
|
532
|
+
function pe(e, t, n) {
|
|
530
533
|
if (!e) return;
|
|
531
534
|
let r = /* @__PURE__ */ new Set([...t, ...n]), i = {};
|
|
532
535
|
for (let [t, n] of Object.entries(e)) r.has(t) && (i[t] = n);
|
|
533
536
|
return Object.keys(i).length > 0 ? i : void 0;
|
|
534
537
|
}
|
|
535
|
-
function
|
|
536
|
-
let [s,
|
|
538
|
+
function J(e, t, n, r, i, a, o) {
|
|
539
|
+
let [s, c] = u.useState({
|
|
537
540
|
status: "idle",
|
|
538
541
|
rows: []
|
|
539
|
-
}),
|
|
540
|
-
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(() => {
|
|
541
544
|
let o = i;
|
|
542
545
|
if (!o || typeof o.queryDataset != "function") {
|
|
543
|
-
|
|
546
|
+
c({
|
|
544
547
|
status: "error",
|
|
545
548
|
rows: [],
|
|
546
549
|
error: "This data source does not support dataset queries."
|
|
@@ -548,14 +551,14 @@ function Y(e, t, n, r, i, a, o) {
|
|
|
548
551
|
return;
|
|
549
552
|
}
|
|
550
553
|
if (!e || n.length === 0) {
|
|
551
|
-
|
|
554
|
+
c({
|
|
552
555
|
status: "idle",
|
|
553
556
|
rows: []
|
|
554
557
|
});
|
|
555
558
|
return;
|
|
556
559
|
}
|
|
557
560
|
let s = !1;
|
|
558
|
-
return
|
|
561
|
+
return c({
|
|
559
562
|
status: "loading",
|
|
560
563
|
rows: []
|
|
561
564
|
}), o.queryDataset(e, {
|
|
@@ -563,9 +566,9 @@ function Y(e, t, n, r, i, a, o) {
|
|
|
563
566
|
measures: n,
|
|
564
567
|
...r && Object.keys(r).length > 0 ? { runtimeFilter: r } : {},
|
|
565
568
|
...a ? { totals: { groupings: a } } : {},
|
|
566
|
-
...
|
|
569
|
+
...l ? { order: l } : {}
|
|
567
570
|
}).then((e) => {
|
|
568
|
-
s ||
|
|
571
|
+
s || c({
|
|
569
572
|
status: "ok",
|
|
570
573
|
rows: Array.isArray(e?.rows) ? e.rows : [],
|
|
571
574
|
fields: Array.isArray(e?.fields) ? e.fields : [],
|
|
@@ -576,7 +579,7 @@ function Y(e, t, n, r, i, a, o) {
|
|
|
576
579
|
totals: Array.isArray(e?.totals) ? e.totals : void 0
|
|
577
580
|
});
|
|
578
581
|
}).catch((e) => {
|
|
579
|
-
s ||
|
|
582
|
+
s || c({
|
|
580
583
|
status: "error",
|
|
581
584
|
rows: [],
|
|
582
585
|
error: String(e?.message ?? e)
|
|
@@ -586,8 +589,8 @@ function Y(e, t, n, r, i, a, o) {
|
|
|
586
589
|
};
|
|
587
590
|
}, [m]), s;
|
|
588
591
|
}
|
|
589
|
-
function
|
|
590
|
-
return /* @__PURE__ */
|
|
592
|
+
function me({ dataset: e }) {
|
|
593
|
+
return /* @__PURE__ */ D("div", {
|
|
591
594
|
className: "flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
592
595
|
children: [
|
|
593
596
|
"This report binds the “",
|
|
@@ -596,81 +599,81 @@ function X({ dataset: e }) {
|
|
|
596
599
|
]
|
|
597
600
|
});
|
|
598
601
|
}
|
|
599
|
-
function
|
|
600
|
-
return e === "error" ? /* @__PURE__ */
|
|
602
|
+
function Y({ status: e, error: t }) {
|
|
603
|
+
return e === "error" ? /* @__PURE__ */ D("div", {
|
|
601
604
|
role: "alert",
|
|
602
605
|
className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive",
|
|
603
|
-
children: [/* @__PURE__ */
|
|
606
|
+
children: [/* @__PURE__ */ E(O, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ E("span", {
|
|
604
607
|
className: "break-words",
|
|
605
608
|
children: t
|
|
606
609
|
})]
|
|
607
|
-
}) : /* @__PURE__ */
|
|
610
|
+
}) : /* @__PURE__ */ D("div", {
|
|
608
611
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
609
|
-
children: [/* @__PURE__ */
|
|
612
|
+
children: [/* @__PURE__ */ E(A, { className: "h-4 w-4 animate-spin" }), " Running report…"]
|
|
610
613
|
});
|
|
611
614
|
}
|
|
612
|
-
function
|
|
613
|
-
return /* @__PURE__ */
|
|
615
|
+
function he() {
|
|
616
|
+
return /* @__PURE__ */ D("div", {
|
|
614
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",
|
|
615
|
-
children: [/* @__PURE__ */
|
|
618
|
+
children: [/* @__PURE__ */ E(N, { className: "h-6 w-6" }), " The dataset returned no rows for this report’s scope."]
|
|
616
619
|
});
|
|
617
620
|
}
|
|
618
|
-
var
|
|
619
|
-
function
|
|
620
|
-
let
|
|
621
|
-
if (o.length === 0) return /* @__PURE__ */
|
|
622
|
-
if (
|
|
623
|
-
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, {
|
|
624
627
|
status: "error",
|
|
625
|
-
error:
|
|
628
|
+
error: p.error
|
|
626
629
|
});
|
|
627
|
-
if (
|
|
628
|
-
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) => {
|
|
629
632
|
let i = {};
|
|
630
633
|
for (let e of a) i[e] = n[e];
|
|
631
|
-
let o =
|
|
632
|
-
|
|
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({
|
|
633
636
|
dataset: e,
|
|
634
637
|
groupKey: i,
|
|
635
638
|
runtimeFilter: s,
|
|
636
|
-
object:
|
|
637
|
-
objectFilter:
|
|
639
|
+
object: p.object,
|
|
640
|
+
objectFilter: l
|
|
638
641
|
});
|
|
639
|
-
}, { measureField:
|
|
640
|
-
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", {
|
|
641
644
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
642
|
-
children: /* @__PURE__ */
|
|
645
|
+
children: /* @__PURE__ */ D("table", {
|
|
643
646
|
className: "w-full text-xs",
|
|
644
|
-
children: [/* @__PURE__ */
|
|
647
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
645
648
|
className: "bg-muted/40",
|
|
646
|
-
children: /* @__PURE__ */
|
|
649
|
+
children: /* @__PURE__ */ E("tr", { children: w.map((e) => /* @__PURE__ */ E("th", {
|
|
647
650
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
648
|
-
children:
|
|
651
|
+
children: C(e)
|
|
649
652
|
}, e)) })
|
|
650
|
-
}), /* @__PURE__ */
|
|
651
|
-
className: `border-t${
|
|
652
|
-
"data-testid":
|
|
653
|
-
onClick:
|
|
654
|
-
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", {
|
|
655
658
|
className: "px-2 py-1 tabular-nums whitespace-nowrap",
|
|
656
|
-
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)
|
|
657
660
|
}, t))
|
|
658
|
-
}, t)),
|
|
661
|
+
}, t)), O && /* @__PURE__ */ D("tr", {
|
|
659
662
|
className: "border-t bg-muted/30 font-medium",
|
|
660
663
|
"data-testid": "dataset-report-total-row",
|
|
661
|
-
children: [a.length > 0 && /* @__PURE__ */
|
|
664
|
+
children: [a.length > 0 && /* @__PURE__ */ E("td", {
|
|
662
665
|
colSpan: a.length,
|
|
663
666
|
className: "px-2 py-1 whitespace-nowrap",
|
|
664
|
-
children:
|
|
665
|
-
}), o.map((e) => /* @__PURE__ */
|
|
667
|
+
children: k
|
|
668
|
+
}), o.map((e) => /* @__PURE__ */ E("td", {
|
|
666
669
|
className: "px-2 py-1 tabular-nums whitespace-nowrap",
|
|
667
|
-
children: i(
|
|
670
|
+
children: i(O[e], S(e)?.format, S(e)?.currency, S(e)?.percentScale, g)
|
|
668
671
|
}, e))]
|
|
669
672
|
})] })]
|
|
670
673
|
})
|
|
671
674
|
});
|
|
672
675
|
}
|
|
673
|
-
function
|
|
676
|
+
function ve(e) {
|
|
674
677
|
switch (e) {
|
|
675
678
|
case "summary": return "summary";
|
|
676
679
|
case "matrix": return "matrix";
|
|
@@ -678,7 +681,7 @@ function de(e) {
|
|
|
678
681
|
default: return "tabular";
|
|
679
682
|
}
|
|
680
683
|
}
|
|
681
|
-
function
|
|
684
|
+
function ye(e) {
|
|
682
685
|
switch (e) {
|
|
683
686
|
case "bar":
|
|
684
687
|
case "column":
|
|
@@ -709,9 +712,9 @@ function fe(e) {
|
|
|
709
712
|
};
|
|
710
713
|
}
|
|
711
714
|
}
|
|
712
|
-
function
|
|
713
|
-
let [, n] =
|
|
714
|
-
return
|
|
715
|
+
function be(t) {
|
|
716
|
+
let [, n] = u.useReducer((e) => e + 1, 0);
|
|
717
|
+
return u.useEffect(() => {
|
|
715
718
|
if (e.get(t)) return;
|
|
716
719
|
let r = typeof e.subscribe == "function" ? e.subscribe(() => {
|
|
717
720
|
e.get(t) && n();
|
|
@@ -719,53 +722,53 @@ function pe(t) {
|
|
|
719
722
|
return i && typeof i.then == "function" && i.then(() => n()).catch(() => {}), r;
|
|
720
723
|
}, [t]), e.get(t);
|
|
721
724
|
}
|
|
722
|
-
function
|
|
723
|
-
let s = typeof t.xAxis == "string" ? t.xAxis : "", c = typeof t.yAxis == "string" ? t.yAxis : "",
|
|
724
|
-
if (
|
|
725
|
-
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", {
|
|
726
729
|
className: "rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground",
|
|
727
730
|
"data-testid": "dataset-report-chart-unsupported",
|
|
728
731
|
children: [
|
|
729
732
|
"Chart type “",
|
|
730
|
-
|
|
733
|
+
d.type,
|
|
731
734
|
"” is not a spec chart type — the grouped table below carries this report’s numbers."
|
|
732
735
|
]
|
|
733
736
|
});
|
|
734
|
-
if (
|
|
735
|
-
if (
|
|
737
|
+
if (d.kind === "series" && !s || !c) return null;
|
|
738
|
+
if (p.status === "loading" || p.status === "idle") return /* @__PURE__ */ D("div", {
|
|
736
739
|
className: "flex items-center gap-2 p-4 text-xs text-muted-foreground",
|
|
737
|
-
children: [/* @__PURE__ */
|
|
740
|
+
children: [/* @__PURE__ */ E(A, { className: "h-4 w-4 animate-spin" }), " Loading chart…"]
|
|
738
741
|
});
|
|
739
|
-
if (
|
|
740
|
-
if (
|
|
741
|
-
let { measureField: e, headerLabel: t } = n(
|
|
742
|
-
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", {
|
|
743
746
|
className: "rounded-md border bg-card p-3",
|
|
744
747
|
"data-testid": "dataset-report-metric",
|
|
745
|
-
children: [
|
|
748
|
+
children: [b ? /* @__PURE__ */ E("h3", {
|
|
746
749
|
className: "mb-2 text-sm font-semibold",
|
|
747
|
-
children:
|
|
748
|
-
}) : null, /* @__PURE__ */
|
|
750
|
+
children: b
|
|
751
|
+
}) : null, /* @__PURE__ */ D("div", {
|
|
749
752
|
className: "flex flex-col gap-0.5 py-2",
|
|
750
|
-
children: [/* @__PURE__ */
|
|
753
|
+
children: [/* @__PURE__ */ E("span", {
|
|
751
754
|
className: "text-2xl font-semibold tabular-nums",
|
|
752
|
-
children: i(
|
|
753
|
-
}), /* @__PURE__ */
|
|
755
|
+
children: i(p.rows[0]?.[c], r?.format, r?.currency, r?.percentScale, g)
|
|
756
|
+
}), /* @__PURE__ */ E("span", {
|
|
754
757
|
className: "text-xs text-muted-foreground",
|
|
755
758
|
children: t(c)
|
|
756
759
|
})]
|
|
757
760
|
})]
|
|
758
761
|
});
|
|
759
762
|
}
|
|
760
|
-
return
|
|
763
|
+
return m ? /* @__PURE__ */ D("div", {
|
|
761
764
|
className: "rounded-md border bg-card p-3",
|
|
762
765
|
"data-testid": "dataset-report-chart",
|
|
763
|
-
children: [
|
|
766
|
+
children: [b ? /* @__PURE__ */ E("h3", {
|
|
764
767
|
className: "mb-2 text-sm font-semibold",
|
|
765
|
-
children:
|
|
766
|
-
}) : null, /* @__PURE__ */
|
|
767
|
-
chartType:
|
|
768
|
-
data:
|
|
768
|
+
children: b
|
|
769
|
+
}) : null, /* @__PURE__ */ E(m, { schema: {
|
|
770
|
+
chartType: d.chartType,
|
|
771
|
+
data: l(p.rows, y),
|
|
769
772
|
xAxisKey: s,
|
|
770
773
|
series: [{ dataKey: c }],
|
|
771
774
|
height: typeof t.height == "number" ? t.height : 280,
|
|
@@ -773,44 +776,46 @@ function me({ dataset: e, chart: t, runtimeFilter: r, dataSource: a, order: o })
|
|
|
773
776
|
} })]
|
|
774
777
|
}) : null;
|
|
775
778
|
}
|
|
776
|
-
function
|
|
777
|
-
return o(e.map((e) =>
|
|
779
|
+
function X(e, t) {
|
|
780
|
+
return o(e.map((e) => c(t[e])));
|
|
778
781
|
}
|
|
779
|
-
function
|
|
780
|
-
return e.map((e) => r(t[e])).join(" / ");
|
|
782
|
+
function Se(e, t, n) {
|
|
783
|
+
return e.map((e) => r(t[e], n)).join(" / ");
|
|
781
784
|
}
|
|
782
|
-
function
|
|
783
|
-
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, [
|
|
784
787
|
a,
|
|
785
788
|
o,
|
|
786
789
|
[]
|
|
787
|
-
],
|
|
788
|
-
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;
|
|
789
792
|
let e = [], t = [], n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Map();
|
|
790
|
-
return
|
|
791
|
-
let u =
|
|
792
|
-
if (!n.has(
|
|
793
|
-
n.add(
|
|
794
|
-
let t = {};
|
|
795
|
-
for (let e of a) t[e] = c[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];
|
|
796
799
|
e.push({
|
|
797
|
-
id:
|
|
798
|
-
label:
|
|
799
|
-
key: t
|
|
800
|
+
id: d,
|
|
801
|
+
label: Se(a, c, y),
|
|
802
|
+
key: t,
|
|
803
|
+
display: r
|
|
800
804
|
});
|
|
801
805
|
}
|
|
802
|
-
if (!r.has(
|
|
803
|
-
r.add(
|
|
804
|
-
let e = {};
|
|
805
|
-
for (let t of o) e[t] = c[t];
|
|
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];
|
|
806
810
|
t.push({
|
|
807
|
-
id:
|
|
808
|
-
label:
|
|
809
|
-
key: e
|
|
811
|
+
id: f,
|
|
812
|
+
label: Se(o, c, y),
|
|
813
|
+
key: e,
|
|
814
|
+
display: n
|
|
810
815
|
});
|
|
811
816
|
}
|
|
812
|
-
i.set(s(
|
|
813
|
-
row:
|
|
817
|
+
i.set(s(d, f), {
|
|
818
|
+
row: u,
|
|
814
819
|
index: l
|
|
815
820
|
});
|
|
816
821
|
}), {
|
|
@@ -819,108 +824,113 @@ function ge({ dataset: e, rows: a, columnsAcross: o, values: l, runtimeFilter: u
|
|
|
819
824
|
cells: i
|
|
820
825
|
};
|
|
821
826
|
}, [
|
|
822
|
-
|
|
827
|
+
h,
|
|
823
828
|
a,
|
|
824
|
-
o
|
|
829
|
+
o,
|
|
830
|
+
b,
|
|
831
|
+
y
|
|
825
832
|
]);
|
|
826
|
-
if (
|
|
827
|
-
if (
|
|
828
|
-
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, {
|
|
829
836
|
status: "error",
|
|
830
|
-
error:
|
|
837
|
+
error: h.error
|
|
831
838
|
});
|
|
832
|
-
if (!
|
|
833
|
-
let { measureField:
|
|
834
|
-
let a =
|
|
835
|
-
|
|
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({
|
|
836
843
|
dataset: e,
|
|
837
844
|
groupKey: {
|
|
838
845
|
...n,
|
|
839
846
|
...r
|
|
840
847
|
},
|
|
841
|
-
runtimeFilter:
|
|
842
|
-
object:
|
|
848
|
+
runtimeFilter: d,
|
|
849
|
+
object: h.object,
|
|
843
850
|
objectFilter: s
|
|
844
851
|
});
|
|
845
|
-
},
|
|
852
|
+
}, A = x.colHeaders.flatMap((e) => c.map((t) => ({
|
|
846
853
|
col: e,
|
|
847
854
|
measure: t,
|
|
848
|
-
header:
|
|
849
|
-
}))),
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
let
|
|
854
|
-
|
|
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", {
|
|
855
865
|
className: "overflow-auto max-h-[70vh] rounded-md border",
|
|
856
866
|
"data-testid": "dataset-matrix",
|
|
857
|
-
children: /* @__PURE__ */
|
|
867
|
+
children: /* @__PURE__ */ D("table", {
|
|
858
868
|
className: "w-full text-xs",
|
|
859
|
-
children: [/* @__PURE__ */
|
|
869
|
+
children: [/* @__PURE__ */ E("thead", {
|
|
860
870
|
className: "bg-muted/40",
|
|
861
|
-
children: /* @__PURE__ */
|
|
862
|
-
a.map((e) => /* @__PURE__ */
|
|
871
|
+
children: /* @__PURE__ */ D("tr", { children: [
|
|
872
|
+
a.map((e) => /* @__PURE__ */ E("th", {
|
|
863
873
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
864
|
-
children:
|
|
874
|
+
children: C(e)
|
|
865
875
|
}, e)),
|
|
866
|
-
|
|
876
|
+
A.map((e) => /* @__PURE__ */ E("th", {
|
|
867
877
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
868
878
|
children: e.header
|
|
869
879
|
}, `${e.col.id}-${e.measure}`)),
|
|
870
|
-
|
|
880
|
+
P && c.map((e) => /* @__PURE__ */ E("th", {
|
|
871
881
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
872
882
|
"data-testid": "matrix-total-col-header",
|
|
873
|
-
children:
|
|
883
|
+
children: c.length === 1 ? w : `${w} · ${C(e)}`
|
|
874
884
|
}, `total-${e}`))
|
|
875
885
|
] })
|
|
876
|
-
}), /* @__PURE__ */
|
|
886
|
+
}), /* @__PURE__ */ D("tbody", { children: [x.rowHeaders.map((e) => /* @__PURE__ */ D("tr", {
|
|
877
887
|
className: "border-t",
|
|
878
888
|
children: [
|
|
879
|
-
a.map((t) => /* @__PURE__ */
|
|
889
|
+
a.map((t) => /* @__PURE__ */ E("td", {
|
|
880
890
|
className: "px-2 py-1 whitespace-nowrap font-medium",
|
|
881
|
-
children: r(e.
|
|
891
|
+
children: r(e.display[t], y)
|
|
882
892
|
}, t)),
|
|
883
|
-
|
|
884
|
-
let n =
|
|
885
|
-
return /* @__PURE__ */
|
|
886
|
-
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}` : ""}`,
|
|
887
897
|
"data-testid": a ? "dataset-drill-cell" : void 0,
|
|
888
|
-
onClick: a ? () =>
|
|
889
|
-
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)
|
|
890
900
|
}, `${t.col.id}-${t.measure}`);
|
|
891
901
|
}),
|
|
892
|
-
|
|
902
|
+
P && c.map((t) => /* @__PURE__ */ E("td", {
|
|
893
903
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
894
904
|
"data-testid": "matrix-row-total",
|
|
895
|
-
children: i(
|
|
905
|
+
children: i(M.get(e.id)?.[t], S(t)?.format, S(t)?.currency, S(t)?.percentScale, y)
|
|
896
906
|
}, `total-${t}`))
|
|
897
907
|
]
|
|
898
|
-
}, e.id)),
|
|
908
|
+
}, e.id)), R && /* @__PURE__ */ D("tr", {
|
|
899
909
|
className: "border-t bg-muted/30 font-medium",
|
|
900
910
|
"data-testid": "matrix-total-row",
|
|
901
911
|
children: [
|
|
902
|
-
a.length > 0 && /* @__PURE__ */
|
|
912
|
+
a.length > 0 && /* @__PURE__ */ E("td", {
|
|
903
913
|
colSpan: a.length,
|
|
904
914
|
className: "px-2 py-1 whitespace-nowrap",
|
|
905
|
-
children:
|
|
915
|
+
children: w
|
|
906
916
|
}),
|
|
907
|
-
|
|
917
|
+
A.map((e) => /* @__PURE__ */ E("td", {
|
|
908
918
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
909
|
-
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)
|
|
910
920
|
}, `${e.col.id}-${e.measure}`)),
|
|
911
|
-
|
|
921
|
+
P && c.map((e) => /* @__PURE__ */ E("td", {
|
|
912
922
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
913
923
|
"data-testid": "matrix-grand-total",
|
|
914
|
-
children: i(
|
|
924
|
+
children: i(ee?.[e], S(e)?.format, S(e)?.currency, S(e)?.percentScale, y)
|
|
915
925
|
}, `grand-${e}`))
|
|
916
926
|
]
|
|
917
927
|
})] })]
|
|
918
928
|
})
|
|
919
929
|
});
|
|
920
930
|
}
|
|
921
|
-
var
|
|
922
|
-
let o = a(e.runtimeFilter ?? e.filter, n), s = e.drilldown === !1 ? void 0 : r, c =
|
|
923
|
-
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", {
|
|
924
934
|
className: i,
|
|
925
935
|
"data-testid": "dataset-joined-report",
|
|
926
936
|
"data-report-name": e.name,
|
|
@@ -930,7 +940,7 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
930
940
|
gap: 24
|
|
931
941
|
},
|
|
932
942
|
children: e.blocks.map((e, n) => {
|
|
933
|
-
let r = a(o, e.runtimeFilter ?? e.filter), i = q(e.columns), c =
|
|
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, {
|
|
934
944
|
dataset: String(e.dataset ?? ""),
|
|
935
945
|
rows: q(e.rows),
|
|
936
946
|
columnsAcross: i,
|
|
@@ -939,7 +949,7 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
939
949
|
dataSource: t,
|
|
940
950
|
onDrill: s,
|
|
941
951
|
order: c
|
|
942
|
-
}) : /* @__PURE__ */
|
|
952
|
+
}) : /* @__PURE__ */ E(_e, {
|
|
943
953
|
dataset: String(e.dataset ?? ""),
|
|
944
954
|
rows: q(e.rows),
|
|
945
955
|
values: q(e.values),
|
|
@@ -949,29 +959,29 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
949
959
|
order: c,
|
|
950
960
|
withTotals: l === "summary" || l === "matrix"
|
|
951
961
|
});
|
|
952
|
-
return /* @__PURE__ */
|
|
962
|
+
return /* @__PURE__ */ D("section", {
|
|
953
963
|
"data-testid": "dataset-report-block",
|
|
954
964
|
"data-block-id": e.name ?? `block-${n}`,
|
|
955
965
|
className: "flex flex-col gap-2 rounded-lg border bg-card p-4",
|
|
956
|
-
children: [/* @__PURE__ */
|
|
966
|
+
children: [/* @__PURE__ */ D("header", {
|
|
957
967
|
className: "flex flex-col gap-0.5",
|
|
958
|
-
children: [/* @__PURE__ */
|
|
968
|
+
children: [/* @__PURE__ */ E("h3", {
|
|
959
969
|
className: "text-sm font-semibold",
|
|
960
|
-
children:
|
|
961
|
-
}), e.description ? /* @__PURE__ */
|
|
970
|
+
children: de(e.label, e.name ?? `Block ${n + 1}`)
|
|
971
|
+
}), e.description ? /* @__PURE__ */ E("p", {
|
|
962
972
|
className: "text-xs text-muted-foreground",
|
|
963
|
-
children:
|
|
973
|
+
children: de(e.description, "")
|
|
964
974
|
}) : null]
|
|
965
975
|
}), u]
|
|
966
976
|
}, e.name ?? `block-${n}`);
|
|
967
977
|
})
|
|
968
978
|
});
|
|
969
|
-
let l = q(e.columns), u =
|
|
970
|
-
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", {
|
|
971
981
|
className: i,
|
|
972
982
|
"data-testid": "dataset-report",
|
|
973
983
|
"data-report-name": e.name,
|
|
974
|
-
children: /* @__PURE__ */
|
|
984
|
+
children: /* @__PURE__ */ E(Z, {
|
|
975
985
|
dataset: String(e.dataset ?? ""),
|
|
976
986
|
rows: q(e.rows),
|
|
977
987
|
columnsAcross: l,
|
|
@@ -983,18 +993,18 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
983
993
|
})
|
|
984
994
|
});
|
|
985
995
|
let d = e.chart && typeof e.chart == "object" && e.chart.type ? e.chart : null;
|
|
986
|
-
return /* @__PURE__ */
|
|
996
|
+
return /* @__PURE__ */ D("div", {
|
|
987
997
|
className: `${i ?? ""} flex flex-col gap-3`,
|
|
988
998
|
"data-testid": "dataset-report",
|
|
989
999
|
"data-report-name": e.name,
|
|
990
1000
|
"data-report-presentation": c,
|
|
991
|
-
children: [d ? /* @__PURE__ */
|
|
1001
|
+
children: [d ? /* @__PURE__ */ E(xe, {
|
|
992
1002
|
dataset: String(e.dataset ?? ""),
|
|
993
1003
|
chart: d,
|
|
994
1004
|
runtimeFilter: o,
|
|
995
1005
|
dataSource: t,
|
|
996
1006
|
order: u
|
|
997
|
-
}) : null, /* @__PURE__ */
|
|
1007
|
+
}) : null, /* @__PURE__ */ E(_e, {
|
|
998
1008
|
dataset: String(e.dataset ?? ""),
|
|
999
1009
|
rows: q(e.rows),
|
|
1000
1010
|
values: q(e.values),
|
|
@@ -1005,37 +1015,37 @@ var _e = ({ report: e, dataSource: t, runtimeFilter: n, onDrill: r, className: i
|
|
|
1005
1015
|
withTotals: c === "summary" || c === "matrix"
|
|
1006
1016
|
})]
|
|
1007
1017
|
});
|
|
1008
|
-
},
|
|
1009
|
-
let { dataSource: t, rows: n, runtimeFilter: r, onDrill: i, className: a } = e, o =
|
|
1010
|
-
if (
|
|
1011
|
-
report:
|
|
1018
|
+
}, Q = (e) => {
|
|
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,
|
|
1012
1022
|
dataSource: s,
|
|
1013
1023
|
runtimeFilter: r,
|
|
1014
1024
|
onDrill: i,
|
|
1015
1025
|
className: a
|
|
1016
1026
|
});
|
|
1017
|
-
if (
|
|
1027
|
+
if (f(c)) {
|
|
1018
1028
|
let e = {
|
|
1019
1029
|
type: "report-viewer",
|
|
1020
|
-
report:
|
|
1030
|
+
report: p(c),
|
|
1021
1031
|
data: n ?? [],
|
|
1022
1032
|
showToolbar: !1
|
|
1023
1033
|
};
|
|
1024
|
-
return /* @__PURE__ */
|
|
1034
|
+
return /* @__PURE__ */ E("div", {
|
|
1025
1035
|
className: a,
|
|
1026
1036
|
"data-testid": "report-presentation-bridge",
|
|
1027
|
-
children: /* @__PURE__ */
|
|
1037
|
+
children: /* @__PURE__ */ E(G, { schema: e })
|
|
1028
1038
|
});
|
|
1029
1039
|
}
|
|
1030
|
-
return /* @__PURE__ */
|
|
1040
|
+
return /* @__PURE__ */ E(R, { schema: c });
|
|
1031
1041
|
};
|
|
1032
1042
|
//#endregion
|
|
1033
1043
|
//#region src/LiveReportExporter.ts
|
|
1034
|
-
async function
|
|
1044
|
+
async function $(e, t) {
|
|
1035
1045
|
let { dataSource: n, resource: r, queryParams: i, format: a, exportConfig: o } = t, s = a || e.defaultExportFormat || "pdf";
|
|
1036
1046
|
try {
|
|
1037
1047
|
let t = (await n.find(r, i)).data || [];
|
|
1038
|
-
return
|
|
1048
|
+
return V(s, e, t, {
|
|
1039
1049
|
format: s,
|
|
1040
1050
|
...e.exportConfigs?.[s],
|
|
1041
1051
|
...o
|
|
@@ -1053,17 +1063,17 @@ async function ve(e, t) {
|
|
|
1053
1063
|
};
|
|
1054
1064
|
}
|
|
1055
1065
|
}
|
|
1056
|
-
function
|
|
1057
|
-
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) => {
|
|
1058
1068
|
if (n.formula) return n.formula.replace(/\{ROW\}/g, String(t + 2));
|
|
1059
1069
|
let r = e[n.name];
|
|
1060
|
-
return
|
|
1070
|
+
return De(r, n.numberFormat);
|
|
1061
1071
|
}));
|
|
1062
1072
|
if (a && t.length > 0) {
|
|
1063
1073
|
let n = o.map((n, r) => {
|
|
1064
1074
|
let i = (e.fields || []).find((e) => e.name === n.name);
|
|
1065
1075
|
if (i?.aggregation) {
|
|
1066
|
-
let e =
|
|
1076
|
+
let e = ke(r), n = t.length + 1;
|
|
1067
1077
|
switch (i.aggregation) {
|
|
1068
1078
|
case "sum": return `=SUM(${e}2:${e}${n})`;
|
|
1069
1079
|
case "avg": return `=AVERAGE(${e}2:${e}${n})`;
|
|
@@ -1077,15 +1087,15 @@ function ye(e, t, n = {}) {
|
|
|
1077
1087
|
});
|
|
1078
1088
|
c.push(n);
|
|
1079
1089
|
}
|
|
1080
|
-
|
|
1090
|
+
je("" + [s.join(" "), ...c.map((e) => e.join(" "))].join("\n"), i || `${e.title || "report"}.tsv`, "text/tab-separated-values");
|
|
1081
1091
|
}
|
|
1082
|
-
function
|
|
1092
|
+
function Te(e, t, n, r) {
|
|
1083
1093
|
return async () => {
|
|
1084
1094
|
let i = e.schedule;
|
|
1085
1095
|
if (!i?.enabled) return [];
|
|
1086
1096
|
let a = i.formats || [e.defaultExportFormat || "pdf"], o = [];
|
|
1087
1097
|
for (let r of a) {
|
|
1088
|
-
let i = await
|
|
1098
|
+
let i = await $(e, {
|
|
1089
1099
|
dataSource: t,
|
|
1090
1100
|
resource: n,
|
|
1091
1101
|
format: r
|
|
@@ -1095,16 +1105,16 @@ function be(e, t, n, r) {
|
|
|
1095
1105
|
return r(e, i), o;
|
|
1096
1106
|
};
|
|
1097
1107
|
}
|
|
1098
|
-
function
|
|
1108
|
+
function Ee(e) {
|
|
1099
1109
|
return {
|
|
1100
1110
|
name: e.name,
|
|
1101
1111
|
header: e.label || e.name
|
|
1102
1112
|
};
|
|
1103
1113
|
}
|
|
1104
|
-
function
|
|
1105
|
-
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));
|
|
1106
1116
|
}
|
|
1107
|
-
function
|
|
1117
|
+
function Oe(e) {
|
|
1108
1118
|
if (e.includes("%")) return {
|
|
1109
1119
|
style: "percent",
|
|
1110
1120
|
minimumFractionDigits: 0
|
|
@@ -1115,23 +1125,23 @@ function Ce(e) {
|
|
|
1115
1125
|
maximumFractionDigits: Math.max(0, t - 1)
|
|
1116
1126
|
};
|
|
1117
1127
|
}
|
|
1118
|
-
function
|
|
1128
|
+
function ke(e) {
|
|
1119
1129
|
let t = "", n = e;
|
|
1120
1130
|
for (; n >= 0;) t = String.fromCharCode(n % 26 + 65) + t, n = Math.floor(n / 26) - 1;
|
|
1121
1131
|
return t;
|
|
1122
1132
|
}
|
|
1123
|
-
function
|
|
1133
|
+
function Ae(e) {
|
|
1124
1134
|
if (e.length > 0) {
|
|
1125
1135
|
let t = e.charAt(0);
|
|
1126
1136
|
if (t === "=" || t === "+" || t === "-" || t === "@" || t === "|") return `'${e}`;
|
|
1127
1137
|
}
|
|
1128
1138
|
return e;
|
|
1129
1139
|
}
|
|
1130
|
-
function
|
|
1140
|
+
function je(e, t, n) {
|
|
1131
1141
|
let r = new Blob([e], { type: `${n};charset=utf-8` }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
1132
1142
|
a.href = i, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
1133
1143
|
}
|
|
1134
|
-
e.register("report",
|
|
1144
|
+
e.register("report", Q, {
|
|
1135
1145
|
namespace: "report",
|
|
1136
1146
|
label: "Report",
|
|
1137
1147
|
category: "Report",
|
|
@@ -1152,7 +1162,7 @@ e.register("report", $, {
|
|
|
1152
1162
|
label: "Chart Configuration"
|
|
1153
1163
|
}
|
|
1154
1164
|
]
|
|
1155
|
-
}), e.register("spec-report",
|
|
1165
|
+
}), e.register("spec-report", Q, {
|
|
1156
1166
|
namespace: "report",
|
|
1157
1167
|
label: "Spec Report",
|
|
1158
1168
|
category: "Report",
|
|
@@ -1165,7 +1175,7 @@ e.register("report", $, {
|
|
|
1165
1175
|
type: "string",
|
|
1166
1176
|
label: "Report Type"
|
|
1167
1177
|
}]
|
|
1168
|
-
}), e.register("report-viewer",
|
|
1178
|
+
}), e.register("report-viewer", G, {
|
|
1169
1179
|
namespace: "report",
|
|
1170
1180
|
label: "Report Viewer",
|
|
1171
1181
|
category: "Report",
|
|
@@ -1180,4 +1190,4 @@ e.register("report", $, {
|
|
|
1180
1190
|
}]
|
|
1181
1191
|
});
|
|
1182
1192
|
//#endregion
|
|
1183
|
-
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 };
|