Skip to content
Data TableAPI Reference

Transfer functions and result model

comins-table@0.2.2React

Import transferCominsRowBetweenTables and transferCominsGroupBetweenTables from comins-table. These synchronous pure functions return next models without mutating input arrays. The view changes only after applying the result to parent state.

A null result indicates an invalid move or rejected conflict; retain both current states. Apply source and target together on success. Pure functions have no coordinator, canTransfer, or pointer lifecycle, so enforce application permissions before calling them. They emit neither tooltips nor onTransferRejected. Handle exceptions thrown by application resolvers/getters.

data: readonly TData[];

Required parent-owned source row array.

getRowId: (row: TData, dataIndex: number) => CominsRowId;

Required stable row-ID resolver; identity must be preserved after transfer.

tableId: string;

Required distinct ID for source and target.

groups?: readonly TGroup[];

Group definitions required for grouped transfers. Omission denotes a flat endpoint.

getGroupId?: (group: TGroup) => CominsRowId;

Unique group-ID resolver required for grouped endpoints.

getRowGroupId?: (row: TData, dataIndex: number) => CominsRowId;

Row membership resolver required for grouped endpoints.

setRowGroupId?: (params: {
fromGroupId: CominsRowId;
row: TData;
rowId: CominsRowId;
toGroupId: CominsRowId;
}) => TData;

Returns a new row with destination membership. Preserve original objects and business IDs.

source: CominsTableTransferEndpoint<TData, TGroup>;

Required source endpoint.

sourceRowId: CominsRowId;

Required source row ID to move.

target: CominsTableTransferEndpoint<TData, TGroup>;

Required target endpoint. Matching source/target tableId is rejected.

targetRowId?: CominsRowId;

Inserts before the target row. Omission appends for flat data or uses the target group insertion position for grouped data.

targetGroupId?: CominsRowId;

Destination group ID for grouped row moves. Omit for flat data.

resolveConflict?: CominsTableTransferConflictResolver<TData, TGroup>;

Duplicate-ID policy; omitted/undefined means reject.

source: CominsTableTransferEndpoint<TData, TGroup>;

Required grouped source endpoint.

sourceGroupId: CominsRowId;

Required group ID to move with its members. Empty groups can move.

target: CominsTableTransferEndpoint<TData, TGroup>;

Required grouped target endpoint.

targetGroupId?: CominsRowId;

Reference group for before/after. Omission defaults to append.

position?: CominsTableTransferDropPosition;

after/append/before. Defaults to append without targetGroupId, otherwise before.

resolveConflict?: CominsTableTransferConflictResolver<TData, TGroup>;

Handles duplicate group/member IDs. Defaults to reject.

kind: "group" | "row";

Executed transfer kind: row/group.

source: CominsTableTransferNextEndpoint<TData, TGroup>;

Source tableId, next data, and optional groups.

target: CominsTableTransferNextEndpoint<TData, TGroup>;

Target tableId, next data, and optional groups.

details: CominsTableTransferDetails<TData, TGroup>;

Moved IDs, target position, and resolved conflicts. Narrow the detail variant using kind.

export type CominsTableTransferRowEndpoint<TData> = {
dataIndex: number;
row: TData;
rowId: CominsRowId;
tableId: string;
};

Row location in conflict payloads. dataIndex is the position in its original array; row/rowId/tableId identify the data.

export type CominsTableTransferGroupEndpoint<TData, TGroup> = {
group: TGroup;
groupId: CominsRowId;
groupIndex: number;
rows: readonly CominsTableTransferRowEndpoint<TData>[];
tableId: string;
};

Group location in conflict payloads. groupIndex is its groups position; rows are member endpoints.

export type CominsTableTransferResolvedConflict<TData, TGroup> = {
conflict: CominsTableTransferConflict<TData, TGroup>;
policy: CominsTableTransferConflictPolicy;
};

Pair of a conflict and the chosen reject/overwrite policy.

export type CominsTableRowTransferDetails<TData, TGroup> = {
conflicts: readonly CominsTableTransferResolvedConflict<TData, TGroup>[];
kind: "row";
sourceRowId: CominsRowId;
targetGroupId?: CominsRowId;
targetRowId?: CominsRowId;
};

Row transfer identifiers and resolved conflicts. Target row/group may be absent.

export type CominsTableGroupTransferDetails<TData, TGroup> = {
conflicts: readonly CominsTableTransferResolvedConflict<TData, TGroup>[];
kind: "group";
position: CominsTableTransferDropPosition;
sourceGroupId: CominsRowId;
targetGroupId?: CominsRowId;
};

Group identifiers, position, and conflicts. targetGroupId may be absent for append.

export declare function transferCominsRowBetweenTables<TData, TGroup = never>(input: CominsRowBetweenTablesInput<TData, TGroup>): CominsTableTransferResult<TData, TGroup> | null;

Takes CominsRowBetweenTablesInput above. Returns both next models on success, null on rejection.

export declare function transferCominsGroupBetweenTables<TData, TGroup>(input: CominsGroupBetweenTablesInput<TData, TGroup>): CominsTableTransferResult<TData, TGroup> | null;

Takes CominsGroupBetweenTablesInput above. Transfers the group and all members together; returns null on rejection.