@toolbox-web/grid 1.2.0 → 1.3.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.
Files changed (79) hide show
  1. package/README.md +80 -22
  2. package/all.js +619 -571
  3. package/all.js.map +1 -1
  4. package/index.js +362 -302
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +64 -1
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/row-animation.d.ts +37 -0
  9. package/lib/core/internal/row-animation.d.ts.map +1 -0
  10. package/lib/core/types.d.ts +17 -0
  11. package/lib/core/types.d.ts.map +1 -1
  12. package/lib/plugins/clipboard/index.js +82 -76
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/clipboard/types.d.ts +1 -0
  15. package/lib/plugins/clipboard/types.d.ts.map +1 -1
  16. package/lib/plugins/column-virtualization/index.js +43 -41
  17. package/lib/plugins/column-virtualization/index.js.map +1 -1
  18. package/lib/plugins/context-menu/index.js +24 -22
  19. package/lib/plugins/context-menu/index.js.map +1 -1
  20. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  21. package/lib/plugins/editing/index.js +83 -52
  22. package/lib/plugins/editing/index.js.map +1 -1
  23. package/lib/plugins/export/index.js +22 -20
  24. package/lib/plugins/export/index.js.map +1 -1
  25. package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
  26. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  27. package/lib/plugins/filtering/index.js +160 -125
  28. package/lib/plugins/filtering/index.js.map +1 -1
  29. package/lib/plugins/grouping-columns/index.js +20 -18
  30. package/lib/plugins/grouping-columns/index.js.map +1 -1
  31. package/lib/plugins/grouping-rows/index.js +66 -64
  32. package/lib/plugins/grouping-rows/index.js.map +1 -1
  33. package/lib/plugins/master-detail/index.js +51 -49
  34. package/lib/plugins/master-detail/index.js.map +1 -1
  35. package/lib/plugins/multi-sort/index.js +17 -15
  36. package/lib/plugins/multi-sort/index.js.map +1 -1
  37. package/lib/plugins/pinned-columns/index.js +24 -22
  38. package/lib/plugins/pinned-columns/index.js.map +1 -1
  39. package/lib/plugins/pinned-rows/index.js +25 -23
  40. package/lib/plugins/pinned-rows/index.js.map +1 -1
  41. package/lib/plugins/pivot/index.js +49 -47
  42. package/lib/plugins/pivot/index.js.map +1 -1
  43. package/lib/plugins/reorder/index.js +24 -22
  44. package/lib/plugins/reorder/index.js.map +1 -1
  45. package/lib/plugins/responsive/index.js +19 -17
  46. package/lib/plugins/responsive/index.js.map +1 -1
  47. package/lib/plugins/row-reorder/index.js +38 -36
  48. package/lib/plugins/row-reorder/index.js.map +1 -1
  49. package/lib/plugins/selection/SelectionPlugin.d.ts +13 -0
  50. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  51. package/lib/plugins/selection/index.d.ts +1 -1
  52. package/lib/plugins/selection/index.d.ts.map +1 -1
  53. package/lib/plugins/selection/index.js +118 -85
  54. package/lib/plugins/selection/index.js.map +1 -1
  55. package/lib/plugins/selection/types.d.ts +50 -6
  56. package/lib/plugins/selection/types.d.ts.map +1 -1
  57. package/lib/plugins/server-side/index.js +34 -32
  58. package/lib/plugins/server-side/index.js.map +1 -1
  59. package/lib/plugins/tree/index.js +25 -23
  60. package/lib/plugins/tree/index.js.map +1 -1
  61. package/lib/plugins/undo-redo/index.js +22 -20
  62. package/lib/plugins/undo-redo/index.js.map +1 -1
  63. package/lib/plugins/visibility/index.js +21 -19
  64. package/lib/plugins/visibility/index.js.map +1 -1
  65. package/package.json +21 -4
  66. package/public.d.ts +1 -1
  67. package/public.d.ts.map +1 -1
  68. package/umd/grid.all.umd.js +19 -19
  69. package/umd/grid.all.umd.js.map +1 -1
  70. package/umd/grid.umd.js +9 -9
  71. package/umd/grid.umd.js.map +1 -1
  72. package/umd/plugins/clipboard.umd.js +5 -5
  73. package/umd/plugins/clipboard.umd.js.map +1 -1
  74. package/umd/plugins/editing.umd.js +1 -1
  75. package/umd/plugins/editing.umd.js.map +1 -1
  76. package/umd/plugins/filtering.umd.js +1 -1
  77. package/umd/plugins/filtering.umd.js.map +1 -1
  78. package/umd/plugins/selection.umd.js +2 -2
  79. 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,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,e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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 b(r) {
1
+ function A(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 n = 0; n < i.length; n++)
11
- if (i[n] === t) return n;
10
+ for (let l = 0; l < i.length; l++)
11
+ if (i[l] === t) return l;
12
12
  return -1;
13
13
  }
