# @salmonui/data-grid/engine/row-drag-drop API reference

> 34 exported symbols of @salmonui/data-grid/engine/row-drag-drop: 6 functions, 9 interfaces, 18 types and 1 constant.

Canonical: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop

```ts
import { … } from '@salmonui/data-grid/engine/row-drag-drop';
```

## Functions

### computeDropPoint

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/computeDropPoint

```ts
function computeDropPoint<Row>(model: RowModelSnapshot<Row>, index: number, fraction: number): DropPoint;
```

Drop point for a pointer at `fraction` (0..1) of the height of visible row
`index`: the upper half of a data row is `before`, the lower half `after`;
a group caption is `into` that group; a detail row is `after` its parent
and a group footer `after` the group's last row. Indexes past the end land
after the last row. O(log) in the row model.

### createRowDragDropModule

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/createRowDragDropModule

```ts
function createRowDragDropModule<Row>(): RowDragDropModule<Row>;
```

Creates the `rowDragDrop` module. Options are read from
`options.rowDragDrop` (`RowDragDropOptions`).

### isPinnedIndex

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/isPinnedIndex

```ts
function isPinnedIndex<Row>(model: RowModelSnapshot<Row>, index: number): boolean;
```

True for a visible index among the pinned rows, which head the
model. Pinned rows are neither drag sources nor drop targets: their place
comes from pinning and the sort, not from the row order.

### resolvePlacement

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/resolvePlacement

```ts
function resolvePlacement<Row>(model: RowModelSnapshot<Row>, point: DropPoint): {
    readonly targetRowId: RowId | null;
    readonly position: 'before' | 'after';
    readonly groupId: RowId | null;
} | null;
```

Data placement of a drop point: a data row id and `before` / `after`; null when the group is empty or unknown.

## Types

### RowDragCancelCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragCancelCommand

```ts
type RowDragCancelCommand = {
    type: 'rowDragDrop.cancel';
};
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.cancel';` |  |  |

### RowDragDropCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragDropCommand

```ts
type RowDragDropCommand = {
    type: 'rowDragDrop.drop';
};
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.drop';` |  |  |

### RowDragEndCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragEndCommand

```ts
type RowDragEndCommand = {
    type: 'rowDragDrop.end';
    dropped?: boolean;
    targetGridId?: string;
};
```

Ends the drag; `dropped: true` with another `targetGridId` removes the rows from this grid.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.end';` |  |  |
| `dropped` | `dropped?: boolean;` | optional |  |
| `targetGridId` | `targetGridId?: string;` | optional |  |

### RowDragLeaveCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragLeaveCommand

```ts
type RowDragLeaveCommand = {
    type: 'rowDragDrop.leave';
};
```

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.leave';` |  |  |

### RowDragMoveByCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragMoveByCommand

```ts
type RowDragMoveByCommand = {
    type: 'rowDragDrop.moveBy';
    rowIds: RowId[];
    offset: number;
};
```

Keyboard reorder: move the rows `offset` data rows up (negative) or down.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.moveBy';` |  |  |
| `rowIds` | `rowIds: RowId[];` |  |  |
| `offset` | `offset: number;` |  |  |

### RowDragMoveCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragMoveCommand

```ts
type RowDragMoveCommand = {
    type: 'rowDragDrop.move';
    rowIds: RowId[];
    targetRowId: RowId | null;
    position: 'before' | 'after' | 'into';
};
```

Programmatic reorder. `into` (tree mode) makes the rows the last children of the target.

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.move';` |  |  |
| `rowIds` | `rowIds: RowId[];` |  |  |
| `targetRowId` | `targetRowId: RowId \| null;` |  |  |
| `position` | `position: 'before' \| 'after' \| 'into';` |  |  |

### RowDragOverCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragOverCommand

```ts
type RowDragOverCommand = {
    type: 'rowDragDrop.over';
    index?: number;
    fraction?: number;
    rowId?: RowId;
    position?: DropPosition;
};
```

