'use client' import { MoreHorizontal } from 'lucide-react' import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, cn, } from 'ui' import { DataTableCell } from './DataTableCell' import type { DataTableColumn, EditingCell, RowAction } from './types' interface DataTableRowProps { row: T rowKey: string rowIndex: number columns: DataTableColumn[] isSelected: boolean selectable: boolean onSelect: (key: string, checked: boolean) => void onRowClick?: (row: T) => void onRowDoubleClick?: (row: T) => void rowActions?: RowAction[] editingCell: EditingCell | null onStartEdit: (cell: EditingCell) => void onCommitEdit: (rowKey: string, columnId: string, value: unknown) => void onCancelEdit: () => void editable: boolean compact: boolean } export function DataTableRow>({ row, rowKey, rowIndex, columns, isSelected, selectable, onSelect, onRowClick, onRowDoubleClick, rowActions, editingCell, onStartEdit, onCommitEdit, onCancelEdit, editable, compact, }: DataTableRowProps) { const rowHeight = compact ? 'h-7' : 'h-[35px]' return ( onRowClick(row) : undefined} onDoubleClick={onRowDoubleClick ? () => onRowDoubleClick(row) : undefined} onKeyDown={ onRowClick ? (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault() onRowClick(row) } } : undefined } > {selectable && ( e.stopPropagation()} onKeyDown={(e) => e.stopPropagation()} > onSelect(rowKey, e.target.checked)} aria-label={`Select row ${rowIndex + 1}`} /> )} {columns.map((col) => ( ))} {rowActions && rowActions.length > 0 && ( e.stopPropagation()} onKeyDown={(e) => e.stopPropagation()} >