import { type DragEvent, type RefObject } from 'react'; import { type ActionIconProps } from '@mantine/core'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, } from '../../types'; import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton'; interface Props extends ActionIconProps { row: MRT_Row; rowRef: RefObject; table: MRT_TableInstance; } export const MRT_TableBodyRowGrabHandle = ({ row, rowRef, table, ...rest }: Props) => { 'use no memo'; const { options: { mantineRowDragHandleProps }, } = table; const actionIconProps = { ...parseFromValuesOrFunc(mantineRowDragHandleProps, { row, table, }), ...rest, }; 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 ( ); };