@toolbox-web/grid 1.13.0 → 1.14.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 +1483 -1403
- package/all.js.map +1 -1
- package/index.js +11 -4
- package/index.js.map +1 -1
- package/lib/core/internal/row-animation.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/index.d.ts +1 -1
- package/lib/plugins/filtering/index.d.ts.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/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 +147 -139
- 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 +23 -23
- 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/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/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.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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(o) {
|
|
2
|
+
if (!o) return -1;
|
|
3
|
+
const e = o.getAttribute("data-row");
|
|
4
4
|
if (e) return parseInt(e, 10);
|
|
5
|
-
const t =
|
|
5
|
+
const t = o.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 (
|
|
9
|
+
const r = s.querySelectorAll(":scope > .data-grid-row");
|
|
10
|
+
for (let n = 0; n < r.length; n++)
|
|
11
|
+
if (r[n] === t) return n;
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
|
-
function C(
|
|
15
|
-
|
|
14
|
+
function C(o) {
|
|
15
|
+
o && o.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: "▶",
|
|
@@ -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,68 +394,68 @@ class k {
|
|
|
394
394
|
// #endregion
|
|
395
395
|
}
|
|
396
396
|
const E = "__tbw_expander";
|
|
397
|
-
function
|
|
398
|
-
return
|
|
397
|
+
function k(o) {
|
|
398
|
+
return o.field === E;
|
|
399
399
|
}
|
|
400
|
-
function f(
|
|
401
|
-
return
|
|
400
|
+
function f(o) {
|
|
401
|
+
return o.meta?.utility === !0;
|
|
402
402
|
}
|
|
403
|
-
function g(
|
|
403
|
+
function g(o) {
|
|
404
404
|
return {
|
|
405
|
-
startRow: Math.min(
|
|
406
|
-
startCol: Math.min(
|
|
407
|
-
endRow: Math.max(
|
|
408
|
-
endCol: Math.max(
|
|
405
|
+
startRow: Math.min(o.startRow, o.endRow),
|
|
406
|
+
startCol: Math.min(o.startCol, o.endCol),
|
|
407
|
+
endRow: Math.max(o.startRow, o.endRow),
|
|
408
|
+
endCol: Math.max(o.startCol, o.endCol)
|
|
409
409
|
};
|
|
410
410
|
}
|
|
411
|
-
function
|
|
412
|
-
const e = g(
|
|
411
|
+
function I(o) {
|
|
412
|
+
const e = g(o);
|
|
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(o) {
|
|
419
|
+
return o.map(I);
|
|
420
420
|
}
|
|
421
|
-
function _(
|
|
421
|
+
function _(o, e, t) {
|
|
422
422
|
const s = g(t);
|
|
423
|
-
return
|
|
423
|
+
return o >= s.startRow && o <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
424
424
|
}
|
|
425
|
-
function q(
|
|
426
|
-
return t.some((s) => _(
|
|
425
|
+
function q(o, e, t) {
|
|
426
|
+
return t.some((s) => _(o, e, s));
|
|
427
427
|
}
|
|
428
|
-
function K(
|
|
429
|
-
const e = [], t = g(
|
|
428
|
+
function K(o) {
|
|
429
|
+
const e = [], t = g(o);
|
|
430
430
|
for (let s = t.startRow; s <= t.endRow; s++)
|
|
431
|
-
for (let
|
|
432
|
-
e.push({ row: s, col:
|
|
431
|
+
for (let r = t.startCol; r <= t.endCol; r++)
|
|
432
|
+
e.push({ row: s, col: r });
|
|
433
433
|
return e;
|
|
434
434
|
}
|
|
435
|
-
function M(
|
|
435
|
+
function M(o) {
|
|
436
436
|
const e = /* @__PURE__ */ new Map();
|
|
437
|
-
for (const t of
|
|
437
|
+
for (const t of o)
|
|
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(o, e) {
|
|
443
443
|
return {
|
|
444
|
-
startRow:
|
|
445
|
-
startCol:
|
|
444
|
+
startRow: o.row,
|
|
445
|
+
startCol: o.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(o, e) {
|
|
451
|
+
const t = g(o), 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
|
|
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}}', S = "__tbw_checkbox";
|
|
455
|
+
function D(o, e, t) {
|
|
456
|
+
if (o === "cell" && e.selectedCell)
|
|
457
457
|
return {
|
|
458
|
-
mode:
|
|
458
|
+
mode: o,
|
|
459
459
|
ranges: [
|
|
460
460
|
{
|
|
461
461
|
from: { row: e.selectedCell.row, col: e.selectedCell.col },
|
|
@@ -463,22 +463,26 @@ function D(n, e, t) {
|
|
|
463
463
|
}
|
|
464
464
|
]
|
|
465
465
|
};
|
|
466
|
-
if (
|
|
467
|
-
const s = [...e.selected].sort((
|
|
468
|
-
let
|
|
469
|
-
for (let
|
|
470
|
-
s[
|
|
471
|
-
return
|
|
472
|
-
}
|
|
473
|
-
return
|
|
466
|
+
if (o === "row" && e.selected.size > 0) {
|
|
467
|
+
const s = [...e.selected].sort((l, d) => l - d), r = [];
|
|
468
|
+
let n = s[0], i = n;
|
|
469
|
+
for (let l = 1; l < s.length; l++)
|
|
470
|
+
s[l] === i + 1 ? i = s[l] : (r.push({ from: { row: n, col: 0 }, to: { row: i, col: t - 1 } }), n = s[l], i = n);
|
|
471
|
+
return r.push({ from: { row: n, col: 0 }, to: { row: i, col: t - 1 } }), { mode: o, ranges: r };
|
|
472
|
+
}
|
|
473
|
+
return o === "range" && e.ranges.length > 0 ? { mode: o, ranges: y(e.ranges) } : { mode: o, 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",
|
|
@@ -540,10 +544,10 @@ class L extends k {
|
|
|
540
544
|
checkSelectable(e, t) {
|
|
541
545
|
const { isSelectable: s } = this.config;
|
|
542
546
|
if (!s) return !0;
|
|
543
|
-
const
|
|
544
|
-
if (!
|
|
545
|
-
const
|
|
546
|
-
return s(
|
|
547
|
+
const r = this.rows[e];
|
|
548
|
+
if (!r) return !1;
|
|
549
|
+
const n = t !== void 0 ? this.columns[t] : void 0;
|
|
550
|
+
return s(r, e, n, 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:
|
|
591
|
-
if (
|
|
598
|
+
const { rowIndex: t, colIndex: s, originalEvent: r } = e, { mode: n, triggerOn: i = "click" } = this.config;
|
|
599
|
+
if (r.type !== i)
|
|
592
600
|
return !1;
|
|
593
|
-
const
|
|
594
|
-
if (
|
|
595
|
-
if (
|
|
601
|
+
const l = this.columns[s], d = l && f(l);
|
|
602
|
+
if (n === "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 (n === "row") {
|
|
601
609
|
if (!this.isRowSelectable(t))
|
|
602
610
|
return !1;
|
|
603
|
-
const a =
|
|
611
|
+
const a = r.shiftKey, h = r.ctrlKey || r.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 (n === "range") {
|
|
627
|
+
if (d || !this.isCellSelectable(t, s))
|
|
620
628
|
return !1;
|
|
621
|
-
const a =
|
|
629
|
+
const a = r.shiftKey, h = r.ctrlKey || r.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,
|
|
@@ -650,35 +658,35 @@ class L extends k {
|
|
|
650
658
|
/** @internal */
|
|
651
659
|
onKeyDown(e) {
|
|
652
660
|
if (!this.isSelectionEnabled()) return !1;
|
|
653
|
-
const { mode: t } = this.config,
|
|
661
|
+
const { mode: t } = this.config, r = ["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;
|
|
656
|
-
if (t === "cell" &&
|
|
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" && r)
|
|
657
665
|
return queueMicrotask(() => {
|
|
658
|
-
const
|
|
659
|
-
this.isCellSelectable(
|
|
666
|
+
const n = this.grid._focusRow, i = this.grid._focusCol;
|
|
667
|
+
this.isCellSelectable(n, i) ? this.selectedCell = { row: n, col: i } : 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 n = e.shiftKey;
|
|
672
|
+
return n && this.anchor === null && (this.anchor = this.grid._focusRow), queueMicrotask(() => {
|
|
673
|
+
const i = this.grid._focusRow;
|
|
674
|
+
if (n && this.anchor !== null) {
|
|
667
675
|
this.selected.clear();
|
|
668
|
-
const
|
|
669
|
-
for (let a =
|
|
676
|
+
const l = Math.min(this.anchor, i), d = Math.max(this.anchor, i);
|
|
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(i) ? (this.selected.clear(), this.selected.add(i), this.anchor = i) : this.selected.clear();
|
|
681
|
+
this.lastSelected = i, 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
685
|
return e.preventDefault(), e.stopPropagation(), this.selectAll(), !0;
|
|
678
686
|
}
|
|
679
|
-
if (t === "range" &&
|
|
680
|
-
const
|
|
681
|
-
return
|
|
687
|
+
if (t === "range" && r) {
|
|
688
|
+
const n = e.key === "Tab", i = e.shiftKey && !n;
|
|
689
|
+
return i && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: i }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
682
690
|
}
|
|
683
691
|
return t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey) ? (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0) : !1;
|
|
684
692
|
}
|
|
@@ -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,
|
|
700
|
+
const s = e.rowIndex, r = e.colIndex, n = e.originalEvent.ctrlKey || e.originalEvent.metaKey, i = {
|
|
693
701
|
startRow: s,
|
|
694
|
-
startCol:
|
|
702
|
+
startCol: r,
|
|
695
703
|
endRow: s,
|
|
696
|
-
endCol:
|
|
704
|
+
endCol: r
|
|
697
705
|
};
|
|
698
|
-
return !
|
|
706
|
+
return !n && this.ranges.length === 1 && b(this.ranges[0], i) ? (this.cellAnchor = { row: s, col: r }, !0) : (this.cellAnchor = { row: s, col: r }, n || (this.ranges = []), this.ranges.push(i), this.activeRange = i, 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 i = this.columns.findIndex((l) => !f(l));
|
|
715
|
+
i >= 0 && (t = i);
|
|
708
716
|
}
|
|
709
|
-
const
|
|
710
|
-
return
|
|
717
|
+
const r = m(this.cellAnchor, { row: e.rowIndex, col: t }), n = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
718
|
+
return n && b(n, r) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = r : this.ranges.push(r), this.activeRange = r, this.emit("selection-change", this.#e()), this.requestAfterRender()), !0;
|
|
711
719
|
}
|
|
712
720
|
/** @internal */
|
|
713
721
|
onCellMouseUp(e) {
|
|
@@ -721,10 +729,10 @@ 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((n) => n.field === S))
|
|
725
733
|
return e;
|
|
726
|
-
const t = this.#t(), s = e.findIndex(
|
|
727
|
-
return [...e.slice(0,
|
|
734
|
+
const t = this.#t(), s = e.findIndex(k), r = s >= 0 ? s + 1 : 0;
|
|
735
|
+
return [...e.slice(0, r), t, ...e.slice(r)];
|
|
728
736
|
}
|
|
729
737
|
return e;
|
|
730
738
|
}
|
|
@@ -757,8 +765,8 @@ class L extends k {
|
|
|
757
765
|
t.type = "checkbox", t.className = "tbw-select-row-checkbox";
|
|
758
766
|
const s = e.cellEl;
|
|
759
767
|
if (s) {
|
|
760
|
-
const
|
|
761
|
-
|
|
768
|
+
const r = parseInt(s.getAttribute("data-row") ?? "-1", 10);
|
|
769
|
+
r >= 0 && (t.checked = this.selected.has(r));
|
|
762
770
|
}
|
|
763
771
|
return t;
|
|
764
772
|
}
|
|
@@ -768,22 +776,22 @@ class L extends k {
|
|
|
768
776
|
* Update checkbox checked states to reflect current selection.
|
|
769
777
|
* Called from #applySelectionClasses.
|
|
770
778
|
*/
|
|
771
|
-
#
|
|
772
|
-
e.querySelectorAll(".tbw-select-row-checkbox").forEach((
|
|
773
|
-
const
|
|
774
|
-
|
|
779
|
+
#r(e) {
|
|
780
|
+
e.querySelectorAll(".tbw-select-row-checkbox").forEach((r) => {
|
|
781
|
+
const n = r.closest(".cell"), i = n ? R(n) : -1;
|
|
782
|
+
i >= 0 && (r.checked = this.selected.has(i));
|
|
775
783
|
});
|
|
776
784
|
const s = e.querySelector(".tbw-select-all-checkbox");
|
|
777
785
|
if (s) {
|
|
778
|
-
const
|
|
779
|
-
let
|
|
786
|
+
const r = this.rows.length;
|
|
787
|
+
let n = 0;
|
|
780
788
|
if (this.config.isSelectable)
|
|
781
|
-
for (let
|
|
782
|
-
this.isRowSelectable(
|
|
789
|
+
for (let d = 0; d < r; d++)
|
|
790
|
+
this.isRowSelectable(d) && n++;
|
|
783
791
|
else
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
s.checked =
|
|
792
|
+
n = r;
|
|
793
|
+
const i = n > 0 && this.selected.size >= n, l = this.selected.size > 0;
|
|
794
|
+
s.checked = i, s.indeterminate = l && !i;
|
|
787
795
|
}
|
|
788
796
|
}
|
|
789
797
|
// #endregion
|
|
@@ -794,7 +802,7 @@ class L extends k {
|
|
|
794
802
|
* Only updates when the focus has changed since the last sync.
|
|
795
803
|
* Skips when `explicitSelection` is set (click/keyboard set selection directly).
|
|
796
804
|
*/
|
|
797
|
-
#
|
|
805
|
+
#i(e) {
|
|
798
806
|
const t = this.grid._focusRow, s = this.grid._focusCol;
|
|
799
807
|
if (e === "row") {
|
|
800
808
|
if (this.explicitSelection) {
|
|
@@ -809,8 +817,8 @@ class L extends k {
|
|
|
809
817
|
return;
|
|
810
818
|
}
|
|
811
819
|
if ((t !== this.lastSyncedFocusRow || s !== this.lastSyncedFocusCol) && (this.lastSyncedFocusRow = t, this.lastSyncedFocusCol = s, this.isCellSelectable(t, s))) {
|
|
812
|
-
const
|
|
813
|
-
(!
|
|
820
|
+
const r = this.selectedCell;
|
|
821
|
+
(!r || r.row !== t || r.col !== s) && (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()));
|
|
814
822
|
}
|
|
815
823
|
}
|
|
816
824
|
}
|
|
@@ -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((i) => {
|
|
834
|
+
i.classList.remove("selected", "top", "bottom", "first", "last"), s && i.removeAttribute("data-selectable");
|
|
827
835
|
});
|
|
828
|
-
const
|
|
829
|
-
if (
|
|
830
|
-
|
|
831
|
-
}), t === "row" && (C(e),
|
|
832
|
-
const
|
|
833
|
-
|
|
834
|
-
}), this.config.checkbox && this.#
|
|
835
|
-
const
|
|
836
|
-
|
|
836
|
+
const n = e.querySelectorAll(".data-grid-row");
|
|
837
|
+
if (n.forEach((i) => {
|
|
838
|
+
i.classList.remove("selected", "row-focus"), s && i.removeAttribute("data-selectable");
|
|
839
|
+
}), t === "row" && (C(e), n.forEach((i) => {
|
|
840
|
+
const l = i.querySelector(".cell[data-row]"), d = R(l);
|
|
841
|
+
d >= 0 && (s && !this.isRowSelectable(d) && i.setAttribute("data-selectable", "false"), this.selected.has(d) && i.classList.add("selected", "row-focus"));
|
|
842
|
+
}), this.config.checkbox && this.#r(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 i = this.ranges.map(g), l = (a, h) => {
|
|
848
|
+
for (const c of i)
|
|
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
|
}
|
|
@@ -860,16 +868,16 @@ class L extends k {
|
|
|
860
868
|
if (!e) return;
|
|
861
869
|
const t = e.children[0], { mode: s } = this.config;
|
|
862
870
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
863
|
-
const { shiftKey:
|
|
871
|
+
const { shiftKey: r } = this.pendingKeyboardUpdate;
|
|
864
872
|
this.pendingKeyboardUpdate = null;
|
|
865
|
-
const
|
|
866
|
-
if (
|
|
867
|
-
const
|
|
868
|
-
this.ranges = [
|
|
869
|
-
} else
|
|
873
|
+
const n = this.grid._focusRow, i = this.grid._focusCol;
|
|
874
|
+
if (r && this.cellAnchor) {
|
|
875
|
+
const l = m(this.cellAnchor, { row: n, col: i });
|
|
876
|
+
this.ranges = [l], this.activeRange = l;
|
|
877
|
+
} else r || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: n, col: i });
|
|
870
878
|
this.emit("selection-change", this.#e());
|
|
871
879
|
}
|
|
872
|
-
this.#
|
|
880
|
+
this.#i(s), this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#s();
|
|
873
881
|
}
|
|
874
882
|
/**
|
|
875
883
|
* Called after scroll-triggered row rendering.
|
|
@@ -938,13 +946,13 @@ class L extends k {
|
|
|
938
946
|
} else if (e === "range") {
|
|
939
947
|
const t = this.rows.length, s = this.columns.length;
|
|
940
948
|
if (t > 0 && s > 0) {
|
|
941
|
-
const
|
|
949
|
+
const r = {
|
|
942
950
|
startRow: 0,
|
|
943
951
|
startCol: 0,
|
|
944
952
|
endRow: t - 1,
|
|
945
953
|
endCol: s - 1
|
|
946
954
|
};
|
|
947
|
-
this.ranges = [
|
|
955
|
+
this.ranges = [r], this.activeRange = r, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
948
956
|
}
|
|
949
957
|
}
|
|
950
958
|
}
|