@toolbox-web/grid 0.2.1 → 0.2.3
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/README.md +96 -59
- package/all.d.ts +328 -225
- package/all.js +522 -525
- package/all.js.map +1 -1
- package/index.d.ts +220 -160
- package/index.js +1197 -1112
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +11 -5
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +9 -4
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +11 -5
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +7 -3
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +16 -149
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +13 -6
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +13 -6
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +11 -5
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +13 -6
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +102 -53
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +13 -6
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +19 -9
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +49 -40
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +13 -6
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +11 -5
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +15 -7
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +3 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +13 -6
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +19 -160
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +16 -16
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -142
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +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.map +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/all.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseGridPlugin as x, DEFAULT_GRID_ICONS as
|
|
2
|
-
import { DGEvents as
|
|
1
|
+
import { BaseGridPlugin as x, DEFAULT_GRID_ICONS as He, runAggregator as se, PLUGIN_QUERIES as Pe, getAggregator as Ge, getValueAggregator as Oe } from "./index.js";
|
|
2
|
+
import { DGEvents as Nn, DataGridElement as Pn, FitModeEnum as qn, GridCSSVars as Dn, GridClasses as Kn, GridDataAttrs as Hn, DataGridElement as Gn, GridSelectors as On, PluginEvents as Bn, PluginManager as Vn, aggregatorRegistry as zn, listAggregators as Wn, registerAggregator as $n, runValueAggregator as jn, unregisterAggregator as Un } from "./index.js";
|
|
3
3
|
function Be(r, e, t, n) {
|
|
4
4
|
if (n.processCell)
|
|
5
5
|
return n.processCell(r, e, t);
|
|
@@ -60,7 +60,7 @@ async function ae() {
|
|
|
60
60
|
return "";
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
class
|
|
63
|
+
class wn extends x {
|
|
64
64
|
name = "clipboard";
|
|
65
65
|
version = "1.0.0";
|
|
66
66
|
get defaultConfig() {
|
|
@@ -72,19 +72,22 @@ class mn extends x {
|
|
|
72
72
|
quoteStrings: !1
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
//
|
|
75
|
+
// #region Internal State
|
|
76
76
|
/** The last copied text (for reference/debugging) */
|
|
77
77
|
lastCopied = null;
|
|
78
|
-
//
|
|
78
|
+
// #endregion
|
|
79
|
+
// #region Lifecycle
|
|
79
80
|
detach() {
|
|
80
81
|
this.lastCopied = null;
|
|
81
82
|
}
|
|
82
|
-
//
|
|
83
|
+
// #endregion
|
|
84
|
+
// #region Event Handlers
|
|
83
85
|
onKeyDown(e) {
|
|
84
86
|
const t = (e.ctrlKey || e.metaKey) && e.key === "c", n = (e.ctrlKey || e.metaKey) && e.key === "v";
|
|
85
87
|
return t ? (this.#t(e.target), !0) : n ? (this.#e(), !0) : !1;
|
|
86
88
|
}
|
|
87
|
-
//
|
|
89
|
+
// #endregion
|
|
90
|
+
// #region Private Methods
|
|
88
91
|
/**
|
|
89
92
|
* Handle copy operation
|
|
90
93
|
*/
|
|
@@ -209,7 +212,8 @@ class mn extends x {
|
|
|
209
212
|
c = l == null ? "" : String(l);
|
|
210
213
|
return { text: c, field: n, value: l };
|
|
211
214
|
}
|
|
212
|
-
//
|
|
215
|
+
// #endregion
|
|
216
|
+
// #region Public API
|
|
213
217
|
/**
|
|
214
218
|
* Copy currently selected rows to clipboard.
|
|
215
219
|
* @returns The copied text
|
|
@@ -252,6 +256,7 @@ class mn extends x {
|
|
|
252
256
|
getLastCopied() {
|
|
253
257
|
return this.lastCopied;
|
|
254
258
|
}
|
|
259
|
+
// #endregion
|
|
255
260
|
}
|
|
256
261
|
const de = 100;
|
|
257
262
|
function Q(r) {
|
|
@@ -275,7 +280,7 @@ function ue(r) {
|
|
|
275
280
|
function he(r) {
|
|
276
281
|
return r.reduce((e, t) => e + Q(t.width), 0);
|
|
277
282
|
}
|
|
278
|
-
function
|
|
283
|
+
function Ve(r, e, t, n, o) {
|
|
279
284
|
const i = t.length;
|
|
280
285
|
if (i === 0)
|
|
281
286
|
return { startCol: 0, endCol: 0, visibleColumns: [] };
|
|
@@ -304,10 +309,10 @@ function ze(r, e, t) {
|
|
|
304
309
|
}
|
|
305
310
|
return n;
|
|
306
311
|
}
|
|
307
|
-
function
|
|
312
|
+
function We(r, e, t) {
|
|
308
313
|
return t ? r > e : !1;
|
|
309
314
|
}
|
|
310
|
-
class
|
|
315
|
+
class bn extends x {
|
|
311
316
|
name = "columnVirtualization";
|
|
312
317
|
version = "1.0.0";
|
|
313
318
|
get defaultConfig() {
|
|
@@ -317,7 +322,7 @@ class wn extends x {
|
|
|
317
322
|
overscan: 3
|
|
318
323
|
};
|
|
319
324
|
}
|
|
320
|
-
//
|
|
325
|
+
// #region Internal State
|
|
321
326
|
isVirtualized = !1;
|
|
322
327
|
startCol = 0;
|
|
323
328
|
endCol = 0;
|
|
@@ -325,7 +330,8 @@ class wn extends x {
|
|
|
325
330
|
totalWidth = 0;
|
|
326
331
|
columnWidths = [];
|
|
327
332
|
columnOffsets = [];
|
|
328
|
-
//
|
|
333
|
+
// #endregion
|
|
334
|
+
// #region Lifecycle
|
|
329
335
|
attach(e) {
|
|
330
336
|
super.attach(e);
|
|
331
337
|
const t = this.columns;
|
|
@@ -334,12 +340,13 @@ class wn extends x {
|
|
|
334
340
|
detach() {
|
|
335
341
|
this.columnWidths = [], this.columnOffsets = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
|
|
336
342
|
}
|
|
337
|
-
//
|
|
343
|
+
// #endregion
|
|
344
|
+
// #region Hooks
|
|
338
345
|
processColumns(e) {
|
|
339
|
-
const t =
|
|
346
|
+
const t = We(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
|
|
340
347
|
if (this.isVirtualized = t ?? !1, this.columnWidths = ce(e), this.columnOffsets = ue(e), this.totalWidth = he(e), !t)
|
|
341
348
|
return this.startCol = 0, this.endCol = e.length - 1, [...e];
|
|
342
|
-
const n = this.grid.clientWidth || 800, o =
|
|
349
|
+
const n = this.grid.clientWidth || 800, o = Ve(
|
|
343
350
|
this.scrollLeft,
|
|
344
351
|
n,
|
|
345
352
|
this.columnOffsets,
|
|
@@ -362,7 +369,8 @@ class wn extends x {
|
|
|
362
369
|
onScroll(e) {
|
|
363
370
|
!this.isVirtualized || Math.abs(e.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = e.scrollLeft, this.requestRender());
|
|
364
371
|
}
|
|
365
|
-
//
|
|
372
|
+
// #endregion
|
|
373
|
+
// #region Public API
|
|
366
374
|
/**
|
|
367
375
|
* Check if column virtualization is currently active.
|
|
368
376
|
*/
|
|
@@ -396,15 +404,16 @@ class wn extends x {
|
|
|
396
404
|
getTotalWidth() {
|
|
397
405
|
return this.totalWidth;
|
|
398
406
|
}
|
|
407
|
+
// #endregion
|
|
399
408
|
}
|
|
400
|
-
const
|
|
409
|
+
const $e = ".tbw-context-menu{position:fixed;background:light-dark(#f5f5f5,#2a2a2a);color:light-dark(#222,#eee);border:1px solid light-dark(#d0d0d4,#454545);border-radius:4px;box-shadow:0 2px 10px #00000026;min-width:160px;padding:4px 0;z-index:10000;font-size:13px;font-family:system-ui,sans-serif}.tbw-context-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;gap:8px}.tbw-context-menu-item:hover:not(.disabled){background:light-dark(#e8e8e8,#3a3a3a)}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:16px;text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:light-dark(#888,#888);font-size:11px}.tbw-context-menu-arrow{font-size:10px;color:light-dark(#888,#888)}.tbw-context-menu-separator{height:1px;background:light-dark(#d0d0d4,#454545);margin:4px 0}";
|
|
401
410
|
function Y(r, e) {
|
|
402
411
|
return (typeof r == "function" ? r(e) : r).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
|
|
403
412
|
}
|
|
404
|
-
function
|
|
413
|
+
function je(r, e) {
|
|
405
414
|
return r.disabled === !0 ? !0 : typeof r.disabled == "function" ? r.disabled(e) : !1;
|
|
406
415
|
}
|
|
407
|
-
function Z(r, e, t, n =
|
|
416
|
+
function Z(r, e, t, n = He.submenuArrow) {
|
|
408
417
|
const o = document.createElement("div");
|
|
409
418
|
o.className = "tbw-context-menu", o.setAttribute("role", "menu");
|
|
410
419
|
for (const i of r) {
|
|
@@ -415,7 +424,7 @@ function Z(r, e, t, n = Ke.submenuArrow) {
|
|
|
415
424
|
}
|
|
416
425
|
const s = document.createElement("div");
|
|
417
426
|
s.className = "tbw-context-menu-item", i.cssClass && s.classList.add(i.cssClass), s.setAttribute("role", "menuitem"), s.setAttribute("data-id", i.id);
|
|
418
|
-
const l =
|
|
427
|
+
const l = je(i, e);
|
|
419
428
|
if (l && (s.classList.add("disabled"), s.setAttribute("aria-disabled", "true")), i.icon) {
|
|
420
429
|
const d = document.createElement("span");
|
|
421
430
|
d.className = "tbw-context-menu-icon", d.innerHTML = i.icon, s.appendChild(d);
|
|
@@ -448,8 +457,8 @@ function ge(r, e, t) {
|
|
|
448
457
|
let s = e, l = t;
|
|
449
458
|
e + n.width > o && (s = e - n.width), t + n.height > i && (l = t - n.height), s = Math.max(0, s), l = Math.max(0, l), r.style.left = `${s}px`, r.style.top = `${l}px`, r.style.visibility = "visible";
|
|
450
459
|
}
|
|
451
|
-
let _ = null, I = null, E = null,
|
|
452
|
-
const
|
|
460
|
+
let _ = null, I = null, E = null, O = 0;
|
|
461
|
+
const B = [
|
|
453
462
|
{
|
|
454
463
|
id: "copy",
|
|
455
464
|
name: "Copy",
|
|
@@ -467,29 +476,31 @@ const O = [
|
|
|
467
476
|
}
|
|
468
477
|
}
|
|
469
478
|
];
|
|
470
|
-
class
|
|
479
|
+
class vn extends x {
|
|
471
480
|
name = "contextMenu";
|
|
472
481
|
version = "1.0.0";
|
|
473
482
|
get defaultConfig() {
|
|
474
483
|
return {
|
|
475
|
-
items:
|
|
484
|
+
items: B
|
|
476
485
|
};
|
|
477
486
|
}
|
|
478
|
-
//
|
|
487
|
+
// #region Internal State
|
|
479
488
|
isOpen = !1;
|
|
480
489
|
position = { x: 0, y: 0 };
|
|
481
490
|
params = null;
|
|
482
491
|
menuElement = null;
|
|
483
|
-
//
|
|
492
|
+
// #endregion
|
|
493
|
+
// #region Lifecycle
|
|
484
494
|
attach(e) {
|
|
485
|
-
super.attach(e), this.installGlobalHandlers(),
|
|
495
|
+
super.attach(e), this.installGlobalHandlers(), O++;
|
|
486
496
|
}
|
|
487
497
|
detach() {
|
|
488
498
|
this.menuElement && (this.menuElement.remove(), this.menuElement = null), this.isOpen = !1, this.params = null, this.uninstallGlobalHandlers();
|
|
489
499
|
}
|
|
490
|
-
//
|
|
500
|
+
// #endregion
|
|
501
|
+
// #region Private Methods
|
|
491
502
|
installGlobalHandlers() {
|
|
492
|
-
!E && typeof document < "u" && (E = document.createElement("style"), E.id = "tbw-context-menu-styles", E.textContent =
|
|
503
|
+
!E && typeof document < "u" && (E = document.createElement("style"), E.id = "tbw-context-menu-styles", E.textContent = $e, document.head.appendChild(E)), _ || (_ = () => {
|
|
493
504
|
document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
|
|
494
505
|
}, document.addEventListener("click", _)), I || (I = (e) => {
|
|
495
506
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
|
|
@@ -500,9 +511,10 @@ class bn extends x {
|
|
|
500
511
|
* Uses reference counting to ensure handlers persist while any grid uses the plugin.
|
|
501
512
|
*/
|
|
502
513
|
uninstallGlobalHandlers() {
|
|
503
|
-
|
|
514
|
+
O--, !(O > 0) && (_ && (document.removeEventListener("click", _), _ = null), I && (document.removeEventListener("keydown", I), I = null), E && (E.remove(), E = null));
|
|
504
515
|
}
|
|
505
|
-
//
|
|
516
|
+
// #endregion
|
|
517
|
+
// #region Hooks
|
|
506
518
|
afterRender() {
|
|
507
519
|
const e = this.shadowRoot;
|
|
508
520
|
if (!e) return;
|
|
@@ -539,7 +551,7 @@ class bn extends x {
|
|
|
539
551
|
} else
|
|
540
552
|
return;
|
|
541
553
|
this.params = a, this.position = { x: o.clientX, y: o.clientY };
|
|
542
|
-
const d = Y(this.config.items ??
|
|
554
|
+
const d = Y(this.config.items ?? B, a);
|
|
543
555
|
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = Z(
|
|
544
556
|
d,
|
|
545
557
|
a,
|
|
@@ -550,7 +562,8 @@ class bn extends x {
|
|
|
550
562
|
), document.body.appendChild(this.menuElement), ge(this.menuElement, o.clientX, o.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: d }));
|
|
551
563
|
}));
|
|
552
564
|
}
|
|
553
|
-
//
|
|
565
|
+
// #endregion
|
|
566
|
+
// #region Public API
|
|
554
567
|
/**
|
|
555
568
|
* Programmatically show the context menu at the specified position.
|
|
556
569
|
* @param x - X coordinate
|
|
@@ -567,7 +580,7 @@ class bn extends x {
|
|
|
567
580
|
value: n.value ?? null,
|
|
568
581
|
isHeader: n.isHeader ?? !1,
|
|
569
582
|
event: n.event ?? new MouseEvent("contextmenu")
|
|
570
|
-
}, i = Y(this.config.items ??
|
|
583
|
+
}, i = Y(this.config.items ?? B, o);
|
|
571
584
|
this.menuElement && this.menuElement.remove(), this.menuElement = Z(
|
|
572
585
|
i,
|
|
573
586
|
o,
|
|
@@ -590,6 +603,7 @@ class bn extends x {
|
|
|
590
603
|
isMenuOpen() {
|
|
591
604
|
return this.isOpen;
|
|
592
605
|
}
|
|
606
|
+
// #endregion
|
|
593
607
|
// Styles are injected globally via installGlobalHandlers() since menu renders in document.body
|
|
594
608
|
}
|
|
595
609
|
function pe(r, e = !0) {
|
|
@@ -600,7 +614,7 @@ function pe(r, e = !0) {
|
|
|
600
614
|
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
601
615
|
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
602
616
|
}
|
|
603
|
-
function
|
|
617
|
+
function Ue(r, e, t, n = {}) {
|
|
604
618
|
const o = n.delimiter ?? ",", i = n.newline ?? `
|
|
605
619
|
`, s = [], l = n.bom ? "\uFEFF" : "";
|
|
606
620
|
if (t.includeHeaders !== !1) {
|
|
@@ -623,14 +637,14 @@ function ee(r, e) {
|
|
|
623
637
|
const t = URL.createObjectURL(r), n = document.createElement("a");
|
|
624
638
|
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
625
639
|
}
|
|
626
|
-
function
|
|
640
|
+
function Ye(r, e) {
|
|
627
641
|
const t = new Blob([r], { type: "text/csv;charset=utf-8;" });
|
|
628
642
|
ee(t, e);
|
|
629
643
|
}
|
|
630
644
|
function fe(r) {
|
|
631
645
|
return r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
632
646
|
}
|
|
633
|
-
function
|
|
647
|
+
function Ze(r, e, t) {
|
|
634
648
|
let n = `<?xml version="1.0" encoding="UTF-8"?>
|
|
635
649
|
<?mso-application progid="Excel.Sheet"?>
|
|
636
650
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
@@ -662,13 +676,13 @@ function Ye(r, e, t) {
|
|
|
662
676
|
</Worksheet>
|
|
663
677
|
</Workbook>`, n;
|
|
664
678
|
}
|
|
665
|
-
function
|
|
679
|
+
function Xe(r, e) {
|
|
666
680
|
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([r], {
|
|
667
681
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
668
682
|
});
|
|
669
683
|
ee(n, t);
|
|
670
684
|
}
|
|
671
|
-
class
|
|
685
|
+
class xn extends x {
|
|
672
686
|
name = "export";
|
|
673
687
|
version = "1.0.0";
|
|
674
688
|
get defaultConfig() {
|
|
@@ -679,10 +693,11 @@ class vn extends x {
|
|
|
679
693
|
onlySelected: !1
|
|
680
694
|
};
|
|
681
695
|
}
|
|
682
|
-
//
|
|
696
|
+
// #region Internal State
|
|
683
697
|
isExportingFlag = !1;
|
|
684
698
|
lastExportInfo = null;
|
|
685
|
-
//
|
|
699
|
+
// #endregion
|
|
700
|
+
// #region Private Methods
|
|
686
701
|
performExport(e, t) {
|
|
687
702
|
const n = this.config, o = {
|
|
688
703
|
format: e,
|
|
@@ -708,13 +723,13 @@ class vn extends x {
|
|
|
708
723
|
try {
|
|
709
724
|
switch (e) {
|
|
710
725
|
case "csv": {
|
|
711
|
-
const a =
|
|
712
|
-
l = l.endsWith(".csv") ? l : `${l}.csv`,
|
|
726
|
+
const a = Ue(s, i, o, { bom: !0 });
|
|
727
|
+
l = l.endsWith(".csv") ? l : `${l}.csv`, Ye(a, l);
|
|
713
728
|
break;
|
|
714
729
|
}
|
|
715
730
|
case "excel": {
|
|
716
|
-
const a =
|
|
717
|
-
l = l.endsWith(".xls") ? l : `${l}.xls`,
|
|
731
|
+
const a = Ze(s, i, o);
|
|
732
|
+
l = l.endsWith(".xls") ? l : `${l}.xls`, Xe(a, l);
|
|
718
733
|
break;
|
|
719
734
|
}
|
|
720
735
|
case "json": {
|
|
@@ -749,7 +764,8 @@ class vn extends x {
|
|
|
749
764
|
return null;
|
|
750
765
|
}
|
|
751
766
|
}
|
|
752
|
-
//
|
|
767
|
+
// #endregion
|
|
768
|
+
// #region Public API
|
|
753
769
|
/**
|
|
754
770
|
* Export data to CSV format.
|
|
755
771
|
* @param params - Optional export parameters
|
|
@@ -785,8 +801,9 @@ class vn extends x {
|
|
|
785
801
|
getLastExport() {
|
|
786
802
|
return this.lastExportInfo;
|
|
787
803
|
}
|
|
804
|
+
// #endregion
|
|
788
805
|
}
|
|
789
|
-
function
|
|
806
|
+
function Je(r) {
|
|
790
807
|
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: i } = r, s = Math.ceil(t / o);
|
|
791
808
|
let l = Math.floor(n / o) - i;
|
|
792
809
|
l < 0 && (l = 0);
|
|
@@ -798,10 +815,10 @@ function Xe(r) {
|
|
|
798
815
|
totalHeight: e * o
|
|
799
816
|
};
|
|
800
817
|
}
|
|
801
|
-
function
|
|
818
|
+
function Qe(r, e) {
|
|
802
819
|
return r <= e;
|
|
803
820
|
}
|
|
804
|
-
function
|
|
821
|
+
function et(r, e, t = !1) {
|
|
805
822
|
const n = r[e.field];
|
|
806
823
|
if (e.operator === "blank")
|
|
807
824
|
return n == null || n === "";
|
|
@@ -843,10 +860,10 @@ function Qe(r, e, t = !1) {
|
|
|
843
860
|
return !0;
|
|
844
861
|
}
|
|
845
862
|
}
|
|
846
|
-
function
|
|
847
|
-
return e.length ? r.filter((n) => e.every((o) =>
|
|
863
|
+
function tt(r, e, t = !1) {
|
|
864
|
+
return e.length ? r.filter((n) => e.every((o) => et(n, o, t))) : r;
|
|
848
865
|
}
|
|
849
|
-
function
|
|
866
|
+
function nt(r) {
|
|
850
867
|
return JSON.stringify(
|
|
851
868
|
r.map((e) => ({
|
|
852
869
|
field: e.field,
|
|
@@ -864,148 +881,7 @@ function me(r, e) {
|
|
|
864
881
|
}
|
|
865
882
|
return [...t].sort((n, o) => typeof n == "number" && typeof o == "number" ? n - o : String(n).localeCompare(String(o)));
|
|
866
883
|
}
|
|
867
|
-
const
|
|
868
|
-
.tbw-filter-panel {
|
|
869
|
-
position: fixed;
|
|
870
|
-
background: var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));
|
|
871
|
-
color: var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));
|
|
872
|
-
border: 1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));
|
|
873
|
-
border-radius: var(--tbw-filter-panel-radius, var(--tbw-border-radius, 4px));
|
|
874
|
-
box-shadow: 0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0,0,0,0.1), rgba(0,0,0,0.3))));
|
|
875
|
-
padding: 12px;
|
|
876
|
-
z-index: 10000;
|
|
877
|
-
min-width: 200px;
|
|
878
|
-
max-width: 280px;
|
|
879
|
-
max-height: 350px;
|
|
880
|
-
display: flex;
|
|
881
|
-
flex-direction: column;
|
|
882
|
-
font-family: var(--tbw-font-family, system-ui, sans-serif);
|
|
883
|
-
font-size: var(--tbw-font-size, 13px);
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
.tbw-filter-search {
|
|
887
|
-
margin-bottom: 8px;
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
.tbw-filter-search-input {
|
|
891
|
-
width: 100%;
|
|
892
|
-
padding: 6px 10px;
|
|
893
|
-
background: var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));
|
|
894
|
-
color: inherit;
|
|
895
|
-
border: 1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));
|
|
896
|
-
border-radius: var(--tbw-filter-input-radius, 4px);
|
|
897
|
-
font-size: inherit;
|
|
898
|
-
box-sizing: border-box;
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
.tbw-filter-search-input:focus {
|
|
902
|
-
outline: none;
|
|
903
|
-
border-color: var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));
|
|
904
|
-
box-shadow: 0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%);
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
.tbw-filter-actions {
|
|
908
|
-
display: flex;
|
|
909
|
-
padding: 4px 2px;
|
|
910
|
-
margin-bottom: 8px;
|
|
911
|
-
border-bottom: 1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
.tbw-filter-action-btn {
|
|
915
|
-
background: transparent;
|
|
916
|
-
border: none;
|
|
917
|
-
color: var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));
|
|
918
|
-
cursor: pointer;
|
|
919
|
-
font-size: 12px;
|
|
920
|
-
padding: 2px 0;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
.tbw-filter-action-btn:hover {
|
|
924
|
-
text-decoration: underline;
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
.tbw-filter-values {
|
|
928
|
-
flex: 1;
|
|
929
|
-
overflow-y: auto;
|
|
930
|
-
margin-bottom: 8px;
|
|
931
|
-
max-height: 180px;
|
|
932
|
-
position: relative;
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
.tbw-filter-values-spacer {
|
|
936
|
-
width: 1px;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
.tbw-filter-values-content {
|
|
940
|
-
position: absolute;
|
|
941
|
-
top: 0;
|
|
942
|
-
left: 0;
|
|
943
|
-
right: 0;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
.tbw-filter-value-item {
|
|
947
|
-
display: flex;
|
|
948
|
-
align-items: center;
|
|
949
|
-
gap: 8px;
|
|
950
|
-
padding: 4px 2px;
|
|
951
|
-
cursor: pointer;
|
|
952
|
-
border-radius: 3px;
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
.tbw-filter-value-item:hover {
|
|
956
|
-
background: var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)));
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
.tbw-filter-checkbox {
|
|
960
|
-
margin: 0;
|
|
961
|
-
cursor: pointer;
|
|
962
|
-
accent-color: var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));
|
|
963
|
-
}
|
|
964
|
-
|
|
965
|
-
.tbw-filter-no-match {
|
|
966
|
-
color: var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));
|
|
967
|
-
padding: 8px 0;
|
|
968
|
-
text-align: center;
|
|
969
|
-
font-style: italic;
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
.tbw-filter-buttons {
|
|
973
|
-
display: flex;
|
|
974
|
-
gap: 8px;
|
|
975
|
-
padding-top: 8px;
|
|
976
|
-
border-top: 1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));
|
|
977
|
-
}
|
|
978
|
-
|
|
979
|
-
.tbw-filter-apply-btn {
|
|
980
|
-
flex: 1;
|
|
981
|
-
padding: 6px 12px;
|
|
982
|
-
background: var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));
|
|
983
|
-
color: var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));
|
|
984
|
-
border: none;
|
|
985
|
-
border-radius: 4px;
|
|
986
|
-
cursor: pointer;
|
|
987
|
-
font-size: 13px;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
.tbw-filter-apply-btn:hover {
|
|
991
|
-
filter: brightness(0.9);
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
.tbw-filter-clear-btn {
|
|
995
|
-
flex: 1;
|
|
996
|
-
padding: 6px 12px;
|
|
997
|
-
background: transparent;
|
|
998
|
-
color: var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));
|
|
999
|
-
border: 1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));
|
|
1000
|
-
border-radius: 4px;
|
|
1001
|
-
cursor: pointer;
|
|
1002
|
-
font-size: 13px;
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
.tbw-filter-clear-btn:hover {
|
|
1006
|
-
background: var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)));
|
|
1007
|
-
}
|
|
1008
|
-
`;
|
|
884
|
+
const ot = '.header-cell.filtered:before{content:"";position:absolute;top:4px;right:4px;width:6px;height:6px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}.tbw-filter-btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:4px;opacity:.4;transition:opacity .15s;color:inherit;vertical-align:middle}.tbw-filter-btn:hover,.tbw-filter-btn.active{opacity:1}.tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}', it = ".tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, 4px));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:12px;z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, 13px)}.tbw-filter-search{margin-bottom:8px}.tbw-filter-search-input{width:100%;padding:6px 10px;background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, 4px);font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:4px 2px;margin-bottom:8px;border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:12px;padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:8px;max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:8px;padding:4px 2px;cursor:pointer;border-radius:3px}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:8px 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:8px;padding-top:8px;border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:6px 12px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:4px;cursor:pointer;font-size:13px}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:6px 12px;background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:4px;cursor:pointer;font-size:13px}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}";
|
|
1009
885
|
class A extends x {
|
|
1010
886
|
name = "filtering";
|
|
1011
887
|
version = "1.0.0";
|
|
@@ -1017,7 +893,7 @@ class A extends x {
|
|
|
1017
893
|
useWorker: !0
|
|
1018
894
|
};
|
|
1019
895
|
}
|
|
1020
|
-
//
|
|
896
|
+
// #region Internal State
|
|
1021
897
|
filters = /* @__PURE__ */ new Map();
|
|
1022
898
|
cachedResult = null;
|
|
1023
899
|
cacheKey = null;
|
|
@@ -1033,21 +909,23 @@ class A extends x {
|
|
|
1033
909
|
static LIST_OVERSCAN = 3;
|
|
1034
910
|
static LIST_BYPASS_THRESHOLD = 50;
|
|
1035
911
|
// Don't virtualize if < 50 items
|
|
1036
|
-
//
|
|
912
|
+
// #endregion
|
|
913
|
+
// #region Lifecycle
|
|
1037
914
|
attach(e) {
|
|
1038
915
|
super.attach(e), this.injectGlobalStyles();
|
|
1039
916
|
}
|
|
1040
917
|
detach() {
|
|
1041
918
|
this.filters.clear(), this.cachedResult = null, this.cacheKey = null, this.openPanelField = null, this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.searchText.clear(), this.excludedValues.clear(), this.panelAbortController?.abort(), this.panelAbortController = null;
|
|
1042
919
|
}
|
|
1043
|
-
//
|
|
920
|
+
// #endregion
|
|
921
|
+
// #region Hooks
|
|
1044
922
|
processRows(e) {
|
|
1045
923
|
const t = [...this.filters.values()];
|
|
1046
924
|
if (!t.length) return [...e];
|
|
1047
|
-
const n =
|
|
925
|
+
const n = nt(t);
|
|
1048
926
|
if (this.cacheKey === n && this.cachedResult)
|
|
1049
927
|
return this.cachedResult;
|
|
1050
|
-
const o =
|
|
928
|
+
const o = tt([...e], t, this.config.caseSensitive);
|
|
1051
929
|
return this.cachedResult = o, this.cacheKey = n, o;
|
|
1052
930
|
}
|
|
1053
931
|
afterRender() {
|
|
@@ -1066,7 +944,8 @@ class A extends x {
|
|
|
1066
944
|
}), n.appendChild(l);
|
|
1067
945
|
});
|
|
1068
946
|
}
|
|
1069
|
-
//
|
|
947
|
+
// #endregion
|
|
948
|
+
// #region Public API
|
|
1070
949
|
/**
|
|
1071
950
|
* Set a filter on a specific field.
|
|
1072
951
|
* Pass null to remove the filter.
|
|
@@ -1151,7 +1030,8 @@ class A extends x {
|
|
|
1151
1030
|
getUniqueValues(e) {
|
|
1152
1031
|
return me(this.sourceRows, e);
|
|
1153
1032
|
}
|
|
1154
|
-
//
|
|
1033
|
+
// #endregion
|
|
1034
|
+
// #region Private Methods
|
|
1155
1035
|
/**
|
|
1156
1036
|
* Inject global styles for filter panel (rendered in document.body)
|
|
1157
1037
|
*/
|
|
@@ -1162,7 +1042,7 @@ class A extends x {
|
|
|
1162
1042
|
return;
|
|
1163
1043
|
}
|
|
1164
1044
|
const e = document.createElement("style");
|
|
1165
|
-
e.id = "tbw-filter-panel-styles", e.textContent =
|
|
1045
|
+
e.id = "tbw-filter-panel-styles", e.textContent = it, document.head.appendChild(e), this.globalStylesInjected = !0;
|
|
1166
1046
|
}
|
|
1167
1047
|
/**
|
|
1168
1048
|
* Toggle the filter panel for a field
|
|
@@ -1239,13 +1119,13 @@ class A extends x {
|
|
|
1239
1119
|
const u = document.createElement("span");
|
|
1240
1120
|
u.textContent = "Select All", d.appendChild(c), d.appendChild(u), a.appendChild(d);
|
|
1241
1121
|
const h = () => {
|
|
1242
|
-
const b = [...m.values()],
|
|
1243
|
-
c.checked =
|
|
1122
|
+
const b = [...m.values()], C = b.every((y) => y), R = b.every((y) => !y);
|
|
1123
|
+
c.checked = C, c.indeterminate = !C && !R;
|
|
1244
1124
|
};
|
|
1245
1125
|
c.addEventListener("change", () => {
|
|
1246
1126
|
const b = c.checked;
|
|
1247
|
-
for (const
|
|
1248
|
-
m.set(
|
|
1127
|
+
for (const C of m.keys())
|
|
1128
|
+
m.set(C, b);
|
|
1249
1129
|
h(), K();
|
|
1250
1130
|
}), e.appendChild(a);
|
|
1251
1131
|
const g = document.createElement("div");
|
|
@@ -1256,42 +1136,42 @@ class A extends x {
|
|
|
1256
1136
|
f.className = "tbw-filter-values-content", g.appendChild(f);
|
|
1257
1137
|
const m = /* @__PURE__ */ new Map();
|
|
1258
1138
|
n.forEach((b) => {
|
|
1259
|
-
const
|
|
1260
|
-
m.set(
|
|
1139
|
+
const C = b == null ? "__null__" : String(b);
|
|
1140
|
+
m.set(C, !o.has(b));
|
|
1261
1141
|
}), h();
|
|
1262
1142
|
let w = [];
|
|
1263
|
-
const k = (b,
|
|
1264
|
-
const R = b == null ? "(Blank)" : String(b),
|
|
1265
|
-
v.className = "tbw-filter-value-item", v.style.position = "absolute", v.style.top = `${
|
|
1143
|
+
const k = (b, C) => {
|
|
1144
|
+
const R = b == null ? "(Blank)" : String(b), y = b == null ? "__null__" : String(b), v = document.createElement("label");
|
|
1145
|
+
v.className = "tbw-filter-value-item", v.style.position = "absolute", v.style.top = `${C * A.LIST_ITEM_HEIGHT}px`, v.style.left = "0", v.style.right = "0", v.style.height = `${A.LIST_ITEM_HEIGHT}px`, v.style.boxSizing = "border-box";
|
|
1266
1146
|
const S = document.createElement("input");
|
|
1267
|
-
S.type = "checkbox", S.className = "tbw-filter-checkbox", S.checked = m.get(
|
|
1268
|
-
m.set(
|
|
1147
|
+
S.type = "checkbox", S.className = "tbw-filter-checkbox", S.checked = m.get(y) ?? !0, S.dataset.value = y, S.addEventListener("change", () => {
|
|
1148
|
+
m.set(y, S.checked), h();
|
|
1269
1149
|
});
|
|
1270
1150
|
const re = document.createElement("span");
|
|
1271
1151
|
return re.textContent = R, v.appendChild(S), v.appendChild(re), v;
|
|
1272
1152
|
}, K = () => {
|
|
1273
|
-
const b = w.length,
|
|
1274
|
-
if (p.style.height = `${b * A.LIST_ITEM_HEIGHT}px`,
|
|
1153
|
+
const b = w.length, C = g.clientHeight, R = g.scrollTop;
|
|
1154
|
+
if (p.style.height = `${b * A.LIST_ITEM_HEIGHT}px`, Qe(b, A.LIST_BYPASS_THRESHOLD / 3)) {
|
|
1275
1155
|
f.innerHTML = "", f.style.transform = "translateY(0px)", w.forEach((v, S) => {
|
|
1276
1156
|
f.appendChild(k(v, S));
|
|
1277
1157
|
});
|
|
1278
1158
|
return;
|
|
1279
1159
|
}
|
|
1280
|
-
const
|
|
1160
|
+
const y = Je({
|
|
1281
1161
|
totalRows: b,
|
|
1282
|
-
viewportHeight:
|
|
1162
|
+
viewportHeight: C,
|
|
1283
1163
|
scrollTop: R,
|
|
1284
1164
|
rowHeight: A.LIST_ITEM_HEIGHT,
|
|
1285
1165
|
overscan: A.LIST_OVERSCAN
|
|
1286
1166
|
});
|
|
1287
|
-
f.style.transform = `translateY(${
|
|
1288
|
-
for (let v =
|
|
1289
|
-
f.appendChild(k(w[v], v -
|
|
1167
|
+
f.style.transform = `translateY(${y.offsetY}px)`, f.innerHTML = "";
|
|
1168
|
+
for (let v = y.start; v < y.end; v++)
|
|
1169
|
+
f.appendChild(k(w[v], v - y.start));
|
|
1290
1170
|
}, oe = (b) => {
|
|
1291
|
-
const
|
|
1171
|
+
const C = b.toLowerCase();
|
|
1292
1172
|
if (w = n.filter((R) => {
|
|
1293
|
-
const
|
|
1294
|
-
return !b ||
|
|
1173
|
+
const y = R == null ? "(Blank)" : String(R);
|
|
1174
|
+
return !b || y.toLowerCase().includes(C);
|
|
1295
1175
|
}), w.length === 0) {
|
|
1296
1176
|
p.style.height = "0px", f.innerHTML = "";
|
|
1297
1177
|
const R = document.createElement("div");
|
|
@@ -1318,13 +1198,13 @@ class A extends x {
|
|
|
1318
1198
|
const N = document.createElement("button");
|
|
1319
1199
|
N.className = "tbw-filter-apply-btn", N.textContent = "Apply", N.addEventListener("click", () => {
|
|
1320
1200
|
const b = [];
|
|
1321
|
-
for (const [
|
|
1201
|
+
for (const [C, R] of m)
|
|
1322
1202
|
if (!R)
|
|
1323
|
-
if (
|
|
1203
|
+
if (C === "__null__")
|
|
1324
1204
|
b.push(null);
|
|
1325
1205
|
else {
|
|
1326
|
-
const
|
|
1327
|
-
b.push(
|
|
1206
|
+
const y = n.find((v) => String(v) === C);
|
|
1207
|
+
b.push(y !== void 0 ? y : C);
|
|
1328
1208
|
}
|
|
1329
1209
|
t.applySetFilter(b);
|
|
1330
1210
|
}), M.appendChild(N);
|
|
@@ -1362,7 +1242,8 @@ class A extends x {
|
|
|
1362
1242
|
filteredRowCount: 0
|
|
1363
1243
|
}), this.requestRender();
|
|
1364
1244
|
}
|
|
1365
|
-
//
|
|
1245
|
+
// #endregion
|
|
1246
|
+
// #region Column State Hooks
|
|
1366
1247
|
/**
|
|
1367
1248
|
* Return filter state for a column if it has an active filter.
|
|
1368
1249
|
*/
|
|
@@ -1395,10 +1276,12 @@ class A extends x {
|
|
|
1395
1276
|
};
|
|
1396
1277
|
this.filters.set(e, n), this.cachedResult = null, this.cacheKey = null;
|
|
1397
1278
|
}
|
|
1398
|
-
//
|
|
1399
|
-
|
|
1279
|
+
// #endregion
|
|
1280
|
+
// #region Styles
|
|
1281
|
+
styles = ot;
|
|
1282
|
+
// #endregion
|
|
1400
1283
|
}
|
|
1401
|
-
function
|
|
1284
|
+
function rt(r) {
|
|
1402
1285
|
if (!r.length) return [];
|
|
1403
1286
|
const e = /* @__PURE__ */ new Map(), t = [], n = (s, l) => {
|
|
1404
1287
|
if (!l.length) return;
|
|
@@ -1433,7 +1316,7 @@ function it(r) {
|
|
|
1433
1316
|
}, e.set(d, c), t.push(c)), c.columns.push(s);
|
|
1434
1317
|
}), o.length && n(i, o), t.length === 1 && t[0].implicit && t[0].columns.length === r.length ? [] : t;
|
|
1435
1318
|
}
|
|
1436
|
-
function
|
|
1319
|
+
function st(r, e, t) {
|
|
1437
1320
|
if (!e.length || !r) return;
|
|
1438
1321
|
const n = /* @__PURE__ */ new Map();
|
|
1439
1322
|
for (const i of e)
|
|
@@ -1449,7 +1332,7 @@ function rt(r, e, t) {
|
|
|
1449
1332
|
l && l.classList.add("group-end");
|
|
1450
1333
|
}
|
|
1451
1334
|
}
|
|
1452
|
-
function
|
|
1335
|
+
function lt(r, e) {
|
|
1453
1336
|
if (r.length === 0) return null;
|
|
1454
1337
|
const t = document.createElement("div");
|
|
1455
1338
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
@@ -1459,11 +1342,11 @@ function st(r, e) {
|
|
|
1459
1342
|
}
|
|
1460
1343
|
return t;
|
|
1461
1344
|
}
|
|
1462
|
-
function
|
|
1345
|
+
function at(r) {
|
|
1463
1346
|
return r.some((e) => e.group != null);
|
|
1464
1347
|
}
|
|
1465
|
-
const
|
|
1466
|
-
class
|
|
1348
|
+
const dt = ".header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong))}";
|
|
1349
|
+
class yn extends x {
|
|
1467
1350
|
name = "groupingColumns";
|
|
1468
1351
|
version = "1.0.0";
|
|
1469
1352
|
get defaultConfig() {
|
|
@@ -1471,24 +1354,27 @@ class xn extends x {
|
|
|
1471
1354
|
showGroupBorders: !0
|
|
1472
1355
|
};
|
|
1473
1356
|
}
|
|
1474
|
-
//
|
|
1357
|
+
// #region Internal State
|
|
1475
1358
|
groups = [];
|
|
1476
1359
|
isActive = !1;
|
|
1477
|
-
//
|
|
1360
|
+
// #endregion
|
|
1361
|
+
// #region Lifecycle
|
|
1478
1362
|
detach() {
|
|
1479
1363
|
this.groups = [], this.isActive = !1;
|
|
1480
1364
|
}
|
|
1481
|
-
//
|
|
1365
|
+
// #endregion
|
|
1366
|
+
// #region Static Detection
|
|
1482
1367
|
/**
|
|
1483
1368
|
* Auto-detect column groups from column configuration.
|
|
1484
1369
|
*/
|
|
1485
1370
|
static detect(e, t) {
|
|
1486
1371
|
const n = t?.columns;
|
|
1487
|
-
return Array.isArray(n) ?
|
|
1372
|
+
return Array.isArray(n) ? at(n) : !1;
|
|
1488
1373
|
}
|
|
1489
|
-
//
|
|
1374
|
+
// #endregion
|
|
1375
|
+
// #region Hooks
|
|
1490
1376
|
processColumns(e) {
|
|
1491
|
-
const t =
|
|
1377
|
+
const t = rt(e);
|
|
1492
1378
|
return t.length === 0 ? (this.isActive = !1, this.groups = [], [...e]) : (this.isActive = !0, this.groups = t, [...e]);
|
|
1493
1379
|
}
|
|
1494
1380
|
afterRender() {
|
|
@@ -1501,15 +1387,16 @@ class xn extends x {
|
|
|
1501
1387
|
if (!e) return;
|
|
1502
1388
|
const t = e.querySelector(".header-group-row");
|
|
1503
1389
|
t && t.remove();
|
|
1504
|
-
const n =
|
|
1390
|
+
const n = lt(this.groups, this.columns);
|
|
1505
1391
|
if (n) {
|
|
1506
1392
|
const i = e.querySelector(".header-row");
|
|
1507
1393
|
i ? e.insertBefore(n, i) : e.appendChild(n);
|
|
1508
1394
|
}
|
|
1509
1395
|
const o = e.querySelector(".header-row");
|
|
1510
|
-
o &&
|
|
1396
|
+
o && st(o, this.groups, this.columns);
|
|
1511
1397
|
}
|
|
1512
|
-
//
|
|
1398
|
+
// #endregion
|
|
1399
|
+
// #region Public API
|
|
1513
1400
|
/**
|
|
1514
1401
|
* Check if column groups are active.
|
|
1515
1402
|
* @returns Whether grouping is active
|
|
@@ -1539,10 +1426,12 @@ class xn extends x {
|
|
|
1539
1426
|
refresh() {
|
|
1540
1427
|
this.requestRender();
|
|
1541
1428
|
}
|
|
1542
|
-
//
|
|
1543
|
-
|
|
1429
|
+
// #endregion
|
|
1430
|
+
// #region Styles
|
|
1431
|
+
styles = dt;
|
|
1432
|
+
// #endregion
|
|
1544
1433
|
}
|
|
1545
|
-
function
|
|
1434
|
+
function ct({ rows: r, config: e, expanded: t }) {
|
|
1546
1435
|
const n = e.groupOn;
|
|
1547
1436
|
if (typeof n != "function")
|
|
1548
1437
|
return [];
|
|
@@ -1575,23 +1464,23 @@ function dt({ rows: r, config: e, expanded: t }) {
|
|
|
1575
1464
|
};
|
|
1576
1465
|
return s(o), i;
|
|
1577
1466
|
}
|
|
1578
|
-
function
|
|
1467
|
+
function ut(r, e) {
|
|
1579
1468
|
const t = new Set(r);
|
|
1580
1469
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1581
1470
|
}
|
|
1582
|
-
function
|
|
1471
|
+
function ht(r) {
|
|
1583
1472
|
const e = /* @__PURE__ */ new Set();
|
|
1584
1473
|
for (const t of r)
|
|
1585
1474
|
t.kind === "group" && e.add(t.key);
|
|
1586
1475
|
return e;
|
|
1587
1476
|
}
|
|
1588
|
-
function
|
|
1477
|
+
function gt() {
|
|
1589
1478
|
return /* @__PURE__ */ new Set();
|
|
1590
1479
|
}
|
|
1591
|
-
function
|
|
1480
|
+
function pt(r) {
|
|
1592
1481
|
return r.kind !== "group" ? 0 : r.rows.length;
|
|
1593
1482
|
}
|
|
1594
|
-
const
|
|
1483
|
+
const ft = '.group-row{background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-right:4px;font-size:10px}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:2px}.group-label{display:inline-flex;align-items:center;gap:8px}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:.85em;font-weight:400}[data-group-depth="0"] .group-label{padding-left:0}[data-group-depth="1"] .group-label{padding-left:20px}[data-group-depth="2"] .group-label{padding-left:40px}[data-group-depth="3"] .group-label{padding-left:60px}[data-group-depth="4"] .group-label{padding-left:80px}';
|
|
1595
1484
|
class Cn extends x {
|
|
1596
1485
|
name = "groupingRows";
|
|
1597
1486
|
version = "1.0.0";
|
|
@@ -1603,15 +1492,17 @@ class Cn extends x {
|
|
|
1603
1492
|
aggregators: {}
|
|
1604
1493
|
};
|
|
1605
1494
|
}
|
|
1606
|
-
//
|
|
1495
|
+
// #region Internal State
|
|
1607
1496
|
expandedKeys = /* @__PURE__ */ new Set();
|
|
1608
1497
|
flattenedRows = [];
|
|
1609
1498
|
isActive = !1;
|
|
1610
|
-
//
|
|
1499
|
+
// #endregion
|
|
1500
|
+
// #region Lifecycle
|
|
1611
1501
|
detach() {
|
|
1612
1502
|
this.expandedKeys.clear(), this.flattenedRows = [], this.isActive = !1;
|
|
1613
1503
|
}
|
|
1614
|
-
//
|
|
1504
|
+
// #endregion
|
|
1505
|
+
// #region Hooks
|
|
1615
1506
|
/**
|
|
1616
1507
|
* Auto-detect grouping configuration from grid config.
|
|
1617
1508
|
* Called by plugin system to determine if plugin should activate.
|
|
@@ -1623,7 +1514,7 @@ class Cn extends x {
|
|
|
1623
1514
|
const t = this.config;
|
|
1624
1515
|
if (typeof t.groupOn != "function")
|
|
1625
1516
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
1626
|
-
const n =
|
|
1517
|
+
const n = ct({
|
|
1627
1518
|
rows: e,
|
|
1628
1519
|
config: t,
|
|
1629
1520
|
expanded: this.expandedKeys
|
|
@@ -1635,7 +1526,7 @@ class Cn extends x {
|
|
|
1635
1526
|
__groupDepth: o.depth,
|
|
1636
1527
|
__groupRows: o.rows,
|
|
1637
1528
|
__groupExpanded: o.expanded,
|
|
1638
|
-
__groupRowCount:
|
|
1529
|
+
__groupRowCount: pt(o)
|
|
1639
1530
|
} : o.row));
|
|
1640
1531
|
}
|
|
1641
1532
|
onCellClick(e) {
|
|
@@ -1671,7 +1562,8 @@ class Cn extends x {
|
|
|
1671
1562
|
}
|
|
1672
1563
|
afterRender() {
|
|
1673
1564
|
}
|
|
1674
|
-
//
|
|
1565
|
+
// #endregion
|
|
1566
|
+
// #region Private Rendering Helpers
|
|
1675
1567
|
renderFullWidthGroupRow(e, t, n) {
|
|
1676
1568
|
const o = this.config, i = document.createElement("div");
|
|
1677
1569
|
i.className = "cell group-full", i.style.gridColumn = "1 / -1", i.setAttribute("role", "gridcell");
|
|
@@ -1720,25 +1612,26 @@ class Cn extends x {
|
|
|
1720
1612
|
t.appendChild(h);
|
|
1721
1613
|
});
|
|
1722
1614
|
}
|
|
1723
|
-
//
|
|
1615
|
+
// #endregion
|
|
1616
|
+
// #region Public API
|
|
1724
1617
|
/**
|
|
1725
1618
|
* Expand all groups.
|
|
1726
1619
|
*/
|
|
1727
1620
|
expandAll() {
|
|
1728
|
-
this.expandedKeys =
|
|
1621
|
+
this.expandedKeys = ht(this.flattenedRows), this.requestRender();
|
|
1729
1622
|
}
|
|
1730
1623
|
/**
|
|
1731
1624
|
* Collapse all groups.
|
|
1732
1625
|
*/
|
|
1733
1626
|
collapseAll() {
|
|
1734
|
-
this.expandedKeys =
|
|
1627
|
+
this.expandedKeys = gt(), this.requestRender();
|
|
1735
1628
|
}
|
|
1736
1629
|
/**
|
|
1737
1630
|
* Toggle expansion of a specific group.
|
|
1738
1631
|
* @param key - The group key to toggle
|
|
1739
1632
|
*/
|
|
1740
1633
|
toggle(e) {
|
|
1741
|
-
this.expandedKeys =
|
|
1634
|
+
this.expandedKeys = ut(this.expandedKeys, e);
|
|
1742
1635
|
const t = this.flattenedRows.find((n) => n.kind === "group" && n.key === e);
|
|
1743
1636
|
this.emit("group-toggle", {
|
|
1744
1637
|
key: e,
|
|
@@ -1827,25 +1720,27 @@ class Cn extends x {
|
|
|
1827
1720
|
setGroupOn(e) {
|
|
1828
1721
|
this.config.groupOn = e, this.requestRender();
|
|
1829
1722
|
}
|
|
1830
|
-
//
|
|
1831
|
-
|
|
1723
|
+
// #endregion
|
|
1724
|
+
// #region Styles
|
|
1725
|
+
styles = ft;
|
|
1726
|
+
// #endregion
|
|
1832
1727
|
}
|
|
1833
|
-
function
|
|
1728
|
+
function V(r, e) {
|
|
1834
1729
|
const t = new Set(r);
|
|
1835
1730
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1836
1731
|
}
|
|
1837
|
-
function
|
|
1732
|
+
function mt(r, e) {
|
|
1838
1733
|
const t = new Set(r);
|
|
1839
1734
|
return t.add(e), t;
|
|
1840
1735
|
}
|
|
1841
|
-
function
|
|
1736
|
+
function wt(r, e) {
|
|
1842
1737
|
const t = new Set(r);
|
|
1843
1738
|
return t.delete(e), t;
|
|
1844
1739
|
}
|
|
1845
|
-
function
|
|
1740
|
+
function bt(r, e) {
|
|
1846
1741
|
return r.has(e);
|
|
1847
1742
|
}
|
|
1848
|
-
function
|
|
1743
|
+
function vt(r, e, t, n) {
|
|
1849
1744
|
const o = document.createElement("div");
|
|
1850
1745
|
o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
|
|
1851
1746
|
const i = document.createElement("div");
|
|
@@ -1853,8 +1748,8 @@ function bt(r, e, t, n) {
|
|
|
1853
1748
|
const s = t(r, e);
|
|
1854
1749
|
return typeof s == "string" ? i.innerHTML = s : s instanceof HTMLElement && i.appendChild(s), o.appendChild(i), o;
|
|
1855
1750
|
}
|
|
1856
|
-
const
|
|
1857
|
-
class
|
|
1751
|
+
const xt = ".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;font-size:10px;opacity:.7;user-select:none}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border))}.master-detail-cell{padding:16px;overflow:auto}";
|
|
1752
|
+
class Rn extends x {
|
|
1858
1753
|
name = "masterDetail";
|
|
1859
1754
|
version = "1.0.0";
|
|
1860
1755
|
get defaultConfig() {
|
|
@@ -1865,14 +1760,16 @@ class yn extends x {
|
|
|
1865
1760
|
showExpandColumn: !0
|
|
1866
1761
|
};
|
|
1867
1762
|
}
|
|
1868
|
-
//
|
|
1763
|
+
// #region Internal State
|
|
1869
1764
|
expandedRows = /* @__PURE__ */ new Set();
|
|
1870
1765
|
detailElements = /* @__PURE__ */ new Map();
|
|
1871
|
-
//
|
|
1766
|
+
// #endregion
|
|
1767
|
+
// #region Lifecycle
|
|
1872
1768
|
detach() {
|
|
1873
1769
|
this.expandedRows.clear(), this.detailElements.clear();
|
|
1874
1770
|
}
|
|
1875
|
-
//
|
|
1771
|
+
// #endregion
|
|
1772
|
+
// #region Hooks
|
|
1876
1773
|
processColumns(e) {
|
|
1877
1774
|
if (!this.config.detailRenderer)
|
|
1878
1775
|
return [...e];
|
|
@@ -1888,7 +1785,7 @@ class yn extends x {
|
|
|
1888
1785
|
u.className = "master-detail-toggle", this.setIcon(u, this.resolveIcon(d ? "collapse" : "expand")), u.setAttribute("role", "button"), u.setAttribute("tabindex", "0"), u.setAttribute("aria-expanded", String(d)), u.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), u.addEventListener("click", (g) => {
|
|
1889
1786
|
g.stopPropagation();
|
|
1890
1787
|
const p = this.rows.indexOf(a);
|
|
1891
|
-
this.expandedRows =
|
|
1788
|
+
this.expandedRows = V(this.expandedRows, a), this.emit("detail-expand", {
|
|
1892
1789
|
rowIndex: p,
|
|
1893
1790
|
row: a,
|
|
1894
1791
|
expanded: this.expandedRows.has(a)
|
|
@@ -1908,7 +1805,7 @@ class yn extends x {
|
|
|
1908
1805
|
}
|
|
1909
1806
|
onRowClick(e) {
|
|
1910
1807
|
if (!(!this.config.expandOnRowClick || !this.config.detailRenderer))
|
|
1911
|
-
return this.expandedRows =
|
|
1808
|
+
return this.expandedRows = V(this.expandedRows, e.row), this.emit("detail-expand", {
|
|
1912
1809
|
rowIndex: e.rowIndex,
|
|
1913
1810
|
row: e.row,
|
|
1914
1811
|
expanded: this.expandedRows.has(e.row)
|
|
@@ -1953,7 +1850,7 @@ class yn extends x {
|
|
|
1953
1850
|
d.previousElementSibling !== l && l.after(d);
|
|
1954
1851
|
continue;
|
|
1955
1852
|
}
|
|
1956
|
-
const c =
|
|
1853
|
+
const c = vt(a, s, this.config.detailRenderer, o);
|
|
1957
1854
|
typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), l.after(c), this.detailElements.set(a, c);
|
|
1958
1855
|
}
|
|
1959
1856
|
}
|
|
@@ -2013,14 +1910,15 @@ class yn extends x {
|
|
|
2013
1910
|
}
|
|
2014
1911
|
return i;
|
|
2015
1912
|
}
|
|
2016
|
-
//
|
|
1913
|
+
// #endregion
|
|
1914
|
+
// #region Public API
|
|
2017
1915
|
/**
|
|
2018
1916
|
* Expand the detail row at the given index.
|
|
2019
1917
|
* @param rowIndex - Index of the row to expand
|
|
2020
1918
|
*/
|
|
2021
1919
|
expand(e) {
|
|
2022
1920
|
const t = this.rows[e];
|
|
2023
|
-
t && (this.expandedRows =
|
|
1921
|
+
t && (this.expandedRows = mt(this.expandedRows, t), this.requestRender());
|
|
2024
1922
|
}
|
|
2025
1923
|
/**
|
|
2026
1924
|
* Collapse the detail row at the given index.
|
|
@@ -2028,7 +1926,7 @@ class yn extends x {
|
|
|
2028
1926
|
*/
|
|
2029
1927
|
collapse(e) {
|
|
2030
1928
|
const t = this.rows[e];
|
|
2031
|
-
t && (this.expandedRows =
|
|
1929
|
+
t && (this.expandedRows = wt(this.expandedRows, t), this.requestRender());
|
|
2032
1930
|
}
|
|
2033
1931
|
/**
|
|
2034
1932
|
* Toggle the detail row at the given index.
|
|
@@ -2036,7 +1934,7 @@ class yn extends x {
|
|
|
2036
1934
|
*/
|
|
2037
1935
|
toggle(e) {
|
|
2038
1936
|
const t = this.rows[e];
|
|
2039
|
-
t && (this.expandedRows =
|
|
1937
|
+
t && (this.expandedRows = V(this.expandedRows, t), this.requestRender());
|
|
2040
1938
|
}
|
|
2041
1939
|
/**
|
|
2042
1940
|
* Check if the detail row at the given index is expanded.
|
|
@@ -2045,7 +1943,7 @@ class yn extends x {
|
|
|
2045
1943
|
*/
|
|
2046
1944
|
isExpanded(e) {
|
|
2047
1945
|
const t = this.rows[e];
|
|
2048
|
-
return t ?
|
|
1946
|
+
return t ? bt(this.expandedRows, t) : !1;
|
|
2049
1947
|
}
|
|
2050
1948
|
/**
|
|
2051
1949
|
* Expand all detail rows.
|
|
@@ -2082,10 +1980,12 @@ class yn extends x {
|
|
|
2082
1980
|
const t = this.rows[e];
|
|
2083
1981
|
return t ? this.detailElements.get(t) : void 0;
|
|
2084
1982
|
}
|
|
2085
|
-
//
|
|
2086
|
-
|
|
1983
|
+
// #endregion
|
|
1984
|
+
// #region Styles
|
|
1985
|
+
styles = xt;
|
|
1986
|
+
// #endregion
|
|
2087
1987
|
}
|
|
2088
|
-
function
|
|
1988
|
+
function yt(r, e, t) {
|
|
2089
1989
|
return e.length ? [...r].sort((n, o) => {
|
|
2090
1990
|
for (const i of e) {
|
|
2091
1991
|
const l = t.find((u) => u.field === i.field)?.sortComparator ?? Ct, a = n[i.field], d = o[i.field], c = l(a, d, n, o);
|
|
@@ -2098,7 +1998,7 @@ function xt(r, e, t) {
|
|
|
2098
1998
|
function Ct(r, e) {
|
|
2099
1999
|
return r == null && e == null ? 0 : r == null ? 1 : e == null ? -1 : typeof r == "number" && typeof e == "number" ? r - e : r instanceof Date && e instanceof Date ? r.getTime() - e.getTime() : typeof r == "boolean" && typeof e == "boolean" ? r === e ? 0 : r ? -1 : 1 : String(r).localeCompare(String(e));
|
|
2100
2000
|
}
|
|
2101
|
-
function
|
|
2001
|
+
function Rt(r, e, t, n) {
|
|
2102
2002
|
const o = r.find((i) => i.field === e);
|
|
2103
2003
|
return t ? o ? o.direction === "asc" ? r.map((i) => i.field === e ? { ...i, direction: "desc" } : i) : r.filter((i) => i.field !== e) : r.length < n ? [...r, { field: e, direction: "asc" }] : r : o?.direction === "asc" ? [{ field: e, direction: "desc" }] : o?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
|
|
2104
2004
|
}
|
|
@@ -2109,8 +2009,8 @@ function we(r, e) {
|
|
|
2109
2009
|
function be(r, e) {
|
|
2110
2010
|
return r.find((t) => t.field === e)?.direction;
|
|
2111
2011
|
}
|
|
2112
|
-
const
|
|
2113
|
-
class
|
|
2012
|
+
const St = '.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';
|
|
2013
|
+
class Sn extends x {
|
|
2114
2014
|
name = "multiSort";
|
|
2115
2015
|
version = "1.0.0";
|
|
2116
2016
|
get defaultConfig() {
|
|
@@ -2119,20 +2019,22 @@ class Rn extends x {
|
|
|
2119
2019
|
showSortIndex: !0
|
|
2120
2020
|
};
|
|
2121
2021
|
}
|
|
2122
|
-
//
|
|
2022
|
+
// #region Internal State
|
|
2123
2023
|
sortModel = [];
|
|
2124
|
-
//
|
|
2024
|
+
// #endregion
|
|
2025
|
+
// #region Lifecycle
|
|
2125
2026
|
detach() {
|
|
2126
2027
|
this.sortModel = [];
|
|
2127
2028
|
}
|
|
2128
|
-
//
|
|
2029
|
+
// #endregion
|
|
2030
|
+
// #region Hooks
|
|
2129
2031
|
processRows(e) {
|
|
2130
|
-
return this.sortModel.length === 0 ? [...e] :
|
|
2032
|
+
return this.sortModel.length === 0 ? [...e] : yt([...e], this.sortModel, [...this.columns]);
|
|
2131
2033
|
}
|
|
2132
2034
|
onHeaderClick(e) {
|
|
2133
2035
|
if (!this.columns.find((i) => i.field === e.field)?.sortable) return !1;
|
|
2134
2036
|
const n = e.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
|
|
2135
|
-
return this.sortModel =
|
|
2037
|
+
return this.sortModel = Rt(this.sortModel, e.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
2136
2038
|
}
|
|
2137
2039
|
afterRender() {
|
|
2138
2040
|
const e = this.shadowRoot;
|
|
@@ -2153,7 +2055,8 @@ class Rn extends x {
|
|
|
2153
2055
|
o.removeAttribute("data-sort");
|
|
2154
2056
|
});
|
|
2155
2057
|
}
|
|
2156
|
-
//
|
|
2058
|
+
// #endregion
|
|
2059
|
+
// #region Public API
|
|
2157
2060
|
/**
|
|
2158
2061
|
* Get the current sort model.
|
|
2159
2062
|
* @returns Copy of the current sort model
|
|
@@ -2190,7 +2093,8 @@ class Rn extends x {
|
|
|
2190
2093
|
getSortDirection(e) {
|
|
2191
2094
|
return be(this.sortModel, e);
|
|
2192
2095
|
}
|
|
2193
|
-
//
|
|
2096
|
+
// #endregion
|
|
2097
|
+
// #region Column State Hooks
|
|
2194
2098
|
/**
|
|
2195
2099
|
* Return sort state for a column if it's in the sort model.
|
|
2196
2100
|
*/
|
|
@@ -2218,16 +2122,18 @@ class Rn extends x {
|
|
|
2218
2122
|
};
|
|
2219
2123
|
n !== -1 ? this.sortModel[n] = o : this.sortModel.splice(t.sort.priority, 0, o);
|
|
2220
2124
|
}
|
|
2221
|
-
//
|
|
2222
|
-
|
|
2125
|
+
// #endregion
|
|
2126
|
+
// #region Styles
|
|
2127
|
+
styles = St;
|
|
2128
|
+
// #endregion
|
|
2223
2129
|
}
|
|
2224
|
-
function
|
|
2130
|
+
function Et(r) {
|
|
2225
2131
|
return r.filter((e) => e.sticky === "left");
|
|
2226
2132
|
}
|
|
2227
|
-
function
|
|
2133
|
+
function kt(r) {
|
|
2228
2134
|
return r.filter((e) => e.sticky === "right");
|
|
2229
2135
|
}
|
|
2230
|
-
function
|
|
2136
|
+
function z(r) {
|
|
2231
2137
|
return r.some((e) => e.sticky === "left" || e.sticky === "right");
|
|
2232
2138
|
}
|
|
2233
2139
|
function ve(r, e) {
|
|
@@ -2243,16 +2149,16 @@ function ve(r, e) {
|
|
|
2243
2149
|
for (const l of e)
|
|
2244
2150
|
if (l.sticky === "left") {
|
|
2245
2151
|
const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
|
|
2246
|
-
d && (d.classList.add("sticky-left"), d.style.left = i + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2247
|
-
c.classList.add("sticky-left"), c.style.left = i + "px";
|
|
2152
|
+
d && (d.classList.add("sticky-left"), d.style.position = "sticky", d.style.left = i + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2153
|
+
c.classList.add("sticky-left"), c.style.position = "sticky", c.style.left = i + "px";
|
|
2248
2154
|
}), i += d.offsetWidth);
|
|
2249
2155
|
}
|
|
2250
2156
|
let s = 0;
|
|
2251
2157
|
for (const l of [...e].reverse())
|
|
2252
2158
|
if (l.sticky === "right") {
|
|
2253
2159
|
const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
|
|
2254
|
-
d && (d.classList.add("sticky-right"), d.style.right = s + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2255
|
-
c.classList.add("sticky-right"), c.style.right = s + "px";
|
|
2160
|
+
d && (d.classList.add("sticky-right"), d.style.position = "sticky", d.style.right = s + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2161
|
+
c.classList.add("sticky-right"), c.style.position = "sticky", c.style.right = s + "px";
|
|
2256
2162
|
}), s += d.offsetWidth);
|
|
2257
2163
|
}
|
|
2258
2164
|
}
|
|
@@ -2260,40 +2166,43 @@ function xe(r) {
|
|
|
2260
2166
|
const e = r.shadowRoot;
|
|
2261
2167
|
if (!e) return;
|
|
2262
2168
|
e.querySelectorAll(".sticky-left, .sticky-right").forEach((n) => {
|
|
2263
|
-
n.classList.remove("sticky-left", "sticky-right"), n.style.left = "", n.style.right = "";
|
|
2169
|
+
n.classList.remove("sticky-left", "sticky-right"), n.style.position = "", n.style.left = "", n.style.right = "";
|
|
2264
2170
|
});
|
|
2265
2171
|
}
|
|
2266
|
-
class
|
|
2172
|
+
class En extends x {
|
|
2267
2173
|
name = "pinnedColumns";
|
|
2268
2174
|
version = "1.0.0";
|
|
2269
2175
|
get defaultConfig() {
|
|
2270
2176
|
return {};
|
|
2271
2177
|
}
|
|
2272
|
-
//
|
|
2178
|
+
// #region Internal State
|
|
2273
2179
|
isApplied = !1;
|
|
2274
2180
|
leftOffsets = /* @__PURE__ */ new Map();
|
|
2275
2181
|
rightOffsets = /* @__PURE__ */ new Map();
|
|
2276
|
-
//
|
|
2182
|
+
// #endregion
|
|
2183
|
+
// #region Lifecycle
|
|
2277
2184
|
detach() {
|
|
2278
2185
|
this.leftOffsets.clear(), this.rightOffsets.clear(), this.isApplied = !1;
|
|
2279
2186
|
}
|
|
2280
|
-
//
|
|
2187
|
+
// #endregion
|
|
2188
|
+
// #region Detection
|
|
2281
2189
|
/**
|
|
2282
2190
|
* Auto-detect sticky columns from column configuration.
|
|
2283
2191
|
*/
|
|
2284
2192
|
static detect(e, t) {
|
|
2285
2193
|
const n = t?.columns;
|
|
2286
|
-
return Array.isArray(n) ?
|
|
2194
|
+
return Array.isArray(n) ? z(n) : !1;
|
|
2287
2195
|
}
|
|
2288
|
-
//
|
|
2196
|
+
// #endregion
|
|
2197
|
+
// #region Hooks
|
|
2289
2198
|
processColumns(e) {
|
|
2290
|
-
return this.isApplied =
|
|
2199
|
+
return this.isApplied = z([...e]), [...e];
|
|
2291
2200
|
}
|
|
2292
2201
|
afterRender() {
|
|
2293
2202
|
if (!this.isApplied)
|
|
2294
2203
|
return;
|
|
2295
2204
|
const e = this.grid, t = [...this.columns];
|
|
2296
|
-
if (!
|
|
2205
|
+
if (!z(t)) {
|
|
2297
2206
|
xe(e), this.isApplied = !1;
|
|
2298
2207
|
return;
|
|
2299
2208
|
}
|
|
@@ -2301,7 +2210,24 @@ class Sn extends x {
|
|
|
2301
2210
|
ve(e, t);
|
|
2302
2211
|
});
|
|
2303
2212
|
}
|
|
2304
|
-
|
|
2213
|
+
/**
|
|
2214
|
+
* Handle inter-plugin queries.
|
|
2215
|
+
*/
|
|
2216
|
+
onPluginQuery(e) {
|
|
2217
|
+
switch (e.type) {
|
|
2218
|
+
case Pe.CAN_MOVE_COLUMN: {
|
|
2219
|
+
const t = e.context, n = t.sticky;
|
|
2220
|
+
if (n === "left" || n === "right")
|
|
2221
|
+
return !1;
|
|
2222
|
+
const o = t.meta?.sticky;
|
|
2223
|
+
return o === "left" || o === "right" ? !1 : void 0;
|
|
2224
|
+
}
|
|
2225
|
+
default:
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
// #endregion
|
|
2230
|
+
// #region Public API
|
|
2305
2231
|
/**
|
|
2306
2232
|
* Re-apply sticky offsets (e.g., after column resize).
|
|
2307
2233
|
*/
|
|
@@ -2314,14 +2240,14 @@ class Sn extends x {
|
|
|
2314
2240
|
*/
|
|
2315
2241
|
getLeftPinnedColumns() {
|
|
2316
2242
|
const e = [...this.columns];
|
|
2317
|
-
return
|
|
2243
|
+
return Et(e);
|
|
2318
2244
|
}
|
|
2319
2245
|
/**
|
|
2320
2246
|
* Get columns pinned to the right.
|
|
2321
2247
|
*/
|
|
2322
2248
|
getRightPinnedColumns() {
|
|
2323
2249
|
const e = [...this.columns];
|
|
2324
|
-
return
|
|
2250
|
+
return kt(e);
|
|
2325
2251
|
}
|
|
2326
2252
|
/**
|
|
2327
2253
|
* Clear all sticky positioning.
|
|
@@ -2329,6 +2255,31 @@ class Sn extends x {
|
|
|
2329
2255
|
clearStickyPositions() {
|
|
2330
2256
|
xe(this.grid);
|
|
2331
2257
|
}
|
|
2258
|
+
/**
|
|
2259
|
+
* Report horizontal scroll boundary offsets for pinned columns.
|
|
2260
|
+
* Used by keyboard navigation to ensure focused cells aren't hidden behind sticky columns.
|
|
2261
|
+
*/
|
|
2262
|
+
getHorizontalScrollOffsets(e, t) {
|
|
2263
|
+
if (!this.isApplied)
|
|
2264
|
+
return;
|
|
2265
|
+
let n = 0, o = 0;
|
|
2266
|
+
if (e) {
|
|
2267
|
+
const s = e.querySelectorAll(".sticky-left"), l = e.querySelectorAll(".sticky-right");
|
|
2268
|
+
s.forEach((a) => {
|
|
2269
|
+
n += a.offsetWidth;
|
|
2270
|
+
}), l.forEach((a) => {
|
|
2271
|
+
o += a.offsetWidth;
|
|
2272
|
+
});
|
|
2273
|
+
} else {
|
|
2274
|
+
const l = this.grid.shadowRoot;
|
|
2275
|
+
l && l.querySelectorAll(".header-row .cell").forEach((d) => {
|
|
2276
|
+
d.classList.contains("sticky-left") ? n += d.offsetWidth : d.classList.contains("sticky-right") && (o += d.offsetWidth);
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
const i = t?.classList.contains("sticky-left") || t?.classList.contains("sticky-right");
|
|
2280
|
+
return { left: n, right: o, skipScroll: i };
|
|
2281
|
+
}
|
|
2282
|
+
// #endregion
|
|
2332
2283
|
}
|
|
2333
2284
|
function W(r, e) {
|
|
2334
2285
|
const t = document.createElement("div");
|
|
@@ -2352,7 +2303,7 @@ function W(r, e) {
|
|
|
2352
2303
|
}
|
|
2353
2304
|
if (r.customPanels)
|
|
2354
2305
|
for (const s of r.customPanels) {
|
|
2355
|
-
const l =
|
|
2306
|
+
const l = At(s, e);
|
|
2356
2307
|
switch (s.position) {
|
|
2357
2308
|
case "left":
|
|
2358
2309
|
n.appendChild(l);
|
|
@@ -2367,11 +2318,11 @@ function W(r, e) {
|
|
|
2367
2318
|
}
|
|
2368
2319
|
return t.appendChild(n), t.appendChild(o), t.appendChild(i), t;
|
|
2369
2320
|
}
|
|
2370
|
-
function
|
|
2321
|
+
function ye(r) {
|
|
2371
2322
|
const e = document.createElement("div");
|
|
2372
2323
|
return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${r}`, e.setAttribute("role", "presentation"), e;
|
|
2373
2324
|
}
|
|
2374
|
-
function
|
|
2325
|
+
function Ce(r, e, t, n) {
|
|
2375
2326
|
r.innerHTML = "";
|
|
2376
2327
|
for (const o of e) {
|
|
2377
2328
|
const i = document.createElement("div");
|
|
@@ -2385,7 +2336,7 @@ function ye(r, e, t, n) {
|
|
|
2385
2336
|
let a;
|
|
2386
2337
|
const d = o.aggregators?.[s.field];
|
|
2387
2338
|
if (d) {
|
|
2388
|
-
const c =
|
|
2339
|
+
const c = Ge(d);
|
|
2389
2340
|
c && (a = c(n, s.field, s));
|
|
2390
2341
|
} else if (o.cells && Object.prototype.hasOwnProperty.call(o.cells, s.field)) {
|
|
2391
2342
|
const c = o.cells[s.field];
|
|
@@ -2396,7 +2347,7 @@ function ye(r, e, t, n) {
|
|
|
2396
2347
|
r.appendChild(i);
|
|
2397
2348
|
}
|
|
2398
2349
|
}
|
|
2399
|
-
function
|
|
2350
|
+
function At(r, e) {
|
|
2400
2351
|
const t = document.createElement("div");
|
|
2401
2352
|
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${r.id}`;
|
|
2402
2353
|
const n = r.render(e);
|
|
@@ -2412,8 +2363,8 @@ function Re(r, e, t, n, o) {
|
|
|
2412
2363
|
grid: t
|
|
2413
2364
|
};
|
|
2414
2365
|
}
|
|
2415
|
-
const
|
|
2416
|
-
class
|
|
2366
|
+
const _t = ".tbw-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";
|
|
2367
|
+
class kn extends x {
|
|
2417
2368
|
name = "pinnedRows";
|
|
2418
2369
|
version = "1.0.0";
|
|
2419
2370
|
get defaultConfig() {
|
|
@@ -2424,16 +2375,18 @@ class En extends x {
|
|
|
2424
2375
|
showFilteredCount: !0
|
|
2425
2376
|
};
|
|
2426
2377
|
}
|
|
2427
|
-
//
|
|
2378
|
+
// #region Internal State
|
|
2428
2379
|
infoBarElement = null;
|
|
2429
2380
|
topAggregationContainer = null;
|
|
2430
2381
|
bottomAggregationContainer = null;
|
|
2431
2382
|
footerWrapper = null;
|
|
2432
|
-
//
|
|
2383
|
+
// #endregion
|
|
2384
|
+
// #region Lifecycle
|
|
2433
2385
|
detach() {
|
|
2434
2386
|
this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null), this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null), this.bottomAggregationContainer && (this.bottomAggregationContainer.remove(), this.bottomAggregationContainer = null), this.footerWrapper && (this.footerWrapper.remove(), this.footerWrapper = null);
|
|
2435
2387
|
}
|
|
2436
|
-
//
|
|
2388
|
+
// #endregion
|
|
2389
|
+
// #region Hooks
|
|
2437
2390
|
afterRender() {
|
|
2438
2391
|
const e = this.shadowRoot;
|
|
2439
2392
|
if (!e) return;
|
|
@@ -2448,11 +2401,11 @@ class En extends x {
|
|
|
2448
2401
|
), s = this.config.aggregationRows || [], l = s.filter((h) => h.position === "top"), a = s.filter((h) => h.position !== "top");
|
|
2449
2402
|
if (l.length > 0) {
|
|
2450
2403
|
if (!this.topAggregationContainer) {
|
|
2451
|
-
this.topAggregationContainer =
|
|
2404
|
+
this.topAggregationContainer = ye("top");
|
|
2452
2405
|
const h = e.querySelector(".header");
|
|
2453
2406
|
h && h.nextSibling ? t.insertBefore(this.topAggregationContainer, h.nextSibling) : t.appendChild(this.topAggregationContainer);
|
|
2454
2407
|
}
|
|
2455
|
-
|
|
2408
|
+
Ce(
|
|
2456
2409
|
this.topAggregationContainer,
|
|
2457
2410
|
l,
|
|
2458
2411
|
this.visibleColumns,
|
|
@@ -2468,14 +2421,15 @@ class En extends x {
|
|
|
2468
2421
|
this.infoBarElement.replaceWith(h), this.infoBarElement = h;
|
|
2469
2422
|
}
|
|
2470
2423
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
2471
|
-
u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", a.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer =
|
|
2424
|
+
u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", a.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = ye("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), Ce(
|
|
2472
2425
|
this.bottomAggregationContainer,
|
|
2473
2426
|
a,
|
|
2474
2427
|
this.visibleColumns,
|
|
2475
2428
|
this.rows
|
|
2476
2429
|
)), c && (this.infoBarElement = W(this.config, i), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
|
|
2477
2430
|
}
|
|
2478
|
-
//
|
|
2431
|
+
// #endregion
|
|
2432
|
+
// #region Private Methods
|
|
2479
2433
|
cleanup() {
|
|
2480
2434
|
this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null), this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null), this.bottomAggregationContainer && (this.bottomAggregationContainer.remove(), this.bottomAggregationContainer = null), this.footerWrapper && (this.footerWrapper.remove(), this.footerWrapper = null);
|
|
2481
2435
|
}
|
|
@@ -2496,7 +2450,8 @@ class En extends x {
|
|
|
2496
2450
|
return null;
|
|
2497
2451
|
}
|
|
2498
2452
|
}
|
|
2499
|
-
//
|
|
2453
|
+
// #endregion
|
|
2454
|
+
// #region Public API
|
|
2500
2455
|
/**
|
|
2501
2456
|
* Refresh the status bar to reflect current grid state.
|
|
2502
2457
|
*/
|
|
@@ -2545,11 +2500,13 @@ class En extends x {
|
|
|
2545
2500
|
removeAggregationRow(e) {
|
|
2546
2501
|
this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((t) => t.id !== e), this.requestRender());
|
|
2547
2502
|
}
|
|
2548
|
-
//
|
|
2549
|
-
|
|
2503
|
+
// #endregion
|
|
2504
|
+
// #region Styles
|
|
2505
|
+
styles = _t;
|
|
2506
|
+
// #endregion
|
|
2550
2507
|
}
|
|
2551
|
-
const
|
|
2552
|
-
function
|
|
2508
|
+
const It = Oe;
|
|
2509
|
+
function Lt(r) {
|
|
2553
2510
|
const e = [];
|
|
2554
2511
|
return !r.rowGroupFields?.length && !r.columnGroupFields?.length && e.push("At least one row or column group field is required"), r.valueFields?.length || e.push("At least one value field is required"), e;
|
|
2555
2512
|
}
|
|
@@ -2557,7 +2514,7 @@ function te(r, e) {
|
|
|
2557
2514
|
return [...r, e].join("|");
|
|
2558
2515
|
}
|
|
2559
2516
|
function Ft(r, e) {
|
|
2560
|
-
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], i =
|
|
2517
|
+
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], i = Tt(r, n), s = qe(
|
|
2561
2518
|
r,
|
|
2562
2519
|
t,
|
|
2563
2520
|
n,
|
|
@@ -2567,7 +2524,7 @@ function Ft(r, e) {
|
|
|
2567
2524
|
// starting depth
|
|
2568
2525
|
""
|
|
2569
2526
|
// parent key prefix
|
|
2570
|
-
), l =
|
|
2527
|
+
), l = Nt(s, i, o), a = Object.values(l).reduce((d, c) => d + c, 0);
|
|
2571
2528
|
return {
|
|
2572
2529
|
rows: s,
|
|
2573
2530
|
columnKeys: i,
|
|
@@ -2575,7 +2532,7 @@ function Ft(r, e) {
|
|
|
2575
2532
|
grandTotal: a
|
|
2576
2533
|
};
|
|
2577
2534
|
}
|
|
2578
|
-
function
|
|
2535
|
+
function Tt(r, e) {
|
|
2579
2536
|
if (e.length === 0) return ["value"];
|
|
2580
2537
|
const t = /* @__PURE__ */ new Set();
|
|
2581
2538
|
for (const n of r) {
|
|
@@ -2584,7 +2541,7 @@ function Lt(r, e) {
|
|
|
2584
2541
|
}
|
|
2585
2542
|
return [...t].sort();
|
|
2586
2543
|
}
|
|
2587
|
-
function
|
|
2544
|
+
function Mt(r, e) {
|
|
2588
2545
|
const t = /* @__PURE__ */ new Map();
|
|
2589
2546
|
for (const n of r) {
|
|
2590
2547
|
const o = String(n[e] ?? ""), i = t.get(o);
|
|
@@ -2592,7 +2549,7 @@ function Tt(r, e) {
|
|
|
2592
2549
|
}
|
|
2593
2550
|
return t;
|
|
2594
2551
|
}
|
|
2595
|
-
function
|
|
2552
|
+
function qe(r, e, t, n, o, i, s) {
|
|
2596
2553
|
const l = [];
|
|
2597
2554
|
if (e.length === 0) {
|
|
2598
2555
|
const h = Se(r, t, n, o), g = Ee(h);
|
|
@@ -2606,11 +2563,11 @@ function Pe(r, e, t, n, o, i, s) {
|
|
|
2606
2563
|
rowCount: r.length
|
|
2607
2564
|
}), l;
|
|
2608
2565
|
}
|
|
2609
|
-
const a = e[0], d = e.slice(1), c = d.length > 0, u =
|
|
2566
|
+
const a = e[0], d = e.slice(1), c = d.length > 0, u = Mt(r, a);
|
|
2610
2567
|
for (const [h, g] of u) {
|
|
2611
2568
|
const p = s ? `${s}|${h}` : h, f = Se(g, t, n, o), m = Ee(f);
|
|
2612
2569
|
let w;
|
|
2613
|
-
c && (w =
|
|
2570
|
+
c && (w = qe(
|
|
2614
2571
|
g,
|
|
2615
2572
|
d,
|
|
2616
2573
|
t,
|
|
@@ -2635,7 +2592,7 @@ function Se(r, e, t, n) {
|
|
|
2635
2592
|
const o = {};
|
|
2636
2593
|
for (const i of t)
|
|
2637
2594
|
for (const s of n) {
|
|
2638
|
-
const a = (e.length > 0 ? r.filter((h) => e.map((g) => String(h[g] ?? "")).join("|") === i) : r).map((h) => Number(h[s.field]) || 0), d =
|
|
2595
|
+
const a = (e.length > 0 ? r.filter((h) => e.map((g) => String(h[g] ?? "")).join("|") === i) : r).map((h) => Number(h[s.field]) || 0), d = It(s.aggFunc), c = a.length > 0 ? d(a) : null, u = te([i], s.field);
|
|
2639
2596
|
o[u] = c;
|
|
2640
2597
|
}
|
|
2641
2598
|
return o;
|
|
@@ -2646,7 +2603,7 @@ function Ee(r) {
|
|
|
2646
2603
|
e += t ?? 0;
|
|
2647
2604
|
return e;
|
|
2648
2605
|
}
|
|
2649
|
-
function
|
|
2606
|
+
function Nt(r, e, t) {
|
|
2650
2607
|
const n = {};
|
|
2651
2608
|
function o(i) {
|
|
2652
2609
|
for (const s of i)
|
|
@@ -2660,7 +2617,7 @@ function Mt(r, e, t) {
|
|
|
2660
2617
|
}
|
|
2661
2618
|
return o(r), n;
|
|
2662
2619
|
}
|
|
2663
|
-
function
|
|
2620
|
+
function Pt(r, e, t = !0) {
|
|
2664
2621
|
const n = [];
|
|
2665
2622
|
function o(i) {
|
|
2666
2623
|
n.push(i);
|
|
@@ -2684,14 +2641,14 @@ function $(r) {
|
|
|
2684
2641
|
t(n);
|
|
2685
2642
|
return e;
|
|
2686
2643
|
}
|
|
2687
|
-
const
|
|
2688
|
-
function
|
|
2644
|
+
const qt = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
2645
|
+
function Dt(r, e, t, n) {
|
|
2689
2646
|
const o = new AbortController(), i = { config: e, callbacks: n, signal: o.signal }, s = document.createElement("div");
|
|
2690
|
-
return s.className = "tbw-pivot-panel", s.appendChild(
|
|
2647
|
+
return s.className = "tbw-pivot-panel", s.appendChild(L("Options", () => Bt(t, i))), s.appendChild(L("Row Groups", () => ke("rowGroups", i))), s.appendChild(L("Column Groups", () => ke("columnGroups", i))), s.appendChild(L("Values", () => Ht(i))), s.appendChild(L("Available Fields", () => Ot(i))), r.appendChild(s), () => {
|
|
2691
2648
|
o.abort(), s.remove();
|
|
2692
2649
|
};
|
|
2693
2650
|
}
|
|
2694
|
-
function
|
|
2651
|
+
function L(r, e) {
|
|
2695
2652
|
const t = document.createElement("div");
|
|
2696
2653
|
t.className = "tbw-pivot-section";
|
|
2697
2654
|
const n = document.createElement("div");
|
|
@@ -2708,7 +2665,7 @@ function ke(r, e) {
|
|
|
2708
2665
|
l.className = "tbw-pivot-placeholder", l.textContent = "Drag fields here or click to add", i.appendChild(l);
|
|
2709
2666
|
} else
|
|
2710
2667
|
for (const l of s)
|
|
2711
|
-
i.appendChild(
|
|
2668
|
+
i.appendChild(Kt(l, r, e));
|
|
2712
2669
|
return i.addEventListener(
|
|
2713
2670
|
"dragover",
|
|
2714
2671
|
(l) => {
|
|
@@ -2731,7 +2688,7 @@ function ke(r, e) {
|
|
|
2731
2688
|
{ signal: o }
|
|
2732
2689
|
), i;
|
|
2733
2690
|
}
|
|
2734
|
-
function
|
|
2691
|
+
function Kt(r, e, t) {
|
|
2735
2692
|
const { callbacks: n, signal: o } = t, i = document.createElement("div");
|
|
2736
2693
|
i.className = "tbw-pivot-field-chip", i.draggable = !0;
|
|
2737
2694
|
const s = n.getAvailableFields().find((d) => d.field === r), l = document.createElement("span");
|
|
@@ -2757,7 +2714,7 @@ function Dt(r, e, t) {
|
|
|
2757
2714
|
{ signal: o }
|
|
2758
2715
|
), i;
|
|
2759
2716
|
}
|
|
2760
|
-
function
|
|
2717
|
+
function Ht(r) {
|
|
2761
2718
|
const { config: e, callbacks: t, signal: n } = r, o = document.createElement("div");
|
|
2762
2719
|
o.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", o.setAttribute("data-zone", "values");
|
|
2763
2720
|
const i = e.valueFields ?? [];
|
|
@@ -2766,7 +2723,7 @@ function Kt(r) {
|
|
|
2766
2723
|
s.className = "tbw-pivot-placeholder", s.textContent = "Drag numeric fields here for aggregation", o.appendChild(s);
|
|
2767
2724
|
} else
|
|
2768
2725
|
for (const s of i)
|
|
2769
|
-
o.appendChild(
|
|
2726
|
+
o.appendChild(Gt(s, r));
|
|
2770
2727
|
return o.addEventListener(
|
|
2771
2728
|
"dragover",
|
|
2772
2729
|
(s) => {
|
|
@@ -2789,7 +2746,7 @@ function Kt(r) {
|
|
|
2789
2746
|
{ signal: n }
|
|
2790
2747
|
), o;
|
|
2791
2748
|
}
|
|
2792
|
-
function
|
|
2749
|
+
function Gt(r, e) {
|
|
2793
2750
|
const { callbacks: t, signal: n } = e, o = document.createElement("div");
|
|
2794
2751
|
o.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
2795
2752
|
const i = t.getAvailableFields().find((c) => c.field === r.field), s = document.createElement("div");
|
|
@@ -2798,7 +2755,7 @@ function Ht(r, e) {
|
|
|
2798
2755
|
l.className = "tbw-pivot-chip-label", l.textContent = i?.header ?? r.field;
|
|
2799
2756
|
const a = document.createElement("select");
|
|
2800
2757
|
a.className = "tbw-pivot-agg-select", a.title = "Aggregation function";
|
|
2801
|
-
for (const c of
|
|
2758
|
+
for (const c of qt) {
|
|
2802
2759
|
const u = document.createElement("option");
|
|
2803
2760
|
u.value = c, u.textContent = c.toUpperCase(), u.selected = c === r.aggFunc, a.appendChild(u);
|
|
2804
2761
|
}
|
|
@@ -2818,7 +2775,7 @@ function Ht(r, e) {
|
|
|
2818
2775
|
{ signal: n }
|
|
2819
2776
|
), s.appendChild(l), s.appendChild(a), o.appendChild(s), o.appendChild(d), o;
|
|
2820
2777
|
}
|
|
2821
|
-
function
|
|
2778
|
+
function Ot(r) {
|
|
2822
2779
|
const { config: e, callbacks: t, signal: n } = r, o = document.createElement("div");
|
|
2823
2780
|
o.className = "tbw-pivot-available-fields";
|
|
2824
2781
|
const i = t.getAvailableFields(), s = /* @__PURE__ */ new Set([
|
|
@@ -2887,7 +2844,7 @@ function j(r, e, t, n) {
|
|
|
2887
2844
|
const s = document.createElement("span");
|
|
2888
2845
|
return s.textContent = r, o.appendChild(i), o.appendChild(s), o;
|
|
2889
2846
|
}
|
|
2890
|
-
function
|
|
2847
|
+
function Vt(r, e, t) {
|
|
2891
2848
|
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(r.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((n, o) => {
|
|
2892
2849
|
const i = document.createElement("div");
|
|
2893
2850
|
if (i.className = "cell", i.setAttribute("data-col", String(o)), i.setAttribute("role", "gridcell"), o === 0) {
|
|
@@ -2923,7 +2880,7 @@ function zt(r, e, t) {
|
|
|
2923
2880
|
e.appendChild(i);
|
|
2924
2881
|
}), !0;
|
|
2925
2882
|
}
|
|
2926
|
-
function
|
|
2883
|
+
function Wt(r, e, t) {
|
|
2927
2884
|
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((n, o) => {
|
|
2928
2885
|
const i = document.createElement("div");
|
|
2929
2886
|
if (i.className = "cell", i.setAttribute("data-col", String(o)), o === 0) {
|
|
@@ -2936,8 +2893,8 @@ function Vt(r, e, t) {
|
|
|
2936
2893
|
e.appendChild(i);
|
|
2937
2894
|
}), !0;
|
|
2938
2895
|
}
|
|
2939
|
-
const
|
|
2940
|
-
class
|
|
2896
|
+
const $t = '.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;font-size:10px;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:8px 12px;font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:6px;align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:12px;transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}';
|
|
2897
|
+
class F extends x {
|
|
2941
2898
|
name = "pivot";
|
|
2942
2899
|
version = "1.0.0";
|
|
2943
2900
|
/** Tool panel ID for shell integration */
|
|
@@ -2949,7 +2906,7 @@ class L extends x {
|
|
|
2949
2906
|
showGrandTotal: !0
|
|
2950
2907
|
};
|
|
2951
2908
|
}
|
|
2952
|
-
//
|
|
2909
|
+
// #region Internal State
|
|
2953
2910
|
isActive = !1;
|
|
2954
2911
|
hasInitialized = !1;
|
|
2955
2912
|
pivotResult = null;
|
|
@@ -2965,14 +2922,16 @@ class L extends x {
|
|
|
2965
2922
|
hasValidPivotConfig() {
|
|
2966
2923
|
return (this.config.valueFields?.length ?? 0) > 0;
|
|
2967
2924
|
}
|
|
2968
|
-
//
|
|
2925
|
+
// #endregion
|
|
2926
|
+
// #region Lifecycle
|
|
2969
2927
|
detach() {
|
|
2970
2928
|
this.isActive = !1, this.hasInitialized = !1, this.pivotResult = null, this.fieldHeaderMap.clear(), this.originalColumns = [], this.panelContainer = null, this.cleanupGrandTotalFooter();
|
|
2971
2929
|
}
|
|
2972
|
-
//
|
|
2930
|
+
// #endregion
|
|
2931
|
+
// #region Shell Integration
|
|
2973
2932
|
getToolPanel() {
|
|
2974
2933
|
return {
|
|
2975
|
-
id:
|
|
2934
|
+
id: F.PANEL_ID,
|
|
2976
2935
|
title: "Pivot",
|
|
2977
2936
|
icon: "⊞",
|
|
2978
2937
|
tooltip: "Configure pivot table",
|
|
@@ -2980,11 +2939,12 @@ class L extends x {
|
|
|
2980
2939
|
render: (e) => this.renderPanel(e)
|
|
2981
2940
|
};
|
|
2982
2941
|
}
|
|
2983
|
-
//
|
|
2942
|
+
// #endregion
|
|
2943
|
+
// #region Hooks
|
|
2984
2944
|
processRows(e) {
|
|
2985
2945
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
2986
2946
|
return [...e];
|
|
2987
|
-
const t =
|
|
2947
|
+
const t = Lt(this.config);
|
|
2988
2948
|
if (t.length > 0)
|
|
2989
2949
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
2990
2950
|
if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
|
|
@@ -2998,7 +2958,7 @@ class L extends x {
|
|
|
2998
2958
|
this.expandedKeys.add(s);
|
|
2999
2959
|
}
|
|
3000
2960
|
const n = this.config.indentWidth ?? 20;
|
|
3001
|
-
return
|
|
2961
|
+
return Pt(
|
|
3002
2962
|
this.pivotResult.rows,
|
|
3003
2963
|
this.expandedKeys,
|
|
3004
2964
|
this.defaultExpanded
|
|
@@ -3043,7 +3003,7 @@ class L extends x {
|
|
|
3043
3003
|
}
|
|
3044
3004
|
renderRow(e, t) {
|
|
3045
3005
|
const n = e;
|
|
3046
|
-
return n.__pivotRowKey && n.__pivotHasChildren ?
|
|
3006
|
+
return n.__pivotRowKey && n.__pivotHasChildren ? Vt(n, t, {
|
|
3047
3007
|
columns: this.gridColumns,
|
|
3048
3008
|
onToggle: (o) => this.toggle(o),
|
|
3049
3009
|
resolveIcon: (o) => this.resolveIcon(o),
|
|
@@ -3078,7 +3038,7 @@ class L extends x {
|
|
|
3078
3038
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
3079
3039
|
...this.pivotResult.totals
|
|
3080
3040
|
};
|
|
3081
|
-
|
|
3041
|
+
Wt(n, this.grandTotalFooter, this.gridColumns);
|
|
3082
3042
|
}
|
|
3083
3043
|
/**
|
|
3084
3044
|
* Remove the grand total footer element.
|
|
@@ -3086,7 +3046,8 @@ class L extends x {
|
|
|
3086
3046
|
cleanupGrandTotalFooter() {
|
|
3087
3047
|
this.grandTotalFooter && (this.grandTotalFooter.remove(), this.grandTotalFooter = null);
|
|
3088
3048
|
}
|
|
3089
|
-
//
|
|
3049
|
+
// #endregion
|
|
3050
|
+
// #region Expand/Collapse API
|
|
3090
3051
|
toggle(e) {
|
|
3091
3052
|
this.expandedKeys.has(e) ? this.expandedKeys.delete(e) : this.expandedKeys.add(e), this.requestRender();
|
|
3092
3053
|
}
|
|
@@ -3110,7 +3071,8 @@ class L extends x {
|
|
|
3110
3071
|
isExpanded(e) {
|
|
3111
3072
|
return this.expandedKeys.has(e);
|
|
3112
3073
|
}
|
|
3113
|
-
//
|
|
3074
|
+
// #endregion
|
|
3075
|
+
// #region Public API
|
|
3114
3076
|
enablePivot() {
|
|
3115
3077
|
this.originalColumns.length === 0 && this.captureOriginalColumns(), this.isActive = !0, this.requestRender();
|
|
3116
3078
|
}
|
|
@@ -3135,20 +3097,22 @@ class L extends x {
|
|
|
3135
3097
|
refresh() {
|
|
3136
3098
|
this.pivotResult = null, this.requestRender();
|
|
3137
3099
|
}
|
|
3138
|
-
//
|
|
3100
|
+
// #endregion
|
|
3101
|
+
// #region Tool Panel API
|
|
3139
3102
|
showPanel() {
|
|
3140
|
-
this.grid.openToolPanel(
|
|
3103
|
+
this.grid.openToolPanel(F.PANEL_ID);
|
|
3141
3104
|
}
|
|
3142
3105
|
hidePanel() {
|
|
3143
3106
|
this.grid.closeToolPanel();
|
|
3144
3107
|
}
|
|
3145
3108
|
togglePanel() {
|
|
3146
|
-
this.grid.toggleToolPanel(
|
|
3109
|
+
this.grid.toggleToolPanel(F.PANEL_ID);
|
|
3147
3110
|
}
|
|
3148
3111
|
isPanelVisible() {
|
|
3149
|
-
return this.grid.activeToolPanel ===
|
|
3112
|
+
return this.grid.activeToolPanel === F.PANEL_ID;
|
|
3150
3113
|
}
|
|
3151
|
-
//
|
|
3114
|
+
// #endregion
|
|
3115
|
+
// #region Private Helpers
|
|
3152
3116
|
get gridColumns() {
|
|
3153
3117
|
return this.grid.columns ?? [];
|
|
3154
3118
|
}
|
|
@@ -3189,7 +3153,7 @@ class L extends x {
|
|
|
3189
3153
|
},
|
|
3190
3154
|
getAvailableFields: () => this.getAvailableFields()
|
|
3191
3155
|
};
|
|
3192
|
-
return
|
|
3156
|
+
return Dt(e, this.config, this.isActive, t);
|
|
3193
3157
|
}
|
|
3194
3158
|
refreshPanel() {
|
|
3195
3159
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
@@ -3221,23 +3185,22 @@ class L extends x {
|
|
|
3221
3185
|
const n = this.config.valueFields ?? [], o = n.findIndex((i) => i.field === e);
|
|
3222
3186
|
o >= 0 && (n[o] = { ...n[o], aggFunc: t }, this.config.valueFields = [...n]), this.isActive && this.refresh();
|
|
3223
3187
|
}
|
|
3224
|
-
//
|
|
3225
|
-
|
|
3188
|
+
// #endregion
|
|
3189
|
+
// #region Styles
|
|
3190
|
+
styles = $t;
|
|
3191
|
+
// #endregion
|
|
3226
3192
|
}
|
|
3227
|
-
function
|
|
3228
|
-
const e = r.
|
|
3229
|
-
|
|
3230
|
-
return !1;
|
|
3231
|
-
const t = r.meta ?? {}, n = t.sticky;
|
|
3232
|
-
return n === "left" || n === "right" ? !1 : t.lockPosition !== !0 && t.suppressMovable !== !0;
|
|
3193
|
+
function jt(r) {
|
|
3194
|
+
const e = r.meta ?? {};
|
|
3195
|
+
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
3233
3196
|
}
|
|
3234
3197
|
function Ae(r, e, t) {
|
|
3235
3198
|
if (e === t || e < 0 || e >= r.length || t < 0 || t > r.length) return r;
|
|
3236
3199
|
const n = [...r], [o] = n.splice(e, 1);
|
|
3237
3200
|
return n.splice(t, 0, o), n;
|
|
3238
3201
|
}
|
|
3239
|
-
const
|
|
3240
|
-
class
|
|
3202
|
+
const Ut = '.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}';
|
|
3203
|
+
class An extends x {
|
|
3241
3204
|
name = "reorder";
|
|
3242
3205
|
version = "1.0.0";
|
|
3243
3206
|
get defaultConfig() {
|
|
@@ -3246,12 +3209,13 @@ class kn extends x {
|
|
|
3246
3209
|
animationDuration: 200
|
|
3247
3210
|
};
|
|
3248
3211
|
}
|
|
3249
|
-
//
|
|
3212
|
+
// #region Internal State
|
|
3250
3213
|
isDragging = !1;
|
|
3251
3214
|
draggedField = null;
|
|
3252
3215
|
draggedIndex = null;
|
|
3253
3216
|
dropIndex = null;
|
|
3254
|
-
//
|
|
3217
|
+
// #endregion
|
|
3218
|
+
// #region Lifecycle
|
|
3255
3219
|
attach(e) {
|
|
3256
3220
|
super.attach(e), e.addEventListener(
|
|
3257
3221
|
"column-reorder-request",
|
|
@@ -3265,7 +3229,8 @@ class kn extends x {
|
|
|
3265
3229
|
detach() {
|
|
3266
3230
|
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
|
|
3267
3231
|
}
|
|
3268
|
-
//
|
|
3232
|
+
// #endregion
|
|
3233
|
+
// #region Hooks
|
|
3269
3234
|
// Note: No processColumns hook needed - we directly update the grid's column order
|
|
3270
3235
|
afterRender() {
|
|
3271
3236
|
const e = this.shadowRoot;
|
|
@@ -3273,40 +3238,44 @@ class kn extends x {
|
|
|
3273
3238
|
e.querySelectorAll(".header-row > .cell").forEach((n) => {
|
|
3274
3239
|
const o = n, i = o.getAttribute("data-field");
|
|
3275
3240
|
if (!i) return;
|
|
3276
|
-
const s = this.columns.find((
|
|
3277
|
-
|
|
3241
|
+
const s = this.columns.find((c) => c.field === i), d = !this.grid.queryPlugins({
|
|
3242
|
+
type: Pe.CAN_MOVE_COLUMN,
|
|
3243
|
+
context: s
|
|
3244
|
+
}).includes(!1);
|
|
3245
|
+
if (!s || !jt(s) || !d) {
|
|
3278
3246
|
o.draggable = !1;
|
|
3279
3247
|
return;
|
|
3280
3248
|
}
|
|
3281
|
-
o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (
|
|
3282
|
-
const
|
|
3283
|
-
this.isDragging = !0, this.draggedField = i, this.draggedIndex =
|
|
3249
|
+
o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (c) => {
|
|
3250
|
+
const h = this.getColumnOrder().indexOf(i);
|
|
3251
|
+
this.isDragging = !0, this.draggedField = i, this.draggedIndex = h, c.dataTransfer && (c.dataTransfer.effectAllowed = "move", c.dataTransfer.setData("text/plain", i)), o.classList.add("dragging");
|
|
3284
3252
|
}), o.addEventListener("dragend", () => {
|
|
3285
|
-
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((
|
|
3286
|
-
|
|
3253
|
+
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((c) => {
|
|
3254
|
+
c.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
3287
3255
|
});
|
|
3288
|
-
}), o.addEventListener("dragover", (
|
|
3289
|
-
if (
|
|
3290
|
-
const
|
|
3291
|
-
this.dropIndex =
|
|
3256
|
+
}), o.addEventListener("dragover", (c) => {
|
|
3257
|
+
if (c.preventDefault(), !this.isDragging || this.draggedField === i) return;
|
|
3258
|
+
const u = o.getBoundingClientRect(), h = u.left + u.width / 2, p = this.getColumnOrder().indexOf(i);
|
|
3259
|
+
this.dropIndex = c.clientX < h ? p : p + 1, o.classList.add("drop-target"), o.classList.toggle("drop-before", c.clientX < h), o.classList.toggle("drop-after", c.clientX >= h);
|
|
3292
3260
|
}), o.addEventListener("dragleave", () => {
|
|
3293
3261
|
o.classList.remove("drop-target", "drop-before", "drop-after");
|
|
3294
|
-
}), o.addEventListener("drop", (
|
|
3295
|
-
|
|
3296
|
-
const
|
|
3297
|
-
if (!this.isDragging ||
|
|
3262
|
+
}), o.addEventListener("drop", (c) => {
|
|
3263
|
+
c.preventDefault();
|
|
3264
|
+
const u = this.draggedField, h = this.draggedIndex, g = this.dropIndex;
|
|
3265
|
+
if (!this.isDragging || u === null || h === null || g === null)
|
|
3298
3266
|
return;
|
|
3299
|
-
const
|
|
3300
|
-
field:
|
|
3301
|
-
fromIndex:
|
|
3302
|
-
toIndex:
|
|
3303
|
-
columnOrder:
|
|
3267
|
+
const p = g > h ? g - 1 : g, f = this.getColumnOrder(), m = Ae(f, h, p), w = {
|
|
3268
|
+
field: u,
|
|
3269
|
+
fromIndex: h,
|
|
3270
|
+
toIndex: p,
|
|
3271
|
+
columnOrder: m
|
|
3304
3272
|
};
|
|
3305
|
-
this.grid.setColumnOrder(
|
|
3273
|
+
this.grid.setColumnOrder(m), this.emit("column-move", w), this.grid.requestStateChange?.();
|
|
3306
3274
|
}));
|
|
3307
3275
|
});
|
|
3308
3276
|
}
|
|
3309
|
-
//
|
|
3277
|
+
// #endregion
|
|
3278
|
+
// #region Public API
|
|
3310
3279
|
/**
|
|
3311
3280
|
* Get the current column order from the grid.
|
|
3312
3281
|
* @returns Array of field names in display order
|
|
@@ -3344,8 +3313,10 @@ class kn extends x {
|
|
|
3344
3313
|
const e = this.columns.map((t) => t.field);
|
|
3345
3314
|
this.grid.setColumnOrder(e), this.grid.requestStateChange?.();
|
|
3346
3315
|
}
|
|
3347
|
-
//
|
|
3348
|
-
|
|
3316
|
+
// #endregion
|
|
3317
|
+
// #region Styles
|
|
3318
|
+
styles = Ut;
|
|
3319
|
+
// #endregion
|
|
3349
3320
|
}
|
|
3350
3321
|
function D(r) {
|
|
3351
3322
|
return {
|
|
@@ -3355,7 +3326,7 @@ function D(r) {
|
|
|
3355
3326
|
endCol: Math.max(r.startCol, r.endCol)
|
|
3356
3327
|
};
|
|
3357
3328
|
}
|
|
3358
|
-
function
|
|
3329
|
+
function Yt(r) {
|
|
3359
3330
|
const e = D(r);
|
|
3360
3331
|
return {
|
|
3361
3332
|
from: { row: e.startRow, col: e.startCol },
|
|
@@ -3363,26 +3334,26 @@ function Ut(r) {
|
|
|
3363
3334
|
};
|
|
3364
3335
|
}
|
|
3365
3336
|
function X(r) {
|
|
3366
|
-
return r.map(
|
|
3337
|
+
return r.map(Yt);
|
|
3367
3338
|
}
|
|
3368
|
-
function
|
|
3339
|
+
function Zt(r, e, t) {
|
|
3369
3340
|
const n = D(t);
|
|
3370
3341
|
return r >= n.startRow && r <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
3371
3342
|
}
|
|
3372
3343
|
function _e(r, e, t) {
|
|
3373
|
-
return t.some((n) =>
|
|
3344
|
+
return t.some((n) => Zt(r, e, n));
|
|
3374
3345
|
}
|
|
3375
|
-
function
|
|
3346
|
+
function Xt(r) {
|
|
3376
3347
|
const e = [], t = D(r);
|
|
3377
3348
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
3378
3349
|
for (let o = t.startCol; o <= t.endCol; o++)
|
|
3379
3350
|
e.push({ row: n, col: o });
|
|
3380
3351
|
return e;
|
|
3381
3352
|
}
|
|
3382
|
-
function
|
|
3353
|
+
function Jt(r) {
|
|
3383
3354
|
const e = /* @__PURE__ */ new Map();
|
|
3384
3355
|
for (const t of r)
|
|
3385
|
-
for (const n of
|
|
3356
|
+
for (const n of Xt(t))
|
|
3386
3357
|
e.set(`${n.row},${n.col}`, n);
|
|
3387
3358
|
return [...e.values()];
|
|
3388
3359
|
}
|
|
@@ -3394,8 +3365,8 @@ function U(r, e) {
|
|
|
3394
3365
|
endCol: e.col
|
|
3395
3366
|
};
|
|
3396
3367
|
}
|
|
3397
|
-
const
|
|
3398
|
-
function
|
|
3368
|
+
const Qt = ':host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';
|
|
3369
|
+
function en(r, e, t) {
|
|
3399
3370
|
if (r === "cell" && e.selectedCell)
|
|
3400
3371
|
return {
|
|
3401
3372
|
mode: r,
|
|
@@ -3415,7 +3386,7 @@ function Qt(r, e, t) {
|
|
|
3415
3386
|
}
|
|
3416
3387
|
return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: X(e.ranges) } : { mode: r, ranges: [] };
|
|
3417
3388
|
}
|
|
3418
|
-
class
|
|
3389
|
+
class _n extends x {
|
|
3419
3390
|
name = "selection";
|
|
3420
3391
|
version = "1.0.0";
|
|
3421
3392
|
get defaultConfig() {
|
|
@@ -3423,7 +3394,7 @@ class An extends x {
|
|
|
3423
3394
|
mode: "cell"
|
|
3424
3395
|
};
|
|
3425
3396
|
}
|
|
3426
|
-
//
|
|
3397
|
+
// #region Internal State
|
|
3427
3398
|
/** Row selection state (row mode) */
|
|
3428
3399
|
selected = /* @__PURE__ */ new Set();
|
|
3429
3400
|
lastSelected = null;
|
|
@@ -3435,11 +3406,13 @@ class An extends x {
|
|
|
3435
3406
|
isDragging = !1;
|
|
3436
3407
|
/** Cell selection state (cell mode) */
|
|
3437
3408
|
selectedCell = null;
|
|
3438
|
-
//
|
|
3409
|
+
// #endregion
|
|
3410
|
+
// #region Lifecycle
|
|
3439
3411
|
detach() {
|
|
3440
3412
|
this.selected.clear(), this.ranges = [], this.activeRange = null, this.cellAnchor = null, this.isDragging = !1, this.selectedCell = null;
|
|
3441
3413
|
}
|
|
3442
|
-
//
|
|
3414
|
+
// #endregion
|
|
3415
|
+
// #region Event Handlers
|
|
3443
3416
|
onCellClick(e) {
|
|
3444
3417
|
const { rowIndex: t, colIndex: n, originalEvent: o } = e, { mode: i } = this.config;
|
|
3445
3418
|
if (i === "cell")
|
|
@@ -3573,7 +3546,8 @@ class An extends x {
|
|
|
3573
3546
|
onScrollRender() {
|
|
3574
3547
|
this.#t();
|
|
3575
3548
|
}
|
|
3576
|
-
//
|
|
3549
|
+
// #endregion
|
|
3550
|
+
// #region Public API
|
|
3577
3551
|
/**
|
|
3578
3552
|
* Get the selected cell (cell mode only).
|
|
3579
3553
|
*/
|
|
@@ -3596,7 +3570,7 @@ class An extends x {
|
|
|
3596
3570
|
* Get all selected cells across all ranges.
|
|
3597
3571
|
*/
|
|
3598
3572
|
getSelectedCells() {
|
|
3599
|
-
return
|
|
3573
|
+
return Jt(this.ranges);
|
|
3600
3574
|
}
|
|
3601
3575
|
/**
|
|
3602
3576
|
* Check if a specific cell is in range selection.
|
|
@@ -3624,9 +3598,10 @@ class An extends x {
|
|
|
3624
3598
|
ranges: X(this.ranges)
|
|
3625
3599
|
}), this.requestAfterRender();
|
|
3626
3600
|
}
|
|
3627
|
-
//
|
|
3601
|
+
// #endregion
|
|
3602
|
+
// #region Private Helpers
|
|
3628
3603
|
#e() {
|
|
3629
|
-
return
|
|
3604
|
+
return en(
|
|
3630
3605
|
this.config.mode,
|
|
3631
3606
|
{
|
|
3632
3607
|
selectedCell: this.selectedCell,
|
|
@@ -3636,26 +3611,28 @@ class An extends x {
|
|
|
3636
3611
|
this.columns.length
|
|
3637
3612
|
);
|
|
3638
3613
|
}
|
|
3639
|
-
//
|
|
3640
|
-
|
|
3614
|
+
// #endregion
|
|
3615
|
+
// #region Styles
|
|
3616
|
+
styles = Qt;
|
|
3617
|
+
// #endregion
|
|
3641
3618
|
}
|
|
3642
3619
|
function q(r, e) {
|
|
3643
3620
|
return Math.floor(r / e);
|
|
3644
3621
|
}
|
|
3645
|
-
function
|
|
3622
|
+
function tn(r, e) {
|
|
3646
3623
|
return {
|
|
3647
3624
|
start: r * e,
|
|
3648
3625
|
end: (r + 1) * e
|
|
3649
3626
|
};
|
|
3650
3627
|
}
|
|
3651
|
-
function
|
|
3628
|
+
function nn(r, e, t) {
|
|
3652
3629
|
const n = q(r, t), o = q(e - 1, t), i = [];
|
|
3653
3630
|
for (let s = n; s <= o; s++)
|
|
3654
3631
|
i.push(s);
|
|
3655
3632
|
return i;
|
|
3656
3633
|
}
|
|
3657
3634
|
async function Ie(r, e, t, n) {
|
|
3658
|
-
const o =
|
|
3635
|
+
const o = tn(e, t);
|
|
3659
3636
|
return r.getRows({
|
|
3660
3637
|
startRow: o.start,
|
|
3661
3638
|
endRow: o.end,
|
|
@@ -3663,14 +3640,14 @@ async function Ie(r, e, t, n) {
|
|
|
3663
3640
|
filterModel: n.filterModel
|
|
3664
3641
|
});
|
|
3665
3642
|
}
|
|
3666
|
-
function
|
|
3643
|
+
function on(r, e, t) {
|
|
3667
3644
|
const n = q(r, e), o = t.get(n);
|
|
3668
3645
|
if (!o) return;
|
|
3669
3646
|
const i = r % e;
|
|
3670
3647
|
return o[i];
|
|
3671
3648
|
}
|
|
3672
|
-
const
|
|
3673
|
-
class
|
|
3649
|
+
const rn = 100;
|
|
3650
|
+
class In extends x {
|
|
3674
3651
|
name = "serverSide";
|
|
3675
3652
|
version = "1.0.0";
|
|
3676
3653
|
get defaultConfig() {
|
|
@@ -3680,24 +3657,26 @@ class _n extends x {
|
|
|
3680
3657
|
maxConcurrentRequests: 2
|
|
3681
3658
|
};
|
|
3682
3659
|
}
|
|
3683
|
-
//
|
|
3660
|
+
// #region Internal State
|
|
3684
3661
|
dataSource = null;
|
|
3685
3662
|
totalRowCount = 0;
|
|
3686
3663
|
loadedBlocks = /* @__PURE__ */ new Map();
|
|
3687
3664
|
loadingBlocks = /* @__PURE__ */ new Set();
|
|
3688
3665
|
lastRequestId = 0;
|
|
3689
3666
|
scrollDebounceTimer;
|
|
3690
|
-
//
|
|
3667
|
+
// #endregion
|
|
3668
|
+
// #region Lifecycle
|
|
3691
3669
|
detach() {
|
|
3692
3670
|
this.dataSource = null, this.totalRowCount = 0, this.loadedBlocks.clear(), this.loadingBlocks.clear(), this.lastRequestId = 0, this.scrollDebounceTimer && (clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = void 0);
|
|
3693
3671
|
}
|
|
3694
|
-
//
|
|
3672
|
+
// #endregion
|
|
3673
|
+
// #region Private Methods
|
|
3695
3674
|
/**
|
|
3696
3675
|
* Check current viewport and load any missing blocks.
|
|
3697
3676
|
*/
|
|
3698
3677
|
loadRequiredBlocks() {
|
|
3699
3678
|
if (!this.dataSource) return;
|
|
3700
|
-
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, o =
|
|
3679
|
+
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, o = nn(n.startRow, n.endRow, t);
|
|
3701
3680
|
for (const i of o)
|
|
3702
3681
|
if (!(this.loadedBlocks.has(i) || this.loadingBlocks.has(i))) {
|
|
3703
3682
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
@@ -3709,12 +3688,13 @@ class _n extends x {
|
|
|
3709
3688
|
});
|
|
3710
3689
|
}
|
|
3711
3690
|
}
|
|
3712
|
-
//
|
|
3691
|
+
// #endregion
|
|
3692
|
+
// #region Hooks
|
|
3713
3693
|
processRows(e) {
|
|
3714
3694
|
if (!this.dataSource) return [...e];
|
|
3715
3695
|
const t = [];
|
|
3716
3696
|
for (let n = 0; n < this.totalRowCount; n++) {
|
|
3717
|
-
const o =
|
|
3697
|
+
const o = on(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
3718
3698
|
t.push(o ?? { __loading: !0, __index: n });
|
|
3719
3699
|
}
|
|
3720
3700
|
return t;
|
|
@@ -3722,9 +3702,10 @@ class _n extends x {
|
|
|
3722
3702
|
onScroll(e) {
|
|
3723
3703
|
this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
|
|
3724
3704
|
this.loadRequiredBlocks();
|
|
3725
|
-
},
|
|
3705
|
+
}, rn));
|
|
3726
3706
|
}
|
|
3727
|
-
//
|
|
3707
|
+
// #endregion
|
|
3708
|
+
// #region Public API
|
|
3728
3709
|
/**
|
|
3729
3710
|
* Set the data source for server-side loading.
|
|
3730
3711
|
* @param dataSource - Data source implementing the getRows method
|
|
@@ -3768,11 +3749,12 @@ class _n extends x {
|
|
|
3768
3749
|
getLoadedBlockCount() {
|
|
3769
3750
|
return this.loadedBlocks.size;
|
|
3770
3751
|
}
|
|
3752
|
+
// #endregion
|
|
3771
3753
|
}
|
|
3772
3754
|
function ne(r, e, t) {
|
|
3773
3755
|
return r.id !== void 0 ? String(r.id) : t ? `${t}-${e}` : String(e);
|
|
3774
3756
|
}
|
|
3775
|
-
function
|
|
3757
|
+
function De(r, e, t, n = null, o = 0) {
|
|
3776
3758
|
const i = e.childrenField ?? "children", s = [];
|
|
3777
3759
|
for (let l = 0; l < r.length; l++) {
|
|
3778
3760
|
const a = r[l], d = ne(a, l, n), c = a[i], u = Array.isArray(c) && c.length > 0, h = t.has(d);
|
|
@@ -3784,13 +3766,13 @@ function qe(r, e, t, n = null, o = 0) {
|
|
|
3784
3766
|
isExpanded: h,
|
|
3785
3767
|
parentKey: n
|
|
3786
3768
|
}), u && h) {
|
|
3787
|
-
const g =
|
|
3769
|
+
const g = De(c, e, t, d, o + 1);
|
|
3788
3770
|
s.push(...g);
|
|
3789
3771
|
}
|
|
3790
3772
|
}
|
|
3791
3773
|
return s;
|
|
3792
3774
|
}
|
|
3793
|
-
function
|
|
3775
|
+
function Le(r, e) {
|
|
3794
3776
|
const t = new Set(r);
|
|
3795
3777
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
3796
3778
|
}
|
|
@@ -3806,10 +3788,10 @@ function J(r, e, t = null, n = 0) {
|
|
|
3806
3788
|
}
|
|
3807
3789
|
return i;
|
|
3808
3790
|
}
|
|
3809
|
-
function
|
|
3791
|
+
function sn() {
|
|
3810
3792
|
return /* @__PURE__ */ new Set();
|
|
3811
3793
|
}
|
|
3812
|
-
function
|
|
3794
|
+
function Ke(r, e, t, n = null, o = 0) {
|
|
3813
3795
|
const i = t.childrenField ?? "children";
|
|
3814
3796
|
for (let s = 0; s < r.length; s++) {
|
|
3815
3797
|
const l = r[s], a = ne(l, s, n);
|
|
@@ -3817,29 +3799,29 @@ function De(r, e, t, n = null, o = 0) {
|
|
|
3817
3799
|
return [a];
|
|
3818
3800
|
const d = l[i];
|
|
3819
3801
|
if (Array.isArray(d) && d.length > 0) {
|
|
3820
|
-
const c =
|
|
3802
|
+
const c = Ke(d, e, t, a, o + 1);
|
|
3821
3803
|
if (c)
|
|
3822
3804
|
return [a, ...c];
|
|
3823
3805
|
}
|
|
3824
3806
|
}
|
|
3825
3807
|
return null;
|
|
3826
3808
|
}
|
|
3827
|
-
function
|
|
3828
|
-
const o =
|
|
3809
|
+
function ln(r, e, t, n) {
|
|
3810
|
+
const o = Ke(r, e, t);
|
|
3829
3811
|
if (!o) return n;
|
|
3830
3812
|
const i = new Set(n);
|
|
3831
3813
|
for (let s = 0; s < o.length - 1; s++)
|
|
3832
3814
|
i.add(o[s]);
|
|
3833
3815
|
return i;
|
|
3834
3816
|
}
|
|
3835
|
-
function
|
|
3817
|
+
function Fe(r, e = "children") {
|
|
3836
3818
|
if (!Array.isArray(r) || r.length === 0) return !1;
|
|
3837
3819
|
for (const t of r)
|
|
3838
3820
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
3839
3821
|
return !0;
|
|
3840
3822
|
return !1;
|
|
3841
3823
|
}
|
|
3842
|
-
function
|
|
3824
|
+
function an(r) {
|
|
3843
3825
|
if (!Array.isArray(r) || r.length === 0) return null;
|
|
3844
3826
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
3845
3827
|
for (const t of r)
|
|
@@ -3850,8 +3832,8 @@ function ln(r) {
|
|
|
3850
3832
|
}
|
|
3851
3833
|
return null;
|
|
3852
3834
|
}
|
|
3853
|
-
const
|
|
3854
|
-
class
|
|
3835
|
+
const dn = ".tree-toggle{cursor:pointer;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
|
|
3836
|
+
class Ln extends x {
|
|
3855
3837
|
name = "tree";
|
|
3856
3838
|
version = "1.0.0";
|
|
3857
3839
|
get defaultConfig() {
|
|
@@ -3863,7 +3845,7 @@ class In extends x {
|
|
|
3863
3845
|
showExpandIcons: !0
|
|
3864
3846
|
};
|
|
3865
3847
|
}
|
|
3866
|
-
//
|
|
3848
|
+
// #region Internal State
|
|
3867
3849
|
/** Set of expanded row keys */
|
|
3868
3850
|
expandedKeys = /* @__PURE__ */ new Set();
|
|
3869
3851
|
/** Whether initial expansion (based on defaultExpanded config) has been applied */
|
|
@@ -3872,26 +3854,29 @@ class In extends x {
|
|
|
3872
3854
|
flattenedRows = [];
|
|
3873
3855
|
/** Map from key to flattened row for quick lookup */
|
|
3874
3856
|
rowKeyMap = /* @__PURE__ */ new Map();
|
|
3875
|
-
//
|
|
3857
|
+
// #endregion
|
|
3858
|
+
// #region Lifecycle
|
|
3876
3859
|
detach() {
|
|
3877
3860
|
this.expandedKeys.clear(), this.initialExpansionDone = !1, this.flattenedRows = [], this.rowKeyMap.clear();
|
|
3878
3861
|
}
|
|
3879
|
-
//
|
|
3862
|
+
// #endregion
|
|
3863
|
+
// #region Auto-Detection
|
|
3880
3864
|
/**
|
|
3881
3865
|
* Detects if tree functionality should be enabled based on data structure.
|
|
3882
3866
|
* Called by the grid during plugin initialization.
|
|
3883
3867
|
*/
|
|
3884
3868
|
detect(e) {
|
|
3885
3869
|
if (!this.config.autoDetect) return !1;
|
|
3886
|
-
const t = this.config.childrenField ??
|
|
3887
|
-
return
|
|
3870
|
+
const t = this.config.childrenField ?? an(e) ?? "children";
|
|
3871
|
+
return Fe(e, t);
|
|
3888
3872
|
}
|
|
3889
|
-
//
|
|
3873
|
+
// #endregion
|
|
3874
|
+
// #region Data Processing
|
|
3890
3875
|
processRows(e) {
|
|
3891
3876
|
const t = this.config.childrenField ?? "children";
|
|
3892
|
-
if (!
|
|
3877
|
+
if (!Fe(e, t))
|
|
3893
3878
|
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
3894
|
-
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = J(e, this.config), this.initialExpansionDone = !0), this.flattenedRows =
|
|
3879
|
+
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = J(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = De(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
3895
3880
|
for (const n of this.flattenedRows)
|
|
3896
3881
|
this.rowKeyMap.set(n.key, n);
|
|
3897
3882
|
return this.flattenedRows.map((n) => ({
|
|
@@ -3930,21 +3915,23 @@ class In extends x {
|
|
|
3930
3915
|
}
|
|
3931
3916
|
return o;
|
|
3932
3917
|
}
|
|
3933
|
-
//
|
|
3918
|
+
// #endregion
|
|
3919
|
+
// #region Event Handlers
|
|
3934
3920
|
onCellClick(e) {
|
|
3935
3921
|
const t = e.originalEvent?.target;
|
|
3936
3922
|
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
3937
3923
|
const n = t.getAttribute("data-tree-key");
|
|
3938
3924
|
if (!n) return !1;
|
|
3939
3925
|
const o = this.rowKeyMap.get(n);
|
|
3940
|
-
return o ? (this.expandedKeys =
|
|
3926
|
+
return o ? (this.expandedKeys = Le(this.expandedKeys, n), this.emit("tree-expand", {
|
|
3941
3927
|
key: n,
|
|
3942
3928
|
row: o.data,
|
|
3943
3929
|
expanded: this.expandedKeys.has(n),
|
|
3944
3930
|
depth: o.depth
|
|
3945
3931
|
}), this.requestRender(), !0) : !1;
|
|
3946
3932
|
}
|
|
3947
|
-
//
|
|
3933
|
+
// #endregion
|
|
3934
|
+
// #region Public API
|
|
3948
3935
|
/**
|
|
3949
3936
|
* Expand a specific node by key.
|
|
3950
3937
|
*/
|
|
@@ -3961,7 +3948,7 @@ class In extends x {
|
|
|
3961
3948
|
* Toggle the expansion state of a node.
|
|
3962
3949
|
*/
|
|
3963
3950
|
toggle(e) {
|
|
3964
|
-
this.expandedKeys =
|
|
3951
|
+
this.expandedKeys = Le(this.expandedKeys, e), this.requestRender();
|
|
3965
3952
|
}
|
|
3966
3953
|
/**
|
|
3967
3954
|
* Expand all nodes in the tree.
|
|
@@ -3973,7 +3960,7 @@ class In extends x {
|
|
|
3973
3960
|
* Collapse all nodes in the tree.
|
|
3974
3961
|
*/
|
|
3975
3962
|
collapseAll() {
|
|
3976
|
-
this.expandedKeys =
|
|
3963
|
+
this.expandedKeys = sn(), this.requestRender();
|
|
3977
3964
|
}
|
|
3978
3965
|
/**
|
|
3979
3966
|
* Check if a node is currently expanded.
|
|
@@ -4003,12 +3990,14 @@ class In extends x {
|
|
|
4003
3990
|
* Expand all ancestors of a node to make it visible.
|
|
4004
3991
|
*/
|
|
4005
3992
|
expandToKey(e) {
|
|
4006
|
-
this.expandedKeys =
|
|
3993
|
+
this.expandedKeys = ln(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
4007
3994
|
}
|
|
4008
|
-
//
|
|
4009
|
-
|
|
3995
|
+
// #endregion
|
|
3996
|
+
// #region Styles
|
|
3997
|
+
styles = dn;
|
|
3998
|
+
// #endregion
|
|
4010
3999
|
}
|
|
4011
|
-
function
|
|
4000
|
+
function cn(r, e, t) {
|
|
4012
4001
|
const n = [...r.undoStack, e];
|
|
4013
4002
|
for (; n.length > t; )
|
|
4014
4003
|
n.shift();
|
|
@@ -4042,16 +4031,16 @@ function Me(r) {
|
|
|
4042
4031
|
action: t
|
|
4043
4032
|
} : { newState: r, action: null };
|
|
4044
4033
|
}
|
|
4045
|
-
function
|
|
4034
|
+
function un(r) {
|
|
4046
4035
|
return r.undoStack.length > 0;
|
|
4047
4036
|
}
|
|
4048
|
-
function
|
|
4037
|
+
function hn(r) {
|
|
4049
4038
|
return r.redoStack.length > 0;
|
|
4050
4039
|
}
|
|
4051
|
-
function
|
|
4040
|
+
function gn() {
|
|
4052
4041
|
return { undoStack: [], redoStack: [] };
|
|
4053
4042
|
}
|
|
4054
|
-
function
|
|
4043
|
+
function pn(r, e, t, n) {
|
|
4055
4044
|
return {
|
|
4056
4045
|
type: "cell-edit",
|
|
4057
4046
|
rowIndex: r,
|
|
@@ -4109,7 +4098,7 @@ class Fn extends x {
|
|
|
4109
4098
|
}
|
|
4110
4099
|
return !1;
|
|
4111
4100
|
}
|
|
4112
|
-
//
|
|
4101
|
+
// #region Public API Methods
|
|
4113
4102
|
/**
|
|
4114
4103
|
* Record a cell edit for undo/redo tracking.
|
|
4115
4104
|
* Call this when a cell value changes.
|
|
@@ -4120,7 +4109,7 @@ class Fn extends x {
|
|
|
4120
4109
|
* @param newValue - The value after the edit
|
|
4121
4110
|
*/
|
|
4122
4111
|
recordEdit(e, t, n, o) {
|
|
4123
|
-
const i =
|
|
4112
|
+
const i = pn(e, t, n, o), s = cn(
|
|
4124
4113
|
{ undoStack: this.undoStack, redoStack: this.redoStack },
|
|
4125
4114
|
i,
|
|
4126
4115
|
this.config.maxHistorySize ?? 100
|
|
@@ -4157,19 +4146,19 @@ class Fn extends x {
|
|
|
4157
4146
|
* Check if there are any actions that can be undone.
|
|
4158
4147
|
*/
|
|
4159
4148
|
canUndo() {
|
|
4160
|
-
return
|
|
4149
|
+
return un({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4161
4150
|
}
|
|
4162
4151
|
/**
|
|
4163
4152
|
* Check if there are any actions that can be redone.
|
|
4164
4153
|
*/
|
|
4165
4154
|
canRedo() {
|
|
4166
|
-
return
|
|
4155
|
+
return hn({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4167
4156
|
}
|
|
4168
4157
|
/**
|
|
4169
4158
|
* Clear all undo/redo history.
|
|
4170
4159
|
*/
|
|
4171
4160
|
clearHistory() {
|
|
4172
|
-
const e =
|
|
4161
|
+
const e = gn();
|
|
4173
4162
|
this.undoStack = e.undoStack, this.redoStack = e.redoStack;
|
|
4174
4163
|
}
|
|
4175
4164
|
/**
|
|
@@ -4184,8 +4173,9 @@ class Fn extends x {
|
|
|
4184
4173
|
getRedoStack() {
|
|
4185
4174
|
return [...this.redoStack];
|
|
4186
4175
|
}
|
|
4176
|
+
// #endregion
|
|
4187
4177
|
}
|
|
4188
|
-
const
|
|
4178
|
+
const fn = '.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:10px;letter-spacing:-2px;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:8px;flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';
|
|
4189
4179
|
function Ne(r) {
|
|
4190
4180
|
const e = r.meta ?? {};
|
|
4191
4181
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
@@ -4200,18 +4190,20 @@ class T extends x {
|
|
|
4200
4190
|
allowHideAll: !1
|
|
4201
4191
|
};
|
|
4202
4192
|
}
|
|
4203
|
-
//
|
|
4193
|
+
// #region Internal State
|
|
4204
4194
|
columnListElement = null;
|
|
4205
4195
|
// Drag state for reorder integration
|
|
4206
4196
|
isDragging = !1;
|
|
4207
4197
|
draggedField = null;
|
|
4208
4198
|
draggedIndex = null;
|
|
4209
4199
|
dropIndex = null;
|
|
4210
|
-
//
|
|
4200
|
+
// #endregion
|
|
4201
|
+
// #region Lifecycle
|
|
4211
4202
|
detach() {
|
|
4212
4203
|
this.columnListElement = null, this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
|
|
4213
4204
|
}
|
|
4214
|
-
//
|
|
4205
|
+
// #endregion
|
|
4206
|
+
// #region Shell Integration
|
|
4215
4207
|
/**
|
|
4216
4208
|
* Register the column visibility tool panel with the shell.
|
|
4217
4209
|
*/
|
|
@@ -4226,7 +4218,8 @@ class T extends x {
|
|
|
4226
4218
|
render: (e) => this.renderPanelContent(e)
|
|
4227
4219
|
};
|
|
4228
4220
|
}
|
|
4229
|
-
//
|
|
4221
|
+
// #endregion
|
|
4222
|
+
// #region Public API
|
|
4230
4223
|
/**
|
|
4231
4224
|
* Show the visibility sidebar panel.
|
|
4232
4225
|
*/
|
|
@@ -4323,7 +4316,8 @@ class T extends x {
|
|
|
4323
4316
|
isPanelVisible() {
|
|
4324
4317
|
return this.grid.activeToolPanel === T.PANEL_ID;
|
|
4325
4318
|
}
|
|
4326
|
-
//
|
|
4319
|
+
// #endregion
|
|
4320
|
+
// #region Private Methods
|
|
4327
4321
|
/**
|
|
4328
4322
|
* Render the panel content into the shell's tool panel container.
|
|
4329
4323
|
* Returns a cleanup function.
|
|
@@ -4409,47 +4403,50 @@ class T extends x {
|
|
|
4409
4403
|
}
|
|
4410
4404
|
});
|
|
4411
4405
|
}
|
|
4412
|
-
//
|
|
4413
|
-
|
|
4406
|
+
// #endregion
|
|
4407
|
+
// #region Styles
|
|
4408
|
+
styles = fn;
|
|
4409
|
+
// #endregion
|
|
4414
4410
|
}
|
|
4415
4411
|
export {
|
|
4416
4412
|
x as BaseGridPlugin,
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4413
|
+
wn as ClipboardPlugin,
|
|
4414
|
+
bn as ColumnVirtualizationPlugin,
|
|
4415
|
+
vn as ContextMenuPlugin,
|
|
4416
|
+
He as DEFAULT_GRID_ICONS,
|
|
4417
|
+
Nn as DGEvents,
|
|
4418
|
+
Pn as DataGridElement,
|
|
4419
|
+
xn as ExportPlugin,
|
|
4424
4420
|
A as FilteringPlugin,
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4421
|
+
qn as FitModeEnum,
|
|
4422
|
+
Dn as GridCSSVars,
|
|
4423
|
+
Kn as GridClasses,
|
|
4424
|
+
Hn as GridDataAttrs,
|
|
4425
|
+
Gn as GridElement,
|
|
4426
|
+
On as GridSelectors,
|
|
4427
|
+
yn as GroupingColumnsPlugin,
|
|
4432
4428
|
Cn as GroupingRowsPlugin,
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
En as
|
|
4437
|
-
|
|
4429
|
+
Rn as MasterDetailPlugin,
|
|
4430
|
+
Sn as MultiSortPlugin,
|
|
4431
|
+
Pe as PLUGIN_QUERIES,
|
|
4432
|
+
En as PinnedColumnsPlugin,
|
|
4433
|
+
kn as PinnedRowsPlugin,
|
|
4434
|
+
F as PivotPlugin,
|
|
4438
4435
|
Bn as PluginEvents,
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4436
|
+
Vn as PluginManager,
|
|
4437
|
+
An as ReorderPlugin,
|
|
4438
|
+
_n as SelectionPlugin,
|
|
4439
|
+
In as ServerSidePlugin,
|
|
4440
|
+
Ln as TreePlugin,
|
|
4444
4441
|
Fn as UndoRedoPlugin,
|
|
4445
4442
|
T as VisibilityPlugin,
|
|
4446
4443
|
zn as aggregatorRegistry,
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4444
|
+
Ge as getAggregator,
|
|
4445
|
+
Oe as getValueAggregator,
|
|
4446
|
+
Wn as listAggregators,
|
|
4447
|
+
$n as registerAggregator,
|
|
4451
4448
|
se as runAggregator,
|
|
4452
|
-
|
|
4453
|
-
|
|
4449
|
+
jn as runValueAggregator,
|
|
4450
|
+
Un as unregisterAggregator
|
|
4454
4451
|
};
|
|
4455
4452
|
//# sourceMappingURL=all.js.map
|