import { Box, chakra, InputGroup } from '@chakra-ui/react'; import { observer } from 'mobx-react-lite'; import React, { useEffect, useRef, useState } from 'react'; import AutoResize from 'react-textarea-autosize'; const AutoResizeTextArea = chakra(AutoResize); interface InputTextAreaProps { inputRef: React.RefObject; value: string; onChange: (value: string) => void; onKeyDown: (e: React.KeyboardEvent) => void; isLoading: boolean; } const InputTextArea: React.FC = observer( ({ inputRef, value, onChange, onKeyDown, isLoading }) => { const [heightConstraint, setHeightConstraint] = useState(10); useEffect(() => { if (value.length > 10) { setHeightConstraint(); } }, [value]); return ( {/* Input Area */} onChange(e.target.value)} onKeyDown={onKeyDown} p={2} pr="8px" pl="17px" bg="rgba(255, 255, 255, 0.15)" color="text.primary" borderRadius="20px" border="none" placeholder="Free my mind..." _placeholder={{ color: 'gray.400' }} _focus={{ outline: 'none', }} disabled={isLoading} minRows={1} maxRows={12} style={{ touchAction: 'none', resize: 'none', overflowY: 'auto', width: '100%', transition: 'height 0.2s ease-in-out', }} /> ); }, ); export default InputTextArea;