New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@statflo/textkit-widget-sdk-react

Package Overview
Dependencies
Maintainers
5
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@statflo/textkit-widget-sdk-react

React Widget SDK for TextKit

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

TextKit by Statflo

TextKit Widget React SDK

Installation

yarn add @statflo/textkit-widget-sdk-react

TextKit Provider

Begin by importing the provider into your App.tsx file

import { TextKitWidgetProvider } from "@statflo/textkit-widget-sdk-react";
import Widget from "./Widget";

export default function App() {
  return (
    <TextKitWidgetProvider header="My header" footer="My footer">
      <Widget />
    </TextKitWidgetProvider>
  )
}

Available properties

PropertyTypeDefaultDescription
headerstringundefinedInitial header value. Recommended for Standard Widgets.
footerstringundefinedInitial footer value. Recommended for Standard Widgets.
labelstringundefinedRequired for Action widgets that use the Conversation Scope.
scrollOverridebooleanfalseOverride the default scroll implmentation so you can create and manage your own.

TextKit hook

The following hook will give you access to the current widget state along with helpers for performing various functions. When importing this hook ensure it's within a child component of the above Provider.

import { useTextKitWidget } from "@statflo/textkit-widget-sdk-react";

export default function Widget() {
  const { state, setHeader, setFooter } = useTextKitWidget();

  const handleUpdateHeader = () => {
    setHeader("My new header");
  };

  const handleUpdateFooter = () => {
    setFooter("My new footer");
  };

  return (
    <div>
      <p>My Widget Content</p>
      <button onClick={handleUpdateHeader}>Update Header</button>
      <button onClick={handleUpdateFooter}>Update Footer</button>
    </div>
  );
}

Available Properties/Methods

PropertyTypePropertyDescription
stateobjectCurrent widget state please review below for all the available properties.
setFooterfunctionstringUpdate the widget footer. Used for Standard Widgets.
setHeaderfunctionstringUpdate the widget header. Used for Standard Widgets.
setLabelfunctionstringUpdate the widget label. Used for Action Widgets using the Conversation Scope.
setOpenfunctionbooleanOpen or close the widget.
setSizefunctionWidgetViewSizeChange the size of the widget. Used for Standard Widgets. Must be an instance of WidgetViewSize which can be imported. See below.
appendMessagefunctionstringThe text/string you want to append to the message input. Used for Sendable Widets.
replaceMessagefunctionstringThe text/string you want to replace to the message input with. Used for Sendable Widets.
clientwidgetClientAccess to the underlying widget class for low level implementations. Read the Widget SDK Readme for more details.

State Properties

When importing state from useTextKitWidget() these are the available properties.

PropertyTypeDescription
contextobjectWill return the current conversation context.
defaultScrollbooleanWhether you are using the default scrolling functionality or not. Default scrolling will be based on the length of the body and the state of the widget.
isOpenbooleanWhether the widget is opened or not. Used in Standard widgets.
isReadybooleanThe state of the widget. This will be true when TextKit is aware the widget has been registered.
isShownbooleanWhether the widget is shown or not. Used in Sendables and Action widgets.
maxHeightnumberWill return the available maximum height based on the resolution. Great for when creating your own scrolling capabilities.
sizeWidgetViewSizeWill contain one of the enum values from WidgetViewSize. This is for Standard Widgets only.

Widget View Size

import { WidgetViewSize } from "@statflo/textkit-widget-sdk-react";

/**
 * Example function
 * 
 * Available enums
 * 
 * WidgetViewSize.Small
 * WidgetViewSize.Medium
 * WidgetViewSize.Large
 */
setSize(WidgetViewSize.Medium);

Medium & Large Content Wrappers

These helper components listen for the size state changes and will display the correct content based on the current state value.

Example

import { MediumContent, LargeContent } from "@statflo/textkit-widget-sdk-react";

export default function Widget() {
  return (
    <div>
      <MediumContent>
        This content will be visible when Standard widgets are in their default view state. WidgetViewState.Medium.
      </MediumContent>
      <LargeContent>
        This content will be visible when Standard widgets are in their default view state. WidgetViewState.Large.
      </LargeContent>
    </div>
  )
}

FAQs

Package last updated on 03 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc