import { ReactNode } from 'react';
import { X, FileText, Image, Music, Video } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
interface FileListItemProps {
file: File;
index?: number;
onRemove: () => void;
iconColor?: 'yellow' | 'green' | 'blue' | 'gray';
className?: string;
}
const iconColorMap = {
yellow: 'bg-yellow-100 text-yellow-600',
green: 'bg-green-100 text-green-600',
blue: 'bg-blue-100 text-blue-600',
gray: 'bg-gray-100 text-gray-600',
};
const formatFileSize = (bytes: number): string => {
if (bytes === 0) return '0 Bytes';
const k = 1024;
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
};
const getFileIcon = (file: File): ReactNode => {
const ext = file.name.split('.').pop()?.toLowerCase() || '';
const type = file.type;
if (type.startsWith('image/') || ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].includes(ext)) {
return
{file.name}
{formatFileSize(file.size)}