diff --git a/src/components/MessageInput/hooks/messageInput.js b/src/components/MessageInput/hooks/messageInput.js index 953e98a3b..b6adb658e 100644 --- a/src/components/MessageInput/hooks/messageInput.js +++ b/src/components/MessageInput/hooks/messageInput.js @@ -208,7 +208,7 @@ function messageInputReducer(state, action) { } /** * hook for MessageInput state - * @param {Props} props + * @type{import('types').useMessageInput} */ export default function useMessageInputState(props) { const { @@ -665,6 +665,7 @@ export default function useMessageInputState(props) { ); const onPaste = useCallback( + /** (e: React.ClipboardEvent) */ (e) => { (async (event) => { // TODO: Move this handler to package with ImageDropzone diff --git a/types/index.d.ts b/types/index.d.ts index c144e795a..b663b0b8f 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -711,6 +711,34 @@ export interface MessageInputEmojiPickerProps extends MessageInputState { small?: boolean; } +interface MessageInputHookProps { + isUploadEnabled: boolean; + maxFilesLeft: number; + // refs + textareaRef: React.MutableRefObject; + emojiPickerRef: React.MutableRefObject; + // handlers + uploadNewFiles(files: FileList): void; + removeImage(id: string): void; + uploadImage(id: string): void; + removeFile(id: string): void; + uploadFile(id: string): void; + onSelectEmoji(emoji: { native: string }): void; + getUsers(): ( + | ImmutableObject> + | undefined + )[]; + getCommands(): Client.CommandResponse[] | undefined; + handleSubmit(event: React.FormEvent | React.MouseEvent): void; + handleChange(event: React.ChangeEventHandler): void; + onPaste(event: React.ClipboardEvent): void; + onSelectItem(item: Client.UserResponse): void; + openEmojiPicker(): void; +} +export function useMessageInput( + props: MessageInputProps, +): MessageInputState & MessageInputHookProps; + export interface FileAttachmentProps { attachment: Client.Attachment & { asset_url?: string }; }