import { useEffect, useRef, useState } from "react"; import { Button } from "./primitives"; export interface ChatInputProps { onSend: (text: string) => void; sending: boolean; onVoice: () => void; placeholder?: string; } export function ChatInput({ onSend, sending, onVoice, placeholder = "给昔涟发消息…", }: ChatInputProps): React.ReactNode { const [value, setValue] = useState(""); const taRef = useRef(null); // auto-grow the textarea up to a max height useEffect(() => { const el = taRef.current; if (!el) return; el.style.height = "auto"; el.style.height = Math.min(el.scrollHeight, 140) + "px"; }, [value]); const submit = () => { const t = value.trim(); if (!t || sending) return; onSend(t); setValue(""); }; return (