import { IconArrowUp } from "@tabler/icons-react" import type { KeyboardEvent } from "react" import { useTranslation } from "react-i18next" import TextareaAutosize from "react-textarea-autosize" import { Button } from "@/components/ui/button" import { cn } from "@/lib/utils" interface ChatComposerProps { input: string onInputChange: (value: string) => void onSend: () => void isConnected: boolean hasDefaultModel: boolean } export function ChatComposer({ input, onInputChange, onSend, isConnected, hasDefaultModel, }: ChatComposerProps) { const { t } = useTranslation() const canInput = isConnected && hasDefaultModel const handleKeyDown = (e: KeyboardEvent) => { if (e.nativeEvent.isComposing) return if (e.key === "Enter" && !e.shiftKey) { e.preventDefault() onSend() } } return (
onInputChange(e.target.value)} onKeyDown={handleKeyDown} placeholder={t("chat.placeholder")} disabled={!canInput} className={cn( "placeholder:text-muted-foreground max-h-[200px] min-h-[60px] resize-none border-0 bg-transparent px-2 py-1 text-[15px] shadow-none transition-colors focus-visible:ring-0 focus-visible:outline-none dark:bg-transparent", !canInput && "cursor-not-allowed", )} minRows={1} maxRows={8} />
{/* action buttons */}
) }