Pointer over visible row `index` at `fraction` (0..1) of its height; or an explicit `rowId` + `position`.

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.over';` |  |  |
| `index` | `index?: number;` | optional |  |
| `fraction` | `fraction?: number;` | optional |  |
| `rowId` | `rowId?: RowId;` | optional |  |
| `position` | `position?: DropPosition;` | optional |  |

### RowDragOverExternalCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragOverExternalCommand

```ts
type RowDragOverExternalCommand = {
    type: 'rowDragDrop.overExternal';
    token: string;
    index?: number;
    fraction?: number;
    rowId?: RowId;
    position?: DropPosition;
};
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.overExternal';` |  |  |
| `token` | `token: string;` |  |  |
| `index` | `index?: number;` | optional |  |
| `fraction` | `fraction?: number;` | optional |  |
| `rowId` | `rowId?: RowId;` | optional |  |
| `position` | `position?: DropPosition;` | optional |  |

### RowDragReceiveCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragReceiveCommand

```ts
type RowDragReceiveCommand = {
    type: 'rowDragDrop.receive';
    token: string;
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.receive';` |  |  |
| `token` | `token: string;` |  |  |

### RowDragReorderCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragReorderCommand

```ts
type RowDragReorderCommand = {
    type: 'rowDragDrop.reorder';
    fromIndexes: number[];
    toIndex: number;
};
```

`reorderRows(fromIndexes, toIndex)`: data row indexes of the
current view; the rows are removed and inserted so the first one ends at
data index `toIndex` (clamped).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.reorder';` |  |  |
| `fromIndexes` | `fromIndexes: number[];` |  |  |
| `toIndex` | `toIndex: number;` |  |  |

### RowDragSetEnabledCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragSetEnabledCommand

```ts
type RowDragSetEnabledCommand = {
    type: 'rowDragDrop.setEnabled';
    enabled: boolean;
};
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.setEnabled';` |  |  |
| `enabled` | `enabled: boolean;` |  |  |

### RowDragSetOptionsCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragSetOptionsCommand

```ts
type RowDragSetOptionsCommand = {
    type: 'rowDragDrop.setOptions';
    allowGroupChange?: boolean;
    orderField?: string | null;
};
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.setOptions';` |  |  |
| `allowGroupChange` | `allowGroupChange?: boolean;` | optional |  |
| `orderField` | `orderField?: string \| null;` | optional |  |

### RowDragSettledCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragSettledCommand

```ts
type RowDragSettledCommand = {
    type: 'rowDragDrop.settled';
    id: number;
    status: 'applied' | 'rejected' | 'error';
    reason?: string | null;
};
```

A row move write settled (dispatched by the engine; part of the public command union).

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.settled';` |  |  |
| `id` | `id: number;` |  |  |
| `status` | `status: 'applied' \| 'rejected' \| 'error';` |  |  |
| `reason` | `reason?: string \| null;` | optional |  |

### RowDragStartCommand

Kind: type

Page: https://salmonui.dev/docs/reference/data-grid/engine-row-drag-drop/RowDragStartCommand

```ts
type RowDragStartCommand = {
    type: 'rowDragDrop.start';
    rowId: RowId;
    rowIds?: RowId[];
};
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `type: 'rowDragDrop.start';` |  |  |
| `rowId` | `rowId: RowId;` |  |  |
| `rowIds` | `rowIds?: RowId[];` | optional |  |

## Re-exported entry points

- [@salmonui/data-grid/engine](https://salmonui.dev/docs/reference/data-grid/engine.md): 13 symbols: 9 interfaces and 4 types
  `DropPoint`, `DropPosition`, `DropTarget`, `RowDragCommand`, `RowDragDropMethods`, `RowDragDropModule`, `RowDragDropOptions`, `RowDragDropState`, `RowDragEventInfo`, `RowDragHandoff`, `RowDragPayload`, `RowDragSession`, `RowDropStatus`
- [@salmonui/data-grid/engine/row-drag-state](https://salmonui.dev/docs/reference/data-grid/engine-row-drag-state.md): 3 symbols: 2 functions and 1 constant
  `ROW_DRAG_COMMANDS`, `createInitialRowDragState`, `createRowDragHandoff`
