♻️ Re-organize workspace folders
This commit is contained in:
2
packages/embeds/js/src/features/commands/index.ts
Normal file
2
packages/embeds/js/src/features/commands/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './types'
|
||||
export * from './utils'
|
21
packages/embeds/js/src/features/commands/types.ts
Normal file
21
packages/embeds/js/src/features/commands/types.ts
Normal 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>
|
||||
}
|
9
packages/embeds/js/src/features/commands/utils/close.ts
Normal file
9
packages/embeds/js/src/features/commands/utils/close.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { CommandData } from '../types'
|
||||
|
||||
export const close = () => {
|
||||
const message: CommandData = {
|
||||
isFromTypebot: true,
|
||||
command: 'close',
|
||||
}
|
||||
window.postMessage(message)
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { CommandData } from '../types'
|
||||
|
||||
export const hidePreviewMessage = () => {
|
||||
const message: CommandData = {
|
||||
isFromTypebot: true,
|
||||
command: 'hidePreviewMessage',
|
||||
}
|
||||
window.postMessage(message)
|
||||
}
|
6
packages/embeds/js/src/features/commands/utils/index.ts
Normal file
6
packages/embeds/js/src/features/commands/utils/index.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export * from './close'
|
||||
export * from './hidePreviewMessage'
|
||||
export * from './open'
|
||||
export * from './setPrefilledVariables'
|
||||
export * from './showPreviewMessage'
|
||||
export * from './toggle'
|
9
packages/embeds/js/src/features/commands/utils/open.ts
Normal file
9
packages/embeds/js/src/features/commands/utils/open.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { CommandData } from '../types'
|
||||
|
||||
export const open = () => {
|
||||
const message: CommandData = {
|
||||
isFromTypebot: true,
|
||||
command: 'open',
|
||||
}
|
||||
window.postMessage(message)
|
||||
}
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
9
packages/embeds/js/src/features/commands/utils/toggle.ts
Normal file
9
packages/embeds/js/src/features/commands/utils/toggle.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { CommandData } from '../types'
|
||||
|
||||
export const toggle = () => {
|
||||
const message: CommandData = {
|
||||
isFromTypebot: true,
|
||||
command: 'toggle',
|
||||
}
|
||||
window.postMessage(message)
|
||||
}
|
Reference in New Issue
Block a user