@toolbox-web/grid 0.2.5 → 0.2.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/all.d.ts +56 -23
- package/all.js +841 -809
- package/all.js.map +1 -1
- package/index.d.ts +12 -5
- package/index.js +276 -225
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +46 -45
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +55 -47
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +243 -241
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +87 -67
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +28 -27
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -2
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +70 -70
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +13 -13
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +7 -7
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
|
@@ -59,8 +59,8 @@ class N {
|
|
|
59
59
|
/**
|
|
60
60
|
* Emit a custom event from the grid.
|
|
61
61
|
*/
|
|
62
|
-
emit(e,
|
|
63
|
-
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail:
|
|
62
|
+
emit(e, o) {
|
|
63
|
+
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: o, bubbles: !0 }));
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Request a re-render of the grid.
|
|
@@ -99,7 +99,7 @@ class N {
|
|
|
99
99
|
* Use this for rendering that needs to match the grid template.
|
|
100
100
|
*/
|
|
101
101
|
get visibleColumns() {
|
|
102
|
-
return this.grid?.
|
|
102
|
+
return this.grid?._visibleColumns ?? [];
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Get the shadow root of the grid.
|
|
@@ -143,8 +143,8 @@ class N {
|
|
|
143
143
|
* @param pluginOverride - Optional plugin-level override
|
|
144
144
|
* @returns The resolved icon value
|
|
145
145
|
*/
|
|
146
|
-
resolveIcon(e,
|
|
147
|
-
return
|
|
146
|
+
resolveIcon(e, o) {
|
|
147
|
+
return o !== void 0 ? o : this.gridIcons[e];
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* Set an icon value on an element.
|
|
@@ -153,8 +153,8 @@ class N {
|
|
|
153
153
|
* @param element - The element to set the icon on
|
|
154
154
|
* @param icon - The icon value (string or HTMLElement)
|
|
155
155
|
*/
|
|
156
|
-
setIcon(e,
|
|
157
|
-
typeof
|
|
156
|
+
setIcon(e, o) {
|
|
157
|
+
typeof o == "string" ? e.innerHTML = o : o instanceof HTMLElement && (e.innerHTML = "", e.appendChild(o.cloneNode(!0)));
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Log a warning message.
|
|
@@ -165,14 +165,14 @@ class N {
|
|
|
165
165
|
// #endregion
|
|
166
166
|
}
|
|
167
167
|
const m = {
|
|
168
|
-
sum: (t, e) => t.reduce((
|
|
168
|
+
sum: (t, e) => t.reduce((o, i) => o + (Number(i[e]) || 0), 0),
|
|
169
169
|
avg: (t, e) => {
|
|
170
|
-
const
|
|
171
|
-
return t.length ?
|
|
170
|
+
const o = t.reduce((i, r) => i + (Number(r[e]) || 0), 0);
|
|
171
|
+
return t.length ? o / t.length : 0;
|
|
172
172
|
},
|
|
173
173
|
count: (t) => t.length,
|
|
174
|
-
min: (t, e) => Math.min(...t.map((
|
|
175
|
-
max: (t, e) => Math.max(...t.map((
|
|
174
|
+
min: (t, e) => Math.min(...t.map((o) => Number(o[e]) || 1 / 0)),
|
|
175
|
+
max: (t, e) => Math.max(...t.map((o) => Number(o[e]) || -1 / 0)),
|
|
176
176
|
first: (t, e) => t[0]?.[e],
|
|
177
177
|
last: (t, e) => t[t.length - 1]?.[e]
|
|
178
178
|
}, v = /* @__PURE__ */ new Map(), h = {
|
|
@@ -198,9 +198,9 @@ const m = {
|
|
|
198
198
|
/**
|
|
199
199
|
* Run an aggregator on a set of rows.
|
|
200
200
|
*/
|
|
201
|
-
run(t, e,
|
|
201
|
+
run(t, e, o, i) {
|
|
202
202
|
const r = this.get(t);
|
|
203
|
-
return r ? r(e,
|
|
203
|
+
return r ? r(e, o, i) : void 0;
|
|
204
204
|
},
|
|
205
205
|
/**
|
|
206
206
|
* Check if an aggregator exists.
|
|
@@ -215,8 +215,8 @@ const m = {
|
|
|
215
215
|
return [...Object.keys(m), ...v.keys()];
|
|
216
216
|
}
|
|
217
217
|
}, A = {
|
|
218
|
-
sum: (t) => t.reduce((e,
|
|
219
|
-
avg: (t) => t.length ? t.reduce((e,
|
|
218
|
+
sum: (t) => t.reduce((e, o) => e + o, 0),
|
|
219
|
+
avg: (t) => t.length ? t.reduce((e, o) => e + o, 0) / t.length : 0,
|
|
220
220
|
count: (t) => t.length,
|
|
221
221
|
min: (t) => t.length ? Math.min(...t) : 0,
|
|
222
222
|
max: (t) => t.length ? Math.max(...t) : 0,
|
|
@@ -240,68 +240,68 @@ function C(t, e) {
|
|
|
240
240
|
return [...t, e].join("|");
|
|
241
241
|
}
|
|
242
242
|
function S(t, e) {
|
|
243
|
-
const
|
|
243
|
+
const o = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], r = e.valueFields ?? [], n = V(t, i), s = L(
|
|
244
244
|
t,
|
|
245
|
-
i,
|
|
246
245
|
o,
|
|
246
|
+
i,
|
|
247
247
|
n,
|
|
248
248
|
r,
|
|
249
249
|
0,
|
|
250
250
|
// starting depth
|
|
251
251
|
""
|
|
252
252
|
// parent key prefix
|
|
253
|
-
),
|
|
253
|
+
), a = H(s, n, r), l = Object.values(a).reduce((d, c) => d + c, 0);
|
|
254
254
|
return {
|
|
255
|
-
rows:
|
|
255
|
+
rows: s,
|
|
256
256
|
columnKeys: n,
|
|
257
|
-
totals:
|
|
257
|
+
totals: a,
|
|
258
258
|
grandTotal: l
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
261
|
function V(t, e) {
|
|
262
262
|
if (e.length === 0) return ["value"];
|
|
263
|
-
const
|
|
264
|
-
for (const
|
|
265
|
-
const r = e.map((n) => String(
|
|
266
|
-
|
|
263
|
+
const o = /* @__PURE__ */ new Set();
|
|
264
|
+
for (const i of t) {
|
|
265
|
+
const r = e.map((n) => String(i[n] ?? "")).join("|");
|
|
266
|
+
o.add(r);
|
|
267
267
|
}
|
|
268
|
-
return [...
|
|
268
|
+
return [...o].sort();
|
|
269
269
|
}
|
|
270
270
|
function M(t, e) {
|
|
271
|
-
const
|
|
272
|
-
for (const
|
|
273
|
-
const r = String(
|
|
274
|
-
n ? n.push(
|
|
271
|
+
const o = /* @__PURE__ */ new Map();
|
|
272
|
+
for (const i of t) {
|
|
273
|
+
const r = String(i[e] ?? ""), n = o.get(r);
|
|
274
|
+
n ? n.push(i) : o.set(r, [i]);
|
|
275
275
|
}
|
|
276
|
-
return
|
|
276
|
+
return o;
|
|
277
277
|
}
|
|
278
|
-
function L(t, e,
|
|
279
|
-
const
|
|
278
|
+
function L(t, e, o, i, r, n, s) {
|
|
279
|
+
const a = [];
|
|
280
280
|
if (e.length === 0) {
|
|
281
|
-
const u =
|
|
282
|
-
return
|
|
283
|
-
rowKey:
|
|
284
|
-
rowLabel:
|
|
281
|
+
const u = T(t, o, i, r), g = _(u);
|
|
282
|
+
return a.push({
|
|
283
|
+
rowKey: s || "all",
|
|
284
|
+
rowLabel: s || "All",
|
|
285
285
|
depth: n,
|
|
286
286
|
values: u,
|
|
287
287
|
total: g,
|
|
288
288
|
isGroup: !1,
|
|
289
289
|
rowCount: t.length
|
|
290
|
-
}),
|
|
290
|
+
}), a;
|
|
291
291
|
}
|
|
292
292
|
const l = e[0], d = e.slice(1), c = d.length > 0, p = M(t, l);
|
|
293
293
|
for (const [u, g] of p) {
|
|
294
|
-
const F =
|
|
294
|
+
const F = s ? `${s}|${u}` : u, y = T(g, o, i, r), E = _(y);
|
|
295
295
|
let R;
|
|
296
296
|
c && (R = L(
|
|
297
297
|
g,
|
|
298
298
|
d,
|
|
299
|
-
i,
|
|
300
299
|
o,
|
|
300
|
+
i,
|
|
301
301
|
r,
|
|
302
302
|
n + 1,
|
|
303
303
|
F
|
|
304
|
-
)),
|
|
304
|
+
)), a.push({
|
|
305
305
|
rowKey: F,
|
|
306
306
|
rowLabel: u || "(blank)",
|
|
307
307
|
depth: n,
|
|
@@ -312,90 +312,90 @@ function L(t, e, i, o, r, n, a) {
|
|
|
312
312
|
rowCount: g.length
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
|
-
return
|
|
315
|
+
return a;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function T(t, e, o, i) {
|
|
318
318
|
const r = {};
|
|
319
|
-
for (const n of
|
|
320
|
-
for (const
|
|
321
|
-
const l = (e.length > 0 ? t.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") === n) : t).map((u) => Number(u[
|
|
319
|
+
for (const n of o)
|
|
320
|
+
for (const s of i) {
|
|
321
|
+
const l = (e.length > 0 ? t.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") === n) : t).map((u) => Number(u[s.field]) || 0), d = K(s.aggFunc), c = l.length > 0 ? d(l) : null, p = C([n], s.field);
|
|
322
322
|
r[p] = c;
|
|
323
323
|
}
|
|
324
324
|
return r;
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function _(t) {
|
|
327
327
|
let e = 0;
|
|
328
|
-
for (const
|
|
329
|
-
e +=
|
|
328
|
+
for (const o of Object.values(t))
|
|
329
|
+
e += o ?? 0;
|
|
330
330
|
return e;
|
|
331
331
|
}
|
|
332
|
-
function H(t, e,
|
|
333
|
-
const
|
|
332
|
+
function H(t, e, o) {
|
|
333
|
+
const i = {};
|
|
334
334
|
function r(n) {
|
|
335
|
-
for (const
|
|
336
|
-
if (!
|
|
337
|
-
for (const
|
|
338
|
-
for (const l of
|
|
339
|
-
const d = C([
|
|
340
|
-
|
|
335
|
+
for (const s of n)
|
|
336
|
+
if (!s.isGroup || !s.children?.length)
|
|
337
|
+
for (const a of e)
|
|
338
|
+
for (const l of o) {
|
|
339
|
+
const d = C([a], l.field);
|
|
340
|
+
i[d] = (i[d] ?? 0) + (s.values[d] ?? 0);
|
|
341
341
|
}
|
|
342
|
-
else
|
|
342
|
+
else s.children && r(s.children);
|
|
343
343
|
}
|
|
344
|
-
return r(t),
|
|
344
|
+
return r(t), i;
|
|
345
345
|
}
|
|
346
|
-
function D(t, e,
|
|
347
|
-
const
|
|
346
|
+
function D(t, e, o = !0) {
|
|
347
|
+
const i = [];
|
|
348
348
|
function r(n) {
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
if (n.children &&
|
|
352
|
-
for (const
|
|
353
|
-
r(
|
|
349
|
+
i.push(n);
|
|
350
|
+
const s = e ? e.has(n.rowKey) : o;
|
|
351
|
+
if (n.children && s)
|
|
352
|
+
for (const a of n.children)
|
|
353
|
+
r(a);
|
|
354
354
|
}
|
|
355
355
|
for (const n of t)
|
|
356
356
|
r(n);
|
|
357
|
-
return
|
|
357
|
+
return i;
|
|
358
358
|
}
|
|
359
359
|
function w(t) {
|
|
360
360
|
const e = [];
|
|
361
|
-
function i
|
|
362
|
-
if (
|
|
363
|
-
for (const r of
|
|
364
|
-
|
|
361
|
+
function o(i) {
|
|
362
|
+
if (i.isGroup && e.push(i.rowKey), i.children)
|
|
363
|
+
for (const r of i.children)
|
|
364
|
+
o(r);
|
|
365
365
|
}
|
|
366
|
-
for (const
|
|
367
|
-
i
|
|
366
|
+
for (const i of t)
|
|
367
|
+
o(i);
|
|
368
368
|
return e;
|
|
369
369
|
}
|
|
370
370
|
const z = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
371
|
-
function q(t, e,
|
|
372
|
-
const r = new AbortController(), n = { config: e, callbacks:
|
|
373
|
-
return
|
|
374
|
-
r.abort(),
|
|
371
|
+
function q(t, e, o, i) {
|
|
372
|
+
const r = new AbortController(), n = { config: e, callbacks: i, signal: r.signal }, s = document.createElement("div");
|
|
373
|
+
return s.className = "tbw-pivot-panel", s.appendChild(f("Options", () => U(o, n))), s.appendChild(f("Row Groups", () => G("rowGroups", n))), s.appendChild(f("Column Groups", () => G("columnGroups", n))), s.appendChild(f("Values", () => Z(n))), s.appendChild(f("Available Fields", () => j(n))), t.appendChild(s), () => {
|
|
374
|
+
r.abort(), s.remove();
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
377
|
function f(t, e) {
|
|
378
|
-
const i = document.createElement("div");
|
|
379
|
-
i.className = "tbw-pivot-section";
|
|
380
378
|
const o = document.createElement("div");
|
|
381
|
-
o.className = "tbw-pivot-section
|
|
379
|
+
o.className = "tbw-pivot-section";
|
|
380
|
+
const i = document.createElement("div");
|
|
381
|
+
i.className = "tbw-pivot-section-header", i.textContent = t;
|
|
382
382
|
const r = document.createElement("div");
|
|
383
|
-
return r.className = "tbw-pivot-section-content", r.appendChild(e()),
|
|
383
|
+
return r.className = "tbw-pivot-section-content", r.appendChild(e()), o.appendChild(i), o.appendChild(r), o;
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
const { config:
|
|
385
|
+
function G(t, e) {
|
|
386
|
+
const { config: o, callbacks: i, signal: r } = e, n = document.createElement("div");
|
|
387
387
|
n.className = "tbw-pivot-drop-zone", n.setAttribute("data-zone", t);
|
|
388
|
-
const
|
|
389
|
-
if (
|
|
390
|
-
const
|
|
391
|
-
|
|
388
|
+
const s = t === "rowGroups" ? o.rowGroupFields ?? [] : o.columnGroupFields ?? [];
|
|
389
|
+
if (s.length === 0) {
|
|
390
|
+
const a = document.createElement("div");
|
|
391
|
+
a.className = "tbw-pivot-placeholder", a.textContent = "Drag fields here or click to add", n.appendChild(a);
|
|
392
392
|
} else
|
|
393
|
-
for (const
|
|
394
|
-
n.appendChild(O(
|
|
393
|
+
for (const a of s)
|
|
394
|
+
n.appendChild(O(a, t, e));
|
|
395
395
|
return n.addEventListener(
|
|
396
396
|
"dragover",
|
|
397
|
-
(
|
|
398
|
-
|
|
397
|
+
(a) => {
|
|
398
|
+
a.preventDefault(), n.classList.add("drag-over");
|
|
399
399
|
},
|
|
400
400
|
{ signal: r }
|
|
401
401
|
), n.addEventListener(
|
|
@@ -406,27 +406,27 @@ function T(t, e) {
|
|
|
406
406
|
{ signal: r }
|
|
407
407
|
), n.addEventListener(
|
|
408
408
|
"drop",
|
|
409
|
-
(
|
|
410
|
-
|
|
411
|
-
const l =
|
|
412
|
-
l &&
|
|
409
|
+
(a) => {
|
|
410
|
+
a.preventDefault(), n.classList.remove("drag-over");
|
|
411
|
+
const l = a.dataTransfer?.getData("text/plain");
|
|
412
|
+
l && i.onAddFieldToZone(l, t);
|
|
413
413
|
},
|
|
414
414
|
{ signal: r }
|
|
415
415
|
), n;
|
|
416
416
|
}
|
|
417
|
-
function O(t, e,
|
|
418
|
-
const { callbacks:
|
|
417
|
+
function O(t, e, o) {
|
|
418
|
+
const { callbacks: i, signal: r } = o, n = document.createElement("div");
|
|
419
419
|
n.className = "tbw-pivot-field-chip", n.draggable = !0;
|
|
420
|
-
const
|
|
421
|
-
|
|
420
|
+
const s = i.getAvailableFields().find((d) => d.field === t), a = document.createElement("span");
|
|
421
|
+
a.className = "tbw-pivot-chip-label", a.textContent = s?.header ?? t;
|
|
422
422
|
const l = document.createElement("button");
|
|
423
423
|
return l.className = "tbw-pivot-chip-remove", l.innerHTML = "×", l.title = "Remove field", l.addEventListener(
|
|
424
424
|
"click",
|
|
425
425
|
(d) => {
|
|
426
|
-
d.stopPropagation(),
|
|
426
|
+
d.stopPropagation(), i.onRemoveFieldFromZone(t, e);
|
|
427
427
|
},
|
|
428
428
|
{ signal: r }
|
|
429
|
-
), n.appendChild(
|
|
429
|
+
), n.appendChild(a), n.appendChild(l), n.addEventListener(
|
|
430
430
|
"dragstart",
|
|
431
431
|
(d) => {
|
|
432
432
|
d.dataTransfer?.setData("text/plain", t), d.dataTransfer?.setData("source-zone", e), n.classList.add("dragging");
|
|
@@ -441,44 +441,44 @@ function O(t, e, i) {
|
|
|
441
441
|
), n;
|
|
442
442
|
}
|
|
443
443
|
function Z(t) {
|
|
444
|
-
const { config: e, callbacks:
|
|
444
|
+
const { config: e, callbacks: o, signal: i } = t, r = document.createElement("div");
|
|
445
445
|
r.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", r.setAttribute("data-zone", "values");
|
|
446
446
|
const n = e.valueFields ?? [];
|
|
447
447
|
if (n.length === 0) {
|
|
448
|
-
const
|
|
449
|
-
|
|
448
|
+
const s = document.createElement("div");
|
|
449
|
+
s.className = "tbw-pivot-placeholder", s.textContent = "Drag numeric fields here for aggregation", r.appendChild(s);
|
|
450
450
|
} else
|
|
451
|
-
for (const
|
|
452
|
-
r.appendChild($(
|
|
451
|
+
for (const s of n)
|
|
452
|
+
r.appendChild($(s, t));
|
|
453
453
|
return r.addEventListener(
|
|
454
454
|
"dragover",
|
|
455
|
-
(
|
|
456
|
-
|
|
455
|
+
(s) => {
|
|
456
|
+
s.preventDefault(), r.classList.add("drag-over");
|
|
457
457
|
},
|
|
458
|
-
{ signal:
|
|
458
|
+
{ signal: i }
|
|
459
459
|
), r.addEventListener(
|
|
460
460
|
"dragleave",
|
|
461
461
|
() => {
|
|
462
462
|
r.classList.remove("drag-over");
|
|
463
463
|
},
|
|
464
|
-
{ signal:
|
|
464
|
+
{ signal: i }
|
|
465
465
|
), r.addEventListener(
|
|
466
466
|
"drop",
|
|
467
|
-
(
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
|
|
467
|
+
(s) => {
|
|
468
|
+
s.preventDefault(), r.classList.remove("drag-over");
|
|
469
|
+
const a = s.dataTransfer?.getData("text/plain");
|
|
470
|
+
a && o.onAddValueField(a, "sum");
|
|
471
471
|
},
|
|
472
|
-
{ signal:
|
|
472
|
+
{ signal: i }
|
|
473
473
|
), r;
|
|
474
474
|
}
|
|
475
475
|
function $(t, e) {
|
|
476
|
-
const { callbacks:
|
|
476
|
+
const { callbacks: o, signal: i } = e, r = document.createElement("div");
|
|
477
477
|
r.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
478
|
-
const n =
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
478
|
+
const n = o.getAvailableFields().find((c) => c.field === t.field), s = document.createElement("div");
|
|
479
|
+
s.className = "tbw-pivot-value-label-wrapper";
|
|
480
|
+
const a = document.createElement("span");
|
|
481
|
+
a.className = "tbw-pivot-chip-label", a.textContent = n?.header ?? t.field;
|
|
482
482
|
const l = document.createElement("select");
|
|
483
483
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
484
484
|
for (const c of z) {
|
|
@@ -488,133 +488,133 @@ function $(t, e) {
|
|
|
488
488
|
l.addEventListener(
|
|
489
489
|
"change",
|
|
490
490
|
() => {
|
|
491
|
-
|
|
491
|
+
o.onUpdateValueAggFunc(t.field, l.value);
|
|
492
492
|
},
|
|
493
|
-
{ signal:
|
|
493
|
+
{ signal: i }
|
|
494
494
|
);
|
|
495
495
|
const d = document.createElement("button");
|
|
496
496
|
return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
|
|
497
497
|
"click",
|
|
498
498
|
(c) => {
|
|
499
|
-
c.stopPropagation(),
|
|
499
|
+
c.stopPropagation(), o.onRemoveValueField(t.field);
|
|
500
500
|
},
|
|
501
|
-
{ signal:
|
|
502
|
-
),
|
|
501
|
+
{ signal: i }
|
|
502
|
+
), s.appendChild(a), s.appendChild(l), r.appendChild(s), r.appendChild(d), r;
|
|
503
503
|
}
|
|
504
504
|
function j(t) {
|
|
505
|
-
const { config: e, callbacks:
|
|
505
|
+
const { config: e, callbacks: o, signal: i } = t, r = document.createElement("div");
|
|
506
506
|
r.className = "tbw-pivot-available-fields";
|
|
507
|
-
const n =
|
|
507
|
+
const n = o.getAvailableFields(), s = /* @__PURE__ */ new Set([
|
|
508
508
|
...e.rowGroupFields ?? [],
|
|
509
509
|
...e.columnGroupFields ?? [],
|
|
510
510
|
...e.valueFields?.map((l) => l.field) ?? []
|
|
511
|
-
]),
|
|
512
|
-
if (
|
|
511
|
+
]), a = n.filter((l) => !s.has(l.field));
|
|
512
|
+
if (a.length === 0) {
|
|
513
513
|
const l = document.createElement("div");
|
|
514
514
|
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", r.appendChild(l);
|
|
515
515
|
} else
|
|
516
|
-
for (const l of
|
|
516
|
+
for (const l of a) {
|
|
517
517
|
const d = document.createElement("div");
|
|
518
518
|
d.className = "tbw-pivot-field-chip available", d.textContent = l.header, d.draggable = !0, d.title = `Drag to add "${l.field}" to a zone`, d.addEventListener(
|
|
519
519
|
"dragstart",
|
|
520
520
|
(c) => {
|
|
521
521
|
c.dataTransfer?.setData("text/plain", l.field), d.classList.add("dragging");
|
|
522
522
|
},
|
|
523
|
-
{ signal:
|
|
523
|
+
{ signal: i }
|
|
524
524
|
), d.addEventListener(
|
|
525
525
|
"dragend",
|
|
526
526
|
() => {
|
|
527
527
|
d.classList.remove("dragging");
|
|
528
528
|
},
|
|
529
|
-
{ signal:
|
|
529
|
+
{ signal: i }
|
|
530
530
|
), r.appendChild(d);
|
|
531
531
|
}
|
|
532
532
|
return r;
|
|
533
533
|
}
|
|
534
534
|
function U(t, e) {
|
|
535
|
-
const { config:
|
|
535
|
+
const { config: o, callbacks: i, signal: r } = e, n = document.createElement("div");
|
|
536
536
|
return n.className = "tbw-pivot-options", n.appendChild(
|
|
537
537
|
x(
|
|
538
538
|
"Enable Pivot View",
|
|
539
539
|
t,
|
|
540
|
-
(
|
|
541
|
-
|
|
540
|
+
(s) => {
|
|
541
|
+
i.onTogglePivot(s);
|
|
542
542
|
},
|
|
543
543
|
r
|
|
544
544
|
)
|
|
545
545
|
), n.appendChild(
|
|
546
546
|
x(
|
|
547
547
|
"Show Row Totals",
|
|
548
|
-
|
|
549
|
-
(
|
|
550
|
-
|
|
548
|
+
o.showTotals ?? !0,
|
|
549
|
+
(s) => {
|
|
550
|
+
i.onOptionChange("showTotals", s);
|
|
551
551
|
},
|
|
552
552
|
r
|
|
553
553
|
)
|
|
554
554
|
), n.appendChild(
|
|
555
555
|
x(
|
|
556
556
|
"Show Grand Total",
|
|
557
|
-
|
|
558
|
-
(
|
|
559
|
-
|
|
557
|
+
o.showGrandTotal ?? !0,
|
|
558
|
+
(s) => {
|
|
559
|
+
i.onOptionChange("showGrandTotal", s);
|
|
560
560
|
},
|
|
561
561
|
r
|
|
562
562
|
)
|
|
563
563
|
), n;
|
|
564
564
|
}
|
|
565
|
-
function x(t, e,
|
|
565
|
+
function x(t, e, o, i) {
|
|
566
566
|
const r = document.createElement("label");
|
|
567
567
|
r.className = "tbw-pivot-checkbox";
|
|
568
568
|
const n = document.createElement("input");
|
|
569
|
-
n.type = "checkbox", n.checked = e, n.addEventListener("change", () =>
|
|
570
|
-
const
|
|
571
|
-
return
|
|
569
|
+
n.type = "checkbox", n.checked = e, n.addEventListener("change", () => o(n.checked), { signal: i });
|
|
570
|
+
const s = document.createElement("span");
|
|
571
|
+
return s.textContent = t, r.appendChild(n), r.appendChild(s), r;
|
|
572
572
|
}
|
|
573
|
-
function B(t, e,
|
|
574
|
-
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "",
|
|
573
|
+
function B(t, e, o) {
|
|
574
|
+
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "", o.columns.forEach((i, r) => {
|
|
575
575
|
const n = document.createElement("div");
|
|
576
576
|
if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("role", "gridcell"), r === 0) {
|
|
577
|
-
const
|
|
578
|
-
n.style.paddingLeft = `${
|
|
579
|
-
const
|
|
580
|
-
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", t.__pivotExpanded ? "Collapse group" : "Expand group"),
|
|
581
|
-
p.stopPropagation(),
|
|
577
|
+
const s = Number(t.__pivotIndent) || 0;
|
|
578
|
+
n.style.paddingLeft = `${s}px`;
|
|
579
|
+
const a = String(t.__pivotRowKey), l = document.createElement("button");
|
|
580
|
+
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", t.__pivotExpanded ? "Collapse group" : "Expand group"), o.setIcon(l, o.resolveIcon(t.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (p) => {
|
|
581
|
+
p.stopPropagation(), o.onToggle(a);
|
|
582
582
|
}), n.appendChild(l);
|
|
583
583
|
const d = document.createElement("span");
|
|
584
584
|
d.className = "pivot-label", d.textContent = String(t.__pivotLabel ?? ""), n.appendChild(d);
|
|
585
585
|
const c = document.createElement("span");
|
|
586
586
|
c.className = "pivot-count", c.textContent = ` (${Number(t.__pivotRowCount) || 0})`, n.appendChild(c);
|
|
587
587
|
} else {
|
|
588
|
-
const
|
|
589
|
-
n.textContent =
|
|
588
|
+
const s = t[i.field];
|
|
589
|
+
n.textContent = s != null ? String(s) : "";
|
|
590
590
|
}
|
|
591
591
|
e.appendChild(n);
|
|
592
592
|
}), !0;
|
|
593
593
|
}
|
|
594
|
-
function W(t, e,
|
|
595
|
-
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.innerHTML = "",
|
|
594
|
+
function W(t, e, o) {
|
|
595
|
+
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.innerHTML = "", o.forEach((i, r) => {
|
|
596
596
|
const n = document.createElement("div");
|
|
597
597
|
if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("role", "gridcell"), r === 0) {
|
|
598
|
-
const
|
|
599
|
-
n.style.paddingLeft = `${
|
|
600
|
-
const
|
|
601
|
-
|
|
598
|
+
const s = Number(t.__pivotIndent) || 0;
|
|
599
|
+
n.style.paddingLeft = `${s + 20}px`;
|
|
600
|
+
const a = document.createElement("span");
|
|
601
|
+
a.className = "pivot-label", a.textContent = String(t.__pivotLabel ?? ""), n.appendChild(a);
|
|
602
602
|
} else {
|
|
603
|
-
const
|
|
604
|
-
n.textContent =
|
|
603
|
+
const s = t[i.field];
|
|
604
|
+
n.textContent = s != null ? String(s) : "";
|
|
605
605
|
}
|
|
606
606
|
e.appendChild(n);
|
|
607
607
|
}), !0;
|
|
608
608
|
}
|
|
609
|
-
function J(t, e,
|
|
610
|
-
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "",
|
|
609
|
+
function J(t, e, o) {
|
|
610
|
+
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", o.forEach((i, r) => {
|
|
611
611
|
const n = document.createElement("div");
|
|
612
612
|
if (n.className = "cell", n.setAttribute("data-col", String(r)), r === 0) {
|
|
613
|
-
const
|
|
614
|
-
|
|
613
|
+
const s = document.createElement("span");
|
|
614
|
+
s.className = "pivot-label", s.textContent = "Grand Total", n.appendChild(s);
|
|
615
615
|
} else {
|
|
616
|
-
const
|
|
617
|
-
n.textContent =
|
|
616
|
+
const s = t[i.field];
|
|
617
|
+
n.textContent = s != null ? String(s) : "";
|
|
618
618
|
}
|
|
619
619
|
e.appendChild(n);
|
|
620
620
|
}), !0;
|
|
@@ -629,7 +629,8 @@ class b extends N {
|
|
|
629
629
|
return {
|
|
630
630
|
active: !0,
|
|
631
631
|
showTotals: !0,
|
|
632
|
-
showGrandTotal: !0
|
|
632
|
+
showGrandTotal: !0,
|
|
633
|
+
showToolPanel: !0
|
|
633
634
|
};
|
|
634
635
|
}
|
|
635
636
|
// #region Internal State
|
|
@@ -656,34 +657,35 @@ class b extends N {
|
|
|
656
657
|
// #endregion
|
|
657
658
|
// #region Shell Integration
|
|
658
659
|
getToolPanel() {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
660
|
+
if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
|
|
661
|
+
return {
|
|
662
|
+
id: b.PANEL_ID,
|
|
663
|
+
title: "Pivot",
|
|
664
|
+
icon: "⊞",
|
|
665
|
+
tooltip: "Configure pivot table",
|
|
666
|
+
order: 90,
|
|
667
|
+
render: (o) => this.renderPanel(o)
|
|
668
|
+
};
|
|
667
669
|
}
|
|
668
670
|
// #endregion
|
|
669
671
|
// #region Hooks
|
|
670
672
|
processRows(e) {
|
|
671
673
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
672
674
|
return [...e];
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
675
|
-
return this.warn(`Config errors: ${
|
|
675
|
+
const o = I(this.config);
|
|
676
|
+
if (o.length > 0)
|
|
677
|
+
return this.warn(`Config errors: ${o.join(", ")}`), [...e];
|
|
676
678
|
if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
|
|
677
679
|
const n = w(this.pivotResult.rows);
|
|
678
|
-
for (const
|
|
679
|
-
this.expandedKeys.add(
|
|
680
|
+
for (const s of n)
|
|
681
|
+
this.expandedKeys.add(s);
|
|
680
682
|
}
|
|
681
683
|
if (this.pivotResult = S(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
|
|
682
684
|
const n = w(this.pivotResult.rows);
|
|
683
|
-
for (const
|
|
684
|
-
this.expandedKeys.add(
|
|
685
|
+
for (const s of n)
|
|
686
|
+
this.expandedKeys.add(s);
|
|
685
687
|
}
|
|
686
|
-
const
|
|
688
|
+
const i = this.config.indentWidth ?? 20;
|
|
687
689
|
return D(
|
|
688
690
|
this.pivotResult.rows,
|
|
689
691
|
this.expandedKeys,
|
|
@@ -696,7 +698,7 @@ class b extends N {
|
|
|
696
698
|
__pivotHasChildren: !!n.children?.length,
|
|
697
699
|
__pivotExpanded: this.expandedKeys.has(n.rowKey),
|
|
698
700
|
__pivotRowCount: n.rowCount ?? 0,
|
|
699
|
-
__pivotIndent: n.depth *
|
|
701
|
+
__pivotIndent: n.depth * i,
|
|
700
702
|
__pivotTotal: n.total,
|
|
701
703
|
...n.values
|
|
702
704
|
}));
|
|
@@ -704,37 +706,37 @@ class b extends N {
|
|
|
704
706
|
processColumns(e) {
|
|
705
707
|
if (!this.isActive || !this.pivotResult)
|
|
706
708
|
return [...e];
|
|
707
|
-
const
|
|
708
|
-
|
|
709
|
+
const o = [], i = (this.config.rowGroupFields ?? []).map((r) => this.fieldHeaderMap.get(r) ?? r).join(" / ");
|
|
710
|
+
o.push({
|
|
709
711
|
field: "__pivotLabel",
|
|
710
|
-
header:
|
|
712
|
+
header: i || "Group",
|
|
711
713
|
width: 200
|
|
712
714
|
});
|
|
713
715
|
for (const r of this.pivotResult.columnKeys)
|
|
714
716
|
for (const n of this.config.valueFields ?? []) {
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
field:
|
|
718
|
-
header: `${r} - ${
|
|
717
|
+
const s = C([r], n.field), a = n.header || this.fieldHeaderMap.get(n.field) || n.field;
|
|
718
|
+
o.push({
|
|
719
|
+
field: s,
|
|
720
|
+
header: `${r} - ${a} (${n.aggFunc})`,
|
|
719
721
|
width: 120,
|
|
720
722
|
type: "number"
|
|
721
723
|
});
|
|
722
724
|
}
|
|
723
|
-
return this.config.showTotals &&
|
|
725
|
+
return this.config.showTotals && o.push({
|
|
724
726
|
field: "__pivotTotal",
|
|
725
727
|
header: "Total",
|
|
726
728
|
width: 100,
|
|
727
729
|
type: "number"
|
|
728
|
-
}),
|
|
730
|
+
}), o;
|
|
729
731
|
}
|
|
730
|
-
renderRow(e,
|
|
731
|
-
const
|
|
732
|
-
return
|
|
732
|
+
renderRow(e, o) {
|
|
733
|
+
const i = e;
|
|
734
|
+
return i.__pivotRowKey && i.__pivotHasChildren ? B(i, o, {
|
|
733
735
|
columns: this.gridColumns,
|
|
734
736
|
onToggle: (r) => this.toggle(r),
|
|
735
737
|
resolveIcon: (r) => this.resolveIcon(r),
|
|
736
738
|
setIcon: (r, n) => this.setIcon(r, n)
|
|
737
|
-
}) :
|
|
739
|
+
}) : i.__pivotRowKey !== void 0 && this.isActive ? W(i, o, this.gridColumns) : (this.cleanupPivotStyling(o), !1);
|
|
738
740
|
}
|
|
739
741
|
/**
|
|
740
742
|
* Remove pivot-specific classes, attributes, and inline styles from a row element.
|
|
@@ -754,17 +756,17 @@ class b extends N {
|
|
|
754
756
|
if (!this.pivotResult) return;
|
|
755
757
|
const e = this.shadowRoot;
|
|
756
758
|
if (!e) return;
|
|
757
|
-
const
|
|
758
|
-
if (!
|
|
759
|
-
this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer",
|
|
760
|
-
const
|
|
759
|
+
const o = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
760
|
+
if (!o) return;
|
|
761
|
+
this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", o.appendChild(this.grandTotalFooter));
|
|
762
|
+
const i = {
|
|
761
763
|
__pivotRowKey: "__grandTotal",
|
|
762
764
|
__pivotLabel: "Grand Total",
|
|
763
765
|
__pivotIsGrandTotal: !0,
|
|
764
766
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
765
767
|
...this.pivotResult.totals
|
|
766
768
|
};
|
|
767
|
-
J(
|
|
769
|
+
J(i, this.grandTotalFooter, this.gridColumns);
|
|
768
770
|
}
|
|
769
771
|
/**
|
|
770
772
|
* Remove the grand total footer element.
|
|
@@ -786,8 +788,8 @@ class b extends N {
|
|
|
786
788
|
expandAll() {
|
|
787
789
|
if (this.pivotResult) {
|
|
788
790
|
const e = w(this.pivotResult.rows);
|
|
789
|
-
for (const
|
|
790
|
-
this.expandedKeys.add(
|
|
791
|
+
for (const o of e)
|
|
792
|
+
this.expandedKeys.add(o);
|
|
791
793
|
this.requestRender();
|
|
792
794
|
}
|
|
793
795
|
}
|
|
@@ -845,8 +847,8 @@ class b extends N {
|
|
|
845
847
|
buildFieldHeaderMap() {
|
|
846
848
|
const e = this.getAvailableFields();
|
|
847
849
|
this.fieldHeaderMap.clear();
|
|
848
|
-
for (const
|
|
849
|
-
this.fieldHeaderMap.set(
|
|
850
|
+
for (const o of e)
|
|
851
|
+
this.fieldHeaderMap.set(o.field, o.header);
|
|
850
852
|
}
|
|
851
853
|
getAvailableFields() {
|
|
852
854
|
return this.originalColumns.length > 0 ? this.originalColumns : this.captureOriginalColumns();
|
|
@@ -854,10 +856,10 @@ class b extends N {
|
|
|
854
856
|
captureOriginalColumns() {
|
|
855
857
|
const e = this.grid;
|
|
856
858
|
try {
|
|
857
|
-
const
|
|
858
|
-
return this.originalColumns =
|
|
859
|
-
field:
|
|
860
|
-
header:
|
|
859
|
+
const o = e.getAllColumns?.() ?? e.columns ?? [];
|
|
860
|
+
return this.originalColumns = o.filter((i) => !i.field.startsWith("__pivot")).map((i) => ({
|
|
861
|
+
field: i.field,
|
|
862
|
+
header: i.header ?? i.field
|
|
861
863
|
})), this.originalColumns;
|
|
862
864
|
} catch {
|
|
863
865
|
return [];
|
|
@@ -865,51 +867,51 @@ class b extends N {
|
|
|
865
867
|
}
|
|
866
868
|
renderPanel(e) {
|
|
867
869
|
this.panelContainer = e, this.originalColumns.length === 0 && this.captureOriginalColumns();
|
|
868
|
-
const
|
|
869
|
-
onTogglePivot: (
|
|
870
|
-
|
|
870
|
+
const o = {
|
|
871
|
+
onTogglePivot: (i) => {
|
|
872
|
+
i ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
|
|
871
873
|
},
|
|
872
|
-
onAddFieldToZone: (
|
|
873
|
-
onRemoveFieldFromZone: (
|
|
874
|
-
onAddValueField: (
|
|
875
|
-
onRemoveValueField: (
|
|
876
|
-
onUpdateValueAggFunc: (
|
|
877
|
-
onOptionChange: (
|
|
878
|
-
this.config[
|
|
874
|
+
onAddFieldToZone: (i, r) => this.addFieldToZone(i, r),
|
|
875
|
+
onRemoveFieldFromZone: (i, r) => this.removeFieldFromZone(i, r),
|
|
876
|
+
onAddValueField: (i, r) => this.addValueField(i, r),
|
|
877
|
+
onRemoveValueField: (i) => this.removeValueField(i),
|
|
878
|
+
onUpdateValueAggFunc: (i, r) => this.updateValueAggFunc(i, r),
|
|
879
|
+
onOptionChange: (i, r) => {
|
|
880
|
+
this.config[i] = r, this.isActive && this.refresh();
|
|
879
881
|
},
|
|
880
882
|
getAvailableFields: () => this.getAvailableFields()
|
|
881
883
|
};
|
|
882
|
-
return q(e, this.config, this.isActive,
|
|
884
|
+
return q(e, this.config, this.isActive, o);
|
|
883
885
|
}
|
|
884
886
|
refreshPanel() {
|
|
885
887
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
886
888
|
}
|
|
887
|
-
addFieldToZone(e,
|
|
888
|
-
if (
|
|
889
|
-
const
|
|
890
|
-
|
|
889
|
+
addFieldToZone(e, o) {
|
|
890
|
+
if (o === "rowGroups") {
|
|
891
|
+
const i = this.config.rowGroupFields ?? [];
|
|
892
|
+
i.includes(e) || (this.config.rowGroupFields = [...i, e]);
|
|
891
893
|
} else {
|
|
892
|
-
const
|
|
893
|
-
|
|
894
|
+
const i = this.config.columnGroupFields ?? [];
|
|
895
|
+
i.includes(e) || (this.config.columnGroupFields = [...i, e]);
|
|
894
896
|
}
|
|
895
|
-
this.removeFromOtherZones(e,
|
|
897
|
+
this.removeFromOtherZones(e, o), this.isActive && this.refresh(), this.refreshPanel();
|
|
896
898
|
}
|
|
897
|
-
removeFieldFromZone(e,
|
|
898
|
-
|
|
899
|
+
removeFieldFromZone(e, o) {
|
|
900
|
+
o === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((i) => i !== e) : this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((i) => i !== e), this.isActive && this.refresh(), this.refreshPanel();
|
|
899
901
|
}
|
|
900
|
-
removeFromOtherZones(e,
|
|
901
|
-
|
|
902
|
+
removeFromOtherZones(e, o) {
|
|
903
|
+
o !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((i) => i !== e)), o !== "columnGroups" && (this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((i) => i !== e)), o !== "values" && (this.config.valueFields = (this.config.valueFields ?? []).filter((i) => i.field !== e));
|
|
902
904
|
}
|
|
903
|
-
addValueField(e,
|
|
904
|
-
const
|
|
905
|
-
|
|
905
|
+
addValueField(e, o) {
|
|
906
|
+
const i = this.config.valueFields ?? [];
|
|
907
|
+
i.some((r) => r.field === e) || (this.config.valueFields = [...i, { field: e, aggFunc: o }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
|
|
906
908
|
}
|
|
907
909
|
removeValueField(e) {
|
|
908
|
-
this.config.valueFields = (this.config.valueFields ?? []).filter((
|
|
910
|
+
this.config.valueFields = (this.config.valueFields ?? []).filter((o) => o.field !== e), this.isActive && this.refresh(), this.refreshPanel();
|
|
909
911
|
}
|
|
910
|
-
updateValueAggFunc(e,
|
|
911
|
-
const
|
|
912
|
-
r >= 0 && (
|
|
912
|
+
updateValueAggFunc(e, o) {
|
|
913
|
+
const i = this.config.valueFields ?? [], r = i.findIndex((n) => n.field === e);
|
|
914
|
+
r >= 0 && (i[r] = { ...i[r], aggFunc: o }, this.config.valueFields = [...i]), this.isActive && this.refresh();
|
|
913
915
|
}
|
|
914
916
|
// #endregion
|
|
915
917
|
// #region Styles
|