@toolbox-web/grid 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -2777,7 +2777,7 @@ ${Qi}
2777
2777
  `;
2778
2778
  class k extends HTMLElement {
2779
2779
  static tagName = "tbw-grid";
2780
- static version = "1.18.0";
2780
+ static version = "1.19.0";
2781
2781
  static #l = 0;
2782
2782
  static adapters = [];
2783
2783
  static registerAdapter(e) {
@@ -3978,7 +3978,7 @@ const lo = {
3978
3978
  class ao {
3979
3979
  static dependencies;
3980
3980
  static manifest;
3981
- version = "1.18.0";
3981
+ version = "1.19.0";
3982
3982
  styles;
3983
3983
  cellRenderers;
3984
3984
  headerRenderers;
@@ -233,6 +233,24 @@ export declare class SelectionPlugin extends BaseGridPlugin<SelectionConfig> {
233
233
  * ```
234
234
  */
235
235
  getSelectedRowIndices(): number[];
236
+ /**
237
+ * Get the actual row objects for the current selection.
238
+ *
239
+ * Works across all selection modes:
240
+ * - **Row mode**: Returns the row objects for all selected rows.
241
+ * - **Cell mode**: Returns the single row containing the selected cell, or `[]`.
242
+ * - **Range mode**: Returns the unique row objects that intersect any selected range.
243
+ *
244
+ * Row objects are resolved from the grid's processed (sorted/filtered) row array,
245
+ * so they always reflect the current visual order.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * const plugin = grid.getPlugin(SelectionPlugin);
250
+ * const selected = plugin.getSelectedRows(); // [{ id: 1, name: 'Alice' }, ...]
251
+ * ```
252
+ */
253
+ getSelectedRows<T = unknown>(): T[];
236
254
  /**
237
255
  * Clear all selection.
238
256
  */
@@ -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,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,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,EAAE,MAAM,GAAG,OAAO;IAIjD;;;;;;;;;;;;OAYG;IACH,SAAS,IAAI,IAAI;IA+BjB;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAcnC;;;;;;;;;OASG;IACH,qBAAqB,IAAI,MAAM,EAAE;IAIjC;;;;;;;;;;;;;;;;OAgBG;IACH,eAAe,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,EAAE;IAiCnC;;OAEG;IACH,cAAc,IAAI,IAAI;IAWtB;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI;CAgCrC"}
@@ -6,9 +6,9 @@ function R(n) {
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 r = 0; r < i.length; r++)
11
- if (i[r] === t) return r;
9
+ const r = s.querySelectorAll(":scope > .data-grid-row");
10
+ for (let i = 0; i < r.length; i++)
11
+ if (r[i] === t) return i;
12
12
  return -1;
13
13
  }
14
14
  function C(n) {
@@ -415,7 +415,7 @@ function I(n) {
415
415
  to: { row: e.endRow, col: e.endCol }
416
416
  };
417
417
  }
