@object-ui/plugin-dashboard 6.0.3 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/index.js +595 -532
- package/dist/index.umd.cjs +1 -1
- package/dist/packages/plugin-dashboard/src/DashboardRenderer.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/ObjectMetricWidget.d.ts +16 -0
- package/dist/packages/plugin-dashboard/src/ObjectMetricWidget.d.ts.map +1 -1
- package/dist/packages/plugin-dashboard/src/utils.d.ts +18 -0
- package/dist/packages/plugin-dashboard/src/utils.d.ts.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,32 +1,52 @@
|
|
|
1
|
-
import { ComponentRegistry as e,
|
|
2
|
-
import { SchemaRenderer as
|
|
3
|
-
import { createSafeTranslation as
|
|
4
|
-
import { Button as
|
|
5
|
-
import * as
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { AlertCircle as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
1
|
+
import { ComponentRegistry as e, compareToTrendLabelKey as t, computeDrillFilter as n, extractRecords as r, isDrillEnabled as i, resolveDateMacros as a, resolveDrillTitle as o, shiftFilterByCompareTo as s } from "@object-ui/core";
|
|
2
|
+
import { SchemaRenderer as c, SchemaRendererContext as l, useActionEngine as u, useDataScope as d, useDnd as f, useHasDndProvider as p, useObjectLabel as m } from "@object-ui/react";
|
|
3
|
+
import { createSafeTranslation as h, useObjectTranslation as g, useSafeFieldLabel as _ } from "@object-ui/i18n";
|
|
4
|
+
import { Button as v, Card as y, CardContent as b, CardHeader as x, CardTitle as S, Combobox as C, ConfigPanelRenderer as w, ConfigRow as T, DataEmptyState as E, Dialog as D, DialogContent as O, DialogHeader as k, DialogTitle as A, RefreshIndicator as j, Sheet as M, SheetContent as ee, SheetHeader as te, SheetTitle as ne, Skeleton as N, cn as P, getLazyIcon as F, useConfigDraft as I } from "@object-ui/components";
|
|
5
|
+
import * as L from "react";
|
|
6
|
+
import { Fragment as re, forwardRef as ie, useCallback as R, useContext as z, useEffect as B, useMemo as V, useRef as ae, useState as H } from "react";
|
|
7
|
+
import { AlertCircle as U, ArrowDownIcon as oe, ArrowUpIcon as W, Edit as se, GripVertical as ce, Loader2 as G, MinusIcon as le, RefreshCw as ue, Save as K, Settings as q, X as de } from "lucide-react";
|
|
8
|
+
import { DndContext as fe, PointerSensor as pe, closestCenter as me, useSensor as J, useSensors as he } from "@dnd-kit/core";
|
|
9
|
+
import { SortableContext as Y, arrayMove as ge, rectSortingStrategy as _e, useSortable as ve, verticalListSortingStrategy as ye } from "@dnd-kit/sortable";
|
|
10
|
+
import { CSS as be } from "@dnd-kit/utilities";
|
|
11
11
|
import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
|
|
12
|
-
import { ResponsiveGridLayout as
|
|
12
|
+
import { ResponsiveGridLayout as xe, useContainerWidth as Se } from "react-grid-layout";
|
|
13
13
|
import "react-grid-layout/css/styles.css";
|
|
14
|
-
import { formatCurrency as
|
|
14
|
+
import { formatCurrency as Ce, formatDate as we, formatPercent as Te, getCellRenderer as Ee, resolveCellRendererType as De } from "@object-ui/fields";
|
|
15
15
|
//#region src/utils.ts
|
|
16
16
|
function $(e) {
|
|
17
17
|
return typeof e == "object" && !!e && !Array.isArray(e) && e.provider === "object";
|
|
18
18
|
}
|
|
19
|
+
function Oe(e, t) {
|
|
20
|
+
if (t == null || e == null || typeof e != "number" || !Number.isFinite(e) || typeof t != "number" || !Number.isFinite(t)) return null;
|
|
21
|
+
if (t === 0) return e === 0 ? {
|
|
22
|
+
value: 0,
|
|
23
|
+
direction: "neutral"
|
|
24
|
+
} : {
|
|
25
|
+
value: 100,
|
|
26
|
+
direction: e > 0 ? "up" : "down"
|
|
27
|
+
};
|
|
28
|
+
let n = e - t;
|
|
29
|
+
if (n === 0) return {
|
|
30
|
+
value: 0,
|
|
31
|
+
direction: "neutral"
|
|
32
|
+
};
|
|
33
|
+
let r = Math.round(n / Math.abs(t) * 100);
|
|
34
|
+
return {
|
|
35
|
+
value: Math.abs(r),
|
|
36
|
+
direction: r > 0 ? "up" : "down"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
19
39
|
//#endregion
|
|
20
40
|
//#region src/DashboardRenderer.tsx
|
|
21
|
-
function
|
|
22
|
-
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } =
|
|
41
|
+
function ke({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
42
|
+
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } = ve({
|
|
23
43
|
id: e,
|
|
24
44
|
disabled: t
|
|
25
45
|
});
|
|
26
46
|
return /* @__PURE__ */ Z("div", {
|
|
27
47
|
ref: s,
|
|
28
48
|
style: {
|
|
29
|
-
transform:
|
|
49
|
+
transform: be.Transform.toString(c),
|
|
30
50
|
transition: l,
|
|
31
51
|
opacity: u ? .4 : 1,
|
|
32
52
|
...n ? {
|
|
@@ -41,19 +61,19 @@ function Ee({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
|
41
61
|
children: i
|
|
42
62
|
});
|
|
43
63
|
}
|
|
44
|
-
function
|
|
64
|
+
function Ae(e) {
|
|
45
65
|
return e ? F(e) : null;
|
|
46
66
|
}
|
|
47
|
-
function
|
|
67
|
+
function je(e) {
|
|
48
68
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
49
69
|
}
|
|
50
|
-
var
|
|
70
|
+
var Me = [
|
|
51
71
|
"hsl(var(--chart-1))",
|
|
52
72
|
"hsl(var(--chart-2))",
|
|
53
73
|
"hsl(var(--chart-3))",
|
|
54
74
|
"hsl(var(--chart-4))",
|
|
55
75
|
"hsl(var(--chart-5))"
|
|
56
|
-
],
|
|
76
|
+
], Ne = new Set([
|
|
57
77
|
"bar",
|
|
58
78
|
"horizontal-bar",
|
|
59
79
|
"line",
|
|
@@ -62,10 +82,10 @@ var ke = [
|
|
|
62
82
|
"donut",
|
|
63
83
|
"funnel"
|
|
64
84
|
]);
|
|
65
|
-
function
|
|
66
|
-
return
|
|
85
|
+
function Pe(e) {
|
|
86
|
+
return Ne.has(e) ? { enabled: !0 } : void 0;
|
|
67
87
|
}
|
|
68
|
-
var
|
|
88
|
+
var Fe = ie(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount: i, userActions: a, designMode: o, selectedWidgetId: s, onWidgetClick: l, onWidgetsReorder: d, modalHandler: f, scriptHandlers: p, hideHeaderText: h, ..._ }, C) => {
|
|
69
89
|
let w = (() => {
|
|
70
90
|
if (e.columns != null) return e.columns;
|
|
71
91
|
let t = e.widgets ?? [], n = 0;
|
|
@@ -74,73 +94,73 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
74
94
|
t > n && (n = t), (e.layout?.w ?? 0) > n && (n = e.layout.w);
|
|
75
95
|
}
|
|
76
96
|
return n > 4 ? 12 : 4;
|
|
77
|
-
})(), T = w, E = e.gap || 4, [D, O] =
|
|
97
|
+
})(), T = w, E = e.gap || 4, [D, O] = H(!1), [k, A] = H(!1), j = ae(null), { executeAction: M, engine: ee } = u({ actions: V(() => (e.header?.actions ?? []).map((e) => ({
|
|
78
98
|
name: e.actionUrl || e.label,
|
|
79
99
|
type: e.actionType || "url",
|
|
80
100
|
target: e.actionUrl,
|
|
81
101
|
label: e.label
|
|
82
|
-
})), [e.header?.actions]) }), { dashboardLabel:
|
|
83
|
-
let t =
|
|
84
|
-
return !U || !e.id || t === void 0 ? t :
|
|
85
|
-
}, [U,
|
|
86
|
-
let t =
|
|
87
|
-
return !U || !e.id ? t :
|
|
88
|
-
}, [U,
|
|
89
|
-
|
|
102
|
+
})), [e.header?.actions]) }), { dashboardLabel: te, dashboardDescription: ne, dashboardActionLabel: N, widgetTitle: F, widgetDescription: I, fieldLabel: L } = m(), { t: ie } = g(), z = R((e, t, n) => n && (!t || t === "value" || t === "count" || n === "count") ? ie(`report.aggregate.${n}`, { defaultValue: n }) : e ? L(e, t, t) : t, [ie, L]), U = e.name, oe = R((e) => U ? N(U, e.actionUrl || e.label, e.label) : e.label, [U, N]), W = R((e) => {
|
|
103
|
+
let t = je(e.title);
|
|
104
|
+
return !U || !e.id || t === void 0 ? t : F(U, e.id, t);
|
|
105
|
+
}, [U, F]), se = R((e) => {
|
|
106
|
+
let t = je(e.description);
|
|
107
|
+
return !U || !e.id ? t : I(U, e.id, t);
|
|
108
|
+
}, [U, I]);
|
|
109
|
+
B(() => {
|
|
90
110
|
let e = ee.getRunner();
|
|
91
|
-
if (
|
|
111
|
+
if (f && e.setModalHandler(f), p) for (let [t, n] of Object.entries(p)) e.registerScript(t, n);
|
|
92
112
|
}, [
|
|
93
113
|
ee,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
]),
|
|
114
|
+
f,
|
|
115
|
+
p
|
|
116
|
+
]), B(() => {
|
|
97
117
|
let e = () => A(window.innerWidth < 768);
|
|
98
118
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
99
119
|
}, []);
|
|
100
|
-
let
|
|
120
|
+
let ce = R(() => {
|
|
101
121
|
r && (O(!0), r(), setTimeout(() => O(!1), 600));
|
|
102
122
|
}, [r]);
|
|
103
|
-
|
|
104
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return j.current = setInterval(
|
|
123
|
+
B(() => {
|
|
124
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !r)) return j.current = setInterval(ce, e.refreshInterval * 1e3), () => {
|
|
105
125
|
j.current && clearInterval(j.current);
|
|
106
126
|
};
|
|
107
127
|
}, [
|
|
108
128
|
e.refreshInterval,
|
|
109
129
|
r,
|
|
110
|
-
|
|
130
|
+
ce
|
|
111
131
|
]);
|
|
112
|
-
let
|
|
113
|
-
!
|
|
114
|
-
}, [
|
|
115
|
-
if (!
|
|
132
|
+
let G = R((e, t) => {
|
|
133
|
+
!o || !l || !t || (e.stopPropagation(), l(t));
|
|
134
|
+
}, [o, l]), le = R((t, n, r) => {
|
|
135
|
+
if (!o || !l) return;
|
|
116
136
|
let i = e.widgets || [];
|
|
117
|
-
if (t.key === "Enter" || t.key === " ") t.preventDefault(),
|
|
137
|
+
if (t.key === "Enter" || t.key === " ") t.preventDefault(), l(n ?? null);
|
|
118
138
|
else if (t.key === "ArrowRight" || t.key === "ArrowDown") {
|
|
119
139
|
t.preventDefault();
|
|
120
140
|
let e = r + 1 < i.length ? i[r + 1] : null;
|
|
121
|
-
e?.id &&
|
|
141
|
+
e?.id && l(e.id);
|
|
122
142
|
} else if (t.key === "ArrowLeft" || t.key === "ArrowUp") {
|
|
123
143
|
t.preventDefault();
|
|
124
144
|
let e = r - 1 >= 0 ? i[r - 1] : null;
|
|
125
|
-
e?.id &&
|
|
126
|
-
} else t.key === "Escape" && (t.preventDefault(),
|
|
145
|
+
e?.id && l(e.id);
|
|
146
|
+
} else t.key === "Escape" && (t.preventDefault(), l(null));
|
|
127
147
|
}, [
|
|
128
|
-
|
|
129
|
-
|
|
148
|
+
o,
|
|
149
|
+
l,
|
|
130
150
|
e.widgets
|
|
131
|
-
]),
|
|
132
|
-
!
|
|
133
|
-
}, [
|
|
134
|
-
if (!
|
|
151
|
+
]), K = R((e) => {
|
|
152
|
+
!o || !l || e.target === e.currentTarget && l(null);
|
|
153
|
+
}, [o, l]), q = !!(o && d), de = he(J(pe, { activationConstraint: { distance: 5 } })), ve = R((t) => {
|
|
154
|
+
if (!q) return;
|
|
135
155
|
let { active: n, over: r } = t;
|
|
136
156
|
if (!r || n.id === r.id) return;
|
|
137
157
|
let i = e.widgets ?? [], a = i.findIndex((e) => e.id === n.id), o = i.findIndex((e) => e.id === r.id);
|
|
138
|
-
a < 0 || o < 0 || d?.(
|
|
158
|
+
a < 0 || o < 0 || d?.(ge(i, a, o));
|
|
139
159
|
}, [
|
|
140
|
-
|
|
160
|
+
q,
|
|
141
161
|
e.widgets,
|
|
142
162
|
d
|
|
143
|
-
]),
|
|
163
|
+
]), be = (e, t, r) => {
|
|
144
164
|
let i = e.layout ? {
|
|
145
165
|
...e.layout,
|
|
146
166
|
w: Math.min(e.layout.w, T)
|
|
@@ -173,7 +193,8 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
173
193
|
prefix: n.prefix,
|
|
174
194
|
suffix: n.suffix,
|
|
175
195
|
drillDown: n.drillDown ?? { enabled: !0 },
|
|
176
|
-
title: n.label || W(e) || ""
|
|
196
|
+
title: n.label || W(e) || "",
|
|
197
|
+
compareTo: e.compareTo
|
|
177
198
|
};
|
|
178
199
|
}
|
|
179
200
|
if ((t === "gauge" || t === "solid-gauge") && e.object) {
|
|
@@ -196,51 +217,65 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
196
217
|
currency: n.currency,
|
|
197
218
|
prefix: n.prefix,
|
|
198
219
|
suffix: n.suffix,
|
|
199
|
-
invert: n.invert
|
|
220
|
+
invert: n.invert,
|
|
221
|
+
compareTo: e.compareTo
|
|
200
222
|
};
|
|
201
223
|
}
|
|
202
224
|
let r = t && {}[t] || t;
|
|
203
225
|
if (r === "bar" || r === "horizontal-bar" || r === "line" || r === "area" || r === "pie" || r === "donut" || r === "scatter" || r === "funnel") {
|
|
204
226
|
let t = e.data || n.data, i = e.categoryField || n.xField || "name", a = e.valueField || n.yField || "value";
|
|
205
227
|
if ($(t)) {
|
|
206
|
-
let o = t.aggregate, s =
|
|
228
|
+
let o = t.aggregate, s = (() => {
|
|
229
|
+
let t = e.categoryField || o?.groupBy;
|
|
230
|
+
if (t) return e.categoryGranularity && typeof t == "string" ? {
|
|
231
|
+
field: t,
|
|
232
|
+
dateGranularity: e.categoryGranularity
|
|
233
|
+
} : t;
|
|
234
|
+
})(), c = o ? {
|
|
207
235
|
field: e.valueField || o.field,
|
|
208
236
|
function: e.aggregate || o.function,
|
|
209
|
-
groupBy:
|
|
210
|
-
} : void 0,
|
|
237
|
+
groupBy: s
|
|
238
|
+
} : void 0, l = c?.field || a, u = e.object || t.object;
|
|
211
239
|
return {
|
|
212
240
|
type: "object-chart",
|
|
213
241
|
chartType: r,
|
|
214
|
-
objectName:
|
|
215
|
-
aggregate:
|
|
242
|
+
objectName: u,
|
|
243
|
+
aggregate: c,
|
|
244
|
+
filter: t.filter || e.filter,
|
|
216
245
|
xAxisKey: i,
|
|
217
246
|
series: [{
|
|
218
|
-
dataKey:
|
|
219
|
-
label:
|
|
247
|
+
dataKey: l,
|
|
248
|
+
label: z(u, l, c?.function)
|
|
220
249
|
}],
|
|
221
|
-
colors:
|
|
222
|
-
drillDown: n.drillDown ??
|
|
250
|
+
colors: Me,
|
|
251
|
+
drillDown: n.drillDown ?? Pe(r),
|
|
252
|
+
compareTo: e.compareTo,
|
|
223
253
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
224
254
|
};
|
|
225
255
|
}
|
|
226
256
|
if (!t && e.object) {
|
|
227
|
-
let t = e.
|
|
257
|
+
let t = e.categoryField || "name", a = e.categoryGranularity ? {
|
|
258
|
+
field: t,
|
|
259
|
+
dateGranularity: e.categoryGranularity
|
|
260
|
+
} : t, o = e.aggregate ? {
|
|
228
261
|
field: e.valueField || "value",
|
|
229
262
|
function: e.aggregate,
|
|
230
|
-
groupBy:
|
|
231
|
-
} : void 0,
|
|
263
|
+
groupBy: a
|
|
264
|
+
} : void 0, s = e.valueField || "value";
|
|
232
265
|
return {
|
|
233
266
|
type: "object-chart",
|
|
234
267
|
chartType: r,
|
|
235
268
|
objectName: e.object,
|
|
236
|
-
aggregate:
|
|
269
|
+
aggregate: o,
|
|
270
|
+
filter: e.filter,
|
|
237
271
|
xAxisKey: i,
|
|
238
272
|
series: [{
|
|
239
|
-
dataKey:
|
|
240
|
-
label:
|
|
273
|
+
dataKey: s,
|
|
274
|
+
label: z(e.object, s, e.aggregate)
|
|
241
275
|
}],
|
|
242
|
-
colors:
|
|
243
|
-
drillDown: n.drillDown ??
|
|
276
|
+
colors: Me,
|
|
277
|
+
drillDown: n.drillDown ?? Pe(r),
|
|
278
|
+
compareTo: e.compareTo,
|
|
244
279
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
245
280
|
};
|
|
246
281
|
}
|
|
@@ -251,9 +286,9 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
251
286
|
xAxisKey: i,
|
|
252
287
|
series: [{
|
|
253
288
|
dataKey: a,
|
|
254
|
-
label:
|
|
289
|
+
label: z(e.object, a, e.aggregate)
|
|
255
290
|
}],
|
|
256
|
-
colors:
|
|
291
|
+
colors: Me,
|
|
257
292
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
258
293
|
};
|
|
259
294
|
}
|
|
@@ -368,39 +403,39 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
368
403
|
...e,
|
|
369
404
|
...n
|
|
370
405
|
};
|
|
371
|
-
})(),
|
|
406
|
+
})(), l = e.type === "metric", u = W(e), d = se(e), f = e.id || u || `widget-${t}`, p = o && s === e.id, m = o ? {
|
|
372
407
|
"data-testid": `dashboard-preview-widget-${e.id}`,
|
|
373
408
|
"data-widget-id": e.id,
|
|
374
409
|
role: "button",
|
|
375
410
|
tabIndex: 0,
|
|
376
411
|
"aria-selected": p,
|
|
377
412
|
"aria-label": `Widget: ${u || `Widget ${t + 1}`}`,
|
|
378
|
-
onClick: (t) =>
|
|
379
|
-
onKeyDown: (n) =>
|
|
380
|
-
} : {}, h =
|
|
413
|
+
onClick: (t) => G(t, e.id),
|
|
414
|
+
onKeyDown: (n) => le(n, e.id, t)
|
|
415
|
+
} : {}, h = o ? P("cursor-pointer rounded-lg transition-all outline-none", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", p ? "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, g = !k && i && !q ? {
|
|
381
416
|
gridColumn: `span ${i.w}`,
|
|
382
417
|
gridRow: `span ${i.h}`
|
|
383
|
-
} : void 0,
|
|
384
|
-
className: P("h-full w-full",
|
|
418
|
+
} : void 0, _ = l ? /* @__PURE__ */ Q("div", {
|
|
419
|
+
className: P("h-full w-full", o && "relative", h),
|
|
385
420
|
style: g,
|
|
386
421
|
...m,
|
|
387
|
-
children: [/* @__PURE__ */ Z(
|
|
422
|
+
children: [/* @__PURE__ */ Z(c, {
|
|
388
423
|
schema: a,
|
|
389
|
-
className: P("h-full w-full",
|
|
424
|
+
className: P("h-full w-full", o && "pointer-events-none"),
|
|
390
425
|
dataSource: n
|
|
391
|
-
}),
|
|
426
|
+
}), o && /* @__PURE__ */ Z("div", {
|
|
392
427
|
className: "absolute inset-0 z-10",
|
|
393
428
|
"aria-hidden": "true",
|
|
394
429
|
"data-testid": "widget-click-overlay"
|
|
395
430
|
})]
|
|
396
|
-
}) : /* @__PURE__ */ Q(
|
|
397
|
-
className: P("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full",
|
|
431
|
+
}) : /* @__PURE__ */ Q(y, {
|
|
432
|
+
className: P("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", r && "w-full", o && "relative", h),
|
|
398
433
|
style: g,
|
|
399
434
|
...m,
|
|
400
435
|
children: [
|
|
401
|
-
u && /* @__PURE__ */ Q(
|
|
436
|
+
u && /* @__PURE__ */ Q(x, {
|
|
402
437
|
className: "pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6",
|
|
403
|
-
children: [/* @__PURE__ */ Z(
|
|
438
|
+
children: [/* @__PURE__ */ Z(S, {
|
|
404
439
|
className: "text-sm sm:text-base font-medium tracking-tight truncate",
|
|
405
440
|
title: u,
|
|
406
441
|
children: u
|
|
@@ -409,53 +444,53 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
409
444
|
children: d
|
|
410
445
|
})]
|
|
411
446
|
}),
|
|
412
|
-
/* @__PURE__ */ Z(
|
|
447
|
+
/* @__PURE__ */ Z(b, {
|
|
413
448
|
className: "p-0",
|
|
414
449
|
children: /* @__PURE__ */ Z("div", {
|
|
415
|
-
className: P("h-full w-full", "p-3 sm:p-4 md:p-6",
|
|
416
|
-
children: /* @__PURE__ */ Z(
|
|
450
|
+
className: P("h-full w-full", "p-3 sm:p-4 md:p-6", o && "pointer-events-none"),
|
|
451
|
+
children: /* @__PURE__ */ Z(c, {
|
|
417
452
|
schema: a,
|
|
418
453
|
dataSource: n
|
|
419
454
|
})
|
|
420
455
|
})
|
|
421
456
|
}),
|
|
422
|
-
|
|
457
|
+
o && /* @__PURE__ */ Z("div", {
|
|
423
458
|
className: "absolute inset-0 z-10",
|
|
424
459
|
"aria-hidden": "true",
|
|
425
460
|
"data-testid": "widget-click-overlay"
|
|
426
461
|
})
|
|
427
462
|
]
|
|
428
463
|
});
|
|
429
|
-
return
|
|
464
|
+
return q && e.id ? /* @__PURE__ */ Z(ke, {
|
|
430
465
|
id: e.id,
|
|
431
466
|
gridSpan: !k && i ? {
|
|
432
467
|
w: i.w,
|
|
433
468
|
h: i.h
|
|
434
469
|
} : void 0,
|
|
435
|
-
children:
|
|
436
|
-
}, f) : /* @__PURE__ */ Z(
|
|
437
|
-
},
|
|
470
|
+
children: _
|
|
471
|
+
}, f) : /* @__PURE__ */ Z(re, { children: _ }, f);
|
|
472
|
+
}, X = e.header && /* @__PURE__ */ Q("div", {
|
|
438
473
|
className: "col-span-full mb-4",
|
|
439
474
|
children: [
|
|
440
|
-
!
|
|
475
|
+
!h && e.header.showTitle !== !1 && e.title && /* @__PURE__ */ Z("h2", {
|
|
441
476
|
className: "text-lg font-semibold tracking-tight",
|
|
442
|
-
children: U ?
|
|
477
|
+
children: U ? te({
|
|
443
478
|
name: U,
|
|
444
|
-
label:
|
|
445
|
-
}) :
|
|
479
|
+
label: je(e.title)
|
|
480
|
+
}) : je(e.title)
|
|
446
481
|
}),
|
|
447
|
-
!
|
|
482
|
+
!h && e.header.showDescription !== !1 && e.description && /* @__PURE__ */ Z("p", {
|
|
448
483
|
className: "text-sm text-muted-foreground mt-1",
|
|
449
|
-
children: U ?
|
|
484
|
+
children: U ? ne({
|
|
450
485
|
name: U,
|
|
451
|
-
description:
|
|
452
|
-
}) :
|
|
486
|
+
description: je(e.description)
|
|
487
|
+
}) : je(e.description)
|
|
453
488
|
}),
|
|
454
489
|
e.header.actions && e.header.actions.length > 0 && /* @__PURE__ */ Z("div", {
|
|
455
490
|
className: "flex gap-2 mt-3",
|
|
456
491
|
children: e.header.actions.map((e, t) => {
|
|
457
|
-
let n =
|
|
458
|
-
return /* @__PURE__ */ Q(
|
|
492
|
+
let n = Ae(e.icon);
|
|
493
|
+
return /* @__PURE__ */ Q(v, {
|
|
459
494
|
variant: "outline",
|
|
460
495
|
size: "sm",
|
|
461
496
|
onClick: async () => {
|
|
@@ -485,87 +520,87 @@ var Me = L(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount:
|
|
|
485
520
|
children: [i.toLocaleString(), " records"]
|
|
486
521
|
}), Se = a ? JSON.stringify(a) : void 0, Ce = r && /* @__PURE__ */ Q("div", {
|
|
487
522
|
className: P("flex items-center justify-end gap-3 mb-2", !k && "col-span-full"),
|
|
488
|
-
children: [xe, /* @__PURE__ */ Q(
|
|
523
|
+
children: [xe, /* @__PURE__ */ Q(v, {
|
|
489
524
|
variant: "outline",
|
|
490
525
|
size: "sm",
|
|
491
|
-
onClick:
|
|
526
|
+
onClick: ce,
|
|
492
527
|
disabled: D,
|
|
493
528
|
"aria-label": "Refresh dashboard",
|
|
494
|
-
children: [/* @__PURE__ */ Z(
|
|
529
|
+
children: [/* @__PURE__ */ Z(ue, { className: P("h-4 w-4 mr-2", D && "animate-spin") }), D ? "Refreshing…" : "Refresh All"]
|
|
495
530
|
})]
|
|
496
|
-
}), we =
|
|
531
|
+
}), we = V(() => (e.widgets ?? []).map((e) => e.id).filter((e) => !!e), [e.widgets]), Te = V(() => (e.widgets ?? []).filter((e) => e.type === "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]), Ee = V(() => (e.widgets ?? []).filter((e) => e.type !== "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]);
|
|
497
532
|
if (k) {
|
|
498
533
|
let n = e.widgets?.filter((e) => e.type === "metric") || [], r = e.widgets?.filter((e) => e.type !== "metric") || [], i = /* @__PURE__ */ Q("div", {
|
|
499
534
|
ref: C,
|
|
500
535
|
className: P("flex flex-col gap-4 px-4", t),
|
|
501
536
|
"data-user-actions": Se,
|
|
502
|
-
onClick:
|
|
503
|
-
...
|
|
537
|
+
onClick: K,
|
|
538
|
+
..._,
|
|
504
539
|
children: [
|
|
505
|
-
|
|
540
|
+
X,
|
|
506
541
|
Ce,
|
|
507
542
|
n.length > 0 && /* @__PURE__ */ Z("div", {
|
|
508
543
|
className: "grid grid-cols-2 gap-3",
|
|
509
|
-
onClick:
|
|
510
|
-
children: /* @__PURE__ */ Z(
|
|
544
|
+
onClick: K,
|
|
545
|
+
children: /* @__PURE__ */ Z(Y, {
|
|
511
546
|
items: Te,
|
|
512
|
-
strategy:
|
|
513
|
-
disabled: !
|
|
514
|
-
children: n.map((e, t) =>
|
|
547
|
+
strategy: _e,
|
|
548
|
+
disabled: !q,
|
|
549
|
+
children: n.map((e, t) => be(e, t))
|
|
515
550
|
})
|
|
516
551
|
}),
|
|
517
552
|
r.length > 0 && /* @__PURE__ */ Z("div", {
|
|
518
553
|
className: "flex flex-col gap-4",
|
|
519
|
-
onClick:
|
|
520
|
-
children: /* @__PURE__ */ Z(
|
|
521
|
-
items:
|
|
522
|
-
strategy:
|
|
523
|
-
disabled: !
|
|
524
|
-
children: r.map((e, t) =>
|
|
554
|
+
onClick: K,
|
|
555
|
+
children: /* @__PURE__ */ Z(Y, {
|
|
556
|
+
items: Ee,
|
|
557
|
+
strategy: ye,
|
|
558
|
+
disabled: !q,
|
|
559
|
+
children: r.map((e, t) => be(e, t, !0))
|
|
525
560
|
})
|
|
526
561
|
})
|
|
527
562
|
]
|
|
528
563
|
});
|
|
529
|
-
return
|
|
530
|
-
sensors:
|
|
531
|
-
collisionDetection:
|
|
532
|
-
onDragEnd:
|
|
564
|
+
return q ? /* @__PURE__ */ Z(fe, {
|
|
565
|
+
sensors: de,
|
|
566
|
+
collisionDetection: me,
|
|
567
|
+
onDragEnd: ve,
|
|
533
568
|
children: i
|
|
534
569
|
}) : i;
|
|
535
570
|
}
|
|
536
|
-
let
|
|
571
|
+
let De = e.columns != null || w !== 4, Oe = /* @__PURE__ */ Q("div", {
|
|
537
572
|
ref: C,
|
|
538
|
-
className: P("grid auto-rows-min", !
|
|
573
|
+
className: P("grid auto-rows-min", !De && "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", t),
|
|
539
574
|
style: {
|
|
540
|
-
...
|
|
575
|
+
...De && { gridTemplateColumns: `repeat(${T}, minmax(0, 1fr))` },
|
|
541
576
|
gap: `${E * .25}rem`
|
|
542
577
|
},
|
|
543
578
|
"data-user-actions": Se,
|
|
544
|
-
onClick:
|
|
545
|
-
...
|
|
579
|
+
onClick: K,
|
|
580
|
+
..._,
|
|
546
581
|
children: [
|
|
547
|
-
|
|
582
|
+
X,
|
|
548
583
|
Ce,
|
|
549
|
-
/* @__PURE__ */ Z(
|
|
584
|
+
/* @__PURE__ */ Z(Y, {
|
|
550
585
|
items: we,
|
|
551
|
-
strategy:
|
|
552
|
-
disabled: !
|
|
553
|
-
children: e.widgets?.map((e, t) =>
|
|
586
|
+
strategy: _e,
|
|
587
|
+
disabled: !q,
|
|
588
|
+
children: e.widgets?.map((e, t) => be(e, t))
|
|
554
589
|
})
|
|
555
590
|
]
|
|
556
591
|
});
|
|
557
|
-
return
|
|
558
|
-
sensors:
|
|
559
|
-
collisionDetection:
|
|
560
|
-
onDragEnd:
|
|
561
|
-
children:
|
|
562
|
-
}) :
|
|
592
|
+
return q ? /* @__PURE__ */ Z(fe, {
|
|
593
|
+
sensors: de,
|
|
594
|
+
collisionDetection: me,
|
|
595
|
+
onDragEnd: ve,
|
|
596
|
+
children: Oe
|
|
597
|
+
}) : Oe;
|
|
563
598
|
});
|
|
564
599
|
//#endregion
|
|
565
600
|
//#region src/DashboardGridLayout.tsx
|
|
566
|
-
function
|
|
567
|
-
let t =
|
|
568
|
-
return
|
|
601
|
+
function Ie({ editMode: e }) {
|
|
602
|
+
let t = f();
|
|
603
|
+
return L.useEffect(() => {
|
|
569
604
|
if (e) return t.startDrag({
|
|
570
605
|
id: "dashboard-layout",
|
|
571
606
|
type: "dashboard-widget",
|
|
@@ -576,14 +611,14 @@ function Ne({ editMode: e }) {
|
|
|
576
611
|
t.endDrag("dashboard");
|
|
577
612
|
}, [e, t]), null;
|
|
578
613
|
}
|
|
579
|
-
var
|
|
614
|
+
var Le = [
|
|
580
615
|
"hsl(var(--chart-1))",
|
|
581
616
|
"hsl(var(--chart-2))",
|
|
582
617
|
"hsl(var(--chart-3))",
|
|
583
618
|
"hsl(var(--chart-4))",
|
|
584
619
|
"hsl(var(--chart-5))"
|
|
585
620
|
];
|
|
586
|
-
function
|
|
621
|
+
function Re(e, t) {
|
|
587
622
|
if (!e.widgets?.length) return e;
|
|
588
623
|
let n = new Map(t.map((e) => [e.i, e])), r = e.widgets.map((e, t) => {
|
|
589
624
|
let r = e.id || `widget-${t}`, i = n.get(r);
|
|
@@ -602,7 +637,7 @@ function Fe(e, t) {
|
|
|
602
637
|
widgets: r
|
|
603
638
|
};
|
|
604
639
|
}
|
|
605
|
-
function
|
|
640
|
+
function ze(e) {
|
|
606
641
|
return { lg: e.widgets?.map((e, t) => ({
|
|
607
642
|
i: e.id || `widget-${t}`,
|
|
608
643
|
x: e.layout?.x ?? t % 4 * 3,
|
|
@@ -611,40 +646,40 @@ function Ie(e) {
|
|
|
611
646
|
h: e.layout?.h ?? 4
|
|
612
647
|
})) || [] };
|
|
613
648
|
}
|
|
614
|
-
var
|
|
615
|
-
let { width: a, containerRef:
|
|
616
|
-
i && (
|
|
649
|
+
var Be = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRefresh: i }) => {
|
|
650
|
+
let { width: a, containerRef: o, mounted: s } = Se(), [l, u] = L.useState(!1), [d, f] = L.useState(!1), m = p(), h = L.useRef(null), g = L.useCallback(() => {
|
|
651
|
+
i && (f(!0), i(), setTimeout(() => f(!1), 600));
|
|
617
652
|
}, [i]);
|
|
618
|
-
|
|
619
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !i)) return h.current = setInterval(
|
|
653
|
+
L.useEffect(() => {
|
|
654
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !i)) return h.current = setInterval(g, e.refreshInterval * 1e3), () => {
|
|
620
655
|
h.current && clearInterval(h.current);
|
|
621
656
|
};
|
|
622
657
|
}, [
|
|
623
658
|
e.refreshInterval,
|
|
624
659
|
i,
|
|
625
|
-
|
|
660
|
+
g
|
|
626
661
|
]);
|
|
627
|
-
let [
|
|
662
|
+
let [_, C] = L.useState(() => ze(e)), w = L.useMemo(() => JSON.stringify(e.widgets?.map((e, t) => ({
|
|
628
663
|
i: e.id || `widget-${t}`,
|
|
629
664
|
x: e.layout?.x,
|
|
630
665
|
y: e.layout?.y,
|
|
631
666
|
w: e.layout?.w,
|
|
632
667
|
h: e.layout?.h
|
|
633
668
|
})) ?? []), [e.widgets]);
|
|
634
|
-
|
|
635
|
-
C(
|
|
669
|
+
L.useEffect(() => {
|
|
670
|
+
C(ze(e));
|
|
636
671
|
}, [w]);
|
|
637
|
-
let T =
|
|
672
|
+
let T = L.useCallback((e, t) => {
|
|
638
673
|
C(t), n?.(e);
|
|
639
|
-
}, [n]), E =
|
|
640
|
-
r ? r(
|
|
674
|
+
}, [n]), E = L.useCallback(() => {
|
|
675
|
+
r ? r(Re(e, _.lg)) : globalThis.process?.env?.NODE_ENV !== "production" && console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."), u(!1);
|
|
641
676
|
}, [
|
|
642
677
|
r,
|
|
643
678
|
e,
|
|
644
|
-
|
|
645
|
-
]), D =
|
|
646
|
-
C(
|
|
647
|
-
}, [e]), O =
|
|
679
|
+
_
|
|
680
|
+
]), D = L.useCallback(() => {
|
|
681
|
+
C(ze(e));
|
|
682
|
+
}, [e]), O = L.useCallback((e) => {
|
|
648
683
|
if (e.component) return e.component;
|
|
649
684
|
let t = e.type, n = e.options || {};
|
|
650
685
|
if (t === "bar" || t === "horizontal-bar" || t === "line" || t === "area" || t === "pie" || t === "donut" || t === "scatter" || t === "funnel") {
|
|
@@ -662,7 +697,7 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
662
697
|
aggregate: o,
|
|
663
698
|
xAxisKey: i,
|
|
664
699
|
series: [{ dataKey: s }],
|
|
665
|
-
colors:
|
|
700
|
+
colors: Le,
|
|
666
701
|
className: "h-full"
|
|
667
702
|
};
|
|
668
703
|
}
|
|
@@ -679,7 +714,7 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
679
714
|
aggregate: n,
|
|
680
715
|
xAxisKey: i,
|
|
681
716
|
series: [{ dataKey: e.valueField || "value" }],
|
|
682
|
-
colors:
|
|
717
|
+
colors: Le,
|
|
683
718
|
className: "h-full"
|
|
684
719
|
};
|
|
685
720
|
}
|
|
@@ -689,7 +724,7 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
689
724
|
data: Array.isArray(r) ? r : r?.items || [],
|
|
690
725
|
xAxisKey: i,
|
|
691
726
|
series: [{ dataKey: a }],
|
|
692
|
-
colors:
|
|
727
|
+
colors: Le,
|
|
693
728
|
className: "h-full"
|
|
694
729
|
};
|
|
695
730
|
}
|
|
@@ -749,11 +784,11 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
749
784
|
};
|
|
750
785
|
}, []);
|
|
751
786
|
return /* @__PURE__ */ Q("div", {
|
|
752
|
-
ref:
|
|
787
|
+
ref: o,
|
|
753
788
|
className: P("w-full", t),
|
|
754
789
|
"data-testid": "grid-layout",
|
|
755
790
|
children: [
|
|
756
|
-
m && /* @__PURE__ */ Z(
|
|
791
|
+
m && /* @__PURE__ */ Z(Ie, { editMode: l }),
|
|
757
792
|
/* @__PURE__ */ Q("div", {
|
|
758
793
|
className: "mb-4 flex items-center justify-between",
|
|
759
794
|
children: [/* @__PURE__ */ Z("h2", {
|
|
@@ -762,43 +797,43 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
762
797
|
}), /* @__PURE__ */ Z("div", {
|
|
763
798
|
className: "flex gap-2",
|
|
764
799
|
children: l ? /* @__PURE__ */ Q(X, { children: [
|
|
765
|
-
/* @__PURE__ */ Q(
|
|
800
|
+
/* @__PURE__ */ Q(v, {
|
|
766
801
|
onClick: E,
|
|
767
802
|
size: "sm",
|
|
768
803
|
variant: "default",
|
|
769
|
-
children: [/* @__PURE__ */ Z(
|
|
804
|
+
children: [/* @__PURE__ */ Z(K, { className: "h-4 w-4 mr-2" }), "Save Layout"]
|
|
770
805
|
}),
|
|
771
|
-
/* @__PURE__ */ Q(
|
|
806
|
+
/* @__PURE__ */ Q(v, {
|
|
772
807
|
onClick: D,
|
|
773
808
|
size: "sm",
|
|
774
809
|
variant: "outline",
|
|
775
|
-
children: [/* @__PURE__ */ Z(
|
|
810
|
+
children: [/* @__PURE__ */ Z(de, { className: "h-4 w-4 mr-2" }), "Reset"]
|
|
776
811
|
}),
|
|
777
|
-
/* @__PURE__ */ Z(
|
|
812
|
+
/* @__PURE__ */ Z(v, {
|
|
778
813
|
onClick: () => u(!1),
|
|
779
814
|
size: "sm",
|
|
780
815
|
variant: "ghost",
|
|
781
816
|
children: "Cancel"
|
|
782
817
|
})
|
|
783
|
-
] }) : /* @__PURE__ */ Q(X, { children: [i && /* @__PURE__ */ Q(
|
|
784
|
-
onClick:
|
|
818
|
+
] }) : /* @__PURE__ */ Q(X, { children: [i && /* @__PURE__ */ Q(v, {
|
|
819
|
+
onClick: g,
|
|
785
820
|
size: "sm",
|
|
786
821
|
variant: "outline",
|
|
787
|
-
disabled:
|
|
822
|
+
disabled: d,
|
|
788
823
|
"aria-label": "Refresh dashboard",
|
|
789
|
-
children: [/* @__PURE__ */ Z(
|
|
790
|
-
}), /* @__PURE__ */ Q(
|
|
824
|
+
children: [/* @__PURE__ */ Z(ue, { className: P("h-4 w-4 mr-2", d && "animate-spin") }), d ? "Refreshing…" : "Refresh All"]
|
|
825
|
+
}), /* @__PURE__ */ Q(v, {
|
|
791
826
|
onClick: () => u(!0),
|
|
792
827
|
size: "sm",
|
|
793
828
|
variant: "outline",
|
|
794
|
-
children: [/* @__PURE__ */ Z(
|
|
829
|
+
children: [/* @__PURE__ */ Z(se, { className: "h-4 w-4 mr-2" }), "Edit Layout"]
|
|
795
830
|
})] })
|
|
796
831
|
})]
|
|
797
832
|
}),
|
|
798
|
-
|
|
833
|
+
s && /* @__PURE__ */ Z(xe, {
|
|
799
834
|
className: "layout",
|
|
800
835
|
width: a,
|
|
801
|
-
layouts:
|
|
836
|
+
layouts: _,
|
|
802
837
|
breakpoints: {
|
|
803
838
|
lg: 1200,
|
|
804
839
|
md: 996,
|
|
@@ -828,28 +863,28 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
828
863
|
className: "h-full w-full relative",
|
|
829
864
|
children: [l && /* @__PURE__ */ Z("div", {
|
|
830
865
|
className: "drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border",
|
|
831
|
-
children: /* @__PURE__ */ Z(
|
|
832
|
-
}), /* @__PURE__ */ Z(
|
|
866
|
+
children: /* @__PURE__ */ Z(ce, { className: "h-4 w-4" })
|
|
867
|
+
}), /* @__PURE__ */ Z(c, {
|
|
833
868
|
schema: r,
|
|
834
869
|
className: "h-full w-full"
|
|
835
870
|
})]
|
|
836
|
-
}) : /* @__PURE__ */ Q(
|
|
871
|
+
}) : /* @__PURE__ */ Q(y, {
|
|
837
872
|
className: P("h-full overflow-hidden border-border/50 shadow-sm transition-all", "bg-card/50 backdrop-blur-sm", l && "ring-2 ring-primary/20"),
|
|
838
|
-
children: [e.title && /* @__PURE__ */ Q(
|
|
873
|
+
children: [e.title && /* @__PURE__ */ Q(x, {
|
|
839
874
|
className: "pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between",
|
|
840
|
-
children: [/* @__PURE__ */ Z(
|
|
875
|
+
children: [/* @__PURE__ */ Z(S, {
|
|
841
876
|
className: "text-base font-medium tracking-tight truncate",
|
|
842
877
|
title: e.title,
|
|
843
878
|
children: e.title
|
|
844
879
|
}), l && /* @__PURE__ */ Z("div", {
|
|
845
880
|
className: "drag-handle cursor-move p-1 hover:bg-muted/40 rounded",
|
|
846
|
-
children: /* @__PURE__ */ Z(
|
|
881
|
+
children: /* @__PURE__ */ Z(ce, { className: "h-4 w-4" })
|
|
847
882
|
})]
|
|
848
|
-
}), /* @__PURE__ */ Z(
|
|
883
|
+
}), /* @__PURE__ */ Z(b, {
|
|
849
884
|
className: "p-0 h-full",
|
|
850
885
|
children: /* @__PURE__ */ Z("div", {
|
|
851
886
|
className: P("h-full w-full overflow-auto p-4"),
|
|
852
|
-
children: /* @__PURE__ */ Z(
|
|
887
|
+
children: /* @__PURE__ */ Z(c, { schema: r })
|
|
853
888
|
})
|
|
854
889
|
})]
|
|
855
890
|
})
|
|
@@ -858,7 +893,7 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
858
893
|
})
|
|
859
894
|
]
|
|
860
895
|
});
|
|
861
|
-
},
|
|
896
|
+
}, Ve = h({
|
|
862
897
|
"dashboard.trend.vsLastQuarter": "vs last quarter",
|
|
863
898
|
"dashboard.trend.vsLastMonth": "vs last month",
|
|
864
899
|
"dashboard.trend.vsLastWeek": "vs last week",
|
|
@@ -866,7 +901,7 @@ var Le = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
866
901
|
"dashboard.trend.vsYesterday": "vs yesterday",
|
|
867
902
|
"dashboard.trend.vsPreviousPeriod": "vs previous period"
|
|
868
903
|
}, "dashboard.trend.vsLastQuarter");
|
|
869
|
-
function
|
|
904
|
+
function He(e) {
|
|
870
905
|
switch (e.trim().toLowerCase().replace(/\s+/g, " ")) {
|
|
871
906
|
case "vs last quarter":
|
|
872
907
|
case "vs previous quarter": return "dashboard.trend.vsLastQuarter";
|
|
@@ -882,11 +917,11 @@ function ze(e) {
|
|
|
882
917
|
default: return;
|
|
883
918
|
}
|
|
884
919
|
}
|
|
885
|
-
function
|
|
920
|
+
function Ue(e, t, n) {
|
|
886
921
|
if (e == null) return "";
|
|
887
922
|
if (typeof e == "string") {
|
|
888
923
|
let r = Number(e);
|
|
889
|
-
return !isFinite(r) || e.trim() === "" ? e :
|
|
924
|
+
return !isFinite(r) || e.trim() === "" ? e : Ue(r, t, n);
|
|
890
925
|
}
|
|
891
926
|
if (!isFinite(e)) return String(e);
|
|
892
927
|
let r = {
|
|
@@ -913,10 +948,10 @@ function Be(e, t, n) {
|
|
|
913
948
|
maximumFractionDigits: c
|
|
914
949
|
}).format(e);
|
|
915
950
|
}
|
|
916
|
-
function
|
|
951
|
+
function We(e) {
|
|
917
952
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
918
953
|
}
|
|
919
|
-
var
|
|
954
|
+
var Ge = {
|
|
920
955
|
default: "bg-muted text-muted-foreground",
|
|
921
956
|
blue: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
922
957
|
teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
|
|
@@ -925,18 +960,18 @@ var He = {
|
|
|
925
960
|
success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
|
|
926
961
|
warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
|
|
927
962
|
danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
|
|
928
|
-
},
|
|
929
|
-
let h =
|
|
930
|
-
let e =
|
|
963
|
+
}, Ke = ({ 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, ...m }) => {
|
|
964
|
+
let h = Ge[c] || Ge.default, { t: g } = Ve(), _ = V(() => {
|
|
965
|
+
let e = We(a) || We(n?.label);
|
|
931
966
|
if (!e) return e;
|
|
932
|
-
let t =
|
|
967
|
+
let t = He(e);
|
|
933
968
|
return t ? g(t) : e;
|
|
934
969
|
}, [
|
|
935
970
|
a,
|
|
936
971
|
n?.label,
|
|
937
972
|
g
|
|
938
|
-
]),
|
|
939
|
-
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ?
|
|
973
|
+
]), v = V(() => {
|
|
974
|
+
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ? Ue(t, l, u) : t ?? "", n = String(e);
|
|
940
975
|
return `${d && n.startsWith(d) ? "" : d ?? ""}${n}${f && n.endsWith(f) ? "" : f ?? ""}`;
|
|
941
976
|
}, [
|
|
942
977
|
t,
|
|
@@ -944,14 +979,14 @@ var He = {
|
|
|
944
979
|
u,
|
|
945
980
|
d,
|
|
946
981
|
f
|
|
947
|
-
]), C =
|
|
982
|
+
]), C = V(() => {
|
|
948
983
|
if (typeof r == "string") {
|
|
949
984
|
let e = F(r);
|
|
950
985
|
return e ? /* @__PURE__ */ Z(e, { className: "h-4 w-4" }) : null;
|
|
951
986
|
}
|
|
952
987
|
return r;
|
|
953
988
|
}, [r]);
|
|
954
|
-
return /* @__PURE__ */ Q(
|
|
989
|
+
return /* @__PURE__ */ Q(y, {
|
|
955
990
|
className: P("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),
|
|
956
991
|
onClick: p,
|
|
957
992
|
role: p ? "button" : void 0,
|
|
@@ -960,16 +995,16 @@ var He = {
|
|
|
960
995
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
|
|
961
996
|
} : void 0,
|
|
962
997
|
...m,
|
|
963
|
-
children: [/* @__PURE__ */ Q(
|
|
998
|
+
children: [/* @__PURE__ */ Q(x, {
|
|
964
999
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
965
|
-
children: [/* @__PURE__ */ Z(
|
|
1000
|
+
children: [/* @__PURE__ */ Z(S, {
|
|
966
1001
|
className: "text-sm font-medium truncate",
|
|
967
|
-
children:
|
|
1002
|
+
children: We(e)
|
|
968
1003
|
}), C && /* @__PURE__ */ Z("div", {
|
|
969
1004
|
className: P("flex h-8 w-8 items-center justify-center rounded-md shrink-0", h),
|
|
970
1005
|
children: C
|
|
971
1006
|
})]
|
|
972
|
-
}), /* @__PURE__ */ Z(
|
|
1007
|
+
}), /* @__PURE__ */ Z(b, { children: o ? /* @__PURE__ */ Q("div", {
|
|
973
1008
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
974
1009
|
"data-testid": "metric-loading",
|
|
975
1010
|
children: [/* @__PURE__ */ Z(G, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
@@ -980,48 +1015,48 @@ var He = {
|
|
|
980
1015
|
className: "flex items-center gap-2",
|
|
981
1016
|
"data-testid": "metric-error",
|
|
982
1017
|
role: "alert",
|
|
983
|
-
children: [/* @__PURE__ */ Z(
|
|
1018
|
+
children: [/* @__PURE__ */ Z(U, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
984
1019
|
className: "text-xs text-destructive truncate",
|
|
985
1020
|
children: s
|
|
986
1021
|
})]
|
|
987
1022
|
}) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("div", {
|
|
988
1023
|
className: "text-2xl font-bold truncate",
|
|
989
|
-
children:
|
|
1024
|
+
children: v
|
|
990
1025
|
}), (n || a) && /* @__PURE__ */ Q("div", {
|
|
991
1026
|
className: "text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0",
|
|
992
1027
|
children: [n && /* @__PURE__ */ Q("span", {
|
|
993
1028
|
className: P("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"),
|
|
994
1029
|
children: [
|
|
995
|
-
n.direction === "up" && /* @__PURE__ */ Z(
|
|
996
|
-
n.direction === "down" && /* @__PURE__ */ Z(
|
|
997
|
-
n.direction === "neutral" && /* @__PURE__ */ Z(
|
|
1030
|
+
n.direction === "up" && /* @__PURE__ */ Z(W, { className: "h-3 w-3 mr-1" }),
|
|
1031
|
+
n.direction === "down" && /* @__PURE__ */ Z(oe, { className: "h-3 w-3 mr-1" }),
|
|
1032
|
+
n.direction === "neutral" && /* @__PURE__ */ Z(le, { className: "h-3 w-3 mr-1" }),
|
|
998
1033
|
n.value,
|
|
999
1034
|
"%"
|
|
1000
1035
|
]
|
|
1001
1036
|
}), /* @__PURE__ */ Z("span", {
|
|
1002
1037
|
className: "truncate min-w-0",
|
|
1003
|
-
children:
|
|
1038
|
+
children: _
|
|
1004
1039
|
})]
|
|
1005
1040
|
})] }) })]
|
|
1006
1041
|
});
|
|
1007
1042
|
};
|
|
1008
1043
|
//#endregion
|
|
1009
1044
|
//#region src/MetricCard.tsx
|
|
1010
|
-
function
|
|
1045
|
+
function qe(e) {
|
|
1011
1046
|
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
1012
1047
|
}
|
|
1013
|
-
var
|
|
1048
|
+
var Je = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
|
|
1014
1049
|
let u = n ? F(n) : null;
|
|
1015
|
-
return /* @__PURE__ */ Q(
|
|
1050
|
+
return /* @__PURE__ */ Q(y, {
|
|
1016
1051
|
className: P("h-full", o),
|
|
1017
1052
|
...l,
|
|
1018
|
-
children: [/* @__PURE__ */ Q(
|
|
1053
|
+
children: [/* @__PURE__ */ Q(x, {
|
|
1019
1054
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
1020
|
-
children: [/* @__PURE__ */ Z(
|
|
1055
|
+
children: [/* @__PURE__ */ Z(S, {
|
|
1021
1056
|
className: "text-sm font-medium",
|
|
1022
|
-
children:
|
|
1057
|
+
children: qe(e)
|
|
1023
1058
|
}), u && /* @__PURE__ */ Z(u, { className: "h-4 w-4 text-muted-foreground" })]
|
|
1024
|
-
}), /* @__PURE__ */ Z(
|
|
1059
|
+
}), /* @__PURE__ */ Z(b, { children: s ? /* @__PURE__ */ Q("div", {
|
|
1025
1060
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
1026
1061
|
"data-testid": "metric-card-loading",
|
|
1027
1062
|
children: [/* @__PURE__ */ Z(G, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Z("span", {
|
|
@@ -1032,7 +1067,7 @@ var Ge = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
1032
1067
|
className: "flex items-center gap-2",
|
|
1033
1068
|
"data-testid": "metric-card-error",
|
|
1034
1069
|
role: "alert",
|
|
1035
|
-
children: [/* @__PURE__ */ Z(
|
|
1070
|
+
children: [/* @__PURE__ */ Z(U, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Z("span", {
|
|
1036
1071
|
className: "text-xs text-destructive truncate",
|
|
1037
1072
|
children: c
|
|
1038
1073
|
})]
|
|
@@ -1044,105 +1079,133 @@ var Ge = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
1044
1079
|
children: [r && i && /* @__PURE__ */ Q("span", {
|
|
1045
1080
|
className: P("flex items-center mr-2", r === "up" && "text-green-500", r === "down" && "text-red-500", r === "neutral" && "text-yellow-500"),
|
|
1046
1081
|
children: [
|
|
1047
|
-
r === "up" && /* @__PURE__ */ Z(
|
|
1048
|
-
r === "down" && /* @__PURE__ */ Z(
|
|
1049
|
-
r === "neutral" && /* @__PURE__ */ Z(
|
|
1082
|
+
r === "up" && /* @__PURE__ */ Z(W, { className: "h-3 w-3 mr-1" }),
|
|
1083
|
+
r === "down" && /* @__PURE__ */ Z(oe, { className: "h-3 w-3 mr-1" }),
|
|
1084
|
+
r === "neutral" && /* @__PURE__ */ Z(le, { className: "h-3 w-3 mr-1" }),
|
|
1050
1085
|
i
|
|
1051
1086
|
]
|
|
1052
|
-
}),
|
|
1087
|
+
}), qe(a)]
|
|
1053
1088
|
})] }) })]
|
|
1054
1089
|
});
|
|
1055
|
-
},
|
|
1056
|
-
let
|
|
1057
|
-
|
|
1090
|
+
}, Ye = ({ objectName: e, aggregate: n, filter: r, label: u, fallbackValue: d, trend: f, icon: p, className: m, description: h, dataSource: g, colorVariant: _, format: v, currency: y, prefix: b, suffix: x, invert: S, drillDown: C, title: w, compareTo: T, t: E }) => {
|
|
1091
|
+
let j = z(l), N = g || j?.dataSource, [P, F] = H(!1), [I, L] = H(null), [re, ie] = H(null), [ae, U] = H(!1), [oe, W] = H(null), [se, ce] = H(null);
|
|
1092
|
+
B(() => {
|
|
1058
1093
|
let t = !0;
|
|
1059
|
-
if (!(!
|
|
1060
|
-
t &&
|
|
1094
|
+
if (!(!N || !e || typeof N.getObjectSchema != "function")) return N.getObjectSchema(e).then((e) => {
|
|
1095
|
+
t && ce(e);
|
|
1061
1096
|
}).catch(() => {}), () => {
|
|
1062
1097
|
t = !1;
|
|
1063
1098
|
};
|
|
1064
|
-
}, [
|
|
1065
|
-
let
|
|
1066
|
-
let e =
|
|
1067
|
-
if (!e || !
|
|
1068
|
-
let
|
|
1069
|
-
return Array.isArray(
|
|
1070
|
-
}, [
|
|
1071
|
-
if (
|
|
1072
|
-
if (
|
|
1073
|
-
if (
|
|
1074
|
-
let e =
|
|
1099
|
+
}, [N, e]);
|
|
1100
|
+
let G = V(() => {
|
|
1101
|
+
let e = n?.field;
|
|
1102
|
+
if (!e || !se?.fields) return null;
|
|
1103
|
+
let t = se.fields;
|
|
1104
|
+
return Array.isArray(t) ? t.find((t) => t?.name === e) || null : t[e] || null;
|
|
1105
|
+
}, [se, n?.field]), le = V(() => {
|
|
1106
|
+
if (v) return v;
|
|
1107
|
+
if (G) {
|
|
1108
|
+
if (G.type === "currency") {
|
|
1109
|
+
let e = G.precision ?? G.scale ?? 0;
|
|
1075
1110
|
return e > 0 ? `0,0.${"0".repeat(e)}` : "0,0";
|
|
1076
1111
|
}
|
|
1077
|
-
if (
|
|
1078
|
-
if (
|
|
1112
|
+
if (G.type === "percent") return "0,0%";
|
|
1113
|
+
if (G.type === "number" || G.type === "integer") return "0,0";
|
|
1079
1114
|
}
|
|
1080
|
-
}, [
|
|
1081
|
-
if (
|
|
1082
|
-
if (
|
|
1083
|
-
}, [
|
|
1084
|
-
if (
|
|
1085
|
-
|
|
1115
|
+
}, [v, G]), ue = V(() => {
|
|
1116
|
+
if (y) return y;
|
|
1117
|
+
if (G?.type === "currency") return G.defaultCurrency || G.currency || void 0;
|
|
1118
|
+
}, [y, G]), K = V(() => n ? JSON.stringify(n) : "", [n]), q = V(() => a(r), [r]), de = V(() => q ? JSON.stringify(q) : "", [q]), fe = V(() => T ? JSON.stringify(T) : "", [T]), pe = R(async (t, r) => {
|
|
1119
|
+
if (n && typeof t.aggregate == "function") {
|
|
1120
|
+
let i = await t.aggregate(e, {
|
|
1121
|
+
field: n.field,
|
|
1122
|
+
function: n.function,
|
|
1123
|
+
groupBy: n.groupBy || "_all",
|
|
1124
|
+
filter: r
|
|
1125
|
+
}), a = Array.isArray(i) ? i : [];
|
|
1126
|
+
if (a.length === 0) return 0;
|
|
1127
|
+
if (n.function === "count") {
|
|
1128
|
+
let e = `${n.field}_count`;
|
|
1129
|
+
return a.reduce((t, r) => t + (Number(r[e]) || Number(r[n.field]) || Number(r.count) || 0), 0);
|
|
1130
|
+
}
|
|
1131
|
+
let o = a[0];
|
|
1132
|
+
return o[`${n.field}_${n.function}`] ?? o[n.field] ?? o.value ?? 0;
|
|
1133
|
+
}
|
|
1134
|
+
if (typeof t.find == "function") {
|
|
1135
|
+
let n = await t.find(e, { $filter: r });
|
|
1136
|
+
return (Array.isArray(n) ? n : n?.data || n?.records || []).length;
|
|
1137
|
+
}
|
|
1138
|
+
return null;
|
|
1139
|
+
}, [e, K]), me = R(async (t, n) => {
|
|
1140
|
+
if (!(!t || !e)) {
|
|
1141
|
+
n.current && (U(!0), W(null));
|
|
1086
1142
|
try {
|
|
1087
|
-
let i;
|
|
1088
|
-
if (
|
|
1089
|
-
|
|
1090
|
-
field: t.field,
|
|
1091
|
-
function: t.function,
|
|
1092
|
-
groupBy: t.groupBy || "_all",
|
|
1093
|
-
filter: G
|
|
1094
|
-
}), a = Array.isArray(r) ? r : [];
|
|
1095
|
-
if (a.length === 0) i = 0;
|
|
1096
|
-
else if (t.function === "count") {
|
|
1097
|
-
let e = `${t.field}_count`;
|
|
1098
|
-
i = a.reduce((n, r) => n + (Number(r[e]) || Number(r[t.field]) || Number(r.count) || 0), 0);
|
|
1099
|
-
} else {
|
|
1100
|
-
let e = a[0];
|
|
1101
|
-
i = e[`${t.field}_${t.function}`] ?? e[t.field] ?? e.value ?? 0;
|
|
1102
|
-
}
|
|
1103
|
-
} else if (typeof n.find == "function") {
|
|
1104
|
-
let t = await n.find(e, { $filter: G });
|
|
1105
|
-
i = (Array.isArray(t) ? t : t?.data || t?.records || []).length;
|
|
1106
|
-
} else return;
|
|
1107
|
-
r.current && F(i);
|
|
1143
|
+
let e = T ? s(r, T) : null, [i, a] = await Promise.all([pe(t, q), e ? pe(t, e) : Promise.resolve(null)]);
|
|
1144
|
+
if (i === null) return;
|
|
1145
|
+
n.current && (L(i), ie(typeof a == "number" && Number.isFinite(a) ? a : null));
|
|
1108
1146
|
} catch (e) {
|
|
1109
|
-
console.error("[ObjectMetricWidget] Fetch error:", e),
|
|
1147
|
+
console.error("[ObjectMetricWidget] Fetch error:", e), n.current && W(e instanceof Error ? e.message : "Failed to load metric");
|
|
1110
1148
|
} finally {
|
|
1111
|
-
|
|
1149
|
+
n.current && U(!1);
|
|
1112
1150
|
}
|
|
1113
1151
|
}
|
|
1114
1152
|
}, [
|
|
1115
1153
|
e,
|
|
1116
|
-
|
|
1117
|
-
|
|
1154
|
+
K,
|
|
1155
|
+
de,
|
|
1156
|
+
fe,
|
|
1157
|
+
pe
|
|
1118
1158
|
]);
|
|
1119
|
-
|
|
1159
|
+
B(() => {
|
|
1120
1160
|
let t = { current: !0 };
|
|
1121
|
-
return
|
|
1161
|
+
return N && e ? me(N, t) : (L(null), W(null)), () => {
|
|
1122
1162
|
t.current = !1;
|
|
1123
1163
|
};
|
|
1124
1164
|
}, [
|
|
1125
|
-
|
|
1165
|
+
N,
|
|
1126
1166
|
e,
|
|
1127
|
-
|
|
1167
|
+
me
|
|
1128
1168
|
]);
|
|
1129
|
-
let
|
|
1130
|
-
|
|
1131
|
-
let
|
|
1132
|
-
|
|
1133
|
-
|
|
1169
|
+
let J = I === null ? N ? "—" : d ?? "—" : I;
|
|
1170
|
+
S && typeof J == "number" && isFinite(J) && J >= 0 && J <= 1 && (J = 1 - J);
|
|
1171
|
+
let he = V(() => {
|
|
1172
|
+
if (!T || typeof I != "number" || !Number.isFinite(I) || re === null) return;
|
|
1173
|
+
let e = Oe(I, re);
|
|
1174
|
+
if (!e) return;
|
|
1175
|
+
let n = t(T, r), i = `dashboard.trend.${n}`, a = {
|
|
1176
|
+
vsPreviousPeriod: "vs previous period",
|
|
1177
|
+
vsLastWeek: "vs last week",
|
|
1178
|
+
vsLastMonth: "vs last month",
|
|
1179
|
+
vsLastQuarter: "vs last quarter",
|
|
1180
|
+
vsLastYear: "vs last year",
|
|
1181
|
+
vsYesterday: "vs yesterday"
|
|
1182
|
+
}, o = E ? E(i, a[n] || n) : a[n] || n;
|
|
1183
|
+
return {
|
|
1184
|
+
value: e.value,
|
|
1185
|
+
direction: e.direction,
|
|
1186
|
+
label: o
|
|
1187
|
+
};
|
|
1134
1188
|
}, [
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1189
|
+
T,
|
|
1190
|
+
I,
|
|
1191
|
+
re,
|
|
1192
|
+
r,
|
|
1193
|
+
E
|
|
1194
|
+
]) ?? f, Y = i(C) && !!e && !!N, ge = V(() => {
|
|
1195
|
+
let e = typeof u == "string" ? u : u?.defaultValue || "";
|
|
1196
|
+
return o(C, {}, (typeof w == "string" ? w : w?.defaultValue || "") || e || "Details");
|
|
1197
|
+
}, [
|
|
1198
|
+
C,
|
|
1199
|
+
u,
|
|
1200
|
+
w
|
|
1201
|
+
]), _e = V(() => {
|
|
1202
|
+
if (!Y) return null;
|
|
1203
|
+
let t = C?.target ?? "drawer", n = C?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i;
|
|
1141
1204
|
if (r) {
|
|
1142
|
-
let e = n.filter, t = e ?
|
|
1205
|
+
let e = n.filter, t = e ? q ? { $and: [e, q] } : e : q;
|
|
1143
1206
|
i = /* @__PURE__ */ Z("div", {
|
|
1144
1207
|
className: "h-full overflow-auto",
|
|
1145
|
-
children: /* @__PURE__ */ Z(
|
|
1208
|
+
children: /* @__PURE__ */ Z(c, { schema: {
|
|
1146
1209
|
type: "spec-report",
|
|
1147
1210
|
...n,
|
|
1148
1211
|
filter: t
|
|
@@ -1150,76 +1213,76 @@ var Ge = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
1150
1213
|
});
|
|
1151
1214
|
} else i = /* @__PURE__ */ Z("div", {
|
|
1152
1215
|
className: "h-full overflow-auto",
|
|
1153
|
-
children: /* @__PURE__ */ Z(
|
|
1216
|
+
children: /* @__PURE__ */ Z(c, { schema: {
|
|
1154
1217
|
type: "object-data-table",
|
|
1155
1218
|
objectName: e,
|
|
1156
|
-
filter:
|
|
1219
|
+
filter: q,
|
|
1157
1220
|
pageSize: 25,
|
|
1158
1221
|
drillDown: { enabled: !1 }
|
|
1159
1222
|
} })
|
|
1160
1223
|
});
|
|
1161
|
-
return t === "dialog" ? /* @__PURE__ */ Z(
|
|
1224
|
+
return t === "dialog" ? /* @__PURE__ */ Z(D, {
|
|
1162
1225
|
open: !0,
|
|
1163
|
-
onOpenChange: (e) => !e &&
|
|
1164
|
-
children: /* @__PURE__ */ Q(
|
|
1226
|
+
onOpenChange: (e) => !e && F(!1),
|
|
1227
|
+
children: /* @__PURE__ */ Q(O, {
|
|
1165
1228
|
className: "max-w-5xl",
|
|
1166
|
-
children: [/* @__PURE__ */ Z(
|
|
1229
|
+
children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Z(A, { children: ge }) }), i]
|
|
1167
1230
|
})
|
|
1168
|
-
}) : /* @__PURE__ */ Z(
|
|
1231
|
+
}) : /* @__PURE__ */ Z(M, {
|
|
1169
1232
|
open: !0,
|
|
1170
|
-
onOpenChange: (e) => !e &&
|
|
1171
|
-
children: /* @__PURE__ */ Q(
|
|
1233
|
+
onOpenChange: (e) => !e && F(!1),
|
|
1234
|
+
children: /* @__PURE__ */ Q(ee, {
|
|
1172
1235
|
side: "right",
|
|
1173
1236
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col",
|
|
1174
|
-
children: [/* @__PURE__ */ Z(
|
|
1237
|
+
children: [/* @__PURE__ */ Z(te, { children: /* @__PURE__ */ Z(ne, { children: ge }) }), /* @__PURE__ */ Z("div", {
|
|
1175
1238
|
className: "flex-1 overflow-hidden mt-2",
|
|
1176
1239
|
children: i
|
|
1177
1240
|
})]
|
|
1178
1241
|
})
|
|
1179
1242
|
});
|
|
1180
1243
|
}, [
|
|
1181
|
-
|
|
1182
|
-
|
|
1244
|
+
Y,
|
|
1245
|
+
C,
|
|
1183
1246
|
e,
|
|
1184
|
-
|
|
1185
|
-
|
|
1247
|
+
q,
|
|
1248
|
+
ge
|
|
1186
1249
|
]);
|
|
1187
|
-
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(
|
|
1188
|
-
label:
|
|
1189
|
-
value:
|
|
1190
|
-
trend:
|
|
1191
|
-
icon:
|
|
1192
|
-
className:
|
|
1193
|
-
description:
|
|
1194
|
-
loading:
|
|
1195
|
-
error:
|
|
1196
|
-
colorVariant:
|
|
1197
|
-
format:
|
|
1198
|
-
currency:
|
|
1199
|
-
prefix:
|
|
1200
|
-
suffix:
|
|
1201
|
-
onClick:
|
|
1202
|
-
}),
|
|
1250
|
+
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(Ke, {
|
|
1251
|
+
label: u,
|
|
1252
|
+
value: J,
|
|
1253
|
+
trend: he,
|
|
1254
|
+
icon: p,
|
|
1255
|
+
className: m,
|
|
1256
|
+
description: h,
|
|
1257
|
+
loading: ae,
|
|
1258
|
+
error: oe,
|
|
1259
|
+
colorVariant: _,
|
|
1260
|
+
format: le,
|
|
1261
|
+
currency: ue,
|
|
1262
|
+
prefix: b,
|
|
1263
|
+
suffix: x,
|
|
1264
|
+
onClick: Y ? () => F(!0) : void 0
|
|
1265
|
+
}), P && _e] });
|
|
1203
1266
|
};
|
|
1204
1267
|
//#endregion
|
|
1205
1268
|
//#region src/PivotTable.tsx
|
|
1206
|
-
function
|
|
1269
|
+
function Xe() {
|
|
1207
1270
|
try {
|
|
1208
|
-
let { t: e } =
|
|
1271
|
+
let { t: e } = g(), t = e("dashboard.total");
|
|
1209
1272
|
return !t || t === "dashboard.total" ? "Total" : t;
|
|
1210
1273
|
} catch {
|
|
1211
1274
|
return "Total";
|
|
1212
1275
|
}
|
|
1213
1276
|
}
|
|
1214
|
-
function
|
|
1277
|
+
function Ze() {
|
|
1215
1278
|
try {
|
|
1216
|
-
let { t: e } =
|
|
1279
|
+
let { t: e } = g(), t = e("dashboard.noDataAvailable");
|
|
1217
1280
|
return !t || t === "dashboard.noDataAvailable" ? "No data available" : t;
|
|
1218
1281
|
} catch {
|
|
1219
1282
|
return "No data available";
|
|
1220
1283
|
}
|
|
1221
1284
|
}
|
|
1222
|
-
function
|
|
1285
|
+
function Qe(e, t) {
|
|
1223
1286
|
if (!t) return String(e);
|
|
1224
1287
|
let n = "", r = "", i = !1, a, o = t, s = o.match(/^([^0-9.,#]*)/);
|
|
1225
1288
|
if (s && s[1]) {
|
|
@@ -1236,11 +1299,11 @@ function Ye(e, t) {
|
|
|
1236
1299
|
}
|
|
1237
1300
|
return n + l + r;
|
|
1238
1301
|
}
|
|
1239
|
-
var
|
|
1240
|
-
function
|
|
1241
|
-
return e === "" ?
|
|
1302
|
+
var $e = "—";
|
|
1303
|
+
function et(e, t) {
|
|
1304
|
+
return e === "" ? $e : t?.[e] ?? e;
|
|
1242
1305
|
}
|
|
1243
|
-
function
|
|
1306
|
+
function tt(e, t) {
|
|
1244
1307
|
if (e.length === 0) return 0;
|
|
1245
1308
|
switch (t) {
|
|
1246
1309
|
case "sum": return e.reduce((e, t) => e + t, 0);
|
|
@@ -1251,18 +1314,18 @@ function Qe(e, t) {
|
|
|
1251
1314
|
default: return e.reduce((e, t) => e + t, 0);
|
|
1252
1315
|
}
|
|
1253
1316
|
}
|
|
1254
|
-
var
|
|
1255
|
-
let { title: s, rowField: c, columnField: l, valueField: u, aggregation: d = "sum", data: f = [], showRowTotals: p = !1, showColumnTotals: m = !1, format: h, columnColors: g, drillDown: _ } = e, v =
|
|
1317
|
+
var nt = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabel: a, onDrillDown: o }) => {
|
|
1318
|
+
let { title: s, rowField: c, columnField: l, valueField: u, aggregation: d = "sum", data: f = [], showRowTotals: p = !1, showColumnTotals: m = !1, format: h, columnColors: g, drillDown: _ } = e, v = Xe(), y = Ze(), b = i(_) && typeof o == "function", x = (e) => {
|
|
1256
1319
|
b && o({
|
|
1257
1320
|
...e,
|
|
1258
1321
|
rowLabel: e.rowKey === void 0 ? e.rowLabel : n?.[e.rowKey] ?? e.rowKey,
|
|
1259
|
-
colLabel: e.colKey === void 0 ? e.colLabel :
|
|
1322
|
+
colLabel: e.colKey === void 0 ? e.colLabel : r?.[e.colKey] ?? e.colKey
|
|
1260
1323
|
});
|
|
1261
1324
|
}, S = (e) => (t) => {
|
|
1262
1325
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
|
|
1263
|
-
}, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "",
|
|
1326
|
+
}, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "", w = Array.isArray(f) ? f : [], { rowKeys: T, colKeys: D, matrix: O, rowTotals: k, colTotals: A, grandTotal: j } = V(() => {
|
|
1264
1327
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = {};
|
|
1265
|
-
for (let r of
|
|
1328
|
+
for (let r of w) {
|
|
1266
1329
|
let i = String(r[c] ?? ""), a = String(r[l] ?? ""), o = Number(r[u]) || 0;
|
|
1267
1330
|
e.set(i, !0), t.set(a, !0), n[i] || (n[i] = {}), n[i][a] || (n[i][a] = []), n[i][a].push(o);
|
|
1268
1331
|
}
|
|
@@ -1271,10 +1334,10 @@ var $e = ({ schema: e, className: t, rowLabels: n, columnLabels: i, rowFieldLabe
|
|
|
1271
1334
|
a[e] = {};
|
|
1272
1335
|
let t = [];
|
|
1273
1336
|
for (let r of i) {
|
|
1274
|
-
let i = n[e]?.[r] ?? [], o =
|
|
1337
|
+
let i = n[e]?.[r] ?? [], o = tt(i, d);
|
|
1275
1338
|
a[e][r] = o, t.push(...i), !s[r] && s[r];
|
|
1276
1339
|
}
|
|
1277
|
-
o[e] =
|
|
1340
|
+
o[e] = tt(t, d);
|
|
1278
1341
|
}
|
|
1279
1342
|
for (let e of i) {
|
|
1280
1343
|
let t = [];
|
|
@@ -1282,31 +1345,31 @@ var $e = ({ schema: e, className: t, rowLabels: n, columnLabels: i, rowFieldLabe
|
|
|
1282
1345
|
let r = n[i]?.[e] ?? [];
|
|
1283
1346
|
t.push(...r);
|
|
1284
1347
|
}
|
|
1285
|
-
s[e] =
|
|
1348
|
+
s[e] = tt(t, d);
|
|
1286
1349
|
}
|
|
1287
1350
|
let f = [];
|
|
1288
|
-
for (let e of
|
|
1351
|
+
for (let e of w) f.push(Number(e[u]) || 0);
|
|
1289
1352
|
return {
|
|
1290
1353
|
rowKeys: r,
|
|
1291
1354
|
colKeys: i,
|
|
1292
1355
|
matrix: a,
|
|
1293
1356
|
rowTotals: o,
|
|
1294
1357
|
colTotals: s,
|
|
1295
|
-
grandTotal:
|
|
1358
|
+
grandTotal: tt(f, d)
|
|
1296
1359
|
};
|
|
1297
1360
|
}, [
|
|
1298
|
-
|
|
1361
|
+
w,
|
|
1299
1362
|
c,
|
|
1300
1363
|
l,
|
|
1301
1364
|
u,
|
|
1302
1365
|
d
|
|
1303
|
-
]), M = (e) =>
|
|
1304
|
-
return
|
|
1366
|
+
]), M = (e) => Qe(e, h);
|
|
1367
|
+
return w.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
1305
1368
|
className: P("overflow-auto", t),
|
|
1306
1369
|
children: [s && /* @__PURE__ */ Z("h3", {
|
|
1307
1370
|
className: "text-sm font-semibold mb-2",
|
|
1308
1371
|
children: s
|
|
1309
|
-
}), /* @__PURE__ */ Z(
|
|
1372
|
+
}), /* @__PURE__ */ Z(E, {
|
|
1310
1373
|
"data-testid": "pivot-empty-state",
|
|
1311
1374
|
className: "py-8 gap-2 [&>h3]:hidden",
|
|
1312
1375
|
icon: /* @__PURE__ */ Q("svg", {
|
|
@@ -1378,7 +1441,7 @@ var $e = ({ schema: e, className: t, rowLabels: n, columnLabels: i, rowFieldLabe
|
|
|
1378
1441
|
onClick: b ? t : void 0,
|
|
1379
1442
|
onKeyDown: b ? S(t) : void 0,
|
|
1380
1443
|
"aria-label": b ? `Drill into ${l}: ${e || "(empty)"}` : void 0,
|
|
1381
|
-
children:
|
|
1444
|
+
children: et(e, r)
|
|
1382
1445
|
}, e);
|
|
1383
1446
|
}),
|
|
1384
1447
|
p && /* @__PURE__ */ Z("th", {
|
|
@@ -1387,7 +1450,7 @@ var $e = ({ schema: e, className: t, rowLabels: n, columnLabels: i, rowFieldLabe
|
|
|
1387
1450
|
})
|
|
1388
1451
|
]
|
|
1389
1452
|
}) }),
|
|
1390
|
-
/* @__PURE__ */ Z("tbody", { children:
|
|
1453
|
+
/* @__PURE__ */ Z("tbody", { children: T.map((e) => /* @__PURE__ */ Q("tr", {
|
|
1391
1454
|
className: "border-b border-border/50 hover:bg-muted/30",
|
|
1392
1455
|
children: [
|
|
1393
1456
|
/* @__PURE__ */ Z("td", {
|
|
@@ -1403,7 +1466,7 @@ var $e = ({ schema: e, className: t, rowLabels: n, columnLabels: i, rowFieldLabe
|
|
|
1403
1466
|
rowKey: e
|
|
1404
1467
|
})) : void 0,
|
|
1405
1468
|
"aria-label": b ? `Drill into ${c}: ${e || "(empty)"}` : void 0,
|
|
1406
|
-
children:
|
|
1469
|
+
children: et(e, n)
|
|
1407
1470
|
}),
|
|
1408
1471
|
D.map((t) => {
|
|
1409
1472
|
let n = O[e]?.[t] ?? 0, r = () => x({
|
|
@@ -1485,13 +1548,13 @@ var $e = ({ schema: e, className: t, rowLabels: n, columnLabels: i, rowFieldLabe
|
|
|
1485
1548
|
};
|
|
1486
1549
|
//#endregion
|
|
1487
1550
|
//#region src/ObjectDataTable.tsx
|
|
1488
|
-
function
|
|
1551
|
+
function rt(e) {
|
|
1489
1552
|
return e.map((e) => typeof e == "string" ? {
|
|
1490
1553
|
header: e.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (e) => e.toUpperCase()),
|
|
1491
1554
|
accessorKey: e
|
|
1492
1555
|
} : e);
|
|
1493
1556
|
}
|
|
1494
|
-
function
|
|
1557
|
+
function it(e, t) {
|
|
1495
1558
|
if (!t?.fields) return [];
|
|
1496
1559
|
let n = {};
|
|
1497
1560
|
if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
|
|
@@ -1509,30 +1572,30 @@ function tt(e, t) {
|
|
|
1509
1572
|
} else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
|
|
1510
1573
|
return Array.from(a);
|
|
1511
1574
|
}
|
|
1512
|
-
var
|
|
1513
|
-
let
|
|
1575
|
+
var at = ({ schema: e, dataSource: t, className: n }) => {
|
|
1576
|
+
let i = z(l), o = t || i?.dataSource, s = d(e.bind), { fieldLabel: u, fieldOptionLabel: f } = _(), p = "No data available", m = "No data source available for";
|
|
1514
1577
|
try {
|
|
1515
|
-
let { t: e } =
|
|
1578
|
+
let { t: e } = g(), t = e("dashboard.noDataAvailable");
|
|
1516
1579
|
t && t !== "dashboard.noDataAvailable" && (p = t);
|
|
1517
1580
|
let n = e("dashboard.noDataSourceFor");
|
|
1518
|
-
n && n !== "dashboard.noDataSourceFor" && (
|
|
1581
|
+
n && n !== "dashboard.noDataSourceFor" && (m = n);
|
|
1519
1582
|
} catch {}
|
|
1520
|
-
let [
|
|
1521
|
-
|
|
1583
|
+
let [h, v] = H([]), [y, b] = H(null), [x, S] = H(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [C, w] = H(null);
|
|
1584
|
+
B(() => {
|
|
1522
1585
|
let t = !0;
|
|
1523
|
-
return e.objectName && !
|
|
1524
|
-
if (!
|
|
1586
|
+
return e.objectName && !s && (!e.data || e.data.length === 0) ? (async () => {
|
|
1587
|
+
if (!o || !e.objectName) {
|
|
1525
1588
|
t && S(!1);
|
|
1526
1589
|
return;
|
|
1527
1590
|
}
|
|
1528
1591
|
t && (S(!0), w(null));
|
|
1529
1592
|
try {
|
|
1530
|
-
let
|
|
1531
|
-
if (typeof
|
|
1532
|
-
let t =
|
|
1533
|
-
t.length && (
|
|
1593
|
+
let n;
|
|
1594
|
+
if (typeof o.find == "function") {
|
|
1595
|
+
let t = it(e, y), i = { $filter: a(e.filter) };
|
|
1596
|
+
t.length && (i.$expand = t), n = r(await o.find(e.objectName, i));
|
|
1534
1597
|
} else return;
|
|
1535
|
-
t && v(
|
|
1598
|
+
t && v(n);
|
|
1536
1599
|
} catch (e) {
|
|
1537
1600
|
console.error("[ObjectDataTable] Fetch error:", e), t && w(e instanceof Error ? e.message : "Failed to load data");
|
|
1538
1601
|
} finally {
|
|
@@ -1543,20 +1606,20 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1543
1606
|
};
|
|
1544
1607
|
}, [
|
|
1545
1608
|
e.objectName,
|
|
1546
|
-
|
|
1547
|
-
|
|
1609
|
+
o,
|
|
1610
|
+
s,
|
|
1548
1611
|
e.data,
|
|
1549
1612
|
e.filter,
|
|
1550
1613
|
y
|
|
1551
|
-
]),
|
|
1614
|
+
]), B(() => {
|
|
1552
1615
|
let t = !0;
|
|
1553
|
-
if (!(!
|
|
1616
|
+
if (!(!o || !e.objectName || typeof o.getObjectSchema != "function")) return o.getObjectSchema(e.objectName).then((e) => {
|
|
1554
1617
|
t && b(e);
|
|
1555
1618
|
}).catch(() => {}), () => {
|
|
1556
1619
|
t = !1;
|
|
1557
1620
|
};
|
|
1558
|
-
}, [e.objectName,
|
|
1559
|
-
let T =
|
|
1621
|
+
}, [e.objectName, o]);
|
|
1622
|
+
let T = s || e.data || h, E = Array.isArray(T) ? T : [], D = V(() => {
|
|
1560
1623
|
let t = e.objectName, n = {};
|
|
1561
1624
|
if (y?.fields) {
|
|
1562
1625
|
let e = y.fields;
|
|
@@ -1568,7 +1631,7 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1568
1631
|
}
|
|
1569
1632
|
let r = (e) => {
|
|
1570
1633
|
let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
|
|
1571
|
-
return t ?
|
|
1634
|
+
return t ? u(t, e, n) : n;
|
|
1572
1635
|
}, i = (e) => {
|
|
1573
1636
|
let r = n[e.accessorKey], i = e.referenceTo ?? r?.referenceTo ?? (typeof r?.reference == "string" ? r.reference : r?.reference?.to) ?? r?.target, a = e.options ?? r?.options;
|
|
1574
1637
|
t && a && (r?.type === "select" || r?.type === "picklist" || r?.type === "dropdown" || r?.type === "status") && (a = a.map((n) => {
|
|
@@ -1614,13 +1677,13 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1614
1677
|
"€": "EUR",
|
|
1615
1678
|
"£": "GBP"
|
|
1616
1679
|
}[t[0]];
|
|
1617
|
-
return
|
|
1680
|
+
return Ce(e, o.currency || n);
|
|
1618
1681
|
}
|
|
1619
1682
|
if (typeof t == "string" && /%/.test(t) && typeof e == "number") {
|
|
1620
1683
|
let n = (t.match(/0\.(0+)%/) || [, ""])[1].length;
|
|
1621
|
-
return
|
|
1684
|
+
return Te((e > 1 ? e / 100 : e) * 100, n);
|
|
1622
1685
|
}
|
|
1623
|
-
return typeof t == "string" && /[YMDHms]/.test(t) ?
|
|
1686
|
+
return typeof t == "string" && /[YMDHms]/.test(t) ? we(e, t) : /* @__PURE__ */ Z(Ee(De(o)), {
|
|
1624
1687
|
value: e,
|
|
1625
1688
|
field: o
|
|
1626
1689
|
});
|
|
@@ -1633,10 +1696,10 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1633
1696
|
};
|
|
1634
1697
|
};
|
|
1635
1698
|
if (e.columns && e.columns.length > 0) {
|
|
1636
|
-
let n =
|
|
1699
|
+
let n = rt(e.columns);
|
|
1637
1700
|
return (t ? n.map((e) => ({
|
|
1638
1701
|
...e,
|
|
1639
|
-
header:
|
|
1702
|
+
header: u(t, e.accessorKey, e.header)
|
|
1640
1703
|
})) : n).map(i);
|
|
1641
1704
|
}
|
|
1642
1705
|
if (E.length === 0) return [];
|
|
@@ -1663,11 +1726,11 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1663
1726
|
e.objectName,
|
|
1664
1727
|
E,
|
|
1665
1728
|
y,
|
|
1666
|
-
|
|
1729
|
+
u,
|
|
1667
1730
|
f
|
|
1668
1731
|
]);
|
|
1669
1732
|
if (x && E.length === 0) return /* @__PURE__ */ Z("div", {
|
|
1670
|
-
className: P("overflow-auto",
|
|
1733
|
+
className: P("overflow-auto", n),
|
|
1671
1734
|
"data-testid": "table-loading",
|
|
1672
1735
|
children: /* @__PURE__ */ Q("div", {
|
|
1673
1736
|
className: "space-y-2 p-2",
|
|
@@ -1696,7 +1759,7 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1696
1759
|
})
|
|
1697
1760
|
});
|
|
1698
1761
|
if (C) return /* @__PURE__ */ Z("div", {
|
|
1699
|
-
className: P("overflow-auto",
|
|
1762
|
+
className: P("overflow-auto", n),
|
|
1700
1763
|
"data-testid": "table-error",
|
|
1701
1764
|
children: /* @__PURE__ */ Q("div", {
|
|
1702
1765
|
className: "flex flex-col items-center justify-center py-8 text-destructive",
|
|
@@ -1735,14 +1798,14 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1735
1798
|
})]
|
|
1736
1799
|
})
|
|
1737
1800
|
});
|
|
1738
|
-
if (!
|
|
1739
|
-
className: P("overflow-auto",
|
|
1801
|
+
if (!o && e.objectName && E.length === 0) return /* @__PURE__ */ Z("div", {
|
|
1802
|
+
className: P("overflow-auto", n),
|
|
1740
1803
|
children: /* @__PURE__ */ Z("div", {
|
|
1741
1804
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
1742
1805
|
children: /* @__PURE__ */ Q("p", {
|
|
1743
1806
|
className: "text-xs",
|
|
1744
1807
|
children: [
|
|
1745
|
-
|
|
1808
|
+
m,
|
|
1746
1809
|
" “",
|
|
1747
1810
|
e.objectName,
|
|
1748
1811
|
"”"
|
|
@@ -1751,7 +1814,7 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1751
1814
|
})
|
|
1752
1815
|
});
|
|
1753
1816
|
if (E.length === 0) return /* @__PURE__ */ Z("div", {
|
|
1754
|
-
className: P("overflow-auto",
|
|
1817
|
+
className: P("overflow-auto", n),
|
|
1755
1818
|
"data-testid": "table-empty-state",
|
|
1756
1819
|
children: /* @__PURE__ */ Q("div", {
|
|
1757
1820
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
@@ -1799,19 +1862,19 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1799
1862
|
columns: D
|
|
1800
1863
|
};
|
|
1801
1864
|
return /* @__PURE__ */ Q("div", {
|
|
1802
|
-
className: P("relative",
|
|
1803
|
-
children: [/* @__PURE__ */ Z(
|
|
1865
|
+
className: P("relative", n),
|
|
1866
|
+
children: [/* @__PURE__ */ Z(j, { active: x && E.length > 0 }), /* @__PURE__ */ Z(c, {
|
|
1804
1867
|
schema: O,
|
|
1805
|
-
className:
|
|
1868
|
+
className: n
|
|
1806
1869
|
})]
|
|
1807
1870
|
});
|
|
1808
|
-
},
|
|
1871
|
+
}, ot = ({ open: e, onClose: t, title: n, target: r = "drawer", objectName: i, filter: a, dataSource: o, columns: s, maxRows: l, className: u, report: d }) => {
|
|
1809
1872
|
let f = d && typeof d == "object" && (Array.isArray(d.columns) || "objectName" in d), p = /* @__PURE__ */ Z("div", {
|
|
1810
1873
|
className: P("overflow-auto", u),
|
|
1811
1874
|
"data-testid": "drill-down-body",
|
|
1812
1875
|
children: f ? (() => {
|
|
1813
1876
|
let e = d.filter, t = e ? a ? { $and: [e, a] } : e : a;
|
|
1814
|
-
return /* @__PURE__ */ Z(
|
|
1877
|
+
return /* @__PURE__ */ Z(c, { schema: {
|
|
1815
1878
|
...d,
|
|
1816
1879
|
type: "spec-report",
|
|
1817
1880
|
report: {
|
|
@@ -1820,12 +1883,12 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1820
1883
|
},
|
|
1821
1884
|
filter: t
|
|
1822
1885
|
} });
|
|
1823
|
-
})() : /* @__PURE__ */ Z(
|
|
1886
|
+
})() : /* @__PURE__ */ Z(at, {
|
|
1824
1887
|
schema: {
|
|
1825
1888
|
type: "object-data-table",
|
|
1826
1889
|
objectName: i,
|
|
1827
1890
|
filter: a,
|
|
1828
|
-
columns:
|
|
1891
|
+
columns: s?.map((e) => ({
|
|
1829
1892
|
accessorKey: e,
|
|
1830
1893
|
header: e
|
|
1831
1894
|
})),
|
|
@@ -1833,38 +1896,38 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1833
1896
|
searchable: !1,
|
|
1834
1897
|
pageSize: l
|
|
1835
1898
|
},
|
|
1836
|
-
dataSource:
|
|
1899
|
+
dataSource: o
|
|
1837
1900
|
})
|
|
1838
1901
|
});
|
|
1839
|
-
return r === "dialog" ? /* @__PURE__ */ Z(
|
|
1902
|
+
return r === "dialog" ? /* @__PURE__ */ Z(D, {
|
|
1840
1903
|
open: e,
|
|
1841
1904
|
onOpenChange: (e) => !e && t(),
|
|
1842
|
-
children: /* @__PURE__ */ Q(
|
|
1905
|
+
children: /* @__PURE__ */ Q(O, {
|
|
1843
1906
|
className: "max-w-5xl",
|
|
1844
|
-
children: [/* @__PURE__ */ Z(
|
|
1907
|
+
children: [/* @__PURE__ */ Z(k, { children: /* @__PURE__ */ Z(A, { children: n }) }), p]
|
|
1845
1908
|
})
|
|
1846
|
-
}) : /* @__PURE__ */ Z(
|
|
1909
|
+
}) : /* @__PURE__ */ Z(M, {
|
|
1847
1910
|
open: e,
|
|
1848
1911
|
onOpenChange: (e) => !e && t(),
|
|
1849
|
-
children: /* @__PURE__ */ Q(
|
|
1912
|
+
children: /* @__PURE__ */ Q(ee, {
|
|
1850
1913
|
side: "right",
|
|
1851
1914
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
1852
|
-
children: [/* @__PURE__ */ Z(
|
|
1915
|
+
children: [/* @__PURE__ */ Z(te, { children: /* @__PURE__ */ Z(ne, { children: n }) }), /* @__PURE__ */ Z("div", {
|
|
1853
1916
|
className: "flex-1 overflow-hidden mt-2",
|
|
1854
1917
|
children: p
|
|
1855
1918
|
})]
|
|
1856
1919
|
})
|
|
1857
1920
|
});
|
|
1858
|
-
},
|
|
1859
|
-
let
|
|
1860
|
-
|
|
1921
|
+
}, st = ({ schema: e, dataSource: t, className: s }) => {
|
|
1922
|
+
let c = z(l), u = t || c?.dataSource, f = d(e.bind), [p, m] = H([]), [h, g] = H(!1), [v, y] = H(null), [b, x] = H({}), [S, C] = H({}), [w, T] = H(null), { fieldLabel: E, fieldOptionLabel: D } = _(), O = ae(E), k = ae(D);
|
|
1923
|
+
B(() => {
|
|
1861
1924
|
O.current = E, k.current = D;
|
|
1862
|
-
}, [E, D]),
|
|
1863
|
-
if (!
|
|
1864
|
-
let t =
|
|
1925
|
+
}, [E, D]), B(() => {
|
|
1926
|
+
if (!u || !e.objectName) return;
|
|
1927
|
+
let t = u.getObjectSchema;
|
|
1865
1928
|
if (typeof t != "function") return;
|
|
1866
1929
|
let n = !0;
|
|
1867
|
-
return Promise.resolve(t.call(
|
|
1930
|
+
return Promise.resolve(t.call(u, e.objectName)).then((t) => {
|
|
1868
1931
|
if (!n || !t?.fields) return;
|
|
1869
1932
|
let r = e.objectName, i = {}, a = {};
|
|
1870
1933
|
for (let [e, n] of Object.entries(t.fields)) {
|
|
@@ -1884,20 +1947,20 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1884
1947
|
}).catch(() => {}), () => {
|
|
1885
1948
|
n = !1;
|
|
1886
1949
|
};
|
|
1887
|
-
}, [
|
|
1950
|
+
}, [u, e.objectName]), B(() => {
|
|
1888
1951
|
let t = !0;
|
|
1889
1952
|
return e.objectName && !f && (!e.data || e.data.length === 0) && (async () => {
|
|
1890
|
-
if (!(!
|
|
1891
|
-
t && (
|
|
1953
|
+
if (!(!u || !e.objectName)) {
|
|
1954
|
+
t && (g(!0), y(null));
|
|
1892
1955
|
try {
|
|
1893
|
-
let
|
|
1894
|
-
if (typeof
|
|
1956
|
+
let n;
|
|
1957
|
+
if (typeof u.find == "function") n = r(await u.find(e.objectName, { $filter: a(e.filter) }));
|
|
1895
1958
|
else return;
|
|
1896
|
-
t && m(
|
|
1959
|
+
t && m(n);
|
|
1897
1960
|
} catch (e) {
|
|
1898
1961
|
console.error("[ObjectPivotTable] Fetch error:", e), t && y(e instanceof Error ? e.message : "Failed to load data");
|
|
1899
1962
|
} finally {
|
|
1900
|
-
t &&
|
|
1963
|
+
t && g(!1);
|
|
1901
1964
|
}
|
|
1902
1965
|
}
|
|
1903
1966
|
})(), () => {
|
|
@@ -1905,14 +1968,14 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1905
1968
|
};
|
|
1906
1969
|
}, [
|
|
1907
1970
|
e.objectName,
|
|
1908
|
-
|
|
1971
|
+
u,
|
|
1909
1972
|
f,
|
|
1910
1973
|
e.data,
|
|
1911
1974
|
e.filter
|
|
1912
1975
|
]);
|
|
1913
1976
|
let A = f || e.data || p, j = Array.isArray(A) ? A : [];
|
|
1914
|
-
if (
|
|
1915
|
-
className: P("overflow-auto",
|
|
1977
|
+
if (h && j.length === 0) return /* @__PURE__ */ Q("div", {
|
|
1978
|
+
className: P("overflow-auto", s),
|
|
1916
1979
|
"data-testid": "pivot-loading",
|
|
1917
1980
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
1918
1981
|
className: "text-sm font-semibold mb-2",
|
|
@@ -1943,7 +2006,7 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1943
2006
|
})]
|
|
1944
2007
|
});
|
|
1945
2008
|
if (v) return /* @__PURE__ */ Q("div", {
|
|
1946
|
-
className: P("overflow-auto",
|
|
2009
|
+
className: P("overflow-auto", s),
|
|
1947
2010
|
"data-testid": "pivot-error",
|
|
1948
2011
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
1949
2012
|
className: "text-sm font-semibold mb-2",
|
|
@@ -1985,8 +2048,8 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
1985
2048
|
})]
|
|
1986
2049
|
})]
|
|
1987
2050
|
});
|
|
1988
|
-
if (!
|
|
1989
|
-
className: P("overflow-auto",
|
|
2051
|
+
if (!u && e.objectName && j.length === 0) return /* @__PURE__ */ Q("div", {
|
|
2052
|
+
className: P("overflow-auto", s),
|
|
1990
2053
|
children: [e.title && /* @__PURE__ */ Z("h3", {
|
|
1991
2054
|
className: "text-sm font-semibold mb-2",
|
|
1992
2055
|
children: e.title
|
|
@@ -2005,37 +2068,37 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
2005
2068
|
let M = {
|
|
2006
2069
|
...e,
|
|
2007
2070
|
data: j
|
|
2008
|
-
}, ee = e.rowField ? b[e.rowField] : void 0,
|
|
2009
|
-
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(
|
|
2071
|
+
}, ee = e.rowField ? b[e.rowField] : void 0, te = e.columnField ? b[e.columnField] : void 0, ne = e.rowField ? S[e.rowField] : void 0, F = e.drillDown;
|
|
2072
|
+
return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(nt, {
|
|
2010
2073
|
schema: M,
|
|
2011
|
-
className:
|
|
2074
|
+
className: s,
|
|
2012
2075
|
rowLabels: ee,
|
|
2013
|
-
columnLabels:
|
|
2014
|
-
rowFieldLabel:
|
|
2015
|
-
onDrillDown:
|
|
2076
|
+
columnLabels: te,
|
|
2077
|
+
rowFieldLabel: ne,
|
|
2078
|
+
onDrillDown: i(F) ? (e) => T(e) : void 0
|
|
2016
2079
|
}), (() => {
|
|
2017
2080
|
if (!w || !e.objectName) return null;
|
|
2018
|
-
let
|
|
2081
|
+
let t = n(F, w, {
|
|
2019
2082
|
rowField: e.rowField,
|
|
2020
2083
|
columnField: e.columnField
|
|
2021
2084
|
}), r = {
|
|
2022
2085
|
...e.filter || {},
|
|
2023
|
-
...
|
|
2086
|
+
...t
|
|
2024
2087
|
};
|
|
2025
|
-
return /* @__PURE__ */ Z(
|
|
2088
|
+
return /* @__PURE__ */ Z(ot, {
|
|
2026
2089
|
open: !0,
|
|
2027
2090
|
onClose: () => T(null),
|
|
2028
|
-
title:
|
|
2029
|
-
target:
|
|
2091
|
+
title: o(F, w, e.title || "Details"),
|
|
2092
|
+
target: F?.target ?? "drawer",
|
|
2030
2093
|
objectName: e.objectName,
|
|
2031
2094
|
filter: r,
|
|
2032
|
-
dataSource:
|
|
2033
|
-
columns:
|
|
2034
|
-
maxRows:
|
|
2035
|
-
report:
|
|
2095
|
+
dataSource: u,
|
|
2096
|
+
columns: F?.columns,
|
|
2097
|
+
maxRows: F?.maxRows,
|
|
2098
|
+
report: F?.report
|
|
2036
2099
|
});
|
|
2037
2100
|
})()] });
|
|
2038
|
-
},
|
|
2101
|
+
}, ct = {
|
|
2039
2102
|
breadcrumb: ["Dashboard", "Configuration"],
|
|
2040
2103
|
sections: [
|
|
2041
2104
|
{
|
|
@@ -2161,12 +2224,12 @@ var nt = ({ schema: e, dataSource: t, className: r }) => {
|
|
|
2161
2224
|
}
|
|
2162
2225
|
]
|
|
2163
2226
|
};
|
|
2164
|
-
function
|
|
2165
|
-
let { draft: a, isDirty: o, updateField: s, discard: c } =
|
|
2166
|
-
return /* @__PURE__ */ Z(
|
|
2227
|
+
function lt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
2228
|
+
let { draft: a, isDirty: o, updateField: s, discard: c } = I(n, { onUpdate: i });
|
|
2229
|
+
return /* @__PURE__ */ Z(w, {
|
|
2167
2230
|
open: e,
|
|
2168
2231
|
onClose: t,
|
|
2169
|
-
schema:
|
|
2232
|
+
schema: ct,
|
|
2170
2233
|
draft: a,
|
|
2171
2234
|
isDirty: o,
|
|
2172
2235
|
onFieldChange: s,
|
|
@@ -2176,7 +2239,7 @@ function ot({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
|
2176
2239
|
}
|
|
2177
2240
|
//#endregion
|
|
2178
2241
|
//#region src/WidgetConfigPanel.tsx
|
|
2179
|
-
var
|
|
2242
|
+
var ut = [
|
|
2180
2243
|
{
|
|
2181
2244
|
value: "metric",
|
|
2182
2245
|
label: "Metric"
|
|
@@ -2221,7 +2284,7 @@ var st = [
|
|
|
2221
2284
|
value: "pivot",
|
|
2222
2285
|
label: "Pivot Table"
|
|
2223
2286
|
}
|
|
2224
|
-
],
|
|
2287
|
+
], dt = [
|
|
2225
2288
|
{
|
|
2226
2289
|
value: "default",
|
|
2227
2290
|
label: "Default"
|
|
@@ -2254,7 +2317,7 @@ var st = [
|
|
|
2254
2317
|
value: "danger",
|
|
2255
2318
|
label: "Danger"
|
|
2256
2319
|
}
|
|
2257
|
-
],
|
|
2320
|
+
], ft = [
|
|
2258
2321
|
{
|
|
2259
2322
|
value: "count",
|
|
2260
2323
|
label: "Count"
|
|
@@ -2275,7 +2338,7 @@ var st = [
|
|
|
2275
2338
|
value: "max",
|
|
2276
2339
|
label: "Max"
|
|
2277
2340
|
}
|
|
2278
|
-
],
|
|
2341
|
+
], pt = [
|
|
2279
2342
|
"bar",
|
|
2280
2343
|
"horizontal-bar",
|
|
2281
2344
|
"line",
|
|
@@ -2284,17 +2347,17 @@ var st = [
|
|
|
2284
2347
|
"donut",
|
|
2285
2348
|
"scatter",
|
|
2286
2349
|
"funnel"
|
|
2287
|
-
],
|
|
2350
|
+
], mt = [
|
|
2288
2351
|
"bar",
|
|
2289
2352
|
"horizontal-bar",
|
|
2290
2353
|
"line",
|
|
2291
2354
|
"area",
|
|
2292
2355
|
"scatter"
|
|
2293
|
-
],
|
|
2356
|
+
], ht = [
|
|
2294
2357
|
"pie",
|
|
2295
2358
|
"donut",
|
|
2296
2359
|
"funnel"
|
|
2297
|
-
],
|
|
2360
|
+
], gt = ["metric", ...pt], _t = [...pt], vt = [
|
|
2298
2361
|
"pivot",
|
|
2299
2362
|
"metric",
|
|
2300
2363
|
"bar",
|
|
@@ -2305,50 +2368,50 @@ var st = [
|
|
|
2305
2368
|
"donut",
|
|
2306
2369
|
"funnel"
|
|
2307
2370
|
];
|
|
2308
|
-
function gt(e) {
|
|
2309
|
-
return !!e && ut.includes(e);
|
|
2310
|
-
}
|
|
2311
|
-
function _t(e) {
|
|
2312
|
-
return !!e && dt.includes(e);
|
|
2313
|
-
}
|
|
2314
|
-
function vt(e) {
|
|
2315
|
-
return !!e && mt.includes(e);
|
|
2316
|
-
}
|
|
2317
2371
|
function yt(e) {
|
|
2318
2372
|
return !!e && pt.includes(e);
|
|
2319
2373
|
}
|
|
2320
2374
|
function bt(e) {
|
|
2321
|
-
return !!e &&
|
|
2375
|
+
return !!e && mt.includes(e);
|
|
2376
|
+
}
|
|
2377
|
+
function xt(e) {
|
|
2378
|
+
return !!e && _t.includes(e);
|
|
2322
2379
|
}
|
|
2323
|
-
|
|
2380
|
+
function St(e) {
|
|
2381
|
+
return !!e && gt.includes(e);
|
|
2382
|
+
}
|
|
2383
|
+
function Ct(e) {
|
|
2384
|
+
return !!e && vt.includes(e);
|
|
2385
|
+
}
|
|
2386
|
+
var wt = [{
|
|
2324
2387
|
value: "drawer",
|
|
2325
2388
|
label: "Side drawer"
|
|
2326
2389
|
}, {
|
|
2327
2390
|
value: "dialog",
|
|
2328
2391
|
label: "Center dialog"
|
|
2329
|
-
}],
|
|
2392
|
+
}], Tt = [{
|
|
2330
2393
|
value: "group",
|
|
2331
2394
|
label: "Group"
|
|
2332
2395
|
}, {
|
|
2333
2396
|
value: "value",
|
|
2334
2397
|
label: "Value"
|
|
2335
|
-
}],
|
|
2398
|
+
}], Et = [{
|
|
2336
2399
|
value: "asc",
|
|
2337
2400
|
label: "↑"
|
|
2338
2401
|
}, {
|
|
2339
2402
|
value: "desc",
|
|
2340
2403
|
label: "↓"
|
|
2341
2404
|
}];
|
|
2342
|
-
function
|
|
2405
|
+
function Dt(e, t, n, r) {
|
|
2343
2406
|
return {
|
|
2344
2407
|
key: e,
|
|
2345
2408
|
label: t,
|
|
2346
2409
|
type: "custom",
|
|
2347
|
-
render: (i, a, o) => /* @__PURE__ */ Z(
|
|
2410
|
+
render: (i, a, o) => /* @__PURE__ */ Z(T, {
|
|
2348
2411
|
label: t,
|
|
2349
2412
|
children: /* @__PURE__ */ Z("div", {
|
|
2350
2413
|
"data-testid": `config-field-${e}`,
|
|
2351
|
-
children: /* @__PURE__ */ Z(
|
|
2414
|
+
children: /* @__PURE__ */ Z(C, {
|
|
2352
2415
|
options: r ?? [],
|
|
2353
2416
|
value: i ?? "",
|
|
2354
2417
|
onValueChange: a,
|
|
@@ -2362,16 +2425,16 @@ function wt(e, t, n, r) {
|
|
|
2362
2425
|
})
|
|
2363
2426
|
};
|
|
2364
2427
|
}
|
|
2365
|
-
function
|
|
2428
|
+
function Ot(e, t, n) {
|
|
2366
2429
|
let r = e && e.length > 0, i = r ? {
|
|
2367
2430
|
key: "object",
|
|
2368
2431
|
label: "Data source",
|
|
2369
2432
|
type: "custom",
|
|
2370
|
-
render: (t, n) => /* @__PURE__ */ Z(
|
|
2433
|
+
render: (t, n) => /* @__PURE__ */ Z(T, {
|
|
2371
2434
|
label: "Data source",
|
|
2372
2435
|
children: /* @__PURE__ */ Z("div", {
|
|
2373
2436
|
"data-testid": "config-field-object",
|
|
2374
|
-
children: /* @__PURE__ */ Z(
|
|
2437
|
+
children: /* @__PURE__ */ Z(C, {
|
|
2375
2438
|
options: e,
|
|
2376
2439
|
value: t ?? "",
|
|
2377
2440
|
onValueChange: n,
|
|
@@ -2388,38 +2451,38 @@ function Tt(e, t, n) {
|
|
|
2388
2451
|
type: "input",
|
|
2389
2452
|
placeholder: "Object name"
|
|
2390
2453
|
}, a = r ? {
|
|
2391
|
-
...
|
|
2454
|
+
...Dt("categoryField", "Category field", "Select field…", t),
|
|
2392
2455
|
helpText: "Group records by this field (one bar/slice/segment per value).",
|
|
2393
|
-
visibleWhen: (e) =>
|
|
2456
|
+
visibleWhen: (e) => xt(e.type)
|
|
2394
2457
|
} : {
|
|
2395
2458
|
key: "categoryField",
|
|
2396
2459
|
label: "Category field",
|
|
2397
2460
|
type: "input",
|
|
2398
2461
|
placeholder: "e.g. status",
|
|
2399
2462
|
helpText: "Group records by this field (one bar/slice/segment per value).",
|
|
2400
|
-
visibleWhen: (e) =>
|
|
2463
|
+
visibleWhen: (e) => xt(e.type)
|
|
2401
2464
|
}, o = r ? {
|
|
2402
|
-
...
|
|
2465
|
+
...Dt("valueField", "Value field", "Select field…", t),
|
|
2403
2466
|
helpText: "Field to aggregate (sum / average / min / max).",
|
|
2404
|
-
visibleWhen: (e) =>
|
|
2467
|
+
visibleWhen: (e) => St(e.type) && (e.aggregate ?? "count") !== "count"
|
|
2405
2468
|
} : {
|
|
2406
2469
|
key: "valueField",
|
|
2407
2470
|
label: "Value field",
|
|
2408
2471
|
type: "input",
|
|
2409
2472
|
placeholder: "e.g. amount",
|
|
2410
2473
|
helpText: "Field to aggregate (sum / average / min / max).",
|
|
2411
|
-
visibleWhen: (e) =>
|
|
2412
|
-
}, s = r ?
|
|
2474
|
+
visibleWhen: (e) => St(e.type) && (e.aggregate ?? "count") !== "count"
|
|
2475
|
+
}, s = r ? Dt("rowField", "Field", "Select row field…", t) : {
|
|
2413
2476
|
key: "rowField",
|
|
2414
2477
|
label: "Field",
|
|
2415
2478
|
type: "input",
|
|
2416
2479
|
placeholder: "e.g. owner"
|
|
2417
|
-
}, c = r ?
|
|
2480
|
+
}, c = r ? Dt("columnField", "Field", "Select column field…", t) : {
|
|
2418
2481
|
key: "columnField",
|
|
2419
2482
|
label: "Field",
|
|
2420
2483
|
type: "input",
|
|
2421
2484
|
placeholder: "e.g. stage"
|
|
2422
|
-
}, l = r ?
|
|
2485
|
+
}, l = r ? Dt("valueField", "Field", "Select value field…", t) : {
|
|
2423
2486
|
key: "valueField",
|
|
2424
2487
|
label: "Field",
|
|
2425
2488
|
type: "input",
|
|
@@ -2429,7 +2492,7 @@ function Tt(e, t, n) {
|
|
|
2429
2492
|
breadcrumb: ["Dashboard", {
|
|
2430
2493
|
pivot: "Pivot table",
|
|
2431
2494
|
table: "Table"
|
|
2432
|
-
}[n ?? ""] ?? (
|
|
2495
|
+
}[n ?? ""] ?? (yt(n) ? "Chart" : "Widget")],
|
|
2433
2496
|
sections: [
|
|
2434
2497
|
{
|
|
2435
2498
|
key: "general",
|
|
@@ -2451,7 +2514,7 @@ function Tt(e, t, n) {
|
|
|
2451
2514
|
key: "type",
|
|
2452
2515
|
label: "Widget type",
|
|
2453
2516
|
type: "select",
|
|
2454
|
-
options:
|
|
2517
|
+
options: ut,
|
|
2455
2518
|
defaultValue: "metric"
|
|
2456
2519
|
}
|
|
2457
2520
|
]
|
|
@@ -2469,10 +2532,10 @@ function Tt(e, t, n) {
|
|
|
2469
2532
|
key: "aggregate",
|
|
2470
2533
|
label: "Aggregation",
|
|
2471
2534
|
type: "select",
|
|
2472
|
-
options:
|
|
2535
|
+
options: ft,
|
|
2473
2536
|
defaultValue: "count",
|
|
2474
2537
|
helpText: "Count ignores Value field; Sum / Avg / Min / Max require it.",
|
|
2475
|
-
visibleWhen: (e) =>
|
|
2538
|
+
visibleWhen: (e) => St(e.type)
|
|
2476
2539
|
}
|
|
2477
2540
|
]
|
|
2478
2541
|
},
|
|
@@ -2494,14 +2557,14 @@ function Tt(e, t, n) {
|
|
|
2494
2557
|
key: "rowSortBy",
|
|
2495
2558
|
label: "Sort by",
|
|
2496
2559
|
type: "icon-group",
|
|
2497
|
-
options:
|
|
2560
|
+
options: Tt,
|
|
2498
2561
|
defaultValue: "group"
|
|
2499
2562
|
},
|
|
2500
2563
|
{
|
|
2501
2564
|
key: "rowSortOrder",
|
|
2502
2565
|
label: "Sort order",
|
|
2503
2566
|
type: "icon-group",
|
|
2504
|
-
options:
|
|
2567
|
+
options: Et,
|
|
2505
2568
|
defaultValue: "asc"
|
|
2506
2569
|
},
|
|
2507
2570
|
{
|
|
@@ -2529,14 +2592,14 @@ function Tt(e, t, n) {
|
|
|
2529
2592
|
key: "columnSortBy",
|
|
2530
2593
|
label: "Sort by",
|
|
2531
2594
|
type: "icon-group",
|
|
2532
|
-
options:
|
|
2595
|
+
options: Tt,
|
|
2533
2596
|
defaultValue: "group"
|
|
2534
2597
|
},
|
|
2535
2598
|
{
|
|
2536
2599
|
key: "columnSortOrder",
|
|
2537
2600
|
label: "Sort order",
|
|
2538
2601
|
type: "icon-group",
|
|
2539
|
-
options:
|
|
2602
|
+
options: Et,
|
|
2540
2603
|
defaultValue: "asc"
|
|
2541
2604
|
},
|
|
2542
2605
|
{
|
|
@@ -2564,7 +2627,7 @@ function Tt(e, t, n) {
|
|
|
2564
2627
|
key: "aggregation",
|
|
2565
2628
|
label: "Aggregation",
|
|
2566
2629
|
type: "select",
|
|
2567
|
-
options:
|
|
2630
|
+
options: ft,
|
|
2568
2631
|
defaultValue: "sum"
|
|
2569
2632
|
},
|
|
2570
2633
|
{
|
|
@@ -2579,7 +2642,7 @@ function Tt(e, t, n) {
|
|
|
2579
2642
|
key: "chart-axis",
|
|
2580
2643
|
title: "Axis & Series",
|
|
2581
2644
|
collapsible: !0,
|
|
2582
|
-
visibleWhen: (e) =>
|
|
2645
|
+
visibleWhen: (e) => bt(e.type),
|
|
2583
2646
|
fields: [
|
|
2584
2647
|
{
|
|
2585
2648
|
key: "xAxisLabel",
|
|
@@ -2605,7 +2668,7 @@ function Tt(e, t, n) {
|
|
|
2605
2668
|
key: "chart-legend",
|
|
2606
2669
|
title: "Display",
|
|
2607
2670
|
collapsible: !0,
|
|
2608
|
-
visibleWhen: (e) => !!e.type &&
|
|
2671
|
+
visibleWhen: (e) => !!e.type && ht.includes(e.type),
|
|
2609
2672
|
fields: [{
|
|
2610
2673
|
key: "showLegend",
|
|
2611
2674
|
label: "Show legend",
|
|
@@ -2657,7 +2720,7 @@ function Tt(e, t, n) {
|
|
|
2657
2720
|
title: "Drill-down",
|
|
2658
2721
|
collapsible: !0,
|
|
2659
2722
|
defaultCollapsed: !0,
|
|
2660
|
-
visibleWhen: (e) =>
|
|
2723
|
+
visibleWhen: (e) => Ct(e.type),
|
|
2661
2724
|
fields: [{
|
|
2662
2725
|
key: "drillDownEnabled",
|
|
2663
2726
|
label: "Enable drill-down",
|
|
@@ -2668,7 +2731,7 @@ function Tt(e, t, n) {
|
|
|
2668
2731
|
key: "drillDownTarget",
|
|
2669
2732
|
label: "Open in",
|
|
2670
2733
|
type: "select",
|
|
2671
|
-
options:
|
|
2734
|
+
options: wt,
|
|
2672
2735
|
defaultValue: "drawer",
|
|
2673
2736
|
visibleWhen: (e) => !!e.drillDownEnabled
|
|
2674
2737
|
}]
|
|
@@ -2694,14 +2757,14 @@ function Tt(e, t, n) {
|
|
|
2694
2757
|
key: "colorVariant",
|
|
2695
2758
|
label: "Color variant",
|
|
2696
2759
|
type: "select",
|
|
2697
|
-
options:
|
|
2760
|
+
options: dt,
|
|
2698
2761
|
defaultValue: "default"
|
|
2699
2762
|
}]
|
|
2700
2763
|
}
|
|
2701
2764
|
]
|
|
2702
2765
|
};
|
|
2703
2766
|
}
|
|
2704
|
-
function
|
|
2767
|
+
function kt(e) {
|
|
2705
2768
|
if (e == null) return "";
|
|
2706
2769
|
if (typeof e == "string") return e;
|
|
2707
2770
|
if (typeof e == "object") {
|
|
@@ -2710,20 +2773,20 @@ function Et(e) {
|
|
|
2710
2773
|
}
|
|
2711
2774
|
return String(e);
|
|
2712
2775
|
}
|
|
2713
|
-
function
|
|
2776
|
+
function At(e) {
|
|
2714
2777
|
let t = e.type, n = { ...e };
|
|
2715
|
-
return
|
|
2778
|
+
return xt(t) || delete n.categoryField, St(t) ? (n.aggregate ?? "count") === "count" && delete n.valueField : (delete n.valueField, delete n.aggregate), bt(t) || (delete n.xAxisLabel, delete n.yAxisLabel), t === "pivot" ? (delete n.aggregate, delete n.categoryField) : (delete n.rowField, delete n.columnField, delete n.aggregation, delete n.rowSortBy, delete n.rowSortOrder, delete n.columnSortBy, delete n.columnSortOrder, delete n.showRowLabels, delete n.showRowTotals, delete n.showColumnLabels, delete n.showColumnTotals, delete n.format), t !== "table" && (delete n.searchable, delete n.pagination), Ct(t) || (delete n.drillDownEnabled, delete n.drillDownTarget), n;
|
|
2716
2779
|
}
|
|
2717
|
-
function
|
|
2718
|
-
let { draft: c, isDirty: l, updateField: u, discard: d } =
|
|
2780
|
+
function jt({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, headerExtra: a, availableObjects: o, availableFields: s }) {
|
|
2781
|
+
let { draft: c, isDirty: l, updateField: u, discard: d } = I(L.useMemo(() => ({
|
|
2719
2782
|
...n,
|
|
2720
|
-
title: typeof n.title == "object" ?
|
|
2721
|
-
description: typeof n.description == "object" ?
|
|
2783
|
+
title: typeof n.title == "object" ? kt(n.title) : n.title,
|
|
2784
|
+
description: typeof n.description == "object" ? kt(n.description) : n.description
|
|
2722
2785
|
}), [n]), { onUpdate: i });
|
|
2723
|
-
return /* @__PURE__ */ Z(
|
|
2786
|
+
return /* @__PURE__ */ Z(w, {
|
|
2724
2787
|
open: e,
|
|
2725
2788
|
onClose: t,
|
|
2726
|
-
schema:
|
|
2789
|
+
schema: L.useMemo(() => Ot(o, s, c.type), [
|
|
2727
2790
|
o,
|
|
2728
2791
|
s,
|
|
2729
2792
|
c.type
|
|
@@ -2731,19 +2794,19 @@ function Ot({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i, heade
|
|
|
2731
2794
|
draft: c,
|
|
2732
2795
|
isDirty: l,
|
|
2733
2796
|
onFieldChange: u,
|
|
2734
|
-
onSave: () => r(
|
|
2797
|
+
onSave: () => r(At(c)),
|
|
2735
2798
|
onDiscard: d,
|
|
2736
2799
|
headerExtra: a
|
|
2737
2800
|
});
|
|
2738
2801
|
}
|
|
2739
2802
|
//#endregion
|
|
2740
2803
|
//#region src/DashboardWithConfig.tsx
|
|
2741
|
-
function
|
|
2742
|
-
let [c, l] =
|
|
2743
|
-
|
|
2804
|
+
function Mt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh: i, recordCount: a, defaultConfigOpen: o = !1, className: s }) {
|
|
2805
|
+
let [c, l] = H(o), [u, d] = H(null), [f, p] = H(e), [m, h] = H(0);
|
|
2806
|
+
B(() => {
|
|
2744
2807
|
p(e), h((e) => e + 1);
|
|
2745
2808
|
}, [e]);
|
|
2746
|
-
let
|
|
2809
|
+
let g = L.useMemo(() => {
|
|
2747
2810
|
if (!u || !f.widgets) return null;
|
|
2748
2811
|
let e = f.widgets.find((e) => (e.id || e.title) === u);
|
|
2749
2812
|
if (!e) return null;
|
|
@@ -2765,7 +2828,7 @@ function kt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2765
2828
|
layoutW: e.layout?.w ?? 1,
|
|
2766
2829
|
layoutH: e.layout?.h ?? 1
|
|
2767
2830
|
};
|
|
2768
|
-
}, [u, m]),
|
|
2831
|
+
}, [u, m]), _ = R((e) => {
|
|
2769
2832
|
d(e), l(!0);
|
|
2770
2833
|
}, []), y = R(() => {
|
|
2771
2834
|
d(null);
|
|
@@ -2833,30 +2896,30 @@ function kt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2833
2896
|
className: "flex-1 min-w-0 overflow-auto relative",
|
|
2834
2897
|
children: [/* @__PURE__ */ Z("div", {
|
|
2835
2898
|
className: "absolute top-2 right-2 z-10",
|
|
2836
|
-
children: /* @__PURE__ */ Q(
|
|
2899
|
+
children: /* @__PURE__ */ Q(v, {
|
|
2837
2900
|
size: "sm",
|
|
2838
2901
|
variant: c ? "default" : "outline",
|
|
2839
2902
|
onClick: S,
|
|
2840
2903
|
"data-testid": "dashboard-config-toggle",
|
|
2841
|
-
children: [/* @__PURE__ */ Z(
|
|
2904
|
+
children: [/* @__PURE__ */ Z(q, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
|
|
2842
2905
|
})
|
|
2843
|
-
}), /* @__PURE__ */ Z(
|
|
2906
|
+
}), /* @__PURE__ */ Z(Fe, {
|
|
2844
2907
|
schema: f,
|
|
2845
2908
|
onRefresh: i,
|
|
2846
2909
|
recordCount: a,
|
|
2847
2910
|
designMode: c,
|
|
2848
2911
|
selectedWidgetId: u,
|
|
2849
|
-
onWidgetClick:
|
|
2912
|
+
onWidgetClick: _
|
|
2850
2913
|
})]
|
|
2851
2914
|
}), c && /* @__PURE__ */ Z("div", {
|
|
2852
2915
|
className: "relative shrink-0",
|
|
2853
|
-
children: u &&
|
|
2916
|
+
children: u && g ? /* @__PURE__ */ Z(jt, {
|
|
2854
2917
|
open: !0,
|
|
2855
2918
|
onClose: y,
|
|
2856
|
-
config:
|
|
2919
|
+
config: g,
|
|
2857
2920
|
onSave: x,
|
|
2858
2921
|
onFieldChange: b
|
|
2859
|
-
}) : /* @__PURE__ */ Z(
|
|
2922
|
+
}) : /* @__PURE__ */ Z(lt, {
|
|
2860
2923
|
open: !0,
|
|
2861
2924
|
onClose: () => l(!1),
|
|
2862
2925
|
config: t,
|
|
@@ -2865,7 +2928,7 @@ function kt({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
2865
2928
|
})]
|
|
2866
2929
|
});
|
|
2867
2930
|
}
|
|
2868
|
-
e.register("dashboard",
|
|
2931
|
+
e.register("dashboard", Fe, {
|
|
2869
2932
|
namespace: "view",
|
|
2870
2933
|
label: "Dashboard",
|
|
2871
2934
|
category: "Complex",
|
|
@@ -2893,7 +2956,7 @@ e.register("dashboard", Me, {
|
|
|
2893
2956
|
columns: 3,
|
|
2894
2957
|
widgets: []
|
|
2895
2958
|
}
|
|
2896
|
-
}), e.register("metric",
|
|
2959
|
+
}), e.register("metric", Ke, {
|
|
2897
2960
|
namespace: "plugin-dashboard",
|
|
2898
2961
|
label: "Metric Widget",
|
|
2899
2962
|
category: "Dashboard",
|
|
@@ -2906,7 +2969,7 @@ e.register("dashboard", Me, {
|
|
|
2906
2969
|
type: "string",
|
|
2907
2970
|
label: "Value"
|
|
2908
2971
|
}]
|
|
2909
|
-
}), e.register("metric-card",
|
|
2972
|
+
}), e.register("metric-card", Je, {
|
|
2910
2973
|
namespace: "plugin-dashboard",
|
|
2911
2974
|
label: "Metric Card",
|
|
2912
2975
|
category: "Dashboard",
|
|
@@ -2961,7 +3024,7 @@ e.register("dashboard", Me, {
|
|
|
2961
3024
|
title: "Metric",
|
|
2962
3025
|
value: "0"
|
|
2963
3026
|
}
|
|
2964
|
-
}), e.register("object-metric",
|
|
3027
|
+
}), e.register("object-metric", Ye, {
|
|
2965
3028
|
namespace: "plugin-dashboard",
|
|
2966
3029
|
label: "Object Metric",
|
|
2967
3030
|
category: "Dashboard",
|
|
@@ -2990,7 +3053,7 @@ e.register("dashboard", Me, {
|
|
|
2990
3053
|
}
|
|
2991
3054
|
],
|
|
2992
3055
|
defaultProps: { label: "Metric" }
|
|
2993
|
-
}), e.register("pivot",
|
|
3056
|
+
}), e.register("pivot", nt, {
|
|
2994
3057
|
namespace: "plugin-dashboard",
|
|
2995
3058
|
label: "Pivot Table",
|
|
2996
3059
|
category: "Dashboard",
|
|
@@ -3069,7 +3132,7 @@ e.register("dashboard", Me, {
|
|
|
3069
3132
|
aggregation: "sum",
|
|
3070
3133
|
data: []
|
|
3071
3134
|
}
|
|
3072
|
-
}), e.register("object-pivot",
|
|
3135
|
+
}), e.register("object-pivot", st, {
|
|
3073
3136
|
namespace: "plugin-dashboard",
|
|
3074
3137
|
label: "Object Pivot Table",
|
|
3075
3138
|
category: "Dashboard",
|
|
@@ -3158,7 +3221,7 @@ e.register("dashboard", Me, {
|
|
|
3158
3221
|
valueField: "",
|
|
3159
3222
|
aggregation: "sum"
|
|
3160
3223
|
}
|
|
3161
|
-
}), e.register("dashboard-grid",
|
|
3224
|
+
}), e.register("dashboard-grid", Be, {
|
|
3162
3225
|
namespace: "plugin-dashboard",
|
|
3163
3226
|
label: "Dashboard Grid (Editable)",
|
|
3164
3227
|
category: "Complex",
|
|
@@ -3176,7 +3239,7 @@ e.register("dashboard", Me, {
|
|
|
3176
3239
|
title: "Dashboard",
|
|
3177
3240
|
widgets: []
|
|
3178
3241
|
}
|
|
3179
|
-
}), e.register("object-data-table",
|
|
3242
|
+
}), e.register("object-data-table", at, {
|
|
3180
3243
|
namespace: "plugin-dashboard",
|
|
3181
3244
|
label: "Object Data Table",
|
|
3182
3245
|
category: "Dashboard",
|
|
@@ -3214,18 +3277,18 @@ e.register("dashboard", Me, {
|
|
|
3214
3277
|
pagination: !1
|
|
3215
3278
|
}
|
|
3216
3279
|
});
|
|
3217
|
-
var
|
|
3218
|
-
DashboardRenderer:
|
|
3219
|
-
DashboardGridLayout:
|
|
3220
|
-
MetricWidget:
|
|
3221
|
-
MetricCard:
|
|
3222
|
-
ObjectMetricWidget:
|
|
3223
|
-
PivotTable:
|
|
3224
|
-
ObjectPivotTable:
|
|
3225
|
-
ObjectDataTable:
|
|
3226
|
-
DashboardConfigPanel:
|
|
3227
|
-
WidgetConfigPanel:
|
|
3228
|
-
DashboardWithConfig:
|
|
3280
|
+
var Nt = {
|
|
3281
|
+
DashboardRenderer: Fe,
|
|
3282
|
+
DashboardGridLayout: Be,
|
|
3283
|
+
MetricWidget: Ke,
|
|
3284
|
+
MetricCard: Je,
|
|
3285
|
+
ObjectMetricWidget: Ye,
|
|
3286
|
+
PivotTable: nt,
|
|
3287
|
+
ObjectPivotTable: st,
|
|
3288
|
+
ObjectDataTable: at,
|
|
3289
|
+
DashboardConfigPanel: lt,
|
|
3290
|
+
WidgetConfigPanel: jt,
|
|
3291
|
+
DashboardWithConfig: Mt
|
|
3229
3292
|
};
|
|
3230
3293
|
//#endregion
|
|
3231
|
-
export {
|
|
3294
|
+
export { lt as DashboardConfigPanel, Be as DashboardGridLayout, Fe as DashboardRenderer, Mt as DashboardWithConfig, ot as DrillDownDrawer, Je as MetricCard, Ke as MetricWidget, at as ObjectDataTable, Ye as ObjectMetricWidget, st as ObjectPivotTable, nt as PivotTable, jt as WidgetConfigPanel, Nt as dashboardComponents };
|