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", "name": "@typebot.io/js",
"version": "0.0.11", "version": "0.0.12",
"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",

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 styles from '../../../assets/index.css'
import { CommandData } from '../../commands' import { CommandData } from '../../commands'
import { BubbleButton } from './BubbleButton' import { BubbleButton } from './BubbleButton'
@ -52,6 +59,14 @@ export const Bubble = (props: BubbleProps) => {
window.removeEventListener('message', processIncomingEvent) window.removeEventListener('message', processIncomingEvent)
}) })
createEffect(() => {
if (!props.prefilledVariables) return
setPrefilledVariables((existingPrefilledVariables) => ({
...existingPrefilledVariables,
...props.prefilledVariables,
}))
})
const processIncomingEvent = (event: MessageEvent<CommandData>) => { const processIncomingEvent = (event: MessageEvent<CommandData>) => {
const { data } = event const { data } = event
if (!data.isFromTypebot) return if (!data.isFromTypebot) return

View File

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

View File

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