import type { KeyboardEvent, ReactNode } from 'react'; import { Send, Square, Upload } from 'lucide-react'; import { Textarea } from 'tdesign-react'; import { useRef } from 'react'; interface ChatInputComposerProps { value: string; onChange?: (value: string) => void; onSend?: () => void; onStop?: () => void; onKeyDown?: (event: KeyboardEvent) => void; placeholder?: string; disabled?: boolean; isSending?: boolean; isDarkMode: boolean; trailingActions?: ReactNode; readOnly?: boolean; className?: string; showBorderTop?: boolean; showUpload?: boolean; onUploadFile?: (file: File) => void | Promise; } export default function ChatInputComposer({ value, onChange, onSend, onStop, onKeyDown, placeholder = '输入你的问题...', disabled = false, isSending = false, isDarkMode, trailingActions, readOnly = false, className = '', showBorderTop = false, showUpload = true, onUploadFile, }: ChatInputComposerProps) { const submitEnabled = Boolean(value.trim()) && !disabled && !readOnly && Boolean(onSend); const inputRef = useRef(null); const iconButtonClass = `rounded-lg p-2 transition-colors ${ isDarkMode ? 'text-slate-400 hover:bg-slate-600 hover:text-slate-200' : 'text-gray-500 hover:bg-gray-200 hover:text-gray-700' }`; const handleKeyDown = (val, context) => { if (context?.e?.key === 'Enter') { // 阻止默认的换行行为(如果是 Textarea) context.e.preventDefault(); // 模拟发送请求 onSend() } }; return (