import { useRef, useCallback } from "react"; export default function MessageInput({ onSubmit }) { const textareaRef = useRef(null); const autoResize = useCallback(() => { const el = textareaRef.current; if (!el) return; el.style.height = "auto"; el.style.height = el.scrollHeight + "px"; }, []); const handleKeyDown = (e) => { if (e.key === "Enter" && !e.shiftKey) { e.preventDefault(); handleSubmit(e); } }; const handleSubmit = (e) => { e.preventDefault(); const el = textareaRef.current; const query = el.value.trim(); if (!query) return; onSubmit(query); el.value = ""; el.style.height = "auto"; }; return (
{/* Left scroll edge accent */}