@object-ui/plugin-dashboard 7.0.0 → 7.1.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 +39 -0
- package/dist/DashboardRenderer.d.ts.map +1 -1
- package/dist/DatasetWidget.d.ts.map +1 -1
- package/dist/MetricWidget.d.ts +7 -1
- package/dist/MetricWidget.d.ts.map +1 -1
- package/dist/ObjectMetricWidget.d.ts +2 -0
- package/dist/ObjectMetricWidget.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +747 -659
- package/dist/index.umd.cjs +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ComponentRegistry as e, buildChartSeries as t, buildDatasetDrillFilter as n, buildDatasetFieldHelpers as r,
|
|
2
|
-
import { SchemaRenderer as
|
|
3
|
-
import { createSafeTranslation as
|
|
4
|
-
import { Button as
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
7
|
-
import { AlertCircle as fe, AlertTriangle as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
11
|
-
import { formatCurrency as
|
|
12
|
-
import { Fragment as
|
|
13
|
-
import { ResponsiveGridLayout as
|
|
1
|
+
import { ComponentRegistry as e, buildChartSeries as t, buildDatasetDrillFilter as n, buildDatasetFieldHelpers as r, buildOptionColorMap as i, compareToTrendLabelKey as a, computeDrillFilter as o, extractRecords as s, findChartSeriesRow as c, formatDimensionValue as l, formatMeasure as u, isDrillEnabled as d, resolveDateMacros as f, resolveDrillTitle as p, shiftFilterByCompareTo as m } from "@object-ui/core";
|
|
2
|
+
import { SchemaRenderer as h, SchemaRendererContext as g, useActionEngine as _, useDataScope as v, useDnd as y, useDrillNavigation as b, useHasDndProvider as x, useObjectLabel as S } from "@object-ui/react";
|
|
3
|
+
import { createSafeTranslation as C, resolveFieldCurrency as w, useLocalization as T, useObjectTranslation as E, useSafeFieldLabel as D, useSafeTranslate as O } from "@object-ui/i18n";
|
|
4
|
+
import { Button as k, Card as A, CardContent as j, CardHeader as M, CardTitle as N, Combobox as P, ConfigPanelRenderer as F, ConfigRow as I, DataEmptyState as ee, Dialog as te, DialogContent as L, DialogHeader as R, DialogTitle as ne, RefreshIndicator as re, Sheet as z, SheetContent as ie, SheetHeader as B, SheetTitle as ae, Skeleton as V, cn as H, getLazyIcon as oe, useConfigDraft as se } from "@object-ui/components";
|
|
5
|
+
import * as U from "react";
|
|
6
|
+
import W, { Fragment as ce, forwardRef as le, useCallback as G, useContext as ue, useEffect as K, useMemo as q, useRef as de, useState as J } from "react";
|
|
7
|
+
import { AlertCircle as fe, AlertTriangle as Y, ArrowDownIcon as pe, ArrowUpIcon as me, ArrowUpRight as he, BarChart3 as ge, Download as X, Edit as _e, GripVertical as ve, Loader2 as ye, MinusIcon as be, RefreshCw as xe, Save as Se, Settings as Ce, X as we } from "lucide-react";
|
|
8
|
+
import { DndContext as Te, PointerSensor as Ee, closestCenter as De, useSensor as Oe, useSensors as ke } from "@dnd-kit/core";
|
|
9
|
+
import { SortableContext as Ae, arrayMove as je, rectSortingStrategy as Me, useSortable as Ne, verticalListSortingStrategy as Pe } from "@dnd-kit/sortable";
|
|
10
|
+
import { CSS as Fe } from "@dnd-kit/utilities";
|
|
11
|
+
import { formatCurrency as Ie, formatDate as Le, formatPercent as Re, getCellRenderer as ze, resolveCellRendererType as Be } from "@object-ui/fields";
|
|
12
|
+
import { Fragment as Ve, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
13
|
+
import { ResponsiveGridLayout as He, useContainerWidth as Ue } from "react-grid-layout";
|
|
14
14
|
import "react-grid-layout/css/styles.css";
|
|
15
15
|
//#region src/utils.ts
|
|
16
16
|
function $(e) {
|
|
17
17
|
return typeof e == "object" && !!e && !Array.isArray(e) && e.provider === "object";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function We(e, t) {
|
|
20
20
|
if (t == null || e == null || typeof e != "number" || !Number.isFinite(e) || typeof t != "number" || !Number.isFinite(t)) return null;
|
|
21
21
|
if (t === 0) return e === 0 ? {
|
|
22
22
|
value: 0,
|
|
@@ -38,7 +38,7 @@ function Ue(e, t) {
|
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/recordFields.tsx
|
|
41
|
-
var
|
|
41
|
+
var Ge = new Set([
|
|
42
42
|
"id",
|
|
43
43
|
"organization_id",
|
|
44
44
|
"tenant_id",
|
|
@@ -52,15 +52,15 @@ var We = new Set([
|
|
|
52
52
|
"_id",
|
|
53
53
|
"__typename"
|
|
54
54
|
]);
|
|
55
|
-
function
|
|
56
|
-
return t && (t.isSystem === !0 || t.system === !0) ? !0 :
|
|
55
|
+
function Ke(e, t) {
|
|
56
|
+
return t && (t.isSystem === !0 || t.system === !0) ? !0 : Ge.has(e);
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var qe = new Set([
|
|
59
59
|
"select",
|
|
60
60
|
"picklist",
|
|
61
61
|
"dropdown",
|
|
62
62
|
"status"
|
|
63
|
-
]),
|
|
63
|
+
]), Je = new Set([
|
|
64
64
|
"currency",
|
|
65
65
|
"money",
|
|
66
66
|
"number",
|
|
@@ -70,7 +70,7 @@ var Ke = new Set([
|
|
|
70
70
|
"percent",
|
|
71
71
|
"percentage"
|
|
72
72
|
]);
|
|
73
|
-
function
|
|
73
|
+
function Ye(e) {
|
|
74
74
|
let t = {}, n = e?.fields;
|
|
75
75
|
if (!n) return t;
|
|
76
76
|
if (Array.isArray(n)) for (let e of n) e?.name && (t[e.name] = e);
|
|
@@ -80,9 +80,9 @@ function Je(e) {
|
|
|
80
80
|
};
|
|
81
81
|
return t;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function Xe(e) {
|
|
84
84
|
let { accessorKey: t, label: n, def: r, objectName: i, fieldOptionLabel: a, overrides: o = {} } = e, s = o.referenceTo ?? r?.referenceTo ?? (typeof r?.reference == "string" ? r.reference : r?.reference?.to) ?? r?.target, c = o.options ?? r?.options;
|
|
85
|
-
return i && c && a &&
|
|
85
|
+
return i && c && a && qe.has(r?.type) && (c = c.map((e) => {
|
|
86
86
|
if (e == null) return e;
|
|
87
87
|
let n = typeof e == "object" ? e.value : e, r = typeof e == "object" && e.label || String(n);
|
|
88
88
|
return {
|
|
@@ -101,10 +101,10 @@ function Ye(e) {
|
|
|
101
101
|
decimals: o.decimals ?? r?.decimals ?? r?.precision ?? r?.scale
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
104
|
+
function Ze(e) {
|
|
105
|
+
return Je.has(e.type) || typeof e.format == "string" && /^[\$¥€£]|%$|0/.test(e.format);
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function Qe(e, t, n) {
|
|
108
108
|
if (e == null || e === "") return "";
|
|
109
109
|
let r = t.format;
|
|
110
110
|
if (typeof r == "string" && /^\$|¥|€|£/.test(r) && typeof e == "number") {
|
|
@@ -114,20 +114,20 @@ function Ze(e, t, n) {
|
|
|
114
114
|
"€": "EUR",
|
|
115
115
|
"£": "GBP"
|
|
116
116
|
}[r[0]];
|
|
117
|
-
return
|
|
117
|
+
return Ie(e, t.currency || i || n);
|
|
118
118
|
}
|
|
119
119
|
if (typeof r == "string" && /%/.test(r) && typeof e == "number") {
|
|
120
120
|
let t = (r.match(/0\.(0+)%/) || [, ""])[1].length;
|
|
121
|
-
return
|
|
121
|
+
return Re((e > 1 ? e / 100 : e) * 100, t);
|
|
122
122
|
}
|
|
123
|
-
return typeof r == "string" && /[YMDHms]/.test(r) ?
|
|
123
|
+
return typeof r == "string" && /[YMDHms]/.test(r) ? Le(e, r) : /* @__PURE__ */ Z(ze(Be(t)), {
|
|
124
124
|
value: e,
|
|
125
125
|
field: t
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
//#endregion
|
|
129
129
|
//#region src/RecordDetailDrawer.tsx
|
|
130
|
-
var
|
|
130
|
+
var $e = [
|
|
131
131
|
"name",
|
|
132
132
|
"title",
|
|
133
133
|
"label",
|
|
@@ -135,21 +135,21 @@ var Qe = [
|
|
|
135
135
|
"display_name",
|
|
136
136
|
"full_name"
|
|
137
137
|
];
|
|
138
|
-
function
|
|
138
|
+
function et(e, t) {
|
|
139
139
|
if (t && t.trim()) return t;
|
|
140
|
-
for (let t of
|
|
140
|
+
for (let t of $e) {
|
|
141
141
|
let n = e[t];
|
|
142
142
|
if (typeof n == "string" && n.trim()) return n;
|
|
143
143
|
}
|
|
144
144
|
let n = e.id ?? e._id;
|
|
145
145
|
return n == null ? "Record" : String(n);
|
|
146
146
|
}
|
|
147
|
-
var
|
|
148
|
-
let { fieldLabel: s, fieldOptionLabel: c } =
|
|
147
|
+
var tt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, target: a = "drawer", onClose: o }) => {
|
|
148
|
+
let { fieldLabel: s, fieldOptionLabel: c } = D(), { currency: l } = T(), u = q(() => {
|
|
149
149
|
if (!e) return [];
|
|
150
|
-
let i =
|
|
151
|
-
return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !
|
|
152
|
-
let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ? s(t, n, a) : a, u =
|
|
150
|
+
let i = Ye(n), a;
|
|
151
|
+
return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !Ke(e, i[e])) : Object.keys(e).filter((e) => !e.startsWith("_") && !Ke(e)), a.map((n) => {
|
|
152
|
+
let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ? s(t, n, a) : a, u = Xe({
|
|
153
153
|
accessorKey: n,
|
|
154
154
|
label: o,
|
|
155
155
|
def: r,
|
|
@@ -159,8 +159,8 @@ var et = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
159
159
|
return {
|
|
160
160
|
key: n,
|
|
161
161
|
label: o,
|
|
162
|
-
node:
|
|
163
|
-
numeric:
|
|
162
|
+
node: Qe(e[n], u, l),
|
|
163
|
+
numeric: Ze(u)
|
|
164
164
|
};
|
|
165
165
|
});
|
|
166
166
|
}, [
|
|
@@ -173,7 +173,7 @@ var et = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
173
173
|
l
|
|
174
174
|
]);
|
|
175
175
|
if (!e) return null;
|
|
176
|
-
let d =
|
|
176
|
+
let d = et(e, i), f = /* @__PURE__ */ Z("dl", {
|
|
177
177
|
className: "divide-y divide-border/60",
|
|
178
178
|
"data-testid": "record-detail-body",
|
|
179
179
|
children: u.map((e) => /* @__PURE__ */ Q("div", {
|
|
@@ -190,12 +190,12 @@ var et = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
190
190
|
})]
|
|
191
191
|
}, e.key))
|
|
192
192
|
});
|
|
193
|
-
return a === "dialog" ? /* @__PURE__ */ Z(
|
|
193
|
+
return a === "dialog" ? /* @__PURE__ */ Z(te, {
|
|
194
194
|
open: !0,
|
|
195
195
|
onOpenChange: (e) => !e && o(),
|
|
196
|
-
children: /* @__PURE__ */ Q(
|
|
196
|
+
children: /* @__PURE__ */ Q(L, {
|
|
197
197
|
className: "max-w-2xl",
|
|
198
|
-
children: [/* @__PURE__ */ Z(
|
|
198
|
+
children: [/* @__PURE__ */ Z(R, { children: /* @__PURE__ */ Z(ne, { children: d }) }), /* @__PURE__ */ Z("div", {
|
|
199
199
|
className: "max-h-[70vh] overflow-auto",
|
|
200
200
|
children: f
|
|
201
201
|
})]
|
|
@@ -203,10 +203,10 @@ var et = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
203
203
|
}) : /* @__PURE__ */ Z(z, {
|
|
204
204
|
open: !0,
|
|
205
205
|
onOpenChange: (e) => !e && o(),
|
|
206
|
-
children: /* @__PURE__ */ Q(
|
|
206
|
+
children: /* @__PURE__ */ Q(ie, {
|
|
207
207
|
side: "right",
|
|
208
208
|
className: "w-full sm:max-w-md md:max-w-lg flex flex-col",
|
|
209
|
-
children: [/* @__PURE__ */ Z(
|
|
209
|
+
children: [/* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z(ae, { children: d }) }), /* @__PURE__ */ Z("div", {
|
|
210
210
|
className: "flex-1 overflow-auto mt-2 pr-1",
|
|
211
211
|
children: f
|
|
212
212
|
})]
|
|
@@ -215,13 +215,13 @@ var et = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
215
215
|
};
|
|
216
216
|
//#endregion
|
|
217
217
|
//#region src/ObjectDataTable.tsx
|
|
218
|
-
function
|
|
218
|
+
function nt(e) {
|
|
219
219
|
return e.map((e) => typeof e == "string" ? {
|
|
220
220
|
header: e.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (e) => e.toUpperCase()),
|
|
221
221
|
accessorKey: e
|
|
222
222
|
} : e);
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function rt(e, t) {
|
|
225
225
|
if (!t?.fields) return [];
|
|
226
226
|
let n = {};
|
|
227
227
|
if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
|
|
@@ -239,34 +239,34 @@ function nt(e, t) {
|
|
|
239
239
|
} else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
|
|
240
240
|
return Array.from(a);
|
|
241
241
|
}
|
|
242
|
-
var
|
|
243
|
-
let { currency: r } =
|
|
242
|
+
var it = ({ schema: e, dataSource: t, className: n }) => {
|
|
243
|
+
let { currency: r } = T(), i = ue(g), a = t || i?.dataSource, o = v(e.bind), { fieldLabel: c, fieldOptionLabel: l } = D(), u = "No data available", p = "No data source available for";
|
|
244
244
|
try {
|
|
245
|
-
let { t: e } =
|
|
246
|
-
t && t !== "dashboard.noDataAvailable" && (
|
|
245
|
+
let { t: e } = E(), t = e("dashboard.noDataAvailable");
|
|
246
|
+
t && t !== "dashboard.noDataAvailable" && (u = t);
|
|
247
247
|
let n = e("dashboard.noDataSourceFor");
|
|
248
248
|
n && n !== "dashboard.noDataSourceFor" && (p = n);
|
|
249
249
|
} catch {}
|
|
250
|
-
let [
|
|
250
|
+
let [m, _] = J([]), [y, b] = J(null), [x, S] = J(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [C, w] = J(null), O = e.drillDown, k = d(O) && (O?.mode ?? "record") === "record", [A, j] = J(null), M = G((e) => {
|
|
251
251
|
j(e ?? null);
|
|
252
252
|
}, []);
|
|
253
|
-
|
|
253
|
+
K(() => {
|
|
254
254
|
let t = !0;
|
|
255
|
-
return e.objectName && !
|
|
255
|
+
return e.objectName && !o && (!e.data || e.data.length === 0) ? (async () => {
|
|
256
256
|
if (!a || !e.objectName) {
|
|
257
257
|
t && S(!1);
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
|
-
t && (S(!0),
|
|
260
|
+
t && (S(!0), w(null));
|
|
261
261
|
try {
|
|
262
262
|
let n;
|
|
263
263
|
if (typeof a.find == "function") {
|
|
264
|
-
let t =
|
|
265
|
-
t.length && (r.$expand = t), n =
|
|
264
|
+
let t = rt(e, y), r = { $filter: f(e.filter) };
|
|
265
|
+
t.length && (r.$expand = t), n = s(await a.find(e.objectName, r));
|
|
266
266
|
} else return;
|
|
267
|
-
t &&
|
|
267
|
+
t && _(n);
|
|
268
268
|
} catch (e) {
|
|
269
|
-
console.error("[ObjectDataTable] Fetch error:", e), t &&
|
|
269
|
+
console.error("[ObjectDataTable] Fetch error:", e), t && w(e instanceof Error ? e.message : "Failed to load data");
|
|
270
270
|
} finally {
|
|
271
271
|
t && S(!1);
|
|
272
272
|
}
|
|
@@ -276,11 +276,11 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
276
276
|
}, [
|
|
277
277
|
e.objectName,
|
|
278
278
|
a,
|
|
279
|
-
|
|
279
|
+
o,
|
|
280
280
|
e.data,
|
|
281
281
|
e.filter,
|
|
282
282
|
y
|
|
283
|
-
]),
|
|
283
|
+
]), K(() => {
|
|
284
284
|
let t = !0;
|
|
285
285
|
if (!(!a || !e.objectName || typeof a.getObjectSchema != "function")) return a.getObjectSchema(e.objectName).then((e) => {
|
|
286
286
|
t && b(e);
|
|
@@ -288,7 +288,7 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
288
288
|
t = !1;
|
|
289
289
|
};
|
|
290
290
|
}, [e.objectName, a]);
|
|
291
|
-
let N =
|
|
291
|
+
let N = o || e.data || m, P = Array.isArray(N) ? N : [], F = q(() => {
|
|
292
292
|
let t = e.objectName, n = {};
|
|
293
293
|
if (y?.fields) {
|
|
294
294
|
let e = y.fields;
|
|
@@ -302,7 +302,7 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
302
302
|
let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
|
|
303
303
|
return t ? c(t, e, n) : n;
|
|
304
304
|
}, a = (e) => {
|
|
305
|
-
let i =
|
|
305
|
+
let i = Xe({
|
|
306
306
|
accessorKey: e.accessorKey,
|
|
307
307
|
label: e.header,
|
|
308
308
|
def: n[e.accessorKey],
|
|
@@ -316,13 +316,13 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
316
316
|
currency: e.currency,
|
|
317
317
|
decimals: e.decimals
|
|
318
318
|
}
|
|
319
|
-
}), a = e.align ?? (
|
|
319
|
+
}), a = e.align ?? (Ze(i) ? "right" : void 0);
|
|
320
320
|
if (typeof e.cell == "function") return {
|
|
321
321
|
...e,
|
|
322
322
|
...i,
|
|
323
323
|
align: a
|
|
324
324
|
};
|
|
325
|
-
let o = (e) =>
|
|
325
|
+
let o = (e) => Qe(e, i, r);
|
|
326
326
|
return {
|
|
327
327
|
...e,
|
|
328
328
|
...i,
|
|
@@ -331,13 +331,13 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
331
331
|
};
|
|
332
332
|
};
|
|
333
333
|
if (e.columns && e.columns.length > 0) {
|
|
334
|
-
let n =
|
|
334
|
+
let n = nt(e.columns);
|
|
335
335
|
return (t ? n.map((e) => ({
|
|
336
336
|
...e,
|
|
337
337
|
header: c(t, e.accessorKey, e.header)
|
|
338
338
|
})) : n).map(a);
|
|
339
339
|
}
|
|
340
|
-
return P.length === 0 ? [] : (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !
|
|
340
|
+
return P.length === 0 ? [] : (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !Ke(e, n[e])) : Object.keys(P[0]).filter((e) => !e.startsWith("_") && !Ke(e))).map((e) => a({
|
|
341
341
|
header: i(e),
|
|
342
342
|
accessorKey: e
|
|
343
343
|
}));
|
|
@@ -351,17 +351,17 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
351
351
|
r
|
|
352
352
|
]);
|
|
353
353
|
if (x && P.length === 0) return /* @__PURE__ */ Z("div", {
|
|
354
|
-
className:
|
|
354
|
+
className: H("overflow-auto", n),
|
|
355
355
|
"data-testid": "table-loading",
|
|
356
356
|
children: /* @__PURE__ */ Q("div", {
|
|
357
357
|
className: "space-y-2 p-2",
|
|
358
358
|
children: [/* @__PURE__ */ Q("div", {
|
|
359
359
|
className: "flex gap-2",
|
|
360
360
|
children: [
|
|
361
|
-
/* @__PURE__ */ Z(
|
|
362
|
-
/* @__PURE__ */ Z(
|
|
363
|
-
/* @__PURE__ */ Z(
|
|
364
|
-
/* @__PURE__ */ Z(
|
|
361
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-1/4" }),
|
|
362
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-1/4" }),
|
|
363
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-1/4" }),
|
|
364
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-1/4" })
|
|
365
365
|
]
|
|
366
366
|
}), [
|
|
367
367
|
1,
|
|
@@ -371,16 +371,16 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
371
371
|
].map((e) => /* @__PURE__ */ Q("div", {
|
|
372
372
|
className: "flex gap-2",
|
|
373
373
|
children: [
|
|
374
|
-
/* @__PURE__ */ Z(
|
|
375
|
-
/* @__PURE__ */ Z(
|
|
376
|
-
/* @__PURE__ */ Z(
|
|
377
|
-
/* @__PURE__ */ Z(
|
|
374
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-1/4" }),
|
|
375
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-1/4" }),
|
|
376
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-1/4" }),
|
|
377
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-1/4" })
|
|
378
378
|
]
|
|
379
379
|
}, e))]
|
|
380
380
|
})
|
|
381
381
|
});
|
|
382
382
|
if (C) return /* @__PURE__ */ Z("div", {
|
|
383
|
-
className:
|
|
383
|
+
className: H("overflow-auto", n),
|
|
384
384
|
"data-testid": "table-error",
|
|
385
385
|
children: /* @__PURE__ */ Q("div", {
|
|
386
386
|
className: "flex flex-col items-center justify-center py-8 text-destructive",
|
|
@@ -420,7 +420,7 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
420
420
|
})
|
|
421
421
|
});
|
|
422
422
|
if (!a && e.objectName && P.length === 0) return /* @__PURE__ */ Z("div", {
|
|
423
|
-
className:
|
|
423
|
+
className: H("overflow-auto", n),
|
|
424
424
|
children: /* @__PURE__ */ Z("div", {
|
|
425
425
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
426
426
|
children: /* @__PURE__ */ Q("p", {
|
|
@@ -435,7 +435,7 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
435
435
|
})
|
|
436
436
|
});
|
|
437
437
|
if (P.length === 0) return /* @__PURE__ */ Z("div", {
|
|
438
|
-
className:
|
|
438
|
+
className: H("overflow-auto", n),
|
|
439
439
|
"data-testid": "table-empty-state",
|
|
440
440
|
children: /* @__PURE__ */ Q("div", {
|
|
441
441
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
@@ -472,7 +472,7 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
472
472
|
]
|
|
473
473
|
}), /* @__PURE__ */ Z("p", {
|
|
474
474
|
className: "text-xs",
|
|
475
|
-
children:
|
|
475
|
+
children: u
|
|
476
476
|
})]
|
|
477
477
|
})
|
|
478
478
|
});
|
|
@@ -482,29 +482,29 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
482
482
|
data: P,
|
|
483
483
|
columns: F,
|
|
484
484
|
onRowClick: e.onRowClick ?? (k ? M : void 0)
|
|
485
|
-
},
|
|
485
|
+
}, ee = O?.title && !O.title.includes("${") ? O.title : void 0;
|
|
486
486
|
return /* @__PURE__ */ Q("div", {
|
|
487
|
-
className:
|
|
487
|
+
className: H("relative", n),
|
|
488
488
|
children: [
|
|
489
|
-
/* @__PURE__ */ Z(
|
|
490
|
-
/* @__PURE__ */ Z(
|
|
489
|
+
/* @__PURE__ */ Z(re, { active: x && P.length > 0 }),
|
|
490
|
+
/* @__PURE__ */ Z(h, {
|
|
491
491
|
schema: I,
|
|
492
492
|
className: n
|
|
493
493
|
}),
|
|
494
|
-
k && /* @__PURE__ */ Z(
|
|
494
|
+
k && /* @__PURE__ */ Z(tt, {
|
|
495
495
|
record: A,
|
|
496
496
|
objectName: e.objectName,
|
|
497
497
|
objectSchema: y,
|
|
498
498
|
fields: O?.columns,
|
|
499
|
-
title:
|
|
499
|
+
title: ee,
|
|
500
500
|
target: O?.target === "dialog" ? "dialog" : "drawer",
|
|
501
501
|
onClose: () => j(null)
|
|
502
502
|
})
|
|
503
503
|
]
|
|
504
504
|
});
|
|
505
|
-
},
|
|
506
|
-
let { openRecordList: i } =
|
|
507
|
-
return !i || !e ? null : /* @__PURE__ */ Q(
|
|
505
|
+
}, at = ({ objectName: e, filter: t, onNavigate: n, className: r }) => {
|
|
506
|
+
let { openRecordList: i } = b(), a = O();
|
|
507
|
+
return !i || !e ? null : /* @__PURE__ */ Q(k, {
|
|
508
508
|
type: "button",
|
|
509
509
|
variant: "ghost",
|
|
510
510
|
size: "sm",
|
|
@@ -515,21 +515,21 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
515
515
|
},
|
|
516
516
|
children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Z(he, { className: "ml-1 h-3.5 w-3.5" })]
|
|
517
517
|
});
|
|
518
|
-
},
|
|
519
|
-
let { openRecordList: d } =
|
|
520
|
-
if (
|
|
518
|
+
}, ot = ({ open: e, onClose: t, title: n, target: r = "drawer", objectName: i, filter: a, dataSource: o, columns: s, maxRows: c, className: l, report: u }) => {
|
|
519
|
+
let { openRecordList: d } = b(), f = u && typeof u == "object" && (Array.isArray(u.columns) || "objectName" in u), p = r === "navigate" && !!d && !f && !!i;
|
|
520
|
+
if (W.useEffect(() => {
|
|
521
521
|
e && p && (d(i, a), t());
|
|
522
522
|
}, [e, p]), p) return null;
|
|
523
|
-
let
|
|
523
|
+
let m = f ? null : /* @__PURE__ */ Z(at, {
|
|
524
524
|
objectName: i,
|
|
525
525
|
filter: a,
|
|
526
526
|
onNavigate: t
|
|
527
527
|
}), g = /* @__PURE__ */ Z("div", {
|
|
528
|
-
className:
|
|
528
|
+
className: H("overflow-auto", l),
|
|
529
529
|
"data-testid": "drill-down-body",
|
|
530
530
|
children: f ? (() => {
|
|
531
531
|
let e = u.filter, t = e ? a ? { $and: [e, a] } : e : a;
|
|
532
|
-
return /* @__PURE__ */ Z(
|
|
532
|
+
return /* @__PURE__ */ Z(h, { schema: {
|
|
533
533
|
...u,
|
|
534
534
|
type: "spec-report",
|
|
535
535
|
report: {
|
|
@@ -538,7 +538,7 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
538
538
|
},
|
|
539
539
|
filter: t
|
|
540
540
|
} });
|
|
541
|
-
})() : /* @__PURE__ */ Z(
|
|
541
|
+
})() : /* @__PURE__ */ Z(it, {
|
|
542
542
|
schema: {
|
|
543
543
|
type: "object-data-table",
|
|
544
544
|
objectName: i,
|
|
@@ -559,69 +559,69 @@ var rt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
559
559
|
dataSource: o
|
|
560
560
|
})
|
|
561
561
|
});
|
|
562
|
-
return r === "dialog" ? /* @__PURE__ */ Z(
|
|
562
|
+
return r === "dialog" ? /* @__PURE__ */ Z(te, {
|
|
563
563
|
open: e,
|
|
564
564
|
onOpenChange: (e) => !e && t(),
|
|
565
|
-
children: /* @__PURE__ */ Q(
|
|
565
|
+
children: /* @__PURE__ */ Q(L, {
|
|
566
566
|
className: "max-w-5xl",
|
|
567
|
-
children: [/* @__PURE__ */ Q(
|
|
567
|
+
children: [/* @__PURE__ */ Q(R, {
|
|
568
568
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
569
|
-
children: [/* @__PURE__ */ Z(
|
|
569
|
+
children: [/* @__PURE__ */ Z(ne, { children: n }), m]
|
|
570
570
|
}), g]
|
|
571
571
|
})
|
|
572
572
|
}) : /* @__PURE__ */ Z(z, {
|
|
573
573
|
open: e,
|
|
574
574
|
onOpenChange: (e) => !e && t(),
|
|
575
|
-
children: /* @__PURE__ */ Q(
|
|
575
|
+
children: /* @__PURE__ */ Q(ie, {
|
|
576
576
|
side: "right",
|
|
577
577
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
578
|
-
children: [/* @__PURE__ */ Q(
|
|
578
|
+
children: [/* @__PURE__ */ Q(B, {
|
|
579
579
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
580
|
-
children: [/* @__PURE__ */ Z(ae, { children: n }),
|
|
580
|
+
children: [/* @__PURE__ */ Z(ae, { children: n }), m]
|
|
581
581
|
}), /* @__PURE__ */ Z("div", {
|
|
582
582
|
className: "flex-1 overflow-hidden mt-2",
|
|
583
583
|
children: g
|
|
584
584
|
})]
|
|
585
585
|
})
|
|
586
586
|
});
|
|
587
|
-
},
|
|
588
|
-
function
|
|
587
|
+
}, st = n;
|
|
588
|
+
function ct(e, t, n) {
|
|
589
589
|
let r = [], i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
590
|
-
return e.forEach((e,
|
|
590
|
+
return e.forEach((e, c) => {
|
|
591
591
|
let u = t.map((t) => String(e[t] ?? "∅")).join(""), d = String(e[n] ?? "∅");
|
|
592
592
|
a.has(u) || (a.add(u), r.push({
|
|
593
593
|
id: u,
|
|
594
|
-
labels: t.map((t) =>
|
|
594
|
+
labels: t.map((t) => l(e[t]))
|
|
595
595
|
})), o.has(d) || (o.add(d), i.push({
|
|
596
596
|
id: d,
|
|
597
|
-
label:
|
|
598
|
-
})), s.set(`${u} ${d}`,
|
|
597
|
+
label: l(e[n])
|
|
598
|
+
})), s.set(`${u} ${d}`, c);
|
|
599
599
|
}), {
|
|
600
600
|
rowHeaders: r,
|
|
601
601
|
colHeaders: i,
|
|
602
602
|
cellIndex: s
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
|
-
function
|
|
605
|
+
function lt(e) {
|
|
606
606
|
if (e == null) return "";
|
|
607
607
|
let t = String(e);
|
|
608
608
|
return /[",\n\r]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
609
609
|
}
|
|
610
|
-
function
|
|
611
|
-
return e.map((e) => e.map(
|
|
610
|
+
function ut(e) {
|
|
611
|
+
return e.map((e) => e.map(lt).join(",")).join("\r\n");
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function dt(e, t) {
|
|
614
614
|
if (typeof document > "u") return;
|
|
615
|
-
let n = e && e.trim() ? e.trim() : "export", r = new Blob([`${
|
|
615
|
+
let n = e && e.trim() ? e.trim() : "export", r = new Blob([`${ut(t)}`], { type: "text/csv;charset=utf-8;" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
616
616
|
a.href = i, a.download = n.endsWith(".csv") ? n : `${n}.csv`, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
|
|
617
617
|
}
|
|
618
|
-
var
|
|
618
|
+
var ft = new Set([
|
|
619
619
|
"metric",
|
|
620
620
|
"kpi",
|
|
621
621
|
"gauge",
|
|
622
622
|
"solid-gauge",
|
|
623
623
|
"bullet"
|
|
624
|
-
]),
|
|
624
|
+
]), pt = {
|
|
625
625
|
bar: "bar",
|
|
626
626
|
column: "column",
|
|
627
627
|
"horizontal-bar": "horizontal-bar",
|
|
@@ -643,44 +643,44 @@ var dt = new Set([
|
|
|
643
643
|
treemap: "treemap",
|
|
644
644
|
sankey: "sankey"
|
|
645
645
|
};
|
|
646
|
-
function
|
|
647
|
-
let
|
|
648
|
-
|
|
649
|
-
[
|
|
646
|
+
function mt({ widget: e, dataSource: n }) {
|
|
647
|
+
let a = String(e?.dataset ?? ""), o = q(() => Array.isArray(e?.dimensions) ? e.dimensions.filter(Boolean) : [], [e]), s = q(() => Array.isArray(e?.values) ? e.values.filter(Boolean) : [], [e]), d = e?.compareTo && typeof e.compareTo == "object" ? e.compareTo : void 0, p = String(e?.type ?? ""), m = ft.has(p) || o.length === 0, g = p === "table" || p === "pivot", _ = p === "pivot" && o.length >= 2, v = _ ? o.slice(0, -1) : [], y = _ ? o[o.length - 1] : "", b = _ ? [
|
|
648
|
+
v,
|
|
649
|
+
[y],
|
|
650
650
|
[]
|
|
651
|
-
] : void 0,
|
|
651
|
+
] : void 0, x = O(), { fieldLabel: S } = D(), C = e?.filter, w = q(() => C && typeof C == "object" && Object.keys(C).length > 0 ? f(C) : void 0, [C]), [T, E] = J({
|
|
652
652
|
status: "idle",
|
|
653
653
|
rows: []
|
|
654
|
-
}), [
|
|
655
|
-
if (
|
|
654
|
+
}), [k, A] = J(null), [j, M] = J(null);
|
|
655
|
+
if (K(() => {
|
|
656
656
|
let e = n;
|
|
657
657
|
if (!e || typeof e.queryDataset != "function") {
|
|
658
|
-
|
|
658
|
+
E({
|
|
659
659
|
status: "error",
|
|
660
660
|
rows: [],
|
|
661
|
-
error:
|
|
661
|
+
error: x("dashboard.datasetUnsupported", "This data source does not support dataset queries.")
|
|
662
662
|
});
|
|
663
663
|
return;
|
|
664
664
|
}
|
|
665
|
-
if (
|
|
666
|
-
|
|
665
|
+
if (s.length === 0) {
|
|
666
|
+
E({
|
|
667
667
|
status: "idle",
|
|
668
668
|
rows: []
|
|
669
669
|
});
|
|
670
670
|
return;
|
|
671
671
|
}
|
|
672
672
|
let t = !1;
|
|
673
|
-
return
|
|
673
|
+
return E({
|
|
674
674
|
status: "loading",
|
|
675
675
|
rows: []
|
|
676
|
-
}), e.queryDataset(
|
|
677
|
-
dimensions:
|
|
678
|
-
measures:
|
|
679
|
-
...
|
|
680
|
-
...
|
|
681
|
-
...
|
|
676
|
+
}), e.queryDataset(a, {
|
|
677
|
+
dimensions: o,
|
|
678
|
+
measures: s,
|
|
679
|
+
...w ? { runtimeFilter: w } : {},
|
|
680
|
+
...d ? { compareTo: d } : {},
|
|
681
|
+
...b ? { totals: { groupings: b } } : {}
|
|
682
682
|
}).then((e) => {
|
|
683
|
-
t ||
|
|
683
|
+
t || E({
|
|
684
684
|
status: "ok",
|
|
685
685
|
rows: Array.isArray(e?.rows) ? e.rows : [],
|
|
686
686
|
fields: Array.isArray(e?.fields) ? e.fields : [],
|
|
@@ -690,7 +690,7 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
690
690
|
totals: Array.isArray(e?.totals) ? e.totals : void 0
|
|
691
691
|
});
|
|
692
692
|
}).catch((e) => {
|
|
693
|
-
t ||
|
|
693
|
+
t || E({
|
|
694
694
|
status: "error",
|
|
695
695
|
rows: [],
|
|
696
696
|
error: String(e?.message ?? e)
|
|
@@ -698,75 +698,105 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
698
698
|
}), () => {
|
|
699
699
|
t = !0;
|
|
700
700
|
};
|
|
701
|
-
}, [`${
|
|
701
|
+
}, [`${p}|${a}|${o.join(",")}|${s.join(",")}|${JSON.stringify(C ?? null)}|${JSON.stringify(d ?? null)}`]), K(() => {
|
|
702
|
+
if (m || g) {
|
|
703
|
+
M(null);
|
|
704
|
+
return;
|
|
705
|
+
}
|
|
706
|
+
let e = T.object, t = o[0], n = T.dimensionFields && T.dimensionFields[t] || t;
|
|
707
|
+
if (!e || !n) {
|
|
708
|
+
M(null);
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
let r = !1;
|
|
712
|
+
return (async () => {
|
|
713
|
+
try {
|
|
714
|
+
let t = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`, {
|
|
715
|
+
headers: { accept: "application/json" },
|
|
716
|
+
credentials: "include"
|
|
717
|
+
})).json().catch(() => null), a = i((t?.item ?? t?.data ?? t)?.fields?.[n]?.options);
|
|
718
|
+
r || M(a);
|
|
719
|
+
} catch {
|
|
720
|
+
r || M(null);
|
|
721
|
+
}
|
|
722
|
+
})(), () => {
|
|
723
|
+
r = !0;
|
|
724
|
+
};
|
|
725
|
+
}, [
|
|
726
|
+
T.object,
|
|
727
|
+
T.dimensionFields,
|
|
728
|
+
o,
|
|
729
|
+
m,
|
|
730
|
+
g
|
|
731
|
+
]), s.length === 0) return /* @__PURE__ */ Z("div", {
|
|
702
732
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
703
|
-
children:
|
|
733
|
+
children: x("dashboard.pickMeasures", "Pick measures (values) for this dataset widget.")
|
|
704
734
|
});
|
|
705
|
-
if (
|
|
735
|
+
if (T.status === "loading" || T.status === "idle") return /* @__PURE__ */ Z("div", {
|
|
706
736
|
className: "flex h-full w-full items-center justify-center p-4 text-muted-foreground",
|
|
707
|
-
children: /* @__PURE__ */ Z(
|
|
737
|
+
children: /* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" })
|
|
708
738
|
});
|
|
709
|
-
if (
|
|
739
|
+
if (T.status === "error") return /* @__PURE__ */ Q("div", {
|
|
710
740
|
role: "alert",
|
|
711
741
|
className: "flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive",
|
|
712
|
-
children: [/* @__PURE__ */ Z(
|
|
742
|
+
children: [/* @__PURE__ */ Z(Y, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
713
743
|
className: "break-words",
|
|
714
|
-
children:
|
|
744
|
+
children: T.error
|
|
715
745
|
})]
|
|
716
746
|
});
|
|
717
|
-
if (
|
|
747
|
+
if (T.rows.length === 0 && !m) return /* @__PURE__ */ Q("div", {
|
|
718
748
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
719
|
-
children: [/* @__PURE__ */ Z(ge, { className: "mr-2 h-4 w-4" }),
|
|
749
|
+
children: [/* @__PURE__ */ Z(ge, { className: "mr-2 h-4 w-4" }), x("dashboard.noRows", "No rows")]
|
|
720
750
|
});
|
|
721
|
-
let { measureField:
|
|
722
|
-
!
|
|
723
|
-
filter:
|
|
751
|
+
let { measureField: N, headerLabel: P } = r(T.fields, T.object, S), { object: F, dimensionFields: I, drillRawRows: ee } = T, te = I ? o.filter((e) => e in I) : [], L = !!F && te.length > 0, R = (t, n) => {
|
|
752
|
+
!F || !I || A({
|
|
753
|
+
filter: st(ee?.[t], te, I, w),
|
|
724
754
|
title: n || String(e?.title ?? "")
|
|
725
755
|
});
|
|
726
|
-
},
|
|
756
|
+
}, ne = k && F ? /* @__PURE__ */ Z(ot, {
|
|
727
757
|
open: !0,
|
|
728
|
-
onClose: () =>
|
|
729
|
-
title:
|
|
730
|
-
objectName:
|
|
731
|
-
filter:
|
|
758
|
+
onClose: () => A(null),
|
|
759
|
+
title: k.title || String(e?.title ?? x("dashboard.details", "Details")),
|
|
760
|
+
objectName: F,
|
|
761
|
+
filter: k.filter,
|
|
732
762
|
dataSource: n
|
|
733
763
|
}) : null;
|
|
734
|
-
if (
|
|
735
|
-
let e =
|
|
764
|
+
if (m) {
|
|
765
|
+
let e = N(s[0]);
|
|
736
766
|
return /* @__PURE__ */ Q("div", {
|
|
737
767
|
className: "flex h-full w-full flex-col items-start justify-center gap-1 p-2",
|
|
738
768
|
children: [/* @__PURE__ */ Z("span", {
|
|
739
769
|
className: "text-2xl font-semibold tabular-nums",
|
|
740
|
-
children:
|
|
770
|
+
children: u(T.rows[0]?.[s[0]] ?? 0, e?.format, e?.currency)
|
|
741
771
|
}), /* @__PURE__ */ Z("span", {
|
|
742
772
|
className: "text-xs text-muted-foreground",
|
|
743
|
-
children:
|
|
773
|
+
children: P(s[0])
|
|
744
774
|
})]
|
|
745
775
|
});
|
|
746
776
|
}
|
|
747
|
-
if (
|
|
748
|
-
let t = [...
|
|
777
|
+
if (g) {
|
|
778
|
+
let t = [...o, ...s], n = /* @__PURE__ */ Z("button", {
|
|
749
779
|
type: "button",
|
|
750
|
-
onClick: () =>
|
|
780
|
+
onClick: () => dt(String(e?.title ?? a ?? "export"), [t.map((e) => P(e)), ...T.rows.map((e) => t.map((t) => {
|
|
751
781
|
let n = e[t];
|
|
752
782
|
return n == null ? "" : typeof n == "number" ? n : String(n);
|
|
753
783
|
}))]),
|
|
754
784
|
"data-testid": "dataset-export",
|
|
755
|
-
title:
|
|
756
|
-
"aria-label":
|
|
785
|
+
title: x("dashboard.exportCsv", "Export CSV"),
|
|
786
|
+
"aria-label": x("dashboard.exportCsv", "Export CSV"),
|
|
757
787
|
className: "absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100",
|
|
758
|
-
children: /* @__PURE__ */ Z(
|
|
788
|
+
children: /* @__PURE__ */ Z(X, { className: "h-3.5 w-3.5" })
|
|
759
789
|
});
|
|
760
|
-
if (
|
|
761
|
-
let e =
|
|
790
|
+
if (_) {
|
|
791
|
+
let e = ct(T.rows, v, y), t = e.colHeaders.flatMap((e) => s.map((t) => ({
|
|
762
792
|
col: e,
|
|
763
793
|
measure: t,
|
|
764
|
-
header:
|
|
765
|
-
}))), r = (e, t) =>
|
|
766
|
-
for (let e of i(
|
|
767
|
-
let
|
|
768
|
-
for (let e of i([
|
|
769
|
-
let c = i([])?.[0],
|
|
794
|
+
header: s.length === 1 ? e.label : `${e.label} · ${P(t)}`
|
|
795
|
+
}))), r = (e, t) => u(e, N(t)?.format, N(t)?.currency), i = (e) => T.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows, a = /* @__PURE__ */ new Map();
|
|
796
|
+
for (let e of i(v) ?? []) a.set(v.map((t) => String(e[t] ?? "∅")).join(""), e);
|
|
797
|
+
let o = /* @__PURE__ */ new Map();
|
|
798
|
+
for (let e of i([y]) ?? []) o.set(String(e[y] ?? "∅"), e);
|
|
799
|
+
let c = i([])?.[0], l = a.size > 0, d = o.size > 0, f = x("dashboard.total", "Total");
|
|
770
800
|
return /* @__PURE__ */ Q("div", {
|
|
771
801
|
className: "relative h-full w-full overflow-auto p-1",
|
|
772
802
|
"data-testid": "dataset-matrix",
|
|
@@ -777,18 +807,18 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
777
807
|
children: [/* @__PURE__ */ Z("thead", {
|
|
778
808
|
className: "bg-muted/40",
|
|
779
809
|
children: /* @__PURE__ */ Q("tr", { children: [
|
|
780
|
-
|
|
810
|
+
v.map((e) => /* @__PURE__ */ Z("th", {
|
|
781
811
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
782
|
-
children:
|
|
812
|
+
children: P(e)
|
|
783
813
|
}, e)),
|
|
784
814
|
t.map((e) => /* @__PURE__ */ Z("th", {
|
|
785
815
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
786
816
|
children: e.header
|
|
787
817
|
}, `${e.col.id}-${e.measure}`)),
|
|
788
|
-
|
|
818
|
+
l && s.map((e) => /* @__PURE__ */ Z("th", {
|
|
789
819
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
790
820
|
"data-testid": "matrix-total-col-header",
|
|
791
|
-
children:
|
|
821
|
+
children: s.length === 1 ? f : `${f} · ${P(e)}`
|
|
792
822
|
}, `total-${e}`))
|
|
793
823
|
] })
|
|
794
824
|
}), /* @__PURE__ */ Q("tbody", { children: [e.rowHeaders.map((n) => /* @__PURE__ */ Q("tr", {
|
|
@@ -799,15 +829,15 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
799
829
|
children: e
|
|
800
830
|
}, t)),
|
|
801
831
|
t.map((t) => {
|
|
802
|
-
let i = e.cellIndex.get(`${n.id} ${t.col.id}`), a = i == null ? void 0 :
|
|
832
|
+
let i = e.cellIndex.get(`${n.id} ${t.col.id}`), a = i == null ? void 0 : T.rows[i], o = L && i != null, s = [...n.labels, t.col.label].filter(Boolean).join(" / ");
|
|
803
833
|
return /* @__PURE__ */ Z("td", {
|
|
804
|
-
className:
|
|
834
|
+
className: H("px-2 py-1 text-right tabular-nums whitespace-nowrap", o && "cursor-pointer hover:bg-accent/40"),
|
|
805
835
|
"data-testid": o ? "dataset-drill-cell" : void 0,
|
|
806
|
-
onClick: o ? () =>
|
|
836
|
+
onClick: o ? () => R(i, s) : void 0,
|
|
807
837
|
children: a ? r(a[t.measure], t.measure) : "—"
|
|
808
838
|
}, `${t.col.id}-${t.measure}`);
|
|
809
839
|
}),
|
|
810
|
-
|
|
840
|
+
l && s.map((e) => /* @__PURE__ */ Z("td", {
|
|
811
841
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
812
842
|
"data-testid": "matrix-row-total",
|
|
813
843
|
children: r(a.get(n.id)?.[e], e)
|
|
@@ -817,16 +847,16 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
817
847
|
className: "border-t bg-muted/30 font-medium",
|
|
818
848
|
"data-testid": "matrix-total-row",
|
|
819
849
|
children: [
|
|
820
|
-
|
|
821
|
-
colSpan:
|
|
850
|
+
v.length > 0 && /* @__PURE__ */ Z("td", {
|
|
851
|
+
colSpan: v.length,
|
|
822
852
|
className: "px-2 py-1 whitespace-nowrap",
|
|
823
853
|
children: f
|
|
824
854
|
}),
|
|
825
855
|
t.map((e) => /* @__PURE__ */ Z("td", {
|
|
826
856
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
827
|
-
children: r(
|
|
857
|
+
children: r(o.get(e.col.id)?.[e.measure], e.measure)
|
|
828
858
|
}, `${e.col.id}-${e.measure}`)),
|
|
829
|
-
|
|
859
|
+
l && s.map((e) => /* @__PURE__ */ Z("td", {
|
|
830
860
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
831
861
|
"data-testid": "matrix-grand-total",
|
|
832
862
|
children: r(c?.[e], e)
|
|
@@ -834,11 +864,11 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
834
864
|
]
|
|
835
865
|
})] })]
|
|
836
866
|
}),
|
|
837
|
-
|
|
867
|
+
ne
|
|
838
868
|
]
|
|
839
869
|
});
|
|
840
870
|
}
|
|
841
|
-
let r = [...
|
|
871
|
+
let r = [...o, ...s];
|
|
842
872
|
return /* @__PURE__ */ Q("div", {
|
|
843
873
|
className: "relative h-full w-full overflow-auto p-1",
|
|
844
874
|
children: [
|
|
@@ -849,54 +879,55 @@ function pt({ widget: e, dataSource: n }) {
|
|
|
849
879
|
className: "bg-muted/40",
|
|
850
880
|
children: /* @__PURE__ */ Z("tr", { children: r.map((e) => /* @__PURE__ */ Z("th", {
|
|
851
881
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
852
|
-
children:
|
|
882
|
+
children: P(e)
|
|
853
883
|
}, e)) })
|
|
854
|
-
}), /* @__PURE__ */ Z("tbody", { children:
|
|
855
|
-
className:
|
|
856
|
-
"data-testid":
|
|
857
|
-
onClick:
|
|
884
|
+
}), /* @__PURE__ */ Z("tbody", { children: T.rows.map((e, t) => /* @__PURE__ */ Z("tr", {
|
|
885
|
+
className: H("border-t", L && "cursor-pointer hover:bg-accent/40"),
|
|
886
|
+
"data-testid": L ? "dataset-drill-row" : void 0,
|
|
887
|
+
onClick: L ? () => R(t, te.map((t) => l(e[t])).filter(Boolean).join(" / ")) : void 0,
|
|
858
888
|
children: r.map((t) => /* @__PURE__ */ Z("td", {
|
|
859
889
|
className: "px-2 py-1 whitespace-nowrap tabular-nums",
|
|
860
|
-
children:
|
|
890
|
+
children: s.includes(t) ? u(e[t], N(t)?.format, N(t)?.currency) : l(e[t])
|
|
861
891
|
}, t))
|
|
862
892
|
}, t)) })]
|
|
863
893
|
}),
|
|
864
|
-
|
|
894
|
+
ne
|
|
865
895
|
]
|
|
866
896
|
});
|
|
867
897
|
}
|
|
868
|
-
let
|
|
869
|
-
let t =
|
|
898
|
+
let re = pt[p] ?? "bar", { data: z, xAxisKey: ie, series: B } = t(T.rows, o, s, T.fields), ae = L ? (e) => {
|
|
899
|
+
let t = c(T.rows, o, s, e?.category, e?.series);
|
|
870
900
|
if (t < 0) return;
|
|
871
|
-
let n =
|
|
872
|
-
|
|
901
|
+
let n = o.length >= 2 && s.length === 1;
|
|
902
|
+
R(t, [e?.category, n ? e?.series : void 0].filter(Boolean).map(String).join(" / "));
|
|
873
903
|
} : void 0;
|
|
874
904
|
return /* @__PURE__ */ Q("div", {
|
|
875
|
-
className:
|
|
876
|
-
children: [/* @__PURE__ */ Z(
|
|
905
|
+
className: H("relative h-full w-full min-h-[220px]"),
|
|
906
|
+
children: [/* @__PURE__ */ Z(h, {
|
|
877
907
|
schema: {
|
|
878
908
|
type: "chart",
|
|
879
|
-
chartType:
|
|
880
|
-
data:
|
|
881
|
-
xAxisKey:
|
|
882
|
-
series:
|
|
909
|
+
chartType: re,
|
|
910
|
+
data: z,
|
|
911
|
+
xAxisKey: ie,
|
|
912
|
+
series: B,
|
|
913
|
+
...j ? { categoryColors: j } : {}
|
|
883
914
|
},
|
|
884
|
-
onChartClick:
|
|
885
|
-
onSegmentClick:
|
|
886
|
-
}),
|
|
915
|
+
onChartClick: ae,
|
|
916
|
+
onSegmentClick: ae
|
|
917
|
+
}), ne]
|
|
887
918
|
});
|
|
888
919
|
}
|
|
889
920
|
//#endregion
|
|
890
921
|
//#region src/DashboardRenderer.tsx
|
|
891
|
-
function
|
|
892
|
-
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } =
|
|
922
|
+
function ht({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
923
|
+
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } = Ne({
|
|
893
924
|
id: e,
|
|
894
925
|
disabled: t
|
|
895
926
|
});
|
|
896
927
|
return /* @__PURE__ */ Z("div", {
|
|
897
928
|
ref: s,
|
|
898
929
|
style: {
|
|
899
|
-
transform:
|
|
930
|
+
transform: Fe.Transform.toString(c),
|
|
900
931
|
transition: l,
|
|
901
932
|
opacity: u ? .4 : 1,
|
|
902
933
|
...n ? {
|
|
@@ -904,26 +935,26 @@ function mt({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
|
904
935
|
gridRow: `span ${n.h}`
|
|
905
936
|
} : {}
|
|
906
937
|
},
|
|
907
|
-
className:
|
|
938
|
+
className: H("h-full w-full", r, !t && "cursor-grab active:cursor-grabbing", d && !u && "ring-2 ring-primary ring-offset-2 rounded-lg"),
|
|
908
939
|
"data-sortable-widget-id": e,
|
|
909
940
|
...a,
|
|
910
941
|
...o,
|
|
911
942
|
children: i
|
|
912
943
|
});
|
|
913
944
|
}
|
|
914
|
-
function
|
|
945
|
+
function gt(e) {
|
|
915
946
|
return e ? oe(e) : null;
|
|
916
947
|
}
|
|
917
|
-
function
|
|
948
|
+
function _t(e) {
|
|
918
949
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
919
950
|
}
|
|
920
|
-
var
|
|
951
|
+
var vt = [
|
|
921
952
|
"hsl(var(--chart-1))",
|
|
922
953
|
"hsl(var(--chart-2))",
|
|
923
954
|
"hsl(var(--chart-3))",
|
|
924
955
|
"hsl(var(--chart-4))",
|
|
925
956
|
"hsl(var(--chart-5))"
|
|
926
|
-
],
|
|
957
|
+
], yt = {
|
|
927
958
|
column: "bar",
|
|
928
959
|
"stacked-bar": "bar",
|
|
929
960
|
"grouped-bar": "bar",
|
|
@@ -933,7 +964,7 @@ var _t = [
|
|
|
933
964
|
"stacked-area": "area",
|
|
934
965
|
pyramid: "funnel",
|
|
935
966
|
bubble: "scatter"
|
|
936
|
-
},
|
|
967
|
+
}, bt = new Set([
|
|
937
968
|
"bar",
|
|
938
969
|
"horizontal-bar",
|
|
939
970
|
"line",
|
|
@@ -945,12 +976,12 @@ var _t = [
|
|
|
945
976
|
"radar",
|
|
946
977
|
"treemap",
|
|
947
978
|
"sankey"
|
|
948
|
-
]),
|
|
979
|
+
]), xt = new Set([
|
|
949
980
|
"gauge",
|
|
950
981
|
"solid-gauge",
|
|
951
982
|
"kpi",
|
|
952
983
|
"bullet"
|
|
953
|
-
]),
|
|
984
|
+
]), St = new Set([
|
|
954
985
|
"sunburst",
|
|
955
986
|
"word-cloud",
|
|
956
987
|
"choropleth",
|
|
@@ -962,7 +993,7 @@ var _t = [
|
|
|
962
993
|
"violin",
|
|
963
994
|
"candlestick",
|
|
964
995
|
"stock"
|
|
965
|
-
]),
|
|
996
|
+
]), Ct = new Set([
|
|
966
997
|
"bar",
|
|
967
998
|
"horizontal-bar",
|
|
968
999
|
"line",
|
|
@@ -974,11 +1005,11 @@ var _t = [
|
|
|
974
1005
|
"treemap",
|
|
975
1006
|
"sankey"
|
|
976
1007
|
]);
|
|
977
|
-
function
|
|
978
|
-
return
|
|
1008
|
+
function wt(e) {
|
|
1009
|
+
return Ct.has(e) ? { enabled: !0 } : void 0;
|
|
979
1010
|
}
|
|
980
|
-
var
|
|
981
|
-
let
|
|
1011
|
+
var Tt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount: i, userActions: a, designMode: o, selectedWidgetId: s, onWidgetClick: c, onWidgetsReorder: l, modalHandler: u, scriptHandlers: d, hideHeaderText: f, ...p }, m) => {
|
|
1012
|
+
let g = (() => {
|
|
982
1013
|
if (e.columns != null) return e.columns;
|
|
983
1014
|
let t = e.widgets ?? [], n = 0;
|
|
984
1015
|
for (let e of t) {
|
|
@@ -986,44 +1017,44 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
986
1017
|
t > n && (n = t), (e.layout?.w ?? 0) > n && (n = e.layout.w);
|
|
987
1018
|
}
|
|
988
1019
|
return n > 4 ? 12 : 4;
|
|
989
|
-
})(), v =
|
|
1020
|
+
})(), v = g, y = e.gap || 4, b = e.columns != null || g !== 4, [x, C] = J(!1), [w, T] = J(!1), D = de(null), { executeAction: O, engine: P } = _({ actions: q(() => (e.header?.actions ?? []).map((e) => ({
|
|
990
1021
|
name: e.actionUrl || e.label,
|
|
991
1022
|
type: e.actionType || "url",
|
|
992
1023
|
target: e.actionUrl,
|
|
993
1024
|
label: e.label
|
|
994
|
-
})), [e.header?.actions]) }), { dashboardLabel:
|
|
995
|
-
let t =
|
|
996
|
-
return !z || !e.id || t === void 0 ? t :
|
|
997
|
-
}, [z,
|
|
998
|
-
let t =
|
|
999
|
-
return !z || !e.id ? t :
|
|
1000
|
-
}, [z,
|
|
1001
|
-
|
|
1002
|
-
let e =
|
|
1025
|
+
})), [e.header?.actions]) }), { dashboardLabel: F, dashboardDescription: I, dashboardActionLabel: ee, widgetTitle: te, widgetDescription: L, fieldLabel: R } = S(), { t: ne } = E(), re = G((e, t, n) => n && (!t || t === "value" || t === "count" || n === "count") ? ne(`report.aggregate.${n}`, { defaultValue: n }) : e ? R(e, t, t) : t, [ne, R]), z = e.name, ie = G((e) => z ? ee(z, e.actionUrl || e.label, e.label) : e.label, [z, ee]), B = G((e) => {
|
|
1026
|
+
let t = _t(e.title);
|
|
1027
|
+
return !z || !e.id || t === void 0 ? t : te(z, e.id, t);
|
|
1028
|
+
}, [z, te]), ae = G((e) => {
|
|
1029
|
+
let t = _t(e.description);
|
|
1030
|
+
return !z || !e.id ? t : L(z, e.id, t);
|
|
1031
|
+
}, [z, L]);
|
|
1032
|
+
K(() => {
|
|
1033
|
+
let e = P.getRunner();
|
|
1003
1034
|
if (u && e.setModalHandler(u), d) for (let [t, n] of Object.entries(d)) e.registerScript(t, n);
|
|
1004
1035
|
}, [
|
|
1005
|
-
|
|
1036
|
+
P,
|
|
1006
1037
|
u,
|
|
1007
1038
|
d
|
|
1008
|
-
]),
|
|
1009
|
-
let e = () =>
|
|
1039
|
+
]), K(() => {
|
|
1040
|
+
let e = () => T(window.innerWidth < 768);
|
|
1010
1041
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
1011
1042
|
}, []);
|
|
1012
|
-
let
|
|
1013
|
-
r && (
|
|
1043
|
+
let V = G(() => {
|
|
1044
|
+
r && (C(!0), r(), setTimeout(() => C(!1), 600));
|
|
1014
1045
|
}, [r]);
|
|
1015
|
-
|
|
1016
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return
|
|
1017
|
-
|
|
1046
|
+
K(() => {
|
|
1047
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return D.current = setInterval(V, e.refreshInterval * 1e3), () => {
|
|
1048
|
+
D.current && clearInterval(D.current);
|
|
1018
1049
|
};
|
|
1019
1050
|
}, [
|
|
1020
1051
|
e.refreshInterval,
|
|
1021
1052
|
r,
|
|
1022
|
-
|
|
1053
|
+
V
|
|
1023
1054
|
]);
|
|
1024
|
-
let oe =
|
|
1055
|
+
let oe = G((e, t) => {
|
|
1025
1056
|
!o || !c || !t || (e.stopPropagation(), c(t));
|
|
1026
|
-
}, [o, c]), se =
|
|
1057
|
+
}, [o, c]), se = G((t, n, r) => {
|
|
1027
1058
|
if (!o || !c) return;
|
|
1028
1059
|
let i = e.widgets || [];
|
|
1029
1060
|
if (t.key === "Enter" || t.key === " ") t.preventDefault(), c(n ?? null);
|
|
@@ -1040,23 +1071,26 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1040
1071
|
o,
|
|
1041
1072
|
c,
|
|
1042
1073
|
e.widgets
|
|
1043
|
-
]),
|
|
1074
|
+
]), U = G((e) => {
|
|
1044
1075
|
!o || !c || e.target === e.currentTarget && c(null);
|
|
1045
|
-
}, [o, c]),
|
|
1046
|
-
if (!
|
|
1076
|
+
}, [o, c]), W = !!(o && l), le = ke(Oe(Ee, { activationConstraint: { distance: 5 } })), ue = G((t) => {
|
|
1077
|
+
if (!W) return;
|
|
1047
1078
|
let { active: n, over: r } = t;
|
|
1048
1079
|
if (!r || n.id === r.id) return;
|
|
1049
1080
|
let i = e.widgets ?? [], a = i.findIndex((e) => e.id === n.id), o = i.findIndex((e) => e.id === r.id);
|
|
1050
|
-
a < 0 || o < 0 || l?.(
|
|
1081
|
+
a < 0 || o < 0 || l?.(je(i, a, o));
|
|
1051
1082
|
}, [
|
|
1052
|
-
|
|
1083
|
+
W,
|
|
1053
1084
|
e.widgets,
|
|
1054
1085
|
l
|
|
1055
1086
|
]), fe = (e, t, r) => {
|
|
1056
|
-
let i = e.
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
} : void 0,
|
|
1087
|
+
let i = e.type === "metric" || xt.has(e.type || ""), a = b ? {
|
|
1088
|
+
w: Math.min(i ? 3 : 6, v),
|
|
1089
|
+
h: i ? 2 : 4
|
|
1090
|
+
} : void 0, c = e.layout ?? a, l = c ? {
|
|
1091
|
+
...c,
|
|
1092
|
+
w: Math.min(c.w, v)
|
|
1093
|
+
} : void 0, u = !!e.dataset, d = (() => {
|
|
1060
1094
|
if (e.component) return e.component;
|
|
1061
1095
|
let t = e.type, n = e.options || {};
|
|
1062
1096
|
if (t === "metric" && e.object) {
|
|
@@ -1074,7 +1108,7 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1074
1108
|
objectName: e.object || ($(t) ? t.object : void 0),
|
|
1075
1109
|
aggregate: r,
|
|
1076
1110
|
filter: ($(t) ? t.filter : void 0) || e.filter,
|
|
1077
|
-
label: n.label ||
|
|
1111
|
+
label: n.label || B(e) || "",
|
|
1078
1112
|
fallbackValue: n.value,
|
|
1079
1113
|
trend: n.trend,
|
|
1080
1114
|
icon: n.icon,
|
|
@@ -1085,11 +1119,11 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1085
1119
|
prefix: n.prefix,
|
|
1086
1120
|
suffix: n.suffix,
|
|
1087
1121
|
drillDown: n.drillDown ?? { enabled: !0 },
|
|
1088
|
-
title: n.label ||
|
|
1122
|
+
title: n.label || B(e) || "",
|
|
1089
1123
|
compareTo: e.compareTo
|
|
1090
1124
|
};
|
|
1091
1125
|
}
|
|
1092
|
-
if (
|
|
1126
|
+
if (xt.has(t || "") && e.object) {
|
|
1093
1127
|
let t = e.aggregate ? {
|
|
1094
1128
|
field: e.valueField || "value",
|
|
1095
1129
|
function: e.aggregate,
|
|
@@ -1100,7 +1134,7 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1100
1134
|
objectName: e.object,
|
|
1101
1135
|
aggregate: t,
|
|
1102
1136
|
filter: e.filter,
|
|
1103
|
-
label: n.label ||
|
|
1137
|
+
label: n.label || B(e) || "",
|
|
1104
1138
|
fallbackValue: n.fallbackValue ?? n.value,
|
|
1105
1139
|
icon: n.icon,
|
|
1106
1140
|
description: n.description,
|
|
@@ -1113,8 +1147,8 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1113
1147
|
compareTo: e.compareTo
|
|
1114
1148
|
};
|
|
1115
1149
|
}
|
|
1116
|
-
let r = t &&
|
|
1117
|
-
if (r &&
|
|
1150
|
+
let r = t && yt[t] || t;
|
|
1151
|
+
if (r && bt.has(r)) {
|
|
1118
1152
|
let t = e.data || n.data, i = e.categoryField || n.xField || "name", a = e.valueField || n.yField || "value";
|
|
1119
1153
|
if ($(t)) {
|
|
1120
1154
|
let o = t.aggregate, s = (() => {
|
|
@@ -1137,10 +1171,10 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1137
1171
|
xAxisKey: i,
|
|
1138
1172
|
series: [{
|
|
1139
1173
|
dataKey: l,
|
|
1140
|
-
label:
|
|
1174
|
+
label: re(u, l, c?.function)
|
|
1141
1175
|
}],
|
|
1142
|
-
colors:
|
|
1143
|
-
drillDown: n.drillDown ??
|
|
1176
|
+
colors: vt,
|
|
1177
|
+
drillDown: n.drillDown ?? wt(r),
|
|
1144
1178
|
compareTo: e.compareTo,
|
|
1145
1179
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1146
1180
|
};
|
|
@@ -1163,10 +1197,10 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1163
1197
|
xAxisKey: i,
|
|
1164
1198
|
series: [{
|
|
1165
1199
|
dataKey: s,
|
|
1166
|
-
label:
|
|
1200
|
+
label: re(e.object, s, e.aggregate)
|
|
1167
1201
|
}],
|
|
1168
|
-
colors:
|
|
1169
|
-
drillDown: n.drillDown ??
|
|
1202
|
+
colors: vt,
|
|
1203
|
+
drillDown: n.drillDown ?? wt(r),
|
|
1170
1204
|
compareTo: e.compareTo,
|
|
1171
1205
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1172
1206
|
};
|
|
@@ -1178,9 +1212,9 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1178
1212
|
xAxisKey: i,
|
|
1179
1213
|
series: [{
|
|
1180
1214
|
dataKey: a,
|
|
1181
|
-
label:
|
|
1215
|
+
label: re(e.object, a, e.aggregate)
|
|
1182
1216
|
}],
|
|
1183
|
-
colors:
|
|
1217
|
+
colors: vt,
|
|
1184
1218
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1185
1219
|
};
|
|
1186
1220
|
}
|
|
@@ -1301,7 +1335,7 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1301
1335
|
variant: "caption",
|
|
1302
1336
|
align: "center",
|
|
1303
1337
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
|
|
1304
|
-
} : t &&
|
|
1338
|
+
} : t && St.has(t) ? {
|
|
1305
1339
|
type: "text",
|
|
1306
1340
|
value: `「${t}」chart type is not supported yet`,
|
|
1307
1341
|
variant: "caption",
|
|
@@ -1311,62 +1345,62 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1311
1345
|
...e,
|
|
1312
1346
|
...n
|
|
1313
1347
|
};
|
|
1314
|
-
})(),
|
|
1348
|
+
})(), f = e.type === "metric" && !u, p = B(e), m = ae(e), g = e.id || p || `widget-${t}`, _ = o && s === e.id, y = o ? {
|
|
1315
1349
|
"data-testid": `dashboard-preview-widget-${e.id}`,
|
|
1316
1350
|
"data-widget-id": e.id,
|
|
1317
1351
|
role: "button",
|
|
1318
1352
|
tabIndex: 0,
|
|
1319
|
-
"aria-selected":
|
|
1320
|
-
"aria-label": `Widget: ${
|
|
1353
|
+
"aria-selected": _,
|
|
1354
|
+
"aria-label": `Widget: ${p || `Widget ${t + 1}`}`,
|
|
1321
1355
|
onClick: (t) => oe(t, e.id),
|
|
1322
1356
|
onKeyDown: (n) => se(n, e.id, t)
|
|
1323
|
-
} : {},
|
|
1324
|
-
gridColumn: `span ${
|
|
1325
|
-
gridRow: `span ${
|
|
1326
|
-
} : void 0,
|
|
1327
|
-
className:
|
|
1328
|
-
style:
|
|
1329
|
-
...
|
|
1330
|
-
children: [
|
|
1331
|
-
className:
|
|
1332
|
-
children: /* @__PURE__ */ Z(
|
|
1357
|
+
} : {}, x = o ? H("cursor-pointer rounded-lg transition-all outline-none", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", _ ? "ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10" : "hover:ring-2 hover:ring-primary/40 hover:shadow-sm") : void 0, S = !w && l && !W ? {
|
|
1358
|
+
gridColumn: `span ${l.w}`,
|
|
1359
|
+
gridRow: `span ${l.h}`
|
|
1360
|
+
} : void 0, C = f ? /* @__PURE__ */ Q("div", {
|
|
1361
|
+
className: H("h-full w-full", o && "relative", x),
|
|
1362
|
+
style: S,
|
|
1363
|
+
...y,
|
|
1364
|
+
children: [u ? /* @__PURE__ */ Z("div", {
|
|
1365
|
+
className: H("h-full w-full", o && "pointer-events-none"),
|
|
1366
|
+
children: /* @__PURE__ */ Z(mt, {
|
|
1333
1367
|
widget: e,
|
|
1334
1368
|
dataSource: n
|
|
1335
1369
|
})
|
|
1336
|
-
}) : /* @__PURE__ */ Z(
|
|
1337
|
-
schema:
|
|
1338
|
-
className:
|
|
1370
|
+
}) : /* @__PURE__ */ Z(h, {
|
|
1371
|
+
schema: d,
|
|
1372
|
+
className: H("h-full w-full", o && "pointer-events-none"),
|
|
1339
1373
|
dataSource: n
|
|
1340
1374
|
}), o && /* @__PURE__ */ Z("div", {
|
|
1341
1375
|
className: "absolute inset-0 z-10",
|
|
1342
1376
|
"aria-hidden": "true",
|
|
1343
1377
|
"data-testid": "widget-click-overlay"
|
|
1344
1378
|
})]
|
|
1345
|
-
}) : /* @__PURE__ */ Q(
|
|
1346
|
-
className:
|
|
1347
|
-
style:
|
|
1348
|
-
...
|
|
1379
|
+
}) : /* @__PURE__ */ Q(A, {
|
|
1380
|
+
className: H("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full", o && "relative", x),
|
|
1381
|
+
style: S,
|
|
1382
|
+
...y,
|
|
1349
1383
|
children: [
|
|
1350
|
-
|
|
1384
|
+
p && /* @__PURE__ */ Q(M, {
|
|
1351
1385
|
className: "pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6",
|
|
1352
|
-
children: [/* @__PURE__ */ Z(
|
|
1386
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1353
1387
|
className: "text-sm sm:text-base font-medium tracking-tight truncate",
|
|
1354
|
-
title:
|
|
1355
|
-
children:
|
|
1356
|
-
}),
|
|
1388
|
+
title: p,
|
|
1389
|
+
children: p
|
|
1390
|
+
}), m && /* @__PURE__ */ Z("p", {
|
|
1357
1391
|
className: "text-xs text-muted-foreground mt-0.5 line-clamp-2",
|
|
1358
|
-
children:
|
|
1392
|
+
children: m
|
|
1359
1393
|
})]
|
|
1360
1394
|
}),
|
|
1361
|
-
/* @__PURE__ */ Z(
|
|
1395
|
+
/* @__PURE__ */ Z(j, {
|
|
1362
1396
|
className: "p-0",
|
|
1363
1397
|
children: /* @__PURE__ */ Z("div", {
|
|
1364
|
-
className:
|
|
1365
|
-
children:
|
|
1398
|
+
className: H("h-full w-full", "p-3 sm:p-4 md:p-6", o && "pointer-events-none"),
|
|
1399
|
+
children: u ? /* @__PURE__ */ Z(mt, {
|
|
1366
1400
|
widget: e,
|
|
1367
1401
|
dataSource: n
|
|
1368
|
-
}) : /* @__PURE__ */ Z(
|
|
1369
|
-
schema:
|
|
1402
|
+
}) : /* @__PURE__ */ Z(h, {
|
|
1403
|
+
schema: d,
|
|
1370
1404
|
dataSource: n
|
|
1371
1405
|
})
|
|
1372
1406
|
})
|
|
@@ -1378,36 +1412,36 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1378
1412
|
})
|
|
1379
1413
|
]
|
|
1380
1414
|
});
|
|
1381
|
-
return
|
|
1415
|
+
return W && e.id ? /* @__PURE__ */ Z(ht, {
|
|
1382
1416
|
id: e.id,
|
|
1383
|
-
gridSpan: !
|
|
1384
|
-
w:
|
|
1385
|
-
h:
|
|
1417
|
+
gridSpan: !w && l ? {
|
|
1418
|
+
w: l.w,
|
|
1419
|
+
h: l.h
|
|
1386
1420
|
} : void 0,
|
|
1387
|
-
children:
|
|
1388
|
-
},
|
|
1389
|
-
},
|
|
1421
|
+
children: C
|
|
1422
|
+
}, g) : /* @__PURE__ */ Z(ce, { children: C }, g);
|
|
1423
|
+
}, Y = e.header && /* @__PURE__ */ Q("div", {
|
|
1390
1424
|
className: "col-span-full mb-4",
|
|
1391
1425
|
children: [
|
|
1392
1426
|
!f && e.header.showTitle !== !1 && e.title && /* @__PURE__ */ Z("h2", {
|
|
1393
1427
|
className: "text-lg font-semibold tracking-tight",
|
|
1394
|
-
children: z ?
|
|
1428
|
+
children: z ? F({
|
|
1395
1429
|
name: z,
|
|
1396
|
-
label:
|
|
1397
|
-
}) :
|
|
1430
|
+
label: _t(e.title)
|
|
1431
|
+
}) : _t(e.title)
|
|
1398
1432
|
}),
|
|
1399
1433
|
!f && e.header.showDescription !== !1 && e.description && /* @__PURE__ */ Z("p", {
|
|
1400
1434
|
className: "text-sm text-muted-foreground mt-1",
|
|
1401
|
-
children: z ?
|
|
1435
|
+
children: z ? I({
|
|
1402
1436
|
name: z,
|
|
1403
|
-
description:
|
|
1404
|
-
}) :
|
|
1437
|
+
description: _t(e.description)
|
|
1438
|
+
}) : _t(e.description)
|
|
1405
1439
|
}),
|
|
1406
1440
|
e.header.actions && e.header.actions.length > 0 && /* @__PURE__ */ Z("div", {
|
|
1407
1441
|
className: "flex gap-2 mt-3",
|
|
1408
1442
|
children: e.header.actions.map((e, t) => {
|
|
1409
|
-
let n =
|
|
1410
|
-
return /* @__PURE__ */ Q(
|
|
1443
|
+
let n = gt(e.icon);
|
|
1444
|
+
return /* @__PURE__ */ Q(k, {
|
|
1411
1445
|
variant: "outline",
|
|
1412
1446
|
size: "sm",
|
|
1413
1447
|
onClick: async () => {
|
|
@@ -1421,13 +1455,13 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1421
1455
|
return;
|
|
1422
1456
|
}
|
|
1423
1457
|
if (t === "modal" || t === "script") {
|
|
1424
|
-
let e = await
|
|
1458
|
+
let e = await O(n || r);
|
|
1425
1459
|
e?.success || console.warn("[DashboardRenderer] action failed", e?.error);
|
|
1426
1460
|
return;
|
|
1427
1461
|
}
|
|
1428
1462
|
console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`);
|
|
1429
1463
|
},
|
|
1430
|
-
children: [n && /* @__PURE__ */ Z(n, { className: "w-4 h-4 mr-1.5" }),
|
|
1464
|
+
children: [n && /* @__PURE__ */ Z(n, { className: "w-4 h-4 mr-1.5" }), ie(e)]
|
|
1431
1465
|
}, t);
|
|
1432
1466
|
})
|
|
1433
1467
|
})
|
|
@@ -1436,91 +1470,91 @@ var wt = le(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
1436
1470
|
className: "text-xs text-muted-foreground",
|
|
1437
1471
|
children: [i.toLocaleString(), " records"]
|
|
1438
1472
|
}), me = a ? JSON.stringify(a) : void 0, he = r && /* @__PURE__ */ Q("div", {
|
|
1439
|
-
className:
|
|
1440
|
-
children: [pe, /* @__PURE__ */ Q(
|
|
1473
|
+
className: H("flex items-center justify-end gap-3 mb-2", !w && "col-span-full"),
|
|
1474
|
+
children: [pe, /* @__PURE__ */ Q(k, {
|
|
1441
1475
|
variant: "outline",
|
|
1442
1476
|
size: "sm",
|
|
1443
|
-
onClick:
|
|
1444
|
-
disabled:
|
|
1477
|
+
onClick: V,
|
|
1478
|
+
disabled: x,
|
|
1445
1479
|
"aria-label": "Refresh dashboard",
|
|
1446
|
-
children: [/* @__PURE__ */ Z(
|
|
1480
|
+
children: [/* @__PURE__ */ Z(xe, { className: H("h-4 w-4 mr-2", x && "animate-spin") }), x ? "Refreshing…" : "Refresh All"]
|
|
1447
1481
|
})]
|
|
1448
|
-
}), ge =
|
|
1449
|
-
if (
|
|
1482
|
+
}), ge = q(() => (e.widgets ?? []).map((e) => e.id).filter((e) => !!e), [e.widgets]), X = q(() => (e.widgets ?? []).filter((e) => e.type === "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]), _e = q(() => (e.widgets ?? []).filter((e) => e.type !== "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]);
|
|
1483
|
+
if (w) {
|
|
1450
1484
|
let n = e.widgets?.filter((e) => e.type === "metric") || [], r = e.widgets?.filter((e) => e.type !== "metric") || [], i = /* @__PURE__ */ Q("div", {
|
|
1451
|
-
ref:
|
|
1452
|
-
className:
|
|
1485
|
+
ref: m,
|
|
1486
|
+
className: H("flex flex-col gap-4 px-4", t),
|
|
1453
1487
|
"data-user-actions": me,
|
|
1454
|
-
onClick:
|
|
1488
|
+
onClick: U,
|
|
1455
1489
|
...p,
|
|
1456
1490
|
children: [
|
|
1457
|
-
|
|
1491
|
+
Y,
|
|
1458
1492
|
he,
|
|
1459
1493
|
n.length > 0 && /* @__PURE__ */ Z("div", {
|
|
1460
1494
|
className: "grid grid-cols-2 gap-3",
|
|
1461
|
-
onClick:
|
|
1462
|
-
children: /* @__PURE__ */ Z(
|
|
1463
|
-
items:
|
|
1464
|
-
strategy:
|
|
1465
|
-
disabled: !
|
|
1495
|
+
onClick: U,
|
|
1496
|
+
children: /* @__PURE__ */ Z(Ae, {
|
|
1497
|
+
items: X,
|
|
1498
|
+
strategy: Me,
|
|
1499
|
+
disabled: !W,
|
|
1466
1500
|
children: n.map((e, t) => fe(e, t))
|
|
1467
1501
|
})
|
|
1468
1502
|
}),
|
|
1469
1503
|
r.length > 0 && /* @__PURE__ */ Z("div", {
|
|
1470
1504
|
className: "flex flex-col gap-4",
|
|
1471
|
-
onClick:
|
|
1472
|
-
children: /* @__PURE__ */ Z(
|
|
1505
|
+
onClick: U,
|
|
1506
|
+
children: /* @__PURE__ */ Z(Ae, {
|
|
1473
1507
|
items: _e,
|
|
1474
|
-
strategy:
|
|
1475
|
-
disabled: !
|
|
1508
|
+
strategy: Pe,
|
|
1509
|
+
disabled: !W,
|
|
1476
1510
|
children: r.map((e, t) => fe(e, t, !0))
|
|
1477
1511
|
})
|
|
1478
1512
|
})
|
|
1479
1513
|
]
|
|
1480
1514
|
});
|
|
1481
|
-
return
|
|
1515
|
+
return W ? /* @__PURE__ */ Z(Te, {
|
|
1482
1516
|
sensors: le,
|
|
1483
|
-
collisionDetection:
|
|
1517
|
+
collisionDetection: De,
|
|
1484
1518
|
onDragEnd: ue,
|
|
1485
1519
|
children: i
|
|
1486
1520
|
}) : i;
|
|
1487
1521
|
}
|
|
1488
|
-
let ve =
|
|
1489
|
-
ref:
|
|
1490
|
-
className:
|
|
1522
|
+
let ve = /* @__PURE__ */ Q("div", {
|
|
1523
|
+
ref: m,
|
|
1524
|
+
className: H("grid", !b && "auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", t),
|
|
1491
1525
|
style: {
|
|
1492
|
-
...
|
|
1526
|
+
...b && {
|
|
1493
1527
|
gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))`,
|
|
1494
1528
|
gridAutoRows: "minmax(5rem, auto)"
|
|
1495
1529
|
},
|
|
1496
1530
|
gap: `${y * .25}rem`
|
|
1497
1531
|
},
|
|
1498
1532
|
"data-user-actions": me,
|
|
1499
|
-
onClick:
|
|
1533
|
+
onClick: U,
|
|
1500
1534
|
...p,
|
|
1501
1535
|
children: [
|
|
1502
|
-
|
|
1536
|
+
Y,
|
|
1503
1537
|
he,
|
|
1504
|
-
/* @__PURE__ */ Z(
|
|
1538
|
+
/* @__PURE__ */ Z(Ae, {
|
|
1505
1539
|
items: ge,
|
|
1506
|
-
strategy:
|
|
1507
|
-
disabled: !
|
|
1540
|
+
strategy: Me,
|
|
1541
|
+
disabled: !W,
|
|
1508
1542
|
children: e.widgets?.map((e, t) => fe(e, t))
|
|
1509
1543
|
})
|
|
1510
1544
|
]
|
|
1511
1545
|
});
|
|
1512
|
-
return
|
|
1546
|
+
return W ? /* @__PURE__ */ Z(Te, {
|
|
1513
1547
|
sensors: le,
|
|
1514
|
-
collisionDetection:
|
|
1548
|
+
collisionDetection: De,
|
|
1515
1549
|
onDragEnd: ue,
|
|
1516
|
-
children:
|
|
1517
|
-
}) :
|
|
1550
|
+
children: ve
|
|
1551
|
+
}) : ve;
|
|
1518
1552
|
});
|
|
1519
1553
|
//#endregion
|
|
1520
1554
|
//#region src/DashboardGridLayout.tsx
|
|
1521
|
-
function
|
|
1522
|
-
let t =
|
|
1523
|
-
return
|
|
1555
|
+
function Et({ editMode: e }) {
|
|
1556
|
+
let t = y();
|
|
1557
|
+
return U.useEffect(() => {
|
|
1524
1558
|
if (e) return t.startDrag({
|
|
1525
1559
|
id: "dashboard-layout",
|
|
1526
1560
|
type: "dashboard-widget",
|
|
@@ -1531,14 +1565,14 @@ function Tt({ editMode: e }) {
|
|
|
1531
1565
|
t.endDrag("dashboard");
|
|
1532
1566
|
}, [e, t]), null;
|
|
1533
1567
|
}
|
|
1534
|
-
var
|
|
1568
|
+
var Dt = [
|
|
1535
1569
|
"hsl(var(--chart-1))",
|
|
1536
1570
|
"hsl(var(--chart-2))",
|
|
1537
1571
|
"hsl(var(--chart-3))",
|
|
1538
1572
|
"hsl(var(--chart-4))",
|
|
1539
1573
|
"hsl(var(--chart-5))"
|
|
1540
1574
|
];
|
|
1541
|
-
function
|
|
1575
|
+
function Ot(e, t) {
|
|
1542
1576
|
if (!e.widgets?.length) return e;
|
|
1543
1577
|
let n = new Map(t.map((e) => [e.i, e])), r = e.widgets.map((e, t) => {
|
|
1544
1578
|
let r = e.id || `widget-${t}`, i = n.get(r);
|
|
@@ -1557,7 +1591,7 @@ function Dt(e, t) {
|
|
|
1557
1591
|
widgets: r
|
|
1558
1592
|
};
|
|
1559
1593
|
}
|
|
1560
|
-
function
|
|
1594
|
+
function kt(e) {
|
|
1561
1595
|
return { lg: e.widgets?.map((e, t) => ({
|
|
1562
1596
|
i: e.id || `widget-${t}`,
|
|
1563
1597
|
x: e.layout?.x ?? t % 4 * 3,
|
|
@@ -1566,40 +1600,40 @@ function Ot(e) {
|
|
|
1566
1600
|
h: e.layout?.h ?? 4
|
|
1567
1601
|
})) || [] };
|
|
1568
1602
|
}
|
|
1569
|
-
var
|
|
1570
|
-
let { width: a, containerRef: o, mounted: s } =
|
|
1603
|
+
var At = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRefresh: i }) => {
|
|
1604
|
+
let { width: a, containerRef: o, mounted: s } = Ue(), [c, l] = U.useState(!1), [u, d] = U.useState(!1), f = x(), p = U.useRef(null), m = U.useCallback(() => {
|
|
1571
1605
|
i && (d(!0), i(), setTimeout(() => d(!1), 600));
|
|
1572
1606
|
}, [i]);
|
|
1573
|
-
|
|
1574
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !i)) return p.current = setInterval(
|
|
1607
|
+
U.useEffect(() => {
|
|
1608
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !i)) return p.current = setInterval(m, e.refreshInterval * 1e3), () => {
|
|
1575
1609
|
p.current && clearInterval(p.current);
|
|
1576
1610
|
};
|
|
1577
1611
|
}, [
|
|
1578
1612
|
e.refreshInterval,
|
|
1579
1613
|
i,
|
|
1580
|
-
|
|
1614
|
+
m
|
|
1581
1615
|
]);
|
|
1582
|
-
let [g, _] =
|
|
1616
|
+
let [g, _] = U.useState(() => kt(e)), v = U.useMemo(() => JSON.stringify(e.widgets?.map((e, t) => ({
|
|
1583
1617
|
i: e.id || `widget-${t}`,
|
|
1584
1618
|
x: e.layout?.x,
|
|
1585
1619
|
y: e.layout?.y,
|
|
1586
1620
|
w: e.layout?.w,
|
|
1587
1621
|
h: e.layout?.h
|
|
1588
1622
|
})) ?? []), [e.widgets]);
|
|
1589
|
-
|
|
1590
|
-
_(
|
|
1623
|
+
U.useEffect(() => {
|
|
1624
|
+
_(kt(e));
|
|
1591
1625
|
}, [v]);
|
|
1592
|
-
let y =
|
|
1626
|
+
let y = U.useCallback((e, t) => {
|
|
1593
1627
|
_(t), n?.(e);
|
|
1594
|
-
}, [n]),
|
|
1595
|
-
r ? r(
|
|
1628
|
+
}, [n]), b = U.useCallback(() => {
|
|
1629
|
+
r ? r(Ot(e, g.lg)) : globalThis.process?.env?.NODE_ENV !== "production" && console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."), l(!1);
|
|
1596
1630
|
}, [
|
|
1597
1631
|
r,
|
|
1598
1632
|
e,
|
|
1599
1633
|
g
|
|
1600
|
-
]), S =
|
|
1601
|
-
_(
|
|
1602
|
-
}, [e]), C =
|
|
1634
|
+
]), S = U.useCallback(() => {
|
|
1635
|
+
_(kt(e));
|
|
1636
|
+
}, [e]), C = U.useCallback((e) => {
|
|
1603
1637
|
if (e.component) return e.component;
|
|
1604
1638
|
let t = e.type, n = e.options || {};
|
|
1605
1639
|
if (t === "bar" || t === "horizontal-bar" || t === "line" || t === "area" || t === "pie" || t === "donut" || t === "scatter" || t === "funnel") {
|
|
@@ -1617,7 +1651,7 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1617
1651
|
aggregate: o,
|
|
1618
1652
|
xAxisKey: i,
|
|
1619
1653
|
series: [{ dataKey: s }],
|
|
1620
|
-
colors:
|
|
1654
|
+
colors: Dt,
|
|
1621
1655
|
className: "h-full"
|
|
1622
1656
|
};
|
|
1623
1657
|
}
|
|
@@ -1634,7 +1668,7 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1634
1668
|
aggregate: n,
|
|
1635
1669
|
xAxisKey: i,
|
|
1636
1670
|
series: [{ dataKey: e.valueField || "value" }],
|
|
1637
|
-
colors:
|
|
1671
|
+
colors: Dt,
|
|
1638
1672
|
className: "h-full"
|
|
1639
1673
|
};
|
|
1640
1674
|
}
|
|
@@ -1644,7 +1678,7 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1644
1678
|
data: Array.isArray(r) ? r : r?.items || [],
|
|
1645
1679
|
xAxisKey: i,
|
|
1646
1680
|
series: [{ dataKey: a }],
|
|
1647
|
-
colors:
|
|
1681
|
+
colors: Dt,
|
|
1648
1682
|
className: "h-full"
|
|
1649
1683
|
};
|
|
1650
1684
|
}
|
|
@@ -1705,10 +1739,10 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1705
1739
|
}, []);
|
|
1706
1740
|
return /* @__PURE__ */ Q("div", {
|
|
1707
1741
|
ref: o,
|
|
1708
|
-
className:
|
|
1742
|
+
className: H("w-full", t),
|
|
1709
1743
|
"data-testid": "grid-layout",
|
|
1710
1744
|
children: [
|
|
1711
|
-
f && /* @__PURE__ */ Z(
|
|
1745
|
+
f && /* @__PURE__ */ Z(Et, { editMode: c }),
|
|
1712
1746
|
/* @__PURE__ */ Q("div", {
|
|
1713
1747
|
className: "mb-4 flex items-center justify-between",
|
|
1714
1748
|
children: [/* @__PURE__ */ Z("h2", {
|
|
@@ -1716,33 +1750,33 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1716
1750
|
children: e.title || "Dashboard"
|
|
1717
1751
|
}), /* @__PURE__ */ Z("div", {
|
|
1718
1752
|
className: "flex gap-2",
|
|
1719
|
-
children: c ? /* @__PURE__ */ Q(
|
|
1720
|
-
/* @__PURE__ */ Q(
|
|
1721
|
-
onClick:
|
|
1753
|
+
children: c ? /* @__PURE__ */ Q(Ve, { children: [
|
|
1754
|
+
/* @__PURE__ */ Q(k, {
|
|
1755
|
+
onClick: b,
|
|
1722
1756
|
size: "sm",
|
|
1723
1757
|
variant: "default",
|
|
1724
|
-
children: [/* @__PURE__ */ Z(
|
|
1758
|
+
children: [/* @__PURE__ */ Z(Se, { className: "h-4 w-4 mr-2" }), "Save Layout"]
|
|
1725
1759
|
}),
|
|
1726
|
-
/* @__PURE__ */ Q(
|
|
1760
|
+
/* @__PURE__ */ Q(k, {
|
|
1727
1761
|
onClick: S,
|
|
1728
1762
|
size: "sm",
|
|
1729
1763
|
variant: "outline",
|
|
1730
|
-
children: [/* @__PURE__ */ Z(
|
|
1764
|
+
children: [/* @__PURE__ */ Z(we, { className: "h-4 w-4 mr-2" }), "Reset"]
|
|
1731
1765
|
}),
|
|
1732
|
-
/* @__PURE__ */ Z(
|
|
1766
|
+
/* @__PURE__ */ Z(k, {
|
|
1733
1767
|
onClick: () => l(!1),
|
|
1734
1768
|
size: "sm",
|
|
1735
1769
|
variant: "ghost",
|
|
1736
1770
|
children: "Cancel"
|
|
1737
1771
|
})
|
|
1738
|
-
] }) : /* @__PURE__ */ Q(
|
|
1739
|
-
onClick:
|
|
1772
|
+
] }) : /* @__PURE__ */ Q(Ve, { children: [i && /* @__PURE__ */ Q(k, {
|
|
1773
|
+
onClick: m,
|
|
1740
1774
|
size: "sm",
|
|
1741
1775
|
variant: "outline",
|
|
1742
1776
|
disabled: u,
|
|
1743
1777
|
"aria-label": "Refresh dashboard",
|
|
1744
|
-
children: [/* @__PURE__ */ Z(
|
|
1745
|
-
}), /* @__PURE__ */ Q(
|
|
1778
|
+
children: [/* @__PURE__ */ Z(xe, { className: H("h-4 w-4 mr-2", u && "animate-spin") }), u ? "Refreshing…" : "Refresh All"]
|
|
1779
|
+
}), /* @__PURE__ */ Q(k, {
|
|
1746
1780
|
onClick: () => l(!0),
|
|
1747
1781
|
size: "sm",
|
|
1748
1782
|
variant: "outline",
|
|
@@ -1750,7 +1784,7 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1750
1784
|
})] })
|
|
1751
1785
|
})]
|
|
1752
1786
|
}),
|
|
1753
|
-
s && /* @__PURE__ */ Z(
|
|
1787
|
+
s && /* @__PURE__ */ Z(He, {
|
|
1754
1788
|
className: "layout",
|
|
1755
1789
|
width: a,
|
|
1756
1790
|
layouts: g,
|
|
@@ -1784,15 +1818,15 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1784
1818
|
children: [c && /* @__PURE__ */ Z("div", {
|
|
1785
1819
|
className: "drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border",
|
|
1786
1820
|
children: /* @__PURE__ */ Z(ve, { className: "h-4 w-4" })
|
|
1787
|
-
}), /* @__PURE__ */ Z(
|
|
1821
|
+
}), /* @__PURE__ */ Z(h, {
|
|
1788
1822
|
schema: r,
|
|
1789
1823
|
className: "h-full w-full"
|
|
1790
1824
|
})]
|
|
1791
|
-
}) : /* @__PURE__ */ Q(
|
|
1792
|
-
className:
|
|
1793
|
-
children: [e.title && /* @__PURE__ */ Q(
|
|
1825
|
+
}) : /* @__PURE__ */ Q(A, {
|
|
1826
|
+
className: H("h-full overflow-hidden border-border/50 shadow-sm transition-all", "bg-card/50 backdrop-blur-sm", c && "ring-2 ring-primary/20"),
|
|
1827
|
+
children: [e.title && /* @__PURE__ */ Q(M, {
|
|
1794
1828
|
className: "pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between",
|
|
1795
|
-
children: [/* @__PURE__ */ Z(
|
|
1829
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1796
1830
|
className: "text-base font-medium tracking-tight truncate",
|
|
1797
1831
|
title: e.title,
|
|
1798
1832
|
children: e.title
|
|
@@ -1800,11 +1834,11 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1800
1834
|
className: "drag-handle cursor-move p-1 hover:bg-muted/40 rounded",
|
|
1801
1835
|
children: /* @__PURE__ */ Z(ve, { className: "h-4 w-4" })
|
|
1802
1836
|
})]
|
|
1803
|
-
}), /* @__PURE__ */ Z(
|
|
1837
|
+
}), /* @__PURE__ */ Z(j, {
|
|
1804
1838
|
className: "p-0 h-full",
|
|
1805
1839
|
children: /* @__PURE__ */ Z("div", {
|
|
1806
|
-
className:
|
|
1807
|
-
children: /* @__PURE__ */ Z(
|
|
1840
|
+
className: H("h-full w-full overflow-auto p-4"),
|
|
1841
|
+
children: /* @__PURE__ */ Z(h, { schema: r })
|
|
1808
1842
|
})
|
|
1809
1843
|
})]
|
|
1810
1844
|
})
|
|
@@ -1813,7 +1847,7 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1813
1847
|
})
|
|
1814
1848
|
]
|
|
1815
1849
|
});
|
|
1816
|
-
},
|
|
1850
|
+
}, jt = C({
|
|
1817
1851
|
"dashboard.trend.vsLastQuarter": "vs last quarter",
|
|
1818
1852
|
"dashboard.trend.vsLastMonth": "vs last month",
|
|
1819
1853
|
"dashboard.trend.vsLastWeek": "vs last week",
|
|
@@ -1821,7 +1855,7 @@ var kt = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1821
1855
|
"dashboard.trend.vsYesterday": "vs yesterday",
|
|
1822
1856
|
"dashboard.trend.vsPreviousPeriod": "vs previous period"
|
|
1823
1857
|
}, "dashboard.trend.vsLastQuarter");
|
|
1824
|
-
function
|
|
1858
|
+
function Mt(e) {
|
|
1825
1859
|
switch (e.trim().toLowerCase().replace(/\s+/g, " ")) {
|
|
1826
1860
|
case "vs last quarter":
|
|
1827
1861
|
case "vs previous quarter": return "dashboard.trend.vsLastQuarter";
|
|
@@ -1837,11 +1871,11 @@ function jt(e) {
|
|
|
1837
1871
|
default: return;
|
|
1838
1872
|
}
|
|
1839
1873
|
}
|
|
1840
|
-
function
|
|
1874
|
+
function Nt(e, t, n) {
|
|
1841
1875
|
if (e == null) return "";
|
|
1842
1876
|
if (typeof e == "string") {
|
|
1843
1877
|
let r = Number(e);
|
|
1844
|
-
return !isFinite(r) || e.trim() === "" ? e :
|
|
1878
|
+
return !isFinite(r) || e.trim() === "" ? e : Nt(r, t, n);
|
|
1845
1879
|
}
|
|
1846
1880
|
if (!isFinite(e)) return String(e);
|
|
1847
1881
|
let r = {
|
|
@@ -1850,6 +1884,16 @@ function Mt(e, t, n) {
|
|
|
1850
1884
|
"€": "EUR",
|
|
1851
1885
|
"£": "GBP"
|
|
1852
1886
|
}, i = (t || "").trim(), a = !!n || i.length > 0 && r[i[0]] !== void 0, o = i.endsWith("%"), s = i.match(/0\.(0+)/), c = s ? s[1].length : 0;
|
|
1887
|
+
if (/a/i.test(i)) {
|
|
1888
|
+
let t = {
|
|
1889
|
+
notation: "compact",
|
|
1890
|
+
maximumFractionDigits: c || 1
|
|
1891
|
+
};
|
|
1892
|
+
a && (t.style = "currency", t.currency = n || r[i[0]] || "USD");
|
|
1893
|
+
try {
|
|
1894
|
+
return new Intl.NumberFormat("en-US", t).format(e);
|
|
1895
|
+
} catch {}
|
|
1896
|
+
}
|
|
1853
1897
|
if (a) {
|
|
1854
1898
|
let t = n || r[i[0]] || "USD";
|
|
1855
1899
|
try {
|
|
@@ -1868,10 +1912,10 @@ function Mt(e, t, n) {
|
|
|
1868
1912
|
maximumFractionDigits: c
|
|
1869
1913
|
}).format(e);
|
|
1870
1914
|
}
|
|
1871
|
-
function
|
|
1915
|
+
function Pt(e) {
|
|
1872
1916
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
1873
1917
|
}
|
|
1874
|
-
var
|
|
1918
|
+
var Ft = {
|
|
1875
1919
|
default: "bg-muted text-muted-foreground",
|
|
1876
1920
|
blue: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
1877
1921
|
teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
|
|
@@ -1880,18 +1924,27 @@ var Pt = {
|
|
|
1880
1924
|
success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
|
|
1881
1925
|
warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
|
|
1882
1926
|
danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
|
|
1883
|
-
},
|
|
1884
|
-
|
|
1885
|
-
|
|
1927
|
+
}, It = {
|
|
1928
|
+
default: "text-foreground",
|
|
1929
|
+
blue: "text-blue-600 dark:text-blue-400",
|
|
1930
|
+
teal: "text-teal-600 dark:text-teal-400",
|
|
1931
|
+
orange: "text-orange-600 dark:text-orange-400",
|
|
1932
|
+
purple: "text-purple-600 dark:text-purple-400",
|
|
1933
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
1934
|
+
warning: "text-amber-600 dark:text-amber-400",
|
|
1935
|
+
danger: "text-rose-600 dark:text-rose-400"
|
|
1936
|
+
}, Lt = ({ label: e, value: t, trend: n, icon: r, className: i, description: a, loading: o, error: s, colorVariant: c = "default", format: l, currency: u, prefix: d, suffix: f, onClick: p, variant: m = "card", ...h }) => {
|
|
1937
|
+
let g = Ft[c] || Ft.default, { t: _ } = jt(), v = q(() => {
|
|
1938
|
+
let e = Pt(a) || Pt(n?.label);
|
|
1886
1939
|
if (!e) return e;
|
|
1887
|
-
let t =
|
|
1888
|
-
return t ?
|
|
1940
|
+
let t = Mt(e);
|
|
1941
|
+
return t ? _(t) : e;
|
|
1889
1942
|
}, [
|
|
1890
1943
|
a,
|
|
1891
1944
|
n?.label,
|
|
1892
|
-
|
|
1893
|
-
]),
|
|
1894
|
-
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ?
|
|
1945
|
+
_
|
|
1946
|
+
]), y = q(() => {
|
|
1947
|
+
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ? Nt(t, l, u) : t ?? "", n = String(e);
|
|
1895
1948
|
return `${d && n.startsWith(d) ? "" : d ?? ""}${n}${f && n.endsWith(f) ? "" : f ?? ""}`;
|
|
1896
1949
|
}, [
|
|
1897
1950
|
t,
|
|
@@ -1899,35 +1952,69 @@ var Pt = {
|
|
|
1899
1952
|
u,
|
|
1900
1953
|
d,
|
|
1901
1954
|
f
|
|
1902
|
-
]),
|
|
1955
|
+
]), b = q(() => {
|
|
1903
1956
|
if (typeof r == "string") {
|
|
1904
1957
|
let e = oe(r);
|
|
1905
1958
|
return e ? /* @__PURE__ */ Z(e, { className: "h-4 w-4" }) : null;
|
|
1906
1959
|
}
|
|
1907
1960
|
return r;
|
|
1908
1961
|
}, [r]);
|
|
1909
|
-
|
|
1910
|
-
|
|
1962
|
+
if (m === "bare") {
|
|
1963
|
+
let t = It[c] || It.default;
|
|
1964
|
+
return /* @__PURE__ */ Z("div", {
|
|
1965
|
+
className: H("flex flex-col gap-1 min-w-0", p && "cursor-pointer", i),
|
|
1966
|
+
onClick: p,
|
|
1967
|
+
role: p ? "button" : void 0,
|
|
1968
|
+
tabIndex: p ? 0 : void 0,
|
|
1969
|
+
onKeyDown: p ? (e) => {
|
|
1970
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
|
|
1971
|
+
} : void 0,
|
|
1972
|
+
children: o ? /* @__PURE__ */ Q("div", {
|
|
1973
|
+
className: "flex items-center gap-2 text-muted-foreground",
|
|
1974
|
+
"data-testid": "metric-loading",
|
|
1975
|
+
children: [/* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
1976
|
+
className: "text-sm",
|
|
1977
|
+
children: "Loading…"
|
|
1978
|
+
})]
|
|
1979
|
+
}) : s ? /* @__PURE__ */ Q("div", {
|
|
1980
|
+
className: "flex items-center gap-2",
|
|
1981
|
+
"data-testid": "metric-error",
|
|
1982
|
+
role: "alert",
|
|
1983
|
+
children: [/* @__PURE__ */ Z(fe, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
1984
|
+
className: "text-xs text-destructive truncate",
|
|
1985
|
+
children: s
|
|
1986
|
+
})]
|
|
1987
|
+
}) : /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z("div", {
|
|
1988
|
+
className: H("text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate", t),
|
|
1989
|
+
children: y
|
|
1990
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1991
|
+
className: "text-xs font-medium text-muted-foreground truncate",
|
|
1992
|
+
children: Pt(e)
|
|
1993
|
+
})] })
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1996
|
+
return /* @__PURE__ */ Q(A, {
|
|
1997
|
+
className: H("h-full overflow-hidden", p && "cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", i),
|
|
1911
1998
|
onClick: p,
|
|
1912
1999
|
role: p ? "button" : void 0,
|
|
1913
2000
|
tabIndex: p ? 0 : void 0,
|
|
1914
2001
|
onKeyDown: p ? (e) => {
|
|
1915
2002
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
|
|
1916
2003
|
} : void 0,
|
|
1917
|
-
...
|
|
1918
|
-
children: [/* @__PURE__ */ Q(
|
|
2004
|
+
...h,
|
|
2005
|
+
children: [/* @__PURE__ */ Q(M, {
|
|
1919
2006
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
1920
|
-
children: [/* @__PURE__ */ Z(
|
|
2007
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1921
2008
|
className: "text-sm font-medium truncate",
|
|
1922
|
-
children:
|
|
1923
|
-
}),
|
|
1924
|
-
className:
|
|
1925
|
-
children:
|
|
2009
|
+
children: Pt(e)
|
|
2010
|
+
}), b && /* @__PURE__ */ Z("div", {
|
|
2011
|
+
className: H("flex h-8 w-8 items-center justify-center rounded-md shrink-0", g),
|
|
2012
|
+
children: b
|
|
1926
2013
|
})]
|
|
1927
|
-
}), /* @__PURE__ */ Z(
|
|
2014
|
+
}), /* @__PURE__ */ Z(j, { children: o ? /* @__PURE__ */ Q("div", {
|
|
1928
2015
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
1929
2016
|
"data-testid": "metric-loading",
|
|
1930
|
-
children: [/* @__PURE__ */ Z(
|
|
2017
|
+
children: [/* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
1931
2018
|
className: "text-sm",
|
|
1932
2019
|
children: "Loading…"
|
|
1933
2020
|
})]
|
|
@@ -1939,47 +2026,47 @@ var Pt = {
|
|
|
1939
2026
|
className: "text-xs text-destructive truncate",
|
|
1940
2027
|
children: s
|
|
1941
2028
|
})]
|
|
1942
|
-
}) : /* @__PURE__ */ Q(
|
|
2029
|
+
}) : /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z("div", {
|
|
1943
2030
|
className: "text-2xl font-bold tabular-nums tracking-tight truncate",
|
|
1944
|
-
children:
|
|
2031
|
+
children: y
|
|
1945
2032
|
}), (n || a) && /* @__PURE__ */ Q("div", {
|
|
1946
2033
|
className: "text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0",
|
|
1947
2034
|
children: [n && /* @__PURE__ */ Q("span", {
|
|
1948
|
-
className:
|
|
2035
|
+
className: H("flex items-center shrink-0 font-medium", n.direction === "up" && "text-emerald-600 dark:text-emerald-400", n.direction === "down" && "text-rose-600 dark:text-rose-400", n.direction === "neutral" && "text-muted-foreground"),
|
|
1949
2036
|
children: [
|
|
1950
2037
|
n.direction === "up" && /* @__PURE__ */ Z(me, { className: "h-3 w-3 mr-1" }),
|
|
1951
2038
|
n.direction === "down" && /* @__PURE__ */ Z(pe, { className: "h-3 w-3 mr-1" }),
|
|
1952
|
-
n.direction === "neutral" && /* @__PURE__ */ Z(
|
|
2039
|
+
n.direction === "neutral" && /* @__PURE__ */ Z(be, { className: "h-3 w-3 mr-1" }),
|
|
1953
2040
|
n.value,
|
|
1954
2041
|
"%"
|
|
1955
2042
|
]
|
|
1956
2043
|
}), /* @__PURE__ */ Z("span", {
|
|
1957
2044
|
className: "truncate min-w-0",
|
|
1958
|
-
children:
|
|
2045
|
+
children: v
|
|
1959
2046
|
})]
|
|
1960
2047
|
})] }) })]
|
|
1961
2048
|
});
|
|
1962
2049
|
};
|
|
1963
2050
|
//#endregion
|
|
1964
2051
|
//#region src/MetricCard.tsx
|
|
1965
|
-
function
|
|
2052
|
+
function Rt(e) {
|
|
1966
2053
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
1967
2054
|
}
|
|
1968
|
-
var
|
|
2055
|
+
var zt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
|
|
1969
2056
|
let u = n ? oe(n) : null;
|
|
1970
|
-
return /* @__PURE__ */ Q(
|
|
1971
|
-
className:
|
|
2057
|
+
return /* @__PURE__ */ Q(A, {
|
|
2058
|
+
className: H("h-full", o),
|
|
1972
2059
|
...l,
|
|
1973
|
-
children: [/* @__PURE__ */ Q(
|
|
2060
|
+
children: [/* @__PURE__ */ Q(M, {
|
|
1974
2061
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
1975
|
-
children: [/* @__PURE__ */ Z(
|
|
2062
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1976
2063
|
className: "text-sm font-medium",
|
|
1977
|
-
children:
|
|
2064
|
+
children: Rt(e)
|
|
1978
2065
|
}), u && /* @__PURE__ */ Z(u, { className: "h-4 w-4 text-muted-foreground" })]
|
|
1979
|
-
}), /* @__PURE__ */ Z(
|
|
2066
|
+
}), /* @__PURE__ */ Z(j, { children: s ? /* @__PURE__ */ Q("div", {
|
|
1980
2067
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
1981
2068
|
"data-testid": "metric-card-loading",
|
|
1982
|
-
children: [/* @__PURE__ */ Z(
|
|
2069
|
+
children: [/* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
1983
2070
|
className: "text-sm",
|
|
1984
2071
|
children: "Loading…"
|
|
1985
2072
|
})]
|
|
@@ -1991,55 +2078,55 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
1991
2078
|
className: "text-xs text-destructive truncate",
|
|
1992
2079
|
children: c
|
|
1993
2080
|
})]
|
|
1994
|
-
}) : /* @__PURE__ */ Q(
|
|
2081
|
+
}) : /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z("div", {
|
|
1995
2082
|
className: "text-2xl font-bold",
|
|
1996
2083
|
children: t
|
|
1997
2084
|
}), (r || i || a) && /* @__PURE__ */ Q("p", {
|
|
1998
2085
|
className: "text-xs text-muted-foreground flex items-center mt-1",
|
|
1999
2086
|
children: [r && i && /* @__PURE__ */ Q("span", {
|
|
2000
|
-
className:
|
|
2087
|
+
className: H("flex items-center mr-2", r === "up" && "text-green-500", r === "down" && "text-red-500", r === "neutral" && "text-yellow-500"),
|
|
2001
2088
|
children: [
|
|
2002
2089
|
r === "up" && /* @__PURE__ */ Z(me, { className: "h-3 w-3 mr-1" }),
|
|
2003
2090
|
r === "down" && /* @__PURE__ */ Z(pe, { className: "h-3 w-3 mr-1" }),
|
|
2004
|
-
r === "neutral" && /* @__PURE__ */ Z(
|
|
2091
|
+
r === "neutral" && /* @__PURE__ */ Z(be, { className: "h-3 w-3 mr-1" }),
|
|
2005
2092
|
i
|
|
2006
2093
|
]
|
|
2007
|
-
}),
|
|
2094
|
+
}), Rt(a)]
|
|
2008
2095
|
})] }) })]
|
|
2009
2096
|
});
|
|
2010
|
-
},
|
|
2011
|
-
let
|
|
2012
|
-
|
|
2097
|
+
}, Bt = ({ objectName: e, aggregate: t, filter: n, label: r, fallbackValue: i, trend: o, icon: s, className: c, description: l, dataSource: u, colorVariant: _, format: v, currency: y, prefix: b, suffix: x, invert: S, drillDown: C, title: E, compareTo: D, t: O, variant: k }) => {
|
|
2098
|
+
let A = ue(g), j = u || A?.dataSource, [M, N] = J(!1), [P, F] = J(null), [I, ee] = J(null), [re, V] = J(!1), [H, oe] = J(null), [se, U] = J(null);
|
|
2099
|
+
K(() => {
|
|
2013
2100
|
let t = !0;
|
|
2014
|
-
if (!(!
|
|
2015
|
-
t &&
|
|
2101
|
+
if (!(!j || !e || typeof j.getObjectSchema != "function")) return j.getObjectSchema(e).then((e) => {
|
|
2102
|
+
t && U(e);
|
|
2016
2103
|
}).catch(() => {}), () => {
|
|
2017
2104
|
t = !1;
|
|
2018
2105
|
};
|
|
2019
|
-
}, [
|
|
2020
|
-
let
|
|
2106
|
+
}, [j, e]);
|
|
2107
|
+
let W = q(() => {
|
|
2021
2108
|
let e = t?.field;
|
|
2022
2109
|
if (!e || !se?.fields) return null;
|
|
2023
2110
|
let n = se.fields;
|
|
2024
2111
|
return Array.isArray(n) ? n.find((t) => t?.name === e) || null : n[e] || null;
|
|
2025
|
-
}, [se, t?.field]), ce =
|
|
2112
|
+
}, [se, t?.field]), ce = q(() => {
|
|
2026
2113
|
if (v) return v;
|
|
2027
|
-
if (
|
|
2028
|
-
if (
|
|
2029
|
-
let e =
|
|
2114
|
+
if (W) {
|
|
2115
|
+
if (W.type === "currency") {
|
|
2116
|
+
let e = W.precision ?? W.scale ?? 0;
|
|
2030
2117
|
return e > 0 ? `0,0.${"0".repeat(e)}` : "0,0";
|
|
2031
2118
|
}
|
|
2032
|
-
if (
|
|
2033
|
-
if (
|
|
2119
|
+
if (W.type === "percent") return "0,0%";
|
|
2120
|
+
if (W.type === "number" || W.type === "integer") return "0,0";
|
|
2034
2121
|
}
|
|
2035
|
-
}, [v,
|
|
2122
|
+
}, [v, W]), { currency: le } = T(), de = q(() => {
|
|
2036
2123
|
if (y) return y;
|
|
2037
|
-
if (
|
|
2124
|
+
if (W?.type === "currency") return w(W, le);
|
|
2038
2125
|
}, [
|
|
2039
2126
|
y,
|
|
2040
|
-
|
|
2127
|
+
W,
|
|
2041
2128
|
le
|
|
2042
|
-
]), fe =
|
|
2129
|
+
]), fe = q(() => t ? JSON.stringify(t) : "", [t]), Y = q(() => f(n), [n]), pe = q(() => Y ? JSON.stringify(Y) : "", [Y]), me = q(() => D ? JSON.stringify(D) : "", [D]), he = G(async (n, r) => {
|
|
2043
2130
|
if (t && typeof n.aggregate == "function") {
|
|
2044
2131
|
let i = await n.aggregate(e, {
|
|
2045
2132
|
field: t.field,
|
|
@@ -2060,17 +2147,17 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2060
2147
|
return (Array.isArray(t) ? t : t?.data || t?.records || []).length;
|
|
2061
2148
|
}
|
|
2062
2149
|
return null;
|
|
2063
|
-
}, [e, fe]), ge =
|
|
2150
|
+
}, [e, fe]), ge = G(async (t, r) => {
|
|
2064
2151
|
if (!(!t || !e)) {
|
|
2065
|
-
r.current && (
|
|
2152
|
+
r.current && (V(!0), oe(null));
|
|
2066
2153
|
try {
|
|
2067
|
-
let e = D ?
|
|
2154
|
+
let e = D ? m(n, D) : null, [i, a] = await Promise.all([he(t, Y), e ? he(t, e) : Promise.resolve(null)]);
|
|
2068
2155
|
if (i === null) return;
|
|
2069
|
-
r.current && (
|
|
2156
|
+
r.current && (F(i), ee(typeof a == "number" && Number.isFinite(a) ? a : null));
|
|
2070
2157
|
} catch (e) {
|
|
2071
2158
|
console.error("[ObjectMetricWidget] Fetch error:", e), r.current && oe(e instanceof Error ? e.message : "Failed to load metric");
|
|
2072
2159
|
} finally {
|
|
2073
|
-
r.current &&
|
|
2160
|
+
r.current && V(!1);
|
|
2074
2161
|
}
|
|
2075
2162
|
}
|
|
2076
2163
|
}, [
|
|
@@ -2080,30 +2167,30 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2080
2167
|
me,
|
|
2081
2168
|
he
|
|
2082
2169
|
]);
|
|
2083
|
-
|
|
2170
|
+
K(() => {
|
|
2084
2171
|
let t = { current: !0 };
|
|
2085
|
-
return
|
|
2172
|
+
return j && e ? ge(j, t) : (F(null), oe(null)), () => {
|
|
2086
2173
|
t.current = !1;
|
|
2087
2174
|
};
|
|
2088
2175
|
}, [
|
|
2089
|
-
|
|
2176
|
+
j,
|
|
2090
2177
|
e,
|
|
2091
2178
|
ge
|
|
2092
2179
|
]);
|
|
2093
|
-
let
|
|
2094
|
-
S && typeof
|
|
2095
|
-
let _e =
|
|
2096
|
-
if (!D || typeof
|
|
2097
|
-
let e =
|
|
2180
|
+
let X = P === null ? j ? "—" : i ?? "—" : P;
|
|
2181
|
+
S && typeof X == "number" && isFinite(X) && X >= 0 && X <= 1 && (X = 1 - X);
|
|
2182
|
+
let _e = q(() => {
|
|
2183
|
+
if (!D || typeof P != "number" || !Number.isFinite(P) || I === null) return;
|
|
2184
|
+
let e = We(P, I);
|
|
2098
2185
|
if (!e) return;
|
|
2099
|
-
let t =
|
|
2186
|
+
let t = a(D, n), r = `dashboard.trend.${t}`, i = {
|
|
2100
2187
|
vsPreviousPeriod: "vs previous period",
|
|
2101
2188
|
vsLastWeek: "vs last week",
|
|
2102
2189
|
vsLastMonth: "vs last month",
|
|
2103
2190
|
vsLastQuarter: "vs last quarter",
|
|
2104
2191
|
vsLastYear: "vs last year",
|
|
2105
2192
|
vsYesterday: "vs yesterday"
|
|
2106
|
-
}, o = O ? O(r,
|
|
2193
|
+
}, o = O ? O(r, i[t] || t) : i[t] || t;
|
|
2107
2194
|
return {
|
|
2108
2195
|
value: e.value,
|
|
2109
2196
|
direction: e.direction,
|
|
@@ -2111,29 +2198,29 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2111
2198
|
};
|
|
2112
2199
|
}, [
|
|
2113
2200
|
D,
|
|
2114
|
-
|
|
2115
|
-
|
|
2201
|
+
P,
|
|
2202
|
+
I,
|
|
2116
2203
|
n,
|
|
2117
2204
|
O
|
|
2118
|
-
]) ?? o, ve =
|
|
2205
|
+
]) ?? o, ve = d(C) && !!e && !!j, ye = q(() => {
|
|
2119
2206
|
let e = typeof r == "string" ? r : r?.defaultValue || "";
|
|
2120
|
-
return
|
|
2207
|
+
return p(C, {}, (typeof E == "string" ? E : E?.defaultValue || "") || e || "Details");
|
|
2121
2208
|
}, [
|
|
2122
|
-
|
|
2209
|
+
C,
|
|
2123
2210
|
r,
|
|
2124
2211
|
E
|
|
2125
|
-
]),
|
|
2212
|
+
]), be = q(() => {
|
|
2126
2213
|
if (!ve) return null;
|
|
2127
|
-
let t =
|
|
2214
|
+
let t = C?.target ?? "drawer", n = C?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i = r ? null : /* @__PURE__ */ Z(at, {
|
|
2128
2215
|
objectName: e,
|
|
2129
|
-
filter:
|
|
2130
|
-
onNavigate: () =>
|
|
2216
|
+
filter: Y,
|
|
2217
|
+
onNavigate: () => N(!1)
|
|
2131
2218
|
}), a;
|
|
2132
2219
|
if (r) {
|
|
2133
|
-
let e = n.filter, t = e ?
|
|
2220
|
+
let e = n.filter, t = e ? Y ? { $and: [e, Y] } : e : Y;
|
|
2134
2221
|
a = /* @__PURE__ */ Z("div", {
|
|
2135
2222
|
className: "h-full overflow-auto",
|
|
2136
|
-
children: /* @__PURE__ */ Z(
|
|
2223
|
+
children: /* @__PURE__ */ Z(h, { schema: {
|
|
2137
2224
|
type: "spec-report",
|
|
2138
2225
|
...n,
|
|
2139
2226
|
filter: t
|
|
@@ -2141,10 +2228,10 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2141
2228
|
});
|
|
2142
2229
|
} else a = /* @__PURE__ */ Z("div", {
|
|
2143
2230
|
className: "h-full overflow-auto",
|
|
2144
|
-
children: /* @__PURE__ */ Z(
|
|
2231
|
+
children: /* @__PURE__ */ Z(h, { schema: {
|
|
2145
2232
|
type: "object-data-table",
|
|
2146
2233
|
objectName: e,
|
|
2147
|
-
filter:
|
|
2234
|
+
filter: Y,
|
|
2148
2235
|
pageSize: 25,
|
|
2149
2236
|
drillDown: {
|
|
2150
2237
|
enabled: !0,
|
|
@@ -2153,25 +2240,25 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2153
2240
|
}
|
|
2154
2241
|
} })
|
|
2155
2242
|
});
|
|
2156
|
-
return t === "dialog" ? /* @__PURE__ */ Z(
|
|
2243
|
+
return t === "dialog" ? /* @__PURE__ */ Z(te, {
|
|
2157
2244
|
open: !0,
|
|
2158
|
-
onOpenChange: (e) => !e &&
|
|
2159
|
-
children: /* @__PURE__ */ Q(
|
|
2245
|
+
onOpenChange: (e) => !e && N(!1),
|
|
2246
|
+
children: /* @__PURE__ */ Q(L, {
|
|
2160
2247
|
className: "max-w-5xl",
|
|
2161
|
-
children: [/* @__PURE__ */ Q(
|
|
2248
|
+
children: [/* @__PURE__ */ Q(R, {
|
|
2162
2249
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2163
|
-
children: [/* @__PURE__ */ Z(
|
|
2250
|
+
children: [/* @__PURE__ */ Z(ne, { children: ye }), i]
|
|
2164
2251
|
}), a]
|
|
2165
2252
|
})
|
|
2166
2253
|
}) : /* @__PURE__ */ Z(z, {
|
|
2167
2254
|
open: !0,
|
|
2168
|
-
onOpenChange: (e) => !e &&
|
|
2169
|
-
children: /* @__PURE__ */ Q(
|
|
2255
|
+
onOpenChange: (e) => !e && N(!1),
|
|
2256
|
+
children: /* @__PURE__ */ Q(ie, {
|
|
2170
2257
|
side: "right",
|
|
2171
2258
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col",
|
|
2172
|
-
children: [/* @__PURE__ */ Q(
|
|
2259
|
+
children: [/* @__PURE__ */ Q(B, {
|
|
2173
2260
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2174
|
-
children: [/* @__PURE__ */ Z(ae, { children:
|
|
2261
|
+
children: [/* @__PURE__ */ Z(ae, { children: ye }), i]
|
|
2175
2262
|
}), /* @__PURE__ */ Z("div", {
|
|
2176
2263
|
className: "flex-1 overflow-hidden mt-2",
|
|
2177
2264
|
children: a
|
|
@@ -2180,37 +2267,38 @@ var Lt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2180
2267
|
});
|
|
2181
2268
|
}, [
|
|
2182
2269
|
ve,
|
|
2183
|
-
|
|
2270
|
+
C,
|
|
2184
2271
|
e,
|
|
2185
|
-
|
|
2186
|
-
|
|
2272
|
+
Y,
|
|
2273
|
+
ye
|
|
2187
2274
|
]);
|
|
2188
|
-
return /* @__PURE__ */ Q(
|
|
2275
|
+
return /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z(Lt, {
|
|
2189
2276
|
label: r,
|
|
2190
|
-
value:
|
|
2277
|
+
value: X,
|
|
2191
2278
|
trend: _e,
|
|
2192
2279
|
icon: s,
|
|
2193
2280
|
className: c,
|
|
2194
2281
|
description: l,
|
|
2195
|
-
loading:
|
|
2196
|
-
error:
|
|
2282
|
+
loading: re,
|
|
2283
|
+
error: H,
|
|
2197
2284
|
colorVariant: _,
|
|
2198
2285
|
format: ce,
|
|
2199
2286
|
currency: de,
|
|
2200
2287
|
prefix: b,
|
|
2201
2288
|
suffix: x,
|
|
2202
|
-
|
|
2203
|
-
|
|
2289
|
+
variant: k,
|
|
2290
|
+
onClick: ve ? () => N(!0) : void 0
|
|
2291
|
+
}), M && be] });
|
|
2204
2292
|
};
|
|
2205
2293
|
//#endregion
|
|
2206
2294
|
//#region src/PivotTable.tsx
|
|
2207
|
-
function
|
|
2208
|
-
return
|
|
2295
|
+
function Vt() {
|
|
2296
|
+
return O()("dashboard.total", "Total");
|
|
2209
2297
|
}
|
|
2210
|
-
function
|
|
2211
|
-
return
|
|
2298
|
+
function Ht() {
|
|
2299
|
+
return O()("dashboard.noDataAvailable", "No data available");
|
|
2212
2300
|
}
|
|
2213
|
-
function
|
|
2301
|
+
function Ut(e, t) {
|
|
2214
2302
|
if (!t) return String(e);
|
|
2215
2303
|
let n = "", r = "", i = !1, a, o = t, s = o.match(/^([^0-9.,#]*)/);
|
|
2216
2304
|
if (s && s[1]) {
|
|
@@ -2227,11 +2315,11 @@ function Vt(e, t) {
|
|
|
2227
2315
|
}
|
|
2228
2316
|
return n + l + r;
|
|
2229
2317
|
}
|
|
2230
|
-
var
|
|
2231
|
-
function
|
|
2232
|
-
return e === "" ?
|
|
2318
|
+
var Wt = "—";
|
|
2319
|
+
function Gt(e, t) {
|
|
2320
|
+
return e === "" ? Wt : t?.[e] ?? e;
|
|
2233
2321
|
}
|
|
2234
|
-
function
|
|
2322
|
+
function Kt(e, t) {
|
|
2235
2323
|
if (e.length === 0) return 0;
|
|
2236
2324
|
switch (t) {
|
|
2237
2325
|
case "sum": return e.reduce((e, t) => e + t, 0);
|
|
@@ -2242,8 +2330,8 @@ function Wt(e, t) {
|
|
|
2242
2330
|
default: return e.reduce((e, t) => e + t, 0);
|
|
2243
2331
|
}
|
|
2244
2332
|
}
|
|
2245
|
-
var
|
|
2246
|
-
let { title: o, rowField: s, columnField: c, valueField: l, aggregation:
|
|
2333
|
+
var qt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabel: i, onDrillDown: a }) => {
|
|
2334
|
+
let { title: o, rowField: s, columnField: c, valueField: l, aggregation: u = "sum", data: f = [], showRowTotals: p = !1, showColumnTotals: m = !1, format: h, columnColors: g, drillDown: _ } = e, v = Vt(), y = Ht(), b = d(_) && typeof a == "function", x = (e) => {
|
|
2247
2335
|
b && a({
|
|
2248
2336
|
...e,
|
|
2249
2337
|
rowLabel: e.rowKey === void 0 ? e.rowLabel : n?.[e.rowKey] ?? e.rowKey,
|
|
@@ -2251,21 +2339,21 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2251
2339
|
});
|
|
2252
2340
|
}, S = (e) => (t) => {
|
|
2253
2341
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
|
|
2254
|
-
}, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "", w = Array.isArray(f) ? f : [], { rowKeys: T, colKeys: E, matrix: D, rowTotals: O, colTotals: k, grandTotal: A } =
|
|
2342
|
+
}, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "", w = Array.isArray(f) ? f : [], { rowKeys: T, colKeys: E, matrix: D, rowTotals: O, colTotals: k, grandTotal: A } = q(() => {
|
|
2255
2343
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = {};
|
|
2256
2344
|
for (let r of w) {
|
|
2257
2345
|
let i = String(r[s] ?? ""), a = String(r[c] ?? ""), o = Number(r[l]) || 0;
|
|
2258
2346
|
e.set(i, !0), t.set(a, !0), n[i] || (n[i] = {}), n[i][a] || (n[i][a] = []), n[i][a].push(o);
|
|
2259
2347
|
}
|
|
2260
|
-
let r = Array.from(e.keys()), i = Array.from(t.keys()), a = {}, o = {},
|
|
2348
|
+
let r = Array.from(e.keys()), i = Array.from(t.keys()), a = {}, o = {}, d = {};
|
|
2261
2349
|
for (let e of r) {
|
|
2262
2350
|
a[e] = {};
|
|
2263
2351
|
let t = [];
|
|
2264
2352
|
for (let r of i) {
|
|
2265
|
-
let i = n[e]?.[r] ?? [], o =
|
|
2266
|
-
a[e][r] = o, t.push(...i), !
|
|
2353
|
+
let i = n[e]?.[r] ?? [], o = Kt(i, u);
|
|
2354
|
+
a[e][r] = o, t.push(...i), !d[r] && d[r];
|
|
2267
2355
|
}
|
|
2268
|
-
o[e] =
|
|
2356
|
+
o[e] = Kt(t, u);
|
|
2269
2357
|
}
|
|
2270
2358
|
for (let e of i) {
|
|
2271
2359
|
let t = [];
|
|
@@ -2273,7 +2361,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2273
2361
|
let r = n[i]?.[e] ?? [];
|
|
2274
2362
|
t.push(...r);
|
|
2275
2363
|
}
|
|
2276
|
-
|
|
2364
|
+
d[e] = Kt(t, u);
|
|
2277
2365
|
}
|
|
2278
2366
|
let f = [];
|
|
2279
2367
|
for (let e of w) f.push(Number(e[l]) || 0);
|
|
@@ -2282,22 +2370,22 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2282
2370
|
colKeys: i,
|
|
2283
2371
|
matrix: a,
|
|
2284
2372
|
rowTotals: o,
|
|
2285
|
-
colTotals:
|
|
2286
|
-
grandTotal:
|
|
2373
|
+
colTotals: d,
|
|
2374
|
+
grandTotal: Kt(f, u)
|
|
2287
2375
|
};
|
|
2288
2376
|
}, [
|
|
2289
2377
|
w,
|
|
2290
2378
|
s,
|
|
2291
2379
|
c,
|
|
2292
2380
|
l,
|
|
2293
|
-
|
|
2294
|
-
]), j = (e) =>
|
|
2381
|
+
u
|
|
2382
|
+
]), j = (e) => Ut(e, h);
|
|
2295
2383
|
return w.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
2296
|
-
className:
|
|
2384
|
+
className: H("overflow-auto", t),
|
|
2297
2385
|
children: [o && /* @__PURE__ */ Z("h3", {
|
|
2298
2386
|
className: "text-sm font-semibold mb-2",
|
|
2299
2387
|
children: o
|
|
2300
|
-
}), /* @__PURE__ */ Z(
|
|
2388
|
+
}), /* @__PURE__ */ Z(ee, {
|
|
2301
2389
|
"data-testid": "pivot-empty-state",
|
|
2302
2390
|
className: "py-8 gap-2 [&>h3]:hidden",
|
|
2303
2391
|
icon: /* @__PURE__ */ Q("svg", {
|
|
@@ -2341,7 +2429,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2341
2429
|
description: y
|
|
2342
2430
|
})]
|
|
2343
2431
|
}) : /* @__PURE__ */ Q("div", {
|
|
2344
|
-
className:
|
|
2432
|
+
className: H("overflow-auto", t),
|
|
2345
2433
|
children: [o && /* @__PURE__ */ Z("h3", {
|
|
2346
2434
|
className: "text-sm font-semibold mb-2",
|
|
2347
2435
|
children: o
|
|
@@ -2362,14 +2450,14 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2362
2450
|
colKey: e
|
|
2363
2451
|
});
|
|
2364
2452
|
return /* @__PURE__ */ Z("th", {
|
|
2365
|
-
className:
|
|
2453
|
+
className: H("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", g?.[e] ?? "text-muted-foreground", C),
|
|
2366
2454
|
title: e === "" ? `${c}: (empty)` : `${c}: ${e}`,
|
|
2367
2455
|
role: b ? "button" : void 0,
|
|
2368
2456
|
tabIndex: b ? 0 : void 0,
|
|
2369
2457
|
onClick: b ? t : void 0,
|
|
2370
2458
|
onKeyDown: b ? S(t) : void 0,
|
|
2371
2459
|
"aria-label": b ? `Drill into ${c}: ${e || "(empty)"}` : void 0,
|
|
2372
|
-
children:
|
|
2460
|
+
children: Gt(e, r)
|
|
2373
2461
|
}, e);
|
|
2374
2462
|
}),
|
|
2375
2463
|
p && /* @__PURE__ */ Z("th", {
|
|
@@ -2382,7 +2470,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2382
2470
|
className: "border-b border-border/50 hover:bg-muted/30",
|
|
2383
2471
|
children: [
|
|
2384
2472
|
/* @__PURE__ */ Z("td", {
|
|
2385
|
-
className:
|
|
2473
|
+
className: H("p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", C),
|
|
2386
2474
|
role: b ? "button" : void 0,
|
|
2387
2475
|
tabIndex: b ? 0 : void 0,
|
|
2388
2476
|
onClick: b ? () => x({
|
|
@@ -2394,7 +2482,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2394
2482
|
rowKey: e
|
|
2395
2483
|
})) : void 0,
|
|
2396
2484
|
"aria-label": b ? `Drill into ${s}: ${e || "(empty)"}` : void 0,
|
|
2397
|
-
children:
|
|
2485
|
+
children: Gt(e, n)
|
|
2398
2486
|
}),
|
|
2399
2487
|
E.map((t) => {
|
|
2400
2488
|
let n = D[e]?.[t] ?? 0, r = () => x({
|
|
@@ -2404,7 +2492,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2404
2492
|
value: n
|
|
2405
2493
|
});
|
|
2406
2494
|
return /* @__PURE__ */ Z("td", {
|
|
2407
|
-
className:
|
|
2495
|
+
className: H("text-right p-2 tabular-nums", g?.[t], C),
|
|
2408
2496
|
role: b ? "button" : void 0,
|
|
2409
2497
|
tabIndex: b ? 0 : void 0,
|
|
2410
2498
|
onClick: b ? r : void 0,
|
|
@@ -2414,7 +2502,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2414
2502
|
}, t);
|
|
2415
2503
|
}),
|
|
2416
2504
|
p && /* @__PURE__ */ Z("td", {
|
|
2417
|
-
className:
|
|
2505
|
+
className: H("text-right p-2 font-semibold tabular-nums bg-muted/20", C),
|
|
2418
2506
|
role: b ? "button" : void 0,
|
|
2419
2507
|
tabIndex: b ? 0 : void 0,
|
|
2420
2508
|
onClick: b ? () => x({
|
|
@@ -2439,7 +2527,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2439
2527
|
children: v
|
|
2440
2528
|
}),
|
|
2441
2529
|
E.map((e) => /* @__PURE__ */ Z("td", {
|
|
2442
|
-
className:
|
|
2530
|
+
className: H("text-right p-2 tabular-nums", C),
|
|
2443
2531
|
role: b ? "button" : void 0,
|
|
2444
2532
|
tabIndex: b ? 0 : void 0,
|
|
2445
2533
|
onClick: b ? () => x({
|
|
@@ -2455,7 +2543,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2455
2543
|
children: j(k[e] ?? 0)
|
|
2456
2544
|
}, e)),
|
|
2457
2545
|
p && /* @__PURE__ */ Z("td", {
|
|
2458
|
-
className:
|
|
2546
|
+
className: H("text-right p-2 tabular-nums font-bold", C),
|
|
2459
2547
|
role: b ? "button" : void 0,
|
|
2460
2548
|
tabIndex: b ? 0 : void 0,
|
|
2461
2549
|
onClick: b ? () => x({
|
|
@@ -2473,11 +2561,11 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2473
2561
|
]
|
|
2474
2562
|
})]
|
|
2475
2563
|
});
|
|
2476
|
-
},
|
|
2477
|
-
let r = ue(
|
|
2478
|
-
|
|
2479
|
-
O.current = T, k.current =
|
|
2480
|
-
}, [T,
|
|
2564
|
+
}, Jt = ({ schema: e, dataSource: t, className: n }) => {
|
|
2565
|
+
let r = ue(g), i = t || r?.dataSource, a = v(e.bind), [c, l] = J([]), [u, m] = J(!1), [h, _] = J(null), [y, b] = J({}), [x, S] = J({}), [C, w] = J(null), { fieldLabel: T, fieldOptionLabel: E } = D(), O = de(T), k = de(E);
|
|
2566
|
+
K(() => {
|
|
2567
|
+
O.current = T, k.current = E;
|
|
2568
|
+
}, [T, E]), K(() => {
|
|
2481
2569
|
if (!i || !e.objectName) return;
|
|
2482
2570
|
let t = i.getObjectSchema;
|
|
2483
2571
|
if (typeof t != "function") return;
|
|
@@ -2502,18 +2590,18 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2502
2590
|
}).catch(() => {}), () => {
|
|
2503
2591
|
n = !1;
|
|
2504
2592
|
};
|
|
2505
|
-
}, [i, e.objectName]),
|
|
2593
|
+
}, [i, e.objectName]), K(() => {
|
|
2506
2594
|
let t = !0;
|
|
2507
|
-
return e.objectName && !
|
|
2595
|
+
return e.objectName && !a && (!e.data || e.data.length === 0) && (async () => {
|
|
2508
2596
|
if (!(!i || !e.objectName)) {
|
|
2509
|
-
t && (m(!0),
|
|
2597
|
+
t && (m(!0), _(null));
|
|
2510
2598
|
try {
|
|
2511
2599
|
let n;
|
|
2512
|
-
if (typeof i.find == "function") n =
|
|
2600
|
+
if (typeof i.find == "function") n = s(await i.find(e.objectName, { $filter: f(e.filter) }));
|
|
2513
2601
|
else return;
|
|
2514
2602
|
t && l(n);
|
|
2515
2603
|
} catch (e) {
|
|
2516
|
-
console.error("[ObjectPivotTable] Fetch error:", e), t &&
|
|
2604
|
+
console.error("[ObjectPivotTable] Fetch error:", e), t && _(e instanceof Error ? e.message : "Failed to load data");
|
|
2517
2605
|
} finally {
|
|
2518
2606
|
t && m(!1);
|
|
2519
2607
|
}
|
|
@@ -2524,13 +2612,13 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2524
2612
|
}, [
|
|
2525
2613
|
e.objectName,
|
|
2526
2614
|
i,
|
|
2527
|
-
|
|
2615
|
+
a,
|
|
2528
2616
|
e.data,
|
|
2529
2617
|
e.filter
|
|
2530
2618
|
]);
|
|
2531
|
-
let A =
|
|
2532
|
-
if (
|
|
2533
|
-
className:
|
|
2619
|
+
let A = a || e.data || c, j = Array.isArray(A) ? A : [];
|
|
2620
|
+
if (u && j.length === 0) return /* @__PURE__ */ Q("div", {
|
|
2621
|
+
className: H("overflow-auto", n),
|
|
2534
2622
|
"data-testid": "pivot-loading",
|
|
2535
2623
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
2536
2624
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2540,10 +2628,10 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2540
2628
|
children: [/* @__PURE__ */ Q("div", {
|
|
2541
2629
|
className: "flex gap-2",
|
|
2542
2630
|
children: [
|
|
2543
|
-
/* @__PURE__ */ Z(
|
|
2544
|
-
/* @__PURE__ */ Z(
|
|
2545
|
-
/* @__PURE__ */ Z(
|
|
2546
|
-
/* @__PURE__ */ Z(
|
|
2631
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-24" }),
|
|
2632
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-20" }),
|
|
2633
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-20" }),
|
|
2634
|
+
/* @__PURE__ */ Z(V, { className: "h-6 w-20" })
|
|
2547
2635
|
]
|
|
2548
2636
|
}), [
|
|
2549
2637
|
1,
|
|
@@ -2552,16 +2640,16 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2552
2640
|
].map((e) => /* @__PURE__ */ Q("div", {
|
|
2553
2641
|
className: "flex gap-2",
|
|
2554
2642
|
children: [
|
|
2555
|
-
/* @__PURE__ */ Z(
|
|
2556
|
-
/* @__PURE__ */ Z(
|
|
2557
|
-
/* @__PURE__ */ Z(
|
|
2558
|
-
/* @__PURE__ */ Z(
|
|
2643
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-24" }),
|
|
2644
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-20" }),
|
|
2645
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-20" }),
|
|
2646
|
+
/* @__PURE__ */ Z(V, { className: "h-5 w-20" })
|
|
2559
2647
|
]
|
|
2560
2648
|
}, e))]
|
|
2561
2649
|
})]
|
|
2562
2650
|
});
|
|
2563
|
-
if (
|
|
2564
|
-
className:
|
|
2651
|
+
if (h) return /* @__PURE__ */ Q("div", {
|
|
2652
|
+
className: H("overflow-auto", n),
|
|
2565
2653
|
"data-testid": "pivot-error",
|
|
2566
2654
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
2567
2655
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2599,12 +2687,12 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2599
2687
|
]
|
|
2600
2688
|
}), /* @__PURE__ */ Z("p", {
|
|
2601
2689
|
className: "text-xs",
|
|
2602
|
-
children:
|
|
2690
|
+
children: h
|
|
2603
2691
|
})]
|
|
2604
2692
|
})]
|
|
2605
2693
|
});
|
|
2606
2694
|
if (!i && e.objectName && j.length === 0) return /* @__PURE__ */ Q("div", {
|
|
2607
|
-
className:
|
|
2695
|
+
className: H("overflow-auto", n),
|
|
2608
2696
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
2609
2697
|
className: "text-sm font-semibold mb-2",
|
|
2610
2698
|
children: e.title
|
|
@@ -2624,26 +2712,26 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2624
2712
|
...e,
|
|
2625
2713
|
data: j
|
|
2626
2714
|
}, N = e.rowField ? y[e.rowField] : void 0, P = e.columnField ? y[e.columnField] : void 0, F = e.rowField ? x[e.rowField] : void 0, I = e.drillDown;
|
|
2627
|
-
return /* @__PURE__ */ Q(
|
|
2715
|
+
return /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z(qt, {
|
|
2628
2716
|
schema: M,
|
|
2629
2717
|
className: n,
|
|
2630
2718
|
rowLabels: N,
|
|
2631
2719
|
columnLabels: P,
|
|
2632
2720
|
rowFieldLabel: F,
|
|
2633
|
-
onDrillDown:
|
|
2721
|
+
onDrillDown: d(I) ? (e) => w(e) : void 0
|
|
2634
2722
|
}), (() => {
|
|
2635
2723
|
if (!C || !e.objectName) return null;
|
|
2636
|
-
let t =
|
|
2724
|
+
let t = o(I, C, {
|
|
2637
2725
|
rowField: e.rowField,
|
|
2638
2726
|
columnField: e.columnField
|
|
2639
2727
|
}), n = {
|
|
2640
2728
|
...e.filter || {},
|
|
2641
2729
|
...t
|
|
2642
2730
|
};
|
|
2643
|
-
return /* @__PURE__ */ Z(
|
|
2731
|
+
return /* @__PURE__ */ Z(ot, {
|
|
2644
2732
|
open: !0,
|
|
2645
2733
|
onClose: () => w(null),
|
|
2646
|
-
title:
|
|
2734
|
+
title: p(I, C, e.title || "Details"),
|
|
2647
2735
|
target: I?.target ?? "drawer",
|
|
2648
2736
|
objectName: e.objectName,
|
|
2649
2737
|
filter: n,
|
|
@@ -2653,7 +2741,7 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2653
2741
|
report: I?.report
|
|
2654
2742
|
});
|
|
2655
2743
|
})()] });
|
|
2656
|
-
},
|
|
2744
|
+
}, Yt = {
|
|
2657
2745
|
breadcrumb: ["Dashboard", "Configuration"],
|
|
2658
2746
|
sections: [
|
|
2659
2747
|
{
|
|
@@ -2779,12 +2867,12 @@ var Gt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2779
2867
|
}
|
|
2780
2868
|
]
|
|
2781
2869
|
};
|
|
2782
|
-
function
|
|
2870
|
+
function Xt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
2783
2871
|
let { draft: a, isDirty: o, updateField: s, discard: c } = se(n, { onUpdate: i });
|
|
2784
|
-
return /* @__PURE__ */ Z(
|
|
2872
|
+
return /* @__PURE__ */ Z(F, {
|
|
2785
2873
|
open: e,
|
|
2786
2874
|
onClose: t,
|
|
2787
|
-
schema:
|
|
2875
|
+
schema: Yt,
|
|
2788
2876
|
draft: a,
|
|
2789
2877
|
isDirty: o,
|
|
2790
2878
|
onFieldChange: s,
|
|
@@ -2794,7 +2882,7 @@ function Jt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
|
2794
2882
|
}
|
|
2795
2883
|
//#endregion
|
|
2796
2884
|
//#region src/WidgetConfigPanel.tsx
|
|
2797
|
-
var
|
|
2885
|
+
var Zt = [
|
|
2798
2886
|
{
|
|
2799
2887
|
value: "metric",
|
|
2800
2888
|
label: "Metric"
|
|
@@ -2839,7 +2927,7 @@ var Yt = [
|
|
|
2839
2927
|
value: "pivot",
|
|
2840
2928
|
label: "Pivot Table"
|
|
2841
2929
|
}
|
|
2842
|
-
],
|
|
2930
|
+
], Qt = [
|
|
2843
2931
|
{
|
|
2844
2932
|
value: "default",
|
|
2845
2933
|
label: "Default"
|
|
@@ -2872,7 +2960,7 @@ var Yt = [
|
|
|
2872
2960
|
value: "danger",
|
|
2873
2961
|
label: "Danger"
|
|
2874
2962
|
}
|
|
2875
|
-
],
|
|
2963
|
+
], $t = [
|
|
2876
2964
|
{
|
|
2877
2965
|
value: "count",
|
|
2878
2966
|
label: "Count"
|
|
@@ -2893,7 +2981,7 @@ var Yt = [
|
|
|
2893
2981
|
value: "max",
|
|
2894
2982
|
label: "Max"
|
|
2895
2983
|
}
|
|
2896
|
-
],
|
|
2984
|
+
], en = [
|
|
2897
2985
|
"bar",
|
|
2898
2986
|
"horizontal-bar",
|
|
2899
2987
|
"line",
|
|
@@ -2902,17 +2990,17 @@ var Yt = [
|
|
|
2902
2990
|
"donut",
|
|
2903
2991
|
"scatter",
|
|
2904
2992
|
"funnel"
|
|
2905
|
-
],
|
|
2993
|
+
], tn = [
|
|
2906
2994
|
"bar",
|
|
2907
2995
|
"horizontal-bar",
|
|
2908
2996
|
"line",
|
|
2909
2997
|
"area",
|
|
2910
2998
|
"scatter"
|
|
2911
|
-
],
|
|
2999
|
+
], nn = [
|
|
2912
3000
|
"pie",
|
|
2913
3001
|
"donut",
|
|
2914
3002
|
"funnel"
|
|
2915
|
-
],
|
|
3003
|
+
], rn = ["metric", ...en], an = [...en], on = [
|
|
2916
3004
|
"pivot",
|
|
2917
3005
|
"metric",
|
|
2918
3006
|
"bar",
|
|
@@ -2928,50 +3016,50 @@ var Yt = [
|
|
|
2928
3016
|
"table",
|
|
2929
3017
|
"list"
|
|
2930
3018
|
];
|
|
2931
|
-
function an(e) {
|
|
2932
|
-
return !!e && Qt.includes(e);
|
|
2933
|
-
}
|
|
2934
|
-
function on(e) {
|
|
2935
|
-
return !!e && $t.includes(e);
|
|
2936
|
-
}
|
|
2937
3019
|
function sn(e) {
|
|
2938
|
-
return !!e &&
|
|
3020
|
+
return !!e && en.includes(e);
|
|
2939
3021
|
}
|
|
2940
3022
|
function cn(e) {
|
|
2941
3023
|
return !!e && tn.includes(e);
|
|
2942
3024
|
}
|
|
2943
3025
|
function ln(e) {
|
|
3026
|
+
return !!e && an.includes(e);
|
|
3027
|
+
}
|
|
3028
|
+
function un(e) {
|
|
2944
3029
|
return !!e && rn.includes(e);
|
|
2945
3030
|
}
|
|
2946
|
-
|
|
3031
|
+
function dn(e) {
|
|
3032
|
+
return !!e && on.includes(e);
|
|
3033
|
+
}
|
|
3034
|
+
var fn = [{
|
|
2947
3035
|
value: "drawer",
|
|
2948
3036
|
label: "Side drawer"
|
|
2949
3037
|
}, {
|
|
2950
3038
|
value: "dialog",
|
|
2951
3039
|
label: "Center dialog"
|
|
2952
|
-
}],
|
|
3040
|
+
}], pn = [{
|
|
2953
3041
|
value: "group",
|
|
2954
3042
|
label: "Group"
|
|
2955
3043
|
}, {
|
|
2956
3044
|
value: "value",
|
|
2957
3045
|
label: "Value"
|
|
2958
|
-
}],
|
|
3046
|
+
}], mn = [{
|
|
2959
3047
|
value: "asc",
|
|
2960
3048
|
label: "↑"
|
|
2961
3049
|
}, {
|
|
2962
3050
|
value: "desc",
|
|
2963
3051
|
label: "↓"
|
|
2964
3052
|
}];
|
|
2965
|
-
function
|
|
3053
|
+
function hn(e, t, n, r) {
|
|
2966
3054
|
return {
|
|
2967
3055
|
key: e,
|
|
2968
3056
|
label: t,
|
|
2969
3057
|
type: "custom",
|
|
2970
|
-
render: (i, a, o) => /* @__PURE__ */ Z(
|
|
3058
|
+
render: (i, a, o) => /* @__PURE__ */ Z(I, {
|
|
2971
3059
|
label: t,
|
|
2972
3060
|
children: /* @__PURE__ */ Z("div", {
|
|
2973
3061
|
"data-testid": `config-field-${e}`,
|
|
2974
|
-
children: /* @__PURE__ */ Z(
|
|
3062
|
+
children: /* @__PURE__ */ Z(P, {
|
|
2975
3063
|
options: r ?? [],
|
|
2976
3064
|
value: i ?? "",
|
|
2977
3065
|
onValueChange: a,
|
|
@@ -2985,16 +3073,16 @@ function pn(e, t, n, r) {
|
|
|
2985
3073
|
})
|
|
2986
3074
|
};
|
|
2987
3075
|
}
|
|
2988
|
-
function
|
|
3076
|
+
function gn(e, t, n) {
|
|
2989
3077
|
let r = e && e.length > 0, i = r ? {
|
|
2990
3078
|
key: "object",
|
|
2991
3079
|
label: "Data source",
|
|
2992
3080
|
type: "custom",
|
|
2993
|
-
render: (t, n) => /* @__PURE__ */ Z(
|
|
3081
|
+
render: (t, n) => /* @__PURE__ */ Z(I, {
|
|
2994
3082
|
label: "Data source",
|
|
2995
3083
|
children: /* @__PURE__ */ Z("div", {
|
|
2996
3084
|
"data-testid": "config-field-object",
|
|
2997
|
-
children: /* @__PURE__ */ Z(
|
|
3085
|
+
children: /* @__PURE__ */ Z(P, {
|
|
2998
3086
|
options: e,
|
|
2999
3087
|
value: t ?? "",
|
|
3000
3088
|
onValueChange: n,
|
|
@@ -3011,38 +3099,38 @@ function mn(e, t, n) {
|
|
|
3011
3099
|
type: "input",
|
|
3012
3100
|
placeholder: "Object name"
|
|
3013
3101
|
}, a = r ? {
|
|
3014
|
-
...
|
|
3102
|
+
...hn("categoryField", "Category field", "Select field…", t),
|
|
3015
3103
|
helpText: "Group records by this field (one bar/slice/segment per value).",
|
|
3016
|
-
visibleWhen: (e) =>
|
|
3104
|
+
visibleWhen: (e) => ln(e.type)
|
|
3017
3105
|
} : {
|
|
3018
3106
|
key: "categoryField",
|
|
3019
3107
|
label: "Category field",
|
|
3020
3108
|
type: "input",
|
|
3021
3109
|
placeholder: "e.g. status",
|
|
3022
3110
|
helpText: "Group records by this field (one bar/slice/segment per value).",
|
|
3023
|
-
visibleWhen: (e) =>
|
|
3111
|
+
visibleWhen: (e) => ln(e.type)
|
|
3024
3112
|
}, o = r ? {
|
|
3025
|
-
...
|
|
3113
|
+
...hn("valueField", "Value field", "Select field…", t),
|
|
3026
3114
|
helpText: "Field to aggregate (sum / average / min / max).",
|
|
3027
|
-
visibleWhen: (e) =>
|
|
3115
|
+
visibleWhen: (e) => un(e.type) && (e.aggregate ?? "count") !== "count"
|
|
3028
3116
|
} : {
|
|
3029
3117
|
key: "valueField",
|
|
3030
3118
|
label: "Value field",
|
|
3031
3119
|
type: "input",
|
|
3032
3120
|
placeholder: "e.g. amount",
|
|
3033
3121
|
helpText: "Field to aggregate (sum / average / min / max).",
|
|
3034
|
-
visibleWhen: (e) =>
|
|
3035
|
-
}, s = r ?
|
|
3122
|
+
visibleWhen: (e) => un(e.type) && (e.aggregate ?? "count") !== "count"
|
|
3123
|
+
}, s = r ? hn("rowField", "Field", "Select row field…", t) : {
|
|
3036
3124
|
key: "rowField",
|
|
3037
3125
|
label: "Field",
|
|
3038
3126
|
type: "input",
|
|
3039
3127
|
placeholder: "e.g. owner"
|
|
3040
|
-
}, c = r ?
|
|
3128
|
+
}, c = r ? hn("columnField", "Field", "Select column field…", t) : {
|
|
3041
3129
|
key: "columnField",
|
|
3042
3130
|
label: "Field",
|
|
3043
3131
|
type: "input",
|
|
3044
3132
|
placeholder: "e.g. stage"
|
|
3045
|
-
}, l = r ?
|
|
3133
|
+
}, l = r ? hn("valueField", "Field", "Select value field…", t) : {
|
|
3046
3134
|
key: "valueField",
|
|
3047
3135
|
label: "Field",
|
|
3048
3136
|
type: "input",
|
|
@@ -3052,7 +3140,7 @@ function mn(e, t, n) {
|
|
|
3052
3140
|
breadcrumb: ["Dashboard", {
|
|
3053
3141
|
pivot: "Pivot table",
|
|
3054
3142
|
table: "Table"
|
|
3055
|
-
}[n ?? ""] ?? (
|
|
3143
|
+
}[n ?? ""] ?? (sn(n) ? "Chart" : "Widget")],
|
|
3056
3144
|
sections: [
|
|
3057
3145
|
{
|
|
3058
3146
|
key: "general",
|
|
@@ -3074,7 +3162,7 @@ function mn(e, t, n) {
|
|
|
3074
3162
|
key: "type",
|
|
3075
3163
|
label: "Widget type",
|
|
3076
3164
|
type: "select",
|
|
3077
|
-
options:
|
|
3165
|
+
options: Zt,
|
|
3078
3166
|
defaultValue: "metric"
|
|
3079
3167
|
}
|
|
3080
3168
|
]
|
|
@@ -3092,10 +3180,10 @@ function mn(e, t, n) {
|
|
|
3092
3180
|
key: "aggregate",
|
|
3093
3181
|
label: "Aggregation",
|
|
3094
3182
|
type: "select",
|
|
3095
|
-
options:
|
|
3183
|
+
options: $t,
|
|
3096
3184
|
defaultValue: "count",
|
|
3097
3185
|
helpText: "Count ignores Value field; Sum / Avg / Min / Max require it.",
|
|
3098
|
-
visibleWhen: (e) =>
|
|
3186
|
+
visibleWhen: (e) => un(e.type)
|
|
3099
3187
|
}
|
|
3100
3188
|
]
|
|
3101
3189
|
},
|
|
@@ -3117,14 +3205,14 @@ function mn(e, t, n) {
|
|
|
3117
3205
|
key: "rowSortBy",
|
|
3118
3206
|
label: "Sort by",
|
|
3119
3207
|
type: "icon-group",
|
|
3120
|
-
options:
|
|
3208
|
+
options: pn,
|
|
3121
3209
|
defaultValue: "group"
|
|
3122
3210
|
},
|
|
3123
3211
|
{
|
|
3124
3212
|
key: "rowSortOrder",
|
|
3125
3213
|
label: "Sort order",
|
|
3126
3214
|
type: "icon-group",
|
|
3127
|
-
options:
|
|
3215
|
+
options: mn,
|
|
3128
3216
|
defaultValue: "asc"
|
|
3129
3217
|
},
|
|
3130
3218
|
{
|
|
@@ -3152,14 +3240,14 @@ function mn(e, t, n) {
|
|
|
3152
3240
|
key: "columnSortBy",
|
|
3153
3241
|
label: "Sort by",
|
|
3154
3242
|
type: "icon-group",
|
|
3155
|
-
options:
|
|
3243
|
+
options: pn,
|
|
3156
3244
|
defaultValue: "group"
|
|
3157
3245
|
},
|
|
3158
3246
|
{
|
|
3159
3247
|
key: "columnSortOrder",
|
|
3160
3248
|
label: "Sort order",
|
|
3161
3249
|
type: "icon-group",
|
|
3162
|
-
options:
|
|
3250
|
+
options: mn,
|
|
3163
3251
|
defaultValue: "asc"
|
|
3164
3252
|
},
|
|
3165
3253
|
{
|
|
@@ -3187,7 +3275,7 @@ function mn(e, t, n) {
|
|
|
3187
3275
|
key: "aggregation",
|
|
3188
3276
|
label: "Aggregation",
|
|
3189
3277
|
type: "select",
|
|
3190
|
-
options:
|
|
3278
|
+
options: $t,
|
|
3191
3279
|
defaultValue: "sum"
|
|
3192
3280
|
},
|
|
3193
3281
|
{
|
|
@@ -3202,7 +3290,7 @@ function mn(e, t, n) {
|
|
|
3202
3290
|
key: "chart-axis",
|
|
3203
3291
|
title: "Axis & Series",
|
|
3204
3292
|
collapsible: !0,
|
|
3205
|
-
visibleWhen: (e) =>
|
|
3293
|
+
visibleWhen: (e) => cn(e.type),
|
|
3206
3294
|
fields: [
|
|
3207
3295
|
{
|
|
3208
3296
|
key: "xAxisLabel",
|
|
@@ -3228,7 +3316,7 @@ function mn(e, t, n) {
|
|
|
3228
3316
|
key: "chart-legend",
|
|
3229
3317
|
title: "Display",
|
|
3230
3318
|
collapsible: !0,
|
|
3231
|
-
visibleWhen: (e) => !!e.type &&
|
|
3319
|
+
visibleWhen: (e) => !!e.type && nn.includes(e.type),
|
|
3232
3320
|
fields: [{
|
|
3233
3321
|
key: "showLegend",
|
|
3234
3322
|
label: "Show legend",
|
|
@@ -3280,7 +3368,7 @@ function mn(e, t, n) {
|
|
|
3280
3368
|
title: "Drill-down",
|
|
3281
3369
|
collapsible: !0,
|
|
3282
3370
|
defaultCollapsed: !0,
|
|
3283
|
-
visibleWhen: (e) =>
|
|
3371
|
+
visibleWhen: (e) => dn(e.type),
|
|
3284
3372
|
fields: [{
|
|
3285
3373
|
key: "drillDownEnabled",
|
|
3286
3374
|
label: "Enable drill-down",
|
|
@@ -3291,7 +3379,7 @@ function mn(e, t, n) {
|
|
|
3291
3379
|
key: "drillDownTarget",
|
|
3292
3380
|
label: "Open in",
|
|
3293
3381
|
type: "select",
|
|
3294
|
-
options:
|
|
3382
|
+
options: fn,
|
|
3295
3383
|
defaultValue: "drawer",
|
|
3296
3384
|
visibleWhen: (e) => !!e.drillDownEnabled
|
|
3297
3385
|
}]
|
|
@@ -3317,14 +3405,14 @@ function mn(e, t, n) {
|
|
|
3317
3405
|
key: "colorVariant",
|
|
3318
3406
|
label: "Color variant",
|
|
3319
3407
|
type: "select",
|
|
3320
|
-
options:
|
|
3408
|
+
options: Qt,
|
|
3321
3409
|
defaultValue: "default"
|
|
3322
3410
|
}]
|
|
3323
3411
|
}
|
|
3324
3412
|
]
|
|
3325
3413
|
};
|
|
3326
3414
|
}
|
|
3327
|
-
function
|
|
3415
|
+
function _n(e) {
|
|
3328
3416
|
if (e == null) return "";
|
|
3329
3417
|
if (typeof e == "string") return e;
|
|
3330
3418
|
if (typeof e == "object") {
|
|
@@ -3333,20 +3421,20 @@ function hn(e) {
|
|
|
3333
3421
|
}
|
|
3334
3422
|
return String(e);
|
|
3335
3423
|
}
|
|
3336
|
-
function
|
|
3424
|
+
function vn(e) {
|
|
3337
3425
|
let t = e.type, n = { ...e };
|
|
3338
|
-
return
|
|
3426
|
+
return ln(t) || delete n.categoryField, un(t) ? (n.aggregate ?? "count") === "count" && delete n.valueField : (delete n.valueField, delete n.aggregate), cn(t) || (delete n.xAxisLabel, delete n.yAxisLabel), t === "pivot" ? (delete n.aggregate, delete n.categoryField) : (delete n.rowField, delete n.columnField, delete n.aggregation, delete n.rowSortBy, delete n.rowSortOrder, delete n.columnSortBy, delete n.columnSortOrder, delete n.showRowLabels, delete n.showRowTotals, delete n.showColumnLabels, delete n.showColumnTotals, delete n.format), t !== "table" && (delete n.searchable, delete n.pagination), dn(t) || (delete n.drillDownEnabled, delete n.drillDownTarget), n;
|
|
3339
3427
|
}
|
|
3340
|
-
function
|
|
3341
|
-
let { draft: c, isDirty: l, updateField: u, discard: d } = se(
|
|
3428
|
+
function yn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, headerExtra: a, availableObjects: o, availableFields: s }) {
|
|
3429
|
+
let { draft: c, isDirty: l, updateField: u, discard: d } = se(U.useMemo(() => ({
|
|
3342
3430
|
...n,
|
|
3343
|
-
title: typeof n.title == "object" ?
|
|
3344
|
-
description: typeof n.description == "object" ?
|
|
3431
|
+
title: typeof n.title == "object" ? _n(n.title) : n.title,
|
|
3432
|
+
description: typeof n.description == "object" ? _n(n.description) : n.description
|
|
3345
3433
|
}), [n]), { onUpdate: i });
|
|
3346
|
-
return /* @__PURE__ */ Z(
|
|
3434
|
+
return /* @__PURE__ */ Z(F, {
|
|
3347
3435
|
open: e,
|
|
3348
3436
|
onClose: t,
|
|
3349
|
-
schema:
|
|
3437
|
+
schema: U.useMemo(() => gn(o, s, c.type), [
|
|
3350
3438
|
o,
|
|
3351
3439
|
s,
|
|
3352
3440
|
c.type
|
|
@@ -3354,19 +3442,19 @@ function _n({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, heade
|
|
|
3354
3442
|
draft: c,
|
|
3355
3443
|
isDirty: l,
|
|
3356
3444
|
onFieldChange: u,
|
|
3357
|
-
onSave: () => r(
|
|
3445
|
+
onSave: () => r(vn(c)),
|
|
3358
3446
|
onDiscard: d,
|
|
3359
3447
|
headerExtra: a
|
|
3360
3448
|
});
|
|
3361
3449
|
}
|
|
3362
3450
|
//#endregion
|
|
3363
3451
|
//#region src/DashboardWithConfig.tsx
|
|
3364
|
-
function
|
|
3365
|
-
let [c, l] =
|
|
3366
|
-
|
|
3452
|
+
function bn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh: i, recordCount: a, defaultConfigOpen: o = !1, className: s }) {
|
|
3453
|
+
let [c, l] = J(o), [u, d] = J(null), [f, p] = J(e), [m, h] = J(0);
|
|
3454
|
+
K(() => {
|
|
3367
3455
|
p(e), h((e) => e + 1);
|
|
3368
3456
|
}, [e]);
|
|
3369
|
-
let g =
|
|
3457
|
+
let g = U.useMemo(() => {
|
|
3370
3458
|
if (!u || !f.widgets) return null;
|
|
3371
3459
|
let e = f.widgets.find((e) => (e.id || e.title) === u);
|
|
3372
3460
|
if (!e) return null;
|
|
@@ -3388,11 +3476,11 @@ function vn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3388
3476
|
layoutW: e.layout?.w ?? 1,
|
|
3389
3477
|
layoutH: e.layout?.h ?? 1
|
|
3390
3478
|
};
|
|
3391
|
-
}, [u, m]), _ =
|
|
3479
|
+
}, [u, m]), _ = G((e) => {
|
|
3392
3480
|
d(e), l(!0);
|
|
3393
|
-
}, []), v =
|
|
3481
|
+
}, []), v = G(() => {
|
|
3394
3482
|
d(null);
|
|
3395
|
-
}, []), y =
|
|
3483
|
+
}, []), y = G((e, t) => {
|
|
3396
3484
|
u && p((n) => n.widgets ? {
|
|
3397
3485
|
...n,
|
|
3398
3486
|
widgets: n.widgets.map((n) => {
|
|
@@ -3433,7 +3521,7 @@ function vn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3433
3521
|
};
|
|
3434
3522
|
})
|
|
3435
3523
|
} : n);
|
|
3436
|
-
}, [u]), b =
|
|
3524
|
+
}, [u]), b = G((e) => {
|
|
3437
3525
|
if (u && r) {
|
|
3438
3526
|
let { drillDownEnabled: t, drillDownTarget: n, ...i } = e, a = { ...i };
|
|
3439
3527
|
(t || n) && (a.options = {
|
|
@@ -3446,24 +3534,24 @@ function vn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3446
3534
|
}), r(u, a);
|
|
3447
3535
|
}
|
|
3448
3536
|
d(null), h((e) => e + 1);
|
|
3449
|
-
}, [u, r]), x =
|
|
3537
|
+
}, [u, r]), x = G(() => {
|
|
3450
3538
|
l((e) => !e), d(null);
|
|
3451
3539
|
}, []);
|
|
3452
3540
|
return /* @__PURE__ */ Q("div", {
|
|
3453
|
-
className:
|
|
3541
|
+
className: H("flex h-full w-full", s),
|
|
3454
3542
|
"data-testid": "dashboard-with-config",
|
|
3455
3543
|
children: [/* @__PURE__ */ Q("div", {
|
|
3456
3544
|
className: "flex-1 min-w-0 overflow-auto relative",
|
|
3457
3545
|
children: [/* @__PURE__ */ Z("div", {
|
|
3458
3546
|
className: "absolute top-2 right-2 z-10",
|
|
3459
|
-
children: /* @__PURE__ */ Q(
|
|
3547
|
+
children: /* @__PURE__ */ Q(k, {
|
|
3460
3548
|
size: "sm",
|
|
3461
3549
|
variant: c ? "default" : "outline",
|
|
3462
3550
|
onClick: x,
|
|
3463
3551
|
"data-testid": "dashboard-config-toggle",
|
|
3464
|
-
children: [/* @__PURE__ */ Z(
|
|
3552
|
+
children: [/* @__PURE__ */ Z(Ce, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
|
|
3465
3553
|
})
|
|
3466
|
-
}), /* @__PURE__ */ Z(
|
|
3554
|
+
}), /* @__PURE__ */ Z(Tt, {
|
|
3467
3555
|
schema: f,
|
|
3468
3556
|
onRefresh: i,
|
|
3469
3557
|
recordCount: a,
|
|
@@ -3473,13 +3561,13 @@ function vn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3473
3561
|
})]
|
|
3474
3562
|
}), c && /* @__PURE__ */ Z("div", {
|
|
3475
3563
|
className: "relative shrink-0",
|
|
3476
|
-
children: u && g ? /* @__PURE__ */ Z(
|
|
3564
|
+
children: u && g ? /* @__PURE__ */ Z(yn, {
|
|
3477
3565
|
open: !0,
|
|
3478
3566
|
onClose: v,
|
|
3479
3567
|
config: g,
|
|
3480
3568
|
onSave: b,
|
|
3481
3569
|
onFieldChange: y
|
|
3482
|
-
}) : /* @__PURE__ */ Z(
|
|
3570
|
+
}) : /* @__PURE__ */ Z(Xt, {
|
|
3483
3571
|
open: !0,
|
|
3484
3572
|
onClose: () => l(!1),
|
|
3485
3573
|
config: t,
|
|
@@ -3488,7 +3576,7 @@ function vn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3488
3576
|
})]
|
|
3489
3577
|
});
|
|
3490
3578
|
}
|
|
3491
|
-
e.register("dashboard",
|
|
3579
|
+
e.register("dashboard", Tt, {
|
|
3492
3580
|
namespace: "view",
|
|
3493
3581
|
label: "Dashboard",
|
|
3494
3582
|
category: "Complex",
|
|
@@ -3516,7 +3604,7 @@ e.register("dashboard", wt, {
|
|
|
3516
3604
|
columns: 3,
|
|
3517
3605
|
widgets: []
|
|
3518
3606
|
}
|
|
3519
|
-
}), e.register("metric",
|
|
3607
|
+
}), e.register("metric", Lt, {
|
|
3520
3608
|
namespace: "plugin-dashboard",
|
|
3521
3609
|
label: "Metric Widget",
|
|
3522
3610
|
category: "Dashboard",
|
|
@@ -3529,7 +3617,7 @@ e.register("dashboard", wt, {
|
|
|
3529
3617
|
type: "string",
|
|
3530
3618
|
label: "Value"
|
|
3531
3619
|
}]
|
|
3532
|
-
}), e.register("metric-card",
|
|
3620
|
+
}), e.register("metric-card", zt, {
|
|
3533
3621
|
namespace: "plugin-dashboard",
|
|
3534
3622
|
label: "Metric Card",
|
|
3535
3623
|
category: "Dashboard",
|
|
@@ -3584,7 +3672,7 @@ e.register("dashboard", wt, {
|
|
|
3584
3672
|
title: "Metric",
|
|
3585
3673
|
value: "0"
|
|
3586
3674
|
}
|
|
3587
|
-
}), e.register("object-metric",
|
|
3675
|
+
}), e.register("object-metric", Bt, {
|
|
3588
3676
|
namespace: "plugin-dashboard",
|
|
3589
3677
|
label: "Object Metric",
|
|
3590
3678
|
category: "Dashboard",
|
|
@@ -3613,7 +3701,7 @@ e.register("dashboard", wt, {
|
|
|
3613
3701
|
}
|
|
3614
3702
|
],
|
|
3615
3703
|
defaultProps: { label: "Metric" }
|
|
3616
|
-
}), e.register("pivot",
|
|
3704
|
+
}), e.register("pivot", qt, {
|
|
3617
3705
|
namespace: "plugin-dashboard",
|
|
3618
3706
|
label: "Pivot Table",
|
|
3619
3707
|
category: "Dashboard",
|
|
@@ -3692,7 +3780,7 @@ e.register("dashboard", wt, {
|
|
|
3692
3780
|
aggregation: "sum",
|
|
3693
3781
|
data: []
|
|
3694
3782
|
}
|
|
3695
|
-
}), e.register("object-pivot",
|
|
3783
|
+
}), e.register("object-pivot", Jt, {
|
|
3696
3784
|
namespace: "plugin-dashboard",
|
|
3697
3785
|
label: "Object Pivot Table",
|
|
3698
3786
|
category: "Dashboard",
|
|
@@ -3781,7 +3869,7 @@ e.register("dashboard", wt, {
|
|
|
3781
3869
|
valueField: "",
|
|
3782
3870
|
aggregation: "sum"
|
|
3783
3871
|
}
|
|
3784
|
-
}), e.register("dashboard-grid",
|
|
3872
|
+
}), e.register("dashboard-grid", At, {
|
|
3785
3873
|
namespace: "plugin-dashboard",
|
|
3786
3874
|
label: "Dashboard Grid (Editable)",
|
|
3787
3875
|
category: "Complex",
|
|
@@ -3799,7 +3887,7 @@ e.register("dashboard", wt, {
|
|
|
3799
3887
|
title: "Dashboard",
|
|
3800
3888
|
widgets: []
|
|
3801
3889
|
}
|
|
3802
|
-
}), e.register("object-data-table",
|
|
3890
|
+
}), e.register("object-data-table", it, {
|
|
3803
3891
|
namespace: "plugin-dashboard",
|
|
3804
3892
|
label: "Object Data Table",
|
|
3805
3893
|
category: "Dashboard",
|
|
@@ -3837,18 +3925,18 @@ e.register("dashboard", wt, {
|
|
|
3837
3925
|
pagination: !1
|
|
3838
3926
|
}
|
|
3839
3927
|
});
|
|
3840
|
-
var
|
|
3841
|
-
DashboardRenderer:
|
|
3842
|
-
DashboardGridLayout:
|
|
3843
|
-
MetricWidget:
|
|
3844
|
-
MetricCard:
|
|
3845
|
-
ObjectMetricWidget:
|
|
3846
|
-
PivotTable:
|
|
3847
|
-
ObjectPivotTable:
|
|
3848
|
-
ObjectDataTable:
|
|
3849
|
-
DashboardConfigPanel:
|
|
3850
|
-
WidgetConfigPanel:
|
|
3851
|
-
DashboardWithConfig:
|
|
3928
|
+
var xn = {
|
|
3929
|
+
DashboardRenderer: Tt,
|
|
3930
|
+
DashboardGridLayout: At,
|
|
3931
|
+
MetricWidget: Lt,
|
|
3932
|
+
MetricCard: zt,
|
|
3933
|
+
ObjectMetricWidget: Bt,
|
|
3934
|
+
PivotTable: qt,
|
|
3935
|
+
ObjectPivotTable: Jt,
|
|
3936
|
+
ObjectDataTable: it,
|
|
3937
|
+
DashboardConfigPanel: Xt,
|
|
3938
|
+
WidgetConfigPanel: yn,
|
|
3939
|
+
DashboardWithConfig: bn
|
|
3852
3940
|
};
|
|
3853
3941
|
//#endregion
|
|
3854
|
-
export {
|
|
3942
|
+
export { Xt as DashboardConfigPanel, At as DashboardGridLayout, Tt as DashboardRenderer, bn as DashboardWithConfig, ot as DrillDownDrawer, zt as MetricCard, Lt as MetricWidget, it as ObjectDataTable, Bt as ObjectMetricWidget, Jt as ObjectPivotTable, qt as PivotTable, yn as WidgetConfigPanel, xn as dashboardComponents };
|