@burdenoff/microfe-bigconsole 2026.615.1 → 2026.615.2
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/WidgetWrapper.js +183 -183
- package/dist/bigconsole/components/widgets/WidgetWrapper.js.map +1 -1
- package/dist/bigconsole/components/widgets/pivot-table/PivotTableWidget.js +275 -114
- package/dist/bigconsole/components/widgets/pivot-table/PivotTableWidget.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { useIsEditMode as e } from "../../../store/dashboardStore.js";
|
|
2
|
+
import "../../../store/index.js";
|
|
3
|
+
import t from "../../../hooks/useWidgetOperations.js";
|
|
4
|
+
import "../../../hooks/index.js";
|
|
5
|
+
import { memo as n, useCallback as r, useMemo as i, useState as a } from "react";
|
|
6
|
+
import { ChevronDown as o, ChevronRight as s, GripVertical as c, Settings as l } from "lucide-react";
|
|
7
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
4
8
|
//#region src/bigconsole/components/widgets/pivot-table/PivotTableWidget.tsx
|
|
5
|
-
var
|
|
9
|
+
var f = [
|
|
10
|
+
"sum",
|
|
11
|
+
"count",
|
|
12
|
+
"average",
|
|
13
|
+
"min",
|
|
14
|
+
"max"
|
|
15
|
+
], p = {
|
|
6
16
|
sum: (e) => e.reduce((e, t) => e + t, 0),
|
|
7
17
|
count: (e) => e.length,
|
|
8
18
|
average: (e) => e.length ? e.reduce((e, t) => e + t, 0) / e.length : 0,
|
|
9
19
|
min: (e) => e.length ? Math.min(...e) : 0,
|
|
10
20
|
max: (e) => e.length ? Math.max(...e) : 0
|
|
11
21
|
};
|
|
12
|
-
function
|
|
22
|
+
function m(e, t, n, r = 0) {
|
|
13
23
|
let i = {
|
|
14
24
|
key: "root",
|
|
15
25
|
values: {},
|
|
@@ -20,7 +30,7 @@ function u(e, t, n, r = 0) {
|
|
|
20
30
|
if (t.length === 0) {
|
|
21
31
|
for (let t of n) {
|
|
22
32
|
let n = e.map((e) => Number(e[t.field]) || 0).filter((e) => !isNaN(e));
|
|
23
|
-
i.values[t.field] =
|
|
33
|
+
i.values[t.field] = p[t.aggregation](n);
|
|
24
34
|
}
|
|
25
35
|
return i;
|
|
26
36
|
}
|
|
@@ -30,22 +40,22 @@ function u(e, t, n, r = 0) {
|
|
|
30
40
|
s.has(e) || s.set(e, []), s.get(e).push(t);
|
|
31
41
|
}
|
|
32
42
|
for (let [e, t] of s) {
|
|
33
|
-
let a =
|
|
43
|
+
let a = m(t, o, n, r + 1);
|
|
34
44
|
a.key = e, i.children.set(e, a);
|
|
35
45
|
}
|
|
36
46
|
for (let t of n) {
|
|
37
47
|
let n = e.map((e) => Number(e[t.field]) || 0).filter((e) => !isNaN(e));
|
|
38
|
-
i.values[t.field] =
|
|
48
|
+
i.values[t.field] = p[t.aggregation](n);
|
|
39
49
|
}
|
|
40
50
|
return i;
|
|
41
51
|
}
|
|
42
|
-
function
|
|
52
|
+
function h(e, t) {
|
|
43
53
|
if (t.length === 0) return ["Total"];
|
|
44
54
|
let n = t[0], r = /* @__PURE__ */ new Set();
|
|
45
55
|
for (let t of e) r.add(String(t[n] ?? "Unknown"));
|
|
46
56
|
return Array.from(r).sort();
|
|
47
57
|
}
|
|
48
|
-
function
|
|
58
|
+
function g(e, t, n, r) {
|
|
49
59
|
let i = e;
|
|
50
60
|
for (let [e, t] of Object.entries(r)) i = i.filter((n) => String(n[e]) === t);
|
|
51
61
|
let a = /* @__PURE__ */ new Map();
|
|
@@ -53,24 +63,24 @@ function f(e, t, n, r) {
|
|
|
53
63
|
let e = {};
|
|
54
64
|
for (let t of n) {
|
|
55
65
|
let n = i.map((e) => Number(e[t.field]) || 0).filter((e) => !isNaN(e));
|
|
56
|
-
e[t.field] =
|
|
66
|
+
e[t.field] = p[t.aggregation](n);
|
|
57
67
|
}
|
|
58
68
|
return a.set("Total", e), a;
|
|
59
69
|
}
|
|
60
|
-
let o = t[0], s =
|
|
70
|
+
let o = t[0], s = h(e, t);
|
|
61
71
|
for (let e of s) {
|
|
62
72
|
let t = i.filter((t) => String(t[o]) === e), r = {};
|
|
63
73
|
for (let e of n) {
|
|
64
74
|
let n = t.map((t) => Number(t[e.field]) || 0).filter((e) => !isNaN(e));
|
|
65
|
-
r[e.field] =
|
|
75
|
+
r[e.field] = p[e.aggregation](n);
|
|
66
76
|
}
|
|
67
77
|
a.set(e, r);
|
|
68
78
|
}
|
|
69
79
|
return a;
|
|
70
80
|
}
|
|
71
|
-
var
|
|
72
|
-
let
|
|
73
|
-
let
|
|
81
|
+
var _ = n(function({ widget: n, data: c = [], onDrilldown: f }) {
|
|
82
|
+
let p = i(() => Array.isArray(c) ? c : [], [c]), _ = i(() => {
|
|
83
|
+
let e = {
|
|
74
84
|
rows: [],
|
|
75
85
|
columns: [],
|
|
76
86
|
values: [],
|
|
@@ -81,201 +91,352 @@ var p = e(function({ widget: e, data: l = [], onDrilldown: p }) {
|
|
|
81
91
|
numberFormat: "number",
|
|
82
92
|
decimalPlaces: 0
|
|
83
93
|
};
|
|
84
|
-
return
|
|
85
|
-
...
|
|
86
|
-
...
|
|
87
|
-
} :
|
|
88
|
-
}, [
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
return n.config ? {
|
|
95
|
+
...e,
|
|
96
|
+
...n.config
|
|
97
|
+
} : e;
|
|
98
|
+
}, [n.config]), v = e(), { updateWidget: b } = t(void 0, void 0, { skipFetch: !0 }), x = JSON.stringify({
|
|
99
|
+
rows: _.rows,
|
|
100
|
+
columns: _.columns,
|
|
101
|
+
values: _.values
|
|
102
|
+
}), [S, C] = a({
|
|
103
|
+
rows: _.rows,
|
|
104
|
+
columns: _.columns,
|
|
105
|
+
values: _.values
|
|
106
|
+
}), [w, T] = a(x);
|
|
107
|
+
x !== w && (T(x), C({
|
|
108
|
+
rows: _.rows,
|
|
109
|
+
columns: _.columns,
|
|
110
|
+
values: _.values
|
|
111
|
+
}));
|
|
112
|
+
let { rows: E, columns: D, values: O } = S, k = r((e) => {
|
|
113
|
+
v && b({
|
|
114
|
+
id: n.id,
|
|
115
|
+
config: {
|
|
116
|
+
...n.config,
|
|
117
|
+
rows: e.rows,
|
|
118
|
+
columns: e.columns,
|
|
119
|
+
values: e.values
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}, [
|
|
123
|
+
v,
|
|
124
|
+
b,
|
|
125
|
+
n.id,
|
|
126
|
+
n.config
|
|
127
|
+
]), A = r((e) => {
|
|
128
|
+
C(e), k(e);
|
|
129
|
+
}, [k]), [j, M] = a(new Set(["root"])), N = i(() => m(p, E, O), [
|
|
130
|
+
p,
|
|
131
|
+
E,
|
|
132
|
+
O
|
|
133
|
+
]), P = i(() => h(p, D), [p, D]), F = i(() => _.showColumnTotals ? g(p, D, O, {}) : null, [
|
|
134
|
+
_.showColumnTotals,
|
|
135
|
+
p,
|
|
136
|
+
D,
|
|
137
|
+
O
|
|
138
|
+
]), I = i(() => p.length > 0 ? Object.keys(p[0]) : [], [p]), L = i(() => {
|
|
139
|
+
let e = new Set([
|
|
140
|
+
...E,
|
|
141
|
+
...D,
|
|
142
|
+
...O.map((e) => e.field)
|
|
143
|
+
]);
|
|
144
|
+
return I.filter((t) => !e.has(t));
|
|
145
|
+
}, [
|
|
146
|
+
I,
|
|
147
|
+
E,
|
|
148
|
+
D,
|
|
149
|
+
O
|
|
150
|
+
]), R = r((e, t, n) => {
|
|
151
|
+
if (t === n) return;
|
|
152
|
+
let r = {
|
|
153
|
+
rows: t === "rows" ? E.filter((t) => t !== e) : [...E],
|
|
154
|
+
columns: t === "columns" ? D.filter((t) => t !== e) : [...D],
|
|
155
|
+
values: t === "values" ? O.filter((t) => t.field !== e) : [...O]
|
|
156
|
+
};
|
|
157
|
+
n === "rows" && !r.rows.includes(e) ? r.rows.push(e) : n === "columns" && !r.columns.includes(e) ? r.columns.push(e) : n === "values" && !r.values.some((t) => t.field === e) && r.values.push({
|
|
158
|
+
field: e,
|
|
159
|
+
aggregation: "sum"
|
|
160
|
+
}), A(r);
|
|
161
|
+
}, [
|
|
162
|
+
E,
|
|
163
|
+
D,
|
|
164
|
+
O,
|
|
165
|
+
A
|
|
166
|
+
]), z = r((e, t) => {
|
|
167
|
+
A({
|
|
168
|
+
rows: [...E],
|
|
169
|
+
columns: [...D],
|
|
170
|
+
values: O.map((n) => n.field === e ? {
|
|
171
|
+
...n,
|
|
172
|
+
aggregation: t
|
|
173
|
+
} : n)
|
|
174
|
+
});
|
|
175
|
+
}, [
|
|
176
|
+
E,
|
|
177
|
+
D,
|
|
178
|
+
O,
|
|
179
|
+
A
|
|
180
|
+
]), B = r((e) => {
|
|
93
181
|
if (isNaN(e)) return "-";
|
|
94
|
-
switch (
|
|
182
|
+
switch (_.numberFormat) {
|
|
95
183
|
case "currency": return new Intl.NumberFormat("en-US", {
|
|
96
184
|
style: "currency",
|
|
97
185
|
currency: "USD",
|
|
98
|
-
minimumFractionDigits:
|
|
99
|
-
maximumFractionDigits:
|
|
186
|
+
minimumFractionDigits: _.decimalPlaces,
|
|
187
|
+
maximumFractionDigits: _.decimalPlaces
|
|
100
188
|
}).format(e);
|
|
101
189
|
case "percentage": return new Intl.NumberFormat("en-US", {
|
|
102
190
|
style: "percent",
|
|
103
|
-
minimumFractionDigits:
|
|
104
|
-
maximumFractionDigits:
|
|
191
|
+
minimumFractionDigits: _.decimalPlaces,
|
|
192
|
+
maximumFractionDigits: _.decimalPlaces
|
|
105
193
|
}).format(e / 100);
|
|
106
194
|
default: return new Intl.NumberFormat("en-US", {
|
|
107
|
-
minimumFractionDigits:
|
|
108
|
-
maximumFractionDigits:
|
|
195
|
+
minimumFractionDigits: _.decimalPlaces,
|
|
196
|
+
maximumFractionDigits: _.decimalPlaces
|
|
109
197
|
}).format(e);
|
|
110
198
|
}
|
|
111
|
-
}, [
|
|
112
|
-
|
|
199
|
+
}, [_.numberFormat, _.decimalPlaces]), V = r((e) => {
|
|
200
|
+
M((t) => {
|
|
113
201
|
let n = new Set(t);
|
|
114
202
|
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
115
203
|
});
|
|
116
|
-
}, []),
|
|
117
|
-
|
|
204
|
+
}, []), H = r((e, t) => {
|
|
205
|
+
f && f({
|
|
118
206
|
rowFilter: e,
|
|
119
207
|
columnValue: t,
|
|
120
208
|
type: "pivot_cell_click"
|
|
121
209
|
});
|
|
122
|
-
}, [
|
|
123
|
-
let
|
|
210
|
+
}, [f]), U = r((e, t, n, r) => {
|
|
211
|
+
let i = [], a = e.children.size > 0, c = j.has(n), l = E[r - 1];
|
|
124
212
|
if (r > 0) {
|
|
125
|
-
let
|
|
126
|
-
|
|
213
|
+
let l = g(p, D, O, t);
|
|
214
|
+
i.push(/* @__PURE__ */ d("tr", {
|
|
127
215
|
className: "hover:bg-bg-muted/50 transition-colors",
|
|
128
216
|
children: [
|
|
129
|
-
/* @__PURE__ */
|
|
217
|
+
/* @__PURE__ */ u("td", {
|
|
130
218
|
className: "sticky left-0 bg-bg-surface border-r border-border-default px-3 py-2 font-medium text-sm",
|
|
131
219
|
style: { paddingLeft: `${r * 16 + 8}px` },
|
|
132
|
-
children: /* @__PURE__ */
|
|
220
|
+
children: /* @__PURE__ */ d("div", {
|
|
133
221
|
className: "flex items-center gap-1",
|
|
134
222
|
children: [
|
|
135
|
-
|
|
223
|
+
_.expandable && a && /* @__PURE__ */ u("button", {
|
|
136
224
|
type: "button",
|
|
137
|
-
onClick: () =>
|
|
225
|
+
onClick: () => V(n),
|
|
138
226
|
className: "p-0.5 hover:bg-bg-muted rounded",
|
|
139
|
-
children:
|
|
227
|
+
children: u(c ? o : s, { className: "w-4 h-4 text-text-secondary" })
|
|
140
228
|
}),
|
|
141
|
-
!
|
|
142
|
-
/* @__PURE__ */
|
|
229
|
+
!a && _.expandable && /* @__PURE__ */ u("span", { className: "w-5" }),
|
|
230
|
+
/* @__PURE__ */ u("span", { children: e.key })
|
|
143
231
|
]
|
|
144
232
|
})
|
|
145
233
|
}),
|
|
146
|
-
|
|
147
|
-
let n =
|
|
148
|
-
return
|
|
234
|
+
P.map((e) => {
|
|
235
|
+
let n = l.get(e) || {};
|
|
236
|
+
return O.map((r) => /* @__PURE__ */ u("td", {
|
|
149
237
|
className: "px-3 py-2 text-sm text-right tabular-nums cursor-pointer hover:bg-action-primary-bg/10",
|
|
150
|
-
onClick: () =>
|
|
151
|
-
children:
|
|
238
|
+
onClick: () => H(t, e),
|
|
239
|
+
children: B(n[r.field] || 0)
|
|
152
240
|
}, `${e}-${r.field}`));
|
|
153
241
|
}),
|
|
154
|
-
|
|
242
|
+
_.showRowTotals && O.map((t) => /* @__PURE__ */ u("td", {
|
|
155
243
|
className: "px-3 py-2 text-sm text-right tabular-nums font-medium bg-bg-muted/30",
|
|
156
|
-
children:
|
|
244
|
+
children: B(e.values[t.field] || 0)
|
|
157
245
|
}, `total-${t.field}`))
|
|
158
246
|
]
|
|
159
247
|
}, n));
|
|
160
248
|
}
|
|
161
|
-
if (
|
|
162
|
-
let
|
|
163
|
-
for (let
|
|
164
|
-
let
|
|
249
|
+
if (a && (c || r === 0)) {
|
|
250
|
+
let a = Array.from(e.children.keys()).sort();
|
|
251
|
+
for (let o of a) {
|
|
252
|
+
let a = e.children.get(o), s = `${n}/${o}`, c = l ? {
|
|
165
253
|
...t,
|
|
166
|
-
[
|
|
254
|
+
[l]: o
|
|
167
255
|
} : t;
|
|
168
|
-
|
|
256
|
+
i.push(...U(a, c, s, r + 1));
|
|
169
257
|
}
|
|
170
258
|
}
|
|
171
|
-
return
|
|
259
|
+
return i;
|
|
172
260
|
}, [
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
261
|
+
p,
|
|
262
|
+
_,
|
|
263
|
+
E,
|
|
264
|
+
D,
|
|
265
|
+
O,
|
|
266
|
+
P,
|
|
267
|
+
j,
|
|
268
|
+
B,
|
|
269
|
+
H,
|
|
270
|
+
V
|
|
271
|
+
]), W = E.length > 0 || O.length > 0;
|
|
272
|
+
return p.length === 0 ? /* @__PURE__ */ d("div", {
|
|
182
273
|
className: "flex flex-col items-center justify-center h-full p-8 text-text-secondary",
|
|
183
274
|
children: [
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
275
|
+
/* @__PURE__ */ u(l, { className: "w-12 h-12 mb-4 opacity-50" }),
|
|
276
|
+
/* @__PURE__ */ u("p", {
|
|
186
277
|
className: "text-sm",
|
|
187
278
|
children: "No data available"
|
|
188
279
|
}),
|
|
189
|
-
/* @__PURE__ */
|
|
280
|
+
/* @__PURE__ */ u("p", {
|
|
190
281
|
className: "text-xs mt-1",
|
|
191
282
|
children: "Configure data source to populate pivot table"
|
|
192
283
|
})
|
|
193
284
|
]
|
|
194
|
-
}) :
|
|
195
|
-
className: "flex flex-col items-center justify-center h-full p-8 text-text-secondary",
|
|
196
|
-
children: [
|
|
197
|
-
/* @__PURE__ */ s(o, { className: "w-12 h-12 mb-4 opacity-50" }),
|
|
198
|
-
/* @__PURE__ */ s("p", {
|
|
199
|
-
className: "text-sm",
|
|
200
|
-
children: "Configure Pivot Table"
|
|
201
|
-
}),
|
|
202
|
-
/* @__PURE__ */ s("p", {
|
|
203
|
-
className: "text-xs mt-1",
|
|
204
|
-
children: "Add row fields and value fields in widget settings"
|
|
205
|
-
})
|
|
206
|
-
]
|
|
207
|
-
}) : /* @__PURE__ */ s("div", {
|
|
285
|
+
}) : /* @__PURE__ */ d("div", {
|
|
208
286
|
className: "flex flex-col h-full overflow-hidden",
|
|
209
|
-
children: /* @__PURE__ */
|
|
287
|
+
children: [v && /* @__PURE__ */ u(y, {
|
|
288
|
+
rowFields: E,
|
|
289
|
+
columnFields: D,
|
|
290
|
+
valueFields: O,
|
|
291
|
+
availableFields: L,
|
|
292
|
+
onMoveField: R,
|
|
293
|
+
onChangeAggregation: z
|
|
294
|
+
}), W ? /* @__PURE__ */ u("div", {
|
|
210
295
|
className: "flex-1 overflow-auto",
|
|
211
|
-
children: /* @__PURE__ */
|
|
296
|
+
children: /* @__PURE__ */ d("table", {
|
|
212
297
|
className: "w-full border-collapse",
|
|
213
298
|
children: [
|
|
214
|
-
/* @__PURE__ */
|
|
299
|
+
/* @__PURE__ */ d("thead", {
|
|
215
300
|
className: "sticky top-0 z-10",
|
|
216
|
-
children: [/* @__PURE__ */
|
|
301
|
+
children: [/* @__PURE__ */ d("tr", {
|
|
217
302
|
className: "bg-bg-muted",
|
|
218
303
|
children: [
|
|
219
|
-
/* @__PURE__ */
|
|
304
|
+
/* @__PURE__ */ u("th", {
|
|
220
305
|
className: "sticky left-0 bg-bg-muted border-r border-b border-border-default px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-text-secondary",
|
|
221
|
-
children:
|
|
306
|
+
children: E.length > 0 ? E.map((e) => e.replace(/_/g, " ")).join(" / ") : "Values"
|
|
222
307
|
}),
|
|
223
|
-
|
|
224
|
-
colSpan:
|
|
308
|
+
P.map((e) => /* @__PURE__ */ u("th", {
|
|
309
|
+
colSpan: O.length || 1,
|
|
225
310
|
className: "border-b border-border-default px-3 py-2 text-center text-xs font-semibold uppercase tracking-wider text-text-secondary",
|
|
226
311
|
children: e
|
|
227
312
|
}, e)),
|
|
228
|
-
|
|
229
|
-
colSpan:
|
|
313
|
+
_.showRowTotals && /* @__PURE__ */ u("th", {
|
|
314
|
+
colSpan: O.length || 1,
|
|
230
315
|
className: "border-b border-border-default px-3 py-2 text-center text-xs font-semibold uppercase tracking-wider text-text-secondary bg-bg-muted/50",
|
|
231
316
|
children: "Total"
|
|
232
317
|
})
|
|
233
318
|
]
|
|
234
|
-
}),
|
|
319
|
+
}), O.length > 1 && /* @__PURE__ */ d("tr", {
|
|
235
320
|
className: "bg-bg-surface",
|
|
236
321
|
children: [
|
|
237
|
-
/* @__PURE__ */
|
|
238
|
-
|
|
322
|
+
/* @__PURE__ */ u("th", { className: "sticky left-0 bg-bg-surface border-r border-b border-border-default" }),
|
|
323
|
+
P.map((e) => O.map((t) => /* @__PURE__ */ u("th", {
|
|
239
324
|
className: "border-b border-border-default px-3 py-1 text-center text-xs text-text-secondary",
|
|
240
325
|
children: t.label || t.field.replace(/_/g, " ")
|
|
241
326
|
}, `${e}-${t.field}`))),
|
|
242
|
-
|
|
327
|
+
_.showRowTotals && O.map((e) => /* @__PURE__ */ u("th", {
|
|
243
328
|
className: "border-b border-border-default px-3 py-1 text-center text-xs text-text-secondary bg-bg-muted/30",
|
|
244
329
|
children: e.label || e.field.replace(/_/g, " ")
|
|
245
330
|
}, `total-${e.field}`))
|
|
246
331
|
]
|
|
247
332
|
})]
|
|
248
333
|
}),
|
|
249
|
-
/* @__PURE__ */
|
|
334
|
+
/* @__PURE__ */ u("tbody", {
|
|
250
335
|
className: "divide-y divide-border-default",
|
|
251
|
-
children:
|
|
336
|
+
children: U(N, {}, "root", 0)
|
|
252
337
|
}),
|
|
253
|
-
|
|
338
|
+
_.showColumnTotals && /* @__PURE__ */ u("tfoot", { children: /* @__PURE__ */ d("tr", {
|
|
254
339
|
className: "bg-bg-muted/50 font-medium",
|
|
255
340
|
children: [
|
|
256
|
-
/* @__PURE__ */
|
|
341
|
+
/* @__PURE__ */ u("td", {
|
|
257
342
|
className: "sticky left-0 bg-bg-muted/50 border-r border-t border-border-default px-3 py-2 text-sm",
|
|
258
343
|
children: "Total"
|
|
259
344
|
}),
|
|
260
|
-
|
|
261
|
-
let t =
|
|
262
|
-
return
|
|
345
|
+
P.map((e) => {
|
|
346
|
+
let t = F?.get(e) || {};
|
|
347
|
+
return O.map((n) => /* @__PURE__ */ u("td", {
|
|
263
348
|
className: "border-t border-border-default px-3 py-2 text-sm text-right tabular-nums",
|
|
264
|
-
children:
|
|
349
|
+
children: B(t[n.field] || 0)
|
|
265
350
|
}, `footer-${e}-${n.field}`));
|
|
266
351
|
}),
|
|
267
|
-
|
|
352
|
+
_.showRowTotals && _.showGrandTotal && O.map((e) => /* @__PURE__ */ u("td", {
|
|
268
353
|
className: "border-t border-border-default px-3 py-2 text-sm text-right tabular-nums font-bold bg-bg-muted",
|
|
269
|
-
children:
|
|
354
|
+
children: B(N.values[e.field] || 0)
|
|
270
355
|
}, `grand-${e.field}`))
|
|
271
356
|
]
|
|
272
357
|
}) })
|
|
273
358
|
]
|
|
274
359
|
})
|
|
275
|
-
})
|
|
360
|
+
}) : /* @__PURE__ */ d("div", {
|
|
361
|
+
className: "flex flex-col items-center justify-center flex-1 p-8 text-text-secondary",
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ u(l, { className: "w-12 h-12 mb-4 opacity-50" }),
|
|
364
|
+
/* @__PURE__ */ u("p", {
|
|
365
|
+
className: "text-sm",
|
|
366
|
+
children: "Configure Pivot Table"
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ u("p", {
|
|
369
|
+
className: "text-xs mt-1",
|
|
370
|
+
children: v ? "Drag fields into the Rows and Values zones above" : "Add row fields and value fields in widget settings"
|
|
371
|
+
})
|
|
372
|
+
]
|
|
373
|
+
})]
|
|
276
374
|
});
|
|
277
|
-
})
|
|
375
|
+
}), v = "application/x-pivot-field", y = ({ rowFields: e, columnFields: t, valueFields: n, availableFields: r, onMoveField: i, onChangeAggregation: o }) => {
|
|
376
|
+
let [s, l] = a(null), p = (e) => (t) => {
|
|
377
|
+
t.preventDefault(), l(null);
|
|
378
|
+
let n = t.dataTransfer.getData(v) || t.dataTransfer.getData("text/plain");
|
|
379
|
+
if (n) try {
|
|
380
|
+
let { field: t, from: r } = JSON.parse(n);
|
|
381
|
+
t && i(t, r, e);
|
|
382
|
+
} catch {}
|
|
383
|
+
}, m = (e, t, n) => /* @__PURE__ */ d("span", {
|
|
384
|
+
draggable: !0,
|
|
385
|
+
onDragStart: (n) => {
|
|
386
|
+
let r = JSON.stringify({
|
|
387
|
+
field: e,
|
|
388
|
+
from: t
|
|
389
|
+
});
|
|
390
|
+
n.dataTransfer.setData(v, r), n.dataTransfer.setData("text/plain", r), n.dataTransfer.effectAllowed = "move";
|
|
391
|
+
},
|
|
392
|
+
className: "inline-flex items-center gap-1 px-2 py-1 rounded-md bg-bg-surface border border-border-default text-xs text-text-primary cursor-grab",
|
|
393
|
+
children: [
|
|
394
|
+
/* @__PURE__ */ u(c, {
|
|
395
|
+
className: "w-3 h-3 text-text-tertiary",
|
|
396
|
+
"aria-hidden": "true"
|
|
397
|
+
}),
|
|
398
|
+
/* @__PURE__ */ u("span", { children: (n?.label || e).replace(/_/g, " ") }),
|
|
399
|
+
n && /* @__PURE__ */ u("select", {
|
|
400
|
+
value: n.aggregation,
|
|
401
|
+
onChange: (t) => o(e, t.target.value),
|
|
402
|
+
onClick: (e) => e.stopPropagation(),
|
|
403
|
+
"aria-label": `Aggregation for ${e}`,
|
|
404
|
+
className: "ml-1 bg-bg-muted text-text-secondary rounded px-1 py-0.5 text-[10px] uppercase",
|
|
405
|
+
children: f.map((e) => /* @__PURE__ */ u("option", {
|
|
406
|
+
value: e,
|
|
407
|
+
children: e
|
|
408
|
+
}, e))
|
|
409
|
+
})
|
|
410
|
+
]
|
|
411
|
+
}, e), h = (e, t, n) => /* @__PURE__ */ d("div", {
|
|
412
|
+
onDragOver: (e) => {
|
|
413
|
+
e.preventDefault(), e.dataTransfer.dropEffect = "move", s !== t && l(t);
|
|
414
|
+
},
|
|
415
|
+
onDragLeave: () => l((e) => e === t ? null : e),
|
|
416
|
+
onDrop: p(t),
|
|
417
|
+
className: `flex-1 min-w-[8rem] rounded-md border p-2 transition-colors ${s === t ? "border-action-primary-bg bg-action-primary-bg/5" : "border-border-default bg-bg-muted/30"}`,
|
|
418
|
+
children: [/* @__PURE__ */ u("div", {
|
|
419
|
+
className: "text-[10px] font-semibold uppercase tracking-wider text-text-tertiary mb-1.5",
|
|
420
|
+
children: e
|
|
421
|
+
}), /* @__PURE__ */ u("div", {
|
|
422
|
+
className: "flex flex-wrap gap-1.5 min-h-[1.75rem]",
|
|
423
|
+
children: n
|
|
424
|
+
})]
|
|
425
|
+
});
|
|
426
|
+
return /* @__PURE__ */ d("div", {
|
|
427
|
+
className: "flex flex-wrap gap-2 p-2 border-b border-border-default bg-bg-surface",
|
|
428
|
+
children: [
|
|
429
|
+
h("Rows", "rows", e.map((e) => m(e, "rows"))),
|
|
430
|
+
h("Columns", "columns", t.map((e) => m(e, "columns"))),
|
|
431
|
+
h("Values", "values", n.map((e) => m(e.field, "values", e))),
|
|
432
|
+
h("Available", "available", r.length > 0 ? r.map((e) => m(e, "available")) : /* @__PURE__ */ u("span", {
|
|
433
|
+
className: "text-[11px] text-text-tertiary italic",
|
|
434
|
+
children: "All fields in use"
|
|
435
|
+
}))
|
|
436
|
+
]
|
|
437
|
+
});
|
|
438
|
+
};
|
|
278
439
|
//#endregion
|
|
279
|
-
export {
|
|
440
|
+
export { _ as default };
|
|
280
441
|
|
|
281
442
|
//# sourceMappingURL=PivotTableWidget.js.map
|