418
- function S(n) {
418
+ function y(n) {
419
419
  return n.map(I);
420
420
  }
421
421
  function _(n, e, t) {
@@ -428,8 +428,8 @@ function q(n, e, t) {
428
428
  function K(n) {
429
429
  const e = [], t = g(n);
430
430
  for (let s = t.startRow; s <= t.endRow; s++)
431
- for (let i = t.startCol; i <= t.endCol; i++)
432
- e.push({ row: s, col: i });
431
+ for (let r = t.startCol; r <= t.endCol; r++)
432
+ e.push({ row: s, col: r });
433
433
  return e;
434
434
  }
435
435
  function M(n) {
@@ -451,7 +451,7 @@ function b(n, e) {
451
451
  const t = g(n), s = g(e);
452
452
  return t.startRow === s.startRow && t.startCol === s.startCol && t.endRow === s.endRow && t.endCol === s.endCol;
453
453
  }
454
- const F = '@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid:has(.selection){-webkit-user-select:none;user-select:none}tbw-grid .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));outline:none;position:relative}tbw-grid .data-grid-row.row-focus:after{content:"";position:absolute;inset:0;pointer-events:none;border-width:0;border-style:var(--tbw-selection-border-style, var(--tbw-border-style));border-color:var(--tbw-range-border-color, var(--tbw-color-accent));border-top-width:var(--tbw-selection-border-width, var(--tbw-border-width));border-bottom-width:var(--tbw-selection-border-width, var(--tbw-border-width));z-index:1}tbw-grid .data-grid-row.row-focus+.data-grid-row.row-focus:after{border-top-width:0}tbw-grid .data-grid-row.row-focus:has(+.data-grid-row.row-focus):after{border-bottom-width:0}tbw-grid[data-selection-mode=row] .cell-focus,tbw-grid[data-selection-mode=row] .row-focus,tbw-grid[data-selection-mode=range] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg);position:relative}tbw-grid .data-grid-row>.cell.selected:after{content:"";position:absolute;inset:0;pointer-events:none;border:0 var(--tbw-selection-border-style, var(--tbw-border-style)) var(--tbw-range-border-color);z-index:1}tbw-grid .data-grid-row>.cell.selected.top:after{border-top-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.bottom:after{border-bottom-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.first:after{border-left-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.last:after{border-right-width:var(--tbw-selection-border-width, var(--tbw-border-width))}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-selection-warning-bg, rgba(from var(--tbw-color-error) r g b / 50%))}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}tbw-grid .data-grid-row>.cell[data-field=__tbw_checkbox],tbw-grid .header-row>.cell[data-field=__tbw_checkbox]{text-align:center;cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center}tbw-grid .tbw-select-row-checkbox{pointer-events:none;margin:0;cursor:pointer}tbw-grid .tbw-checkbox-header{display:flex;justify-content:center;align-items:center;height:100%}tbw-grid .tbw-select-all-checkbox{margin:0;cursor:pointer}}', y = "__tbw_checkbox";
454
+ const F = '@layer tbw-plugins{tbw-grid.selecting .data-grid-row>.cell{-webkit-user-select:none;user-select:none}tbw-grid:has(.selection){-webkit-user-select:none;user-select:none}tbw-grid .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%));outline:none;position:relative}tbw-grid .data-grid-row.row-focus:after{content:"";position:absolute;inset:0;pointer-events:none;border-width:0;border-style:var(--tbw-selection-border-style, var(--tbw-border-style));border-color:var(--tbw-range-border-color, var(--tbw-color-accent));border-top-width:var(--tbw-selection-border-width, var(--tbw-border-width));border-bottom-width:var(--tbw-selection-border-width, var(--tbw-border-width));z-index:1}tbw-grid .data-grid-row.row-focus+.data-grid-row.row-focus:after{border-top-width:0}tbw-grid .data-grid-row.row-focus:has(+.data-grid-row.row-focus):after{border-bottom-width:0}tbw-grid[data-selection-mode=row] .cell-focus,tbw-grid[data-selection-mode=row] .row-focus,tbw-grid[data-selection-mode=range] .cell-focus{outline:none}tbw-grid .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg);position:relative}tbw-grid .data-grid-row>.cell.selected:after{content:"";position:absolute;inset:0;pointer-events:none;border:0 var(--tbw-selection-border-style, var(--tbw-border-style)) var(--tbw-range-border-color);z-index:1}tbw-grid .data-grid-row>.cell.selected.top:after{border-top-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.bottom:after{border-bottom-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.first:after{border-left-width:var(--tbw-selection-border-width, var(--tbw-border-width))}tbw-grid .data-grid-row>.cell.selected.last:after{border-right-width:var(--tbw-selection-border-width, var(--tbw-border-width))}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-selection-warning-bg, rgba(from var(--tbw-color-error) r g b / 50%))}tbw-grid .tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}tbw-grid .data-grid-row>.cell[data-field=__tbw_checkbox],tbw-grid .header-row>.cell[data-field=__tbw_checkbox]{text-align:center;cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center}tbw-grid .tbw-select-row-checkbox{pointer-events:none;margin:0;cursor:pointer}tbw-grid .tbw-checkbox-header{display:flex;justify-content:center;align-items:center;height:100%}tbw-grid .tbw-select-all-checkbox{margin:0;cursor:pointer}}', S = "__tbw_checkbox";
455
455
  function D(n, e, t) {
456
456
  if (n === "cell" && e.selectedCell)
457
457
  return {
@@ -464,13 +464,13 @@ function D(n, e, t) {
464
464
  ]
465
465
  };
466
466
  if (n === "row" && e.selected.size > 0) {
467
- const s = [...e.selected].sort((l, d) => l - d), i = [];
468
- let r = s[0], o = r;
467
+ const s = [...e.selected].sort((l, d) => l - d), r = [];
468
+ let i = s[0], o = i;
469
469
  for (let l = 1; l < s.length; l++)
470
- s[l] === o + 1 ? o = s[l] : (i.push({ from: { row: r, col: 0 }, to: { row: o, col: t - 1 } }), r = s[l], o = r);
471
- return i.push({ from: { row: r, col: 0 }, to: { row: o, col: t - 1 } }), { mode: n, ranges: i };
470
+ s[l] === o + 1 ? o = s[l] : (r.push({ from: { row: i, col: 0 }, to: { row: o, col: t - 1 } }), i = s[l], o = i);
471
+ return r.push({ from: { row: i, col: 0 }, to: { row: o, col: t - 1 } }), { mode: n, ranges: r };
472
472
  }
473
- return n === "range" && e.ranges.length > 0 ? { mode: n, ranges: S(e.ranges) } : { mode: n, ranges: [] };
473
+ return n === "range" && e.ranges.length > 0 ? { mode: n, ranges: y(e.ranges) } : { mode: n, ranges: [] };
474
474
  }
475
475
  class L extends v {
476
476
  /**
@@ -481,7 +481,8 @@ class L extends v {
481
481
  queries: [
482
482
  { type: "getSelection", description: "Get the current selection state" },
483
483
  { type: "selectRows", description: "Select specific rows by index (row mode only)" },
484
- { type: "getSelectedRowIndices", description: "Get sorted array of selected row indices" }
484
+ { type: "getSelectedRowIndices", description: "Get sorted array of selected row indices" },
485
+ { type: "getSelectedRows", description: "Get actual row objects for the current selection (works in all modes)" }
485
486
  ],
486
487
  configRules: [
487
488
  {
@@ -544,10 +545,10 @@ class L extends v {
544
545
  checkSelectable(e, t) {
545
546
  const { isSelectable: s } = this.config;
546
547
  if (!s) return !0;
547
- const i = this.rows[e];
548
- if (!i) return !1;
549
- const r = t !== void 0 ? this.columns[t] : void 0;
550
- return s(i, e, r, t);
548
+ const r = this.rows[e];
549
+ if (!r) return !1;
550
+ const i = t !== void 0 ? this.columns[t] : void 0;
551
+ return s(r, e, i, t);
551
552
  }
552
553
  /**
553
554
  * Check if an entire row is selectable (for row mode).
@@ -576,6 +577,8 @@ class L extends v {
576
577
  return this.getSelection();
577
578
  if (e.type === "getSelectedRowIndices")
578
579
  return this.getSelectedRowIndices();
580
+ if (e.type === "getSelectedRows")
581
+ return this.getSelectedRows();
579
582
  if (e.type === "selectRows")
580
583
  return this.selectRows(e.context), !0;
581
584
  }
@@ -595,20 +598,20 @@ class L extends v {
595
598
  /** @internal */
596
599
  onCellClick(e) {
597
600
  if (!this.isSelectionEnabled()) return !1;
598
- const { rowIndex: t, colIndex: s, originalEvent: i } = e, { mode: r, triggerOn: o = "click" } = this.config;
599
- if (i.type !== o)
601
+ const { rowIndex: t, colIndex: s, originalEvent: r } = e, { mode: i, triggerOn: o = "click" } = this.config;
602
+ if (r.type !== o)
600
603
  return !1;
601
604
  const l = this.columns[s], d = l && f(l);
602
- if (r === "cell") {
605
+ if (i === "cell") {
603
606
  if (d || !this.isCellSelectable(t, s))
604
607
  return !1;
605
608
  const a = this.selectedCell;
606
609
  return a && a.row === t && a.col === s || (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()), this.requestAfterRender()), !1;
607
610
  }
608
- if (r === "row") {
611
+ if (i === "row") {
609
612
  if (!this.isRowSelectable(t))
610
613
  return !1;
611
- const a = i.shiftKey, h = i.ctrlKey || i.metaKey, c = l?.meta?.checkboxColumn === !0;
614
+ const a = r.shiftKey, h = r.ctrlKey || r.metaKey, c = l?.meta?.checkboxColumn === !0;
612
615
  if (a && this.anchor !== null) {
613
616
  const u = Math.min(this.anchor, t), x = Math.max(this.anchor, t);
614
617
  h || this.selected.clear();
@@ -623,10 +626,10 @@ class L extends v {
623
626
  }
624
627
  return this.lastSelected = t, this.explicitSelection = !0, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
625
628
  }
626
- if (r === "range") {
629
+ if (i === "range") {
627
630
  if (d || !this.isCellSelectable(t, s))
628
631
  return !1;
629
- const a = i.shiftKey, h = i.ctrlKey || i.metaKey;
632
+ const a = r.shiftKey, h = r.ctrlKey || r.metaKey;
630
633
  if (a && this.cellAnchor) {
631
634
  const c = m(this.cellAnchor, { row: t, col: s }), u = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
632
635
  if (u && b(u, c))
@@ -658,20 +661,20 @@ class L extends v {
658
661
  /** @internal */
659
662
  onKeyDown(e) {
660
663
  if (!this.isSelectionEnabled()) return !1;
661
- const { mode: t } = this.config, i = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
664
+ const { mode: t } = this.config, r = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Home", "End", "PageUp", "PageDown"].includes(e.key);
662
665
  if (e.key === "Escape")
663
666
  return this.grid.query("isEditing").some(Boolean) ? !1 : (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);
664
- if (t === "cell" && i)
667
+ if (t === "cell" && r)
665
668
  return queueMicrotask(() => {
666
- const r = this.grid._focusRow, o = this.grid._focusCol;
667
- this.isCellSelectable(r, o) ? this.selectedCell = { row: r, col: o } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
669
+ const i = this.grid._focusRow, o = this.grid._focusCol;
670
+ this.isCellSelectable(i, o) ? this.selectedCell = { row: i, col: o } : this.selectedCell = null, this.emit("selection-change", this.#e()), this.requestAfterRender();
668
671
  }), !1;
669
672
  if (t === "row") {
670
673
  if (e.key === "ArrowUp" || e.key === "ArrowDown") {
671
- const r = e.shiftKey;
672
- return r && this.anchor === null && (this.anchor = this.grid._focusRow), queueMicrotask(() => {
674
+ const i = e.shiftKey;
675
+ return i && this.anchor === null && (this.anchor = this.grid._focusRow), queueMicrotask(() => {
673
676
  const o = this.grid._focusRow;
674
- if (r && this.anchor !== null) {
677
+ if (i && this.anchor !== null) {
675
678
  this.selected.clear();
676
679
  const l = Math.min(this.anchor, o), d = Math.max(this.anchor, o);
677
680
  for (let a = l; a <= d; a++)
@@ -684,8 +687,8 @@ class L extends v {
684
687
  if (e.key === "a" && (e.ctrlKey || e.metaKey))
685
688
  return this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0);
686
689
  }
687
- if (t === "range" && i) {
688
- const r = e.key === "Tab", o = e.shiftKey && !r;
690
+ if (t === "range" && r) {
691
+ const i = e.key === "Tab", o = e.shiftKey && !i;
689
692
  return o && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: o }, queueMicrotask(() => this.requestAfterRender()), !1;
690
693
  }
691
694
  return t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey) ? this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0) : !1;
@@ -697,13 +700,13 @@ class L extends v {
697
700
  if (t && f(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
698
701
  return;
699
702
  this.isDragging = !0;
700
- const s = e.rowIndex, i = e.colIndex, r = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
703
+ const s = e.rowIndex, r = e.colIndex, i = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
701
704
  startRow: s,
702
- startCol: i,
705
+ startCol: r,
703
706
  endRow: s,
704
- endCol: i
707
+ endCol: r
705
708
  };
706
- return !r && this.ranges.length === 1 && b(this.ranges[0], o) ? (this.cellAnchor = { row: s, col: i }, !0) : (this.cellAnchor = { row: s, col: i }, r || (this.ranges = []), this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
709
+ return !i && this.ranges.length === 1 && b(this.ranges[0], o) ? (this.cellAnchor = { row: s, col: r }, !0) : (this.cellAnchor = { row: s, col: r }, i || (this.ranges = []), this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0);
707
710
  }
708
711
  /** @internal */
709
712
  onCellMouseMove(e) {
@@ -714,8 +717,8 @@ class L extends v {
714
717
  const o = this.columns.findIndex((l) => !f(l));
715
718
  o >= 0 && (t = o);
716
719
  }
717
- const i = m(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
718
- return r && b(r, 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;
720
+ const r = m(this.cellAnchor, { row: e.rowIndex, col: t }), i = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
721
+ return i && b(i, r) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = r : this.ranges.push(r), this.activeRange = r, this.emit("selection-change", this.#e()), this.requestAfterRender()), !0;
719
722
  }
720
723
  /** @internal */
721
724
  onCellMouseUp(e) {
@@ -729,10 +732,10 @@ class L extends v {
729
732
  */
730
733
  processColumns(e) {
731
734
  if (this.config.checkbox && this.config.mode === "row") {
732
- if (e.some((r) => r.field === y))
735
+ if (e.some((i) => i.field === S))
733
736
  return e;
734
- const t = this.#t(), s = e.findIndex(k), i = s >= 0 ? s + 1 : 0;
735
- return [...e.slice(0, i), t, ...e.slice(i)];
737
+ const t = this.#t(), s = e.findIndex(k), r = s >= 0 ? s + 1 : 0;
738
+ return [...e.slice(0, r), t, ...e.slice(r)];
736
739
  }
737
740
  return e;
738
741
  }
@@ -741,7 +744,7 @@ class L extends v {
741
744
  */
742
745
  #t() {
743
746
  return {
744
- field: y,
747
+ field: S,
745
748
  header: "",
746
749
  width: 32,
747
750
  resizable: !1,
@@ -765,8 +768,8 @@ class L extends v {
765
768
  t.type = "checkbox", t.className = "tbw-select-row-checkbox";
766
769
  const s = e.cellEl;
767
770
  if (s) {
768
- const i = parseInt(s.getAttribute("data-row") ?? "-1", 10);
769
- i >= 0 && (t.checked = this.selected.has(i));
771
+ const r = parseInt(s.getAttribute("data-row") ?? "-1", 10);
772
+ r >= 0 && (t.checked = this.selected.has(r));
770
773
  }
771
774
  return t;
772
775
  }
@@ -776,21 +779,21 @@ class L extends v {
776
779
  * Update checkbox checked states to reflect current selection.
777
780
  * Called from #applySelectionClasses.
778
781
  */
779
- #i(e) {
780
- e.querySelectorAll(".tbw-select-row-checkbox").forEach((i) => {
781
- const r = i.closest(".cell"), o = r ? R(r) : -1;
782
- o >= 0 && (i.checked = this.selected.has(o));
782
+ #r(e) {
783
+ e.querySelectorAll(".tbw-select-row-checkbox").forEach((r) => {
784
+ const i = r.closest(".cell"), o = i ? R(i) : -1;
785
+ o >= 0 && (r.checked = this.selected.has(o));
783
786
  });
784
787
  const s = e.querySelector(".tbw-select-all-checkbox");
785
788
  if (s) {
786
- const i = this.rows.length;
787
- let r = 0;
789
+ const r = this.rows.length;
790
+ let i = 0;
788
791
  if (this.config.isSelectable)
789
- for (let d = 0; d < i; d++)
790
- this.isRowSelectable(d) && r++;
792
+ for (let d = 0; d < r; d++)
793
+ this.isRowSelectable(d) && i++;
791
794
  else
792
- r = i;
793
- const o = r > 0 && this.selected.size >= r, l = this.selected.size > 0;
795
+ i = r;
796
+ const o = i > 0 && this.selected.size >= i, l = this.selected.size > 0;
794
797
  s.checked = o, s.indeterminate = l && !o;
795
798
  }
796
799
  }
@@ -802,7 +805,7 @@ class L extends v {
802
805
  * Only updates when the focus has changed since the last sync.
803
806
  * Skips when `explicitSelection` is set (click/keyboard set selection directly).
804
807
  */
805
- #r(e) {
808
+ #i(e) {
806
809
  const t = this.grid._focusRow, s = this.grid._focusCol;
807
810
  if (e === "row") {
808
811
  if (this.explicitSelection) {
@@ -817,8 +820,8 @@ class L extends v {
817
820
  return;
818
821
  }
819
822
  if ((t !== this.lastSyncedFocusRow || s !== this.lastSyncedFocusCol) && (this.lastSyncedFocusRow = t, this.lastSyncedFocusCol = s, this.isCellSelectable(t, s))) {
820
- const i = this.selectedCell;
821
- (!i || i.row !== t || i.col !== s) && (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()));
823
+ const r = this.selectedCell;
824
+ (!r || r.row !== t || r.col !== s) && (this.selectedCell = { row: t, col: s }, this.emit("selection-change", this.#e()));
822
825
  }
823
826
  }
824
827
  }
@@ -833,13 +836,13 @@ class L extends v {
833
836
  e.querySelectorAll(".cell").forEach((o) => {
834
837
  o.classList.remove("selected", "top", "bottom", "first", "last"), s && o.removeAttribute("data-selectable");
835
838
  });
836
- const r = e.querySelectorAll(".data-grid-row");
837
- if (r.forEach((o) => {
839
+ const i = e.querySelectorAll(".data-grid-row");
840
+ if (i.forEach((o) => {
838
841
  o.classList.remove("selected", "row-focus"), s && o.removeAttribute("data-selectable");
839
- }), t === "row" && (C(e), r.forEach((o) => {
842
+ }), t === "row" && (C(e), i.forEach((o) => {
840
843
  const l = o.querySelector(".cell[data-row]"), d = R(l);
841
844
  d >= 0 && (s && !this.isRowSelectable(d) && o.setAttribute("data-selectable", "false"), this.selected.has(d) && o.classList.add("selected", "row-focus"));
842
- }), this.config.checkbox && this.#i(e)), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((l) => {
845
+ }), this.config.checkbox && this.#r(e)), (t === "cell" || t === "range") && s && e.querySelectorAll(".cell[data-row][data-col]").forEach((l) => {
843
846
  const d = parseInt(l.getAttribute("data-row") ?? "-1", 10), a = parseInt(l.getAttribute("data-col") ?? "-1", 10);
844
847
  d >= 0 && a >= 0 && (this.isCellSelectable(d, a) || l.setAttribute("data-selectable", "false"));
845
848
  }), t === "range" && this.ranges.length > 0) {
@@ -868,16 +871,16 @@ class L extends v {
868
871
  if (!e) return;
869
872
  const t = e.children[0], { mode: s } = this.config;
870
873
  if (this.pendingKeyboardUpdate && s === "range") {
871
- const { shiftKey: i } = this.pendingKeyboardUpdate;
874
+ const { shiftKey: r } = this.pendingKeyboardUpdate;
872
875
  this.pendingKeyboardUpdate = null;
873
- const r = this.grid._focusRow, o = this.grid._focusCol;
874
- if (i && this.cellAnchor) {
875
- const l = m(this.cellAnchor, { row: r, col: o });
876
+ const i = this.grid._focusRow, o = this.grid._focusCol;
877
+ if (r && this.cellAnchor) {
878
+ const l = m(this.cellAnchor, { row: i, col: o });
876
879
  this.ranges = [l], this.activeRange = l;
877
- } else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
880
+ } else r || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: i, col: o });
878
881
  this.emit("selection-change", this.#e());
879
882
  }
880
- this.#r(s), this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#s();
883
+ this.#i(s), this.grid.setAttribute("data-selection-mode", s), t && t.classList.toggle("selecting", this.isDragging), this.#s();
881
884
  }
882
885
  /**
883
886
  * Called after scroll-triggered row rendering.
@@ -946,13 +949,13 @@ class L extends v {
946
949
  } else if (e === "range") {
947
950
  const t = this.rows.length, s = this.columns.length;
948
951
  if (t > 0 && s > 0) {
949
- const i = {
952
+ const r = {
950
953
  startRow: 0,
951
954
  startCol: 0,
952
955
  endRow: t - 1,
953
956
  endCol: s - 1
954
957
  };
955
- this.ranges = [i], this.activeRange = i, this.emit("selection-change", this.#e()), this.requestAfterRender();
958
+ this.ranges = [r], this.activeRange = r, this.emit("selection-change", this.#e()), this.requestAfterRender();
956
959
  }
957
960
  }
958
961
  }
@@ -990,6 +993,42 @@ class L extends v {
990
993
  getSelectedRowIndices() {
991
994
  return [...this.selected].sort((e, t) => e - t);
992
995
  }
996
+ /**
997
+ * Get the actual row objects for the current selection.
998
+ *
999
+ * Works across all selection modes:
1000
+ * - **Row mode**: Returns the row objects for all selected rows.
1001
+ * - **Cell mode**: Returns the single row containing the selected cell, or `[]`.
1002
+ * - **Range mode**: Returns the unique row objects that intersect any selected range.
1003
+ *
1004
+ * Row objects are resolved from the grid's processed (sorted/filtered) row array,
1005
+ * so they always reflect the current visual order.
1006
+ *
1007
+ * @example
1008
+ * ```ts
1009
+ * const plugin = grid.getPlugin(SelectionPlugin);
1010
+ * const selected = plugin.getSelectedRows(); // [{ id: 1, name: 'Alice' }, ...]
1011
+ * ```
1012
+ */
1013
+ getSelectedRows() {
1014
+ const { mode: e } = this.config, t = this.rows;
1015
+ if (e === "row")
1016
+ return this.getSelectedRowIndices().filter((s) => s >= 0 && s < t.length).map((s) => t[s]);
1017
+ if (e === "cell" && this.selectedCell) {
1018
+ const { row: s } = this.selectedCell;
1019
+ return s >= 0 && s < t.length ? [t[s]] : [];
1020
+ }
1021
+ if (e === "range" && this.ranges.length > 0) {
1022
+ const s = /* @__PURE__ */ new Set();
1023
+ for (const r of this.ranges) {
1024
+ const i = Math.max(0, Math.min(r.startRow, r.endRow)), o = Math.min(t.length - 1, Math.max(r.startRow, r.endRow));
1025
+ for (let l = i; l <= o; l++)
1026
+ s.add(l);
1027
+ }
1028
+ return [...s].sort((r, i) => r - i).map((r) => t[r]);
1029
+ }
1030
+ return [];
1031
+ }
993
1032
  /**
994
1033
  * Clear all selection.
995
1034
  */
@@ -1007,7 +1046,7 @@ class L extends v {
1007
1046
  endCol: t.to.col
1008
1047
  })), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
1009
1048
  mode: this.config.mode,
1010
- ranges: S(this.ranges)
1049
+ ranges: y(this.ranges)
1011
1050
  }), this.requestAfterRender();
1012
1051
  }
1013
1052
  // #endregion