import React, { useCallback } from 'react'; import { useTranslation } from '@/hooks/useI18n.tsx'; import { Mic, Paperclip, Send, X } from 'lucide-react'; import Button from '@/components/ui/Button.tsx'; interface ChatInputProps { inputValue: string; onInputChange: (value: string) => void; onSendMessage: () => void; attachedImage: { previewUrl: string } | null; onClearAttachment: () => void; onFileChange: (e: React.ChangeEvent) => void; fileInputRef: React.RefObject; inputRef: React.RefObject; isListening: boolean; onStartListening: () => void; onStopListening: () => void; isSpeechSupported: boolean; isLoading: boolean; } const ChatInput = ({ inputValue, onInputChange, onSendMessage, attachedImage, onClearAttachment, onFileChange, fileInputRef, inputRef, isListening, onStartListening, onStopListening, isSpeechSupported, isLoading, }: ChatInputProps) => { const { t } = useTranslation(); const handleSubmit = useCallback( (e: React.FormEvent) => { e.preventDefault(); onSendMessage(); }, [onSendMessage] ); return (
{attachedImage && (
Preview
)}
onInputChange(e.target.value)} placeholder={t('chatbot.placeholder')} className="w-full h-10 rounded-md border bg-muted pl-4 pr-10 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" disabled={isLoading} />
{isSpeechSupported && ( )}
); }; export default React.memo(ChatInput);