Skip to content

Commit

Permalink
Move custom message input hook types to definition file
Browse files Browse the repository at this point in the history
Signed-off-by: Vini Andrade <vini.andrade.dev@gmail.com>
  • Loading branch information
vini-btc committed Nov 4, 2020
1 parent 258a0f8 commit 316cf29
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/MessageInput/hooks/messageInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -665,6 +665,7 @@ export default function useMessageInputState(props) {
);

const onPaste = useCallback(
/** (event: React.ClipboardEvent) */
(e) => {
(async (event) => {
// TODO: Move this handler to package with ImageDropzone
Expand Down
28 changes: 28 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,34 @@ export interface MessageInputEmojiPickerProps extends MessageInputState {
small?: boolean;
}

interface MessageInputHookProps {
isUploadEnabled: boolean;
maxFilesLeft: number;
// refs
textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>;
emojiPickerRef: React.MutableRefObject<HTMLDivElement | null>;
// 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<Client.ChannelMemberAPIResponse<StreamChatReactUserType>>
| 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 };
}
Expand Down

0 comments on commit 316cf29

Please sign in to comment.