import { type DragEvent, type RefObject } from 'react'; import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; import { type MRT_Row, type MRT_TableInstance } from '../types'; interface Props = {}> { row: MRT_Row; rowRef: RefObject; table: MRT_TableInstance; } export const MRT_TableBodyRowGrabHandle = < TData extends Record = {}, >({ row, rowRef, table, }: Props) => { const { options: { mantineRowDragHandleProps }, } = table; const actionIconProps = mantineRowDragHandleProps instanceof Function ? mantineRowDragHandleProps({ row, table }) : mantineRowDragHandleProps; const handleDragStart = (event: DragEvent) => { actionIconProps?.onDragStart?.(event); event.dataTransfer.setDragImage(rowRef.current as HTMLElement, 0, 0); table.setDraggingRow(row as any); }; const handleDragEnd = (event: DragEvent) => { actionIconProps?.onDragEnd?.(event); table.setDraggingRow(null); table.setHoveredRow(null); }; return ( ); };