diff --git a/packages/embeds/js/package.json b/packages/embeds/js/package.json index bd7388ff1..d5bc17c31 100644 --- a/packages/embeds/js/package.json +++ b/packages/embeds/js/package.json @@ -1,6 +1,6 @@ { "name": "@typebot.io/js", - "version": "0.3.2", + "version": "0.3.3", "description": "Javascript library to display typebots on your website", "type": "module", "main": "dist/index.js", diff --git a/packages/embeds/js/src/components/ConversationContainer/ChatChunk.tsx b/packages/embeds/js/src/components/ConversationContainer/ChatChunk.tsx index 7378290b6..9030675c0 100644 --- a/packages/embeds/js/src/components/ConversationContainer/ChatChunk.tsx +++ b/packages/embeds/js/src/components/ConversationContainer/ChatChunk.tsx @@ -1,4 +1,4 @@ -import { BotContext, ChatChunk as ChatChunkType } from '@/types' +import { Answer, BotContext, ChatChunk as ChatChunkType } from '@/types' import { isMobile } from '@/utils/isMobileSignal' import { ContinueChatResponse, Settings, Theme } from '@typebot.io/schemas' import { createSignal, For, onMount, Show } from 'solid-js' @@ -23,7 +23,7 @@ type Props = Pick & { isTransitionDisabled?: boolean onNewBubbleDisplayed: (blockId: string) => Promise onScrollToBottom: (ref?: HTMLDivElement, offset?: number) => void - onSubmit: (input?: string) => void + onSubmit: (answer?: string, attachments?: Answer['attachments']) => void onSkip: () => void onAllBubblesDisplayed: () => void } diff --git a/packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx b/packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx index 7d93de292..2d1346a62 100644 --- a/packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx +++ b/packages/embeds/js/src/components/ConversationContainer/ConversationContainer.tsx @@ -15,7 +15,12 @@ import { } from 'solid-js' import { continueChatQuery } from '@/queries/continueChatQuery' import { ChatChunk } from './ChatChunk' -import { BotContext, ChatChunk as ChatChunkType, OutgoingLog } from '@/types' +import { + Answer, + BotContext, + ChatChunk as ChatChunkType, + OutgoingLog, +} from '@/types' import { isNotDefined } from '@typebot.io/lib' import { executeClientSideAction } from '@/utils/executeClientSideActions' import { LoadingChunk } from './LoadingChunk' @@ -137,7 +142,10 @@ export const ConversationContainer = (props: Props) => { }) } - const sendMessage = async (message: string | undefined) => { + const sendMessage = async ( + message?: string, + attachments?: Answer['attachments'] + ) => { setHasError(false) const currentInputBlock = [...chatChunks()].pop()?.input if (currentInputBlock?.id && props.onAnswer && message) @@ -149,7 +157,13 @@ export const ConversationContainer = (props: Props) => { const { data, error } = await continueChatQuery({ apiHost: props.context.apiHost, sessionId: props.initialChatReply.sessionId, - message, + message: message + ? { + type: 'text', + text: message, + attachedFileUrls: attachments?.map((attachment) => attachment.url), + } + : undefined, }) clearTimeout(longRequest) setIsSending(false) diff --git a/packages/embeds/js/src/components/TextInputAddFileButton.tsx b/packages/embeds/js/src/components/TextInputAddFileButton.tsx index b262fd893..381e82893 100644 --- a/packages/embeds/js/src/components/TextInputAddFileButton.tsx +++ b/packages/embeds/js/src/components/TextInputAddFileButton.tsx @@ -1,6 +1,5 @@ -import { Show } from 'solid-js' +import { Match, Switch } from 'solid-js' import { Menu } from '@ark-ui/solid' -import { CameraIcon } from './icons/CameraIcon' import { FileIcon } from './icons/FileIcon' import { PictureIcon } from './icons/PictureIcon' import { isMobile } from '@/utils/isMobileSignal' @@ -35,69 +34,62 @@ export const TextInputAddFileButton = (props: Props) => { props.onNewFiles(e.currentTarget.files) }} /> - - { - if (!e.currentTarget.files) return - props.onNewFiles(e.currentTarget.files) - }} - /> - - - - - - - - ( - + + + + + + + - ( - - )} - /> - - - - Camera - - - - - + aria-label="Add attachments" + > + + + + + ( + + )} + /> + ( + + )} + /> + + + + + ) } diff --git a/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx b/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx index 3c9bbde52..0b17486ca 100644 --- a/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx +++ b/packages/embeds/js/src/features/blocks/inputs/textInput/components/TextInput.tsx @@ -139,7 +139,10 @@ export const TextInput = (props: Props) => { return (
{ try { diff --git a/packages/embeds/nextjs/package.json b/packages/embeds/nextjs/package.json index 487f96755..42c9d6f61 100644 --- a/packages/embeds/nextjs/package.json +++ b/packages/embeds/nextjs/package.json @@ -1,6 +1,6 @@ { "name": "@typebot.io/nextjs", - "version": "0.3.2", + "version": "0.3.3", "description": "Convenient library to display typebots on your Next.js website", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/embeds/react/package.json b/packages/embeds/react/package.json index ca05d5876..f4d6eb8ce 100644 --- a/packages/embeds/react/package.json +++ b/packages/embeds/react/package.json @@ -1,6 +1,6 @@ { "name": "@typebot.io/react", - "version": "0.3.2", + "version": "0.3.3", "description": "Convenient library to display typebots on your React app", "main": "dist/index.js", "types": "dist/index.d.ts",