14
- function w(r) {
14
+ function b(r) {
15
15
  r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
16
16
  }
17
- const p = {
17
+ const m = '<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>', y = {
18
18
  expand: "▶",
19
19
  collapse: "▼",
20
20
  sortAsc: "▲",
@@ -22,9 +22,11 @@ const p = {
22
22
  sortNone: "⇅",
23
23
  submenuArrow: "▶",
24
24
  dragHandle: "⋮⋮",
25
- toolPanel: "☰"
25
+ toolPanel: "☰",
26
+ filter: m,
27
+ filterActive: m
26
28
  };
27
- class y {
29
+ class v {
28
30
  /**
29
31
  * Plugin dependencies - declare other plugins this one requires.
30
32
  *
@@ -248,7 +250,7 @@ class y {
248
250
  */
249
251
  get gridIcons() {
250
252
  const e = this.grid?.gridConfig?.icons ?? {};
251
- return { ...p, ...e };
253
+ return { ...y, ...e };
252
254
  }
253
255
  // #region Animation Helpers
254
256
  /**
@@ -324,7 +326,7 @@ class y {
324
326
  }
325
327
  // #endregion
326
328
  }
327
- function h(r) {
329
+ function g(r) {
328
330
  return r.meta?.utility === !0;
329
331
  }
330
332
  function u(r) {
@@ -335,34 +337,34 @@ function u(r) {
335
337
  endCol: Math.max(r.startCol, r.endCol)
336
338
  };
337
339
  }
338
- function A(r) {
340
+ function I(r) {
339
341
  const e = u(r);
340
342
  return {
341
343
  from: { row: e.startRow, col: e.startCol },
342
344
  to: { row: e.endRow, col: e.endCol }
343
345
  };
344
346
  }
345
- function R(r) {
346
- return r.map(A);
347
+ function C(r) {
348
+ return r.map(I);
347
349
  }
348
- function v(r, e, t) {
350
+ function S(r, e, t) {
349
351
  const s = u(t);
350
352
  return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
351
353
  }
352
- function m(r, e, t) {
353
- return t.some((s) => v(r, e, s));
354
+ function R(r, e, t) {
355
+ return t.some((s) => S(r, e, s));
354
356
  }
355
- function I(r) {
357
+ function E(r) {
356
358
  const e = [], t = u(r);
357
359
  for (let s = t.startRow; s <= t.endRow; s++)
358
360
  for (let i = t.startCol; i <= t.endCol; i++)
359
361
  e.push({ row: s, col: i });
360
362
  return e;
361
363
  }
362
- function E(r) {
364
+ function x(r) {
363
365
  const e = /* @__PURE__ */ new Map();
364
366
  for (const t of r)
365
- for (const s of I(t))
367
+ for (const s of E(t))
366
368
  e.set(`${s.row},${s.col}`, s);
367
369
  return [...e.values()];
368
370
  }
@@ -374,8 +376,8 @@ function f(r, e) {
374
376
  endCol: e.col
375
377
  };
376
378
  }
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}}";
378
- function q(r, e, t) {
379
+ const q = "@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}}";
380
+ function k(r, e, t) {
379
381
  if (r === "cell" && e.selectedCell)
380
382
  return {
381
383
  mode: r,
@@ -393,9 +395,9 @@ function q(r, e, t) {
393
395
  }));
394
396
  return { mode: r, ranges: s };
395
397
  }
396
- return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: R(e.ranges) } : { mode: r, ranges: [] };
398
+ return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: C(e.ranges) } : { mode: r, ranges: [] };
397
399
  }
