import { Input, Spinner, Tooltip } from "@nextui-org/react";
import { Airplane, ArrowRight, PaperPlaneRight } from "@phosphor-icons/react";
import clsx from "clsx";
interface StreamingAvatarTextInputProps {
label: string;
placeholder: string;
input: string;
onSubmit: () => void;
setInput: (value: string) => void;
endContent?: React.ReactNode;
disabled?: boolean;
loading?: boolean;
}
export default function InteractiveAvatarTextInput({
label,
placeholder,
input,
onSubmit,
setInput,
endContent,
disabled = false,
loading = false,
}: StreamingAvatarTextInputProps) {
function handleSubmit() {
if (input.trim() === "") {
return;
}
onSubmit();
setInput("");
}
return (
{endContent}
{loading ? (
) : (
)}
}
label={label}
placeholder={placeholder}
size="sm"
value={input}
onKeyDown={(e) => {
if (e.key === "Enter") {
handleSubmit();
}
}}
onValueChange={setInput}
isDisabled={disabled}
/>
);
}