UNPKG

@ibm-watson/assistant-web-chat-react

Version:
49 lines (48 loc) 2.35 kB
/** * (C) Copyright IBM Corp. 2022. * * Licensed under the MIT License (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * https://opensource.org/licenses/MIT * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * */ import React from 'react'; import { WebChatContainerProps } from './WebChatContainer'; import { WebChatInstance } from './types/WebChatInstance'; interface WebChatCustomElementProps extends WebChatContainerProps { /** * An optional classname that will be added to the custom element. */ className?: string; /** * An optional id that will be added to the custom element. */ id?: string; /** * An optional listener for "view:change" events. Such a listener is required when using a custom element in order * to control the visibility of the web chat main window. If no callback is provided here, a default one will be * used that injects styling into the app that will show and hide the web chat main window and also change the * size of the custom element so it doesn't take up space when the main window is closed. * * You can provide a different callback here if you want custom behavior such as an animation when the main window * is opened or closed. * * Note that this function can only be provided before web chat is loaded. After web chat is loaded, the event * handler will not be updated. */ onViewChange?: (event: any, instance: WebChatInstance) => void; } /** * This component can be used if you want to render web chat inside a custom element. It will perform two functions: * * 1. It will create the custom element as part of the React application. * 2. It will attach web chat to the custom element and use the WebChatContainer component to manage the life cycle * of the web chat instance. */ declare function WebChatCustomElement(props: WebChatCustomElementProps): React.JSX.Element; export { WebChatCustomElement };