398
- class K extends y {
400
+ class _ extends v {
399
401
  /**
400
402
  * Plugin manifest - declares configuration validation rules.
401
403
  * @internal
@@ -415,7 +417,7 @@ class K extends y {
415
417
  /** @internal */
416
418
  name = "selection";
417
419
  /** @internal */
418
- styles = x;
420
+ styles = q;
419
421
  /** @internal */
420
422
  get defaultConfig() {
421
423
  return {
@@ -438,6 +440,32 @@ class K extends y {
438
440
  /** Cell selection state (cell mode) */
439
441
  selectedCell = null;
440
442
  // #endregion
443
+ // #region Private Helpers - Selectability
444
+ /**
445
+ * Check if a row/cell is selectable.
446
+ * Returns true if selectable, false if not.
447
+ */
448
+ checkSelectable(e, t) {
449
+ const { isSelectable: s } = this.config;
450
+ if (!s) return !0;
451
+ const i = this.rows[e];
452
+ if (!i) return !1;
453
+ const l = t !== void 0 ? this.columns[t] : void 0;
454
+ return s(i, e, l, t);
455
+ }
456
+ /**
457
+ * Check if an entire row is selectable (for row mode).
458
+ */
459
+ isRowSelectable(e) {
460
+ return this.checkSelectable(e);
461
+ }
462
+ /**
463
+ * Check if a cell is selectable (for cell/range modes).
464
+ */
465
+ isCellSelectable(e, t) {
466
+ return this.checkSelectable(e, t);
467
+ }
468
+ // #endregion
441
469
  // #region Lifecycle
442
470
  /** @internal */
443
471
  detach() {
@@ -447,37 +475,37 @@ class K extends y {
447
475
  // #region Event Handlers
448
476
  /** @internal */
449
477
  onCellClick(e) {
450
- const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: n, triggerOn: o = "click" } = this.config;
451
- if (i.type !== o)
478
+ const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: l, triggerOn: n = "click" } = this.config;
479
+ if (i.type !== n)
452
480
  return !1;
453
- const c = this.columns[s], a = c && h(c);
454
- if (n === "cell")
455
- return a || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
456
- if (n === "row")
457
- return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
458
- if (n === "range") {
459
- if (a)
481
+ const o = this.columns[s], d = o && g(o);
482
+ if (l === "cell")
483
+ return d || !this.isCellSelectable(t, s) || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
484
+ if (l === "row")
485
+ return this.isRowSelectable(t) && (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
486
+ if (l === "range") {
487
+ if (d || !this.isCellSelectable(t, s))
460
488
  return !1;
461
- const g = i.shiftKey, d = i.ctrlKey || i.metaKey;
462
- if (g && this.cellAnchor) {
463
- const l = f(this.cellAnchor, { row: t, col: s });
464
- d ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
465
- } else if (d) {
466
- const l = {
489
+ const a = i.shiftKey, h = i.ctrlKey || i.metaKey;
490
+ if (a && this.cellAnchor) {
491
+ const c = f(this.cellAnchor, { row: t, col: s });
492
+ h ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = c : this.ranges.push(c) : this.ranges = [c], this.activeRange = c;
493
+ } else if (h) {
494
+ const c = {
467
495
  startRow: t,
468
496
  startCol: s,
469
497
  endRow: t,
470
498
  endCol: s
471
499
  };
472
- this.ranges.push(l), this.activeRange = l, this.cellAnchor = { row: t, col: s };
500
+ this.ranges.push(c), this.activeRange = c, this.cellAnchor = { row: t, col: s };
473
501
  } else {
474
- const l = {
502
+ const c = {
475
503
  startRow: t,
476
504
  startCol: s,
477
505
  endRow: t,
478
506
  endCol: s
479
507
  };
480
- this.ranges = [l], this.activeRange = l, this.cellAnchor = { row: t, col: s };
508
+ this.ranges = [c], this.activeRange = c, this.cellAnchor = { row: t, col: s };
481
509
  }
482
510
  return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
483
511
  }
@@ -490,26 +518,28 @@ class K extends y {
490
518
  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
519
  if (t === "cell" && i)
492
520
  return queueMicrotask(() => {
493
- this.selectedCell = { row: this.grid._focusRow, col: this.grid._focusCol }, this.emit("selection-change", this.#e()), this.requestAfterRender();
521
+ const l = this.grid._focusRow, n = this.grid._focusCol;
522
+ this.isCellSelectable(l, n) ? this.selectedCell = { row: l, col: n } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
494
523
  }), !1;
495
524
  if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
496
525
  return queueMicrotask(() => {
497
- this.selected.clear(), this.selected.add(this.grid._focusRow), this.lastSelected = this.grid._focusRow, this.emit("selection-change", this.#e()), this.requestAfterRender();
526
+ const l = this.grid._focusRow;
527
+ 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
528
  }), !1;
499
529
  if (t === "range" && i) {
500
- const n = e.key === "Tab", o = e.shiftKey && !n;
501
- return o && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: o }, queueMicrotask(() => this.requestAfterRender()), !1;
530
+ const l = e.key === "Tab", n = e.shiftKey && !l;
531
+ return n && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: n }, queueMicrotask(() => this.requestAfterRender()), !1;
502
532
  }
503
533
  if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
504
- const n = this.rows.length, o = this.columns.length;
505
- if (n > 0 && o > 0) {
506
- const c = {
534
+ const l = this.rows.length, n = this.columns.length;
535
+ if (l > 0 && n > 0) {
536
+ const o = {
507
537
  startRow: 0,
508
538
  startCol: 0,
509
- endRow: n - 1,
510
- endCol: o - 1
539
+ endRow: l - 1,
540
+ endCol: n - 1
511
541
  };
512
- return this.ranges = [c], this.activeRange = c, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
542
+ return this.ranges = [o], this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
513
543
  }
514
544
  }
515
545
  return !1;
@@ -518,27 +548,27 @@ class K extends y {
518
548
  onCellMouseDown(e) {
519
549
  if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
520
550
  const t = this.columns[e.colIndex];
521
- if (t && h(t) || e.originalEvent.shiftKey && this.cellAnchor)
551
+ if (t && g(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
522
552
  return;
523
553
  this.isDragging = !0;
524
554
  const s = e.rowIndex, i = e.colIndex;
525
555
  this.cellAnchor = { row: s, col: i }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
526
- const o = {
556
+ const n = {
527
557
  startRow: s,
528
558
  startCol: i,
529
559
  endRow: s,
530
560
  endCol: i
531
561
  };
532
- return this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
562
+ return this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
533
563
  }
534
564
  /** @internal */
535
565
  onCellMouseMove(e) {
536
566
  if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
537
567
  let t = e.colIndex;
538
568
  const s = this.columns[t];
539
- if (s && h(s)) {
540
- const n = this.columns.findIndex((o) => !h(o));
541
- n >= 0 && (t = n);
569
+ if (s && g(s)) {
570
+ const l = this.columns.findIndex((n) => !g(n));
571
+ l >= 0 && (t = l);
542
572
  }
543
573
  const i = f(this.cellAnchor, { row: e.rowIndex, col: t });
544
574
  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 +585,32 @@ class K extends y {
555
585
  #t() {
556
586
  const e = this.gridElement;
557
587
  if (!e) return;
558
- const { mode: t } = this.config;
588
+ const { mode: t } = this.config, s = !!this.config.isSelectable;
559
589
  e.querySelectorAll(".cell").forEach((n) => {
560
- n.classList.remove("selected", "top", "bottom", "first", "last");
590
+ n.classList.remove("selected", "top", "bottom", "first", "last"), s && n.removeAttribute("data-selectable");
561
591
  });
562
- const i = e.querySelectorAll(".data-grid-row");
563
- if (i.forEach((n) => {
564
- n.classList.remove("selected", "row-focus");
565
- }), t === "row" && (w(e), i.forEach((n) => {
566
- const o = n.querySelector(".cell[data-row]"), c = b(o);
567
- c >= 0 && this.selected.has(c) && n.classList.add("selected", "row-focus");
568
- })), t === "range" && this.ranges.length > 0) {
569
- w(e);
570
- const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !h(a));
592
+ const l = e.querySelectorAll(".data-grid-row");
593
+ if (l.forEach((n) => {
594
+ n.classList.remove("selected", "row-focus"), s && n.removeAttribute("data-selectable");
595
+ }), t === "row" && (b(e), l.forEach((n) => {
596
+ const o = n.querySelector(".cell[data-row]"), d = A(o);
597
+ d >= 0 && (s && !this.isRowSelectable(d) && n.setAttribute("data-selectable", "false"), this.selected.has(d) && n.classList.add("selected", "row-focus"));
598
+ })), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((o) => {
599
+ const d = parseInt(o.getAttribute("data-row") ?? "-1", 10), a = parseInt(o.getAttribute("data-col") ?? "-1", 10);
600
+ d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || o.setAttribute("data-selectable", "false"));
601
+ }), t === "range" && this.ranges.length > 0) {
602
+ b(e);
603
+ const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !g(a));
571
604
  this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
572
- const g = parseInt(a.getAttribute("data-row") ?? "-1", 10), d = parseInt(a.getAttribute("data-col") ?? "-1", 10);
573
- if (g >= 0 && d >= 0) {
574
- const l = this.columns[d];
575
- if (l && h(l))
605
+ const h = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
606
+ if (h >= 0 && c >= 0) {
607
+ const w = this.columns[c];
608
+ if (w && g(w))
576
609
  return;
577
- if (m(g, d, this.ranges) && (a.classList.add("selected"), n)) {
578
- g === n.startRow && a.classList.add("top"), g === n.endRow && a.classList.add("bottom");
579
- const C = Math.max(n.startCol, o);
580
- d === C && a.classList.add("first"), d === n.endCol && a.classList.add("last");
610
+ if (R(h, c, this.ranges) && (a.classList.add("selected"), n)) {
611
+ h === n.startRow && a.classList.add("top"), h === n.endRow && a.classList.add("bottom");
612
+ const p = Math.max(n.startCol, o);
613
+ c === p && a.classList.add("first"), c === n.endCol && a.classList.add("last");
581
614
  }
582
615
  }
583
616
  });
@@ -591,11 +624,11 @@ class K extends y {
591
624
  if (this.pendingKeyboardUpdate && s === "range") {
592
625
  const { shiftKey: i } = this.pendingKeyboardUpdate;
593
626
  this.pendingKeyboardUpdate = null;
594
- const n = this.grid._focusRow, o = this.grid._focusCol;
627
+ const l = this.grid._focusRow, n = this.grid._focusCol;
595
628
  if (i && this.cellAnchor) {
596
- const c = f(this.cellAnchor, { row: n, col: o });
597
- this.ranges = [c], this.activeRange = c;
598
- } else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: n, col: o });
629
+ const o = f(this.cellAnchor, { row: l, col: n });
630
+ this.ranges = [o], this.activeRange = o;
631
+ } else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: l, col: n });
599
632
  this.emit("selection-change", this.#e());
600
633
  }
601
634
  this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#t();
@@ -636,13 +669,13 @@ class K extends y {
636
669
  * Get all selected cells across all ranges.
637
670
  */
638
671
  getSelectedCells() {
639
- return E(this.ranges);
672
+ return x(this.ranges);
640
673
  }
641
674
  /**
642
675
  * Check if a specific cell is in range selection.
643
676
  */
644
677
  isCellSelected(e, t) {
645
- return m(e, t, this.ranges);
678
+ return R(e, t, this.ranges);
646
679
  }
647
680
  /**
648
681
  * Clear all selection.
@@ -661,13 +694,13 @@ class K extends y {
661
694
  endCol: t.to.col
662
695
  })), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
663
696
  mode: this.config.mode,
664
- ranges: R(this.ranges)
697
+ ranges: C(this.ranges)
665
698
  }), this.requestAfterRender();
666
699
  }
667
700
  // #endregion
668
701
  // #region Private Helpers
669
702
  #e() {
670
- return q(
703
+ return k(
671
704
  this.config.mode,
672
705
  {
673
706
  selectedCell: this.selectedCell,
@@ -680,6 +713,6 @@ class K extends y {
680
713
  // #endregion
681
714
  }
682
715
  export {
683
- K as SelectionPlugin
716
+ _ as SelectionPlugin
684
717
  };
685
718
  //# sourceMappingURL=index.js.map