@toolbox-web/grid 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -41
- package/all.js +1045 -935
- package/all.js.map +1 -1
- package/index.js +39 -33
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +12 -2
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/types.d.ts +34 -1
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +155 -145
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +31 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts +30 -3
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +471 -361
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +32 -0
- package/lib/plugins/filtering/types.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +4 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +49 -39
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +81 -78
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +58 -55
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +5 -2
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +29 -29
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +2 -2
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
|
@@ -7,43 +7,46 @@ const w = document.createElement("template");
|
|
|
7
7
|
w.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
8
8
|
function y(l, e) {
|
|
9
9
|
if (l._virtualization?.enabled) {
|
|
10
|
-
const { rowHeight: a, container: r, viewportEl: s } = l._virtualization,
|
|
11
|
-
if (
|
|
10
|
+
const { rowHeight: a, container: r, viewportEl: s } = l._virtualization, i = r, c = s?.clientHeight ?? i?.clientHeight ?? 0;
|
|
11
|
+
if (i && c > 0) {
|
|
12
12
|
const u = l._focusRow * a;
|
|
13
|
-
u <
|
|
13
|
+
u < i.scrollTop ? i.scrollTop = u : u + a > i.scrollTop + c && (i.scrollTop = u - c + a);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
const t = l._activeEditRows !== void 0 && l._activeEditRows !== -1;
|
|
17
17
|
t || l.refreshVirtualWindow(!1), v(l._bodyEl), Array.from(l._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((a) => {
|
|
18
18
|
a.setAttribute("aria-selected", "false");
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const a = l._bodyEl.querySelectorAll(".data-grid-row")[
|
|
20
|
+
const n = l._focusRow, o = l._virtualization.start ?? 0, d = l._virtualization.end ?? l._rows.length;
|
|
21
|
+
if (n >= o && n < d) {
|
|
22
|
+
const a = l._bodyEl.querySelectorAll(".data-grid-row")[n - o];
|
|
23
23
|
let r = a?.children[l._focusCol];
|
|
24
24
|
if ((!r || !r.classList?.contains("cell")) && (r = a?.querySelector(`.cell[data-col="${l._focusCol}"]`) ?? a?.querySelector(".cell[data-col]")), r) {
|
|
25
25
|
r.classList.add("cell-focus"), r.setAttribute("aria-selected", "true");
|
|
26
26
|
const s = l.querySelector(".tbw-scroll-area");
|
|
27
27
|
if (s && r && (!t || e?.forceHorizontalScroll)) {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
30
|
-
const c = r.getBoundingClientRect(), u = s.getBoundingClientRect(), f = c.left - u.left + s.scrollLeft, g = f + c.width, h = s.scrollLeft +
|
|
31
|
-
f < h ? s.scrollLeft = f -
|
|
28
|
+
const i = l._getHorizontalScrollOffsets?.(a ?? void 0, r) ?? { left: 0, right: 0 };
|
|
29
|
+
if (!i.skipScroll) {
|
|
30
|
+
const c = r.getBoundingClientRect(), u = s.getBoundingClientRect(), f = c.left - u.left + s.scrollLeft, g = f + c.width, h = s.scrollLeft + i.left, m = s.scrollLeft + s.clientWidth - i.right;
|
|
31
|
+
f < h ? s.scrollLeft = f - i.left : g > m && (s.scrollLeft = g - s.clientWidth + i.right);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
34
|
+
if (t && r.classList.contains("editing")) {
|
|
35
|
+
const i = r.querySelector(C);
|
|
36
|
+
if (i && document.activeElement !== i)
|
|
37
37
|
try {
|
|
38
|
-
|
|
38
|
+
i.focus({ preventScroll: !0 });
|
|
39
39
|
} catch {
|
|
40
40
|
}
|
|
41
|
-
} else if (!r.contains(document.activeElement)) {
|
|
41
|
+
} else if (t && !r.contains(document.activeElement)) {
|
|
42
42
|
r.hasAttribute("tabindex") || r.setAttribute("tabindex", "-1");
|
|
43
43
|
try {
|
|
44
44
|
r.focus({ preventScroll: !0 });
|
|
45
45
|
} catch {
|
|
46
46
|
}
|
|
47
|
+
} else if (!t) {
|
|
48
|
+
const i = l;
|
|
49
|
+
document.activeElement !== i && i.focus({ preventScroll: !0 });
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
@@ -196,8 +199,8 @@ class A {
|
|
|
196
199
|
* @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
|
|
197
200
|
*/
|
|
198
201
|
emitCancelable(e, t) {
|
|
199
|
-
const
|
|
200
|
-
return this.grid?.dispatchEvent?.(
|
|
202
|
+
const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
|
|
203
|
+
return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
|
|
201
204
|
}
|
|
202
205
|
// =========================================================================
|
|
203
206
|
// Event Bus - Plugin-to-Plugin Communication
|
|
@@ -392,8 +395,8 @@ class A {
|
|
|
392
395
|
get animationDuration() {
|
|
393
396
|
const e = this.gridElement;
|
|
394
397
|
if (e) {
|
|
395
|
-
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),
|
|
396
|
-
if (!isNaN(
|
|
398
|
+
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(t, 10);
|
|
399
|
+
if (!isNaN(n)) return n;
|
|
397
400
|
}
|
|
398
401
|
return 200;
|
|
399
402
|
}
|
|
@@ -427,21 +430,21 @@ class A {
|
|
|
427
430
|
}
|
|
428
431
|
// #endregion
|
|
429
432
|
}
|
|
430
|
-
function
|
|
433
|
+
function O(l) {
|
|
431
434
|
const e = l.meta ?? {};
|
|
432
435
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
433
436
|
}
|
|
434
437
|
function b(l, e, t) {
|
|
435
438
|
if (e === t || e < 0 || e >= l.length || t < 0 || t > l.length) return l;
|
|
436
|
-
const
|
|
437
|
-
return
|
|
439
|
+
const n = [...l], [o] = n.splice(e, 1);
|
|
440
|
+
return n.splice(t, 0, o), n;
|
|
438
441
|
}
|
|
439
|
-
const
|
|
440
|
-
class
|
|
442
|
+
const _ = '@layer tbw-plugins{.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}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';
|
|
443
|
+
class R extends A {
|
|
441
444
|
/** @internal */
|
|
442
445
|
name = "reorder";
|
|
443
446
|
/** @internal */
|
|
444
|
-
styles =
|
|
447
|
+
styles = _;
|
|
445
448
|
/** @internal */
|
|
446
449
|
get defaultConfig() {
|
|
447
450
|
return {
|
|
@@ -472,7 +475,7 @@ class O extends A {
|
|
|
472
475
|
* Check if a column can be moved, considering both column config and plugin queries.
|
|
473
476
|
*/
|
|
474
477
|
canMoveColumnWithPlugins(e) {
|
|
475
|
-
return !e || !
|
|
478
|
+
return !e || !O(e) ? !1 : !this.grid.query("canMoveColumn", e).includes(!1);
|
|
476
479
|
}
|
|
477
480
|
/**
|
|
478
481
|
* Clear all drag-related classes from header cells.
|
|
@@ -489,8 +492,8 @@ class O extends A {
|
|
|
489
492
|
super.attach(e), e.addEventListener(
|
|
490
493
|
"column-reorder-request",
|
|
491
494
|
(t) => {
|
|
492
|
-
const
|
|
493
|
-
|
|
495
|
+
const n = t.detail;
|
|
496
|
+
n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
|
|
494
497
|
},
|
|
495
498
|
{ signal: this.disconnectSignal }
|
|
496
499
|
);
|
|
@@ -505,33 +508,33 @@ class O extends A {
|
|
|
505
508
|
afterRender() {
|
|
506
509
|
const e = this.gridElement;
|
|
507
510
|
if (!e) return;
|
|
508
|
-
e.querySelectorAll(".header-row > .cell").forEach((
|
|
509
|
-
const
|
|
511
|
+
e.querySelectorAll(".header-row > .cell").forEach((n) => {
|
|
512
|
+
const o = n, d = o.getAttribute("data-field");
|
|
510
513
|
if (!d) return;
|
|
511
514
|
const a = this.columns.find((r) => r.field === d);
|
|
512
515
|
if (!this.canMoveColumnWithPlugins(a)) {
|
|
513
|
-
|
|
516
|
+
o.draggable = !1;
|
|
514
517
|
return;
|
|
515
518
|
}
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
this.isDragging = !0, this.draggedField = d, this.draggedIndex =
|
|
519
|
-
}),
|
|
519
|
+
o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (r) => {
|
|
520
|
+
const i = this.getColumnOrder().indexOf(d);
|
|
521
|
+
this.isDragging = !0, this.draggedField = d, this.draggedIndex = i, r.dataTransfer && (r.dataTransfer.effectAllowed = "move", r.dataTransfer.setData("text/plain", d)), o.classList.add("dragging");
|
|
522
|
+
}), o.addEventListener("dragend", () => {
|
|
520
523
|
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses();
|
|
521
|
-
}),
|
|
524
|
+
}), o.addEventListener("dragover", (r) => {
|
|
522
525
|
if (r.preventDefault(), !this.isDragging || this.draggedField === d) return;
|
|
523
|
-
const s =
|
|
524
|
-
this.dropIndex = r.clientX <
|
|
525
|
-
}),
|
|
526
|
-
|
|
527
|
-
}),
|
|
526
|
+
const s = o.getBoundingClientRect(), i = s.left + s.width / 2, u = this.getColumnOrder().indexOf(d);
|
|
527
|
+
this.dropIndex = r.clientX < i ? u : u + 1, o.classList.add("drop-target"), o.classList.toggle("drop-before", r.clientX < i), o.classList.toggle("drop-after", r.clientX >= i);
|
|
528
|
+
}), o.addEventListener("dragleave", () => {
|
|
529
|
+
o.classList.remove("drop-target", "drop-before", "drop-after");
|
|
530
|
+
}), o.addEventListener("drop", (r) => {
|
|
528
531
|
r.preventDefault();
|
|
529
|
-
const s = this.draggedField,
|
|
530
|
-
if (!this.isDragging || s === null ||
|
|
532
|
+
const s = this.draggedField, i = this.draggedIndex, c = this.dropIndex;
|
|
533
|
+
if (!this.isDragging || s === null || i === null || c === null)
|
|
531
534
|
return;
|
|
532
|
-
const u = c >
|
|
535
|
+
const u = c > i ? c - 1 : c, f = this.getColumnOrder(), g = b(f, i, u), h = {
|
|
533
536
|
field: s,
|
|
534
|
-
fromIndex:
|
|
537
|
+
fromIndex: i,
|
|
535
538
|
toIndex: u,
|
|
536
539
|
columnOrder: g
|
|
537
540
|
};
|
|
@@ -546,16 +549,16 @@ class O extends A {
|
|
|
546
549
|
onKeyDown(e) {
|
|
547
550
|
if (!e.altKey || e.key !== "ArrowLeft" && e.key !== "ArrowRight")
|
|
548
551
|
return;
|
|
549
|
-
const t = this.grid,
|
|
550
|
-
if (
|
|
551
|
-
const d = n
|
|
552
|
+
const t = this.grid, n = t._focusCol, o = t._visibleColumns;
|
|
553
|
+
if (n < 0 || n >= o.length) return;
|
|
554
|
+
const d = o[n];
|
|
552
555
|
if (!this.canMoveColumnWithPlugins(d)) return;
|
|
553
556
|
const a = this.getColumnOrder(), r = a.indexOf(d.field);
|
|
554
557
|
if (r === -1) return;
|
|
555
558
|
const s = e.key === "ArrowLeft" ? r - 1 : r + 1;
|
|
556
559
|
if (s < 0 || s >= a.length) return;
|
|
557
|
-
const
|
|
558
|
-
if (this.canMoveColumnWithPlugins(
|
|
560
|
+
const i = o.find((c) => c.field === a[s]);
|
|
561
|
+
if (this.canMoveColumnWithPlugins(i))
|
|
559
562
|
return this.moveColumn(d.field, s), t._focusCol = s, y(this.grid), e.preventDefault(), e.stopPropagation(), !0;
|
|
560
563
|
}
|
|
561
564
|
// #endregion
|
|
@@ -573,12 +576,12 @@ class O extends A {
|
|
|
573
576
|
* @param toIndex - The target index
|
|
574
577
|
*/
|
|
575
578
|
moveColumn(e, t) {
|
|
576
|
-
const
|
|
577
|
-
if (
|
|
578
|
-
const d = b(
|
|
579
|
+
const n = this.getColumnOrder(), o = n.indexOf(e);
|
|
580
|
+
if (o === -1) return;
|
|
581
|
+
const d = b(n, o, t);
|
|
579
582
|
this.emitCancelable("column-move", {
|
|
580
583
|
field: e,
|
|
581
|
-
fromIndex:
|
|
584
|
+
fromIndex: o,
|
|
582
585
|
toIndex: t,
|
|
583
586
|
columnOrder: d
|
|
584
587
|
}) || this.updateColumnOrder(d);
|
|
@@ -605,8 +608,8 @@ class O extends A {
|
|
|
605
608
|
captureHeaderPositions() {
|
|
606
609
|
const e = /* @__PURE__ */ new Map();
|
|
607
610
|
return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach((t) => {
|
|
608
|
-
const
|
|
609
|
-
|
|
611
|
+
const n = t.getAttribute("data-field");
|
|
612
|
+
n && e.set(n, t.getBoundingClientRect().left);
|
|
610
613
|
}), e;
|
|
611
614
|
}
|
|
612
615
|
/**
|
|
@@ -617,30 +620,30 @@ class O extends A {
|
|
|
617
620
|
animateFLIP(e) {
|
|
618
621
|
const t = this.gridElement;
|
|
619
622
|
if (!t || e.size === 0) return;
|
|
620
|
-
const
|
|
623
|
+
const n = /* @__PURE__ */ new Map();
|
|
621
624
|
if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((a) => {
|
|
622
625
|
const r = a.getAttribute("data-field");
|
|
623
626
|
if (!r) return;
|
|
624
627
|
const s = e.get(r);
|
|
625
628
|
if (s === void 0) return;
|
|
626
|
-
const
|
|
627
|
-
Math.abs(
|
|
628
|
-
}),
|
|
629
|
-
const
|
|
629
|
+
const i = s - a.getBoundingClientRect().left;
|
|
630
|
+
Math.abs(i) > 1 && n.set(r, i);
|
|
631
|
+
}), n.size === 0) return;
|
|
632
|
+
const o = [];
|
|
630
633
|
if (t.querySelectorAll(".cell[data-field]").forEach((a) => {
|
|
631
|
-
const r =
|
|
634
|
+
const r = n.get(a.getAttribute("data-field") ?? "");
|
|
632
635
|
if (r !== void 0) {
|
|
633
636
|
const s = a;
|
|
634
|
-
s.style.transform = `translateX(${r}px)`,
|
|
637
|
+
s.style.transform = `translateX(${r}px)`, o.push(s);
|
|
635
638
|
}
|
|
636
|
-
}),
|
|
639
|
+
}), o.length === 0) return;
|
|
637
640
|
this.gridElement.offsetHeight;
|
|
638
641
|
const d = this.animationDuration;
|
|
639
642
|
requestAnimationFrame(() => {
|
|
640
|
-
|
|
643
|
+
o.forEach((a) => {
|
|
641
644
|
a.classList.add("flip-animating"), a.style.transform = "";
|
|
642
645
|
}), setTimeout(() => {
|
|
643
|
-
|
|
646
|
+
o.forEach((a) => {
|
|
644
647
|
a.style.transform = "", a.classList.remove("flip-animating");
|
|
645
648
|
});
|
|
646
649
|
}, d + 50);
|
|
@@ -656,23 +659,23 @@ class O extends A {
|
|
|
656
659
|
e();
|
|
657
660
|
return;
|
|
658
661
|
}
|
|
659
|
-
const
|
|
662
|
+
const n = this.captureHeaderPositions();
|
|
660
663
|
e();
|
|
661
|
-
const
|
|
664
|
+
const o = /* @__PURE__ */ new Set();
|
|
662
665
|
if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((r) => {
|
|
663
666
|
const s = r.getAttribute("data-field");
|
|
664
667
|
if (!s) return;
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
668
|
+
const i = n.get(s);
|
|
669
|
+
if (i === void 0) return;
|
|
667
670
|
const c = r.getBoundingClientRect().left;
|
|
668
|
-
Math.abs(
|
|
669
|
-
}),
|
|
671
|
+
Math.abs(i - c) > 1 && o.add(s);
|
|
672
|
+
}), o.size === 0) return;
|
|
670
673
|
const d = [];
|
|
671
674
|
if (t.querySelectorAll(".cell[data-field]").forEach((r) => {
|
|
672
675
|
const s = r.getAttribute("data-field");
|
|
673
|
-
if (s &&
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
+
if (s && o.has(s)) {
|
|
677
|
+
const i = r;
|
|
678
|
+
i.classList.add("fade-animating"), d.push(i);
|
|
676
679
|
}
|
|
677
680
|
}), d.length === 0) return;
|
|
678
681
|
const a = this.animationDuration;
|
|
@@ -686,9 +689,9 @@ class O extends A {
|
|
|
686
689
|
updateColumnOrder(e) {
|
|
687
690
|
const t = this.animationType;
|
|
688
691
|
if (t === "flip" && this.gridElement) {
|
|
689
|
-
const
|
|
692
|
+
const n = this.captureHeaderPositions();
|
|
690
693
|
this.grid.setColumnOrder(e), requestAnimationFrame(() => {
|
|
691
|
-
this.gridElement.offsetHeight, this.animateFLIP(
|
|
694
|
+
this.gridElement.offsetHeight, this.animateFLIP(n);
|
|
692
695
|
});
|
|
693
696
|
} else t === "fade" ? this.animateFade(() => this.grid.setColumnOrder(e)) : this.grid.setColumnOrder(e);
|
|
694
697
|
this.grid.requestStateChange?.();
|
|
@@ -696,6 +699,6 @@ class O extends A {
|
|
|
696
699
|
// #endregion
|
|
697
700
|
}
|
|
698
701
|
export {
|
|
699
|
-
|
|
702
|
+
R as ReorderPlugin
|
|
700
703
|
};
|
|
701
704
|
//# sourceMappingURL=index.js.map
|