import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { HStack, IconButton, Stack, Text, Textarea } from 'soapbox/components/ui'; const messages = defineMessages({ placeholder: { id: 'chat.input.placeholder', defaultMessage: 'Type a message' }, send: { id: 'chat.actions.send', defaultMessage: 'Send' }, failedToSend: { id: 'chat.failed_to_send', defaultMessage: 'Message failed to send.' }, retry: { id: 'chat.retry', defaultMessage: 'Retry?' }, }); interface IChatComposer extends Pick, 'onKeyDown' | 'onChange' | 'disabled'> { value: string, onSubmit: () => void, hasErrorSubmittingMessage?: boolean, } /** Textarea input for chats. */ const ChatComposer = React.forwardRef(({ onKeyDown, onChange, value, onSubmit, hasErrorSubmittingMessage = false, disabled = false, }, ref) => { const intl = useIntl(); const isSubmitDisabled = disabled || value.length === 0; return (