import type { ChatReply, ChoiceInputBlock, DateInputOptions, EmailInputBlock, FileInputBlock, NumberInputBlock, PaymentInputOptions, PhoneNumberInputBlock, RatingInputBlock, RuntimeOptions, TextInputBlock, Theme, UrlInputBlock, } from '@typebot.io/schemas' import { InputBlockType } from '@typebot.io/schemas/features/blocks/inputs/enums' import { GuestBubble } from './bubbles/GuestBubble' import { BotContext, InputSubmitContent } from '@/types' import { TextInput } from '@/features/blocks/inputs/textInput' import { NumberInput } from '@/features/blocks/inputs/number' import { EmailInput } from '@/features/blocks/inputs/email' import { UrlInput } from '@/features/blocks/inputs/url' import { PhoneInput } from '@/features/blocks/inputs/phone' import { DateForm } from '@/features/blocks/inputs/date' import { RatingForm } from '@/features/blocks/inputs/rating' import { FileUploadForm } from '@/features/blocks/inputs/fileUpload' import { createSignal, Switch, Match } from 'solid-js' import { isNotDefined } from '@typebot.io/lib' import { isMobile } from '@/utils/isMobileSignal' import { PaymentForm } from '@/features/blocks/inputs/payment' import { MultipleChoicesForm } from '@/features/blocks/inputs/buttons/components/MultipleChoicesForm' import { Buttons } from '@/features/blocks/inputs/buttons/components/Buttons' type Props = { block: NonNullable hasHostAvatar: boolean guestAvatar?: Theme['chat']['guestAvatar'] inputIndex: number context: BotContext isInputPrefillEnabled: boolean hasError: boolean onSubmit: (answer: string) => void onSkip: () => void } export const InputChatBlock = (props: Props) => { const [answer, setAnswer] = createSignal() const handleSubmit = async ({ label, value }: InputSubmitContent) => { setAnswer(label ?? value) props.onSubmit(value ?? label) } const handleSkip = (label: string) => { setAnswer(label) props.onSkip() } return (
{props.hasHostAvatar && (
)}
) } const Input = (props: { context: BotContext block: NonNullable inputIndex: number isInputPrefillEnabled: boolean onSubmit: (answer: InputSubmitContent) => void onSkip: (label: string) => void }) => { const onSubmit = (answer: InputSubmitContent) => props.onSubmit(answer) const getPrefilledValue = () => props.isInputPrefillEnabled ? props.block.prefilledValue : undefined const submitPaymentSuccess = () => props.onSubmit({ value: (props.block.options as PaymentInputOptions).labels.success ?? 'Success', }) return ( ) }