@burdenoff/microfe-bigconsole 2026.1103.4 → 2026.1103.6
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/dist/bigconsole/components/widgets/chart/charts/FunnelChart.d.ts +1 -1
- package/dist/bigconsole/components/widgets/chart/charts/FunnelChart.js +69 -54
- package/dist/bigconsole/components/widgets/chart/charts/funnelData.d.ts +8 -0
- package/dist/bigconsole/components/widgets/chart/charts/funnelData.js +17 -0
- package/dist/bigconsole/components/widgets/table/TableConfig.js +208 -201
- package/dist/bigconsole/components/widgets/table/TableWidget.js +121 -119
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { ChartConfig, ChartData } from './types';
|
|
3
3
|
export interface FunnelChartProps {
|
|
4
|
-
/** Chart data
|
|
4
|
+
/** Chart data in funnel stage order */
|
|
5
5
|
data: ChartData[];
|
|
6
6
|
/** Chart configuration */
|
|
7
7
|
config: ChartConfig;
|
|
@@ -1,68 +1,83 @@
|
|
|
1
1
|
import { ChartTooltip as e } from "../ChartTooltip.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { funnelStages as t } from "./funnelData.js";
|
|
3
|
+
import { memo as n } from "react";
|
|
4
|
+
import { useI18n as r } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
5
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
|
+
import { Cell as o, Funnel as s, FunnelChart as c, LabelList as l, ResponsiveContainer as u, Tooltip as d } from "recharts";
|
|
5
7
|
//#region src/bigconsole/components/widgets/chart/charts/FunnelChart.tsx
|
|
6
|
-
var
|
|
8
|
+
var f = [
|
|
7
9
|
"var(--color-chart-1)",
|
|
8
10
|
"var(--color-chart-2)",
|
|
9
11
|
"var(--color-chart-3)",
|
|
10
12
|
"var(--color-chart-4)",
|
|
11
13
|
"var(--color-chart-5)"
|
|
12
|
-
],
|
|
13
|
-
let h = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
14
|
+
], p = n(function({ data: n = [], config: p, dataKey: m = "value", nameKey: h = "name", onDataClick: g }) {
|
|
15
|
+
let { t: _, locale: v } = r(), y = t(n, m, h), b = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
14
16
|
notation: e >= 1e4 ? "compact" : "standard",
|
|
15
17
|
maximumFractionDigits: 2
|
|
16
18
|
}).format(e) : String(e);
|
|
17
|
-
if (!
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...e,
|
|
26
|
-
rate: a
|
|
27
|
-
};
|
|
19
|
+
if (!y || !y.length || y.every((e) => e.value === 0)) return /* @__PURE__ */ i("div", {
|
|
20
|
+
role: "status",
|
|
21
|
+
className: "flex items-center justify-center h-full text-text-secondary text-sm p-4",
|
|
22
|
+
children: y ? _("bigconsole.widgets.funnel.noCounts", "No funnel counts to display. Connect data with at least one count greater than zero.") : _("bigconsole.widgets.funnel.invalidFields", "Each funnel row needs a label in \"{{labelField}}\" and a non-negative number in \"{{valueField}}\". Choose the label and value fields in Style.", {
|
|
23
|
+
labelField: h,
|
|
24
|
+
valueField: m
|
|
25
|
+
})
|
|
28
26
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
children:
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
27
|
+
let x = new Intl.NumberFormat(v, {
|
|
28
|
+
style: "percent",
|
|
29
|
+
maximumFractionDigits: 1
|
|
30
|
+
}), S = y.map((e) => ({
|
|
31
|
+
...e.row,
|
|
32
|
+
__conversionLabel: `${e.label} (${e.conversion === void 0 ? "—" : x.format(e.conversion)})`
|
|
33
|
+
}));
|
|
34
|
+
return /* @__PURE__ */ a("div", {
|
|
35
|
+
className: "flex flex-col h-full",
|
|
36
|
+
children: [/* @__PURE__ */ i("p", {
|
|
37
|
+
className: "text-xs text-text-secondary mb-2",
|
|
38
|
+
children: _("bigconsole.widgets.funnel.conversionBasis", "Conversion from previous stage; first stage is the baseline.")
|
|
39
|
+
}), /* @__PURE__ */ i("div", {
|
|
40
|
+
className: "flex-1 min-h-0",
|
|
41
|
+
children: /* @__PURE__ */ i(u, {
|
|
42
|
+
width: "100%",
|
|
43
|
+
height: "100%",
|
|
44
|
+
children: /* @__PURE__ */ a(c, { children: [/* @__PURE__ */ i(d, { content: /* @__PURE__ */ i(e, {
|
|
45
|
+
valueFormatter: b,
|
|
46
|
+
labelFormatter: (e) => String(e)
|
|
47
|
+
}) }), /* @__PURE__ */ a(s, {
|
|
48
|
+
dataKey: m,
|
|
49
|
+
nameKey: h,
|
|
50
|
+
data: S,
|
|
51
|
+
isAnimationActive: !0,
|
|
52
|
+
onClick: (e, t) => {
|
|
53
|
+
t !== void 0 && n[t] && g?.(n[t], t);
|
|
54
|
+
},
|
|
55
|
+
children: [
|
|
56
|
+
/* @__PURE__ */ i(l, {
|
|
57
|
+
position: "right",
|
|
58
|
+
fill: "var(--color-text-primary)",
|
|
59
|
+
stroke: "none",
|
|
60
|
+
dataKey: "__conversionLabel",
|
|
61
|
+
fontSize: 12
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ i(l, {
|
|
64
|
+
position: "center",
|
|
65
|
+
fill: "var(--color-text-on-primary, #ffffff)",
|
|
66
|
+
stroke: "none",
|
|
67
|
+
dataKey: m,
|
|
68
|
+
formatter: (e) => b(e),
|
|
69
|
+
fontSize: 14,
|
|
70
|
+
fontWeight: 600
|
|
71
|
+
}),
|
|
72
|
+
S.map((e, t) => /* @__PURE__ */ i(o, {
|
|
73
|
+
fill: p.colors?.[t] || f[t % f.length],
|
|
74
|
+
style: { cursor: g ? "pointer" : "default" }
|
|
75
|
+
}, `cell-${t}`))
|
|
76
|
+
]
|
|
77
|
+
})] })
|
|
78
|
+
})
|
|
79
|
+
})]
|
|
65
80
|
});
|
|
66
81
|
});
|
|
67
82
|
//#endregion
|
|
68
|
-
export {
|
|
83
|
+
export { p as FunnelChart, p as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ChartData } from './types';
|
|
2
|
+
/** Keep the caller's stage order; conversions compare adjacent stages. */
|
|
3
|
+
export declare function funnelStages(data: ChartData[], valueField: string, labelField: string): {
|
|
4
|
+
row: ChartData;
|
|
5
|
+
value: number;
|
|
6
|
+
label: string;
|
|
7
|
+
conversion: number | undefined;
|
|
8
|
+
}[] | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/bigconsole/components/widgets/chart/charts/funnelData.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
return !Array.isArray(e) || e.some((e) => {
|
|
4
|
+
let r = e?.[t], i = e?.[n];
|
|
5
|
+
return typeof r != "number" || !Number.isFinite(r) || r < 0 || !["string", "number"].includes(typeof i) || String(i).trim() === "";
|
|
6
|
+
}) ? null : e.map((r, i) => {
|
|
7
|
+
let a = r[t], o = e[Math.max(0, i - 1)][t];
|
|
8
|
+
return {
|
|
9
|
+
row: r,
|
|
10
|
+
value: a,
|
|
11
|
+
label: String(r[n]),
|
|
12
|
+
conversion: o > 0 ? a / o : void 0
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { e as funnelStages };
|
|
@@ -179,217 +179,224 @@ var c = [
|
|
|
179
179
|
})
|
|
180
180
|
]
|
|
181
181
|
})] }),
|
|
182
|
-
/* @__PURE__ */ s("div", { children: [
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
className: "
|
|
197
|
-
children:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
type: "text",
|
|
225
|
-
value: e.field || "",
|
|
226
|
-
onChange: (e) => g(t, "field", e.target.value),
|
|
227
|
-
placeholder: f("bigconsole.widget.config.table.column.fieldPlaceholder", "Field name"),
|
|
228
|
-
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n "
|
|
229
|
-
}), /* @__PURE__ */ o("input", {
|
|
230
|
-
type: "text",
|
|
231
|
-
value: e.header || "",
|
|
232
|
-
onChange: (e) => g(t, "header", e.target.value),
|
|
233
|
-
placeholder: f("bigconsole.widget.config.table.column.headerPlaceholder", "Header label"),
|
|
234
|
-
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n "
|
|
235
|
-
})]
|
|
236
|
-
}),
|
|
237
|
-
/* @__PURE__ */ s("div", {
|
|
238
|
-
className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
|
|
239
|
-
children: [/* @__PURE__ */ s("select", {
|
|
240
|
-
value: e.format || "text",
|
|
241
|
-
onChange: (e) => g(t, "format", e.target.value),
|
|
242
|
-
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n ",
|
|
243
|
-
children: [
|
|
244
|
-
/* @__PURE__ */ o("option", {
|
|
245
|
-
value: "text",
|
|
246
|
-
children: f("bigconsole.widget.config.table.format.text", "Text")
|
|
247
|
-
}),
|
|
248
|
-
/* @__PURE__ */ o("option", {
|
|
249
|
-
value: "number",
|
|
250
|
-
children: f("bigconsole.widget.config.table.format.number", "Number")
|
|
251
|
-
}),
|
|
252
|
-
/* @__PURE__ */ o("option", {
|
|
253
|
-
value: "currency",
|
|
254
|
-
children: f("bigconsole.widget.config.table.format.currency", "Currency")
|
|
255
|
-
}),
|
|
256
|
-
/* @__PURE__ */ o("option", {
|
|
257
|
-
value: "percentage",
|
|
258
|
-
children: f("bigconsole.widget.config.table.format.percentage", "Percentage")
|
|
259
|
-
}),
|
|
260
|
-
/* @__PURE__ */ o("option", {
|
|
261
|
-
value: "date",
|
|
262
|
-
children: f("bigconsole.widget.config.table.format.date", "Date")
|
|
263
|
-
}),
|
|
264
|
-
/* @__PURE__ */ o("option", {
|
|
265
|
-
value: "badge",
|
|
266
|
-
children: f("bigconsole.widget.config.table.format.badge", "Badge")
|
|
182
|
+
/* @__PURE__ */ s("div", { children: [
|
|
183
|
+
/* @__PURE__ */ s("div", {
|
|
184
|
+
className: "flex items-center justify-between mb-2",
|
|
185
|
+
children: [/* @__PURE__ */ o("label", {
|
|
186
|
+
className: "text-sm font-medium text-text-primary",
|
|
187
|
+
children: f("bigconsole.widget.config.table.columns.label", "Columns")
|
|
188
|
+
}), /* @__PURE__ */ o("button", {
|
|
189
|
+
type: "button",
|
|
190
|
+
onClick: S,
|
|
191
|
+
className: "\n text-sm text-action-primary-bg\n hover:text-action-primary-bgHover\n ",
|
|
192
|
+
children: f("bigconsole.widget.config.table.columns.add", "+ Add Column")
|
|
193
|
+
})]
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ o("p", {
|
|
196
|
+
className: "text-sm text-text-secondary mb-3",
|
|
197
|
+
children: f("bigconsole.widget.config.table.columns.replacementHelp", "Adding columns here replaces auto-generated columns. Only configured columns will be shown, in this order. In edit mode, drag table headers to reorder.")
|
|
198
|
+
}),
|
|
199
|
+
/* @__PURE__ */ s("div", {
|
|
200
|
+
className: "space-y-3",
|
|
201
|
+
children: [p.map((e, t) => /* @__PURE__ */ s("div", {
|
|
202
|
+
className: "\n p-3\n bg-bg-sunken\n rounded-md\n space-y-2\n ",
|
|
203
|
+
children: [
|
|
204
|
+
/* @__PURE__ */ s("div", {
|
|
205
|
+
className: "flex items-center justify-between",
|
|
206
|
+
children: [/* @__PURE__ */ o("span", {
|
|
207
|
+
className: "text-xs text-text-secondary",
|
|
208
|
+
children: f("bigconsole.widget.config.table.columns.columnN", "Column {{index}}", { index: t + 1 })
|
|
209
|
+
}), /* @__PURE__ */ o("button", {
|
|
210
|
+
type: "button",
|
|
211
|
+
onClick: () => C(t),
|
|
212
|
+
className: "text-status-error-text hover:text-status-error-text/80",
|
|
213
|
+
children: /* @__PURE__ */ o("svg", {
|
|
214
|
+
className: "w-4 h-4",
|
|
215
|
+
fill: "none",
|
|
216
|
+
stroke: "currentColor",
|
|
217
|
+
viewBox: "0 0 24 24",
|
|
218
|
+
children: /* @__PURE__ */ o("path", {
|
|
219
|
+
strokeLinecap: "round",
|
|
220
|
+
strokeLinejoin: "round",
|
|
221
|
+
strokeWidth: 2,
|
|
222
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
223
|
+
})
|
|
267
224
|
})
|
|
268
|
-
]
|
|
269
|
-
}),
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
225
|
+
})]
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ s("div", {
|
|
228
|
+
className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
|
|
229
|
+
children: [/* @__PURE__ */ o("input", {
|
|
230
|
+
type: "text",
|
|
231
|
+
value: e.field || "",
|
|
232
|
+
onChange: (e) => g(t, "field", e.target.value),
|
|
233
|
+
placeholder: f("bigconsole.widget.config.table.column.fieldPlaceholder", "Field name"),
|
|
234
|
+
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n "
|
|
235
|
+
}), /* @__PURE__ */ o("input", {
|
|
236
|
+
type: "text",
|
|
237
|
+
value: e.header || "",
|
|
238
|
+
onChange: (e) => g(t, "header", e.target.value),
|
|
239
|
+
placeholder: f("bigconsole.widget.config.table.column.headerPlaceholder", "Header label"),
|
|
240
|
+
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n "
|
|
241
|
+
})]
|
|
242
|
+
}),
|
|
243
|
+
/* @__PURE__ */ s("div", {
|
|
244
|
+
className: "grid grid-cols-1 gap-2 sm:grid-cols-2",
|
|
245
|
+
children: [/* @__PURE__ */ s("select", {
|
|
246
|
+
value: e.format || "text",
|
|
247
|
+
onChange: (e) => g(t, "format", e.target.value),
|
|
248
|
+
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n ",
|
|
249
|
+
children: [
|
|
250
|
+
/* @__PURE__ */ o("option", {
|
|
251
|
+
value: "text",
|
|
252
|
+
children: f("bigconsole.widget.config.table.format.text", "Text")
|
|
253
|
+
}),
|
|
254
|
+
/* @__PURE__ */ o("option", {
|
|
255
|
+
value: "number",
|
|
256
|
+
children: f("bigconsole.widget.config.table.format.number", "Number")
|
|
257
|
+
}),
|
|
258
|
+
/* @__PURE__ */ o("option", {
|
|
259
|
+
value: "currency",
|
|
260
|
+
children: f("bigconsole.widget.config.table.format.currency", "Currency")
|
|
261
|
+
}),
|
|
262
|
+
/* @__PURE__ */ o("option", {
|
|
263
|
+
value: "percentage",
|
|
264
|
+
children: f("bigconsole.widget.config.table.format.percentage", "Percentage")
|
|
265
|
+
}),
|
|
266
|
+
/* @__PURE__ */ o("option", {
|
|
267
|
+
value: "date",
|
|
268
|
+
children: f("bigconsole.widget.config.table.format.date", "Date")
|
|
269
|
+
}),
|
|
270
|
+
/* @__PURE__ */ o("option", {
|
|
271
|
+
value: "badge",
|
|
272
|
+
children: f("bigconsole.widget.config.table.format.badge", "Badge")
|
|
273
|
+
})
|
|
274
|
+
]
|
|
275
|
+
}), /* @__PURE__ */ s("select", {
|
|
276
|
+
value: e.align || "left",
|
|
277
|
+
onChange: (e) => g(t, "align", e.target.value),
|
|
278
|
+
className: "\n px-2 py-1\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg\n ",
|
|
279
|
+
children: [
|
|
280
|
+
/* @__PURE__ */ o("option", {
|
|
281
|
+
value: "left",
|
|
282
|
+
children: f("bigconsole.widget.config.table.align.left", "Left")
|
|
283
|
+
}),
|
|
284
|
+
/* @__PURE__ */ o("option", {
|
|
285
|
+
value: "center",
|
|
286
|
+
children: f("bigconsole.widget.config.table.align.center", "Center")
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ o("option", {
|
|
289
|
+
value: "right",
|
|
290
|
+
children: f("bigconsole.widget.config.table.align.right", "Right")
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
})]
|
|
294
|
+
}),
|
|
295
|
+
/* @__PURE__ */ s("div", {
|
|
296
|
+
className: "pt-2 border-t border-border-default/60",
|
|
273
297
|
children: [
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
|
|
276
|
-
children:
|
|
298
|
+
/* @__PURE__ */ s("div", {
|
|
299
|
+
className: "flex items-center justify-between mb-1",
|
|
300
|
+
children: [/* @__PURE__ */ o("span", {
|
|
301
|
+
className: "text-xs font-medium text-text-secondary",
|
|
302
|
+
children: f("bigconsole.widget.config.table.conditionalFormatting.title", "Conditional formatting")
|
|
303
|
+
}), /* @__PURE__ */ o("button", {
|
|
304
|
+
type: "button",
|
|
305
|
+
onClick: () => v(t),
|
|
306
|
+
className: "text-xs text-action-primary-bg hover:text-action-primary-bgHover",
|
|
307
|
+
children: f("bigconsole.widget.config.table.conditionalFormatting.addRule", "+ Add rule")
|
|
308
|
+
})]
|
|
277
309
|
}),
|
|
278
|
-
/* @__PURE__ */ o("
|
|
279
|
-
|
|
280
|
-
children: f("bigconsole.widget.config.table.
|
|
310
|
+
(e.conditionalRules?.length ?? 0) === 0 && /* @__PURE__ */ o("p", {
|
|
311
|
+
className: "text-xs text-text-secondary",
|
|
312
|
+
children: f("bigconsole.widget.config.table.conditionalFormatting.noRules", "No rules — cell shows its plain value.")
|
|
281
313
|
}),
|
|
282
|
-
/* @__PURE__ */ o("
|
|
283
|
-
|
|
284
|
-
children:
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
314
|
+
/* @__PURE__ */ o("div", {
|
|
315
|
+
className: "space-y-2",
|
|
316
|
+
children: (e.conditionalRules ?? []).map((e, n) => {
|
|
317
|
+
let r = e.operator === "between" || e.operator === "outside", i = e.style?.bgColor ?? e.style?.textColor ?? "danger";
|
|
318
|
+
return /* @__PURE__ */ s("div", {
|
|
319
|
+
className: "p-2 bg-bg-surface rounded-md border border-border-default space-y-2",
|
|
320
|
+
children: [/* @__PURE__ */ s("div", {
|
|
321
|
+
className: "flex items-center gap-2",
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ o("select", {
|
|
324
|
+
value: e.operator,
|
|
325
|
+
onChange: (e) => y(t, n, { operator: e.target.value }),
|
|
326
|
+
className: `${u} flex-1`,
|
|
327
|
+
children: c.map((e) => /* @__PURE__ */ o("option", {
|
|
328
|
+
value: e.value,
|
|
329
|
+
children: f(e.labelKey, e.labelDefault)
|
|
330
|
+
}, e.value))
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ o("input", {
|
|
333
|
+
type: "text",
|
|
334
|
+
value: e.value ?? "",
|
|
335
|
+
onChange: (e) => y(t, n, { value: e.target.value }),
|
|
336
|
+
placeholder: f("bigconsole.widget.config.table.rule.valuePlaceholder", "value"),
|
|
337
|
+
className: `${u} w-20`
|
|
338
|
+
}),
|
|
339
|
+
r && /* @__PURE__ */ o("input", {
|
|
340
|
+
type: "text",
|
|
341
|
+
value: e.value2 ?? "",
|
|
342
|
+
onChange: (e) => y(t, n, { value2: e.target.value }),
|
|
343
|
+
placeholder: f("bigconsole.widget.config.table.rule.value2Placeholder", "and"),
|
|
344
|
+
className: `${u} w-20`
|
|
345
|
+
}),
|
|
346
|
+
/* @__PURE__ */ o("button", {
|
|
347
|
+
type: "button",
|
|
348
|
+
onClick: () => x(t, n),
|
|
349
|
+
className: "text-status-error-text hover:text-status-error-text/80",
|
|
350
|
+
"aria-label": f("bigconsole.widget.config.table.rule.remove", "Remove rule"),
|
|
351
|
+
children: /* @__PURE__ */ o("svg", {
|
|
352
|
+
className: "w-3.5 h-3.5",
|
|
353
|
+
fill: "none",
|
|
354
|
+
stroke: "currentColor",
|
|
355
|
+
viewBox: "0 0 24 24",
|
|
356
|
+
children: /* @__PURE__ */ o("path", {
|
|
357
|
+
strokeLinecap: "round",
|
|
358
|
+
strokeLinejoin: "round",
|
|
359
|
+
strokeWidth: 2,
|
|
360
|
+
d: "M6 18L18 6M6 6l12 12"
|
|
361
|
+
})
|
|
362
|
+
})
|
|
363
|
+
})
|
|
364
|
+
]
|
|
365
|
+
}), /* @__PURE__ */ s("div", {
|
|
366
|
+
className: "flex items-center gap-2",
|
|
367
|
+
children: [/* @__PURE__ */ o("select", {
|
|
368
|
+
value: i,
|
|
369
|
+
onChange: (e) => b(t, n, e.target.value),
|
|
320
370
|
className: `${u} flex-1`,
|
|
321
|
-
children:
|
|
371
|
+
children: l.map((e) => /* @__PURE__ */ o("option", {
|
|
322
372
|
value: e.value,
|
|
323
373
|
children: f(e.labelKey, e.labelDefault)
|
|
324
374
|
}, e.value))
|
|
325
|
-
}),
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
placeholder: f("bigconsole.widget.config.table.rule.value2Placeholder", "and"),
|
|
338
|
-
className: `${u} w-20`
|
|
339
|
-
}),
|
|
340
|
-
/* @__PURE__ */ o("button", {
|
|
341
|
-
type: "button",
|
|
342
|
-
onClick: () => x(t, n),
|
|
343
|
-
className: "text-status-error-text hover:text-status-error-text/80",
|
|
344
|
-
"aria-label": f("bigconsole.widget.config.table.rule.remove", "Remove rule"),
|
|
345
|
-
children: /* @__PURE__ */ o("svg", {
|
|
346
|
-
className: "w-3.5 h-3.5",
|
|
347
|
-
fill: "none",
|
|
348
|
-
stroke: "currentColor",
|
|
349
|
-
viewBox: "0 0 24 24",
|
|
350
|
-
children: /* @__PURE__ */ o("path", {
|
|
351
|
-
strokeLinecap: "round",
|
|
352
|
-
strokeLinejoin: "round",
|
|
353
|
-
strokeWidth: 2,
|
|
354
|
-
d: "M6 18L18 6M6 6l12 12"
|
|
355
|
-
})
|
|
356
|
-
})
|
|
357
|
-
})
|
|
358
|
-
]
|
|
359
|
-
}), /* @__PURE__ */ s("div", {
|
|
360
|
-
className: "flex items-center gap-2",
|
|
361
|
-
children: [/* @__PURE__ */ o("select", {
|
|
362
|
-
value: i,
|
|
363
|
-
onChange: (e) => b(t, n, e.target.value),
|
|
364
|
-
className: `${u} flex-1`,
|
|
365
|
-
children: l.map((e) => /* @__PURE__ */ o("option", {
|
|
366
|
-
value: e.value,
|
|
367
|
-
children: f(e.labelKey, e.labelDefault)
|
|
368
|
-
}, e.value))
|
|
369
|
-
}), /* @__PURE__ */ s("label", {
|
|
370
|
-
className: "flex items-center gap-1 text-xs text-text-primary",
|
|
371
|
-
children: [/* @__PURE__ */ o("input", {
|
|
372
|
-
type: "checkbox",
|
|
373
|
-
checked: e.style?.bold === !0,
|
|
374
|
-
onChange: (r) => y(t, n, { style: {
|
|
375
|
-
...e.style,
|
|
376
|
-
bold: r.target.checked
|
|
377
|
-
} }),
|
|
378
|
-
className: "w-3.5 h-3.5 text-action-primary-bg bg-bg-surface border-border-default rounded focus:ring-action-primary-bg"
|
|
379
|
-
}), f("bigconsole.widget.config.table.rule.bold", "Bold")]
|
|
375
|
+
}), /* @__PURE__ */ s("label", {
|
|
376
|
+
className: "flex items-center gap-1 text-xs text-text-primary",
|
|
377
|
+
children: [/* @__PURE__ */ o("input", {
|
|
378
|
+
type: "checkbox",
|
|
379
|
+
checked: e.style?.bold === !0,
|
|
380
|
+
onChange: (r) => y(t, n, { style: {
|
|
381
|
+
...e.style,
|
|
382
|
+
bold: r.target.checked
|
|
383
|
+
} }),
|
|
384
|
+
className: "w-3.5 h-3.5 text-action-primary-bg bg-bg-surface border-border-default rounded focus:ring-action-primary-bg"
|
|
385
|
+
}), f("bigconsole.widget.config.table.rule.bold", "Bold")]
|
|
386
|
+
})]
|
|
380
387
|
})]
|
|
381
|
-
})
|
|
382
|
-
}
|
|
388
|
+
}, n);
|
|
389
|
+
})
|
|
383
390
|
})
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
})
|
|
392
|
-
|
|
391
|
+
]
|
|
392
|
+
})
|
|
393
|
+
]
|
|
394
|
+
}, t)), p.length === 0 && /* @__PURE__ */ o("p", {
|
|
395
|
+
className: "text-sm text-text-secondary text-center py-4",
|
|
396
|
+
children: f("bigconsole.widget.config.table.columns.empty", "No columns configured. Columns will be auto-generated from data.")
|
|
397
|
+
})]
|
|
398
|
+
})
|
|
399
|
+
] }),
|
|
393
400
|
/* @__PURE__ */ s("div", {
|
|
394
401
|
role: "group",
|
|
395
402
|
"aria-label": "Display options",
|
|
@@ -6,12 +6,13 @@ import r from "../../../hooks/useWidgetConfigPersist.js";
|
|
|
6
6
|
import "../../../hooks/index.js";
|
|
7
7
|
import { resolveRowClassName as i } from "../utils/conditionalFormat.js";
|
|
8
8
|
import { TableHeader as a } from "./TableHeader.js";
|
|
9
|
-
import { TableCell as
|
|
10
|
-
import { TablePagination as
|
|
11
|
-
import { memo as
|
|
12
|
-
import {
|
|
9
|
+
import { TableCell as ee } from "./TableCell.js";
|
|
10
|
+
import { TablePagination as te } from "./TablePagination.js";
|
|
11
|
+
import { memo as o, useCallback as s, useEffect as ne, useMemo as c, useRef as re, useState as l } from "react";
|
|
12
|
+
import { useI18n as ie } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
13
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
13
14
|
//#region src/bigconsole/components/widgets/table/TableWidget.tsx
|
|
14
|
-
function
|
|
15
|
+
function ae(e, t) {
|
|
15
16
|
return !t.column || !t.direction ? e : [...e].sort((e, n) => {
|
|
16
17
|
let r = e[t.column], i = n[t.column];
|
|
17
18
|
if (r == null && i == null) return 0;
|
|
@@ -21,7 +22,7 @@ function ne(e, t) {
|
|
|
21
22
|
return a = typeof r == "number" && typeof i == "number" ? r - i : String(r).localeCompare(String(i)), t.direction === "asc" ? a : -a;
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function f(e, t, n) {
|
|
25
26
|
if (!t.trim()) return e;
|
|
26
27
|
let r = t.toLowerCase();
|
|
27
28
|
return e.filter((e) => n.some((t) => {
|
|
@@ -29,7 +30,7 @@ function re(e, t, n) {
|
|
|
29
30
|
return n != null && String(n).toLowerCase().includes(r);
|
|
30
31
|
}));
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
+
function oe(e, t, n) {
|
|
33
34
|
switch (t) {
|
|
34
35
|
case "currency": return new Intl.NumberFormat("en-US", {
|
|
35
36
|
style: "currency",
|
|
@@ -40,10 +41,10 @@ function m(e, t, n) {
|
|
|
40
41
|
default: return Number.isInteger(e) ? String(e) : e.toFixed(2);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
|
-
var
|
|
44
|
-
let
|
|
45
|
-
if (Array.isArray(
|
|
46
|
-
if (
|
|
44
|
+
var p = o(function({ widget: o, data: p = [], onRowClick: m, onDrilldown: h }) {
|
|
45
|
+
let { t: g } = ie(), _ = o.config, v = c(() => {
|
|
46
|
+
if (Array.isArray(p)) return p;
|
|
47
|
+
if (p && typeof p == "object") {
|
|
47
48
|
for (let e of [
|
|
48
49
|
"data",
|
|
49
50
|
"items",
|
|
@@ -54,20 +55,20 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
54
55
|
"sales",
|
|
55
56
|
"entries",
|
|
56
57
|
"values"
|
|
57
|
-
]) if (Array.isArray(
|
|
58
|
-
let e = Object.values(
|
|
58
|
+
]) if (Array.isArray(p[e])) return p[e];
|
|
59
|
+
let e = Object.values(p);
|
|
59
60
|
for (let t of e) if (Array.isArray(t)) return t;
|
|
60
|
-
return [
|
|
61
|
+
return [p];
|
|
61
62
|
}
|
|
62
63
|
return [];
|
|
63
|
-
}, [
|
|
64
|
-
column:
|
|
65
|
-
direction:
|
|
66
|
-
}), [w,
|
|
64
|
+
}, [p]), { handleDataClick: y, enabled: b } = n(o.id, _?.crossFilterMappings), { clearAllCrossFilters: x, hasCrossFilters: S } = t(), [C, se] = l({
|
|
65
|
+
column: _?.defaultSortColumn || null,
|
|
66
|
+
direction: _?.defaultSortDirection || null
|
|
67
|
+
}), [w, ce] = l(""), [T, E] = l({
|
|
67
68
|
page: 0,
|
|
68
|
-
pageSize:
|
|
69
|
+
pageSize: _?.pageSize || 10,
|
|
69
70
|
totalItems: 0
|
|
70
|
-
}), D = e(), { persistConfig: O } = r(
|
|
71
|
+
}), D = e(), { persistConfig: O } = r(o), [k, A] = l({}), [j, le] = l(null), M = c(() => _?.columns?.length ? _.columns.map((e) => {
|
|
71
72
|
if (typeof e == "string") return {
|
|
72
73
|
key: e,
|
|
73
74
|
header: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
|
|
@@ -81,11 +82,11 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
81
82
|
width: e.width == null ? void 0 : String(e.width),
|
|
82
83
|
align: e.align
|
|
83
84
|
};
|
|
84
|
-
}) :
|
|
85
|
+
}) : v.length > 0 ? Object.keys(v[0]).map((e) => ({
|
|
85
86
|
key: e,
|
|
86
87
|
header: e.charAt(0).toUpperCase() + e.slice(1).replace(/_/g, " "),
|
|
87
88
|
sortable: !0
|
|
88
|
-
})) : [], [
|
|
89
|
+
})) : [], [_?.columns, v]), N = c(() => {
|
|
89
90
|
let e = M;
|
|
90
91
|
if (j) {
|
|
91
92
|
let t = new Map(M.map((e) => [e.key, e])), n = j.map((e) => t.get(e)).filter((e) => e !== void 0), r = M.filter((e) => !j.includes(e.key));
|
|
@@ -99,9 +100,9 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
99
100
|
M,
|
|
100
101
|
j,
|
|
101
102
|
k
|
|
102
|
-
]), P =
|
|
103
|
+
]), P = s((e, t) => {
|
|
103
104
|
let n = /* @__PURE__ */ new Map();
|
|
104
|
-
|
|
105
|
+
_?.columns?.forEach((e) => {
|
|
105
106
|
let t = e.key || e.field;
|
|
106
107
|
t && n.set(t, e);
|
|
107
108
|
});
|
|
@@ -117,14 +118,14 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
117
118
|
O({ columns: i });
|
|
118
119
|
}, [
|
|
119
120
|
M,
|
|
120
|
-
|
|
121
|
+
_?.columns,
|
|
121
122
|
O
|
|
122
|
-
]),
|
|
123
|
+
]), F = s((e, t) => {
|
|
123
124
|
A((n) => ({
|
|
124
125
|
...n,
|
|
125
126
|
[e]: t
|
|
126
127
|
}));
|
|
127
|
-
}, []),
|
|
128
|
+
}, []), ue = s((e, t) => {
|
|
128
129
|
let n = {
|
|
129
130
|
...k,
|
|
130
131
|
[e]: t
|
|
@@ -137,54 +138,54 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
137
138
|
j,
|
|
138
139
|
M,
|
|
139
140
|
P
|
|
140
|
-
]),
|
|
141
|
+
]), de = s((e, t) => {
|
|
141
142
|
let n = j ?? M.map((e) => e.key), r = n.indexOf(e);
|
|
142
143
|
if (r < 0 || e === t) return;
|
|
143
144
|
let i = [...n];
|
|
144
145
|
i.splice(r, 1);
|
|
145
146
|
let a = i.indexOf(t);
|
|
146
|
-
a < 0 || (i.splice(a, 0, e),
|
|
147
|
+
a < 0 || (i.splice(a, 0, e), le(i), P(i, k));
|
|
147
148
|
}, [
|
|
148
149
|
j,
|
|
149
150
|
M,
|
|
150
151
|
k,
|
|
151
152
|
P
|
|
152
|
-
]), I =
|
|
153
|
+
]), I = c(() => {
|
|
153
154
|
let e = {};
|
|
154
|
-
return
|
|
155
|
+
return _?.columns?.forEach((t) => {
|
|
155
156
|
t.format && (t.key || t.field) && (e[t.key || t.field || ""] = {
|
|
156
157
|
type: t.format,
|
|
157
158
|
...t.linkPattern ? { linkPattern: t.linkPattern } : {}
|
|
158
159
|
});
|
|
159
160
|
}), e;
|
|
160
|
-
}, [
|
|
161
|
+
}, [_?.columns]), L = c(() => {
|
|
161
162
|
let e = {};
|
|
162
|
-
return
|
|
163
|
+
return _?.columns?.forEach((t) => {
|
|
163
164
|
let n = t.key || t.field;
|
|
164
165
|
n && t.cellChart && (e[n] = t.cellChart);
|
|
165
166
|
}), e;
|
|
166
|
-
}, [
|
|
167
|
+
}, [_?.columns]), R = _?.conditionalRules, z = _?.rowRules, B = c(() => {
|
|
167
168
|
let e = {};
|
|
168
|
-
return
|
|
169
|
+
return _?.columns?.forEach((t) => {
|
|
169
170
|
let n = t.key || t.field;
|
|
170
171
|
n && t.conditionalRules?.length && (e[n] = t.conditionalRules);
|
|
171
172
|
}), e;
|
|
172
|
-
}, [
|
|
173
|
+
}, [_?.columns]), V = c(() => {
|
|
173
174
|
let e = {};
|
|
174
|
-
return
|
|
175
|
+
return _?.columns?.forEach((t) => {
|
|
175
176
|
let n = t.key || t.field;
|
|
176
177
|
n && t.total && t.total !== "none" && (e[n] = t.total);
|
|
177
178
|
}), e;
|
|
178
|
-
}, [
|
|
179
|
-
let e =
|
|
180
|
-
return
|
|
179
|
+
}, [_?.columns]), H = _?.showTotals === !0 || Object.keys(V).length > 0, U = c(() => {
|
|
180
|
+
let e = v;
|
|
181
|
+
return _?.showSearch !== !1 && (e = f(e, w, N)), e = ae(e, C), e;
|
|
181
182
|
}, [
|
|
182
|
-
|
|
183
|
+
v,
|
|
183
184
|
w,
|
|
184
|
-
|
|
185
|
+
C,
|
|
185
186
|
N,
|
|
186
|
-
|
|
187
|
-
]),
|
|
187
|
+
_?.showSearch
|
|
188
|
+
]), fe = c(() => {
|
|
188
189
|
let e = {};
|
|
189
190
|
for (let t of N) {
|
|
190
191
|
let n = 0;
|
|
@@ -195,7 +196,7 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
195
196
|
e[t.key] = n;
|
|
196
197
|
}
|
|
197
198
|
return e;
|
|
198
|
-
}, [N, U]),
|
|
199
|
+
}, [N, U]), pe = c(() => {
|
|
199
200
|
if (!H) return {};
|
|
200
201
|
let e = {};
|
|
201
202
|
for (let t of N) {
|
|
@@ -214,22 +215,22 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
214
215
|
V,
|
|
215
216
|
U
|
|
216
217
|
]);
|
|
217
|
-
|
|
218
|
+
c(() => {
|
|
218
219
|
E((e) => ({
|
|
219
220
|
...e,
|
|
220
221
|
totalItems: U.length
|
|
221
222
|
}));
|
|
222
223
|
}, [U.length]);
|
|
223
|
-
let
|
|
224
|
-
if (
|
|
224
|
+
let me = c(() => {
|
|
225
|
+
if (_?.showPagination === !1) return U;
|
|
225
226
|
let e = T.page * T.pageSize;
|
|
226
227
|
return U.slice(e, e + T.pageSize);
|
|
227
228
|
}, [
|
|
228
229
|
U,
|
|
229
230
|
T,
|
|
230
|
-
|
|
231
|
-
]), W =
|
|
232
|
-
|
|
231
|
+
_?.showPagination
|
|
232
|
+
]), W = _?.virtualized === !0, G = _?.rowHeight && _.rowHeight > 0 ? _.rowHeight : 44, K = re(null), [q, he] = l(0), [J, Y] = l(0);
|
|
233
|
+
ne(() => {
|
|
233
234
|
if (!W) return;
|
|
234
235
|
let e = K.current;
|
|
235
236
|
if (!e) return;
|
|
@@ -237,7 +238,7 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
237
238
|
let t = typeof ResizeObserver < "u" ? new ResizeObserver(() => Y(e.clientHeight)) : void 0;
|
|
238
239
|
return t?.observe(e), () => t?.disconnect();
|
|
239
240
|
}, [W]);
|
|
240
|
-
let X =
|
|
241
|
+
let X = c(() => {
|
|
241
242
|
if (!W) return null;
|
|
242
243
|
let e = U.length, t = J > 0 ? Math.ceil(J / G) : 20, n = Math.max(0, Math.floor(q / G) - 6), r = Math.min(e, n + t + 12);
|
|
243
244
|
return {
|
|
@@ -252,7 +253,7 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
252
253
|
J,
|
|
253
254
|
q,
|
|
254
255
|
G
|
|
255
|
-
]),
|
|
256
|
+
]), ge = W && X ? X.rows : me, _e = W && X ? X.startIndex : 0, Z = _?.frozenColumns && _.frozenColumns > 0 ? _.frozenColumns : 0, { displayColumns: Q, frozenLefts: $ } = c(() => {
|
|
256
257
|
if (Z <= 0) return {
|
|
257
258
|
displayColumns: N,
|
|
258
259
|
frozenLefts: {}
|
|
@@ -271,8 +272,8 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
271
272
|
}),
|
|
272
273
|
frozenLefts: e
|
|
273
274
|
};
|
|
274
|
-
}, [N, Z]),
|
|
275
|
-
|
|
275
|
+
}, [N, Z]), ve = s((e) => {
|
|
276
|
+
se((t) => {
|
|
276
277
|
if (t.column !== e) return {
|
|
277
278
|
column: e,
|
|
278
279
|
direction: "asc"
|
|
@@ -283,63 +284,63 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
283
284
|
direction: n
|
|
284
285
|
};
|
|
285
286
|
});
|
|
286
|
-
}, []),
|
|
287
|
+
}, []), ye = s((e) => {
|
|
287
288
|
E((t) => ({
|
|
288
289
|
...t,
|
|
289
290
|
page: e
|
|
290
291
|
}));
|
|
291
|
-
}, []),
|
|
292
|
+
}, []), be = s((e) => {
|
|
292
293
|
E((t) => ({
|
|
293
294
|
...t,
|
|
294
295
|
pageSize: e,
|
|
295
296
|
page: 0
|
|
296
297
|
}));
|
|
297
|
-
}, []),
|
|
298
|
-
let n =
|
|
299
|
-
if (
|
|
298
|
+
}, []), xe = s((e, t) => {
|
|
299
|
+
let n = _?.crossFilterMappings?.length || _?.enableCrossFilter;
|
|
300
|
+
if (b && n) {
|
|
300
301
|
let t = N[0]?.key, n = t ? String(e[t]) : void 0;
|
|
301
|
-
|
|
302
|
+
y(e, n);
|
|
302
303
|
}
|
|
303
|
-
|
|
304
|
+
h ? h(e) : m && o.drilldowns?.length && m(e, t);
|
|
304
305
|
}, [
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
x,
|
|
306
|
+
m,
|
|
307
|
+
h,
|
|
308
|
+
o.drilldowns,
|
|
309
309
|
b,
|
|
310
|
+
y,
|
|
310
311
|
N,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
]),
|
|
312
|
+
_?.crossFilterMappings,
|
|
313
|
+
_?.enableCrossFilter
|
|
314
|
+
]), Se = s(() => {
|
|
314
315
|
let e = [N.map((e) => e.header).join(","), ...U.map((e) => N.map((t) => {
|
|
315
316
|
let n = e[t.key];
|
|
316
317
|
if (n == null) return "";
|
|
317
318
|
let r = String(n);
|
|
318
319
|
return r.includes(",") || r.includes("\"") ? `"${r.replace(/"/g, "\"\"")}"` : r;
|
|
319
320
|
}).join(","))].join("\n"), t = new Blob([e], { type: "text/csv" }), n = URL.createObjectURL(t), r = document.createElement("a");
|
|
320
|
-
r.href = n, r.download = `${
|
|
321
|
+
r.href = n, r.download = `${o.title || "table"}-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`, r.click(), URL.revokeObjectURL(n);
|
|
321
322
|
}, [
|
|
322
323
|
N,
|
|
323
324
|
U,
|
|
324
|
-
|
|
325
|
-
]),
|
|
326
|
-
return /* @__PURE__ */
|
|
325
|
+
o.title
|
|
326
|
+
]), Ce = _?.crossFilterMappings?.length || _?.enableCrossFilter, we = !!(h || m && o.drilldowns?.length || Ce);
|
|
327
|
+
return /* @__PURE__ */ d("div", {
|
|
327
328
|
className: "flex flex-col h-full",
|
|
328
329
|
children: [
|
|
329
|
-
|
|
330
|
+
S && /* @__PURE__ */ u("div", {
|
|
330
331
|
className: "flex items-center gap-2 px-3 py-2 border-b border-border-default",
|
|
331
|
-
children: /* @__PURE__ */
|
|
332
|
+
children: /* @__PURE__ */ d("button", {
|
|
332
333
|
type: "button",
|
|
333
334
|
onClick: (e) => {
|
|
334
|
-
e.stopPropagation(),
|
|
335
|
+
e.stopPropagation(), x();
|
|
335
336
|
},
|
|
336
337
|
className: "\n inline-flex items-center gap-1.5\n px-2.5 py-1 rounded-md\n text-xs font-medium\n bg-action-primary-bg/10 text-action-primary-text\n hover:bg-action-primary-bg/20\n transition-colors\n ",
|
|
337
|
-
children: [/* @__PURE__ */
|
|
338
|
+
children: [/* @__PURE__ */ u("svg", {
|
|
338
339
|
className: "w-3.5 h-3.5",
|
|
339
340
|
fill: "none",
|
|
340
341
|
stroke: "currentColor",
|
|
341
342
|
viewBox: "0 0 24 24",
|
|
342
|
-
children: /* @__PURE__ */
|
|
343
|
+
children: /* @__PURE__ */ u("path", {
|
|
343
344
|
strokeLinecap: "round",
|
|
344
345
|
strokeLinejoin: "round",
|
|
345
346
|
strokeWidth: 2,
|
|
@@ -348,38 +349,39 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
348
349
|
}), "Clear Filter"]
|
|
349
350
|
})
|
|
350
351
|
}),
|
|
351
|
-
(
|
|
352
|
+
(_?.showSearch !== !1 || _?.showExport !== !1) && /* @__PURE__ */ d("div", {
|
|
352
353
|
className: "flex items-center justify-between p-3 border-b border-border-default",
|
|
353
|
-
children: [
|
|
354
|
+
children: [_?.showSearch !== !1 && /* @__PURE__ */ d("div", {
|
|
354
355
|
className: "relative flex items-center",
|
|
355
|
-
children: [/* @__PURE__ */
|
|
356
|
+
children: [/* @__PURE__ */ u("svg", {
|
|
356
357
|
className: "absolute left-3 w-4 h-4 text-text-secondary pointer-events-none",
|
|
357
358
|
fill: "none",
|
|
358
359
|
stroke: "currentColor",
|
|
359
360
|
viewBox: "0 0 24 24",
|
|
360
|
-
children: /* @__PURE__ */
|
|
361
|
+
children: /* @__PURE__ */ u("path", {
|
|
361
362
|
strokeLinecap: "round",
|
|
362
363
|
strokeLinejoin: "round",
|
|
363
364
|
strokeWidth: 2,
|
|
364
365
|
d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
|
|
365
366
|
})
|
|
366
|
-
}), /* @__PURE__ */
|
|
367
|
+
}), /* @__PURE__ */ u("input", {
|
|
367
368
|
type: "text",
|
|
368
|
-
placeholder: "
|
|
369
|
+
placeholder: g("bigconsole.widget.table.search", "Search…"),
|
|
370
|
+
"aria-label": g("bigconsole.widget.table.search", "Search…"),
|
|
369
371
|
value: w,
|
|
370
|
-
onChange: (e) =>
|
|
372
|
+
onChange: (e) => ce(e.target.value),
|
|
371
373
|
className: "\n pl-10 pr-4 py-2\n text-sm text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n focus:outline-none focus:ring-2 focus:ring-action-primary-bg focus:border-action-primary-bg\n w-48 sm:w-64\n placeholder:text-text-muted\n "
|
|
372
374
|
})]
|
|
373
|
-
}),
|
|
375
|
+
}), _?.showExport !== !1 && /* @__PURE__ */ d("button", {
|
|
374
376
|
type: "button",
|
|
375
|
-
onClick:
|
|
377
|
+
onClick: Se,
|
|
376
378
|
className: "\n inline-flex items-center gap-2\n px-3 py-2\n text-sm font-medium\n text-text-primary\n bg-bg-surface\n border border-border-default\n rounded-md\n hover:bg-bg-sunken\n transition-colors\n ",
|
|
377
|
-
children: [/* @__PURE__ */
|
|
379
|
+
children: [/* @__PURE__ */ u("svg", {
|
|
378
380
|
className: "w-4 h-4",
|
|
379
381
|
fill: "none",
|
|
380
382
|
stroke: "currentColor",
|
|
381
383
|
viewBox: "0 0 24 24",
|
|
382
|
-
children: /* @__PURE__ */
|
|
384
|
+
children: /* @__PURE__ */ u("path", {
|
|
383
385
|
strokeLinecap: "round",
|
|
384
386
|
strokeLinejoin: "round",
|
|
385
387
|
strokeWidth: 2,
|
|
@@ -388,28 +390,28 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
388
390
|
}), "Export CSV"]
|
|
389
391
|
})]
|
|
390
392
|
}),
|
|
391
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ d("div", {
|
|
392
394
|
ref: K,
|
|
393
395
|
className: "flex-1 overflow-auto",
|
|
394
|
-
onScroll: W ? (e) =>
|
|
395
|
-
children: [/* @__PURE__ */
|
|
396
|
+
onScroll: W ? (e) => he(e.target.scrollTop) : void 0,
|
|
397
|
+
children: [/* @__PURE__ */ d("table", {
|
|
396
398
|
className: "w-full",
|
|
397
399
|
children: [
|
|
398
|
-
/* @__PURE__ */
|
|
400
|
+
/* @__PURE__ */ u(a, {
|
|
399
401
|
columns: Q,
|
|
400
|
-
sortState:
|
|
401
|
-
onSort:
|
|
402
|
+
sortState: C,
|
|
403
|
+
onSort: ve,
|
|
402
404
|
frozenLefts: Z > 0 ? $ : void 0,
|
|
403
405
|
editable: D,
|
|
404
|
-
onColumnResize: D ?
|
|
405
|
-
onColumnResizeEnd: D ?
|
|
406
|
-
onColumnReorder: D ?
|
|
406
|
+
onColumnResize: D ? F : void 0,
|
|
407
|
+
onColumnResizeEnd: D ? ue : void 0,
|
|
408
|
+
onColumnReorder: D ? de : void 0
|
|
407
409
|
}),
|
|
408
|
-
/* @__PURE__ */
|
|
409
|
-
W && X && X.topSpacer > 0 && /* @__PURE__ */
|
|
410
|
+
/* @__PURE__ */ d("tbody", { children: [
|
|
411
|
+
W && X && X.topSpacer > 0 && /* @__PURE__ */ u("tr", {
|
|
410
412
|
"aria-hidden": "true",
|
|
411
413
|
style: { height: X.topSpacer },
|
|
412
|
-
children: /* @__PURE__ */
|
|
414
|
+
children: /* @__PURE__ */ u("td", {
|
|
413
415
|
colSpan: Q.length,
|
|
414
416
|
style: {
|
|
415
417
|
padding: 0,
|
|
@@ -417,32 +419,32 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
417
419
|
}
|
|
418
420
|
})
|
|
419
421
|
}),
|
|
420
|
-
|
|
421
|
-
let n =
|
|
422
|
-
return /* @__PURE__ */
|
|
422
|
+
ge.map((e, t) => {
|
|
423
|
+
let n = _e + t;
|
|
424
|
+
return /* @__PURE__ */ u("tr", {
|
|
423
425
|
className: `
|
|
424
|
-
${
|
|
426
|
+
${we ? "cursor-pointer hover:bg-bg-sunken/50" : ""}
|
|
425
427
|
${n % 2 == 0 ? "bg-bg-surface" : "bg-bg-sunken/30"}
|
|
426
428
|
${i(e, z)}
|
|
427
429
|
`,
|
|
428
430
|
style: W ? { height: G } : void 0,
|
|
429
|
-
onClick: () =>
|
|
430
|
-
children: Q.map((t) => /* @__PURE__ */
|
|
431
|
+
onClick: () => xe(e, n),
|
|
432
|
+
children: Q.map((t) => /* @__PURE__ */ u(ee, {
|
|
431
433
|
value: e[t.key],
|
|
432
434
|
column: t,
|
|
433
435
|
format: I[t.key],
|
|
434
436
|
rowData: e,
|
|
435
437
|
conditionalRules: B[t.key] ?? R,
|
|
436
|
-
dataBarMax:
|
|
438
|
+
dataBarMax: fe[t.key],
|
|
437
439
|
stickyLeft: $[t.key],
|
|
438
440
|
cellChart: L[t.key]
|
|
439
441
|
}, t.key))
|
|
440
442
|
}, n);
|
|
441
443
|
}),
|
|
442
|
-
W && X && X.bottomSpacer > 0 && /* @__PURE__ */
|
|
444
|
+
W && X && X.bottomSpacer > 0 && /* @__PURE__ */ u("tr", {
|
|
443
445
|
"aria-hidden": "true",
|
|
444
446
|
style: { height: X.bottomSpacer },
|
|
445
|
-
children: /* @__PURE__ */
|
|
447
|
+
children: /* @__PURE__ */ u("td", {
|
|
446
448
|
colSpan: Q.length,
|
|
447
449
|
style: {
|
|
448
450
|
padding: 0,
|
|
@@ -451,11 +453,11 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
451
453
|
})
|
|
452
454
|
})
|
|
453
455
|
] }),
|
|
454
|
-
H && U.length > 0 && /* @__PURE__ */
|
|
456
|
+
H && U.length > 0 && /* @__PURE__ */ u("tfoot", { children: /* @__PURE__ */ u("tr", {
|
|
455
457
|
className: "bg-bg-sunken/50 font-semibold border-t-2 border-border-default",
|
|
456
458
|
children: Q.map((e, t) => {
|
|
457
|
-
let n =
|
|
458
|
-
return /* @__PURE__ */
|
|
459
|
+
let n = pe[e.key], r = I[e.key], i = $[e.key];
|
|
460
|
+
return /* @__PURE__ */ u("td", {
|
|
459
461
|
className: `
|
|
460
462
|
px-4 py-3 text-sm text-text-primary
|
|
461
463
|
${e.align === "center" ? "text-center" : ""}
|
|
@@ -463,26 +465,26 @@ var h = c(function({ widget: c, data: h = [], onRowClick: g, onDrilldown: _ }) {
|
|
|
463
465
|
${i == null ? "" : "sticky z-10 bg-bg-sunken"}
|
|
464
466
|
`,
|
|
465
467
|
style: i == null ? void 0 : { left: i },
|
|
466
|
-
children: n == null ? t === 0 ? "Total" : "" :
|
|
468
|
+
children: n == null ? t === 0 ? "Total" : "" : oe(n, r?.type, r?.currency)
|
|
467
469
|
}, e.key);
|
|
468
470
|
})
|
|
469
471
|
}) })
|
|
470
472
|
]
|
|
471
|
-
}), U.length === 0 && /* @__PURE__ */
|
|
473
|
+
}), U.length === 0 && /* @__PURE__ */ u("div", {
|
|
472
474
|
className: "flex items-center justify-center py-12 text-text-secondary",
|
|
473
475
|
children: w ? "No matching records found" : "No data available"
|
|
474
476
|
})]
|
|
475
477
|
}),
|
|
476
|
-
!W &&
|
|
478
|
+
!W && _?.showPagination !== !1 && U.length > 0 && /* @__PURE__ */ u(te, {
|
|
477
479
|
pagination: {
|
|
478
480
|
...T,
|
|
479
481
|
totalItems: U.length
|
|
480
482
|
},
|
|
481
|
-
onPageChange:
|
|
482
|
-
onPageSizeChange:
|
|
483
|
+
onPageChange: ye,
|
|
484
|
+
onPageSizeChange: be
|
|
483
485
|
})
|
|
484
486
|
]
|
|
485
487
|
});
|
|
486
488
|
});
|
|
487
489
|
//#endregion
|
|
488
|
-
export {
|
|
490
|
+
export { p as TableWidget, p as default };
|