@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
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
INPUT,
|
|
4
4
|
isMobile,
|
|
5
5
|
params2queryString,
|
|
6
|
+
Session as CoreSession,
|
|
6
7
|
} from '@botonic/core'
|
|
7
8
|
import merge from 'lodash.merge'
|
|
8
9
|
import React, {
|
|
@@ -12,15 +13,22 @@ import React, {
|
|
|
12
13
|
useRef,
|
|
13
14
|
useState,
|
|
14
15
|
} from 'react'
|
|
15
|
-
import
|
|
16
|
+
import { StyleSheetManager } from 'styled-components'
|
|
16
17
|
import { v7 as uuidv7 } from 'uuid'
|
|
17
18
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
import {
|
|
20
|
+
Audio,
|
|
21
|
+
Document,
|
|
22
|
+
Handoff,
|
|
23
|
+
Image,
|
|
24
|
+
normalizeWebchatSettings,
|
|
25
|
+
Text,
|
|
26
|
+
Video,
|
|
27
|
+
WebchatSettingsProps,
|
|
28
|
+
} from '../components'
|
|
21
29
|
import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../constants'
|
|
22
|
-
import {
|
|
23
|
-
import { SENDERS } from '../index-types'
|
|
30
|
+
import { CloseWebviewOptions, WebviewRequestContext } from '../contexts'
|
|
31
|
+
import { SENDERS, WebchatProps, WebchatRef } from '../index-types'
|
|
24
32
|
import {
|
|
25
33
|
getMediaType,
|
|
26
34
|
isAllowedSize,
|
|
@@ -44,6 +52,7 @@ import {
|
|
|
44
52
|
import { ChatArea } from './chat-area'
|
|
45
53
|
import { OpenedPersistentMenu } from './components/opened-persistent-menu'
|
|
46
54
|
import { BotonicContainerId } from './constants'
|
|
55
|
+
import { useWebchat, WebchatContext, WebchatState } from './context'
|
|
47
56
|
import { CoverComponent } from './cover-component'
|
|
48
57
|
import { WebchatHeader } from './header'
|
|
49
58
|
import {
|
|
@@ -51,73 +60,26 @@ import {
|
|
|
51
60
|
usePrevious,
|
|
52
61
|
useScrollToBottom,
|
|
53
62
|
useTyping,
|
|
54
|
-
useWebchat,
|
|
55
63
|
} from './hooks'
|
|
56
64
|
import { InputPanel } from './input-panel'
|
|
65
|
+
import {
|
|
66
|
+
DarkBackgroundMenu,
|
|
67
|
+
ErrorMessage,
|
|
68
|
+
ErrorMessageContainer,
|
|
69
|
+
StyledWebchat,
|
|
70
|
+
} from './styles'
|
|
57
71
|
import { TriggerButton } from './trigger-button'
|
|
58
72
|
import { useStorageState } from './use-storage-state-hook'
|
|
59
73
|
import { getParsedAction } from './utils'
|
|
60
74
|
import { WebviewContainer } from './webview'
|
|
61
75
|
|
|
62
|
-
const StyledWebchat = styled.div`
|
|
63
|
-
position: fixed;
|
|
64
|
-
right: 20px;
|
|
65
|
-
bottom: 20px;
|
|
66
|
-
width: ${props => props.width}px;
|
|
67
|
-
height: ${props => props.height}px;
|
|
68
|
-
margin: auto;
|
|
69
|
-
background-color: ${COLORS.SOLID_WHITE};
|
|
70
|
-
border-radius: 10px;
|
|
71
|
-
box-shadow: ${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
|
|
72
|
-
display: flex;
|
|
73
|
-
flex-direction: column;
|
|
74
|
-
justify-content: space-between;
|
|
75
|
-
overflow: hidden;
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
const ErrorMessageContainer = styled.div`
|
|
79
|
-
position: relative;
|
|
80
|
-
display: flex;
|
|
81
|
-
z-index: 1;
|
|
82
|
-
justify-content: center;
|
|
83
|
-
width: 100%;
|
|
84
|
-
`
|
|
85
|
-
|
|
86
|
-
const ErrorMessage = styled.div`
|
|
87
|
-
position: absolute;
|
|
88
|
-
top: 10px;
|
|
89
|
-
font-size: 14px;
|
|
90
|
-
line-height: 20px;
|
|
91
|
-
padding: 4px 11px;
|
|
92
|
-
display: flex;
|
|
93
|
-
background-color: ${COLORS.ERROR_RED};
|
|
94
|
-
color: ${COLORS.CONCRETE_WHITE};
|
|
95
|
-
border-radius: 5px;
|
|
96
|
-
align-items: center;
|
|
97
|
-
justify-content: center;
|
|
98
|
-
font-family: ${WEBCHAT.DEFAULTS.FONT_FAMILY};
|
|
99
|
-
`
|
|
100
|
-
|
|
101
|
-
const DarkBackgroundMenu = styled.div`
|
|
102
|
-
background: ${COLORS.SOLID_BLACK};
|
|
103
|
-
opacity: 0.3;
|
|
104
|
-
z-index: 1;
|
|
105
|
-
right: 0;
|
|
106
|
-
bottom: 0;
|
|
107
|
-
border-radius: 10px;
|
|
108
|
-
position: absolute;
|
|
109
|
-
width: 100%;
|
|
110
|
-
height: 100%;
|
|
111
|
-
`
|
|
112
|
-
|
|
113
76
|
// eslint-disable-next-line complexity, react/display-name
|
|
114
|
-
|
|
77
|
+
const Webchat = forwardRef<WebchatRef | null, WebchatProps>((props, ref) => {
|
|
115
78
|
const {
|
|
116
79
|
addMessage,
|
|
117
80
|
addMessageComponent,
|
|
118
81
|
clearMessages,
|
|
119
82
|
doRenderCustomComponent,
|
|
120
|
-
openWebviewT,
|
|
121
83
|
resetUnreadMessages,
|
|
122
84
|
setCurrentAttachment,
|
|
123
85
|
setError,
|
|
@@ -139,15 +101,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
139
101
|
updateTheme,
|
|
140
102
|
updateTyping,
|
|
141
103
|
updateWebview,
|
|
104
|
+
removeWebview,
|
|
105
|
+
removeReplies,
|
|
142
106
|
webchatState,
|
|
143
107
|
webchatRef,
|
|
144
108
|
chatAreaRef,
|
|
145
109
|
inputPanelRef,
|
|
146
110
|
headerRef,
|
|
111
|
+
repliesRef,
|
|
147
112
|
scrollableMessagesListRef,
|
|
148
|
-
|
|
149
113
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
150
114
|
} = props.webchatHooks || useWebchat()
|
|
115
|
+
|
|
151
116
|
const firstUpdate = useRef(true)
|
|
152
117
|
const isOnline = () => webchatState.online
|
|
153
118
|
const currentDateString = () => new Date().toISOString()
|
|
@@ -168,7 +133,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
168
133
|
|
|
169
134
|
const { scrollToBottom } = useScrollToBottom({ host })
|
|
170
135
|
|
|
171
|
-
const saveWebchatState = webchatState => {
|
|
136
|
+
const saveWebchatState = (webchatState: WebchatState) => {
|
|
172
137
|
storage &&
|
|
173
138
|
saveState(
|
|
174
139
|
JSON.parse(
|
|
@@ -184,32 +149,34 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
184
149
|
)
|
|
185
150
|
}
|
|
186
151
|
|
|
187
|
-
const handleAttachment = event => {
|
|
152
|
+
const handleAttachment = (event: any) => {
|
|
188
153
|
if (!isAllowedSize(event.target.files[0].size)) {
|
|
189
154
|
throw new Error(
|
|
190
155
|
`The file is too large. A maximum of ${MAX_ALLOWED_SIZE_MB}MB is allowed.`
|
|
191
156
|
)
|
|
192
157
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
attachmentType: getMediaType(event.target.files[0].type),
|
|
197
|
-
})
|
|
158
|
+
|
|
159
|
+
// TODO: Attach more files?
|
|
160
|
+
setCurrentAttachment(event.target.files[0])
|
|
198
161
|
}
|
|
199
162
|
|
|
200
163
|
useEffect(() => {
|
|
201
|
-
if (webchatState.currentAttachment)
|
|
164
|
+
if (webchatState.currentAttachment) {
|
|
202
165
|
sendAttachment(webchatState.currentAttachment)
|
|
166
|
+
}
|
|
203
167
|
}, [webchatState.currentAttachment])
|
|
204
168
|
|
|
205
|
-
const sendUserInput = async input => {
|
|
169
|
+
const sendUserInput = async (input: any) => {
|
|
206
170
|
if (props.onUserInput) {
|
|
207
171
|
resetUnreadMessages()
|
|
208
172
|
scrollToBottom()
|
|
209
173
|
props.onUserInput({
|
|
210
174
|
user: webchatState.session.user,
|
|
175
|
+
// TODO: Review if this input.sentBy exists in the frontend
|
|
211
176
|
input: input,
|
|
177
|
+
//@ts-ignore
|
|
212
178
|
session: webchatState.session,
|
|
179
|
+
// TODO: Review why we were passing lastRoutePath, is only for devMode?
|
|
213
180
|
lastRoutePath: webchatState.lastRoutePath,
|
|
214
181
|
})
|
|
215
182
|
}
|
|
@@ -261,9 +228,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
261
228
|
addMessage(message)
|
|
262
229
|
const newMessageComponent = msgToBotonic(
|
|
263
230
|
{ ...message, delay: 0, typing: 0 },
|
|
264
|
-
|
|
265
|
-
props.theme.customMessageTypes
|
|
231
|
+
props.theme?.message?.customTypes || props.theme?.customMessageTypes
|
|
266
232
|
)
|
|
233
|
+
//@ts-ignore
|
|
267
234
|
if (newMessageComponent) addMessageComponent(newMessageComponent)
|
|
268
235
|
})
|
|
269
236
|
}
|
|
@@ -272,10 +239,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
272
239
|
} else updateSession(merge(initialSession, session))
|
|
273
240
|
if (devSettings) updateDevSettings(devSettings)
|
|
274
241
|
else if (initialDevSettings) updateDevSettings(initialDevSettings)
|
|
275
|
-
|
|
276
|
-
if (
|
|
242
|
+
|
|
243
|
+
if (lastMessageUpdate) {
|
|
244
|
+
updateLastMessageDate(lastMessageUpdate)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (themeUpdates !== undefined) {
|
|
277
248
|
updateTheme(merge(props.theme, themeUpdates), themeUpdates)
|
|
278
|
-
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (props.onInit) {
|
|
252
|
+
setTimeout(() => props.onInit && props.onInit(), 100)
|
|
253
|
+
}
|
|
279
254
|
}, [])
|
|
280
255
|
|
|
281
256
|
useEffect(() => {
|
|
@@ -288,8 +263,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
288
263
|
}, [webchatState.isWebchatOpen])
|
|
289
264
|
|
|
290
265
|
useEffect(() => {
|
|
291
|
-
|
|
292
|
-
|
|
266
|
+
const { messagesJSON, session } = webchatState
|
|
267
|
+
if (onStateChange && typeof onStateChange === 'function' && session.user) {
|
|
268
|
+
onStateChange({ messagesJSON, user: session.user })
|
|
293
269
|
}
|
|
294
270
|
saveWebchatState(webchatState)
|
|
295
271
|
}, [
|
|
@@ -322,12 +298,12 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
322
298
|
updateWebview(webviewComponent, params)
|
|
323
299
|
}
|
|
324
300
|
|
|
325
|
-
const textareaRef = useRef(
|
|
301
|
+
const textareaRef = useRef<HTMLTextAreaElement | undefined>()
|
|
326
302
|
|
|
327
|
-
const closeWebview = async options => {
|
|
328
|
-
|
|
303
|
+
const closeWebview = async (options?: CloseWebviewOptions) => {
|
|
304
|
+
removeWebview()
|
|
329
305
|
if (userInputEnabled) {
|
|
330
|
-
textareaRef.current
|
|
306
|
+
textareaRef.current?.focus()
|
|
331
307
|
}
|
|
332
308
|
if (options?.payload) {
|
|
333
309
|
await sendPayload(options.payload)
|
|
@@ -369,7 +345,10 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
369
345
|
if (getBlockInputs(rule, input.data)) {
|
|
370
346
|
addMessageComponent(
|
|
371
347
|
<Text
|
|
372
|
-
|
|
348
|
+
// Is necessary to add the id of the input
|
|
349
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
350
|
+
// @ts-ignore
|
|
351
|
+
id={input.id}
|
|
373
352
|
sentBy={SENDERS.user}
|
|
374
353
|
blob={false}
|
|
375
354
|
style={{
|
|
@@ -381,7 +360,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
381
360
|
{rule.message}
|
|
382
361
|
</Text>
|
|
383
362
|
)
|
|
384
|
-
|
|
363
|
+
removeReplies()
|
|
385
364
|
return true
|
|
386
365
|
}
|
|
387
366
|
}
|
|
@@ -422,17 +401,32 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
422
401
|
}, [])
|
|
423
402
|
|
|
424
403
|
const messageComponentFromInput = input => {
|
|
425
|
-
let messageComponent = null
|
|
404
|
+
let messageComponent: any = null
|
|
426
405
|
if (isText(input)) {
|
|
427
406
|
messageComponent = (
|
|
428
|
-
|
|
429
|
-
|
|
407
|
+
<Text
|
|
408
|
+
// Is necessary to add the id of the input
|
|
409
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
410
|
+
// @ts-ignore
|
|
411
|
+
id={input.id}
|
|
412
|
+
// Is necessary to add the payload of the input when user clicks a button
|
|
413
|
+
// @ts-ignore
|
|
414
|
+
payload={input.payload}
|
|
415
|
+
sentBy={SENDERS.user}
|
|
416
|
+
>
|
|
430
417
|
{input.data}
|
|
431
418
|
</Text>
|
|
432
419
|
)
|
|
433
420
|
} else if (isMedia(input)) {
|
|
434
421
|
const temporaryDisplayUrl = URL.createObjectURL(input.data)
|
|
435
|
-
|
|
422
|
+
// TODO: We sould use URL.revokeObjectURL(temporaryDisplayUrl) when the component is unmounted
|
|
423
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL_static#memory_management
|
|
424
|
+
const mediaProps: {
|
|
425
|
+
id: string
|
|
426
|
+
sentBy: SENDERS
|
|
427
|
+
src: string
|
|
428
|
+
input?: any
|
|
429
|
+
} = {
|
|
436
430
|
id: input.id,
|
|
437
431
|
sentBy: SENDERS.user,
|
|
438
432
|
src: temporaryDisplayUrl,
|
|
@@ -448,7 +442,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
448
442
|
return messageComponent
|
|
449
443
|
}
|
|
450
444
|
|
|
451
|
-
const sendInput = async input => {
|
|
445
|
+
const sendInput = async (input: any) => {
|
|
452
446
|
if (!input || Object.keys(input).length == 0) return
|
|
453
447
|
if (isText(input) && (!input.data || !input.data.trim())) return // in case trim() doesn't work in a browser we can use !/\S/.test(input.data)
|
|
454
448
|
if (isText(input) && checkBlockInput(input)) return
|
|
@@ -459,7 +453,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
459
453
|
sendUserInput(input)
|
|
460
454
|
updateLatestInput(input)
|
|
461
455
|
isOnline() && updateLastMessageDate(currentDateString())
|
|
462
|
-
|
|
456
|
+
removeReplies()
|
|
463
457
|
togglePersistentMenu(false)
|
|
464
458
|
toggleEmojiPicker(false)
|
|
465
459
|
}
|
|
@@ -468,7 +462,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
468
462
|
https://stackoverflow.com/questions/37949981/call-child-method-from-parent
|
|
469
463
|
*/
|
|
470
464
|
|
|
471
|
-
const updateSessionWithUser = userToUpdate =>
|
|
465
|
+
const updateSessionWithUser = (userToUpdate: any) =>
|
|
472
466
|
updateSession(merge(webchatState.session, { user: userToUpdate }))
|
|
473
467
|
|
|
474
468
|
useImperativeHandle(ref, () => ({
|
|
@@ -501,7 +495,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
501
495
|
|
|
502
496
|
updateLastMessageDate(currentDateString())
|
|
503
497
|
},
|
|
504
|
-
setTyping: typing => updateTyping(typing),
|
|
498
|
+
setTyping: (typing: boolean) => updateTyping(typing),
|
|
505
499
|
addUserMessage: message => sendInput(message),
|
|
506
500
|
updateUser: updateSessionWithUser,
|
|
507
501
|
openWebchat: () => toggleWebchat(true),
|
|
@@ -516,25 +510,23 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
516
510
|
unmountCustomComponent: () => doRenderCustomComponent(false),
|
|
517
511
|
toggleCoverComponent: () =>
|
|
518
512
|
toggleCoverComponent(!webchatState.isCoverComponentOpen),
|
|
519
|
-
openWebviewApi: component => openWebviewT(component),
|
|
520
|
-
setError,
|
|
521
513
|
setOnline,
|
|
522
514
|
getMessages: () => webchatState.messagesJSON,
|
|
523
515
|
isOnline,
|
|
524
516
|
clearMessages: () => {
|
|
525
517
|
clearMessages()
|
|
526
|
-
|
|
518
|
+
removeReplies()
|
|
527
519
|
},
|
|
528
520
|
getLastMessageUpdate: () => webchatState.lastMessageUpdate,
|
|
529
|
-
updateMessageInfo: (msgId, messageInfo) => {
|
|
521
|
+
updateMessageInfo: (msgId: string, messageInfo: any) => {
|
|
530
522
|
const messageToUpdate = webchatState.messagesJSON.filter(
|
|
531
|
-
m => m.id
|
|
523
|
+
m => m.id === msgId
|
|
532
524
|
)[0]
|
|
533
525
|
const updatedMsg = merge(messageToUpdate, messageInfo)
|
|
534
526
|
if (updatedMsg.ack === 1) delete updatedMsg.unsentInput
|
|
535
527
|
updateMessage(updatedMsg)
|
|
536
528
|
},
|
|
537
|
-
updateWebchatSettings: settings => {
|
|
529
|
+
updateWebchatSettings: (settings: WebchatSettingsProps) => {
|
|
538
530
|
if (settings.user) {
|
|
539
531
|
updateSessionWithUser(settings.user)
|
|
540
532
|
}
|
|
@@ -542,57 +534,54 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
542
534
|
updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates)
|
|
543
535
|
updateTyping(false)
|
|
544
536
|
},
|
|
545
|
-
closeWebview:
|
|
537
|
+
closeWebview: async (options?: CloseWebviewOptions) =>
|
|
538
|
+
closeWebview(options),
|
|
546
539
|
}))
|
|
547
540
|
|
|
548
541
|
const resolveCase = () => {
|
|
549
542
|
updateHandoff(false)
|
|
550
|
-
updateSession({ ...webchatState.session, _botonic_action:
|
|
543
|
+
updateSession({ ...webchatState.session, _botonic_action: undefined })
|
|
551
544
|
}
|
|
552
545
|
|
|
553
546
|
const prevSession = usePrevious(webchatState.session)
|
|
554
547
|
useEffect(() => {
|
|
555
548
|
// Resume conversation after handoff
|
|
556
|
-
if (
|
|
557
|
-
prevSession &&
|
|
558
|
-
prevSession._botonic_action &&
|
|
559
|
-
!webchatState.session._botonic_action
|
|
560
|
-
) {
|
|
549
|
+
if (prevSession?._botonic_action && !webchatState.session._botonic_action) {
|
|
561
550
|
const action = getParsedAction(prevSession._botonic_action)
|
|
562
|
-
if (action
|
|
551
|
+
if (action?.on_finish) sendPayload(action.on_finish)
|
|
563
552
|
}
|
|
564
553
|
}, [webchatState.session._botonic_action])
|
|
565
554
|
|
|
566
|
-
const sendText = async (text, payload) => {
|
|
555
|
+
const sendText = async (text: string, payload?: string) => {
|
|
567
556
|
if (!text) return
|
|
568
557
|
const input = { type: INPUT.TEXT, data: text, payload }
|
|
569
558
|
await sendInput(input)
|
|
570
559
|
}
|
|
571
560
|
|
|
572
|
-
const sendPayload = async payload => {
|
|
561
|
+
const sendPayload = async (payload: string) => {
|
|
573
562
|
if (!payload) return
|
|
574
563
|
const input = { type: INPUT.POSTBACK, payload }
|
|
575
564
|
await sendInput(input)
|
|
576
565
|
}
|
|
577
566
|
|
|
578
|
-
const sendAttachment = async attachment => {
|
|
579
|
-
if (attachment
|
|
580
|
-
const attachmentType = getMediaType(attachment.
|
|
567
|
+
const sendAttachment = async (attachment: File) => {
|
|
568
|
+
if (attachment) {
|
|
569
|
+
const attachmentType = getMediaType(attachment.type)
|
|
581
570
|
if (!attachmentType) return
|
|
582
571
|
const input = {
|
|
583
572
|
type: attachmentType,
|
|
584
|
-
data: attachment
|
|
573
|
+
data: attachment,
|
|
585
574
|
}
|
|
586
575
|
await sendInput(input)
|
|
587
|
-
setCurrentAttachment(
|
|
576
|
+
setCurrentAttachment()
|
|
588
577
|
}
|
|
589
578
|
}
|
|
590
579
|
|
|
591
580
|
const webviewRequestContext = {
|
|
592
|
-
closeWebview:
|
|
593
|
-
|
|
594
|
-
params: webchatState.webviewParams || {},
|
|
595
|
-
session: webchatState.session || {},
|
|
581
|
+
closeWebview: async (options?: CloseWebviewOptions) =>
|
|
582
|
+
await closeWebview(options),
|
|
583
|
+
params: webchatState.webviewParams || ({} as Record<string, any>),
|
|
584
|
+
session: webchatState.session || ({} as Partial<CoreSession>),
|
|
596
585
|
}
|
|
597
586
|
|
|
598
587
|
useEffect(() => {
|
|
@@ -631,6 +620,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
631
620
|
/>
|
|
632
621
|
</WebviewRequestContext.Provider>
|
|
633
622
|
)
|
|
623
|
+
|
|
634
624
|
let mobileStyle = {}
|
|
635
625
|
if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
|
|
636
626
|
mobileStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
|
|
@@ -699,12 +689,15 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
699
689
|
updateReplies,
|
|
700
690
|
updateUser: updateSessionWithUser,
|
|
701
691
|
updateWebchatDevSettings: updateWebchatDevSettings,
|
|
702
|
-
webchatState,
|
|
703
692
|
trackEvent: props.onTrackEvent,
|
|
693
|
+
webchatState,
|
|
694
|
+
// TODO: Review if need theme inside Context, already exist innside webchatState
|
|
695
|
+
theme,
|
|
704
696
|
webchatRef,
|
|
705
697
|
chatAreaRef,
|
|
706
698
|
inputPanelRef,
|
|
707
699
|
headerRef,
|
|
700
|
+
repliesRef,
|
|
708
701
|
scrollableMessagesListRef,
|
|
709
702
|
}}
|
|
710
703
|
>
|
|
@@ -723,13 +716,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
723
716
|
...mobileStyle,
|
|
724
717
|
}}
|
|
725
718
|
>
|
|
726
|
-
<WebchatHeader
|
|
727
|
-
id={BotonicContainerId.Header}
|
|
728
|
-
ref={headerRef}
|
|
729
|
-
onCloseClick={() => {
|
|
730
|
-
toggleWebchat(false)
|
|
731
|
-
}}
|
|
732
|
-
/>
|
|
719
|
+
<WebchatHeader ref={headerRef} />
|
|
733
720
|
|
|
734
721
|
{webchatState.isCoverComponentOpen ? (
|
|
735
722
|
<CoverComponent
|
|
@@ -780,3 +767,6 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
780
767
|
WebchatComponent
|
|
781
768
|
)
|
|
782
769
|
})
|
|
770
|
+
|
|
771
|
+
Webchat.displayName = 'Webchat'
|
|
772
|
+
export { Webchat }
|
package/src/webchat/webview.jsx
CHANGED
|
@@ -2,7 +2,8 @@ import React, { useContext, useEffect } from 'react'
|
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
4
|
import { COLORS, ROLES, WEBCHAT } from '../constants'
|
|
5
|
-
import {
|
|
5
|
+
import { WebviewRequestContext } from '../contexts'
|
|
6
|
+
import { WebchatContext } from '../webchat/context'
|
|
6
7
|
|
|
7
8
|
const StyledWebview = styled.div`
|
|
8
9
|
position: absolute;
|