import {useSortable} from '@dnd-kit/sortable'; import {Row, flexRender} from '@tanstack/react-table'; import classNames from 'classnames'; import {CSSProperties, FC, ReactNode} from 'react'; type Props = { highlight?: boolean, enableDnd?: boolean, preview?: boolean, row: Row>, renderSubComponent?: (row: Row>) => ReactNode; enableEllipsis?: boolean; }; const BodyTr: FC = function({ row, highlight, enableDnd, preview, renderSubComponent, enableEllipsis, }) { const trList = row.getVisibleCells(); const {setNodeRef, listeners, attributes} = useSortable({ id: row.id, disabled: !enableDnd, data: { row, }, }); return ( <> {trList.map(function({ id, column, getContext, }) { const { align, fixed, fixedStyle, ellipsis, } = column.columnDef.meta as { align?: 'left' | 'center' | 'right'; fixed?: 'right' | 'left'; fixedStyle: CSSProperties, ellipsis?: boolean, }; return ( {flexRender( column.columnDef.cell, getContext(), )} ); })} {row.getIsExpanded() && Boolean(renderSubComponent) ? ( {renderSubComponent?.(row)} ) : null} ); }; export default BodyTr;