@botonic/react 0.23.0 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/botonic-tester.js +2 -2
- package/lib/cjs/botonic-tester.js.map +1 -1
- package/lib/cjs/components/audio.js +2 -2
- package/lib/cjs/components/audio.js.map +1 -1
- package/lib/cjs/components/button.js +2 -2
- package/lib/cjs/components/button.js.map +1 -1
- package/lib/cjs/components/carousel.js +3 -3
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/custom-message.js +1 -1
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/components/document.js +2 -2
- package/lib/cjs/components/document.js.map +1 -1
- package/lib/cjs/components/handoff.js +2 -2
- package/lib/cjs/components/handoff.js.map +1 -1
- package/lib/cjs/components/image.js +4 -2
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +8 -1
- package/lib/cjs/components/index-types.js.map +1 -1
- package/lib/cjs/components/location.js +2 -2
- package/lib/cjs/components/location.js.map +1 -1
- package/lib/cjs/components/message-template.js +1 -1
- package/lib/cjs/components/message-template.js.map +1 -1
- package/lib/cjs/components/message.js +3 -3
- package/lib/cjs/components/message.js.map +1 -1
- package/lib/cjs/components/multichannel/index-types.d.ts +1 -0
- package/lib/cjs/components/multichannel/multichannel-carousel.js +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +43 -19
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.d.ts +6 -4
- package/lib/cjs/components/multichannel/multichannel-utils.js +3 -1
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +2 -2
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/components/raw.js +2 -2
- package/lib/cjs/components/raw.js.map +1 -1
- package/lib/cjs/components/reply.js +4 -4
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/share-button.js +1 -1
- package/lib/cjs/components/share-button.js.map +1 -1
- package/lib/cjs/components/subtitle.js +1 -1
- package/lib/cjs/components/subtitle.js.map +1 -1
- package/lib/cjs/components/text.js +2 -2
- package/lib/cjs/components/text.js.map +1 -1
- package/lib/cjs/components/timestamps.js +1 -1
- package/lib/cjs/components/timestamps.js.map +1 -1
- package/lib/cjs/components/title.js +1 -1
- package/lib/cjs/components/title.js.map +1 -1
- package/lib/cjs/components/video.js +2 -2
- package/lib/cjs/components/video.js.map +1 -1
- package/lib/cjs/components/webchat-settings.d.ts +3 -10
- package/lib/cjs/components/webchat-settings.js +9 -14
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/components/whatsapp-button-list.d.ts +1 -1
- package/lib/cjs/components/whatsapp-button-list.js +1 -1
- package/lib/cjs/components/whatsapp-button-list.js.map +1 -1
- package/lib/cjs/components/whatsapp-template.js +1 -1
- package/lib/cjs/components/whatsapp-template.js.map +1 -1
- package/lib/cjs/constants.d.ts +148 -148
- package/lib/cjs/contexts.d.ts +4 -62
- package/lib/cjs/contexts.js +45 -19
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/index-types.d.ts +12 -12
- package/lib/cjs/msg-to-botonic.js +2 -2
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/react-bot.js +1 -1
- package/lib/cjs/react-bot.js.map +1 -1
- package/lib/cjs/util/environment.js +1 -1
- package/lib/cjs/util/environment.js.map +1 -1
- package/lib/cjs/webchat/actions.d.ts +25 -23
- package/lib/cjs/webchat/actions.js +27 -24
- package/lib/cjs/webchat/actions.js.map +1 -1
- package/lib/cjs/webchat/components/attachment.js +1 -1
- package/lib/cjs/webchat/components/attachment.js.map +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/emoji-picker.js +2 -2
- package/lib/cjs/webchat/components/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/components/persistent-menu.js +4 -4
- package/lib/cjs/webchat/components/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/components/send-button.js +1 -1
- package/lib/cjs/webchat/components/send-button.js.map +1 -1
- package/lib/cjs/webchat/components/typing-indicator.js +1 -1
- package/lib/cjs/webchat/components/typing-indicator.js.map +1 -1
- package/lib/cjs/webchat/header.js +1 -1
- package/lib/cjs/webchat/header.js.map +1 -1
- package/lib/cjs/webchat/hooks/index.d.ts +5 -0
- package/lib/cjs/webchat/hooks/index.js +15 -0
- package/lib/cjs/webchat/hooks/index.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-component-visible.d.ts +8 -0
- package/lib/cjs/webchat/hooks/use-component-visible.js +24 -0
- package/lib/cjs/webchat/hooks/use-component-visible.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-component-will-mount.d.ts +1 -0
- package/lib/cjs/webchat/hooks/use-component-will-mount.js +9 -0
- package/lib/cjs/webchat/hooks/use-component-will-mount.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-previous.d.ts +1 -0
- package/lib/cjs/webchat/hooks/use-previous.js +13 -0
- package/lib/cjs/webchat/hooks/use-previous.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-typing.d.ts +10 -0
- package/lib/cjs/webchat/hooks/use-typing.js +32 -0
- package/lib/cjs/webchat/hooks/use-typing.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-webchat.d.ts +37 -0
- package/lib/cjs/webchat/hooks/use-webchat.js +167 -0
- package/lib/cjs/webchat/hooks/use-webchat.js.map +1 -0
- package/lib/cjs/webchat/index-types.d.ts +16 -10
- package/lib/cjs/webchat/message-list.js +2 -2
- package/lib/cjs/webchat/message-list.js.map +1 -1
- package/lib/cjs/webchat/messages-reducer.d.ts +6 -1
- package/lib/cjs/webchat/messages-reducer.js +8 -8
- package/lib/cjs/webchat/messages-reducer.js.map +1 -1
- package/lib/cjs/webchat/replies.js +1 -1
- package/lib/cjs/webchat/replies.js.map +1 -1
- package/lib/cjs/webchat/session-view.js +2 -2
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/index.js +1 -3
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/cjs/webchat/webchat-reducer.d.ts +6 -1
- package/lib/cjs/webchat/webchat-reducer.js +17 -17
- package/lib/cjs/webchat/webchat-reducer.js.map +1 -1
- package/lib/cjs/webchat/webchat.js +24 -22
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.js +4 -4
- package/lib/cjs/webchat/webview.js.map +1 -1
- package/lib/cjs/webview-app.js +1 -1
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/botonic-tester.js +2 -2
- package/lib/esm/botonic-tester.js.map +1 -1
- package/lib/esm/components/audio.js +2 -2
- package/lib/esm/components/audio.js.map +1 -1
- package/lib/esm/components/button.js +2 -2
- package/lib/esm/components/button.js.map +1 -1
- package/lib/esm/components/carousel.js +3 -3
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/custom-message.js +1 -1
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/components/document.js +2 -2
- package/lib/esm/components/document.js.map +1 -1
- package/lib/esm/components/handoff.js +2 -2
- package/lib/esm/components/handoff.js.map +1 -1
- package/lib/esm/components/image.js +4 -2
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +8 -1
- package/lib/esm/components/index-types.js.map +1 -1
- package/lib/esm/components/location.js +2 -2
- package/lib/esm/components/location.js.map +1 -1
- package/lib/esm/components/message-template.js +1 -1
- package/lib/esm/components/message-template.js.map +1 -1
- package/lib/esm/components/message.js +3 -3
- package/lib/esm/components/message.js.map +1 -1
- package/lib/esm/components/multichannel/index-types.d.ts +1 -0
- package/lib/esm/components/multichannel/multichannel-carousel.js +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +45 -21
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.d.ts +6 -4
- package/lib/esm/components/multichannel/multichannel-utils.js +2 -0
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +2 -2
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/components/raw.js +2 -2
- package/lib/esm/components/raw.js.map +1 -1
- package/lib/esm/components/reply.js +4 -4
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/share-button.js +1 -1
- package/lib/esm/components/share-button.js.map +1 -1
- package/lib/esm/components/subtitle.js +1 -1
- package/lib/esm/components/subtitle.js.map +1 -1
- package/lib/esm/components/text.js +2 -2
- package/lib/esm/components/text.js.map +1 -1
- package/lib/esm/components/timestamps.js +1 -1
- package/lib/esm/components/timestamps.js.map +1 -1
- package/lib/esm/components/title.js +1 -1
- package/lib/esm/components/title.js.map +1 -1
- package/lib/esm/components/video.js +2 -2
- package/lib/esm/components/video.js.map +1 -1
- package/lib/esm/components/webchat-settings.d.ts +3 -10
- package/lib/esm/components/webchat-settings.js +9 -13
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/components/whatsapp-button-list.d.ts +1 -1
- package/lib/esm/components/whatsapp-button-list.js +1 -1
- package/lib/esm/components/whatsapp-button-list.js.map +1 -1
- package/lib/esm/components/whatsapp-template.js +1 -1
- package/lib/esm/components/whatsapp-template.js.map +1 -1
- package/lib/esm/constants.d.ts +148 -148
- package/lib/esm/contexts.d.ts +4 -62
- package/lib/esm/contexts.js +45 -19
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/index-types.d.ts +12 -12
- package/lib/esm/msg-to-botonic.js +2 -2
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/react-bot.js +1 -1
- package/lib/esm/react-bot.js.map +1 -1
- package/lib/esm/util/environment.js +1 -1
- package/lib/esm/util/environment.js.map +1 -1
- package/lib/esm/webchat/actions.d.ts +25 -23
- package/lib/esm/webchat/actions.js +26 -23
- package/lib/esm/webchat/actions.js.map +1 -1
- package/lib/esm/webchat/components/attachment.js +1 -1
- package/lib/esm/webchat/components/attachment.js.map +1 -1
- package/lib/esm/webchat/components/conditional-animation.js +1 -1
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
- package/lib/esm/webchat/components/emoji-picker.js +2 -2
- package/lib/esm/webchat/components/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/components/persistent-menu.js +4 -4
- package/lib/esm/webchat/components/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/components/send-button.js +1 -1
- package/lib/esm/webchat/components/send-button.js.map +1 -1
- package/lib/esm/webchat/components/typing-indicator.js +1 -1
- package/lib/esm/webchat/components/typing-indicator.js.map +1 -1
- package/lib/esm/webchat/header.js +1 -1
- package/lib/esm/webchat/header.js.map +1 -1
- package/lib/esm/webchat/hooks/index.d.ts +5 -0
- package/lib/esm/webchat/hooks/index.js +6 -0
- package/lib/esm/webchat/hooks/index.js.map +1 -0
- package/lib/esm/webchat/hooks/use-component-visible.d.ts +8 -0
- package/lib/esm/webchat/hooks/use-component-visible.js +20 -0
- package/lib/esm/webchat/hooks/use-component-visible.js.map +1 -0
- package/lib/esm/webchat/hooks/use-component-will-mount.d.ts +1 -0
- package/lib/esm/webchat/hooks/use-component-will-mount.js +5 -0
- package/lib/esm/webchat/hooks/use-component-will-mount.js.map +1 -0
- package/lib/esm/webchat/hooks/use-previous.d.ts +1 -0
- package/lib/esm/webchat/hooks/use-previous.js +9 -0
- package/lib/esm/webchat/hooks/use-previous.js.map +1 -0
- package/lib/esm/webchat/hooks/use-typing.d.ts +10 -0
- package/lib/esm/webchat/hooks/use-typing.js +28 -0
- package/lib/esm/webchat/hooks/use-typing.js.map +1 -0
- package/lib/esm/webchat/hooks/use-webchat.d.ts +37 -0
- package/lib/esm/webchat/hooks/use-webchat.js +163 -0
- package/lib/esm/webchat/hooks/use-webchat.js.map +1 -0
- package/lib/esm/webchat/index-types.d.ts +16 -10
- package/lib/esm/webchat/message-list.js +2 -2
- package/lib/esm/webchat/message-list.js.map +1 -1
- package/lib/esm/webchat/messages-reducer.d.ts +6 -1
- package/lib/esm/webchat/messages-reducer.js +9 -9
- package/lib/esm/webchat/messages-reducer.js.map +1 -1
- package/lib/esm/webchat/replies.js +1 -1
- package/lib/esm/webchat/replies.js.map +1 -1
- package/lib/esm/webchat/session-view.js +2 -2
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/trigger-button/index.js +1 -3
- package/lib/esm/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/webchat/webchat-reducer.d.ts +6 -1
- package/lib/esm/webchat/webchat-reducer.js +18 -18
- package/lib/esm/webchat/webchat-reducer.js.map +1 -1
- package/lib/esm/webchat/webchat.js +24 -22
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.js +4 -4
- package/lib/esm/webchat/webview.js.map +1 -1
- package/lib/esm/webview-app.js +1 -1
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +2 -2
- package/src/components/image.jsx +3 -1
- package/src/components/index-types.ts +8 -1
- package/src/components/multichannel/index-types.ts +1 -0
- package/src/components/multichannel/multichannel-text.jsx +92 -28
- package/src/components/multichannel/multichannel-utils.js +2 -0
- package/src/components/{webchat-settings.jsx → webchat-settings.tsx} +8 -8
- package/src/components/whatsapp-button-list.tsx +1 -1
- package/src/contexts.tsx +64 -0
- package/src/index-types.ts +12 -12
- package/src/util/environment.js +1 -1
- package/src/webchat/actions.ts +25 -0
- package/src/webchat/hooks/index.ts +5 -0
- package/src/webchat/hooks/use-component-visible.ts +29 -0
- package/src/webchat/hooks/use-component-will-mount.ts +5 -0
- package/src/webchat/hooks/use-previous.ts +9 -0
- package/src/webchat/hooks/use-typing.ts +43 -0
- package/src/webchat/hooks/use-webchat.ts +213 -0
- package/src/webchat/index-types.ts +17 -8
- package/src/webchat/{messages-reducer.js → messages-reducer.ts} +25 -19
- package/src/webchat/trigger-button/index.tsx +0 -1
- package/src/webchat/{webchat-reducer.js → webchat-reducer.ts} +23 -37
- package/src/webchat/webchat.jsx +12 -11
- package/lib/cjs/webchat/hooks.d.ts +0 -81
- package/lib/cjs/webchat/hooks.js +0 -222
- package/lib/cjs/webchat/hooks.js.map +0 -1
- package/lib/esm/webchat/hooks.d.ts +0 -81
- package/lib/esm/webchat/hooks.js +0 -214
- package/lib/esm/webchat/hooks.js.map +0 -1
- package/src/contexts.jsx +0 -37
- package/src/webchat/actions.jsx +0 -23
- package/src/webchat/hooks.js +0 -270
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useComponentVisible } from './use-component-visible'
|
|
2
|
+
export { useComponentWillMount } from './use-component-will-mount'
|
|
3
|
+
export { usePrevious } from './use-previous'
|
|
4
|
+
export { useTyping } from './use-typing'
|
|
5
|
+
export { useWebchat, webchatInitialState } from './use-webchat'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
interface ComponentVisible {
|
|
4
|
+
ref: React.RefObject<HTMLElement>
|
|
5
|
+
isComponentVisible: boolean
|
|
6
|
+
setIsComponentVisible: React.Dispatch<React.SetStateAction<boolean>>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function useComponentVisible(
|
|
10
|
+
initialIsVisible: boolean,
|
|
11
|
+
onClickOutside: () => void
|
|
12
|
+
): ComponentVisible {
|
|
13
|
+
const [isComponentVisible, setIsComponentVisible] = useState(initialIsVisible)
|
|
14
|
+
const ref = useRef<HTMLElement>(null)
|
|
15
|
+
const handleClickOutside = event => {
|
|
16
|
+
const target = event.path ? event.path[0] : event.target
|
|
17
|
+
if (ref.current && !ref.current.contains(target)) {
|
|
18
|
+
setIsComponentVisible(false)
|
|
19
|
+
onClickOutside()
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
document.addEventListener('click', handleClickOutside, false)
|
|
24
|
+
return () => {
|
|
25
|
+
document.removeEventListener('click', handleClickOutside, false)
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
return { ref, isComponentVisible, setIsComponentVisible }
|
|
29
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WebchatMessage } from '../../index-types'
|
|
4
|
+
import { scrollToBottom } from '../../util'
|
|
5
|
+
import { WebchatState } from '../index-types'
|
|
6
|
+
|
|
7
|
+
interface UseTyping {
|
|
8
|
+
webchatState: WebchatState
|
|
9
|
+
updateTyping: (typing: boolean) => void
|
|
10
|
+
updateMessage: (message: WebchatMessage) => void
|
|
11
|
+
host: any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function useTyping({
|
|
15
|
+
webchatState,
|
|
16
|
+
updateTyping,
|
|
17
|
+
updateMessage,
|
|
18
|
+
host,
|
|
19
|
+
}: UseTyping): void {
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let delayTimeout, typingTimeout
|
|
22
|
+
scrollToBottom({ host })
|
|
23
|
+
try {
|
|
24
|
+
const nextMsg = webchatState.messagesJSON.filter(m => !m.display)[0]
|
|
25
|
+
if (nextMsg.delay && nextMsg.typing) {
|
|
26
|
+
delayTimeout = setTimeout(
|
|
27
|
+
() => updateTyping(true),
|
|
28
|
+
nextMsg.delay * 1000
|
|
29
|
+
)
|
|
30
|
+
} else if (nextMsg.typing) updateTyping(true)
|
|
31
|
+
const totalDelay = nextMsg.delay + nextMsg.typing
|
|
32
|
+
if (totalDelay)
|
|
33
|
+
typingTimeout = setTimeout(() => {
|
|
34
|
+
updateMessage({ ...nextMsg, display: true })
|
|
35
|
+
updateTyping(false)
|
|
36
|
+
}, totalDelay * 1000)
|
|
37
|
+
} catch (e) {}
|
|
38
|
+
return () => {
|
|
39
|
+
clearTimeout(delayTimeout)
|
|
40
|
+
clearTimeout(typingTimeout)
|
|
41
|
+
}
|
|
42
|
+
}, [webchatState.messagesJSON, webchatState.typing])
|
|
43
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { Input, Session } from '@botonic/core'
|
|
2
|
+
import { useReducer } from 'react'
|
|
3
|
+
|
|
4
|
+
import { ThemeProps, Webview } from '../../components/index-types'
|
|
5
|
+
import { COLORS, WEBCHAT } from '../../constants'
|
|
6
|
+
import { WebchatMessage } from '../../index-types'
|
|
7
|
+
import { WebchatAction } from '../actions'
|
|
8
|
+
import { DevSettings, ErrorMessage, WebchatState } from '../index-types'
|
|
9
|
+
import { webchatReducer } from '../webchat-reducer'
|
|
10
|
+
|
|
11
|
+
export const webchatInitialState: WebchatState = {
|
|
12
|
+
width: WEBCHAT.DEFAULTS.WIDTH,
|
|
13
|
+
height: WEBCHAT.DEFAULTS.HEIGHT,
|
|
14
|
+
messagesJSON: [],
|
|
15
|
+
messagesComponents: [],
|
|
16
|
+
replies: [],
|
|
17
|
+
latestInput: {},
|
|
18
|
+
typing: false,
|
|
19
|
+
webview: null,
|
|
20
|
+
webviewParams: null,
|
|
21
|
+
session: { user: undefined },
|
|
22
|
+
lastRoutePath: null,
|
|
23
|
+
handoff: false,
|
|
24
|
+
theme: {
|
|
25
|
+
headerTitle: WEBCHAT.DEFAULTS.TITLE,
|
|
26
|
+
brandColor: COLORS.BOTONIC_BLUE,
|
|
27
|
+
brandImage: WEBCHAT.DEFAULTS.LOGO,
|
|
28
|
+
triggerButtonImage: undefined,
|
|
29
|
+
textPlaceholder: WEBCHAT.DEFAULTS.PLACEHOLDER,
|
|
30
|
+
style: {
|
|
31
|
+
fontFamily: WEBCHAT.DEFAULTS.FONT_FAMILY,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
themeUpdates: {},
|
|
35
|
+
error: {},
|
|
36
|
+
online: true,
|
|
37
|
+
devSettings: { keepSessionOnReload: false },
|
|
38
|
+
isWebchatOpen: false,
|
|
39
|
+
isEmojiPickerOpen: false,
|
|
40
|
+
isPersistentMenuOpen: false,
|
|
41
|
+
isCoverComponentOpen: false,
|
|
42
|
+
isCustomComponentRendered: false,
|
|
43
|
+
lastMessageUpdate: undefined,
|
|
44
|
+
currentAttachment: undefined,
|
|
45
|
+
jwt: undefined,
|
|
46
|
+
unreadMessages: 0,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function useWebchat() {
|
|
50
|
+
const [webchatState, webchatDispatch] = useReducer(
|
|
51
|
+
webchatReducer,
|
|
52
|
+
webchatInitialState
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
const addMessage = (message: WebchatMessage) =>
|
|
56
|
+
webchatDispatch({ type: WebchatAction.ADD_MESSAGE, payload: message })
|
|
57
|
+
|
|
58
|
+
const addMessageComponent = (message: WebchatMessage) =>
|
|
59
|
+
webchatDispatch({
|
|
60
|
+
type: WebchatAction.ADD_MESSAGE_COMPONENT,
|
|
61
|
+
payload: message,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const updateMessage = (message: WebchatMessage) =>
|
|
65
|
+
webchatDispatch({ type: WebchatAction.UPDATE_MESSAGE, payload: message })
|
|
66
|
+
|
|
67
|
+
const updateReplies = replies =>
|
|
68
|
+
webchatDispatch({ type: WebchatAction.UPDATE_REPLIES, payload: replies })
|
|
69
|
+
|
|
70
|
+
const updateLatestInput = (input: Input) =>
|
|
71
|
+
webchatDispatch({ type: WebchatAction.UPDATE_LATEST_INPUT, payload: input })
|
|
72
|
+
|
|
73
|
+
const updateTyping = (typing: boolean) =>
|
|
74
|
+
webchatDispatch({ type: WebchatAction.UPDATE_TYPING, payload: typing })
|
|
75
|
+
|
|
76
|
+
const updateWebview = (webview: Webview, params: Record<string, string>) =>
|
|
77
|
+
webchatDispatch({
|
|
78
|
+
type: WebchatAction.UPDATE_WEBVIEW,
|
|
79
|
+
payload: { webview, webviewParams: params },
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const updateSession = (session: Session) => {
|
|
83
|
+
webchatDispatch({
|
|
84
|
+
type: WebchatAction.UPDATE_SESSION,
|
|
85
|
+
payload: session,
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const updateLastRoutePath = (path: string) =>
|
|
90
|
+
webchatDispatch({
|
|
91
|
+
type: WebchatAction.UPDATE_LAST_ROUTE_PATH,
|
|
92
|
+
payload: path,
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const updateHandoff = (handoff: boolean) =>
|
|
96
|
+
webchatDispatch({
|
|
97
|
+
type: WebchatAction.UPDATE_HANDOFF,
|
|
98
|
+
payload: handoff,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const updateTheme = (theme: ThemeProps, themeUpdates?: ThemeProps) => {
|
|
102
|
+
const payload =
|
|
103
|
+
themeUpdates !== undefined ? { theme, themeUpdates } : { theme }
|
|
104
|
+
webchatDispatch({
|
|
105
|
+
type: WebchatAction.UPDATE_THEME,
|
|
106
|
+
payload,
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const updateDevSettings = (settings: DevSettings) =>
|
|
111
|
+
webchatDispatch({
|
|
112
|
+
type: WebchatAction.UPDATE_DEV_SETTINGS,
|
|
113
|
+
payload: settings,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const toggleWebchat = (toggle: boolean) => {
|
|
117
|
+
webchatDispatch({
|
|
118
|
+
type: WebchatAction.TOGGLE_WEBCHAT,
|
|
119
|
+
payload: toggle,
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const toggleEmojiPicker = (toggle: boolean) =>
|
|
124
|
+
webchatDispatch({
|
|
125
|
+
type: WebchatAction.TOGGLE_EMOJI_PICKER,
|
|
126
|
+
payload: toggle,
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const togglePersistentMenu = (toggle: boolean) =>
|
|
130
|
+
webchatDispatch({
|
|
131
|
+
type: WebchatAction.TOGGLE_PERSISTENT_MENU,
|
|
132
|
+
payload: toggle,
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const toggleCoverComponent = (toggle: boolean) =>
|
|
136
|
+
webchatDispatch({
|
|
137
|
+
type: WebchatAction.TOGGLE_COVER_COMPONENT,
|
|
138
|
+
payload: toggle,
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
const doRenderCustomComponent = (toggle: boolean) =>
|
|
142
|
+
webchatDispatch({
|
|
143
|
+
type: WebchatAction.DO_RENDER_CUSTOM_COMPONENT,
|
|
144
|
+
payload: toggle,
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const setError = (error: ErrorMessage) =>
|
|
148
|
+
webchatDispatch({
|
|
149
|
+
type: WebchatAction.SET_ERROR,
|
|
150
|
+
payload: error,
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
const setOnline = (online: boolean) =>
|
|
154
|
+
webchatDispatch({
|
|
155
|
+
type: WebchatAction.SET_ONLINE,
|
|
156
|
+
payload: online,
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const clearMessages = () => {
|
|
160
|
+
webchatDispatch({
|
|
161
|
+
type: WebchatAction.CLEAR_MESSAGES,
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const updateLastMessageDate = (date: string) => {
|
|
166
|
+
webchatDispatch({
|
|
167
|
+
type: WebchatAction.UPDATE_LAST_MESSAGE_DATE,
|
|
168
|
+
payload: date,
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const setCurrentAttachment = (attachment: File) => {
|
|
173
|
+
webchatDispatch({
|
|
174
|
+
type: WebchatAction.SET_CURRENT_ATTACHMENT,
|
|
175
|
+
payload: attachment,
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const updateJwt = (jwt: string) => {
|
|
180
|
+
webchatDispatch({
|
|
181
|
+
type: WebchatAction.UPDATE_JWT,
|
|
182
|
+
payload: jwt,
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
addMessage,
|
|
188
|
+
addMessageComponent,
|
|
189
|
+
clearMessages,
|
|
190
|
+
doRenderCustomComponent,
|
|
191
|
+
setCurrentAttachment,
|
|
192
|
+
setError,
|
|
193
|
+
setOnline,
|
|
194
|
+
toggleCoverComponent,
|
|
195
|
+
toggleEmojiPicker,
|
|
196
|
+
togglePersistentMenu,
|
|
197
|
+
toggleWebchat,
|
|
198
|
+
updateDevSettings,
|
|
199
|
+
updateHandoff,
|
|
200
|
+
updateJwt,
|
|
201
|
+
updateLastMessageDate,
|
|
202
|
+
updateLastRoutePath,
|
|
203
|
+
updateLatestInput,
|
|
204
|
+
updateMessage,
|
|
205
|
+
updateReplies,
|
|
206
|
+
updateSession,
|
|
207
|
+
updateTheme,
|
|
208
|
+
updateTyping,
|
|
209
|
+
updateWebview,
|
|
210
|
+
webchatDispatch,
|
|
211
|
+
webchatState,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
Input as CoreInput,
|
|
3
|
-
Session as CoreSession,
|
|
4
|
-
} from '@botonic/core/lib/esm/models/legacy-types'
|
|
1
|
+
import type { Input as CoreInput, Session as CoreSession } from '@botonic/core'
|
|
5
2
|
import { RefObject } from 'react'
|
|
6
3
|
|
|
7
4
|
import { Webview } from '../components/index-types'
|
|
@@ -17,6 +14,14 @@ export interface WebchatStateTheme {
|
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
16
|
|
|
17
|
+
export interface ErrorMessage {
|
|
18
|
+
message?: string
|
|
19
|
+
}
|
|
20
|
+
export interface DevSettings {
|
|
21
|
+
keepSessionOnReload?: boolean
|
|
22
|
+
showSessionView?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
20
25
|
export interface WebchatState {
|
|
21
26
|
width: number
|
|
22
27
|
height: number
|
|
@@ -32,14 +37,18 @@ export interface WebchatState {
|
|
|
32
37
|
handoff: boolean
|
|
33
38
|
theme: WebchatStateTheme
|
|
34
39
|
themeUpdates: Partial<WebchatStateTheme>
|
|
35
|
-
error:
|
|
36
|
-
|
|
40
|
+
error: ErrorMessage
|
|
41
|
+
online: boolean
|
|
42
|
+
devSettings: DevSettings
|
|
37
43
|
isWebchatOpen: boolean
|
|
38
44
|
isEmojiPickerOpen: boolean
|
|
39
45
|
isPersistentMenuOpen: boolean
|
|
40
46
|
isCoverComponentOpen: boolean
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
isCustomComponentRendered: boolean
|
|
48
|
+
lastMessageUpdate?: string
|
|
49
|
+
currentAttachment?: File
|
|
50
|
+
jwt?: string
|
|
51
|
+
unreadMessages: number
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
// export interface WebchatProps extends WebchatArgs {
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ADD_MESSAGE_COMPONENT,
|
|
4
|
-
CLEAR_MESSAGES,
|
|
5
|
-
UPDATE_LAST_MESSAGE_DATE,
|
|
6
|
-
UPDATE_MESSAGE,
|
|
7
|
-
UPDATE_REPLIES,
|
|
8
|
-
} from './actions'
|
|
1
|
+
import { WebchatAction } from './actions'
|
|
2
|
+
import { WebchatState } from './index-types'
|
|
9
3
|
|
|
10
|
-
export const messagesReducer = (
|
|
4
|
+
export const messagesReducer = (
|
|
5
|
+
state: WebchatState,
|
|
6
|
+
action: { type: WebchatAction; payload?: any }
|
|
7
|
+
): WebchatState => {
|
|
11
8
|
switch (action.type) {
|
|
12
|
-
case ADD_MESSAGE:
|
|
9
|
+
case WebchatAction.ADD_MESSAGE:
|
|
13
10
|
return addMessageReducer(state, action)
|
|
14
|
-
case ADD_MESSAGE_COMPONENT:
|
|
15
|
-
return addMessageComponent(
|
|
16
|
-
case UPDATE_MESSAGE:
|
|
11
|
+
case WebchatAction.ADD_MESSAGE_COMPONENT:
|
|
12
|
+
return addMessageComponent(state, action)
|
|
13
|
+
case WebchatAction.UPDATE_MESSAGE:
|
|
17
14
|
return updateMessageReducer(state, action)
|
|
18
|
-
case UPDATE_REPLIES:
|
|
15
|
+
case WebchatAction.UPDATE_REPLIES:
|
|
19
16
|
return { ...state, replies: action.payload }
|
|
20
|
-
case CLEAR_MESSAGES:
|
|
17
|
+
case WebchatAction.CLEAR_MESSAGES:
|
|
21
18
|
return {
|
|
22
19
|
...state,
|
|
23
20
|
messagesJSON: [],
|
|
24
21
|
messagesComponents: [],
|
|
25
22
|
}
|
|
26
|
-
case UPDATE_LAST_MESSAGE_DATE:
|
|
23
|
+
case WebchatAction.UPDATE_LAST_MESSAGE_DATE:
|
|
27
24
|
return {
|
|
28
25
|
...state,
|
|
29
26
|
lastMessageUpdate: action.payload,
|
|
@@ -33,7 +30,10 @@ export const messagesReducer = (state, action) => {
|
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
32
|
|
|
36
|
-
function addMessageComponent(
|
|
33
|
+
function addMessageComponent(
|
|
34
|
+
state: WebchatState,
|
|
35
|
+
action: { type: WebchatAction; payload?: any }
|
|
36
|
+
) {
|
|
37
37
|
const messageComponent = action.payload
|
|
38
38
|
const isUnreadMessage =
|
|
39
39
|
!state.isWebchatOpen && messageComponent.props?.ack !== 1
|
|
@@ -48,7 +48,10 @@ function addMessageComponent(action, state) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function updateMessageReducer(
|
|
51
|
+
function updateMessageReducer(
|
|
52
|
+
state: WebchatState,
|
|
53
|
+
action: { type: WebchatAction; payload?: any }
|
|
54
|
+
) {
|
|
52
55
|
const msgIndex = state.messagesJSON.map(m => m.id).indexOf(action.payload.id)
|
|
53
56
|
if (msgIndex > -1) {
|
|
54
57
|
const msgComponent = state.messagesComponents[msgIndex]
|
|
@@ -82,7 +85,10 @@ function updateMessageReducer(state, action) {
|
|
|
82
85
|
return state
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
function addMessageReducer(
|
|
88
|
+
function addMessageReducer(
|
|
89
|
+
state: WebchatState,
|
|
90
|
+
action: { type: WebchatAction; payload?: any }
|
|
91
|
+
) {
|
|
86
92
|
if (
|
|
87
93
|
state.messagesJSON &&
|
|
88
94
|
state.messagesJSON.find(m => m.id === action.payload.id)
|
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
SET_CURRENT_ATTACHMENT,
|
|
4
|
-
SET_ERROR,
|
|
5
|
-
SET_ONLINE,
|
|
6
|
-
TOGGLE_COVER_COMPONENT,
|
|
7
|
-
TOGGLE_EMOJI_PICKER,
|
|
8
|
-
TOGGLE_PERSISTENT_MENU,
|
|
9
|
-
TOGGLE_WEBCHAT,
|
|
10
|
-
UPDATE_DEV_SETTINGS,
|
|
11
|
-
UPDATE_HANDOFF,
|
|
12
|
-
UPDATE_JWT,
|
|
13
|
-
UPDATE_LAST_ROUTE_PATH,
|
|
14
|
-
UPDATE_LATEST_INPUT,
|
|
15
|
-
UPDATE_SESSION,
|
|
16
|
-
UPDATE_THEME,
|
|
17
|
-
UPDATE_TYPING,
|
|
18
|
-
UPDATE_WEBVIEW,
|
|
19
|
-
} from './actions'
|
|
1
|
+
import { WebchatAction } from './actions'
|
|
2
|
+
import { WebchatState } from './index-types'
|
|
20
3
|
import { messagesReducer } from './messages-reducer'
|
|
21
4
|
|
|
22
5
|
// eslint-disable-next-line complexity
|
|
23
|
-
export function webchatReducer(
|
|
6
|
+
export function webchatReducer(
|
|
7
|
+
state: WebchatState,
|
|
8
|
+
action: { type: WebchatAction; payload?: any }
|
|
9
|
+
): WebchatState {
|
|
24
10
|
switch (action.type) {
|
|
25
|
-
case UPDATE_WEBVIEW:
|
|
11
|
+
case WebchatAction.UPDATE_WEBVIEW:
|
|
26
12
|
return { ...state, ...action.payload }
|
|
27
|
-
case UPDATE_SESSION:
|
|
13
|
+
case WebchatAction.UPDATE_SESSION:
|
|
28
14
|
return { ...state, session: { ...action.payload } }
|
|
29
|
-
case UPDATE_TYPING:
|
|
15
|
+
case WebchatAction.UPDATE_TYPING:
|
|
30
16
|
return { ...state, typing: action.payload }
|
|
31
|
-
case UPDATE_THEME:
|
|
17
|
+
case WebchatAction.UPDATE_THEME:
|
|
32
18
|
return {
|
|
33
19
|
...state,
|
|
34
20
|
...action.payload,
|
|
35
21
|
}
|
|
36
|
-
case UPDATE_HANDOFF:
|
|
22
|
+
case WebchatAction.UPDATE_HANDOFF:
|
|
37
23
|
return { ...state, handoff: action.payload }
|
|
38
|
-
case TOGGLE_WEBCHAT: {
|
|
24
|
+
case WebchatAction.TOGGLE_WEBCHAT: {
|
|
39
25
|
const isWebchatOpen = action.payload
|
|
40
26
|
return {
|
|
41
27
|
...state,
|
|
@@ -43,27 +29,27 @@ export function webchatReducer(state, action) {
|
|
|
43
29
|
unreadMessages: isWebchatOpen ? 0 : state.unreadMessages,
|
|
44
30
|
}
|
|
45
31
|
}
|
|
46
|
-
case TOGGLE_EMOJI_PICKER:
|
|
32
|
+
case WebchatAction.TOGGLE_EMOJI_PICKER:
|
|
47
33
|
return { ...state, isEmojiPickerOpen: action.payload }
|
|
48
|
-
case TOGGLE_PERSISTENT_MENU:
|
|
34
|
+
case WebchatAction.TOGGLE_PERSISTENT_MENU:
|
|
49
35
|
return { ...state, isPersistentMenuOpen: action.payload }
|
|
50
|
-
case TOGGLE_COVER_COMPONENT:
|
|
36
|
+
case WebchatAction.TOGGLE_COVER_COMPONENT:
|
|
51
37
|
return { ...state, isCoverComponentOpen: action.payload }
|
|
52
|
-
case DO_RENDER_CUSTOM_COMPONENT:
|
|
38
|
+
case WebchatAction.DO_RENDER_CUSTOM_COMPONENT:
|
|
53
39
|
return { ...state, isCustomComponentRendered: action.payload }
|
|
54
|
-
case SET_ERROR:
|
|
40
|
+
case WebchatAction.SET_ERROR:
|
|
55
41
|
return { ...state, error: action.payload || {} }
|
|
56
|
-
case SET_ONLINE:
|
|
42
|
+
case WebchatAction.SET_ONLINE:
|
|
57
43
|
return { ...state, online: action.payload }
|
|
58
|
-
case UPDATE_DEV_SETTINGS:
|
|
44
|
+
case WebchatAction.UPDATE_DEV_SETTINGS:
|
|
59
45
|
return { ...state, devSettings: { ...action.payload } }
|
|
60
|
-
case UPDATE_LATEST_INPUT:
|
|
46
|
+
case WebchatAction.UPDATE_LATEST_INPUT:
|
|
61
47
|
return { ...state, latestInput: action.payload }
|
|
62
|
-
case UPDATE_LAST_ROUTE_PATH:
|
|
48
|
+
case WebchatAction.UPDATE_LAST_ROUTE_PATH:
|
|
63
49
|
return { ...state, lastRoutePath: action.payload }
|
|
64
|
-
case SET_CURRENT_ATTACHMENT:
|
|
50
|
+
case WebchatAction.SET_CURRENT_ATTACHMENT:
|
|
65
51
|
return { ...state, currentAttachment: action.payload }
|
|
66
|
-
case UPDATE_JWT:
|
|
52
|
+
case WebchatAction.UPDATE_JWT:
|
|
67
53
|
return { ...state, jwt: action.payload }
|
|
68
54
|
default:
|
|
69
55
|
return messagesReducer(state, action)
|
package/src/webchat/webchat.jsx
CHANGED
|
@@ -165,7 +165,6 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
165
165
|
setOnline,
|
|
166
166
|
clearMessages,
|
|
167
167
|
openWebviewT,
|
|
168
|
-
closeWebviewT,
|
|
169
168
|
updateLastMessageDate,
|
|
170
169
|
setCurrentAttachment,
|
|
171
170
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -496,8 +495,10 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
496
495
|
from: SENDERS.user,
|
|
497
496
|
src: temporaryDisplayUrl,
|
|
498
497
|
}
|
|
499
|
-
if (isImage(input))
|
|
500
|
-
|
|
498
|
+
if (isImage(input)) {
|
|
499
|
+
mediaProps.input = input
|
|
500
|
+
messageComponent = <Image {...mediaProps} />
|
|
501
|
+
} else if (isAudio(input)) messageComponent = <Audio {...mediaProps} />
|
|
501
502
|
else if (isVideo(input)) messageComponent = <Video {...mediaProps} />
|
|
502
503
|
else if (isDocument(input))
|
|
503
504
|
messageComponent = <Document {...mediaProps} />
|
|
@@ -844,21 +845,21 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
844
845
|
const WebchatComponent = (
|
|
845
846
|
<WebchatContext.Provider
|
|
846
847
|
value={{
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
sendPayload,
|
|
850
|
-
sendInput,
|
|
848
|
+
addMessage,
|
|
849
|
+
getThemeProperty,
|
|
851
850
|
openWebview,
|
|
852
851
|
resolveCase,
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
852
|
+
sendAttachment,
|
|
853
|
+
sendInput,
|
|
854
|
+
sendPayload,
|
|
855
|
+
sendText,
|
|
856
856
|
toggleWebchat,
|
|
857
|
+
updateLatestInput,
|
|
857
858
|
updateMessage,
|
|
858
859
|
updateReplies,
|
|
859
|
-
updateLatestInput,
|
|
860
860
|
updateUser: updateSessionWithUser,
|
|
861
861
|
updateWebchatDevSettings: updateWebchatDevSettings,
|
|
862
|
+
webchatState,
|
|
862
863
|
}}
|
|
863
864
|
>
|
|
864
865
|
{!webchatState.isWebchatOpen && <TriggerButton />}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
export function useWebchat(): {
|
|
2
|
-
webchatState: any;
|
|
3
|
-
webchatDispatch: import("react").DispatchWithoutAction;
|
|
4
|
-
addMessage: (message: any) => void;
|
|
5
|
-
addMessageComponent: (message: any) => void;
|
|
6
|
-
updateMessage: (message: any) => void;
|
|
7
|
-
updateReplies: (replies: any) => void;
|
|
8
|
-
updateLatestInput: (input: any) => void;
|
|
9
|
-
updateTyping: (typing: any) => void;
|
|
10
|
-
updateWebview: (webview: any, params: any) => void;
|
|
11
|
-
updateSession: (session: any) => void;
|
|
12
|
-
updateLastRoutePath: (path: any) => void;
|
|
13
|
-
updateHandoff: (handoff: any) => void;
|
|
14
|
-
updateTheme: (theme: any, themeUpdates?: undefined) => void;
|
|
15
|
-
updateDevSettings: (settings: any) => void;
|
|
16
|
-
toggleWebchat: (toggle: any) => void;
|
|
17
|
-
toggleEmojiPicker: (toggle: any) => void;
|
|
18
|
-
togglePersistentMenu: (toggle: any) => void;
|
|
19
|
-
toggleCoverComponent: (toggle: any) => void;
|
|
20
|
-
doRenderCustomComponent: (toggle: any) => void;
|
|
21
|
-
setError: (error: any) => void;
|
|
22
|
-
setOnline: (online: any) => void;
|
|
23
|
-
clearMessages: () => void;
|
|
24
|
-
updateLastMessageDate: (date: any) => void;
|
|
25
|
-
setCurrentAttachment: (attachment: any) => void;
|
|
26
|
-
updateJwt: (jwt: any) => void;
|
|
27
|
-
};
|
|
28
|
-
export function useTyping({ webchatState, updateTyping, updateMessage, host }: {
|
|
29
|
-
webchatState: any;
|
|
30
|
-
updateTyping: any;
|
|
31
|
-
updateMessage: any;
|
|
32
|
-
host: any;
|
|
33
|
-
}): void;
|
|
34
|
-
export function usePrevious(value: any): undefined;
|
|
35
|
-
export function useComponentVisible(initialIsVisible: any, onClickOutside: any): {
|
|
36
|
-
ref: import("react").MutableRefObject<null>;
|
|
37
|
-
isComponentVisible: any;
|
|
38
|
-
setIsComponentVisible: import("react").Dispatch<any>;
|
|
39
|
-
};
|
|
40
|
-
export namespace webchatInitialState {
|
|
41
|
-
let width: number;
|
|
42
|
-
let height: number;
|
|
43
|
-
let messagesJSON: never[];
|
|
44
|
-
let messagesComponents: never[];
|
|
45
|
-
let replies: never[];
|
|
46
|
-
let latestInput: {};
|
|
47
|
-
let typing: boolean;
|
|
48
|
-
let webview: null;
|
|
49
|
-
let webviewParams: null;
|
|
50
|
-
namespace session {
|
|
51
|
-
let user: null;
|
|
52
|
-
}
|
|
53
|
-
let lastRoutePath: null;
|
|
54
|
-
let handoff: boolean;
|
|
55
|
-
namespace theme {
|
|
56
|
-
let headerTitle: string;
|
|
57
|
-
let brandColor: string;
|
|
58
|
-
let brandImage: any;
|
|
59
|
-
let triggerButtonImage: undefined;
|
|
60
|
-
let textPlaceholder: string;
|
|
61
|
-
namespace style {
|
|
62
|
-
let fontFamily: string;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
let themeUpdates: {};
|
|
66
|
-
let error: {};
|
|
67
|
-
let online: boolean;
|
|
68
|
-
namespace devSettings {
|
|
69
|
-
let keepSessionOnReload: boolean;
|
|
70
|
-
}
|
|
71
|
-
let isWebchatOpen: boolean;
|
|
72
|
-
let isEmojiPickerOpen: boolean;
|
|
73
|
-
let isPersistentMenuOpen: boolean;
|
|
74
|
-
let isCoverComponentOpen: boolean;
|
|
75
|
-
let isCustomComponentRendered: boolean;
|
|
76
|
-
let lastMessageUpdate: undefined;
|
|
77
|
-
let currentAttachment: undefined;
|
|
78
|
-
let jwt: null;
|
|
79
|
-
let unreadMessages: number;
|
|
80
|
-
}
|
|
81
|
-
export function useComponentWillMount(func: any): void;
|