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