'use client' import Link from '../../../embed-shims/next-link' import React from 'react' import { cn } from '../../../utils/cn' import { Checkbox } from '../checkbox' import { TableCell } from './table-cell' import { COMPACT_ROW_MIN_HEIGHT, ROW_HEIGHT_DESKTOP } from './table-skeleton' import type { TableRowProps } from './types' import { getHideClasses } from './utils' /** @deprecated Use `DataTableRow` from `data-table` instead. */ export function TableRow({ item, columns, onClick, href, className, index, compact, selectable, selected, onSelect, animateRowReorder, motionDiv }: TableRowProps) { const isLinkMode = Boolean(href) && !onClick // Opt-in FLIP: the outer row becomes a `motion.div` (passed down lazily from // Table, so framer-motion stays out of the default bundle) that animates only // its position (`layout="position"`) so reordering doesn't distort inner cell // content (CircularProgress / ProgressBar). Plain `
` when off, or until // framer-motion has loaded — zero cost on the default path. const animate = Boolean(animateRowReorder && motionDiv) const Row: any = animate ? motionDiv : 'div' const motionProps = animate ? { layout: 'position' as const, transition: { layout: { duration: 0.35, ease: [0.22, 1, 0.36, 1] as const } } } : {} const handleRowClick = (e: React.MouseEvent) => { const target = e.target as HTMLElement if (target.closest('[data-no-row-click]')) { return } if (onClick) { onClick(item) } } const handleSelect = () => { if (onSelect) { onSelect(item) } } const getCellValue = (column: typeof columns[0]): React.ReactNode => { if (column.renderCell) { return column.renderCell(item, column) } // Access nested properties using dot notation const keys = column.key.split('.') let value: any = item for (const key of keys) { value = value?.[key] } if (value === null || value === undefined) { return '-' } if (typeof value === 'boolean') { return value ? 'Yes' : 'No' } if (typeof value === 'object') { return JSON.stringify(value) } return String(value) } return ( {isLinkMode && href && ( )}
{/* Selection checkbox */} {selectable && (
)} {columns.map((column) => ( {getCellValue(column)} ))}
) }