View as Markdown

API reference: @salmonui/data-grid/engine

SelectionPreviewinterface

import type { SelectionPreview } from '@salmonui/data-grid/engine';

Also exported from @salmonui/data-grid/engine/selection.

interface SelectionPreview {
    readonly scope: 'explicit' | 'allFiltered';
    readonly changes: {
        readonly rows: boolean;
        readonly cells: boolean;
        readonly columns: boolean;
    };
    readonly added: readonly RowId[];
    readonly removed: readonly RowId[];
    readonly selectedRowIds: readonly RowId[];
    readonly excludedRowIds: readonly RowId[];
    readonly cellRanges: readonly CellRange[];
    readonly addedCells: readonly CellKey[];
    readonly removedCells: readonly CellKey[];
    readonly columnIds: readonly ColumnId[];
    readonly addedColumns: readonly ColumnId[];
    readonly removedColumns: readonly ColumnId[];
}

Proposed selection of a command (rows, cells and columns), computed without committing: before-events and controlled renderers. Parts the command leaves alone report the current selection with empty added / removed lists. Large fields are computed on first read; read them synchronously.

SelectionPreview members (12)
NameSignatureDescription
scopereadonly scope: 'explicit' | 'allFiltered';
changesreadonly changes: { readonly rows: boolean; readonly cells: boolean; readonly columns: boolean; };

Which parts of the selection the command changes.

addedreadonly added: readonly RowId[];

Rows that become selected / deselected; computed on first read.

removedreadonly removed: readonly RowId[];
selectedRowIdsreadonly selectedRowIds: readonly RowId[];

Selected ids after the command; materialized on first read (O(selected)). Read synchronously.

excludedRowIdsreadonly excludedRowIds: readonly RowId[];

Excluded ids when the scope is allFiltered.

cellRangesreadonly cellRanges: readonly CellRange[];

Cell ranges after the command.

addedCellsreadonly addedCells: readonly CellKey[];

Cells (data rows, visible columns) that become selected / deselected; O(cells in the old and new ranges) on first read.

removedCellsreadonly removedCells: readonly CellKey[];
columnIdsreadonly columnIds: readonly ColumnId[];

Selected column ids after the command.

addedColumnsreadonly addedColumns: readonly ColumnId[];
removedColumnsreadonly removedColumns: readonly ColumnId[];