@toolbox-web/grid 1.13.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1850 -1742
- package/all.js.map +1 -1
- package/index.js +159 -139
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/loading.d.ts +2 -0
- package/lib/core/internal/loading.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +1 -1
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +44 -1
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +69 -8
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.d.ts +1 -1
- package/lib/plugins/clipboard/index.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +257 -192
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +31 -0
- package/lib/plugins/clipboard/types.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +8 -0
- package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
- package/lib/plugins/context-menu/index.js +75 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/context-menu/types.d.ts +7 -0
- package/lib/plugins/context-menu/types.d.ts.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/editors.d.ts +2 -2
- package/lib/plugins/editing/editors.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +420 -381
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +6 -23
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +75 -66
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +2 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -1
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +319 -290
- package/lib/plugins/filtering/index.js.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/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts +1 -0
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +118 -87
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts +2 -1
- package/lib/plugins/pinned-rows/pinned-rows.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/types.d.ts +23 -2
- package/lib/plugins/pinned-rows/types.d.ts.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.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +94 -86
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/shared/data-collection.d.ts +33 -0
- package/lib/plugins/shared/data-collection.d.ts.map +1 -0
- 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 +31 -31
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +4 -4
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +5 -5
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.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/export.umd.js +7 -7
- package/umd/plugins/export.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/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/SelectionPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUrD,OAAO,KAAK,EACV,SAAS,EAGT,eAAe,EAEf,eAAe,EAChB,MAAM,SAAS,CAAC;AAuDjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAAC,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"SelectionPlugin.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;;;;;;OAYG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAcnC;;;;;;;;;OASG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;OAEG;IACH,cAAc,IAAI,IAAI;IAWtB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;CAgCrC"}
|
|
@@ -7,8 +7,8 @@ function R(n) {
|
|
|
7
7
|
const s = t.parentElement;
|
|
8
8
|
if (!s) return -1;
|
|
9
9
|
const i = s.querySelectorAll(":scope > .data-grid-row");
|
|
10
|
-
for (let
|
|
11
|
-
if (i[
|
|
10
|
+
for (let r = 0; r < i.length; r++)
|
|
11
|
+
if (i[r] === t) return r;
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
14
|
function C(n) {
|
|
@@ -27,7 +27,7 @@ const p = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
27
27
|
filterActive: p,
|
|
28
28
|
print: "🖨️"
|
|
29
29
|
};
|
|
30
|
-
class
|
|
30
|
+
class v {
|
|
31
31
|
/**
|
|
32
32
|
* Plugin dependencies - declare other plugins this one requires.
|
|
33
33
|
*
|
|
@@ -394,7 +394,7 @@ class k {
|
|
|
394
394
|
// #endregion
|
|
395
395
|
}
|
|
396
396
|
const E = "__tbw_expander";
|
|
397
|
-
function
|
|
397
|
+
function k(n) {
|
|
398
398
|
return n.field === E;
|
|
399
399
|
}
|
|
400
400
|
function f(n) {
|
|
@@ -408,15 +408,15 @@ function g(n) {
|
|
|
408
408
|
endCol: Math.max(n.startCol, n.endCol)
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function I(n) {
|
|
412
412
|
const e = g(n);
|
|
413
413
|
return {
|
|
414
414
|
from: { row: e.startRow, col: e.startCol },
|
|
415
415
|
to: { row: e.endRow, col: e.endCol }
|
|
416
416
|
};
|
|
417
417
|
}
|
|
418
|
-
function
|
|
419
|
-
return n.map(
|
|
418
|
+
function S(n) {
|
|
419
|
+
return n.map(I);
|
|
420
420
|
}
|
|
421
421
|
function _(n, e, t) {
|
|
422
422
|
const s = g(t);
|
|
@@ -451,7 +451,7 @@ function b(n, e) {
|
|
|
451
451
|
const t = g(n), s = g(e);
|
|
452
452
|
return t.startRow === s.startRow && t.startCol === s.startCol && t.endRow === s.endRow && t.endCol === s.endCol;
|
|
453
453
|
}
|
|
454
|
-
const F = '@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid:has(.selection){-webkit-user-select:none;user-select:none}tbw-grid
|
|
454
|
+
const F = '@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid:has(.selection){-webkit-user-select:none;user-select:none}tbw-grid .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));outline:none;position:relative}tbw-grid .data-grid-row.row-focus:after{content:"";position:absolute;inset:0;pointer-events:none;border-width:0;border-style:var(--tbw-selection-border-style, var(--tbw-border-style));border-color:var(--tbw-range-border-color, var(--tbw-color-accent));border-top-width:var(--tbw-selection-border-width, var(--tbw-border-width));border-bottom-width:var(--tbw-selection-border-width, var(--tbw-border-width));z-index:1}tbw-grid .data-grid-row.row-focus+.data-grid-row.row-focus:after{border-top-width:0}tbw-grid .data-grid-row.row-focus:has(+.data-grid-row.row-focus):after{border-bottom-width:0}tbw-grid[data-selection-mode=row] .cell-focus,tbw-grid[data-selection-mode=row] .row-focus,tbw-grid[data-selection-mode=range] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg);position:relative}tbw-grid .data-grid-row>.cell.selected:after{content:"";position:absolute;inset:0;pointer-events:none;border:0 var(--tbw-selection-border-style, var(--tbw-border-style)) var(--tbw-range-border-color);z-index:1}tbw-grid .data-grid-row>.cell.selected.top:after{border-top-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.bottom:after{border-bottom-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.first:after{border-left-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.last:after{border-right-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row[data-selectable=false]{cursor:not-allowed;opacity:.6}tbw-grid .data-grid-row[data-selectable=false].row-focus{background-color:var(--tbw-color-row-alt)}tbw-grid .data-grid-row>.cell[data-selectable=false]{cursor:not-allowed;opacity:.6}tbw-grid .data-grid-row>.cell[data-selectable=false].selected{background-color:var(--tbw-selection-warning-bg, rgba(from var(--tbw-color-error) r g b / 50%))}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}tbw-grid .data-grid-row>.cell[data-field=__tbw_checkbox],tbw-grid .header-row>.cell[data-field=__tbw_checkbox]{text-align:center;cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center}tbw-grid .tbw-select-row-checkbox{pointer-events:none;margin:0;cursor:pointer}tbw-grid .tbw-checkbox-header{display:flex;justify-content:center;align-items:center;height:100%}tbw-grid .tbw-select-all-checkbox{margin:0;cursor:pointer}}', y = "__tbw_checkbox";
|
|
455
455
|
function D(n, e, t) {
|
|
456
456
|
if (n === "cell" && e.selectedCell)
|
|
457
457
|
return {
|
|
@@ -464,21 +464,25 @@ function D(n, e, t) {
|
|
|
464
464
|
]
|
|
465
465
|
};
|
|
466
466
|
if (n === "row" && e.selected.size > 0) {
|
|
467
|
-
const s = [...e.selected].sort((
|
|
468
|
-
let
|
|
469
|
-
for (let
|
|
470
|
-
s[
|
|
471
|
-
return i.push({ from: { row:
|
|
467
|
+
const s = [...e.selected].sort((l, d) => l - d), i = [];
|
|
468
|
+
let r = s[0], o = r;
|
|
469
|
+
for (let l = 1; l < s.length; l++)
|
|
470
|
+
s[l] === o + 1 ? o = s[l] : (i.push({ from: { row: r, col: 0 }, to: { row: o, col: t - 1 } }), r = s[l], o = r);
|
|
471
|
+
return i.push({ from: { row: r, col: 0 }, to: { row: o, col: t - 1 } }), { mode: n, ranges: i };
|
|
472
472
|
}
|
|
473
|
-
return n === "range" && e.ranges.length > 0 ? { mode: n, ranges:
|
|
473
|
+
return n === "range" && e.ranges.length > 0 ? { mode: n, ranges: S(e.ranges) } : { mode: n, ranges: [] };
|
|
474
474
|
}
|
|
475
|
-
class L extends
|
|
475
|
+
class L extends v {
|
|
476
476
|
/**
|
|
477
477
|
* Plugin manifest - declares queries and configuration validation rules.
|
|
478
478
|
* @internal
|
|
479
479
|
*/
|
|
480
480
|
static manifest = {
|
|
481
|
-
queries: [
|
|
481
|
+
queries: [
|
|
482
|
+
{ type: "getSelection", description: "Get the current selection state" },
|
|
483
|
+
{ type: "selectRows", description: "Select specific rows by index (row mode only)" },
|
|
484
|
+
{ type: "getSelectedRowIndices", description: "Get sorted array of selected row indices" }
|
|
485
|
+
],
|
|
482
486
|
configRules: [
|
|
483
487
|
{
|
|
484
488
|
id: "selection/range-dblclick",
|
|
@@ -542,8 +546,8 @@ class L extends k {
|
|
|
542
546
|
if (!s) return !0;
|
|
543
547
|
const i = this.rows[e];
|
|
544
548
|
if (!i) return !1;
|
|
545
|
-
const
|
|
546
|
-
return s(i, e,
|
|
549
|
+
const r = t !== void 0 ? this.columns[t] : void 0;
|
|
550
|
+
return s(i, e, r, t);
|
|
547
551
|
}
|
|
548
552
|
/**
|
|
549
553
|
* Check if an entire row is selectable (for row mode).
|
|
@@ -570,6 +574,10 @@ class L extends k {
|
|
|
570
574
|
handleQuery(e) {
|
|
571
575
|
if (e.type === "getSelection")
|
|
572
576
|
return this.getSelection();
|
|
577
|
+
if (e.type === "getSelectedRowIndices")
|
|
578
|
+
return this.getSelectedRowIndices();
|
|
579
|
+
if (e.type === "selectRows")
|
|
580
|
+
return this.selectRows(e.context), !0;
|
|
573
581
|
}
|
|
574
582
|
/** @internal */
|
|
575
583
|
detach() {
|
|
@@ -587,26 +595,26 @@ class L extends k {
|
|
|
587
595
|
/** @internal */
|
|
588
596
|
onCellClick(e) {
|
|
589
597
|
if (!this.isSelectionEnabled()) return !1;
|
|
590
|
-
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode:
|
|
591
|
-
if (i.type !==
|
|
598
|
+
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: r, triggerOn: o = "click" } = this.config;
|
|
599
|
+
if (i.type !== o)
|
|
592
600
|
return !1;
|
|
593
|
-
const
|
|
594
|
-
if (
|
|
595
|
-
if (
|
|
601
|
+
const l = this.columns[s], d = l && f(l);
|
|
602
|
+
if (r === "cell") {
|
|
603
|
+
if (d || !this.isCellSelectable(t, s))
|
|
596
604
|
return !1;
|
|
597
605
|
const a = this.selectedCell;
|
|
598
606
|
return a && a.row === t && a.col === s || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
599
607
|
}
|
|
600
|
-
if (
|
|
608
|
+
if (r === "row") {
|
|
601
609
|
if (!this.isRowSelectable(t))
|
|
602
610
|
return !1;
|
|
603
|
-
const a = i.shiftKey,
|
|
611
|
+
const a = i.shiftKey, h = i.ctrlKey || i.metaKey, c = l?.meta?.checkboxColumn === !0;
|
|
604
612
|
if (a && this.anchor !== null) {
|
|
605
613
|
const u = Math.min(this.anchor, t), x = Math.max(this.anchor, t);
|
|
606
|
-
|
|
614
|
+
h || this.selected.clear();
|
|
607
615
|
for (let w = u; w <= x; w++)
|
|
608
616
|
this.isRowSelectable(w) && this.selected.add(w);
|
|
609
|
-
} else if (
|
|
617
|
+
} else if (h || c)
|
|
610
618
|
this.selected.has(t) ? this.selected.delete(t) : this.selected.add(t), this.anchor = t;
|
|
611
619
|
else {
|
|
612
620
|
if (this.selected.size === 1 && this.selected.has(t))
|
|
@@ -615,16 +623,16 @@ class L extends k {
|
|
|
615
623
|
}
|
|
616
624
|
return this.lastSelected = t, this.explicitSelection = !0, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
617
625
|
}
|
|
618
|
-
if (
|
|
619
|
-
if (
|
|
626
|
+
if (r === "range") {
|
|
627
|
+
if (d || !this.isCellSelectable(t, s))
|
|
620
628
|
return !1;
|
|
621
|
-
const a = i.shiftKey,
|
|
629
|
+
const a = i.shiftKey, h = i.ctrlKey || i.metaKey;
|
|
622
630
|
if (a && this.cellAnchor) {
|
|
623
631
|
const c = m(this.cellAnchor, { row: t, col: s }), u = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
624
632
|
if (u && b(u, c))
|
|
625
633
|
return !1;
|
|
626
|
-
|
|
627
|
-
} else if (
|
|
634
|
+
h ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = c : this.ranges.push(c) : this.ranges = [c], this.activeRange = c;
|
|
635
|
+
} else if (h) {
|
|
628
636
|
const c = {
|
|
629
637
|
startRow: t,
|
|
630
638
|
startCol: s,
|
|
@@ -652,35 +660,35 @@ class L extends k {
|
|
|
652
660
|
if (!this.isSelectionEnabled()) return !1;
|
|
653
661
|
const { mode: t } = this.config, i = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
|
|
654
662
|
if (e.key === "Escape")
|
|
655
|
-
return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
663
|
+
return this.grid.query("isEditing").some(Boolean) ? !1 : (t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
|
|
656
664
|
if (t === "cell" && i)
|
|
657
665
|
return queueMicrotask(() => {
|
|
658
|
-
const
|
|
659
|
-
this.isCellSelectable(
|
|
666
|
+
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
667
|
+
this.isCellSelectable(r, o) ? this.selectedCell = { row: r, col: o } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
660
668
|
}), !1;
|
|
661
669
|
if (t === "row") {
|
|
662
670
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
663
|
-
const
|
|
664
|
-
return
|
|
665
|
-
const
|
|
666
|
-
if (
|
|
671
|
+
const r = e.shiftKey;
|
|
672
|
+
return r && this.anchor === null && (this.anchor = this.grid._focusRow), queueMicrotask(() => {
|
|
673
|
+
const o = this.grid._focusRow;
|
|
674
|
+
if (r && this.anchor !== null) {
|
|
667
675
|
this.selected.clear();
|
|
668
|
-
const
|
|
669
|
-
for (let a =
|
|
676
|
+
const l = Math.min(this.anchor, o), d = Math.max(this.anchor, o);
|
|
677
|
+
for (let a = l; a <= d; a++)
|
|
670
678
|
this.isRowSelectable(a) && this.selected.add(a);
|
|
671
679
|
} else
|
|
672
|
-
this.isRowSelectable(
|
|
673
|
-
this.lastSelected =
|
|
680
|
+
this.isRowSelectable(o) ? (this.selected.clear(), this.selected.add(o), this.anchor = o) : this.selected.clear();
|
|
681
|
+
this.lastSelected = o, this.explicitSelection = !0, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
674
682
|
}), !1;
|
|
675
683
|
}
|
|
676
684
|
if (e.key === "a" && (e.ctrlKey || e.metaKey))
|
|
677
|
-
return e.preventDefault(), e.stopPropagation(), this.selectAll(), !0;
|
|
685
|
+
return this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0);
|
|
678
686
|
}
|
|
679
687
|
if (t === "range" && i) {
|
|
680
|
-
const
|
|
681
|
-
return
|
|
688
|
+
const r = e.key === "Tab", o = e.shiftKey && !r;
|
|
689
|
+
return o && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: o }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
682
690
|
}
|
|
683
|
-
return t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey) ? (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0) : !1;
|
|
691
|
+
return t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey) ? this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0) : !1;
|
|
684
692
|
}
|
|
685
693
|
/** @internal */
|
|
686
694
|
onCellMouseDown(e) {
|
|
@@ -689,13 +697,13 @@ class L extends k {
|
|
|
689
697
|
if (t && f(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
690
698
|
return;
|
|
691
699
|
this.isDragging = !0;
|
|
692
|
-
const s = e.rowIndex, i = e.colIndex,
|
|
700
|
+
const s = e.rowIndex, i = e.colIndex, r = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
|
|
693
701
|
startRow: s,
|
|
694
702
|
startCol: i,
|
|
695
703
|
endRow: s,
|
|
696
704
|
endCol: i
|
|
697
705
|
};
|
|
698
|
-
return !
|
|
706
|
+
return !r && this.ranges.length === 1 && b(this.ranges[0], o) ? (this.cellAnchor = { row: s, col: i }, !0) : (this.cellAnchor = { row: s, col: i }, r || (this.ranges = []), this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
|
|
699
707
|
}
|
|
700
708
|
/** @internal */
|
|
701
709
|
onCellMouseMove(e) {
|
|
@@ -703,11 +711,11 @@ class L extends k {
|
|
|
703
711
|
let t = e.colIndex;
|
|
704
712
|
const s = this.columns[t];
|
|
705
713
|
if (s && f(s)) {
|
|
706
|
-
const
|
|
707
|
-
|
|
714
|
+
const o = this.columns.findIndex((l) => !f(l));
|
|
715
|
+
o >= 0 && (t = o);
|
|
708
716
|
}
|
|
709
|
-
const i = m(this.cellAnchor, { row: e.rowIndex, col: t }),
|
|
710
|
-
return
|
|
717
|
+
const i = m(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
718
|
+
return r && b(r, i) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = i : this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#e()), this.requestAfterRender()), !0;
|
|
711
719
|
}
|
|
712
720
|
/** @internal */
|
|
713
721
|
onCellMouseUp(e) {
|
|
@@ -721,9 +729,9 @@ class L extends k {
|
|
|
721
729
|
*/
|
|
722
730
|
processColumns(e) {
|
|
723
731
|
if (this.config.checkbox && this.config.mode === "row") {
|
|
724
|
-
if (e.some((
|
|
732
|
+
if (e.some((r) => r.field === y))
|
|
725
733
|
return e;
|
|
726
|
-
const t = this.#t(), s = e.findIndex(
|
|
734
|
+
const t = this.#t(), s = e.findIndex(k), i = s >= 0 ? s + 1 : 0;
|
|
727
735
|
return [...e.slice(0, i), t, ...e.slice(i)];
|
|
728
736
|
}
|
|
729
737
|
return e;
|
|
@@ -733,7 +741,7 @@ class L extends k {
|
|
|
733
741
|
*/
|
|
734
742
|
#t() {
|
|
735
743
|
return {
|
|
736
|
-
field:
|
|
744
|
+
field: y,
|
|
737
745
|
header: "",
|
|
738
746
|
width: 32,
|
|
739
747
|
resizable: !1,
|
|
@@ -770,20 +778,20 @@ class L extends k {
|
|
|
770
778
|
*/
|
|
771
779
|
#i(e) {
|
|
772
780
|
e.querySelectorAll(".tbw-select-row-checkbox").forEach((i) => {
|
|
773
|
-
const
|
|
774
|
-
|
|
781
|
+
const r = i.closest(".cell"), o = r ? R(r) : -1;
|
|
782
|
+
o >= 0 && (i.checked = this.selected.has(o));
|
|
775
783
|
});
|
|
776
784
|
const s = e.querySelector(".tbw-select-all-checkbox");
|
|
777
785
|
if (s) {
|
|
778
786
|
const i = this.rows.length;
|
|
779
|
-
let
|
|
787
|
+
let r = 0;
|
|
780
788
|
if (this.config.isSelectable)
|
|
781
|
-
for (let
|
|
782
|
-
this.isRowSelectable(
|
|
789
|
+
for (let d = 0; d < i; d++)
|
|
790
|
+
this.isRowSelectable(d) && r++;
|
|
783
791
|
else
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
s.checked =
|
|
792
|
+
r = i;
|
|
793
|
+
const o = r > 0 && this.selected.size >= r, l = this.selected.size > 0;
|
|
794
|
+
s.checked = o, s.indeterminate = l && !o;
|
|
787
795
|
}
|
|
788
796
|
}
|
|
789
797
|
// #endregion
|
|
@@ -822,33 +830,33 @@ class L extends k {
|
|
|
822
830
|
const e = this.gridElement;
|
|
823
831
|
if (!e) return;
|
|
824
832
|
const { mode: t } = this.config, s = !!this.config.isSelectable;
|
|
825
|
-
e.querySelectorAll(".cell").forEach((
|
|
826
|
-
|
|
833
|
+
e.querySelectorAll(".cell").forEach((o) => {
|
|
834
|
+
o.classList.remove("selected", "top", "bottom", "first", "last"), s && o.removeAttribute("data-selectable");
|
|
827
835
|
});
|
|
828
|
-
const
|
|
829
|
-
if (
|
|
830
|
-
|
|
831
|
-
}), t === "row" && (C(e),
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
}), this.config.checkbox && this.#i(e)), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((
|
|
835
|
-
const
|
|
836
|
-
|
|
836
|
+
const r = e.querySelectorAll(".data-grid-row");
|
|
837
|
+
if (r.forEach((o) => {
|
|
838
|
+
o.classList.remove("selected", "row-focus"), s && o.removeAttribute("data-selectable");
|
|
839
|
+
}), t === "row" && (C(e), r.forEach((o) => {
|
|
840
|
+
const l = o.querySelector(".cell[data-row]"), d = R(l);
|
|
841
|
+
d >= 0 && (s && !this.isRowSelectable(d) && o.setAttribute("data-selectable", "false"), this.selected.has(d) && o.classList.add("selected", "row-focus"));
|
|
842
|
+
}), this.config.checkbox && this.#i(e)), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((l) => {
|
|
843
|
+
const d = parseInt(l.getAttribute("data-row") ?? "-1", 10), a = parseInt(l.getAttribute("data-col") ?? "-1", 10);
|
|
844
|
+
d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || l.setAttribute("data-selectable", "false"));
|
|
837
845
|
}), t === "range" && this.ranges.length > 0) {
|
|
838
846
|
C(e);
|
|
839
|
-
const
|
|
840
|
-
for (const c of
|
|
841
|
-
if (a >= c.startRow && a <= c.endRow &&
|
|
847
|
+
const o = this.ranges.map(g), l = (a, h) => {
|
|
848
|
+
for (const c of o)
|
|
849
|
+
if (a >= c.startRow && a <= c.endRow && h >= c.startCol && h <= c.endCol)
|
|
842
850
|
return !0;
|
|
843
851
|
return !1;
|
|
844
852
|
};
|
|
845
853
|
e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
846
|
-
const
|
|
847
|
-
if (
|
|
854
|
+
const h = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
855
|
+
if (h >= 0 && c >= 0) {
|
|
848
856
|
const u = this.columns[c];
|
|
849
857
|
if (u && f(u))
|
|
850
858
|
return;
|
|
851
|
-
|
|
859
|
+
l(h, c) && (a.classList.add("selected"), l(h - 1, c) || a.classList.add("top"), l(h + 1, c) || a.classList.add("bottom"), l(h, c - 1) || a.classList.add("first"), l(h, c + 1) || a.classList.add("last"));
|
|
852
860
|
}
|
|
853
861
|
});
|
|
854
862
|
}
|
|
@@ -862,11 +870,11 @@ class L extends k {
|
|
|
862
870
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
863
871
|
const { shiftKey: i } = this.pendingKeyboardUpdate;
|
|
864
872
|
this.pendingKeyboardUpdate = null;
|
|
865
|
-
const
|
|
873
|
+
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
866
874
|
if (i && this.cellAnchor) {
|
|
867
|
-
const
|
|
868
|
-
this.ranges = [
|
|
869
|
-
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row:
|
|
875
|
+
const l = m(this.cellAnchor, { row: r, col: o });
|
|
876
|
+
this.ranges = [l], this.activeRange = l;
|
|
877
|
+
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
|
|
870
878
|
this.emit("selection-change", this.#e());
|
|
871
879
|
}
|
|
872
880
|
this.#r(s), this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#s();
|
|
@@ -999,7 +1007,7 @@ class L extends k {
|
|
|
999
1007
|
endCol: t.to.col
|
|
1000
1008
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
1001
1009
|
mode: this.config.mode,
|
|
1002
|
-
ranges:
|
|
1010
|
+
ranges: S(this.ranges)
|
|
1003
1011
|
}), this.requestAfterRender();
|
|
1004
1012
|
}
|
|
1005
1013
|
// #endregion
|