/** @jsxImportSource @emotion/react */ import { useUid } from '@/libs/hooks'; import { ForwardedRef, forwardRef, useCallback, useEffect, useState } from 'react'; import FieldContainer from './container/FieldContainer'; const Textarea = forwardRef((props: EditorType, ref: ForwardedRef) => { const { tab, rows = 1, textCountActive, error, sizes, themes, value, disabled, autoRaise, editorScroll, ...rest } = props; const id = props?.id ?? useUid(); const [isFocused, setIsFocused] = useState(false); const handleFocus = useCallback(() => setIsFocused(true), [isFocused]); const handleBlur = useCallback(() => setIsFocused(false), [isFocused]); // // rasize useEffect(() => { const handleRasie = () => { if (value && value !== '' && ref && 'current' in ref && ref.current) { ref.current.style.height = 'auto'; ref.current.style.height = ref.current.scrollHeight + 'px'; } else if (ref && 'current' in ref && ref.current) { ref.current.style.height = 'auto'; } }; if (autoRaise) handleRasie(); }, [value, ref, autoRaise]); return (