'use client'; import { useState, useRef, type KeyboardEvent } from 'react'; interface Props { isDisabled: boolean; onSend: (text: string) => void; } export default function ChatInput({ isDisabled, onSend }: Props) { const [text, setText] = useState(''); const textareaRef = useRef(null); function handleSend() { const trimmed = text.trim(); if (!trimmed || isDisabled) return; onSend(trimmed); setText(''); // Reset height if (textareaRef.current) { textareaRef.current.style.height = 'auto'; } } function handleKeyDown(e: KeyboardEvent) { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); } } function handleInput() { const el = textareaRef.current; if (!el) return; el.style.height = 'auto'; el.style.height = `${Math.min(el.scrollHeight, 160)}px`; } return (