@toolbox-web/grid 1.4.0 → 1.6.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.
Files changed (76) hide show
  1. package/all.js +859 -671
  2. package/all.js.map +1 -1
  3. package/index.js +513 -495
  4. package/index.js.map +1 -1
  5. package/lib/core/internal/header.d.ts.map +1 -1
  6. package/lib/core/internal/rows.d.ts +8 -0
  7. package/lib/core/internal/rows.d.ts.map +1 -1
  8. package/lib/core/types.d.ts +82 -17
  9. package/lib/core/types.d.ts.map +1 -1
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/index.js.map +1 -1
  12. package/lib/plugins/context-menu/index.js.map +1 -1
  13. package/lib/plugins/editing/index.js.map +1 -1
  14. package/lib/plugins/editing/types.d.ts +68 -0
  15. package/lib/plugins/editing/types.d.ts.map +1 -1
  16. package/lib/plugins/export/index.d.ts +1 -1
  17. package/lib/plugins/export/index.d.ts.map +1 -1
  18. package/lib/plugins/export/index.js.map +1 -1
  19. package/lib/plugins/filtering/FilteringPlugin.d.ts +18 -1
  20. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  21. package/lib/plugins/filtering/index.d.ts +1 -1
  22. package/lib/plugins/filtering/index.d.ts.map +1 -1
  23. package/lib/plugins/filtering/index.js +313 -183
  24. package/lib/plugins/filtering/index.js.map +1 -1
  25. package/lib/plugins/filtering/types.d.ts +81 -2
  26. package/lib/plugins/filtering/types.d.ts.map +1 -1
  27. package/lib/plugins/grouping-columns/index.js.map +1 -1
  28. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +12 -3
  29. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  30. package/lib/plugins/grouping-rows/grouping-rows.d.ts +13 -2
  31. package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
  32. package/lib/plugins/grouping-rows/index.d.ts +1 -1
  33. package/lib/plugins/grouping-rows/index.d.ts.map +1 -1
  34. package/lib/plugins/grouping-rows/index.js +199 -125
  35. package/lib/plugins/grouping-rows/index.js.map +1 -1
  36. package/lib/plugins/grouping-rows/types.d.ts +24 -2
  37. package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
  38. package/lib/plugins/master-detail/index.d.ts +1 -1
  39. package/lib/plugins/master-detail/index.d.ts.map +1 -1
  40. package/lib/plugins/master-detail/index.js.map +1 -1
  41. package/lib/plugins/multi-sort/index.js.map +1 -1
  42. package/lib/plugins/pinned-columns/index.js.map +1 -1
  43. package/lib/plugins/pinned-rows/index.js +1 -1
  44. package/lib/plugins/pinned-rows/index.js.map +1 -1
  45. package/lib/plugins/pivot/index.js.map +1 -1
  46. package/lib/plugins/print/index.js.map +1 -1
  47. package/lib/plugins/reorder/index.js.map +1 -1
  48. package/lib/plugins/responsive/index.js.map +1 -1
  49. package/lib/plugins/row-reorder/index.js.map +1 -1
  50. package/lib/plugins/selection/SelectionPlugin.d.ts +5 -0
  51. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  52. package/lib/plugins/selection/index.js +90 -77
  53. package/lib/plugins/selection/index.js.map +1 -1
  54. package/lib/plugins/selection/types.d.ts +45 -0
  55. package/lib/plugins/selection/types.d.ts.map +1 -1
  56. package/lib/plugins/server-side/index.js.map +1 -1
  57. package/lib/plugins/tree/index.js.map +1 -1
  58. package/lib/plugins/undo-redo/index.d.ts +1 -1
  59. package/lib/plugins/undo-redo/index.d.ts.map +1 -1
  60. package/lib/plugins/undo-redo/index.js.map +1 -1
  61. package/lib/plugins/visibility/index.d.ts +1 -1
  62. package/lib/plugins/visibility/index.d.ts.map +1 -1
  63. package/lib/plugins/visibility/index.js.map +1 -1
  64. package/package.json +1 -1
  65. package/umd/grid.all.umd.js +27 -24
  66. package/umd/grid.all.umd.js.map +1 -1
  67. package/umd/grid.umd.js +10 -10
  68. package/umd/grid.umd.js.map +1 -1
  69. package/umd/plugins/filtering.umd.js +1 -1
  70. package/umd/plugins/filtering.umd.js.map +1 -1
  71. package/umd/plugins/grouping-rows.umd.js +4 -1
  72. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  73. package/umd/plugins/pinned-rows.umd.js +1 -1
  74. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  75. package/umd/plugins/selection.umd.js +2 -2
  76. package/umd/plugins/selection.umd.js.map +1 -1
