UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

21 lines (20 loc) 751 B
import { getNearestRow, getRowIndexFromEl } from "@1771technologies/lytenyte-shared"; import { useDraggable } from "@1771technologies/lytenyte-core/yinternal"; export const makeUseRowDrag = (grid) => { return (params) => { const c = useDraggable({ ...params, getItems: (el) => { const nearestRow = getNearestRow(grid.state.gridId.get(), el); if (!nearestRow) return {}; const rowIndex = getRowIndexFromEl(nearestRow); const row = grid.api.rowByIndex(rowIndex); if (!row) return {}; return params.getDragData({ grid, row }); }, }); return c; }; };