@botonic/react 0.31.0-alpha.4 → 0.31.0-alpha.6
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/components/audio.d.ts +8 -7
- package/lib/cjs/components/audio.js +7 -4
- package/lib/cjs/components/audio.js.map +1 -1
- package/lib/cjs/components/button.js +3 -4
- package/lib/cjs/components/button.js.map +1 -1
- package/lib/cjs/components/carousel.js +2 -2
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/custom-message.d.ts +16 -12
- package/lib/cjs/components/custom-message.js +3 -9
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/components/document.d.ts +8 -7
- package/lib/cjs/components/document.js +5 -5
- 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.d.ts +8 -7
- package/lib/cjs/components/image.js +5 -5
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +30 -128
- package/lib/cjs/components/index.d.ts +2 -1
- package/lib/cjs/components/index.js +4 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/message/index.js +2 -1
- package/lib/cjs/components/message/index.js.map +1 -1
- package/lib/cjs/components/message/message-feedback.js +2 -2
- package/lib/cjs/components/message/message-feedback.js.map +1 -1
- package/lib/cjs/components/message/message-footer.js +2 -2
- package/lib/cjs/components/message/message-footer.js.map +1 -1
- package/lib/cjs/components/message/message-image.js +2 -2
- package/lib/cjs/components/message/message-image.js.map +1 -1
- package/lib/cjs/components/message/timestamps.js +2 -2
- package/lib/cjs/components/message/timestamps.js.map +1 -1
- package/lib/cjs/components/reply.d.ts +7 -6
- package/lib/cjs/components/reply.js +10 -6
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/video.d.ts +8 -7
- package/lib/cjs/components/video.js +2 -3
- package/lib/cjs/components/video.js.map +1 -1
- package/lib/cjs/components/webchat-settings.d.ts +15 -2
- package/lib/cjs/components/webchat-settings.js +2 -2
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/contexts.d.ts +3 -4
- package/lib/cjs/contexts.js +2 -79
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/index-types.d.ts +89 -56
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/msg-to-botonic.d.ts +1 -1
- package/lib/cjs/msg-to-botonic.js +5 -8
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/util/webchat.d.ts +17 -6
- package/lib/cjs/util/webchat.js +9 -7
- package/lib/cjs/util/webchat.js.map +1 -1
- package/lib/cjs/webchat/chat-area/index.js +3 -3
- package/lib/cjs/webchat/chat-area/index.js.map +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +2 -2
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/opened-persistent-menu.js +2 -2
- package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
- package/lib/cjs/webchat/{actions.js → context/actions.js} +3 -0
- package/lib/cjs/webchat/context/actions.js.map +1 -0
- package/lib/cjs/webchat/context/index.d.ts +5 -0
- package/lib/cjs/webchat/context/index.js +83 -0
- package/lib/cjs/webchat/context/index.js.map +1 -0
- package/lib/cjs/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
- package/lib/cjs/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
- package/lib/cjs/webchat/context/messages-reducer.js.map +1 -0
- package/lib/cjs/webchat/context/types.d.ts +74 -0
- package/lib/cjs/webchat/context/types.js +3 -0
- package/lib/cjs/webchat/context/types.js.map +1 -0
- package/lib/cjs/webchat/{hooks → context}/use-webchat.d.ts +20 -20
- package/lib/cjs/webchat/{hooks → context}/use-webchat.js +11 -5
- package/lib/cjs/webchat/context/use-webchat.js.map +1 -0
- package/lib/cjs/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
- package/lib/cjs/webchat/{webchat-reducer.js → context/webchat-reducer.js} +2 -0
- package/lib/cjs/webchat/context/webchat-reducer.js.map +1 -0
- package/lib/cjs/webchat/cover-component/index.js +2 -2
- package/lib/cjs/webchat/cover-component/index.js.map +1 -1
- package/lib/cjs/webchat/header/default-header.d.ts +1 -0
- package/lib/cjs/webchat/header/default-header.js +25 -0
- package/lib/cjs/webchat/header/default-header.js.map +1 -0
- package/lib/cjs/webchat/header/index.d.ts +2 -0
- package/lib/cjs/webchat/header/index.js +23 -0
- package/lib/cjs/webchat/header/index.js.map +1 -0
- package/lib/cjs/webchat/header/styles.d.ts +7 -0
- package/lib/cjs/webchat/header/styles.js +59 -0
- package/lib/cjs/webchat/header/styles.js.map +1 -0
- package/lib/cjs/webchat/hooks/index.d.ts +0 -1
- package/lib/cjs/webchat/hooks/index.js +1 -4
- package/lib/cjs/webchat/hooks/index.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-previous.d.ts +1 -1
- package/lib/cjs/webchat/hooks/use-previous.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +3 -3
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-typing.d.ts +1 -1
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.js +2 -2
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js +2 -2
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +3 -47
- package/lib/cjs/webchat/index.d.ts +1 -0
- package/lib/cjs/webchat/index.js +3 -1
- package/lib/cjs/webchat/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/attachment.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/attachment.js +2 -2
- package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.js +2 -2
- package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/input-panel/index.d.ts +3 -3
- package/lib/cjs/webchat/input-panel/index.js +8 -3
- package/lib/cjs/webchat/input-panel/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/persistent-menu.js +2 -2
- package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/input-panel/send-button.js +2 -2
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/cjs/webchat/input-panel/textarea.d.ts +3 -3
- package/lib/cjs/webchat/input-panel/textarea.js +4 -2
- package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/message-list/index.js +5 -7
- package/lib/cjs/webchat/message-list/index.js.map +1 -1
- package/lib/cjs/webchat/message-list/intro-message.js +2 -2
- package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
- package/lib/cjs/webchat/message-list/styles.js +1 -0
- package/lib/cjs/webchat/message-list/styles.js.map +1 -1
- package/lib/cjs/webchat/message-list/unread-messages-banner.js +2 -2
- package/lib/cjs/webchat/message-list/unread-messages-banner.js.map +1 -1
- package/lib/cjs/webchat/message-list/use-notifications.js +2 -2
- package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/cjs/webchat/replies/index.d.ts +1 -0
- package/lib/cjs/webchat/replies/index.js +32 -0
- package/lib/cjs/webchat/replies/index.js.map +1 -0
- package/lib/cjs/webchat/replies/styles.d.ts +8 -0
- package/lib/cjs/webchat/replies/styles.js +25 -0
- package/lib/cjs/webchat/replies/styles.js.map +1 -0
- package/lib/cjs/webchat/session-view.js +2 -2
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
- package/lib/cjs/webchat/{webchat-typed/styles.js → styles.js} +1 -1
- package/lib/cjs/webchat/styles.js.map +1 -0
- package/lib/cjs/webchat/theme/types.d.ts +167 -0
- package/lib/cjs/webchat/theme/types.js +3 -0
- package/lib/cjs/webchat/theme/types.js.map +1 -0
- package/lib/cjs/webchat/trigger-button/index.js +2 -2
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/cjs/webchat/webchat-dev.js +2 -2
- package/lib/cjs/webchat/webchat-dev.js.map +1 -1
- package/lib/cjs/webchat/webchat.d.ts +4 -2
- package/lib/cjs/webchat/webchat.js +85 -108
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.js +3 -2
- package/lib/cjs/webchat/webview.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +14 -80
- package/lib/cjs/webchat-app.js +28 -14
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/esm/components/audio.d.ts +8 -7
- package/lib/esm/components/audio.js +7 -4
- package/lib/esm/components/audio.js.map +1 -1
- package/lib/esm/components/button.js +2 -3
- package/lib/esm/components/button.js.map +1 -1
- package/lib/esm/components/carousel.js +1 -1
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/custom-message.d.ts +16 -12
- package/lib/esm/components/custom-message.js +3 -9
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/components/document.d.ts +8 -7
- package/lib/esm/components/document.js +4 -4
- package/lib/esm/components/document.js.map +1 -1
- package/lib/esm/components/handoff.js +1 -1
- package/lib/esm/components/handoff.js.map +1 -1
- package/lib/esm/components/image.d.ts +8 -7
- package/lib/esm/components/image.js +4 -4
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +30 -128
- package/lib/esm/components/index.d.ts +2 -1
- package/lib/esm/components/index.js +2 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/message/index.js +2 -1
- package/lib/esm/components/message/index.js.map +1 -1
- package/lib/esm/components/message/message-feedback.js +1 -1
- package/lib/esm/components/message/message-feedback.js.map +1 -1
- package/lib/esm/components/message/message-footer.js +1 -1
- package/lib/esm/components/message/message-footer.js.map +1 -1
- package/lib/esm/components/message/message-image.js +1 -1
- package/lib/esm/components/message/message-image.js.map +1 -1
- package/lib/esm/components/message/timestamps.js +1 -1
- package/lib/esm/components/message/timestamps.js.map +1 -1
- package/lib/esm/components/reply.d.ts +7 -6
- package/lib/esm/components/reply.js +9 -5
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/video.d.ts +8 -7
- package/lib/esm/components/video.js +2 -3
- package/lib/esm/components/video.js.map +1 -1
- package/lib/esm/components/webchat-settings.d.ts +15 -2
- package/lib/esm/components/webchat-settings.js +1 -1
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/contexts.d.ts +3 -4
- package/lib/esm/contexts.js +1 -78
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/index-types.d.ts +89 -56
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/msg-to-botonic.d.ts +1 -1
- package/lib/esm/msg-to-botonic.js +5 -8
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/util/webchat.d.ts +17 -6
- package/lib/esm/util/webchat.js +9 -7
- package/lib/esm/util/webchat.js.map +1 -1
- package/lib/esm/webchat/chat-area/index.js +2 -2
- package/lib/esm/webchat/chat-area/index.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/opened-persistent-menu.js +1 -1
- package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/esm/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
- package/lib/esm/webchat/{actions.js → context/actions.js} +3 -0
- package/lib/esm/webchat/context/actions.js.map +1 -0
- package/lib/esm/webchat/context/index.d.ts +5 -0
- package/lib/esm/webchat/context/index.js +78 -0
- package/lib/esm/webchat/context/index.js.map +1 -0
- package/lib/esm/webchat/{messages-reducer.d.ts → context/messages-reducer.d.ts} +1 -1
- package/lib/esm/webchat/{messages-reducer.js → context/messages-reducer.js} +3 -1
- package/lib/esm/webchat/context/messages-reducer.js.map +1 -0
- package/lib/esm/webchat/context/types.d.ts +74 -0
- package/lib/esm/webchat/context/types.js +2 -0
- package/lib/esm/webchat/context/types.js.map +1 -0
- package/lib/esm/webchat/{hooks → context}/use-webchat.d.ts +20 -20
- package/lib/esm/webchat/{hooks → context}/use-webchat.js +11 -5
- package/lib/esm/webchat/context/use-webchat.js.map +1 -0
- package/lib/esm/webchat/{webchat-reducer.d.ts → context/webchat-reducer.d.ts} +1 -1
- package/lib/esm/webchat/{webchat-reducer.js → context/webchat-reducer.js} +2 -0
- package/lib/esm/webchat/context/webchat-reducer.js.map +1 -0
- package/lib/esm/webchat/cover-component/index.js +1 -1
- package/lib/esm/webchat/cover-component/index.js.map +1 -1
- package/lib/esm/webchat/header/default-header.d.ts +1 -0
- package/lib/esm/webchat/header/default-header.js +21 -0
- package/lib/esm/webchat/header/default-header.js.map +1 -0
- package/lib/esm/webchat/header/index.d.ts +2 -0
- package/lib/esm/webchat/header/index.js +20 -0
- package/lib/esm/webchat/header/index.js.map +1 -0
- package/lib/esm/webchat/header/styles.d.ts +7 -0
- package/lib/esm/webchat/header/styles.js +55 -0
- package/lib/esm/webchat/header/styles.js.map +1 -0
- package/lib/esm/webchat/hooks/index.d.ts +0 -1
- package/lib/esm/webchat/hooks/index.js +0 -1
- package/lib/esm/webchat/hooks/index.js.map +1 -1
- package/lib/esm/webchat/hooks/use-previous.d.ts +1 -1
- package/lib/esm/webchat/hooks/use-previous.js.map +1 -1
- package/lib/esm/webchat/hooks/use-scrollbar-controller.js +2 -2
- package/lib/esm/webchat/hooks/use-scrollbar-controller.js.map +1 -1
- package/lib/esm/webchat/hooks/use-typing.d.ts +1 -1
- package/lib/esm/webchat/hooks/use-webchat-dimensions.js +1 -1
- package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -1
- package/lib/esm/webchat/hooks/use-webchat-resizer.js +1 -1
- package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +3 -47
- package/lib/esm/webchat/index.d.ts +1 -0
- package/lib/esm/webchat/index.js +1 -0
- package/lib/esm/webchat/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/attachment.d.ts +1 -1
- package/lib/esm/webchat/input-panel/attachment.js +1 -1
- package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.js +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/input-panel/index.d.ts +3 -3
- package/lib/esm/webchat/input-panel/index.js +7 -2
- package/lib/esm/webchat/input-panel/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.js +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/input-panel/send-button.js +1 -1
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/webchat/input-panel/textarea.d.ts +3 -3
- package/lib/esm/webchat/input-panel/textarea.js +3 -1
- package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/message-list/index.js +4 -6
- package/lib/esm/webchat/message-list/index.js.map +1 -1
- package/lib/esm/webchat/message-list/intro-message.js +1 -1
- package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
- package/lib/esm/webchat/message-list/styles.js +1 -0
- package/lib/esm/webchat/message-list/styles.js.map +1 -1
- package/lib/esm/webchat/message-list/unread-messages-banner.js +1 -1
- package/lib/esm/webchat/message-list/unread-messages-banner.js.map +1 -1
- package/lib/esm/webchat/message-list/use-notifications.js +1 -1
- package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/esm/webchat/replies/index.d.ts +1 -0
- package/lib/esm/webchat/replies/index.js +28 -0
- package/lib/esm/webchat/replies/index.js.map +1 -0
- package/lib/esm/webchat/replies/styles.d.ts +8 -0
- package/lib/esm/webchat/replies/styles.js +21 -0
- package/lib/esm/webchat/replies/styles.js.map +1 -0
- package/lib/esm/webchat/session-view.js +1 -1
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
- package/lib/esm/webchat/{webchat-typed/styles.js → styles.js} +1 -1
- package/lib/esm/webchat/styles.js.map +1 -0
- package/lib/esm/webchat/theme/types.d.ts +167 -0
- package/lib/esm/webchat/theme/types.js +2 -0
- package/lib/esm/webchat/theme/types.js.map +1 -0
- package/lib/esm/webchat/trigger-button/index.js +1 -1
- package/lib/esm/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/webchat/webchat-dev.js +1 -1
- package/lib/esm/webchat/webchat-dev.js.map +1 -1
- package/lib/esm/webchat/webchat.d.ts +4 -2
- package/lib/esm/webchat/webchat.js +81 -104
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.js +2 -1
- package/lib/esm/webchat/webview.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +14 -80
- package/lib/esm/webchat-app.js +28 -14
- package/lib/esm/webchat-app.js.map +1 -1
- package/package.json +2 -1
- package/src/components/{audio.jsx → audio.tsx} +10 -4
- package/src/components/button.tsx +1 -3
- package/src/components/carousel.jsx +1 -1
- package/src/components/{custom-message.jsx → custom-message.tsx} +19 -7
- package/src/components/{document.jsx → document.tsx} +5 -3
- package/src/components/handoff.jsx +1 -1
- package/src/components/{image.jsx → image.tsx} +10 -4
- package/src/components/index-types.ts +25 -117
- package/src/components/index.ts +6 -1
- package/src/components/message/index.jsx +2 -1
- package/src/components/message/message-feedback.tsx +1 -1
- package/src/components/message/message-footer.tsx +1 -1
- package/src/components/message/message-image.tsx +1 -1
- package/src/components/message/timestamps.tsx +1 -1
- package/src/components/{reply.jsx → reply.tsx} +10 -4
- package/src/components/{video.jsx → video.tsx} +3 -2
- package/src/components/webchat-settings.tsx +14 -2
- package/src/contexts.tsx +5 -83
- package/src/index-types.ts +99 -64
- package/src/index.ts +2 -6
- package/src/msg-to-botonic.jsx +5 -9
- package/src/util/{webchat.js → webchat.ts} +15 -9
- package/src/webchat/chat-area/index.tsx +2 -4
- package/src/webchat/components/conditional-animation.jsx +1 -1
- package/src/webchat/components/opened-persistent-menu.jsx +1 -1
- package/src/webchat/{actions.ts → context/actions.ts} +3 -0
- package/src/webchat/context/index.tsx +81 -0
- package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
- package/src/webchat/context/types.ts +84 -0
- package/src/webchat/{hooks → context}/use-webchat.ts +62 -13
- package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +3 -1
- package/src/webchat/cover-component/index.tsx +1 -1
- package/src/webchat/global.d.ts +3 -0
- package/src/webchat/header/default-header.tsx +75 -0
- package/src/webchat/header/index.tsx +37 -0
- package/src/webchat/header/styles.ts +62 -0
- package/src/webchat/hooks/index.ts +0 -1
- package/src/webchat/hooks/use-previous.ts +1 -1
- package/src/webchat/hooks/use-scrollbar-controller.ts +2 -2
- package/src/webchat/hooks/use-typing.ts +1 -1
- package/src/webchat/hooks/use-webchat-dimensions.ts +1 -1
- package/src/webchat/hooks/use-webchat-resizer.ts +1 -1
- package/src/webchat/index-types.ts +3 -53
- package/src/webchat/index.ts +1 -0
- package/src/webchat/input-panel/attachment.tsx +2 -2
- package/src/webchat/input-panel/emoji-picker.tsx +2 -2
- package/src/webchat/input-panel/index.tsx +9 -5
- package/src/webchat/input-panel/persistent-menu.tsx +1 -1
- package/src/webchat/input-panel/send-button.tsx +1 -1
- package/src/webchat/input-panel/textarea.tsx +6 -4
- package/src/webchat/message-list/index.tsx +4 -6
- package/src/webchat/message-list/intro-message.tsx +1 -1
- package/src/webchat/message-list/styles.ts +1 -0
- package/src/webchat/message-list/unread-messages-banner.tsx +1 -1
- package/src/webchat/message-list/use-notifications.ts +1 -1
- package/src/webchat/replies/index.tsx +47 -0
- package/src/webchat/replies/styles.ts +28 -0
- package/src/webchat/session-view.jsx +1 -1
- package/src/webchat/{webchat-typed/styles.ts → styles.ts} +7 -2
- package/src/webchat/theme/types.ts +119 -0
- package/src/webchat/trigger-button/index.tsx +1 -1
- package/src/webchat/webchat-dev.jsx +1 -1
- package/src/webchat/{webchat.jsx → webchat.tsx} +114 -124
- package/src/webchat/webview.jsx +2 -1
- package/src/webchat-app.tsx +55 -95
- package/lib/cjs/webchat/actions.js.map +0 -1
- package/lib/cjs/webchat/header.d.ts +0 -3
- package/lib/cjs/webchat/header.js +0 -86
- package/lib/cjs/webchat/header.js.map +0 -1
- package/lib/cjs/webchat/hooks/use-webchat.js.map +0 -1
- package/lib/cjs/webchat/messages-reducer.js.map +0 -1
- package/lib/cjs/webchat/replies.d.ts +0 -1
- package/lib/cjs/webchat/replies.js +0 -47
- package/lib/cjs/webchat/replies.js.map +0 -1
- package/lib/cjs/webchat/webchat-reducer.js.map +0 -1
- package/lib/cjs/webchat/webchat-typed/styles.js.map +0 -1
- package/lib/cjs/webchat/webchat-typed/webchat-typed.d.ts +0 -0
- package/lib/cjs/webchat/webchat-typed/webchat-typed.js +0 -663
- package/lib/cjs/webchat/webchat-typed/webchat-typed.js.map +0 -1
- package/lib/esm/webchat/actions.js.map +0 -1
- package/lib/esm/webchat/header.d.ts +0 -3
- package/lib/esm/webchat/header.js +0 -81
- package/lib/esm/webchat/header.js.map +0 -1
- package/lib/esm/webchat/hooks/use-webchat.js.map +0 -1
- package/lib/esm/webchat/messages-reducer.js.map +0 -1
- package/lib/esm/webchat/replies.d.ts +0 -1
- package/lib/esm/webchat/replies.js +0 -42
- package/lib/esm/webchat/replies.js.map +0 -1
- package/lib/esm/webchat/webchat-reducer.js.map +0 -1
- package/lib/esm/webchat/webchat-typed/styles.js.map +0 -1
- package/lib/esm/webchat/webchat-typed/webchat-typed.d.ts +0 -0
- package/lib/esm/webchat/webchat-typed/webchat-typed.js +0 -663
- package/lib/esm/webchat/webchat-typed/webchat-typed.js.map +0 -1
- package/src/webchat/header.jsx +0 -149
- package/src/webchat/replies.jsx +0 -64
- package/src/webchat/webchat-typed/webchat-typed.tsx +0 -728
package/src/index-types.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
Plugin as CorePlugin,
|
|
6
6
|
Route as CoreRoute,
|
|
7
7
|
Routes as CoreRoutes,
|
|
8
|
+
ServerConfig,
|
|
8
9
|
Session as CoreSession,
|
|
9
10
|
SessionUser as CoreSessionUser,
|
|
10
11
|
} from '@botonic/core'
|
|
@@ -13,14 +14,16 @@ import React from 'react'
|
|
|
13
14
|
import {
|
|
14
15
|
BlockInputOption,
|
|
15
16
|
ButtonProps,
|
|
16
|
-
CoverComponentOptions,
|
|
17
|
-
PersistentMenuTheme,
|
|
18
17
|
ReplyProps,
|
|
19
|
-
ThemeProps,
|
|
20
18
|
WebchatSettingsProps,
|
|
21
|
-
|
|
22
|
-
} from './
|
|
23
|
-
import {
|
|
19
|
+
} from './components'
|
|
20
|
+
import { CloseWebviewOptions } from './contexts'
|
|
21
|
+
import { UseWebchat } from './webchat/context/use-webchat'
|
|
22
|
+
import {
|
|
23
|
+
CoverComponentOptions,
|
|
24
|
+
PersistentMenuOptionsTheme,
|
|
25
|
+
ThemeProps,
|
|
26
|
+
} from './webchat/theme/types'
|
|
24
27
|
import { WebchatApp } from './webchat-app'
|
|
25
28
|
|
|
26
29
|
/**
|
|
@@ -51,32 +54,91 @@ export interface RequestContextInterface extends ActionRequest {
|
|
|
51
54
|
setLocale: (locale: string) => string
|
|
52
55
|
}
|
|
53
56
|
|
|
54
|
-
export interface
|
|
55
|
-
|
|
57
|
+
export interface WebchatRef {
|
|
58
|
+
addBotResponse: ({
|
|
59
|
+
response,
|
|
60
|
+
session,
|
|
61
|
+
lastRoutePath,
|
|
62
|
+
}: AddBotResponseArgs) => void
|
|
63
|
+
setTyping: (typing: boolean) => void
|
|
64
|
+
addUserMessage: (message: any) => Promise<void>
|
|
65
|
+
updateUser: (userToUpdate: any) => void
|
|
66
|
+
openWebchat: () => void
|
|
67
|
+
closeWebchat: () => void
|
|
68
|
+
toggleWebchat: () => void
|
|
69
|
+
openCoverComponent: () => void
|
|
70
|
+
closeCoverComponent: () => void
|
|
71
|
+
toggleCoverComponent: () => void
|
|
72
|
+
renderCustomComponent: (customComponent: any) => void
|
|
73
|
+
unmountCustomComponent: () => void
|
|
74
|
+
isOnline: () => boolean
|
|
75
|
+
setOnline: (online: boolean) => void
|
|
76
|
+
getMessages: () => { id: string; ack: number; unsentInput: CoreInput }[] // TODO: define MessagesJSON
|
|
77
|
+
clearMessages: () => void
|
|
78
|
+
getLastMessageUpdate: () => string | undefined
|
|
79
|
+
updateMessageInfo: (msgId: string, messageInfo: any) => void
|
|
80
|
+
updateWebchatSettings: (settings: WebchatSettingsProps) => void
|
|
81
|
+
closeWebview: (options?: CloseWebviewOptions) => Promise<void>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface AddBotResponseArgs {
|
|
85
|
+
response: any
|
|
86
|
+
session?: any
|
|
87
|
+
lastRoutePath?: any
|
|
56
88
|
}
|
|
57
89
|
|
|
58
90
|
export interface WebchatArgs {
|
|
59
|
-
|
|
91
|
+
theme?: ThemeProps
|
|
92
|
+
persistentMenu?: PersistentMenuOptionsTheme
|
|
60
93
|
coverComponent?: CoverComponentOptions
|
|
61
|
-
|
|
62
|
-
defaultTyping?: number
|
|
63
|
-
enableAnimations?: boolean
|
|
64
|
-
enableAttachments?: boolean
|
|
94
|
+
blockInputs?: BlockInputOption[]
|
|
65
95
|
enableEmojiPicker?: boolean
|
|
96
|
+
enableAttachments?: boolean
|
|
66
97
|
enableUserInput?: boolean
|
|
67
|
-
|
|
98
|
+
enableAnimations?: boolean
|
|
68
99
|
hostId?: string
|
|
69
|
-
|
|
70
|
-
|
|
100
|
+
shadowDOM?: boolean | (() => boolean)
|
|
101
|
+
defaultDelay?: number
|
|
102
|
+
defaultTyping?: number
|
|
103
|
+
storage?: Storage | null
|
|
104
|
+
storageKey?: string
|
|
71
105
|
onInit?: (app: WebchatApp, args: any) => void
|
|
72
|
-
onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
73
106
|
onOpen?: (app: WebchatApp, args: any) => void
|
|
74
|
-
|
|
107
|
+
onClose?: (app: WebchatApp, args: any) => void
|
|
108
|
+
onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
75
109
|
onTrackEvent?: TrackEventFunction
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
110
|
+
onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
|
|
111
|
+
appId?: string
|
|
112
|
+
visibility?: boolean | (() => boolean) | 'dynamic'
|
|
113
|
+
server?: ServerConfig
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface WebchatProps {
|
|
117
|
+
webchatHooks?: UseWebchat
|
|
118
|
+
initialSession?: any
|
|
119
|
+
initialDevSettings?: any
|
|
120
|
+
onStateChange: (args: OnStateChangeArgs) => void
|
|
121
|
+
|
|
122
|
+
shadowDOM?: any
|
|
79
123
|
theme?: ThemeProps
|
|
124
|
+
persistentMenu?: PersistentMenuOptionsTheme
|
|
125
|
+
coverComponent?: CoverComponentOptions
|
|
126
|
+
blockInputs?: BlockInputOption[]
|
|
127
|
+
enableEmojiPicker?: boolean
|
|
128
|
+
enableAttachments?: boolean
|
|
129
|
+
enableUserInput?: boolean
|
|
130
|
+
enableAnimations?: boolean
|
|
131
|
+
storage?: Storage | null
|
|
132
|
+
storageKey?: string | (() => string)
|
|
133
|
+
defaultDelay?: number
|
|
134
|
+
defaultTyping?: number
|
|
135
|
+
onInit?: (args?: any) => void
|
|
136
|
+
onOpen?: (args?: any) => void
|
|
137
|
+
onClose?: (args?: any) => void
|
|
138
|
+
onUserInput(args: OnUserInputArgs): Promise<void>
|
|
139
|
+
onTrackEvent?: TrackEventFunction
|
|
140
|
+
host?: any
|
|
141
|
+
server?: ServerConfig
|
|
80
142
|
}
|
|
81
143
|
|
|
82
144
|
export type EventArgs = { [key: string]: any }
|
|
@@ -101,19 +163,19 @@ export interface WebchatMessage {
|
|
|
101
163
|
ack: 0 | 1
|
|
102
164
|
blob: boolean
|
|
103
165
|
buttons: ButtonProps[]
|
|
104
|
-
children: any
|
|
105
|
-
data: any
|
|
166
|
+
children: any // messageJSON don't have children prop
|
|
167
|
+
data: any // if message.type === 'text' => message.data = {text: string}
|
|
106
168
|
delay: number
|
|
107
169
|
display: boolean
|
|
108
|
-
enabletimestamps
|
|
170
|
+
enabletimestamps?: boolean
|
|
109
171
|
id: string
|
|
110
|
-
imagestyle
|
|
172
|
+
imagestyle?: any
|
|
111
173
|
isUnread: boolean
|
|
112
174
|
json: any
|
|
113
|
-
markdown: boolean
|
|
175
|
+
markdown: boolean // 0 | 1
|
|
114
176
|
replies: ReplyProps[]
|
|
115
177
|
sentBy: SENDERS
|
|
116
|
-
style
|
|
178
|
+
style?: any
|
|
117
179
|
timestamp: string
|
|
118
180
|
type: CoreInputType
|
|
119
181
|
typing: number
|
|
@@ -123,7 +185,7 @@ export interface OnUserInputArgs {
|
|
|
123
185
|
input: CoreInput
|
|
124
186
|
lastRoutePath?: string
|
|
125
187
|
session?: CoreSession
|
|
126
|
-
user
|
|
188
|
+
user?: CoreSessionUser
|
|
127
189
|
}
|
|
128
190
|
|
|
129
191
|
export interface OnStateChangeArgs {
|
|
@@ -137,44 +199,17 @@ export interface MessageInfo {
|
|
|
137
199
|
type: 'update_webchat_settings' | 'sender_action'
|
|
138
200
|
}
|
|
139
201
|
|
|
140
|
-
export
|
|
141
|
-
|
|
202
|
+
export type Event = ConnectionChangeEvent | UpdateMessageInfoEvent
|
|
203
|
+
|
|
204
|
+
interface ConnectionChangeEvent {
|
|
205
|
+
action: 'connectionChange'
|
|
206
|
+
online: boolean
|
|
142
207
|
isError?: boolean
|
|
143
208
|
message?: MessageInfo
|
|
144
209
|
}
|
|
145
210
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
addMessage: (message: WebchatMessage) => void
|
|
151
|
-
closeWebview: () => Promise<void>
|
|
152
|
-
getThemeProperty: (property: string, defaultValue?: any) => any
|
|
153
|
-
openWebview: (webviewComponent: Webview, params?: any) => void
|
|
154
|
-
resetUnreadMessages: () => void
|
|
155
|
-
resolveCase: () => void
|
|
156
|
-
sendAttachment: (attachment: File) => Promise<void>
|
|
157
|
-
sendInput: (input: ClientInput) => Promise<void>
|
|
158
|
-
sendPayload: (payload: string) => Promise<void>
|
|
159
|
-
sendText: (text: string, payload?: string) => Promise<void>
|
|
160
|
-
setIsInputFocused: (isInputFocused: boolean) => void
|
|
161
|
-
setLastMessageVisible: (isLastMessageVisible: boolean) => void
|
|
162
|
-
theme: ThemeProps
|
|
163
|
-
toggleWebchat: (toggle: boolean) => void
|
|
164
|
-
toggleEmojiPicker: (toggle: boolean) => void
|
|
165
|
-
togglePersistentMenu: (toggle: boolean) => void
|
|
166
|
-
toggleCoverComponent: (toggle: boolean) => void
|
|
167
|
-
updateLatestInput: (input: ClientInput) => void
|
|
168
|
-
updateMessage: (message: WebchatMessage) => void
|
|
169
|
-
updateReplies: (replies: boolean) => void
|
|
170
|
-
updateUser: (user: Partial<CoreSessionUser>) => void
|
|
171
|
-
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
172
|
-
webchatState: WebchatState
|
|
173
|
-
trackEvent: TrackEventFunction
|
|
174
|
-
webchatRef: React.MutableRefObject<HTMLDivElement | null>
|
|
175
|
-
chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
|
|
176
|
-
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
177
|
-
headerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
178
|
-
scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
|
|
179
|
-
repliesRef: React.MutableRefObject<HTMLDivElement | null>
|
|
211
|
+
interface UpdateMessageInfoEvent {
|
|
212
|
+
action: 'update_message_info'
|
|
213
|
+
message: MessageInfo
|
|
214
|
+
isError?: boolean
|
|
180
215
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
|
|
2
2
|
export * from './components'
|
|
3
|
-
export {
|
|
4
|
-
RequestContext,
|
|
5
|
-
WebchatContext,
|
|
6
|
-
WebviewRequestContext,
|
|
7
|
-
} from './contexts'
|
|
3
|
+
export { RequestContext, WebviewRequestContext } from './contexts'
|
|
8
4
|
export { DevApp } from './dev-app'
|
|
9
5
|
export * from './index-types'
|
|
10
6
|
export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
|
|
11
7
|
export { NodeApp } from './node-app'
|
|
12
8
|
export * from './util'
|
|
13
9
|
export * from './webchat'
|
|
14
|
-
export { WebchatApp
|
|
10
|
+
export { WebchatApp } from './webchat-app'
|
|
15
11
|
export { WebviewApp } from './webview-app'
|
package/src/msg-to-botonic.jsx
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
* @param customMessageTypes {{customTypeName}[]?}
|
|
33
33
|
* @return {React.ReactNode}
|
|
34
34
|
*/
|
|
35
|
-
export function msgToBotonic(msg, customMessageTypes) {
|
|
35
|
+
export function msgToBotonic(msg, customMessageTypes = []) {
|
|
36
36
|
delete msg.display
|
|
37
37
|
if (isCustom(msg)) {
|
|
38
38
|
try {
|
|
@@ -56,28 +56,28 @@ export function msgToBotonic(msg, customMessageTypes) {
|
|
|
56
56
|
<Image
|
|
57
57
|
key={msg.key}
|
|
58
58
|
{...msg}
|
|
59
|
-
src={msg.data.image
|
|
59
|
+
src={msg.data.image !== undefined ? msg.data.image : msg.data}
|
|
60
60
|
/>
|
|
61
61
|
)
|
|
62
62
|
} else if (isVideo(msg)) {
|
|
63
63
|
return (
|
|
64
64
|
<Video
|
|
65
65
|
{...msg}
|
|
66
|
-
src={msg.data.video
|
|
66
|
+
src={msg.data.video !== undefined ? msg.data.video : msg.data}
|
|
67
67
|
/>
|
|
68
68
|
)
|
|
69
69
|
} else if (isAudio(msg)) {
|
|
70
70
|
return (
|
|
71
71
|
<Audio
|
|
72
72
|
{...msg}
|
|
73
|
-
src={msg.data.audio
|
|
73
|
+
src={msg.data.audio !== undefined ? msg.data.audio : msg.data}
|
|
74
74
|
/>
|
|
75
75
|
)
|
|
76
76
|
} else if (isDocument(msg)) {
|
|
77
77
|
return (
|
|
78
78
|
<Document
|
|
79
79
|
{...msg}
|
|
80
|
-
src={msg.data.document
|
|
80
|
+
src={msg.data.document !== undefined ? msg.data.document : msg.data}
|
|
81
81
|
/>
|
|
82
82
|
)
|
|
83
83
|
} else if (isLocation(msg)) {
|
|
@@ -99,10 +99,6 @@ export function msgToBotonic(msg, customMessageTypes) {
|
|
|
99
99
|
return null
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function rndStr() {
|
|
103
|
-
return Math.random().toString()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
102
|
/**
|
|
107
103
|
* @param msgs {object|object[]}
|
|
108
104
|
* @param customMessageTypes {{customTypeName}[]?}
|
|
@@ -3,6 +3,7 @@ import UAParser from 'ua-parser-js'
|
|
|
3
3
|
import { v7 as uuidv7 } from 'uuid'
|
|
4
4
|
|
|
5
5
|
import { WEBCHAT } from '../constants'
|
|
6
|
+
import { ThemeProps } from '../webchat/theme/types'
|
|
6
7
|
import { getProperty } from './objects'
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -11,13 +12,12 @@ import { getProperty } from './objects'
|
|
|
11
12
|
* If property doesn't exist, returns the defaultValue.
|
|
12
13
|
*/
|
|
13
14
|
export const _getThemeProperty =
|
|
14
|
-
theme =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const nestedProperty = getProperty(theme, v)
|
|
15
|
+
(theme: ThemeProps) => (property: string, defaultValue?: any) => {
|
|
16
|
+
for (const [key, value] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
|
|
17
|
+
if (value === property) {
|
|
18
|
+
const nestedProperty = getProperty(theme, value)
|
|
19
19
|
if (nestedProperty !== undefined) return nestedProperty
|
|
20
|
-
const plainProperty = getProperty(theme,
|
|
20
|
+
const plainProperty = getProperty(theme, key)
|
|
21
21
|
if (plainProperty !== undefined) return plainProperty
|
|
22
22
|
return defaultValue
|
|
23
23
|
}
|
|
@@ -25,7 +25,10 @@ export const _getThemeProperty =
|
|
|
25
25
|
return undefined
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const createUser = ()
|
|
28
|
+
export const createUser = (): {
|
|
29
|
+
id: string
|
|
30
|
+
name: string
|
|
31
|
+
} => {
|
|
29
32
|
const parser = new UAParser()
|
|
30
33
|
const ua = parser.getResult()
|
|
31
34
|
let name = `${ua.os.name} ${ua.browser.name}`
|
|
@@ -35,9 +38,11 @@ export const createUser = () => {
|
|
|
35
38
|
name,
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
export const initSession =
|
|
41
|
+
export const initSession = (
|
|
42
|
+
session: any
|
|
43
|
+
): { user: { id: string; name: string } } => {
|
|
39
44
|
if (!session) session = {}
|
|
40
|
-
const hasUserId = session
|
|
45
|
+
const hasUserId = session?.user?.id !== undefined
|
|
41
46
|
if (!session.user || Object.keys(session.user).length === 0 || !hasUserId)
|
|
42
47
|
session.user = !hasUserId ? merge(session.user, createUser()) : createUser()
|
|
43
48
|
return session
|
|
@@ -48,6 +53,7 @@ export const shouldKeepSessionOnReload = ({
|
|
|
48
53
|
devSettings,
|
|
49
54
|
}) => !initialDevSettings || (devSettings && devSettings.keepSessionOnReload)
|
|
50
55
|
|
|
56
|
+
//TODO: Review param serverConfig if is of type ServerConfig this never have errorMessage
|
|
51
57
|
export const getServerErrorMessage = serverConfig => {
|
|
52
58
|
if (!serverConfig || !serverConfig.errorMessage) return 'Connection issues'
|
|
53
59
|
if (typeof serverConfig.errorMessage === 'function') {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebchatContext } from '../../contexts'
|
|
4
3
|
import { BotonicContainerId } from '../constants'
|
|
4
|
+
import { WebchatContext } from '../context'
|
|
5
5
|
import { useWebchatDimensions } from '../hooks'
|
|
6
6
|
import { WebchatMessageList } from '../message-list'
|
|
7
7
|
import { WebchatReplies } from '../replies'
|
|
@@ -27,9 +27,7 @@ export const ChatArea = () => {
|
|
|
27
27
|
height={chatAreaHeight}
|
|
28
28
|
>
|
|
29
29
|
<WebchatMessageList />
|
|
30
|
-
{replies &&
|
|
31
|
-
<WebchatReplies replies={replies} />
|
|
32
|
-
)}
|
|
30
|
+
{replies && replies.length > 0 && <WebchatReplies />}
|
|
33
31
|
</StyledChatArea>
|
|
34
32
|
)
|
|
35
33
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import { WEBCHAT } from '../../constants'
|
|
4
|
-
import { WebchatContext } from '../../contexts'
|
|
5
4
|
import { Scale } from '../../shared/styles'
|
|
6
5
|
import { ConditionalWrapper } from '../../util/react'
|
|
6
|
+
import { WebchatContext } from '../context'
|
|
7
7
|
|
|
8
8
|
export const ConditionalAnimation = props => {
|
|
9
9
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
@@ -3,7 +3,7 @@ import styled from 'styled-components'
|
|
|
3
3
|
|
|
4
4
|
import { Button } from '../../components/button'
|
|
5
5
|
import { ROLES, WEBCHAT } from '../../constants'
|
|
6
|
-
import { WebchatContext } from '
|
|
6
|
+
import { WebchatContext } from '../context'
|
|
7
7
|
import { useComponentVisible } from '../hooks'
|
|
8
8
|
|
|
9
9
|
const ButtonsContainer = styled.div`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
export enum WebchatAction {
|
|
2
3
|
ADD_MESSAGE = 'addMessage',
|
|
3
4
|
ADD_MESSAGE_COMPONENT = 'addMessageComponent',
|
|
@@ -23,5 +24,7 @@ export enum WebchatAction {
|
|
|
23
24
|
UPDATE_THEME = 'updateTheme',
|
|
24
25
|
UPDATE_TYPING = 'updateTyping',
|
|
25
26
|
UPDATE_WEBVIEW = 'updateWebview',
|
|
27
|
+
REMOVE_REPLIES = 'removeReplies',
|
|
28
|
+
REMOVE_WEBVIEW = 'removeWebview',
|
|
26
29
|
SET_IS_INPUT_FOCUSED = 'setIsInputFocused',
|
|
27
30
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WebchatContextProps } from './types'
|
|
4
|
+
import { webchatInitialState } from './use-webchat'
|
|
5
|
+
|
|
6
|
+
export { WebchatState } from './types'
|
|
7
|
+
export { useWebchat, webchatInitialState } from './use-webchat'
|
|
8
|
+
|
|
9
|
+
export const WebchatContext = createContext<WebchatContextProps>({
|
|
10
|
+
addMessage: () => {
|
|
11
|
+
return
|
|
12
|
+
},
|
|
13
|
+
getThemeProperty: () => {
|
|
14
|
+
return
|
|
15
|
+
}, // used to retrieve a specific property of the theme defined by the developer in his 'webchat/index.js'
|
|
16
|
+
openWebview: () => {
|
|
17
|
+
return
|
|
18
|
+
},
|
|
19
|
+
resolveCase: () => {
|
|
20
|
+
return
|
|
21
|
+
},
|
|
22
|
+
resetUnreadMessages: () => {
|
|
23
|
+
return
|
|
24
|
+
},
|
|
25
|
+
setIsInputFocused: () => {
|
|
26
|
+
return
|
|
27
|
+
},
|
|
28
|
+
setLastMessageVisible: () => {
|
|
29
|
+
return
|
|
30
|
+
},
|
|
31
|
+
sendAttachment: async () => {
|
|
32
|
+
return
|
|
33
|
+
},
|
|
34
|
+
sendInput: async () => {
|
|
35
|
+
return
|
|
36
|
+
},
|
|
37
|
+
sendPayload: async () => {
|
|
38
|
+
return
|
|
39
|
+
},
|
|
40
|
+
sendText: async () => {
|
|
41
|
+
return
|
|
42
|
+
},
|
|
43
|
+
theme: {}, // TODO: Remove this attribute and use allways webchatState.theme
|
|
44
|
+
toggleCoverComponent: () => {
|
|
45
|
+
return
|
|
46
|
+
},
|
|
47
|
+
toggleWebchat: () => {
|
|
48
|
+
return
|
|
49
|
+
},
|
|
50
|
+
toggleEmojiPicker: () => {
|
|
51
|
+
return
|
|
52
|
+
},
|
|
53
|
+
togglePersistentMenu: () => {
|
|
54
|
+
return
|
|
55
|
+
},
|
|
56
|
+
updateLatestInput: () => {
|
|
57
|
+
return
|
|
58
|
+
},
|
|
59
|
+
updateMessage: () => {
|
|
60
|
+
return
|
|
61
|
+
},
|
|
62
|
+
updateReplies: () => {
|
|
63
|
+
return
|
|
64
|
+
},
|
|
65
|
+
updateUser: () => {
|
|
66
|
+
return
|
|
67
|
+
},
|
|
68
|
+
updateWebchatDevSettings: () => {
|
|
69
|
+
return
|
|
70
|
+
},
|
|
71
|
+
webchatState: webchatInitialState,
|
|
72
|
+
trackEvent: async () => {
|
|
73
|
+
return
|
|
74
|
+
},
|
|
75
|
+
webchatRef: { current: null },
|
|
76
|
+
chatAreaRef: { current: null },
|
|
77
|
+
inputPanelRef: { current: null },
|
|
78
|
+
headerRef: { current: null },
|
|
79
|
+
scrollableMessagesListRef: { current: null },
|
|
80
|
+
repliesRef: { current: null },
|
|
81
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SENDERS } from '
|
|
1
|
+
import { SENDERS } from '../../index-types'
|
|
2
2
|
import { WebchatAction } from './actions'
|
|
3
|
-
import { WebchatState } from './
|
|
3
|
+
import { WebchatState } from './types'
|
|
4
4
|
|
|
5
5
|
export const messagesReducer = (
|
|
6
6
|
state: WebchatState,
|
|
@@ -15,6 +15,8 @@ export const messagesReducer = (
|
|
|
15
15
|
return updateMessageReducer(state, action)
|
|
16
16
|
case WebchatAction.UPDATE_REPLIES:
|
|
17
17
|
return { ...state, replies: action.payload }
|
|
18
|
+
case WebchatAction.REMOVE_REPLIES:
|
|
19
|
+
return { ...state, replies: undefined }
|
|
18
20
|
case WebchatAction.CLEAR_MESSAGES:
|
|
19
21
|
return {
|
|
20
22
|
...state,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Input as CoreInput,
|
|
3
|
+
Session as CoreSession,
|
|
4
|
+
SessionUser as CoreSessionUser,
|
|
5
|
+
} from '@botonic/core'
|
|
6
|
+
|
|
7
|
+
import { Reply, WebchatSettingsProps, Webview } from '../../components'
|
|
8
|
+
import { TrackEventFunction, WebchatMessage } from '../../index-types'
|
|
9
|
+
import { WebchatStateTheme } from '../index-types'
|
|
10
|
+
import { ThemeProps } from '../theme/types'
|
|
11
|
+
|
|
12
|
+
export interface ErrorMessage {
|
|
13
|
+
message?: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DevSettings {
|
|
17
|
+
keepSessionOnReload?: boolean
|
|
18
|
+
showSessionView?: boolean
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface WebchatState {
|
|
22
|
+
width: number // TODO: move this inside webchatState.theme.style
|
|
23
|
+
height: number // TODO: move this inside webchatState.theme.style
|
|
24
|
+
messagesJSON: any[]
|
|
25
|
+
messagesComponents: any[]
|
|
26
|
+
replies?: (typeof Reply)[]
|
|
27
|
+
latestInput: Partial<CoreInput>
|
|
28
|
+
typing: boolean
|
|
29
|
+
webview: Webview | null
|
|
30
|
+
webviewParams: null
|
|
31
|
+
session: Partial<CoreSession>
|
|
32
|
+
lastRoutePath?: string
|
|
33
|
+
handoff: boolean
|
|
34
|
+
theme: WebchatStateTheme // TODO: type this as ThemeProps
|
|
35
|
+
themeUpdates: Partial<WebchatStateTheme> // TODO: type this as Partial<ThemeProps>
|
|
36
|
+
error: ErrorMessage
|
|
37
|
+
online: boolean
|
|
38
|
+
devSettings: DevSettings
|
|
39
|
+
isWebchatOpen: boolean
|
|
40
|
+
isEmojiPickerOpen: boolean
|
|
41
|
+
isPersistentMenuOpen: boolean
|
|
42
|
+
isCoverComponentOpen: boolean
|
|
43
|
+
isCustomComponentRendered: boolean
|
|
44
|
+
lastMessageUpdate?: string
|
|
45
|
+
currentAttachment?: File
|
|
46
|
+
numUnreadMessages: number
|
|
47
|
+
isLastMessageVisible: boolean
|
|
48
|
+
isInputFocused: boolean
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ClientInput: type for sendInput and updateLatestInput function without message_id and bot_interaction_id because backend set this values
|
|
52
|
+
export type ClientInput = Omit<CoreInput, 'message_id' | 'bot_interaction_id'>
|
|
53
|
+
|
|
54
|
+
export interface WebchatContextProps {
|
|
55
|
+
addMessage: (message: WebchatMessage) => void
|
|
56
|
+
getThemeProperty: (property: string, defaultValue?: any) => any
|
|
57
|
+
openWebview: (webviewComponent: Webview, params?: any) => void
|
|
58
|
+
resetUnreadMessages: () => void
|
|
59
|
+
resolveCase: () => void
|
|
60
|
+
sendAttachment: (attachment: File) => Promise<void>
|
|
61
|
+
sendInput: (input: ClientInput) => Promise<void>
|
|
62
|
+
sendPayload: (payload: string) => Promise<void>
|
|
63
|
+
sendText: (text: string, payload?: string) => Promise<void>
|
|
64
|
+
setIsInputFocused: (isInputFocused: boolean) => void
|
|
65
|
+
setLastMessageVisible: (isLastMessageVisible: boolean) => void
|
|
66
|
+
theme: ThemeProps // TODO: Remove this attribute and use allways webchatState.theme
|
|
67
|
+
toggleWebchat: (toggle: boolean) => void
|
|
68
|
+
toggleEmojiPicker: (toggle: boolean) => void
|
|
69
|
+
togglePersistentMenu: (toggle: boolean) => void
|
|
70
|
+
toggleCoverComponent: (toggle: boolean) => void
|
|
71
|
+
updateLatestInput: (input: ClientInput) => void
|
|
72
|
+
updateMessage: (message: WebchatMessage) => void
|
|
73
|
+
updateReplies: (replies: (typeof Reply)[]) => void
|
|
74
|
+
updateUser: (user: Partial<CoreSessionUser>) => void
|
|
75
|
+
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
76
|
+
trackEvent?: TrackEventFunction
|
|
77
|
+
webchatState: WebchatState
|
|
78
|
+
webchatRef: React.MutableRefObject<HTMLDivElement | null> // Rename this to webchatContainerRef
|
|
79
|
+
chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
|
|
80
|
+
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
81
|
+
headerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
82
|
+
scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
|
|
83
|
+
repliesRef: React.MutableRefObject<HTMLDivElement | null>
|
|
84
|
+
}
|