import { Button, ButtonGroup } from '@heroui/button' import { Pagination } from '@heroui/pagination' import { Spinner } from '@heroui/spinner' import { type Selection, type SortDescriptor, Table, TableBody, TableCell, TableColumn, TableHeader, TableRow } from '@heroui/table' import path from 'path-browserify' import { useState } from 'react' import { BiRename } from 'react-icons/bi' import { FiCopy, FiDownload, FiMove, FiTrash2 } from 'react-icons/fi' import FileIcon from '@/components/file_icon' import type { FileInfo } from '@/controllers/file_manager' interface FileTableProps { files: FileInfo[] currentPath: string loading: boolean sortDescriptor: SortDescriptor onSortChange: (descriptor: SortDescriptor) => void selectedFiles: Selection onSelectionChange: (selected: Selection) => void onDirectoryClick: (dirPath: string) => void onEdit: (filePath: string) => void onPreview: (filePath: string) => void onRenameRequest: (name: string) => void onMoveRequest: (name: string) => void onCopyPath: (fileName: string) => void onDelete: (filePath: string) => void onDownload: (filePath: string) => void } const PAGE_SIZE = 20 export default function FileTable({ files, currentPath, loading, sortDescriptor, onSortChange, selectedFiles, onSelectionChange, onDirectoryClick, onEdit, onPreview, onRenameRequest, onMoveRequest, onCopyPath, onDelete, onDownload }: FileTableProps) { const [page, setPage] = useState(1) const pages = Math.ceil(files.length / PAGE_SIZE) || 1 const start = (page - 1) * PAGE_SIZE const end = start + PAGE_SIZE const displayFiles = files.slice(start, end) return (