@object-ui/plugin-dashboard 17.3.0 → 17.5.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 +922 -0
- package/README.md +52 -15
- package/dist/DashboardFilterBar.d.ts.map +1 -1
- package/dist/DashboardGridLayout.d.ts +27 -0
- package/dist/DashboardGridLayout.d.ts.map +1 -1
- package/dist/DashboardRenderer.d.ts +46 -4
- package/dist/DashboardRenderer.d.ts.map +1 -1
- package/dist/DashboardWithConfig.d.ts.map +1 -1
- package/dist/DatasetWidget.d.ts +174 -6
- package/dist/DatasetWidget.d.ts.map +1 -1
- package/dist/MetricCard.d.ts +29 -10
- package/dist/MetricCard.d.ts.map +1 -1
- package/dist/MetricWidget.d.ts +82 -17
- package/dist/MetricWidget.d.ts.map +1 -1
- package/dist/ObjectDataTable.d.ts.map +1 -1
- package/dist/ObjectMetricWidget.d.ts +10 -7
- package/dist/ObjectMetricWidget.d.ts.map +1 -1
- package/dist/RecordDetailDrawer.d.ts.map +1 -1
- package/dist/WidgetConfigPanel.d.ts.map +1 -1
- package/dist/colorVariants.d.ts +56 -0
- package/dist/colorVariants.d.ts.map +1 -0
- package/dist/domPassthroughPins.d.ts +9 -0
- package/dist/domPassthroughPins.d.ts.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1506 -1268
- package/dist/index.umd.cjs +2 -2
- package/dist/legacyRetiredWidget.d.ts +41 -0
- package/dist/legacyRetiredWidget.d.ts.map +1 -0
- package/dist/recordFields.d.ts +1 -1
- package/dist/recordFields.d.ts.map +1 -1
- package/dist/schemaHostProps.d.ts +80 -0
- package/dist/schemaHostProps.d.ts.map +1 -0
- package/dist/utils.d.ts +34 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +13 -12
package/dist/index.js
CHANGED
|
@@ -1,22 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { AlertCircle as
|
|
8
|
-
import { DndContext as
|
|
9
|
-
import { SortableContext as
|
|
10
|
-
import { CSS as
|
|
11
|
-
import { formatCurrency as
|
|
12
|
-
import { Fragment as
|
|
13
|
-
import { ResponsiveGridLayout as
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
import t, { Fragment as n, forwardRef as r, useCallback as i, useContext as a, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
3
|
+
import { ComponentRegistry as u, DATE_RANGE_PRESETS as d, buildCategoryOrder as f, buildChartSeries as p, buildDatasetDrillFilter as m, buildDatasetFieldHelpers as h, buildOptionColorMap as g, buildWidgetScopedFilter as _, compareToTrendLabelKey as v, compareToTrendLabelKey as y, computeDrillFilter as b, dashboardFilterVariableDefs as x, deriveDimensionLabelMaps as S, dimensionOptionTranslator as C, extractRecords as w, findChartSeriesRow as T, formatDimensionValue as E, formatMeasure as D, isDrillEnabled as O, localizeFieldOptions as k, mergeFilters as A, pivotBucketId as j, pivotCellKey as M, pivotDimensionValue as N, relabelDimensions as ee, resolveDashboardFilterDefs as te, resolveDrillTitle as ne, resolveFilterPlaceholders as re, shiftFilterByCompareTo as P, toDomProps as ie } from "@object-ui/core";
|
|
4
|
+
import { ElementDataSourceGate as F, PageVariablesProvider as ae, SchemaRenderer as oe, SchemaRendererContext as se, useActionEngine as I, useDataScope as L, useDatasetDimensionMeta as ce, useDnd as R, useDrillNavigation as le, useFilterScope as ue, useHasDndProvider as z, useObjectLabel as de, usePageVariables as fe } from "@object-ui/react";
|
|
5
|
+
import { createSafeTranslation as B, formatDisplayNumber as V, pickLocalized as H, resolveFieldCurrency as U, useDisplayLocale as pe, useLocalization as me, useObjectTranslation as W, useSafeFieldLabel as he, useSafeTranslate as G } from "@object-ui/i18n";
|
|
6
|
+
import { Button as K, Calendar as q, Card as J, CardContent as ge, CardHeader as _e, CardTitle as ve, ChartSkeleton as ye, Combobox as be, ConfigPanelRenderer as xe, ConfigRow as Y, DataEmptyState as Se, Dialog as Ce, DialogContent as we, DialogHeader as Te, DialogTitle as Ee, GridSkeleton as De, Input as Oe, Popover as ke, PopoverContent as Ae, PopoverTrigger as je, RefreshIndicator as Me, Select as Ne, SelectContent as Pe, SelectItem as Fe, SelectTrigger as Ie, SelectValue as Le, Sheet as Re, SheetContent as ze, SheetHeader as Be, SheetTitle as Ve, Skeleton as X, cn as Z, getLazyIcon as He, useConfigDraft as Ue } from "@object-ui/components";
|
|
7
|
+
import { AlertCircle as We, AlertTriangle as Ge, ArrowDownIcon as Ke, ArrowUpIcon as qe, ArrowUpRight as Je, BarChart3 as Ye, CalendarIcon as Xe, Download as Ze, Edit as Qe, GripVertical as $e, Loader2 as et, MinusIcon as tt, RefreshCw as nt, RotateCcw as rt, Save as it, Settings as at, X as ot } from "lucide-react";
|
|
8
|
+
import { DndContext as st, PointerSensor as ct, closestCenter as lt, useSensor as ut, useSensors as dt } from "@dnd-kit/core";
|
|
9
|
+
import { SortableContext as ft, arrayMove as pt, rectSortingStrategy as mt, useSortable as ht, verticalListSortingStrategy as gt } from "@dnd-kit/sortable";
|
|
10
|
+
import { CSS as _t } from "@dnd-kit/utilities";
|
|
11
|
+
import { formatCurrency as vt, formatDate as yt, formatPercent as bt, getCellRenderer as xt, resolveCellRendererType as St } from "@object-ui/fields";
|
|
12
|
+
import { Fragment as Ct, jsx as Q, jsxs as $ } from "react/jsx-runtime";
|
|
13
|
+
import { ResponsiveGridLayout as wt, useContainerWidth as Tt } from "react-grid-layout";
|
|
14
14
|
import "react-grid-layout/css/styles.css";
|
|
15
15
|
//#region src/utils.ts
|
|
16
|
-
function
|
|
16
|
+
function Et(e) {
|
|
17
17
|
return typeof e == "object" && !!e && !Array.isArray(e) && e.provider === "object";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function Dt(e) {
|
|
20
|
+
return e.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
21
|
+
}
|
|
22
|
+
function Ot(e) {
|
|
23
|
+
if (!Array.isArray(e) || e.length === 0) return [];
|
|
24
|
+
let t = e[0];
|
|
25
|
+
return typeof t != "object" || !t || Array.isArray(t) ? [] : Object.keys(t).filter((e) => !e.startsWith("_")).map((e) => ({
|
|
26
|
+
header: Dt(e),
|
|
27
|
+
accessorKey: e
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function kt(e, t) {
|
|
20
31
|
if (t == null || e == null || typeof e != "number" || !Number.isFinite(e) || typeof t != "number" || !Number.isFinite(t)) return null;
|
|
21
32
|
if (t === 0) return e === 0 ? {
|
|
22
33
|
value: 0,
|
|
@@ -38,7 +49,7 @@ function _t(e, t) {
|
|
|
38
49
|
}
|
|
39
50
|
//#endregion
|
|
40
51
|
//#region src/widgetDispatch.ts
|
|
41
|
-
var
|
|
52
|
+
var At = {
|
|
42
53
|
column: "bar",
|
|
43
54
|
"stacked-bar": "bar",
|
|
44
55
|
"grouped-bar": "bar",
|
|
@@ -48,7 +59,7 @@ var vt = {
|
|
|
48
59
|
"stacked-area": "area",
|
|
49
60
|
pyramid: "funnel",
|
|
50
61
|
bubble: "scatter"
|
|
51
|
-
},
|
|
62
|
+
}, jt = /* @__PURE__ */ new Set([
|
|
52
63
|
"bar",
|
|
53
64
|
"horizontal-bar",
|
|
54
65
|
"line",
|
|
@@ -61,13 +72,13 @@ var vt = {
|
|
|
61
72
|
"treemap",
|
|
62
73
|
"sankey",
|
|
63
74
|
"combo"
|
|
64
|
-
]),
|
|
75
|
+
]), Mt = /* @__PURE__ */ new Set([
|
|
65
76
|
"metric",
|
|
66
77
|
"gauge",
|
|
67
78
|
"solid-gauge",
|
|
68
79
|
"kpi",
|
|
69
80
|
"bullet"
|
|
70
|
-
]),
|
|
81
|
+
]), Nt = /* @__PURE__ */ new Set(["table", "list"]), Pt = /* @__PURE__ */ new Set([
|
|
71
82
|
"sunburst",
|
|
72
83
|
"word-cloud",
|
|
73
84
|
"choropleth",
|
|
@@ -80,17 +91,55 @@ var vt = {
|
|
|
80
91
|
"candlestick",
|
|
81
92
|
"stock"
|
|
82
93
|
]);
|
|
83
|
-
function
|
|
94
|
+
function Ft(e) {
|
|
84
95
|
if (!e) return { family: "passthrough" };
|
|
85
|
-
let t =
|
|
86
|
-
return
|
|
96
|
+
let t = At[e] ?? e;
|
|
97
|
+
return jt.has(t) ? {
|
|
87
98
|
family: "series",
|
|
88
99
|
chartType: t
|
|
89
|
-
} :
|
|
100
|
+
} : Mt.has(e) ? { family: "metric" } : Nt.has(e) ? { family: "table" } : e === "pivot" ? { family: "pivot" } : e === "custom" ? { family: "custom" } : Pt.has(e) ? { family: "unsupported" } : { family: "passthrough" };
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/legacyRetiredWidget.ts
|
|
104
|
+
var It = {
|
|
105
|
+
type: "text",
|
|
106
|
+
value: "This widget uses a retired data format. Edit it to bind a dataset.",
|
|
107
|
+
variant: "caption",
|
|
108
|
+
align: "center",
|
|
109
|
+
className: "flex h-full w-full items-center justify-center rounded border border-dashed border-destructive/40 bg-destructive/5 p-4 text-center text-destructive"
|
|
110
|
+
};
|
|
111
|
+
function Lt(e) {
|
|
112
|
+
if (!e) return !1;
|
|
113
|
+
let t = e;
|
|
114
|
+
return !t.dataset && !(t.data || t.options?.data) && !!t.object;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/colorVariants.ts
|
|
118
|
+
var Rt = {
|
|
119
|
+
default: "bg-muted text-muted-foreground",
|
|
120
|
+
blue: "bg-blue-500/10 text-blue-600 dark:text-blue-400",
|
|
121
|
+
teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
|
|
122
|
+
orange: "bg-orange-500/10 text-orange-600 dark:text-orange-400",
|
|
123
|
+
purple: "bg-purple-500/10 text-purple-600 dark:text-purple-400",
|
|
124
|
+
success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
|
|
125
|
+
warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
|
|
126
|
+
danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
|
|
127
|
+
}, zt = {
|
|
128
|
+
default: "text-foreground",
|
|
129
|
+
blue: "text-blue-600 dark:text-blue-400",
|
|
130
|
+
teal: "text-teal-600 dark:text-teal-400",
|
|
131
|
+
orange: "text-orange-600 dark:text-orange-400",
|
|
132
|
+
purple: "text-purple-600 dark:text-purple-400",
|
|
133
|
+
success: "text-emerald-600 dark:text-emerald-400",
|
|
134
|
+
warning: "text-amber-600 dark:text-amber-400",
|
|
135
|
+
danger: "text-rose-600 dark:text-rose-400"
|
|
136
|
+
};
|
|
137
|
+
function Bt(e) {
|
|
138
|
+
if (typeof e == "string" && e !== "default") return zt[e];
|
|
90
139
|
}
|
|
91
140
|
//#endregion
|
|
92
141
|
//#region src/recordFields.tsx
|
|
93
|
-
var
|
|
142
|
+
var Vt = /* @__PURE__ */ new Set([
|
|
94
143
|
"id",
|
|
95
144
|
"organization_id",
|
|
96
145
|
"tenant_id",
|
|
@@ -104,15 +153,15 @@ var wt = /* @__PURE__ */ new Set([
|
|
|
104
153
|
"_id",
|
|
105
154
|
"__typename"
|
|
106
155
|
]);
|
|
107
|
-
function
|
|
108
|
-
return t && (t.isSystem === !0 || t.system === !0) ? !0 :
|
|
156
|
+
function Ht(e, t) {
|
|
157
|
+
return t && (t.isSystem === !0 || t.system === !0) ? !0 : Vt.has(e);
|
|
109
158
|
}
|
|
110
|
-
var
|
|
159
|
+
var Ut = /* @__PURE__ */ new Set([
|
|
111
160
|
"select",
|
|
112
161
|
"picklist",
|
|
113
162
|
"dropdown",
|
|
114
163
|
"status"
|
|
115
|
-
]),
|
|
164
|
+
]), Wt = /* @__PURE__ */ new Set([
|
|
116
165
|
"currency",
|
|
117
166
|
"money",
|
|
118
167
|
"number",
|
|
@@ -122,7 +171,7 @@ var Et = /* @__PURE__ */ new Set([
|
|
|
122
171
|
"percent",
|
|
123
172
|
"percentage"
|
|
124
173
|
]);
|
|
125
|
-
function
|
|
174
|
+
function Gt(e) {
|
|
126
175
|
let t = {}, n = e?.fields;
|
|
127
176
|
if (!n) return t;
|
|
128
177
|
if (Array.isArray(n)) for (let e of n) e?.name && (t[e.name] = e);
|
|
@@ -132,9 +181,9 @@ function Ot(e) {
|
|
|
132
181
|
};
|
|
133
182
|
return t;
|
|
134
183
|
}
|
|
135
|
-
function
|
|
184
|
+
function Kt(e) {
|
|
136
185
|
let { accessorKey: t, label: n, def: r, objectName: i, fieldOptionLabel: a, overrides: o = {} } = e, s = o.referenceTo ?? r?.referenceTo ?? (typeof r?.reference == "string" ? r.reference : r?.reference?.to) ?? r?.target, c = o.options ?? r?.options;
|
|
137
|
-
return i && c && a &&
|
|
186
|
+
return i && c && a && Ut.has(r?.type) && (c = c.map((e) => {
|
|
138
187
|
if (e == null) return e;
|
|
139
188
|
let n = typeof e == "object" ? e.value : e, r = typeof e == "object" && e.label || String(n);
|
|
140
189
|
return {
|
|
@@ -153,35 +202,35 @@ function kt(e) {
|
|
|
153
202
|
decimals: o.decimals ?? r?.decimals ?? r?.scale
|
|
154
203
|
};
|
|
155
204
|
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
205
|
+
function qt(e) {
|
|
206
|
+
return Wt.has(e.type) || typeof e.format == "string" && /^[$¥€£]|%$|0/.test(e.format);
|
|
158
207
|
}
|
|
159
|
-
function
|
|
208
|
+
function Jt(e, t, n, r) {
|
|
160
209
|
if (e == null || e === "") return "";
|
|
161
|
-
let
|
|
162
|
-
if (typeof
|
|
163
|
-
let
|
|
210
|
+
let i = t.format;
|
|
211
|
+
if (typeof i == "string" && /^\$|¥|€|£/.test(i) && typeof e == "number") {
|
|
212
|
+
let r = {
|
|
164
213
|
$: "USD",
|
|
165
214
|
"¥": "JPY",
|
|
166
215
|
"€": "EUR",
|
|
167
216
|
"£": "GBP"
|
|
168
|
-
}[
|
|
169
|
-
return
|
|
217
|
+
}[i[0]];
|
|
218
|
+
return vt(e, t.currency || r || n);
|
|
170
219
|
}
|
|
171
|
-
if (typeof
|
|
172
|
-
let t = (
|
|
173
|
-
return
|
|
220
|
+
if (typeof i == "string" && /%/.test(i) && typeof e == "number") {
|
|
221
|
+
let t = (i.match(/0\.(0+)%/) || [void 0, ""])[1].length, n = e > 1 ? e / 100 : e;
|
|
222
|
+
return bt(n * 100, t, r);
|
|
174
223
|
}
|
|
175
|
-
if (typeof
|
|
176
|
-
let
|
|
177
|
-
return /* @__PURE__ */ Q(
|
|
224
|
+
if (typeof i == "string" && /[YMDHms]/.test(i)) return yt(e, i);
|
|
225
|
+
let a = xt(St(t));
|
|
226
|
+
return /* @__PURE__ */ Q(a, {
|
|
178
227
|
value: e,
|
|
179
228
|
field: t
|
|
180
229
|
});
|
|
181
230
|
}
|
|
182
231
|
//#endregion
|
|
183
232
|
//#region src/RecordDetailDrawer.tsx
|
|
184
|
-
var
|
|
233
|
+
var Yt = [
|
|
185
234
|
"name",
|
|
186
235
|
"title",
|
|
187
236
|
"label",
|
|
@@ -189,32 +238,32 @@ var Mt = [
|
|
|
189
238
|
"display_name",
|
|
190
239
|
"full_name"
|
|
191
240
|
];
|
|
192
|
-
function
|
|
241
|
+
function Xt(e, t) {
|
|
193
242
|
if (t && t.trim()) return t;
|
|
194
|
-
for (let t of
|
|
243
|
+
for (let t of Yt) {
|
|
195
244
|
let n = e[t];
|
|
196
245
|
if (typeof n == "string" && n.trim()) return n;
|
|
197
246
|
}
|
|
198
247
|
let n = e.id ?? e._id;
|
|
199
248
|
return n == null ? "Record" : String(n);
|
|
200
249
|
}
|
|
201
|
-
var
|
|
202
|
-
let { fieldLabel:
|
|
250
|
+
var Zt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, target: a = "drawer", onClose: o }) => {
|
|
251
|
+
let { fieldLabel: c, fieldOptionLabel: l } = he(), { currency: u } = me(), d = pe(), f = s(() => {
|
|
203
252
|
if (!e) return [];
|
|
204
|
-
let i =
|
|
205
|
-
return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !
|
|
206
|
-
let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ?
|
|
253
|
+
let i = Gt(n), a;
|
|
254
|
+
return a = r && r.length > 0 ? r : Object.keys(i).length > 0 ? Object.keys(i).filter((e) => !Ht(e, i[e])) : Object.keys(e).filter((e) => !e.startsWith("_") && !Ht(e)), a.map((n) => {
|
|
255
|
+
let r = i[n], a = n.charAt(0).toUpperCase() + n.slice(1).replace(/([A-Z])/g, " $1").replace(/_/g, " "), o = t ? c(t, n, a) : a, s = Kt({
|
|
207
256
|
accessorKey: n,
|
|
208
257
|
label: o,
|
|
209
258
|
def: r,
|
|
210
259
|
objectName: t,
|
|
211
|
-
fieldOptionLabel:
|
|
260
|
+
fieldOptionLabel: l
|
|
212
261
|
});
|
|
213
262
|
return {
|
|
214
263
|
key: n,
|
|
215
264
|
label: o,
|
|
216
|
-
node:
|
|
217
|
-
numeric:
|
|
265
|
+
node: Jt(e[n], s, u, d),
|
|
266
|
+
numeric: qt(s)
|
|
218
267
|
};
|
|
219
268
|
});
|
|
220
269
|
}, [
|
|
@@ -222,15 +271,16 @@ var Pt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
222
271
|
n,
|
|
223
272
|
t,
|
|
224
273
|
r,
|
|
225
|
-
s,
|
|
226
274
|
c,
|
|
227
|
-
l
|
|
275
|
+
l,
|
|
276
|
+
u,
|
|
277
|
+
d
|
|
228
278
|
]);
|
|
229
279
|
if (!e) return null;
|
|
230
|
-
let
|
|
280
|
+
let p = Xt(e, i), m = /* @__PURE__ */ Q("dl", {
|
|
231
281
|
className: "divide-y divide-border/60",
|
|
232
282
|
"data-testid": "record-detail-body",
|
|
233
|
-
children:
|
|
283
|
+
children: f.map((e) => /* @__PURE__ */ $("div", {
|
|
234
284
|
className: "grid grid-cols-3 gap-3 py-2.5",
|
|
235
285
|
children: [/* @__PURE__ */ Q("dt", {
|
|
236
286
|
className: "text-xs font-medium text-muted-foreground self-center",
|
|
@@ -244,38 +294,38 @@ var Pt = ({ record: e, objectName: t, objectSchema: n, fields: r, title: i, targ
|
|
|
244
294
|
})]
|
|
245
295
|
}, e.key))
|
|
246
296
|
});
|
|
247
|
-
return a === "dialog" ? /* @__PURE__ */ Q(
|
|
297
|
+
return a === "dialog" ? /* @__PURE__ */ Q(Ce, {
|
|
248
298
|
open: !0,
|
|
249
299
|
onOpenChange: (e) => !e && o(),
|
|
250
|
-
children: /* @__PURE__ */ $(
|
|
300
|
+
children: /* @__PURE__ */ $(we, {
|
|
251
301
|
className: "max-w-2xl",
|
|
252
|
-
children: [/* @__PURE__ */ Q(
|
|
302
|
+
children: [/* @__PURE__ */ Q(Te, { children: /* @__PURE__ */ Q(Ee, { children: p }) }), /* @__PURE__ */ Q("div", {
|
|
253
303
|
className: "max-h-[70vh] overflow-auto",
|
|
254
|
-
children:
|
|
304
|
+
children: m
|
|
255
305
|
})]
|
|
256
306
|
})
|
|
257
|
-
}) : /* @__PURE__ */ Q(
|
|
307
|
+
}) : /* @__PURE__ */ Q(Re, {
|
|
258
308
|
open: !0,
|
|
259
309
|
onOpenChange: (e) => !e && o(),
|
|
260
|
-
children: /* @__PURE__ */ $(
|
|
310
|
+
children: /* @__PURE__ */ $(ze, {
|
|
261
311
|
side: "right",
|
|
262
312
|
className: "w-full sm:max-w-md md:max-w-lg flex flex-col",
|
|
263
|
-
children: [/* @__PURE__ */ Q(
|
|
313
|
+
children: [/* @__PURE__ */ Q(Be, { children: /* @__PURE__ */ Q(Ve, { children: p }) }), /* @__PURE__ */ Q("div", {
|
|
264
314
|
className: "flex-1 overflow-auto mt-2 pr-1",
|
|
265
|
-
children:
|
|
315
|
+
children: m
|
|
266
316
|
})]
|
|
267
317
|
})
|
|
268
318
|
});
|
|
269
319
|
};
|
|
270
320
|
//#endregion
|
|
271
321
|
//#region src/ObjectDataTable.tsx
|
|
272
|
-
function
|
|
322
|
+
function Qt(e) {
|
|
273
323
|
return e.map((e) => typeof e == "string" ? {
|
|
274
|
-
header:
|
|
324
|
+
header: Dt(e),
|
|
275
325
|
accessorKey: e
|
|
276
326
|
} : e);
|
|
277
327
|
}
|
|
278
|
-
function
|
|
328
|
+
function $t(e, t) {
|
|
279
329
|
if (!t?.fields) return [];
|
|
280
330
|
let n = {};
|
|
281
331
|
if (Array.isArray(t.fields)) for (let e of t.fields) e?.name && (n[e.name] = e);
|
|
@@ -293,59 +343,59 @@ function It(e, t) {
|
|
|
293
343
|
} else for (let [e, t] of Object.entries(n)) r(t?.type) && a.add(e);
|
|
294
344
|
return Array.from(a);
|
|
295
345
|
}
|
|
296
|
-
var
|
|
297
|
-
let { currency: r } =
|
|
298
|
-
|
|
299
|
-
let
|
|
300
|
-
|
|
301
|
-
let [
|
|
302
|
-
|
|
303
|
-
}, []), te =
|
|
304
|
-
|
|
346
|
+
var en = ({ schema: e, dataSource: t, className: n }) => {
|
|
347
|
+
let { currency: r } = me(), c = pe(), u = a(se), d = t || u?.dataSource, f = L(e.bind), { fieldLabel: p, fieldOptionLabel: m } = he(), h = "No data available", g = "No data source available for", { t: _ } = W(), v = _("dashboard.noDataAvailable");
|
|
348
|
+
v && v !== "dashboard.noDataAvailable" && (h = v);
|
|
349
|
+
let y = _("dashboard.noDataSourceFor");
|
|
350
|
+
y && y !== "dashboard.noDataSourceFor" && (g = y);
|
|
351
|
+
let [b, x] = l([]), [S, C] = l(null), [T, E] = l(() => !(Array.isArray(e.data) && e.data.length > 0) && !!e.objectName), [D, k] = l(null), A = e.drillDown, j = O(A) && (A?.mode ?? "record") === "record", [M, N] = l(null), ee = i((e) => {
|
|
352
|
+
N(e ?? null);
|
|
353
|
+
}, []), te = ue();
|
|
354
|
+
o(() => {
|
|
305
355
|
let t = !0;
|
|
306
|
-
return e.objectName && !
|
|
307
|
-
if (!
|
|
308
|
-
t &&
|
|
356
|
+
return e.objectName && !f && (!e.data || e.data.length === 0) ? (async () => {
|
|
357
|
+
if (!d || !e.objectName) {
|
|
358
|
+
t && E(!1);
|
|
309
359
|
return;
|
|
310
360
|
}
|
|
311
|
-
t && (
|
|
361
|
+
t && (E(!0), k(null));
|
|
312
362
|
try {
|
|
313
363
|
let n;
|
|
314
|
-
if (typeof
|
|
315
|
-
let t =
|
|
364
|
+
if (typeof d.find == "function") {
|
|
365
|
+
let t = $t(e, S), r = { $filter: re(e.filter, te) };
|
|
316
366
|
t.length && (r.$expand = t);
|
|
317
|
-
let i = await
|
|
318
|
-
n =
|
|
367
|
+
let i = await d.find(e.objectName, r);
|
|
368
|
+
n = w(i);
|
|
319
369
|
} else return;
|
|
320
|
-
t &&
|
|
370
|
+
t && x(n);
|
|
321
371
|
} catch (e) {
|
|
322
|
-
console.error("[ObjectDataTable] Fetch error:", e), t &&
|
|
372
|
+
console.error("[ObjectDataTable] Fetch error:", e), t && k(e instanceof Error ? e.message : "Failed to load data");
|
|
323
373
|
} finally {
|
|
324
|
-
t &&
|
|
374
|
+
t && E(!1);
|
|
325
375
|
}
|
|
326
|
-
})() : t &&
|
|
376
|
+
})() : t && E(!1), () => {
|
|
327
377
|
t = !1;
|
|
328
378
|
};
|
|
329
379
|
}, [
|
|
330
380
|
e.objectName,
|
|
331
|
-
|
|
332
|
-
|
|
381
|
+
d,
|
|
382
|
+
f,
|
|
333
383
|
e.data,
|
|
334
384
|
e.filter,
|
|
335
|
-
|
|
385
|
+
S,
|
|
336
386
|
te
|
|
337
|
-
]),
|
|
387
|
+
]), o(() => {
|
|
338
388
|
let t = !0;
|
|
339
|
-
if (!(!
|
|
340
|
-
t &&
|
|
389
|
+
if (!(!d || !e.objectName || typeof d.getObjectSchema != "function")) return d.getObjectSchema(e.objectName).then((e) => {
|
|
390
|
+
t && C(e);
|
|
341
391
|
}).catch(() => {}), () => {
|
|
342
392
|
t = !1;
|
|
343
393
|
};
|
|
344
|
-
}, [e.objectName,
|
|
345
|
-
let ne =
|
|
394
|
+
}, [e.objectName, d]);
|
|
395
|
+
let ne = f || e.data || b, P = Array.isArray(ne) ? ne : [], ie = s(() => {
|
|
346
396
|
let t = e.objectName, n = {};
|
|
347
|
-
if (
|
|
348
|
-
let e =
|
|
397
|
+
if (S?.fields) {
|
|
398
|
+
let e = S.fields;
|
|
349
399
|
if (Array.isArray(e)) for (let t of e) t?.name && (n[t.name] = t);
|
|
350
400
|
else for (let [t, r] of Object.entries(e)) n[t] = {
|
|
351
401
|
name: t,
|
|
@@ -354,14 +404,14 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
354
404
|
}
|
|
355
405
|
let i = (e) => {
|
|
356
406
|
let n = e.charAt(0).toUpperCase() + e.slice(1).replace(/([A-Z])/g, " $1");
|
|
357
|
-
return t ?
|
|
407
|
+
return t ? p(t, e, n) : n;
|
|
358
408
|
}, a = (e) => {
|
|
359
|
-
let i =
|
|
409
|
+
let i = Kt({
|
|
360
410
|
accessorKey: e.accessorKey,
|
|
361
411
|
label: e.header,
|
|
362
412
|
def: n[e.accessorKey],
|
|
363
413
|
objectName: t,
|
|
364
|
-
fieldOptionLabel:
|
|
414
|
+
fieldOptionLabel: m,
|
|
365
415
|
overrides: {
|
|
366
416
|
type: e.type,
|
|
367
417
|
format: e.format,
|
|
@@ -370,13 +420,13 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
370
420
|
currency: e.currency,
|
|
371
421
|
decimals: e.decimals
|
|
372
422
|
}
|
|
373
|
-
}), a = e.align ?? (
|
|
423
|
+
}), a = e.align ?? (qt(i) ? "right" : void 0);
|
|
374
424
|
if (typeof e.cell == "function") return {
|
|
375
425
|
...e,
|
|
376
426
|
...i,
|
|
377
427
|
align: a
|
|
378
428
|
};
|
|
379
|
-
let o = (e) =>
|
|
429
|
+
let o = (e) => Jt(e, i, r, c);
|
|
380
430
|
return {
|
|
381
431
|
...e,
|
|
382
432
|
...i,
|
|
@@ -385,37 +435,38 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
385
435
|
};
|
|
386
436
|
};
|
|
387
437
|
if (e.columns && e.columns.length > 0) {
|
|
388
|
-
let n =
|
|
438
|
+
let n = Qt(e.columns);
|
|
389
439
|
return (t ? n.map((e) => ({
|
|
390
440
|
...e,
|
|
391
|
-
header:
|
|
441
|
+
header: p(t, e.accessorKey, e.header)
|
|
392
442
|
})) : n).map(a);
|
|
393
443
|
}
|
|
394
|
-
return
|
|
444
|
+
return P.length === 0 ? [] : (Object.keys(n).length > 0 ? Object.keys(n).filter((e) => !Ht(e, n[e])) : Object.keys(P[0]).filter((e) => !e.startsWith("_") && !Ht(e))).map((e) => a({
|
|
395
445
|
header: i(e),
|
|
396
446
|
accessorKey: e
|
|
397
447
|
}));
|
|
398
448
|
}, [
|
|
399
449
|
e.columns,
|
|
400
450
|
e.objectName,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
r
|
|
451
|
+
P,
|
|
452
|
+
S,
|
|
453
|
+
p,
|
|
454
|
+
m,
|
|
455
|
+
r,
|
|
456
|
+
c
|
|
406
457
|
]);
|
|
407
|
-
if (
|
|
408
|
-
className:
|
|
458
|
+
if (T && P.length === 0) return /* @__PURE__ */ Q("div", {
|
|
459
|
+
className: Z("overflow-auto", n),
|
|
409
460
|
"data-testid": "table-loading",
|
|
410
461
|
children: /* @__PURE__ */ $("div", {
|
|
411
462
|
className: "space-y-2 p-2",
|
|
412
463
|
children: [/* @__PURE__ */ $("div", {
|
|
413
464
|
className: "flex gap-2",
|
|
414
465
|
children: [
|
|
415
|
-
/* @__PURE__ */ Q(
|
|
416
|
-
/* @__PURE__ */ Q(
|
|
417
|
-
/* @__PURE__ */ Q(
|
|
418
|
-
/* @__PURE__ */ Q(
|
|
466
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-1/4" }),
|
|
467
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-1/4" }),
|
|
468
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-1/4" }),
|
|
469
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-1/4" })
|
|
419
470
|
]
|
|
420
471
|
}), [
|
|
421
472
|
1,
|
|
@@ -425,16 +476,16 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
425
476
|
].map((e) => /* @__PURE__ */ $("div", {
|
|
426
477
|
className: "flex gap-2",
|
|
427
478
|
children: [
|
|
428
|
-
/* @__PURE__ */ Q(
|
|
429
|
-
/* @__PURE__ */ Q(
|
|
430
|
-
/* @__PURE__ */ Q(
|
|
431
|
-
/* @__PURE__ */ Q(
|
|
479
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-1/4" }),
|
|
480
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-1/4" }),
|
|
481
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-1/4" }),
|
|
482
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-1/4" })
|
|
432
483
|
]
|
|
433
484
|
}, e))]
|
|
434
485
|
})
|
|
435
486
|
});
|
|
436
|
-
if (
|
|
437
|
-
className:
|
|
487
|
+
if (D) return /* @__PURE__ */ Q("div", {
|
|
488
|
+
className: Z("overflow-auto", n),
|
|
438
489
|
"data-testid": "table-error",
|
|
439
490
|
children: /* @__PURE__ */ $("div", {
|
|
440
491
|
className: "flex flex-col items-center justify-center py-8 text-destructive",
|
|
@@ -469,18 +520,18 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
469
520
|
]
|
|
470
521
|
}), /* @__PURE__ */ Q("p", {
|
|
471
522
|
className: "text-xs",
|
|
472
|
-
children:
|
|
523
|
+
children: D
|
|
473
524
|
})]
|
|
474
525
|
})
|
|
475
526
|
});
|
|
476
|
-
if (!
|
|
477
|
-
className:
|
|
527
|
+
if (!d && e.objectName && P.length === 0) return /* @__PURE__ */ Q("div", {
|
|
528
|
+
className: Z("overflow-auto", n),
|
|
478
529
|
children: /* @__PURE__ */ Q("div", {
|
|
479
530
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
480
531
|
children: /* @__PURE__ */ $("p", {
|
|
481
532
|
className: "text-xs",
|
|
482
533
|
children: [
|
|
483
|
-
|
|
534
|
+
g,
|
|
484
535
|
" “",
|
|
485
536
|
e.objectName,
|
|
486
537
|
"”"
|
|
@@ -488,8 +539,8 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
488
539
|
})
|
|
489
540
|
})
|
|
490
541
|
});
|
|
491
|
-
if (
|
|
492
|
-
className:
|
|
542
|
+
if (P.length === 0) return /* @__PURE__ */ Q("div", {
|
|
543
|
+
className: Z("overflow-auto", n),
|
|
493
544
|
"data-testid": "table-empty-state",
|
|
494
545
|
children: /* @__PURE__ */ $("div", {
|
|
495
546
|
className: "flex flex-col items-center justify-center py-8 text-muted-foreground",
|
|
@@ -526,39 +577,39 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
526
577
|
]
|
|
527
578
|
}), /* @__PURE__ */ Q("p", {
|
|
528
579
|
className: "text-xs",
|
|
529
|
-
children:
|
|
580
|
+
children: h
|
|
530
581
|
})]
|
|
531
582
|
})
|
|
532
583
|
});
|
|
533
|
-
let
|
|
584
|
+
let F = {
|
|
534
585
|
...e,
|
|
535
586
|
type: "data-table",
|
|
536
|
-
data:
|
|
537
|
-
columns:
|
|
538
|
-
onRowClick: e.onRowClick ?? (
|
|
539
|
-
},
|
|
587
|
+
data: P,
|
|
588
|
+
columns: ie,
|
|
589
|
+
onRowClick: e.onRowClick ?? (j ? ee : void 0)
|
|
590
|
+
}, ae = A?.title && !A.title.includes("${") ? A.title : void 0;
|
|
540
591
|
return /* @__PURE__ */ $("div", {
|
|
541
|
-
className:
|
|
592
|
+
className: Z("relative", n),
|
|
542
593
|
children: [
|
|
543
|
-
/* @__PURE__ */ Q(
|
|
544
|
-
/* @__PURE__ */ Q(
|
|
545
|
-
schema:
|
|
594
|
+
/* @__PURE__ */ Q(Me, { active: T && P.length > 0 }),
|
|
595
|
+
/* @__PURE__ */ Q(oe, {
|
|
596
|
+
schema: F,
|
|
546
597
|
className: n
|
|
547
598
|
}),
|
|
548
|
-
|
|
549
|
-
record:
|
|
599
|
+
j && /* @__PURE__ */ Q(Zt, {
|
|
600
|
+
record: M,
|
|
550
601
|
objectName: e.objectName,
|
|
551
|
-
objectSchema:
|
|
552
|
-
fields:
|
|
553
|
-
title:
|
|
554
|
-
target:
|
|
555
|
-
onClose: () =>
|
|
602
|
+
objectSchema: S,
|
|
603
|
+
fields: A?.columns,
|
|
604
|
+
title: ae,
|
|
605
|
+
target: A?.target === "dialog" ? "dialog" : "drawer",
|
|
606
|
+
onClose: () => N(null)
|
|
556
607
|
})
|
|
557
608
|
]
|
|
558
609
|
});
|
|
559
|
-
},
|
|
560
|
-
let { openRecordList: i } =
|
|
561
|
-
return !i || !e ? null : /* @__PURE__ */ $(
|
|
610
|
+
}, tn = ({ objectName: e, filter: t, onNavigate: n, className: r }) => {
|
|
611
|
+
let { openRecordList: i } = le(), a = G();
|
|
612
|
+
return !i || !e ? null : /* @__PURE__ */ $(K, {
|
|
562
613
|
type: "button",
|
|
563
614
|
variant: "ghost",
|
|
564
615
|
size: "sm",
|
|
@@ -567,115 +618,161 @@ var Lt = ({ schema: e, dataSource: t, className: n }) => {
|
|
|
567
618
|
onClick: () => {
|
|
568
619
|
i(e, t), n?.();
|
|
569
620
|
},
|
|
570
|
-
children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Q(
|
|
621
|
+
children: [a("dashboard.openInList", "Open in list"), /* @__PURE__ */ Q(Je, { className: "ml-1 h-3.5 w-3.5" })]
|
|
571
622
|
});
|
|
572
|
-
},
|
|
573
|
-
let { openRecordList:
|
|
574
|
-
if (
|
|
575
|
-
e &&
|
|
576
|
-
}, [e,
|
|
577
|
-
let
|
|
578
|
-
objectName:
|
|
579
|
-
filter:
|
|
580
|
-
onNavigate:
|
|
581
|
-
}),
|
|
582
|
-
className:
|
|
623
|
+
}, nn = ({ open: e, onClose: n, title: r, target: i = "drawer", objectName: a, filter: o, dataSource: s, columns: c, maxRows: l, className: u, report: d }) => {
|
|
624
|
+
let { openRecordList: f } = le(), p = d && typeof d == "object" && (Array.isArray(d.columns) || "objectName" in d), m = i === "navigate" && !!f && !p && !!a;
|
|
625
|
+
if (t.useEffect(() => {
|
|
626
|
+
e && m && (f(a, o), n());
|
|
627
|
+
}, [e, m]), m) return null;
|
|
628
|
+
let h = p ? null : /* @__PURE__ */ Q(tn, {
|
|
629
|
+
objectName: a,
|
|
630
|
+
filter: o,
|
|
631
|
+
onNavigate: n
|
|
632
|
+
}), g = /* @__PURE__ */ Q("div", {
|
|
633
|
+
className: Z("overflow-auto", u),
|
|
583
634
|
"data-testid": "drill-down-body",
|
|
584
|
-
children:
|
|
585
|
-
let e =
|
|
586
|
-
...
|
|
635
|
+
children: p ? (() => {
|
|
636
|
+
let e = d.filter, t = e ? o ? { $and: [e, o] } : e : o, n = {
|
|
637
|
+
...d,
|
|
587
638
|
type: "spec-report",
|
|
588
639
|
report: {
|
|
589
|
-
...
|
|
640
|
+
...d,
|
|
590
641
|
filter: t
|
|
591
642
|
},
|
|
592
643
|
filter: t
|
|
593
644
|
};
|
|
594
|
-
return /* @__PURE__ */ Q(
|
|
595
|
-
})() : /* @__PURE__ */ Q(
|
|
645
|
+
return /* @__PURE__ */ Q(oe, { schema: n });
|
|
646
|
+
})() : /* @__PURE__ */ Q(en, {
|
|
596
647
|
schema: {
|
|
597
648
|
type: "object-data-table",
|
|
598
|
-
objectName:
|
|
599
|
-
filter:
|
|
600
|
-
columns:
|
|
649
|
+
objectName: a,
|
|
650
|
+
filter: o,
|
|
651
|
+
columns: c?.map((e) => ({
|
|
601
652
|
accessorKey: e,
|
|
602
653
|
header: e
|
|
603
654
|
})),
|
|
604
655
|
pagination: !0,
|
|
605
656
|
searchable: !1,
|
|
606
|
-
pageSize:
|
|
657
|
+
pageSize: l,
|
|
607
658
|
drillDown: {
|
|
608
659
|
enabled: !0,
|
|
609
660
|
mode: "record",
|
|
610
661
|
target: "dialog"
|
|
611
662
|
}
|
|
612
663
|
},
|
|
613
|
-
dataSource:
|
|
664
|
+
dataSource: s
|
|
614
665
|
})
|
|
615
666
|
});
|
|
616
|
-
return
|
|
667
|
+
return i === "dialog" ? /* @__PURE__ */ Q(Ce, {
|
|
617
668
|
open: e,
|
|
618
|
-
onOpenChange: (e) => !e &&
|
|
619
|
-
children: /* @__PURE__ */ $(
|
|
669
|
+
onOpenChange: (e) => !e && n(),
|
|
670
|
+
children: /* @__PURE__ */ $(we, {
|
|
620
671
|
className: "max-w-5xl",
|
|
621
|
-
children: [/* @__PURE__ */ $(
|
|
672
|
+
children: [/* @__PURE__ */ $(Te, {
|
|
622
673
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
623
|
-
children: [/* @__PURE__ */ Q(
|
|
624
|
-
}),
|
|
674
|
+
children: [/* @__PURE__ */ Q(Ee, { children: r }), h]
|
|
675
|
+
}), g]
|
|
625
676
|
})
|
|
626
|
-
}) : /* @__PURE__ */ Q(
|
|
677
|
+
}) : /* @__PURE__ */ Q(Re, {
|
|
627
678
|
open: e,
|
|
628
|
-
onOpenChange: (e) => !e &&
|
|
629
|
-
children: /* @__PURE__ */ $(
|
|
679
|
+
onOpenChange: (e) => !e && n(),
|
|
680
|
+
children: /* @__PURE__ */ $(ze, {
|
|
630
681
|
side: "right",
|
|
631
682
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col",
|
|
632
|
-
children: [/* @__PURE__ */ $(
|
|
683
|
+
children: [/* @__PURE__ */ $(Be, {
|
|
633
684
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
634
|
-
children: [/* @__PURE__ */ Q(
|
|
685
|
+
children: [/* @__PURE__ */ Q(Ve, { children: r }), h]
|
|
635
686
|
}), /* @__PURE__ */ Q("div", {
|
|
636
687
|
className: "flex-1 overflow-hidden mt-2",
|
|
637
|
-
children:
|
|
688
|
+
children: g
|
|
638
689
|
})]
|
|
639
690
|
})
|
|
640
691
|
});
|
|
641
|
-
},
|
|
642
|
-
function
|
|
643
|
-
let
|
|
644
|
-
return e.forEach((e,
|
|
645
|
-
let
|
|
646
|
-
|
|
647
|
-
id: l,
|
|
648
|
-
labels: t.map((t) => m(e[t]))
|
|
649
|
-
})), o.has(u) || (o.add(u), i.push({
|
|
692
|
+
}, rn = m;
|
|
693
|
+
function an(e, t, n, r) {
|
|
694
|
+
let i = [], a = [], o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map();
|
|
695
|
+
return e.forEach((e, l) => {
|
|
696
|
+
let u = j(t.map((t) => N(e[t]))), d = j([N(e[n])]);
|
|
697
|
+
o.has(u) || (o.add(u), i.push({
|
|
650
698
|
id: u,
|
|
651
|
-
|
|
652
|
-
})), s.
|
|
699
|
+
labels: t.map((t) => E(e[t], r))
|
|
700
|
+
})), s.has(d) || (s.add(d), a.push({
|
|
701
|
+
id: d,
|
|
702
|
+
label: E(e[n], r)
|
|
703
|
+
})), c.set(M(u, d), l);
|
|
653
704
|
}), {
|
|
654
|
-
rowHeaders:
|
|
655
|
-
colHeaders:
|
|
656
|
-
cellIndex:
|
|
705
|
+
rowHeaders: i,
|
|
706
|
+
colHeaders: a,
|
|
707
|
+
cellIndex: c
|
|
657
708
|
};
|
|
658
709
|
}
|
|
659
|
-
function
|
|
710
|
+
function on(e) {
|
|
660
711
|
if (e == null) return "";
|
|
661
712
|
let t = String(e);
|
|
662
713
|
return /[",\n\r]/.test(t) ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
663
714
|
}
|
|
664
|
-
function
|
|
665
|
-
return e.map((e) => e.map(
|
|
715
|
+
function sn(e) {
|
|
716
|
+
return e.map((e) => e.map(on).join(",")).join("\r\n");
|
|
666
717
|
}
|
|
667
|
-
function
|
|
718
|
+
function cn(e, t) {
|
|
668
719
|
if (typeof document > "u") return;
|
|
669
|
-
let n = e && e.trim() ? e.trim() : "export", r = new Blob([`\uFEFF${
|
|
720
|
+
let n = e && e.trim() ? e.trim() : "export", r = new Blob([`\uFEFF${sn(t)}`], { type: "text/csv;charset=utf-8;" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
670
721
|
a.href = i, a.download = n.endsWith(".csv") ? n : `${n}.csv`, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
|
|
671
722
|
}
|
|
672
|
-
var
|
|
723
|
+
var ln = "__compare", un = (e) => `${e}${ln}`, dn = {
|
|
724
|
+
vsLastQuarter: "vs last quarter",
|
|
725
|
+
vsLastMonth: "vs last month",
|
|
726
|
+
vsLastWeek: "vs last week",
|
|
727
|
+
vsLastYear: "vs last year",
|
|
728
|
+
vsYesterday: "vs yesterday",
|
|
729
|
+
vsPreviousPeriod: "vs previous period"
|
|
730
|
+
}, fn = /^\d{4}-\d{2}-\d{2}(?:[T ][\d:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
731
|
+
function pn(e) {
|
|
732
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return null;
|
|
733
|
+
let t = Object.keys(e);
|
|
734
|
+
if (t.length !== 2 || !t.includes("$gte") || !t.includes("$lte")) return null;
|
|
735
|
+
let { $gte: n, $lte: r } = e;
|
|
736
|
+
return typeof n != "string" || typeof r != "string" || !fn.test(n) || !fn.test(r) ? null : [n, r];
|
|
737
|
+
}
|
|
738
|
+
function mn(e) {
|
|
739
|
+
let t = /* @__PURE__ */ new Map(), n = (e) => {
|
|
740
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return e;
|
|
741
|
+
let r = {}, i = null;
|
|
742
|
+
for (let [a, o] of Object.entries(e)) {
|
|
743
|
+
if (a === "$and" && Array.isArray(o)) {
|
|
744
|
+
i = o.map(n).filter((e) => !!e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length > 0);
|
|
745
|
+
continue;
|
|
746
|
+
}
|
|
747
|
+
if (a.startsWith("$")) {
|
|
748
|
+
r[a] = o;
|
|
749
|
+
continue;
|
|
750
|
+
}
|
|
751
|
+
let e = pn(o);
|
|
752
|
+
if (!e) {
|
|
753
|
+
r[a] = o;
|
|
754
|
+
continue;
|
|
755
|
+
}
|
|
756
|
+
let s = t.get(a);
|
|
757
|
+
t.set(a, s ? [s[0] > e[0] ? s[0] : e[0], s[1] < e[1] ? s[1] : e[1]] : e);
|
|
758
|
+
}
|
|
759
|
+
return i && i.length > 0 && (r.$and = i), r;
|
|
760
|
+
}, r = n(e), i = r && Object.keys(r).length > 0 ? r : void 0, a = i && Object.keys(i).length === 1 && Array.isArray(i.$and) && i.$and.length === 1 ? i.$and[0] : void 0;
|
|
761
|
+
return a && (i = a), {
|
|
762
|
+
windows: Array.from(t, ([e, t]) => ({
|
|
763
|
+
dimension: e,
|
|
764
|
+
dateRange: t
|
|
765
|
+
})),
|
|
766
|
+
rest: i
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
var hn = /* @__PURE__ */ new Set([
|
|
673
770
|
"metric",
|
|
674
771
|
"kpi",
|
|
675
772
|
"gauge",
|
|
676
773
|
"solid-gauge",
|
|
677
774
|
"bullet"
|
|
678
|
-
]),
|
|
775
|
+
]), gn = {
|
|
679
776
|
bar: "bar",
|
|
680
777
|
column: "column",
|
|
681
778
|
"horizontal-bar": "horizontal-bar",
|
|
@@ -695,49 +792,109 @@ var Gt = /* @__PURE__ */ new Set([
|
|
|
695
792
|
bubble: "scatter",
|
|
696
793
|
radar: "radar",
|
|
697
794
|
treemap: "treemap",
|
|
698
|
-
sankey: "sankey"
|
|
795
|
+
sankey: "sankey",
|
|
796
|
+
combo: "combo"
|
|
699
797
|
};
|
|
700
|
-
function
|
|
701
|
-
let
|
|
702
|
-
|
|
703
|
-
|
|
798
|
+
function _n(e, t) {
|
|
799
|
+
let n = e && typeof e == "object" && !Array.isArray(e) ? e : {}, r = {}, i = (e) => typeof e == "string" && e ? e : void 0;
|
|
800
|
+
typeof n.showLegend == "boolean" && (r.showLegend = n.showLegend), typeof n.showDataLabels == "boolean" && (r.showDataLabels = n.showDataLabels);
|
|
801
|
+
let a = i(n.title);
|
|
802
|
+
a && (r.title = a);
|
|
803
|
+
let o = i(n.subtitle);
|
|
804
|
+
o && (r.subtitle = o);
|
|
805
|
+
let s = i(n.description);
|
|
806
|
+
s && (r.description = s), typeof n.height == "number" && Number.isFinite(n.height) && n.height > 0 && (r.height = n.height), Array.isArray(n.annotations) && n.annotations.length > 0 && (r.annotations = n.annotations), n.interaction && typeof n.interaction == "object" && !Array.isArray(n.interaction) && (r.interaction = n.interaction);
|
|
807
|
+
let c = Array.isArray(n.colors) ? n.colors.filter((e) => typeof e == "string" && !!e) : void 0;
|
|
808
|
+
c?.length && (r.colors = c);
|
|
809
|
+
let l = n.colors && typeof n.colors == "object" && !Array.isArray(n.colors) ? n.colors : void 0;
|
|
810
|
+
return (t || l) && (r.categoryColors = {
|
|
811
|
+
...t ?? {},
|
|
812
|
+
...l ?? {}
|
|
813
|
+
}), r;
|
|
814
|
+
}
|
|
815
|
+
var vn = (e) => !!e && typeof e == "object" && !Array.isArray(e);
|
|
816
|
+
function yn(e) {
|
|
817
|
+
if (typeof e == "string" && e) return e;
|
|
818
|
+
if (vn(e)) return Object.values(e).find((e) => typeof e == "string" && e);
|
|
819
|
+
}
|
|
820
|
+
function bn(e) {
|
|
821
|
+
let t = {}, n = e.type;
|
|
822
|
+
(n === "bar" || n === "line" || n === "area") && (t.chartType = n), (e.yAxis === "left" || e.yAxis === "right") && (t.yAxis = e.yAxis);
|
|
823
|
+
let r = yn(e.label);
|
|
824
|
+
return r && (t.label = r), typeof e.color == "string" && e.color && (t.color = e.color), typeof e.stack == "string" && e.stack && (t.stack = e.stack), (e.variant === "primary" || e.variant === "comparison") && (t.variant = e.variant), typeof e.dashArray == "string" && e.dashArray && (t.dashArray = e.dashArray), typeof e.opacity == "number" && Number.isFinite(e.opacity) && (t.opacity = e.opacity), t;
|
|
825
|
+
}
|
|
826
|
+
function xn(e) {
|
|
827
|
+
let t = {};
|
|
828
|
+
if (!vn(e)) return t;
|
|
829
|
+
let n = yn(e.title);
|
|
830
|
+
return n && (t.title = n), typeof e.format == "string" && e.format && (t.format = e.format), typeof e.min == "number" && Number.isFinite(e.min) && (t.min = e.min), typeof e.max == "number" && Number.isFinite(e.max) && (t.max = e.max), typeof e.stepSize == "number" && Number.isFinite(e.stepSize) && e.stepSize > 0 && (t.stepSize = e.stepSize), typeof e.showGridLines == "boolean" && (t.showGridLines = e.showGridLines), (e.position === "left" || e.position === "right" || e.position === "top" || e.position === "bottom") && (t.position = e.position), typeof e.logarithmic == "boolean" && (t.logarithmic = e.logarithmic), t;
|
|
831
|
+
}
|
|
832
|
+
function Sn(e, t) {
|
|
833
|
+
let n = vn(t) ? t : {}, r = /* @__PURE__ */ new Map();
|
|
834
|
+
for (let e of Array.isArray(n.series) ? n.series : []) {
|
|
835
|
+
if (!vn(e)) continue;
|
|
836
|
+
let t = typeof e.name == "string" ? e.name : void 0;
|
|
837
|
+
t && !r.has(t) && r.set(t, e);
|
|
838
|
+
}
|
|
839
|
+
let i = e.map((e) => {
|
|
840
|
+
let t = r.get(e.dataKey);
|
|
841
|
+
return t ? {
|
|
842
|
+
...e,
|
|
843
|
+
...bn(t)
|
|
844
|
+
} : e;
|
|
845
|
+
}), a = {}, o = xn(n.xAxis);
|
|
846
|
+
Object.keys(o).length > 0 && (a.xAxis = o);
|
|
847
|
+
let s = Array.isArray(n.yAxis) ? n.yAxis : n.yAxis === void 0 ? [] : [n.yAxis];
|
|
848
|
+
return s.length > 0 && (a.yAxis = s.map(xn)), {
|
|
849
|
+
series: i,
|
|
850
|
+
axes: a
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
function Cn({ widget: e, dataSource: t }) {
|
|
854
|
+
let n = String(e?.dataset ?? ""), r = s(() => Array.isArray(e?.dimensions) ? e.dimensions.filter(Boolean) : [], [e]), i = s(() => Array.isArray(e?.values) ? e.values.filter(Boolean) : [], [e]), a = e?.compareTo, c = String(e?.type ?? ""), u = hn.has(c) || r.length === 0, d = c === "table" || c === "pivot", m = c === "pivot" && r.length >= 2, _ = m ? r.slice(0, -1) : [], y = m ? r[r.length - 1] : "", b = m ? [
|
|
855
|
+
_,
|
|
856
|
+
[y],
|
|
704
857
|
[]
|
|
705
|
-
] : void 0,
|
|
858
|
+
] : void 0, x = e?.options && typeof e.options == "object" && !Array.isArray(e.options) ? e.options : {}, w = typeof x.dateGranularity == "string" ? x.dateGranularity : void 0, O = typeof x.sortBy == "string" && x.sortBy ? x.sortBy : void 0, A = O && (r.includes(O) || i.includes(O)) ? O : void 0, te = A ? { [A]: x.sortOrder === "desc" ? "desc" : "asc" } : void 0, ne = typeof x.limit == "number" && Number.isFinite(x.limit) && x.limit > 0 ? Math.floor(x.limit) : void 0, P = G(), { fieldLabel: ie, fieldOptionLabel: F } = he(), ae = pe(), se = ue(), I = e?.filter, L = s(() => I && typeof I == "object" && Object.keys(I).length > 0 ? re(I, se) : void 0, [I, se]), { windows: R, rest: le } = s(() => a ? mn(L) : {
|
|
859
|
+
windows: [],
|
|
860
|
+
rest: L
|
|
861
|
+
}, [a, L]), [z, de] = l({
|
|
706
862
|
status: "idle",
|
|
707
863
|
rows: []
|
|
708
|
-
}), [
|
|
709
|
-
|
|
864
|
+
}), [fe, B] = l(null), V = `${c}|${n}|${r.join(",")}|${i.join(",")}|${JSON.stringify(I ?? null)}|${JSON.stringify(a ?? null)}|${w ?? ""}|${JSON.stringify(te ?? null)}|${ne ?? ""}`;
|
|
865
|
+
o(() => {
|
|
710
866
|
let e = t;
|
|
711
867
|
if (!e || typeof e.queryDataset != "function") {
|
|
712
|
-
|
|
868
|
+
de({
|
|
713
869
|
status: "error",
|
|
714
870
|
rows: [],
|
|
715
|
-
error:
|
|
871
|
+
error: P("dashboard.datasetUnsupported", "This data source does not support dataset queries.")
|
|
716
872
|
});
|
|
717
873
|
return;
|
|
718
874
|
}
|
|
719
|
-
if (
|
|
720
|
-
|
|
875
|
+
if (i.length === 0) {
|
|
876
|
+
de({
|
|
721
877
|
status: "idle",
|
|
722
878
|
rows: []
|
|
723
879
|
});
|
|
724
880
|
return;
|
|
725
881
|
}
|
|
726
|
-
let
|
|
727
|
-
return
|
|
882
|
+
let o = !1;
|
|
883
|
+
return de({
|
|
728
884
|
status: "loading",
|
|
729
885
|
rows: []
|
|
730
|
-
}), e.queryDataset(
|
|
731
|
-
dimensions:
|
|
732
|
-
measures:
|
|
733
|
-
...
|
|
734
|
-
...
|
|
735
|
-
...
|
|
736
|
-
...
|
|
737
|
-
...
|
|
738
|
-
...
|
|
886
|
+
}), e.queryDataset(n, {
|
|
887
|
+
dimensions: r,
|
|
888
|
+
measures: i,
|
|
889
|
+
...le ? { runtimeFilter: le } : {},
|
|
890
|
+
...R.length > 0 ? { timeDimensions: R } : {},
|
|
891
|
+
...a ? { compareTo: a } : {},
|
|
892
|
+
...b ? { totals: { groupings: b } } : {},
|
|
893
|
+
...w ? { dateGranularity: w } : {},
|
|
894
|
+
...te ? { order: te } : {},
|
|
895
|
+
...ne == null ? {} : { limit: ne }
|
|
739
896
|
}).then((e) => {
|
|
740
|
-
|
|
897
|
+
o || de({
|
|
741
898
|
status: "ok",
|
|
742
899
|
rows: Array.isArray(e?.rows) ? e.rows : [],
|
|
743
900
|
fields: Array.isArray(e?.fields) ? e.fields : [],
|
|
@@ -748,53 +905,37 @@ function qt({ widget: e, dataSource: t }) {
|
|
|
748
905
|
totals: Array.isArray(e?.totals) ? e.totals : void 0
|
|
749
906
|
});
|
|
750
907
|
}).catch((e) => {
|
|
751
|
-
|
|
908
|
+
o || de({
|
|
752
909
|
status: "error",
|
|
753
910
|
rows: [],
|
|
754
911
|
error: String(e?.message ?? e)
|
|
755
912
|
});
|
|
756
913
|
}), () => {
|
|
757
|
-
|
|
914
|
+
o = !0;
|
|
758
915
|
};
|
|
759
|
-
}, [
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
try {
|
|
772
|
-
let i = await (await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`, {
|
|
773
|
-
headers: { accept: "application/json" },
|
|
774
|
-
credentials: "include"
|
|
775
|
-
})).json().catch(() => null), a = i?.item ?? i?.data ?? i, l = a?.fields?.[t(c[0])]?.options, u = s(l), d = {};
|
|
776
|
-
for (let e of c) {
|
|
777
|
-
let n = o(a?.fields?.[t(e)]?.options);
|
|
778
|
-
n && (d[e] = n);
|
|
779
|
-
}
|
|
780
|
-
r || (R(u), z(Object.keys(d).length > 0 ? d : null), ue(n(l)));
|
|
781
|
-
} catch {
|
|
782
|
-
r || (R(null), z(null), ue(null));
|
|
783
|
-
}
|
|
784
|
-
})(), () => {
|
|
785
|
-
r = !0;
|
|
916
|
+
}, [V]);
|
|
917
|
+
let H = ce(z.object, z.dimensionFields, r, { enabled: !u }), { categoryColors: U, dimensionLabels: me, categoryOrder: W } = s(() => {
|
|
918
|
+
if (!H) return {
|
|
919
|
+
categoryColors: null,
|
|
920
|
+
dimensionLabels: null,
|
|
921
|
+
categoryOrder: null
|
|
922
|
+
};
|
|
923
|
+
let { metaByPath: e, relabel: t } = H, n = d ? void 0 : t[0]?.path, r = n ? e[n] : void 0, i = n ? k(r?.options, C(r, F)) : void 0;
|
|
924
|
+
return {
|
|
925
|
+
categoryColors: g(i),
|
|
926
|
+
dimensionLabels: S(e, t, F),
|
|
927
|
+
categoryOrder: f(i)
|
|
786
928
|
};
|
|
787
929
|
}, [
|
|
788
|
-
|
|
789
|
-
F
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
]), l.length === 0) return /* @__PURE__ */ Q("div", {
|
|
930
|
+
H,
|
|
931
|
+
F,
|
|
932
|
+
d
|
|
933
|
+
]);
|
|
934
|
+
if (i.length === 0) return /* @__PURE__ */ Q("div", {
|
|
794
935
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
795
|
-
children:
|
|
936
|
+
children: P("dashboard.pickMeasures", "Pick measures (values) for this dataset widget.")
|
|
796
937
|
});
|
|
797
|
-
if (
|
|
938
|
+
if (z.status === "loading" || z.status === "idle") return /* @__PURE__ */ $("div", {
|
|
798
939
|
className: "h-full w-full p-2",
|
|
799
940
|
"data-testid": "dataset-loading",
|
|
800
941
|
role: "status",
|
|
@@ -802,275 +943,363 @@ function qt({ widget: e, dataSource: t }) {
|
|
|
802
943
|
"aria-live": "polite",
|
|
803
944
|
children: [/* @__PURE__ */ Q("span", {
|
|
804
945
|
className: "sr-only",
|
|
805
|
-
children:
|
|
806
|
-
}),
|
|
946
|
+
children: P("dashboard.loading", "Loading…")
|
|
947
|
+
}), u ? /* @__PURE__ */ $("div", {
|
|
807
948
|
className: "flex h-full w-full flex-col items-start justify-center gap-2 p-2",
|
|
808
|
-
children: [/* @__PURE__ */ Q(
|
|
809
|
-
}) :
|
|
949
|
+
children: [/* @__PURE__ */ Q(X, { className: "h-8 w-32 rounded" }), /* @__PURE__ */ Q(X, { className: "h-3 w-20 rounded" })]
|
|
950
|
+
}) : d ? /* @__PURE__ */ Q(De, {
|
|
810
951
|
className: "h-full",
|
|
811
952
|
rows: 5,
|
|
812
|
-
columns: Math.max(2,
|
|
813
|
-
}) : /* @__PURE__ */ Q(
|
|
953
|
+
columns: Math.max(2, r.length + i.length)
|
|
954
|
+
}) : /* @__PURE__ */ Q(ye, { className: "h-full" })]
|
|
814
955
|
});
|
|
815
|
-
if (
|
|
956
|
+
if (z.status === "error") return /* @__PURE__ */ $("div", {
|
|
816
957
|
role: "alert",
|
|
817
958
|
className: "flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive",
|
|
818
|
-
children: [/* @__PURE__ */ Q(
|
|
959
|
+
children: [/* @__PURE__ */ Q(Ge, { className: "h-3.5 w-3.5 mt-0.5 shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
819
960
|
className: "break-words",
|
|
820
|
-
children:
|
|
961
|
+
children: z.error
|
|
821
962
|
})]
|
|
822
963
|
});
|
|
823
|
-
if (
|
|
964
|
+
if (z.rows.length === 0 && !u) return /* @__PURE__ */ $("div", {
|
|
824
965
|
className: "flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground",
|
|
825
|
-
children: [/* @__PURE__ */ Q(
|
|
966
|
+
children: [/* @__PURE__ */ Q(Ye, { className: "mr-2 h-4 w-4" }), P("dashboard.noRows", "No rows")]
|
|
826
967
|
});
|
|
827
|
-
let { measureField:
|
|
828
|
-
if (!
|
|
829
|
-
let r =
|
|
830
|
-
|
|
968
|
+
let { measureField: K, headerLabel: q } = h(z.fields, z.object, ie), J = a ? i.filter((e) => z.rows.some((t) => t[un(e)] != null)) : [], ge = a ? v(a, I) : "", _e = a ? P(`dashboard.trend.${ge}`, dn[ge] ?? "vs previous period") : "", { object: ve, dimensionFields: be, drillRawRows: xe, drillRanges: Y } = z, Se = be ? r.filter((e) => e in be) : [], Ce = !!ve && (Se.length > 0 || !!Y?.length), we = (t, n) => {
|
|
969
|
+
if (!ve) return;
|
|
970
|
+
let r = rn(xe?.[t], Se, be ?? {}, L, Y?.[t]);
|
|
971
|
+
B({
|
|
831
972
|
filter: r,
|
|
832
973
|
title: n || String(e?.title ?? "")
|
|
833
974
|
});
|
|
834
|
-
},
|
|
975
|
+
}, Te = fe && ve ? /* @__PURE__ */ Q(nn, {
|
|
835
976
|
open: !0,
|
|
836
|
-
onClose: () =>
|
|
837
|
-
title:
|
|
838
|
-
objectName:
|
|
839
|
-
filter:
|
|
977
|
+
onClose: () => B(null),
|
|
978
|
+
title: fe.title || String(e?.title ?? P("dashboard.details", "Details")),
|
|
979
|
+
objectName: ve,
|
|
980
|
+
filter: fe.filter,
|
|
840
981
|
dataSource: t
|
|
841
982
|
}) : null;
|
|
842
|
-
if (
|
|
843
|
-
let
|
|
983
|
+
if (u) {
|
|
984
|
+
let t = K(i[0]), n = z.rows[0]?.[i[0]] ?? 0, r = z.rows[0]?.[un(i[0])], a = J.includes(i[0]) ? kt(typeof n == "number" ? n : null, typeof r == "number" ? r : null) : null, o = Bt(e?.colorVariant);
|
|
844
985
|
return /* @__PURE__ */ $("div", {
|
|
845
986
|
className: "flex h-full w-full flex-col items-start justify-center gap-1 p-2",
|
|
846
|
-
children: [
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
987
|
+
children: [
|
|
988
|
+
/* @__PURE__ */ Q("span", {
|
|
989
|
+
className: Z("text-2xl font-semibold tabular-nums", o),
|
|
990
|
+
children: D(n, t?.format, t?.currency, t?.percentScale, ae)
|
|
991
|
+
}),
|
|
992
|
+
a && /* @__PURE__ */ $("div", {
|
|
993
|
+
className: "mt-0.5 flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground",
|
|
994
|
+
"data-testid": "dataset-compare-trend",
|
|
995
|
+
children: [/* @__PURE__ */ $("span", {
|
|
996
|
+
className: Z("flex shrink-0 items-center font-medium", a.direction === "up" && "text-emerald-600 dark:text-emerald-400", a.direction === "down" && "text-rose-600 dark:text-rose-400", a.direction === "neutral" && "text-muted-foreground"),
|
|
997
|
+
children: [
|
|
998
|
+
a.direction === "up" && /* @__PURE__ */ Q(qe, { className: "mr-1 h-3 w-3" }),
|
|
999
|
+
a.direction === "down" && /* @__PURE__ */ Q(Ke, { className: "mr-1 h-3 w-3" }),
|
|
1000
|
+
a.direction === "neutral" && /* @__PURE__ */ Q(tt, { className: "mr-1 h-3 w-3" }),
|
|
1001
|
+
a.value,
|
|
1002
|
+
"%"
|
|
1003
|
+
]
|
|
1004
|
+
}), /* @__PURE__ */ Q("span", {
|
|
1005
|
+
className: "min-w-0 truncate",
|
|
1006
|
+
children: _e
|
|
1007
|
+
})]
|
|
1008
|
+
}),
|
|
1009
|
+
/* @__PURE__ */ Q("span", {
|
|
1010
|
+
className: "text-xs text-muted-foreground",
|
|
1011
|
+
children: q(i[0])
|
|
1012
|
+
})
|
|
1013
|
+
]
|
|
853
1014
|
});
|
|
854
1015
|
}
|
|
855
|
-
if (
|
|
856
|
-
let t =
|
|
1016
|
+
if (d) {
|
|
1017
|
+
let t = ee(z.rows, me), a = (e) => {
|
|
1018
|
+
if (i.includes(e) || !e.endsWith(ln)) return;
|
|
1019
|
+
let t = e.slice(0, -9);
|
|
1020
|
+
return i.includes(t) ? t : void 0;
|
|
1021
|
+
}, o = (e) => {
|
|
1022
|
+
let t = a(e);
|
|
1023
|
+
return t ? `${q(t)} · ${_e}` : q(e);
|
|
1024
|
+
}, s = i.flatMap((e) => J.includes(e) ? [e, un(e)] : [e]), c = [...r, ...s], l = /* @__PURE__ */ Q("button", {
|
|
857
1025
|
type: "button",
|
|
858
|
-
onClick: () =>
|
|
1026
|
+
onClick: () => cn(String(e?.title ?? n ?? "export"), [c.map((e) => o(e)), ...t.map((e) => c.map((t) => {
|
|
859
1027
|
let n = e[t];
|
|
860
1028
|
return n == null ? "" : typeof n == "number" ? n : String(n);
|
|
861
1029
|
}))]),
|
|
862
1030
|
"data-testid": "dataset-export",
|
|
863
|
-
title:
|
|
864
|
-
"aria-label":
|
|
1031
|
+
title: P("dashboard.exportCsv", "Export CSV"),
|
|
1032
|
+
"aria-label": P("dashboard.exportCsv", "Export CSV"),
|
|
865
1033
|
className: "absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100",
|
|
866
|
-
children: /* @__PURE__ */ Q(
|
|
1034
|
+
children: /* @__PURE__ */ Q(Ze, { className: "h-3.5 w-3.5" })
|
|
867
1035
|
});
|
|
868
|
-
if (
|
|
869
|
-
let e =
|
|
1036
|
+
if (m) {
|
|
1037
|
+
let e = an(t, _, y, ae), n = e.colHeaders.flatMap((e) => i.map((t) => ({
|
|
870
1038
|
col: e,
|
|
871
1039
|
measure: t,
|
|
872
|
-
header:
|
|
873
|
-
}))), r = (e, t) =>
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1040
|
+
header: i.length === 1 ? e.label : `${e.label} · ${q(t)}`
|
|
1041
|
+
}))), r = (e, t) => D(e, K(t)?.format, K(t)?.currency, K(t)?.percentScale, ae), a = (e, t) => {
|
|
1042
|
+
if (!J.includes(t)) return null;
|
|
1043
|
+
let n = e?.[un(t)];
|
|
1044
|
+
if (n == null) return null;
|
|
1045
|
+
let i = e?.[t], a = kt(typeof i == "number" ? i : null, typeof n == "number" ? n : null);
|
|
1046
|
+
return /* @__PURE__ */ $("div", {
|
|
1047
|
+
className: "flex items-center justify-end gap-1 text-[10px] font-normal leading-tight text-muted-foreground",
|
|
1048
|
+
"data-testid": "matrix-cell-compare",
|
|
1049
|
+
"data-direction": a?.direction,
|
|
1050
|
+
title: _e,
|
|
1051
|
+
children: [/* @__PURE__ */ Q("span", {
|
|
1052
|
+
className: "tabular-nums",
|
|
1053
|
+
children: r(n, t)
|
|
1054
|
+
}), a && /* @__PURE__ */ $("span", {
|
|
1055
|
+
className: Z("flex shrink-0 items-center tabular-nums font-medium", a.direction === "up" && "text-emerald-600 dark:text-emerald-400", a.direction === "down" && "text-rose-600 dark:text-rose-400"),
|
|
1056
|
+
children: [
|
|
1057
|
+
a.direction === "up" && /* @__PURE__ */ Q(qe, { className: "h-2.5 w-2.5" }),
|
|
1058
|
+
a.direction === "down" && /* @__PURE__ */ Q(Ke, { className: "h-2.5 w-2.5" }),
|
|
1059
|
+
a.direction === "neutral" && /* @__PURE__ */ Q(tt, { className: "h-2.5 w-2.5" }),
|
|
1060
|
+
a.value,
|
|
1061
|
+
"%"
|
|
1062
|
+
]
|
|
1063
|
+
})]
|
|
1064
|
+
});
|
|
1065
|
+
}, o = J.length > 0 ? /* @__PURE__ */ Q("caption", {
|
|
1066
|
+
className: "px-2 pb-1 text-left text-[10px] font-normal text-muted-foreground",
|
|
1067
|
+
"data-testid": "matrix-compare-caption",
|
|
1068
|
+
children: _e
|
|
1069
|
+
}) : null, s = (e) => {
|
|
1070
|
+
let t = z.totals?.find((t) => Array.isArray(t.dimensions) && t.dimensions.join(",") === e.join(","))?.rows;
|
|
1071
|
+
return t && ee(t, me);
|
|
1072
|
+
}, c = /* @__PURE__ */ new Map();
|
|
1073
|
+
for (let e of s(_) ?? []) c.set(j(_.map((t) => N(e[t]))), e);
|
|
1074
|
+
let u = /* @__PURE__ */ new Map();
|
|
1075
|
+
for (let e of s([y]) ?? []) u.set(j([N(e[y])]), e);
|
|
1076
|
+
let d = s([])?.[0], f = c.size > 0, p = u.size > 0, m = P("dashboard.total", "Total");
|
|
878
1077
|
return /* @__PURE__ */ $("div", {
|
|
879
1078
|
className: "relative h-full w-full overflow-auto p-1",
|
|
880
1079
|
"data-testid": "dataset-matrix",
|
|
881
1080
|
children: [
|
|
882
|
-
|
|
1081
|
+
l,
|
|
883
1082
|
/* @__PURE__ */ $("table", {
|
|
884
1083
|
className: "w-full text-xs",
|
|
885
|
-
children: [
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1084
|
+
children: [
|
|
1085
|
+
o,
|
|
1086
|
+
/* @__PURE__ */ Q("thead", {
|
|
1087
|
+
className: "bg-muted/40",
|
|
1088
|
+
children: /* @__PURE__ */ $("tr", { children: [
|
|
1089
|
+
_.map((e) => /* @__PURE__ */ Q("th", {
|
|
1090
|
+
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
1091
|
+
children: q(e)
|
|
1092
|
+
}, e)),
|
|
1093
|
+
n.map((e) => /* @__PURE__ */ Q("th", {
|
|
1094
|
+
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
1095
|
+
children: e.header
|
|
1096
|
+
}, `${e.col.id}-${e.measure}`)),
|
|
1097
|
+
f && i.map((e) => /* @__PURE__ */ Q("th", {
|
|
1098
|
+
className: "px-2 py-1.5 text-right font-medium whitespace-nowrap",
|
|
1099
|
+
"data-testid": "matrix-total-col-header",
|
|
1100
|
+
children: i.length === 1 ? m : `${m} · ${q(e)}`
|
|
1101
|
+
}, `total-${e}`))
|
|
1102
|
+
] })
|
|
1103
|
+
}),
|
|
1104
|
+
/* @__PURE__ */ $("tbody", { children: [e.rowHeaders.map((t) => /* @__PURE__ */ $("tr", {
|
|
1105
|
+
className: "border-t",
|
|
1106
|
+
children: [
|
|
1107
|
+
t.labels.map((e, t) => /* @__PURE__ */ Q("td", {
|
|
1108
|
+
className: "px-2 py-1 whitespace-nowrap font-medium",
|
|
1109
|
+
children: e
|
|
1110
|
+
}, t)),
|
|
1111
|
+
n.map((n) => {
|
|
1112
|
+
let i = e.cellIndex.get(M(t.id, n.col.id)), o = i == null ? void 0 : z.rows[i], s = Ce && i != null, c = [...t.labels, n.col.label].filter(Boolean).join(" / ");
|
|
1113
|
+
return /* @__PURE__ */ $("td", {
|
|
1114
|
+
className: Z("px-2 py-1 text-right tabular-nums whitespace-nowrap", s && "cursor-pointer hover:bg-accent/40"),
|
|
1115
|
+
"data-testid": s ? "dataset-drill-cell" : void 0,
|
|
1116
|
+
onClick: s ? () => we(i, c) : void 0,
|
|
1117
|
+
children: [o ? r(o[n.measure], n.measure) : "—", a(o, n.measure)]
|
|
1118
|
+
}, `${n.col.id}-${n.measure}`);
|
|
1119
|
+
}),
|
|
1120
|
+
f && i.map((e) => {
|
|
1121
|
+
let n = c.get(t.id);
|
|
1122
|
+
return /* @__PURE__ */ $("td", {
|
|
1123
|
+
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium",
|
|
1124
|
+
"data-testid": "matrix-row-total",
|
|
1125
|
+
children: [r(n?.[e], e), a(n, e)]
|
|
1126
|
+
}, `total-${e}`);
|
|
1127
|
+
})
|
|
1128
|
+
]
|
|
1129
|
+
}, t.id)), p && /* @__PURE__ */ $("tr", {
|
|
1130
|
+
className: "border-t bg-muted/30 font-medium",
|
|
1131
|
+
"data-testid": "matrix-total-row",
|
|
1132
|
+
children: [
|
|
1133
|
+
_.length > 0 && /* @__PURE__ */ Q("td", {
|
|
1134
|
+
colSpan: _.length,
|
|
1135
|
+
className: "px-2 py-1 whitespace-nowrap",
|
|
1136
|
+
children: m
|
|
1137
|
+
}),
|
|
1138
|
+
n.map((e) => {
|
|
1139
|
+
let t = u.get(e.col.id);
|
|
1140
|
+
return /* @__PURE__ */ $("td", {
|
|
1141
|
+
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
1142
|
+
children: [r(t?.[e.measure], e.measure), a(t, e.measure)]
|
|
1143
|
+
}, `${e.col.id}-${e.measure}`);
|
|
1144
|
+
}),
|
|
1145
|
+
f && i.map((e) => /* @__PURE__ */ $("td", {
|
|
1146
|
+
className: "px-2 py-1 text-right tabular-nums whitespace-nowrap",
|
|
1147
|
+
"data-testid": "matrix-grand-total",
|
|
1148
|
+
children: [r(d?.[e], e), a(d, e)]
|
|
1149
|
+
}, `grand-${e}`))
|
|
1150
|
+
]
|
|
1151
|
+
})] })
|
|
1152
|
+
]
|
|
944
1153
|
}),
|
|
945
|
-
|
|
1154
|
+
Te
|
|
946
1155
|
]
|
|
947
1156
|
});
|
|
948
1157
|
}
|
|
949
|
-
let
|
|
1158
|
+
let u = [...r, ...s];
|
|
950
1159
|
return /* @__PURE__ */ $("div", {
|
|
951
1160
|
className: "relative h-full w-full overflow-auto p-1",
|
|
952
1161
|
children: [
|
|
953
|
-
|
|
1162
|
+
l,
|
|
954
1163
|
/* @__PURE__ */ $("table", {
|
|
955
1164
|
className: "w-full text-xs",
|
|
956
1165
|
children: [/* @__PURE__ */ Q("thead", {
|
|
957
1166
|
className: "bg-muted/40",
|
|
958
|
-
children: /* @__PURE__ */ Q("tr", { children:
|
|
1167
|
+
children: /* @__PURE__ */ Q("tr", { children: u.map((e) => /* @__PURE__ */ Q("th", {
|
|
959
1168
|
className: "px-2 py-1.5 text-left font-medium whitespace-nowrap",
|
|
960
|
-
|
|
1169
|
+
"data-testid": a(e) ? "dataset-compare-column" : void 0,
|
|
1170
|
+
children: o(e)
|
|
961
1171
|
}, e)) })
|
|
962
|
-
}), /* @__PURE__ */ Q("tbody", { children:
|
|
963
|
-
className:
|
|
964
|
-
"data-testid":
|
|
965
|
-
onClick:
|
|
966
|
-
children:
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1172
|
+
}), /* @__PURE__ */ Q("tbody", { children: t.map((e, t) => /* @__PURE__ */ Q("tr", {
|
|
1173
|
+
className: Z("border-t", Ce && "cursor-pointer hover:bg-accent/40"),
|
|
1174
|
+
"data-testid": Ce ? "dataset-drill-row" : void 0,
|
|
1175
|
+
onClick: Ce ? () => we(t, Se.map((t) => E(e[t], ae)).filter(Boolean).join(" / ")) : void 0,
|
|
1176
|
+
children: u.map((t) => {
|
|
1177
|
+
let n = a(t) ?? (i.includes(t) ? t : void 0);
|
|
1178
|
+
return /* @__PURE__ */ Q("td", {
|
|
1179
|
+
className: "px-2 py-1 whitespace-nowrap tabular-nums",
|
|
1180
|
+
children: n ? D(e[t], K(n)?.format, K(n)?.currency, K(n)?.percentScale, ae) : E(e[t], ae)
|
|
1181
|
+
}, t);
|
|
1182
|
+
})
|
|
970
1183
|
}, t)) })]
|
|
971
1184
|
}),
|
|
972
|
-
|
|
1185
|
+
Te
|
|
973
1186
|
]
|
|
974
1187
|
});
|
|
975
1188
|
}
|
|
976
|
-
let
|
|
977
|
-
let t =
|
|
1189
|
+
let Ee = gn[c] ?? "bar", Oe = ee(z.rows, me), ke = P("chart.nullCategory", "(None)"), { data: Ae, xAxisKey: je, series: Me } = p(Oe, r, i, z.fields, { nullCategoryLabel: ke }), { series: Ne, axes: Pe } = Sn(Me, e?.chartConfig), Fe = r.length >= 2 && i.length === 1 ? [] : J.map((e) => {
|
|
1190
|
+
let t = Ne.find((t) => t.dataKey === e);
|
|
1191
|
+
return {
|
|
1192
|
+
dataKey: un(e),
|
|
1193
|
+
label: `${q(e)} · ${_e}`,
|
|
1194
|
+
variant: "comparison",
|
|
1195
|
+
...t?.chartType ? { chartType: t.chartType } : {},
|
|
1196
|
+
...t?.yAxis ? { yAxis: t.yAxis } : {}
|
|
1197
|
+
};
|
|
1198
|
+
}), Ie = Fe.length > 0 ? [...Ne.map((e) => ({
|
|
1199
|
+
...e,
|
|
1200
|
+
variant: e.variant ?? "current"
|
|
1201
|
+
})), ...Fe] : Ne, Le = (Array.isArray(x.stageOrder) ? x.stageOrder : void 0)?.flatMap((e) => {
|
|
1202
|
+
let t = String(e), n = me?.[r[0]]?.[t];
|
|
978
1203
|
return n && n !== t ? [t, n] : [t];
|
|
979
|
-
}),
|
|
980
|
-
let t =
|
|
1204
|
+
}), Re = Le?.length ? Le : W, ze = _n(e?.chartConfig, U), Be = Ce ? (e) => {
|
|
1205
|
+
let t = T(Oe, r, i, e?.category, e?.series, { nullCategoryLabel: ke });
|
|
981
1206
|
if (t < 0) return;
|
|
982
|
-
let n =
|
|
983
|
-
|
|
1207
|
+
let n = r.length >= 2 && i.length === 1, a = [e?.category, n ? e?.series : void 0].filter(Boolean).map(String).join(" / ");
|
|
1208
|
+
we(t, a);
|
|
984
1209
|
} : void 0;
|
|
985
1210
|
return /* @__PURE__ */ $("div", {
|
|
986
|
-
className:
|
|
987
|
-
children: [/* @__PURE__ */ Q(
|
|
1211
|
+
className: Z("relative h-full w-full min-h-[220px]"),
|
|
1212
|
+
children: [/* @__PURE__ */ Q(oe, {
|
|
988
1213
|
schema: {
|
|
989
1214
|
type: "chart",
|
|
990
|
-
chartType:
|
|
991
|
-
data:
|
|
992
|
-
xAxisKey:
|
|
993
|
-
series:
|
|
1215
|
+
chartType: Ee,
|
|
1216
|
+
data: Ae,
|
|
1217
|
+
xAxisKey: je,
|
|
1218
|
+
series: Ie,
|
|
994
1219
|
isAnimationActive: !1,
|
|
995
|
-
...
|
|
996
|
-
...
|
|
997
|
-
...
|
|
1220
|
+
...ze,
|
|
1221
|
+
...Pe,
|
|
1222
|
+
...Re ? { categoryOrder: Re } : {}
|
|
998
1223
|
},
|
|
999
|
-
onChartClick:
|
|
1000
|
-
onSegmentClick:
|
|
1001
|
-
}),
|
|
1224
|
+
onChartClick: Be,
|
|
1225
|
+
onSegmentClick: Be
|
|
1226
|
+
}), Te]
|
|
1002
1227
|
});
|
|
1003
1228
|
}
|
|
1004
1229
|
//#endregion
|
|
1005
1230
|
//#region src/DashboardFilterBar.tsx
|
|
1006
|
-
|
|
1007
|
-
|
|
1231
|
+
function wn(e) {
|
|
1232
|
+
let { language: t } = W();
|
|
1233
|
+
return H(e.label, t);
|
|
1234
|
+
}
|
|
1235
|
+
var Tn = "__all__", En = "__custom__";
|
|
1236
|
+
function Dn(e, t) {
|
|
1008
1237
|
if (e) {
|
|
1009
1238
|
if (e.preset) return t(e.preset);
|
|
1010
1239
|
if (e.from || e.to) return `${e.from ?? "…"} – ${e.to ?? "…"}`;
|
|
1011
1240
|
}
|
|
1012
1241
|
}
|
|
1013
|
-
function
|
|
1242
|
+
function On(e) {
|
|
1014
1243
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
1015
1244
|
}
|
|
1016
|
-
function
|
|
1017
|
-
let i =
|
|
1245
|
+
function kn({ def: e, value: t, onChange: n }) {
|
|
1246
|
+
let r = G(), i = wn(e), [a, o] = l(!1), s = e.allowCustomRange !== !1, c = (e) => r(`dashboard.filters.range.${e}`, e.replace(/_/g, " ")), u = t?.preset ?? (t?.from || t?.to ? En : Tn);
|
|
1018
1247
|
return /* @__PURE__ */ $("div", {
|
|
1019
1248
|
className: "flex items-center gap-1",
|
|
1020
1249
|
"data-testid": `dashboard-filter-${e.name}`,
|
|
1021
|
-
children: [/* @__PURE__ */ $(
|
|
1022
|
-
value:
|
|
1250
|
+
children: [/* @__PURE__ */ $(Ne, {
|
|
1251
|
+
value: u,
|
|
1023
1252
|
onValueChange: (e) => {
|
|
1024
|
-
e ===
|
|
1253
|
+
e === Tn ? n(void 0) : e === En ? o(!0) : n({ preset: e });
|
|
1025
1254
|
},
|
|
1026
|
-
children: [/* @__PURE__ */ $(
|
|
1255
|
+
children: [/* @__PURE__ */ $(Ie, {
|
|
1027
1256
|
className: "h-8 w-auto min-w-36 gap-1",
|
|
1028
|
-
"aria-label":
|
|
1029
|
-
children: [/* @__PURE__ */ Q(
|
|
1030
|
-
placeholder:
|
|
1031
|
-
children:
|
|
1257
|
+
"aria-label": i || r("dashboard.filters.dateRange", "Date range"),
|
|
1258
|
+
children: [/* @__PURE__ */ Q(Xe, { className: "size-3.5 opacity-60" }), /* @__PURE__ */ Q(Le, {
|
|
1259
|
+
placeholder: r("dashboard.filters.dateRange", "Date range"),
|
|
1260
|
+
children: Dn(t, c) ?? r("dashboard.filters.allTime", "All time")
|
|
1032
1261
|
})]
|
|
1033
|
-
}), /* @__PURE__ */ $(
|
|
1034
|
-
/* @__PURE__ */ Q(
|
|
1035
|
-
value:
|
|
1036
|
-
children:
|
|
1262
|
+
}), /* @__PURE__ */ $(Pe, { children: [
|
|
1263
|
+
/* @__PURE__ */ Q(Fe, {
|
|
1264
|
+
value: Tn,
|
|
1265
|
+
children: r("dashboard.filters.allTime", "All time")
|
|
1037
1266
|
}),
|
|
1038
|
-
|
|
1267
|
+
d.map((e) => /* @__PURE__ */ Q(Fe, {
|
|
1039
1268
|
value: e,
|
|
1040
1269
|
children: c(e)
|
|
1041
1270
|
}, e)),
|
|
1042
|
-
s && /* @__PURE__ */ Q(
|
|
1043
|
-
value:
|
|
1044
|
-
children:
|
|
1271
|
+
s && /* @__PURE__ */ Q(Fe, {
|
|
1272
|
+
value: En,
|
|
1273
|
+
children: r("dashboard.filters.custom", "Custom…")
|
|
1045
1274
|
})
|
|
1046
1275
|
] })]
|
|
1047
|
-
}), s && /* @__PURE__ */ $(
|
|
1276
|
+
}), s && /* @__PURE__ */ $(ke, {
|
|
1048
1277
|
open: a,
|
|
1049
1278
|
onOpenChange: o,
|
|
1050
|
-
children: [/* @__PURE__ */ Q(
|
|
1279
|
+
children: [/* @__PURE__ */ Q(je, {
|
|
1051
1280
|
asChild: !0,
|
|
1052
1281
|
children: /* @__PURE__ */ Q("span", {
|
|
1053
1282
|
"aria-hidden": !0,
|
|
1054
1283
|
className: "size-0"
|
|
1055
1284
|
})
|
|
1056
|
-
}), /* @__PURE__ */ Q(
|
|
1285
|
+
}), /* @__PURE__ */ Q(Ae, {
|
|
1057
1286
|
className: "w-auto p-0",
|
|
1058
1287
|
align: "start",
|
|
1059
|
-
children: /* @__PURE__ */ Q(
|
|
1288
|
+
children: /* @__PURE__ */ Q(q, {
|
|
1060
1289
|
mode: "range",
|
|
1061
1290
|
numberOfMonths: 2,
|
|
1062
1291
|
selected: {
|
|
1063
|
-
from:
|
|
1064
|
-
to:
|
|
1292
|
+
from: t?.from && !t.from.startsWith("{") ? new Date(t.from) : void 0,
|
|
1293
|
+
to: t?.to && !t.to.startsWith("{") ? new Date(t.to) : void 0
|
|
1065
1294
|
},
|
|
1066
1295
|
onSelect: (e) => {
|
|
1067
1296
|
if (!e?.from && !e?.to) {
|
|
1068
|
-
|
|
1297
|
+
n(void 0);
|
|
1069
1298
|
return;
|
|
1070
1299
|
}
|
|
1071
|
-
|
|
1072
|
-
...e?.from ? { from:
|
|
1073
|
-
...e?.to ? { to:
|
|
1300
|
+
n({
|
|
1301
|
+
...e?.from ? { from: On(e.from) } : {},
|
|
1302
|
+
...e?.to ? { to: On(e.to) } : {}
|
|
1074
1303
|
});
|
|
1075
1304
|
}
|
|
1076
1305
|
})
|
|
@@ -1078,48 +1307,54 @@ function Qt({ def: e, value: n, onChange: r }) {
|
|
|
1078
1307
|
})]
|
|
1079
1308
|
});
|
|
1080
1309
|
}
|
|
1081
|
-
function
|
|
1082
|
-
let
|
|
1083
|
-
|
|
1084
|
-
|
|
1310
|
+
function An(e, t, n) {
|
|
1311
|
+
let r = Array.isArray(t) && t.length === e.length && t.some((e) => e?.[n.valueField] !== void 0) ? t : void 0, i = /* @__PURE__ */ new Map();
|
|
1312
|
+
for (let t = 0; t < e.length; t++) {
|
|
1313
|
+
let a = e[t], o = r ? r[t]?.[n.valueField] : a?.[n.valueField];
|
|
1314
|
+
if (o == null || o === "") continue;
|
|
1315
|
+
let s = String(o);
|
|
1316
|
+
if (i.has(s)) continue;
|
|
1317
|
+
let c = n.labelField ? a?.[n.labelField] : a?.[n.valueField];
|
|
1318
|
+
i.set(s, String(c ?? s));
|
|
1319
|
+
}
|
|
1320
|
+
return Array.from(i, ([e, t]) => ({
|
|
1321
|
+
value: e,
|
|
1322
|
+
label: t
|
|
1323
|
+
}));
|
|
1324
|
+
}
|
|
1325
|
+
function jn({ def: e, value: t, onChange: n, dataSource: r }) {
|
|
1326
|
+
let i = G(), { language: a } = W(), c = wn(e), [u, d] = l(null), f = e.optionsFrom;
|
|
1327
|
+
o(() => {
|
|
1328
|
+
if (!f || !r) return;
|
|
1085
1329
|
let e = !1, t = () => {
|
|
1086
1330
|
if (typeof r.find != "function") {
|
|
1087
|
-
e ||
|
|
1331
|
+
e || d([]);
|
|
1088
1332
|
return;
|
|
1089
1333
|
}
|
|
1090
|
-
r.find(
|
|
1091
|
-
fields: [
|
|
1092
|
-
...
|
|
1334
|
+
r.find(f.object, {
|
|
1335
|
+
fields: [f.valueField, ...f.labelField ? [f.labelField] : []],
|
|
1336
|
+
...f.filter ? { $filter: f.filter } : {},
|
|
1093
1337
|
top: 200
|
|
1094
1338
|
}).then((t) => {
|
|
1095
1339
|
if (e) return;
|
|
1096
|
-
let n = Array.isArray(t) ? t : t?.items ?? []
|
|
1097
|
-
|
|
1098
|
-
let t = e?.[s.valueField];
|
|
1099
|
-
if (t == null || t === "") continue;
|
|
1100
|
-
let n = String(t);
|
|
1101
|
-
r.has(n) || r.set(n, String(s.labelField ? e?.[s.labelField] ?? n : n));
|
|
1102
|
-
}
|
|
1103
|
-
o(Array.from(r, ([e, t]) => ({
|
|
1104
|
-
value: e,
|
|
1105
|
-
label: t
|
|
1106
|
-
})));
|
|
1340
|
+
let n = Array.isArray(t) ? t : t?.items ?? [];
|
|
1341
|
+
d(An(n, void 0, f));
|
|
1107
1342
|
}).catch(() => {
|
|
1108
|
-
e ||
|
|
1343
|
+
e || d([]);
|
|
1109
1344
|
});
|
|
1110
1345
|
};
|
|
1111
1346
|
if (typeof r.queryDataset == "function") {
|
|
1112
1347
|
let n = [{
|
|
1113
|
-
name:
|
|
1114
|
-
field:
|
|
1348
|
+
name: f.valueField,
|
|
1349
|
+
field: f.valueField
|
|
1115
1350
|
}];
|
|
1116
|
-
|
|
1117
|
-
name:
|
|
1118
|
-
field:
|
|
1351
|
+
f.labelField && f.labelField !== f.valueField && n.push({
|
|
1352
|
+
name: f.labelField,
|
|
1353
|
+
field: f.labelField
|
|
1119
1354
|
}), r.queryDataset({
|
|
1120
1355
|
name: "dashboard_filter_options",
|
|
1121
1356
|
label: "Dashboard filter options",
|
|
1122
|
-
object:
|
|
1357
|
+
object: f.object,
|
|
1123
1358
|
dimensions: n,
|
|
1124
1359
|
measures: [{
|
|
1125
1360
|
name: "option_count",
|
|
@@ -1128,22 +1363,13 @@ function $t({ def: e, value: t, onChange: n, dataSource: r }) {
|
|
|
1128
1363
|
}, {
|
|
1129
1364
|
dimensions: n.map((e) => e.name),
|
|
1130
1365
|
measures: ["option_count"],
|
|
1131
|
-
...
|
|
1132
|
-
order: { [
|
|
1366
|
+
...f.filter ? { runtimeFilter: f.filter } : {},
|
|
1367
|
+
order: { [f.valueField]: "asc" },
|
|
1133
1368
|
limit: 1e3
|
|
1134
1369
|
}).then((t) => {
|
|
1135
1370
|
if (e) return;
|
|
1136
|
-
let n = Array.isArray(t?.rows) ? t.rows : [], r =
|
|
1137
|
-
|
|
1138
|
-
let t = e?.[s.valueField];
|
|
1139
|
-
if (t == null || t === "") continue;
|
|
1140
|
-
let n = String(t);
|
|
1141
|
-
r.has(n) || r.set(n, String(s.labelField ? e?.[s.labelField] ?? n : n));
|
|
1142
|
-
}
|
|
1143
|
-
o(Array.from(r, ([e, t]) => ({
|
|
1144
|
-
value: e,
|
|
1145
|
-
label: t
|
|
1146
|
-
})));
|
|
1371
|
+
let n = Array.isArray(t?.rows) ? t.rows : [], r = Array.isArray(t?.drillRawRows) ? t.drillRawRows : void 0;
|
|
1372
|
+
d(An(n, r, f));
|
|
1147
1373
|
}).catch(() => {
|
|
1148
1374
|
e || t();
|
|
1149
1375
|
});
|
|
@@ -1152,101 +1378,108 @@ function $t({ def: e, value: t, onChange: n, dataSource: r }) {
|
|
|
1152
1378
|
e = !0;
|
|
1153
1379
|
};
|
|
1154
1380
|
}, [
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1381
|
+
f?.object,
|
|
1382
|
+
f?.valueField,
|
|
1383
|
+
f?.labelField,
|
|
1158
1384
|
r
|
|
1159
1385
|
]);
|
|
1160
|
-
let
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1386
|
+
let p = s(() => (e.options?.length ? e.options : u ?? []).map((e) => ({
|
|
1387
|
+
value: e.value,
|
|
1388
|
+
label: H(e.label, a) || e.value
|
|
1389
|
+
})), [
|
|
1390
|
+
e.options,
|
|
1391
|
+
u,
|
|
1392
|
+
a
|
|
1393
|
+
]), m = c || e.name, h = t ? p.find((e) => e.value === String(t))?.label ?? String(t) : void 0;
|
|
1394
|
+
return /* @__PURE__ */ $(Ne, {
|
|
1395
|
+
value: t ? String(t) : Tn,
|
|
1396
|
+
onValueChange: (e) => n(e === Tn ? void 0 : e),
|
|
1397
|
+
children: [/* @__PURE__ */ Q(Ie, {
|
|
1165
1398
|
className: "h-8 w-auto min-w-32",
|
|
1166
|
-
"aria-label":
|
|
1399
|
+
"aria-label": m,
|
|
1167
1400
|
"data-testid": `dashboard-filter-${e.name}`,
|
|
1168
|
-
children: /* @__PURE__ */ Q(
|
|
1169
|
-
}), /* @__PURE__ */ $(
|
|
1170
|
-
value:
|
|
1401
|
+
children: /* @__PURE__ */ Q(Le, { children: h ?? `${m}: ${i("dashboard.filters.all", "All")}` })
|
|
1402
|
+
}), /* @__PURE__ */ $(Pe, { children: [/* @__PURE__ */ Q(Fe, {
|
|
1403
|
+
value: Tn,
|
|
1171
1404
|
children: i("dashboard.filters.all", "All")
|
|
1172
|
-
}),
|
|
1405
|
+
}), p.map((e) => /* @__PURE__ */ Q(Fe, {
|
|
1173
1406
|
value: e.value,
|
|
1174
1407
|
children: e.label
|
|
1175
1408
|
}, e.value))] })]
|
|
1176
1409
|
});
|
|
1177
1410
|
}
|
|
1178
|
-
function
|
|
1179
|
-
let
|
|
1180
|
-
|
|
1181
|
-
|
|
1411
|
+
function Mn({ def: e, value: t, onChange: n }) {
|
|
1412
|
+
let r = wn(e) || e.name, [i, a] = l(t == null ? "" : String(t));
|
|
1413
|
+
o(() => {
|
|
1414
|
+
a(t == null ? "" : String(t));
|
|
1182
1415
|
}, [t]);
|
|
1183
|
-
let
|
|
1184
|
-
let t =
|
|
1416
|
+
let s = () => {
|
|
1417
|
+
let t = i.trim();
|
|
1185
1418
|
if (t === "") {
|
|
1186
1419
|
n(void 0);
|
|
1187
1420
|
return;
|
|
1188
1421
|
}
|
|
1189
1422
|
n(e.type === "number" ? Number(t) : t);
|
|
1190
1423
|
};
|
|
1191
|
-
return /* @__PURE__ */ Q(
|
|
1424
|
+
return /* @__PURE__ */ Q(Oe, {
|
|
1192
1425
|
className: "h-8 w-36",
|
|
1193
1426
|
type: e.type === "number" ? "number" : "text",
|
|
1194
|
-
placeholder:
|
|
1195
|
-
value:
|
|
1196
|
-
onChange: (e) =>
|
|
1197
|
-
onBlur:
|
|
1427
|
+
placeholder: r,
|
|
1428
|
+
value: i,
|
|
1429
|
+
onChange: (e) => a(e.target.value),
|
|
1430
|
+
onBlur: s,
|
|
1198
1431
|
onKeyDown: (e) => {
|
|
1199
|
-
e.key === "Enter" &&
|
|
1432
|
+
e.key === "Enter" && s();
|
|
1200
1433
|
},
|
|
1201
|
-
"aria-label":
|
|
1434
|
+
"aria-label": r,
|
|
1202
1435
|
"data-testid": `dashboard-filter-${e.name}`
|
|
1203
1436
|
});
|
|
1204
1437
|
}
|
|
1205
|
-
function
|
|
1206
|
-
let o =
|
|
1438
|
+
function Nn({ defs: e, values: t, onChange: n, onReset: r, dataSource: i, className: a }) {
|
|
1439
|
+
let o = G();
|
|
1207
1440
|
if (e.length === 0) return null;
|
|
1208
1441
|
let s = (e) => e == null || e === "" || typeof e == "object" && Object.keys(e).length === 0, c = e.some((e) => {
|
|
1209
1442
|
let n = t[e.name], r = e.defaultValue;
|
|
1210
1443
|
return s(n) && s(r) ? !1 : JSON.stringify(n ?? null) !== JSON.stringify(r ?? null);
|
|
1211
1444
|
});
|
|
1212
1445
|
return /* @__PURE__ */ $("div", {
|
|
1213
|
-
className:
|
|
1446
|
+
className: Z("col-span-full flex flex-wrap items-center gap-2", a),
|
|
1214
1447
|
"data-testid": "dashboard-filter-bar",
|
|
1215
1448
|
role: "group",
|
|
1216
1449
|
"aria-label": o("dashboard.filters.label", "Dashboard filters"),
|
|
1217
1450
|
children: [e.map((e) => {
|
|
1218
1451
|
let r = t[e.name], a = (t) => n(e.name, t);
|
|
1219
|
-
return e.type === "dateRange" || e.type === "date" ? /* @__PURE__ */ Q(
|
|
1452
|
+
return e.type === "dateRange" || e.type === "date" ? /* @__PURE__ */ Q(kn, {
|
|
1220
1453
|
def: e,
|
|
1221
1454
|
value: r,
|
|
1222
1455
|
onChange: a
|
|
1223
|
-
}, e.name) : e.type === "select" || e.type === "lookup" ? /* @__PURE__ */ Q(
|
|
1456
|
+
}, e.name) : e.type === "select" || e.type === "lookup" ? /* @__PURE__ */ Q(jn, {
|
|
1224
1457
|
def: e,
|
|
1225
1458
|
value: r,
|
|
1226
1459
|
onChange: a,
|
|
1227
1460
|
dataSource: i
|
|
1228
|
-
}, e.name) : /* @__PURE__ */ Q(
|
|
1461
|
+
}, e.name) : /* @__PURE__ */ Q(Mn, {
|
|
1229
1462
|
def: e,
|
|
1230
1463
|
value: r,
|
|
1231
1464
|
onChange: a
|
|
1232
1465
|
}, e.name);
|
|
1233
|
-
}), r && c && /* @__PURE__ */ $(
|
|
1466
|
+
}), r && c && /* @__PURE__ */ $(K, {
|
|
1234
1467
|
variant: "ghost",
|
|
1235
1468
|
size: "sm",
|
|
1236
1469
|
onClick: r,
|
|
1237
1470
|
className: "text-muted-foreground",
|
|
1238
|
-
children: [/* @__PURE__ */ Q(
|
|
1471
|
+
children: [/* @__PURE__ */ Q(rt, { className: "size-3.5" }), o("dashboard.filters.reset", "Reset")]
|
|
1239
1472
|
})]
|
|
1240
1473
|
});
|
|
1241
1474
|
}
|
|
1242
1475
|
//#endregion
|
|
1243
1476
|
//#region src/DashboardRenderer.tsx
|
|
1244
|
-
function
|
|
1245
|
-
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } =
|
|
1477
|
+
function Pn({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
1478
|
+
let { attributes: a, listeners: o, setNodeRef: s, transform: c, transition: l, isDragging: u, isOver: d } = ht({
|
|
1246
1479
|
id: e,
|
|
1247
1480
|
disabled: t
|
|
1248
1481
|
}), f = {
|
|
1249
|
-
transform:
|
|
1482
|
+
transform: _t.Transform.toString(c),
|
|
1250
1483
|
transition: l,
|
|
1251
1484
|
opacity: u ? .4 : 1,
|
|
1252
1485
|
...n ? {
|
|
@@ -1257,26 +1490,23 @@ function nn({ id: e, disabled: t, gridSpan: n, className: r, children: i }) {
|
|
|
1257
1490
|
return /* @__PURE__ */ Q("div", {
|
|
1258
1491
|
ref: s,
|
|
1259
1492
|
style: f,
|
|
1260
|
-
className:
|
|
1493
|
+
className: Z("h-full w-full", r, !t && "cursor-grab active:cursor-grabbing", d && !u && "ring-2 ring-primary ring-offset-2 rounded-lg"),
|
|
1261
1494
|
"data-sortable-widget-id": e,
|
|
1262
1495
|
...a,
|
|
1263
1496
|
...o,
|
|
1264
1497
|
children: i
|
|
1265
1498
|
});
|
|
1266
1499
|
}
|
|
1267
|
-
function
|
|
1268
|
-
return e ?
|
|
1500
|
+
function Fn(e) {
|
|
1501
|
+
return e ? He(e) : null;
|
|
1269
1502
|
}
|
|
1270
|
-
|
|
1271
|
-
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
1272
|
-
}
|
|
1273
|
-
var on = [
|
|
1503
|
+
var In = [
|
|
1274
1504
|
"hsl(var(--chart-1))",
|
|
1275
1505
|
"hsl(var(--chart-2))",
|
|
1276
1506
|
"hsl(var(--chart-3))",
|
|
1277
1507
|
"hsl(var(--chart-4))",
|
|
1278
1508
|
"hsl(var(--chart-5))"
|
|
1279
|
-
],
|
|
1509
|
+
], Ln = /* @__PURE__ */ new Set([
|
|
1280
1510
|
"bar",
|
|
1281
1511
|
"horizontal-bar",
|
|
1282
1512
|
"line",
|
|
@@ -1288,21 +1518,15 @@ var on = [
|
|
|
1288
1518
|
"treemap",
|
|
1289
1519
|
"sankey"
|
|
1290
1520
|
]);
|
|
1291
|
-
function
|
|
1292
|
-
return
|
|
1521
|
+
function Rn(e) {
|
|
1522
|
+
return Ln.has(e) ? { enabled: !0 } : void 0;
|
|
1293
1523
|
}
|
|
1294
|
-
var
|
|
1524
|
+
var zn = /* @__PURE__ */ new Set([
|
|
1295
1525
|
"object-chart",
|
|
1296
1526
|
"object-metric",
|
|
1297
1527
|
"object-data-table"
|
|
1298
|
-
]),
|
|
1299
|
-
|
|
1300
|
-
value: "This widget uses a retired data format. Edit it to bind a dataset.",
|
|
1301
|
-
variant: "caption",
|
|
1302
|
-
align: "center",
|
|
1303
|
-
className: "flex h-full w-full items-center justify-center rounded border border-dashed border-destructive/40 bg-destructive/5 p-4 text-center text-destructive"
|
|
1304
|
-
}, dn = je(({ schema: e, className: t, dataSource: n, onRefresh: r, recordCount: i, userActions: a, designMode: o, selectedWidgetId: s, onWidgetClick: l, onWidgetsReorder: u, modalHandler: d, scriptHandlers: f, hideHeaderText: p, ...m }, h) => {
|
|
1305
|
-
let g = (() => {
|
|
1528
|
+
]), Bn = r(({ schema: e, className: t, dataSource: r, onRefresh: a, recordCount: u, userActions: d, designMode: f, selectedWidgetId: p, onWidgetClick: m, onWidgetsReorder: h, modalHandler: g, scriptHandlers: v, hideHeaderText: y, ...b }, x) => {
|
|
1529
|
+
let S = (() => {
|
|
1306
1530
|
if (e.columns != null) return e.columns;
|
|
1307
1531
|
let t = e.widgets ?? [], n = 0;
|
|
1308
1532
|
for (let e of t) {
|
|
@@ -1310,91 +1534,103 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1310
1534
|
t > n && (n = t), (e.layout?.w ?? 0) > n && (n = e.layout.w);
|
|
1311
1535
|
}
|
|
1312
1536
|
return n > 4 ? 12 : 4;
|
|
1313
|
-
})(),
|
|
1537
|
+
})(), C = S, w = e.gap || 4, T = e.columns != null || S !== 4, [E, D] = l(!1), [O, k] = l(!1), j = c(null), M = s(() => te(e), [e.globalFilters, e.dateRange]), { variables: N, setVariable: ee, resetVariables: ne } = fe(), re = s(() => (e.header?.actions ?? []).map((e) => ({
|
|
1314
1538
|
name: e.actionUrl || e.label,
|
|
1315
1539
|
type: e.actionType || "url",
|
|
1316
1540
|
target: e.actionUrl,
|
|
1317
1541
|
label: e.label
|
|
1318
|
-
})), [e.header?.actions]), { executeAction:
|
|
1319
|
-
if (
|
|
1542
|
+
})), [e.header?.actions]), { executeAction: P, engine: F } = I({ actions: re }), { dashboardLabel: ae, dashboardDescription: se, dashboardActionLabel: L, widgetTitle: ce, widgetDescription: R, fieldLabel: le } = de(), { t: ue, language: z } = W(), B = i((e) => {
|
|
1543
|
+
if (e != null) return H(e, z) || void 0;
|
|
1544
|
+
}, [z]), V = i((e, t, n) => n && (!t || t === "value" || t === "count" || n === "count") ? ue(`report.aggregate.${n}`, { defaultValue: n }) : e ? le(e, t, t) : t, [ue, le]), U = e.name, pe = i((e) => {
|
|
1545
|
+
if (!U) return e.label;
|
|
1320
1546
|
let t = e.actionUrl || e.label;
|
|
1321
|
-
return
|
|
1322
|
-
}, [
|
|
1323
|
-
let t =
|
|
1324
|
-
return !
|
|
1325
|
-
}, [V, ae]), fe = J((e) => {
|
|
1326
|
-
let t = an(e.description);
|
|
1327
|
-
return !V || !e.id ? t : ce(V, e.id, t);
|
|
1328
|
-
}, [V, ce]);
|
|
1329
|
-
Y(() => {
|
|
1330
|
-
let e = P.getRunner();
|
|
1331
|
-
if (d && e.setModalHandler(d), f) for (let [t, n] of Object.entries(f)) e.registerScript(t, n);
|
|
1547
|
+
return L(U, t, e.label);
|
|
1548
|
+
}, [U, L]), me = i((e) => {
|
|
1549
|
+
let t = B(e.title);
|
|
1550
|
+
return !U || !e.id || t === void 0 ? t : ce(U, e.id, t);
|
|
1332
1551
|
}, [
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
]),
|
|
1337
|
-
let
|
|
1552
|
+
U,
|
|
1553
|
+
ce,
|
|
1554
|
+
B
|
|
1555
|
+
]), he = i((e) => {
|
|
1556
|
+
let t = B(e.description);
|
|
1557
|
+
return !U || !e.id ? t : R(U, e.id, t);
|
|
1558
|
+
}, [
|
|
1559
|
+
U,
|
|
1560
|
+
R,
|
|
1561
|
+
B
|
|
1562
|
+
]);
|
|
1563
|
+
o(() => {
|
|
1564
|
+
let e = F.getRunner();
|
|
1565
|
+
if (g && e.setModalHandler(g), v) for (let [t, n] of Object.entries(v)) e.registerScript(t, n);
|
|
1566
|
+
}, [
|
|
1567
|
+
F,
|
|
1568
|
+
g,
|
|
1569
|
+
v
|
|
1570
|
+
]), o(() => {
|
|
1571
|
+
let e = () => k(window.innerWidth < 768);
|
|
1338
1572
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
1339
1573
|
}, []);
|
|
1340
|
-
let
|
|
1341
|
-
|
|
1342
|
-
}, [
|
|
1343
|
-
|
|
1344
|
-
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !
|
|
1345
|
-
|
|
1574
|
+
let G = i(() => {
|
|
1575
|
+
a && (D(!0), a(), setTimeout(() => D(!1), 600));
|
|
1576
|
+
}, [a]);
|
|
1577
|
+
o(() => {
|
|
1578
|
+
if (!(!e.refreshInterval || e.refreshInterval <= 0 || !a)) return j.current = setInterval(G, e.refreshInterval * 1e3), () => {
|
|
1579
|
+
j.current && clearInterval(j.current);
|
|
1346
1580
|
};
|
|
1347
1581
|
}, [
|
|
1348
1582
|
e.refreshInterval,
|
|
1349
|
-
|
|
1350
|
-
|
|
1583
|
+
a,
|
|
1584
|
+
G
|
|
1351
1585
|
]);
|
|
1352
|
-
let
|
|
1353
|
-
!
|
|
1354
|
-
}, [
|
|
1355
|
-
if (!
|
|
1586
|
+
let q = i((e, t) => {
|
|
1587
|
+
!f || !m || !t || (e.stopPropagation(), m(t));
|
|
1588
|
+
}, [f, m]), ye = i((t, n, r) => {
|
|
1589
|
+
if (!f || !m) return;
|
|
1356
1590
|
let i = e.widgets || [];
|
|
1357
|
-
if (t.key === "Enter" || t.key === " ") t.preventDefault(),
|
|
1591
|
+
if (t.key === "Enter" || t.key === " ") t.preventDefault(), m(n ?? null);
|
|
1358
1592
|
else if (t.key === "ArrowRight" || t.key === "ArrowDown") {
|
|
1359
1593
|
t.preventDefault();
|
|
1360
1594
|
let e = r + 1 < i.length ? i[r + 1] : null;
|
|
1361
|
-
e?.id &&
|
|
1595
|
+
e?.id && m(e.id);
|
|
1362
1596
|
} else if (t.key === "ArrowLeft" || t.key === "ArrowUp") {
|
|
1363
1597
|
t.preventDefault();
|
|
1364
1598
|
let e = r - 1 >= 0 ? i[r - 1] : null;
|
|
1365
|
-
e?.id &&
|
|
1366
|
-
} else t.key === "Escape" && (t.preventDefault(),
|
|
1599
|
+
e?.id && m(e.id);
|
|
1600
|
+
} else t.key === "Escape" && (t.preventDefault(), m(null));
|
|
1367
1601
|
}, [
|
|
1368
|
-
|
|
1369
|
-
|
|
1602
|
+
f,
|
|
1603
|
+
m,
|
|
1370
1604
|
e.widgets
|
|
1371
|
-
]),
|
|
1372
|
-
!
|
|
1373
|
-
}, [
|
|
1374
|
-
|
|
1605
|
+
]), be = i((e) => {
|
|
1606
|
+
!f || !m || e.target === e.currentTarget && m(null);
|
|
1607
|
+
}, [f, m]), xe = (e) => {
|
|
1608
|
+
be(e), typeof b.onClick == "function" && b.onClick(e);
|
|
1609
|
+
}, Y = !!(f && h), Se = dt(ut(ct, { activationConstraint: { distance: 5 } })), Ce = i((t) => {
|
|
1610
|
+
if (!Y) return;
|
|
1375
1611
|
let { active: n, over: r } = t;
|
|
1376
1612
|
if (!r || n.id === r.id) return;
|
|
1377
1613
|
let i = e.widgets ?? [], a = i.findIndex((e) => e.id === n.id), o = i.findIndex((e) => e.id === r.id);
|
|
1378
|
-
a < 0 || o < 0 ||
|
|
1614
|
+
a < 0 || o < 0 || h?.(pt(i, a, o));
|
|
1379
1615
|
}, [
|
|
1380
|
-
|
|
1616
|
+
Y,
|
|
1381
1617
|
e.widgets,
|
|
1382
|
-
|
|
1383
|
-
]),
|
|
1384
|
-
let
|
|
1385
|
-
w: Math.min(
|
|
1386
|
-
h:
|
|
1387
|
-
} : void 0,
|
|
1388
|
-
...
|
|
1389
|
-
w: Math.min(
|
|
1390
|
-
} : void 0,
|
|
1618
|
+
h
|
|
1619
|
+
]), we = (e, t, i) => {
|
|
1620
|
+
let a = e.type === "metric" || Mt.has(e.type || ""), o = T ? {
|
|
1621
|
+
w: Math.min(a ? 3 : 6, C),
|
|
1622
|
+
h: a ? 2 : 4
|
|
1623
|
+
} : void 0, s = e.layout ?? o, c = s ? {
|
|
1624
|
+
...s,
|
|
1625
|
+
w: Math.min(s.w, C)
|
|
1626
|
+
} : void 0, l = !!e.dataset, u = () => {
|
|
1391
1627
|
if (e.component) return e.component;
|
|
1392
1628
|
let t = e.type, n = e.options || {}, r = e.data || n.data;
|
|
1393
|
-
if (
|
|
1394
|
-
let i =
|
|
1629
|
+
if (Lt(e)) return It;
|
|
1630
|
+
let i = Ft(t), a = i.chartType ?? t;
|
|
1395
1631
|
if (i.family === "series" && i.chartType) {
|
|
1396
1632
|
let t = n.xField || "name", o = n.yField || "value";
|
|
1397
|
-
if (
|
|
1633
|
+
if (Et(r)) {
|
|
1398
1634
|
let s = r.aggregate, c = s ? {
|
|
1399
1635
|
field: s.field,
|
|
1400
1636
|
function: s.function,
|
|
@@ -1409,11 +1645,11 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1409
1645
|
xAxisKey: t,
|
|
1410
1646
|
series: [{
|
|
1411
1647
|
dataKey: l,
|
|
1412
|
-
label:
|
|
1648
|
+
label: V(r.object, l, c?.function)
|
|
1413
1649
|
}],
|
|
1414
|
-
colors:
|
|
1650
|
+
colors: In,
|
|
1415
1651
|
isAnimationActive: !1,
|
|
1416
|
-
drillDown: n.drillDown ??
|
|
1652
|
+
drillDown: n.drillDown ?? Rn(i.chartType),
|
|
1417
1653
|
compareTo: e.compareTo,
|
|
1418
1654
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1419
1655
|
};
|
|
@@ -1425,16 +1661,16 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1425
1661
|
xAxisKey: t,
|
|
1426
1662
|
series: [{
|
|
1427
1663
|
dataKey: o,
|
|
1428
|
-
label:
|
|
1664
|
+
label: V(void 0, o, void 0)
|
|
1429
1665
|
}],
|
|
1430
|
-
colors:
|
|
1666
|
+
colors: In,
|
|
1431
1667
|
isAnimationActive: !1,
|
|
1432
1668
|
className: "h-[200px] sm:h-[250px] md:h-[300px]"
|
|
1433
1669
|
};
|
|
1434
1670
|
}
|
|
1435
1671
|
if (i.family === "metric") {
|
|
1436
|
-
let i =
|
|
1437
|
-
if (
|
|
1672
|
+
let i = me(e) || t;
|
|
1673
|
+
if (Et(r)) {
|
|
1438
1674
|
let t = r.aggregate;
|
|
1439
1675
|
return {
|
|
1440
1676
|
type: "object-metric",
|
|
@@ -1459,7 +1695,7 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1459
1695
|
}
|
|
1460
1696
|
if (i.family === "table") {
|
|
1461
1697
|
let i = t === "list";
|
|
1462
|
-
if (
|
|
1698
|
+
if (Et(r)) {
|
|
1463
1699
|
let { data: t, ...a } = n;
|
|
1464
1700
|
return {
|
|
1465
1701
|
type: "object-data-table",
|
|
@@ -1476,16 +1712,18 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1476
1712
|
className: "border-0"
|
|
1477
1713
|
};
|
|
1478
1714
|
}
|
|
1715
|
+
let a = Array.isArray(r) ? r : r?.items || [];
|
|
1479
1716
|
return {
|
|
1480
1717
|
type: "data-table",
|
|
1481
1718
|
...n,
|
|
1482
|
-
data:
|
|
1719
|
+
data: a,
|
|
1720
|
+
columns: Array.isArray(n.columns) && n.columns.length > 0 ? n.columns : Ot(a),
|
|
1483
1721
|
searchable: !1,
|
|
1484
1722
|
pagination: !1,
|
|
1485
1723
|
className: "border-0"
|
|
1486
1724
|
};
|
|
1487
1725
|
}
|
|
1488
|
-
return i.family === "pivot" ?
|
|
1726
|
+
return i.family === "pivot" ? It : i.family === "custom" ? {
|
|
1489
1727
|
type: "text",
|
|
1490
1728
|
value: "Custom widget — set `component` to a UIComponent schema.",
|
|
1491
1729
|
variant: "caption",
|
|
@@ -1501,112 +1739,112 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1501
1739
|
...e,
|
|
1502
1740
|
...n
|
|
1503
1741
|
};
|
|
1504
|
-
},
|
|
1505
|
-
let e =
|
|
1506
|
-
return
|
|
1742
|
+
}, d = M.length > 0 ? _(e, M, N) : void 0, m = (() => {
|
|
1743
|
+
let e = u();
|
|
1744
|
+
return d && e && zn.has(e.type) ? {
|
|
1507
1745
|
...e,
|
|
1508
|
-
filter:
|
|
1746
|
+
filter: A(e.filter, d)
|
|
1509
1747
|
} : e;
|
|
1510
|
-
})(), h =
|
|
1748
|
+
})(), h = d && l ? {
|
|
1511
1749
|
...e,
|
|
1512
|
-
filter:
|
|
1513
|
-
} : e, g = e.type === "metric" && !
|
|
1750
|
+
filter: A(e.filter, d)
|
|
1751
|
+
} : e, g = e.type === "metric" && !l, v = me(e), y = he(e), b = e.id || v || `widget-${t}`, x = f && p === e.id, S = f ? {
|
|
1514
1752
|
"data-testid": `dashboard-preview-widget-${e.id}`,
|
|
1515
1753
|
"data-widget-id": e.id,
|
|
1516
1754
|
role: "button",
|
|
1517
1755
|
tabIndex: 0,
|
|
1518
|
-
"aria-selected":
|
|
1519
|
-
"aria-label": `Widget: ${
|
|
1520
|
-
onClick: (t) =>
|
|
1521
|
-
onKeyDown: (n) =>
|
|
1522
|
-
} : {},
|
|
1523
|
-
gridColumn: `span ${
|
|
1524
|
-
gridRow: `span ${
|
|
1525
|
-
} : void 0,
|
|
1526
|
-
className:
|
|
1527
|
-
style:
|
|
1528
|
-
...
|
|
1529
|
-
children: [
|
|
1530
|
-
className:
|
|
1531
|
-
children: /* @__PURE__ */ Q(
|
|
1756
|
+
"aria-selected": x,
|
|
1757
|
+
"aria-label": `Widget: ${v || `Widget ${t + 1}`}`,
|
|
1758
|
+
onClick: (t) => q(t, e.id),
|
|
1759
|
+
onKeyDown: (n) => ye(n, e.id, t)
|
|
1760
|
+
} : {}, w = f ? Z("cursor-pointer rounded-lg transition-all outline-none", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", x ? "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, E = !O && c && !Y ? {
|
|
1761
|
+
gridColumn: `span ${c.w}`,
|
|
1762
|
+
gridRow: `span ${c.h}`
|
|
1763
|
+
} : void 0, D = g ? /* @__PURE__ */ $("div", {
|
|
1764
|
+
className: Z("h-full w-full", f && "relative", w),
|
|
1765
|
+
style: E,
|
|
1766
|
+
...S,
|
|
1767
|
+
children: [l ? /* @__PURE__ */ Q("div", {
|
|
1768
|
+
className: Z("h-full w-full", f && "pointer-events-none"),
|
|
1769
|
+
children: /* @__PURE__ */ Q(Cn, {
|
|
1532
1770
|
widget: h,
|
|
1533
|
-
dataSource:
|
|
1771
|
+
dataSource: r
|
|
1534
1772
|
})
|
|
1535
|
-
}) : /* @__PURE__ */ Q(
|
|
1773
|
+
}) : /* @__PURE__ */ Q(oe, {
|
|
1536
1774
|
schema: m,
|
|
1537
|
-
className:
|
|
1538
|
-
dataSource:
|
|
1539
|
-
}),
|
|
1775
|
+
className: Z("h-full w-full", f && "pointer-events-none"),
|
|
1776
|
+
dataSource: r
|
|
1777
|
+
}), f && /* @__PURE__ */ Q("div", {
|
|
1540
1778
|
className: "absolute inset-0 z-10",
|
|
1541
1779
|
"aria-hidden": "true",
|
|
1542
1780
|
"data-testid": "widget-click-overlay"
|
|
1543
1781
|
})]
|
|
1544
|
-
}) : /* @__PURE__ */ $(
|
|
1545
|
-
className:
|
|
1546
|
-
style:
|
|
1547
|
-
...
|
|
1782
|
+
}) : /* @__PURE__ */ $(J, {
|
|
1783
|
+
className: Z("overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md", "bg-card/50 backdrop-blur-sm", i && "w-full", f && "relative", w),
|
|
1784
|
+
style: E,
|
|
1785
|
+
...S,
|
|
1548
1786
|
children: [
|
|
1549
|
-
|
|
1787
|
+
v && /* @__PURE__ */ $(_e, {
|
|
1550
1788
|
className: "pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6",
|
|
1551
|
-
children: [/* @__PURE__ */ Q(
|
|
1789
|
+
children: [/* @__PURE__ */ Q(ve, {
|
|
1552
1790
|
className: "text-sm sm:text-base font-medium tracking-tight truncate",
|
|
1553
|
-
title:
|
|
1554
|
-
children:
|
|
1555
|
-
}),
|
|
1791
|
+
title: v,
|
|
1792
|
+
children: v
|
|
1793
|
+
}), y && /* @__PURE__ */ Q("p", {
|
|
1556
1794
|
className: "text-xs text-muted-foreground mt-0.5 line-clamp-2",
|
|
1557
|
-
children:
|
|
1795
|
+
children: y
|
|
1558
1796
|
})]
|
|
1559
1797
|
}),
|
|
1560
|
-
/* @__PURE__ */ Q(
|
|
1798
|
+
/* @__PURE__ */ Q(ge, {
|
|
1561
1799
|
className: "p-0",
|
|
1562
1800
|
children: /* @__PURE__ */ Q("div", {
|
|
1563
|
-
className:
|
|
1564
|
-
children:
|
|
1801
|
+
className: Z("h-full w-full", "p-3 sm:p-4 md:p-6", f && "pointer-events-none"),
|
|
1802
|
+
children: l ? /* @__PURE__ */ Q(Cn, {
|
|
1565
1803
|
widget: h,
|
|
1566
|
-
dataSource:
|
|
1567
|
-
}) : /* @__PURE__ */ Q(
|
|
1804
|
+
dataSource: r
|
|
1805
|
+
}) : /* @__PURE__ */ Q(oe, {
|
|
1568
1806
|
schema: m,
|
|
1569
|
-
dataSource:
|
|
1807
|
+
dataSource: r
|
|
1570
1808
|
})
|
|
1571
1809
|
})
|
|
1572
1810
|
}),
|
|
1573
|
-
|
|
1811
|
+
f && /* @__PURE__ */ Q("div", {
|
|
1574
1812
|
className: "absolute inset-0 z-10",
|
|
1575
1813
|
"aria-hidden": "true",
|
|
1576
1814
|
"data-testid": "widget-click-overlay"
|
|
1577
1815
|
})
|
|
1578
1816
|
]
|
|
1579
1817
|
});
|
|
1580
|
-
return
|
|
1818
|
+
return Y && e.id ? /* @__PURE__ */ Q(Pn, {
|
|
1581
1819
|
id: e.id,
|
|
1582
|
-
gridSpan: !
|
|
1583
|
-
w:
|
|
1584
|
-
h:
|
|
1820
|
+
gridSpan: !O && c ? {
|
|
1821
|
+
w: c.w,
|
|
1822
|
+
h: c.h
|
|
1585
1823
|
} : void 0,
|
|
1586
|
-
children:
|
|
1587
|
-
},
|
|
1588
|
-
},
|
|
1824
|
+
children: D
|
|
1825
|
+
}, b) : /* @__PURE__ */ Q(n, { children: D }, b);
|
|
1826
|
+
}, Te = e.title || e.label, Ee = e.header && /* @__PURE__ */ $("div", {
|
|
1589
1827
|
className: "col-span-full mb-4",
|
|
1590
1828
|
children: [
|
|
1591
|
-
!
|
|
1829
|
+
!y && e.header.showTitle !== !1 && Te && /* @__PURE__ */ Q("h2", {
|
|
1592
1830
|
className: "text-lg font-semibold tracking-tight",
|
|
1593
|
-
children:
|
|
1594
|
-
name:
|
|
1595
|
-
label:
|
|
1596
|
-
}) :
|
|
1831
|
+
children: U ? ae({
|
|
1832
|
+
name: U,
|
|
1833
|
+
label: B(Te)
|
|
1834
|
+
}) : B(Te)
|
|
1597
1835
|
}),
|
|
1598
|
-
!
|
|
1836
|
+
!y && e.header.showDescription !== !1 && e.description && /* @__PURE__ */ Q("p", {
|
|
1599
1837
|
className: "text-sm text-muted-foreground mt-1",
|
|
1600
|
-
children:
|
|
1601
|
-
name:
|
|
1602
|
-
description:
|
|
1603
|
-
}) :
|
|
1838
|
+
children: U ? se({
|
|
1839
|
+
name: U,
|
|
1840
|
+
description: B(e.description)
|
|
1841
|
+
}) : B(e.description)
|
|
1604
1842
|
}),
|
|
1605
1843
|
e.header.actions && e.header.actions.length > 0 && /* @__PURE__ */ Q("div", {
|
|
1606
1844
|
className: "flex gap-2 mt-3",
|
|
1607
1845
|
children: e.header.actions.map((e, t) => {
|
|
1608
|
-
let n =
|
|
1609
|
-
return /* @__PURE__ */ $(
|
|
1846
|
+
let n = Fn(e.icon);
|
|
1847
|
+
return /* @__PURE__ */ $(K, {
|
|
1610
1848
|
variant: "outline",
|
|
1611
1849
|
size: "sm",
|
|
1612
1850
|
onClick: async () => {
|
|
@@ -1619,145 +1857,145 @@ var ln = /* @__PURE__ */ new Set([
|
|
|
1619
1857
|
/^https?:\/\//.test(n) || n.startsWith("//") ? window.location.assign(n) : (window.history.pushState({}, "", n), window.dispatchEvent(new PopStateEvent("popstate")));
|
|
1620
1858
|
return;
|
|
1621
1859
|
}
|
|
1622
|
-
let i = await
|
|
1860
|
+
let i = await P(n || r);
|
|
1623
1861
|
i?.success || console.warn("[DashboardRenderer] action failed", i?.error);
|
|
1624
1862
|
},
|
|
1625
|
-
children: [n && /* @__PURE__ */ Q(n, { className: "w-4 h-4 mr-1.5" }),
|
|
1863
|
+
children: [n && /* @__PURE__ */ Q(n, { className: "w-4 h-4 mr-1.5" }), pe(e)]
|
|
1626
1864
|
}, t);
|
|
1627
1865
|
})
|
|
1628
1866
|
})
|
|
1629
1867
|
]
|
|
1630
|
-
}),
|
|
1631
|
-
defs:
|
|
1632
|
-
values:
|
|
1633
|
-
onChange:
|
|
1634
|
-
onReset:
|
|
1635
|
-
dataSource:
|
|
1868
|
+
}), De = M.length > 0 && /* @__PURE__ */ Q(Nn, {
|
|
1869
|
+
defs: M,
|
|
1870
|
+
values: N,
|
|
1871
|
+
onChange: ee,
|
|
1872
|
+
onReset: ne,
|
|
1873
|
+
dataSource: r,
|
|
1636
1874
|
className: "mb-2"
|
|
1637
|
-
}),
|
|
1875
|
+
}), Oe = u !== void 0 && /* @__PURE__ */ $("span", {
|
|
1638
1876
|
className: "text-xs text-muted-foreground",
|
|
1639
|
-
children: [
|
|
1640
|
-
}),
|
|
1641
|
-
className:
|
|
1642
|
-
children: [
|
|
1877
|
+
children: [u.toLocaleString(), " records"]
|
|
1878
|
+
}), ke = d ? JSON.stringify(d) : void 0, Ae = ie(b), je = a && /* @__PURE__ */ $("div", {
|
|
1879
|
+
className: Z("flex items-center justify-end gap-3 mb-2", !O && "col-span-full"),
|
|
1880
|
+
children: [Oe, /* @__PURE__ */ $(K, {
|
|
1643
1881
|
variant: "outline",
|
|
1644
1882
|
size: "sm",
|
|
1645
|
-
onClick:
|
|
1646
|
-
disabled:
|
|
1883
|
+
onClick: G,
|
|
1884
|
+
disabled: E,
|
|
1647
1885
|
"aria-label": "Refresh dashboard",
|
|
1648
|
-
children: [/* @__PURE__ */ Q(
|
|
1886
|
+
children: [/* @__PURE__ */ Q(nt, { className: Z("h-4 w-4 mr-2", E && "animate-spin") }), E ? "Refreshing…" : "Refresh All"]
|
|
1649
1887
|
})]
|
|
1650
|
-
}),
|
|
1651
|
-
if (
|
|
1888
|
+
}), Me = s(() => (e.widgets ?? []).map((e) => e.id).filter((e) => !!e), [e.widgets]), Ne = s(() => (e.widgets ?? []).filter((e) => e.type === "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]), Pe = s(() => (e.widgets ?? []).filter((e) => e.type !== "metric").map((e) => e.id).filter((e) => !!e), [e.widgets]);
|
|
1889
|
+
if (O) {
|
|
1652
1890
|
let n = e.widgets?.filter((e) => e.type === "metric") || [], r = e.widgets?.filter((e) => e.type !== "metric") || [], i = /* @__PURE__ */ $("div", {
|
|
1653
|
-
ref:
|
|
1654
|
-
|
|
1655
|
-
"
|
|
1656
|
-
|
|
1657
|
-
|
|
1891
|
+
ref: x,
|
|
1892
|
+
...Ae,
|
|
1893
|
+
className: Z("flex flex-col gap-4 px-4", t),
|
|
1894
|
+
"data-user-actions": ke,
|
|
1895
|
+
onClick: xe,
|
|
1658
1896
|
children: [
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1897
|
+
Ee,
|
|
1898
|
+
De,
|
|
1899
|
+
je,
|
|
1662
1900
|
n.length > 0 && /* @__PURE__ */ Q("div", {
|
|
1663
1901
|
className: "grid grid-cols-2 gap-3",
|
|
1664
|
-
onClick:
|
|
1665
|
-
children: /* @__PURE__ */ Q(
|
|
1666
|
-
items:
|
|
1667
|
-
strategy:
|
|
1668
|
-
disabled: !
|
|
1669
|
-
children: n.map((e, t) =>
|
|
1902
|
+
onClick: be,
|
|
1903
|
+
children: /* @__PURE__ */ Q(ft, {
|
|
1904
|
+
items: Ne,
|
|
1905
|
+
strategy: mt,
|
|
1906
|
+
disabled: !Y,
|
|
1907
|
+
children: n.map((e, t) => we(e, t))
|
|
1670
1908
|
})
|
|
1671
1909
|
}),
|
|
1672
1910
|
r.length > 0 && /* @__PURE__ */ Q("div", {
|
|
1673
1911
|
className: "flex flex-col gap-4",
|
|
1674
|
-
onClick:
|
|
1675
|
-
children: /* @__PURE__ */ Q(
|
|
1676
|
-
items:
|
|
1677
|
-
strategy:
|
|
1678
|
-
disabled: !
|
|
1679
|
-
children: r.map((e, t) =>
|
|
1912
|
+
onClick: be,
|
|
1913
|
+
children: /* @__PURE__ */ Q(ft, {
|
|
1914
|
+
items: Pe,
|
|
1915
|
+
strategy: gt,
|
|
1916
|
+
disabled: !Y,
|
|
1917
|
+
children: r.map((e, t) => we(e, t, !0))
|
|
1680
1918
|
})
|
|
1681
1919
|
})
|
|
1682
1920
|
]
|
|
1683
1921
|
});
|
|
1684
|
-
return
|
|
1685
|
-
sensors:
|
|
1686
|
-
collisionDetection:
|
|
1687
|
-
onDragEnd:
|
|
1922
|
+
return Y ? /* @__PURE__ */ Q(st, {
|
|
1923
|
+
sensors: Se,
|
|
1924
|
+
collisionDetection: lt,
|
|
1925
|
+
onDragEnd: Ce,
|
|
1688
1926
|
children: i
|
|
1689
1927
|
}) : i;
|
|
1690
1928
|
}
|
|
1691
|
-
let
|
|
1692
|
-
ref:
|
|
1693
|
-
|
|
1929
|
+
let Fe = /* @__PURE__ */ $("div", {
|
|
1930
|
+
ref: x,
|
|
1931
|
+
...Ae,
|
|
1932
|
+
className: Z("grid", !T && "auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", t),
|
|
1694
1933
|
style: {
|
|
1695
|
-
...
|
|
1696
|
-
gridTemplateColumns: `repeat(${
|
|
1934
|
+
...T && {
|
|
1935
|
+
gridTemplateColumns: `repeat(${C}, minmax(0, 1fr))`,
|
|
1697
1936
|
gridAutoRows: "minmax(5rem, auto)"
|
|
1698
1937
|
},
|
|
1699
|
-
gap: `${
|
|
1938
|
+
gap: `${w * .25}rem`
|
|
1700
1939
|
},
|
|
1701
|
-
"data-user-actions":
|
|
1702
|
-
onClick:
|
|
1703
|
-
...m,
|
|
1940
|
+
"data-user-actions": ke,
|
|
1941
|
+
onClick: xe,
|
|
1704
1942
|
children: [
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
/* @__PURE__ */ Q(
|
|
1709
|
-
items:
|
|
1710
|
-
strategy:
|
|
1711
|
-
disabled: !
|
|
1712
|
-
children: e.widgets?.map((e, t) =>
|
|
1943
|
+
Ee,
|
|
1944
|
+
De,
|
|
1945
|
+
je,
|
|
1946
|
+
/* @__PURE__ */ Q(ft, {
|
|
1947
|
+
items: Me,
|
|
1948
|
+
strategy: mt,
|
|
1949
|
+
disabled: !Y,
|
|
1950
|
+
children: e.widgets?.map((e, t) => we(e, t))
|
|
1713
1951
|
})
|
|
1714
1952
|
]
|
|
1715
1953
|
});
|
|
1716
|
-
return
|
|
1717
|
-
sensors:
|
|
1718
|
-
collisionDetection:
|
|
1719
|
-
onDragEnd:
|
|
1720
|
-
children:
|
|
1721
|
-
}) :
|
|
1954
|
+
return Y ? /* @__PURE__ */ Q(st, {
|
|
1955
|
+
sensors: Se,
|
|
1956
|
+
collisionDetection: lt,
|
|
1957
|
+
onDragEnd: Ce,
|
|
1958
|
+
children: Fe
|
|
1959
|
+
}) : Fe;
|
|
1722
1960
|
});
|
|
1723
|
-
|
|
1724
|
-
var
|
|
1725
|
-
let { schema: n } = e, r =
|
|
1726
|
-
return r.length === 0 ? /* @__PURE__ */ Q(
|
|
1961
|
+
Bn.displayName = "DashboardRendererInner";
|
|
1962
|
+
var Vn = r((e, t) => {
|
|
1963
|
+
let { schema: n } = e, r = s(() => te(n), [n.globalFilters, n.dateRange]);
|
|
1964
|
+
return r.length === 0 ? /* @__PURE__ */ Q(Bn, {
|
|
1727
1965
|
ref: t,
|
|
1728
1966
|
...e
|
|
1729
|
-
}) : /* @__PURE__ */ Q(
|
|
1730
|
-
definitions:
|
|
1731
|
-
children: /* @__PURE__ */ Q(
|
|
1967
|
+
}) : /* @__PURE__ */ Q(ae, {
|
|
1968
|
+
definitions: x(r),
|
|
1969
|
+
children: /* @__PURE__ */ Q(Bn, {
|
|
1732
1970
|
ref: t,
|
|
1733
1971
|
...e
|
|
1734
1972
|
})
|
|
1735
1973
|
});
|
|
1736
1974
|
});
|
|
1737
|
-
|
|
1975
|
+
Vn.displayName = "DashboardRenderer";
|
|
1738
1976
|
//#endregion
|
|
1739
1977
|
//#region src/DashboardGridLayout.tsx
|
|
1740
|
-
function
|
|
1741
|
-
let
|
|
1742
|
-
return
|
|
1743
|
-
if (
|
|
1978
|
+
function Hn({ editMode: t }) {
|
|
1979
|
+
let n = R();
|
|
1980
|
+
return e.useEffect(() => {
|
|
1981
|
+
if (t) return n.startDrag({
|
|
1744
1982
|
id: "dashboard-layout",
|
|
1745
1983
|
type: "dashboard-widget",
|
|
1746
1984
|
data: {}
|
|
1747
1985
|
}), () => {
|
|
1748
|
-
|
|
1986
|
+
n.endDrag();
|
|
1749
1987
|
};
|
|
1750
|
-
|
|
1751
|
-
}, [
|
|
1988
|
+
n.endDrag("dashboard");
|
|
1989
|
+
}, [t, n]), null;
|
|
1752
1990
|
}
|
|
1753
|
-
var
|
|
1991
|
+
var Un = [
|
|
1754
1992
|
"hsl(var(--chart-1))",
|
|
1755
1993
|
"hsl(var(--chart-2))",
|
|
1756
1994
|
"hsl(var(--chart-3))",
|
|
1757
1995
|
"hsl(var(--chart-4))",
|
|
1758
1996
|
"hsl(var(--chart-5))"
|
|
1759
1997
|
];
|
|
1760
|
-
function
|
|
1998
|
+
function Wn(e, t) {
|
|
1761
1999
|
if (!e.widgets?.length) return e;
|
|
1762
2000
|
let n = new Map(t.map((e) => [e.i, e])), r = e.widgets.map((e, t) => {
|
|
1763
2001
|
let r = e.id || `widget-${t}`, i = n.get(r);
|
|
@@ -1776,7 +2014,7 @@ function hn(e, t) {
|
|
|
1776
2014
|
widgets: r
|
|
1777
2015
|
};
|
|
1778
2016
|
}
|
|
1779
|
-
function
|
|
2017
|
+
function Gn(e) {
|
|
1780
2018
|
return { lg: e.widgets?.map((e, t) => ({
|
|
1781
2019
|
i: e.id || `widget-${t}`,
|
|
1782
2020
|
x: e.layout?.x ?? t % 4 * 3,
|
|
@@ -1785,45 +2023,46 @@ function gn(e) {
|
|
|
1785
2023
|
h: e.layout?.h ?? 4
|
|
1786
2024
|
})) || [] };
|
|
1787
2025
|
}
|
|
1788
|
-
var
|
|
1789
|
-
let { width:
|
|
1790
|
-
|
|
1791
|
-
}, [
|
|
1792
|
-
|
|
1793
|
-
if (!(!
|
|
1794
|
-
|
|
2026
|
+
var Kn = ({ schema: t, className: n, dataSource: r, onLayoutChange: i, onSchemaChange: a, onRefresh: o }) => {
|
|
2027
|
+
let { width: s, containerRef: c, mounted: l } = Tt(), [u, d] = e.useState(!1), [f, p] = e.useState(!1), m = z(), { language: h } = W(), g = e.useRef(null), _ = e.useCallback(() => {
|
|
2028
|
+
o && (p(!0), o(), setTimeout(() => p(!1), 600));
|
|
2029
|
+
}, [o]);
|
|
2030
|
+
e.useEffect(() => {
|
|
2031
|
+
if (!(!t.refreshInterval || t.refreshInterval <= 0 || !o)) return g.current = setInterval(_, t.refreshInterval * 1e3), () => {
|
|
2032
|
+
g.current && clearInterval(g.current);
|
|
1795
2033
|
};
|
|
1796
2034
|
}, [
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
2035
|
+
t.refreshInterval,
|
|
2036
|
+
o,
|
|
2037
|
+
_
|
|
1800
2038
|
]);
|
|
1801
|
-
let [
|
|
2039
|
+
let [v, y] = e.useState(() => Gn(t)), b = e.useMemo(() => JSON.stringify(t.widgets?.map((e, t) => ({
|
|
1802
2040
|
i: e.id || `widget-${t}`,
|
|
1803
2041
|
x: e.layout?.x,
|
|
1804
2042
|
y: e.layout?.y,
|
|
1805
2043
|
w: e.layout?.w,
|
|
1806
2044
|
h: e.layout?.h
|
|
1807
|
-
})) ?? []), [
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
}, [
|
|
1811
|
-
let
|
|
1812
|
-
|
|
1813
|
-
}, [
|
|
1814
|
-
|
|
2045
|
+
})) ?? []), [t.widgets]);
|
|
2046
|
+
e.useEffect(() => {
|
|
2047
|
+
y(Gn(t));
|
|
2048
|
+
}, [b]);
|
|
2049
|
+
let x = e.useCallback((e, t) => {
|
|
2050
|
+
y(t), i?.(e);
|
|
2051
|
+
}, [i]), S = e.useCallback(() => {
|
|
2052
|
+
a ? a(Wn(t, v.lg)) : globalThis.process?.env?.NODE_ENV !== "production" && console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."), d(!1);
|
|
1815
2053
|
}, [
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
]),
|
|
1820
|
-
|
|
1821
|
-
}, [
|
|
2054
|
+
a,
|
|
2055
|
+
t,
|
|
2056
|
+
v
|
|
2057
|
+
]), C = e.useCallback(() => {
|
|
2058
|
+
y(Gn(t));
|
|
2059
|
+
}, [t]), w = e.useCallback((e) => {
|
|
1822
2060
|
if (e.component) return e.component;
|
|
1823
|
-
|
|
2061
|
+
if (Lt(e)) return It;
|
|
2062
|
+
let t = e.type, n = e.options || {}, r = Ft(t);
|
|
1824
2063
|
if (r.family === "series" && r.chartType) {
|
|
1825
2064
|
let t = e.data || n.data, i = n.xField || "name", a = n.yField || "value";
|
|
1826
|
-
if (
|
|
2065
|
+
if (Et(t)) {
|
|
1827
2066
|
let e = t.aggregate, n = e ? {
|
|
1828
2067
|
field: e.field,
|
|
1829
2068
|
function: e.function,
|
|
@@ -1836,7 +2075,7 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1836
2075
|
aggregate: n,
|
|
1837
2076
|
xAxisKey: i,
|
|
1838
2077
|
series: [{ dataKey: o }],
|
|
1839
|
-
colors:
|
|
2078
|
+
colors: Un,
|
|
1840
2079
|
isAnimationActive: !1,
|
|
1841
2080
|
className: "h-full"
|
|
1842
2081
|
};
|
|
@@ -1848,14 +2087,14 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1848
2087
|
data: o,
|
|
1849
2088
|
xAxisKey: i,
|
|
1850
2089
|
series: [{ dataKey: a }],
|
|
1851
|
-
colors:
|
|
2090
|
+
colors: Un,
|
|
1852
2091
|
isAnimationActive: !1,
|
|
1853
2092
|
className: "h-full"
|
|
1854
2093
|
};
|
|
1855
2094
|
}
|
|
1856
2095
|
if (r.family === "metric") {
|
|
1857
2096
|
let r = e.data || n.data, i = e.title || t;
|
|
1858
|
-
if (
|
|
2097
|
+
if (Et(r)) {
|
|
1859
2098
|
let t = r.aggregate;
|
|
1860
2099
|
return {
|
|
1861
2100
|
type: "object-metric",
|
|
@@ -1880,7 +2119,7 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1880
2119
|
}
|
|
1881
2120
|
if (r.family === "table") {
|
|
1882
2121
|
let t = e.data || n.data;
|
|
1883
|
-
if (
|
|
2122
|
+
if (Et(t)) {
|
|
1884
2123
|
let { data: e, ...r } = n;
|
|
1885
2124
|
return {
|
|
1886
2125
|
type: "data-table",
|
|
@@ -1893,10 +2132,12 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1893
2132
|
className: "border-0"
|
|
1894
2133
|
};
|
|
1895
2134
|
}
|
|
2135
|
+
let r = Array.isArray(t) ? t : t?.items || [];
|
|
1896
2136
|
return {
|
|
1897
2137
|
type: "data-table",
|
|
1898
2138
|
...n,
|
|
1899
|
-
data:
|
|
2139
|
+
data: r,
|
|
2140
|
+
columns: Array.isArray(n.columns) && n.columns.length > 0 ? n.columns : Ot(r),
|
|
1900
2141
|
searchable: !1,
|
|
1901
2142
|
pagination: !1,
|
|
1902
2143
|
className: "border-0"
|
|
@@ -1904,7 +2145,7 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1904
2145
|
}
|
|
1905
2146
|
if (r.family === "pivot") {
|
|
1906
2147
|
let t = e.data || n.data;
|
|
1907
|
-
if (
|
|
2148
|
+
if (Et(t)) {
|
|
1908
2149
|
let { data: e, ...r } = n;
|
|
1909
2150
|
return {
|
|
1910
2151
|
type: "pivot",
|
|
@@ -1932,56 +2173,56 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1932
2173
|
};
|
|
1933
2174
|
}, []);
|
|
1934
2175
|
return /* @__PURE__ */ $("div", {
|
|
1935
|
-
ref:
|
|
1936
|
-
className:
|
|
2176
|
+
ref: c,
|
|
2177
|
+
className: Z("w-full", n),
|
|
1937
2178
|
"data-testid": "grid-layout",
|
|
1938
2179
|
children: [
|
|
1939
|
-
|
|
2180
|
+
m && /* @__PURE__ */ Q(Hn, { editMode: u }),
|
|
1940
2181
|
/* @__PURE__ */ $("div", {
|
|
1941
2182
|
className: "mb-4 flex items-center justify-between",
|
|
1942
2183
|
children: [/* @__PURE__ */ Q("h2", {
|
|
1943
2184
|
className: "text-2xl font-bold",
|
|
1944
|
-
children:
|
|
2185
|
+
children: t.title || H(t.label, h) || "Dashboard"
|
|
1945
2186
|
}), /* @__PURE__ */ Q("div", {
|
|
1946
2187
|
className: "flex gap-2",
|
|
1947
|
-
children:
|
|
1948
|
-
/* @__PURE__ */ $(
|
|
1949
|
-
onClick:
|
|
2188
|
+
children: u ? /* @__PURE__ */ $(Ct, { children: [
|
|
2189
|
+
/* @__PURE__ */ $(K, {
|
|
2190
|
+
onClick: S,
|
|
1950
2191
|
size: "sm",
|
|
1951
2192
|
variant: "default",
|
|
1952
|
-
children: [/* @__PURE__ */ Q(
|
|
2193
|
+
children: [/* @__PURE__ */ Q(it, { className: "h-4 w-4 mr-2" }), "Save Layout"]
|
|
1953
2194
|
}),
|
|
1954
|
-
/* @__PURE__ */ $(
|
|
1955
|
-
onClick:
|
|
2195
|
+
/* @__PURE__ */ $(K, {
|
|
2196
|
+
onClick: C,
|
|
1956
2197
|
size: "sm",
|
|
1957
2198
|
variant: "outline",
|
|
1958
|
-
children: [/* @__PURE__ */ Q(
|
|
2199
|
+
children: [/* @__PURE__ */ Q(ot, { className: "h-4 w-4 mr-2" }), "Reset"]
|
|
1959
2200
|
}),
|
|
1960
|
-
/* @__PURE__ */ Q(
|
|
1961
|
-
onClick: () =>
|
|
2201
|
+
/* @__PURE__ */ Q(K, {
|
|
2202
|
+
onClick: () => d(!1),
|
|
1962
2203
|
size: "sm",
|
|
1963
2204
|
variant: "ghost",
|
|
1964
2205
|
children: "Cancel"
|
|
1965
2206
|
})
|
|
1966
|
-
] }) : /* @__PURE__ */ $(
|
|
1967
|
-
onClick:
|
|
2207
|
+
] }) : /* @__PURE__ */ $(Ct, { children: [o && /* @__PURE__ */ $(K, {
|
|
2208
|
+
onClick: _,
|
|
1968
2209
|
size: "sm",
|
|
1969
2210
|
variant: "outline",
|
|
1970
|
-
disabled:
|
|
2211
|
+
disabled: f,
|
|
1971
2212
|
"aria-label": "Refresh dashboard",
|
|
1972
|
-
children: [/* @__PURE__ */ Q(
|
|
1973
|
-
}), /* @__PURE__ */ $(
|
|
1974
|
-
onClick: () =>
|
|
2213
|
+
children: [/* @__PURE__ */ Q(nt, { className: Z("h-4 w-4 mr-2", f && "animate-spin") }), f ? "Refreshing…" : "Refresh All"]
|
|
2214
|
+
}), /* @__PURE__ */ $(K, {
|
|
2215
|
+
onClick: () => d(!0),
|
|
1975
2216
|
size: "sm",
|
|
1976
2217
|
variant: "outline",
|
|
1977
|
-
children: [/* @__PURE__ */ Q(
|
|
2218
|
+
children: [/* @__PURE__ */ Q(Qe, { className: "h-4 w-4 mr-2" }), "Edit Layout"]
|
|
1978
2219
|
})] })
|
|
1979
2220
|
})]
|
|
1980
2221
|
}),
|
|
1981
|
-
|
|
2222
|
+
l && /* @__PURE__ */ Q(wt, {
|
|
1982
2223
|
className: "layout",
|
|
1983
|
-
width:
|
|
1984
|
-
layouts:
|
|
2224
|
+
width: s,
|
|
2225
|
+
layouts: v,
|
|
1985
2226
|
breakpoints: {
|
|
1986
2227
|
lg: 1200,
|
|
1987
2228
|
md: 996,
|
|
@@ -1998,41 +2239,44 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
1998
2239
|
},
|
|
1999
2240
|
rowHeight: 60,
|
|
2000
2241
|
dragConfig: {
|
|
2001
|
-
enabled:
|
|
2242
|
+
enabled: u,
|
|
2002
2243
|
handle: ".drag-handle"
|
|
2003
2244
|
},
|
|
2004
|
-
resizeConfig: { enabled:
|
|
2005
|
-
onLayoutChange:
|
|
2006
|
-
children:
|
|
2007
|
-
let n = e.id || `widget-${t}`,
|
|
2245
|
+
resizeConfig: { enabled: u },
|
|
2246
|
+
onLayoutChange: x,
|
|
2247
|
+
children: t.widgets?.map((e, t) => {
|
|
2248
|
+
let n = e.id || `widget-${t}`, i = w(e), a = !!e.dataset, o = e.type === "metric" && !a, s = H(e.title, h);
|
|
2008
2249
|
return /* @__PURE__ */ Q("div", {
|
|
2009
2250
|
className: "h-full",
|
|
2010
|
-
children:
|
|
2251
|
+
children: o ? /* @__PURE__ */ $("div", {
|
|
2011
2252
|
className: "h-full w-full relative",
|
|
2012
|
-
children: [
|
|
2253
|
+
children: [u && /* @__PURE__ */ Q("div", {
|
|
2013
2254
|
className: "drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border",
|
|
2014
|
-
children: /* @__PURE__ */ Q(
|
|
2015
|
-
}), /* @__PURE__ */ Q(
|
|
2016
|
-
schema:
|
|
2255
|
+
children: /* @__PURE__ */ Q($e, { className: "h-4 w-4" })
|
|
2256
|
+
}), /* @__PURE__ */ Q(oe, {
|
|
2257
|
+
schema: i,
|
|
2017
2258
|
className: "h-full w-full"
|
|
2018
2259
|
})]
|
|
2019
|
-
}) : /* @__PURE__ */ $(
|
|
2020
|
-
className:
|
|
2021
|
-
children: [
|
|
2260
|
+
}) : /* @__PURE__ */ $(J, {
|
|
2261
|
+
className: Z("h-full overflow-hidden border-border/50 shadow-sm transition-all", "bg-card/50 backdrop-blur-sm", u && "ring-2 ring-primary/20"),
|
|
2262
|
+
children: [s && /* @__PURE__ */ $(_e, {
|
|
2022
2263
|
className: "pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between",
|
|
2023
|
-
children: [/* @__PURE__ */ Q(
|
|
2264
|
+
children: [/* @__PURE__ */ Q(ve, {
|
|
2024
2265
|
className: "text-base font-medium tracking-tight truncate",
|
|
2025
|
-
title:
|
|
2026
|
-
children:
|
|
2027
|
-
}),
|
|
2266
|
+
title: s,
|
|
2267
|
+
children: s
|
|
2268
|
+
}), u && /* @__PURE__ */ Q("div", {
|
|
2028
2269
|
className: "drag-handle cursor-move p-1 hover:bg-muted/40 rounded",
|
|
2029
|
-
children: /* @__PURE__ */ Q(
|
|
2270
|
+
children: /* @__PURE__ */ Q($e, { className: "h-4 w-4" })
|
|
2030
2271
|
})]
|
|
2031
|
-
}), /* @__PURE__ */ Q(
|
|
2272
|
+
}), /* @__PURE__ */ Q(ge, {
|
|
2032
2273
|
className: "p-0 h-full",
|
|
2033
2274
|
children: /* @__PURE__ */ Q("div", {
|
|
2034
|
-
className:
|
|
2035
|
-
children: /* @__PURE__ */ Q(
|
|
2275
|
+
className: Z("h-full w-full overflow-auto p-4"),
|
|
2276
|
+
children: a ? /* @__PURE__ */ Q(Cn, {
|
|
2277
|
+
widget: e,
|
|
2278
|
+
dataSource: r
|
|
2279
|
+
}) : /* @__PURE__ */ Q(oe, { schema: i })
|
|
2036
2280
|
})
|
|
2037
2281
|
})]
|
|
2038
2282
|
})
|
|
@@ -2041,7 +2285,7 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
2041
2285
|
})
|
|
2042
2286
|
]
|
|
2043
2287
|
});
|
|
2044
|
-
},
|
|
2288
|
+
}, qn = B({
|
|
2045
2289
|
"dashboard.trend.vsLastQuarter": "vs last quarter",
|
|
2046
2290
|
"dashboard.trend.vsLastMonth": "vs last month",
|
|
2047
2291
|
"dashboard.trend.vsLastWeek": "vs last week",
|
|
@@ -2049,7 +2293,7 @@ var _n = ({ schema: e, className: t, onLayoutChange: n, onSchemaChange: r, onRef
|
|
|
2049
2293
|
"dashboard.trend.vsYesterday": "vs yesterday",
|
|
2050
2294
|
"dashboard.trend.vsPreviousPeriod": "vs previous period"
|
|
2051
2295
|
}, "dashboard.trend.vsLastQuarter");
|
|
2052
|
-
function
|
|
2296
|
+
function Jn(e) {
|
|
2053
2297
|
switch (e.trim().toLowerCase().replace(/\s+/g, " ")) {
|
|
2054
2298
|
case "vs last quarter":
|
|
2055
2299
|
case "vs previous quarter": return "dashboard.trend.vsLastQuarter";
|
|
@@ -2065,202 +2309,179 @@ function yn(e) {
|
|
|
2065
2309
|
default: return;
|
|
2066
2310
|
}
|
|
2067
2311
|
}
|
|
2068
|
-
function
|
|
2312
|
+
function Yn(e, t, n, r) {
|
|
2069
2313
|
if (e == null) return "";
|
|
2070
2314
|
if (typeof e == "string") {
|
|
2071
|
-
let
|
|
2072
|
-
return !isFinite(
|
|
2315
|
+
let i = Number(e);
|
|
2316
|
+
return !isFinite(i) || e.trim() === "" ? e : Yn(i, t, n, r);
|
|
2073
2317
|
}
|
|
2074
2318
|
if (!isFinite(e)) return String(e);
|
|
2075
|
-
let
|
|
2319
|
+
let i = {
|
|
2076
2320
|
$: "USD",
|
|
2077
2321
|
"¥": "JPY",
|
|
2078
2322
|
"€": "EUR",
|
|
2079
2323
|
"£": "GBP"
|
|
2080
|
-
},
|
|
2081
|
-
if (/a/i.test(
|
|
2324
|
+
}, a = (t || "").trim(), o = !!n || a.length > 0 && i[a[0]] !== void 0, s = a.endsWith("%"), c = a.match(/0\.(0+)/), l = c ? c[1].length : 0;
|
|
2325
|
+
if (/a/i.test(a)) {
|
|
2082
2326
|
let t = {
|
|
2327
|
+
locale: r,
|
|
2083
2328
|
notation: "compact",
|
|
2084
|
-
maximumFractionDigits:
|
|
2329
|
+
maximumFractionDigits: l || 1
|
|
2085
2330
|
};
|
|
2086
|
-
|
|
2331
|
+
o && (t.currency = n || i[a[0]] || "USD");
|
|
2087
2332
|
try {
|
|
2088
|
-
return
|
|
2333
|
+
return V(e, t);
|
|
2089
2334
|
} catch {}
|
|
2090
2335
|
}
|
|
2091
|
-
if (
|
|
2092
|
-
let t = n ||
|
|
2336
|
+
if (o) {
|
|
2337
|
+
let t = n || i[a[0]] || "USD";
|
|
2093
2338
|
try {
|
|
2094
|
-
return
|
|
2095
|
-
|
|
2339
|
+
return V(e, {
|
|
2340
|
+
locale: r,
|
|
2096
2341
|
currency: t,
|
|
2097
|
-
minimumFractionDigits:
|
|
2098
|
-
maximumFractionDigits:
|
|
2099
|
-
})
|
|
2342
|
+
minimumFractionDigits: l,
|
|
2343
|
+
maximumFractionDigits: l
|
|
2344
|
+
});
|
|
2100
2345
|
} catch {
|
|
2101
|
-
return `${t} ${e.toFixed(
|
|
2346
|
+
return `${t} ${e.toFixed(l)}`;
|
|
2102
2347
|
}
|
|
2103
2348
|
}
|
|
2104
|
-
return
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
}
|
|
2109
|
-
function xn(e) {
|
|
2110
|
-
if (e != null) return typeof e == "string" ? e : e.defaultValue || e.key;
|
|
2349
|
+
return s ? `${(e > 1 ? e : e * 100).toFixed(l)}%` : V(e, {
|
|
2350
|
+
locale: r,
|
|
2351
|
+
minimumFractionDigits: l,
|
|
2352
|
+
maximumFractionDigits: l
|
|
2353
|
+
});
|
|
2111
2354
|
}
|
|
2112
|
-
var
|
|
2113
|
-
default:
|
|
2114
|
-
|
|
2115
|
-
teal: "bg-teal-500/10 text-teal-600 dark:text-teal-400",
|
|
2116
|
-
orange: "bg-orange-500/10 text-orange-600 dark:text-orange-400",
|
|
2117
|
-
purple: "bg-purple-500/10 text-purple-600 dark:text-purple-400",
|
|
2118
|
-
success: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",
|
|
2119
|
-
warning: "bg-amber-500/10 text-amber-600 dark:text-amber-400",
|
|
2120
|
-
danger: "bg-rose-500/10 text-rose-600 dark:text-rose-400"
|
|
2121
|
-
}, Cn = {
|
|
2122
|
-
default: "text-foreground",
|
|
2123
|
-
blue: "text-blue-600 dark:text-blue-400",
|
|
2124
|
-
teal: "text-teal-600 dark:text-teal-400",
|
|
2125
|
-
orange: "text-orange-600 dark:text-orange-400",
|
|
2126
|
-
purple: "text-purple-600 dark:text-purple-400",
|
|
2127
|
-
success: "text-emerald-600 dark:text-emerald-400",
|
|
2128
|
-
warning: "text-amber-600 dark:text-amber-400",
|
|
2129
|
-
danger: "text-rose-600 dark:text-rose-400"
|
|
2130
|
-
}, wn = ({ label: e, value: t, trend: n, icon: r, className: i, description: a, loading: o, error: s, colorVariant: c = "default", format: l, currency: u, prefix: d, suffix: f, onClick: p, variant: m = "card", ...h }) => {
|
|
2131
|
-
let g = Sn[c] || Sn.default, { t: _ } = vn(), v = X(() => {
|
|
2132
|
-
let e = xn(a) || xn(n?.label);
|
|
2355
|
+
var Xn = ({ label: e, value: t, trend: n, icon: r, className: i, description: a, loading: o, error: c, colorVariant: l = "default", format: u, currency: d, prefix: f, suffix: p, onClick: m, variant: h = "card", schema: g, bind: _, events: v, props: y, ariaLabel: b, ariaDescribedBy: x, dataSource: S, ...C }) => {
|
|
2356
|
+
let w = Rt[l] || Rt.default, { t: T } = qn(), E = pe(), { language: D } = W(), O = s(() => H(e, D) || void 0, [e, D]), k = s(() => {
|
|
2357
|
+
let e = H(a, D) || H(n?.label, D) || void 0;
|
|
2133
2358
|
if (!e) return e;
|
|
2134
|
-
let t =
|
|
2135
|
-
return t ?
|
|
2359
|
+
let t = Jn(e);
|
|
2360
|
+
return t ? T(t) : e;
|
|
2136
2361
|
}, [
|
|
2137
2362
|
a,
|
|
2138
2363
|
n?.label,
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2364
|
+
T,
|
|
2365
|
+
D
|
|
2366
|
+
]), A = s(() => {
|
|
2367
|
+
let e = typeof t == "number" || typeof t == "string" && t.trim() !== "" && isFinite(Number(t)) ? Yn(t, u, d, E) : t ?? "", n = String(e);
|
|
2368
|
+
return `${f && n.startsWith(f) ? "" : f ?? ""}${n}${p && n.endsWith(p) ? "" : p ?? ""}`;
|
|
2143
2369
|
}, [
|
|
2144
2370
|
t,
|
|
2145
|
-
l,
|
|
2146
2371
|
u,
|
|
2147
2372
|
d,
|
|
2148
|
-
f
|
|
2149
|
-
|
|
2373
|
+
f,
|
|
2374
|
+
p,
|
|
2375
|
+
E
|
|
2376
|
+
]), j = s(() => {
|
|
2150
2377
|
if (typeof r == "string") {
|
|
2151
|
-
let e =
|
|
2378
|
+
let e = He(r);
|
|
2152
2379
|
return e ? /* @__PURE__ */ Q(e, { className: "h-4 w-4" }) : null;
|
|
2153
2380
|
}
|
|
2154
2381
|
return r;
|
|
2155
2382
|
}, [r]);
|
|
2156
|
-
if (
|
|
2157
|
-
let
|
|
2383
|
+
if (h === "bare") {
|
|
2384
|
+
let e = zt[l] || zt.default;
|
|
2158
2385
|
return /* @__PURE__ */ Q("div", {
|
|
2159
|
-
className:
|
|
2160
|
-
onClick:
|
|
2161
|
-
role:
|
|
2162
|
-
tabIndex:
|
|
2163
|
-
onKeyDown:
|
|
2164
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
2386
|
+
className: Z("flex flex-col gap-1 min-w-0", m && "cursor-pointer", i),
|
|
2387
|
+
onClick: m,
|
|
2388
|
+
role: m ? "button" : void 0,
|
|
2389
|
+
tabIndex: m ? 0 : void 0,
|
|
2390
|
+
onKeyDown: m ? (e) => {
|
|
2391
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), m());
|
|
2165
2392
|
} : void 0,
|
|
2166
2393
|
children: o ? /* @__PURE__ */ $("div", {
|
|
2167
2394
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
2168
2395
|
"data-testid": "metric-loading",
|
|
2169
|
-
children: [/* @__PURE__ */ Q(
|
|
2396
|
+
children: [/* @__PURE__ */ Q(et, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
|
|
2170
2397
|
className: "text-sm",
|
|
2171
2398
|
children: "Loading…"
|
|
2172
2399
|
})]
|
|
2173
|
-
}) :
|
|
2400
|
+
}) : c ? /* @__PURE__ */ $("div", {
|
|
2174
2401
|
className: "flex items-center gap-2",
|
|
2175
2402
|
"data-testid": "metric-error",
|
|
2176
2403
|
role: "alert",
|
|
2177
|
-
children: [/* @__PURE__ */ Q(
|
|
2404
|
+
children: [/* @__PURE__ */ Q(We, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
2178
2405
|
className: "text-xs text-destructive truncate",
|
|
2179
|
-
children:
|
|
2406
|
+
children: c
|
|
2180
2407
|
})]
|
|
2181
|
-
}) : /* @__PURE__ */ $(
|
|
2182
|
-
className:
|
|
2183
|
-
children:
|
|
2408
|
+
}) : /* @__PURE__ */ $(Ct, { children: [/* @__PURE__ */ Q("div", {
|
|
2409
|
+
className: Z("text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate", e),
|
|
2410
|
+
children: A
|
|
2184
2411
|
}), /* @__PURE__ */ Q("div", {
|
|
2185
2412
|
className: "text-xs font-medium text-muted-foreground truncate",
|
|
2186
|
-
children:
|
|
2413
|
+
children: O
|
|
2187
2414
|
})] })
|
|
2188
2415
|
});
|
|
2189
2416
|
}
|
|
2190
|
-
return /* @__PURE__ */ $(
|
|
2191
|
-
className:
|
|
2192
|
-
onClick:
|
|
2193
|
-
role:
|
|
2194
|
-
tabIndex:
|
|
2195
|
-
onKeyDown:
|
|
2196
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
2417
|
+
return /* @__PURE__ */ $(J, {
|
|
2418
|
+
className: Z("h-full overflow-hidden", m && "cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none", i),
|
|
2419
|
+
onClick: m,
|
|
2420
|
+
role: m ? "button" : void 0,
|
|
2421
|
+
tabIndex: m ? 0 : void 0,
|
|
2422
|
+
onKeyDown: m ? (e) => {
|
|
2423
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), m());
|
|
2197
2424
|
} : void 0,
|
|
2198
|
-
...
|
|
2199
|
-
children: [/* @__PURE__ */ $(
|
|
2425
|
+
...C,
|
|
2426
|
+
children: [/* @__PURE__ */ $(_e, {
|
|
2200
2427
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
2201
|
-
children: [/* @__PURE__ */ Q(
|
|
2428
|
+
children: [/* @__PURE__ */ Q(ve, {
|
|
2202
2429
|
className: "text-sm font-medium truncate",
|
|
2203
|
-
children:
|
|
2204
|
-
}),
|
|
2205
|
-
className:
|
|
2206
|
-
children:
|
|
2430
|
+
children: O
|
|
2431
|
+
}), j && /* @__PURE__ */ Q("div", {
|
|
2432
|
+
className: Z("flex h-8 w-8 items-center justify-center rounded-md shrink-0", w),
|
|
2433
|
+
children: j
|
|
2207
2434
|
})]
|
|
2208
|
-
}), /* @__PURE__ */ Q(
|
|
2435
|
+
}), /* @__PURE__ */ Q(ge, { children: o ? /* @__PURE__ */ $("div", {
|
|
2209
2436
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
2210
2437
|
"data-testid": "metric-loading",
|
|
2211
|
-
children: [/* @__PURE__ */ Q(
|
|
2438
|
+
children: [/* @__PURE__ */ Q(et, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
|
|
2212
2439
|
className: "text-sm",
|
|
2213
2440
|
children: "Loading…"
|
|
2214
2441
|
})]
|
|
2215
|
-
}) :
|
|
2442
|
+
}) : c ? /* @__PURE__ */ $("div", {
|
|
2216
2443
|
className: "flex items-center gap-2",
|
|
2217
2444
|
"data-testid": "metric-error",
|
|
2218
2445
|
role: "alert",
|
|
2219
|
-
children: [/* @__PURE__ */ Q(
|
|
2446
|
+
children: [/* @__PURE__ */ Q(We, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
2220
2447
|
className: "text-xs text-destructive truncate",
|
|
2221
|
-
children:
|
|
2448
|
+
children: c
|
|
2222
2449
|
})]
|
|
2223
|
-
}) : /* @__PURE__ */ $(
|
|
2450
|
+
}) : /* @__PURE__ */ $(Ct, { children: [/* @__PURE__ */ Q("div", {
|
|
2224
2451
|
className: "text-2xl font-bold tabular-nums tracking-tight truncate",
|
|
2225
|
-
children:
|
|
2452
|
+
children: A
|
|
2226
2453
|
}), (n || a) && /* @__PURE__ */ $("div", {
|
|
2227
2454
|
className: "text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0",
|
|
2228
2455
|
children: [n && /* @__PURE__ */ $("span", {
|
|
2229
|
-
className:
|
|
2456
|
+
className: Z("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"),
|
|
2230
2457
|
children: [
|
|
2231
|
-
n.direction === "up" && /* @__PURE__ */ Q(
|
|
2232
|
-
n.direction === "down" && /* @__PURE__ */ Q(
|
|
2233
|
-
n.direction === "neutral" && /* @__PURE__ */ Q(
|
|
2458
|
+
n.direction === "up" && /* @__PURE__ */ Q(qe, { className: "h-3 w-3 mr-1" }),
|
|
2459
|
+
n.direction === "down" && /* @__PURE__ */ Q(Ke, { className: "h-3 w-3 mr-1" }),
|
|
2460
|
+
n.direction === "neutral" && /* @__PURE__ */ Q(tt, { className: "h-3 w-3 mr-1" }),
|
|
2234
2461
|
n.value,
|
|
2235
2462
|
"%"
|
|
2236
2463
|
]
|
|
2237
2464
|
}), /* @__PURE__ */ Q("span", {
|
|
2238
2465
|
className: "truncate min-w-0",
|
|
2239
|
-
children:
|
|
2466
|
+
children: k
|
|
2240
2467
|
})]
|
|
2241
2468
|
})] }) })]
|
|
2242
2469
|
});
|
|
2243
|
-
}
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
var En = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, ...l }) => {
|
|
2250
|
-
let u = n ? De(n) : null;
|
|
2251
|
-
return /* @__PURE__ */ $(oe, {
|
|
2252
|
-
className: K("h-full", o),
|
|
2253
|
-
...l,
|
|
2254
|
-
children: [/* @__PURE__ */ $(se, {
|
|
2470
|
+
}, Zn = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a, className: o, loading: s, error: c, schema: l, bind: u, events: d, props: f, ariaLabel: p, ariaDescribedBy: m, dataSource: h, ...g }) => {
|
|
2471
|
+
let _ = n ? He(n) : null, { language: v } = W();
|
|
2472
|
+
return /* @__PURE__ */ $(J, {
|
|
2473
|
+
className: Z("h-full", o),
|
|
2474
|
+
...g,
|
|
2475
|
+
children: [/* @__PURE__ */ $(_e, {
|
|
2255
2476
|
className: "flex flex-row items-center justify-between space-y-0 pb-2",
|
|
2256
|
-
children: [/* @__PURE__ */ Q(
|
|
2477
|
+
children: [/* @__PURE__ */ Q(ve, {
|
|
2257
2478
|
className: "text-sm font-medium",
|
|
2258
|
-
children:
|
|
2259
|
-
}),
|
|
2260
|
-
}), /* @__PURE__ */ Q(
|
|
2479
|
+
children: H(e, v)
|
|
2480
|
+
}), _ && /* @__PURE__ */ Q(_, { className: "h-4 w-4 text-muted-foreground" })]
|
|
2481
|
+
}), /* @__PURE__ */ Q(ge, { children: s ? /* @__PURE__ */ $("div", {
|
|
2261
2482
|
className: "flex items-center gap-2 text-muted-foreground",
|
|
2262
2483
|
"data-testid": "metric-card-loading",
|
|
2263
|
-
children: [/* @__PURE__ */ Q(
|
|
2484
|
+
children: [/* @__PURE__ */ Q(et, { className: "h-4 w-4 animate-spin" }), /* @__PURE__ */ Q("span", {
|
|
2264
2485
|
className: "text-sm",
|
|
2265
2486
|
children: "Loading…"
|
|
2266
2487
|
})]
|
|
@@ -2268,43 +2489,43 @@ var En = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2268
2489
|
className: "flex items-center gap-2",
|
|
2269
2490
|
"data-testid": "metric-card-error",
|
|
2270
2491
|
role: "alert",
|
|
2271
|
-
children: [/* @__PURE__ */ Q(
|
|
2492
|
+
children: [/* @__PURE__ */ Q(We, { className: "h-4 w-4 text-destructive shrink-0" }), /* @__PURE__ */ Q("span", {
|
|
2272
2493
|
className: "text-xs text-destructive truncate",
|
|
2273
2494
|
children: c
|
|
2274
2495
|
})]
|
|
2275
|
-
}) : /* @__PURE__ */ $(
|
|
2496
|
+
}) : /* @__PURE__ */ $(Ct, { children: [/* @__PURE__ */ Q("div", {
|
|
2276
2497
|
className: "text-2xl font-bold",
|
|
2277
2498
|
children: t
|
|
2278
2499
|
}), (r || i || a) && /* @__PURE__ */ $("p", {
|
|
2279
2500
|
className: "text-xs text-muted-foreground flex items-center mt-1",
|
|
2280
2501
|
children: [r && i && /* @__PURE__ */ $("span", {
|
|
2281
|
-
className:
|
|
2502
|
+
className: Z("flex items-center mr-2", r === "up" && "text-green-500", r === "down" && "text-red-500", r === "neutral" && "text-yellow-500"),
|
|
2282
2503
|
children: [
|
|
2283
|
-
r === "up" && /* @__PURE__ */ Q(
|
|
2284
|
-
r === "down" && /* @__PURE__ */ Q(
|
|
2285
|
-
r === "neutral" && /* @__PURE__ */ Q(
|
|
2504
|
+
r === "up" && /* @__PURE__ */ Q(qe, { className: "h-3 w-3 mr-1" }),
|
|
2505
|
+
r === "down" && /* @__PURE__ */ Q(Ke, { className: "h-3 w-3 mr-1" }),
|
|
2506
|
+
r === "neutral" && /* @__PURE__ */ Q(tt, { className: "h-3 w-3 mr-1" }),
|
|
2286
2507
|
i
|
|
2287
2508
|
]
|
|
2288
|
-
}),
|
|
2509
|
+
}), H(a, v)]
|
|
2289
2510
|
})] }) })]
|
|
2290
2511
|
});
|
|
2291
|
-
},
|
|
2292
|
-
let
|
|
2293
|
-
|
|
2512
|
+
}, Qn = ({ objectName: e, aggregate: t, filter: n, label: r, fallbackValue: c, trend: u, icon: d, className: f, description: p, dataSource: m, colorVariant: h, format: g, currency: _, prefix: v, suffix: b, invert: x, drillDown: S, title: C, compareTo: w, t: T, variant: E }) => {
|
|
2513
|
+
let D = a(se), k = m || D?.dataSource, [A, j] = l(!1), [M, N] = l(null), [ee, te] = l(null), [ie, F] = l(!1), [ae, I] = l(null), [L, ce] = l(null);
|
|
2514
|
+
o(() => {
|
|
2294
2515
|
let t = !0;
|
|
2295
2516
|
if (!(!k || !e || typeof k.getObjectSchema != "function")) return k.getObjectSchema(e).then((e) => {
|
|
2296
|
-
t &&
|
|
2517
|
+
t && ce(e);
|
|
2297
2518
|
}).catch(() => {}), () => {
|
|
2298
2519
|
t = !1;
|
|
2299
2520
|
};
|
|
2300
2521
|
}, [k, e]);
|
|
2301
|
-
let R =
|
|
2522
|
+
let R = s(() => {
|
|
2302
2523
|
let e = t?.field;
|
|
2303
|
-
if (!e || !
|
|
2304
|
-
let n =
|
|
2524
|
+
if (!e || !L?.fields) return null;
|
|
2525
|
+
let n = L.fields;
|
|
2305
2526
|
return Array.isArray(n) ? n.find((t) => t?.name === e) || null : n[e] || null;
|
|
2306
|
-
}, [
|
|
2307
|
-
if (
|
|
2527
|
+
}, [L, t?.field]), le = s(() => {
|
|
2528
|
+
if (g) return g;
|
|
2308
2529
|
if (R) {
|
|
2309
2530
|
if (R.type === "currency") {
|
|
2310
2531
|
let e = R.scale ?? 0;
|
|
@@ -2313,14 +2534,14 @@ var En = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2313
2534
|
if (R.type === "percent") return "0,0%";
|
|
2314
2535
|
if (R.type === "number" || R.type === "integer") return "0,0";
|
|
2315
2536
|
}
|
|
2316
|
-
}, [
|
|
2317
|
-
if (
|
|
2318
|
-
if (R?.type === "currency") return
|
|
2537
|
+
}, [g, R]), { currency: z } = me(), de = s(() => {
|
|
2538
|
+
if (_) return _;
|
|
2539
|
+
if (R?.type === "currency") return U(R, z);
|
|
2319
2540
|
}, [
|
|
2320
|
-
|
|
2541
|
+
_,
|
|
2321
2542
|
R,
|
|
2322
2543
|
z
|
|
2323
|
-
]),
|
|
2544
|
+
]), fe = s(() => t ? JSON.stringify(t) : "", [t]), B = ue(), V = s(() => re(n, B), [n, B]), H = s(() => V ? JSON.stringify(V) : "", [V]), pe = s(() => w ? JSON.stringify(w) : "", [w]), W = i(async (n, r) => {
|
|
2324
2545
|
if (t && typeof n.aggregate == "function") {
|
|
2325
2546
|
let i = await n.aggregate(e, {
|
|
2326
2547
|
field: t.field,
|
|
@@ -2341,91 +2562,91 @@ var En = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2341
2562
|
return (Array.isArray(t) ? t : t?.data || t?.records || []).length;
|
|
2342
2563
|
}
|
|
2343
2564
|
return null;
|
|
2344
|
-
}, [e,
|
|
2565
|
+
}, [e, fe]), he = i(async (t, r) => {
|
|
2345
2566
|
if (!(!t || !e)) {
|
|
2346
|
-
r.current && (
|
|
2567
|
+
r.current && (F(!0), I(null));
|
|
2347
2568
|
try {
|
|
2348
|
-
let e =
|
|
2569
|
+
let e = w ? P(n, w) : null, [i, a] = await Promise.all([W(t, V), e ? W(t, e) : Promise.resolve(null)]);
|
|
2349
2570
|
if (i === null) return;
|
|
2350
|
-
r.current && (
|
|
2571
|
+
r.current && (N(i), te(typeof a == "number" && Number.isFinite(a) ? a : null));
|
|
2351
2572
|
} catch (e) {
|
|
2352
|
-
console.error("[ObjectMetricWidget] Fetch error:", e), r.current &&
|
|
2573
|
+
console.error("[ObjectMetricWidget] Fetch error:", e), r.current && I(e instanceof Error ? e.message : "Failed to load metric");
|
|
2353
2574
|
} finally {
|
|
2354
|
-
r.current &&
|
|
2575
|
+
r.current && F(!1);
|
|
2355
2576
|
}
|
|
2356
2577
|
}
|
|
2357
2578
|
}, [
|
|
2358
2579
|
e,
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2580
|
+
fe,
|
|
2581
|
+
H,
|
|
2582
|
+
pe,
|
|
2583
|
+
W
|
|
2363
2584
|
]);
|
|
2364
|
-
|
|
2585
|
+
o(() => {
|
|
2365
2586
|
let t = { current: !0 };
|
|
2366
|
-
return k && e ?
|
|
2587
|
+
return k && e ? he(k, t) : (N(null), I(null)), () => {
|
|
2367
2588
|
t.current = !1;
|
|
2368
2589
|
};
|
|
2369
2590
|
}, [
|
|
2370
2591
|
k,
|
|
2371
2592
|
e,
|
|
2372
|
-
|
|
2593
|
+
he
|
|
2373
2594
|
]);
|
|
2374
|
-
let
|
|
2375
|
-
|
|
2376
|
-
let
|
|
2377
|
-
if (!
|
|
2378
|
-
let e =
|
|
2595
|
+
let G = M === null ? k ? "—" : c ?? "—" : M;
|
|
2596
|
+
x && typeof G == "number" && isFinite(G) && G >= 0 && G <= 1 && (G = 1 - G);
|
|
2597
|
+
let K = s(() => {
|
|
2598
|
+
if (!w || typeof M != "number" || !Number.isFinite(M) || ee === null) return;
|
|
2599
|
+
let e = kt(M, ee);
|
|
2379
2600
|
if (!e) return;
|
|
2380
|
-
let t =
|
|
2601
|
+
let t = y(w, n), r = `dashboard.trend.${t}`, i = {
|
|
2381
2602
|
vsPreviousPeriod: "vs previous period",
|
|
2382
2603
|
vsLastWeek: "vs last week",
|
|
2383
2604
|
vsLastMonth: "vs last month",
|
|
2384
2605
|
vsLastQuarter: "vs last quarter",
|
|
2385
2606
|
vsLastYear: "vs last year",
|
|
2386
2607
|
vsYesterday: "vs yesterday"
|
|
2387
|
-
}, a =
|
|
2608
|
+
}, a = T ? T(r, i[t] || t) : i[t] || t;
|
|
2388
2609
|
return {
|
|
2389
2610
|
value: e.value,
|
|
2390
2611
|
direction: e.direction,
|
|
2391
2612
|
label: a
|
|
2392
2613
|
};
|
|
2393
2614
|
}, [
|
|
2394
|
-
|
|
2615
|
+
w,
|
|
2395
2616
|
M,
|
|
2396
|
-
|
|
2617
|
+
ee,
|
|
2397
2618
|
n,
|
|
2398
|
-
|
|
2399
|
-
]) ??
|
|
2400
|
-
let e = typeof r == "string" ? r : r?.defaultValue || "", t = typeof
|
|
2401
|
-
return S
|
|
2619
|
+
T
|
|
2620
|
+
]) ?? u, q = O(S) && !!e && !!k, J = s(() => {
|
|
2621
|
+
let e = typeof r == "string" ? r : r?.defaultValue || "", t = typeof C == "string" ? C : C?.defaultValue || "";
|
|
2622
|
+
return ne(S, {}, t || e || "Details");
|
|
2402
2623
|
}, [
|
|
2403
|
-
|
|
2624
|
+
S,
|
|
2404
2625
|
r,
|
|
2405
|
-
|
|
2406
|
-
]),
|
|
2407
|
-
if (!
|
|
2408
|
-
let t =
|
|
2626
|
+
C
|
|
2627
|
+
]), ge = s(() => {
|
|
2628
|
+
if (!q) return null;
|
|
2629
|
+
let t = S?.target ?? "drawer", n = S?.report, r = n && typeof n == "object" && (Array.isArray(n.columns) || "objectName" in n), i = r ? null : /* @__PURE__ */ Q(tn, {
|
|
2409
2630
|
objectName: e,
|
|
2410
|
-
filter:
|
|
2631
|
+
filter: V,
|
|
2411
2632
|
onNavigate: () => j(!1)
|
|
2412
2633
|
}), a;
|
|
2413
2634
|
if (r) {
|
|
2414
|
-
let e = n.filter, t = e ?
|
|
2635
|
+
let e = n.filter, t = e ? V ? { $and: [e, V] } : e : V, r = {
|
|
2415
2636
|
type: "spec-report",
|
|
2416
2637
|
...n,
|
|
2417
2638
|
filter: t
|
|
2418
2639
|
};
|
|
2419
2640
|
a = /* @__PURE__ */ Q("div", {
|
|
2420
2641
|
className: "h-full overflow-auto",
|
|
2421
|
-
children: /* @__PURE__ */ Q(
|
|
2642
|
+
children: /* @__PURE__ */ Q(oe, { schema: r })
|
|
2422
2643
|
});
|
|
2423
2644
|
} else a = /* @__PURE__ */ Q("div", {
|
|
2424
2645
|
className: "h-full overflow-auto",
|
|
2425
|
-
children: /* @__PURE__ */ Q(
|
|
2646
|
+
children: /* @__PURE__ */ Q(oe, { schema: {
|
|
2426
2647
|
type: "object-data-table",
|
|
2427
2648
|
objectName: e,
|
|
2428
|
-
filter:
|
|
2649
|
+
filter: V,
|
|
2429
2650
|
pageSize: 25,
|
|
2430
2651
|
drillDown: {
|
|
2431
2652
|
enabled: !0,
|
|
@@ -2434,25 +2655,25 @@ var En = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2434
2655
|
}
|
|
2435
2656
|
} })
|
|
2436
2657
|
});
|
|
2437
|
-
return t === "dialog" ? /* @__PURE__ */ Q(
|
|
2658
|
+
return t === "dialog" ? /* @__PURE__ */ Q(Ce, {
|
|
2438
2659
|
open: !0,
|
|
2439
2660
|
onOpenChange: (e) => !e && j(!1),
|
|
2440
|
-
children: /* @__PURE__ */ $(
|
|
2661
|
+
children: /* @__PURE__ */ $(we, {
|
|
2441
2662
|
className: "max-w-5xl",
|
|
2442
|
-
children: [/* @__PURE__ */ $(
|
|
2663
|
+
children: [/* @__PURE__ */ $(Te, {
|
|
2443
2664
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2444
|
-
children: [/* @__PURE__ */ Q(
|
|
2665
|
+
children: [/* @__PURE__ */ Q(Ee, { children: J }), i]
|
|
2445
2666
|
}), a]
|
|
2446
2667
|
})
|
|
2447
|
-
}) : /* @__PURE__ */ Q(
|
|
2668
|
+
}) : /* @__PURE__ */ Q(Re, {
|
|
2448
2669
|
open: !0,
|
|
2449
2670
|
onOpenChange: (e) => !e && j(!1),
|
|
2450
|
-
children: /* @__PURE__ */ $(
|
|
2671
|
+
children: /* @__PURE__ */ $(ze, {
|
|
2451
2672
|
side: "right",
|
|
2452
2673
|
className: "w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col",
|
|
2453
|
-
children: [/* @__PURE__ */ $(
|
|
2674
|
+
children: [/* @__PURE__ */ $(Be, {
|
|
2454
2675
|
className: "flex-row items-center justify-between gap-4 pr-8",
|
|
2455
|
-
children: [/* @__PURE__ */ Q(
|
|
2676
|
+
children: [/* @__PURE__ */ Q(Ve, { children: J }), i]
|
|
2456
2677
|
}), /* @__PURE__ */ Q("div", {
|
|
2457
2678
|
className: "flex-1 overflow-hidden mt-2",
|
|
2458
2679
|
children: a
|
|
@@ -2460,39 +2681,39 @@ var En = ({ title: e, value: t, icon: n, trend: r, trendValue: i, description: a
|
|
|
2460
2681
|
})
|
|
2461
2682
|
});
|
|
2462
2683
|
}, [
|
|
2463
|
-
|
|
2464
|
-
|
|
2684
|
+
q,
|
|
2685
|
+
S,
|
|
2465
2686
|
e,
|
|
2466
|
-
|
|
2467
|
-
|
|
2687
|
+
V,
|
|
2688
|
+
J
|
|
2468
2689
|
]);
|
|
2469
|
-
return /* @__PURE__ */ $(
|
|
2690
|
+
return /* @__PURE__ */ $(Ct, { children: [/* @__PURE__ */ Q(Xn, {
|
|
2470
2691
|
label: r,
|
|
2471
|
-
value:
|
|
2472
|
-
trend:
|
|
2473
|
-
icon:
|
|
2474
|
-
className:
|
|
2475
|
-
description:
|
|
2476
|
-
loading:
|
|
2477
|
-
error:
|
|
2478
|
-
colorVariant:
|
|
2479
|
-
format:
|
|
2480
|
-
currency:
|
|
2481
|
-
prefix:
|
|
2482
|
-
suffix:
|
|
2483
|
-
variant:
|
|
2484
|
-
onClick:
|
|
2485
|
-
}), A &&
|
|
2692
|
+
value: G,
|
|
2693
|
+
trend: K,
|
|
2694
|
+
icon: d,
|
|
2695
|
+
className: f,
|
|
2696
|
+
description: p,
|
|
2697
|
+
loading: ie,
|
|
2698
|
+
error: ae,
|
|
2699
|
+
colorVariant: h,
|
|
2700
|
+
format: le,
|
|
2701
|
+
currency: de,
|
|
2702
|
+
prefix: v,
|
|
2703
|
+
suffix: b,
|
|
2704
|
+
variant: E,
|
|
2705
|
+
onClick: q ? () => j(!0) : void 0
|
|
2706
|
+
}), A && ge] });
|
|
2486
2707
|
};
|
|
2487
2708
|
//#endregion
|
|
2488
2709
|
//#region src/PivotTable.tsx
|
|
2489
|
-
function
|
|
2490
|
-
return
|
|
2710
|
+
function $n() {
|
|
2711
|
+
return G()("dashboard.total", "Total");
|
|
2491
2712
|
}
|
|
2492
|
-
function
|
|
2493
|
-
return
|
|
2713
|
+
function er() {
|
|
2714
|
+
return G()("dashboard.noDataAvailable", "No data available");
|
|
2494
2715
|
}
|
|
2495
|
-
function
|
|
2716
|
+
function tr(e, t) {
|
|
2496
2717
|
if (!t) return String(e);
|
|
2497
2718
|
let n = "", r = !1, i, a = t, o = a.match(/^([^0-9.,#]*)/);
|
|
2498
2719
|
if (o && o[1]) {
|
|
@@ -2509,18 +2730,18 @@ function An(e, t) {
|
|
|
2509
2730
|
}
|
|
2510
2731
|
return n + l + c;
|
|
2511
2732
|
}
|
|
2512
|
-
var
|
|
2513
|
-
function
|
|
2514
|
-
return e === "" ?
|
|
2733
|
+
var nr = "—";
|
|
2734
|
+
function rr(e, t) {
|
|
2735
|
+
return e === "" ? nr : t?.[e] ?? e;
|
|
2515
2736
|
}
|
|
2516
|
-
var
|
|
2737
|
+
var ir = /* @__PURE__ */ new Set([
|
|
2517
2738
|
"sum",
|
|
2518
2739
|
"count",
|
|
2519
2740
|
"avg",
|
|
2520
2741
|
"min",
|
|
2521
2742
|
"max"
|
|
2522
2743
|
]);
|
|
2523
|
-
function
|
|
2744
|
+
function ar(e, t) {
|
|
2524
2745
|
if (e.length === 0) return 0;
|
|
2525
2746
|
switch (t) {
|
|
2526
2747
|
case "sum": return e.reduce((e, t) => e + t, 0);
|
|
@@ -2531,8 +2752,8 @@ function Pn(e, t) {
|
|
|
2531
2752
|
default: return NaN;
|
|
2532
2753
|
}
|
|
2533
2754
|
}
|
|
2534
|
-
var
|
|
2535
|
-
let { title: o, rowField:
|
|
2755
|
+
var or = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabel: i, onDrillDown: a }) => {
|
|
2756
|
+
let { title: o, rowField: c, columnField: l, valueField: u, aggregation: d = "sum", data: f = [], showRowTotals: p = !1, showColumnTotals: m = !1, format: h, columnColors: g, drillDown: _ } = e, v = $n(), y = er(), b = O(_) && typeof a == "function", x = (e) => {
|
|
2536
2757
|
b && a({
|
|
2537
2758
|
...e,
|
|
2538
2759
|
rowLabel: e.rowKey === void 0 ? e.rowLabel : n?.[e.rowKey] ?? e.rowKey,
|
|
@@ -2540,21 +2761,21 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2540
2761
|
});
|
|
2541
2762
|
}, S = (e) => (t) => {
|
|
2542
2763
|
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
|
|
2543
|
-
}, 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(
|
|
2764
|
+
}, C = b ? "cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]" : "", w = Array.isArray(f) ? f : [], { rowKeys: T, colKeys: E, matrix: D, rowTotals: k, colTotals: A, grandTotal: j } = s(() => {
|
|
2544
2765
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = {};
|
|
2545
2766
|
for (let r of w) {
|
|
2546
|
-
let i = String(r[
|
|
2767
|
+
let i = String(r[c] ?? ""), a = String(r[l] ?? ""), o = Number(r[u]) || 0;
|
|
2547
2768
|
e.set(i, !0), t.set(a, !0), n[i] || (n[i] = {}), n[i][a] || (n[i][a] = []), n[i][a].push(o);
|
|
2548
2769
|
}
|
|
2549
|
-
let r = Array.from(e.keys()), i = Array.from(t.keys()), a = {}, o = {},
|
|
2770
|
+
let r = Array.from(e.keys()), i = Array.from(t.keys()), a = {}, o = {}, s = {};
|
|
2550
2771
|
for (let e of r) {
|
|
2551
2772
|
a[e] = {};
|
|
2552
2773
|
let t = [];
|
|
2553
2774
|
for (let r of i) {
|
|
2554
|
-
let i = n[e]?.[r] ?? [], o =
|
|
2555
|
-
a[e][r] = o, t.push(...i), !
|
|
2775
|
+
let i = n[e]?.[r] ?? [], o = ar(i, d);
|
|
2776
|
+
a[e][r] = o, t.push(...i), !s[r] && s[r];
|
|
2556
2777
|
}
|
|
2557
|
-
o[e] =
|
|
2778
|
+
o[e] = ar(t, d);
|
|
2558
2779
|
}
|
|
2559
2780
|
for (let e of i) {
|
|
2560
2781
|
let t = [];
|
|
@@ -2562,31 +2783,31 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2562
2783
|
let r = n[i]?.[e] ?? [];
|
|
2563
2784
|
t.push(...r);
|
|
2564
2785
|
}
|
|
2565
|
-
|
|
2786
|
+
s[e] = ar(t, d);
|
|
2566
2787
|
}
|
|
2567
2788
|
let f = [];
|
|
2568
|
-
for (let e of w) f.push(Number(e[
|
|
2789
|
+
for (let e of w) f.push(Number(e[u]) || 0);
|
|
2569
2790
|
return {
|
|
2570
2791
|
rowKeys: r,
|
|
2571
2792
|
colKeys: i,
|
|
2572
2793
|
matrix: a,
|
|
2573
2794
|
rowTotals: o,
|
|
2574
|
-
colTotals:
|
|
2575
|
-
grandTotal:
|
|
2795
|
+
colTotals: s,
|
|
2796
|
+
grandTotal: ar(f, d)
|
|
2576
2797
|
};
|
|
2577
2798
|
}, [
|
|
2578
2799
|
w,
|
|
2579
|
-
s,
|
|
2580
2800
|
c,
|
|
2581
2801
|
l,
|
|
2582
|
-
u
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2802
|
+
u,
|
|
2803
|
+
d
|
|
2804
|
+
]), M = (e) => tr(e, h);
|
|
2805
|
+
return ir.has(d) ? w.length === 0 ? /* @__PURE__ */ $("div", {
|
|
2806
|
+
className: Z("overflow-auto", t),
|
|
2586
2807
|
children: [o && /* @__PURE__ */ Q("h3", {
|
|
2587
2808
|
className: "text-sm font-semibold mb-2",
|
|
2588
2809
|
children: o
|
|
2589
|
-
}), /* @__PURE__ */ Q(
|
|
2810
|
+
}), /* @__PURE__ */ Q(Se, {
|
|
2590
2811
|
"data-testid": "pivot-empty-state",
|
|
2591
2812
|
className: "py-8 gap-2 [&>h3]:hidden",
|
|
2592
2813
|
icon: /* @__PURE__ */ $("svg", {
|
|
@@ -2630,7 +2851,7 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2630
2851
|
description: y
|
|
2631
2852
|
})]
|
|
2632
2853
|
}) : /* @__PURE__ */ $("div", {
|
|
2633
|
-
className:
|
|
2854
|
+
className: Z("overflow-auto", t),
|
|
2634
2855
|
children: [o && /* @__PURE__ */ Q("h3", {
|
|
2635
2856
|
className: "text-sm font-semibold mb-2",
|
|
2636
2857
|
children: o
|
|
@@ -2643,7 +2864,7 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2643
2864
|
children: [
|
|
2644
2865
|
/* @__PURE__ */ Q("th", {
|
|
2645
2866
|
className: "text-left p-2 font-medium text-muted-foreground whitespace-nowrap",
|
|
2646
|
-
children: i ||
|
|
2867
|
+
children: i || c
|
|
2647
2868
|
}),
|
|
2648
2869
|
E.map((e) => {
|
|
2649
2870
|
let t = () => x({
|
|
@@ -2651,17 +2872,17 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2651
2872
|
colKey: e
|
|
2652
2873
|
});
|
|
2653
2874
|
return /* @__PURE__ */ Q("th", {
|
|
2654
|
-
className:
|
|
2655
|
-
title: e === "" ? `${
|
|
2875
|
+
className: Z("text-right p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", g?.[e] ?? "text-muted-foreground", C),
|
|
2876
|
+
title: e === "" ? `${l}: (empty)` : `${l}: ${e}`,
|
|
2656
2877
|
role: b ? "button" : void 0,
|
|
2657
2878
|
tabIndex: b ? 0 : void 0,
|
|
2658
2879
|
onClick: b ? t : void 0,
|
|
2659
2880
|
onKeyDown: b ? S(t) : void 0,
|
|
2660
|
-
"aria-label": b ? `Drill into ${
|
|
2661
|
-
children:
|
|
2881
|
+
"aria-label": b ? `Drill into ${l}: ${e || "(empty)"}` : void 0,
|
|
2882
|
+
children: rr(e, r)
|
|
2662
2883
|
}, e);
|
|
2663
2884
|
}),
|
|
2664
|
-
|
|
2885
|
+
p && /* @__PURE__ */ Q("th", {
|
|
2665
2886
|
className: "text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap",
|
|
2666
2887
|
children: v
|
|
2667
2888
|
})
|
|
@@ -2671,7 +2892,7 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2671
2892
|
className: "border-b border-border/50 hover:bg-muted/30",
|
|
2672
2893
|
children: [
|
|
2673
2894
|
/* @__PURE__ */ Q("td", {
|
|
2674
|
-
className:
|
|
2895
|
+
className: Z("p-2 font-medium whitespace-nowrap", e === "" && "italic text-muted-foreground/70", C),
|
|
2675
2896
|
role: b ? "button" : void 0,
|
|
2676
2897
|
tabIndex: b ? 0 : void 0,
|
|
2677
2898
|
onClick: b ? () => x({
|
|
@@ -2682,8 +2903,8 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2682
2903
|
scope: "row",
|
|
2683
2904
|
rowKey: e
|
|
2684
2905
|
})) : void 0,
|
|
2685
|
-
"aria-label": b ? `Drill into ${
|
|
2686
|
-
children:
|
|
2906
|
+
"aria-label": b ? `Drill into ${c}: ${e || "(empty)"}` : void 0,
|
|
2907
|
+
children: rr(e, n)
|
|
2687
2908
|
}),
|
|
2688
2909
|
E.map((t) => {
|
|
2689
2910
|
let n = D[e]?.[t] ?? 0, r = () => x({
|
|
@@ -2693,34 +2914,34 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2693
2914
|
value: n
|
|
2694
2915
|
});
|
|
2695
2916
|
return /* @__PURE__ */ Q("td", {
|
|
2696
|
-
className:
|
|
2917
|
+
className: Z("text-right p-2 tabular-nums", g?.[t], C),
|
|
2697
2918
|
role: b ? "button" : void 0,
|
|
2698
2919
|
tabIndex: b ? 0 : void 0,
|
|
2699
2920
|
onClick: b ? r : void 0,
|
|
2700
2921
|
onKeyDown: b ? S(r) : void 0,
|
|
2701
|
-
"aria-label": b ? `Drill into ${
|
|
2702
|
-
children:
|
|
2922
|
+
"aria-label": b ? `Drill into ${c}=${e || "(empty)"}, ${l}=${t || "(empty)"}` : void 0,
|
|
2923
|
+
children: M(n)
|
|
2703
2924
|
}, t);
|
|
2704
2925
|
}),
|
|
2705
|
-
|
|
2706
|
-
className:
|
|
2926
|
+
p && /* @__PURE__ */ Q("td", {
|
|
2927
|
+
className: Z("text-right p-2 font-semibold tabular-nums bg-muted/20", C),
|
|
2707
2928
|
role: b ? "button" : void 0,
|
|
2708
2929
|
tabIndex: b ? 0 : void 0,
|
|
2709
2930
|
onClick: b ? () => x({
|
|
2710
2931
|
scope: "row",
|
|
2711
2932
|
rowKey: e,
|
|
2712
|
-
value:
|
|
2933
|
+
value: k[e] ?? 0
|
|
2713
2934
|
}) : void 0,
|
|
2714
2935
|
onKeyDown: b ? S(() => x({
|
|
2715
2936
|
scope: "row",
|
|
2716
2937
|
rowKey: e,
|
|
2717
|
-
value:
|
|
2938
|
+
value: k[e] ?? 0
|
|
2718
2939
|
})) : void 0,
|
|
2719
|
-
children:
|
|
2940
|
+
children: M(k[e] ?? 0)
|
|
2720
2941
|
})
|
|
2721
2942
|
]
|
|
2722
2943
|
}, e)) }),
|
|
2723
|
-
|
|
2944
|
+
m && /* @__PURE__ */ Q("tfoot", { children: /* @__PURE__ */ $("tr", {
|
|
2724
2945
|
className: "border-t-2 border-border font-semibold bg-muted/40",
|
|
2725
2946
|
children: [
|
|
2726
2947
|
/* @__PURE__ */ Q("td", {
|
|
@@ -2728,41 +2949,41 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2728
2949
|
children: v
|
|
2729
2950
|
}),
|
|
2730
2951
|
E.map((e) => /* @__PURE__ */ Q("td", {
|
|
2731
|
-
className:
|
|
2952
|
+
className: Z("text-right p-2 tabular-nums", C),
|
|
2732
2953
|
role: b ? "button" : void 0,
|
|
2733
2954
|
tabIndex: b ? 0 : void 0,
|
|
2734
2955
|
onClick: b ? () => x({
|
|
2735
2956
|
scope: "column",
|
|
2736
2957
|
colKey: e,
|
|
2737
|
-
value:
|
|
2958
|
+
value: A[e] ?? 0
|
|
2738
2959
|
}) : void 0,
|
|
2739
2960
|
onKeyDown: b ? S(() => x({
|
|
2740
2961
|
scope: "column",
|
|
2741
2962
|
colKey: e,
|
|
2742
|
-
value:
|
|
2963
|
+
value: A[e] ?? 0
|
|
2743
2964
|
})) : void 0,
|
|
2744
|
-
children:
|
|
2965
|
+
children: M(A[e] ?? 0)
|
|
2745
2966
|
}, e)),
|
|
2746
|
-
|
|
2747
|
-
className:
|
|
2967
|
+
p && /* @__PURE__ */ Q("td", {
|
|
2968
|
+
className: Z("text-right p-2 tabular-nums font-bold", C),
|
|
2748
2969
|
role: b ? "button" : void 0,
|
|
2749
2970
|
tabIndex: b ? 0 : void 0,
|
|
2750
2971
|
onClick: b ? () => x({
|
|
2751
2972
|
scope: "total",
|
|
2752
|
-
value:
|
|
2973
|
+
value: j
|
|
2753
2974
|
}) : void 0,
|
|
2754
2975
|
onKeyDown: b ? S(() => x({
|
|
2755
2976
|
scope: "total",
|
|
2756
|
-
value:
|
|
2977
|
+
value: j
|
|
2757
2978
|
})) : void 0,
|
|
2758
|
-
children: j
|
|
2979
|
+
children: M(j)
|
|
2759
2980
|
})
|
|
2760
2981
|
]
|
|
2761
2982
|
}) })
|
|
2762
2983
|
]
|
|
2763
2984
|
})]
|
|
2764
2985
|
}) : /* @__PURE__ */ $("div", {
|
|
2765
|
-
className:
|
|
2986
|
+
className: Z("overflow-auto", t),
|
|
2766
2987
|
"data-testid": "pivot-unsupported-aggregation",
|
|
2767
2988
|
children: [o && /* @__PURE__ */ Q("h3", {
|
|
2768
2989
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2774,20 +2995,20 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2774
2995
|
className: "text-xs",
|
|
2775
2996
|
children: [
|
|
2776
2997
|
"Unsupported aggregation “",
|
|
2777
|
-
String(
|
|
2998
|
+
String(d),
|
|
2778
2999
|
"” — this pivot table renders",
|
|
2779
3000
|
" ",
|
|
2780
|
-
[...
|
|
3001
|
+
[...ir].join(", "),
|
|
2781
3002
|
"."
|
|
2782
3003
|
]
|
|
2783
3004
|
})
|
|
2784
3005
|
})]
|
|
2785
3006
|
});
|
|
2786
|
-
},
|
|
2787
|
-
let r =
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
}, [
|
|
3007
|
+
}, sr = ({ schema: e, dataSource: t, className: n }) => {
|
|
3008
|
+
let r = a(se), i = t || r?.dataSource, s = L(e.bind), [u, d] = l([]), [f, p] = l(!1), [m, h] = l(null), [g, _] = l({}), [v, y] = l({}), [x, S] = l(null), { fieldLabel: C, fieldOptionLabel: T } = he(), E = c(C), D = c(T);
|
|
3009
|
+
o(() => {
|
|
3010
|
+
E.current = C, D.current = T;
|
|
3011
|
+
}, [C, T]), o(() => {
|
|
2791
3012
|
if (!i || !e.objectName) return;
|
|
2792
3013
|
let t = i.getObjectSchema;
|
|
2793
3014
|
if (typeof t != "function") return;
|
|
@@ -2797,39 +3018,39 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2797
3018
|
let r = e.objectName, i = {}, a = {};
|
|
2798
3019
|
for (let [e, n] of Object.entries(t.fields)) {
|
|
2799
3020
|
let t = n?.label ? String(n.label) : e;
|
|
2800
|
-
a[e] =
|
|
3021
|
+
a[e] = E.current(r, e, t);
|
|
2801
3022
|
let o = n?.options;
|
|
2802
3023
|
if (Array.isArray(o) && o.length > 0) {
|
|
2803
3024
|
let t = {};
|
|
2804
3025
|
for (let n of o) if (n && n.value !== void 0 && n.label !== void 0) {
|
|
2805
3026
|
let i = String(n.value), a = String(n.label);
|
|
2806
|
-
t[i] =
|
|
3027
|
+
t[i] = D.current(r, e, i, a);
|
|
2807
3028
|
}
|
|
2808
3029
|
Object.keys(t).length > 0 && (i[e] = t);
|
|
2809
3030
|
}
|
|
2810
3031
|
}
|
|
2811
|
-
|
|
3032
|
+
_(i), y(a);
|
|
2812
3033
|
}).catch(() => {}), () => {
|
|
2813
3034
|
n = !1;
|
|
2814
3035
|
};
|
|
2815
3036
|
}, [i, e.objectName]);
|
|
2816
|
-
let
|
|
2817
|
-
|
|
3037
|
+
let k = ue();
|
|
3038
|
+
o(() => {
|
|
2818
3039
|
let t = !0;
|
|
2819
|
-
return e.objectName && !
|
|
3040
|
+
return e.objectName && !s && (!e.data || e.data.length === 0) && (async () => {
|
|
2820
3041
|
if (!(!i || !e.objectName)) {
|
|
2821
|
-
t && (
|
|
3042
|
+
t && (p(!0), h(null));
|
|
2822
3043
|
try {
|
|
2823
3044
|
let n;
|
|
2824
3045
|
if (typeof i.find == "function") {
|
|
2825
|
-
let t = await i.find(e.objectName, { $filter:
|
|
2826
|
-
n =
|
|
3046
|
+
let t = await i.find(e.objectName, { $filter: re(e.filter, k) });
|
|
3047
|
+
n = w(t);
|
|
2827
3048
|
} else return;
|
|
2828
|
-
t &&
|
|
3049
|
+
t && d(n);
|
|
2829
3050
|
} catch (e) {
|
|
2830
|
-
console.error("[ObjectPivotTable] Fetch error:", e), t &&
|
|
3051
|
+
console.error("[ObjectPivotTable] Fetch error:", e), t && h(e instanceof Error ? e.message : "Failed to load data");
|
|
2831
3052
|
} finally {
|
|
2832
|
-
t &&
|
|
3053
|
+
t && p(!1);
|
|
2833
3054
|
}
|
|
2834
3055
|
}
|
|
2835
3056
|
})(), () => {
|
|
@@ -2838,14 +3059,14 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2838
3059
|
}, [
|
|
2839
3060
|
e.objectName,
|
|
2840
3061
|
i,
|
|
2841
|
-
|
|
3062
|
+
s,
|
|
2842
3063
|
e.data,
|
|
2843
3064
|
e.filter,
|
|
2844
|
-
|
|
3065
|
+
k
|
|
2845
3066
|
]);
|
|
2846
|
-
let A =
|
|
2847
|
-
if (
|
|
2848
|
-
className:
|
|
3067
|
+
let A = s || e.data || u, j = Array.isArray(A) ? A : [];
|
|
3068
|
+
if (f && j.length === 0) return /* @__PURE__ */ $("div", {
|
|
3069
|
+
className: Z("overflow-auto", n),
|
|
2849
3070
|
"data-testid": "pivot-loading",
|
|
2850
3071
|
children: [e.title && /* @__PURE__ */ Q("h3", {
|
|
2851
3072
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2855,10 +3076,10 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2855
3076
|
children: [/* @__PURE__ */ $("div", {
|
|
2856
3077
|
className: "flex gap-2",
|
|
2857
3078
|
children: [
|
|
2858
|
-
/* @__PURE__ */ Q(
|
|
2859
|
-
/* @__PURE__ */ Q(
|
|
2860
|
-
/* @__PURE__ */ Q(
|
|
2861
|
-
/* @__PURE__ */ Q(
|
|
3079
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-24" }),
|
|
3080
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-20" }),
|
|
3081
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-20" }),
|
|
3082
|
+
/* @__PURE__ */ Q(X, { className: "h-6 w-20" })
|
|
2862
3083
|
]
|
|
2863
3084
|
}), [
|
|
2864
3085
|
1,
|
|
@@ -2867,16 +3088,16 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2867
3088
|
].map((e) => /* @__PURE__ */ $("div", {
|
|
2868
3089
|
className: "flex gap-2",
|
|
2869
3090
|
children: [
|
|
2870
|
-
/* @__PURE__ */ Q(
|
|
2871
|
-
/* @__PURE__ */ Q(
|
|
2872
|
-
/* @__PURE__ */ Q(
|
|
2873
|
-
/* @__PURE__ */ Q(
|
|
3091
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-24" }),
|
|
3092
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-20" }),
|
|
3093
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-20" }),
|
|
3094
|
+
/* @__PURE__ */ Q(X, { className: "h-5 w-20" })
|
|
2874
3095
|
]
|
|
2875
3096
|
}, e))]
|
|
2876
3097
|
})]
|
|
2877
3098
|
});
|
|
2878
|
-
if (
|
|
2879
|
-
className:
|
|
3099
|
+
if (m) return /* @__PURE__ */ $("div", {
|
|
3100
|
+
className: Z("overflow-auto", n),
|
|
2880
3101
|
"data-testid": "pivot-error",
|
|
2881
3102
|
children: [e.title && /* @__PURE__ */ Q("h3", {
|
|
2882
3103
|
className: "text-sm font-semibold mb-2",
|
|
@@ -2914,12 +3135,12 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2914
3135
|
]
|
|
2915
3136
|
}), /* @__PURE__ */ Q("p", {
|
|
2916
3137
|
className: "text-xs",
|
|
2917
|
-
children:
|
|
3138
|
+
children: m
|
|
2918
3139
|
})]
|
|
2919
3140
|
})]
|
|
2920
3141
|
});
|
|
2921
3142
|
if (!i && e.objectName && j.length === 0) return /* @__PURE__ */ $("div", {
|
|
2922
|
-
className:
|
|
3143
|
+
className: Z("overflow-auto", n),
|
|
2923
3144
|
children: [e.title && /* @__PURE__ */ Q("h3", {
|
|
2924
3145
|
className: "text-sm font-semibold mb-2",
|
|
2925
3146
|
children: e.title
|
|
@@ -2938,26 +3159,26 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2938
3159
|
let M = {
|
|
2939
3160
|
...e,
|
|
2940
3161
|
data: j
|
|
2941
|
-
},
|
|
2942
|
-
return /* @__PURE__ */ $(
|
|
3162
|
+
}, N = e.rowField ? g[e.rowField] : void 0, ee = e.columnField ? g[e.columnField] : void 0, te = e.rowField ? v[e.rowField] : void 0, P = e.drillDown, ie = O(P) ? (e) => S(e) : void 0;
|
|
3163
|
+
return /* @__PURE__ */ $(Ct, { children: [/* @__PURE__ */ Q(or, {
|
|
2943
3164
|
schema: M,
|
|
2944
3165
|
className: n,
|
|
2945
|
-
rowLabels:
|
|
2946
|
-
columnLabels:
|
|
2947
|
-
rowFieldLabel:
|
|
2948
|
-
onDrillDown:
|
|
3166
|
+
rowLabels: N,
|
|
3167
|
+
columnLabels: ee,
|
|
3168
|
+
rowFieldLabel: te,
|
|
3169
|
+
onDrillDown: ie
|
|
2949
3170
|
}), (() => {
|
|
2950
|
-
if (!
|
|
2951
|
-
let t =
|
|
3171
|
+
if (!x || !e.objectName) return null;
|
|
3172
|
+
let t = b(P, x, {
|
|
2952
3173
|
rowField: e.rowField,
|
|
2953
3174
|
columnField: e.columnField
|
|
2954
3175
|
}), n = {
|
|
2955
3176
|
...e.filter || {},
|
|
2956
3177
|
...t
|
|
2957
|
-
}, r =
|
|
2958
|
-
return /* @__PURE__ */ Q(
|
|
3178
|
+
}, r = ne(P, x, e.title || "Details");
|
|
3179
|
+
return /* @__PURE__ */ Q(nn, {
|
|
2959
3180
|
open: !0,
|
|
2960
|
-
onClose: () =>
|
|
3181
|
+
onClose: () => S(null),
|
|
2961
3182
|
title: r,
|
|
2962
3183
|
target: P?.target ?? "drawer",
|
|
2963
3184
|
objectName: e.objectName,
|
|
@@ -2968,7 +3189,7 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
2968
3189
|
report: P?.report
|
|
2969
3190
|
});
|
|
2970
3191
|
})()] });
|
|
2971
|
-
},
|
|
3192
|
+
}, cr = {
|
|
2972
3193
|
breadcrumb: ["Dashboard", "Configuration"],
|
|
2973
3194
|
sections: [
|
|
2974
3195
|
{
|
|
@@ -3094,12 +3315,12 @@ var Fn = ({ schema: e, className: t, rowLabels: n, columnLabels: r, rowFieldLabe
|
|
|
3094
3315
|
}
|
|
3095
3316
|
]
|
|
3096
3317
|
};
|
|
3097
|
-
function
|
|
3098
|
-
let { draft: a, isDirty: o, updateField: s, discard: c } =
|
|
3099
|
-
return /* @__PURE__ */ Q(
|
|
3318
|
+
function lr({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
3319
|
+
let { draft: a, isDirty: o, updateField: s, discard: c } = Ue(n, { onUpdate: i });
|
|
3320
|
+
return /* @__PURE__ */ Q(xe, {
|
|
3100
3321
|
open: e,
|
|
3101
3322
|
onClose: t,
|
|
3102
|
-
schema:
|
|
3323
|
+
schema: cr,
|
|
3103
3324
|
draft: a,
|
|
3104
3325
|
isDirty: o,
|
|
3105
3326
|
onFieldChange: s,
|
|
@@ -3109,7 +3330,7 @@ function Rn({ open: e, onClose: t, config: n, onSave: r, onFieldChange: i }) {
|
|
|
3109
3330
|
}
|
|
3110
3331
|
//#endregion
|
|
3111
3332
|
//#region src/WidgetConfigPanel.tsx
|
|
3112
|
-
var
|
|
3333
|
+
var ur = [
|
|
3113
3334
|
{
|
|
3114
3335
|
value: "metric",
|
|
3115
3336
|
label: "Metric"
|
|
@@ -3154,7 +3375,7 @@ var zn = [
|
|
|
3154
3375
|
value: "pivot",
|
|
3155
3376
|
label: "Pivot Table"
|
|
3156
3377
|
}
|
|
3157
|
-
],
|
|
3378
|
+
], dr = [
|
|
3158
3379
|
{
|
|
3159
3380
|
value: "default",
|
|
3160
3381
|
label: "Default"
|
|
@@ -3187,7 +3408,7 @@ var zn = [
|
|
|
3187
3408
|
value: "danger",
|
|
3188
3409
|
label: "Danger"
|
|
3189
3410
|
}
|
|
3190
|
-
],
|
|
3411
|
+
], fr = [
|
|
3191
3412
|
"bar",
|
|
3192
3413
|
"horizontal-bar",
|
|
3193
3414
|
"line",
|
|
@@ -3196,73 +3417,73 @@ var zn = [
|
|
|
3196
3417
|
"donut",
|
|
3197
3418
|
"scatter",
|
|
3198
3419
|
"funnel"
|
|
3199
|
-
],
|
|
3420
|
+
], pr = [
|
|
3200
3421
|
"metric",
|
|
3201
3422
|
"gauge",
|
|
3202
3423
|
"solid-gauge",
|
|
3203
3424
|
"kpi",
|
|
3204
3425
|
"bullet"
|
|
3205
3426
|
];
|
|
3206
|
-
function
|
|
3207
|
-
return !!e &&
|
|
3427
|
+
function mr(e) {
|
|
3428
|
+
return !!e && fr.includes(e);
|
|
3208
3429
|
}
|
|
3209
|
-
function
|
|
3210
|
-
return !!e && !
|
|
3430
|
+
function hr(e) {
|
|
3431
|
+
return !!e && !pr.includes(e);
|
|
3211
3432
|
}
|
|
3212
|
-
function
|
|
3213
|
-
let [
|
|
3214
|
-
let n =
|
|
3215
|
-
!n ||
|
|
3216
|
-
},
|
|
3433
|
+
function gr({ names: t, options: n, placeholder: r, emptyText: i, onChange: a }) {
|
|
3434
|
+
let [o, s] = e.useState(""), c = e.useMemo(() => new Set(t), [t]), l = e.useMemo(() => n.filter((e) => !c.has(e.value)), [n, c]), u = (e) => {
|
|
3435
|
+
let n = e.trim();
|
|
3436
|
+
!n || c.has(n) || (a([...t, n]), s(""));
|
|
3437
|
+
}, d = (e) => a(t.filter((t) => t !== e));
|
|
3217
3438
|
return /* @__PURE__ */ $("div", {
|
|
3218
3439
|
className: "space-y-1.5",
|
|
3219
|
-
children: [
|
|
3440
|
+
children: [t.length === 0 ? /* @__PURE__ */ Q("p", {
|
|
3220
3441
|
className: "rounded border border-dashed px-2 py-1.5 text-center text-[11px] text-muted-foreground",
|
|
3221
|
-
children:
|
|
3442
|
+
children: i
|
|
3222
3443
|
}) : /* @__PURE__ */ Q("div", {
|
|
3223
3444
|
className: "flex flex-wrap gap-1",
|
|
3224
|
-
children:
|
|
3445
|
+
children: t.map((e) => /* @__PURE__ */ $("span", {
|
|
3225
3446
|
"data-testid": `dataset-name-chip-${e}`,
|
|
3226
|
-
className:
|
|
3447
|
+
className: Z("inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5", "font-mono text-[11px] text-foreground"),
|
|
3227
3448
|
children: [e, /* @__PURE__ */ Q("button", {
|
|
3228
3449
|
type: "button",
|
|
3229
3450
|
"aria-label": `Remove ${e}`,
|
|
3230
3451
|
className: "text-muted-foreground hover:text-foreground",
|
|
3231
|
-
onClick: () =>
|
|
3232
|
-
children: /* @__PURE__ */ Q(
|
|
3452
|
+
onClick: () => d(e),
|
|
3453
|
+
children: /* @__PURE__ */ Q(ot, { className: "h-3 w-3" })
|
|
3233
3454
|
})]
|
|
3234
3455
|
}, e))
|
|
3235
|
-
}),
|
|
3236
|
-
options:
|
|
3456
|
+
}), l.length > 0 ? /* @__PURE__ */ Q(be, {
|
|
3457
|
+
options: l,
|
|
3237
3458
|
value: "",
|
|
3238
|
-
onValueChange:
|
|
3239
|
-
placeholder:
|
|
3459
|
+
onValueChange: u,
|
|
3460
|
+
placeholder: r,
|
|
3240
3461
|
searchPlaceholder: "Search…",
|
|
3241
3462
|
emptyText: "Nothing left to add.",
|
|
3242
3463
|
className: "h-7 w-full text-xs"
|
|
3243
3464
|
}) : /* @__PURE__ */ $("div", {
|
|
3244
3465
|
className: "flex items-center gap-1",
|
|
3245
|
-
children: [/* @__PURE__ */ Q(
|
|
3246
|
-
value:
|
|
3247
|
-
onChange: (e) =>
|
|
3466
|
+
children: [/* @__PURE__ */ Q(Oe, {
|
|
3467
|
+
value: o,
|
|
3468
|
+
onChange: (e) => s(e.target.value),
|
|
3248
3469
|
onKeyDown: (e) => {
|
|
3249
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
3470
|
+
e.key === "Enter" && (e.preventDefault(), u(o));
|
|
3250
3471
|
},
|
|
3251
|
-
placeholder:
|
|
3472
|
+
placeholder: r,
|
|
3252
3473
|
className: "h-7 flex-1 text-xs"
|
|
3253
|
-
}), /* @__PURE__ */ Q(
|
|
3474
|
+
}), /* @__PURE__ */ Q(K, {
|
|
3254
3475
|
type: "button",
|
|
3255
3476
|
size: "sm",
|
|
3256
3477
|
variant: "outline",
|
|
3257
3478
|
className: "h-7 px-2 text-xs",
|
|
3258
|
-
onClick: () =>
|
|
3259
|
-
disabled: !
|
|
3479
|
+
onClick: () => u(o),
|
|
3480
|
+
disabled: !o.trim(),
|
|
3260
3481
|
children: "Add"
|
|
3261
3482
|
})]
|
|
3262
3483
|
})]
|
|
3263
3484
|
});
|
|
3264
3485
|
}
|
|
3265
|
-
function
|
|
3486
|
+
function _r(e, t) {
|
|
3266
3487
|
let n = e ?? [], r = n.length > 0, i = n.map((e) => ({
|
|
3267
3488
|
value: e.name,
|
|
3268
3489
|
label: e.label && e.label !== e.name ? `${e.label} (${e.name})` : e.name
|
|
@@ -3271,11 +3492,11 @@ function Kn(e, t) {
|
|
|
3271
3492
|
label: "Dataset",
|
|
3272
3493
|
type: "custom",
|
|
3273
3494
|
helpText: "The semantic-layer dataset this widget binds to (ADR-0021).",
|
|
3274
|
-
render: (e, t) => /* @__PURE__ */ Q(
|
|
3495
|
+
render: (e, t) => /* @__PURE__ */ Q(Y, {
|
|
3275
3496
|
label: "Dataset",
|
|
3276
3497
|
children: /* @__PURE__ */ Q("div", {
|
|
3277
3498
|
"data-testid": "config-field-dataset",
|
|
3278
|
-
children: /* @__PURE__ */ Q(
|
|
3499
|
+
children: /* @__PURE__ */ Q(be, {
|
|
3279
3500
|
options: i,
|
|
3280
3501
|
value: e ?? "",
|
|
3281
3502
|
onValueChange: t,
|
|
@@ -3296,19 +3517,19 @@ function Kn(e, t) {
|
|
|
3296
3517
|
key: "dimensions",
|
|
3297
3518
|
label: "Dimensions",
|
|
3298
3519
|
type: "custom",
|
|
3299
|
-
visibleWhen: (e) =>
|
|
3520
|
+
visibleWhen: (e) => hr(e.type),
|
|
3300
3521
|
helpText: t === "pivot" ? "Group/split fields. The last dimension spreads across as columns." : "Group/split the values by these dataset dimensions.",
|
|
3301
3522
|
render: (e, t, n) => {
|
|
3302
3523
|
let r = (a(n.dataset)?.dimensions ?? []).map((e) => ({
|
|
3303
3524
|
value: e.name,
|
|
3304
3525
|
label: e.label && e.label !== e.name ? `${e.label} (${e.name})` : e.name
|
|
3305
3526
|
}));
|
|
3306
|
-
return /* @__PURE__ */ Q(
|
|
3527
|
+
return /* @__PURE__ */ Q(Y, {
|
|
3307
3528
|
label: "Dimensions",
|
|
3308
3529
|
children: /* @__PURE__ */ Q("div", {
|
|
3309
3530
|
"data-testid": "config-field-dimensions",
|
|
3310
3531
|
className: "w-40",
|
|
3311
|
-
children: /* @__PURE__ */ Q(
|
|
3532
|
+
children: /* @__PURE__ */ Q(gr, {
|
|
3312
3533
|
names: Array.isArray(e) ? e : [],
|
|
3313
3534
|
options: r,
|
|
3314
3535
|
placeholder: "Add dimension…",
|
|
@@ -3323,7 +3544,7 @@ function Kn(e, t) {
|
|
|
3323
3544
|
breadcrumb: ["Dashboard", {
|
|
3324
3545
|
pivot: "Pivot table",
|
|
3325
3546
|
table: "Table"
|
|
3326
|
-
}[t ?? ""] ?? (
|
|
3547
|
+
}[t ?? ""] ?? (mr(t) ? "Chart" : "Widget")],
|
|
3327
3548
|
sections: [
|
|
3328
3549
|
{
|
|
3329
3550
|
key: "general",
|
|
@@ -3345,7 +3566,7 @@ function Kn(e, t) {
|
|
|
3345
3566
|
key: "type",
|
|
3346
3567
|
label: "Widget type",
|
|
3347
3568
|
type: "select",
|
|
3348
|
-
options:
|
|
3569
|
+
options: ur,
|
|
3349
3570
|
defaultValue: "metric"
|
|
3350
3571
|
}
|
|
3351
3572
|
]
|
|
@@ -3367,12 +3588,12 @@ function Kn(e, t) {
|
|
|
3367
3588
|
value: e.name,
|
|
3368
3589
|
label: e.aggregate ? `${e.label ?? e.name} · ${e.aggregate}` : e.label ?? e.name
|
|
3369
3590
|
}));
|
|
3370
|
-
return /* @__PURE__ */ Q(
|
|
3591
|
+
return /* @__PURE__ */ Q(Y, {
|
|
3371
3592
|
label: "Values",
|
|
3372
3593
|
children: /* @__PURE__ */ Q("div", {
|
|
3373
3594
|
"data-testid": "config-field-values",
|
|
3374
3595
|
className: "w-40",
|
|
3375
|
-
children: /* @__PURE__ */ Q(
|
|
3596
|
+
children: /* @__PURE__ */ Q(gr, {
|
|
3376
3597
|
names: Array.isArray(e) ? e : [],
|
|
3377
3598
|
options: r,
|
|
3378
3599
|
placeholder: "Add measure…",
|
|
@@ -3407,18 +3628,6 @@ function Kn(e, t) {
|
|
|
3407
3628
|
defaultValue: 1
|
|
3408
3629
|
}]
|
|
3409
3630
|
},
|
|
3410
|
-
{
|
|
3411
|
-
key: "behavior",
|
|
3412
|
-
title: "Behavior",
|
|
3413
|
-
collapsible: !0,
|
|
3414
|
-
defaultCollapsed: !0,
|
|
3415
|
-
fields: [{
|
|
3416
|
-
key: "actionUrl",
|
|
3417
|
-
label: "Click-through URL",
|
|
3418
|
-
type: "input",
|
|
3419
|
-
placeholder: "https://..."
|
|
3420
|
-
}]
|
|
3421
|
-
},
|
|
3422
3631
|
{
|
|
3423
3632
|
key: "appearance",
|
|
3424
3633
|
title: "Appearance",
|
|
@@ -3428,14 +3637,14 @@ function Kn(e, t) {
|
|
|
3428
3637
|
key: "colorVariant",
|
|
3429
3638
|
label: "Color variant",
|
|
3430
3639
|
type: "select",
|
|
3431
|
-
options:
|
|
3640
|
+
options: dr,
|
|
3432
3641
|
defaultValue: "default"
|
|
3433
3642
|
}]
|
|
3434
3643
|
}
|
|
3435
3644
|
]
|
|
3436
3645
|
};
|
|
3437
3646
|
}
|
|
3438
|
-
function
|
|
3647
|
+
function vr(e) {
|
|
3439
3648
|
if (e == null) return "";
|
|
3440
3649
|
if (typeof e == "string") return e;
|
|
3441
3650
|
if (typeof e == "object") {
|
|
@@ -3444,7 +3653,11 @@ function qn(e) {
|
|
|
3444
3653
|
}
|
|
3445
3654
|
return String(e);
|
|
3446
3655
|
}
|
|
3447
|
-
var
|
|
3656
|
+
var yr = [
|
|
3657
|
+
"actionUrl",
|
|
3658
|
+
"actionType",
|
|
3659
|
+
"actionIcon"
|
|
3660
|
+
], br = [
|
|
3448
3661
|
"object",
|
|
3449
3662
|
"categoryField",
|
|
3450
3663
|
"categoryGranularity",
|
|
@@ -3471,39 +3684,40 @@ var Jn = [
|
|
|
3471
3684
|
"searchable",
|
|
3472
3685
|
"pagination"
|
|
3473
3686
|
];
|
|
3474
|
-
function
|
|
3687
|
+
function xr(e) {
|
|
3475
3688
|
let t = e.type, n = { ...e };
|
|
3476
|
-
for (let e of
|
|
3477
|
-
|
|
3689
|
+
for (let e of br) delete n[e];
|
|
3690
|
+
for (let e of yr) delete n[e];
|
|
3691
|
+
return hr(t) || delete n.dimensions, n;
|
|
3478
3692
|
}
|
|
3479
|
-
function
|
|
3480
|
-
let
|
|
3481
|
-
...
|
|
3482
|
-
title: typeof
|
|
3483
|
-
description: typeof
|
|
3484
|
-
}), [
|
|
3485
|
-
return /* @__PURE__ */ Q(
|
|
3486
|
-
open:
|
|
3487
|
-
onClose:
|
|
3488
|
-
schema:
|
|
3489
|
-
draft:
|
|
3490
|
-
isDirty:
|
|
3491
|
-
onFieldChange:
|
|
3492
|
-
onSave: () =>
|
|
3493
|
-
onDiscard:
|
|
3494
|
-
headerExtra:
|
|
3693
|
+
function Sr({ open: t, onClose: n, config: r, onSave: i, onFieldChange: a, headerExtra: o, datasets: s, datasetsLoading: c }) {
|
|
3694
|
+
let l = e.useMemo(() => ({
|
|
3695
|
+
...r,
|
|
3696
|
+
title: typeof r.title == "object" ? vr(r.title) : r.title,
|
|
3697
|
+
description: typeof r.description == "object" ? vr(r.description) : r.description
|
|
3698
|
+
}), [r]), { draft: u, isDirty: d, updateField: f, discard: p } = Ue(l, { onUpdate: a }), m = e.useMemo(() => _r(s, u.type), [s, u.type]);
|
|
3699
|
+
return /* @__PURE__ */ Q(xe, {
|
|
3700
|
+
open: t,
|
|
3701
|
+
onClose: n,
|
|
3702
|
+
schema: m,
|
|
3703
|
+
draft: u,
|
|
3704
|
+
isDirty: d,
|
|
3705
|
+
onFieldChange: f,
|
|
3706
|
+
onSave: () => i(xr(u)),
|
|
3707
|
+
onDiscard: p,
|
|
3708
|
+
headerExtra: o
|
|
3495
3709
|
});
|
|
3496
3710
|
}
|
|
3497
3711
|
//#endregion
|
|
3498
3712
|
//#region src/DashboardWithConfig.tsx
|
|
3499
|
-
function
|
|
3500
|
-
let [
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
}, [
|
|
3504
|
-
let
|
|
3505
|
-
if (!
|
|
3506
|
-
let e =
|
|
3713
|
+
function Cr({ schema: t, config: n, onConfigSave: r, onWidgetSave: a, onRefresh: s, recordCount: c, defaultConfigOpen: u = !1, className: d, datasets: f, datasetsLoading: p }) {
|
|
3714
|
+
let [m, h] = l(u), [g, _] = l(null), [v, y] = l(t), [b, x] = l(0);
|
|
3715
|
+
o(() => {
|
|
3716
|
+
y(t), x((e) => e + 1);
|
|
3717
|
+
}, [t]);
|
|
3718
|
+
let S = e.useMemo(() => {
|
|
3719
|
+
if (!g || !v.widgets) return null;
|
|
3720
|
+
let e = v.widgets.find((e) => (e.id || e.title) === g);
|
|
3507
3721
|
if (!e) return null;
|
|
3508
3722
|
let t = e;
|
|
3509
3723
|
return {
|
|
@@ -3515,18 +3729,17 @@ function Zn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3515
3729
|
dimensions: Array.isArray(t.dimensions) ? t.dimensions : [],
|
|
3516
3730
|
values: Array.isArray(t.values) ? t.values : [],
|
|
3517
3731
|
colorVariant: e.colorVariant ?? "default",
|
|
3518
|
-
actionUrl: e.actionUrl ?? "",
|
|
3519
3732
|
layoutW: e.layout?.w ?? 1,
|
|
3520
3733
|
layoutH: e.layout?.h ?? 1
|
|
3521
3734
|
};
|
|
3522
|
-
}, [
|
|
3523
|
-
|
|
3524
|
-
}, []),
|
|
3525
|
-
|
|
3526
|
-
}, []),
|
|
3527
|
-
|
|
3735
|
+
}, [g, b]), C = i((e) => {
|
|
3736
|
+
_(e), h(!0);
|
|
3737
|
+
}, []), w = i(() => {
|
|
3738
|
+
_(null);
|
|
3739
|
+
}, []), T = i((e, t) => {
|
|
3740
|
+
g && y((n) => n.widgets ? {
|
|
3528
3741
|
...n,
|
|
3529
|
-
widgets: n.widgets.map((n) => (n.id || n.title) ===
|
|
3742
|
+
widgets: n.widgets.map((n) => (n.id || n.title) === g ? e === "layoutW" ? {
|
|
3530
3743
|
...n,
|
|
3531
3744
|
layout: {
|
|
3532
3745
|
...n.layout || {},
|
|
@@ -3543,53 +3756,53 @@ function Zn({ schema: e, config: t, onConfigSave: n, onWidgetSave: r, onRefresh:
|
|
|
3543
3756
|
[e]: t
|
|
3544
3757
|
} : n)
|
|
3545
3758
|
} : n);
|
|
3546
|
-
}, [
|
|
3547
|
-
|
|
3548
|
-
}, [
|
|
3549
|
-
|
|
3759
|
+
}, [g]), E = i((e) => {
|
|
3760
|
+
g && a && a(g, e), _(null), x((e) => e + 1);
|
|
3761
|
+
}, [g, a]), D = i(() => {
|
|
3762
|
+
h((e) => !e), _(null);
|
|
3550
3763
|
}, []);
|
|
3551
3764
|
return /* @__PURE__ */ $("div", {
|
|
3552
|
-
className:
|
|
3765
|
+
className: Z("flex h-full w-full", d),
|
|
3553
3766
|
"data-testid": "dashboard-with-config",
|
|
3554
3767
|
children: [/* @__PURE__ */ $("div", {
|
|
3555
3768
|
className: "flex-1 min-w-0 overflow-auto relative",
|
|
3556
3769
|
children: [/* @__PURE__ */ Q("div", {
|
|
3557
3770
|
className: "absolute top-2 right-2 z-10",
|
|
3558
|
-
children: /* @__PURE__ */ $(
|
|
3771
|
+
children: /* @__PURE__ */ $(K, {
|
|
3559
3772
|
size: "sm",
|
|
3560
|
-
variant:
|
|
3561
|
-
onClick:
|
|
3773
|
+
variant: m ? "default" : "outline",
|
|
3774
|
+
onClick: D,
|
|
3562
3775
|
"data-testid": "dashboard-config-toggle",
|
|
3563
|
-
children: [/* @__PURE__ */ Q(
|
|
3776
|
+
children: [/* @__PURE__ */ Q(at, { className: "h-3.5 w-3.5 mr-1" }), "Settings"]
|
|
3564
3777
|
})
|
|
3565
|
-
}), /* @__PURE__ */ Q(
|
|
3566
|
-
schema:
|
|
3567
|
-
onRefresh:
|
|
3568
|
-
recordCount:
|
|
3569
|
-
designMode:
|
|
3570
|
-
selectedWidgetId:
|
|
3571
|
-
onWidgetClick:
|
|
3778
|
+
}), /* @__PURE__ */ Q(Vn, {
|
|
3779
|
+
schema: v,
|
|
3780
|
+
onRefresh: s,
|
|
3781
|
+
recordCount: c,
|
|
3782
|
+
designMode: m,
|
|
3783
|
+
selectedWidgetId: g,
|
|
3784
|
+
onWidgetClick: C
|
|
3572
3785
|
})]
|
|
3573
|
-
}),
|
|
3786
|
+
}), m && /* @__PURE__ */ Q("div", {
|
|
3574
3787
|
className: "relative shrink-0",
|
|
3575
|
-
children:
|
|
3788
|
+
children: g && S ? /* @__PURE__ */ Q(Sr, {
|
|
3576
3789
|
open: !0,
|
|
3577
|
-
onClose:
|
|
3578
|
-
config:
|
|
3579
|
-
onSave:
|
|
3580
|
-
onFieldChange:
|
|
3581
|
-
datasets:
|
|
3582
|
-
datasetsLoading:
|
|
3583
|
-
}) : /* @__PURE__ */ Q(
|
|
3790
|
+
onClose: w,
|
|
3791
|
+
config: S,
|
|
3792
|
+
onSave: E,
|
|
3793
|
+
onFieldChange: T,
|
|
3794
|
+
datasets: f,
|
|
3795
|
+
datasetsLoading: p
|
|
3796
|
+
}) : /* @__PURE__ */ Q(lr, {
|
|
3584
3797
|
open: !0,
|
|
3585
|
-
onClose: () =>
|
|
3586
|
-
config:
|
|
3587
|
-
onSave:
|
|
3798
|
+
onClose: () => h(!1),
|
|
3799
|
+
config: n,
|
|
3800
|
+
onSave: r
|
|
3588
3801
|
})
|
|
3589
3802
|
})]
|
|
3590
3803
|
});
|
|
3591
3804
|
}
|
|
3592
|
-
|
|
3805
|
+
u.register("dashboard", Vn, {
|
|
3593
3806
|
namespace: "view",
|
|
3594
3807
|
label: "Dashboard",
|
|
3595
3808
|
category: "Complex",
|
|
@@ -3617,7 +3830,7 @@ e.register("dashboard", fn, {
|
|
|
3617
3830
|
columns: 3,
|
|
3618
3831
|
widgets: []
|
|
3619
3832
|
}
|
|
3620
|
-
}),
|
|
3833
|
+
}), u.register("metric", Xn, {
|
|
3621
3834
|
namespace: "plugin-dashboard",
|
|
3622
3835
|
label: "Metric Widget",
|
|
3623
3836
|
category: "Dashboard",
|
|
@@ -3630,7 +3843,7 @@ e.register("dashboard", fn, {
|
|
|
3630
3843
|
type: "string",
|
|
3631
3844
|
label: "Value"
|
|
3632
3845
|
}]
|
|
3633
|
-
}),
|
|
3846
|
+
}), u.register("metric-card", Zn, {
|
|
3634
3847
|
namespace: "plugin-dashboard",
|
|
3635
3848
|
label: "Metric Card",
|
|
3636
3849
|
category: "Dashboard",
|
|
@@ -3685,7 +3898,20 @@ e.register("dashboard", fn, {
|
|
|
3685
3898
|
title: "Metric",
|
|
3686
3899
|
value: "0"
|
|
3687
3900
|
}
|
|
3688
|
-
})
|
|
3901
|
+
});
|
|
3902
|
+
var wr = { filter: !0 };
|
|
3903
|
+
u.register("object-metric", ({ schema: e, ...t }) => /* @__PURE__ */ Q(F, {
|
|
3904
|
+
schema: e,
|
|
3905
|
+
mapping: wr,
|
|
3906
|
+
dataSource: t.dataSource,
|
|
3907
|
+
testId: "object-metric",
|
|
3908
|
+
errorTitle: "This metric’s data source could not be resolved",
|
|
3909
|
+
children: (e) => /* @__PURE__ */ Q(Qn, {
|
|
3910
|
+
...t,
|
|
3911
|
+
objectName: e?.objectName ?? t.objectName,
|
|
3912
|
+
filter: e?.filter ?? t.filter
|
|
3913
|
+
})
|
|
3914
|
+
}), {
|
|
3689
3915
|
namespace: "plugin-dashboard",
|
|
3690
3916
|
label: "Object Metric",
|
|
3691
3917
|
category: "Dashboard",
|
|
@@ -3714,7 +3940,7 @@ e.register("dashboard", fn, {
|
|
|
3714
3940
|
}
|
|
3715
3941
|
],
|
|
3716
3942
|
defaultProps: { label: "Metric" }
|
|
3717
|
-
}),
|
|
3943
|
+
}), u.register("pivot", or, {
|
|
3718
3944
|
namespace: "plugin-dashboard",
|
|
3719
3945
|
label: "Pivot Table",
|
|
3720
3946
|
category: "Dashboard",
|
|
@@ -3793,7 +4019,19 @@ e.register("dashboard", fn, {
|
|
|
3793
4019
|
aggregation: "sum",
|
|
3794
4020
|
data: []
|
|
3795
4021
|
}
|
|
3796
|
-
})
|
|
4022
|
+
});
|
|
4023
|
+
var Tr = { filter: !0 };
|
|
4024
|
+
u.register("object-pivot", ({ schema: e, ...t }) => /* @__PURE__ */ Q(F, {
|
|
4025
|
+
schema: e,
|
|
4026
|
+
mapping: Tr,
|
|
4027
|
+
dataSource: t.dataSource,
|
|
4028
|
+
testId: "object-pivot",
|
|
4029
|
+
errorTitle: "This pivot table’s data source could not be resolved",
|
|
4030
|
+
children: (e) => /* @__PURE__ */ Q(sr, {
|
|
4031
|
+
...t,
|
|
4032
|
+
schema: e
|
|
4033
|
+
})
|
|
4034
|
+
}), {
|
|
3797
4035
|
namespace: "plugin-dashboard",
|
|
3798
4036
|
label: "Object Pivot Table",
|
|
3799
4037
|
category: "Dashboard",
|
|
@@ -3882,7 +4120,7 @@ e.register("dashboard", fn, {
|
|
|
3882
4120
|
valueField: "",
|
|
3883
4121
|
aggregation: "sum"
|
|
3884
4122
|
}
|
|
3885
|
-
}),
|
|
4123
|
+
}), u.register("dashboard-grid", Kn, {
|
|
3886
4124
|
namespace: "plugin-dashboard",
|
|
3887
4125
|
label: "Dashboard Grid (Editable)",
|
|
3888
4126
|
category: "Complex",
|
|
@@ -3900,7 +4138,7 @@ e.register("dashboard", fn, {
|
|
|
3900
4138
|
title: "Dashboard",
|
|
3901
4139
|
widgets: []
|
|
3902
4140
|
}
|
|
3903
|
-
}),
|
|
4141
|
+
}), u.register("object-data-table", en, {
|
|
3904
4142
|
namespace: "plugin-dashboard",
|
|
3905
4143
|
label: "Object Data Table",
|
|
3906
4144
|
category: "Dashboard",
|
|
@@ -3938,18 +4176,18 @@ e.register("dashboard", fn, {
|
|
|
3938
4176
|
pagination: !1
|
|
3939
4177
|
}
|
|
3940
4178
|
});
|
|
3941
|
-
var
|
|
3942
|
-
DashboardRenderer:
|
|
3943
|
-
DashboardGridLayout:
|
|
3944
|
-
MetricWidget:
|
|
3945
|
-
MetricCard:
|
|
3946
|
-
ObjectMetricWidget:
|
|
3947
|
-
PivotTable:
|
|
3948
|
-
ObjectPivotTable:
|
|
3949
|
-
ObjectDataTable:
|
|
3950
|
-
DashboardConfigPanel:
|
|
3951
|
-
WidgetConfigPanel:
|
|
3952
|
-
DashboardWithConfig:
|
|
4179
|
+
var Er = {
|
|
4180
|
+
DashboardRenderer: Vn,
|
|
4181
|
+
DashboardGridLayout: Kn,
|
|
4182
|
+
MetricWidget: Xn,
|
|
4183
|
+
MetricCard: Zn,
|
|
4184
|
+
ObjectMetricWidget: Qn,
|
|
4185
|
+
PivotTable: or,
|
|
4186
|
+
ObjectPivotTable: sr,
|
|
4187
|
+
ObjectDataTable: en,
|
|
4188
|
+
DashboardConfigPanel: lr,
|
|
4189
|
+
WidgetConfigPanel: Sr,
|
|
4190
|
+
DashboardWithConfig: Cr
|
|
3953
4191
|
};
|
|
3954
4192
|
//#endregion
|
|
3955
|
-
export {
|
|
4193
|
+
export { lr as DashboardConfigPanel, Kn as DashboardGridLayout, Vn as DashboardRenderer, Cr as DashboardWithConfig, nn as DrillDownDrawer, Zn as MetricCard, Xn as MetricWidget, en as ObjectDataTable, Qn as ObjectMetricWidget, sr as ObjectPivotTable, or as PivotTable, Sr as WidgetConfigPanel, Er as dashboardComponents };
|