import { ReactNode } from 'react'; import { ArrowUpDown, ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react'; import { cn } from '../../lib/utils'; import { EmptyState } from './LinearPrimitives'; // Re-use the AuraUI empty state // --- Types --- export interface Column { key: keyof T | string; // 'tag', 'strain.name', etc. header: string; cell: (row: T) => ReactNode; // Custom renderer sortable?: boolean; className?: string; // e.g. 'text-right', 'w-24' hideOnMobile?: boolean; } interface DataTableProps { data: T[]; columns: Column[]; onRowClick?: (row: T) => void; isLoading?: boolean; emptyState?: ReactNode; // Custom empty state or default } // --- Component --- export function DataTable({ data, columns, onRowClick, isLoading, emptyState, }: DataTableProps) { if (isLoading) { return (
{/* Skeleton Header */}
{Array.from({ length: 5 }).map((_, i) => (
))}
); } if (data.length === 0) { if (emptyState) return <>{emptyState}; return (

No records found

); } return (
{/* Header */} {columns.map((col, idx) => ( ))} {/* Body */} {data.map((row) => ( onRowClick && onRowClick(row)} className={cn( "group transition-colors", onRowClick ? "cursor-pointer hover:bg-slate-50 dark:hover:bg-slate-900/40" : "", "bg-white dark:bg-slate-950" )} > {columns.map((col, idx) => ( ))} ))}
{col.header} {col.sortable && }
{col.cell(row)}
{/* Optional Footer/Pagination area could go here */}
); }