import type { IMessage, IRoom } from '@rocket.chat/core-typings'; import { MessageComposerAction, MessageComposerToolbarActions, MessageComposer, MessageComposerToolbar, MessageComposerActionsDivider, MessageComposerToolbarSubmit, MessageComposerButton, } from '@rocket.chat/ui-composer'; import { useTranslation } from '@rocket.chat/ui-contexts'; import type { MouseEvent, ReactNode, RefObject } from 'react'; import MessageBoxActionsToolbar from './MessageBoxActionsToolbar'; import MessageBoxFormattingToolbar from './MessageBoxFormattingToolbar'; import MessageBoxHint from './MessageBoxHint'; import MessageBoxReplies from './MessageBoxReplies'; import type { ComposerAPI } from '../../../../lib/chats/ChatAPI'; import type { FormattingButton } from '../../../../lib/messageBoxFormatting'; import AudioMessageRecorder from '../../../composer/AudioMessageRecorder'; import VideoMessageRecorder from '../../../composer/VideoMessageRecorder'; import ComposerBoxPopup from '../ComposerBoxPopup'; import ComposerBoxPopupPreview from '../ComposerBoxPopupPreview'; import ComposerUserActionIndicator from '../ComposerUserActionIndicator'; import type { useComposerBoxPopup } from '../hooks/useComposerBoxPopup'; type MessageBoxBaseProps = { rid: IRoom['_id']; tmid?: IMessage['_id']; input: ReactNode; hint?: ReactNode; files?: ReactNode; composer?: ComposerAPI; messageComposerRef: RefObject; popup: ReturnType; shouldPopupPreview?: boolean; isEditing: boolean; isRecording: boolean; isRecordingAudio: boolean; isRecordingVideo: boolean; isMicrophoneDenied: boolean; formatters: FormattingButton[]; canSend: boolean; useEmojis?: boolean; sendEnabled: boolean; sendActive: boolean; inlineSize: number; e2eEnabled: boolean; unencryptedMessagesAllowed: boolean; isMobile: boolean; joinPending: boolean; onEmojiClick: (e: MouseEvent) => void; onSend: () => void; onJoin?: () => Promise; closeEditing: (event: MouseEvent) => void; }; const MessageBoxBase = ({ rid, tmid, input, hint, files, composer, messageComposerRef, popup, shouldPopupPreview, isEditing, isRecording, isRecordingAudio, isRecordingVideo, isMicrophoneDenied, formatters, canSend, useEmojis, sendEnabled, sendActive, inlineSize, e2eEnabled, unencryptedMessagesAllowed, isMobile, joinPending, onEmojiClick, onSend, onJoin, closeEditing, }: MessageBoxBaseProps) => { const t = useTranslation(); const variant = inlineSize < 480 ? 'small' : 'large'; return ( <> {composer?.quotedMessages && } {shouldPopupPreview && popup.option && ( )} {/* SlashCommand Preview popup works in a weird way There is only one trigger for all the commands: "/" After that we need to the slashcommand list and check if the command exists and provide the preview if not the query is `suspend` which means the slashcommand is not found or doesn't have a preview */} {popup.option?.preview && ( )} {hint} {isRecordingVideo && } {isRecordingAudio && } {input} {files} {composer && formatters.length > 0 && ( )} {!canSend && ( {t('Join')} )} {canSend && ( <> {isEditing && {t('Cancel')}} )} ); }; export default MessageBoxBase;