@toolbox-web/grid 1.14.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 +1125 -1097
- package/all.js.map +1 -1
- package/index.js +151 -138
- 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/rows.d.ts.map +1 -1
- package/lib/plugins/editing/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.js +319 -290
- package/lib/plugins/filtering/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 +122 -122
- package/lib/plugins/selection/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +30 -30
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +3 -3
- package/umd/grid.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/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,CA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;;;;;;;;;;;;;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;IA+BjB;;;;;;;;;;;;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"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
function R(
|
|
2
|
-
if (!
|
|
3
|
-
const e =
|
|
1
|
+
function R(n) {
|
|
2
|
+
if (!n) return -1;
|
|
3
|
+
const e = n.getAttribute("data-row");
|
|
4
4
|
if (e) return parseInt(e, 10);
|
|
5
|
-
const t =
|
|
5
|
+
const t = n.closest(".data-grid-row");
|
|
6
6
|
if (!t) return -1;
|
|
7
7
|
const s = t.parentElement;
|
|
8
8
|
if (!s) return -1;
|
|
9
|
-
const
|
|
10
|
-
for (let
|
|
11
|
-
if (r
|
|
9
|
+
const i = s.querySelectorAll(":scope > .data-grid-row");
|
|
10
|
+
for (let r = 0; r < i.length; r++)
|
|
11
|
+
if (i[r] === t) return r;
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
|
-
function C(
|
|
15
|
-
|
|
14
|
+
function C(n) {
|
|
15
|
+
n && n.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>', A = {
|
|
18
18
|
expand: "▶",
|
|
@@ -394,68 +394,68 @@ class v {
|
|
|
394
394
|
// #endregion
|
|
395
395
|
}
|
|
396
396
|
const E = "__tbw_expander";
|
|
397
|
-
function k(
|
|
398
|
-
return
|
|
397
|
+
function k(n) {
|
|
398
|
+
return n.field === E;
|
|
399
399
|
}
|
|
400
|
-
function f(
|
|
401
|
-
return
|
|
400
|
+
function f(n) {
|
|
401
|
+
return n.meta?.utility === !0;
|
|
402
402
|
}
|
|
403
|
-
function g(
|
|
403
|
+
function g(n) {
|
|
404
404
|
return {
|
|
405
|
-
startRow: Math.min(
|
|
406
|
-
startCol: Math.min(
|
|
407
|
-
endRow: Math.max(
|
|
408
|
-
endCol: Math.max(
|
|
405
|
+
startRow: Math.min(n.startRow, n.endRow),
|
|
406
|
+
startCol: Math.min(n.startCol, n.endCol),
|
|
407
|
+
endRow: Math.max(n.startRow, n.endRow),
|
|
408
|
+
endCol: Math.max(n.startCol, n.endCol)
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
|
-
function I(
|
|
412
|
-
const e = g(
|
|
411
|
+
function I(n) {
|
|
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
|
|
418
|
+
function S(n) {
|
|
419
|
+
return n.map(I);
|
|
420
420
|
}
|
|
421
|
-
function _(
|
|
421
|
+
function _(n, e, t) {
|
|
422
422
|
const s = g(t);
|
|
423
|
-
return
|
|
423
|
+
return n >= s.startRow && n <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
424
424
|
}
|
|
425
|
-
function q(
|
|
426
|
-
return t.some((s) => _(
|
|
425
|
+
function q(n, e, t) {
|
|
426
|
+
return t.some((s) => _(n, e, s));
|
|
427
427
|
}
|
|
428
|
-
function K(
|
|
429
|
-
const e = [], t = g(
|
|
428
|
+
function K(n) {
|
|
429
|
+
const e = [], t = g(n);
|
|
430
430
|
for (let s = t.startRow; s <= t.endRow; s++)
|
|
431
|
-
for (let
|
|
432
|
-
e.push({ row: s, col:
|
|
431
|
+
for (let i = t.startCol; i <= t.endCol; i++)
|
|
432
|
+
e.push({ row: s, col: i });
|
|
433
433
|
return e;
|
|
434
434
|
}
|
|
435
|
-
function M(
|
|
435
|
+
function M(n) {
|
|
436
436
|
const e = /* @__PURE__ */ new Map();
|
|
437
|
-
for (const t of
|
|
437
|
+
for (const t of n)
|
|
438
438
|
for (const s of K(t))
|
|
439
439
|
e.set(`${s.row},${s.col}`, s);
|
|
440
440
|
return [...e.values()];
|
|
441
441
|
}
|
|
442
|
-
function m(
|
|
442
|
+
function m(n, e) {
|
|
443
443
|
return {
|
|
444
|
-
startRow:
|
|
445
|
-
startCol:
|
|
444
|
+
startRow: n.row,
|
|
445
|
+
startCol: n.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(n, e) {
|
|
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 .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}}',
|
|
455
|
-
function D(
|
|
456
|
-
if (
|
|
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
|
+
function D(n, e, t) {
|
|
456
|
+
if (n === "cell" && e.selectedCell)
|
|
457
457
|
return {
|
|
458
|
-
mode:
|
|
458
|
+
mode: n,
|
|
459
459
|
ranges: [
|
|
460
460
|
{
|
|
461
461
|
from: { row: e.selectedCell.row, col: e.selectedCell.col },
|
|
@@ -463,14 +463,14 @@ function D(o, e, t) {
|
|
|
463
463
|
}
|
|
464
464
|
]
|
|
465
465
|
};
|
|
466
|
-
if (
|
|
467
|
-
const s = [...e.selected].sort((l, d) => l - d),
|
|
468
|
-
let
|
|
466
|
+
if (n === "row" && e.selected.size > 0) {
|
|
467
|
+
const s = [...e.selected].sort((l, d) => l - d), i = [];
|
|
468
|
+
let r = s[0], o = r;
|
|
469
469
|
for (let l = 1; l < s.length; l++)
|
|
470
|
-
s[l] ===
|
|
471
|
-
return
|
|
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
|
|
473
|
+
return n === "range" && e.ranges.length > 0 ? { mode: n, ranges: S(e.ranges) } : { mode: n, ranges: [] };
|
|
474
474
|
}
|
|
475
475
|
class L extends v {
|
|
476
476
|
/**
|
|
@@ -544,10 +544,10 @@ class L extends v {
|
|
|
544
544
|
checkSelectable(e, t) {
|
|
545
545
|
const { isSelectable: s } = this.config;
|
|
546
546
|
if (!s) return !0;
|
|
547
|
-
const
|
|
548
|
-
if (!
|
|
549
|
-
const
|
|
550
|
-
return s(
|
|
547
|
+
const i = this.rows[e];
|
|
548
|
+
if (!i) return !1;
|
|
549
|
+
const r = t !== void 0 ? this.columns[t] : void 0;
|
|
550
|
+
return s(i, e, r, t);
|
|
551
551
|
}
|
|
552
552
|
/**
|
|
553
553
|
* Check if an entire row is selectable (for row mode).
|
|
@@ -595,20 +595,20 @@ class L extends v {
|
|
|
595
595
|
/** @internal */
|
|
596
596
|
onCellClick(e) {
|
|
597
597
|
if (!this.isSelectionEnabled()) return !1;
|
|
598
|
-
const { rowIndex: t, colIndex: s, originalEvent:
|
|
599
|
-
if (
|
|
598
|
+
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: r, triggerOn: o = "click" } = this.config;
|
|
599
|
+
if (i.type !== o)
|
|
600
600
|
return !1;
|
|
601
601
|
const l = this.columns[s], d = l && f(l);
|
|
602
|
-
if (
|
|
602
|
+
if (r === "cell") {
|
|
603
603
|
if (d || !this.isCellSelectable(t, s))
|
|
604
604
|
return !1;
|
|
605
605
|
const a = this.selectedCell;
|
|
606
606
|
return a && a.row === t && a.col === s || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
607
607
|
}
|
|
608
|
-
if (
|
|
608
|
+
if (r === "row") {
|
|
609
609
|
if (!this.isRowSelectable(t))
|
|
610
610
|
return !1;
|
|
611
|
-
const a =
|
|
611
|
+
const a = i.shiftKey, h = i.ctrlKey || i.metaKey, c = l?.meta?.checkboxColumn === !0;
|
|
612
612
|
if (a && this.anchor !== null) {
|
|
613
613
|
const u = Math.min(this.anchor, t), x = Math.max(this.anchor, t);
|
|
614
614
|
h || this.selected.clear();
|
|
@@ -623,10 +623,10 @@ class L extends v {
|
|
|
623
623
|
}
|
|
624
624
|
return this.lastSelected = t, this.explicitSelection = !0, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
625
625
|
}
|
|
626
|
-
if (
|
|
626
|
+
if (r === "range") {
|
|
627
627
|
if (d || !this.isCellSelectable(t, s))
|
|
628
628
|
return !1;
|
|
629
|
-
const a =
|
|
629
|
+
const a = i.shiftKey, h = i.ctrlKey || i.metaKey;
|
|
630
630
|
if (a && this.cellAnchor) {
|
|
631
631
|
const c = m(this.cellAnchor, { row: t, col: s }), u = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
632
632
|
if (u && b(u, c))
|
|
@@ -658,37 +658,37 @@ class L extends v {
|
|
|
658
658
|
/** @internal */
|
|
659
659
|
onKeyDown(e) {
|
|
660
660
|
if (!this.isSelectionEnabled()) return !1;
|
|
661
|
-
const { mode: t } = this.config,
|
|
661
|
+
const { mode: t } = this.config, i = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
|
|
662
662
|
if (e.key === "Escape")
|
|
663
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);
|
|
664
|
-
if (t === "cell" &&
|
|
664
|
+
if (t === "cell" && i)
|
|
665
665
|
return queueMicrotask(() => {
|
|
666
|
-
const
|
|
667
|
-
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();
|
|
668
668
|
}), !1;
|
|
669
669
|
if (t === "row") {
|
|
670
670
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
671
|
-
const
|
|
672
|
-
return
|
|
673
|
-
const
|
|
674
|
-
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) {
|
|
675
675
|
this.selected.clear();
|
|
676
|
-
const l = Math.min(this.anchor,
|
|
676
|
+
const l = Math.min(this.anchor, o), d = Math.max(this.anchor, o);
|
|
677
677
|
for (let a = l; a <= d; a++)
|
|
678
678
|
this.isRowSelectable(a) && this.selected.add(a);
|
|
679
679
|
} else
|
|
680
|
-
this.isRowSelectable(
|
|
681
|
-
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();
|
|
682
682
|
}), !1;
|
|
683
683
|
}
|
|
684
684
|
if (e.key === "a" && (e.ctrlKey || e.metaKey))
|
|
685
|
-
return e.preventDefault(), e.stopPropagation(), this.selectAll(), !0;
|
|
685
|
+
return this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0);
|
|
686
686
|
}
|
|
687
|
-
if (t === "range" &&
|
|
688
|
-
const
|
|
689
|
-
return
|
|
687
|
+
if (t === "range" && i) {
|
|
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;
|
|
690
690
|
}
|
|
691
|
-
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;
|
|
692
692
|
}
|
|
693
693
|
/** @internal */
|
|
694
694
|
onCellMouseDown(e) {
|
|
@@ -697,13 +697,13 @@ class L extends v {
|
|
|
697
697
|
if (t && f(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
698
698
|
return;
|
|
699
699
|
this.isDragging = !0;
|
|
700
|
-
const s = e.rowIndex,
|
|
700
|
+
const s = e.rowIndex, i = e.colIndex, r = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
|
|
701
701
|
startRow: s,
|
|
702
|
-
startCol:
|
|
702
|
+
startCol: i,
|
|
703
703
|
endRow: s,
|
|
704
|
-
endCol:
|
|
704
|
+
endCol: i
|
|
705
705
|
};
|
|
706
|
-
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);
|
|
707
707
|
}
|
|
708
708
|
/** @internal */
|
|
709
709
|
onCellMouseMove(e) {
|
|
@@ -711,11 +711,11 @@ class L extends v {
|
|
|
711
711
|
let t = e.colIndex;
|
|
712
712
|
const s = this.columns[t];
|
|
713
713
|
if (s && f(s)) {
|
|
714
|
-
const
|
|
715
|
-
|
|
714
|
+
const o = this.columns.findIndex((l) => !f(l));
|
|
715
|
+
o >= 0 && (t = o);
|
|
716
716
|
}
|
|
717
|
-
const
|
|
718
|
-
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;
|
|
719
719
|
}
|
|
720
720
|
/** @internal */
|
|
721
721
|
onCellMouseUp(e) {
|
|
@@ -729,10 +729,10 @@ class L extends v {
|
|
|
729
729
|
*/
|
|
730
730
|
processColumns(e) {
|
|
731
731
|
if (this.config.checkbox && this.config.mode === "row") {
|
|
732
|
-
if (e.some((
|
|
732
|
+
if (e.some((r) => r.field === y))
|
|
733
733
|
return e;
|
|
734
|
-
const t = this.#t(), s = e.findIndex(k),
|
|
735
|
-
return [...e.slice(0,
|
|
734
|
+
const t = this.#t(), s = e.findIndex(k), i = s >= 0 ? s + 1 : 0;
|
|
735
|
+
return [...e.slice(0, i), t, ...e.slice(i)];
|
|
736
736
|
}
|
|
737
737
|
return e;
|
|
738
738
|
}
|
|
@@ -741,7 +741,7 @@ class L extends v {
|
|
|
741
741
|
*/
|
|
742
742
|
#t() {
|
|
743
743
|
return {
|
|
744
|
-
field:
|
|
744
|
+
field: y,
|
|
745
745
|
header: "",
|
|
746
746
|
width: 32,
|
|
747
747
|
resizable: !1,
|
|
@@ -765,8 +765,8 @@ class L extends v {
|
|
|
765
765
|
t.type = "checkbox", t.className = "tbw-select-row-checkbox";
|
|
766
766
|
const s = e.cellEl;
|
|
767
767
|
if (s) {
|
|
768
|
-
const
|
|
769
|
-
|
|
768
|
+
const i = parseInt(s.getAttribute("data-row") ?? "-1", 10);
|
|
769
|
+
i >= 0 && (t.checked = this.selected.has(i));
|
|
770
770
|
}
|
|
771
771
|
return t;
|
|
772
772
|
}
|
|
@@ -776,22 +776,22 @@ class L extends v {
|
|
|
776
776
|
* Update checkbox checked states to reflect current selection.
|
|
777
777
|
* Called from #applySelectionClasses.
|
|
778
778
|
*/
|
|
779
|
-
#
|
|
780
|
-
e.querySelectorAll(".tbw-select-row-checkbox").forEach((
|
|
781
|
-
const
|
|
782
|
-
|
|
779
|
+
#i(e) {
|
|
780
|
+
e.querySelectorAll(".tbw-select-row-checkbox").forEach((i) => {
|
|
781
|
+
const r = i.closest(".cell"), o = r ? R(r) : -1;
|
|
782
|
+
o >= 0 && (i.checked = this.selected.has(o));
|
|
783
783
|
});
|
|
784
784
|
const s = e.querySelector(".tbw-select-all-checkbox");
|
|
785
785
|
if (s) {
|
|
786
|
-
const
|
|
787
|
-
let
|
|
786
|
+
const i = this.rows.length;
|
|
787
|
+
let r = 0;
|
|
788
788
|
if (this.config.isSelectable)
|
|
789
|
-
for (let d = 0; d <
|
|
790
|
-
this.isRowSelectable(d) &&
|
|
789
|
+
for (let d = 0; d < i; d++)
|
|
790
|
+
this.isRowSelectable(d) && r++;
|
|
791
791
|
else
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
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;
|
|
795
795
|
}
|
|
796
796
|
}
|
|
797
797
|
// #endregion
|
|
@@ -802,7 +802,7 @@ class L extends v {
|
|
|
802
802
|
* Only updates when the focus has changed since the last sync.
|
|
803
803
|
* Skips when `explicitSelection` is set (click/keyboard set selection directly).
|
|
804
804
|
*/
|
|
805
|
-
#
|
|
805
|
+
#r(e) {
|
|
806
806
|
const t = this.grid._focusRow, s = this.grid._focusCol;
|
|
807
807
|
if (e === "row") {
|
|
808
808
|
if (this.explicitSelection) {
|
|
@@ -817,8 +817,8 @@ class L extends v {
|
|
|
817
817
|
return;
|
|
818
818
|
}
|
|
819
819
|
if ((t !== this.lastSyncedFocusRow || s !== this.lastSyncedFocusCol) && (this.lastSyncedFocusRow = t, this.lastSyncedFocusCol = s, this.isCellSelectable(t, s))) {
|
|
820
|
-
const
|
|
821
|
-
(!
|
|
820
|
+
const i = this.selectedCell;
|
|
821
|
+
(!i || i.row !== t || i.col !== s) && (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()));
|
|
822
822
|
}
|
|
823
823
|
}
|
|
824
824
|
}
|
|
@@ -830,22 +830,22 @@ class L extends v {
|
|
|
830
830
|
const e = this.gridElement;
|
|
831
831
|
if (!e) return;
|
|
832
832
|
const { mode: t } = this.config, s = !!this.config.isSelectable;
|
|
833
|
-
e.querySelectorAll(".cell").forEach((
|
|
834
|
-
|
|
833
|
+
e.querySelectorAll(".cell").forEach((o) => {
|
|
834
|
+
o.classList.remove("selected", "top", "bottom", "first", "last"), s && o.removeAttribute("data-selectable");
|
|
835
835
|
});
|
|
836
|
-
const
|
|
837
|
-
if (
|
|
838
|
-
|
|
839
|
-
}), t === "row" && (C(e),
|
|
840
|
-
const l =
|
|
841
|
-
d >= 0 && (s && !this.isRowSelectable(d) &&
|
|
842
|
-
}), this.config.checkbox && this.#
|
|
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
843
|
const d = parseInt(l.getAttribute("data-row") ?? "-1", 10), a = parseInt(l.getAttribute("data-col") ?? "-1", 10);
|
|
844
844
|
d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || l.setAttribute("data-selectable", "false"));
|
|
845
845
|
}), t === "range" && this.ranges.length > 0) {
|
|
846
846
|
C(e);
|
|
847
|
-
const
|
|
848
|
-
for (const c of
|
|
847
|
+
const o = this.ranges.map(g), l = (a, h) => {
|
|
848
|
+
for (const c of o)
|
|
849
849
|
if (a >= c.startRow && a <= c.endRow && h >= c.startCol && h <= c.endCol)
|
|
850
850
|
return !0;
|
|
851
851
|
return !1;
|
|
@@ -868,16 +868,16 @@ class L extends v {
|
|
|
868
868
|
if (!e) return;
|
|
869
869
|
const t = e.children[0], { mode: s } = this.config;
|
|
870
870
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
871
|
-
const { shiftKey:
|
|
871
|
+
const { shiftKey: i } = this.pendingKeyboardUpdate;
|
|
872
872
|
this.pendingKeyboardUpdate = null;
|
|
873
|
-
const
|
|
874
|
-
if (
|
|
875
|
-
const l = m(this.cellAnchor, { row:
|
|
873
|
+
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
874
|
+
if (i && this.cellAnchor) {
|
|
875
|
+
const l = m(this.cellAnchor, { row: r, col: o });
|
|
876
876
|
this.ranges = [l], this.activeRange = l;
|
|
877
|
-
} else
|
|
877
|
+
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
|
|
878
878
|
this.emit("selection-change", this.#e());
|
|
879
879
|
}
|
|
880
|
-
this.#
|
|
880
|
+
this.#r(s), this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#s();
|
|
881
881
|
}
|
|
882
882
|
/**
|
|
883
883
|
* Called after scroll-triggered row rendering.
|
|
@@ -946,13 +946,13 @@ class L extends v {
|
|
|
946
946
|
} else if (e === "range") {
|
|
947
947
|
const t = this.rows.length, s = this.columns.length;
|
|
948
948
|
if (t > 0 && s > 0) {
|
|
949
|
-
const
|
|
949
|
+
const i = {
|
|
950
950
|
startRow: 0,
|
|
951
951
|
startCol: 0,
|
|
952
952
|
endRow: t - 1,
|
|
953
953
|
endCol: s - 1
|
|
954
954
|
};
|
|
955
|
-
this.ranges = [
|
|
955
|
+
this.ranges = [i], this.activeRange = i, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
958
|
}
|
|
@@ -1007,7 +1007,7 @@ class L extends v {
|
|
|
1007
1007
|
endCol: t.to.col
|
|
1008
1008
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
1009
1009
|
mode: this.config.mode,
|
|
1010
|
-
ranges:
|
|
1010
|
+
ranges: S(this.ranges)
|
|
1011
1011
|
}), this.requestAfterRender();
|
|
1012
1012
|
}
|
|
1013
1013
|
// #endregion
|