2
0

🐛 Correctly update prefilled variables

This commit is contained in:
Baptiste Arnaud
2023-02-21 20:34:18 +01:00
parent 541dcd2bb7
commit d8194ff998
4 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/js",
"version": "0.0.11",
"version": "0.0.12",
"description": "Javascript library to display typebots on your website",
"type": "module",
"main": "dist/index.js",

View File

@ -1,4 +1,11 @@
import { createSignal, onMount, Show, splitProps, onCleanup } from 'solid-js'
import {
createSignal,
onMount,
Show,
splitProps,
onCleanup,
createEffect,
} from 'solid-js'
import styles from '../../../assets/index.css'
import { CommandData } from '../../commands'
import { BubbleButton } from './BubbleButton'
@ -52,6 +59,14 @@ export const Bubble = (props: BubbleProps) => {
window.removeEventListener('message', processIncomingEvent)
})
createEffect(() => {
if (!props.prefilledVariables) return
setPrefilledVariables((existingPrefilledVariables) => ({
...existingPrefilledVariables,
...props.prefilledVariables,
}))
})
const processIncomingEvent = (event: MessageEvent<CommandData>) => {
const { data } = event
if (!data.isFromTypebot) return

View File

@ -62,6 +62,14 @@ export const Popup = (props: PopupProps) => {
toggleBot()
})
createEffect(() => {
if (!props.prefilledVariables) return
setPrefilledVariables((existingPrefilledVariables) => ({
...existingPrefilledVariables,
...props.prefilledVariables,
}))
})
const stopPropagation = (event: MouseEvent) => {
event.stopPropagation()
}

View File

@ -1,6 +1,6 @@
{
"name": "@typebot.io/react",
"version": "0.0.11",
"version": "0.0.12",
"description": "React library to display typebots on your website",
"main": "dist/index.js",
"types": "dist/index.d.ts",