npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@livechat/developer-ui-react

v0.0.156

Published

Typescript library with react components for Text Platform Developer App.

Downloads

1,815

Readme

Text Platform - Developer UI (react)

Typescript library with react components for Text Platform Developer App

mit

📦 Installation

Use the npm or yarn package managers to install the package in your project.

npm install -g @livechat/developer-ui-react
# or
yarn global add @livechat/developer-ui-react

🚀 Usage

App

import { Button, Card } from "@livechat/design-system-react-components";
import type { AppConfig } from "@livechat/developer-sdk";
import { AppProvider, useApp } from "@livechat/developer-ui-react";

// import app config (aka. manifest) from proper location
// it can be downloaded using 'txdev app pull/clone' (@livechat/developer-cli)
import config from "./livechat.config.json";

function Component() {
  const { app } = useApp();

  return (
    <Card>
      <h1>App is now initialized and ready to use.</h1>
      <h2>Account ID: {app.authorization?.data?.account_id}</h2>
      <Button onClick={() => app.features.reports.sendError("4xx")}>
        Send error
      </Button>
    </Card>
  );
}

function Wrapper() {
  return (
    <AppProvider config={config as unknown as AppConfig}>
      <Component />
    </AppProvider>
  );
}

To be able to use useApp hook, Component must be wrapped with AppProvider. It takes config of your app (aka. manifest) and uses it to construct app instance, to run initialization and authorization (if needed) under the hood. If you don't have your app config (aka. manifest) yet, please refer to @livechat/developer-cli to see how use Text Platform Developer CLI to pull/clone your app.

Also, have a look at @livechat/developer-sdk to see how you can use app instance and its built-in features f.e. reporting.

Product widgets (LiveChat and HelpDesk)

import { Button, Card } from "@livechat/design-system-react-components";
import {
  useLiveChatDetails,
  withLiveChatDetails,
  LiveChatDetailsProvider,
} from "@livechat/developer-ui-react";

const Widget = ({ widget, customerProfile }: LiveChatDetailsContext) => (
  <div>
    <h1>LiveChat Chat Details widget</h1>
    <Button onClick={() => widget.putMessage("New message")} />
    <Card title="Customer profile">
      <span>Name: {customerProfile?.name ?? "Loading..."}</span>
    </Card>
  </div>
);

const WidgetContainer = () => (
  <LiveChatDetailsProvider>
    {(context) => <Widget {...context} />}
  </LiveChatDetailsProvider>
);

// or

const WidgetContainer = () => (
  <LiveChatDetailsProvider>
    <WidgetWrappedWithHook />
    <WidgetWrappedWithHoc />
  </LiveChatDetailsProvider>
);

const WidgetWrappedWithHook = () => {
  const context = useLiveChatDetails();

  return <Widget {...context} />;
};

const WidgetWrappedWithHoc = withLiveChatDetails(Widget);

For now we are supporting widgets:

  • LiveChat
    • Chat Details - LiveChatDetailsProvider and useLiveChatDetails
    • Message Box - LiveChatMessageBoxProvider and useLiveChatMessageBox
    • Fullscreen - LiveChatFullscreenProvider and useLiveChatFullscreen
  • HelpDesk
    • Ticket Details - HelpDeskDetailsProvider and useHelpDeskDetails
    • Fullscreen - HelpDeskFullscreenProvider and useHelpDeskFullscreen

📃 License

The code and documentation in this project are released under the MIT License.