import React from 'react'; import { HStack, Textarea } from 'soapbox/components/ui'; import { Attachment } from 'soapbox/types/entities'; import ChatPendingUpload from './chat-pending-upload'; import ChatUpload from './chat-upload'; interface IChatTextarea extends React.ComponentProps { attachments?: Attachment[] onDeleteAttachment?: (i: number) => void uploadCount?: number uploadProgress?: number } /** Custom textarea for chats. */ const ChatTextarea: React.FC = ({ attachments, onDeleteAttachment, uploadCount = 0, uploadProgress = 0, ...rest }) => { const isUploading = uploadCount > 0; const handleDeleteAttachment = (i: number) => { return () => { if (onDeleteAttachment) { onDeleteAttachment(i); } }; }; return (
{(!!attachments?.length || isUploading) && ( {attachments?.map((attachment, i) => (
))} {Array.from(Array(uploadCount)).map(() => (
))}
)}