import { useState, useRef, useEffect } from 'react'; interface ChatInputProps { onSend: (message: string) => void; disabled: boolean; } export function ChatInput({ onSend, disabled }: ChatInputProps) { const [input, setInput] = useState(''); const textareaRef = useRef(null); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (input.trim() && !disabled) { onSend(input.trim()); setInput(''); } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSubmit(e); } }; // Auto-resize textarea useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto'; const scrollHeight = textareaRef.current.scrollHeight; const maxHeight = 5 * 24; // 5 lines * 24px line height textareaRef.current.style.height = `${Math.min(scrollHeight, maxHeight)}px`; } }, [input]); return (