import React, { useRef } from 'react'; import { Button } from '../ui/Button'; import { FiPaperclip, FiAlertCircle, FiFile, FiX } from 'react-icons/fi'; import { Alert, AlertDescription } from '../ui/alert'; import { cn } from '../../lib/utils'; /** * Chat input composer with attachments and submit controls. */ export type ChatComposerProps = { value: string; onChange: (v: string) => void; onSubmit: () => void; connected: boolean; submitting: boolean; fileError: string | null; files: File[]; onFileAdd: (files: FileList) => void; onFileRemove: (index: number) => void; }; export function ChatComposer(props: ChatComposerProps) { const { value, onChange, onSubmit, connected, submitting, fileError, files, onFileAdd, onFileRemove, } = props; const fileInputRef = useRef(null); return (
{fileError ? ( {fileError} ) : null} {files.length > 0 ? (
{files.map((file, index) => (
{file.name} {file.size > 1024 * 1024 ? `${(file.size / (1024 * 1024)).toFixed(1)}MB` : `${(file.size / 1024).toFixed(1)}KB`}
))}
) : null}