@@ -105,6 +105,11 @@ 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 selection is enabled at the grid level.
110
+ * Grid-wide `selectable: false` or plugin's `enabled: false` disables all selection.
111
+ */
112
+ private isSelectionEnabled;
108
113
  /**
109
114
  * Check if a row/cell is selectable.
110
115
  * Returns true if selectable, false if not.
@@ -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;AAW/F,OAAO,KAAK,EACV,SAAS,EAGT,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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AAC,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;IA+HpD,gBAAgB;IACP,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAkHjD,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IA2D/D,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAwC/D,gBAAgB;IACP,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAuH9D,gBAAgB;IACP,WAAW,IAAI,IAAI;IA6C5B;;;;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;;OAEG;IACH,cAAc,IAAI,IAAI;IAWtB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;CAgCrC"}
@@ -6,15 +6,15 @@ function y(r) {
6
6
  if (!t) return -1;
7
7
  const s = t.parentElement;
8
8
  if (!s) return -1;
9
- const l = s.querySelectorAll(":scope > .data-grid-row");
10
- for (let i = 0; i < l.length; i++)
11
- if (l[i] === t) return i;
9
+ const i = s.querySelectorAll(":scope > .data-grid-row");
10
+ for (let l = 0; l < i.length; l++)
11
+ if (i[l] === t) return l;
12
12
  return -1;
13
13
  }
14
14
  function m(r) {
15
15
  r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
16
16
  }
17
- const R = '<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 = {
17
+ const R = '<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>', S = {
18
18
  expand: "▶",
19
19
  collapse: "▼",
20
20
  sortAsc: "▲",
@@ -27,7 +27,7 @@ const R = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
27
27
  filterActive: R,
28
28
  print: "🖨️"
29
29
  };
30
- class I {
30
+ class v {
31
31
  /**
32
32
  * Plugin dependencies - declare other plugins this one requires.
33
33
  *
@@ -251,7 +251,7 @@ class I {
251
251
  */
252
252
  get gridIcons() {
253
253
  const e = this.grid?.gridConfig?.icons ?? {};
254
- return { ...v, ...e };
254
+ return { ...S, ...e };
255
255
  }
256
256
  // #region Animation Helpers
257
257
  /**
@@ -338,7 +338,7 @@ function u(r) {
338
338
  endCol: Math.max(r.startCol, r.endCol)
339
339
  };
340
340
  }
341
- function S(r) {
341
+ function E(r) {
342
342
  const e = u(r);
343
343
  return {
344
344
  from: { row: e.startRow, col: e.startCol },
@@ -346,20 +346,20 @@ function S(r) {
346
346
  };
347
347
  }
348
348
  function p(r) {
349
- return r.map(S);
349
+ return r.map(E);
350
350
  }
351
- function E(r, e, t) {
351
+ function I(r, e, t) {
352
352
  const s = u(t);
353
353
  return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
354
354
  }
355
355
  function C(r, e, t) {
356
- return t.some((s) => E(r, e, s));
356
+ return t.some((s) => I(r, e, s));
357
357
  }
358
358
  function x(r) {
359
359
  const e = [], t = u(r);
360
360
  for (let s = t.startRow; s <= t.endRow; s++)
361
- for (let l = t.startCol; l <= t.endCol; l++)
362
- e.push({ row: s, col: l });
361
+ for (let i = t.startCol; i <= t.endCol; i++)
362
+ e.push({ row: s, col: i });
363
363
  return e;
364
364
  }
365
365
  function q(r) {
@@ -394,15 +394,15 @@ function K(r, e, t) {
394
394
  ]
395
395
  };
396
396
  if (r === "row" && e.selected.size > 0) {
397
- const s = [...e.selected].map((l) => ({
398
- from: { row: l, col: 0 },
399
- to: { row: l, col: t - 1 }
397
+ const s = [...e.selected].map((i) => ({
398
+ from: { row: i, col: 0 },
399
+ to: { row: i, col: t - 1 }
400
400
  }));
401
401
  return { mode: r, ranges: s };
402
402
  }
403
403
  return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: p(e.ranges) } : { mode: r, ranges: [] };
404
404
  }
405
- class D extends I {
405
+ class D extends v {
406
406
  /**
407
407
  * Plugin manifest - declares configuration validation rules.
408
408
  * @internal
@@ -427,7 +427,8 @@ class D extends I {
427
427
  get defaultConfig() {
428
428
  return {
429
429
  mode: "cell",
430
- triggerOn: "click"
430
+ triggerOn: "click",
431
+ enabled: !0
431
432
  };
432
433
  }
433
434
  // #region Internal State
@@ -445,6 +446,15 @@ class D extends I {
445
446
  /** Cell selection state (cell mode) */
