@toolbox-web/grid 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -22
- package/all.js +439 -416
- package/all.js.map +1 -1
- package/index.js +358 -300
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +64 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +37 -0
- package/lib/core/internal/row-animation.d.ts.map +1 -0
- package/lib/core/types.d.ts +13 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +73 -69
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/clipboard/types.d.ts +1 -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/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +69 -40
- 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/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/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 +13 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.d.ts +1 -1
- package/lib/plugins/selection/index.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +95 -64
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +50 -6
- package/lib/plugins/selection/types.d.ts.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 +21 -4
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +18 -18
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +9 -9
- 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/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -105,6 +105,19 @@ export declare class SelectionPlugin extends BaseGridPlugin<SelectionConfig> {
|
|
|
105
105
|
private pendingKeyboardUpdate;
|
|
106
106
|
/** Cell selection state (cell mode) */
|
|
107
107
|
private selectedCell;
|
|
108
|
+
/**
|
|
109
|
+
* Check if a row/cell is selectable.
|
|
110
|
+
* Returns true if selectable, false if not.
|
|
111
|
+
*/
|
|
112
|
+
private checkSelectable;
|
|
113
|
+
/**
|
|
114
|
+
* Check if an entire row is selectable (for row mode).
|
|
115
|
+
*/
|
|
116
|
+
private isRowSelectable;
|
|
117
|
+
/**
|
|
118
|
+
* Check if a cell is selectable (for cell/range modes).
|
|
119
|
+
*/
|
|
120
|
+
private isCellSelectable;
|
|
108
121
|
/** @internal */
|
|
109
122
|
detach(): void;
|
|
110
123
|
/** @internal */
|
|
@@ -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,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAU/F,OAAO,KAAK,EACV,SAAS,
|
|
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,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAU/F,OAAO,KAAK,EACV,SAAS,EAIT,eAAe,EAEf,eAAe,EAChB,MAAM,SAAS,CAAC;AAyCjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,qBAAa,eAAgB,SAAQ,cAAc,CAAC,eAAe,CAAC;;IAClE;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAAC,eAAe,CAAC,CAYhE;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,eAAe;IAC5B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,eAAe,CAAC,CAK/D;IAGD,qCAAqC;IACrC,OAAO,CAAC,QAAQ,CAAqB;IACrC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,MAAM,CAAuB;IAErC,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAA2B;IACzC,OAAO,CAAC,WAAW,CAAkC;IACrD,OAAO,CAAC,UAAU,CAA6C;IAC/D,OAAO,CAAC,UAAU,CAAS;IAE3B,oEAAoE;IACpE,OAAO,CAAC,qBAAqB,CAAsC;IAEnE,uCAAuC;IACvC,OAAO,CAAC,YAAY,CAA6C;IAMjE;;;OAGG;IACH,OAAO,CAAC,eAAe;IAWvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB,gBAAgB;IACP,MAAM,IAAI,IAAI;IAcvB,gBAAgB;IACP,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO;IAsGpD,gBAAgB;IACP,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IA2GjD,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IA8C/D,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IA+B/D,gBAAgB;IACP,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAoH9D,gBAAgB;IACP,WAAW,IAAI,IAAI;IA0C5B;;;;OAIG;IACM,cAAc,IAAI,IAAI;IAQ/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;;OAEG;IACH,cAAc,IAAI,IAAI;IAWtB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;CAgCrC"}
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @module Plugins/Selection
|
|
6
6
|
*/
|
|
7
7
|
export { SelectionPlugin } from './SelectionPlugin';
|
|
8
|
-
export type { CellRange, SelectionChangeDetail, SelectionConfig, SelectionMode, SelectionResult, SelectionTrigger, } from './types';
|
|
8
|
+
export type { CellRange, SelectableCallback, SelectionChangeDetail, SelectionConfig, SelectionMode, SelectionResult, SelectionTrigger, } from './types';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,SAAS,EACT,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/selection/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,aAAa,EACb,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function p(r) {
|
|
2
2
|
if (!r) return -1;
|
|
3
3
|
const e = r.getAttribute("data-row");
|
|
4
4
|
if (e) return parseInt(e, 10);
|
|
@@ -7,14 +7,14 @@ function b(r) {
|
|
|
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 l = 0; l < i.length; l++)
|
|
11
|
+
if (i[l] === t) return l;
|
|
12
12
|
return -1;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function b(r) {
|
|
15
15
|
r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
|
|
16
16
|
}
|
|
17
|
-
const
|
|
17
|
+
const A = {
|
|
18
18
|
expand: "▶",
|
|
19
19
|
collapse: "▼",
|
|
20
20
|
sortAsc: "▲",
|
|
@@ -248,7 +248,7 @@ class y {
|
|
|
248
248
|
*/
|
|
249
249
|
get gridIcons() {
|
|
250
250
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
251
|
-
return { ...
|
|
251
|
+
return { ...A, ...e };
|
|
252
252
|
}
|
|
253
253
|
// #region Animation Helpers
|
|
254
254
|
/**
|
|
@@ -335,7 +335,7 @@ function u(r) {
|
|
|
335
335
|
endCol: Math.max(r.startCol, r.endCol)
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function v(r) {
|
|
339
339
|
const e = u(r);
|
|
340
340
|
return {
|
|
341
341
|
from: { row: e.startRow, col: e.startCol },
|
|
@@ -343,14 +343,14 @@ function A(r) {
|
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
function R(r) {
|
|
346
|
-
return r.map(
|
|
346
|
+
return r.map(v);
|
|
347
347
|
}
|
|
348
|
-
function
|
|
348
|
+
function S(r, e, t) {
|
|
349
349
|
const s = u(t);
|
|
350
350
|
return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
|
|
351
351
|
}
|
|
352
352
|
function m(r, e, t) {
|
|
353
|
-
return t.some((s) =>
|
|
353
|
+
return t.some((s) => S(r, e, s));
|
|
354
354
|
}
|
|
355
355
|
function I(r) {
|
|
356
356
|
const e = [], t = u(r);
|
|
@@ -374,7 +374,7 @@ function f(r, e) {
|
|
|
374
374
|
endCol: e.col
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
const x = "@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}tbw-grid[data-selection-mode=row] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}tbw-grid .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}";
|
|
377
|
+
const x = "@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}tbw-grid[data-selection-mode=row] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}tbw-grid .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}tbw-grid .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}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-color-warning-bg, rgba(255, 243, 205, .5))}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}";
|
|
378
378
|
function q(r, e, t) {
|
|
379
379
|
if (r === "cell" && e.selectedCell)
|
|
380
380
|
return {
|
|
@@ -438,6 +438,32 @@ class K extends y {
|
|
|
438
438
|
/** Cell selection state (cell mode) */
|
|
439
439
|
selectedCell = null;
|
|
440
440
|
// #endregion
|
|
441
|
+
// #region Private Helpers - Selectability
|
|
442
|
+
/**
|
|
443
|
+
* Check if a row/cell is selectable.
|
|
444
|
+
* Returns true if selectable, false if not.
|
|
445
|
+
*/
|
|
446
|
+
checkSelectable(e, t) {
|
|
447
|
+
const { isSelectable: s } = this.config;
|
|
448
|
+
if (!s) return !0;
|
|
449
|
+
const i = this.rows[e];
|
|
450
|
+
if (!i) return !1;
|
|
451
|
+
const l = t !== void 0 ? this.columns[t] : void 0;
|
|
452
|
+
return s(i, e, l, t);
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Check if an entire row is selectable (for row mode).
|
|
456
|
+
*/
|
|
457
|
+
isRowSelectable(e) {
|
|
458
|
+
return this.checkSelectable(e);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Check if a cell is selectable (for cell/range modes).
|
|
462
|
+
*/
|
|
463
|
+
isCellSelectable(e, t) {
|
|
464
|
+
return this.checkSelectable(e, t);
|
|
465
|
+
}
|
|
466
|
+
// #endregion
|
|
441
467
|
// #region Lifecycle
|
|
442
468
|
/** @internal */
|
|
443
469
|
detach() {
|
|
@@ -447,37 +473,37 @@ class K extends y {
|
|
|
447
473
|
// #region Event Handlers
|
|
448
474
|
/** @internal */
|
|
449
475
|
onCellClick(e) {
|
|
450
|
-
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode:
|
|
451
|
-
if (i.type !==
|
|
476
|
+
const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: l, triggerOn: n = "click" } = this.config;
|
|
477
|
+
if (i.type !== n)
|
|
452
478
|
return !1;
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
return
|
|
456
|
-
if (
|
|
457
|
-
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
458
|
-
if (
|
|
459
|
-
if (
|
|
479
|
+
const o = this.columns[s], d = o && h(o);
|
|
480
|
+
if (l === "cell")
|
|
481
|
+
return d || !this.isCellSelectable(t, s) || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
482
|
+
if (l === "row")
|
|
483
|
+
return this.isRowSelectable(t) && (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
|
|
484
|
+
if (l === "range") {
|
|
485
|
+
if (d || !this.isCellSelectable(t, s))
|
|
460
486
|
return !1;
|
|
461
|
-
const
|
|
462
|
-
if (
|
|
463
|
-
const
|
|
464
|
-
|
|
465
|
-
} else if (
|
|
466
|
-
const
|
|
487
|
+
const a = i.shiftKey, g = i.ctrlKey || i.metaKey;
|
|
488
|
+
if (a && this.cellAnchor) {
|
|
489
|
+
const c = f(this.cellAnchor, { row: t, col: s });
|
|
490
|
+
g ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = c : this.ranges.push(c) : this.ranges = [c], this.activeRange = c;
|
|
491
|
+
} else if (g) {
|
|
492
|
+
const c = {
|
|
467
493
|
startRow: t,
|
|
468
494
|
startCol: s,
|
|
469
495
|
endRow: t,
|
|
470
496
|
endCol: s
|
|
471
497
|
};
|
|
472
|
-
this.ranges.push(
|
|
498
|
+
this.ranges.push(c), this.activeRange = c, this.cellAnchor = { row: t, col: s };
|
|
473
499
|
} else {
|
|
474
|
-
const
|
|
500
|
+
const c = {
|
|
475
501
|
startRow: t,
|
|
476
502
|
startCol: s,
|
|
477
503
|
endRow: t,
|
|
478
504
|
endCol: s
|
|
479
505
|
};
|
|
480
|
-
this.ranges = [
|
|
506
|
+
this.ranges = [c], this.activeRange = c, this.cellAnchor = { row: t, col: s };
|
|
481
507
|
}
|
|
482
508
|
return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
483
509
|
}
|
|
@@ -490,26 +516,28 @@ class K extends y {
|
|
|
490
516
|
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;
|
|
491
517
|
if (t === "cell" && i)
|
|
492
518
|
return queueMicrotask(() => {
|
|
493
|
-
|
|
519
|
+
const l = this.grid._focusRow, n = this.grid._focusCol;
|
|
520
|
+
this.isCellSelectable(l, n) ? this.selectedCell = { row: l, col: n } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
494
521
|
}), !1;
|
|
495
522
|
if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
|
|
496
523
|
return queueMicrotask(() => {
|
|
497
|
-
|
|
524
|
+
const l = this.grid._focusRow;
|
|
525
|
+
this.isRowSelectable(l) ? (this.selected.clear(), this.selected.add(l), this.lastSelected = l) : this.selected.clear(), this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
498
526
|
}), !1;
|
|
499
527
|
if (t === "range" && i) {
|
|
500
|
-
const
|
|
501
|
-
return
|
|
528
|
+
const l = e.key === "Tab", n = e.shiftKey && !l;
|
|
529
|
+
return n && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: n }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
502
530
|
}
|
|
503
531
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
504
|
-
const
|
|
505
|
-
if (
|
|
506
|
-
const
|
|
532
|
+
const l = this.rows.length, n = this.columns.length;
|
|
533
|
+
if (l > 0 && n > 0) {
|
|
534
|
+
const o = {
|
|
507
535
|
startRow: 0,
|
|
508
536
|
startCol: 0,
|
|
509
|
-
endRow:
|
|
510
|
-
endCol:
|
|
537
|
+
endRow: l - 1,
|
|
538
|
+
endCol: n - 1
|
|
511
539
|
};
|
|
512
|
-
return this.ranges = [
|
|
540
|
+
return this.ranges = [o], this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
513
541
|
}
|
|
514
542
|
}
|
|
515
543
|
return !1;
|
|
@@ -518,18 +546,18 @@ class K extends y {
|
|
|
518
546
|
onCellMouseDown(e) {
|
|
519
547
|
if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
520
548
|
const t = this.columns[e.colIndex];
|
|
521
|
-
if (t && h(t) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
549
|
+
if (t && h(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
522
550
|
return;
|
|
523
551
|
this.isDragging = !0;
|
|
524
552
|
const s = e.rowIndex, i = e.colIndex;
|
|
525
553
|
this.cellAnchor = { row: s, col: i }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
526
|
-
const
|
|
554
|
+
const n = {
|
|
527
555
|
startRow: s,
|
|
528
556
|
startCol: i,
|
|
529
557
|
endRow: s,
|
|
530
558
|
endCol: i
|
|
531
559
|
};
|
|
532
|
-
return this.ranges.push(
|
|
560
|
+
return this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
533
561
|
}
|
|
534
562
|
/** @internal */
|
|
535
563
|
onCellMouseMove(e) {
|
|
@@ -537,8 +565,8 @@ class K extends y {
|
|
|
537
565
|
let t = e.colIndex;
|
|
538
566
|
const s = this.columns[t];
|
|
539
567
|
if (s && h(s)) {
|
|
540
|
-
const
|
|
541
|
-
|
|
568
|
+
const l = this.columns.findIndex((n) => !h(n));
|
|
569
|
+
l >= 0 && (t = l);
|
|
542
570
|
}
|
|
543
571
|
const i = f(this.cellAnchor, { row: e.rowIndex, col: t });
|
|
544
572
|
return 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;
|
|
@@ -555,29 +583,32 @@ class K extends y {
|
|
|
555
583
|
#t() {
|
|
556
584
|
const e = this.gridElement;
|
|
557
585
|
if (!e) return;
|
|
558
|
-
const { mode: t } = this.config;
|
|
586
|
+
const { mode: t } = this.config, s = !!this.config.isSelectable;
|
|
559
587
|
e.querySelectorAll(".cell").forEach((n) => {
|
|
560
|
-
n.classList.remove("selected", "top", "bottom", "first", "last");
|
|
588
|
+
n.classList.remove("selected", "top", "bottom", "first", "last"), s && n.removeAttribute("data-selectable");
|
|
561
589
|
});
|
|
562
|
-
const
|
|
563
|
-
if (
|
|
564
|
-
n.classList.remove("selected", "row-focus");
|
|
565
|
-
}), t === "row" && (
|
|
566
|
-
const o = n.querySelector(".cell[data-row]"),
|
|
567
|
-
|
|
568
|
-
})), t === "range" &&
|
|
569
|
-
|
|
590
|
+
const l = e.querySelectorAll(".data-grid-row");
|
|
591
|
+
if (l.forEach((n) => {
|
|
592
|
+
n.classList.remove("selected", "row-focus"), s && n.removeAttribute("data-selectable");
|
|
593
|
+
}), t === "row" && (b(e), l.forEach((n) => {
|
|
594
|
+
const o = n.querySelector(".cell[data-row]"), d = p(o);
|
|
595
|
+
d >= 0 && (s && !this.isRowSelectable(d) && n.setAttribute("data-selectable", "false"), this.selected.has(d) && n.classList.add("selected", "row-focus"));
|
|
596
|
+
})), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((o) => {
|
|
597
|
+
const d = parseInt(o.getAttribute("data-row") ?? "-1", 10), a = parseInt(o.getAttribute("data-col") ?? "-1", 10);
|
|
598
|
+
d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || o.setAttribute("data-selectable", "false"));
|
|
599
|
+
}), t === "range" && this.ranges.length > 0) {
|
|
600
|
+
b(e);
|
|
570
601
|
const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !h(a));
|
|
571
602
|
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
572
|
-
const g = parseInt(a.getAttribute("data-row") ?? "-1", 10),
|
|
573
|
-
if (g >= 0 &&
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
603
|
+
const g = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
604
|
+
if (g >= 0 && c >= 0) {
|
|
605
|
+
const w = this.columns[c];
|
|
606
|
+
if (w && h(w))
|
|
576
607
|
return;
|
|
577
|
-
if (m(g,
|
|
608
|
+
if (m(g, c, this.ranges) && (a.classList.add("selected"), n)) {
|
|
578
609
|
g === n.startRow && a.classList.add("top"), g === n.endRow && a.classList.add("bottom");
|
|
579
610
|
const C = Math.max(n.startCol, o);
|
|
580
|
-
|
|
611
|
+
c === C && a.classList.add("first"), c === n.endCol && a.classList.add("last");
|
|
581
612
|
}
|
|
582
613
|
}
|
|
583
614
|
});
|
|
@@ -591,11 +622,11 @@ class K extends y {
|
|
|
591
622
|
if (this.pendingKeyboardUpdate && s === "range") {
|
|
592
623
|
const { shiftKey: i } = this.pendingKeyboardUpdate;
|
|
593
624
|
this.pendingKeyboardUpdate = null;
|
|
594
|
-
const
|
|
625
|
+
const l = this.grid._focusRow, n = this.grid._focusCol;
|
|
595
626
|
if (i && this.cellAnchor) {
|
|
596
|
-
const
|
|
597
|
-
this.ranges = [
|
|
598
|
-
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row:
|
|
627
|
+
const o = f(this.cellAnchor, { row: l, col: n });
|
|
628
|
+
this.ranges = [o], this.activeRange = o;
|
|
629
|
+
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: l, col: n });
|
|
599
630
|
this.emit("selection-change", this.#e());
|
|
600
631
|
}
|
|
601
632
|
this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#t();
|