UNPKG

@botonic/react

Version:

Build Chatbots using React

112 lines (111 loc) 5.16 kB
import { ServerConfig } from '@botonic/core'; import React from 'react'; import { BlockInputOption, WebchatSettingsProps } from './components'; import { CloseWebviewOptions } from './contexts'; import { ActionRequest, Event, EventArgs, OnStateChangeArgs, OnUserInputArgs, WebchatArgs, WebchatMessage, WebchatRef } from './index-types'; import { CoverComponentOptions, PersistentMenuOptionsTheme, WebchatTheme } from './webchat/theme/types'; export declare class WebchatApp { theme?: Partial<WebchatTheme>; persistentMenu?: PersistentMenuOptionsTheme; coverComponent?: CoverComponentOptions; blockInputs?: BlockInputOption[]; enableEmojiPicker?: boolean; enableAttachments?: boolean; enableUserInput?: boolean; enableAnimations?: boolean; hostId?: string; shadowDOM?: boolean | (() => boolean); defaultDelay?: number; defaultTyping?: number; storage?: Storage | null; storageKey: string; onInit?: (app: WebchatApp, args: any) => void; onOpen?: (app: WebchatApp, args: any) => void; onClose?: (app: WebchatApp, args: any) => void; onMessage?: (app: WebchatApp, message: WebchatMessage) => void; onTrackEvent?: (request: ActionRequest, eventName: string, args?: EventArgs) => Promise<void>; onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void; appId?: string; visibility?: boolean | (() => boolean) | 'dynamic'; server?: ServerConfig; webchatRef: React.RefObject<WebchatRef | null>; private reactRoot; private host; private hubtypeService; constructor({ theme, persistentMenu, coverComponent, blockInputs, enableEmojiPicker, enableAttachments, enableUserInput, enableAnimations, hostId, shadowDOM, defaultDelay, defaultTyping, storage, storageKey, onInit, onOpen, onClose, onMessage, onTrackEvent, onConnectionChange, appId, visibility, server, }: WebchatArgs); createRootElement(host: HTMLElement | null): void; getReactMountNode(node?: (HTMLElement | null) | ShadowRoot): Element | DocumentFragment; onInitWebchat(...args: [any]): void; onOpenWebchat(...args: [any]): void; onCloseWebchat(...args: [any]): void; onUserInput({ user, input }: OnUserInputArgs): Promise<void>; onTrackEventWebchat(request: ActionRequest, eventName: string, args?: EventArgs): Promise<void>; onConnectionRegained(): Promise<void>; onStateChange(args: OnStateChangeArgs): void; onServiceEvent(event: Event): void; updateUser(user: any): void; setSystemLocale(locale: string): void; setUserLocale(locale: string): void; setUserCountry(country: string): void; addBotMessage(message: any): void; addBotText(text: string): void; addUserMessage(message: any): void; addUserText(text: string): void; addUserPayload(payload: string): void; setTyping(typing: boolean): void; open(): void; close(): void; closeWebview(options?: CloseWebviewOptions): Promise<void>; toggle(): void; openCoverComponent(): void; closeCoverComponent(): void; renderCustomComponent(_customComponent: any): void; unmountCustomComponent(): void; toggleCoverComponent(): void; getMessages(): { id: string; ack: number; unsentInput: import("@botonic/core").Input; }[] | undefined; clearMessages(): void; getVisibility(): Promise<boolean>; getLastMessageUpdate(): string | undefined; updateMessageInfo(msgId: string, messageInfo: any): void | undefined; updateWebchatSettings(settings: WebchatSettingsProps): void | undefined; createInitialTheme(optionsAtRuntime?: WebchatArgs): WebchatTheme & Partial<WebchatTheme>; createInitialThemeUserInput(theme: WebchatTheme, optionsAtRuntime?: WebchatArgs): { attachments?: { enable?: boolean | undefined; custom?: React.ComponentType<{}> | undefined; } | undefined; blockInputs?: BlockInputOption[] | undefined; box?: { placeholder: string; style?: any; } | undefined; emojiPicker?: { enable?: boolean | undefined; custom?: React.ComponentType<{}> | undefined; } | undefined; menu?: { darkBackground?: boolean | undefined; custom?: React.ComponentType<import("./webchat/theme/types").PersistentMenuOptionsProps> | undefined; } | undefined; menuButton?: { custom?: React.ComponentType<{}> | undefined; } | undefined; persistentMenu?: PersistentMenuOptionsTheme | undefined; sendButton?: { enable?: boolean | undefined; custom?: React.ComponentType<{}> | undefined; } | undefined; enable?: boolean | undefined; style?: any; }; getComponent(host: HTMLDivElement, optionsAtRuntime?: WebchatArgs): import("react/jsx-runtime").JSX.Element; isWebchatVisible(appId: string): Promise<boolean>; isOnline(): boolean | undefined; resolveWebchatVisibility(optionsAtRuntime?: WebchatArgs): Promise<boolean>; destroy(): void; render(dest: HTMLDivElement, optionsAtRuntime?: WebchatArgs): Promise<void>; }