@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.2.47",
|
"version": "0.2.48",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -19,6 +19,7 @@ import { clsx } from 'clsx'
|
|||||||
import { HTTPError } from 'ky'
|
import { HTTPError } from 'ky'
|
||||||
import { injectFont } from '@/utils/injectFont'
|
import { injectFont } from '@/utils/injectFont'
|
||||||
import { ProgressBar } from './ProgressBar'
|
import { ProgressBar } from './ProgressBar'
|
||||||
|
import { Portal } from 'solid-js/web'
|
||||||
|
|
||||||
export type BotProps = {
|
export type BotProps = {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
@ -28,6 +29,7 @@ export type BotProps = {
|
|||||||
prefilledVariables?: Record<string, unknown>
|
prefilledVariables?: Record<string, unknown>
|
||||||
apiHost?: string
|
apiHost?: string
|
||||||
font?: Font
|
font?: Font
|
||||||
|
progressBarRef?: HTMLDivElement
|
||||||
onNewInputBlock?: (inputBlock: InputBlock) => void
|
onNewInputBlock?: (inputBlock: InputBlock) => void
|
||||||
onAnswer?: (answer: { message: string; blockId: string }) => void
|
onAnswer?: (answer: { message: string; blockId: string }) => void
|
||||||
onInit?: () => void
|
onInit?: () => void
|
||||||
@ -177,6 +179,7 @@ export const Bot = (props: BotProps & { class?: string }) => {
|
|||||||
sessionId: initialChatReply.sessionId,
|
sessionId: initialChatReply.sessionId,
|
||||||
typebot: initialChatReply.typebot,
|
typebot: initialChatReply.typebot,
|
||||||
}}
|
}}
|
||||||
|
progressBarRef={props.progressBarRef}
|
||||||
onNewInputBlock={props.onNewInputBlock}
|
onNewInputBlock={props.onNewInputBlock}
|
||||||
onNewLogs={props.onNewLogs}
|
onNewLogs={props.onNewLogs}
|
||||||
onAnswer={props.onAnswer}
|
onAnswer={props.onAnswer}
|
||||||
@ -192,6 +195,7 @@ type BotContentProps = {
|
|||||||
initialChatReply: InitialChatReply
|
initialChatReply: InitialChatReply
|
||||||
context: BotContext
|
context: BotContext
|
||||||
class?: string
|
class?: string
|
||||||
|
progressBarRef?: HTMLDivElement
|
||||||
onNewInputBlock?: (inputBlock: InputBlock) => void
|
onNewInputBlock?: (inputBlock: InputBlock) => void
|
||||||
onAnswer?: (answer: { message: string; blockId: string }) => void
|
onAnswer?: (answer: { message: string; blockId: string }) => void
|
||||||
onEnd?: () => void
|
onEnd?: () => void
|
||||||
@ -245,7 +249,19 @@ const BotContent = (props: BotContentProps) => {
|
|||||||
props.initialChatReply.typebot.theme.general?.progressBar?.isEnabled
|
props.initialChatReply.typebot.theme.general?.progressBar?.isEnabled
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ProgressBar value={progressValue() as number} />
|
<Show
|
||||||
|
when={
|
||||||
|
props.progressBarRef &&
|
||||||
|
(props.initialChatReply.typebot.theme.general?.progressBar
|
||||||
|
?.position ?? defaultTheme.general.progressBar.position) ===
|
||||||
|
'fixed'
|
||||||
|
}
|
||||||
|
fallback={<ProgressBar value={progressValue() as number} />}
|
||||||
|
>
|
||||||
|
<Portal mount={props.progressBarRef}>
|
||||||
|
<ProgressBar value={progressValue() as number} />
|
||||||
|
</Portal>
|
||||||
|
</Show>
|
||||||
</Show>
|
</Show>
|
||||||
<div class="flex w-full h-full justify-center">
|
<div class="flex w-full h-full justify-center">
|
||||||
<ConversationContainer
|
<ConversationContainer
|
||||||
|
@ -55,6 +55,8 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
setButtonSize(parseButtonSize(bubbleProps.theme?.button?.size ?? 'medium'))
|
setButtonSize(parseButtonSize(bubbleProps.theme?.button?.size ?? 'medium'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let progressBarContainerRef
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
window.addEventListener('message', processIncomingEvent)
|
window.addEventListener('message', processIncomingEvent)
|
||||||
const autoShowDelay = bubbleProps.autoShowDelay
|
const autoShowDelay = bubbleProps.autoShowDelay
|
||||||
@ -164,6 +166,7 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
isBotOpened={isBotOpened()}
|
isBotOpened={isBotOpened()}
|
||||||
buttonSize={buttonSize()}
|
buttonSize={buttonSize()}
|
||||||
/>
|
/>
|
||||||
|
<div ref={progressBarContainerRef} />
|
||||||
<div
|
<div
|
||||||
part="bot"
|
part="bot"
|
||||||
style={{
|
style={{
|
||||||
@ -194,6 +197,7 @@ export const Bubble = (props: BubbleProps) => {
|
|||||||
{...botProps}
|
{...botProps}
|
||||||
prefilledVariables={prefilledVariables()}
|
prefilledVariables={prefilledVariables()}
|
||||||
class="rounded-lg"
|
class="rounded-lg"
|
||||||
|
progressBarRef={progressBarContainerRef}
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Show>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.2.47",
|
"version": "0.2.48",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.2.47",
|
"version": "0.2.48",
|
||||||
"description": "Convenient library to display typebots on your React app",
|
"description": "Convenient library to display typebots on your React app",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
@ -40,7 +40,7 @@ export const defaultTheme = {
|
|||||||
color: '#0042DA',
|
color: '#0042DA',
|
||||||
backgroundColor: '#e0edff',
|
backgroundColor: '#e0edff',
|
||||||
thickness: 4,
|
thickness: 4,
|
||||||
position: 'fixed',
|
position: 'absolute',
|
||||||
placement: 'Top',
|
placement: 'Top',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user