@toolbox-web/grid 1.3.0 → 1.4.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 (82) hide show
  1. package/all.d.ts +1 -0
  2. package/all.d.ts.map +1 -1
  3. package/all.js +997 -710
  4. package/all.js.map +1 -1
  5. package/index.js +642 -599
  6. package/index.js.map +1 -1
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/header.d.ts +7 -0
  9. package/lib/core/internal/header.d.ts.map +1 -1
  10. package/lib/core/types.d.ts +151 -0
  11. package/lib/core/types.d.ts.map +1 -1
  12. package/lib/plugins/clipboard/index.js +19 -16
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/column-virtualization/index.js +42 -39
  15. package/lib/plugins/column-virtualization/index.js.map +1 -1
  16. package/lib/plugins/context-menu/index.js +25 -22
  17. package/lib/plugins/context-menu/index.js.map +1 -1
  18. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  19. package/lib/plugins/editing/index.js +53 -48
  20. package/lib/plugins/editing/index.js.map +1 -1
  21. package/lib/plugins/export/index.js +23 -20
  22. package/lib/plugins/export/index.js.map +1 -1
  23. package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
  24. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  25. package/lib/plugins/filtering/index.js +186 -150
  26. package/lib/plugins/filtering/index.js.map +1 -1
  27. package/lib/plugins/grouping-columns/index.js +21 -18
  28. package/lib/plugins/grouping-columns/index.js.map +1 -1
  29. package/lib/plugins/grouping-rows/index.js +67 -64
  30. package/lib/plugins/grouping-rows/index.js.map +1 -1
  31. package/lib/plugins/master-detail/index.js +52 -49
  32. package/lib/plugins/master-detail/index.js.map +1 -1
  33. package/lib/plugins/multi-sort/index.js +18 -15
  34. package/lib/plugins/multi-sort/index.js.map +1 -1
  35. package/lib/plugins/pinned-columns/index.js +25 -22
  36. package/lib/plugins/pinned-columns/index.js.map +1 -1
  37. package/lib/plugins/pinned-rows/index.js +26 -23
  38. package/lib/plugins/pinned-rows/index.js.map +1 -1
  39. package/lib/plugins/pivot/index.js +50 -47
  40. package/lib/plugins/pivot/index.js.map +1 -1
  41. package/lib/plugins/print/PrintPlugin.d.ts +98 -0
  42. package/lib/plugins/print/PrintPlugin.d.ts.map +1 -0
  43. package/lib/plugins/print/index.d.ts +10 -0
  44. package/lib/plugins/print/index.d.ts.map +1 -0
  45. package/lib/plugins/print/index.js +626 -0
  46. package/lib/plugins/print/index.js.map +1 -0
  47. package/lib/plugins/print/print-isolated.d.ts +26 -0
  48. package/lib/plugins/print/print-isolated.d.ts.map +1 -0
  49. package/lib/plugins/print/types.d.ts +147 -0
  50. package/lib/plugins/print/types.d.ts.map +1 -0
  51. package/lib/plugins/reorder/index.js +25 -22
  52. package/lib/plugins/reorder/index.js.map +1 -1
  53. package/lib/plugins/responsive/index.js +20 -17
  54. package/lib/plugins/responsive/index.js.map +1 -1
  55. package/lib/plugins/row-reorder/index.js +39 -36
  56. package/lib/plugins/row-reorder/index.js.map +1 -1
  57. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  58. package/lib/plugins/selection/index.js +115 -101
  59. package/lib/plugins/selection/index.js.map +1 -1
  60. package/lib/plugins/server-side/index.js +35 -32
  61. package/lib/plugins/server-side/index.js.map +1 -1
  62. package/lib/plugins/tree/index.js +26 -23
  63. package/lib/plugins/tree/index.js.map +1 -1
  64. package/lib/plugins/undo-redo/index.js +23 -20
  65. package/lib/plugins/undo-redo/index.js.map +1 -1
  66. package/lib/plugins/visibility/index.js +22 -19
  67. package/lib/plugins/visibility/index.js.map +1 -1
  68. package/package.json +1 -1
  69. package/public.d.ts +1 -1
  70. package/public.d.ts.map +1 -1
  71. package/umd/grid.all.umd.js +98 -24
  72. package/umd/grid.all.umd.js.map +1 -1
  73. package/umd/grid.umd.js +11 -11
  74. package/umd/grid.umd.js.map +1 -1
  75. package/umd/plugins/editing.umd.js +1 -1
  76. package/umd/plugins/editing.umd.js.map +1 -1
  77. package/umd/plugins/filtering.umd.js +1 -1
  78. package/umd/plugins/filtering.umd.js.map +1 -1
  79. package/umd/plugins/print.umd.js +76 -0
  80. package/umd/plugins/print.umd.js.map +1 -0
  81. package/umd/plugins/selection.umd.js +2 -2
  82. 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,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,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;IAwD/D,gBAAgB;IACP,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,IAAI;IAqC/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"}
