@object-ui/plugin-dashboard 6.2.3 → 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 +220 -0
- package/dist/{packages/plugin-dashboard/src/DashboardConfigPanel.d.ts → DashboardConfigPanel.d.ts} +2 -1
- package/dist/DashboardConfigPanel.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/DashboardGridLayout.d.ts → DashboardGridLayout.d.ts} +1 -1
- package/dist/DashboardGridLayout.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/DashboardRenderer.d.ts → DashboardRenderer.d.ts} +2 -2
- package/dist/DashboardRenderer.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/DashboardWithConfig.d.ts → DashboardWithConfig.d.ts} +10 -2
- package/dist/DashboardWithConfig.d.ts.map +1 -0
- package/dist/DatasetWidget.d.ts +33 -0
- package/dist/DatasetWidget.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/DrillDownDrawer.d.ts → DrillDownDrawer.d.ts} +7 -2
- package/dist/DrillDownDrawer.d.ts.map +1 -0
- package/dist/MetricCard.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/MetricWidget.d.ts → MetricWidget.d.ts} +7 -1
- package/dist/MetricWidget.d.ts.map +1 -0
- package/dist/ObjectDataTable.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/ObjectMetricWidget.d.ts → ObjectMetricWidget.d.ts} +3 -1
- package/dist/ObjectMetricWidget.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/ObjectPivotTable.d.ts → ObjectPivotTable.d.ts} +1 -1
- package/dist/ObjectPivotTable.d.ts.map +1 -0
- package/dist/OpenInListButton.d.ts +12 -0
- package/dist/OpenInListButton.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/PivotTable.d.ts → PivotTable.d.ts} +2 -2
- package/dist/PivotTable.d.ts.map +1 -0
- package/dist/RecordDetailDrawer.d.ts +23 -0
- package/dist/RecordDetailDrawer.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/WidgetConfigPanel.d.ts → WidgetConfigPanel.d.ts} +1 -1
- package/dist/WidgetConfigPanel.d.ts.map +1 -0
- package/dist/index.d.ts +27 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1655 -1007
- package/dist/index.umd.cjs +2 -1
- package/dist/recordFields.d.ts +70 -0
- package/dist/recordFields.d.ts.map +1 -0
- package/dist/{packages/plugin-dashboard/src/utils.d.ts → utils.d.ts} +2 -2
- package/dist/utils.d.ts.map +1 -0
- package/package.json +12 -12
- package/dist/packages/plugin-dashboard/src/DashboardConfigPanel.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/DashboardConfigPanel.stories.d.ts +0 -14
- package/dist/packages/plugin-dashboard/src/DashboardConfigPanel.stories.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/DashboardGridLayout.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/DashboardRenderer.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/DashboardRenderer.stories.d.ts +0 -24
- package/dist/packages/plugin-dashboard/src/DashboardRenderer.stories.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/DashboardWithConfig.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/DrillDownDrawer.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/MetricCard.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/MetricWidget.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/ObjectDataTable.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/ObjectMetricWidget.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/ObjectPivotTable.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/PivotTable.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/WidgetConfigPanel.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/index.d.ts +0 -27
- package/dist/packages/plugin-dashboard/src/index.d.ts.map +0 -1
- package/dist/packages/plugin-dashboard/src/utils.d.ts.map +0 -1
- /package/dist/{packages/plugin-dashboard/src/MetricCard.d.ts → MetricCard.d.ts} +0 -0
- /package/dist/{packages/plugin-dashboard/src/ObjectDataTable.d.ts → ObjectDataTable.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ComponentRegistry as e,
|
|
2
|
-
import { SchemaRenderer as
|
|
3
|
-
import { createSafeTranslation as
|
|
4
|
-
import { Button as
|
|
5
|
-
import * as
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { AlertCircle as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
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";
|
|
13
14
|
import "react-grid-layout/css/styles.css";
|
|
14
|
-
import { formatCurrency as Ce, formatDate as we, formatPercent as Te, getCellRenderer as Ee, resolveCellRendererType as De } from "@object-ui/fields";
|
|
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,
|
|
@@ -37,16 +37,897 @@ function Oe(e, t) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
+
//#region src/recordFields.tsx
|
|
41
|
+
var Ge = new Set([
|
|
42
|
+
"id",
|
|
43
|
+
"organization_id",
|
|
44
|
+
"tenant_id",
|
|
45
|
+
"created_at",
|
|
46
|
+
"updated_at",
|
|
47
|
+
"created_by",
|
|
48
|
+
"updated_by",
|
|
49
|
+
"deleted_at",
|
|
50
|
+
"deleted_by",
|
|
51
|
+
"version",
|
|
52
|
+
"_id",
|
|
53
|
+
"__typename"
|
|
54
|
+
]);
|
|
55
|
+
function Ke(e, t) {
|
|
56
|
+
return t && (t.isSystem === !0 || t.system === !0) ? !0 : Ge.has(e);
|
|
57
|
+
}
|
|
58
|
+
var qe = new Set([
|
|
59
|
+
"select",
|
|
60
|
+
"picklist",
|
|
61
|
+
"dropdown",
|
|
62
|
+
"status"
|
|
63
|
+
]), Je = new Set([
|
|
64
|
+
"currency",
|
|
65
|
+
"money",
|
|
66
|
+
"number",
|
|
67
|
+
"integer",
|
|
68
|
+
"decimal",
|
|
69
|
+
"float",
|
|
70
|
+
"percent",
|
|
71
|
+
"percentage"
|
|
72
|
+
]);
|
|
73
|
+
function Ye(e) {
|
|
74
|
+
let t = {}, n = e?.fields;
|
|
75
|
+
if (!n) return t;
|
|
76
|
+
if (Array.isArray(n)) for (let e of n) e?.name && (t[e.name] = e);
|
|
77
|
+
else for (let [e, r] of Object.entries(n)) t[e] = {
|
|
78
|
+
name: e,
|
|
79
|
+
...r
|
|
80
|
+
};
|
|
81
|
+
return t;
|
|
82
|
+
}
|
|
83
|
+
function Xe(e) {
|
|
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 && qe.has(r?.type) && (c = c.map((e) => {
|
|
86
|
+
if (e == null) return e;
|
|
87
|
+
let n = typeof e == "object" ? e.value : e, r = typeof e == "object" && e.label || String(n);
|
|
88
|
+
return {
|
|
89
|
+
value: n,
|
|
90
|
+
label: a(i, t, String(n), r),
|
|
91
|
+
color: typeof e == "object" ? e.color : void 0
|
|
92
|
+
};
|
|
93
|
+
})), {
|
|
94
|
+
name: t,
|
|
95
|
+
label: n,
|
|
96
|
+
type: o.type ?? r?.type,
|
|
97
|
+
options: c,
|
|
98
|
+
referenceTo: s,
|
|
99
|
+
format: o.format ?? r?.format,
|
|
100
|
+
currency: o.currency ?? r?.currency ?? r?.defaultCurrency,
|
|
101
|
+
decimals: o.decimals ?? r?.decimals ?? r?.precision ?? r?.scale
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function Ze(e) {
|
|
105
|
+
return Je.has(e.type) || typeof e.format == "string" && /^[\$¥€£]|%$|0/.test(e.format);
|
|
106
|
+
}
|
|
107
|
+
function Qe(e, t, n) {
|
|
108
|
+
if (e == null || e === "") return "";
|
|
109
|
+
let r = t.format;
|
|
110
|
+
if (typeof r == "string" && /^\$|¥|€|£/.test(r) && typeof e == "number") {
|
|
111
|
+
let i = {
|
|
112
|
+
$: "USD",
|
|
113
|
+
"¥": "JPY",
|
|
114
|
+
"€": "EUR",
|
|
115
|
+
"£": "GBP"
|
|
116
|
+
}[r[0]];
|
|
117
|
+
return Ie(e, t.currency || i || n);
|
|
118
|
+
}
|
|
119
|
+
if (typeof r == "string" && /%/.test(r) && typeof e == "number") {
|
|
120
|
+
let t = (r.match(/0\.(0+)%/) || [, ""])[1].length;
|
|
121
|
+
return Re((e > 1 ? e / 100 : e) * 100, t);
|
|
122
|
+
}
|
|
123
|
+
return typeof r == "string" && /[YMDHms]/.test(r) ? Le(e, r) : /* @__PURE__ */ Z(ze(Be(t)), {
|
|
124
|
+
value: e,
|
|
125
|
+
field: t
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/RecordDetailDrawer.tsx
|
|
130
|
+
var $e = [
|
|
131
|
+
"name",
|
|
132
|
+
"title",
|
|
133
|
+
"label",
|
|
134
|
+
"subject",
|
|
135
|
+
"display_name",
|
|
136
|
+
"full_name"
|
|
137
|
+
];
|
|
138
|
+
function et(e, t) {
|
|
139
|
+
if (t && t.trim()) return t;
|
|
140
|
+
for (let t of $e) {
|
|
141
|
+
let n = e[t];
|
|
142
|
+
if (typeof n == "string" && n.trim()) return n;
|
|
143
|
+
}
|
|
144
|
+
let n = e.id ?? e._id;
|
|
145
|
+
return n == null ? "Record" : String(n);
|
|
146
|
+
}
|
|
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
|
+
if (!e) return [];
|
|
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
|
+
accessorKey: n,
|
|
154
|
+
label: o,
|
|
155
|
+
def: r,
|
|
156
|
+
objectName: t,
|
|
157
|
+
fieldOptionLabel: c
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
key: n,
|
|
161
|
+
label: o,
|
|
162
|
+
node: Qe(e[n], u, l),
|
|
163
|
+
numeric: Ze(u)
|
|
164
|
+
};
|
|
165
|
+
});
|
|
166
|
+
}, [
|
|
167
|
+
e,
|
|
168
|
+
n,
|
|
169
|
+
t,
|
|
170
|
+
r,
|
|
171
|
+
s,
|
|
172
|
+
c,
|
|
173
|
+
l
|
|
174
|
+
]);
|
|
175
|
+
if (!e) return null;
|
|
176
|
+
let d = et(e, i), f = /* @__PURE__ */ Z("dl", {
|
|
177
|
+
className: "divide-y divide-border/60",
|
|
178
|
+
"data-testid": "record-detail-body",
|
|
179
|
+
children: u.map((e) => /* @__PURE__ */ Q("div", {
|
|
180
|
+
className: "grid grid-cols-3 gap-3 py-2.5",
|
|
181
|
+
children: [/* @__PURE__ */ Z("dt", {
|
|
182
|
+
className: "text-xs font-medium text-muted-foreground self-center",
|
|
183
|
+
children: e.label
|
|
184
|
+
}), /* @__PURE__ */ Z("dd", {
|
|
185
|
+
className: `col-span-2 text-sm break-words ${e.numeric ? "tabular-nums" : ""}`,
|
|
186
|
+
children: e.node === "" || e.node == null ? /* @__PURE__ */ Z("span", {
|
|
187
|
+
className: "text-muted-foreground/60",
|
|
188
|
+
children: "—"
|
|
189
|
+
}) : e.node
|
|
190
|
+
})]
|
|
191
|
+
}, e.key))
|
|
192
|
+
});
|
|
193
|
+
return a === "dialog" ? /* @__PURE__ */ Z(te, {
|
|
194
|
+
open: !0,
|
|
195
|
+
onOpenChange: (e) => !e && o(),
|
|
196
|
+
children: /* @__PURE__ */ Q(L, {
|
|
197
|
+
className: "max-w-2xl",
|
|
198
|
+
children: [/* @__PURE__ */ Z(R, { children: /* @__PURE__ */ Z(ne, { children: d }) }), /* @__PURE__ */ Z("div", {
|
|
199
|
+
className: "max-h-[70vh] overflow-auto",
|
|
200
|
+
children: f
|
|
201
|
+
})]
|
|
202
|
+
})
|
|
203
|
+
}) : /* @__PURE__ */ Z(z, {
|
|
204
|
+
open: !0,
|
|
205
|
+
onOpenChange: (e) => !e && o(),
|
|
206
|
+
children: /* @__PURE__ */ Q(ie, {
|
|
207
|
+
side: "right",
|
|
208
|
+
className: "w-full sm:max-w-md md:max-w-lg flex flex-col",
|
|
209
|
+
children: [/* @__PURE__ */ Z(B, { children: /* @__PURE__ */ Z(ae, { children: d }) }), /* @__PURE__ */ Z("div", {
|
|
210
|
+
className: "flex-1 overflow-auto mt-2 pr-1",
|
|
211
|
+
children: f
|
|
212
|
+
})]
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/ObjectDataTable.tsx
|
|
218
|
+
function nt(e) {
|
|
219
|
+
return e.map((e) => typeof e == "string" ? {
|
|
220
|
+
header: e.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (e) => e.toUpperCase()),
|
|
221
|
+
accessorKey: e
|
|
222
|
+
} : e);
|
|
223
|
+
}
|
|
224
|
+
function rt(e, t) {
|
|
225
|
+
if (!t?.fields) return [];
|
|
226
|
+
let n = {};
|
|
227
|
+
if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
|
|
228
|
+
else for (let [e, r] of Object.entries(t.fields)) n[e] = {
|
|
229
|
+
name: e,
|
|
230
|
+
...r
|
|
231
|
+
};
|
|
232
|
+
let r = (e) => e === "lookup" || e === "reference" || e === "master_detail" || e === "user" || e === "owner", i = Array.isArray(e.columns) ? e.columns : [], a = /* @__PURE__ */ new Set();
|
|
233
|
+
if (i.length > 0) {
|
|
234
|
+
let e = i.map((e) => typeof e == "string" ? e : e.accessorKey || e.name).filter(Boolean);
|
|
235
|
+
for (let t of e) {
|
|
236
|
+
let e = n[t];
|
|
237
|
+
e && r(e.type) && a.add(t);
|
|
238
|
+
}
|
|
239
|
+
} else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
|
|
240
|
+
return Array.from(a);
|
|
241
|
+
}
|
|
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
|
+
try {
|
|
245
|
+
let { t: e } = E(), t = e("dashboard.noDataAvailable");
|
|
246
|
+
t && t !== "dashboard.noDataAvailable" && (u = t);
|
|
247
|
+
let n = e("dashboard.noDataSourceFor");
|
|
248
|
+
n && n !== "dashboard.noDataSourceFor" && (p = n);
|
|
249
|
+
} catch {}
|
|
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
|
+
j(e ?? null);
|
|
252
|
+
}, []);
|
|
253
|
+
K(() => {
|
|
254
|
+
let t = !0;
|
|
255
|
+
return e.objectName && !o && (!e.data || e.data.length === 0) ? (async () => {
|
|
256
|
+
if (!a || !e.objectName) {
|
|
257
|
+
t && S(!1);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
t && (S(!0), w(null));
|
|
261
|
+
try {
|
|
262
|
+
let n;
|
|
263
|
+
if (typeof a.find == "function") {
|
|
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
|
+
} else return;
|
|
267
|
+
t && _(n);
|
|
268
|
+
} catch (e) {
|
|
269
|
+
console.error("[ObjectDataTable] Fetch error:", e), t && w(e instanceof Error ? e.message : "Failed to load data");
|
|
270
|
+
} finally {
|
|
271
|
+
t && S(!1);
|
|
272
|
+
}
|
|
273
|
+
})() : t && S(!1), () => {
|
|
274
|
+
t = !1;
|
|
275
|
+
};
|
|
276
|
+
}, [
|
|
277
|
+
e.objectName,
|
|
278
|
+
a,
|
|
279
|
+
o,
|
|
280
|
+
e.data,
|
|
281
|
+
e.filter,
|
|
282
|
+
y
|
|
283
|
+
]), K(() => {
|
|
284
|
+
let t = !0;
|
|
285
|
+
if (!(!a || !e.objectName || typeof a.getObjectSchema != "function")) return a.getObjectSchema(e.objectName).then((e) => {
|
|
286
|
+
t && b(e);
|
|
287
|
+
}).catch(() => {}), () => {
|
|
288
|
+
t = !1;
|
|
289
|
+
};
|
|
290
|
+
}, [e.objectName, a]);
|
|
291
|
+
let N = o || e.data || m, P = Array.isArray(N) ? N : [], F = q(() => {
|
|
292
|
+
let t = e.objectName, n = {};
|
|
293
|
+
if (y?.fields) {
|
|
294
|
+
let e = y.fields;
|
|
295
|
+
if (Array.isArray(e)) for (let t of e) t?.name && (n[t.name] = t);
|
|
296
|
+
else for (let [t, r] of Object.entries(e)) n[t] = {
|
|
297
|
+
name: t,
|
|
298
|
+
...r
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
let i = (e) => {
|
|
302
|
+
let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
|
|
303
|
+
return t ? c(t, e, n) : n;
|
|
304
|
+
}, a = (e) => {
|
|
305
|
+
let i = Xe({
|
|
306
|
+
accessorKey: e.accessorKey,
|
|
307
|
+
label: e.header,
|
|
308
|
+
def: n[e.accessorKey],
|
|
309
|
+
objectName: t,
|
|
310
|
+
fieldOptionLabel: l,
|
|
311
|
+
overrides: {
|
|
312
|
+
type: e.type,
|
|
313
|
+
format: e.format,
|
|
314
|
+
options: e.options,
|
|
315
|
+
referenceTo: e.referenceTo,
|
|
316
|
+
currency: e.currency,
|
|
317
|
+
decimals: e.decimals
|
|
318
|
+
}
|
|
319
|
+
}), a = e.align ?? (Ze(i) ? "right" : void 0);
|
|
320
|
+
if (typeof e.cell == "function") return {
|
|
321
|
+
...e,
|
|
322
|
+
...i,
|
|
323
|
+
align: a
|
|
324
|
+
};
|
|
325
|
+
let o = (e) => Qe(e, i, r);
|
|
326
|
+
return {
|
|
327
|
+
...e,
|
|
328
|
+
...i,
|
|
329
|
+
align: a,
|
|
330
|
+
cell: o
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
if (e.columns && e.columns.length > 0) {
|
|
334
|
+
let n = nt(e.columns);
|
|
335
|
+
return (t ? n.map((e) => ({
|
|
336
|
+
...e,
|
|
337
|
+
header: c(t, e.accessorKey, e.header)
|
|
338
|
+
})) : n).map(a);
|
|
339
|
+
}
|
|
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
|
+
header: i(e),
|
|
342
|
+
accessorKey: e
|
|
343
|
+
}));
|
|
344
|
+
}, [
|
|
345
|
+
e.columns,
|
|
346
|
+
e.objectName,
|
|
347
|
+
P,
|
|
348
|
+
y,
|
|
349
|
+
c,
|
|
350
|
+
l,
|
|
351
|
+
r
|
|
352
|
+
]);
|
|
353
|
+
if (x && P.length === 0) return /* @__PURE__ */ Z("div", {
|
|
354
|
+
className: H("overflow-auto", n),
|
|
355
|
+
"data-testid": "table-loading",
|
|
356
|
+
children: /* @__PURE__ */ Q("div", {
|
|
357
|
+
className: "space-y-2 p-2",
|
|
358
|
+
children: [/* @__PURE__ */ Q("div", {
|
|
359
|
+
className: "flex gap-2",
|
|
360
|
+
children: [
|
|
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
|
+
]
|
|
366
|
+
}), [
|
|
367
|
+
1,
|
|
368
|
+
2,
|
|
369
|
+
3,
|
|
370
|
+
4
|
|
371
|
+
].map((e) => /* @__PURE__ */ Q("div", {
|
|
372
|
+
className: "flex gap-2",
|
|
373
|
+
children: [
|
|
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
|
+
]
|
|
379
|
+
}, e))]
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
if (C) return /* @__PURE__ */ Z("div", {
|
|
383
|
+
className: H("overflow-auto", n),
|
|
384
|
+
"data-testid": "table-error",
|
|
385
|
+
children: /* @__PURE__ */ Q("div", {
|
|
386
|
+
className: "flex flex-col items-center justify-center py-8 text-destructive",
|
|
387
|
+
"data-testid": "table-error-message",
|
|
388
|
+
children: [/* @__PURE__ */ Q("svg", {
|
|
389
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
390
|
+
className: "h-8 w-8 mb-2 opacity-60",
|
|
391
|
+
viewBox: "0 0 24 24",
|
|
392
|
+
fill: "none",
|
|
393
|
+
stroke: "currentColor",
|
|
394
|
+
strokeWidth: "1.5",
|
|
395
|
+
strokeLinecap: "round",
|
|
396
|
+
strokeLinejoin: "round",
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ Z("circle", {
|
|
399
|
+
cx: "12",
|
|
400
|
+
cy: "12",
|
|
401
|
+
r: "10"
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ Z("line", {
|
|
404
|
+
x1: "12",
|
|
405
|
+
y1: "8",
|
|
406
|
+
x2: "12",
|
|
407
|
+
y2: "12"
|
|
408
|
+
}),
|
|
409
|
+
/* @__PURE__ */ Z("line", {
|
|
410
|
+
x1: "12",
|
|
411
|
+
y1: "16",
|
|
412
|
+
x2: "12.01",
|
|
413
|
+
y2: "16"
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
}), /* @__PURE__ */ Z("p", {
|
|
417
|
+
className: "text-xs",
|
|
418
|
+
children: C
|
|
419
|
+
})]
|
|
420
|
+
})
|
|
421
|
+
});
|
|
422
|
+
if (!a && e.objectName && P.length === 0) return /* @__PURE__ */ Z("div", {
|
|
423
|
+
className: H("overflow-auto", n),
|
|
424
|
+
children: /* @__PURE__ */ Z("div", {
|
|
425
|
+
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
426
|
+
children: /* @__PURE__ */ Q("p", {
|
|
427
|
+
className: "text-xs",
|
|
428
|
+
children: [
|
|
429
|
+
p,
|
|
430
|
+
" “",
|
|
431
|
+
e.objectName,
|
|
432
|
+
"”"
|
|
433
|
+
]
|
|
434
|
+
})
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
if (P.length === 0) return /* @__PURE__ */ Z("div", {
|
|
438
|
+
className: H("overflow-auto", n),
|
|
439
|
+
"data-testid": "table-empty-state",
|
|
440
|
+
children: /* @__PURE__ */ Q("div", {
|
|
441
|
+
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
442
|
+
children: [/* @__PURE__ */ Q("svg", {
|
|
443
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
444
|
+
className: "h-8 w-8 mb-2 opacity-40",
|
|
445
|
+
viewBox: "0 0 24 24",
|
|
446
|
+
fill: "none",
|
|
447
|
+
stroke: "currentColor",
|
|
448
|
+
strokeWidth: "1.5",
|
|
449
|
+
strokeLinecap: "round",
|
|
450
|
+
strokeLinejoin: "round",
|
|
451
|
+
children: [
|
|
452
|
+
/* @__PURE__ */ Z("rect", {
|
|
453
|
+
x: "3",
|
|
454
|
+
y: "3",
|
|
455
|
+
width: "18",
|
|
456
|
+
height: "18",
|
|
457
|
+
rx: "2",
|
|
458
|
+
ry: "2"
|
|
459
|
+
}),
|
|
460
|
+
/* @__PURE__ */ Z("line", {
|
|
461
|
+
x1: "3",
|
|
462
|
+
y1: "9",
|
|
463
|
+
x2: "21",
|
|
464
|
+
y2: "9"
|
|
465
|
+
}),
|
|
466
|
+
/* @__PURE__ */ Z("line", {
|
|
467
|
+
x1: "9",
|
|
468
|
+
y1: "21",
|
|
469
|
+
x2: "9",
|
|
470
|
+
y2: "9"
|
|
471
|
+
})
|
|
472
|
+
]
|
|
473
|
+
}), /* @__PURE__ */ Z("p", {
|
|
474
|
+
className: "text-xs",
|
|
475
|
+
children: u
|
|
476
|
+
})]
|
|
477
|
+
})
|
|
478
|
+
});
|
|
479
|
+
let I = {
|
|
480
|
+
...e,
|
|
481
|
+
type: "data-table",
|
|
482
|
+
data: P,
|
|
483
|
+
columns: F,
|
|
484
|
+
onRowClick: e.onRowClick ?? (k ? M : void 0)
|
|
485
|
+
}, ee = O?.title && !O.title.includes("${") ? O.title : void 0;
|
|
486
|
+
return /* @__PURE__ */ Q("div", {
|
|
487
|
+
className: H("relative", n),
|
|
488
|
+
children: [
|
|
489
|
+
/* @__PURE__ */ Z(re, { active: x && P.length > 0 }),
|
|
490
|
+
/* @__PURE__ */ Z(h, {
|
|
491
|
+
schema: I,
|
|
492
|
+
className: n
|
|
493
|
+
}),
|
|
494
|
+
k && /* @__PURE__ */ Z(tt, {
|
|
495
|
+
record: A,
|
|
496
|
+
objectName: e.objectName,
|
|
497
|
+
objectSchema: y,
|
|
498
|
+
fields: O?.columns,
|
|
499
|
+
title: ee,
|
|
500
|
+
target: O?.target === "dialog" ? "dialog" : "drawer",
|
|
501
|
+
onClose: () => j(null)
|
|
502
|
+
})
|
|
503
|
+
]
|
|
504
|
+
});
|
|
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
|
+
type: "button",
|
|
509
|
+
variant: "ghost",
|
|
510
|
+
size: "sm",
|
|
511
|
+
className: r,
|
|
512
|
+
"data-testid": "drill-open-in-list",
|
|
513
|
+
onClick: () => {
|
|
514
|
+
i(e, t), n?.();
|
|
515
|
+
},
|
|
516
|
+
children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Z(he, { className: "ml-1 h-3.5 w-3.5" })]
|
|
517
|
+
});
|
|
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
|
+
e && p && (d(i, a), t());
|
|
522
|
+
}, [e, p]), p) return null;
|
|
523
|
+
let m = f ? null : /* @__PURE__ */ Z(at, {
|
|
524
|
+
objectName: i,
|
|
525
|
+
filter: a,
|
|
526
|
+
onNavigate: t
|
|
527
|
+
}), g = /* @__PURE__ */ Z("div", {
|
|
528
|
+
className: H("overflow-auto", l),
|
|
529
|
+
"data-testid": "drill-down-body",
|
|
530
|
+
children: f ? (() => {
|
|
531
|
+
let e = u.filter, t = e ? a ? { $and: [e, a] } : e : a;
|
|
532
|
+
return /* @__PURE__ */ Z(h, { schema: {
|
|
533
|
+
...u,
|
|
534
|
+
type: "spec-report",
|
|
535
|
+
report: {
|
|
536
|
+
...u,
|
|
537
|
+
filter: t
|
|
538
|
+
},
|
|
539
|
+
filter: t
|
|
540
|
+
} });
|
|
541
|
+
})() : /* @__PURE__ */ Z(it, {
|
|
542
|
+
schema: {
|
|
543
|
+
type: "object-data-table",
|
|
544
|
+
objectName: i,
|
|
545
|
+
filter: a,
|
|
546
|
+
columns: s?.map((e) => ({
|
|
547
|
+
accessorKey: e,
|
|
548
|
+
header: e
|
|
549
|
+
})),
|
|
550
|
+
pagination: !0,
|
|
551
|
+
searchable: !1,
|
|
552
|
+
pageSize: c,
|
|
553
|
+
drillDown: {
|
|
554
|
+
enabled: !0,
|
|
555
|
+
mode: "record",
|
|
556
|
+
target: "dialog"
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
dataSource: o
|
|
560
|
+
})
|
|
561
|
+
});
|
|
562
|
+
return r === "dialog" ? /* @__PURE__ */ Z(te, {
|
|
563
|
+
open: e,
|
|
564
|
+
onOpenChange: (e) => !e && t(),
|
|
565
|
+
children: /* @__PURE__ */ Q(L, {
|
|
566
|
+
className: "max-w-5xl",
|
|
567
|
+
children: [/* @__PURE__ */ Q(R, {
|
|
568
|
+
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
569
|
+
children: [/* @__PURE__ */ Z(ne, { children: n }), m]
|
|
570
|
+
}), g]
|
|
571
|
+
})
|
|
572
|
+
}) : /* @__PURE__ */ Z(z, {
|
|
573
|
+
open: e,
|
|
574
|
+
onOpenChange: (e) => !e && t(),
|
|
575
|
+
children: /* @__PURE__ */ Q(ie, {
|
|
576
|
+
side: "right",
|
|
577
|
+
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
578
|
+
children: [/* @__PURE__ */ Q(B, {
|
|
579
|
+
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
580
|
+
children: [/* @__PURE__ */ Z(ae, { children: n }), m]
|
|
581
|
+
}), /* @__PURE__ */ Z("div", {
|
|
582
|
+
className: "flex-1 overflow-hidden mt-2",
|
|
583
|
+
children: g
|
|
584
|
+
})]
|
|
585
|
+
})
|
|
586
|
+
});
|
|
587
|
+
}, st = n;
|
|
588
|
+
function ct(e, t, n) {
|
|
589
|
+
let r = [], i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
590
|
+
return e.forEach((e, c) => {
|
|
591
|
+
let u = t.map((t) => String(e[t] ?? "∅")).join(""), d = String(e[n] ?? "∅");
|
|
592
|
+
a.has(u) || (a.add(u), r.push({
|
|
593
|
+
id: u,
|
|
594
|
+
labels: t.map((t) => l(e[t]))
|
|
595
|
+
})), o.has(d) || (o.add(d), i.push({
|
|
596
|
+
id: d,
|
|
597
|
+
label: l(e[n])
|
|
598
|
+
})), s.set(`${u} ${d}`, c);
|
|
599
|
+
}), {
|
|
600
|
+
rowHeaders: r,
|
|
601
|
+
colHeaders: i,
|
|
602
|
+
cellIndex: s
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function lt(e) {
|
|
606
|
+
if (e == null) return "";
|
|
607
|
+
let t = String(e);
|
|
608
|
+
return /[",\n\r]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
609
|
+
}
|
|
610
|
+
function ut(e) {
|
|
611
|
+
return e.map((e) => e.map(lt).join(",")).join("\r\n");
|
|
612
|
+
}
|
|
613
|
+
function dt(e, t) {
|
|
614
|
+
if (typeof document > "u") return;
|
|
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
|
+
a.href = i, a.download = n.endsWith(".csv") ? n : `${n}.csv`, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
|
|
617
|
+
}
|
|
618
|
+
var ft = new Set([
|
|
619
|
+
"metric",
|
|
620
|
+
"kpi",
|
|
621
|
+
"gauge",
|
|
622
|
+
"solid-gauge",
|
|
623
|
+
"bullet"
|
|
624
|
+
]), pt = {
|
|
625
|
+
bar: "bar",
|
|
626
|
+
column: "column",
|
|
627
|
+
"horizontal-bar": "horizontal-bar",
|
|
628
|
+
"grouped-bar": "bar",
|
|
629
|
+
"stacked-bar": "bar",
|
|
630
|
+
"bi-polar-bar": "bar",
|
|
631
|
+
line: "line",
|
|
632
|
+
spline: "line",
|
|
633
|
+
"step-line": "line",
|
|
634
|
+
area: "area",
|
|
635
|
+
"stacked-area": "area",
|
|
636
|
+
pie: "pie",
|
|
637
|
+
donut: "donut",
|
|
638
|
+
funnel: "funnel",
|
|
639
|
+
pyramid: "funnel",
|
|
640
|
+
scatter: "scatter",
|
|
641
|
+
bubble: "scatter",
|
|
642
|
+
radar: "radar",
|
|
643
|
+
treemap: "treemap",
|
|
644
|
+
sankey: "sankey"
|
|
645
|
+
};
|
|
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
|
+
[]
|
|
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
|
+
status: "idle",
|
|
653
|
+
rows: []
|
|
654
|
+
}), [k, A] = J(null), [j, M] = J(null);
|
|
655
|
+
if (K(() => {
|
|
656
|
+
let e = n;
|
|
657
|
+
if (!e || typeof e.queryDataset != "function") {
|
|
658
|
+
E({
|
|
659
|
+
status: "error",
|
|
660
|
+
rows: [],
|
|
661
|
+
error: x("dashboard.datasetUnsupported", "This data source does not support dataset queries.")
|
|
662
|
+
});
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
if (s.length === 0) {
|
|
666
|
+
E({
|
|
667
|
+
status: "idle",
|
|
668
|
+
rows: []
|
|
669
|
+
});
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
let t = !1;
|
|
673
|
+
return E({
|
|
674
|
+
status: "loading",
|
|
675
|
+
rows: []
|
|
676
|
+
}), e.queryDataset(a, {
|
|
677
|
+
dimensions: o,
|
|
678
|
+
measures: s,
|
|
679
|
+
...w ? { runtimeFilter: w } : {},
|
|
680
|
+
...d ? { compareTo: d } : {},
|
|
681
|
+
...b ? { totals: { groupings: b } } : {}
|
|
682
|
+
}).then((e) => {
|
|
683
|
+
t || E({
|
|
684
|
+
status: "ok",
|
|
685
|
+
rows: Array.isArray(e?.rows) ? e.rows : [],
|
|
686
|
+
fields: Array.isArray(e?.fields) ? e.fields : [],
|
|
687
|
+
object: e?.object,
|
|
688
|
+
dimensionFields: e?.dimensionFields,
|
|
689
|
+
drillRawRows: Array.isArray(e?.drillRawRows) ? e.drillRawRows : void 0,
|
|
690
|
+
totals: Array.isArray(e?.totals) ? e.totals : void 0
|
|
691
|
+
});
|
|
692
|
+
}).catch((e) => {
|
|
693
|
+
t || E({
|
|
694
|
+
status: "error",
|
|
695
|
+
rows: [],
|
|
696
|
+
error: String(e?.message ?? e)
|
|
697
|
+
});
|
|
698
|
+
}), () => {
|
|
699
|
+
t = !0;
|
|
700
|
+
};
|
|
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", {
|
|
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",
|
|
733
|
+
children: x("dashboard.pickMeasures", "Pick measures (values) for this dataset widget.")
|
|
734
|
+
});
|
|
735
|
+
if (T.status === "loading" || T.status === "idle") return /* @__PURE__ */ Z("div", {
|
|
736
|
+
className: "flex h-full w-full items-center justify-center p-4 text-muted-foreground",
|
|
737
|
+
children: /* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" })
|
|
738
|
+
});
|
|
739
|
+
if (T.status === "error") return /* @__PURE__ */ Q("div", {
|
|
740
|
+
role: "alert",
|
|
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",
|
|
742
|
+
children: [/* @__PURE__ */ Z(Y, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
743
|
+
className: "break-words",
|
|
744
|
+
children: T.error
|
|
745
|
+
})]
|
|
746
|
+
});
|
|
747
|
+
if (T.rows.length === 0 && !m) return /* @__PURE__ */ Q("div", {
|
|
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",
|
|
749
|
+
children: [/* @__PURE__ */ Z(ge, { className: "mr-2 h-4 w-4" }), x("dashboard.noRows", "No rows")]
|
|
750
|
+
});
|
|
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),
|
|
754
|
+
title: n || String(e?.title ?? "")
|
|
755
|
+
});
|
|
756
|
+
}, ne = k && F ? /* @__PURE__ */ Z(ot, {
|
|
757
|
+
open: !0,
|
|
758
|
+
onClose: () => A(null),
|
|
759
|
+
title: k.title || String(e?.title ?? x("dashboard.details", "Details")),
|
|
760
|
+
objectName: F,
|
|
761
|
+
filter: k.filter,
|
|
762
|
+
dataSource: n
|
|
763
|
+
}) : null;
|
|
764
|
+
if (m) {
|
|
765
|
+
let e = N(s[0]);
|
|
766
|
+
return /* @__PURE__ */ Q("div", {
|
|
767
|
+
className: "flex h-full w-full flex-col items-start justify-center gap-1 p-2",
|
|
768
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
769
|
+
className: "text-2xl font-semibold tabular-nums",
|
|
770
|
+
children: u(T.rows[0]?.[s[0]] ?? 0, e?.format, e?.currency)
|
|
771
|
+
}), /* @__PURE__ */ Z("span", {
|
|
772
|
+
className: "text-xs text-muted-foreground",
|
|
773
|
+
children: P(s[0])
|
|
774
|
+
})]
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
if (g) {
|
|
778
|
+
let t = [...o, ...s], n = /* @__PURE__ */ Z("button", {
|
|
779
|
+
type: "button",
|
|
780
|
+
onClick: () => dt(String(e?.title ?? a ?? "export"), [t.map((e) => P(e)), ...T.rows.map((e) => t.map((t) => {
|
|
781
|
+
let n = e[t];
|
|
782
|
+
return n == null ? "" : typeof n == "number" ? n : String(n);
|
|
783
|
+
}))]),
|
|
784
|
+
"data-testid": "dataset-export",
|
|
785
|
+
title: x("dashboard.exportCsv", "Export CSV"),
|
|
786
|
+
"aria-label": x("dashboard.exportCsv", "Export CSV"),
|
|
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",
|
|
788
|
+
children: /* @__PURE__ */ Z(X, { className: "h-3.5 w-3.5" })
|
|
789
|
+
});
|
|
790
|
+
if (_) {
|
|
791
|
+
let e = ct(T.rows, v, y), t = e.colHeaders.flatMap((e) => s.map((t) => ({
|
|
792
|
+
col: e,
|
|
793
|
+
measure: t,
|
|
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");
|
|
800
|
+
return /* @__PURE__ */ Q("div", {
|
|
801
|
+
className: "relative h-full w-full overflow-auto p-1",
|
|
802
|
+
"data-testid": "dataset-matrix",
|
|
803
|
+
children: [
|
|
804
|
+
n,
|
|
805
|
+
/* @__PURE__ */ Q("table", {
|
|
806
|
+
className: "w-full text-xs",
|
|
807
|
+
children: [/* @__PURE__ */ Z("thead", {
|
|
808
|
+
className: "bg-muted/40",
|
|
809
|
+
children: /* @__PURE__ */ Q("tr", { children: [
|
|
810
|
+
v.map((e) => /* @__PURE__ */ Z("th", {
|
|
811
|
+
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
812
|
+
children: P(e)
|
|
813
|
+
}, e)),
|
|
814
|
+
t.map((e) => /* @__PURE__ */ Z("th", {
|
|
815
|
+
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
816
|
+
children: e.header
|
|
817
|
+
}, `${e.col.id}-${e.measure}`)),
|
|
818
|
+
l && s.map((e) => /* @__PURE__ */ Z("th", {
|
|
819
|
+
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
820
|
+
"data-testid": "matrix-total-col-header",
|
|
821
|
+
children: s.length === 1 ? f : `${f} · ${P(e)}`
|
|
822
|
+
}, `total-${e}`))
|
|
823
|
+
] })
|
|
824
|
+
}), /* @__PURE__ */ Q("tbody", { children: [e.rowHeaders.map((n) => /* @__PURE__ */ Q("tr", {
|
|
825
|
+
className: "border-t",
|
|
826
|
+
children: [
|
|
827
|
+
n.labels.map((e, t) => /* @__PURE__ */ Z("td", {
|
|
828
|
+
className: "px-2 py-1 whitespace-nowrap font-medium",
|
|
829
|
+
children: e
|
|
830
|
+
}, t)),
|
|
831
|
+
t.map((t) => {
|
|
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(" / ");
|
|
833
|
+
return /* @__PURE__ */ Z("td", {
|
|
834
|
+
className: H("px-2 py-1 text-right tabular-nums whitespace-nowrap", o && "cursor-pointer hover:bg-accent/40"),
|
|
835
|
+
"data-testid": o ? "dataset-drill-cell" : void 0,
|
|
836
|
+
onClick: o ? () => R(i, s) : void 0,
|
|
837
|
+
children: a ? r(a[t.measure], t.measure) : "—"
|
|
838
|
+
}, `${t.col.id}-${t.measure}`);
|
|
839
|
+
}),
|
|
840
|
+
l && s.map((e) => /* @__PURE__ */ Z("td", {
|
|
841
|
+
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
842
|
+
"data-testid": "matrix-row-total",
|
|
843
|
+
children: r(a.get(n.id)?.[e], e)
|
|
844
|
+
}, `total-${e}`))
|
|
845
|
+
]
|
|
846
|
+
}, n.id)), d && /* @__PURE__ */ Q("tr", {
|
|
847
|
+
className: "border-t bg-muted/30 font-medium",
|
|
848
|
+
"data-testid": "matrix-total-row",
|
|
849
|
+
children: [
|
|
850
|
+
v.length > 0 && /* @__PURE__ */ Z("td", {
|
|
851
|
+
colSpan: v.length,
|
|
852
|
+
className: "px-2 py-1 whitespace-nowrap",
|
|
853
|
+
children: f
|
|
854
|
+
}),
|
|
855
|
+
t.map((e) => /* @__PURE__ */ Z("td", {
|
|
856
|
+
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
857
|
+
children: r(o.get(e.col.id)?.[e.measure], e.measure)
|
|
858
|
+
}, `${e.col.id}-${e.measure}`)),
|
|
859
|
+
l && s.map((e) => /* @__PURE__ */ Z("td", {
|
|
860
|
+
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
861
|
+
"data-testid": "matrix-grand-total",
|
|
862
|
+
children: r(c?.[e], e)
|
|
863
|
+
}, `grand-${e}`))
|
|
864
|
+
]
|
|
865
|
+
})] })]
|
|
866
|
+
}),
|
|
867
|
+
ne
|
|
868
|
+
]
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
let r = [...o, ...s];
|
|
872
|
+
return /* @__PURE__ */ Q("div", {
|
|
873
|
+
className: "relative h-full w-full overflow-auto p-1",
|
|
874
|
+
children: [
|
|
875
|
+
n,
|
|
876
|
+
/* @__PURE__ */ Q("table", {
|
|
877
|
+
className: "w-full text-xs",
|
|
878
|
+
children: [/* @__PURE__ */ Z("thead", {
|
|
879
|
+
className: "bg-muted/40",
|
|
880
|
+
children: /* @__PURE__ */ Z("tr", { children: r.map((e) => /* @__PURE__ */ Z("th", {
|
|
881
|
+
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
882
|
+
children: P(e)
|
|
883
|
+
}, e)) })
|
|
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,
|
|
888
|
+
children: r.map((t) => /* @__PURE__ */ Z("td", {
|
|
889
|
+
className: "px-2 py-1 whitespace-nowrap tabular-nums",
|
|
890
|
+
children: s.includes(t) ? u(e[t], N(t)?.format, N(t)?.currency) : l(e[t])
|
|
891
|
+
}, t))
|
|
892
|
+
}, t)) })]
|
|
893
|
+
}),
|
|
894
|
+
ne
|
|
895
|
+
]
|
|
896
|
+
});
|
|
897
|
+
}
|
|
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);
|
|
900
|
+
if (t < 0) return;
|
|
901
|
+
let n = o.length >= 2 && s.length === 1;
|
|
902
|
+
R(t, [e?.category, n ? e?.series : void 0].filter(Boolean).map(String).join(" / "));
|
|
903
|
+
} : void 0;
|
|
904
|
+
return /* @__PURE__ */ Q("div", {
|
|
905
|
+
className: H("relative h-full w-full min-h-[220px]"),
|
|
906
|
+
children: [/* @__PURE__ */ Z(h, {
|
|
907
|
+
schema: {
|
|
908
|
+
type: "chart",
|
|
909
|
+
chartType: re,
|
|
910
|
+
data: z,
|
|
911
|
+
xAxisKey: ie,
|
|
912
|
+
series: B,
|
|
913
|
+
...j ? { categoryColors: j } : {}
|
|
914
|
+
},
|
|
915
|
+
onChartClick: ae,
|
|
916
|
+
onSegmentClick: ae
|
|
917
|
+
}), ne]
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
//#endregion
|
|
40
921
|
//#region src/DashboardRenderer.tsx
|
|
41
|
-
function
|
|
42
|
-
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({
|
|
43
924
|
id: e,
|
|
44
925
|
disabled: t
|
|
45
926
|
});
|
|
46
927
|
return /* @__PURE__ */ Z("div", {
|
|
47
928
|
ref: s,
|
|
48
929
|
style: {
|
|
49
|
-
transform:
|
|
930
|
+
transform: Fe.Transform.toString(c),
|
|
50
931
|
transition: l,
|
|
51
932
|
opacity: u ? .4 : 1,
|
|
52
933
|
...n ? {
|
|
@@ -54,39 +935,81 @@ function ke({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
|
54
935
|
gridRow: `span ${n.h}`
|
|
55
936
|
} : {}
|
|
56
937
|
},
|
|
57
|
-
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"),
|
|
58
939
|
"data-sortable-widget-id": e,
|
|
59
940
|
...a,
|
|
60
941
|
...o,
|
|
61
942
|
children: i
|
|
62
943
|
});
|
|
63
944
|
}
|
|
64
|
-
function
|
|
65
|
-
return e ?
|
|
945
|
+
function gt(e) {
|
|
946
|
+
return e ? oe(e) : null;
|
|
66
947
|
}
|
|
67
|
-
function
|
|
948
|
+
function _t(e) {
|
|
68
949
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
69
950
|
}
|
|
70
|
-
var
|
|
951
|
+
var vt = [
|
|
71
952
|
"hsl(var(--chart-1))",
|
|
72
953
|
"hsl(var(--chart-2))",
|
|
73
954
|
"hsl(var(--chart-3))",
|
|
74
955
|
"hsl(var(--chart-4))",
|
|
75
956
|
"hsl(var(--chart-5))"
|
|
76
|
-
],
|
|
957
|
+
], yt = {
|
|
958
|
+
column: "bar",
|
|
959
|
+
"stacked-bar": "bar",
|
|
960
|
+
"grouped-bar": "bar",
|
|
961
|
+
"bi-polar-bar": "bar",
|
|
962
|
+
spline: "line",
|
|
963
|
+
"step-line": "line",
|
|
964
|
+
"stacked-area": "area",
|
|
965
|
+
pyramid: "funnel",
|
|
966
|
+
bubble: "scatter"
|
|
967
|
+
}, bt = new Set([
|
|
77
968
|
"bar",
|
|
78
969
|
"horizontal-bar",
|
|
79
970
|
"line",
|
|
80
971
|
"area",
|
|
81
972
|
"pie",
|
|
82
973
|
"donut",
|
|
83
|
-
"
|
|
974
|
+
"scatter",
|
|
975
|
+
"funnel",
|
|
976
|
+
"radar",
|
|
977
|
+
"treemap",
|
|
978
|
+
"sankey"
|
|
979
|
+
]), xt = new Set([
|
|
980
|
+
"gauge",
|
|
981
|
+
"solid-gauge",
|
|
982
|
+
"kpi",
|
|
983
|
+
"bullet"
|
|
984
|
+
]), St = new Set([
|
|
985
|
+
"sunburst",
|
|
986
|
+
"word-cloud",
|
|
987
|
+
"choropleth",
|
|
988
|
+
"bubble-map",
|
|
989
|
+
"gl-map",
|
|
990
|
+
"heatmap",
|
|
991
|
+
"waterfall",
|
|
992
|
+
"box-plot",
|
|
993
|
+
"violin",
|
|
994
|
+
"candlestick",
|
|
995
|
+
"stock"
|
|
996
|
+
]), Ct = new Set([
|
|
997
|
+
"bar",
|
|
998
|
+
"horizontal-bar",
|
|
999
|
+
"line",
|
|
1000
|
+
"area",
|
|
1001
|
+
"pie",
|
|
1002
|
+
"donut",
|
|
1003
|
+
"funnel",
|
|
1004
|
+
"scatter",
|
|
1005
|
+
"treemap",
|
|
1006
|
+
"sankey"
|
|
84
1007
|
]);
|
|
85
|
-
function
|
|
86
|
-
return
|
|
1008
|
+
function wt(e) {
|
|
1009
|
+
return Ct.has(e) ? { enabled: !0 } : void 0;
|
|
87
1010
|
}
|
|
88
|
-
var
|
|
89
|
-
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 = (() => {
|
|
90
1013
|
if (e.columns != null) return e.columns;
|
|
91
1014
|
let t = e.widgets ?? [], n = 0;
|
|
92
1015
|
for (let e of t) {
|
|
@@ -94,77 +1017,80 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
94
1017
|
t > n && (n = t), (e.layout?.w ?? 0) > n && (n = e.layout.w);
|
|
95
1018
|
}
|
|
96
1019
|
return n > 4 ? 12 : 4;
|
|
97
|
-
})(),
|
|
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) => ({
|
|
98
1021
|
name: e.actionUrl || e.label,
|
|
99
1022
|
type: e.actionType || "url",
|
|
100
1023
|
target: e.actionUrl,
|
|
101
1024
|
label: e.label
|
|
102
|
-
})), [e.header?.actions]) }), { dashboardLabel:
|
|
103
|
-
let t =
|
|
104
|
-
return !
|
|
105
|
-
}, [
|
|
106
|
-
let t =
|
|
107
|
-
return !
|
|
108
|
-
}, [
|
|
109
|
-
|
|
110
|
-
let e =
|
|
111
|
-
if (
|
|
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();
|
|
1034
|
+
if (u && e.setModalHandler(u), d) for (let [t, n] of Object.entries(d)) e.registerScript(t, n);
|
|
112
1035
|
}, [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
]),
|
|
117
|
-
let e = () =>
|
|
1036
|
+
P,
|
|
1037
|
+
u,
|
|
1038
|
+
d
|
|
1039
|
+
]), K(() => {
|
|
1040
|
+
let e = () => T(window.innerWidth < 768);
|
|
118
1041
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
119
1042
|
}, []);
|
|
120
|
-
let
|
|
121
|
-
r && (
|
|
1043
|
+
let V = G(() => {
|
|
1044
|
+
r && (C(!0), r(), setTimeout(() => C(!1), 600));
|
|
122
1045
|
}, [r]);
|
|
123
|
-
|
|
124
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return
|
|
125
|
-
|
|
1046
|
+
K(() => {
|
|
1047
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return D.current = setInterval(V, e.refreshInterval * 1e3), () => {
|
|
1048
|
+
D.current && clearInterval(D.current);
|
|
126
1049
|
};
|
|
127
1050
|
}, [
|
|
128
1051
|
e.refreshInterval,
|
|
129
1052
|
r,
|
|
130
|
-
|
|
1053
|
+
V
|
|
131
1054
|
]);
|
|
132
|
-
let
|
|
133
|
-
!o || !
|
|
134
|
-
}, [o,
|
|
135
|
-
if (!o || !
|
|
1055
|
+
let oe = G((e, t) => {
|
|
1056
|
+
!o || !c || !t || (e.stopPropagation(), c(t));
|
|
1057
|
+
}, [o, c]), se = G((t, n, r) => {
|
|
1058
|
+
if (!o || !c) return;
|
|
136
1059
|
let i = e.widgets || [];
|
|
137
|
-
if (t.key === "Enter" || t.key === " ") t.preventDefault(),
|
|
1060
|
+
if (t.key === "Enter" || t.key === " ") t.preventDefault(), c(n ?? null);
|
|
138
1061
|
else if (t.key === "ArrowRight" || t.key === "ArrowDown") {
|
|
139
1062
|
t.preventDefault();
|
|
140
1063
|
let e = r + 1 < i.length ? i[r + 1] : null;
|
|
141
|
-
e?.id &&
|
|
1064
|
+
e?.id && c(e.id);
|
|
142
1065
|
} else if (t.key === "ArrowLeft" || t.key === "ArrowUp") {
|
|
143
1066
|
t.preventDefault();
|
|
144
1067
|
let e = r - 1 >= 0 ? i[r - 1] : null;
|
|
145
|
-
e?.id &&
|
|
146
|
-
} else t.key === "Escape" && (t.preventDefault(),
|
|
1068
|
+
e?.id && c(e.id);
|
|
1069
|
+
} else t.key === "Escape" && (t.preventDefault(), c(null));
|
|
147
1070
|
}, [
|
|
148
1071
|
o,
|
|
149
|
-
|
|
1072
|
+
c,
|
|
150
1073
|
e.widgets
|
|
151
|
-
]),
|
|
152
|
-
!o || !
|
|
153
|
-
}, [o,
|
|
154
|
-
if (!
|
|
1074
|
+
]), U = G((e) => {
|
|
1075
|
+
!o || !c || e.target === e.currentTarget && c(null);
|
|
1076
|
+
}, [o, c]), W = !!(o && l), le = ke(Oe(Ee, { activationConstraint: { distance: 5 } })), ue = G((t) => {
|
|
1077
|
+
if (!W) return;
|
|
155
1078
|
let { active: n, over: r } = t;
|
|
156
1079
|
if (!r || n.id === r.id) return;
|
|
157
1080
|
let i = e.widgets ?? [], a = i.findIndex((e) => e.id === n.id), o = i.findIndex((e) => e.id === r.id);
|
|
158
|
-
a < 0 || o < 0 ||
|
|
1081
|
+
a < 0 || o < 0 || l?.(je(i, a, o));
|
|
159
1082
|
}, [
|
|
160
|
-
|
|
1083
|
+
W,
|
|
161
1084
|
e.widgets,
|
|
162
|
-
|
|
163
|
-
]),
|
|
164
|
-
let i = e.
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
} : void 0, a =
|
|
1085
|
+
l
|
|
1086
|
+
]), fe = (e, t, r) => {
|
|
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 = (() => {
|
|
168
1094
|
if (e.component) return e.component;
|
|
169
1095
|
let t = e.type, n = e.options || {};
|
|
170
1096
|
if (t === "metric" && e.object) {
|
|
@@ -182,7 +1108,7 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
182
1108
|
objectName: e.object || ($(t) ? t.object : void 0),
|
|
183
1109
|
aggregate: r,
|
|
184
1110
|
filter: ($(t) ? t.filter : void 0) || e.filter,
|
|
185
|
-
label: n.label ||
|
|
1111
|
+
label: n.label || B(e) || "",
|
|
186
1112
|
fallbackValue: n.value,
|
|
187
1113
|
trend: n.trend,
|
|
188
1114
|
icon: n.icon,
|
|
@@ -193,11 +1119,11 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
193
1119
|
prefix: n.prefix,
|
|
194
1120
|
suffix: n.suffix,
|
|
195
1121
|
drillDown: n.drillDown ?? { enabled: !0 },
|
|
196
|
-
title: n.label ||
|
|
1122
|
+
title: n.label || B(e) || "",
|
|
197
1123
|
compareTo: e.compareTo
|
|
198
1124
|
};
|
|
199
1125
|
}
|
|
200
|
-
if ((t
|
|
1126
|
+
if (xt.has(t || "") && e.object) {
|
|
201
1127
|
let t = e.aggregate ? {
|
|
202
1128
|
field: e.valueField || "value",
|
|
203
1129
|
function: e.aggregate,
|
|
@@ -208,7 +1134,7 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
208
1134
|
objectName: e.object,
|
|
209
1135
|
aggregate: t,
|
|
210
1136
|
filter: e.filter,
|
|
211
|
-
label: n.label ||
|
|
1137
|
+
label: n.label || B(e) || "",
|
|
212
1138
|
fallbackValue: n.fallbackValue ?? n.value,
|
|
213
1139
|
icon: n.icon,
|
|
214
1140
|
description: n.description,
|
|
@@ -221,8 +1147,8 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
221
1147
|
compareTo: e.compareTo
|
|
222
1148
|
};
|
|
223
1149
|
}
|
|
224
|
-
let r = t &&
|
|
225
|
-
if (r
|
|
1150
|
+
let r = t && yt[t] || t;
|
|
1151
|
+
if (r && bt.has(r)) {
|
|
226
1152
|
let t = e.data || n.data, i = e.categoryField || n.xField || "name", a = e.valueField || n.yField || "value";
|
|
227
1153
|
if ($(t)) {
|
|
228
1154
|
let o = t.aggregate, s = (() => {
|
|
@@ -245,10 +1171,10 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
245
1171
|
xAxisKey: i,
|
|
246
1172
|
series: [{
|
|
247
1173
|
dataKey: l,
|
|
248
|
-
label:
|
|
1174
|
+
label: re(u, l, c?.function)
|
|
249
1175
|
}],
|
|
250
|
-
colors:
|
|
251
|
-
drillDown: n.drillDown ??
|
|
1176
|
+
colors: vt,
|
|
1177
|
+
drillDown: n.drillDown ?? wt(r),
|
|
252
1178
|
compareTo: e.compareTo,
|
|
253
1179
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
254
1180
|
};
|
|
@@ -271,10 +1197,10 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
271
1197
|
xAxisKey: i,
|
|
272
1198
|
series: [{
|
|
273
1199
|
dataKey: s,
|
|
274
|
-
label:
|
|
1200
|
+
label: re(e.object, s, e.aggregate)
|
|
275
1201
|
}],
|
|
276
|
-
colors:
|
|
277
|
-
drillDown: n.drillDown ??
|
|
1202
|
+
colors: vt,
|
|
1203
|
+
drillDown: n.drillDown ?? wt(r),
|
|
278
1204
|
compareTo: e.compareTo,
|
|
279
1205
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
280
1206
|
};
|
|
@@ -286,24 +1212,28 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
286
1212
|
xAxisKey: i,
|
|
287
1213
|
series: [{
|
|
288
1214
|
dataKey: a,
|
|
289
|
-
label:
|
|
1215
|
+
label: re(e.object, a, e.aggregate)
|
|
290
1216
|
}],
|
|
291
|
-
colors:
|
|
1217
|
+
colors: vt,
|
|
292
1218
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
293
1219
|
};
|
|
294
1220
|
}
|
|
295
1221
|
if (t === "table") {
|
|
296
|
-
let t = e.data || n.data
|
|
1222
|
+
let t = e.data || n.data, r = $(t) || !t && e.object ? n.drillDown ?? {
|
|
1223
|
+
enabled: !0,
|
|
1224
|
+
mode: "record"
|
|
1225
|
+
} : void 0;
|
|
297
1226
|
if ($(t)) {
|
|
298
|
-
let { data:
|
|
1227
|
+
let { data: i, ...a } = n;
|
|
299
1228
|
return {
|
|
300
1229
|
type: "object-data-table",
|
|
301
|
-
...
|
|
1230
|
+
...a,
|
|
302
1231
|
objectName: e.object || t.object,
|
|
303
1232
|
dataProvider: t,
|
|
304
1233
|
filter: t.filter || e.filter,
|
|
305
1234
|
searchable: e.searchable ?? !1,
|
|
306
1235
|
pagination: e.pagination ?? !1,
|
|
1236
|
+
drillDown: r,
|
|
307
1237
|
className: "border-0"
|
|
308
1238
|
};
|
|
309
1239
|
}
|
|
@@ -314,6 +1244,7 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
314
1244
|
filter: e.filter,
|
|
315
1245
|
searchable: e.searchable ?? !1,
|
|
316
1246
|
pagination: e.pagination ?? !1,
|
|
1247
|
+
drillDown: r,
|
|
317
1248
|
className: "border-0"
|
|
318
1249
|
} : {
|
|
319
1250
|
type: "data-table",
|
|
@@ -362,17 +1293,21 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
362
1293
|
};
|
|
363
1294
|
}
|
|
364
1295
|
if (t === "list") {
|
|
365
|
-
let t = e.data || n.data
|
|
1296
|
+
let t = e.data || n.data, r = $(t) || !t && e.object ? n.drillDown ?? {
|
|
1297
|
+
enabled: !0,
|
|
1298
|
+
mode: "record"
|
|
1299
|
+
} : void 0;
|
|
366
1300
|
if ($(t)) {
|
|
367
|
-
let { data:
|
|
1301
|
+
let { data: i, ...a } = n;
|
|
368
1302
|
return {
|
|
369
1303
|
type: "object-data-table",
|
|
370
|
-
...
|
|
1304
|
+
...a,
|
|
371
1305
|
objectName: e.object || t.object,
|
|
372
1306
|
dataProvider: t,
|
|
373
1307
|
filter: t.filter || e.filter,
|
|
374
1308
|
searchable: !1,
|
|
375
1309
|
pagination: !1,
|
|
1310
|
+
drillDown: r,
|
|
376
1311
|
className: "border-0"
|
|
377
1312
|
};
|
|
378
1313
|
}
|
|
@@ -383,6 +1318,7 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
383
1318
|
filter: e.filter,
|
|
384
1319
|
searchable: !1,
|
|
385
1320
|
pagination: !1,
|
|
1321
|
+
drillDown: r,
|
|
386
1322
|
className: "border-0"
|
|
387
1323
|
} : {
|
|
388
1324
|
type: "data-table",
|
|
@@ -399,57 +1335,72 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
399
1335
|
variant: "caption",
|
|
400
1336
|
align: "center",
|
|
401
1337
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
|
|
1338
|
+
} : t && St.has(t) ? {
|
|
1339
|
+
type: "text",
|
|
1340
|
+
value: `「${t}」chart type is not supported yet`,
|
|
1341
|
+
variant: "caption",
|
|
1342
|
+
align: "center",
|
|
1343
|
+
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
|
|
402
1344
|
} : {
|
|
403
1345
|
...e,
|
|
404
1346
|
...n
|
|
405
1347
|
};
|
|
406
|
-
})(),
|
|
1348
|
+
})(), f = e.type === "metric" && !u, p = B(e), m = ae(e), g = e.id || p || `widget-${t}`, _ = o && s === e.id, y = o ? {
|
|
407
1349
|
"data-testid": `dashboard-preview-widget-${e.id}`,
|
|
408
1350
|
"data-widget-id": e.id,
|
|
409
1351
|
role: "button",
|
|
410
1352
|
tabIndex: 0,
|
|
411
|
-
"aria-selected":
|
|
412
|
-
"aria-label": `Widget: ${
|
|
413
|
-
onClick: (t) =>
|
|
414
|
-
onKeyDown: (n) =>
|
|
415
|
-
} : {},
|
|
416
|
-
gridColumn: `span ${
|
|
417
|
-
gridRow: `span ${
|
|
418
|
-
} : void 0,
|
|
419
|
-
className:
|
|
420
|
-
style:
|
|
421
|
-
...
|
|
422
|
-
children: [/* @__PURE__ */ Z(
|
|
423
|
-
|
|
424
|
-
|
|
1353
|
+
"aria-selected": _,
|
|
1354
|
+
"aria-label": `Widget: ${p || `Widget ${t + 1}`}`,
|
|
1355
|
+
onClick: (t) => oe(t, e.id),
|
|
1356
|
+
onKeyDown: (n) => se(n, e.id, t)
|
|
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, {
|
|
1367
|
+
widget: e,
|
|
1368
|
+
dataSource: n
|
|
1369
|
+
})
|
|
1370
|
+
}) : /* @__PURE__ */ Z(h, {
|
|
1371
|
+
schema: d,
|
|
1372
|
+
className: H("h-full w-full", o && "pointer-events-none"),
|
|
425
1373
|
dataSource: n
|
|
426
1374
|
}), o && /* @__PURE__ */ Z("div", {
|
|
427
1375
|
className: "absolute inset-0 z-10",
|
|
428
1376
|
"aria-hidden": "true",
|
|
429
1377
|
"data-testid": "widget-click-overlay"
|
|
430
1378
|
})]
|
|
431
|
-
}) : /* @__PURE__ */ Q(
|
|
432
|
-
className:
|
|
433
|
-
style:
|
|
434
|
-
...
|
|
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,
|
|
435
1383
|
children: [
|
|
436
|
-
|
|
1384
|
+
p && /* @__PURE__ */ Q(M, {
|
|
437
1385
|
className: "pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6",
|
|
438
|
-
children: [/* @__PURE__ */ Z(
|
|
1386
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
439
1387
|
className: "text-sm sm:text-base font-medium tracking-tight truncate",
|
|
440
|
-
title:
|
|
441
|
-
children:
|
|
442
|
-
}),
|
|
1388
|
+
title: p,
|
|
1389
|
+
children: p
|
|
1390
|
+
}), m && /* @__PURE__ */ Z("p", {
|
|
443
1391
|
className: "text-xs text-muted-foreground mt-0.5 line-clamp-2",
|
|
444
|
-
children:
|
|
1392
|
+
children: m
|
|
445
1393
|
})]
|
|
446
1394
|
}),
|
|
447
|
-
/* @__PURE__ */ Z(
|
|
1395
|
+
/* @__PURE__ */ Z(j, {
|
|
448
1396
|
className: "p-0",
|
|
449
1397
|
children: /* @__PURE__ */ Z("div", {
|
|
450
|
-
className:
|
|
451
|
-
children: /* @__PURE__ */ Z(
|
|
452
|
-
|
|
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, {
|
|
1400
|
+
widget: e,
|
|
1401
|
+
dataSource: n
|
|
1402
|
+
}) : /* @__PURE__ */ Z(h, {
|
|
1403
|
+
schema: d,
|
|
453
1404
|
dataSource: n
|
|
454
1405
|
})
|
|
455
1406
|
})
|
|
@@ -461,36 +1412,36 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
461
1412
|
})
|
|
462
1413
|
]
|
|
463
1414
|
});
|
|
464
|
-
return
|
|
1415
|
+
return W && e.id ? /* @__PURE__ */ Z(ht, {
|
|
465
1416
|
id: e.id,
|
|
466
|
-
gridSpan: !
|
|
467
|
-
w:
|
|
468
|
-
h:
|
|
1417
|
+
gridSpan: !w && l ? {
|
|
1418
|
+
w: l.w,
|
|
1419
|
+
h: l.h
|
|
469
1420
|
} : void 0,
|
|
470
|
-
children:
|
|
471
|
-
},
|
|
472
|
-
},
|
|
1421
|
+
children: C
|
|
1422
|
+
}, g) : /* @__PURE__ */ Z(ce, { children: C }, g);
|
|
1423
|
+
}, Y = e.header && /* @__PURE__ */ Q("div", {
|
|
473
1424
|
className: "col-span-full mb-4",
|
|
474
1425
|
children: [
|
|
475
|
-
!
|
|
1426
|
+
!f && e.header.showTitle !== !1 && e.title && /* @__PURE__ */ Z("h2", {
|
|
476
1427
|
className: "text-lg font-semibold tracking-tight",
|
|
477
|
-
children:
|
|
478
|
-
name:
|
|
479
|
-
label:
|
|
480
|
-
}) :
|
|
1428
|
+
children: z ? F({
|
|
1429
|
+
name: z,
|
|
1430
|
+
label: _t(e.title)
|
|
1431
|
+
}) : _t(e.title)
|
|
481
1432
|
}),
|
|
482
|
-
!
|
|
1433
|
+
!f && e.header.showDescription !== !1 && e.description && /* @__PURE__ */ Z("p", {
|
|
483
1434
|
className: "text-sm text-muted-foreground mt-1",
|
|
484
|
-
children:
|
|
485
|
-
name:
|
|
486
|
-
description:
|
|
487
|
-
}) :
|
|
1435
|
+
children: z ? I({
|
|
1436
|
+
name: z,
|
|
1437
|
+
description: _t(e.description)
|
|
1438
|
+
}) : _t(e.description)
|
|
488
1439
|
}),
|
|
489
1440
|
e.header.actions && e.header.actions.length > 0 && /* @__PURE__ */ Z("div", {
|
|
490
1441
|
className: "flex gap-2 mt-3",
|
|
491
1442
|
children: e.header.actions.map((e, t) => {
|
|
492
|
-
let n =
|
|
493
|
-
return /* @__PURE__ */ Q(
|
|
1443
|
+
let n = gt(e.icon);
|
|
1444
|
+
return /* @__PURE__ */ Q(k, {
|
|
494
1445
|
variant: "outline",
|
|
495
1446
|
size: "sm",
|
|
496
1447
|
onClick: async () => {
|
|
@@ -504,103 +1455,106 @@ var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount
|
|
|
504
1455
|
return;
|
|
505
1456
|
}
|
|
506
1457
|
if (t === "modal" || t === "script") {
|
|
507
|
-
let e = await
|
|
1458
|
+
let e = await O(n || r);
|
|
508
1459
|
e?.success || console.warn("[DashboardRenderer] action failed", e?.error);
|
|
509
1460
|
return;
|
|
510
1461
|
}
|
|
511
1462
|
console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`);
|
|
512
1463
|
},
|
|
513
|
-
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)]
|
|
514
1465
|
}, t);
|
|
515
1466
|
})
|
|
516
1467
|
})
|
|
517
1468
|
]
|
|
518
|
-
}),
|
|
1469
|
+
}), pe = i !== void 0 && /* @__PURE__ */ Q("span", {
|
|
519
1470
|
className: "text-xs text-muted-foreground",
|
|
520
1471
|
children: [i.toLocaleString(), " records"]
|
|
521
|
-
}),
|
|
522
|
-
className:
|
|
523
|
-
children: [
|
|
1472
|
+
}), me = a ? JSON.stringify(a) : void 0, he = r && /* @__PURE__ */ Q("div", {
|
|
1473
|
+
className: H("flex items-center justify-end gap-3 mb-2", !w && "col-span-full"),
|
|
1474
|
+
children: [pe, /* @__PURE__ */ Q(k, {
|
|
524
1475
|
variant: "outline",
|
|
525
1476
|
size: "sm",
|
|
526
|
-
onClick:
|
|
527
|
-
disabled:
|
|
1477
|
+
onClick: V,
|
|
1478
|
+
disabled: x,
|
|
528
1479
|
"aria-label": "Refresh dashboard",
|
|
529
|
-
children: [/* @__PURE__ */ Z(
|
|
1480
|
+
children: [/* @__PURE__ */ Z(xe, { className: H("h-4 w-4 mr-2", x && "animate-spin") }), x ? "Refreshing…" : "Refresh All"]
|
|
530
1481
|
})]
|
|
531
|
-
}),
|
|
532
|
-
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) {
|
|
533
1484
|
let n = e.widgets?.filter((e) => e.type === "metric") || [], r = e.widgets?.filter((e) => e.type !== "metric") || [], i = /* @__PURE__ */ Q("div", {
|
|
534
|
-
ref:
|
|
535
|
-
className:
|
|
536
|
-
"data-user-actions":
|
|
537
|
-
onClick:
|
|
538
|
-
...
|
|
1485
|
+
ref: m,
|
|
1486
|
+
className: H("flex flex-col gap-4 px-4", t),
|
|
1487
|
+
"data-user-actions": me,
|
|
1488
|
+
onClick: U,
|
|
1489
|
+
...p,
|
|
539
1490
|
children: [
|
|
540
|
-
|
|
541
|
-
|
|
1491
|
+
Y,
|
|
1492
|
+
he,
|
|
542
1493
|
n.length > 0 && /* @__PURE__ */ Z("div", {
|
|
543
1494
|
className: "grid grid-cols-2 gap-3",
|
|
544
|
-
onClick:
|
|
545
|
-
children: /* @__PURE__ */ Z(
|
|
546
|
-
items:
|
|
547
|
-
strategy:
|
|
548
|
-
disabled: !
|
|
549
|
-
children: n.map((e, t) =>
|
|
1495
|
+
onClick: U,
|
|
1496
|
+
children: /* @__PURE__ */ Z(Ae, {
|
|
1497
|
+
items: X,
|
|
1498
|
+
strategy: Me,
|
|
1499
|
+
disabled: !W,
|
|
1500
|
+
children: n.map((e, t) => fe(e, t))
|
|
550
1501
|
})
|
|
551
1502
|
}),
|
|
552
1503
|
r.length > 0 && /* @__PURE__ */ Z("div", {
|
|
553
1504
|
className: "flex flex-col gap-4",
|
|
554
|
-
onClick:
|
|
555
|
-
children: /* @__PURE__ */ Z(
|
|
556
|
-
items:
|
|
557
|
-
strategy:
|
|
558
|
-
disabled: !
|
|
559
|
-
children: r.map((e, t) =>
|
|
1505
|
+
onClick: U,
|
|
1506
|
+
children: /* @__PURE__ */ Z(Ae, {
|
|
1507
|
+
items: _e,
|
|
1508
|
+
strategy: Pe,
|
|
1509
|
+
disabled: !W,
|
|
1510
|
+
children: r.map((e, t) => fe(e, t, !0))
|
|
560
1511
|
})
|
|
561
1512
|
})
|
|
562
1513
|
]
|
|
563
1514
|
});
|
|
564
|
-
return
|
|
565
|
-
sensors:
|
|
566
|
-
collisionDetection:
|
|
567
|
-
onDragEnd:
|
|
1515
|
+
return W ? /* @__PURE__ */ Z(Te, {
|
|
1516
|
+
sensors: le,
|
|
1517
|
+
collisionDetection: De,
|
|
1518
|
+
onDragEnd: ue,
|
|
568
1519
|
children: i
|
|
569
1520
|
}) : i;
|
|
570
1521
|
}
|
|
571
|
-
let
|
|
572
|
-
ref:
|
|
573
|
-
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),
|
|
574
1525
|
style: {
|
|
575
|
-
...
|
|
576
|
-
|
|
1526
|
+
...b && {
|
|
1527
|
+
gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))`,
|
|
1528
|
+
gridAutoRows: "minmax(5rem, auto)"
|
|
1529
|
+
},
|
|
1530
|
+
gap: `${y * .25}rem`
|
|
577
1531
|
},
|
|
578
|
-
"data-user-actions":
|
|
579
|
-
onClick:
|
|
580
|
-
...
|
|
1532
|
+
"data-user-actions": me,
|
|
1533
|
+
onClick: U,
|
|
1534
|
+
...p,
|
|
581
1535
|
children: [
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
/* @__PURE__ */ Z(
|
|
585
|
-
items:
|
|
586
|
-
strategy:
|
|
587
|
-
disabled: !
|
|
588
|
-
children: e.widgets?.map((e, t) =>
|
|
1536
|
+
Y,
|
|
1537
|
+
he,
|
|
1538
|
+
/* @__PURE__ */ Z(Ae, {
|
|
1539
|
+
items: ge,
|
|
1540
|
+
strategy: Me,
|
|
1541
|
+
disabled: !W,
|
|
1542
|
+
children: e.widgets?.map((e, t) => fe(e, t))
|
|
589
1543
|
})
|
|
590
1544
|
]
|
|
591
1545
|
});
|
|
592
|
-
return
|
|
593
|
-
sensors:
|
|
594
|
-
collisionDetection:
|
|
595
|
-
onDragEnd:
|
|
596
|
-
children:
|
|
597
|
-
}) :
|
|
1546
|
+
return W ? /* @__PURE__ */ Z(Te, {
|
|
1547
|
+
sensors: le,
|
|
1548
|
+
collisionDetection: De,
|
|
1549
|
+
onDragEnd: ue,
|
|
1550
|
+
children: ve
|
|
1551
|
+
}) : ve;
|
|
598
1552
|
});
|
|
599
1553
|
//#endregion
|
|
600
1554
|
//#region src/DashboardGridLayout.tsx
|
|
601
|
-
function
|
|
602
|
-
let t =
|
|
603
|
-
return
|
|
1555
|
+
function Et({ editMode: e }) {
|
|
1556
|
+
let t = y();
|
|
1557
|
+
return U.useEffect(() => {
|
|
604
1558
|
if (e) return t.startDrag({
|
|
605
1559
|
id: "dashboard-layout",
|
|
606
1560
|
type: "dashboard-widget",
|
|
@@ -611,14 +1565,14 @@ function Ie({ editMode: e }) {
|
|
|
611
1565
|
t.endDrag("dashboard");
|
|
612
1566
|
}, [e, t]), null;
|
|
613
1567
|
}
|
|
614
|
-
var
|
|
1568
|
+
var Dt = [
|
|
615
1569
|
"hsl(var(--chart-1))",
|
|
616
1570
|
"hsl(var(--chart-2))",
|
|
617
1571
|
"hsl(var(--chart-3))",
|
|
618
1572
|
"hsl(var(--chart-4))",
|
|
619
1573
|
"hsl(var(--chart-5))"
|
|
620
1574
|
];
|
|
621
|
-
function
|
|
1575
|
+
function Ot(e, t) {
|
|
622
1576
|
if (!e.widgets?.length) return e;
|
|
623
1577
|
let n = new Map(t.map((e) => [e.i, e])), r = e.widgets.map((e, t) => {
|
|
624
1578
|
let r = e.id || `widget-${t}`, i = n.get(r);
|
|
@@ -637,7 +1591,7 @@ function Re(e, t) {
|
|
|
637
1591
|
widgets: r
|
|
638
1592
|
};
|
|
639
1593
|
}
|
|
640
|
-
function
|
|
1594
|
+
function kt(e) {
|
|
641
1595
|
return { lg: e.widgets?.map((e, t) => ({
|
|
642
1596
|
i: e.id || `widget-${t}`,
|
|
643
1597
|
x: e.layout?.x ?? t % 4 * 3,
|
|
@@ -646,40 +1600,40 @@ function ze(e) {
|
|
|
646
1600
|
h: e.layout?.h ?? 4
|
|
647
1601
|
})) || [] };
|
|
648
1602
|
}
|
|
649
|
-
var
|
|
650
|
-
let { width: a, containerRef: o, mounted: s } =
|
|
651
|
-
i && (
|
|
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(() => {
|
|
1605
|
+
i && (d(!0), i(), setTimeout(() => d(!1), 600));
|
|
652
1606
|
}, [i]);
|
|
653
|
-
|
|
654
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !i)) return
|
|
655
|
-
|
|
1607
|
+
U.useEffect(() => {
|
|
1608
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !i)) return p.current = setInterval(m, e.refreshInterval * 1e3), () => {
|
|
1609
|
+
p.current && clearInterval(p.current);
|
|
656
1610
|
};
|
|
657
1611
|
}, [
|
|
658
1612
|
e.refreshInterval,
|
|
659
1613
|
i,
|
|
660
|
-
|
|
1614
|
+
m
|
|
661
1615
|
]);
|
|
662
|
-
let [
|
|
1616
|
+
let [g, _] = U.useState(() => kt(e)), v = U.useMemo(() => JSON.stringify(e.widgets?.map((e, t) => ({
|
|
663
1617
|
i: e.id || `widget-${t}`,
|
|
664
1618
|
x: e.layout?.x,
|
|
665
1619
|
y: e.layout?.y,
|
|
666
1620
|
w: e.layout?.w,
|
|
667
1621
|
h: e.layout?.h
|
|
668
1622
|
})) ?? []), [e.widgets]);
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}, [
|
|
672
|
-
let
|
|
673
|
-
|
|
674
|
-
}, [n]),
|
|
675
|
-
r ? r(
|
|
1623
|
+
U.useEffect(() => {
|
|
1624
|
+
_(kt(e));
|
|
1625
|
+
}, [v]);
|
|
1626
|
+
let y = U.useCallback((e, t) => {
|
|
1627
|
+
_(t), n?.(e);
|
|
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);
|
|
676
1630
|
}, [
|
|
677
1631
|
r,
|
|
678
1632
|
e,
|
|
679
|
-
|
|
680
|
-
]),
|
|
681
|
-
|
|
682
|
-
}, [e]),
|
|
1633
|
+
g
|
|
1634
|
+
]), S = U.useCallback(() => {
|
|
1635
|
+
_(kt(e));
|
|
1636
|
+
}, [e]), C = U.useCallback((e) => {
|
|
683
1637
|
if (e.component) return e.component;
|
|
684
1638
|
let t = e.type, n = e.options || {};
|
|
685
1639
|
if (t === "bar" || t === "horizontal-bar" || t === "line" || t === "area" || t === "pie" || t === "donut" || t === "scatter" || t === "funnel") {
|
|
@@ -697,7 +1651,7 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
697
1651
|
aggregate: o,
|
|
698
1652
|
xAxisKey: i,
|
|
699
1653
|
series: [{ dataKey: s }],
|
|
700
|
-
colors:
|
|
1654
|
+
colors: Dt,
|
|
701
1655
|
className: "h-full"
|
|
702
1656
|
};
|
|
703
1657
|
}
|
|
@@ -714,7 +1668,7 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
714
1668
|
aggregate: n,
|
|
715
1669
|
xAxisKey: i,
|
|
716
1670
|
series: [{ dataKey: e.valueField || "value" }],
|
|
717
|
-
colors:
|
|
1671
|
+
colors: Dt,
|
|
718
1672
|
className: "h-full"
|
|
719
1673
|
};
|
|
720
1674
|
}
|
|
@@ -724,7 +1678,7 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
724
1678
|
data: Array.isArray(r) ? r : r?.items || [],
|
|
725
1679
|
xAxisKey: i,
|
|
726
1680
|
series: [{ dataKey: a }],
|
|
727
|
-
colors:
|
|
1681
|
+
colors: Dt,
|
|
728
1682
|
className: "h-full"
|
|
729
1683
|
};
|
|
730
1684
|
}
|
|
@@ -785,10 +1739,10 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
785
1739
|
}, []);
|
|
786
1740
|
return /* @__PURE__ */ Q("div", {
|
|
787
1741
|
ref: o,
|
|
788
|
-
className:
|
|
1742
|
+
className: H("w-full", t),
|
|
789
1743
|
"data-testid": "grid-layout",
|
|
790
1744
|
children: [
|
|
791
|
-
|
|
1745
|
+
f && /* @__PURE__ */ Z(Et, { editMode: c }),
|
|
792
1746
|
/* @__PURE__ */ Q("div", {
|
|
793
1747
|
className: "mb-4 flex items-center justify-between",
|
|
794
1748
|
children: [/* @__PURE__ */ Z("h2", {
|
|
@@ -796,44 +1750,44 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
796
1750
|
children: e.title || "Dashboard"
|
|
797
1751
|
}), /* @__PURE__ */ Z("div", {
|
|
798
1752
|
className: "flex gap-2",
|
|
799
|
-
children:
|
|
800
|
-
/* @__PURE__ */ Q(
|
|
801
|
-
onClick:
|
|
1753
|
+
children: c ? /* @__PURE__ */ Q(Ve, { children: [
|
|
1754
|
+
/* @__PURE__ */ Q(k, {
|
|
1755
|
+
onClick: b,
|
|
802
1756
|
size: "sm",
|
|
803
1757
|
variant: "default",
|
|
804
|
-
children: [/* @__PURE__ */ Z(
|
|
1758
|
+
children: [/* @__PURE__ */ Z(Se, { className: "h-4 w-4 mr-2" }), "Save Layout"]
|
|
805
1759
|
}),
|
|
806
|
-
/* @__PURE__ */ Q(
|
|
807
|
-
onClick:
|
|
1760
|
+
/* @__PURE__ */ Q(k, {
|
|
1761
|
+
onClick: S,
|
|
808
1762
|
size: "sm",
|
|
809
1763
|
variant: "outline",
|
|
810
|
-
children: [/* @__PURE__ */ Z(
|
|
1764
|
+
children: [/* @__PURE__ */ Z(we, { className: "h-4 w-4 mr-2" }), "Reset"]
|
|
811
1765
|
}),
|
|
812
|
-
/* @__PURE__ */ Z(
|
|
813
|
-
onClick: () =>
|
|
1766
|
+
/* @__PURE__ */ Z(k, {
|
|
1767
|
+
onClick: () => l(!1),
|
|
814
1768
|
size: "sm",
|
|
815
1769
|
variant: "ghost",
|
|
816
1770
|
children: "Cancel"
|
|
817
1771
|
})
|
|
818
|
-
] }) : /* @__PURE__ */ Q(
|
|
819
|
-
onClick:
|
|
1772
|
+
] }) : /* @__PURE__ */ Q(Ve, { children: [i && /* @__PURE__ */ Q(k, {
|
|
1773
|
+
onClick: m,
|
|
820
1774
|
size: "sm",
|
|
821
1775
|
variant: "outline",
|
|
822
|
-
disabled:
|
|
1776
|
+
disabled: u,
|
|
823
1777
|
"aria-label": "Refresh dashboard",
|
|
824
|
-
children: [/* @__PURE__ */ Z(
|
|
825
|
-
}), /* @__PURE__ */ Q(
|
|
826
|
-
onClick: () =>
|
|
1778
|
+
children: [/* @__PURE__ */ Z(xe, { className: H("h-4 w-4 mr-2", u && "animate-spin") }), u ? "Refreshing…" : "Refresh All"]
|
|
1779
|
+
}), /* @__PURE__ */ Q(k, {
|
|
1780
|
+
onClick: () => l(!0),
|
|
827
1781
|
size: "sm",
|
|
828
1782
|
variant: "outline",
|
|
829
|
-
children: [/* @__PURE__ */ Z(
|
|
1783
|
+
children: [/* @__PURE__ */ Z(_e, { className: "h-4 w-4 mr-2" }), "Edit Layout"]
|
|
830
1784
|
})] })
|
|
831
1785
|
})]
|
|
832
1786
|
}),
|
|
833
|
-
s && /* @__PURE__ */ Z(
|
|
1787
|
+
s && /* @__PURE__ */ Z(He, {
|
|
834
1788
|
className: "layout",
|
|
835
1789
|
width: a,
|
|
836
|
-
layouts:
|
|
1790
|
+
layouts: g,
|
|
837
1791
|
breakpoints: {
|
|
838
1792
|
lg: 1200,
|
|
839
1793
|
md: 996,
|
|
@@ -850,41 +1804,41 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
850
1804
|
},
|
|
851
1805
|
rowHeight: 60,
|
|
852
1806
|
dragConfig: {
|
|
853
|
-
enabled:
|
|
1807
|
+
enabled: c,
|
|
854
1808
|
handle: ".drag-handle"
|
|
855
1809
|
},
|
|
856
|
-
resizeConfig: { enabled:
|
|
857
|
-
onLayoutChange:
|
|
1810
|
+
resizeConfig: { enabled: c },
|
|
1811
|
+
onLayoutChange: y,
|
|
858
1812
|
children: e.widgets?.map((e, t) => {
|
|
859
|
-
let n = e.id || `widget-${t}`, r =
|
|
1813
|
+
let n = e.id || `widget-${t}`, r = C(e);
|
|
860
1814
|
return /* @__PURE__ */ Z("div", {
|
|
861
1815
|
className: "h-full",
|
|
862
1816
|
children: e.type === "metric" ? /* @__PURE__ */ Q("div", {
|
|
863
1817
|
className: "h-full w-full relative",
|
|
864
|
-
children: [
|
|
1818
|
+
children: [c && /* @__PURE__ */ Z("div", {
|
|
865
1819
|
className: "drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border",
|
|
866
|
-
children: /* @__PURE__ */ Z(
|
|
867
|
-
}), /* @__PURE__ */ Z(
|
|
1820
|
+
children: /* @__PURE__ */ Z(ve, { className: "h-4 w-4" })
|
|
1821
|
+
}), /* @__PURE__ */ Z(h, {
|
|
868
1822
|
schema: r,
|
|
869
1823
|
className: "h-full w-full"
|
|
870
1824
|
})]
|
|
871
|
-
}) : /* @__PURE__ */ Q(
|
|
872
|
-
className:
|
|
873
|
-
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, {
|
|
874
1828
|
className: "pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between",
|
|
875
|
-
children: [/* @__PURE__ */ Z(
|
|
1829
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
876
1830
|
className: "text-base font-medium tracking-tight truncate",
|
|
877
1831
|
title: e.title,
|
|
878
1832
|
children: e.title
|
|
879
|
-
}),
|
|
1833
|
+
}), c && /* @__PURE__ */ Z("div", {
|
|
880
1834
|
className: "drag-handle cursor-move p-1 hover:bg-muted/40 rounded",
|
|
881
|
-
children: /* @__PURE__ */ Z(
|
|
1835
|
+
children: /* @__PURE__ */ Z(ve, { className: "h-4 w-4" })
|
|
882
1836
|
})]
|
|
883
|
-
}), /* @__PURE__ */ Z(
|
|
1837
|
+
}), /* @__PURE__ */ Z(j, {
|
|
884
1838
|
className: "p-0 h-full",
|
|
885
1839
|
children: /* @__PURE__ */ Z("div", {
|
|
886
|
-
className:
|
|
887
|
-
children: /* @__PURE__ */ Z(
|
|
1840
|
+
className: H("h-full w-full overflow-auto p-4"),
|
|
1841
|
+
children: /* @__PURE__ */ Z(h, { schema: r })
|
|
888
1842
|
})
|
|
889
1843
|
})]
|
|
890
1844
|
})
|
|
@@ -893,7 +1847,7 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
893
1847
|
})
|
|
894
1848
|
]
|
|
895
1849
|
});
|
|
896
|
-
},
|
|
1850
|
+
}, jt = C({
|
|
897
1851
|
"dashboard.trend.vsLastQuarter": "vs last quarter",
|
|
898
1852
|
"dashboard.trend.vsLastMonth": "vs last month",
|
|
899
1853
|
"dashboard.trend.vsLastWeek": "vs last week",
|
|
@@ -901,7 +1855,7 @@ var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
901
1855
|
"dashboard.trend.vsYesterday": "vs yesterday",
|
|
902
1856
|
"dashboard.trend.vsPreviousPeriod": "vs previous period"
|
|
903
1857
|
}, "dashboard.trend.vsLastQuarter");
|
|
904
|
-
function
|
|
1858
|
+
function Mt(e) {
|
|
905
1859
|
switch (e.trim().toLowerCase().replace(/\s+/g, " ")) {
|
|
906
1860
|
case "vs last quarter":
|
|
907
1861
|
case "vs previous quarter": return "dashboard.trend.vsLastQuarter";
|
|
@@ -917,11 +1871,11 @@ function He(e) {
|
|
|
917
1871
|
default: return;
|
|
918
1872
|
}
|
|
919
1873
|
}
|
|
920
|
-
function
|
|
1874
|
+
function Nt(e, t, n) {
|
|
921
1875
|
if (e == null) return "";
|
|
922
1876
|
if (typeof e == "string") {
|
|
923
1877
|
let r = Number(e);
|
|
924
|
-
return !isFinite(r) || e.trim() === "" ? e :
|
|
1878
|
+
return !isFinite(r) || e.trim() === "" ? e : Nt(r, t, n);
|
|
925
1879
|
}
|
|
926
1880
|
if (!isFinite(e)) return String(e);
|
|
927
1881
|
let r = {
|
|
@@ -930,6 +1884,16 @@ function Ue(e, t, n) {
|
|
|
930
1884
|
"€": "EUR",
|
|
931
1885
|
"£": "GBP"
|
|
932
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
|
+
}
|
|
933
1897
|
if (a) {
|
|
934
1898
|
let t = n || r[i[0]] || "USD";
|
|
935
1899
|
try {
|
|
@@ -948,10 +1912,10 @@ function Ue(e, t, n) {
|
|
|
948
1912
|
maximumFractionDigits: c
|
|
949
1913
|
}).format(e);
|
|
950
1914
|
}
|
|
951
|
-
function
|
|
1915
|
+
function Pt(e) {
|
|
952
1916
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
953
1917
|
}
|
|
954
|
-
var
|
|
1918
|
+
var Ft = {
|
|
955
1919
|
default: "bg-muted text-muted-foreground",
|
|
956
1920
|
blue: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
957
1921
|
teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
|
|
@@ -960,18 +1924,27 @@ var Ge = {
|
|
|
960
1924
|
success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
|
|
961
1925
|
warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
|
|
962
1926
|
danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
|
|
963
|
-
},
|
|
964
|
-
|
|
965
|
-
|
|
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);
|
|
966
1939
|
if (!e) return e;
|
|
967
|
-
let t =
|
|
968
|
-
return t ?
|
|
1940
|
+
let t = Mt(e);
|
|
1941
|
+
return t ? _(t) : e;
|
|
969
1942
|
}, [
|
|
970
1943
|
a,
|
|
971
1944
|
n?.label,
|
|
972
|
-
|
|
973
|
-
]),
|
|
974
|
-
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);
|
|
975
1948
|
return `${d && n.startsWith(d) ? "" : d ?? ""}${n}${f && n.endsWith(f) ? "" : f ?? ""}`;
|
|
976
1949
|
}, [
|
|
977
1950
|
t,
|
|
@@ -979,35 +1952,69 @@ var Ge = {
|
|
|
979
1952
|
u,
|
|
980
1953
|
d,
|
|
981
1954
|
f
|
|
982
|
-
]),
|
|
1955
|
+
]), b = q(() => {
|
|
983
1956
|
if (typeof r == "string") {
|
|
984
|
-
let e =
|
|
1957
|
+
let e = oe(r);
|
|
985
1958
|
return e ? /* @__PURE__ */ Z(e, { className: "h-4 w-4" }) : null;
|
|
986
1959
|
}
|
|
987
1960
|
return r;
|
|
988
1961
|
}, [r]);
|
|
989
|
-
|
|
990
|
-
|
|
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),
|
|
991
1998
|
onClick: p,
|
|
992
1999
|
role: p ? "button" : void 0,
|
|
993
2000
|
tabIndex: p ? 0 : void 0,
|
|
994
2001
|
onKeyDown: p ? (e) => {
|
|
995
2002
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
|
|
996
2003
|
} : void 0,
|
|
997
|
-
...
|
|
998
|
-
children: [/* @__PURE__ */ Q(
|
|
2004
|
+
...h,
|
|
2005
|
+
children: [/* @__PURE__ */ Q(M, {
|
|
999
2006
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
1000
|
-
children: [/* @__PURE__ */ Z(
|
|
2007
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1001
2008
|
className: "text-sm font-medium truncate",
|
|
1002
|
-
children:
|
|
1003
|
-
}),
|
|
1004
|
-
className:
|
|
1005
|
-
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
|
|
1006
2013
|
})]
|
|
1007
|
-
}), /* @__PURE__ */ Z(
|
|
2014
|
+
}), /* @__PURE__ */ Z(j, { children: o ? /* @__PURE__ */ Q("div", {
|
|
1008
2015
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
1009
2016
|
"data-testid": "metric-loading",
|
|
1010
|
-
children: [/* @__PURE__ */ Z(
|
|
2017
|
+
children: [/* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
1011
2018
|
className: "text-sm",
|
|
1012
2019
|
children: "Loading…"
|
|
1013
2020
|
})]
|
|
@@ -1015,51 +2022,51 @@ var Ge = {
|
|
|
1015
2022
|
className: "flex items-center gap-2",
|
|
1016
2023
|
"data-testid": "metric-error",
|
|
1017
2024
|
role: "alert",
|
|
1018
|
-
children: [/* @__PURE__ */ Z(
|
|
2025
|
+
children: [/* @__PURE__ */ Z(fe, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
1019
2026
|
className: "text-xs text-destructive truncate",
|
|
1020
2027
|
children: s
|
|
1021
2028
|
})]
|
|
1022
|
-
}) : /* @__PURE__ */ Q(
|
|
1023
|
-
className: "text-2xl font-bold truncate",
|
|
1024
|
-
children:
|
|
2029
|
+
}) : /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z("div", {
|
|
2030
|
+
className: "text-2xl font-bold tabular-nums tracking-tight truncate",
|
|
2031
|
+
children: y
|
|
1025
2032
|
}), (n || a) && /* @__PURE__ */ Q("div", {
|
|
1026
2033
|
className: "text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0",
|
|
1027
2034
|
children: [n && /* @__PURE__ */ Q("span", {
|
|
1028
|
-
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"),
|
|
1029
2036
|
children: [
|
|
1030
|
-
n.direction === "up" && /* @__PURE__ */ Z(
|
|
1031
|
-
n.direction === "down" && /* @__PURE__ */ Z(
|
|
1032
|
-
n.direction === "neutral" && /* @__PURE__ */ Z(
|
|
2037
|
+
n.direction === "up" && /* @__PURE__ */ Z(me, { className: "h-3 w-3 mr-1" }),
|
|
2038
|
+
n.direction === "down" && /* @__PURE__ */ Z(pe, { className: "h-3 w-3 mr-1" }),
|
|
2039
|
+
n.direction === "neutral" && /* @__PURE__ */ Z(be, { className: "h-3 w-3 mr-1" }),
|
|
1033
2040
|
n.value,
|
|
1034
2041
|
"%"
|
|
1035
2042
|
]
|
|
1036
2043
|
}), /* @__PURE__ */ Z("span", {
|
|
1037
2044
|
className: "truncate min-w-0",
|
|
1038
|
-
children:
|
|
2045
|
+
children: v
|
|
1039
2046
|
})]
|
|
1040
2047
|
})] }) })]
|
|
1041
2048
|
});
|
|
1042
2049
|
};
|
|
1043
2050
|
//#endregion
|
|
1044
2051
|
//#region src/MetricCard.tsx
|
|
1045
|
-
function
|
|
2052
|
+
function Rt(e) {
|
|
1046
2053
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
1047
2054
|
}
|
|
1048
|
-
var
|
|
1049
|
-
let u = n ?
|
|
1050
|
-
return /* @__PURE__ */ Q(
|
|
1051
|
-
className:
|
|
2055
|
+
var zt = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
|
|
2056
|
+
let u = n ? oe(n) : null;
|
|
2057
|
+
return /* @__PURE__ */ Q(A, {
|
|
2058
|
+
className: H("h-full", o),
|
|
1052
2059
|
...l,
|
|
1053
|
-
children: [/* @__PURE__ */ Q(
|
|
2060
|
+
children: [/* @__PURE__ */ Q(M, {
|
|
1054
2061
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
1055
|
-
children: [/* @__PURE__ */ Z(
|
|
2062
|
+
children: [/* @__PURE__ */ Z(N, {
|
|
1056
2063
|
className: "text-sm font-medium",
|
|
1057
|
-
children:
|
|
2064
|
+
children: Rt(e)
|
|
1058
2065
|
}), u && /* @__PURE__ */ Z(u, { className: "h-4 w-4 text-muted-foreground" })]
|
|
1059
|
-
}), /* @__PURE__ */ Z(
|
|
2066
|
+
}), /* @__PURE__ */ Z(j, { children: s ? /* @__PURE__ */ Q("div", {
|
|
1060
2067
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
1061
2068
|
"data-testid": "metric-card-loading",
|
|
1062
|
-
children: [/* @__PURE__ */ Z(
|
|
2069
|
+
children: [/* @__PURE__ */ Z(ye, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
1063
2070
|
className: "text-sm",
|
|
1064
2071
|
children: "Loading…"
|
|
1065
2072
|
})]
|
|
@@ -1067,222 +2074,231 @@ var Je = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
1067
2074
|
className: "flex items-center gap-2",
|
|
1068
2075
|
"data-testid": "metric-card-error",
|
|
1069
2076
|
role: "alert",
|
|
1070
|
-
children: [/* @__PURE__ */ Z(
|
|
2077
|
+
children: [/* @__PURE__ */ Z(fe, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
1071
2078
|
className: "text-xs text-destructive truncate",
|
|
1072
2079
|
children: c
|
|
1073
2080
|
})]
|
|
1074
|
-
}) : /* @__PURE__ */ Q(
|
|
2081
|
+
}) : /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z("div", {
|
|
1075
2082
|
className: "text-2xl font-bold",
|
|
1076
2083
|
children: t
|
|
1077
2084
|
}), (r || i || a) && /* @__PURE__ */ Q("p", {
|
|
1078
2085
|
className: "text-xs text-muted-foreground flex items-center mt-1",
|
|
1079
2086
|
children: [r && i && /* @__PURE__ */ Q("span", {
|
|
1080
|
-
className:
|
|
2087
|
+
className: H("flex items-center mr-2", r === "up" && "text-green-500", r === "down" && "text-red-500", r === "neutral" && "text-yellow-500"),
|
|
1081
2088
|
children: [
|
|
1082
|
-
r === "up" && /* @__PURE__ */ Z(
|
|
1083
|
-
r === "down" && /* @__PURE__ */ Z(
|
|
1084
|
-
r === "neutral" && /* @__PURE__ */ Z(
|
|
2089
|
+
r === "up" && /* @__PURE__ */ Z(me, { className: "h-3 w-3 mr-1" }),
|
|
2090
|
+
r === "down" && /* @__PURE__ */ Z(pe, { className: "h-3 w-3 mr-1" }),
|
|
2091
|
+
r === "neutral" && /* @__PURE__ */ Z(be, { className: "h-3 w-3 mr-1" }),
|
|
1085
2092
|
i
|
|
1086
2093
|
]
|
|
1087
|
-
}),
|
|
2094
|
+
}), Rt(a)]
|
|
1088
2095
|
})] }) })]
|
|
1089
2096
|
});
|
|
1090
|
-
},
|
|
1091
|
-
let
|
|
1092
|
-
|
|
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(() => {
|
|
1093
2100
|
let t = !0;
|
|
1094
|
-
if (!(!
|
|
1095
|
-
t &&
|
|
2101
|
+
if (!(!j || !e || typeof j.getObjectSchema != "function")) return j.getObjectSchema(e).then((e) => {
|
|
2102
|
+
t && U(e);
|
|
1096
2103
|
}).catch(() => {}), () => {
|
|
1097
2104
|
t = !1;
|
|
1098
2105
|
};
|
|
1099
|
-
}, [
|
|
1100
|
-
let
|
|
1101
|
-
let e =
|
|
2106
|
+
}, [j, e]);
|
|
2107
|
+
let W = q(() => {
|
|
2108
|
+
let e = t?.field;
|
|
1102
2109
|
if (!e || !se?.fields) return null;
|
|
1103
|
-
let
|
|
1104
|
-
return Array.isArray(
|
|
1105
|
-
}, [se,
|
|
2110
|
+
let n = se.fields;
|
|
2111
|
+
return Array.isArray(n) ? n.find((t) => t?.name === e) || null : n[e] || null;
|
|
2112
|
+
}, [se, t?.field]), ce = q(() => {
|
|
1106
2113
|
if (v) return v;
|
|
1107
|
-
if (
|
|
1108
|
-
if (
|
|
1109
|
-
let e =
|
|
2114
|
+
if (W) {
|
|
2115
|
+
if (W.type === "currency") {
|
|
2116
|
+
let e = W.precision ?? W.scale ?? 0;
|
|
1110
2117
|
return e > 0 ? `0,0.${"0".repeat(e)}` : "0,0";
|
|
1111
2118
|
}
|
|
1112
|
-
if (
|
|
1113
|
-
if (
|
|
2119
|
+
if (W.type === "percent") return "0,0%";
|
|
2120
|
+
if (W.type === "number" || W.type === "integer") return "0,0";
|
|
1114
2121
|
}
|
|
1115
|
-
}, [v,
|
|
2122
|
+
}, [v, W]), { currency: le } = T(), de = q(() => {
|
|
1116
2123
|
if (y) return y;
|
|
1117
|
-
if (
|
|
1118
|
-
}, [
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
2124
|
+
if (W?.type === "currency") return w(W, le);
|
|
2125
|
+
}, [
|
|
2126
|
+
y,
|
|
2127
|
+
W,
|
|
2128
|
+
le
|
|
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) => {
|
|
2130
|
+
if (t && typeof n.aggregate == "function") {
|
|
2131
|
+
let i = await n.aggregate(e, {
|
|
2132
|
+
field: t.field,
|
|
2133
|
+
function: t.function,
|
|
2134
|
+
groupBy: t.groupBy || "_all",
|
|
1124
2135
|
filter: r
|
|
1125
2136
|
}), a = Array.isArray(i) ? i : [];
|
|
1126
2137
|
if (a.length === 0) return 0;
|
|
1127
|
-
if (
|
|
1128
|
-
let e = `${
|
|
1129
|
-
return a.reduce((
|
|
2138
|
+
if (t.function === "count") {
|
|
2139
|
+
let e = `${t.field}_count`;
|
|
2140
|
+
return a.reduce((n, r) => n + (Number(r[e]) || Number(r[t.field]) || Number(r.count) || 0), 0);
|
|
1130
2141
|
}
|
|
1131
2142
|
let o = a[0];
|
|
1132
|
-
return o[`${
|
|
2143
|
+
return o[`${t.field}_${t.function}`] ?? o[t.field] ?? o.value ?? 0;
|
|
1133
2144
|
}
|
|
1134
|
-
if (typeof
|
|
1135
|
-
let
|
|
1136
|
-
return (Array.isArray(
|
|
2145
|
+
if (typeof n.find == "function") {
|
|
2146
|
+
let t = await n.find(e, { $filter: r });
|
|
2147
|
+
return (Array.isArray(t) ? t : t?.data || t?.records || []).length;
|
|
1137
2148
|
}
|
|
1138
2149
|
return null;
|
|
1139
|
-
}, [e,
|
|
2150
|
+
}, [e, fe]), ge = G(async (t, r) => {
|
|
1140
2151
|
if (!(!t || !e)) {
|
|
1141
|
-
|
|
2152
|
+
r.current && (V(!0), oe(null));
|
|
1142
2153
|
try {
|
|
1143
|
-
let e =
|
|
2154
|
+
let e = D ? m(n, D) : null, [i, a] = await Promise.all([he(t, Y), e ? he(t, e) : Promise.resolve(null)]);
|
|
1144
2155
|
if (i === null) return;
|
|
1145
|
-
|
|
2156
|
+
r.current && (F(i), ee(typeof a == "number" && Number.isFinite(a) ? a : null));
|
|
1146
2157
|
} catch (e) {
|
|
1147
|
-
console.error("[ObjectMetricWidget] Fetch error:", e),
|
|
2158
|
+
console.error("[ObjectMetricWidget] Fetch error:", e), r.current && oe(e instanceof Error ? e.message : "Failed to load metric");
|
|
1148
2159
|
} finally {
|
|
1149
|
-
|
|
2160
|
+
r.current && V(!1);
|
|
1150
2161
|
}
|
|
1151
2162
|
}
|
|
1152
2163
|
}, [
|
|
1153
2164
|
e,
|
|
1154
|
-
K,
|
|
1155
|
-
de,
|
|
1156
2165
|
fe,
|
|
1157
|
-
pe
|
|
2166
|
+
pe,
|
|
2167
|
+
me,
|
|
2168
|
+
he
|
|
1158
2169
|
]);
|
|
1159
|
-
|
|
2170
|
+
K(() => {
|
|
1160
2171
|
let t = { current: !0 };
|
|
1161
|
-
return
|
|
2172
|
+
return j && e ? ge(j, t) : (F(null), oe(null)), () => {
|
|
1162
2173
|
t.current = !1;
|
|
1163
2174
|
};
|
|
1164
2175
|
}, [
|
|
1165
|
-
|
|
2176
|
+
j,
|
|
1166
2177
|
e,
|
|
1167
|
-
|
|
2178
|
+
ge
|
|
1168
2179
|
]);
|
|
1169
|
-
let
|
|
1170
|
-
S && typeof
|
|
1171
|
-
let
|
|
1172
|
-
if (!
|
|
1173
|
-
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);
|
|
1174
2185
|
if (!e) return;
|
|
1175
|
-
let
|
|
2186
|
+
let t = a(D, n), r = `dashboard.trend.${t}`, i = {
|
|
1176
2187
|
vsPreviousPeriod: "vs previous period",
|
|
1177
2188
|
vsLastWeek: "vs last week",
|
|
1178
2189
|
vsLastMonth: "vs last month",
|
|
1179
2190
|
vsLastQuarter: "vs last quarter",
|
|
1180
2191
|
vsLastYear: "vs last year",
|
|
1181
2192
|
vsYesterday: "vs yesterday"
|
|
1182
|
-
}, o =
|
|
2193
|
+
}, o = O ? O(r, i[t] || t) : i[t] || t;
|
|
1183
2194
|
return {
|
|
1184
2195
|
value: e.value,
|
|
1185
2196
|
direction: e.direction,
|
|
1186
2197
|
label: o
|
|
1187
2198
|
};
|
|
1188
2199
|
}, [
|
|
1189
|
-
|
|
2200
|
+
D,
|
|
2201
|
+
P,
|
|
1190
2202
|
I,
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
return o(C, {}, (typeof w == "string" ? w : w?.defaultValue || "") || e || "Details");
|
|
2203
|
+
n,
|
|
2204
|
+
O
|
|
2205
|
+
]) ?? o, ve = d(C) && !!e && !!j, ye = q(() => {
|
|
2206
|
+
let e = typeof r == "string" ? r : r?.defaultValue || "";
|
|
2207
|
+
return p(C, {}, (typeof E == "string" ? E : E?.defaultValue || "") || e || "Details");
|
|
1197
2208
|
}, [
|
|
1198
2209
|
C,
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
]),
|
|
1202
|
-
if (!
|
|
1203
|
-
let t = C?.target ?? "drawer", n = C?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i
|
|
2210
|
+
r,
|
|
2211
|
+
E
|
|
2212
|
+
]), be = q(() => {
|
|
2213
|
+
if (!ve) return null;
|
|
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, {
|
|
2215
|
+
objectName: e,
|
|
2216
|
+
filter: Y,
|
|
2217
|
+
onNavigate: () => N(!1)
|
|
2218
|
+
}), a;
|
|
1204
2219
|
if (r) {
|
|
1205
|
-
let e = n.filter, t = e ?
|
|
1206
|
-
|
|
2220
|
+
let e = n.filter, t = e ? Y ? { $and: [e, Y] } : e : Y;
|
|
2221
|
+
a = /* @__PURE__ */ Z("div", {
|
|
1207
2222
|
className: "h-full overflow-auto",
|
|
1208
|
-
children: /* @__PURE__ */ Z(
|
|
2223
|
+
children: /* @__PURE__ */ Z(h, { schema: {
|
|
1209
2224
|
type: "spec-report",
|
|
1210
2225
|
...n,
|
|
1211
2226
|
filter: t
|
|
1212
2227
|
} })
|
|
1213
2228
|
});
|
|
1214
|
-
} else
|
|
2229
|
+
} else a = /* @__PURE__ */ Z("div", {
|
|
1215
2230
|
className: "h-full overflow-auto",
|
|
1216
|
-
children: /* @__PURE__ */ Z(
|
|
2231
|
+
children: /* @__PURE__ */ Z(h, { schema: {
|
|
1217
2232
|
type: "object-data-table",
|
|
1218
2233
|
objectName: e,
|
|
1219
|
-
filter:
|
|
2234
|
+
filter: Y,
|
|
1220
2235
|
pageSize: 25,
|
|
1221
|
-
drillDown: {
|
|
2236
|
+
drillDown: {
|
|
2237
|
+
enabled: !0,
|
|
2238
|
+
mode: "record",
|
|
2239
|
+
target: "dialog"
|
|
2240
|
+
}
|
|
1222
2241
|
} })
|
|
1223
2242
|
});
|
|
1224
|
-
return t === "dialog" ? /* @__PURE__ */ Z(
|
|
2243
|
+
return t === "dialog" ? /* @__PURE__ */ Z(te, {
|
|
1225
2244
|
open: !0,
|
|
1226
|
-
onOpenChange: (e) => !e &&
|
|
1227
|
-
children: /* @__PURE__ */ Q(
|
|
2245
|
+
onOpenChange: (e) => !e && N(!1),
|
|
2246
|
+
children: /* @__PURE__ */ Q(L, {
|
|
1228
2247
|
className: "max-w-5xl",
|
|
1229
|
-
children: [/* @__PURE__ */
|
|
2248
|
+
children: [/* @__PURE__ */ Q(R, {
|
|
2249
|
+
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2250
|
+
children: [/* @__PURE__ */ Z(ne, { children: ye }), i]
|
|
2251
|
+
}), a]
|
|
1230
2252
|
})
|
|
1231
|
-
}) : /* @__PURE__ */ Z(
|
|
2253
|
+
}) : /* @__PURE__ */ Z(z, {
|
|
1232
2254
|
open: !0,
|
|
1233
|
-
onOpenChange: (e) => !e &&
|
|
1234
|
-
children: /* @__PURE__ */ Q(
|
|
2255
|
+
onOpenChange: (e) => !e && N(!1),
|
|
2256
|
+
children: /* @__PURE__ */ Q(ie, {
|
|
1235
2257
|
side: "right",
|
|
1236
2258
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col",
|
|
1237
|
-
children: [/* @__PURE__ */
|
|
2259
|
+
children: [/* @__PURE__ */ Q(B, {
|
|
2260
|
+
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2261
|
+
children: [/* @__PURE__ */ Z(ae, { children: ye }), i]
|
|
2262
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1238
2263
|
className: "flex-1 overflow-hidden mt-2",
|
|
1239
|
-
children:
|
|
2264
|
+
children: a
|
|
1240
2265
|
})]
|
|
1241
2266
|
})
|
|
1242
2267
|
});
|
|
1243
2268
|
}, [
|
|
1244
|
-
|
|
2269
|
+
ve,
|
|
1245
2270
|
C,
|
|
1246
2271
|
e,
|
|
1247
|
-
|
|
1248
|
-
|
|
2272
|
+
Y,
|
|
2273
|
+
ye
|
|
1249
2274
|
]);
|
|
1250
|
-
return /* @__PURE__ */ Q(
|
|
1251
|
-
label:
|
|
1252
|
-
value:
|
|
1253
|
-
trend:
|
|
1254
|
-
icon:
|
|
1255
|
-
className:
|
|
1256
|
-
description:
|
|
1257
|
-
loading:
|
|
1258
|
-
error:
|
|
2275
|
+
return /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z(Lt, {
|
|
2276
|
+
label: r,
|
|
2277
|
+
value: X,
|
|
2278
|
+
trend: _e,
|
|
2279
|
+
icon: s,
|
|
2280
|
+
className: c,
|
|
2281
|
+
description: l,
|
|
2282
|
+
loading: re,
|
|
2283
|
+
error: H,
|
|
1259
2284
|
colorVariant: _,
|
|
1260
|
-
format:
|
|
1261
|
-
currency:
|
|
2285
|
+
format: ce,
|
|
2286
|
+
currency: de,
|
|
1262
2287
|
prefix: b,
|
|
1263
2288
|
suffix: x,
|
|
1264
|
-
|
|
1265
|
-
|
|
2289
|
+
variant: k,
|
|
2290
|
+
onClick: ve ? () => N(!0) : void 0
|
|
2291
|
+
}), M && be] });
|
|
1266
2292
|
};
|
|
1267
2293
|
//#endregion
|
|
1268
2294
|
//#region src/PivotTable.tsx
|
|
1269
|
-
function
|
|
1270
|
-
|
|
1271
|
-
let { t: e } = g(), t = e("dashboard.total");
|
|
1272
|
-
return !t || t === "dashboard.total" ? "Total" : t;
|
|
1273
|
-
} catch {
|
|
1274
|
-
return "Total";
|
|
1275
|
-
}
|
|
2295
|
+
function Vt() {
|
|
2296
|
+
return O()("dashboard.total", "Total");
|
|
1276
2297
|
}
|
|
1277
|
-
function
|
|
1278
|
-
|
|
1279
|
-
let { t: e } = g(), t = e("dashboard.noDataAvailable");
|
|
1280
|
-
return !t || t === "dashboard.noDataAvailable" ? "No data available" : t;
|
|
1281
|
-
} catch {
|
|
1282
|
-
return "No data available";
|
|
1283
|
-
}
|
|
2298
|
+
function Ht() {
|
|
2299
|
+
return O()("dashboard.noDataAvailable", "No data available");
|
|
1284
2300
|
}
|
|
1285
|
-
function
|
|
2301
|
+
function Ut(e, t) {
|
|
1286
2302
|
if (!t) return String(e);
|
|
1287
2303
|
let n = "", r = "", i = !1, a, o = t, s = o.match(/^([^0-9.,#]*)/);
|
|
1288
2304
|
if (s && s[1]) {
|
|
@@ -1299,11 +2315,11 @@ function Qe(e, t) {
|
|
|
1299
2315
|
}
|
|
1300
2316
|
return n + l + r;
|
|
1301
2317
|
}
|
|
1302
|
-
var
|
|
1303
|
-
function
|
|
1304
|
-
return e === "" ?
|
|
2318
|
+
var Wt = "—";
|
|
2319
|
+
function Gt(e, t) {
|
|
2320
|
+
return e === "" ? Wt : t?.[e] ?? e;
|
|
1305
2321
|
}
|
|
1306
|
-
function
|
|
2322
|
+
function Kt(e, t) {
|
|
1307
2323
|
if (e.length === 0) return 0;
|
|
1308
2324
|
switch (t) {
|
|
1309
2325
|
case "sum": return e.reduce((e, t) => e + t, 0);
|
|
@@ -1314,30 +2330,30 @@ function tt(e, t) {
|
|
|
1314
2330
|
default: return e.reduce((e, t) => e + t, 0);
|
|
1315
2331
|
}
|
|
1316
2332
|
}
|
|
1317
|
-
var
|
|
1318
|
-
let { title:
|
|
1319
|
-
b &&
|
|
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) => {
|
|
2335
|
+
b && a({
|
|
1320
2336
|
...e,
|
|
1321
2337
|
rowLabel: e.rowKey === void 0 ? e.rowLabel : n?.[e.rowKey] ?? e.rowKey,
|
|
1322
2338
|
colLabel: e.colKey === void 0 ? e.colLabel : r?.[e.colKey] ?? e.colKey
|
|
1323
2339
|
});
|
|
1324
2340
|
}, S = (e) => (t) => {
|
|
1325
2341
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
|
|
1326
|
-
}, 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:
|
|
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(() => {
|
|
1327
2343
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = {};
|
|
1328
2344
|
for (let r of w) {
|
|
1329
|
-
let i = String(r[
|
|
2345
|
+
let i = String(r[s] ?? ""), a = String(r[c] ?? ""), o = Number(r[l]) || 0;
|
|
1330
2346
|
e.set(i, !0), t.set(a, !0), n[i] || (n[i] = {}), n[i][a] || (n[i][a] = []), n[i][a].push(o);
|
|
1331
2347
|
}
|
|
1332
|
-
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 = {};
|
|
1333
2349
|
for (let e of r) {
|
|
1334
2350
|
a[e] = {};
|
|
1335
2351
|
let t = [];
|
|
1336
2352
|
for (let r of i) {
|
|
1337
|
-
let i = n[e]?.[r] ?? [], o =
|
|
1338
|
-
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];
|
|
1339
2355
|
}
|
|
1340
|
-
o[e] =
|
|
2356
|
+
o[e] = Kt(t, u);
|
|
1341
2357
|
}
|
|
1342
2358
|
for (let e of i) {
|
|
1343
2359
|
let t = [];
|
|
@@ -1345,31 +2361,31 @@ var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
1345
2361
|
let r = n[i]?.[e] ?? [];
|
|
1346
2362
|
t.push(...r);
|
|
1347
2363
|
}
|
|
1348
|
-
|
|
2364
|
+
d[e] = Kt(t, u);
|
|
1349
2365
|
}
|
|
1350
2366
|
let f = [];
|
|
1351
|
-
for (let e of w) f.push(Number(e[
|
|
2367
|
+
for (let e of w) f.push(Number(e[l]) || 0);
|
|
1352
2368
|
return {
|
|
1353
2369
|
rowKeys: r,
|
|
1354
2370
|
colKeys: i,
|
|
1355
2371
|
matrix: a,
|
|
1356
2372
|
rowTotals: o,
|
|
1357
|
-
colTotals:
|
|
1358
|
-
grandTotal:
|
|
2373
|
+
colTotals: d,
|
|
2374
|
+
grandTotal: Kt(f, u)
|
|
1359
2375
|
};
|
|
1360
2376
|
}, [
|
|
1361
2377
|
w,
|
|
2378
|
+
s,
|
|
1362
2379
|
c,
|
|
1363
2380
|
l,
|
|
1364
|
-
u
|
|
1365
|
-
|
|
1366
|
-
]), M = (e) => Qe(e, h);
|
|
2381
|
+
u
|
|
2382
|
+
]), j = (e) => Ut(e, h);
|
|
1367
2383
|
return w.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
1368
|
-
className:
|
|
1369
|
-
children: [
|
|
2384
|
+
className: H("overflow-auto", t),
|
|
2385
|
+
children: [o && /* @__PURE__ */ Z("h3", {
|
|
1370
2386
|
className: "text-sm font-semibold mb-2",
|
|
1371
|
-
children:
|
|
1372
|
-
}), /* @__PURE__ */ Z(
|
|
2387
|
+
children: o
|
|
2388
|
+
}), /* @__PURE__ */ Z(ee, {
|
|
1373
2389
|
"data-testid": "pivot-empty-state",
|
|
1374
2390
|
className: "py-8 gap-2 [&>h3]:hidden",
|
|
1375
2391
|
icon: /* @__PURE__ */ Q("svg", {
|
|
@@ -1413,10 +2429,10 @@ var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
1413
2429
|
description: y
|
|
1414
2430
|
})]
|
|
1415
2431
|
}) : /* @__PURE__ */ Q("div", {
|
|
1416
|
-
className:
|
|
1417
|
-
children: [
|
|
2432
|
+
className: H("overflow-auto", t),
|
|
2433
|
+
children: [o && /* @__PURE__ */ Z("h3", {
|
|
1418
2434
|
className: "text-sm font-semibold mb-2",
|
|
1419
|
-
children:
|
|
2435
|
+
children: o
|
|
1420
2436
|
}), /* @__PURE__ */ Q("table", {
|
|
1421
2437
|
className: "w-full text-sm border-collapse table-auto",
|
|
1422
2438
|
role: "table",
|
|
@@ -1426,22 +2442,22 @@ var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
1426
2442
|
children: [
|
|
1427
2443
|
/* @__PURE__ */ Z("th", {
|
|
1428
2444
|
className: "text-left p-2 font-medium text-muted-foreground whitespace-nowrap",
|
|
1429
|
-
children:
|
|
2445
|
+
children: i || s
|
|
1430
2446
|
}),
|
|
1431
|
-
|
|
2447
|
+
E.map((e) => {
|
|
1432
2448
|
let t = () => x({
|
|
1433
2449
|
scope: "column",
|
|
1434
2450
|
colKey: e
|
|
1435
2451
|
});
|
|
1436
2452
|
return /* @__PURE__ */ Z("th", {
|
|
1437
|
-
className:
|
|
1438
|
-
title: e === "" ? `${
|
|
2453
|
+
className: H("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", g?.[e] ?? "text-muted-foreground", C),
|
|
2454
|
+
title: e === "" ? `${c}: (empty)` : `${c}: ${e}`,
|
|
1439
2455
|
role: b ? "button" : void 0,
|
|
1440
2456
|
tabIndex: b ? 0 : void 0,
|
|
1441
2457
|
onClick: b ? t : void 0,
|
|
1442
2458
|
onKeyDown: b ? S(t) : void 0,
|
|
1443
|
-
"aria-label": b ? `Drill into ${
|
|
1444
|
-
children:
|
|
2459
|
+
"aria-label": b ? `Drill into ${c}: ${e || "(empty)"}` : void 0,
|
|
2460
|
+
children: Gt(e, r)
|
|
1445
2461
|
}, e);
|
|
1446
2462
|
}),
|
|
1447
2463
|
p && /* @__PURE__ */ Z("th", {
|
|
@@ -1454,7 +2470,7 @@ var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
1454
2470
|
className: "border-b border-border/50 hover:bg-muted/30",
|
|
1455
2471
|
children: [
|
|
1456
2472
|
/* @__PURE__ */ Z("td", {
|
|
1457
|
-
className:
|
|
2473
|
+
className: H("p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", C),
|
|
1458
2474
|
role: b ? "button" : void 0,
|
|
1459
2475
|
tabIndex: b ? 0 : void 0,
|
|
1460
2476
|
onClick: b ? () => x({
|
|
@@ -1465,41 +2481,41 @@ var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
1465
2481
|
scope: "row",
|
|
1466
2482
|
rowKey: e
|
|
1467
2483
|
})) : void 0,
|
|
1468
|
-
"aria-label": b ? `Drill into ${
|
|
1469
|
-
children:
|
|
2484
|
+
"aria-label": b ? `Drill into ${s}: ${e || "(empty)"}` : void 0,
|
|
2485
|
+
children: Gt(e, n)
|
|
1470
2486
|
}),
|
|
1471
|
-
|
|
1472
|
-
let n =
|
|
2487
|
+
E.map((t) => {
|
|
2488
|
+
let n = D[e]?.[t] ?? 0, r = () => x({
|
|
1473
2489
|
scope: "cell",
|
|
1474
2490
|
rowKey: e,
|
|
1475
2491
|
colKey: t,
|
|
1476
2492
|
value: n
|
|
1477
2493
|
});
|
|
1478
2494
|
return /* @__PURE__ */ Z("td", {
|
|
1479
|
-
className:
|
|
2495
|
+
className: H("text-right p-2 tabular-nums", g?.[t], C),
|
|
1480
2496
|
role: b ? "button" : void 0,
|
|
1481
2497
|
tabIndex: b ? 0 : void 0,
|
|
1482
2498
|
onClick: b ? r : void 0,
|
|
1483
2499
|
onKeyDown: b ? S(r) : void 0,
|
|
1484
|
-
"aria-label": b ? `Drill into ${
|
|
1485
|
-
children:
|
|
2500
|
+
"aria-label": b ? `Drill into ${s}=${e || "(empty)"}, ${c}=${t || "(empty)"}` : void 0,
|
|
2501
|
+
children: j(n)
|
|
1486
2502
|
}, t);
|
|
1487
2503
|
}),
|
|
1488
2504
|
p && /* @__PURE__ */ Z("td", {
|
|
1489
|
-
className:
|
|
2505
|
+
className: H("text-right p-2 font-semibold tabular-nums bg-muted/20", C),
|
|
1490
2506
|
role: b ? "button" : void 0,
|
|
1491
2507
|
tabIndex: b ? 0 : void 0,
|
|
1492
2508
|
onClick: b ? () => x({
|
|
1493
2509
|
scope: "row",
|
|
1494
2510
|
rowKey: e,
|
|
1495
|
-
value:
|
|
2511
|
+
value: O[e] ?? 0
|
|
1496
2512
|
}) : void 0,
|
|
1497
2513
|
onKeyDown: b ? S(() => x({
|
|
1498
2514
|
scope: "row",
|
|
1499
2515
|
rowKey: e,
|
|
1500
|
-
value:
|
|
2516
|
+
value: O[e] ?? 0
|
|
1501
2517
|
})) : void 0,
|
|
1502
|
-
children:
|
|
2518
|
+
children: j(O[e] ?? 0)
|
|
1503
2519
|
})
|
|
1504
2520
|
]
|
|
1505
2521
|
}, e)) }),
|
|
@@ -1510,424 +2526,51 @@ var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
1510
2526
|
className: "p-2",
|
|
1511
2527
|
children: v
|
|
1512
2528
|
}),
|
|
1513
|
-
|
|
1514
|
-
className:
|
|
2529
|
+
E.map((e) => /* @__PURE__ */ Z("td", {
|
|
2530
|
+
className: H("text-right p-2 tabular-nums", C),
|
|
1515
2531
|
role: b ? "button" : void 0,
|
|
1516
2532
|
tabIndex: b ? 0 : void 0,
|
|
1517
2533
|
onClick: b ? () => x({
|
|
1518
2534
|
scope: "column",
|
|
1519
2535
|
colKey: e,
|
|
1520
|
-
value:
|
|
2536
|
+
value: k[e] ?? 0
|
|
1521
2537
|
}) : void 0,
|
|
1522
2538
|
onKeyDown: b ? S(() => x({
|
|
1523
2539
|
scope: "column",
|
|
1524
2540
|
colKey: e,
|
|
1525
|
-
value:
|
|
2541
|
+
value: k[e] ?? 0
|
|
1526
2542
|
})) : void 0,
|
|
1527
|
-
children:
|
|
2543
|
+
children: j(k[e] ?? 0)
|
|
1528
2544
|
}, e)),
|
|
1529
2545
|
p && /* @__PURE__ */ Z("td", {
|
|
1530
|
-
className:
|
|
2546
|
+
className: H("text-right p-2 tabular-nums font-bold", C),
|
|
1531
2547
|
role: b ? "button" : void 0,
|
|
1532
2548
|
tabIndex: b ? 0 : void 0,
|
|
1533
2549
|
onClick: b ? () => x({
|
|
1534
2550
|
scope: "total",
|
|
1535
|
-
value:
|
|
2551
|
+
value: A
|
|
1536
2552
|
}) : void 0,
|
|
1537
2553
|
onKeyDown: b ? S(() => x({
|
|
1538
2554
|
scope: "total",
|
|
1539
|
-
value:
|
|
2555
|
+
value: A
|
|
1540
2556
|
})) : void 0,
|
|
1541
|
-
children:
|
|
2557
|
+
children: j(A)
|
|
1542
2558
|
})
|
|
1543
2559
|
]
|
|
1544
2560
|
}) })
|
|
1545
2561
|
]
|
|
1546
2562
|
})]
|
|
1547
2563
|
});
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
} : e);
|
|
1556
|
-
}
|
|
1557
|
-
function it(e, t) {
|
|
1558
|
-
if (!t?.fields) return [];
|
|
1559
|
-
let n = {};
|
|
1560
|
-
if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
|
|
1561
|
-
else for (let [e, r] of Object.entries(t.fields)) n[e] = {
|
|
1562
|
-
name: e,
|
|
1563
|
-
...r
|
|
1564
|
-
};
|
|
1565
|
-
let r = (e) => e === "lookup" || e === "reference" || e === "master_detail" || e === "user" || e === "owner", i = Array.isArray(e.columns) ? e.columns : [], a = /* @__PURE__ */ new Set();
|
|
1566
|
-
if (i.length > 0) {
|
|
1567
|
-
let e = i.map((e) => typeof e == "string" ? e : e.accessorKey || e.name).filter(Boolean);
|
|
1568
|
-
for (let t of e) {
|
|
1569
|
-
let e = n[t];
|
|
1570
|
-
e && r(e.type) && a.add(t);
|
|
1571
|
-
}
|
|
1572
|
-
} else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
|
|
1573
|
-
return Array.from(a);
|
|
1574
|
-
}
|
|
1575
|
-
var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
1576
|
-
let i = z(l), o = t || i?.dataSource, s = d(e.bind), { fieldLabel: u, fieldOptionLabel: f } = _(), p = "No data available", m = "No data source available for";
|
|
1577
|
-
try {
|
|
1578
|
-
let { t: e } = g(), t = e("dashboard.noDataAvailable");
|
|
1579
|
-
t && t !== "dashboard.noDataAvailable" && (p = t);
|
|
1580
|
-
let n = e("dashboard.noDataSourceFor");
|
|
1581
|
-
n && n !== "dashboard.noDataSourceFor" && (m = n);
|
|
1582
|
-
} catch {}
|
|
1583
|
-
let [h, v] = H([]), [y, b] = H(null), [x, S] = H(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [C, w] = H(null);
|
|
1584
|
-
B(() => {
|
|
1585
|
-
let t = !0;
|
|
1586
|
-
return e.objectName && !s && (!e.data || e.data.length === 0) ? (async () => {
|
|
1587
|
-
if (!o || !e.objectName) {
|
|
1588
|
-
t && S(!1);
|
|
1589
|
-
return;
|
|
1590
|
-
}
|
|
1591
|
-
t && (S(!0), w(null));
|
|
1592
|
-
try {
|
|
1593
|
-
let n;
|
|
1594
|
-
if (typeof o.find == "function") {
|
|
1595
|
-
let t = it(e, y), i = { $filter: a(e.filter) };
|
|
1596
|
-
t.length && (i.$expand = t), n = r(await o.find(e.objectName, i));
|
|
1597
|
-
} else return;
|
|
1598
|
-
t && v(n);
|
|
1599
|
-
} catch (e) {
|
|
1600
|
-
console.error("[ObjectDataTable] Fetch error:", e), t && w(e instanceof Error ? e.message : "Failed to load data");
|
|
1601
|
-
} finally {
|
|
1602
|
-
t && S(!1);
|
|
1603
|
-
}
|
|
1604
|
-
})() : t && S(!1), () => {
|
|
1605
|
-
t = !1;
|
|
1606
|
-
};
|
|
1607
|
-
}, [
|
|
1608
|
-
e.objectName,
|
|
1609
|
-
o,
|
|
1610
|
-
s,
|
|
1611
|
-
e.data,
|
|
1612
|
-
e.filter,
|
|
1613
|
-
y
|
|
1614
|
-
]), B(() => {
|
|
1615
|
-
let t = !0;
|
|
1616
|
-
if (!(!o || !e.objectName || typeof o.getObjectSchema != "function")) return o.getObjectSchema(e.objectName).then((e) => {
|
|
1617
|
-
t && b(e);
|
|
1618
|
-
}).catch(() => {}), () => {
|
|
1619
|
-
t = !1;
|
|
1620
|
-
};
|
|
1621
|
-
}, [e.objectName, o]);
|
|
1622
|
-
let T = s || e.data || h, E = Array.isArray(T) ? T : [], D = V(() => {
|
|
1623
|
-
let t = e.objectName, n = {};
|
|
1624
|
-
if (y?.fields) {
|
|
1625
|
-
let e = y.fields;
|
|
1626
|
-
if (Array.isArray(e)) for (let t of e) t?.name && (n[t.name] = t);
|
|
1627
|
-
else for (let [t, r] of Object.entries(e)) n[t] = {
|
|
1628
|
-
name: t,
|
|
1629
|
-
...r
|
|
1630
|
-
};
|
|
1631
|
-
}
|
|
1632
|
-
let r = (e) => {
|
|
1633
|
-
let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
|
|
1634
|
-
return t ? u(t, e, n) : n;
|
|
1635
|
-
}, i = (e) => {
|
|
1636
|
-
let r = n[e.accessorKey], i = e.referenceTo ?? r?.referenceTo ?? (typeof r?.reference == "string" ? r.reference : r?.reference?.to) ?? r?.target, a = e.options ?? r?.options;
|
|
1637
|
-
t && a && (r?.type === "select" || r?.type === "picklist" || r?.type === "dropdown" || r?.type === "status") && (a = a.map((n) => {
|
|
1638
|
-
if (n == null) return n;
|
|
1639
|
-
let r = typeof n == "object" ? n.value : n, i = typeof n == "object" && n.label || String(r);
|
|
1640
|
-
return {
|
|
1641
|
-
value: r,
|
|
1642
|
-
label: f(t, e.accessorKey, String(r), i),
|
|
1643
|
-
color: typeof n == "object" ? n.color : void 0
|
|
1644
|
-
};
|
|
1645
|
-
}));
|
|
1646
|
-
let o = {
|
|
1647
|
-
name: e.accessorKey,
|
|
1648
|
-
label: e.header,
|
|
1649
|
-
type: e.type ?? r?.type,
|
|
1650
|
-
options: a,
|
|
1651
|
-
referenceTo: i,
|
|
1652
|
-
format: e.format ?? r?.format,
|
|
1653
|
-
currency: e.currency ?? r?.currency ?? r?.defaultCurrency,
|
|
1654
|
-
decimals: e.decimals ?? r?.decimals ?? r?.precision ?? r?.scale
|
|
1655
|
-
}, s = new Set([
|
|
1656
|
-
"currency",
|
|
1657
|
-
"money",
|
|
1658
|
-
"number",
|
|
1659
|
-
"integer",
|
|
1660
|
-
"decimal",
|
|
1661
|
-
"float",
|
|
1662
|
-
"percent",
|
|
1663
|
-
"percentage"
|
|
1664
|
-
]), c = e.align ?? (s.has(o.type) || typeof o.format == "string" && /^[\$¥€£]|%$|0/.test(o.format) ? "right" : void 0);
|
|
1665
|
-
if (typeof e.cell == "function") return {
|
|
1666
|
-
...e,
|
|
1667
|
-
...o,
|
|
1668
|
-
align: c
|
|
1669
|
-
};
|
|
1670
|
-
let l = (e) => {
|
|
1671
|
-
if (e == null || e === "") return "";
|
|
1672
|
-
let t = o.format;
|
|
1673
|
-
if (typeof t == "string" && /^\$|¥|€|£/.test(t) && typeof e == "number") {
|
|
1674
|
-
let n = {
|
|
1675
|
-
$: "USD",
|
|
1676
|
-
"¥": "JPY",
|
|
1677
|
-
"€": "EUR",
|
|
1678
|
-
"£": "GBP"
|
|
1679
|
-
}[t[0]];
|
|
1680
|
-
return Ce(e, o.currency || n);
|
|
1681
|
-
}
|
|
1682
|
-
if (typeof t == "string" && /%/.test(t) && typeof e == "number") {
|
|
1683
|
-
let n = (t.match(/0\.(0+)%/) || [, ""])[1].length;
|
|
1684
|
-
return Te((e > 1 ? e / 100 : e) * 100, n);
|
|
1685
|
-
}
|
|
1686
|
-
return typeof t == "string" && /[YMDHms]/.test(t) ? we(e, t) : /* @__PURE__ */ Z(Ee(De(o)), {
|
|
1687
|
-
value: e,
|
|
1688
|
-
field: o
|
|
1689
|
-
});
|
|
1690
|
-
};
|
|
1691
|
-
return {
|
|
1692
|
-
...e,
|
|
1693
|
-
...o,
|
|
1694
|
-
align: c,
|
|
1695
|
-
cell: l
|
|
1696
|
-
};
|
|
1697
|
-
};
|
|
1698
|
-
if (e.columns && e.columns.length > 0) {
|
|
1699
|
-
let n = rt(e.columns);
|
|
1700
|
-
return (t ? n.map((e) => ({
|
|
1701
|
-
...e,
|
|
1702
|
-
header: u(t, e.accessorKey, e.header)
|
|
1703
|
-
})) : n).map(i);
|
|
1704
|
-
}
|
|
1705
|
-
if (E.length === 0) return [];
|
|
1706
|
-
let a = new Set([
|
|
1707
|
-
"id",
|
|
1708
|
-
"organization_id",
|
|
1709
|
-
"tenant_id",
|
|
1710
|
-
"created_at",
|
|
1711
|
-
"updated_at",
|
|
1712
|
-
"created_by",
|
|
1713
|
-
"updated_by",
|
|
1714
|
-
"deleted_at",
|
|
1715
|
-
"deleted_by",
|
|
1716
|
-
"version",
|
|
1717
|
-
"_id",
|
|
1718
|
-
"__typename"
|
|
1719
|
-
]), o = (e, t) => t && (t.isSystem === !0 || t.system === !0) ? !0 : a.has(e);
|
|
1720
|
-
return (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !o(e, n[e])) : Object.keys(E[0]).filter((e) => !e.startsWith("_") && !o(e))).map((e) => i({
|
|
1721
|
-
header: r(e),
|
|
1722
|
-
accessorKey: e
|
|
1723
|
-
}));
|
|
1724
|
-
}, [
|
|
1725
|
-
e.columns,
|
|
1726
|
-
e.objectName,
|
|
1727
|
-
E,
|
|
1728
|
-
y,
|
|
1729
|
-
u,
|
|
1730
|
-
f
|
|
1731
|
-
]);
|
|
1732
|
-
if (x && E.length === 0) return /* @__PURE__ */ Z("div", {
|
|
1733
|
-
className: P("overflow-auto", n),
|
|
1734
|
-
"data-testid": "table-loading",
|
|
1735
|
-
children: /* @__PURE__ */ Q("div", {
|
|
1736
|
-
className: "space-y-2 p-2",
|
|
1737
|
-
children: [/* @__PURE__ */ Q("div", {
|
|
1738
|
-
className: "flex gap-2",
|
|
1739
|
-
children: [
|
|
1740
|
-
/* @__PURE__ */ Z(N, { className: "h-6 w-1/4" }),
|
|
1741
|
-
/* @__PURE__ */ Z(N, { className: "h-6 w-1/4" }),
|
|
1742
|
-
/* @__PURE__ */ Z(N, { className: "h-6 w-1/4" }),
|
|
1743
|
-
/* @__PURE__ */ Z(N, { className: "h-6 w-1/4" })
|
|
1744
|
-
]
|
|
1745
|
-
}), [
|
|
1746
|
-
1,
|
|
1747
|
-
2,
|
|
1748
|
-
3,
|
|
1749
|
-
4
|
|
1750
|
-
].map((e) => /* @__PURE__ */ Q("div", {
|
|
1751
|
-
className: "flex gap-2",
|
|
1752
|
-
children: [
|
|
1753
|
-
/* @__PURE__ */ Z(N, { className: "h-5 w-1/4" }),
|
|
1754
|
-
/* @__PURE__ */ Z(N, { className: "h-5 w-1/4" }),
|
|
1755
|
-
/* @__PURE__ */ Z(N, { className: "h-5 w-1/4" }),
|
|
1756
|
-
/* @__PURE__ */ Z(N, { className: "h-5 w-1/4" })
|
|
1757
|
-
]
|
|
1758
|
-
}, e))]
|
|
1759
|
-
})
|
|
1760
|
-
});
|
|
1761
|
-
if (C) return /* @__PURE__ */ Z("div", {
|
|
1762
|
-
className: P("overflow-auto", n),
|
|
1763
|
-
"data-testid": "table-error",
|
|
1764
|
-
children: /* @__PURE__ */ Q("div", {
|
|
1765
|
-
className: "flex flex-col items-center justify-center py-8 text-destructive",
|
|
1766
|
-
"data-testid": "table-error-message",
|
|
1767
|
-
children: [/* @__PURE__ */ Q("svg", {
|
|
1768
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1769
|
-
className: "h-8 w-8 mb-2 opacity-60",
|
|
1770
|
-
viewBox: "0 0 24 24",
|
|
1771
|
-
fill: "none",
|
|
1772
|
-
stroke: "currentColor",
|
|
1773
|
-
strokeWidth: "1.5",
|
|
1774
|
-
strokeLinecap: "round",
|
|
1775
|
-
strokeLinejoin: "round",
|
|
1776
|
-
children: [
|
|
1777
|
-
/* @__PURE__ */ Z("circle", {
|
|
1778
|
-
cx: "12",
|
|
1779
|
-
cy: "12",
|
|
1780
|
-
r: "10"
|
|
1781
|
-
}),
|
|
1782
|
-
/* @__PURE__ */ Z("line", {
|
|
1783
|
-
x1: "12",
|
|
1784
|
-
y1: "8",
|
|
1785
|
-
x2: "12",
|
|
1786
|
-
y2: "12"
|
|
1787
|
-
}),
|
|
1788
|
-
/* @__PURE__ */ Z("line", {
|
|
1789
|
-
x1: "12",
|
|
1790
|
-
y1: "16",
|
|
1791
|
-
x2: "12.01",
|
|
1792
|
-
y2: "16"
|
|
1793
|
-
})
|
|
1794
|
-
]
|
|
1795
|
-
}), /* @__PURE__ */ Z("p", {
|
|
1796
|
-
className: "text-xs",
|
|
1797
|
-
children: C
|
|
1798
|
-
})]
|
|
1799
|
-
})
|
|
1800
|
-
});
|
|
1801
|
-
if (!o && e.objectName && E.length === 0) return /* @__PURE__ */ Z("div", {
|
|
1802
|
-
className: P("overflow-auto", n),
|
|
1803
|
-
children: /* @__PURE__ */ Z("div", {
|
|
1804
|
-
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
1805
|
-
children: /* @__PURE__ */ Q("p", {
|
|
1806
|
-
className: "text-xs",
|
|
1807
|
-
children: [
|
|
1808
|
-
m,
|
|
1809
|
-
" “",
|
|
1810
|
-
e.objectName,
|
|
1811
|
-
"”"
|
|
1812
|
-
]
|
|
1813
|
-
})
|
|
1814
|
-
})
|
|
1815
|
-
});
|
|
1816
|
-
if (E.length === 0) return /* @__PURE__ */ Z("div", {
|
|
1817
|
-
className: P("overflow-auto", n),
|
|
1818
|
-
"data-testid": "table-empty-state",
|
|
1819
|
-
children: /* @__PURE__ */ Q("div", {
|
|
1820
|
-
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
1821
|
-
children: [/* @__PURE__ */ Q("svg", {
|
|
1822
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1823
|
-
className: "h-8 w-8 mb-2 opacity-40",
|
|
1824
|
-
viewBox: "0 0 24 24",
|
|
1825
|
-
fill: "none",
|
|
1826
|
-
stroke: "currentColor",
|
|
1827
|
-
strokeWidth: "1.5",
|
|
1828
|
-
strokeLinecap: "round",
|
|
1829
|
-
strokeLinejoin: "round",
|
|
1830
|
-
children: [
|
|
1831
|
-
/* @__PURE__ */ Z("rect", {
|
|
1832
|
-
x: "3",
|
|
1833
|
-
y: "3",
|
|
1834
|
-
width: "18",
|
|
1835
|
-
height: "18",
|
|
1836
|
-
rx: "2",
|
|
1837
|
-
ry: "2"
|
|
1838
|
-
}),
|
|
1839
|
-
/* @__PURE__ */ Z("line", {
|
|
1840
|
-
x1: "3",
|
|
1841
|
-
y1: "9",
|
|
1842
|
-
x2: "21",
|
|
1843
|
-
y2: "9"
|
|
1844
|
-
}),
|
|
1845
|
-
/* @__PURE__ */ Z("line", {
|
|
1846
|
-
x1: "9",
|
|
1847
|
-
y1: "21",
|
|
1848
|
-
x2: "9",
|
|
1849
|
-
y2: "9"
|
|
1850
|
-
})
|
|
1851
|
-
]
|
|
1852
|
-
}), /* @__PURE__ */ Z("p", {
|
|
1853
|
-
className: "text-xs",
|
|
1854
|
-
children: p
|
|
1855
|
-
})]
|
|
1856
|
-
})
|
|
1857
|
-
});
|
|
1858
|
-
let O = {
|
|
1859
|
-
...e,
|
|
1860
|
-
type: "data-table",
|
|
1861
|
-
data: E,
|
|
1862
|
-
columns: D
|
|
1863
|
-
};
|
|
1864
|
-
return /* @__PURE__ */ Q("div", {
|
|
1865
|
-
className: P("relative", n),
|
|
1866
|
-
children: [/* @__PURE__ */ Z(j, { active: x && E.length > 0 }), /* @__PURE__ */ Z(c, {
|
|
1867
|
-
schema: O,
|
|
1868
|
-
className: n
|
|
1869
|
-
})]
|
|
1870
|
-
});
|
|
1871
|
-
}, ot = ({ open: e, onClose: t, title: n, target: r = "drawer", objectName: i, filter: a, dataSource: o, columns: s, maxRows: l, className: u, report: d }) => {
|
|
1872
|
-
let f = d && typeof d == "object" && (Array.isArray(d.columns) || "objectName" in d), p = /* @__PURE__ */ Z("div", {
|
|
1873
|
-
className: P("overflow-auto", u),
|
|
1874
|
-
"data-testid": "drill-down-body",
|
|
1875
|
-
children: f ? (() => {
|
|
1876
|
-
let e = d.filter, t = e ? a ? { $and: [e, a] } : e : a;
|
|
1877
|
-
return /* @__PURE__ */ Z(c, { schema: {
|
|
1878
|
-
...d,
|
|
1879
|
-
type: "spec-report",
|
|
1880
|
-
report: {
|
|
1881
|
-
...d,
|
|
1882
|
-
filter: t
|
|
1883
|
-
},
|
|
1884
|
-
filter: t
|
|
1885
|
-
} });
|
|
1886
|
-
})() : /* @__PURE__ */ Z(at, {
|
|
1887
|
-
schema: {
|
|
1888
|
-
type: "object-data-table",
|
|
1889
|
-
objectName: i,
|
|
1890
|
-
filter: a,
|
|
1891
|
-
columns: s?.map((e) => ({
|
|
1892
|
-
accessorKey: e,
|
|
1893
|
-
header: e
|
|
1894
|
-
})),
|
|
1895
|
-
pagination: !0,
|
|
1896
|
-
searchable: !1,
|
|
1897
|
-
pageSize: l
|
|
1898
|
-
},
|
|
1899
|
-
dataSource: o
|
|
1900
|
-
})
|
|
1901
|
-
});
|
|
1902
|
-
return r === "dialog" ? /* @__PURE__ */ Z(D, {
|
|
1903
|
-
open: e,
|
|
1904
|
-
onOpenChange: (e) => !e && t(),
|
|
1905
|
-
children: /* @__PURE__ */ Q(O, {
|
|
1906
|
-
className: "max-w-5xl",
|
|
1907
|
-
children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Z(A, { children: n }) }), p]
|
|
1908
|
-
})
|
|
1909
|
-
}) : /* @__PURE__ */ Z(M, {
|
|
1910
|
-
open: e,
|
|
1911
|
-
onOpenChange: (e) => !e && t(),
|
|
1912
|
-
children: /* @__PURE__ */ Q(ee, {
|
|
1913
|
-
side: "right",
|
|
1914
|
-
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
1915
|
-
children: [/* @__PURE__ */ Z(te, { children: /* @__PURE__ */ Z(ne, { children: n }) }), /* @__PURE__ */ Z("div", {
|
|
1916
|
-
className: "flex-1 overflow-hidden mt-2",
|
|
1917
|
-
children: p
|
|
1918
|
-
})]
|
|
1919
|
-
})
|
|
1920
|
-
});
|
|
1921
|
-
}, st = ({ schema: e, dataSource: t, className: s }) => {
|
|
1922
|
-
let c = z(l), u = t || c?.dataSource, f = d(e.bind), [p, m] = H([]), [h, g] = H(!1), [v, y] = H(null), [b, x] = H({}), [S, C] = H({}), [w, T] = H(null), { fieldLabel: E, fieldOptionLabel: D } = _(), O = ae(E), k = ae(D);
|
|
1923
|
-
B(() => {
|
|
1924
|
-
O.current = E, k.current = D;
|
|
1925
|
-
}, [E, D]), B(() => {
|
|
1926
|
-
if (!u || !e.objectName) return;
|
|
1927
|
-
let t = u.getObjectSchema;
|
|
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(() => {
|
|
2569
|
+
if (!i || !e.objectName) return;
|
|
2570
|
+
let t = i.getObjectSchema;
|
|
1928
2571
|
if (typeof t != "function") return;
|
|
1929
2572
|
let n = !0;
|
|
1930
|
-
return Promise.resolve(t.call(
|
|
2573
|
+
return Promise.resolve(t.call(i, e.objectName)).then((t) => {
|
|
1931
2574
|
if (!n || !t?.fields) return;
|
|
1932
2575
|
let r = e.objectName, i = {}, a = {};
|
|
1933
2576
|
for (let [e, n] of Object.entries(t.fields)) {
|
|
@@ -1943,24 +2586,24 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
1943
2586
|
Object.keys(t).length > 0 && (i[e] = t);
|
|
1944
2587
|
}
|
|
1945
2588
|
}
|
|
1946
|
-
|
|
2589
|
+
b(i), S(a);
|
|
1947
2590
|
}).catch(() => {}), () => {
|
|
1948
2591
|
n = !1;
|
|
1949
2592
|
};
|
|
1950
|
-
}, [
|
|
2593
|
+
}, [i, e.objectName]), K(() => {
|
|
1951
2594
|
let t = !0;
|
|
1952
|
-
return e.objectName && !
|
|
1953
|
-
if (!(!
|
|
1954
|
-
t && (
|
|
2595
|
+
return e.objectName && !a && (!e.data || e.data.length === 0) && (async () => {
|
|
2596
|
+
if (!(!i || !e.objectName)) {
|
|
2597
|
+
t && (m(!0), _(null));
|
|
1955
2598
|
try {
|
|
1956
2599
|
let n;
|
|
1957
|
-
if (typeof
|
|
2600
|
+
if (typeof i.find == "function") n = s(await i.find(e.objectName, { $filter: f(e.filter) }));
|
|
1958
2601
|
else return;
|
|
1959
|
-
t &&
|
|
2602
|
+
t && l(n);
|
|
1960
2603
|
} catch (e) {
|
|
1961
|
-
console.error("[ObjectPivotTable] Fetch error:", e), t &&
|
|
2604
|
+
console.error("[ObjectPivotTable] Fetch error:", e), t && _(e instanceof Error ? e.message : "Failed to load data");
|
|
1962
2605
|
} finally {
|
|
1963
|
-
t &&
|
|
2606
|
+
t && m(!1);
|
|
1964
2607
|
}
|
|
1965
2608
|
}
|
|
1966
2609
|
})(), () => {
|
|
@@ -1968,14 +2611,14 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
1968
2611
|
};
|
|
1969
2612
|
}, [
|
|
1970
2613
|
e.objectName,
|
|
1971
|
-
|
|
1972
|
-
|
|
2614
|
+
i,
|
|
2615
|
+
a,
|
|
1973
2616
|
e.data,
|
|
1974
2617
|
e.filter
|
|
1975
2618
|
]);
|
|
1976
|
-
let A =
|
|
1977
|
-
if (
|
|
1978
|
-
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),
|
|
1979
2622
|
"data-testid": "pivot-loading",
|
|
1980
2623
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
1981
2624
|
className: "text-sm font-semibold mb-2",
|
|
@@ -1985,10 +2628,10 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
1985
2628
|
children: [/* @__PURE__ */ Q("div", {
|
|
1986
2629
|
className: "flex gap-2",
|
|
1987
2630
|
children: [
|
|
1988
|
-
/* @__PURE__ */ Z(
|
|
1989
|
-
/* @__PURE__ */ Z(
|
|
1990
|
-
/* @__PURE__ */ Z(
|
|
1991
|
-
/* @__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" })
|
|
1992
2635
|
]
|
|
1993
2636
|
}), [
|
|
1994
2637
|
1,
|
|
@@ -1997,16 +2640,16 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
1997
2640
|
].map((e) => /* @__PURE__ */ Q("div", {
|
|
1998
2641
|
className: "flex gap-2",
|
|
1999
2642
|
children: [
|
|
2000
|
-
/* @__PURE__ */ Z(
|
|
2001
|
-
/* @__PURE__ */ Z(
|
|
2002
|
-
/* @__PURE__ */ Z(
|
|
2003
|
-
/* @__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" })
|
|
2004
2647
|
]
|
|
2005
2648
|
}, e))]
|
|
2006
2649
|
})]
|
|
2007
2650
|
});
|
|
2008
|
-
if (
|
|
2009
|
-
className:
|
|
2651
|
+
if (h) return /* @__PURE__ */ Q("div", {
|
|
2652
|
+
className: H("overflow-auto", n),
|
|
2010
2653
|
"data-testid": "pivot-error",
|
|
2011
2654
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
2012
2655
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2044,12 +2687,12 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
2044
2687
|
]
|
|
2045
2688
|
}), /* @__PURE__ */ Z("p", {
|
|
2046
2689
|
className: "text-xs",
|
|
2047
|
-
children:
|
|
2690
|
+
children: h
|
|
2048
2691
|
})]
|
|
2049
2692
|
})]
|
|
2050
2693
|
});
|
|
2051
|
-
if (!
|
|
2052
|
-
className:
|
|
2694
|
+
if (!i && e.objectName && j.length === 0) return /* @__PURE__ */ Q("div", {
|
|
2695
|
+
className: H("overflow-auto", n),
|
|
2053
2696
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
2054
2697
|
className: "text-sm font-semibold mb-2",
|
|
2055
2698
|
children: e.title
|
|
@@ -2068,37 +2711,37 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
2068
2711
|
let M = {
|
|
2069
2712
|
...e,
|
|
2070
2713
|
data: j
|
|
2071
|
-
},
|
|
2072
|
-
return /* @__PURE__ */ Q(
|
|
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;
|
|
2715
|
+
return /* @__PURE__ */ Q(Ve, { children: [/* @__PURE__ */ Z(qt, {
|
|
2073
2716
|
schema: M,
|
|
2074
|
-
className:
|
|
2075
|
-
rowLabels:
|
|
2076
|
-
columnLabels:
|
|
2077
|
-
rowFieldLabel:
|
|
2078
|
-
onDrillDown:
|
|
2717
|
+
className: n,
|
|
2718
|
+
rowLabels: N,
|
|
2719
|
+
columnLabels: P,
|
|
2720
|
+
rowFieldLabel: F,
|
|
2721
|
+
onDrillDown: d(I) ? (e) => w(e) : void 0
|
|
2079
2722
|
}), (() => {
|
|
2080
|
-
if (!
|
|
2081
|
-
let t =
|
|
2723
|
+
if (!C || !e.objectName) return null;
|
|
2724
|
+
let t = o(I, C, {
|
|
2082
2725
|
rowField: e.rowField,
|
|
2083
2726
|
columnField: e.columnField
|
|
2084
|
-
}),
|
|
2727
|
+
}), n = {
|
|
2085
2728
|
...e.filter || {},
|
|
2086
2729
|
...t
|
|
2087
2730
|
};
|
|
2088
2731
|
return /* @__PURE__ */ Z(ot, {
|
|
2089
2732
|
open: !0,
|
|
2090
|
-
onClose: () =>
|
|
2091
|
-
title:
|
|
2092
|
-
target:
|
|
2733
|
+
onClose: () => w(null),
|
|
2734
|
+
title: p(I, C, e.title || "Details"),
|
|
2735
|
+
target: I?.target ?? "drawer",
|
|
2093
2736
|
objectName: e.objectName,
|
|
2094
|
-
filter:
|
|
2095
|
-
dataSource:
|
|
2096
|
-
columns:
|
|
2097
|
-
maxRows:
|
|
2098
|
-
report:
|
|
2737
|
+
filter: n,
|
|
2738
|
+
dataSource: i,
|
|
2739
|
+
columns: I?.columns,
|
|
2740
|
+
maxRows: I?.maxRows,
|
|
2741
|
+
report: I?.report
|
|
2099
2742
|
});
|
|
2100
2743
|
})()] });
|
|
2101
|
-
},
|
|
2744
|
+
}, Yt = {
|
|
2102
2745
|
breadcrumb: ["Dashboard", "Configuration"],
|
|
2103
2746
|
sections: [
|
|
2104
2747
|
{
|
|
@@ -2224,12 +2867,12 @@ var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
2224
2867
|
}
|
|
2225
2868
|
]
|
|
2226
2869
|
};
|
|
2227
|
-
function
|
|
2228
|
-
let { draft: a, isDirty: o, updateField: s, discard: c } =
|
|
2229
|
-
return /* @__PURE__ */ Z(
|
|
2870
|
+
function Xt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
2871
|
+
let { draft: a, isDirty: o, updateField: s, discard: c } = se(n, { onUpdate: i });
|
|
2872
|
+
return /* @__PURE__ */ Z(F, {
|
|
2230
2873
|
open: e,
|
|
2231
2874
|
onClose: t,
|
|
2232
|
-
schema:
|
|
2875
|
+
schema: Yt,
|
|
2233
2876
|
draft: a,
|
|
2234
2877
|
isDirty: o,
|
|
2235
2878
|
onFieldChange: s,
|
|
@@ -2239,7 +2882,7 @@ function lt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
|
2239
2882
|
}
|
|
2240
2883
|
//#endregion
|
|
2241
2884
|
//#region src/WidgetConfigPanel.tsx
|
|
2242
|
-
var
|
|
2885
|
+
var Zt = [
|
|
2243
2886
|
{
|
|
2244
2887
|
value: "metric",
|
|
2245
2888
|
label: "Metric"
|
|
@@ -2284,7 +2927,7 @@ var ut = [
|
|
|
2284
2927
|
value: "pivot",
|
|
2285
2928
|
label: "Pivot Table"
|
|
2286
2929
|
}
|
|
2287
|
-
],
|
|
2930
|
+
], Qt = [
|
|
2288
2931
|
{
|
|
2289
2932
|
value: "default",
|
|
2290
2933
|
label: "Default"
|
|
@@ -2317,7 +2960,7 @@ var ut = [
|
|
|
2317
2960
|
value: "danger",
|
|
2318
2961
|
label: "Danger"
|
|
2319
2962
|
}
|
|
2320
|
-
],
|
|
2963
|
+
], $t = [
|
|
2321
2964
|
{
|
|
2322
2965
|
value: "count",
|
|
2323
2966
|
label: "Count"
|
|
@@ -2338,7 +2981,7 @@ var ut = [
|
|
|
2338
2981
|
value: "max",
|
|
2339
2982
|
label: "Max"
|
|
2340
2983
|
}
|
|
2341
|
-
],
|
|
2984
|
+
], en = [
|
|
2342
2985
|
"bar",
|
|
2343
2986
|
"horizontal-bar",
|
|
2344
2987
|
"line",
|
|
@@ -2347,17 +2990,17 @@ var ut = [
|
|
|
2347
2990
|
"donut",
|
|
2348
2991
|
"scatter",
|
|
2349
2992
|
"funnel"
|
|
2350
|
-
],
|
|
2993
|
+
], tn = [
|
|
2351
2994
|
"bar",
|
|
2352
2995
|
"horizontal-bar",
|
|
2353
2996
|
"line",
|
|
2354
2997
|
"area",
|
|
2355
2998
|
"scatter"
|
|
2356
|
-
],
|
|
2999
|
+
], nn = [
|
|
2357
3000
|
"pie",
|
|
2358
3001
|
"donut",
|
|
2359
3002
|
"funnel"
|
|
2360
|
-
],
|
|
3003
|
+
], rn = ["metric", ...en], an = [...en], on = [
|
|
2361
3004
|
"pivot",
|
|
2362
3005
|
"metric",
|
|
2363
3006
|
"bar",
|
|
@@ -2366,52 +3009,57 @@ var ut = [
|
|
|
2366
3009
|
"area",
|
|
2367
3010
|
"pie",
|
|
2368
3011
|
"donut",
|
|
2369
|
-
"funnel"
|
|
3012
|
+
"funnel",
|
|
3013
|
+
"scatter",
|
|
3014
|
+
"treemap",
|
|
3015
|
+
"sankey",
|
|
3016
|
+
"table",
|
|
3017
|
+
"list"
|
|
2370
3018
|
];
|
|
2371
|
-
function
|
|
2372
|
-
return !!e &&
|
|
3019
|
+
function sn(e) {
|
|
3020
|
+
return !!e && en.includes(e);
|
|
2373
3021
|
}
|
|
2374
|
-
function
|
|
2375
|
-
return !!e &&
|
|
3022
|
+
function cn(e) {
|
|
3023
|
+
return !!e && tn.includes(e);
|
|
2376
3024
|
}
|
|
2377
|
-
function
|
|
2378
|
-
return !!e &&
|
|
3025
|
+
function ln(e) {
|
|
3026
|
+
return !!e && an.includes(e);
|
|
2379
3027
|
}
|
|
2380
|
-
function
|
|
2381
|
-
return !!e &&
|
|
3028
|
+
function un(e) {
|
|
3029
|
+
return !!e && rn.includes(e);
|
|
2382
3030
|
}
|
|
2383
|
-
function
|
|
2384
|
-
return !!e &&
|
|
3031
|
+
function dn(e) {
|
|
3032
|
+
return !!e && on.includes(e);
|
|
2385
3033
|
}
|
|
2386
|
-
var
|
|
3034
|
+
var fn = [{
|
|
2387
3035
|
value: "drawer",
|
|
2388
3036
|
label: "Side drawer"
|
|
2389
3037
|
}, {
|
|
2390
3038
|
value: "dialog",
|
|
2391
3039
|
label: "Center dialog"
|
|
2392
|
-
}],
|
|
3040
|
+
}], pn = [{
|
|
2393
3041
|
value: "group",
|
|
2394
3042
|
label: "Group"
|
|
2395
3043
|
}, {
|
|
2396
3044
|
value: "value",
|
|
2397
3045
|
label: "Value"
|
|
2398
|
-
}],
|
|
3046
|
+
}], mn = [{
|
|
2399
3047
|
value: "asc",
|
|
2400
3048
|
label: "↑"
|
|
2401
3049
|
}, {
|
|
2402
3050
|
value: "desc",
|
|
2403
3051
|
label: "↓"
|
|
2404
3052
|
}];
|
|
2405
|
-
function
|
|
3053
|
+
function hn(e, t, n, r) {
|
|
2406
3054
|
return {
|
|
2407
3055
|
key: e,
|
|
2408
3056
|
label: t,
|
|
2409
3057
|
type: "custom",
|
|
2410
|
-
render: (i, a, o) => /* @__PURE__ */ Z(
|
|
3058
|
+
render: (i, a, o) => /* @__PURE__ */ Z(I, {
|
|
2411
3059
|
label: t,
|
|
2412
3060
|
children: /* @__PURE__ */ Z("div", {
|
|
2413
3061
|
"data-testid": `config-field-${e}`,
|
|
2414
|
-
children: /* @__PURE__ */ Z(
|
|
3062
|
+
children: /* @__PURE__ */ Z(P, {
|
|
2415
3063
|
options: r ?? [],
|
|
2416
3064
|
value: i ?? "",
|
|
2417
3065
|
onValueChange: a,
|
|
@@ -2425,16 +3073,16 @@ function Dt(e, t, n, r) {
|
|
|
2425
3073
|
})
|
|
2426
3074
|
};
|
|
2427
3075
|
}
|
|
2428
|
-
function
|
|
3076
|
+
function gn(e, t, n) {
|
|
2429
3077
|
let r = e && e.length > 0, i = r ? {
|
|
2430
3078
|
key: "object",
|
|
2431
3079
|
label: "Data source",
|
|
2432
3080
|
type: "custom",
|
|
2433
|
-
render: (t, n) => /* @__PURE__ */ Z(
|
|
3081
|
+
render: (t, n) => /* @__PURE__ */ Z(I, {
|
|
2434
3082
|
label: "Data source",
|
|
2435
3083
|
children: /* @__PURE__ */ Z("div", {
|
|
2436
3084
|
"data-testid": "config-field-object",
|
|
2437
|
-
children: /* @__PURE__ */ Z(
|
|
3085
|
+
children: /* @__PURE__ */ Z(P, {
|
|
2438
3086
|
options: e,
|
|
2439
3087
|
value: t ?? "",
|
|
2440
3088
|
onValueChange: n,
|
|
@@ -2451,38 +3099,38 @@ function Ot(e, t, n) {
|
|
|
2451
3099
|
type: "input",
|
|
2452
3100
|
placeholder: "Object name"
|
|
2453
3101
|
}, a = r ? {
|
|
2454
|
-
...
|
|
3102
|
+
...hn("categoryField", "Category field", "Select field…", t),
|
|
2455
3103
|
helpText: "Group records by this field (one bar/slice/segment per value).",
|
|
2456
|
-
visibleWhen: (e) =>
|
|
3104
|
+
visibleWhen: (e) => ln(e.type)
|
|
2457
3105
|
} : {
|
|
2458
3106
|
key: "categoryField",
|
|
2459
3107
|
label: "Category field",
|
|
2460
3108
|
type: "input",
|
|
2461
3109
|
placeholder: "e.g. status",
|
|
2462
3110
|
helpText: "Group records by this field (one bar/slice/segment per value).",
|
|
2463
|
-
visibleWhen: (e) =>
|
|
3111
|
+
visibleWhen: (e) => ln(e.type)
|
|
2464
3112
|
}, o = r ? {
|
|
2465
|
-
...
|
|
3113
|
+
...hn("valueField", "Value field", "Select field…", t),
|
|
2466
3114
|
helpText: "Field to aggregate (sum / average / min / max).",
|
|
2467
|
-
visibleWhen: (e) =>
|
|
3115
|
+
visibleWhen: (e) => un(e.type) && (e.aggregate ?? "count") !== "count"
|
|
2468
3116
|
} : {
|
|
2469
3117
|
key: "valueField",
|
|
2470
3118
|
label: "Value field",
|
|
2471
3119
|
type: "input",
|
|
2472
3120
|
placeholder: "e.g. amount",
|
|
2473
3121
|
helpText: "Field to aggregate (sum / average / min / max).",
|
|
2474
|
-
visibleWhen: (e) =>
|
|
2475
|
-
}, s = r ?
|
|
3122
|
+
visibleWhen: (e) => un(e.type) && (e.aggregate ?? "count") !== "count"
|
|
3123
|
+
}, s = r ? hn("rowField", "Field", "Select row field…", t) : {
|
|
2476
3124
|
key: "rowField",
|
|
2477
3125
|
label: "Field",
|
|
2478
3126
|
type: "input",
|
|
2479
3127
|
placeholder: "e.g. owner"
|
|
2480
|
-
}, c = r ?
|
|
3128
|
+
}, c = r ? hn("columnField", "Field", "Select column field…", t) : {
|
|
2481
3129
|
key: "columnField",
|
|
2482
3130
|
label: "Field",
|
|
2483
3131
|
type: "input",
|
|
2484
3132
|
placeholder: "e.g. stage"
|
|
2485
|
-
}, l = r ?
|
|
3133
|
+
}, l = r ? hn("valueField", "Field", "Select value field…", t) : {
|
|
2486
3134
|
key: "valueField",
|
|
2487
3135
|
label: "Field",
|
|
2488
3136
|
type: "input",
|
|
@@ -2492,7 +3140,7 @@ function Ot(e, t, n) {
|
|
|
2492
3140
|
breadcrumb: ["Dashboard", {
|
|
2493
3141
|
pivot: "Pivot table",
|
|
2494
3142
|
table: "Table"
|
|
2495
|
-
}[n ?? ""] ?? (
|
|
3143
|
+
}[n ?? ""] ?? (sn(n) ? "Chart" : "Widget")],
|
|
2496
3144
|
sections: [
|
|
2497
3145
|
{
|
|
2498
3146
|
key: "general",
|
|
@@ -2514,7 +3162,7 @@ function Ot(e, t, n) {
|
|
|
2514
3162
|
key: "type",
|
|
2515
3163
|
label: "Widget type",
|
|
2516
3164
|
type: "select",
|
|
2517
|
-
options:
|
|
3165
|
+
options: Zt,
|
|
2518
3166
|
defaultValue: "metric"
|
|
2519
3167
|
}
|
|
2520
3168
|
]
|
|
@@ -2532,10 +3180,10 @@ function Ot(e, t, n) {
|
|
|
2532
3180
|
key: "aggregate",
|
|
2533
3181
|
label: "Aggregation",
|
|
2534
3182
|
type: "select",
|
|
2535
|
-
options:
|
|
3183
|
+
options: $t,
|
|
2536
3184
|
defaultValue: "count",
|
|
2537
3185
|
helpText: "Count ignores Value field; Sum / Avg / Min / Max require it.",
|
|
2538
|
-
visibleWhen: (e) =>
|
|
3186
|
+
visibleWhen: (e) => un(e.type)
|
|
2539
3187
|
}
|
|
2540
3188
|
]
|
|
2541
3189
|
},
|
|
@@ -2557,14 +3205,14 @@ function Ot(e, t, n) {
|
|
|
2557
3205
|
key: "rowSortBy",
|
|
2558
3206
|
label: "Sort by",
|
|
2559
3207
|
type: "icon-group",
|
|
2560
|
-
options:
|
|
3208
|
+
options: pn,
|
|
2561
3209
|
defaultValue: "group"
|
|
2562
3210
|
},
|
|
2563
3211
|
{
|
|
2564
3212
|
key: "rowSortOrder",
|
|
2565
3213
|
label: "Sort order",
|
|
2566
3214
|
type: "icon-group",
|
|
2567
|
-
options:
|
|
3215
|
+
options: mn,
|
|
2568
3216
|
defaultValue: "asc"
|
|
2569
3217
|
},
|
|
2570
3218
|
{
|
|
@@ -2592,14 +3240,14 @@ function Ot(e, t, n) {
|
|
|
2592
3240
|
key: "columnSortBy",
|
|
2593
3241
|
label: "Sort by",
|
|
2594
3242
|
type: "icon-group",
|
|
2595
|
-
options:
|
|
3243
|
+
options: pn,
|
|
2596
3244
|
defaultValue: "group"
|
|
2597
3245
|
},
|
|
2598
3246
|
{
|
|
2599
3247
|
key: "columnSortOrder",
|
|
2600
3248
|
label: "Sort order",
|
|
2601
3249
|
type: "icon-group",
|
|
2602
|
-
options:
|
|
3250
|
+
options: mn,
|
|
2603
3251
|
defaultValue: "asc"
|
|
2604
3252
|
},
|
|
2605
3253
|
{
|
|
@@ -2627,7 +3275,7 @@ function Ot(e, t, n) {
|
|
|
2627
3275
|
key: "aggregation",
|
|
2628
3276
|
label: "Aggregation",
|
|
2629
3277
|
type: "select",
|
|
2630
|
-
options:
|
|
3278
|
+
options: $t,
|
|
2631
3279
|
defaultValue: "sum"
|
|
2632
3280
|
},
|
|
2633
3281
|
{
|
|
@@ -2642,7 +3290,7 @@ function Ot(e, t, n) {
|
|
|
2642
3290
|
key: "chart-axis",
|
|
2643
3291
|
title: "Axis & Series",
|
|
2644
3292
|
collapsible: !0,
|
|
2645
|
-
visibleWhen: (e) =>
|
|
3293
|
+
visibleWhen: (e) => cn(e.type),
|
|
2646
3294
|
fields: [
|
|
2647
3295
|
{
|
|
2648
3296
|
key: "xAxisLabel",
|
|
@@ -2668,7 +3316,7 @@ function Ot(e, t, n) {
|
|
|
2668
3316
|
key: "chart-legend",
|
|
2669
3317
|
title: "Display",
|
|
2670
3318
|
collapsible: !0,
|
|
2671
|
-
visibleWhen: (e) => !!e.type &&
|
|
3319
|
+
visibleWhen: (e) => !!e.type && nn.includes(e.type),
|
|
2672
3320
|
fields: [{
|
|
2673
3321
|
key: "showLegend",
|
|
2674
3322
|
label: "Show legend",
|
|
@@ -2720,18 +3368,18 @@ function Ot(e, t, n) {
|
|
|
2720
3368
|
title: "Drill-down",
|
|
2721
3369
|
collapsible: !0,
|
|
2722
3370
|
defaultCollapsed: !0,
|
|
2723
|
-
visibleWhen: (e) =>
|
|
3371
|
+
visibleWhen: (e) => dn(e.type),
|
|
2724
3372
|
fields: [{
|
|
2725
3373
|
key: "drillDownEnabled",
|
|
2726
3374
|
label: "Enable drill-down",
|
|
2727
3375
|
type: "switch",
|
|
2728
3376
|
defaultValue: !1,
|
|
2729
|
-
helpText: "When enabled, clicking a
|
|
3377
|
+
helpText: "When enabled, clicking a chart segment / pivot cell opens a filtered list of underlying records; clicking a table or list row opens that record."
|
|
2730
3378
|
}, {
|
|
2731
3379
|
key: "drillDownTarget",
|
|
2732
3380
|
label: "Open in",
|
|
2733
3381
|
type: "select",
|
|
2734
|
-
options:
|
|
3382
|
+
options: fn,
|
|
2735
3383
|
defaultValue: "drawer",
|
|
2736
3384
|
visibleWhen: (e) => !!e.drillDownEnabled
|
|
2737
3385
|
}]
|
|
@@ -2757,14 +3405,14 @@ function Ot(e, t, n) {
|
|
|
2757
3405
|
key: "colorVariant",
|
|
2758
3406
|
label: "Color variant",
|
|
2759
3407
|
type: "select",
|
|
2760
|
-
options:
|
|
3408
|
+
options: Qt,
|
|
2761
3409
|
defaultValue: "default"
|
|
2762
3410
|
}]
|
|
2763
3411
|
}
|
|
2764
3412
|
]
|
|
2765
3413
|
};
|
|
2766
3414
|
}
|
|
2767
|
-
function
|
|
3415
|
+
function _n(e) {
|
|
2768
3416
|
if (e == null) return "";
|
|
2769
3417
|
if (typeof e == "string") return e;
|
|
2770
3418
|
if (typeof e == "object") {
|
|
@@ -2773,20 +3421,20 @@ function kt(e) {
|
|
|
2773
3421
|
}
|
|
2774
3422
|
return String(e);
|
|
2775
3423
|
}
|
|
2776
|
-
function
|
|
3424
|
+
function vn(e) {
|
|
2777
3425
|
let t = e.type, n = { ...e };
|
|
2778
|
-
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;
|
|
2779
3427
|
}
|
|
2780
|
-
function
|
|
2781
|
-
let { draft: c, isDirty: l, updateField: u, discard: d } =
|
|
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(() => ({
|
|
2782
3430
|
...n,
|
|
2783
|
-
title: typeof n.title == "object" ?
|
|
2784
|
-
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
|
|
2785
3433
|
}), [n]), { onUpdate: i });
|
|
2786
|
-
return /* @__PURE__ */ Z(
|
|
3434
|
+
return /* @__PURE__ */ Z(F, {
|
|
2787
3435
|
open: e,
|
|
2788
3436
|
onClose: t,
|
|
2789
|
-
schema:
|
|
3437
|
+
schema: U.useMemo(() => gn(o, s, c.type), [
|
|
2790
3438
|
o,
|
|
2791
3439
|
s,
|
|
2792
3440
|
c.type
|
|
@@ -2794,19 +3442,19 @@ function jt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, heade
|
|
|
2794
3442
|
draft: c,
|
|
2795
3443
|
isDirty: l,
|
|
2796
3444
|
onFieldChange: u,
|
|
2797
|
-
onSave: () => r(
|
|
3445
|
+
onSave: () => r(vn(c)),
|
|
2798
3446
|
onDiscard: d,
|
|
2799
3447
|
headerExtra: a
|
|
2800
3448
|
});
|
|
2801
3449
|
}
|
|
2802
3450
|
//#endregion
|
|
2803
3451
|
//#region src/DashboardWithConfig.tsx
|
|
2804
|
-
function
|
|
2805
|
-
let [c, l] =
|
|
2806
|
-
|
|
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(() => {
|
|
2807
3455
|
p(e), h((e) => e + 1);
|
|
2808
3456
|
}, [e]);
|
|
2809
|
-
let g =
|
|
3457
|
+
let g = U.useMemo(() => {
|
|
2810
3458
|
if (!u || !f.widgets) return null;
|
|
2811
3459
|
let e = f.widgets.find((e) => (e.id || e.title) === u);
|
|
2812
3460
|
if (!e) return null;
|
|
@@ -2828,11 +3476,11 @@ function Mt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2828
3476
|
layoutW: e.layout?.w ?? 1,
|
|
2829
3477
|
layoutH: e.layout?.h ?? 1
|
|
2830
3478
|
};
|
|
2831
|
-
}, [u, m]), _ =
|
|
3479
|
+
}, [u, m]), _ = G((e) => {
|
|
2832
3480
|
d(e), l(!0);
|
|
2833
|
-
}, []),
|
|
3481
|
+
}, []), v = G(() => {
|
|
2834
3482
|
d(null);
|
|
2835
|
-
}, []),
|
|
3483
|
+
}, []), y = G((e, t) => {
|
|
2836
3484
|
u && p((n) => n.widgets ? {
|
|
2837
3485
|
...n,
|
|
2838
3486
|
widgets: n.widgets.map((n) => {
|
|
@@ -2873,7 +3521,7 @@ function Mt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2873
3521
|
};
|
|
2874
3522
|
})
|
|
2875
3523
|
} : n);
|
|
2876
|
-
}, [u]),
|
|
3524
|
+
}, [u]), b = G((e) => {
|
|
2877
3525
|
if (u && r) {
|
|
2878
3526
|
let { drillDownEnabled: t, drillDownTarget: n, ...i } = e, a = { ...i };
|
|
2879
3527
|
(t || n) && (a.options = {
|
|
@@ -2886,24 +3534,24 @@ function Mt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2886
3534
|
}), r(u, a);
|
|
2887
3535
|
}
|
|
2888
3536
|
d(null), h((e) => e + 1);
|
|
2889
|
-
}, [u, r]),
|
|
3537
|
+
}, [u, r]), x = G(() => {
|
|
2890
3538
|
l((e) => !e), d(null);
|
|
2891
3539
|
}, []);
|
|
2892
3540
|
return /* @__PURE__ */ Q("div", {
|
|
2893
|
-
className:
|
|
3541
|
+
className: H("flex h-full w-full", s),
|
|
2894
3542
|
"data-testid": "dashboard-with-config",
|
|
2895
3543
|
children: [/* @__PURE__ */ Q("div", {
|
|
2896
3544
|
className: "flex-1 min-w-0 overflow-auto relative",
|
|
2897
3545
|
children: [/* @__PURE__ */ Z("div", {
|
|
2898
3546
|
className: "absolute top-2 right-2 z-10",
|
|
2899
|
-
children: /* @__PURE__ */ Q(
|
|
3547
|
+
children: /* @__PURE__ */ Q(k, {
|
|
2900
3548
|
size: "sm",
|
|
2901
3549
|
variant: c ? "default" : "outline",
|
|
2902
|
-
onClick:
|
|
3550
|
+
onClick: x,
|
|
2903
3551
|
"data-testid": "dashboard-config-toggle",
|
|
2904
|
-
children: [/* @__PURE__ */ Z(
|
|
3552
|
+
children: [/* @__PURE__ */ Z(Ce, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
|
|
2905
3553
|
})
|
|
2906
|
-
}), /* @__PURE__ */ Z(
|
|
3554
|
+
}), /* @__PURE__ */ Z(Tt, {
|
|
2907
3555
|
schema: f,
|
|
2908
3556
|
onRefresh: i,
|
|
2909
3557
|
recordCount: a,
|
|
@@ -2913,13 +3561,13 @@ function Mt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2913
3561
|
})]
|
|
2914
3562
|
}), c && /* @__PURE__ */ Z("div", {
|
|
2915
3563
|
className: "relative shrink-0",
|
|
2916
|
-
children: u && g ? /* @__PURE__ */ Z(
|
|
3564
|
+
children: u && g ? /* @__PURE__ */ Z(yn, {
|
|
2917
3565
|
open: !0,
|
|
2918
|
-
onClose:
|
|
3566
|
+
onClose: v,
|
|
2919
3567
|
config: g,
|
|
2920
|
-
onSave:
|
|
2921
|
-
onFieldChange:
|
|
2922
|
-
}) : /* @__PURE__ */ Z(
|
|
3568
|
+
onSave: b,
|
|
3569
|
+
onFieldChange: y
|
|
3570
|
+
}) : /* @__PURE__ */ Z(Xt, {
|
|
2923
3571
|
open: !0,
|
|
2924
3572
|
onClose: () => l(!1),
|
|
2925
3573
|
config: t,
|
|
@@ -2928,7 +3576,7 @@ function Mt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2928
3576
|
})]
|
|
2929
3577
|
});
|
|
2930
3578
|
}
|
|
2931
|
-
e.register("dashboard",
|
|
3579
|
+
e.register("dashboard", Tt, {
|
|
2932
3580
|
namespace: "view",
|
|
2933
3581
|
label: "Dashboard",
|
|
2934
3582
|
category: "Complex",
|
|
@@ -2956,7 +3604,7 @@ e.register("dashboard", Fe, {
|
|
|
2956
3604
|
columns: 3,
|
|
2957
3605
|
widgets: []
|
|
2958
3606
|
}
|
|
2959
|
-
}), e.register("metric",
|
|
3607
|
+
}), e.register("metric", Lt, {
|
|
2960
3608
|
namespace: "plugin-dashboard",
|
|
2961
3609
|
label: "Metric Widget",
|
|
2962
3610
|
category: "Dashboard",
|
|
@@ -2969,7 +3617,7 @@ e.register("dashboard", Fe, {
|
|
|
2969
3617
|
type: "string",
|
|
2970
3618
|
label: "Value"
|
|
2971
3619
|
}]
|
|
2972
|
-
}), e.register("metric-card",
|
|
3620
|
+
}), e.register("metric-card", zt, {
|
|
2973
3621
|
namespace: "plugin-dashboard",
|
|
2974
3622
|
label: "Metric Card",
|
|
2975
3623
|
category: "Dashboard",
|
|
@@ -3024,7 +3672,7 @@ e.register("dashboard", Fe, {
|
|
|
3024
3672
|
title: "Metric",
|
|
3025
3673
|
value: "0"
|
|
3026
3674
|
}
|
|
3027
|
-
}), e.register("object-metric",
|
|
3675
|
+
}), e.register("object-metric", Bt, {
|
|
3028
3676
|
namespace: "plugin-dashboard",
|
|
3029
3677
|
label: "Object Metric",
|
|
3030
3678
|
category: "Dashboard",
|
|
@@ -3053,7 +3701,7 @@ e.register("dashboard", Fe, {
|
|
|
3053
3701
|
}
|
|
3054
3702
|
],
|
|
3055
3703
|
defaultProps: { label: "Metric" }
|
|
3056
|
-
}), e.register("pivot",
|
|
3704
|
+
}), e.register("pivot", qt, {
|
|
3057
3705
|
namespace: "plugin-dashboard",
|
|
3058
3706
|
label: "Pivot Table",
|
|
3059
3707
|
category: "Dashboard",
|
|
@@ -3132,7 +3780,7 @@ e.register("dashboard", Fe, {
|
|
|
3132
3780
|
aggregation: "sum",
|
|
3133
3781
|
data: []
|
|
3134
3782
|
}
|
|
3135
|
-
}), e.register("object-pivot",
|
|
3783
|
+
}), e.register("object-pivot", Jt, {
|
|
3136
3784
|
namespace: "plugin-dashboard",
|
|
3137
3785
|
label: "Object Pivot Table",
|
|
3138
3786
|
category: "Dashboard",
|
|
@@ -3221,7 +3869,7 @@ e.register("dashboard", Fe, {
|
|
|
3221
3869
|
valueField: "",
|
|
3222
3870
|
aggregation: "sum"
|
|
3223
3871
|
}
|
|
3224
|
-
}), e.register("dashboard-grid",
|
|
3872
|
+
}), e.register("dashboard-grid", At, {
|
|
3225
3873
|
namespace: "plugin-dashboard",
|
|
3226
3874
|
label: "Dashboard Grid (Editable)",
|
|
3227
3875
|
category: "Complex",
|
|
@@ -3239,7 +3887,7 @@ e.register("dashboard", Fe, {
|
|
|
3239
3887
|
title: "Dashboard",
|
|
3240
3888
|
widgets: []
|
|
3241
3889
|
}
|
|
3242
|
-
}), e.register("object-data-table",
|
|
3890
|
+
}), e.register("object-data-table", it, {
|
|
3243
3891
|
namespace: "plugin-dashboard",
|
|
3244
3892
|
label: "Object Data Table",
|
|
3245
3893
|
category: "Dashboard",
|
|
@@ -3277,18 +3925,18 @@ e.register("dashboard", Fe, {
|
|
|
3277
3925
|
pagination: !1
|
|
3278
3926
|
}
|
|
3279
3927
|
});
|
|
3280
|
-
var
|
|
3281
|
-
DashboardRenderer:
|
|
3282
|
-
DashboardGridLayout:
|
|
3283
|
-
MetricWidget:
|
|
3284
|
-
MetricCard:
|
|
3285
|
-
ObjectMetricWidget:
|
|
3286
|
-
PivotTable:
|
|
3287
|
-
ObjectPivotTable:
|
|
3288
|
-
ObjectDataTable:
|
|
3289
|
-
DashboardConfigPanel:
|
|
3290
|
-
WidgetConfigPanel:
|
|
3291
|
-
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
|
|
3292
3940
|
};
|
|
3293
3941
|
//#endregion
|
|
3294
|
-
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 };
|