2
0

♻️ Re-organize workspace folders

This commit is contained in:
Baptiste Arnaud
2023-03-15 08:35:16 +01:00
parent 25c367901f
commit cbc8194f19
987 changed files with 2716 additions and 2770 deletions

View File

@ -0,0 +1,2 @@
export * from './types'
export * from './utils'

View File

@ -0,0 +1,21 @@
import { PreviewMessageParams } from '../bubble/types'
export type CommandData = {
isFromTypebot: boolean
} & (
| {
command: 'open' | 'toggle' | 'close' | 'hidePreviewMessage'
}
| ShowMessageCommandData
| SetPrefilledVariablesCommandData
)
export type ShowMessageCommandData = {
command: 'showPreviewMessage'
message?: Pick<PreviewMessageParams, 'avatarUrl' | 'message'>
}
export type SetPrefilledVariablesCommandData = {
command: 'setPrefilledVariables'
variables: Record<string, string | number | boolean>
}

View File

@ -0,0 +1,9 @@
import { CommandData } from '../types'
export const close = () => {
const message: CommandData = {
isFromTypebot: true,
command: 'close',
}
window.postMessage(message)
}

View File

@ -0,0 +1,9 @@
import { CommandData } from '../types'
export const hidePreviewMessage = () => {
const message: CommandData = {
isFromTypebot: true,
command: 'hidePreviewMessage',
}
window.postMessage(message)
}

View File

@ -0,0 +1,6 @@
export * from './close'
export * from './hidePreviewMessage'
export * from './open'
export * from './setPrefilledVariables'
export * from './showPreviewMessage'
export * from './toggle'

View File

@ -0,0 +1,9 @@
import { CommandData } from '../types'
export const open = () => {
const message: CommandData = {
isFromTypebot: true,
command: 'open',
}
window.postMessage(message)
}

View File

@ -0,0 +1,12 @@
import { CommandData } from '../types'
export const setPrefilledVariables = (
variables: Record<string, string | number | boolean>
) => {
const message: CommandData = {
isFromTypebot: true,
command: 'setPrefilledVariables',
variables,
}
window.postMessage(message)
}

View File

@ -0,0 +1,12 @@
import { CommandData, ShowMessageCommandData } from '../types'
export const showPreviewMessage = (
proactiveMessage?: ShowMessageCommandData['message']
) => {
const message: CommandData = {
isFromTypebot: true,
command: 'showPreviewMessage',
message: proactiveMessage,
}
window.postMessage(message)
}

View File

@ -0,0 +1,9 @@
import { CommandData } from '../types'
export const toggle = () => {
const message: CommandData = {
isFromTypebot: true,
command: 'toggle',
}
window.postMessage(message)
}