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