web-ls-chat
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

web-ls-chat

Web version of react-native-ls-chat

Codacy Badge npm version Node CI Node.js Package

Live sample

Instalation

JS File

ls-chat.min.js

Library

npm i web-ls-chat

or

yarn add web-ls-chat

Usage

// If you are using the library you must import the library otherwise it will be available globally in `window`
import LsChat from 'web-ls-chat'

const options = {
    user: {
        id: '1',
        name: 'User name',
        photo: 'https://user-photo.uri',
    },
    container: document.querySelector('#container'),
    messages: [],
    isLoading: false,
    isFetching: false,
    isTyping: false,
    theme: 'DARK', // 'DARK' or 'LIGHT'
    headerProps: {
        isVisible: true,
        imageSource: 'https://header-image.uri',
        title: 'Chat title',
        onCloseButtonPress: () => { ... },
    onSendMessage: async (message) => {
        return message // must return the message
    },
    onSuccessSendMessage: async (message) => { ... },
    onErrorSendMessage: async (message, error) => { ... },
    onDeleteMessage: async (message) => {
        return message // must return the message
    },
    onSuccessDeleteMessage: (message) => { ... },
    onErrorDeleteMessage: (error) => { ... },
    onReachEndOfMessagesList: async () => { ... }
}

// Create a instance of LsChat
const lsChat = new LsChat(options)


// Methods
lsChat.setTitle('New Title')
lsChat.setMessages(newMessagesArray)
lsChat.setIsLoading(true)
lsChat.setIsFetching(true)
lsChat.setIsTyping(true)
lsChat.destroy()

Readme

Keywords

none

Package Sidebar

Install

npm i web-ls-chat

Weekly Downloads

7

Version

1.0.3

License

MIT

Unpacked Size

77.5 kB

Total Files

48

Last publish

Collaborators

  • leandrosimoes