446
447
  selectedCell = null;
447
448
  // #endregion
449
+ // #region Private Helpers - Selection Enabled Check
450
+ /**
451
+ * Check if selection is enabled at the grid level.
452
+ * Grid-wide `selectable: false` or plugin's `enabled: false` disables all selection.
453
+ */
454
+ isSelectionEnabled() {
455
+ return this.config.enabled === !1 ? !1 : this.grid.effectiveConfig?.selectable !== !1;
456
+ }
457
+ // #endregion
448
458
  // #region Private Helpers - Selectability
449
459
  /**
450
460
  * Check if a row/cell is selectable.
@@ -453,10 +463,10 @@ class D extends I {
453
463
  checkSelectable(e, t) {
454
464
  const { isSelectable: s } = this.config;
455
465
  if (!s) return !0;
456
- const l = this.rows[e];
457
- if (!l) return !1;
458
- const i = t !== void 0 ? this.columns[t] : void 0;
459
- return s(l, e, i, t);
466
+ const i = this.rows[e];
467
+ if (!i) return !1;
468
+ const l = t !== void 0 ? this.columns[t] : void 0;
469
+ return s(i, e, l, t);
460
470
  }
461
471
  /**
462
472
  * Check if an entire row is selectable (for row mode).
@@ -480,45 +490,46 @@ class D extends I {
480
490
  // #region Event Handlers
481
491
  /** @internal */
482
492
  onCellClick(e) {
483
- const { rowIndex: t, colIndex: s, originalEvent: l } = e, { mode: i, triggerOn: n = "click" } = this.config;
484
- if (l.type !== n)
493
+ if (!this.isSelectionEnabled()) return !1;
494
+ const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: l, triggerOn: n = "click" } = this.config;
495
+ if (i.type !== n)
485
496
  return !1;
486
497
  const o = this.columns[s], d = o && g(o);
