@object-ui/plugin-dashboard 16.1.0 → 17.2.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 +441 -2
- package/dist/DashboardGridLayout.d.ts +4 -4
- package/dist/DashboardGridLayout.d.ts.map +1 -1
- package/dist/DashboardRenderer.d.ts +2 -2
- package/dist/DashboardRenderer.d.ts.map +1 -1
- package/dist/DashboardWithConfig.d.ts +2 -2
- package/dist/DashboardWithConfig.d.ts.map +1 -1
- package/dist/DatasetWidget.d.ts.map +1 -1
- package/dist/ObjectDataTable.d.ts.map +1 -1
- package/dist/ObjectMetricWidget.d.ts.map +1 -1
- package/dist/ObjectPivotTable.d.ts.map +1 -1
- package/dist/PivotTable.d.ts +10 -0
- package/dist/PivotTable.d.ts.map +1 -1
- package/dist/index.js +881 -802
- package/dist/index.umd.cjs +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/widgetDispatch.d.ts +76 -0
- package/dist/widgetDispatch.d.ts.map +1 -0
- package/package.json +12 -10
package/dist/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { ComponentRegistry as e, DATE_RANGE_PRESETS as t,
|
|
2
|
-
import { PageVariablesProvider as
|
|
3
|
-
import { createSafeTranslation as
|
|
4
|
-
import { Button as
|
|
1
|
+
import { ComponentRegistry as e, DATE_RANGE_PRESETS as t, buildCategoryOrder as n, buildChartSeries as r, buildDatasetDrillFilter as i, buildDatasetFieldHelpers as a, buildDimensionLabelMap as o, buildOptionColorMap as s, buildWidgetScopedFilter as c, compareToTrendLabelKey as l, computeDrillFilter as u, dashboardFilterVariableDefs as d, extractRecords as f, findChartSeriesRow as p, formatDimensionValue as m, formatMeasure as h, isDrillEnabled as g, mergeFilters as _, relabelDimensions as v, resolveDashboardFilterDefs as y, resolveDrillTitle as b, resolveFilterPlaceholders as x, shiftFilterByCompareTo as S } from "@object-ui/core";
|
|
2
|
+
import { PageVariablesProvider as C, SchemaRenderer as w, SchemaRendererContext as T, useActionEngine as E, useDataScope as ee, useDnd as D, useDrillNavigation as O, useFilterScope as te, useHasDndProvider as k, useObjectLabel as ne, usePageVariables as re } from "@object-ui/react";
|
|
3
|
+
import { createSafeTranslation as A, resolveFieldCurrency as ie, useLocalization as j, useObjectTranslation as M, useSafeFieldLabel as ae, useSafeTranslate as N } from "@object-ui/i18n";
|
|
4
|
+
import { Button as P, Calendar as oe, Card as se, CardContent as F, CardHeader as ce, CardTitle as I, ChartSkeleton as le, Combobox as ue, ConfigPanelRenderer as de, ConfigRow as L, DataEmptyState as R, Dialog as z, DialogContent as fe, DialogHeader as pe, DialogTitle as me, GridSkeleton as B, Input as he, Popover as ge, PopoverContent as V, PopoverTrigger as H, RefreshIndicator as U, Select as _e, SelectContent as ve, SelectItem as W, SelectTrigger as ye, SelectValue as be, Sheet as xe, SheetContent as Se, SheetHeader as Ce, SheetTitle as we, Skeleton as G, cn as K, getLazyIcon as Te, useConfigDraft as Ee } from "@object-ui/components";
|
|
5
5
|
import * as q from "react";
|
|
6
|
-
import
|
|
7
|
-
import { AlertCircle as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
11
|
-
import { formatCurrency as
|
|
12
|
-
import { Fragment as
|
|
13
|
-
import { ResponsiveGridLayout as
|
|
6
|
+
import De, { Fragment as Oe, forwardRef as ke, useCallback as J, useContext as Ae, useEffect as Y, useMemo as X, useRef as je, useState as Z } from "react";
|
|
7
|
+
import { AlertCircle as Me, AlertTriangle as Ne, ArrowDownIcon as Pe, ArrowUpIcon as Fe, ArrowUpRight as Ie, BarChart3 as Le, CalendarIcon as Re, Download as ze, Edit as Be, GripVertical as Ve, Loader2 as He, MinusIcon as Ue, RefreshCw as We, RotateCcw as Ge, Save as Ke, Settings as qe, X as Je } from "lucide-react";
|
|
8
|
+
import { DndContext as Ye, PointerSensor as Xe, closestCenter as Ze, useSensor as Qe, useSensors as $e } from "@dnd-kit/core";
|
|
9
|
+
import { SortableContext as et, arrayMove as tt, rectSortingStrategy as nt, useSortable as rt, verticalListSortingStrategy as it } from "@dnd-kit/sortable";
|
|
10
|
+
import { CSS as at } from "@dnd-kit/utilities";
|
|
11
|
+
import { formatCurrency as ot, formatDate as st, formatPercent as ct, getCellRenderer as lt, resolveCellRendererType as ut } from "@object-ui/fields";
|
|
12
|
+
import { Fragment as dt, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
13
|
+
import { ResponsiveGridLayout as ft, useContainerWidth as pt } from "react-grid-layout";
|
|
14
14
|
import "react-grid-layout/css/styles.css";
|
|
15
15
|
//#region src/utils.ts
|
|
16
|
-
function
|
|
16
|
+
function mt(e) {
|
|
17
17
|
return typeof e == "object" && !!e && !Array.isArray(e) && e.provider === "object";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function ht(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,8 +37,60 @@ function pt(e, t) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
+
//#region src/widgetDispatch.ts
|
|
41
|
+
var gt = {
|
|
42
|
+
column: "bar",
|
|
43
|
+
"stacked-bar": "bar",
|
|
44
|
+
"grouped-bar": "bar",
|
|
45
|
+
"bi-polar-bar": "bar",
|
|
46
|
+
spline: "line",
|
|
47
|
+
"step-line": "line",
|
|
48
|
+
"stacked-area": "area",
|
|
49
|
+
pyramid: "funnel",
|
|
50
|
+
bubble: "scatter"
|
|
51
|
+
}, _t = /* @__PURE__ */ new Set([
|
|
52
|
+
"bar",
|
|
53
|
+
"horizontal-bar",
|
|
54
|
+
"line",
|
|
55
|
+
"area",
|
|
56
|
+
"pie",
|
|
57
|
+
"donut",
|
|
58
|
+
"scatter",
|
|
59
|
+
"funnel",
|
|
60
|
+
"radar",
|
|
61
|
+
"treemap",
|
|
62
|
+
"sankey",
|
|
63
|
+
"combo"
|
|
64
|
+
]), vt = /* @__PURE__ */ new Set([
|
|
65
|
+
"metric",
|
|
66
|
+
"gauge",
|
|
67
|
+
"solid-gauge",
|
|
68
|
+
"kpi",
|
|
69
|
+
"bullet"
|
|
70
|
+
]), yt = /* @__PURE__ */ new Set(["table", "list"]), bt = /* @__PURE__ */ new Set([
|
|
71
|
+
"sunburst",
|
|
72
|
+
"word-cloud",
|
|
73
|
+
"choropleth",
|
|
74
|
+
"bubble-map",
|
|
75
|
+
"gl-map",
|
|
76
|
+
"heatmap",
|
|
77
|
+
"waterfall",
|
|
78
|
+
"box-plot",
|
|
79
|
+
"violin",
|
|
80
|
+
"candlestick",
|
|
81
|
+
"stock"
|
|
82
|
+
]);
|
|
83
|
+
function xt(e) {
|
|
84
|
+
if (!e) return { family: "passthrough" };
|
|
85
|
+
let t = gt[e] ?? e;
|
|
86
|
+
return _t.has(t) ? {
|
|
87
|
+
family: "series",
|
|
88
|
+
chartType: t
|
|
89
|
+
} : vt.has(e) ? { family: "metric" } : yt.has(e) ? { family: "table" } : e === "pivot" ? { family: "pivot" } : e === "custom" ? { family: "custom" } : bt.has(e) ? { family: "unsupported" } : { family: "passthrough" };
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
40
92
|
//#region src/recordFields.tsx
|
|
41
|
-
var
|
|
93
|
+
var St = /* @__PURE__ */ new Set([
|
|
42
94
|
"id",
|
|
43
95
|
"organization_id",
|
|
44
96
|
"tenant_id",
|
|
@@ -52,15 +104,15 @@ var mt = /* @__PURE__ */ new Set([
|
|
|
52
104
|
"_id",
|
|
53
105
|
"__typename"
|
|
54
106
|
]);
|
|
55
|
-
function
|
|
56
|
-
return t && (t.isSystem === !0 || t.system === !0) ? !0 :
|
|
107
|
+
function Ct(e, t) {
|
|
108
|
+
return t && (t.isSystem === !0 || t.system === !0) ? !0 : St.has(e);
|
|
57
109
|
}
|
|
58
|
-
var
|
|
110
|
+
var wt = /* @__PURE__ */ new Set([
|
|
59
111
|
"select",
|
|
60
112
|
"picklist",
|
|
61
113
|
"dropdown",
|
|
62
114
|
"status"
|
|
63
|
-
]),
|
|
115
|
+
]), Tt = /* @__PURE__ */ new Set([
|
|
64
116
|
"currency",
|
|
65
117
|
"money",
|
|
66
118
|
"number",
|
|
@@ -70,7 +122,7 @@ var gt = /* @__PURE__ */ new Set([
|
|
|
70
122
|
"percent",
|
|
71
123
|
"percentage"
|
|
72
124
|
]);
|
|
73
|
-
function
|
|
125
|
+
function Et(e) {
|
|
74
126
|
let t = {}, n = e?.fields;
|
|
75
127
|
if (!n) return t;
|
|
76
128
|
if (Array.isArray(n)) for (let e of n) e?.name && (t[e.name] = e);
|
|
@@ -80,9 +132,9 @@ function vt(e) {
|
|
|
80
132
|
};
|
|
81
133
|
return t;
|
|
82
134
|
}
|
|
83
|
-
function
|
|
135
|
+
function Dt(e) {
|
|
84
136
|
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 &&
|
|
137
|
+
return i && c && a && wt.has(r?.type) && (c = c.map((e) => {
|
|
86
138
|
if (e == null) return e;
|
|
87
139
|
let n = typeof e == "object" ? e.value : e, r = typeof e == "object" && e.label || String(n);
|
|
88
140
|
return {
|
|
@@ -101,10 +153,10 @@ function yt(e) {
|
|
|
101
153
|
decimals: o.decimals ?? r?.decimals ?? r?.scale
|
|
102
154
|
};
|
|
103
155
|
}
|
|
104
|
-
function
|
|
105
|
-
return
|
|
156
|
+
function Ot(e) {
|
|
157
|
+
return Tt.has(e.type) || typeof e.format == "string" && /^[$¥€£]|%$|0/.test(e.format);
|
|
106
158
|
}
|
|
107
|
-
function
|
|
159
|
+
function kt(e, t, n) {
|
|
108
160
|
if (e == null || e === "") return "";
|
|
109
161
|
let r = t.format;
|
|
110
162
|
if (typeof r == "string" && /^\$|¥|€|£/.test(r) && typeof e == "number") {
|
|
@@ -114,20 +166,20 @@ function xt(e, t, n) {
|
|
|
114
166
|
"€": "EUR",
|
|
115
167
|
"£": "GBP"
|
|
116
168
|
}[r[0]];
|
|
117
|
-
return
|
|
169
|
+
return ot(e, t.currency || i || n);
|
|
118
170
|
}
|
|
119
171
|
if (typeof r == "string" && /%/.test(r) && typeof e == "number") {
|
|
120
172
|
let t = (r.match(/0\.(0+)%/) || [void 0, ""])[1].length;
|
|
121
|
-
return
|
|
173
|
+
return ct((e > 1 ? e / 100 : e) * 100, t);
|
|
122
174
|
}
|
|
123
|
-
return typeof r == "string" && /[YMDHms]/.test(r) ?
|
|
175
|
+
return typeof r == "string" && /[YMDHms]/.test(r) ? st(e, r) : /* @__PURE__ */ Q(lt(ut(t)), {
|
|
124
176
|
value: e,
|
|
125
177
|
field: t
|
|
126
178
|
});
|
|
127
179
|
}
|
|
128
180
|
//#endregion
|
|
129
181
|
//#region src/RecordDetailDrawer.tsx
|
|
130
|
-
var
|
|
182
|
+
var At = [
|
|
131
183
|
"name",
|
|
132
184
|
"title",
|
|
133
185
|
"label",
|
|
@@ -135,21 +187,21 @@ var St = [
|
|
|
135
187
|
"display_name",
|
|
136
188
|
"full_name"
|
|
137
189
|
];
|
|
138
|
-
function
|
|
190
|
+
function jt(e, t) {
|
|
139
191
|
if (t && t.trim()) return t;
|
|
140
|
-
for (let t of
|
|
192
|
+
for (let t of At) {
|
|
141
193
|
let n = e[t];
|
|
142
194
|
if (typeof n == "string" && n.trim()) return n;
|
|
143
195
|
}
|
|
144
196
|
let n = e.id ?? e._id;
|
|
145
197
|
return n == null ? "Record" : String(n);
|
|
146
198
|
}
|
|
147
|
-
var
|
|
148
|
-
let { fieldLabel: s, fieldOptionLabel: c } =
|
|
199
|
+
var Mt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, target: a = "drawer", onClose: o }) => {
|
|
200
|
+
let { fieldLabel: s, fieldOptionLabel: c } = ae(), { currency: l } = j(), u = X(() => {
|
|
149
201
|
if (!e) return [];
|
|
150
|
-
let i =
|
|
151
|
-
return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !
|
|
152
|
-
let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ? s(t, n, a) : a, u =
|
|
202
|
+
let i = Et(n), a;
|
|
203
|
+
return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !Ct(e, i[e])) : Object.keys(e).filter((e) => !e.startsWith("_") && !Ct(e)), a.map((n) => {
|
|
204
|
+
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 = Dt({
|
|
153
205
|
accessorKey: n,
|
|
154
206
|
label: o,
|
|
155
207
|
def: r,
|
|
@@ -159,8 +211,8 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
159
211
|
return {
|
|
160
212
|
key: n,
|
|
161
213
|
label: o,
|
|
162
|
-
node:
|
|
163
|
-
numeric:
|
|
214
|
+
node: kt(e[n], u, l),
|
|
215
|
+
numeric: Ot(u)
|
|
164
216
|
};
|
|
165
217
|
});
|
|
166
218
|
}, [
|
|
@@ -173,7 +225,7 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
173
225
|
l
|
|
174
226
|
]);
|
|
175
227
|
if (!e) return null;
|
|
176
|
-
let d =
|
|
228
|
+
let d = jt(e, i), f = /* @__PURE__ */ Q("dl", {
|
|
177
229
|
className: "divide-y divide-border/60",
|
|
178
230
|
"data-testid": "record-detail-body",
|
|
179
231
|
children: u.map((e) => /* @__PURE__ */ $("div", {
|
|
@@ -190,23 +242,23 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
190
242
|
})]
|
|
191
243
|
}, e.key))
|
|
192
244
|
});
|
|
193
|
-
return a === "dialog" ? /* @__PURE__ */ Q(
|
|
245
|
+
return a === "dialog" ? /* @__PURE__ */ Q(z, {
|
|
194
246
|
open: !0,
|
|
195
247
|
onOpenChange: (e) => !e && o(),
|
|
196
|
-
children: /* @__PURE__ */ $(
|
|
248
|
+
children: /* @__PURE__ */ $(fe, {
|
|
197
249
|
className: "max-w-2xl",
|
|
198
|
-
children: [/* @__PURE__ */ Q(
|
|
250
|
+
children: [/* @__PURE__ */ Q(pe, { children: /* @__PURE__ */ Q(me, { children: d }) }), /* @__PURE__ */ Q("div", {
|
|
199
251
|
className: "max-h-[70vh] overflow-auto",
|
|
200
252
|
children: f
|
|
201
253
|
})]
|
|
202
254
|
})
|
|
203
|
-
}) : /* @__PURE__ */ Q(
|
|
255
|
+
}) : /* @__PURE__ */ Q(xe, {
|
|
204
256
|
open: !0,
|
|
205
257
|
onOpenChange: (e) => !e && o(),
|
|
206
|
-
children: /* @__PURE__ */ $(
|
|
258
|
+
children: /* @__PURE__ */ $(Se, {
|
|
207
259
|
side: "right",
|
|
208
260
|
className: "w-full sm:max-w-md md:max-w-lg flex flex-col",
|
|
209
|
-
children: [/* @__PURE__ */ Q(
|
|
261
|
+
children: [/* @__PURE__ */ Q(Ce, { children: /* @__PURE__ */ Q(we, { children: d }) }), /* @__PURE__ */ Q("div", {
|
|
210
262
|
className: "flex-1 overflow-auto mt-2 pr-1",
|
|
211
263
|
children: f
|
|
212
264
|
})]
|
|
@@ -215,13 +267,13 @@ var wt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
215
267
|
};
|
|
216
268
|
//#endregion
|
|
217
269
|
//#region src/ObjectDataTable.tsx
|
|
218
|
-
function
|
|
270
|
+
function Nt(e) {
|
|
219
271
|
return e.map((e) => typeof e == "string" ? {
|
|
220
272
|
header: e.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (e) => e.toUpperCase()),
|
|
221
273
|
accessorKey: e
|
|
222
274
|
} : e);
|
|
223
275
|
}
|
|
224
|
-
function
|
|
276
|
+
function Pt(e, t) {
|
|
225
277
|
if (!t?.fields) return [];
|
|
226
278
|
let n = {};
|
|
227
279
|
if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
|
|
@@ -239,14 +291,14 @@ function Et(e, t) {
|
|
|
239
291
|
} else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
|
|
240
292
|
return Array.from(a);
|
|
241
293
|
}
|
|
242
|
-
var
|
|
243
|
-
let { currency: r } =
|
|
294
|
+
var Ft = ({ schema: e, dataSource: t, className: n }) => {
|
|
295
|
+
let { currency: r } = j(), i = Ae(T), a = t || i?.dataSource, o = ee(e.bind), { fieldLabel: s, fieldOptionLabel: c } = ae(), l = "No data available", u = "No data source available for", { t: d } = M(), p = d("dashboard.noDataAvailable");
|
|
244
296
|
p && p !== "dashboard.noDataAvailable" && (l = p);
|
|
245
|
-
let m =
|
|
297
|
+
let m = d("dashboard.noDataSourceFor");
|
|
246
298
|
m && m !== "dashboard.noDataSourceFor" && (u = m);
|
|
247
|
-
let [
|
|
248
|
-
|
|
249
|
-
}, []);
|
|
299
|
+
let [h, _] = Z([]), [v, y] = Z(null), [b, S] = Z(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [C, E] = Z(null), D = e.drillDown, O = g(D) && (D?.mode ?? "record") === "record", [k, ne] = Z(null), re = J((e) => {
|
|
300
|
+
ne(e ?? null);
|
|
301
|
+
}, []), A = te();
|
|
250
302
|
Y(() => {
|
|
251
303
|
let t = !0;
|
|
252
304
|
return e.objectName && !o && (!e.data || e.data.length === 0) ? (async () => {
|
|
@@ -254,16 +306,16 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
254
306
|
t && S(!1);
|
|
255
307
|
return;
|
|
256
308
|
}
|
|
257
|
-
t && (S(!0),
|
|
309
|
+
t && (S(!0), E(null));
|
|
258
310
|
try {
|
|
259
311
|
let n;
|
|
260
312
|
if (typeof a.find == "function") {
|
|
261
|
-
let t =
|
|
262
|
-
t.length && (r.$expand = t), n =
|
|
313
|
+
let t = Pt(e, v), r = { $filter: x(e.filter, A) };
|
|
314
|
+
t.length && (r.$expand = t), n = f(await a.find(e.objectName, r));
|
|
263
315
|
} else return;
|
|
264
316
|
t && _(n);
|
|
265
317
|
} catch (e) {
|
|
266
|
-
console.error("[ObjectDataTable] Fetch error:", e), t &&
|
|
318
|
+
console.error("[ObjectDataTable] Fetch error:", e), t && E(e instanceof Error ? e.message : "Failed to load data");
|
|
267
319
|
} finally {
|
|
268
320
|
t && S(!1);
|
|
269
321
|
}
|
|
@@ -276,16 +328,17 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
276
328
|
o,
|
|
277
329
|
e.data,
|
|
278
330
|
e.filter,
|
|
279
|
-
v
|
|
331
|
+
v,
|
|
332
|
+
A
|
|
280
333
|
]), Y(() => {
|
|
281
334
|
let t = !0;
|
|
282
335
|
if (!(!a || !e.objectName || typeof a.getObjectSchema != "function")) return a.getObjectSchema(e.objectName).then((e) => {
|
|
283
|
-
t &&
|
|
336
|
+
t && y(e);
|
|
284
337
|
}).catch(() => {}), () => {
|
|
285
338
|
t = !1;
|
|
286
339
|
};
|
|
287
340
|
}, [e.objectName, a]);
|
|
288
|
-
let
|
|
341
|
+
let ie = o || e.data || h, N = Array.isArray(ie) ? ie : [], P = X(() => {
|
|
289
342
|
let t = e.objectName, n = {};
|
|
290
343
|
if (v?.fields) {
|
|
291
344
|
let e = v.fields;
|
|
@@ -299,7 +352,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
299
352
|
let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
|
|
300
353
|
return t ? s(t, e, n) : n;
|
|
301
354
|
}, a = (e) => {
|
|
302
|
-
let i =
|
|
355
|
+
let i = Dt({
|
|
303
356
|
accessorKey: e.accessorKey,
|
|
304
357
|
label: e.header,
|
|
305
358
|
def: n[e.accessorKey],
|
|
@@ -313,13 +366,13 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
313
366
|
currency: e.currency,
|
|
314
367
|
decimals: e.decimals
|
|
315
368
|
}
|
|
316
|
-
}), a = e.align ?? (
|
|
369
|
+
}), a = e.align ?? (Ot(i) ? "right" : void 0);
|
|
317
370
|
if (typeof e.cell == "function") return {
|
|
318
371
|
...e,
|
|
319
372
|
...i,
|
|
320
373
|
align: a
|
|
321
374
|
};
|
|
322
|
-
let o = (e) =>
|
|
375
|
+
let o = (e) => kt(e, i, r);
|
|
323
376
|
return {
|
|
324
377
|
...e,
|
|
325
378
|
...i,
|
|
@@ -328,26 +381,26 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
328
381
|
};
|
|
329
382
|
};
|
|
330
383
|
if (e.columns && e.columns.length > 0) {
|
|
331
|
-
let n =
|
|
384
|
+
let n = Nt(e.columns);
|
|
332
385
|
return (t ? n.map((e) => ({
|
|
333
386
|
...e,
|
|
334
387
|
header: s(t, e.accessorKey, e.header)
|
|
335
388
|
})) : n).map(a);
|
|
336
389
|
}
|
|
337
|
-
return
|
|
390
|
+
return N.length === 0 ? [] : (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !Ct(e, n[e])) : Object.keys(N[0]).filter((e) => !e.startsWith("_") && !Ct(e))).map((e) => a({
|
|
338
391
|
header: i(e),
|
|
339
392
|
accessorKey: e
|
|
340
393
|
}));
|
|
341
394
|
}, [
|
|
342
395
|
e.columns,
|
|
343
396
|
e.objectName,
|
|
344
|
-
|
|
397
|
+
N,
|
|
345
398
|
v,
|
|
346
399
|
s,
|
|
347
400
|
c,
|
|
348
401
|
r
|
|
349
402
|
]);
|
|
350
|
-
if (
|
|
403
|
+
if (b && N.length === 0) return /* @__PURE__ */ Q("div", {
|
|
351
404
|
className: K("overflow-auto", n),
|
|
352
405
|
"data-testid": "table-loading",
|
|
353
406
|
children: /* @__PURE__ */ $("div", {
|
|
@@ -376,7 +429,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
376
429
|
}, e))]
|
|
377
430
|
})
|
|
378
431
|
});
|
|
379
|
-
if (
|
|
432
|
+
if (C) return /* @__PURE__ */ Q("div", {
|
|
380
433
|
className: K("overflow-auto", n),
|
|
381
434
|
"data-testid": "table-error",
|
|
382
435
|
children: /* @__PURE__ */ $("div", {
|
|
@@ -412,11 +465,11 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
412
465
|
]
|
|
413
466
|
}), /* @__PURE__ */ Q("p", {
|
|
414
467
|
className: "text-xs",
|
|
415
|
-
children:
|
|
468
|
+
children: C
|
|
416
469
|
})]
|
|
417
470
|
})
|
|
418
471
|
});
|
|
419
|
-
if (!a && e.objectName &&
|
|
472
|
+
if (!a && e.objectName && N.length === 0) return /* @__PURE__ */ Q("div", {
|
|
420
473
|
className: K("overflow-auto", n),
|
|
421
474
|
children: /* @__PURE__ */ Q("div", {
|
|
422
475
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
@@ -431,7 +484,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
431
484
|
})
|
|
432
485
|
})
|
|
433
486
|
});
|
|
434
|
-
if (
|
|
487
|
+
if (N.length === 0) return /* @__PURE__ */ Q("div", {
|
|
435
488
|
className: K("overflow-auto", n),
|
|
436
489
|
"data-testid": "table-empty-state",
|
|
437
490
|
children: /* @__PURE__ */ $("div", {
|
|
@@ -473,35 +526,35 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
473
526
|
})]
|
|
474
527
|
})
|
|
475
528
|
});
|
|
476
|
-
let
|
|
529
|
+
let oe = {
|
|
477
530
|
...e,
|
|
478
531
|
type: "data-table",
|
|
479
|
-
data:
|
|
480
|
-
columns:
|
|
481
|
-
onRowClick: e.onRowClick ?? (
|
|
482
|
-
},
|
|
532
|
+
data: N,
|
|
533
|
+
columns: P,
|
|
534
|
+
onRowClick: e.onRowClick ?? (O ? re : void 0)
|
|
535
|
+
}, se = D?.title && !D.title.includes("${") ? D.title : void 0;
|
|
483
536
|
return /* @__PURE__ */ $("div", {
|
|
484
537
|
className: K("relative", n),
|
|
485
538
|
children: [
|
|
486
|
-
/* @__PURE__ */ Q(
|
|
487
|
-
/* @__PURE__ */ Q(
|
|
488
|
-
schema:
|
|
539
|
+
/* @__PURE__ */ Q(U, { active: b && N.length > 0 }),
|
|
540
|
+
/* @__PURE__ */ Q(w, {
|
|
541
|
+
schema: oe,
|
|
489
542
|
className: n
|
|
490
543
|
}),
|
|
491
|
-
|
|
492
|
-
record:
|
|
544
|
+
O && /* @__PURE__ */ Q(Mt, {
|
|
545
|
+
record: k,
|
|
493
546
|
objectName: e.objectName,
|
|
494
547
|
objectSchema: v,
|
|
495
|
-
fields:
|
|
496
|
-
title:
|
|
497
|
-
target:
|
|
498
|
-
onClose: () =>
|
|
548
|
+
fields: D?.columns,
|
|
549
|
+
title: se,
|
|
550
|
+
target: D?.target === "dialog" ? "dialog" : "drawer",
|
|
551
|
+
onClose: () => ne(null)
|
|
499
552
|
})
|
|
500
553
|
]
|
|
501
554
|
});
|
|
502
|
-
},
|
|
503
|
-
let { openRecordList: i } = O(), a =
|
|
504
|
-
return !i || !e ? null : /* @__PURE__ */ $(
|
|
555
|
+
}, It = ({ objectName: e, filter: t, onNavigate: n, className: r }) => {
|
|
556
|
+
let { openRecordList: i } = O(), a = N();
|
|
557
|
+
return !i || !e ? null : /* @__PURE__ */ $(P, {
|
|
505
558
|
type: "button",
|
|
506
559
|
variant: "ghost",
|
|
507
560
|
size: "sm",
|
|
@@ -510,14 +563,14 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
510
563
|
onClick: () => {
|
|
511
564
|
i(e, t), n?.();
|
|
512
565
|
},
|
|
513
|
-
children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Q(
|
|
566
|
+
children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Q(Ie, { className: "ml-1 h-3.5 w-3.5" })]
|
|
514
567
|
});
|
|
515
|
-
},
|
|
568
|
+
}, Lt = ({ open: e, onClose: t, title: n, target: r = "drawer", objectName: i, filter: a, dataSource: o, columns: s, maxRows: c, className: l, report: u }) => {
|
|
516
569
|
let { openRecordList: d } = O(), f = u && typeof u == "object" && (Array.isArray(u.columns) || "objectName" in u), p = r === "navigate" && !!d && !f && !!i;
|
|
517
|
-
if (
|
|
570
|
+
if (De.useEffect(() => {
|
|
518
571
|
e && p && (d(i, a), t());
|
|
519
572
|
}, [e, p]), p) return null;
|
|
520
|
-
let m = f ? null : /* @__PURE__ */ Q(
|
|
573
|
+
let m = f ? null : /* @__PURE__ */ Q(It, {
|
|
521
574
|
objectName: i,
|
|
522
575
|
filter: a,
|
|
523
576
|
onNavigate: t
|
|
@@ -526,7 +579,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
526
579
|
"data-testid": "drill-down-body",
|
|
527
580
|
children: f ? (() => {
|
|
528
581
|
let e = u.filter, t = e ? a ? { $and: [e, a] } : e : a;
|
|
529
|
-
return /* @__PURE__ */ Q(
|
|
582
|
+
return /* @__PURE__ */ Q(w, { schema: {
|
|
530
583
|
...u,
|
|
531
584
|
type: "spec-report",
|
|
532
585
|
report: {
|
|
@@ -535,7 +588,7 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
535
588
|
},
|
|
536
589
|
filter: t
|
|
537
590
|
} });
|
|
538
|
-
})() : /* @__PURE__ */ Q(
|
|
591
|
+
})() : /* @__PURE__ */ Q(Ft, {
|
|
539
592
|
schema: {
|
|
540
593
|
type: "object-data-table",
|
|
541
594
|
objectName: i,
|
|
@@ -556,42 +609,42 @@ var Dt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
556
609
|
dataSource: o
|
|
557
610
|
})
|
|
558
611
|
});
|
|
559
|
-
return r === "dialog" ? /* @__PURE__ */ Q(
|
|
612
|
+
return r === "dialog" ? /* @__PURE__ */ Q(z, {
|
|
560
613
|
open: e,
|
|
561
614
|
onOpenChange: (e) => !e && t(),
|
|
562
|
-
children: /* @__PURE__ */ $(
|
|
615
|
+
children: /* @__PURE__ */ $(fe, {
|
|
563
616
|
className: "max-w-5xl",
|
|
564
|
-
children: [/* @__PURE__ */ $(
|
|
617
|
+
children: [/* @__PURE__ */ $(pe, {
|
|
565
618
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
566
|
-
children: [/* @__PURE__ */ Q(
|
|
619
|
+
children: [/* @__PURE__ */ Q(me, { children: n }), m]
|
|
567
620
|
}), h]
|
|
568
621
|
})
|
|
569
|
-
}) : /* @__PURE__ */ Q(
|
|
622
|
+
}) : /* @__PURE__ */ Q(xe, {
|
|
570
623
|
open: e,
|
|
571
624
|
onOpenChange: (e) => !e && t(),
|
|
572
|
-
children: /* @__PURE__ */ $(
|
|
625
|
+
children: /* @__PURE__ */ $(Se, {
|
|
573
626
|
side: "right",
|
|
574
627
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
575
|
-
children: [/* @__PURE__ */ $(
|
|
628
|
+
children: [/* @__PURE__ */ $(Ce, {
|
|
576
629
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
577
|
-
children: [/* @__PURE__ */ Q(
|
|
630
|
+
children: [/* @__PURE__ */ Q(we, { children: n }), m]
|
|
578
631
|
}), /* @__PURE__ */ Q("div", {
|
|
579
632
|
className: "flex-1 overflow-hidden mt-2",
|
|
580
633
|
children: h
|
|
581
634
|
})]
|
|
582
635
|
})
|
|
583
636
|
});
|
|
584
|
-
},
|
|
585
|
-
function
|
|
637
|
+
}, Rt = i;
|
|
638
|
+
function zt(e, t, n) {
|
|
586
639
|
let r = [], i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
587
640
|
return e.forEach((e, c) => {
|
|
588
641
|
let l = t.map((t) => String(e[t] ?? "∅")).join(""), u = String(e[n] ?? "∅");
|
|
589
642
|
a.has(l) || (a.add(l), r.push({
|
|
590
643
|
id: l,
|
|
591
|
-
labels: t.map((t) =>
|
|
644
|
+
labels: t.map((t) => m(e[t]))
|
|
592
645
|
})), o.has(u) || (o.add(u), i.push({
|
|
593
646
|
id: u,
|
|
594
|
-
label:
|
|
647
|
+
label: m(e[n])
|
|
595
648
|
})), s.set(`${l} ${u}`, c);
|
|
596
649
|
}), {
|
|
597
650
|
rowHeaders: r,
|
|
@@ -599,26 +652,26 @@ function jt(e, t, n) {
|
|
|
599
652
|
cellIndex: s
|
|
600
653
|
};
|
|
601
654
|
}
|
|
602
|
-
function
|
|
655
|
+
function Bt(e) {
|
|
603
656
|
if (e == null) return "";
|
|
604
657
|
let t = String(e);
|
|
605
658
|
return /[",\n\r]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
606
659
|
}
|
|
607
|
-
function
|
|
608
|
-
return e.map((e) => e.map(
|
|
660
|
+
function Vt(e) {
|
|
661
|
+
return e.map((e) => e.map(Bt).join(",")).join("\r\n");
|
|
609
662
|
}
|
|
610
|
-
function
|
|
663
|
+
function Ht(e, t) {
|
|
611
664
|
if (typeof document > "u") return;
|
|
612
|
-
let n = e && e.trim() ? e.trim() : "export", r = new Blob([`\uFEFF${
|
|
665
|
+
let n = e && e.trim() ? e.trim() : "export", r = new Blob([`\uFEFF${Vt(t)}`], { type: "text/csv;charset=utf-8;" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
613
666
|
a.href = i, a.download = n.endsWith(".csv") ? n : `${n}.csv`, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
|
|
614
667
|
}
|
|
615
|
-
var
|
|
668
|
+
var Ut = /* @__PURE__ */ new Set([
|
|
616
669
|
"metric",
|
|
617
670
|
"kpi",
|
|
618
671
|
"gauge",
|
|
619
672
|
"solid-gauge",
|
|
620
673
|
"bullet"
|
|
621
|
-
]),
|
|
674
|
+
]), Wt = {
|
|
622
675
|
bar: "bar",
|
|
623
676
|
column: "column",
|
|
624
677
|
"horizontal-bar": "horizontal-bar",
|
|
@@ -640,44 +693,47 @@ var Ft = /* @__PURE__ */ new Set([
|
|
|
640
693
|
treemap: "treemap",
|
|
641
694
|
sankey: "sankey"
|
|
642
695
|
};
|
|
643
|
-
function
|
|
644
|
-
let
|
|
645
|
-
|
|
696
|
+
function Gt({ widget: e, dataSource: t }) {
|
|
697
|
+
let i = String(e?.dataset ?? ""), c = X(() => Array.isArray(e?.dimensions) ? e.dimensions.filter(Boolean) : [], [e]), l = X(() => Array.isArray(e?.values) ? e.values.filter(Boolean) : [], [e]), u = e?.compareTo && typeof e.compareTo == "object" ? e.compareTo : void 0, d = String(e?.type ?? ""), f = Ut.has(d) || c.length === 0, g = d === "table" || d === "pivot", _ = d === "pivot" && c.length >= 2, y = _ ? c.slice(0, -1) : [], b = _ ? c[c.length - 1] : "", S = _ ? [
|
|
698
|
+
y,
|
|
646
699
|
[b],
|
|
647
700
|
[]
|
|
648
|
-
] : void 0,
|
|
701
|
+
] : void 0, C = e?.options && typeof e.options == "object" && !Array.isArray(e.options) ? e.options : {}, T = typeof C.dateGranularity == "string" ? C.dateGranularity : void 0, E = typeof C.sortBy == "string" && C.sortBy ? C.sortBy : void 0, ee = E && (c.includes(E) || l.includes(E)) ? E : void 0, D = ee ? { [ee]: C.sortOrder === "desc" ? "desc" : "asc" } : void 0, O = typeof C.limit == "number" && Number.isFinite(C.limit) && C.limit > 0 ? Math.floor(C.limit) : void 0, k = N(), { fieldLabel: ne } = ae(), re = te(), A = e?.filter, ie = X(() => A && typeof A == "object" && Object.keys(A).length > 0 ? x(A, re) : void 0, [A, re]), [j, M] = Z({
|
|
649
702
|
status: "idle",
|
|
650
703
|
rows: []
|
|
651
|
-
}), [
|
|
704
|
+
}), [P, oe] = Z(null), [se, F] = Z(null), [ce, I] = Z(null), [ue, de] = Z(null);
|
|
652
705
|
if (Y(() => {
|
|
653
706
|
let e = t;
|
|
654
707
|
if (!e || typeof e.queryDataset != "function") {
|
|
655
|
-
|
|
708
|
+
M({
|
|
656
709
|
status: "error",
|
|
657
710
|
rows: [],
|
|
658
|
-
error:
|
|
711
|
+
error: k("dashboard.datasetUnsupported", "This data source does not support dataset queries.")
|
|
659
712
|
});
|
|
660
713
|
return;
|
|
661
714
|
}
|
|
662
|
-
if (
|
|
663
|
-
|
|
715
|
+
if (l.length === 0) {
|
|
716
|
+
M({
|
|
664
717
|
status: "idle",
|
|
665
718
|
rows: []
|
|
666
719
|
});
|
|
667
720
|
return;
|
|
668
721
|
}
|
|
669
722
|
let n = !1;
|
|
670
|
-
return
|
|
723
|
+
return M({
|
|
671
724
|
status: "loading",
|
|
672
725
|
rows: []
|
|
673
|
-
}), e.queryDataset(
|
|
674
|
-
dimensions:
|
|
675
|
-
measures:
|
|
676
|
-
...
|
|
677
|
-
...
|
|
678
|
-
...
|
|
726
|
+
}), e.queryDataset(i, {
|
|
727
|
+
dimensions: c,
|
|
728
|
+
measures: l,
|
|
729
|
+
...ie ? { runtimeFilter: ie } : {},
|
|
730
|
+
...u ? { compareTo: u } : {},
|
|
731
|
+
...S ? { totals: { groupings: S } } : {},
|
|
732
|
+
...T ? { dateGranularity: T } : {},
|
|
733
|
+
...D ? { order: D } : {},
|
|
734
|
+
...O == null ? {} : { limit: O }
|
|
679
735
|
}).then((e) => {
|
|
680
|
-
n ||
|
|
736
|
+
n || M({
|
|
681
737
|
status: "ok",
|
|
682
738
|
rows: Array.isArray(e?.rows) ? e.rows : [],
|
|
683
739
|
fields: Array.isArray(e?.fields) ? e.fields : [],
|
|
@@ -688,7 +744,7 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
688
744
|
totals: Array.isArray(e?.totals) ? e.totals : void 0
|
|
689
745
|
});
|
|
690
746
|
}).catch((e) => {
|
|
691
|
-
n ||
|
|
747
|
+
n || M({
|
|
692
748
|
status: "error",
|
|
693
749
|
rows: [],
|
|
694
750
|
error: String(e?.message ?? e)
|
|
@@ -696,45 +752,45 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
696
752
|
}), () => {
|
|
697
753
|
n = !0;
|
|
698
754
|
};
|
|
699
|
-
}, [`${
|
|
700
|
-
if (
|
|
701
|
-
|
|
755
|
+
}, [`${d}|${i}|${c.join(",")}|${l.join(",")}|${JSON.stringify(A ?? null)}|${JSON.stringify(u ?? null)}|${T ?? ""}|${JSON.stringify(D ?? null)}|${O ?? ""}`]), Y(() => {
|
|
756
|
+
if (f || g) {
|
|
757
|
+
F(null), I(null), de(null);
|
|
702
758
|
return;
|
|
703
759
|
}
|
|
704
|
-
let e =
|
|
705
|
-
if (!e ||
|
|
706
|
-
|
|
760
|
+
let e = j.object;
|
|
761
|
+
if (!e || c.length === 0) {
|
|
762
|
+
F(null), I(null), de(null);
|
|
707
763
|
return;
|
|
708
764
|
}
|
|
709
|
-
let t = (e) =>
|
|
765
|
+
let t = (e) => j.dimensionFields && j.dimensionFields[e] || e, r = !1;
|
|
710
766
|
return (async () => {
|
|
711
767
|
try {
|
|
712
|
-
let
|
|
768
|
+
let i = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`, {
|
|
713
769
|
headers: { accept: "application/json" },
|
|
714
770
|
credentials: "include"
|
|
715
|
-
})).json().catch(() => null),
|
|
716
|
-
for (let e of
|
|
717
|
-
let n = a
|
|
718
|
-
n && (
|
|
771
|
+
})).json().catch(() => null), a = i?.item ?? i?.data ?? i, l = a?.fields?.[t(c[0])]?.options, u = s(l), d = {};
|
|
772
|
+
for (let e of c) {
|
|
773
|
+
let n = o(a?.fields?.[t(e)]?.options);
|
|
774
|
+
n && (d[e] = n);
|
|
719
775
|
}
|
|
720
|
-
|
|
776
|
+
r || (F(u), I(Object.keys(d).length > 0 ? d : null), de(n(l)));
|
|
721
777
|
} catch {
|
|
722
|
-
|
|
778
|
+
r || (F(null), I(null), de(null));
|
|
723
779
|
}
|
|
724
780
|
})(), () => {
|
|
725
|
-
|
|
781
|
+
r = !0;
|
|
726
782
|
};
|
|
727
783
|
}, [
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
]),
|
|
784
|
+
j.object,
|
|
785
|
+
j.dimensionFields,
|
|
786
|
+
c,
|
|
787
|
+
f,
|
|
788
|
+
g
|
|
789
|
+
]), l.length === 0) return /* @__PURE__ */ Q("div", {
|
|
734
790
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
735
|
-
children:
|
|
791
|
+
children: k("dashboard.pickMeasures", "Pick measures (values) for this dataset widget.")
|
|
736
792
|
});
|
|
737
|
-
if (
|
|
793
|
+
if (j.status === "loading" || j.status === "idle") return /* @__PURE__ */ $("div", {
|
|
738
794
|
className: "h-full w-full p-2",
|
|
739
795
|
"data-testid": "dataset-loading",
|
|
740
796
|
role: "status",
|
|
@@ -742,79 +798,79 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
742
798
|
"aria-live": "polite",
|
|
743
799
|
children: [/* @__PURE__ */ Q("span", {
|
|
744
800
|
className: "sr-only",
|
|
745
|
-
children:
|
|
746
|
-
}),
|
|
801
|
+
children: k("dashboard.loading", "Loading…")
|
|
802
|
+
}), f ? /* @__PURE__ */ $("div", {
|
|
747
803
|
className: "flex h-full w-full flex-col items-start justify-center gap-2 p-2",
|
|
748
804
|
children: [/* @__PURE__ */ Q(G, { className: "h-8 w-32 rounded" }), /* @__PURE__ */ Q(G, { className: "h-3 w-20 rounded" })]
|
|
749
|
-
}) :
|
|
805
|
+
}) : g ? /* @__PURE__ */ Q(B, {
|
|
750
806
|
className: "h-full",
|
|
751
807
|
rows: 5,
|
|
752
|
-
columns: Math.max(2,
|
|
753
|
-
}) : /* @__PURE__ */ Q(
|
|
808
|
+
columns: Math.max(2, c.length + l.length)
|
|
809
|
+
}) : /* @__PURE__ */ Q(le, { className: "h-full" })]
|
|
754
810
|
});
|
|
755
|
-
if (
|
|
811
|
+
if (j.status === "error") return /* @__PURE__ */ $("div", {
|
|
756
812
|
role: "alert",
|
|
757
813
|
className: "flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive",
|
|
758
|
-
children: [/* @__PURE__ */ Q(
|
|
814
|
+
children: [/* @__PURE__ */ Q(Ne, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
759
815
|
className: "break-words",
|
|
760
|
-
children:
|
|
816
|
+
children: j.error
|
|
761
817
|
})]
|
|
762
818
|
});
|
|
763
|
-
if (
|
|
819
|
+
if (j.rows.length === 0 && !f) return /* @__PURE__ */ $("div", {
|
|
764
820
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
765
|
-
children: [/* @__PURE__ */ Q(
|
|
821
|
+
children: [/* @__PURE__ */ Q(Le, { className: "mr-2 h-4 w-4" }), k("dashboard.noRows", "No rows")]
|
|
766
822
|
});
|
|
767
|
-
let { measureField:
|
|
768
|
-
if (!
|
|
769
|
-
let r =
|
|
770
|
-
|
|
823
|
+
let { measureField: L, headerLabel: R } = a(j.fields, j.object, ne), { object: z, dimensionFields: fe, drillRawRows: pe, drillRanges: me } = j, he = fe ? c.filter((e) => e in fe) : [], ge = !!z && (he.length > 0 || !!me?.length), V = (t, n) => {
|
|
824
|
+
if (!z) return;
|
|
825
|
+
let r = Rt(pe?.[t], he, fe ?? {}, ie, me?.[t]);
|
|
826
|
+
oe({
|
|
771
827
|
filter: r,
|
|
772
828
|
title: n || String(e?.title ?? "")
|
|
773
829
|
});
|
|
774
|
-
},
|
|
830
|
+
}, H = P && z ? /* @__PURE__ */ Q(Lt, {
|
|
775
831
|
open: !0,
|
|
776
|
-
onClose: () =>
|
|
777
|
-
title:
|
|
778
|
-
objectName:
|
|
779
|
-
filter:
|
|
832
|
+
onClose: () => oe(null),
|
|
833
|
+
title: P.title || String(e?.title ?? k("dashboard.details", "Details")),
|
|
834
|
+
objectName: z,
|
|
835
|
+
filter: P.filter,
|
|
780
836
|
dataSource: t
|
|
781
837
|
}) : null;
|
|
782
|
-
if (
|
|
783
|
-
let e =
|
|
838
|
+
if (f) {
|
|
839
|
+
let e = L(l[0]);
|
|
784
840
|
return /* @__PURE__ */ $("div", {
|
|
785
841
|
className: "flex h-full w-full flex-col items-start justify-center gap-1 p-2",
|
|
786
842
|
children: [/* @__PURE__ */ Q("span", {
|
|
787
843
|
className: "text-2xl font-semibold tabular-nums",
|
|
788
|
-
children:
|
|
844
|
+
children: h(j.rows[0]?.[l[0]] ?? 0, e?.format, e?.currency, e?.percentScale)
|
|
789
845
|
}), /* @__PURE__ */ Q("span", {
|
|
790
846
|
className: "text-xs text-muted-foreground",
|
|
791
|
-
children:
|
|
847
|
+
children: R(l[0])
|
|
792
848
|
})]
|
|
793
849
|
});
|
|
794
850
|
}
|
|
795
|
-
if (
|
|
796
|
-
let t = [...
|
|
851
|
+
if (g) {
|
|
852
|
+
let t = [...c, ...l], n = /* @__PURE__ */ Q("button", {
|
|
797
853
|
type: "button",
|
|
798
|
-
onClick: () =>
|
|
854
|
+
onClick: () => Ht(String(e?.title ?? i ?? "export"), [t.map((e) => R(e)), ...j.rows.map((e) => t.map((t) => {
|
|
799
855
|
let n = e[t];
|
|
800
856
|
return n == null ? "" : typeof n == "number" ? n : String(n);
|
|
801
857
|
}))]),
|
|
802
858
|
"data-testid": "dataset-export",
|
|
803
|
-
title:
|
|
804
|
-
"aria-label":
|
|
859
|
+
title: k("dashboard.exportCsv", "Export CSV"),
|
|
860
|
+
"aria-label": k("dashboard.exportCsv", "Export CSV"),
|
|
805
861
|
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",
|
|
806
|
-
children: /* @__PURE__ */ Q(
|
|
862
|
+
children: /* @__PURE__ */ Q(ze, { className: "h-3.5 w-3.5" })
|
|
807
863
|
});
|
|
808
|
-
if (
|
|
809
|
-
let e =
|
|
864
|
+
if (_) {
|
|
865
|
+
let e = zt(j.rows, y, b), t = e.colHeaders.flatMap((e) => l.map((t) => ({
|
|
810
866
|
col: e,
|
|
811
867
|
measure: t,
|
|
812
|
-
header:
|
|
813
|
-
}))), r = (e, t) =>
|
|
814
|
-
for (let e of i(
|
|
868
|
+
header: l.length === 1 ? e.label : `${e.label} · ${R(t)}`
|
|
869
|
+
}))), r = (e, t) => h(e, L(t)?.format, L(t)?.currency, L(t)?.percentScale), i = (e) => j.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows, a = /* @__PURE__ */ new Map();
|
|
870
|
+
for (let e of i(y) ?? []) a.set(y.map((t) => String(e[t] ?? "∅")).join(""), e);
|
|
815
871
|
let o = /* @__PURE__ */ new Map();
|
|
816
872
|
for (let e of i([b]) ?? []) o.set(String(e[b] ?? "∅"), e);
|
|
817
|
-
let s = i([])?.[0],
|
|
873
|
+
let s = i([])?.[0], c = a.size > 0, u = o.size > 0, d = k("dashboard.total", "Total");
|
|
818
874
|
return /* @__PURE__ */ $("div", {
|
|
819
875
|
className: "relative h-full w-full overflow-auto p-1",
|
|
820
876
|
"data-testid": "dataset-matrix",
|
|
@@ -825,18 +881,18 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
825
881
|
children: [/* @__PURE__ */ Q("thead", {
|
|
826
882
|
className: "bg-muted/40",
|
|
827
883
|
children: /* @__PURE__ */ $("tr", { children: [
|
|
828
|
-
|
|
884
|
+
y.map((e) => /* @__PURE__ */ Q("th", {
|
|
829
885
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
830
|
-
children:
|
|
886
|
+
children: R(e)
|
|
831
887
|
}, e)),
|
|
832
888
|
t.map((e) => /* @__PURE__ */ Q("th", {
|
|
833
889
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
834
890
|
children: e.header
|
|
835
891
|
}, `${e.col.id}-${e.measure}`)),
|
|
836
|
-
|
|
892
|
+
c && l.map((e) => /* @__PURE__ */ Q("th", {
|
|
837
893
|
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
838
894
|
"data-testid": "matrix-total-col-header",
|
|
839
|
-
children:
|
|
895
|
+
children: l.length === 1 ? d : `${d} · ${R(e)}`
|
|
840
896
|
}, `total-${e}`))
|
|
841
897
|
] })
|
|
842
898
|
}), /* @__PURE__ */ $("tbody", { children: [e.rowHeaders.map((n) => /* @__PURE__ */ $("tr", {
|
|
@@ -847,15 +903,15 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
847
903
|
children: e
|
|
848
904
|
}, t)),
|
|
849
905
|
t.map((t) => {
|
|
850
|
-
let i = e.cellIndex.get(`${n.id} ${t.col.id}`), a = i == null ? void 0 :
|
|
906
|
+
let i = e.cellIndex.get(`${n.id} ${t.col.id}`), a = i == null ? void 0 : j.rows[i], o = ge && i != null, s = [...n.labels, t.col.label].filter(Boolean).join(" / ");
|
|
851
907
|
return /* @__PURE__ */ Q("td", {
|
|
852
908
|
className: K("px-2 py-1 text-right tabular-nums whitespace-nowrap", o && "cursor-pointer hover:bg-accent/40"),
|
|
853
909
|
"data-testid": o ? "dataset-drill-cell" : void 0,
|
|
854
|
-
onClick: o ? () =>
|
|
910
|
+
onClick: o ? () => V(i, s) : void 0,
|
|
855
911
|
children: a ? r(a[t.measure], t.measure) : "—"
|
|
856
912
|
}, `${t.col.id}-${t.measure}`);
|
|
857
913
|
}),
|
|
858
|
-
|
|
914
|
+
c && l.map((e) => /* @__PURE__ */ Q("td", {
|
|
859
915
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
860
916
|
"data-testid": "matrix-row-total",
|
|
861
917
|
children: r(a.get(n.id)?.[e], e)
|
|
@@ -865,8 +921,8 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
865
921
|
className: "border-t bg-muted/30 font-medium",
|
|
866
922
|
"data-testid": "matrix-total-row",
|
|
867
923
|
children: [
|
|
868
|
-
|
|
869
|
-
colSpan:
|
|
924
|
+
y.length > 0 && /* @__PURE__ */ Q("td", {
|
|
925
|
+
colSpan: y.length,
|
|
870
926
|
className: "px-2 py-1 whitespace-nowrap",
|
|
871
927
|
children: d
|
|
872
928
|
}),
|
|
@@ -874,7 +930,7 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
874
930
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
875
931
|
children: r(o.get(e.col.id)?.[e.measure], e.measure)
|
|
876
932
|
}, `${e.col.id}-${e.measure}`)),
|
|
877
|
-
|
|
933
|
+
c && l.map((e) => /* @__PURE__ */ Q("td", {
|
|
878
934
|
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
879
935
|
"data-testid": "matrix-grand-total",
|
|
880
936
|
children: r(s?.[e], e)
|
|
@@ -882,11 +938,11 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
882
938
|
]
|
|
883
939
|
})] })]
|
|
884
940
|
}),
|
|
885
|
-
|
|
941
|
+
H
|
|
886
942
|
]
|
|
887
943
|
});
|
|
888
944
|
}
|
|
889
|
-
let
|
|
945
|
+
let r = [...c, ...l];
|
|
890
946
|
return /* @__PURE__ */ $("div", {
|
|
891
947
|
className: "relative h-full w-full overflow-auto p-1",
|
|
892
948
|
children: [
|
|
@@ -895,79 +951,84 @@ function Lt({ widget: e, dataSource: t }) {
|
|
|
895
951
|
className: "w-full text-xs",
|
|
896
952
|
children: [/* @__PURE__ */ Q("thead", {
|
|
897
953
|
className: "bg-muted/40",
|
|
898
|
-
children: /* @__PURE__ */ Q("tr", { children:
|
|
954
|
+
children: /* @__PURE__ */ Q("tr", { children: r.map((e) => /* @__PURE__ */ Q("th", {
|
|
899
955
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
900
|
-
children:
|
|
956
|
+
children: R(e)
|
|
901
957
|
}, e)) })
|
|
902
|
-
}), /* @__PURE__ */ Q("tbody", { children:
|
|
903
|
-
className: K("border-t",
|
|
904
|
-
"data-testid":
|
|
905
|
-
onClick:
|
|
906
|
-
children:
|
|
958
|
+
}), /* @__PURE__ */ Q("tbody", { children: j.rows.map((e, t) => /* @__PURE__ */ Q("tr", {
|
|
959
|
+
className: K("border-t", ge && "cursor-pointer hover:bg-accent/40"),
|
|
960
|
+
"data-testid": ge ? "dataset-drill-row" : void 0,
|
|
961
|
+
onClick: ge ? () => V(t, he.map((t) => m(e[t])).filter(Boolean).join(" / ")) : void 0,
|
|
962
|
+
children: r.map((t) => /* @__PURE__ */ Q("td", {
|
|
907
963
|
className: "px-2 py-1 whitespace-nowrap tabular-nums",
|
|
908
|
-
children:
|
|
964
|
+
children: l.includes(t) ? h(e[t], L(t)?.format, L(t)?.currency, L(t)?.percentScale) : m(e[t])
|
|
909
965
|
}, t))
|
|
910
966
|
}, t)) })]
|
|
911
967
|
}),
|
|
912
|
-
|
|
968
|
+
H
|
|
913
969
|
]
|
|
914
970
|
});
|
|
915
971
|
}
|
|
916
|
-
let
|
|
917
|
-
let t =
|
|
972
|
+
let U = Wt[d] ?? "bar", _e = v(j.rows, ce), { data: ve, xAxisKey: W, series: ye } = r(_e, c, l, j.fields), be = (Array.isArray(C.stageOrder) ? C.stageOrder : void 0)?.flatMap((e) => {
|
|
973
|
+
let t = String(e), n = ce?.[c[0]]?.[t];
|
|
974
|
+
return n && n !== t ? [t, n] : [t];
|
|
975
|
+
}), xe = be?.length ? be : ue, Se = e?.chartConfig && typeof e.chartConfig == "object" && !Array.isArray(e.chartConfig) ? e.chartConfig : {}, Ce = typeof Se.showLegend == "boolean" ? Se.showLegend : void 0, we = ge ? (e) => {
|
|
976
|
+
let t = p(_e, c, l, e?.category, e?.series);
|
|
918
977
|
if (t < 0) return;
|
|
919
|
-
let n =
|
|
920
|
-
|
|
978
|
+
let n = c.length >= 2 && l.length === 1, r = [e?.category, n ? e?.series : void 0].filter(Boolean).map(String).join(" / ");
|
|
979
|
+
V(t, r);
|
|
921
980
|
} : void 0;
|
|
922
981
|
return /* @__PURE__ */ $("div", {
|
|
923
982
|
className: K("relative h-full w-full min-h-[220px]"),
|
|
924
|
-
children: [/* @__PURE__ */ Q(
|
|
983
|
+
children: [/* @__PURE__ */ Q(w, {
|
|
925
984
|
schema: {
|
|
926
985
|
type: "chart",
|
|
927
|
-
chartType:
|
|
928
|
-
data:
|
|
929
|
-
xAxisKey:
|
|
930
|
-
series:
|
|
986
|
+
chartType: U,
|
|
987
|
+
data: ve,
|
|
988
|
+
xAxisKey: W,
|
|
989
|
+
series: ye,
|
|
931
990
|
isAnimationActive: !1,
|
|
932
|
-
...
|
|
991
|
+
...Ce == null ? {} : { showLegend: Ce },
|
|
992
|
+
...se ? { categoryColors: se } : {},
|
|
993
|
+
...xe ? { categoryOrder: xe } : {}
|
|
933
994
|
},
|
|
934
|
-
onChartClick:
|
|
935
|
-
onSegmentClick:
|
|
936
|
-
}),
|
|
995
|
+
onChartClick: we,
|
|
996
|
+
onSegmentClick: we
|
|
997
|
+
}), H]
|
|
937
998
|
});
|
|
938
999
|
}
|
|
939
1000
|
//#endregion
|
|
940
1001
|
//#region src/DashboardFilterBar.tsx
|
|
941
|
-
var
|
|
942
|
-
function
|
|
1002
|
+
var Kt = "__all__", qt = "__custom__";
|
|
1003
|
+
function Jt(e, t) {
|
|
943
1004
|
if (e) {
|
|
944
1005
|
if (e.preset) return t(e.preset);
|
|
945
1006
|
if (e.from || e.to) return `${e.from ?? "…"} – ${e.to ?? "…"}`;
|
|
946
1007
|
}
|
|
947
1008
|
}
|
|
948
|
-
function
|
|
1009
|
+
function Yt(e) {
|
|
949
1010
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
950
1011
|
}
|
|
951
|
-
function
|
|
952
|
-
let i =
|
|
1012
|
+
function Xt({ def: e, value: n, onChange: r }) {
|
|
1013
|
+
let i = N(), [a, o] = Z(!1), s = e.allowCustomRange !== !1, c = (e) => i(`dashboard.filters.range.${e}`, e.replace(/_/g, " ")), l = n?.preset ?? (n?.from || n?.to ? qt : Kt);
|
|
953
1014
|
return /* @__PURE__ */ $("div", {
|
|
954
1015
|
className: "flex items-center gap-1",
|
|
955
1016
|
"data-testid": `dashboard-filter-${e.name}`,
|
|
956
|
-
children: [/* @__PURE__ */ $(
|
|
1017
|
+
children: [/* @__PURE__ */ $(_e, {
|
|
957
1018
|
value: l,
|
|
958
1019
|
onValueChange: (e) => {
|
|
959
|
-
e ===
|
|
1020
|
+
e === Kt ? r(void 0) : e === qt ? o(!0) : r({ preset: e });
|
|
960
1021
|
},
|
|
961
|
-
children: [/* @__PURE__ */ $(
|
|
1022
|
+
children: [/* @__PURE__ */ $(ye, {
|
|
962
1023
|
className: "h-8 w-auto min-w-36 gap-1",
|
|
963
1024
|
"aria-label": e.label || i("dashboard.filters.dateRange", "Date range"),
|
|
964
|
-
children: [/* @__PURE__ */ Q(
|
|
1025
|
+
children: [/* @__PURE__ */ Q(Re, { className: "size-3.5 opacity-60" }), /* @__PURE__ */ Q(be, {
|
|
965
1026
|
placeholder: i("dashboard.filters.dateRange", "Date range"),
|
|
966
|
-
children:
|
|
1027
|
+
children: Jt(n, c) ?? i("dashboard.filters.allTime", "All time")
|
|
967
1028
|
})]
|
|
968
|
-
}), /* @__PURE__ */ $(
|
|
1029
|
+
}), /* @__PURE__ */ $(ve, { children: [
|
|
969
1030
|
/* @__PURE__ */ Q(W, {
|
|
970
|
-
value:
|
|
1031
|
+
value: Kt,
|
|
971
1032
|
children: i("dashboard.filters.allTime", "All time")
|
|
972
1033
|
}),
|
|
973
1034
|
t.map((e) => /* @__PURE__ */ Q(W, {
|
|
@@ -975,23 +1036,23 @@ function Ht({ def: e, value: n, onChange: r }) {
|
|
|
975
1036
|
children: c(e)
|
|
976
1037
|
}, e)),
|
|
977
1038
|
s && /* @__PURE__ */ Q(W, {
|
|
978
|
-
value:
|
|
1039
|
+
value: qt,
|
|
979
1040
|
children: i("dashboard.filters.custom", "Custom…")
|
|
980
1041
|
})
|
|
981
1042
|
] })]
|
|
982
|
-
}), s && /* @__PURE__ */ $(
|
|
1043
|
+
}), s && /* @__PURE__ */ $(ge, {
|
|
983
1044
|
open: a,
|
|
984
1045
|
onOpenChange: o,
|
|
985
|
-
children: [/* @__PURE__ */ Q(
|
|
1046
|
+
children: [/* @__PURE__ */ Q(H, {
|
|
986
1047
|
asChild: !0,
|
|
987
1048
|
children: /* @__PURE__ */ Q("span", {
|
|
988
1049
|
"aria-hidden": !0,
|
|
989
1050
|
className: "size-0"
|
|
990
1051
|
})
|
|
991
|
-
}), /* @__PURE__ */ Q(
|
|
1052
|
+
}), /* @__PURE__ */ Q(V, {
|
|
992
1053
|
className: "w-auto p-0",
|
|
993
1054
|
align: "start",
|
|
994
|
-
children: /* @__PURE__ */ Q(
|
|
1055
|
+
children: /* @__PURE__ */ Q(oe, {
|
|
995
1056
|
mode: "range",
|
|
996
1057
|
numberOfMonths: 2,
|
|
997
1058
|
selected: {
|
|
@@ -1004,8 +1065,8 @@ function Ht({ def: e, value: n, onChange: r }) {
|
|
|
1004
1065
|
return;
|
|
1005
1066
|
}
|
|
1006
1067
|
r({
|
|
1007
|
-
...e?.from ? { from:
|
|
1008
|
-
...e?.to ? { to:
|
|
1068
|
+
...e?.from ? { from: Yt(e.from) } : {},
|
|
1069
|
+
...e?.to ? { to: Yt(e.to) } : {}
|
|
1009
1070
|
});
|
|
1010
1071
|
}
|
|
1011
1072
|
})
|
|
@@ -1013,8 +1074,8 @@ function Ht({ def: e, value: n, onChange: r }) {
|
|
|
1013
1074
|
})]
|
|
1014
1075
|
});
|
|
1015
1076
|
}
|
|
1016
|
-
function
|
|
1017
|
-
let i =
|
|
1077
|
+
function Zt({ def: e, value: t, onChange: n, dataSource: r }) {
|
|
1078
|
+
let i = N(), [a, o] = Z(null), s = e.optionsFrom;
|
|
1018
1079
|
Y(() => {
|
|
1019
1080
|
if (!s || !r) return;
|
|
1020
1081
|
let e = !1, t = () => {
|
|
@@ -1093,16 +1154,16 @@ function Ut({ def: e, value: t, onChange: n, dataSource: r }) {
|
|
|
1093
1154
|
r
|
|
1094
1155
|
]);
|
|
1095
1156
|
let c = X(() => e.options?.length ? e.options : a ?? [], [e.options, a]), l = e.label || e.name, u = t ? c.find((e) => e.value === String(t))?.label ?? String(t) : void 0;
|
|
1096
|
-
return /* @__PURE__ */ $(
|
|
1097
|
-
value: t ? String(t) :
|
|
1098
|
-
onValueChange: (e) => n(e ===
|
|
1099
|
-
children: [/* @__PURE__ */ Q(
|
|
1157
|
+
return /* @__PURE__ */ $(_e, {
|
|
1158
|
+
value: t ? String(t) : Kt,
|
|
1159
|
+
onValueChange: (e) => n(e === Kt ? void 0 : e),
|
|
1160
|
+
children: [/* @__PURE__ */ Q(ye, {
|
|
1100
1161
|
className: "h-8 w-auto min-w-32",
|
|
1101
1162
|
"aria-label": l,
|
|
1102
1163
|
"data-testid": `dashboard-filter-${e.name}`,
|
|
1103
|
-
children: /* @__PURE__ */ Q(
|
|
1104
|
-
}), /* @__PURE__ */ $(
|
|
1105
|
-
value:
|
|
1164
|
+
children: /* @__PURE__ */ Q(be, { children: u ?? `${l}: ${i("dashboard.filters.all", "All")}` })
|
|
1165
|
+
}), /* @__PURE__ */ $(ve, { children: [/* @__PURE__ */ Q(W, {
|
|
1166
|
+
value: Kt,
|
|
1106
1167
|
children: i("dashboard.filters.all", "All")
|
|
1107
1168
|
}), c.map((e) => /* @__PURE__ */ Q(W, {
|
|
1108
1169
|
value: e.value,
|
|
@@ -1110,7 +1171,7 @@ function Ut({ def: e, value: t, onChange: n, dataSource: r }) {
|
|
|
1110
1171
|
}, e.value))] })]
|
|
1111
1172
|
});
|
|
1112
1173
|
}
|
|
1113
|
-
function
|
|
1174
|
+
function Qt({ def: e, value: t, onChange: n }) {
|
|
1114
1175
|
let [r, i] = Z(t == null ? "" : String(t));
|
|
1115
1176
|
Y(() => {
|
|
1116
1177
|
i(t == null ? "" : String(t));
|
|
@@ -1123,7 +1184,7 @@ function Wt({ def: e, value: t, onChange: n }) {
|
|
|
1123
1184
|
}
|
|
1124
1185
|
n(e.type === "number" ? Number(t) : t);
|
|
1125
1186
|
};
|
|
1126
|
-
return /* @__PURE__ */ Q(
|
|
1187
|
+
return /* @__PURE__ */ Q(he, {
|
|
1127
1188
|
className: "h-8 w-36",
|
|
1128
1189
|
type: e.type === "number" ? "number" : "text",
|
|
1129
1190
|
placeholder: e.label || e.name,
|
|
@@ -1137,8 +1198,8 @@ function Wt({ def: e, value: t, onChange: n }) {
|
|
|
1137
1198
|
"data-testid": `dashboard-filter-${e.name}`
|
|
1138
1199
|
});
|
|
1139
1200
|
}
|
|
1140
|
-
function
|
|
1141
|
-
let o =
|
|
1201
|
+
function $t({ defs: e, values: t, onChange: n, onReset: r, dataSource: i, className: a }) {
|
|
1202
|
+
let o = N();
|
|
1142
1203
|
if (e.length === 0) return null;
|
|
1143
1204
|
let s = (e) => e == null || e === "" || typeof e == "object" && Object.keys(e).length === 0, c = e.some((e) => {
|
|
1144
1205
|
let n = t[e.name], r = e.defaultValue;
|
|
@@ -1151,40 +1212,40 @@ function Gt({ defs: e, values: t, onChange: n, onReset: r, dataSource: i, classN
|
|
|
1151
1212
|
"aria-label": o("dashboard.filters.label", "Dashboard filters"),
|
|
1152
1213
|
children: [e.map((e) => {
|
|
1153
1214
|
let r = t[e.name], a = (t) => n(e.name, t);
|
|
1154
|
-
return e.type === "dateRange" || e.type === "date" ? /* @__PURE__ */ Q(
|
|
1215
|
+
return e.type === "dateRange" || e.type === "date" ? /* @__PURE__ */ Q(Xt, {
|
|
1155
1216
|
def: e,
|
|
1156
1217
|
value: r,
|
|
1157
1218
|
onChange: a
|
|
1158
|
-
}, e.name) : e.type === "select" || e.type === "lookup" ? /* @__PURE__ */ Q(
|
|
1219
|
+
}, e.name) : e.type === "select" || e.type === "lookup" ? /* @__PURE__ */ Q(Zt, {
|
|
1159
1220
|
def: e,
|
|
1160
1221
|
value: r,
|
|
1161
1222
|
onChange: a,
|
|
1162
1223
|
dataSource: i
|
|
1163
|
-
}, e.name) : /* @__PURE__ */ Q(
|
|
1224
|
+
}, e.name) : /* @__PURE__ */ Q(Qt, {
|
|
1164
1225
|
def: e,
|
|
1165
1226
|
value: r,
|
|
1166
1227
|
onChange: a
|
|
1167
1228
|
}, e.name);
|
|
1168
|
-
}), r && c && /* @__PURE__ */ $(
|
|
1229
|
+
}), r && c && /* @__PURE__ */ $(P, {
|
|
1169
1230
|
variant: "ghost",
|
|
1170
1231
|
size: "sm",
|
|
1171
1232
|
onClick: r,
|
|
1172
1233
|
className: "text-muted-foreground",
|
|
1173
|
-
children: [/* @__PURE__ */ Q(
|
|
1234
|
+
children: [/* @__PURE__ */ Q(Ge, { className: "size-3.5" }), o("dashboard.filters.reset", "Reset")]
|
|
1174
1235
|
})]
|
|
1175
1236
|
});
|
|
1176
1237
|
}
|
|
1177
1238
|
//#endregion
|
|
1178
1239
|
//#region src/DashboardRenderer.tsx
|
|
1179
|
-
function
|
|
1180
|
-
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } =
|
|
1240
|
+
function en({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
1241
|
+
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } = rt({
|
|
1181
1242
|
id: e,
|
|
1182
1243
|
disabled: t
|
|
1183
1244
|
});
|
|
1184
1245
|
return /* @__PURE__ */ Q("div", {
|
|
1185
1246
|
ref: s,
|
|
1186
1247
|
style: {
|
|
1187
|
-
transform:
|
|
1248
|
+
transform: at.Transform.toString(c),
|
|
1188
1249
|
transition: l,
|
|
1189
1250
|
opacity: u ? .4 : 1,
|
|
1190
1251
|
...n ? {
|
|
@@ -1199,58 +1260,19 @@ function Kt({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
|
1199
1260
|
children: i
|
|
1200
1261
|
});
|
|
1201
1262
|
}
|
|
1202
|
-
function
|
|
1203
|
-
return e ?
|
|
1263
|
+
function tn(e) {
|
|
1264
|
+
return e ? Te(e) : null;
|
|
1204
1265
|
}
|
|
1205
|
-
function
|
|
1266
|
+
function nn(e) {
|
|
1206
1267
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
1207
1268
|
}
|
|
1208
|
-
var
|
|
1269
|
+
var rn = [
|
|
1209
1270
|
"hsl(var(--chart-1))",
|
|
1210
1271
|
"hsl(var(--chart-2))",
|
|
1211
1272
|
"hsl(var(--chart-3))",
|
|
1212
1273
|
"hsl(var(--chart-4))",
|
|
1213
1274
|
"hsl(var(--chart-5))"
|
|
1214
|
-
],
|
|
1215
|
-
column: "bar",
|
|
1216
|
-
"stacked-bar": "bar",
|
|
1217
|
-
"grouped-bar": "bar",
|
|
1218
|
-
"bi-polar-bar": "bar",
|
|
1219
|
-
spline: "line",
|
|
1220
|
-
"step-line": "line",
|
|
1221
|
-
"stacked-area": "area",
|
|
1222
|
-
pyramid: "funnel",
|
|
1223
|
-
bubble: "scatter"
|
|
1224
|
-
}, Zt = /* @__PURE__ */ new Set([
|
|
1225
|
-
"bar",
|
|
1226
|
-
"horizontal-bar",
|
|
1227
|
-
"line",
|
|
1228
|
-
"area",
|
|
1229
|
-
"pie",
|
|
1230
|
-
"donut",
|
|
1231
|
-
"scatter",
|
|
1232
|
-
"funnel",
|
|
1233
|
-
"radar",
|
|
1234
|
-
"treemap",
|
|
1235
|
-
"sankey"
|
|
1236
|
-
]), Qt = /* @__PURE__ */ new Set([
|
|
1237
|
-
"gauge",
|
|
1238
|
-
"solid-gauge",
|
|
1239
|
-
"kpi",
|
|
1240
|
-
"bullet"
|
|
1241
|
-
]), $t = /* @__PURE__ */ new Set([
|
|
1242
|
-
"sunburst",
|
|
1243
|
-
"word-cloud",
|
|
1244
|
-
"choropleth",
|
|
1245
|
-
"bubble-map",
|
|
1246
|
-
"gl-map",
|
|
1247
|
-
"heatmap",
|
|
1248
|
-
"waterfall",
|
|
1249
|
-
"box-plot",
|
|
1250
|
-
"violin",
|
|
1251
|
-
"candlestick",
|
|
1252
|
-
"stock"
|
|
1253
|
-
]), en = /* @__PURE__ */ new Set([
|
|
1275
|
+
], an = /* @__PURE__ */ new Set([
|
|
1254
1276
|
"bar",
|
|
1255
1277
|
"horizontal-bar",
|
|
1256
1278
|
"line",
|
|
@@ -1262,21 +1284,21 @@ var Yt = [
|
|
|
1262
1284
|
"treemap",
|
|
1263
1285
|
"sankey"
|
|
1264
1286
|
]);
|
|
1265
|
-
function
|
|
1266
|
-
return
|
|
1287
|
+
function on(e) {
|
|
1288
|
+
return an.has(e) ? { enabled: !0 } : void 0;
|
|
1267
1289
|
}
|
|
1268
|
-
var
|
|
1290
|
+
var sn = /* @__PURE__ */ new Set([
|
|
1269
1291
|
"object-chart",
|
|
1270
1292
|
"object-metric",
|
|
1271
1293
|
"object-data-table"
|
|
1272
|
-
]),
|
|
1294
|
+
]), cn = {
|
|
1273
1295
|
type: "text",
|
|
1274
1296
|
value: "This widget uses a retired data format. Edit it to bind a dataset.",
|
|
1275
1297
|
variant: "caption",
|
|
1276
1298
|
align: "center",
|
|
1277
1299
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed border-destructive/40 bg-destructive/5 p-4 text-center text-destructive"
|
|
1278
|
-
},
|
|
1279
|
-
let
|
|
1300
|
+
}, ln = ke(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount: i, userActions: a, designMode: o, selectedWidgetId: s, onWidgetClick: l, onWidgetsReorder: u, modalHandler: d, scriptHandlers: f, hideHeaderText: p, ...m }, h) => {
|
|
1301
|
+
let g = (() => {
|
|
1280
1302
|
if (e.columns != null) return e.columns;
|
|
1281
1303
|
let t = e.widgets ?? [], n = 0;
|
|
1282
1304
|
for (let e of t) {
|
|
@@ -1284,48 +1306,48 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1284
1306
|
t > n && (n = t), (e.layout?.w ?? 0) > n && (n = e.layout.w);
|
|
1285
1307
|
}
|
|
1286
1308
|
return n > 4 ? 12 : 4;
|
|
1287
|
-
})(),
|
|
1309
|
+
})(), v = g, b = e.gap || 4, x = e.columns != null || g !== 4, [S, C] = Z(!1), [T, ee] = Z(!1), D = je(null), O = X(() => y(e), [e.globalFilters, e.dateRange]), { variables: te, setVariable: k, resetVariables: A } = re(), { executeAction: ie, engine: j } = E({ actions: X(() => (e.header?.actions ?? []).map((e) => ({
|
|
1288
1310
|
name: e.actionUrl || e.label,
|
|
1289
1311
|
type: e.actionType || "url",
|
|
1290
1312
|
target: e.actionUrl,
|
|
1291
1313
|
label: e.label
|
|
1292
|
-
})), [e.header?.actions]) }), { dashboardLabel:
|
|
1293
|
-
if (!
|
|
1314
|
+
})), [e.header?.actions]) }), { dashboardLabel: ae, dashboardDescription: N, dashboardActionLabel: oe, widgetTitle: le, widgetDescription: ue, fieldLabel: de } = ne(), { t: L } = M(), R = J((e, t, n) => n && (!t || t === "value" || t === "count" || n === "count") ? L(`report.aggregate.${n}`, { defaultValue: n }) : e ? de(e, t, t) : t, [L, de]), z = e.name, fe = J((e) => {
|
|
1315
|
+
if (!z) return e.label;
|
|
1294
1316
|
let t = e.actionUrl || e.label;
|
|
1295
|
-
return z
|
|
1296
|
-
}, [
|
|
1297
|
-
let t =
|
|
1298
|
-
return !
|
|
1299
|
-
}, [
|
|
1300
|
-
let t =
|
|
1301
|
-
return !
|
|
1302
|
-
}, [
|
|
1317
|
+
return oe(z, t, e.label);
|
|
1318
|
+
}, [z, oe]), pe = J((e) => {
|
|
1319
|
+
let t = nn(e.title);
|
|
1320
|
+
return !z || !e.id || t === void 0 ? t : le(z, e.id, t);
|
|
1321
|
+
}, [z, le]), me = J((e) => {
|
|
1322
|
+
let t = nn(e.description);
|
|
1323
|
+
return !z || !e.id ? t : ue(z, e.id, t);
|
|
1324
|
+
}, [z, ue]);
|
|
1303
1325
|
Y(() => {
|
|
1304
|
-
let e =
|
|
1326
|
+
let e = j.getRunner();
|
|
1305
1327
|
if (d && e.setModalHandler(d), f) for (let [t, n] of Object.entries(f)) e.registerScript(t, n);
|
|
1306
1328
|
}, [
|
|
1307
|
-
|
|
1329
|
+
j,
|
|
1308
1330
|
d,
|
|
1309
1331
|
f
|
|
1310
1332
|
]), Y(() => {
|
|
1311
|
-
let e = () =>
|
|
1333
|
+
let e = () => ee(window.innerWidth < 768);
|
|
1312
1334
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
1313
1335
|
}, []);
|
|
1314
|
-
let
|
|
1315
|
-
r && (
|
|
1336
|
+
let B = J(() => {
|
|
1337
|
+
r && (C(!0), r(), setTimeout(() => C(!1), 600));
|
|
1316
1338
|
}, [r]);
|
|
1317
1339
|
Y(() => {
|
|
1318
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return
|
|
1319
|
-
|
|
1340
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return D.current = setInterval(B, e.refreshInterval * 1e3), () => {
|
|
1341
|
+
D.current && clearInterval(D.current);
|
|
1320
1342
|
};
|
|
1321
1343
|
}, [
|
|
1322
1344
|
e.refreshInterval,
|
|
1323
1345
|
r,
|
|
1324
|
-
|
|
1346
|
+
B
|
|
1325
1347
|
]);
|
|
1326
|
-
let
|
|
1348
|
+
let he = J((e, t) => {
|
|
1327
1349
|
!o || !l || !t || (e.stopPropagation(), l(t));
|
|
1328
|
-
}, [o, l]),
|
|
1350
|
+
}, [o, l]), ge = J((t, n, r) => {
|
|
1329
1351
|
if (!o || !l) return;
|
|
1330
1352
|
let i = e.widgets || [];
|
|
1331
1353
|
if (t.key === "Enter" || t.key === " ") t.preventDefault(), l(n ?? null);
|
|
@@ -1342,109 +1364,107 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1342
1364
|
o,
|
|
1343
1365
|
l,
|
|
1344
1366
|
e.widgets
|
|
1345
|
-
]),
|
|
1367
|
+
]), V = J((e) => {
|
|
1346
1368
|
!o || !l || e.target === e.currentTarget && l(null);
|
|
1347
|
-
}, [o, l]),
|
|
1348
|
-
if (!
|
|
1369
|
+
}, [o, l]), H = !!(o && u), U = $e(Qe(Xe, { activationConstraint: { distance: 5 } })), _e = J((t) => {
|
|
1370
|
+
if (!H) return;
|
|
1349
1371
|
let { active: n, over: r } = t;
|
|
1350
1372
|
if (!r || n.id === r.id) return;
|
|
1351
1373
|
let i = e.widgets ?? [], a = i.findIndex((e) => e.id === n.id), o = i.findIndex((e) => e.id === r.id);
|
|
1352
|
-
a < 0 || o < 0 || u?.(
|
|
1374
|
+
a < 0 || o < 0 || u?.(tt(i, a, o));
|
|
1353
1375
|
}, [
|
|
1354
|
-
|
|
1376
|
+
H,
|
|
1355
1377
|
e.widgets,
|
|
1356
1378
|
u
|
|
1357
|
-
]),
|
|
1358
|
-
let i = e.type === "metric" ||
|
|
1359
|
-
w: Math.min(i ? 3 : 6,
|
|
1379
|
+
]), ve = (e, t, r) => {
|
|
1380
|
+
let i = e.type === "metric" || vt.has(e.type || ""), a = x ? {
|
|
1381
|
+
w: Math.min(i ? 3 : 6, v),
|
|
1360
1382
|
h: i ? 2 : 4
|
|
1361
1383
|
} : void 0, l = e.layout ?? a, u = l ? {
|
|
1362
1384
|
...l,
|
|
1363
|
-
w: Math.min(l.w,
|
|
1385
|
+
w: Math.min(l.w, v)
|
|
1364
1386
|
} : void 0, d = !!e.dataset, f = () => {
|
|
1365
1387
|
if (e.component) return e.component;
|
|
1366
1388
|
let t = e.type, n = e.options || {}, r = e.data || n.data;
|
|
1367
|
-
if (!r && e.object) return
|
|
1368
|
-
let i = t
|
|
1369
|
-
if (i &&
|
|
1370
|
-
let t = n.xField || "name",
|
|
1371
|
-
if (
|
|
1372
|
-
let
|
|
1373
|
-
field:
|
|
1374
|
-
function:
|
|
1375
|
-
groupBy:
|
|
1376
|
-
} : void 0,
|
|
1389
|
+
if (!r && e.object) return cn;
|
|
1390
|
+
let i = xt(t), a = i.chartType ?? t;
|
|
1391
|
+
if (i.family === "series" && i.chartType) {
|
|
1392
|
+
let t = n.xField || "name", o = n.yField || "value";
|
|
1393
|
+
if (mt(r)) {
|
|
1394
|
+
let s = r.aggregate, c = s ? {
|
|
1395
|
+
field: s.field,
|
|
1396
|
+
function: s.function,
|
|
1397
|
+
groupBy: s.groupBy
|
|
1398
|
+
} : void 0, l = c?.field || o;
|
|
1377
1399
|
return {
|
|
1378
1400
|
type: "object-chart",
|
|
1379
|
-
chartType:
|
|
1401
|
+
chartType: a,
|
|
1380
1402
|
objectName: r.object,
|
|
1381
|
-
aggregate:
|
|
1403
|
+
aggregate: c,
|
|
1382
1404
|
filter: r.filter || e.filter,
|
|
1383
1405
|
xAxisKey: t,
|
|
1384
1406
|
series: [{
|
|
1385
|
-
dataKey:
|
|
1386
|
-
label:
|
|
1407
|
+
dataKey: l,
|
|
1408
|
+
label: R(r.object, l, c?.function)
|
|
1387
1409
|
}],
|
|
1388
|
-
colors:
|
|
1410
|
+
colors: rn,
|
|
1389
1411
|
isAnimationActive: !1,
|
|
1390
|
-
drillDown: n.drillDown ??
|
|
1412
|
+
drillDown: n.drillDown ?? on(i.chartType),
|
|
1391
1413
|
compareTo: e.compareTo,
|
|
1392
1414
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1393
1415
|
};
|
|
1394
1416
|
}
|
|
1395
1417
|
return {
|
|
1396
1418
|
type: "chart",
|
|
1397
|
-
chartType:
|
|
1419
|
+
chartType: a,
|
|
1398
1420
|
data: Array.isArray(r) ? r : r?.items || [],
|
|
1399
1421
|
xAxisKey: t,
|
|
1400
1422
|
series: [{
|
|
1401
|
-
dataKey:
|
|
1402
|
-
label:
|
|
1423
|
+
dataKey: o,
|
|
1424
|
+
label: R(void 0, o, void 0)
|
|
1403
1425
|
}],
|
|
1404
|
-
colors:
|
|
1426
|
+
colors: rn,
|
|
1405
1427
|
isAnimationActive: !1,
|
|
1406
1428
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1407
1429
|
};
|
|
1408
1430
|
}
|
|
1409
|
-
if (
|
|
1410
|
-
|
|
1411
|
-
|
|
1431
|
+
if (i.family === "metric") {
|
|
1432
|
+
let i = nn(e.title) || t;
|
|
1433
|
+
if (mt(r)) {
|
|
1434
|
+
let t = r.aggregate;
|
|
1412
1435
|
return {
|
|
1413
|
-
type: "object-
|
|
1414
|
-
...
|
|
1436
|
+
type: "object-metric",
|
|
1437
|
+
...n,
|
|
1415
1438
|
objectName: r.object,
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
},
|
|
1424
|
-
className: "border-0"
|
|
1439
|
+
label: i,
|
|
1440
|
+
aggregate: t ? {
|
|
1441
|
+
field: t.field,
|
|
1442
|
+
function: t.function,
|
|
1443
|
+
groupBy: t.groupBy
|
|
1444
|
+
} : void 0,
|
|
1445
|
+
filter: r.filter || e.filter
|
|
1425
1446
|
};
|
|
1426
1447
|
}
|
|
1448
|
+
let a = Array.isArray(r) ? r : r?.items || [], o = n.yField || "value";
|
|
1427
1449
|
return {
|
|
1428
|
-
type: "
|
|
1450
|
+
type: "metric",
|
|
1429
1451
|
...n,
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
pagination: !1,
|
|
1433
|
-
className: "border-0"
|
|
1452
|
+
label: i,
|
|
1453
|
+
value: n.value ?? a[0]?.[o] ?? "—"
|
|
1434
1454
|
};
|
|
1435
1455
|
}
|
|
1436
|
-
if (
|
|
1437
|
-
|
|
1438
|
-
if (
|
|
1439
|
-
let { data: t, ...
|
|
1456
|
+
if (i.family === "table") {
|
|
1457
|
+
let i = t === "list";
|
|
1458
|
+
if (mt(r)) {
|
|
1459
|
+
let { data: t, ...a } = n;
|
|
1440
1460
|
return {
|
|
1441
1461
|
type: "object-data-table",
|
|
1442
|
-
...
|
|
1462
|
+
...a,
|
|
1443
1463
|
objectName: r.object,
|
|
1444
1464
|
dataProvider: r,
|
|
1445
1465
|
filter: r.filter || e.filter,
|
|
1446
|
-
searchable: !1,
|
|
1447
|
-
pagination: !1,
|
|
1466
|
+
searchable: i ? !1 : e.searchable ?? !1,
|
|
1467
|
+
pagination: i ? !1 : e.pagination ?? !1,
|
|
1448
1468
|
drillDown: n.drillDown ?? {
|
|
1449
1469
|
enabled: !0,
|
|
1450
1470
|
mode: "record"
|
|
@@ -1461,13 +1481,13 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1461
1481
|
className: "border-0"
|
|
1462
1482
|
};
|
|
1463
1483
|
}
|
|
1464
|
-
return
|
|
1484
|
+
return i.family === "pivot" ? cn : i.family === "custom" ? {
|
|
1465
1485
|
type: "text",
|
|
1466
1486
|
value: "Custom widget — set `component` to a UIComponent schema.",
|
|
1467
1487
|
variant: "caption",
|
|
1468
1488
|
align: "center",
|
|
1469
1489
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
|
|
1470
|
-
} :
|
|
1490
|
+
} : i.family === "unsupported" ? {
|
|
1471
1491
|
type: "text",
|
|
1472
1492
|
value: `「${t}」chart type is not supported yet`,
|
|
1473
1493
|
variant: "caption",
|
|
@@ -1477,38 +1497,38 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1477
1497
|
...e,
|
|
1478
1498
|
...n
|
|
1479
1499
|
};
|
|
1480
|
-
}, p =
|
|
1500
|
+
}, p = O.length > 0 ? c(e, O, te) : void 0, m = (() => {
|
|
1481
1501
|
let e = f();
|
|
1482
|
-
return p && e &&
|
|
1502
|
+
return p && e && sn.has(e.type) ? {
|
|
1483
1503
|
...e,
|
|
1484
|
-
filter:
|
|
1504
|
+
filter: _(e.filter, p)
|
|
1485
1505
|
} : e;
|
|
1486
1506
|
})(), h = p && d ? {
|
|
1487
1507
|
...e,
|
|
1488
|
-
filter:
|
|
1489
|
-
} : e,
|
|
1508
|
+
filter: _(e.filter, p)
|
|
1509
|
+
} : e, g = e.type === "metric" && !d, y = pe(e), b = me(e), S = e.id || y || `widget-${t}`, C = o && s === e.id, E = o ? {
|
|
1490
1510
|
"data-testid": `dashboard-preview-widget-${e.id}`,
|
|
1491
1511
|
"data-widget-id": e.id,
|
|
1492
1512
|
role: "button",
|
|
1493
1513
|
tabIndex: 0,
|
|
1494
|
-
"aria-selected":
|
|
1495
|
-
"aria-label": `Widget: ${
|
|
1496
|
-
onClick: (t) =>
|
|
1497
|
-
onKeyDown: (n) =>
|
|
1498
|
-
} : {},
|
|
1514
|
+
"aria-selected": C,
|
|
1515
|
+
"aria-label": `Widget: ${y || `Widget ${t + 1}`}`,
|
|
1516
|
+
onClick: (t) => he(t, e.id),
|
|
1517
|
+
onKeyDown: (n) => ge(n, e.id, t)
|
|
1518
|
+
} : {}, ee = o ? K("cursor-pointer rounded-lg transition-all outline-none", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", C ? "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, D = !T && u && !H ? {
|
|
1499
1519
|
gridColumn: `span ${u.w}`,
|
|
1500
1520
|
gridRow: `span ${u.h}`
|
|
1501
|
-
} : void 0,
|
|
1502
|
-
className: K("h-full w-full", o && "relative",
|
|
1503
|
-
style:
|
|
1504
|
-
...
|
|
1521
|
+
} : void 0, k = g ? /* @__PURE__ */ $("div", {
|
|
1522
|
+
className: K("h-full w-full", o && "relative", ee),
|
|
1523
|
+
style: D,
|
|
1524
|
+
...E,
|
|
1505
1525
|
children: [d ? /* @__PURE__ */ Q("div", {
|
|
1506
1526
|
className: K("h-full w-full", o && "pointer-events-none"),
|
|
1507
|
-
children: /* @__PURE__ */ Q(
|
|
1527
|
+
children: /* @__PURE__ */ Q(Gt, {
|
|
1508
1528
|
widget: h,
|
|
1509
1529
|
dataSource: n
|
|
1510
1530
|
})
|
|
1511
|
-
}) : /* @__PURE__ */ Q(
|
|
1531
|
+
}) : /* @__PURE__ */ Q(w, {
|
|
1512
1532
|
schema: m,
|
|
1513
1533
|
className: K("h-full w-full", o && "pointer-events-none"),
|
|
1514
1534
|
dataSource: n
|
|
@@ -1517,30 +1537,30 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1517
1537
|
"aria-hidden": "true",
|
|
1518
1538
|
"data-testid": "widget-click-overlay"
|
|
1519
1539
|
})]
|
|
1520
|
-
}) : /* @__PURE__ */ $(
|
|
1521
|
-
className: K("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full", o && "relative",
|
|
1522
|
-
style:
|
|
1523
|
-
...
|
|
1540
|
+
}) : /* @__PURE__ */ $(se, {
|
|
1541
|
+
className: K("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full", o && "relative", ee),
|
|
1542
|
+
style: D,
|
|
1543
|
+
...E,
|
|
1524
1544
|
children: [
|
|
1525
|
-
|
|
1545
|
+
y && /* @__PURE__ */ $(ce, {
|
|
1526
1546
|
className: "pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6",
|
|
1527
|
-
children: [/* @__PURE__ */ Q(
|
|
1547
|
+
children: [/* @__PURE__ */ Q(I, {
|
|
1528
1548
|
className: "text-sm sm:text-base font-medium tracking-tight truncate",
|
|
1529
|
-
title:
|
|
1530
|
-
children:
|
|
1549
|
+
title: y,
|
|
1550
|
+
children: y
|
|
1531
1551
|
}), b && /* @__PURE__ */ Q("p", {
|
|
1532
1552
|
className: "text-xs text-muted-foreground mt-0.5 line-clamp-2",
|
|
1533
1553
|
children: b
|
|
1534
1554
|
})]
|
|
1535
1555
|
}),
|
|
1536
|
-
/* @__PURE__ */ Q(
|
|
1556
|
+
/* @__PURE__ */ Q(F, {
|
|
1537
1557
|
className: "p-0",
|
|
1538
1558
|
children: /* @__PURE__ */ Q("div", {
|
|
1539
1559
|
className: K("h-full w-full", "p-3 sm:p-4 md:p-6", o && "pointer-events-none"),
|
|
1540
|
-
children: d ? /* @__PURE__ */ Q(
|
|
1560
|
+
children: d ? /* @__PURE__ */ Q(Gt, {
|
|
1541
1561
|
widget: h,
|
|
1542
1562
|
dataSource: n
|
|
1543
|
-
}) : /* @__PURE__ */ Q(
|
|
1563
|
+
}) : /* @__PURE__ */ Q(w, {
|
|
1544
1564
|
schema: m,
|
|
1545
1565
|
dataSource: n
|
|
1546
1566
|
})
|
|
@@ -1553,36 +1573,36 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1553
1573
|
})
|
|
1554
1574
|
]
|
|
1555
1575
|
});
|
|
1556
|
-
return
|
|
1576
|
+
return H && e.id ? /* @__PURE__ */ Q(en, {
|
|
1557
1577
|
id: e.id,
|
|
1558
|
-
gridSpan: !
|
|
1578
|
+
gridSpan: !T && u ? {
|
|
1559
1579
|
w: u.w,
|
|
1560
1580
|
h: u.h
|
|
1561
1581
|
} : void 0,
|
|
1562
|
-
children:
|
|
1563
|
-
}, S) : /* @__PURE__ */ Q(
|
|
1564
|
-
},
|
|
1582
|
+
children: k
|
|
1583
|
+
}, S) : /* @__PURE__ */ Q(Oe, { children: k }, S);
|
|
1584
|
+
}, W = e.title || e.label, ye = e.header && /* @__PURE__ */ $("div", {
|
|
1565
1585
|
className: "col-span-full mb-4",
|
|
1566
1586
|
children: [
|
|
1567
|
-
!p && e.header.showTitle !== !1 &&
|
|
1587
|
+
!p && e.header.showTitle !== !1 && W && /* @__PURE__ */ Q("h2", {
|
|
1568
1588
|
className: "text-lg font-semibold tracking-tight",
|
|
1569
|
-
children:
|
|
1570
|
-
name:
|
|
1571
|
-
label:
|
|
1572
|
-
}) :
|
|
1589
|
+
children: z ? ae({
|
|
1590
|
+
name: z,
|
|
1591
|
+
label: nn(W)
|
|
1592
|
+
}) : nn(W)
|
|
1573
1593
|
}),
|
|
1574
1594
|
!p && e.header.showDescription !== !1 && e.description && /* @__PURE__ */ Q("p", {
|
|
1575
1595
|
className: "text-sm text-muted-foreground mt-1",
|
|
1576
|
-
children:
|
|
1577
|
-
name:
|
|
1578
|
-
description:
|
|
1579
|
-
}) :
|
|
1596
|
+
children: z ? N({
|
|
1597
|
+
name: z,
|
|
1598
|
+
description: nn(e.description)
|
|
1599
|
+
}) : nn(e.description)
|
|
1580
1600
|
}),
|
|
1581
1601
|
e.header.actions && e.header.actions.length > 0 && /* @__PURE__ */ Q("div", {
|
|
1582
1602
|
className: "flex gap-2 mt-3",
|
|
1583
1603
|
children: e.header.actions.map((e, t) => {
|
|
1584
|
-
let n =
|
|
1585
|
-
return /* @__PURE__ */ $(
|
|
1604
|
+
let n = tn(e.icon);
|
|
1605
|
+
return /* @__PURE__ */ $(P, {
|
|
1586
1606
|
variant: "outline",
|
|
1587
1607
|
size: "sm",
|
|
1588
1608
|
onClick: async () => {
|
|
@@ -1595,129 +1615,125 @@ var nn = /* @__PURE__ */ new Set([
|
|
|
1595
1615
|
/^https?:\/\//.test(n) || n.startsWith("//") ? window.location.assign(n) : (window.history.pushState({}, "", n), window.dispatchEvent(new PopStateEvent("popstate")));
|
|
1596
1616
|
return;
|
|
1597
1617
|
}
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
e?.success || console.warn("[DashboardRenderer] action failed", e?.error);
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1603
|
-
console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`);
|
|
1618
|
+
let i = await ie(n || r);
|
|
1619
|
+
i?.success || console.warn("[DashboardRenderer] action failed", i?.error);
|
|
1604
1620
|
},
|
|
1605
|
-
children: [n && /* @__PURE__ */ Q(n, { className: "w-4 h-4 mr-1.5" }),
|
|
1621
|
+
children: [n && /* @__PURE__ */ Q(n, { className: "w-4 h-4 mr-1.5" }), fe(e)]
|
|
1606
1622
|
}, t);
|
|
1607
1623
|
})
|
|
1608
1624
|
})
|
|
1609
1625
|
]
|
|
1610
|
-
}),
|
|
1611
|
-
defs:
|
|
1612
|
-
values:
|
|
1613
|
-
onChange:
|
|
1614
|
-
onReset:
|
|
1626
|
+
}), be = O.length > 0 && /* @__PURE__ */ Q($t, {
|
|
1627
|
+
defs: O,
|
|
1628
|
+
values: te,
|
|
1629
|
+
onChange: k,
|
|
1630
|
+
onReset: A,
|
|
1615
1631
|
dataSource: n,
|
|
1616
1632
|
className: "mb-2"
|
|
1617
|
-
}),
|
|
1633
|
+
}), xe = i !== void 0 && /* @__PURE__ */ $("span", {
|
|
1618
1634
|
className: "text-xs text-muted-foreground",
|
|
1619
1635
|
children: [i.toLocaleString(), " records"]
|
|
1620
|
-
}),
|
|
1621
|
-
className: K("flex items-center justify-end gap-3 mb-2", !
|
|
1622
|
-
children: [
|
|
1636
|
+
}), Se = a ? JSON.stringify(a) : void 0, Ce = r && /* @__PURE__ */ $("div", {
|
|
1637
|
+
className: K("flex items-center justify-end gap-3 mb-2", !T && "col-span-full"),
|
|
1638
|
+
children: [xe, /* @__PURE__ */ $(P, {
|
|
1623
1639
|
variant: "outline",
|
|
1624
1640
|
size: "sm",
|
|
1625
|
-
onClick:
|
|
1641
|
+
onClick: B,
|
|
1626
1642
|
disabled: S,
|
|
1627
1643
|
"aria-label": "Refresh dashboard",
|
|
1628
|
-
children: [/* @__PURE__ */ Q(
|
|
1644
|
+
children: [/* @__PURE__ */ Q(We, { className: K("h-4 w-4 mr-2", S && "animate-spin") }), S ? "Refreshing…" : "Refresh All"]
|
|
1629
1645
|
})]
|
|
1630
|
-
}),
|
|
1631
|
-
if (
|
|
1646
|
+
}), we = X(() => (e.widgets ?? []).map((e) => e.id).filter((e) => !!e), [e.widgets]), G = X(() => (e.widgets ?? []).filter((e) => e.type === "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]), Te = X(() => (e.widgets ?? []).filter((e) => e.type !== "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]);
|
|
1647
|
+
if (T) {
|
|
1632
1648
|
let n = e.widgets?.filter((e) => e.type === "metric") || [], r = e.widgets?.filter((e) => e.type !== "metric") || [], i = /* @__PURE__ */ $("div", {
|
|
1633
1649
|
ref: h,
|
|
1634
1650
|
className: K("flex flex-col gap-4 px-4", t),
|
|
1635
|
-
"data-user-actions":
|
|
1636
|
-
onClick:
|
|
1651
|
+
"data-user-actions": Se,
|
|
1652
|
+
onClick: V,
|
|
1637
1653
|
...m,
|
|
1638
1654
|
children: [
|
|
1639
|
-
ve,
|
|
1640
1655
|
ye,
|
|
1641
|
-
|
|
1656
|
+
be,
|
|
1657
|
+
Ce,
|
|
1642
1658
|
n.length > 0 && /* @__PURE__ */ Q("div", {
|
|
1643
1659
|
className: "grid grid-cols-2 gap-3",
|
|
1644
|
-
onClick:
|
|
1645
|
-
children: /* @__PURE__ */ Q(
|
|
1646
|
-
items:
|
|
1647
|
-
strategy:
|
|
1648
|
-
disabled: !
|
|
1649
|
-
children: n.map((e, t) =>
|
|
1660
|
+
onClick: V,
|
|
1661
|
+
children: /* @__PURE__ */ Q(et, {
|
|
1662
|
+
items: G,
|
|
1663
|
+
strategy: nt,
|
|
1664
|
+
disabled: !H,
|
|
1665
|
+
children: n.map((e, t) => ve(e, t))
|
|
1650
1666
|
})
|
|
1651
1667
|
}),
|
|
1652
1668
|
r.length > 0 && /* @__PURE__ */ Q("div", {
|
|
1653
1669
|
className: "flex flex-col gap-4",
|
|
1654
|
-
onClick:
|
|
1655
|
-
children: /* @__PURE__ */ Q(
|
|
1656
|
-
items:
|
|
1657
|
-
strategy:
|
|
1658
|
-
disabled: !
|
|
1659
|
-
children: r.map((e, t) =>
|
|
1670
|
+
onClick: V,
|
|
1671
|
+
children: /* @__PURE__ */ Q(et, {
|
|
1672
|
+
items: Te,
|
|
1673
|
+
strategy: it,
|
|
1674
|
+
disabled: !H,
|
|
1675
|
+
children: r.map((e, t) => ve(e, t, !0))
|
|
1660
1676
|
})
|
|
1661
1677
|
})
|
|
1662
1678
|
]
|
|
1663
1679
|
});
|
|
1664
|
-
return
|
|
1665
|
-
sensors:
|
|
1666
|
-
collisionDetection:
|
|
1667
|
-
onDragEnd:
|
|
1680
|
+
return H ? /* @__PURE__ */ Q(Ye, {
|
|
1681
|
+
sensors: U,
|
|
1682
|
+
collisionDetection: Ze,
|
|
1683
|
+
onDragEnd: _e,
|
|
1668
1684
|
children: i
|
|
1669
1685
|
}) : i;
|
|
1670
1686
|
}
|
|
1671
|
-
let
|
|
1687
|
+
let Ee = /* @__PURE__ */ $("div", {
|
|
1672
1688
|
ref: h,
|
|
1673
1689
|
className: K("grid", !x && "auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", t),
|
|
1674
1690
|
style: {
|
|
1675
1691
|
...x && {
|
|
1676
|
-
gridTemplateColumns: `repeat(${
|
|
1692
|
+
gridTemplateColumns: `repeat(${v}, minmax(0, 1fr))`,
|
|
1677
1693
|
gridAutoRows: "minmax(5rem, auto)"
|
|
1678
1694
|
},
|
|
1679
1695
|
gap: `${b * .25}rem`
|
|
1680
1696
|
},
|
|
1681
|
-
"data-user-actions":
|
|
1682
|
-
onClick:
|
|
1697
|
+
"data-user-actions": Se,
|
|
1698
|
+
onClick: V,
|
|
1683
1699
|
...m,
|
|
1684
1700
|
children: [
|
|
1685
|
-
ve,
|
|
1686
1701
|
ye,
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1702
|
+
be,
|
|
1703
|
+
Ce,
|
|
1704
|
+
/* @__PURE__ */ Q(et, {
|
|
1705
|
+
items: we,
|
|
1706
|
+
strategy: nt,
|
|
1707
|
+
disabled: !H,
|
|
1708
|
+
children: e.widgets?.map((e, t) => ve(e, t))
|
|
1693
1709
|
})
|
|
1694
1710
|
]
|
|
1695
1711
|
});
|
|
1696
|
-
return
|
|
1697
|
-
sensors:
|
|
1698
|
-
collisionDetection:
|
|
1699
|
-
onDragEnd:
|
|
1700
|
-
children:
|
|
1701
|
-
}) :
|
|
1712
|
+
return H ? /* @__PURE__ */ Q(Ye, {
|
|
1713
|
+
sensors: U,
|
|
1714
|
+
collisionDetection: Ze,
|
|
1715
|
+
onDragEnd: _e,
|
|
1716
|
+
children: Ee
|
|
1717
|
+
}) : Ee;
|
|
1702
1718
|
});
|
|
1703
|
-
|
|
1704
|
-
var
|
|
1705
|
-
let { schema: n } = e, r = X(() =>
|
|
1706
|
-
return r.length === 0 ? /* @__PURE__ */ Q(
|
|
1719
|
+
ln.displayName = "DashboardRendererInner";
|
|
1720
|
+
var un = ke((e, t) => {
|
|
1721
|
+
let { schema: n } = e, r = X(() => y(n), [n.globalFilters, n.dateRange]);
|
|
1722
|
+
return r.length === 0 ? /* @__PURE__ */ Q(ln, {
|
|
1707
1723
|
ref: t,
|
|
1708
1724
|
...e
|
|
1709
|
-
}) : /* @__PURE__ */ Q(
|
|
1710
|
-
definitions:
|
|
1711
|
-
children: /* @__PURE__ */ Q(
|
|
1725
|
+
}) : /* @__PURE__ */ Q(C, {
|
|
1726
|
+
definitions: d(r),
|
|
1727
|
+
children: /* @__PURE__ */ Q(ln, {
|
|
1712
1728
|
ref: t,
|
|
1713
1729
|
...e
|
|
1714
1730
|
})
|
|
1715
1731
|
});
|
|
1716
1732
|
});
|
|
1717
|
-
|
|
1733
|
+
un.displayName = "DashboardRenderer";
|
|
1718
1734
|
//#endregion
|
|
1719
1735
|
//#region src/DashboardGridLayout.tsx
|
|
1720
|
-
function
|
|
1736
|
+
function dn({ editMode: e }) {
|
|
1721
1737
|
let t = D();
|
|
1722
1738
|
return q.useEffect(() => {
|
|
1723
1739
|
if (e) return t.startDrag({
|
|
@@ -1730,14 +1746,14 @@ function sn({ editMode: e }) {
|
|
|
1730
1746
|
t.endDrag("dashboard");
|
|
1731
1747
|
}, [e, t]), null;
|
|
1732
1748
|
}
|
|
1733
|
-
var
|
|
1749
|
+
var fn = [
|
|
1734
1750
|
"hsl(var(--chart-1))",
|
|
1735
1751
|
"hsl(var(--chart-2))",
|
|
1736
1752
|
"hsl(var(--chart-3))",
|
|
1737
1753
|
"hsl(var(--chart-4))",
|
|
1738
1754
|
"hsl(var(--chart-5))"
|
|
1739
1755
|
];
|
|
1740
|
-
function
|
|
1756
|
+
function pn(e, t) {
|
|
1741
1757
|
if (!e.widgets?.length) return e;
|
|
1742
1758
|
let n = new Map(t.map((e) => [e.i, e])), r = e.widgets.map((e, t) => {
|
|
1743
1759
|
let r = e.id || `widget-${t}`, i = n.get(r);
|
|
@@ -1756,7 +1772,7 @@ function ln(e, t) {
|
|
|
1756
1772
|
widgets: r
|
|
1757
1773
|
};
|
|
1758
1774
|
}
|
|
1759
|
-
function
|
|
1775
|
+
function mn(e) {
|
|
1760
1776
|
return { lg: e.widgets?.map((e, t) => ({
|
|
1761
1777
|
i: e.id || `widget-${t}`,
|
|
1762
1778
|
x: e.layout?.x ?? t % 4 * 3,
|
|
@@ -1765,8 +1781,8 @@ function un(e) {
|
|
|
1765
1781
|
h: e.layout?.h ?? 4
|
|
1766
1782
|
})) || [] };
|
|
1767
1783
|
}
|
|
1768
|
-
var
|
|
1769
|
-
let { width: a, containerRef: o, mounted: s } =
|
|
1784
|
+
var hn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRefresh: i }) => {
|
|
1785
|
+
let { width: a, containerRef: o, mounted: s } = pt(), [c, l] = q.useState(!1), [u, d] = q.useState(!1), f = k(), p = q.useRef(null), m = q.useCallback(() => {
|
|
1770
1786
|
i && (d(!0), i(), setTimeout(() => d(!1), 600));
|
|
1771
1787
|
}, [i]);
|
|
1772
1788
|
q.useEffect(() => {
|
|
@@ -1778,7 +1794,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1778
1794
|
i,
|
|
1779
1795
|
m
|
|
1780
1796
|
]);
|
|
1781
|
-
let [h, g] = q.useState(() =>
|
|
1797
|
+
let [h, g] = q.useState(() => mn(e)), _ = q.useMemo(() => JSON.stringify(e.widgets?.map((e, t) => ({
|
|
1782
1798
|
i: e.id || `widget-${t}`,
|
|
1783
1799
|
x: e.layout?.x,
|
|
1784
1800
|
y: e.layout?.y,
|
|
@@ -1786,55 +1802,81 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1786
1802
|
h: e.layout?.h
|
|
1787
1803
|
})) ?? []), [e.widgets]);
|
|
1788
1804
|
q.useEffect(() => {
|
|
1789
|
-
g(
|
|
1805
|
+
g(mn(e));
|
|
1790
1806
|
}, [_]);
|
|
1791
1807
|
let v = q.useCallback((e, t) => {
|
|
1792
1808
|
g(t), n?.(e);
|
|
1793
1809
|
}, [n]), y = q.useCallback(() => {
|
|
1794
|
-
r ? r(
|
|
1810
|
+
r ? r(pn(e, h.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);
|
|
1795
1811
|
}, [
|
|
1796
1812
|
r,
|
|
1797
1813
|
e,
|
|
1798
1814
|
h
|
|
1799
1815
|
]), b = q.useCallback(() => {
|
|
1800
|
-
g(
|
|
1816
|
+
g(mn(e));
|
|
1801
1817
|
}, [e]), x = q.useCallback((e) => {
|
|
1802
1818
|
if (e.component) return e.component;
|
|
1803
|
-
let t = e.type, n = e.options || {};
|
|
1804
|
-
if (
|
|
1805
|
-
let
|
|
1806
|
-
if (
|
|
1807
|
-
let e =
|
|
1819
|
+
let t = e.type, n = e.options || {}, r = xt(t);
|
|
1820
|
+
if (r.family === "series" && r.chartType) {
|
|
1821
|
+
let t = e.data || n.data, i = n.xField || "name", a = n.yField || "value";
|
|
1822
|
+
if (mt(t)) {
|
|
1823
|
+
let e = t.aggregate, n = e ? {
|
|
1808
1824
|
field: e.field,
|
|
1809
1825
|
function: e.function,
|
|
1810
1826
|
groupBy: e.groupBy
|
|
1811
1827
|
} : void 0, o = n?.field || a;
|
|
1812
1828
|
return {
|
|
1813
1829
|
type: "object-chart",
|
|
1814
|
-
chartType:
|
|
1815
|
-
objectName:
|
|
1830
|
+
chartType: r.chartType,
|
|
1831
|
+
objectName: t.object,
|
|
1816
1832
|
aggregate: n,
|
|
1817
1833
|
xAxisKey: i,
|
|
1818
1834
|
series: [{ dataKey: o }],
|
|
1819
|
-
colors:
|
|
1835
|
+
colors: fn,
|
|
1820
1836
|
isAnimationActive: !1,
|
|
1821
1837
|
className: "h-full"
|
|
1822
1838
|
};
|
|
1823
1839
|
}
|
|
1840
|
+
let o = Array.isArray(t) ? t : t?.items || [];
|
|
1824
1841
|
return {
|
|
1825
1842
|
type: "chart",
|
|
1826
|
-
chartType:
|
|
1827
|
-
data:
|
|
1843
|
+
chartType: r.chartType,
|
|
1844
|
+
data: o,
|
|
1828
1845
|
xAxisKey: i,
|
|
1829
1846
|
series: [{ dataKey: a }],
|
|
1830
|
-
colors:
|
|
1847
|
+
colors: fn,
|
|
1831
1848
|
isAnimationActive: !1,
|
|
1832
1849
|
className: "h-full"
|
|
1833
1850
|
};
|
|
1834
1851
|
}
|
|
1835
|
-
if (
|
|
1852
|
+
if (r.family === "metric") {
|
|
1853
|
+
let r = e.data || n.data, i = e.title || t;
|
|
1854
|
+
if (mt(r)) {
|
|
1855
|
+
let t = r.aggregate;
|
|
1856
|
+
return {
|
|
1857
|
+
type: "object-metric",
|
|
1858
|
+
...n,
|
|
1859
|
+
objectName: r.object,
|
|
1860
|
+
label: i,
|
|
1861
|
+
aggregate: t ? {
|
|
1862
|
+
field: t.field,
|
|
1863
|
+
function: t.function,
|
|
1864
|
+
groupBy: t.groupBy
|
|
1865
|
+
} : void 0,
|
|
1866
|
+
filter: r.filter || e.filter
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
let a = Array.isArray(r) ? r : r?.items || [], o = n.yField || "value";
|
|
1870
|
+
return {
|
|
1871
|
+
type: "metric",
|
|
1872
|
+
...n,
|
|
1873
|
+
label: i,
|
|
1874
|
+
value: n.value ?? a[0]?.[o] ?? "—"
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
if (r.family === "table") {
|
|
1836
1878
|
let t = e.data || n.data;
|
|
1837
|
-
if (
|
|
1879
|
+
if (mt(t)) {
|
|
1838
1880
|
let { data: e, ...r } = n;
|
|
1839
1881
|
return {
|
|
1840
1882
|
type: "data-table",
|
|
@@ -1856,9 +1898,9 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1856
1898
|
className: "border-0"
|
|
1857
1899
|
};
|
|
1858
1900
|
}
|
|
1859
|
-
if (
|
|
1901
|
+
if (r.family === "pivot") {
|
|
1860
1902
|
let t = e.data || n.data;
|
|
1861
|
-
if (
|
|
1903
|
+
if (mt(t)) {
|
|
1862
1904
|
let { data: e, ...r } = n;
|
|
1863
1905
|
return {
|
|
1864
1906
|
type: "pivot",
|
|
@@ -1874,7 +1916,13 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1874
1916
|
data: Array.isArray(t) ? t : t?.items || []
|
|
1875
1917
|
};
|
|
1876
1918
|
}
|
|
1877
|
-
return {
|
|
1919
|
+
return r.family === "unsupported" ? {
|
|
1920
|
+
type: "text",
|
|
1921
|
+
value: `「${t}」chart type is not supported yet`,
|
|
1922
|
+
variant: "caption",
|
|
1923
|
+
align: "center",
|
|
1924
|
+
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground"
|
|
1925
|
+
} : {
|
|
1878
1926
|
...e,
|
|
1879
1927
|
...n
|
|
1880
1928
|
};
|
|
@@ -1884,7 +1932,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1884
1932
|
className: K("w-full", t),
|
|
1885
1933
|
"data-testid": "grid-layout",
|
|
1886
1934
|
children: [
|
|
1887
|
-
f && /* @__PURE__ */ Q(
|
|
1935
|
+
f && /* @__PURE__ */ Q(dn, { editMode: c }),
|
|
1888
1936
|
/* @__PURE__ */ $("div", {
|
|
1889
1937
|
className: "mb-4 flex items-center justify-between",
|
|
1890
1938
|
children: [/* @__PURE__ */ Q("h2", {
|
|
@@ -1892,41 +1940,41 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1892
1940
|
children: e.title || e.label || "Dashboard"
|
|
1893
1941
|
}), /* @__PURE__ */ Q("div", {
|
|
1894
1942
|
className: "flex gap-2",
|
|
1895
|
-
children: c ? /* @__PURE__ */ $(
|
|
1896
|
-
/* @__PURE__ */ $(
|
|
1943
|
+
children: c ? /* @__PURE__ */ $(dt, { children: [
|
|
1944
|
+
/* @__PURE__ */ $(P, {
|
|
1897
1945
|
onClick: y,
|
|
1898
1946
|
size: "sm",
|
|
1899
1947
|
variant: "default",
|
|
1900
|
-
children: [/* @__PURE__ */ Q(
|
|
1948
|
+
children: [/* @__PURE__ */ Q(Ke, { className: "h-4 w-4 mr-2" }), "Save Layout"]
|
|
1901
1949
|
}),
|
|
1902
|
-
/* @__PURE__ */ $(
|
|
1950
|
+
/* @__PURE__ */ $(P, {
|
|
1903
1951
|
onClick: b,
|
|
1904
1952
|
size: "sm",
|
|
1905
1953
|
variant: "outline",
|
|
1906
|
-
children: [/* @__PURE__ */ Q(
|
|
1954
|
+
children: [/* @__PURE__ */ Q(Je, { className: "h-4 w-4 mr-2" }), "Reset"]
|
|
1907
1955
|
}),
|
|
1908
|
-
/* @__PURE__ */ Q(
|
|
1956
|
+
/* @__PURE__ */ Q(P, {
|
|
1909
1957
|
onClick: () => l(!1),
|
|
1910
1958
|
size: "sm",
|
|
1911
1959
|
variant: "ghost",
|
|
1912
1960
|
children: "Cancel"
|
|
1913
1961
|
})
|
|
1914
|
-
] }) : /* @__PURE__ */ $(
|
|
1962
|
+
] }) : /* @__PURE__ */ $(dt, { children: [i && /* @__PURE__ */ $(P, {
|
|
1915
1963
|
onClick: m,
|
|
1916
1964
|
size: "sm",
|
|
1917
1965
|
variant: "outline",
|
|
1918
1966
|
disabled: u,
|
|
1919
1967
|
"aria-label": "Refresh dashboard",
|
|
1920
|
-
children: [/* @__PURE__ */ Q(
|
|
1921
|
-
}), /* @__PURE__ */ $(
|
|
1968
|
+
children: [/* @__PURE__ */ Q(We, { className: K("h-4 w-4 mr-2", u && "animate-spin") }), u ? "Refreshing…" : "Refresh All"]
|
|
1969
|
+
}), /* @__PURE__ */ $(P, {
|
|
1922
1970
|
onClick: () => l(!0),
|
|
1923
1971
|
size: "sm",
|
|
1924
1972
|
variant: "outline",
|
|
1925
|
-
children: [/* @__PURE__ */ Q(
|
|
1973
|
+
children: [/* @__PURE__ */ Q(Be, { className: "h-4 w-4 mr-2" }), "Edit Layout"]
|
|
1926
1974
|
})] })
|
|
1927
1975
|
})]
|
|
1928
1976
|
}),
|
|
1929
|
-
s && /* @__PURE__ */ Q(
|
|
1977
|
+
s && /* @__PURE__ */ Q(ft, {
|
|
1930
1978
|
className: "layout",
|
|
1931
1979
|
width: a,
|
|
1932
1980
|
layouts: h,
|
|
@@ -1959,28 +2007,28 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1959
2007
|
className: "h-full w-full relative",
|
|
1960
2008
|
children: [c && /* @__PURE__ */ Q("div", {
|
|
1961
2009
|
className: "drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border",
|
|
1962
|
-
children: /* @__PURE__ */ Q(
|
|
1963
|
-
}), /* @__PURE__ */ Q(
|
|
2010
|
+
children: /* @__PURE__ */ Q(Ve, { className: "h-4 w-4" })
|
|
2011
|
+
}), /* @__PURE__ */ Q(w, {
|
|
1964
2012
|
schema: r,
|
|
1965
2013
|
className: "h-full w-full"
|
|
1966
2014
|
})]
|
|
1967
|
-
}) : /* @__PURE__ */ $(
|
|
2015
|
+
}) : /* @__PURE__ */ $(se, {
|
|
1968
2016
|
className: K("h-full overflow-hidden border-border/50 shadow-sm transition-all", "bg-card/50 backdrop-blur-sm", c && "ring-2 ring-primary/20"),
|
|
1969
|
-
children: [e.title && /* @__PURE__ */ $(
|
|
2017
|
+
children: [e.title && /* @__PURE__ */ $(ce, {
|
|
1970
2018
|
className: "pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between",
|
|
1971
|
-
children: [/* @__PURE__ */ Q(
|
|
2019
|
+
children: [/* @__PURE__ */ Q(I, {
|
|
1972
2020
|
className: "text-base font-medium tracking-tight truncate",
|
|
1973
2021
|
title: e.title,
|
|
1974
2022
|
children: e.title
|
|
1975
2023
|
}), c && /* @__PURE__ */ Q("div", {
|
|
1976
2024
|
className: "drag-handle cursor-move p-1 hover:bg-muted/40 rounded",
|
|
1977
|
-
children: /* @__PURE__ */ Q(
|
|
2025
|
+
children: /* @__PURE__ */ Q(Ve, { className: "h-4 w-4" })
|
|
1978
2026
|
})]
|
|
1979
|
-
}), /* @__PURE__ */ Q(
|
|
2027
|
+
}), /* @__PURE__ */ Q(F, {
|
|
1980
2028
|
className: "p-0 h-full",
|
|
1981
2029
|
children: /* @__PURE__ */ Q("div", {
|
|
1982
2030
|
className: K("h-full w-full overflow-auto p-4"),
|
|
1983
|
-
children: /* @__PURE__ */ Q(
|
|
2031
|
+
children: /* @__PURE__ */ Q(w, { schema: r })
|
|
1984
2032
|
})
|
|
1985
2033
|
})]
|
|
1986
2034
|
})
|
|
@@ -1989,7 +2037,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1989
2037
|
})
|
|
1990
2038
|
]
|
|
1991
2039
|
});
|
|
1992
|
-
},
|
|
2040
|
+
}, gn = A({
|
|
1993
2041
|
"dashboard.trend.vsLastQuarter": "vs last quarter",
|
|
1994
2042
|
"dashboard.trend.vsLastMonth": "vs last month",
|
|
1995
2043
|
"dashboard.trend.vsLastWeek": "vs last week",
|
|
@@ -1997,7 +2045,7 @@ var dn = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1997
2045
|
"dashboard.trend.vsYesterday": "vs yesterday",
|
|
1998
2046
|
"dashboard.trend.vsPreviousPeriod": "vs previous period"
|
|
1999
2047
|
}, "dashboard.trend.vsLastQuarter");
|
|
2000
|
-
function
|
|
2048
|
+
function _n(e) {
|
|
2001
2049
|
switch (e.trim().toLowerCase().replace(/\s+/g, " ")) {
|
|
2002
2050
|
case "vs last quarter":
|
|
2003
2051
|
case "vs previous quarter": return "dashboard.trend.vsLastQuarter";
|
|
@@ -2013,11 +2061,11 @@ function pn(e) {
|
|
|
2013
2061
|
default: return;
|
|
2014
2062
|
}
|
|
2015
2063
|
}
|
|
2016
|
-
function
|
|
2064
|
+
function vn(e, t, n) {
|
|
2017
2065
|
if (e == null) return "";
|
|
2018
2066
|
if (typeof e == "string") {
|
|
2019
2067
|
let r = Number(e);
|
|
2020
|
-
return !isFinite(r) || e.trim() === "" ? e :
|
|
2068
|
+
return !isFinite(r) || e.trim() === "" ? e : vn(r, t, n);
|
|
2021
2069
|
}
|
|
2022
2070
|
if (!isFinite(e)) return String(e);
|
|
2023
2071
|
let r = {
|
|
@@ -2054,10 +2102,10 @@ function mn(e, t, n) {
|
|
|
2054
2102
|
maximumFractionDigits: c
|
|
2055
2103
|
}).format(e);
|
|
2056
2104
|
}
|
|
2057
|
-
function
|
|
2105
|
+
function yn(e) {
|
|
2058
2106
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
2059
2107
|
}
|
|
2060
|
-
var
|
|
2108
|
+
var bn = {
|
|
2061
2109
|
default: "bg-muted text-muted-foreground",
|
|
2062
2110
|
blue: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
2063
2111
|
teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
|
|
@@ -2066,7 +2114,7 @@ var gn = {
|
|
|
2066
2114
|
success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
|
|
2067
2115
|
warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
|
|
2068
2116
|
danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
|
|
2069
|
-
},
|
|
2117
|
+
}, xn = {
|
|
2070
2118
|
default: "text-foreground",
|
|
2071
2119
|
blue: "text-blue-600 dark:text-blue-400",
|
|
2072
2120
|
teal: "text-teal-600 dark:text-teal-400",
|
|
@@ -2075,18 +2123,18 @@ var gn = {
|
|
|
2075
2123
|
success: "text-emerald-600 dark:text-emerald-400",
|
|
2076
2124
|
warning: "text-amber-600 dark:text-amber-400",
|
|
2077
2125
|
danger: "text-rose-600 dark:text-rose-400"
|
|
2078
|
-
},
|
|
2079
|
-
let g =
|
|
2080
|
-
let e =
|
|
2126
|
+
}, Sn = ({ 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 }) => {
|
|
2127
|
+
let g = bn[c] || bn.default, { t: _ } = gn(), v = X(() => {
|
|
2128
|
+
let e = yn(a) || yn(n?.label);
|
|
2081
2129
|
if (!e) return e;
|
|
2082
|
-
let t =
|
|
2130
|
+
let t = _n(e);
|
|
2083
2131
|
return t ? _(t) : e;
|
|
2084
2132
|
}, [
|
|
2085
2133
|
a,
|
|
2086
2134
|
n?.label,
|
|
2087
2135
|
_
|
|
2088
2136
|
]), y = X(() => {
|
|
2089
|
-
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ?
|
|
2137
|
+
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ? vn(t, l, u) : t ?? "", n = String(e);
|
|
2090
2138
|
return `${d && n.startsWith(d) ? "" : d ?? ""}${n}${f && n.endsWith(f) ? "" : f ?? ""}`;
|
|
2091
2139
|
}, [
|
|
2092
2140
|
t,
|
|
@@ -2096,13 +2144,13 @@ var gn = {
|
|
|
2096
2144
|
f
|
|
2097
2145
|
]), b = X(() => {
|
|
2098
2146
|
if (typeof r == "string") {
|
|
2099
|
-
let e =
|
|
2147
|
+
let e = Te(r);
|
|
2100
2148
|
return e ? /* @__PURE__ */ Q(e, { className: "h-4 w-4" }) : null;
|
|
2101
2149
|
}
|
|
2102
2150
|
return r;
|
|
2103
2151
|
}, [r]);
|
|
2104
2152
|
if (m === "bare") {
|
|
2105
|
-
let t =
|
|
2153
|
+
let t = xn[c] || xn.default;
|
|
2106
2154
|
return /* @__PURE__ */ Q("div", {
|
|
2107
2155
|
className: K("flex flex-col gap-1 min-w-0", p && "cursor-pointer", i),
|
|
2108
2156
|
onClick: p,
|
|
@@ -2114,7 +2162,7 @@ var gn = {
|
|
|
2114
2162
|
children: o ? /* @__PURE__ */ $("div", {
|
|
2115
2163
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
2116
2164
|
"data-testid": "metric-loading",
|
|
2117
|
-
children: [/* @__PURE__ */ Q(
|
|
2165
|
+
children: [/* @__PURE__ */ Q(He, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
|
|
2118
2166
|
className: "text-sm",
|
|
2119
2167
|
children: "Loading…"
|
|
2120
2168
|
})]
|
|
@@ -2122,20 +2170,20 @@ var gn = {
|
|
|
2122
2170
|
className: "flex items-center gap-2",
|
|
2123
2171
|
"data-testid": "metric-error",
|
|
2124
2172
|
role: "alert",
|
|
2125
|
-
children: [/* @__PURE__ */ Q(
|
|
2173
|
+
children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
2126
2174
|
className: "text-xs text-destructive truncate",
|
|
2127
2175
|
children: s
|
|
2128
2176
|
})]
|
|
2129
|
-
}) : /* @__PURE__ */ $(
|
|
2177
|
+
}) : /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q("div", {
|
|
2130
2178
|
className: K("text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate", t),
|
|
2131
2179
|
children: y
|
|
2132
2180
|
}), /* @__PURE__ */ Q("div", {
|
|
2133
2181
|
className: "text-xs font-medium text-muted-foreground truncate",
|
|
2134
|
-
children:
|
|
2182
|
+
children: yn(e)
|
|
2135
2183
|
})] })
|
|
2136
2184
|
});
|
|
2137
2185
|
}
|
|
2138
|
-
return /* @__PURE__ */ $(
|
|
2186
|
+
return /* @__PURE__ */ $(se, {
|
|
2139
2187
|
className: K("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),
|
|
2140
2188
|
onClick: p,
|
|
2141
2189
|
role: p ? "button" : void 0,
|
|
@@ -2144,19 +2192,19 @@ var gn = {
|
|
|
2144
2192
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
|
|
2145
2193
|
} : void 0,
|
|
2146
2194
|
...h,
|
|
2147
|
-
children: [/* @__PURE__ */ $(
|
|
2195
|
+
children: [/* @__PURE__ */ $(ce, {
|
|
2148
2196
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
2149
|
-
children: [/* @__PURE__ */ Q(
|
|
2197
|
+
children: [/* @__PURE__ */ Q(I, {
|
|
2150
2198
|
className: "text-sm font-medium truncate",
|
|
2151
|
-
children:
|
|
2199
|
+
children: yn(e)
|
|
2152
2200
|
}), b && /* @__PURE__ */ Q("div", {
|
|
2153
2201
|
className: K("flex h-8 w-8 items-center justify-center rounded-md shrink-0", g),
|
|
2154
2202
|
children: b
|
|
2155
2203
|
})]
|
|
2156
|
-
}), /* @__PURE__ */ Q(
|
|
2204
|
+
}), /* @__PURE__ */ Q(F, { children: o ? /* @__PURE__ */ $("div", {
|
|
2157
2205
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
2158
2206
|
"data-testid": "metric-loading",
|
|
2159
|
-
children: [/* @__PURE__ */ Q(
|
|
2207
|
+
children: [/* @__PURE__ */ Q(He, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
|
|
2160
2208
|
className: "text-sm",
|
|
2161
2209
|
children: "Loading…"
|
|
2162
2210
|
})]
|
|
@@ -2164,11 +2212,11 @@ var gn = {
|
|
|
2164
2212
|
className: "flex items-center gap-2",
|
|
2165
2213
|
"data-testid": "metric-error",
|
|
2166
2214
|
role: "alert",
|
|
2167
|
-
children: [/* @__PURE__ */ Q(
|
|
2215
|
+
children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
2168
2216
|
className: "text-xs text-destructive truncate",
|
|
2169
2217
|
children: s
|
|
2170
2218
|
})]
|
|
2171
|
-
}) : /* @__PURE__ */ $(
|
|
2219
|
+
}) : /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q("div", {
|
|
2172
2220
|
className: "text-2xl font-bold tabular-nums tracking-tight truncate",
|
|
2173
2221
|
children: y
|
|
2174
2222
|
}), (n || a) && /* @__PURE__ */ $("div", {
|
|
@@ -2176,9 +2224,9 @@ var gn = {
|
|
|
2176
2224
|
children: [n && /* @__PURE__ */ $("span", {
|
|
2177
2225
|
className: K("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"),
|
|
2178
2226
|
children: [
|
|
2179
|
-
n.direction === "up" && /* @__PURE__ */ Q(
|
|
2180
|
-
n.direction === "down" && /* @__PURE__ */ Q(
|
|
2181
|
-
n.direction === "neutral" && /* @__PURE__ */ Q(
|
|
2227
|
+
n.direction === "up" && /* @__PURE__ */ Q(Fe, { className: "h-3 w-3 mr-1" }),
|
|
2228
|
+
n.direction === "down" && /* @__PURE__ */ Q(Pe, { className: "h-3 w-3 mr-1" }),
|
|
2229
|
+
n.direction === "neutral" && /* @__PURE__ */ Q(Ue, { className: "h-3 w-3 mr-1" }),
|
|
2182
2230
|
n.value,
|
|
2183
2231
|
"%"
|
|
2184
2232
|
]
|
|
@@ -2191,24 +2239,24 @@ var gn = {
|
|
|
2191
2239
|
};
|
|
2192
2240
|
//#endregion
|
|
2193
2241
|
//#region src/MetricCard.tsx
|
|
2194
|
-
function
|
|
2242
|
+
function Cn(e) {
|
|
2195
2243
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
2196
2244
|
}
|
|
2197
|
-
var
|
|
2198
|
-
let u = n ?
|
|
2199
|
-
return /* @__PURE__ */ $(
|
|
2245
|
+
var wn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
|
|
2246
|
+
let u = n ? Te(n) : null;
|
|
2247
|
+
return /* @__PURE__ */ $(se, {
|
|
2200
2248
|
className: K("h-full", o),
|
|
2201
2249
|
...l,
|
|
2202
|
-
children: [/* @__PURE__ */ $(
|
|
2250
|
+
children: [/* @__PURE__ */ $(ce, {
|
|
2203
2251
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
2204
|
-
children: [/* @__PURE__ */ Q(
|
|
2252
|
+
children: [/* @__PURE__ */ Q(I, {
|
|
2205
2253
|
className: "text-sm font-medium",
|
|
2206
|
-
children:
|
|
2254
|
+
children: Cn(e)
|
|
2207
2255
|
}), u && /* @__PURE__ */ Q(u, { className: "h-4 w-4 text-muted-foreground" })]
|
|
2208
|
-
}), /* @__PURE__ */ Q(
|
|
2256
|
+
}), /* @__PURE__ */ Q(F, { children: s ? /* @__PURE__ */ $("div", {
|
|
2209
2257
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
2210
2258
|
"data-testid": "metric-card-loading",
|
|
2211
|
-
children: [/* @__PURE__ */ Q(
|
|
2259
|
+
children: [/* @__PURE__ */ Q(He, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
|
|
2212
2260
|
className: "text-sm",
|
|
2213
2261
|
children: "Loading…"
|
|
2214
2262
|
})]
|
|
@@ -2216,11 +2264,11 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2216
2264
|
className: "flex items-center gap-2",
|
|
2217
2265
|
"data-testid": "metric-card-error",
|
|
2218
2266
|
role: "alert",
|
|
2219
|
-
children: [/* @__PURE__ */ Q(
|
|
2267
|
+
children: [/* @__PURE__ */ Q(Me, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
2220
2268
|
className: "text-xs text-destructive truncate",
|
|
2221
2269
|
children: c
|
|
2222
2270
|
})]
|
|
2223
|
-
}) : /* @__PURE__ */ $(
|
|
2271
|
+
}) : /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q("div", {
|
|
2224
2272
|
className: "text-2xl font-bold",
|
|
2225
2273
|
children: t
|
|
2226
2274
|
}), (r || i || a) && /* @__PURE__ */ $("p", {
|
|
@@ -2228,47 +2276,47 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2228
2276
|
children: [r && i && /* @__PURE__ */ $("span", {
|
|
2229
2277
|
className: K("flex items-center mr-2", r === "up" && "text-green-500", r === "down" && "text-red-500", r === "neutral" && "text-yellow-500"),
|
|
2230
2278
|
children: [
|
|
2231
|
-
r === "up" && /* @__PURE__ */ Q(
|
|
2232
|
-
r === "down" && /* @__PURE__ */ Q(
|
|
2233
|
-
r === "neutral" && /* @__PURE__ */ Q(
|
|
2279
|
+
r === "up" && /* @__PURE__ */ Q(Fe, { className: "h-3 w-3 mr-1" }),
|
|
2280
|
+
r === "down" && /* @__PURE__ */ Q(Pe, { className: "h-3 w-3 mr-1" }),
|
|
2281
|
+
r === "neutral" && /* @__PURE__ */ Q(Ue, { className: "h-3 w-3 mr-1" }),
|
|
2234
2282
|
i
|
|
2235
2283
|
]
|
|
2236
|
-
}),
|
|
2284
|
+
}), Cn(a)]
|
|
2237
2285
|
})] }) })]
|
|
2238
2286
|
});
|
|
2239
|
-
},
|
|
2240
|
-
let
|
|
2287
|
+
}, Tn = ({ objectName: e, aggregate: t, filter: n, label: r, fallbackValue: i, trend: a, icon: o, className: s, description: c, dataSource: u, colorVariant: d, format: f, currency: p, prefix: m, suffix: h, invert: _, drillDown: v, title: y, compareTo: C, t: E, variant: ee }) => {
|
|
2288
|
+
let D = Ae(T), O = u || D?.dataSource, [k, ne] = Z(!1), [re, A] = Z(null), [M, ae] = Z(null), [N, P] = Z(!1), [oe, se] = Z(null), [F, ce] = Z(null);
|
|
2241
2289
|
Y(() => {
|
|
2242
2290
|
let t = !0;
|
|
2243
|
-
if (!(!
|
|
2244
|
-
t &&
|
|
2291
|
+
if (!(!O || !e || typeof O.getObjectSchema != "function")) return O.getObjectSchema(e).then((e) => {
|
|
2292
|
+
t && ce(e);
|
|
2245
2293
|
}).catch(() => {}), () => {
|
|
2246
2294
|
t = !1;
|
|
2247
2295
|
};
|
|
2248
|
-
}, [
|
|
2249
|
-
let
|
|
2296
|
+
}, [O, e]);
|
|
2297
|
+
let I = X(() => {
|
|
2250
2298
|
let e = t?.field;
|
|
2251
|
-
if (!e || !
|
|
2252
|
-
let n =
|
|
2299
|
+
if (!e || !F?.fields) return null;
|
|
2300
|
+
let n = F.fields;
|
|
2253
2301
|
return Array.isArray(n) ? n.find((t) => t?.name === e) || null : n[e] || null;
|
|
2254
|
-
}, [
|
|
2302
|
+
}, [F, t?.field]), le = X(() => {
|
|
2255
2303
|
if (f) return f;
|
|
2256
|
-
if (
|
|
2257
|
-
if (
|
|
2258
|
-
let e =
|
|
2304
|
+
if (I) {
|
|
2305
|
+
if (I.type === "currency") {
|
|
2306
|
+
let e = I.scale ?? 0;
|
|
2259
2307
|
return e > 0 ? `0,0.${"0".repeat(e)}` : "0,0";
|
|
2260
2308
|
}
|
|
2261
|
-
if (
|
|
2262
|
-
if (
|
|
2309
|
+
if (I.type === "percent") return "0,0%";
|
|
2310
|
+
if (I.type === "number" || I.type === "integer") return "0,0";
|
|
2263
2311
|
}
|
|
2264
|
-
}, [f,
|
|
2312
|
+
}, [f, I]), { currency: ue } = j(), de = X(() => {
|
|
2265
2313
|
if (p) return p;
|
|
2266
|
-
if (
|
|
2314
|
+
if (I?.type === "currency") return ie(I, ue);
|
|
2267
2315
|
}, [
|
|
2268
2316
|
p,
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
]),
|
|
2317
|
+
I,
|
|
2318
|
+
ue
|
|
2319
|
+
]), L = X(() => t ? JSON.stringify(t) : "", [t]), R = te(), B = X(() => x(n, R), [n, R]), he = X(() => B ? JSON.stringify(B) : "", [B]), ge = X(() => C ? JSON.stringify(C) : "", [C]), V = J(async (n, r) => {
|
|
2272
2320
|
if (t && typeof n.aggregate == "function") {
|
|
2273
2321
|
let i = await n.aggregate(e, {
|
|
2274
2322
|
field: t.field,
|
|
@@ -2289,43 +2337,43 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2289
2337
|
return (Array.isArray(t) ? t : t?.data || t?.records || []).length;
|
|
2290
2338
|
}
|
|
2291
2339
|
return null;
|
|
2292
|
-
}, [e,
|
|
2340
|
+
}, [e, L]), H = J(async (t, r) => {
|
|
2293
2341
|
if (!(!t || !e)) {
|
|
2294
|
-
r.current && (
|
|
2342
|
+
r.current && (P(!0), se(null));
|
|
2295
2343
|
try {
|
|
2296
|
-
let e =
|
|
2344
|
+
let e = C ? S(n, C) : null, [i, a] = await Promise.all([V(t, B), e ? V(t, e) : Promise.resolve(null)]);
|
|
2297
2345
|
if (i === null) return;
|
|
2298
|
-
r.current && (
|
|
2346
|
+
r.current && (A(i), ae(typeof a == "number" && Number.isFinite(a) ? a : null));
|
|
2299
2347
|
} catch (e) {
|
|
2300
|
-
console.error("[ObjectMetricWidget] Fetch error:", e), r.current &&
|
|
2348
|
+
console.error("[ObjectMetricWidget] Fetch error:", e), r.current && se(e instanceof Error ? e.message : "Failed to load metric");
|
|
2301
2349
|
} finally {
|
|
2302
|
-
r.current &&
|
|
2350
|
+
r.current && P(!1);
|
|
2303
2351
|
}
|
|
2304
2352
|
}
|
|
2305
2353
|
}, [
|
|
2306
2354
|
e,
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2355
|
+
L,
|
|
2356
|
+
he,
|
|
2357
|
+
ge,
|
|
2358
|
+
V
|
|
2311
2359
|
]);
|
|
2312
2360
|
Y(() => {
|
|
2313
2361
|
let t = { current: !0 };
|
|
2314
|
-
return
|
|
2362
|
+
return O && e ? H(O, t) : (A(null), se(null)), () => {
|
|
2315
2363
|
t.current = !1;
|
|
2316
2364
|
};
|
|
2317
2365
|
}, [
|
|
2318
|
-
|
|
2366
|
+
O,
|
|
2319
2367
|
e,
|
|
2320
|
-
|
|
2368
|
+
H
|
|
2321
2369
|
]);
|
|
2322
|
-
let
|
|
2323
|
-
_ && typeof
|
|
2324
|
-
let
|
|
2325
|
-
if (!
|
|
2326
|
-
let e =
|
|
2370
|
+
let U = re === null ? O ? "—" : i ?? "—" : re;
|
|
2371
|
+
_ && typeof U == "number" && isFinite(U) && U >= 0 && U <= 1 && (U = 1 - U);
|
|
2372
|
+
let _e = X(() => {
|
|
2373
|
+
if (!C || typeof re != "number" || !Number.isFinite(re) || M === null) return;
|
|
2374
|
+
let e = ht(re, M);
|
|
2327
2375
|
if (!e) return;
|
|
2328
|
-
let t =
|
|
2376
|
+
let t = l(C, n), r = `dashboard.trend.${t}`, i = {
|
|
2329
2377
|
vsPreviousPeriod: "vs previous period",
|
|
2330
2378
|
vsLastWeek: "vs last week",
|
|
2331
2379
|
vsLastMonth: "vs last month",
|
|
@@ -2339,30 +2387,30 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2339
2387
|
label: a
|
|
2340
2388
|
};
|
|
2341
2389
|
}, [
|
|
2342
|
-
|
|
2390
|
+
C,
|
|
2391
|
+
re,
|
|
2343
2392
|
M,
|
|
2344
|
-
ne,
|
|
2345
2393
|
n,
|
|
2346
2394
|
E
|
|
2347
|
-
]) ?? a,
|
|
2395
|
+
]) ?? a, ve = g(v) && !!e && !!O, W = X(() => {
|
|
2348
2396
|
let e = typeof r == "string" ? r : r?.defaultValue || "";
|
|
2349
|
-
return b(v, {}, (typeof
|
|
2397
|
+
return b(v, {}, (typeof y == "string" ? y : y?.defaultValue || "") || e || "Details");
|
|
2350
2398
|
}, [
|
|
2351
2399
|
v,
|
|
2352
2400
|
r,
|
|
2353
|
-
|
|
2354
|
-
]),
|
|
2355
|
-
if (!
|
|
2356
|
-
let t = v?.target ?? "drawer", n = v?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i = r ? null : /* @__PURE__ */ Q(
|
|
2401
|
+
y
|
|
2402
|
+
]), ye = X(() => {
|
|
2403
|
+
if (!ve) return null;
|
|
2404
|
+
let t = v?.target ?? "drawer", n = v?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i = r ? null : /* @__PURE__ */ Q(It, {
|
|
2357
2405
|
objectName: e,
|
|
2358
|
-
filter:
|
|
2359
|
-
onNavigate: () =>
|
|
2406
|
+
filter: B,
|
|
2407
|
+
onNavigate: () => ne(!1)
|
|
2360
2408
|
}), a;
|
|
2361
2409
|
if (r) {
|
|
2362
|
-
let e = n.filter, t = e ?
|
|
2410
|
+
let e = n.filter, t = e ? B ? { $and: [e, B] } : e : B;
|
|
2363
2411
|
a = /* @__PURE__ */ Q("div", {
|
|
2364
2412
|
className: "h-full overflow-auto",
|
|
2365
|
-
children: /* @__PURE__ */ Q(
|
|
2413
|
+
children: /* @__PURE__ */ Q(w, { schema: {
|
|
2366
2414
|
type: "spec-report",
|
|
2367
2415
|
...n,
|
|
2368
2416
|
filter: t
|
|
@@ -2370,10 +2418,10 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2370
2418
|
});
|
|
2371
2419
|
} else a = /* @__PURE__ */ Q("div", {
|
|
2372
2420
|
className: "h-full overflow-auto",
|
|
2373
|
-
children: /* @__PURE__ */ Q(
|
|
2421
|
+
children: /* @__PURE__ */ Q(w, { schema: {
|
|
2374
2422
|
type: "object-data-table",
|
|
2375
2423
|
objectName: e,
|
|
2376
|
-
filter:
|
|
2424
|
+
filter: B,
|
|
2377
2425
|
pageSize: 25,
|
|
2378
2426
|
drillDown: {
|
|
2379
2427
|
enabled: !0,
|
|
@@ -2382,25 +2430,25 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2382
2430
|
}
|
|
2383
2431
|
} })
|
|
2384
2432
|
});
|
|
2385
|
-
return t === "dialog" ? /* @__PURE__ */ Q(
|
|
2433
|
+
return t === "dialog" ? /* @__PURE__ */ Q(z, {
|
|
2386
2434
|
open: !0,
|
|
2387
|
-
onOpenChange: (e) => !e &&
|
|
2388
|
-
children: /* @__PURE__ */ $(
|
|
2435
|
+
onOpenChange: (e) => !e && ne(!1),
|
|
2436
|
+
children: /* @__PURE__ */ $(fe, {
|
|
2389
2437
|
className: "max-w-5xl",
|
|
2390
|
-
children: [/* @__PURE__ */ $(
|
|
2438
|
+
children: [/* @__PURE__ */ $(pe, {
|
|
2391
2439
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2392
|
-
children: [/* @__PURE__ */ Q(
|
|
2440
|
+
children: [/* @__PURE__ */ Q(me, { children: W }), i]
|
|
2393
2441
|
}), a]
|
|
2394
2442
|
})
|
|
2395
|
-
}) : /* @__PURE__ */ Q(
|
|
2443
|
+
}) : /* @__PURE__ */ Q(xe, {
|
|
2396
2444
|
open: !0,
|
|
2397
|
-
onOpenChange: (e) => !e &&
|
|
2398
|
-
children: /* @__PURE__ */ $(
|
|
2445
|
+
onOpenChange: (e) => !e && ne(!1),
|
|
2446
|
+
children: /* @__PURE__ */ $(Se, {
|
|
2399
2447
|
side: "right",
|
|
2400
2448
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col",
|
|
2401
|
-
children: [/* @__PURE__ */ $(
|
|
2449
|
+
children: [/* @__PURE__ */ $(Ce, {
|
|
2402
2450
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2403
|
-
children: [/* @__PURE__ */ Q(
|
|
2451
|
+
children: [/* @__PURE__ */ Q(we, { children: W }), i]
|
|
2404
2452
|
}), /* @__PURE__ */ Q("div", {
|
|
2405
2453
|
className: "flex-1 overflow-hidden mt-2",
|
|
2406
2454
|
children: a
|
|
@@ -2408,39 +2456,39 @@ var bn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2408
2456
|
})
|
|
2409
2457
|
});
|
|
2410
2458
|
}, [
|
|
2411
|
-
|
|
2459
|
+
ve,
|
|
2412
2460
|
v,
|
|
2413
2461
|
e,
|
|
2414
|
-
|
|
2462
|
+
B,
|
|
2415
2463
|
W
|
|
2416
2464
|
]);
|
|
2417
|
-
return /* @__PURE__ */ $(
|
|
2465
|
+
return /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q(Sn, {
|
|
2418
2466
|
label: r,
|
|
2419
|
-
value:
|
|
2420
|
-
trend:
|
|
2467
|
+
value: U,
|
|
2468
|
+
trend: _e,
|
|
2421
2469
|
icon: o,
|
|
2422
2470
|
className: s,
|
|
2423
|
-
description:
|
|
2424
|
-
loading:
|
|
2425
|
-
error:
|
|
2471
|
+
description: c,
|
|
2472
|
+
loading: N,
|
|
2473
|
+
error: oe,
|
|
2426
2474
|
colorVariant: d,
|
|
2427
|
-
format:
|
|
2428
|
-
currency:
|
|
2475
|
+
format: le,
|
|
2476
|
+
currency: de,
|
|
2429
2477
|
prefix: m,
|
|
2430
|
-
suffix:
|
|
2431
|
-
variant:
|
|
2432
|
-
onClick:
|
|
2433
|
-
}),
|
|
2478
|
+
suffix: h,
|
|
2479
|
+
variant: ee,
|
|
2480
|
+
onClick: ve ? () => ne(!0) : void 0
|
|
2481
|
+
}), k && ye] });
|
|
2434
2482
|
};
|
|
2435
2483
|
//#endregion
|
|
2436
2484
|
//#region src/PivotTable.tsx
|
|
2437
|
-
function
|
|
2438
|
-
return
|
|
2485
|
+
function En() {
|
|
2486
|
+
return N()("dashboard.total", "Total");
|
|
2439
2487
|
}
|
|
2440
|
-
function
|
|
2441
|
-
return
|
|
2488
|
+
function Dn() {
|
|
2489
|
+
return N()("dashboard.noDataAvailable", "No data available");
|
|
2442
2490
|
}
|
|
2443
|
-
function
|
|
2491
|
+
function On(e, t) {
|
|
2444
2492
|
if (!t) return String(e);
|
|
2445
2493
|
let n = "", r = !1, i, a = t, o = a.match(/^([^0-9.,#]*)/);
|
|
2446
2494
|
if (o && o[1]) {
|
|
@@ -2457,11 +2505,18 @@ function wn(e, t) {
|
|
|
2457
2505
|
}
|
|
2458
2506
|
return n + l + c;
|
|
2459
2507
|
}
|
|
2460
|
-
var
|
|
2461
|
-
function
|
|
2462
|
-
return e === "" ?
|
|
2508
|
+
var kn = "—";
|
|
2509
|
+
function An(e, t) {
|
|
2510
|
+
return e === "" ? kn : t?.[e] ?? e;
|
|
2463
2511
|
}
|
|
2464
|
-
|
|
2512
|
+
var jn = /* @__PURE__ */ new Set([
|
|
2513
|
+
"sum",
|
|
2514
|
+
"count",
|
|
2515
|
+
"avg",
|
|
2516
|
+
"min",
|
|
2517
|
+
"max"
|
|
2518
|
+
]);
|
|
2519
|
+
function Mn(e, t) {
|
|
2465
2520
|
if (e.length === 0) return 0;
|
|
2466
2521
|
switch (t) {
|
|
2467
2522
|
case "sum": return e.reduce((e, t) => e + t, 0);
|
|
@@ -2469,11 +2524,11 @@ function Dn(e, t) {
|
|
|
2469
2524
|
case "avg": return e.reduce((e, t) => e + t, 0) / e.length;
|
|
2470
2525
|
case "min": return Math.min(...e);
|
|
2471
2526
|
case "max": return Math.max(...e);
|
|
2472
|
-
default: return
|
|
2527
|
+
default: return NaN;
|
|
2473
2528
|
}
|
|
2474
2529
|
}
|
|
2475
|
-
var
|
|
2476
|
-
let { title: o, rowField: s, columnField: c, valueField: l, aggregation: u = "sum", data: d = [], showRowTotals: f = !1, showColumnTotals: p = !1, format: m, columnColors:
|
|
2530
|
+
var Nn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabel: i, onDrillDown: a }) => {
|
|
2531
|
+
let { title: o, rowField: s, columnField: c, valueField: l, aggregation: u = "sum", data: d = [], showRowTotals: f = !1, showColumnTotals: p = !1, format: m, columnColors: h, drillDown: _ } = e, v = En(), y = Dn(), b = g(_) && typeof a == "function", x = (e) => {
|
|
2477
2532
|
b && a({
|
|
2478
2533
|
...e,
|
|
2479
2534
|
rowLabel: e.rowKey === void 0 ? e.rowLabel : n?.[e.rowKey] ?? e.rowKey,
|
|
@@ -2481,7 +2536,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2481
2536
|
});
|
|
2482
2537
|
}, S = (e) => (t) => {
|
|
2483
2538
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
|
|
2484
|
-
}, 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(d) ? d : [], { rowKeys: T, colKeys: E, matrix:
|
|
2539
|
+
}, 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(d) ? d : [], { rowKeys: T, colKeys: E, matrix: ee, rowTotals: D, colTotals: O, grandTotal: te } = X(() => {
|
|
2485
2540
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = {};
|
|
2486
2541
|
for (let r of w) {
|
|
2487
2542
|
let i = String(r[s] ?? ""), a = String(r[c] ?? ""), o = Number(r[l]) || 0;
|
|
@@ -2492,10 +2547,10 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2492
2547
|
a[e] = {};
|
|
2493
2548
|
let t = [];
|
|
2494
2549
|
for (let r of i) {
|
|
2495
|
-
let i = n[e]?.[r] ?? [], o =
|
|
2550
|
+
let i = n[e]?.[r] ?? [], o = Mn(i, u);
|
|
2496
2551
|
a[e][r] = o, t.push(...i), !d[r] && d[r];
|
|
2497
2552
|
}
|
|
2498
|
-
o[e] =
|
|
2553
|
+
o[e] = Mn(t, u);
|
|
2499
2554
|
}
|
|
2500
2555
|
for (let e of i) {
|
|
2501
2556
|
let t = [];
|
|
@@ -2503,7 +2558,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2503
2558
|
let r = n[i]?.[e] ?? [];
|
|
2504
2559
|
t.push(...r);
|
|
2505
2560
|
}
|
|
2506
|
-
d[e] =
|
|
2561
|
+
d[e] = Mn(t, u);
|
|
2507
2562
|
}
|
|
2508
2563
|
let f = [];
|
|
2509
2564
|
for (let e of w) f.push(Number(e[l]) || 0);
|
|
@@ -2513,7 +2568,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2513
2568
|
matrix: a,
|
|
2514
2569
|
rowTotals: o,
|
|
2515
2570
|
colTotals: d,
|
|
2516
|
-
grandTotal:
|
|
2571
|
+
grandTotal: Mn(f, u)
|
|
2517
2572
|
};
|
|
2518
2573
|
}, [
|
|
2519
2574
|
w,
|
|
@@ -2521,13 +2576,13 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2521
2576
|
c,
|
|
2522
2577
|
l,
|
|
2523
2578
|
u
|
|
2524
|
-
]),
|
|
2525
|
-
return w.length === 0 ? /* @__PURE__ */ $("div", {
|
|
2579
|
+
]), k = (e) => On(e, m);
|
|
2580
|
+
return jn.has(u) ? w.length === 0 ? /* @__PURE__ */ $("div", {
|
|
2526
2581
|
className: K("overflow-auto", t),
|
|
2527
2582
|
children: [o && /* @__PURE__ */ Q("h3", {
|
|
2528
2583
|
className: "text-sm font-semibold mb-2",
|
|
2529
2584
|
children: o
|
|
2530
|
-
}), /* @__PURE__ */ Q(
|
|
2585
|
+
}), /* @__PURE__ */ Q(R, {
|
|
2531
2586
|
"data-testid": "pivot-empty-state",
|
|
2532
2587
|
className: "py-8 gap-2 [&>h3]:hidden",
|
|
2533
2588
|
icon: /* @__PURE__ */ $("svg", {
|
|
@@ -2592,14 +2647,14 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2592
2647
|
colKey: e
|
|
2593
2648
|
});
|
|
2594
2649
|
return /* @__PURE__ */ Q("th", {
|
|
2595
|
-
className: K("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70",
|
|
2650
|
+
className: K("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", h?.[e] ?? "text-muted-foreground", C),
|
|
2596
2651
|
title: e === "" ? `${c}: (empty)` : `${c}: ${e}`,
|
|
2597
2652
|
role: b ? "button" : void 0,
|
|
2598
2653
|
tabIndex: b ? 0 : void 0,
|
|
2599
2654
|
onClick: b ? t : void 0,
|
|
2600
2655
|
onKeyDown: b ? S(t) : void 0,
|
|
2601
2656
|
"aria-label": b ? `Drill into ${c}: ${e || "(empty)"}` : void 0,
|
|
2602
|
-
children:
|
|
2657
|
+
children: An(e, r)
|
|
2603
2658
|
}, e);
|
|
2604
2659
|
}),
|
|
2605
2660
|
f && /* @__PURE__ */ Q("th", {
|
|
@@ -2624,23 +2679,23 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2624
2679
|
rowKey: e
|
|
2625
2680
|
})) : void 0,
|
|
2626
2681
|
"aria-label": b ? `Drill into ${s}: ${e || "(empty)"}` : void 0,
|
|
2627
|
-
children:
|
|
2682
|
+
children: An(e, n)
|
|
2628
2683
|
}),
|
|
2629
2684
|
E.map((t) => {
|
|
2630
|
-
let n =
|
|
2685
|
+
let n = ee[e]?.[t] ?? 0, r = () => x({
|
|
2631
2686
|
scope: "cell",
|
|
2632
2687
|
rowKey: e,
|
|
2633
2688
|
colKey: t,
|
|
2634
2689
|
value: n
|
|
2635
2690
|
});
|
|
2636
2691
|
return /* @__PURE__ */ Q("td", {
|
|
2637
|
-
className: K("text-right p-2 tabular-nums",
|
|
2692
|
+
className: K("text-right p-2 tabular-nums", h?.[t], C),
|
|
2638
2693
|
role: b ? "button" : void 0,
|
|
2639
2694
|
tabIndex: b ? 0 : void 0,
|
|
2640
2695
|
onClick: b ? r : void 0,
|
|
2641
2696
|
onKeyDown: b ? S(r) : void 0,
|
|
2642
2697
|
"aria-label": b ? `Drill into ${s}=${e || "(empty)"}, ${c}=${t || "(empty)"}` : void 0,
|
|
2643
|
-
children:
|
|
2698
|
+
children: k(n)
|
|
2644
2699
|
}, t);
|
|
2645
2700
|
}),
|
|
2646
2701
|
f && /* @__PURE__ */ Q("td", {
|
|
@@ -2650,14 +2705,14 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2650
2705
|
onClick: b ? () => x({
|
|
2651
2706
|
scope: "row",
|
|
2652
2707
|
rowKey: e,
|
|
2653
|
-
value:
|
|
2708
|
+
value: D[e] ?? 0
|
|
2654
2709
|
}) : void 0,
|
|
2655
2710
|
onKeyDown: b ? S(() => x({
|
|
2656
2711
|
scope: "row",
|
|
2657
2712
|
rowKey: e,
|
|
2658
|
-
value:
|
|
2713
|
+
value: D[e] ?? 0
|
|
2659
2714
|
})) : void 0,
|
|
2660
|
-
children:
|
|
2715
|
+
children: k(D[e] ?? 0)
|
|
2661
2716
|
})
|
|
2662
2717
|
]
|
|
2663
2718
|
}, e)) }),
|
|
@@ -2675,14 +2730,14 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2675
2730
|
onClick: b ? () => x({
|
|
2676
2731
|
scope: "column",
|
|
2677
2732
|
colKey: e,
|
|
2678
|
-
value:
|
|
2733
|
+
value: O[e] ?? 0
|
|
2679
2734
|
}) : void 0,
|
|
2680
2735
|
onKeyDown: b ? S(() => x({
|
|
2681
2736
|
scope: "column",
|
|
2682
2737
|
colKey: e,
|
|
2683
|
-
value:
|
|
2738
|
+
value: O[e] ?? 0
|
|
2684
2739
|
})) : void 0,
|
|
2685
|
-
children:
|
|
2740
|
+
children: k(O[e] ?? 0)
|
|
2686
2741
|
}, e)),
|
|
2687
2742
|
f && /* @__PURE__ */ Q("td", {
|
|
2688
2743
|
className: K("text-right p-2 tabular-nums font-bold", C),
|
|
@@ -2690,24 +2745,45 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2690
2745
|
tabIndex: b ? 0 : void 0,
|
|
2691
2746
|
onClick: b ? () => x({
|
|
2692
2747
|
scope: "total",
|
|
2693
|
-
value:
|
|
2748
|
+
value: te
|
|
2694
2749
|
}) : void 0,
|
|
2695
2750
|
onKeyDown: b ? S(() => x({
|
|
2696
2751
|
scope: "total",
|
|
2697
|
-
value:
|
|
2752
|
+
value: te
|
|
2698
2753
|
})) : void 0,
|
|
2699
|
-
children:
|
|
2754
|
+
children: k(te)
|
|
2700
2755
|
})
|
|
2701
2756
|
]
|
|
2702
2757
|
}) })
|
|
2703
2758
|
]
|
|
2704
2759
|
})]
|
|
2760
|
+
}) : /* @__PURE__ */ $("div", {
|
|
2761
|
+
className: K("overflow-auto", t),
|
|
2762
|
+
"data-testid": "pivot-unsupported-aggregation",
|
|
2763
|
+
children: [o && /* @__PURE__ */ Q("h3", {
|
|
2764
|
+
className: "text-sm font-semibold mb-2",
|
|
2765
|
+
children: o
|
|
2766
|
+
}), /* @__PURE__ */ Q("div", {
|
|
2767
|
+
role: "alert",
|
|
2768
|
+
className: "flex flex-col items-center justify-center py-8 text-destructive",
|
|
2769
|
+
children: /* @__PURE__ */ $("p", {
|
|
2770
|
+
className: "text-xs",
|
|
2771
|
+
children: [
|
|
2772
|
+
"Unsupported aggregation “",
|
|
2773
|
+
String(u),
|
|
2774
|
+
"” — this pivot table renders",
|
|
2775
|
+
" ",
|
|
2776
|
+
[...jn].join(", "),
|
|
2777
|
+
"."
|
|
2778
|
+
]
|
|
2779
|
+
})
|
|
2780
|
+
})]
|
|
2705
2781
|
});
|
|
2706
|
-
},
|
|
2707
|
-
let r =
|
|
2782
|
+
}, Pn = ({ schema: e, dataSource: t, className: n }) => {
|
|
2783
|
+
let r = Ae(T), i = t || r?.dataSource, a = ee(e.bind), [o, s] = Z([]), [c, l] = Z(!1), [d, p] = Z(null), [m, h] = Z({}), [_, v] = Z({}), [y, S] = Z(null), { fieldLabel: C, fieldOptionLabel: w } = ae(), E = je(C), D = je(w);
|
|
2708
2784
|
Y(() => {
|
|
2709
|
-
|
|
2710
|
-
}, [C,
|
|
2785
|
+
E.current = C, D.current = w;
|
|
2786
|
+
}, [C, w]), Y(() => {
|
|
2711
2787
|
if (!i || !e.objectName) return;
|
|
2712
2788
|
let t = i.getObjectSchema;
|
|
2713
2789
|
if (typeof t != "function") return;
|
|
@@ -2717,35 +2793,37 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2717
2793
|
let r = e.objectName, i = {}, a = {};
|
|
2718
2794
|
for (let [e, n] of Object.entries(t.fields)) {
|
|
2719
2795
|
let t = n?.label ? String(n.label) : e;
|
|
2720
|
-
a[e] =
|
|
2796
|
+
a[e] = E.current(r, e, t);
|
|
2721
2797
|
let o = n?.options;
|
|
2722
2798
|
if (Array.isArray(o) && o.length > 0) {
|
|
2723
2799
|
let t = {};
|
|
2724
2800
|
for (let n of o) if (n && n.value !== void 0 && n.label !== void 0) {
|
|
2725
2801
|
let i = String(n.value), a = String(n.label);
|
|
2726
|
-
t[i] =
|
|
2802
|
+
t[i] = D.current(r, e, i, a);
|
|
2727
2803
|
}
|
|
2728
2804
|
Object.keys(t).length > 0 && (i[e] = t);
|
|
2729
2805
|
}
|
|
2730
2806
|
}
|
|
2731
|
-
|
|
2807
|
+
h(i), v(a);
|
|
2732
2808
|
}).catch(() => {}), () => {
|
|
2733
2809
|
n = !1;
|
|
2734
2810
|
};
|
|
2735
|
-
}, [i, e.objectName])
|
|
2811
|
+
}, [i, e.objectName]);
|
|
2812
|
+
let O = te();
|
|
2813
|
+
Y(() => {
|
|
2736
2814
|
let t = !0;
|
|
2737
2815
|
return e.objectName && !a && (!e.data || e.data.length === 0) && (async () => {
|
|
2738
2816
|
if (!(!i || !e.objectName)) {
|
|
2739
|
-
t && (
|
|
2817
|
+
t && (l(!0), p(null));
|
|
2740
2818
|
try {
|
|
2741
2819
|
let n;
|
|
2742
|
-
if (typeof i.find == "function") n =
|
|
2820
|
+
if (typeof i.find == "function") n = f(await i.find(e.objectName, { $filter: x(e.filter, O) }));
|
|
2743
2821
|
else return;
|
|
2744
2822
|
t && s(n);
|
|
2745
2823
|
} catch (e) {
|
|
2746
2824
|
console.error("[ObjectPivotTable] Fetch error:", e), t && p(e instanceof Error ? e.message : "Failed to load data");
|
|
2747
2825
|
} finally {
|
|
2748
|
-
t &&
|
|
2826
|
+
t && l(!1);
|
|
2749
2827
|
}
|
|
2750
2828
|
}
|
|
2751
2829
|
})(), () => {
|
|
@@ -2756,10 +2834,11 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2756
2834
|
i,
|
|
2757
2835
|
a,
|
|
2758
2836
|
e.data,
|
|
2759
|
-
e.filter
|
|
2837
|
+
e.filter,
|
|
2838
|
+
O
|
|
2760
2839
|
]);
|
|
2761
|
-
let k = a || e.data || o,
|
|
2762
|
-
if (c &&
|
|
2840
|
+
let k = a || e.data || o, ne = Array.isArray(k) ? k : [];
|
|
2841
|
+
if (c && ne.length === 0) return /* @__PURE__ */ $("div", {
|
|
2763
2842
|
className: K("overflow-auto", n),
|
|
2764
2843
|
"data-testid": "pivot-loading",
|
|
2765
2844
|
children: [e.title && /* @__PURE__ */ Q("h3", {
|
|
@@ -2790,7 +2869,7 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2790
2869
|
}, e))]
|
|
2791
2870
|
})]
|
|
2792
2871
|
});
|
|
2793
|
-
if (
|
|
2872
|
+
if (d) return /* @__PURE__ */ $("div", {
|
|
2794
2873
|
className: K("overflow-auto", n),
|
|
2795
2874
|
"data-testid": "pivot-error",
|
|
2796
2875
|
children: [e.title && /* @__PURE__ */ Q("h3", {
|
|
@@ -2829,11 +2908,11 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2829
2908
|
]
|
|
2830
2909
|
}), /* @__PURE__ */ Q("p", {
|
|
2831
2910
|
className: "text-xs",
|
|
2832
|
-
children:
|
|
2911
|
+
children: d
|
|
2833
2912
|
})]
|
|
2834
2913
|
})]
|
|
2835
2914
|
});
|
|
2836
|
-
if (!i && e.objectName &&
|
|
2915
|
+
if (!i && e.objectName && ne.length === 0) return /* @__PURE__ */ $("div", {
|
|
2837
2916
|
className: K("overflow-auto", n),
|
|
2838
2917
|
children: [e.title && /* @__PURE__ */ Q("h3", {
|
|
2839
2918
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2850,40 +2929,40 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2850
2929
|
})
|
|
2851
2930
|
})]
|
|
2852
2931
|
});
|
|
2853
|
-
let
|
|
2932
|
+
let re = {
|
|
2854
2933
|
...e,
|
|
2855
|
-
data:
|
|
2856
|
-
},
|
|
2857
|
-
return /* @__PURE__ */ $(
|
|
2858
|
-
schema:
|
|
2934
|
+
data: ne
|
|
2935
|
+
}, A = e.rowField ? m[e.rowField] : void 0, ie = e.columnField ? m[e.columnField] : void 0, j = e.rowField ? _[e.rowField] : void 0, M = e.drillDown;
|
|
2936
|
+
return /* @__PURE__ */ $(dt, { children: [/* @__PURE__ */ Q(Nn, {
|
|
2937
|
+
schema: re,
|
|
2859
2938
|
className: n,
|
|
2860
|
-
rowLabels:
|
|
2861
|
-
columnLabels:
|
|
2862
|
-
rowFieldLabel:
|
|
2863
|
-
onDrillDown:
|
|
2939
|
+
rowLabels: A,
|
|
2940
|
+
columnLabels: ie,
|
|
2941
|
+
rowFieldLabel: j,
|
|
2942
|
+
onDrillDown: g(M) ? (e) => S(e) : void 0
|
|
2864
2943
|
}), (() => {
|
|
2865
|
-
if (!
|
|
2866
|
-
let t =
|
|
2944
|
+
if (!y || !e.objectName) return null;
|
|
2945
|
+
let t = u(M, y, {
|
|
2867
2946
|
rowField: e.rowField,
|
|
2868
2947
|
columnField: e.columnField
|
|
2869
2948
|
}), n = {
|
|
2870
2949
|
...e.filter || {},
|
|
2871
2950
|
...t
|
|
2872
2951
|
};
|
|
2873
|
-
return /* @__PURE__ */ Q(
|
|
2952
|
+
return /* @__PURE__ */ Q(Lt, {
|
|
2874
2953
|
open: !0,
|
|
2875
2954
|
onClose: () => S(null),
|
|
2876
|
-
title: b(
|
|
2877
|
-
target:
|
|
2955
|
+
title: b(M, y, e.title || "Details"),
|
|
2956
|
+
target: M?.target ?? "drawer",
|
|
2878
2957
|
objectName: e.objectName,
|
|
2879
2958
|
filter: n,
|
|
2880
2959
|
dataSource: i,
|
|
2881
|
-
columns:
|
|
2882
|
-
maxRows:
|
|
2883
|
-
report:
|
|
2960
|
+
columns: M?.columns,
|
|
2961
|
+
maxRows: M?.maxRows,
|
|
2962
|
+
report: M?.report
|
|
2884
2963
|
});
|
|
2885
2964
|
})()] });
|
|
2886
|
-
},
|
|
2965
|
+
}, Fn = {
|
|
2887
2966
|
breadcrumb: ["Dashboard", "Configuration"],
|
|
2888
2967
|
sections: [
|
|
2889
2968
|
{
|
|
@@ -3009,12 +3088,12 @@ var On = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
3009
3088
|
}
|
|
3010
3089
|
]
|
|
3011
3090
|
};
|
|
3012
|
-
function
|
|
3013
|
-
let { draft: a, isDirty: o, updateField: s, discard: c } =
|
|
3014
|
-
return /* @__PURE__ */ Q(
|
|
3091
|
+
function In({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
3092
|
+
let { draft: a, isDirty: o, updateField: s, discard: c } = Ee(n, { onUpdate: i });
|
|
3093
|
+
return /* @__PURE__ */ Q(de, {
|
|
3015
3094
|
open: e,
|
|
3016
3095
|
onClose: t,
|
|
3017
|
-
schema:
|
|
3096
|
+
schema: Fn,
|
|
3018
3097
|
draft: a,
|
|
3019
3098
|
isDirty: o,
|
|
3020
3099
|
onFieldChange: s,
|
|
@@ -3024,7 +3103,7 @@ function jn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
|
3024
3103
|
}
|
|
3025
3104
|
//#endregion
|
|
3026
3105
|
//#region src/WidgetConfigPanel.tsx
|
|
3027
|
-
var
|
|
3106
|
+
var Ln = [
|
|
3028
3107
|
{
|
|
3029
3108
|
value: "metric",
|
|
3030
3109
|
label: "Metric"
|
|
@@ -3069,7 +3148,7 @@ var Mn = [
|
|
|
3069
3148
|
value: "pivot",
|
|
3070
3149
|
label: "Pivot Table"
|
|
3071
3150
|
}
|
|
3072
|
-
],
|
|
3151
|
+
], Rn = [
|
|
3073
3152
|
{
|
|
3074
3153
|
value: "default",
|
|
3075
3154
|
label: "Default"
|
|
@@ -3102,7 +3181,7 @@ var Mn = [
|
|
|
3102
3181
|
value: "danger",
|
|
3103
3182
|
label: "Danger"
|
|
3104
3183
|
}
|
|
3105
|
-
],
|
|
3184
|
+
], zn = [
|
|
3106
3185
|
"bar",
|
|
3107
3186
|
"horizontal-bar",
|
|
3108
3187
|
"line",
|
|
@@ -3111,20 +3190,20 @@ var Mn = [
|
|
|
3111
3190
|
"donut",
|
|
3112
3191
|
"scatter",
|
|
3113
3192
|
"funnel"
|
|
3114
|
-
],
|
|
3193
|
+
], Bn = [
|
|
3115
3194
|
"metric",
|
|
3116
3195
|
"gauge",
|
|
3117
3196
|
"solid-gauge",
|
|
3118
3197
|
"kpi",
|
|
3119
3198
|
"bullet"
|
|
3120
3199
|
];
|
|
3121
|
-
function
|
|
3122
|
-
return !!e &&
|
|
3200
|
+
function Vn(e) {
|
|
3201
|
+
return !!e && zn.includes(e);
|
|
3123
3202
|
}
|
|
3124
|
-
function
|
|
3125
|
-
return !!e && !
|
|
3203
|
+
function Hn(e) {
|
|
3204
|
+
return !!e && !Bn.includes(e);
|
|
3126
3205
|
}
|
|
3127
|
-
function
|
|
3206
|
+
function Un({ names: e, options: t, placeholder: n, emptyText: r, onChange: i }) {
|
|
3128
3207
|
let [a, o] = q.useState(""), s = q.useMemo(() => new Set(e), [e]), c = q.useMemo(() => t.filter((e) => !s.has(e.value)), [t, s]), l = (t) => {
|
|
3129
3208
|
let n = t.trim();
|
|
3130
3209
|
!n || s.has(n) || (i([...e, n]), o(""));
|
|
@@ -3144,10 +3223,10 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
|
|
|
3144
3223
|
"aria-label": `Remove ${e}`,
|
|
3145
3224
|
className: "text-muted-foreground hover:text-foreground",
|
|
3146
3225
|
onClick: () => u(e),
|
|
3147
|
-
children: /* @__PURE__ */ Q(
|
|
3226
|
+
children: /* @__PURE__ */ Q(Je, { className: "h-3 w-3" })
|
|
3148
3227
|
})]
|
|
3149
3228
|
}, e))
|
|
3150
|
-
}), c.length > 0 ? /* @__PURE__ */ Q(
|
|
3229
|
+
}), c.length > 0 ? /* @__PURE__ */ Q(ue, {
|
|
3151
3230
|
options: c,
|
|
3152
3231
|
value: "",
|
|
3153
3232
|
onValueChange: l,
|
|
@@ -3157,7 +3236,7 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
|
|
|
3157
3236
|
className: "h-7 w-full text-xs"
|
|
3158
3237
|
}) : /* @__PURE__ */ $("div", {
|
|
3159
3238
|
className: "flex items-center gap-1",
|
|
3160
|
-
children: [/* @__PURE__ */ Q(
|
|
3239
|
+
children: [/* @__PURE__ */ Q(he, {
|
|
3161
3240
|
value: a,
|
|
3162
3241
|
onChange: (e) => o(e.target.value),
|
|
3163
3242
|
onKeyDown: (e) => {
|
|
@@ -3165,7 +3244,7 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
|
|
|
3165
3244
|
},
|
|
3166
3245
|
placeholder: n,
|
|
3167
3246
|
className: "h-7 flex-1 text-xs"
|
|
3168
|
-
}), /* @__PURE__ */ Q(
|
|
3247
|
+
}), /* @__PURE__ */ Q(P, {
|
|
3169
3248
|
type: "button",
|
|
3170
3249
|
size: "sm",
|
|
3171
3250
|
variant: "outline",
|
|
@@ -3177,7 +3256,7 @@ function Rn({ names: e, options: t, placeholder: n, emptyText: r, onChange: i })
|
|
|
3177
3256
|
})]
|
|
3178
3257
|
});
|
|
3179
3258
|
}
|
|
3180
|
-
function
|
|
3259
|
+
function Wn(e, t) {
|
|
3181
3260
|
let n = e ?? [], r = n.length > 0, i = n.map((e) => ({
|
|
3182
3261
|
value: e.name,
|
|
3183
3262
|
label: e.label && e.label !== e.name ? `${e.label} (${e.name})` : e.name
|
|
@@ -3186,11 +3265,11 @@ function zn(e, t) {
|
|
|
3186
3265
|
label: "Dataset",
|
|
3187
3266
|
type: "custom",
|
|
3188
3267
|
helpText: "The semantic-layer dataset this widget binds to (ADR-0021).",
|
|
3189
|
-
render: (e, t) => /* @__PURE__ */ Q(
|
|
3268
|
+
render: (e, t) => /* @__PURE__ */ Q(L, {
|
|
3190
3269
|
label: "Dataset",
|
|
3191
3270
|
children: /* @__PURE__ */ Q("div", {
|
|
3192
3271
|
"data-testid": "config-field-dataset",
|
|
3193
|
-
children: /* @__PURE__ */ Q(
|
|
3272
|
+
children: /* @__PURE__ */ Q(ue, {
|
|
3194
3273
|
options: i,
|
|
3195
3274
|
value: e ?? "",
|
|
3196
3275
|
onValueChange: t,
|
|
@@ -3211,19 +3290,19 @@ function zn(e, t) {
|
|
|
3211
3290
|
key: "dimensions",
|
|
3212
3291
|
label: "Dimensions",
|
|
3213
3292
|
type: "custom",
|
|
3214
|
-
visibleWhen: (e) =>
|
|
3293
|
+
visibleWhen: (e) => Hn(e.type),
|
|
3215
3294
|
helpText: t === "pivot" ? "Group/split fields. The last dimension spreads across as columns." : "Group/split the values by these dataset dimensions.",
|
|
3216
3295
|
render: (e, t, n) => {
|
|
3217
3296
|
let r = (a(n.dataset)?.dimensions ?? []).map((e) => ({
|
|
3218
3297
|
value: e.name,
|
|
3219
3298
|
label: e.label && e.label !== e.name ? `${e.label} (${e.name})` : e.name
|
|
3220
3299
|
}));
|
|
3221
|
-
return /* @__PURE__ */ Q(
|
|
3300
|
+
return /* @__PURE__ */ Q(L, {
|
|
3222
3301
|
label: "Dimensions",
|
|
3223
3302
|
children: /* @__PURE__ */ Q("div", {
|
|
3224
3303
|
"data-testid": "config-field-dimensions",
|
|
3225
3304
|
className: "w-40",
|
|
3226
|
-
children: /* @__PURE__ */ Q(
|
|
3305
|
+
children: /* @__PURE__ */ Q(Un, {
|
|
3227
3306
|
names: Array.isArray(e) ? e : [],
|
|
3228
3307
|
options: r,
|
|
3229
3308
|
placeholder: "Add dimension…",
|
|
@@ -3238,7 +3317,7 @@ function zn(e, t) {
|
|
|
3238
3317
|
breadcrumb: ["Dashboard", {
|
|
3239
3318
|
pivot: "Pivot table",
|
|
3240
3319
|
table: "Table"
|
|
3241
|
-
}[t ?? ""] ?? (
|
|
3320
|
+
}[t ?? ""] ?? (Vn(t) ? "Chart" : "Widget")],
|
|
3242
3321
|
sections: [
|
|
3243
3322
|
{
|
|
3244
3323
|
key: "general",
|
|
@@ -3260,7 +3339,7 @@ function zn(e, t) {
|
|
|
3260
3339
|
key: "type",
|
|
3261
3340
|
label: "Widget type",
|
|
3262
3341
|
type: "select",
|
|
3263
|
-
options:
|
|
3342
|
+
options: Ln,
|
|
3264
3343
|
defaultValue: "metric"
|
|
3265
3344
|
}
|
|
3266
3345
|
]
|
|
@@ -3282,12 +3361,12 @@ function zn(e, t) {
|
|
|
3282
3361
|
value: e.name,
|
|
3283
3362
|
label: e.aggregate ? `${e.label ?? e.name} · ${e.aggregate}` : e.label ?? e.name
|
|
3284
3363
|
}));
|
|
3285
|
-
return /* @__PURE__ */ Q(
|
|
3364
|
+
return /* @__PURE__ */ Q(L, {
|
|
3286
3365
|
label: "Values",
|
|
3287
3366
|
children: /* @__PURE__ */ Q("div", {
|
|
3288
3367
|
"data-testid": "config-field-values",
|
|
3289
3368
|
className: "w-40",
|
|
3290
|
-
children: /* @__PURE__ */ Q(
|
|
3369
|
+
children: /* @__PURE__ */ Q(Un, {
|
|
3291
3370
|
names: Array.isArray(e) ? e : [],
|
|
3292
3371
|
options: r,
|
|
3293
3372
|
placeholder: "Add measure…",
|
|
@@ -3343,14 +3422,14 @@ function zn(e, t) {
|
|
|
3343
3422
|
key: "colorVariant",
|
|
3344
3423
|
label: "Color variant",
|
|
3345
3424
|
type: "select",
|
|
3346
|
-
options:
|
|
3425
|
+
options: Rn,
|
|
3347
3426
|
defaultValue: "default"
|
|
3348
3427
|
}]
|
|
3349
3428
|
}
|
|
3350
3429
|
]
|
|
3351
3430
|
};
|
|
3352
3431
|
}
|
|
3353
|
-
function
|
|
3432
|
+
function Gn(e) {
|
|
3354
3433
|
if (e == null) return "";
|
|
3355
3434
|
if (typeof e == "string") return e;
|
|
3356
3435
|
if (typeof e == "object") {
|
|
@@ -3359,7 +3438,7 @@ function Bn(e) {
|
|
|
3359
3438
|
}
|
|
3360
3439
|
return String(e);
|
|
3361
3440
|
}
|
|
3362
|
-
var
|
|
3441
|
+
var Kn = [
|
|
3363
3442
|
"object",
|
|
3364
3443
|
"categoryField",
|
|
3365
3444
|
"categoryGranularity",
|
|
@@ -3386,32 +3465,32 @@ var Vn = [
|
|
|
3386
3465
|
"searchable",
|
|
3387
3466
|
"pagination"
|
|
3388
3467
|
];
|
|
3389
|
-
function
|
|
3468
|
+
function qn(e) {
|
|
3390
3469
|
let t = e.type, n = { ...e };
|
|
3391
|
-
for (let e of
|
|
3392
|
-
return
|
|
3470
|
+
for (let e of Kn) delete n[e];
|
|
3471
|
+
return Hn(t) || delete n.dimensions, n;
|
|
3393
3472
|
}
|
|
3394
|
-
function
|
|
3395
|
-
let { draft: c, isDirty: l, updateField: u, discard: d } =
|
|
3473
|
+
function Jn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, headerExtra: a, datasets: o, datasetsLoading: s }) {
|
|
3474
|
+
let { draft: c, isDirty: l, updateField: u, discard: d } = Ee(q.useMemo(() => ({
|
|
3396
3475
|
...n,
|
|
3397
|
-
title: typeof n.title == "object" ?
|
|
3398
|
-
description: typeof n.description == "object" ?
|
|
3476
|
+
title: typeof n.title == "object" ? Gn(n.title) : n.title,
|
|
3477
|
+
description: typeof n.description == "object" ? Gn(n.description) : n.description
|
|
3399
3478
|
}), [n]), { onUpdate: i });
|
|
3400
|
-
return /* @__PURE__ */ Q(
|
|
3479
|
+
return /* @__PURE__ */ Q(de, {
|
|
3401
3480
|
open: e,
|
|
3402
3481
|
onClose: t,
|
|
3403
|
-
schema: q.useMemo(() =>
|
|
3482
|
+
schema: q.useMemo(() => Wn(o, c.type), [o, c.type]),
|
|
3404
3483
|
draft: c,
|
|
3405
3484
|
isDirty: l,
|
|
3406
3485
|
onFieldChange: u,
|
|
3407
|
-
onSave: () => r(
|
|
3486
|
+
onSave: () => r(qn(c)),
|
|
3408
3487
|
onDiscard: d,
|
|
3409
3488
|
headerExtra: a
|
|
3410
3489
|
});
|
|
3411
3490
|
}
|
|
3412
3491
|
//#endregion
|
|
3413
3492
|
//#region src/DashboardWithConfig.tsx
|
|
3414
|
-
function
|
|
3493
|
+
function Yn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh: i, recordCount: a, defaultConfigOpen: o = !1, className: s, datasets: c, datasetsLoading: l }) {
|
|
3415
3494
|
let [u, d] = Z(o), [f, p] = Z(null), [m, h] = Z(e), [g, _] = Z(0);
|
|
3416
3495
|
Y(() => {
|
|
3417
3496
|
h(e), _((e) => e + 1);
|
|
@@ -3470,14 +3549,14 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3470
3549
|
className: "flex-1 min-w-0 overflow-auto relative",
|
|
3471
3550
|
children: [/* @__PURE__ */ Q("div", {
|
|
3472
3551
|
className: "absolute top-2 right-2 z-10",
|
|
3473
|
-
children: /* @__PURE__ */ $(
|
|
3552
|
+
children: /* @__PURE__ */ $(P, {
|
|
3474
3553
|
size: "sm",
|
|
3475
3554
|
variant: u ? "default" : "outline",
|
|
3476
3555
|
onClick: C,
|
|
3477
3556
|
"data-testid": "dashboard-config-toggle",
|
|
3478
|
-
children: [/* @__PURE__ */ Q(
|
|
3557
|
+
children: [/* @__PURE__ */ Q(qe, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
|
|
3479
3558
|
})
|
|
3480
|
-
}), /* @__PURE__ */ Q(
|
|
3559
|
+
}), /* @__PURE__ */ Q(un, {
|
|
3481
3560
|
schema: m,
|
|
3482
3561
|
onRefresh: i,
|
|
3483
3562
|
recordCount: a,
|
|
@@ -3487,7 +3566,7 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3487
3566
|
})]
|
|
3488
3567
|
}), u && /* @__PURE__ */ Q("div", {
|
|
3489
3568
|
className: "relative shrink-0",
|
|
3490
|
-
children: f && v ? /* @__PURE__ */ Q(
|
|
3569
|
+
children: f && v ? /* @__PURE__ */ Q(Jn, {
|
|
3491
3570
|
open: !0,
|
|
3492
3571
|
onClose: b,
|
|
3493
3572
|
config: v,
|
|
@@ -3495,7 +3574,7 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3495
3574
|
onFieldChange: x,
|
|
3496
3575
|
datasets: c,
|
|
3497
3576
|
datasetsLoading: l
|
|
3498
|
-
}) : /* @__PURE__ */ Q(
|
|
3577
|
+
}) : /* @__PURE__ */ Q(In, {
|
|
3499
3578
|
open: !0,
|
|
3500
3579
|
onClose: () => d(!1),
|
|
3501
3580
|
config: t,
|
|
@@ -3504,7 +3583,7 @@ function Wn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3504
3583
|
})]
|
|
3505
3584
|
});
|
|
3506
3585
|
}
|
|
3507
|
-
e.register("dashboard",
|
|
3586
|
+
e.register("dashboard", un, {
|
|
3508
3587
|
namespace: "view",
|
|
3509
3588
|
label: "Dashboard",
|
|
3510
3589
|
category: "Complex",
|
|
@@ -3532,7 +3611,7 @@ e.register("dashboard", on, {
|
|
|
3532
3611
|
columns: 3,
|
|
3533
3612
|
widgets: []
|
|
3534
3613
|
}
|
|
3535
|
-
}), e.register("metric",
|
|
3614
|
+
}), e.register("metric", Sn, {
|
|
3536
3615
|
namespace: "plugin-dashboard",
|
|
3537
3616
|
label: "Metric Widget",
|
|
3538
3617
|
category: "Dashboard",
|
|
@@ -3545,7 +3624,7 @@ e.register("dashboard", on, {
|
|
|
3545
3624
|
type: "string",
|
|
3546
3625
|
label: "Value"
|
|
3547
3626
|
}]
|
|
3548
|
-
}), e.register("metric-card",
|
|
3627
|
+
}), e.register("metric-card", wn, {
|
|
3549
3628
|
namespace: "plugin-dashboard",
|
|
3550
3629
|
label: "Metric Card",
|
|
3551
3630
|
category: "Dashboard",
|
|
@@ -3600,7 +3679,7 @@ e.register("dashboard", on, {
|
|
|
3600
3679
|
title: "Metric",
|
|
3601
3680
|
value: "0"
|
|
3602
3681
|
}
|
|
3603
|
-
}), e.register("object-metric",
|
|
3682
|
+
}), e.register("object-metric", Tn, {
|
|
3604
3683
|
namespace: "plugin-dashboard",
|
|
3605
3684
|
label: "Object Metric",
|
|
3606
3685
|
category: "Dashboard",
|
|
@@ -3629,7 +3708,7 @@ e.register("dashboard", on, {
|
|
|
3629
3708
|
}
|
|
3630
3709
|
],
|
|
3631
3710
|
defaultProps: { label: "Metric" }
|
|
3632
|
-
}), e.register("pivot",
|
|
3711
|
+
}), e.register("pivot", Nn, {
|
|
3633
3712
|
namespace: "plugin-dashboard",
|
|
3634
3713
|
label: "Pivot Table",
|
|
3635
3714
|
category: "Dashboard",
|
|
@@ -3708,7 +3787,7 @@ e.register("dashboard", on, {
|
|
|
3708
3787
|
aggregation: "sum",
|
|
3709
3788
|
data: []
|
|
3710
3789
|
}
|
|
3711
|
-
}), e.register("object-pivot",
|
|
3790
|
+
}), e.register("object-pivot", Pn, {
|
|
3712
3791
|
namespace: "plugin-dashboard",
|
|
3713
3792
|
label: "Object Pivot Table",
|
|
3714
3793
|
category: "Dashboard",
|
|
@@ -3797,7 +3876,7 @@ e.register("dashboard", on, {
|
|
|
3797
3876
|
valueField: "",
|
|
3798
3877
|
aggregation: "sum"
|
|
3799
3878
|
}
|
|
3800
|
-
}), e.register("dashboard-grid",
|
|
3879
|
+
}), e.register("dashboard-grid", hn, {
|
|
3801
3880
|
namespace: "plugin-dashboard",
|
|
3802
3881
|
label: "Dashboard Grid (Editable)",
|
|
3803
3882
|
category: "Complex",
|
|
@@ -3815,7 +3894,7 @@ e.register("dashboard", on, {
|
|
|
3815
3894
|
title: "Dashboard",
|
|
3816
3895
|
widgets: []
|
|
3817
3896
|
}
|
|
3818
|
-
}), e.register("object-data-table",
|
|
3897
|
+
}), e.register("object-data-table", Ft, {
|
|
3819
3898
|
namespace: "plugin-dashboard",
|
|
3820
3899
|
label: "Object Data Table",
|
|
3821
3900
|
category: "Dashboard",
|
|
@@ -3853,18 +3932,18 @@ e.register("dashboard", on, {
|
|
|
3853
3932
|
pagination: !1
|
|
3854
3933
|
}
|
|
3855
3934
|
});
|
|
3856
|
-
var
|
|
3857
|
-
DashboardRenderer:
|
|
3858
|
-
DashboardGridLayout:
|
|
3859
|
-
MetricWidget:
|
|
3860
|
-
MetricCard:
|
|
3861
|
-
ObjectMetricWidget:
|
|
3862
|
-
PivotTable:
|
|
3863
|
-
ObjectPivotTable:
|
|
3864
|
-
ObjectDataTable:
|
|
3865
|
-
DashboardConfigPanel:
|
|
3866
|
-
WidgetConfigPanel:
|
|
3867
|
-
DashboardWithConfig:
|
|
3935
|
+
var Xn = {
|
|
3936
|
+
DashboardRenderer: un,
|
|
3937
|
+
DashboardGridLayout: hn,
|
|
3938
|
+
MetricWidget: Sn,
|
|
3939
|
+
MetricCard: wn,
|
|
3940
|
+
ObjectMetricWidget: Tn,
|
|
3941
|
+
PivotTable: Nn,
|
|
3942
|
+
ObjectPivotTable: Pn,
|
|
3943
|
+
ObjectDataTable: Ft,
|
|
3944
|
+
DashboardConfigPanel: In,
|
|
3945
|
+
WidgetConfigPanel: Jn,
|
|
3946
|
+
DashboardWithConfig: Yn
|
|
3868
3947
|
};
|
|
3869
3948
|
//#endregion
|
|
3870
|
-
export {
|
|
3949
|
+
export { In as DashboardConfigPanel, hn as DashboardGridLayout, un as DashboardRenderer, Yn as DashboardWithConfig, Lt as DrillDownDrawer, wn as MetricCard, Sn as MetricWidget, Ft as ObjectDataTable, Tn as ObjectMetricWidget, Pn as ObjectPivotTable, Nn as PivotTable, Jn as WidgetConfigPanel, Xn as dashboardComponents };
|