'use client' import { ReactNode } from 'react' import { ChevronUp, ChevronDown, ChevronsUpDown } from 'lucide-react' export interface Column { key: string; title: string; render?: (row: T) => ReactNode; sortable?: boolean; width?: string } interface TableProps { columns: Column[]; data: T[]; rowKey: (row: T) => string | number; sortKey?: string; sortOrder?: 'asc' | 'desc'; onSort?: (key: string) => void } export default function Table>({ columns, data, rowKey, sortKey, sortOrder, onSort }: TableProps) { return (
{columns.map(col => ( ))} {data.map(row => {columns.map(col => )})}
col.sortable && onSort?.(col.key)}> {col.title}{col.sortable && (sortKey !== col.key ? : sortOrder === 'asc' ? : )}
{col.render ? col.render(row) : String(row[col.key] ?? '')}
{data.length === 0 &&
暂无数据
}
) }