487
- if (i === "cell") {
498
+ if (l === "cell") {
488
499
  if (d || !this.isCellSelectable(t, s))
489
500
  return !1;
490
- const c = this.selectedCell;
491
- return c && c.row === t && c.col === s || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
501
+ const a = this.selectedCell;
502
+ return a && a.row === t && a.col === s || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
492
503
  }
493
- if (i === "row")
504
+ if (l === "row")
494
505
  return !this.isRowSelectable(t) || this.selected.size === 1 && this.selected.has(t) || (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
495
- if (i === "range") {
506
+ if (l === "range") {
496
507
  if (d || !this.isCellSelectable(t, s))
497
508
  return !1;
498
- const c = l.shiftKey, h = l.ctrlKey || l.metaKey;
499
- if (c && this.cellAnchor) {
500
- const a = b(this.cellAnchor, { row: t, col: s }), f = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
501
- if (f && w(f, a))
509
+ const a = i.shiftKey, h = i.ctrlKey || i.metaKey;
510
+ if (a && this.cellAnchor) {
511
+ const c = b(this.cellAnchor, { row: t, col: s }), f = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
512
+ if (f && w(f, c))
502
513
  return !1;
503
- h ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
514
+ h ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = c : this.ranges.push(c) : this.ranges = [c], this.activeRange = c;
504
515
  } else if (h) {
505
- const a = {
516
+ const c = {
506
517
  startRow: t,
507
518
  startCol: s,
508
519
  endRow: t,
509
520
  endCol: s
510
521
  };
511
- this.ranges.push(a), this.activeRange = a, this.cellAnchor = { row: t, col: s };
522
+ this.ranges.push(c), this.activeRange = c, this.cellAnchor = { row: t, col: s };
512
523
  } else {
513
- const a = {
524
+ const c = {
514
525
  startRow: t,
515
526
  startCol: s,
516
527
  endRow: t,
517
528
  endCol: s
518
529
  };
519
- if (this.ranges.length === 1 && w(this.ranges[0], a))
530
+ if (this.ranges.length === 1 && w(this.ranges[0], c))
520
531
  return !1;
521
- this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: t, col: s };
532
+ this.ranges = [c], this.activeRange = c, this.cellAnchor = { row: t, col: s };
522
533
  }
523
534
  return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
524
535
  }
@@ -526,31 +537,32 @@ class D extends I {
526
537
  }
527
538
  /** @internal */
528
539
  onKeyDown(e) {
529
- const { mode: t } = this.config, l = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
540
+ if (!this.isSelectionEnabled()) return !1;
541
+ const { mode: t } = this.config, i = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
530
542
  if (e.key === "Escape")
531
543
  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;
532
- if (t === "cell" && l)
544
+ if (t === "cell" && i)
533
545
  return queueMicrotask(() => {
534
- const i = this.grid._focusRow, n = this.grid._focusCol;
535
- this.isCellSelectable(i, n) ? this.selectedCell = { row: i, col: n } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
546
+ const l = this.grid._focusRow, n = this.grid._focusCol;
547
+ this.isCellSelectable(l, n) ? this.selectedCell = { row: l, col: n } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
536
548
  }), !1;
537
549
  if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
538
550
  return queueMicrotask(() => {
539
- const i = this.grid._focusRow;
540
- this.isRowSelectable(i) ? (this.selected.clear(), this.selected.add(i), this.lastSelected = i) : this.selected.clear(), this.emit("selection-change", this.#e()), this.requestAfterRender();
551
+ const l = this.grid._focusRow;
552
+ this.isRowSelectable(l) ? (this.selected.clear(), this.selected.add(l), this.lastSelected = l) : this.selected.clear(), this.emit("selection-change", this.#e()), this.requestAfterRender();
541
553
  }), !1;
542
- if (t === "range" && l) {
543
- const i = e.key === "Tab", n = e.shiftKey && !i;
554
+ if (t === "range" && i) {
555
+ const l = e.key === "Tab", n = e.shiftKey && !l;
544
556
  return n && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: n }, queueMicrotask(() => this.requestAfterRender()), !1;
545
557
  }
546
558
  if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
547
- const i = this.rows.length, n = this.columns.length;
548
- if (i > 0 && n > 0) {
559
+ const l = this.rows.length, n = this.columns.length;
560
+ if (l > 0 && n > 0) {
549
561
  e.preventDefault(), e.stopPropagation();
550
562
  const o = {
551
563
  startRow: 0,
552
564
  startCol: 0,
553
- endRow: i - 1,
565
+ endRow: l - 1,
554
566
  endCol: n - 1
555
567
  };
556
568
  return this.ranges = [o], this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
@@ -560,34 +572,34 @@ class D extends I {
560
572
  }
561
573
  /** @internal */
562
574
  onCellMouseDown(e) {
563
- if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
575
+ if (!this.isSelectionEnabled() || this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
564
576
  const t = this.columns[e.colIndex];
565
577
  if (t && g(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
566
578
  return;
567
579
  this.isDragging = !0;
568
- const s = e.rowIndex, l = e.colIndex, i = e.originalEvent.ctrlKey || e.originalEvent.metaKey, n = {
580
+ const s = e.rowIndex, i = e.colIndex, l = e.originalEvent.ctrlKey || e.originalEvent.metaKey, n = {
569
581
  startRow: s,
570
- startCol: l,
582
+ startCol: i,
571
583
  endRow: s,
572
- endCol: l
584
+ endCol: i
573
585
  };
574
- return !i && this.ranges.length === 1 && w(this.ranges[0], n) ? (this.cellAnchor = { row: s, col: l }, !0) : (this.cellAnchor = { row: s, col: l }, i || (this.ranges = []), this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
586
+ return !l && this.ranges.length === 1 && w(this.ranges[0], n) ? (this.cellAnchor = { row: s, col: i }, !0) : (this.cellAnchor = { row: s, col: i }, l || (this.ranges = []), this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
575
587
  }
576
588
  /** @internal */
577
589
  onCellMouseMove(e) {
578
- if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
590
+ if (!this.isSelectionEnabled() || this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
579
591
  let t = e.colIndex;
580
592
  const s = this.columns[t];
581
593
  if (s && g(s)) {
582
594
  const n = this.columns.findIndex((o) => !g(o));
583
595
  n >= 0 && (t = n);
584
596
  }
585
- const l = b(this.cellAnchor, { row: e.rowIndex, col: t }), i = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
586
- return i && w(i, l) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l), this.activeRange = l, this.emit("selection-change", this.#e()), this.requestAfterRender()), !0;
597
+ const i = b(this.cellAnchor, { row: e.rowIndex, col: t }), l = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
598
+ return l && w(l, 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;
587
599
  }
588
600
  /** @internal */
589
601
  onCellMouseUp(e) {
590
- if (this.config.mode === "range" && this.isDragging)
602
+ if (this.isSelectionEnabled() && this.config.mode === "range" && this.isDragging)
591
603
  return this.isDragging = !1, !0;
592
604
  }
593
605
  /**
@@ -601,28 +613,28 @@ class D extends I {
601
613
  e.querySelectorAll(".cell").forEach((n) => {
602
614
  n.classList.remove("selected", "top", "bottom", "first", "last"), s && n.removeAttribute("data-selectable");
603
615
  });
604
- const i = e.querySelectorAll(".data-grid-row");
605
- if (i.forEach((n) => {
616
+ const l = e.querySelectorAll(".data-grid-row");
617
+ if (l.forEach((n) => {
606
618
  n.classList.remove("selected", "row-focus"), s && n.removeAttribute("data-selectable");
607
- }), t === "row" && (m(e), i.forEach((n) => {
619
+ }), t === "row" && (m(e), l.forEach((n) => {
608
620
  const o = n.querySelector(".cell[data-row]"), d = y(o);
609
621
  d >= 0 && (s && !this.isRowSelectable(d) && n.setAttribute("data-selectable", "false"), this.selected.has(d) && n.classList.add("selected", "row-focus"));
610
622
  })), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((o) => {
611
- const d = parseInt(o.getAttribute("data-row") ?? "-1", 10), c = parseInt(o.getAttribute("data-col") ?? "-1", 10);
612
- d >= 0 && c >= 0 && (this.isCellSelectable(d, c) || o.setAttribute("data-selectable", "false"));
623
+ const d = parseInt(o.getAttribute("data-row") ?? "-1", 10), a = parseInt(o.getAttribute("data-col") ?? "-1", 10);
624
+ d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || o.setAttribute("data-selectable", "false"));
613
625
  }), t === "range" && this.ranges.length > 0) {
614
626
  m(e);
615
- const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((c) => !g(c));
616
- this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((c) => {
617
- const h = parseInt(c.getAttribute("data-row") ?? "-1", 10), a = parseInt(c.getAttribute("data-col") ?? "-1", 10);
618
- if (h >= 0 && a >= 0) {
619
- const f = this.columns[a];
627
+ const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !g(a));
628
+ this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
629
+ const h = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
630
+ if (h >= 0 && c >= 0) {
631
+ const f = this.columns[c];
620
632
  if (f && g(f))
621
633
  return;
622
- if (C(h, a, this.ranges) && (c.classList.add("selected"), n)) {
623
- h === n.startRow && c.classList.add("top"), h === n.endRow && c.classList.add("bottom");
634
+ if (C(h, c, this.ranges) && (a.classList.add("selected"), n)) {
635
+ h === n.startRow && a.classList.add("top"), h === n.endRow && a.classList.add("bottom");
624
636
  const A = Math.max(n.startCol, o);
625
- a === A && c.classList.add("first"), a === n.endCol && c.classList.add("last");
637
+ c === A && a.classList.add("first"), c === n.endCol && a.classList.add("last");
626
638
  }
627
639
  }
628
640
  });
@@ -630,17 +642,18 @@ class D extends I {
630
642
  }
631
643
  /** @internal */
632
644
  afterRender() {
645
+ if (!this.isSelectionEnabled()) return;
633
646
  const e = this.gridElement;
634
647
  if (!e) return;
635
648
  const t = e.children[0], { mode: s } = this.config;
636
649
  if (this.pendingKeyboardUpdate && s === "range") {
637
- const { shiftKey: l } = this.pendingKeyboardUpdate;
650
+ const { shiftKey: i } = this.pendingKeyboardUpdate;
638
651
  this.pendingKeyboardUpdate = null;
639
- const i = this.grid._focusRow, n = this.grid._focusCol;
640
- if (l && this.cellAnchor) {
641
- const o = b(this.cellAnchor, { row: i, col: n });
652
+ const l = this.grid._focusRow, n = this.grid._focusCol;
653
+ if (i && this.cellAnchor) {
654
+ const o = b(this.cellAnchor, { row: l, col: n });
642
655
  this.ranges = [o], this.activeRange = o;
643
- } else l || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: i, col: n });
656
+ } else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: l, col: n });
644
657
  this.emit("selection-change", this.#e());
645
658
  }
646
659
  this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#t();
@@ -651,7 +664,7 @@ class D extends I {
651
664
  * @internal
652
665
  */
653
666
  onScrollRender() {
654
- this.#t();
667
+ this.isSelectionEnabled() && this.#t();
655
668
  }
656
669
  // #endregion
657
670
  // #region Public API