@@ -1,4 +1,4 @@
1
- function p(r) {
1
+ function y(r) {
2
2
  if (!r) return -1;
3
3
  const e = r.getAttribute("data-row");
4
4
  if (e) return parseInt(e, 10);
@@ -6,15 +6,15 @@ function p(r) {
6
6
  if (!t) return -1;
7
7
  const s = t.parentElement;
8
8
  if (!s) return -1;
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;
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;
12
12
  return -1;
13
13
  }
14
- function b(r) {
14
+ function m(r) {
15
15
  r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
16
16
  }
17
- const A = {
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 = {
18
18
  expand: "▶",
19
19
  collapse: "▼",
20
20
  sortAsc: "▲",
@@ -22,9 +22,12 @@ const A = {
22
22
  sortNone: "⇅",
23
23
  submenuArrow: "▶",
24
24
  dragHandle: "⋮⋮",
25
- toolPanel: "☰"
25
+ toolPanel: "☰",
26
+ filter: R,
27
+ filterActive: R,
28
+ print: "🖨️"
26
29
  };
27
- class y {
30
+ class I {
28
31
  /**
29
32
  * Plugin dependencies - declare other plugins this one requires.
30
33
  *
@@ -248,7 +251,7 @@ class y {
248
251
  */
249
252
  get gridIcons() {
250
253
  const e = this.grid?.gridConfig?.icons ?? {};
251
- return { ...A, ...e };
254
+ return { ...v, ...e };
252
255
  }
253
256
  // #region Animation Helpers
254
257
  /**
@@ -324,7 +327,7 @@ class y {
324
327
  }
325
328
  // #endregion
326
329
  }
327
- function h(r) {
330
+ function g(r) {
328
331
  return r.meta?.utility === !0;
329
332
  }
330
333
  function u(r) {
@@ -335,38 +338,38 @@ function u(r) {
335
338
  endCol: Math.max(r.startCol, r.endCol)
336
339
  };
337
340
  }
338
- function v(r) {
341
+ function S(r) {
339
342
  const e = u(r);
340
343
  return {
341
344
  from: { row: e.startRow, col: e.startCol },
342
345
  to: { row: e.endRow, col: e.endCol }
343
346
  };
344
347
  }
345
- function R(r) {
346
- return r.map(v);
348
+ function p(r) {
349
+ return r.map(S);
347
350
  }
348
- function S(r, e, t) {
351
+ function E(r, e, t) {
349
352
  const s = u(t);
350
353
  return r >= s.startRow && r <= s.endRow && e >= s.startCol && e <= s.endCol;
351
354
  }
352
- function m(r, e, t) {
353
- return t.some((s) => S(r, e, s));
355
+ function C(r, e, t) {
356
+ return t.some((s) => E(r, e, s));
354
357
  }
355
- function I(r) {
358
+ function x(r) {
356
359
  const e = [], t = u(r);
357
360
  for (let s = t.startRow; s <= t.endRow; s++)
358
- for (let i = t.startCol; i <= t.endCol; i++)
359
- e.push({ row: s, col: i });
361
+ for (let l = t.startCol; l <= t.endCol; l++)
362
+ e.push({ row: s, col: l });
360
363
  return e;
361
364
  }
362
- function E(r) {
365
+ function q(r) {
363
366
  const e = /* @__PURE__ */ new Map();
364
367
  for (const t of r)
365
- for (const s of I(t))
368
+ for (const s of x(t))
366
369
  e.set(`${s.row},${s.col}`, s);
367
370
  return [...e.values()];
368
371
  }
369
- function f(r, e) {
372
+ function b(r, e) {
370
373
  return {
371
374
  startRow: r.row,
372
375
  startCol: r.col,
@@ -374,8 +377,12 @@ function f(r, e) {
374
377
  endCol: e.col
375
378
  };
376
379
  }
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
- function q(r, e, t) {
380
+ function w(r, e) {
381
+ const t = u(r), s = u(e);
382
+ return t.startRow === s.startRow && t.startCol === s.startCol && t.endRow === s.endRow && t.endCol === s.endCol;
383
+ }
384
+ const k = "@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}}";
385
+ function K(r, e, t) {
379
386
  if (r === "cell" && e.selectedCell)
380
387
  return {
381
388
  mode: r,
@@ -387,15 +394,15 @@ function q(r, e, t) {
387
394
  ]
388
395
  };
389
396
  if (r === "row" && e.selected.size > 0) {
390
- const s = [...e.selected].map((i) => ({
391
- from: { row: i, col: 0 },
392
- to: { row: i, col: t - 1 }
397
+ const s = [...e.selected].map((l) => ({
398
+ from: { row: l, col: 0 },
399
+ to: { row: l, col: t - 1 }
393
400
  }));
394
401
  return { mode: r, ranges: s };
395
402
  }
396
- return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: R(e.ranges) } : { mode: r, ranges: [] };
403
+ return r === "range" && e.ranges.length > 0 ? { mode: r, ranges: p(e.ranges) } : { mode: r, ranges: [] };
397
404
  }
398
- class K extends y {
405
+ class D extends I {
399
406
  /**
400
407
  * Plugin manifest - declares configuration validation rules.
401
408
  * @internal
@@ -415,7 +422,7 @@ class K extends y {
415
422
  /** @internal */
416
423
  name = "selection";
417
424
  /** @internal */
418
- styles = x;
425
+ styles = k;
419
426
  /** @internal */
420
427
  get defaultConfig() {
421
428
  return {
@@ -446,10 +453,10 @@ class K extends y {
446
453
  checkSelectable(e, t) {
447
454
  const { isSelectable: s } = this.config;
448
455
  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);
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);
453
460
  }
454
461
  /**
455
462
  * Check if an entire row is selectable (for row mode).
@@ -473,37 +480,45 @@ class K extends y {
473
480
  // #region Event Handlers
474
481
  /** @internal */
475
482
  onCellClick(e) {
476
- const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: l, triggerOn: n = "click" } = this.config;
477
- if (i.type !== n)
483
+ const { rowIndex: t, colIndex: s, originalEvent: l } = e, { mode: i, triggerOn: n = "click" } = this.config;
484
+ if (l.type !== n)
478
485
  return !1;
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") {
486
+ const o = this.columns[s], d = o && g(o);
487
+ if (i === "cell") {
488
+ if (d || !this.isCellSelectable(t, s))
489
+ 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;
492
+ }
493
+ if (i === "row")
494
+ 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") {
485
496
  if (d || !this.isCellSelectable(t, s))
486
497
  return !1;
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 = {
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))
502
+ 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;
504
+ } else if (h) {
505
+ const a = {
493
506
  startRow: t,
494
507
  startCol: s,
495
508
  endRow: t,
496
509
  endCol: s
497
510
  };
498
- this.ranges.push(c), this.activeRange = c, this.cellAnchor = { row: t, col: s };
511
+ this.ranges.push(a), this.activeRange = a, this.cellAnchor = { row: t, col: s };
499
512
  } else {
500
- const c = {
513
+ const a = {
501
514
  startRow: t,
502
515
  startCol: s,
503
516
  endRow: t,
504
517
  endCol: s
505
518
  };
506
- this.ranges = [c], this.activeRange = c, this.cellAnchor = { row: t, col: s };
519
+ if (this.ranges.length === 1 && w(this.ranges[0], a))
520
+ return !1;
521
+ this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: t, col: s };
507
522
  }
508
523
  return this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
509
524
  }
@@ -511,30 +526,31 @@ class K extends y {
511
526
  }
512
527
  /** @internal */
513
528
  onKeyDown(e) {
514
- const { mode: t } = this.config, i = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
529
+ const { mode: t } = this.config, l = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
515
530
  if (e.key === "Escape")
516
531
  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;
517
- if (t === "cell" && i)
532
+ if (t === "cell" && l)
518
533
  return queueMicrotask(() => {
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();
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();
521
536
  }), !1;
522
537
  if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
523
538
  return queueMicrotask(() => {
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();
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();
526
541
  }), !1;
527
- if (t === "range" && i) {
528
- const l = e.key === "Tab", n = e.shiftKey && !l;
542
+ if (t === "range" && l) {
543
+ const i = e.key === "Tab", n = e.shiftKey && !i;
529
544
  return n && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: n }, queueMicrotask(() => this.requestAfterRender()), !1;
530
545
  }
531
546
  if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
532
- const l = this.rows.length, n = this.columns.length;
533
- if (l > 0 && n > 0) {
547
+ const i = this.rows.length, n = this.columns.length;
548
+ if (i > 0 && n > 0) {
549
+ e.preventDefault(), e.stopPropagation();
534
550
  const o = {
535
551
  startRow: 0,
536
552
  startCol: 0,
537
- endRow: l - 1,
553
+ endRow: i - 1,
538
554
  endCol: n - 1
539
555
  };
540
556
  return this.ranges = [o], this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
@@ -546,30 +562,28 @@ class K extends y {
546
562
  onCellMouseDown(e) {
547
563
  if (this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
548
564
  const t = this.columns[e.colIndex];
549
- if (t && h(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
565
+ if (t && g(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
550
566
  return;
551
567
  this.isDragging = !0;
552
- const s = e.rowIndex, i = e.colIndex;
553
- this.cellAnchor = { row: s, col: i }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
554
- const n = {
568
+ const s = e.rowIndex, l = e.colIndex, i = e.originalEvent.ctrlKey || e.originalEvent.metaKey, n = {
555
569
  startRow: s,
556
- startCol: i,
570
+ startCol: l,
557
571
  endRow: s,
558
- endCol: i
572
+ endCol: l
559
573
  };
560
- return this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
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);
561
575
  }
562
576
  /** @internal */
563
577
  onCellMouseMove(e) {
564
578
  if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
565
579
  let t = e.colIndex;
566
580
  const s = this.columns[t];
567
- if (s && h(s)) {
568
- const l = this.columns.findIndex((n) => !h(n));
569
- l >= 0 && (t = l);
581
+ if (s && g(s)) {
582
+ const n = this.columns.findIndex((o) => !g(o));
583
+ n >= 0 && (t = n);
570
584
  }
571
- const i = f(this.cellAnchor, { row: e.rowIndex, col: t });
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;
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;
573
587
  }
574
588
  /** @internal */
575
589
  onCellMouseUp(e) {
@@ -587,28 +601,28 @@ class K extends y {
587
601
  e.querySelectorAll(".cell").forEach((n) => {
588
602
  n.classList.remove("selected", "top", "bottom", "first", "last"), s && n.removeAttribute("data-selectable");
589
603
  });
590
- const l = e.querySelectorAll(".data-grid-row");
591
- if (l.forEach((n) => {
604
+ const i = e.querySelectorAll(".data-grid-row");
605
+ if (i.forEach((n) => {
592
606
  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);
607
+ }), t === "row" && (m(e), i.forEach((n) => {
608
+ const o = n.querySelector(".cell[data-row]"), d = y(o);
595
609
  d >= 0 && (s && !this.isRowSelectable(d) && n.setAttribute("data-selectable", "false"), this.selected.has(d) && n.classList.add("selected", "row-focus"));
596
610
  })), (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"));
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"));
599
613
  }), t === "range" && this.ranges.length > 0) {
600
- b(e);
601
- const n = this.activeRange ? u(this.activeRange) : null, o = this.columns.findIndex((a) => !h(a));
602
- this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
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))
614
+ 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];
620
+ if (f && g(f))
607
621
  return;
608
- if (m(g, c, this.ranges) && (a.classList.add("selected"), n)) {
609
- g === n.startRow && a.classList.add("top"), g === n.endRow && a.classList.add("bottom");
610
- const C = Math.max(n.startCol, o);
611
- c === C && a.classList.add("first"), c === n.endCol && a.classList.add("last");
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");
624
+ const A = Math.max(n.startCol, o);
625
+ a === A && c.classList.add("first"), a === n.endCol && c.classList.add("last");
612
626
  }
613
627
  }
614
628
  });
@@ -620,13 +634,13 @@ class K extends y {
620
634
  if (!e) return;
621
635
  const t = e.children[0], { mode: s } = this.config;
622
636
  if (this.pendingKeyboardUpdate && s === "range") {
623
- const { shiftKey: i } = this.pendingKeyboardUpdate;
637
+ const { shiftKey: l } = this.pendingKeyboardUpdate;
624
638
  this.pendingKeyboardUpdate = null;
625
- const l = this.grid._focusRow, n = this.grid._focusCol;
626
- if (i && this.cellAnchor) {
627
- const o = f(this.cellAnchor, { row: l, col: n });
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 });
628
642
  this.ranges = [o], this.activeRange = o;
629
- } else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: l, col: n });
643
+ } else l || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: i, col: n });
630
644
  this.emit("selection-change", this.#e());
631
645
  }
632
646
  this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#t();
@@ -667,13 +681,13 @@ class K extends y {
667
681
  * Get all selected cells across all ranges.
668
682
  */
669
683
  getSelectedCells() {
670
- return E(this.ranges);
684
+ return q(this.ranges);
671
685
  }
672
686
  /**
673
687
  * Check if a specific cell is in range selection.
674
688
  */
675
689
  isCellSelected(e, t) {
676
- return m(e, t, this.ranges);
690
+ return C(e, t, this.ranges);
677
691
  }
678
692
  /**
679
693
  * Clear all selection.
@@ -692,13 +706,13 @@ class K extends y {
692
706
  endCol: t.to.col
693
707
  })), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
694
708
  mode: this.config.mode,
695
- ranges: R(this.ranges)
709
+ ranges: p(this.ranges)
696
710
  }), this.requestAfterRender();
697
711
  }
698
712
  // #endregion
699
713
  // #region Private Helpers
700
714
  #e() {
701
- return q(
715
+ return K(
702
716
  this.config.mode,
703
717
  {
704
718
  selectedCell: this.selectedCell,
@@ -711,6 +725,6 @@ class K extends y {
711
725
  // #endregion
712
726
  }
713
727
  export {
714
- K as SelectionPlugin
728
+ D as SelectionPlugin
715
729
  };
716
730
  //# sourceMappingURL=index.js.map