Core row queries & updates
0.2.0: Types and helpers on this page use the React-state contract from the root
comins-tableentry. Neutral/corehas a separate type contract. See the migration guide for imports and cell policies.
Row update functions return the next state. Store that result rather than mutating input arrays or row objects. Changes to the values or order of the row ID array reset row, cell and range selection.
queryCominsRows
Section titled “queryCominsRows”export declare function queryCominsRows<TData>(state: CominsTableState<TData>, predicate?: (row: TData, index: number) => boolean): TData[];Returns a shallow array copy of rows, or filters it using original indexes when predicate is supplied. It does not apply sorting or pagination.
replaceCominsRows
Section titled “replaceCominsRows”export declare function replaceCominsRows<TData>(state: CominsTableState<TData>, rows: readonly TData[]): CominsTableState<TData>;Replaces rows, always clears selection even when IDs are unchanged, and shares the supplied array reference.
addCominsRows
Section titled “addCominsRows”export declare function addCominsRows<TData>(state: CominsTableState<TData>, rows: readonly TData[]): CominsTableState<TData>;Appends rows. It does not generate unique IDs or remove duplicate IDs.
updateCominsRows
Section titled “updateCominsRows”export declare function updateCominsRows<TData>(state: CominsTableState<TData>, updates: ReadonlyArray<CominsRowUpdate<TData>>): CominsTableState<TData>;Applies patches by ID. Object patches shallow-merge; function patches return a complete new row. The last update for an ID wins; unknown IDs are ignored. Selection is preserved when IDs and their order remain unchanged.
deleteCominsRows
Section titled “deleteCominsRows”export declare function deleteCominsRows<TData>(state: CominsTableState<TData>, rowIds: readonly CominsRowId[]): CominsTableState<TData>;Removes rows with the supplied IDs; unknown IDs are ignored.
moveCominsRow
Section titled “moveCominsRow”export declare function moveCominsRow<TData>(state: CominsTableState<TData>, rowId: CominsRowId, targetIndex: number): CominsTableState<TData>;Removes the row and inserts it at targetIndex in the remaining array, clamped to 0…remaining length. An unknown ID returns the original state. Sort rules remain active, so displayed sorted order can differ.
moveCominsRowToGroup
Section titled “moveCominsRowToGroup”export declare function moveCominsRowToGroup<TData>(state: CominsTableState<TData>, options: CominsRowGroupMoveOptions<TData>): CominsTableState<TData>;Changing membership requires setRowGroupId. With targetRowId, the target’s pre-removal index is clamped into the remaining array: a source before the target lands after it, and a source after the target lands before it. Without targetRowId, insertion is after the group’s last row, or at the array end for an empty group. Invalid IDs or a mismatched target group return the original state.
CominsRowUpdate
Section titled “CominsRowUpdate”export type CominsRowUpdate<TData> = { id: CominsRowId; patch: Partial<TData> | ((row: TData) => TData);};| Property | Behavior / default |
|---|---|
id |
ID of the row to update. |
patch |
A shallow Partial patch or a function returning a new row; do not mutate the input row. |
CominsRowGroupMoveOptions
Section titled “CominsRowGroupMoveOptions”export type CominsRowGroupMoveOptions<TData> = { getRowGroupId: (row: TData, dataIndex: number) => CominsRowId; setRowGroupId?: (params: { fromGroupId: CominsRowId; row: TData; rowId: CominsRowId; toGroupId: CominsRowId; }) => TData; sourceRowId: CominsRowId; targetGroupId: CominsRowId; targetRowId?: CominsRowId;};| Property | Behavior / default |
|---|---|
getRowGroupId |
Required group resolver using the row and current data index. |
setRowGroupId |
Required for membership changes; returns a new row from fromGroupId/row/rowId/toGroupId. |
sourceRowId |
Row ID to move. |
targetGroupId |
Destination group ID. |
targetRowId |
Optional positional target row ID; it must belong to targetGroupId. |