diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx new file mode 100644 index 000000000..ff93a9f7b --- /dev/null +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/buttonSendWrapper/index.tsx @@ -0,0 +1,52 @@ +import IconComponent from "../../../../../../../components/genericIconComponent"; +import { Case } from "../../../../../../../shared/components/caseComponent"; +import { classNames } from "../../../../../../../utils/utils"; + +const ButtonSendWrapper = ({ + send, + lockChat, + noInput, + saveLoading, + chatValue, +}) => { + return ( + + ); +}; + +export default ButtonSendWrapper; diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx index 8a57fc768..8fe8ba09b 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx @@ -1,21 +1,19 @@ import { useState } from "react"; -import ShortUniqueId from "short-unique-id"; -import IconComponent from "../../../../../components/genericIconComponent"; -import { Textarea } from "../../../../../components/ui/textarea"; import { CHAT_INPUT_PLACEHOLDER, CHAT_INPUT_PLACEHOLDER_SEND, } from "../../../../../constants/constants"; import { uploadFile } from "../../../../../controllers/API"; -import { Case } from "../../../../../shared/components/caseComponent"; import useFlowsManagerStore from "../../../../../stores/flowsManagerStore"; import { FilePreviewType, chatInputType, } from "../../../../../types/components"; -import { classNames } from "../../../../../utils/utils"; import FilePreview from "../filePreviewChat"; +import ButtonSendWrapper from "./components/buttonSendWrapper"; +import TextAreaWrapper from "./components/textAreaWrapper"; import useAutoResizeTextArea from "./hooks/use-auto-resize-text-area"; +import useDragAndDrop from "./hooks/use-drag-and-drop"; import useFocusOnUnlock from "./hooks/use-focus-unlock"; import useUpload from "./hooks/use-upload"; export default function ChatInput({ @@ -29,12 +27,18 @@ export default function ChatInput({ const [repeat, setRepeat] = useState(1); const saveLoading = useFlowsManagerStore((state) => state.saveLoading); const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); - const uid = new ShortUniqueId({ length: 3 }); const [files, setFiles] = useState([]); + const [isDragging, setIsDragging] = useState(false); useFocusOnUnlock(lockChat, inputRef); useAutoResizeTextArea(chatValue, inputRef); - useUpload(uploadFile, currentFlowId, setFiles, uid); + useUpload(uploadFile, currentFlowId, setFiles); + + const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop( + setIsDragging, + setFiles, + currentFlowId, + ); const send = () => { sendMessage({ @@ -44,90 +48,44 @@ export default function ChatInput({ setFiles([]); }; + const checkSendingOk = (event: React.KeyboardEvent) => { + return ( + event.key === "Enter" && + !lockChat && + !saveLoading && + !event.shiftKey && + !event.nativeEvent.isComposing + ); + }; + return (
-