"use client"; import { useRef, type ReactNode } from "react"; import { ChevronRight, FileText, Loader2, Paperclip, Plus, Trash2 } from "lucide-react"; interface DocumentFilePanelProps { title: string; count: number; open: boolean; onOpenChange: (open: boolean) => void; onFilesSelected: (files: File[]) => void; children?: ReactNode; multiple?: boolean; disabled?: boolean; busy?: boolean; addLabel?: string; emptyText?: string; } interface DocumentFileRowProps { name: string; meta?: string; pending?: boolean; error?: string; onRemove?: () => void; disabled?: boolean; } export function DocumentFilePanel({ title, count, open, onOpenChange, onFilesSelected, children, multiple = false, disabled = false, busy = false, addLabel = multiple ? "Добавить файлы" : "Добавить файл", emptyText = multiple ? "Файлов пока нет" : "Файл пока не выбран", }: DocumentFilePanelProps) { const inputRef = useRef(null); return (
{ const files = Array.from(event.currentTarget.files || []); event.currentTarget.value = ""; if (files.length === 0) return; onOpenChange(true); onFilesSelected(files); }} />
{open ? (
{children ?? (

{emptyText}

)}
) : null}
); } export function DocumentFileRow({ name, meta, pending = false, error, onRemove, disabled = false, }: DocumentFileRowProps) { return (
{name} {meta || error ? ( {error || meta} ) : null} {pending ? ( новое ) : null} {onRemove ? ( ) : null}
); }