import * as React from 'react'; import Textarea from 'react-textarea-autosize'; import { UseChatHelpers } from 'ai/react'; import { useEnterSubmit } from '@/lib/hooks/useEnterSubmit'; import { cn } from '@/lib/utils'; import { Button, buttonVariants } from '@/components/ui/Button'; import { Tooltip, TooltipContent, TooltipTrigger, } from '@/components/ui/Tooltip'; import { IconArrowElbow, IconPlus } from '@/components/ui/Icons'; import { useRouter } from 'next/navigation'; export interface PromptProps extends Pick { onSubmit: (value: string) => void; isLoading: boolean; } export function PromptForm({ onSubmit, input, setInput, isLoading, }: PromptProps) { const { formRef, onKeyDown } = useEnterSubmit(); const inputRef = React.useRef(null); const router = useRouter(); React.useEffect(() => { if (inputRef.current) { inputRef.current.focus(); } }, []); return (
{ e.preventDefault(); if (!input?.trim()) { return; } setInput(''); await onSubmit(input); }} ref={formRef} >
{/* New Chat */}