![TextKit by Statflo](https://github.com/statflo/textkit-widget-events/raw/HEAD/./assets/textkit-logo.svg)
TextKit Widget Events
This package defines all the available events within the TextKit platform this package extends the Widget SDK package. We export all the functionality from that package along with our implementation of it.
We also include the necessary iframeResizer.contentWindow.min.js
file needed for external widgets. This will always be included therefore it's not necessary to include or import.
Installation
yarn add @statflo/textkit-widget-events
More Documentation
For more information on widget communication or container intialization you can refer to our Widget SDK Readme
Container Initialization
This function will create the initial Widget State.
Usage
import { createWidgetState, ContainerClient } from '@statflo/textkit-widget-events'
const containerClient = new ContainerClient({ window });
const id = 'widgetId';
containerClient.createWidget(createWidgetState(id));
Widget Initialization
import { WidgetClient } from "@statflo/widget-sdk";
export const client = new WidgetClient({
id: "my widget",
window,
createWidgetState: (id) => ({ id }),
});
Events
Usage
import { EventNames } from '@statflo/textkit-widget-events'
Widget Properties
EventNames.widget.postForwardExample
: This event will forward the event data to other widgets this is for cross widget communication.
EventNames.widget.actionCreationFailed
: This event will alert of error when actions are created.
EventNames.widget.appendTextToMessage
: This event will append text to the message box.
EventNames.widget.replaceTextMessage
: This event will replace the contents of the message box.
Container Events
EventNames.container.activeConversationChanged
: This event will include context data when a conversation changes within TextKit so you can know with whom you are speaking to.
EventNames.container.appContextChanged
: This event will include context data about the app session.
Widget Types
Usage
import { WidgetTypes } from '@statflo/textkit-widget-events'
Enum values
- Standard
- Action
- Timeline
- Sendable
Widget Scopes
Usage
import { WidgetScope } from '@statflo/textkit-widget-events'
Enum values
Widget Tabs
Usage
import { WidgetTabs } from '@statflo/textkit-widget-events';
Enum values
Widget State
Usage
import { WidgetState } from '@statflo/textkit-widget-events'
Enum values
- containerDomain
- footer
- header
- id
- isOpen
- isReady
- isShown
- label
- maxHeight
- size
- type
- url
- widgetDomain
Widget View Sizes
Usage
import { WidgetViewSize } from '@statflo/textkit-widget-events'
Enum values
Debug Log
Usage
import { DebugLogLevel } from '@statflo/textkit-widget-events'
Enm values
Example
import { DebugLogLevel, ContainerClient } from '@statflo/textkit-widget-events';
export const widgetContainerClient = new ContainerClient({
logs: DebugLogLevel.None,
window,
});