@toolbox-web/grid 1.19.3 → 1.20.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/all.js +17 -19
- package/all.js.map +1 -1
- package/index.js +361 -349
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +22 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/sorting.d.ts +6 -0
- package/lib/core/internal/sorting.d.ts.map +1 -1
- package/lib/core/types.d.ts +6 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +54 -54
- 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/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- 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/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.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.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 +93 -95
- 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 +21 -21
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +11 -11
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +4 -4
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAAC,eAAe,CAAC,CAkBhE;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,eAAe;IAC5B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAO/D;IAGD,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAqB;IACr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G,IAAI;IAyC/D,gBAAgB;IACP,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAa9D;;;OAGG;IACM,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,YAAY,EAAE;IAoRhE,gBAAgB;IACP,WAAW,IAAI,IAAI;IAkD5B;;;;OAIG;IACM,cAAc,IAAI,IAAI;IAW/B;;;;;;;;;;;;;;OAcG;IACH,YAAY,IAAI,eAAe;IAQ/B;;OAEG;IACH,gBAAgB,IAAI,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAIvD;;OAEG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAIjD;;;;;;;;;;;;OAYG;IACH,SAAS,IAAI,IAAI;IAkCjB;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAiBnC;;;;;;;;;OASG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,EAAE;IA+BnC;;OAEG;IACH,cAAc,IAAI,IAAI;IAWtB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;CAgCrC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
function R(
|
|
2
|
-
if (!
|
|
3
|
-
const e =
|
|
1
|
+
function R(l) {
|
|
2
|
+
if (!l) return -1;
|
|
3
|
+
const e = l.getAttribute("data-row");
|
|
4
4
|
if (e) return parseInt(e, 10);
|
|
5
|
-
const t =
|
|
5
|
+
const t = l.closest(".data-grid-row");
|
|
6
6
|
if (!t) return -1;
|
|
7
7
|
const s = t.parentElement;
|
|
8
8
|
if (!s) return -1;
|
|
@@ -11,8 +11,8 @@ function R(o) {
|
|
|
11
11
|
if (i[r] === t) return r;
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
|
-
function C(
|
|
15
|
-
|
|
14
|
+
function C(l) {
|
|
15
|
+
l && l.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
16
16
|
}
|
|
17
17
|
const p = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', v = {
|
|
18
18
|
expand: "▶",
|
|
@@ -394,68 +394,68 @@ class E {
|
|
|
394
394
|
// #endregion
|
|
395
395
|
}
|
|
396
396
|
const k = "__tbw_expander";
|
|
397
|
-
function I(
|
|
398
|
-
return
|
|
397
|
+
function I(l) {
|
|
398
|
+
return l.field === k;
|
|
399
399
|
}
|
|
400
|
-
function f(
|
|
401
|
-
return
|
|
400
|
+
function f(l) {
|
|
401
|
+
return l.meta?.utility === !0;
|
|
402
402
|
}
|
|
403
|
-
function g(
|
|
403
|
+
function g(l) {
|
|
404
404
|
return {
|
|
405
|
-
startRow: Math.min(
|
|
406
|
-
startCol: Math.min(
|
|
407
|
-
endRow: Math.max(
|
|
408
|
-
endCol: Math.max(
|
|
405
|
+
startRow: Math.min(l.startRow, l.endRow),
|
|
406
|
+
startCol: Math.min(l.startCol, l.endCol),
|
|
407
|
+
endRow: Math.max(l.startRow, l.endRow),
|
|
408
|
+
endCol: Math.max(l.startCol, l.endCol)
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
|
-
function _(
|
|
412
|
-
const e = g(
|
|
411
|
+
function _(l) {
|
|
412
|
+
const e = g(l);
|
|
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 y(
|
|
419
|
-
return
|
|
418
|
+
function y(l) {
|
|
419
|
+
return l.map(_);
|
|
420
420
|
}
|
|
421
|
-
function q(
|
|
421
|
+
function q(l, e, t) {
|
|
422
422
|
const s = g(t);
|
|
423
|
-
return
|
|
423
|
+
return l >= s.startRow && l <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
424
424
|
}
|
|
425
|
-
function K(
|
|
426
|
-
return t.some((s) => q(
|
|
425
|
+
function K(l, e, t) {
|
|
426
|
+
return t.some((s) => q(l, e, s));
|
|
427
427
|
}
|
|
428
|
-
function M(
|
|
429
|
-
const e = [], t = g(
|
|
428
|
+
function M(l) {
|
|
429
|
+
const e = [], t = g(l);
|
|
430
430
|
for (let s = t.startRow; s <= t.endRow; s++)
|
|
431
431
|
for (let i = t.startCol; i <= t.endCol; i++)
|
|
432
432
|
e.push({ row: s, col: i });
|
|
433
433
|
return e;
|
|
434
434
|
}
|
|
435
|
-
function F(
|
|
435
|
+
function F(l) {
|
|
436
436
|
const e = /* @__PURE__ */ new Map();
|
|
437
|
-
for (const t of
|
|
437
|
+
for (const t of l)
|
|
438
438
|
for (const s of M(t))
|
|
439
439
|
e.set(`${s.row},${s.col}`, s);
|
|
440
440
|
return [...e.values()];
|
|
441
441
|
}
|
|
442
|
-
function m(
|
|
442
|
+
function m(l, e) {
|
|
443
443
|
return {
|
|
444
|
-
startRow:
|
|
445
|
-
startCol:
|
|
444
|
+
startRow: l.row,
|
|
445
|
+
startCol: l.col,
|
|
446
446
|
endRow: e.row,
|
|
447
447
|
endCol: e.col
|
|
448
448
|
};
|
|
449
449
|
}
|
|
450
|
-
function b(
|
|
451
|
-
const t = g(
|
|
450
|
+
function b(l, e) {
|
|
451
|
+
const t = g(l), 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
454
|
const D = '@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}}', S = "__tbw_checkbox";
|
|
455
|
-
function L(
|
|
456
|
-
if (
|
|
455
|
+
function L(l, e, t) {
|
|
456
|
+
if (l === "cell" && e.selectedCell)
|
|
457
457
|
return {
|
|
458
|
-
mode:
|
|
458
|
+
mode: l,
|
|
459
459
|
ranges: [
|
|
460
460
|
{
|
|
461
461
|
from: { row: e.selectedCell.row, col: e.selectedCell.col },
|
|
@@ -463,14 +463,14 @@ function L(o, e, t) {
|
|
|
463
463
|
}
|
|
464
464
|
]
|
|
465
465
|
};
|
|
466
|
-
if (
|
|
467
|
-
const s = [...e.selected].sort((
|
|
468
|
-
let r = s[0],
|
|
469
|
-
for (let
|
|
470
|
-
s[
|
|
471
|
-
return i.push({ from: { row: r, col: 0 }, to: { row:
|
|
466
|
+
if (l === "row" && e.selected.size > 0) {
|
|
467
|
+
const s = [...e.selected].sort((n, h) => n - h), i = [];
|
|
468
|
+
let r = s[0], o = r;
|
|
469
|
+
for (let n = 1; n < s.length; n++)
|
|
470
|
+
s[n] === o + 1 ? o = s[n] : (i.push({ from: { row: r, col: 0 }, to: { row: o, col: t - 1 } }), r = s[n], o = r);
|
|
471
|
+
return i.push({ from: { row: r, col: 0 }, to: { row: o, col: t - 1 } }), { mode: l, ranges: i };
|
|
472
472
|
}
|
|
473
|
-
return
|
|
473
|
+
return l === "range" && e.ranges.length > 0 ? { mode: l, ranges: y(e.ranges) } : { mode: l, ranges: [] };
|
|
474
474
|
}
|
|
475
475
|
class P extends E {
|
|
476
476
|
/**
|
|
@@ -548,7 +548,7 @@ class P extends E {
|
|
|
548
548
|
if (!s) return !0;
|
|
549
549
|
const i = this.rows[e];
|
|
550
550
|
if (!i) return !1;
|
|
551
|
-
const r = t !== void 0 ? this.
|
|
551
|
+
const r = t !== void 0 ? this.visibleColumns[t] : void 0;
|
|
552
552
|
return s(i, e, r, t);
|
|
553
553
|
}
|
|
554
554
|
/**
|
|
@@ -599,10 +599,10 @@ class P extends E {
|
|
|
599
599
|
/** @internal */
|
|
600
600
|
onCellClick(e) {
|
|
601
601
|
if (!this.isSelectionEnabled()) return !1;
|
|
602
|
-
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: r, triggerOn:
|
|
603
|
-
if (i.type !==
|
|
602
|
+
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: r, triggerOn: o = "click" } = this.config;
|
|
603
|
+
if (i.type !== o)
|
|
604
604
|
return !1;
|
|
605
|
-
const
|
|
605
|
+
const n = e.column, h = n && f(n);
|
|
606
606
|
if (r === "cell") {
|
|
607
607
|
if (h || !this.isCellSelectable(t, s))
|
|
608
608
|
return !1;
|
|
@@ -612,7 +612,7 @@ class P extends E {
|
|
|
612
612
|
if (r === "row") {
|
|
613
613
|
if (!this.isRowSelectable(t))
|
|
614
614
|
return !1;
|
|
615
|
-
const a = this.config.multiSelect !== !1, d = i.shiftKey && a, c = (i.ctrlKey || i.metaKey) && a, u =
|
|
615
|
+
const a = this.config.multiSelect !== !1, d = i.shiftKey && a, c = (i.ctrlKey || i.metaKey) && a, u = n?.meta?.checkboxColumn === !0;
|
|
616
616
|
if (d && this.anchor !== null) {
|
|
617
617
|
const x = Math.min(this.anchor, t), A = Math.max(this.anchor, t);
|
|
618
618
|
c || this.selected.clear();
|
|
@@ -667,57 +667,55 @@ class P extends E {
|
|
|
667
667
|
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);
|
|
668
668
|
if (t === "cell" && i)
|
|
669
669
|
return queueMicrotask(() => {
|
|
670
|
-
const r = this.grid._focusRow,
|
|
671
|
-
this.isCellSelectable(r,
|
|
670
|
+
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
671
|
+
this.isCellSelectable(r, o) ? this.selectedCell = { row: r, col: o } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
672
672
|
}), !1;
|
|
673
673
|
if (t === "row") {
|
|
674
674
|
const r = this.config.multiSelect !== !1;
|
|
675
675
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
676
|
-
const
|
|
677
|
-
return
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
676
|
+
const o = e.shiftKey && r;
|
|
677
|
+
return o && this.anchor === null && (this.anchor = this.grid._focusRow), queueMicrotask(() => {
|
|
678
|
+
const n = this.grid._focusRow;
|
|
679
|
+
if (o && this.anchor !== null) {
|
|
680
680
|
this.selected.clear();
|
|
681
|
-
const h = Math.min(this.anchor,
|
|
681
|
+
const h = Math.min(this.anchor, n), a = Math.max(this.anchor, n);
|
|
682
682
|
for (let d = h; d <= a; d++)
|
|
683
683
|
this.isRowSelectable(d) && this.selected.add(d);
|
|
684
684
|
} else
|
|
685
|
-
this.isRowSelectable(
|
|
686
|
-
this.lastSelected =
|
|
685
|
+
this.isRowSelectable(n) ? (this.selected.clear(), this.selected.add(n), this.anchor = n) : this.selected.clear();
|
|
686
|
+
this.lastSelected = n, this.explicitSelection = !0, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
687
687
|
}), !1;
|
|
688
688
|
}
|
|
689
689
|
if (r && e.key === "a" && (e.ctrlKey || e.metaKey))
|
|
690
690
|
return this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0);
|
|
691
691
|
}
|
|
692
692
|
if (t === "range" && i) {
|
|
693
|
-
const r = e.key === "Tab",
|
|
694
|
-
return
|
|
693
|
+
const r = e.key === "Tab", o = e.shiftKey && !r;
|
|
694
|
+
return o && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: o }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
695
695
|
}
|
|
696
696
|
return t === "range" && this.config.multiSelect !== !1 && e.key === "a" && (e.ctrlKey || e.metaKey) ? this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0) : !1;
|
|
697
697
|
}
|
|
698
698
|
/** @internal */
|
|
699
699
|
onCellMouseDown(e) {
|
|
700
|
-
if (!this.isSelectionEnabled() || this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0)
|
|
701
|
-
const t = this.columns[e.colIndex];
|
|
702
|
-
if (t && f(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
700
|
+
if (!this.isSelectionEnabled() || this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0 || e.column && f(e.column) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
703
701
|
return;
|
|
704
702
|
this.isDragging = !0;
|
|
705
|
-
const
|
|
706
|
-
startRow:
|
|
707
|
-
startCol:
|
|
708
|
-
endRow:
|
|
709
|
-
endCol:
|
|
703
|
+
const t = e.rowIndex, s = e.colIndex, i = (e.originalEvent.ctrlKey || e.originalEvent.metaKey) && this.config.multiSelect !== !1, r = {
|
|
704
|
+
startRow: t,
|
|
705
|
+
startCol: s,
|
|
706
|
+
endRow: t,
|
|
707
|
+
endCol: s
|
|
710
708
|
};
|
|
711
|
-
return !
|
|
709
|
+
return !i && this.ranges.length === 1 && b(this.ranges[0], r) ? (this.cellAnchor = { row: t, col: s }, !0) : (this.cellAnchor = { row: t, col: s }, i || (this.ranges = []), this.ranges.push(r), this.activeRange = r, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
|
|
712
710
|
}
|
|
713
711
|
/** @internal */
|
|
714
712
|
onCellMouseMove(e) {
|
|
715
713
|
if (!this.isSelectionEnabled() || this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
716
714
|
let t = e.colIndex;
|
|
717
|
-
const s = this.
|
|
715
|
+
const s = this.visibleColumns[t];
|
|
718
716
|
if (s && f(s)) {
|
|
719
|
-
const
|
|
720
|
-
|
|
717
|
+
const o = this.visibleColumns.findIndex((n) => !f(n));
|
|
718
|
+
o >= 0 && (t = o);
|
|
721
719
|
}
|
|
722
720
|
const i = m(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
723
721
|
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;
|
|
@@ -783,8 +781,8 @@ class P extends E {
|
|
|
783
781
|
*/
|
|
784
782
|
#i(e) {
|
|
785
783
|
e.querySelectorAll(".tbw-select-row-checkbox").forEach((i) => {
|
|
786
|
-
const r = i.closest(".cell"),
|
|
787
|
-
|
|
784
|
+
const r = i.closest(".cell"), o = r ? R(r) : -1;
|
|
785
|
+
o >= 0 && (i.checked = this.selected.has(o));
|
|
788
786
|
});
|
|
789
787
|
const s = e.querySelector(".tbw-select-all-checkbox");
|
|
790
788
|
if (s) {
|
|
@@ -795,8 +793,8 @@ class P extends E {
|
|
|
795
793
|
this.isRowSelectable(h) && r++;
|
|
796
794
|
else
|
|
797
795
|
r = i;
|
|
798
|
-
const
|
|
799
|
-
s.checked =
|
|
796
|
+
const o = r > 0 && this.selected.size >= r, n = this.selected.size > 0;
|
|
797
|
+
s.checked = o, s.indeterminate = n && !o;
|
|
800
798
|
}
|
|
801
799
|
}
|
|
802
800
|
// #endregion
|
|
@@ -835,22 +833,22 @@ class P extends E {
|
|
|
835
833
|
const e = this.gridElement;
|
|
836
834
|
if (!e) return;
|
|
837
835
|
const { mode: t } = this.config, s = !!this.config.isSelectable;
|
|
838
|
-
e.querySelectorAll(".cell").forEach((
|
|
839
|
-
|
|
836
|
+
e.querySelectorAll(".cell").forEach((o) => {
|
|
837
|
+
o.classList.remove("selected", "top", "bottom", "first", "last"), s && o.removeAttribute("data-selectable");
|
|
840
838
|
});
|
|
841
839
|
const r = e.querySelectorAll(".data-grid-row");
|
|
842
|
-
if (r.forEach((
|
|
843
|
-
|
|
844
|
-
}), t === "row" && (C(e), r.forEach((
|
|
845
|
-
const
|
|
846
|
-
h >= 0 && (s && !this.isRowSelectable(h) &&
|
|
847
|
-
}), this.config.checkbox && this.#i(e)), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((
|
|
848
|
-
const h = parseInt(
|
|
849
|
-
h >= 0 && a >= 0 && (this.isCellSelectable(h, a) ||
|
|
840
|
+
if (r.forEach((o) => {
|
|
841
|
+
o.classList.remove("selected", "row-focus"), s && o.removeAttribute("data-selectable");
|
|
842
|
+
}), t === "row" && (C(e), r.forEach((o) => {
|
|
843
|
+
const n = o.querySelector(".cell[data-row]"), h = R(n);
|
|
844
|
+
h >= 0 && (s && !this.isRowSelectable(h) && o.setAttribute("data-selectable", "false"), this.selected.has(h) && o.classList.add("selected", "row-focus"));
|
|
845
|
+
}), this.config.checkbox && this.#i(e)), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((n) => {
|
|
846
|
+
const h = parseInt(n.getAttribute("data-row") ?? "-1", 10), a = parseInt(n.getAttribute("data-col") ?? "-1", 10);
|
|
847
|
+
h >= 0 && a >= 0 && (this.isCellSelectable(h, a) || n.setAttribute("data-selectable", "false"));
|
|
850
848
|
}), t === "range" && this.ranges.length > 0) {
|
|
851
849
|
C(e);
|
|
852
|
-
const
|
|
853
|
-
for (const c of
|
|
850
|
+
const o = this.ranges.map(g), n = (a, d) => {
|
|
851
|
+
for (const c of o)
|
|
854
852
|
if (a >= c.startRow && a <= c.endRow && d >= c.startCol && d <= c.endCol)
|
|
855
853
|
return !0;
|
|
856
854
|
return !1;
|
|
@@ -858,10 +856,10 @@ class P extends E {
|
|
|
858
856
|
e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
859
857
|
const d = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
860
858
|
if (d >= 0 && c >= 0) {
|
|
861
|
-
const u = this.
|
|
859
|
+
const u = this.visibleColumns[c];
|
|
862
860
|
if (u && f(u))
|
|
863
861
|
return;
|
|
864
|
-
|
|
862
|
+
n(d, c) && (a.classList.add("selected"), n(d - 1, c) || a.classList.add("top"), n(d + 1, c) || a.classList.add("bottom"), n(d, c - 1) || a.classList.add("first"), n(d, c + 1) || a.classList.add("last"));
|
|
865
863
|
}
|
|
866
864
|
});
|
|
867
865
|
}
|
|
@@ -875,11 +873,11 @@ class P extends E {
|
|
|
875
873
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
876
874
|
const { shiftKey: i } = this.pendingKeyboardUpdate;
|
|
877
875
|
this.pendingKeyboardUpdate = null;
|
|
878
|
-
const r = this.grid._focusRow,
|
|
876
|
+
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
879
877
|
if (i && this.cellAnchor) {
|
|
880
|
-
const
|
|
881
|
-
this.ranges = [
|
|
882
|
-
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col:
|
|
878
|
+
const n = m(this.cellAnchor, { row: r, col: o });
|
|
879
|
+
this.ranges = [n], this.activeRange = n;
|
|
880
|
+
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
|
|
883
881
|
this.emit("selection-change", this.#e());
|
|
884
882
|
}
|
|
885
883
|
this.#r(s), this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#s();
|
|
@@ -1025,9 +1023,9 @@ class P extends E {
|
|
|
1025
1023
|
if (e === "range" && this.ranges.length > 0) {
|
|
1026
1024
|
const s = /* @__PURE__ */ new Set();
|
|
1027
1025
|
for (const i of this.ranges) {
|
|
1028
|
-
const r = Math.max(0, Math.min(i.startRow, i.endRow)),
|
|
1029
|
-
for (let
|
|
1030
|
-
s.add(
|
|
1026
|
+
const r = Math.max(0, Math.min(i.startRow, i.endRow)), o = Math.min(t.length - 1, Math.max(i.startRow, i.endRow));
|
|
1027
|
+
for (let n = r; n <= o; n++)
|
|
1028
|
+
s.add(n);
|
|
1031
1029
|
}
|
|
1032
1030
|
return [...s].sort((i, r) => i - r).map((i) => t[i]);
|
|
1033
1031
|
}
|