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