@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
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BlockInputOption, ButtonProps, CustomMessageType } from '../../components/index-types';
|
|
3
|
+
interface ImagePreviewerProps {
|
|
4
|
+
src: string;
|
|
5
|
+
isPreviewerOpened: boolean;
|
|
6
|
+
closePreviewer: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface CoverComponentProps {
|
|
9
|
+
closeComponent: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface CoverComponentOptions {
|
|
12
|
+
component: React.ComponentType<CoverComponentProps>;
|
|
13
|
+
props?: any;
|
|
14
|
+
}
|
|
15
|
+
export type PersistentMenuCloseOption = {
|
|
16
|
+
closeLabel: string;
|
|
17
|
+
};
|
|
18
|
+
export type PersistentMenuOption = {
|
|
19
|
+
label: string;
|
|
20
|
+
} & ButtonProps;
|
|
21
|
+
export type PersistentMenuOptionsTheme = (PersistentMenuCloseOption | PersistentMenuOption)[];
|
|
22
|
+
export interface PersistentMenuOptionsProps {
|
|
23
|
+
onClick: () => void;
|
|
24
|
+
options: any;
|
|
25
|
+
}
|
|
26
|
+
export interface BlobProps {
|
|
27
|
+
blobTick?: boolean;
|
|
28
|
+
blobTickStyle?: any;
|
|
29
|
+
blobWidth?: string;
|
|
30
|
+
imageStyle?: any;
|
|
31
|
+
}
|
|
32
|
+
export interface ThemeProps {
|
|
33
|
+
style?: any;
|
|
34
|
+
coverComponent?: CoverComponentOptions;
|
|
35
|
+
mobileBreakpoint?: number;
|
|
36
|
+
mobileStyle?: any;
|
|
37
|
+
webview?: {
|
|
38
|
+
style?: any;
|
|
39
|
+
header?: {
|
|
40
|
+
style?: any;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
animations?: {
|
|
44
|
+
enable?: boolean;
|
|
45
|
+
};
|
|
46
|
+
intro?: {
|
|
47
|
+
style?: any;
|
|
48
|
+
image?: string;
|
|
49
|
+
custom?: React.ComponentType;
|
|
50
|
+
};
|
|
51
|
+
brand?: {
|
|
52
|
+
color?: string;
|
|
53
|
+
image?: string;
|
|
54
|
+
};
|
|
55
|
+
header?: {
|
|
56
|
+
title?: string;
|
|
57
|
+
subtitle?: string;
|
|
58
|
+
image?: string;
|
|
59
|
+
style?: any;
|
|
60
|
+
custom?: React.ComponentType;
|
|
61
|
+
};
|
|
62
|
+
customMessageTypes?: CustomMessageType[];
|
|
63
|
+
message?: {
|
|
64
|
+
bot?: BlobProps & {
|
|
65
|
+
image?: string;
|
|
66
|
+
style?: any;
|
|
67
|
+
};
|
|
68
|
+
agent?: {
|
|
69
|
+
image?: string;
|
|
70
|
+
};
|
|
71
|
+
user?: BlobProps & {
|
|
72
|
+
style?: any;
|
|
73
|
+
};
|
|
74
|
+
customTypes?: CustomMessageType[];
|
|
75
|
+
style?: any;
|
|
76
|
+
timestamps?: {
|
|
77
|
+
withImage?: boolean;
|
|
78
|
+
format: () => string;
|
|
79
|
+
style?: any;
|
|
80
|
+
enable?: boolean;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
button?: {
|
|
84
|
+
autodisable?: boolean;
|
|
85
|
+
disabledstyle?: any;
|
|
86
|
+
hoverBackground?: string;
|
|
87
|
+
hoverTextColor?: string;
|
|
88
|
+
messageType?: 'text' | 'payload';
|
|
89
|
+
urlIcon?: {
|
|
90
|
+
image?: string;
|
|
91
|
+
enable?: boolean;
|
|
92
|
+
};
|
|
93
|
+
style?: any;
|
|
94
|
+
custom?: React.ComponentType;
|
|
95
|
+
};
|
|
96
|
+
replies?: {
|
|
97
|
+
align?: 'left' | 'center' | 'right';
|
|
98
|
+
wrap?: 'wrap' | 'nowrap';
|
|
99
|
+
};
|
|
100
|
+
carousel?: {
|
|
101
|
+
arrow?: {
|
|
102
|
+
left: {
|
|
103
|
+
custom?: React.ComponentType;
|
|
104
|
+
};
|
|
105
|
+
right: {
|
|
106
|
+
custom?: React.ComponentType;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
enableArrows?: boolean;
|
|
110
|
+
};
|
|
111
|
+
reply?: {
|
|
112
|
+
style?: any;
|
|
113
|
+
custom?: React.ComponentType;
|
|
114
|
+
};
|
|
115
|
+
triggerButton?: {
|
|
116
|
+
image?: string;
|
|
117
|
+
style?: any;
|
|
118
|
+
custom?: React.ComponentType;
|
|
119
|
+
};
|
|
120
|
+
notifications?: {
|
|
121
|
+
enable?: boolean;
|
|
122
|
+
banner?: {
|
|
123
|
+
custom?: React.ComponentType;
|
|
124
|
+
enable?: boolean;
|
|
125
|
+
text?: string;
|
|
126
|
+
};
|
|
127
|
+
triggerButton?: {
|
|
128
|
+
enable?: boolean;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
scrollButton?: {
|
|
132
|
+
enable?: boolean;
|
|
133
|
+
custom?: React.ComponentType;
|
|
134
|
+
};
|
|
135
|
+
markdownStyle?: string;
|
|
136
|
+
userInput?: {
|
|
137
|
+
attachments?: {
|
|
138
|
+
enable?: boolean;
|
|
139
|
+
custom?: React.ComponentType;
|
|
140
|
+
};
|
|
141
|
+
blockInputs?: BlockInputOption[];
|
|
142
|
+
box?: {
|
|
143
|
+
placeholder: string;
|
|
144
|
+
style?: any;
|
|
145
|
+
};
|
|
146
|
+
emojiPicker?: {
|
|
147
|
+
enable?: boolean;
|
|
148
|
+
custom?: React.ComponentType;
|
|
149
|
+
};
|
|
150
|
+
menu?: {
|
|
151
|
+
darkBackground?: boolean;
|
|
152
|
+
custom?: React.ComponentType<PersistentMenuOptionsProps>;
|
|
153
|
+
};
|
|
154
|
+
menuButton?: {
|
|
155
|
+
custom?: React.ComponentType;
|
|
156
|
+
};
|
|
157
|
+
persistentMenu?: PersistentMenuOptionsTheme;
|
|
158
|
+
sendButton?: {
|
|
159
|
+
enable?: boolean;
|
|
160
|
+
custom?: React.ComponentType;
|
|
161
|
+
};
|
|
162
|
+
enable?: boolean;
|
|
163
|
+
style?: any;
|
|
164
|
+
};
|
|
165
|
+
imagePreviewer?: React.ComponentType<ImagePreviewerProps>;
|
|
166
|
+
}
|
|
167
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/webchat/theme/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { ROLES, WEBCHAT } from '../../constants';
|
|
4
|
-
import { WebchatContext } from '../../contexts';
|
|
5
4
|
import { resolveImage } from '../../util/environment';
|
|
5
|
+
import { WebchatContext } from '../../webchat/context';
|
|
6
6
|
import { StyledTriggerButton, TriggerImage, UnreadMessagesCounter, } from './styles';
|
|
7
7
|
export const TriggerButton = () => {
|
|
8
8
|
const { webchatState, getThemeProperty, toggleWebchat } = useContext(WebchatContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/webchat/trigger-button/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/webchat/trigger-button/index.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEzC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,qBAAqB,GACtB,MAAM,UAAU,CAAA;AAEjB,MAAM,CAAC,MAAM,aAAa,GAAG,GAAgB,EAAE;IAC7C,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,GACrD,UAAU,CAAC,cAAc,CAAC,CAAA;IAE5B,MAAM,eAAe,GAAG,GAAG,EAAE;QAC3B,MAAM,KAAK,GAAG,gBAAgB,CAC5B,OAAO,CAAC,iBAAiB,CAAC,kBAAkB,EAC5C,SAAS,CACV,CAAA;QAED,IAAI,CAAC,KAAK,EAAE;YACV,YAAY,CAAC,KAAK,CAAC,kBAAkB,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAA;YAC7D,OAAO,IAAI,CAAA;SACZ;QACD,OAAO,KAAK,CAAA;IACd,CAAC,CAAA;IAED,MAAM,kBAAkB,GAAG,eAAe,EAAE,CAAA;IAE5C,MAAM,kBAAkB,GAAG,gBAAgB,CACzC,OAAO,CAAC,iBAAiB,CAAC,kBAAkB,CAC7C,CAAA;IAED,MAAM,iCAAiC,GAAG,gBAAgB,CACxD,OAAO,CAAC,iBAAiB,CAAC,iCAAiC,EAC3D,KAAK,CACN,CAAA;IAED,MAAM,oBAAoB,GAAG,gBAAgB,CAC3C,OAAO,CAAC,iBAAiB,CAAC,oBAAoB,EAC9C,iCAAiC,CAClC,CAAA;IAED,MAAM,mBAAmB,GAAG,gBAAgB,CAC1C,OAAO,CAAC,iBAAiB,CAAC,aAAa,EACvC,SAAS,CACV,CAAA;IAED,MAAM,WAAW,GAAG,CAAC,KAAU,EAAE,EAAE;QACjC,aAAa,CAAC,IAAI,CAAC,CAAA;QACnB,KAAK,CAAC,cAAc,EAAE,CAAA;IACxB,CAAC,CAAA;IAED,OAAO,CACL,6BAAK,OAAO,EAAE,WAAW,iBACtB,YAAY,CAAC,iBAAiB,KAAK,CAAC,IAAI,oBAAoB,IAAI,CAC/D,KAAC,qBAAqB,kBAAC,SAAS,EAAC,uBAAuB,gBACrD,YAAY,CAAC,iBAAiB,IACT,CACzB,EACA,mBAAmB,CAAC,CAAC,CAAC,CACrB,KAAC,mBAAmB,KAAG,CACxB,CAAC,CAAC,CAAC,CACF,KAAC,mBAAmB,kBAClB,IAAI,EAAE,KAAK,CAAC,cAAc,EAC1B,KAAK,EAAE,kBAAkB,gBAExB,kBAAkB,IAAI,CACrB,KAAC,YAAY,IAAC,GAAG,EAAE,YAAY,CAAC,kBAAkB,CAAC,GAAI,CACxD,IACmB,CACvB,KACG,CACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -5,7 +5,7 @@ import merge from 'lodash.merge';
|
|
|
5
5
|
import React, { forwardRef, useEffect } from 'react';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { useWebchat } from './
|
|
8
|
+
import { useWebchat } from './context/use-webchat';
|
|
9
9
|
import { SessionView } from './session-view';
|
|
10
10
|
import { Webchat } from './webchat';
|
|
11
11
|
export const DebugTab = styled.div `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webchat-dev.js","sourceRoot":"","sources":["../../../src/webchat/webchat-dev.jsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"webchat-dev.js","sourceRoot":"","sources":["../../../src/webchat/webchat-dev.jsx"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,KAAK,MAAM,cAAc,CAAA;AAChC,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,MAAM,MAAM,mBAAmB,CAAA;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAA;;;;WAIvB,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;YACvC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;CAClD,CAAA;AAED,iEAAiE;AACjE,wEAAwE;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,EAA0B,EAAE,EAAE;QAA9B,EAAE,YAAY,OAAY,EAAP,KAAK,cAAxB,gBAA0B,CAAF;IACrD,OAAA,YAAY,CACV,KAAC,QAAQ,oBAAK,KAAK,cACjB,KAAC,WAAW,IAAC,YAAY,EAAE,YAAY,GAAI,IAClC,EACX,QAAQ,CAAC,IAAI,CACd,CAAA;CAAA,CAAA;AAEH,MAAM,cAAc,GAAG;IACrB,oBAAoB,EAAE,IAAI;IAC1B,YAAY,EAAE,EAAE;IAChB,IAAI,EAAE;QACJ,EAAE,EAAE,QAAQ;QACZ,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE,QAAQ,CAAC,GAAG;QACtB,WAAW,EAAE,SAAS;QACtB,UAAU,EAAE,EAAE;KACf;IACD,YAAY,EAAE,EAAE;IAChB,GAAG,EAAE;QACH,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,SAAS;KAChB;CACF,CAAA;AAED,8CAA8C;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IAClD,MAAM,YAAY,GAAG,UAAU,EAAE,CAAA;IACjC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,YAAY,CAAA;IAElD;;6CAEyC;IACzC,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IACrD,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;IAEjB,OAAO,CACL,8BACE,KAAC,OAAO,kBACN,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,IACpC,KAAK,IACT,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE;oBAClB,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAAC,mBAAmB;oBACjE,eAAe,EAAE,YAAY,CAAC,WAAW,CAAC,eAAe;iBAC1D,IACD,EACF,KAAC,cAAc,IACb,IAAI,EAAE,YAAY,CAAC,WAAW,CAAC,eAAe,EAC9C,YAAY,EAAE,YAAY,GAC1B,IACD,CACJ,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WebchatProps, WebchatRef } from '../index-types';
|
|
3
|
+
declare const Webchat: React.ForwardRefExoticComponent<WebchatProps & React.RefAttributes<WebchatRef | null>>;
|
|
4
|
+
export { Webchat };
|
|
@@ -2,14 +2,12 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { BotonicAction, INPUT, isMobile, params2queryString, } from '@botonic/core';
|
|
4
4
|
import merge from 'lodash.merge';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import { forwardRef, useEffect, useImperativeHandle, useRef, useState, } from 'react';
|
|
6
|
+
import { StyleSheetManager } from 'styled-components';
|
|
7
7
|
import { v7 as uuidv7 } from 'uuid';
|
|
8
|
-
import { Audio, Document, Image, Text, Video } from '../components';
|
|
9
|
-
import { Handoff } from '../components/handoff';
|
|
10
|
-
import { normalizeWebchatSettings } from '../components/webchat-settings';
|
|
8
|
+
import { Audio, Document, Handoff, Image, normalizeWebchatSettings, Text, Video, } from '../components';
|
|
11
9
|
import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../constants';
|
|
12
|
-
import {
|
|
10
|
+
import { WebviewRequestContext } from '../contexts';
|
|
13
11
|
import { SENDERS } from '../index-types';
|
|
14
12
|
import { getMediaType, isAllowedSize, isAudio, isDocument, isImage, isMedia, isText, isVideo, readDataURL, } from '../message-utils';
|
|
15
13
|
import { msgToBotonic } from '../msg-to-botonic';
|
|
@@ -19,65 +17,20 @@ import { _getThemeProperty, getServerErrorMessage, initSession, shouldKeepSessio
|
|
|
19
17
|
import { ChatArea } from './chat-area';
|
|
20
18
|
import { OpenedPersistentMenu } from './components/opened-persistent-menu';
|
|
21
19
|
import { BotonicContainerId } from './constants';
|
|
20
|
+
import { useWebchat, WebchatContext } from './context';
|
|
22
21
|
import { CoverComponent } from './cover-component';
|
|
23
22
|
import { WebchatHeader } from './header';
|
|
24
|
-
import { useComponentWillMount, usePrevious, useScrollToBottom, useTyping,
|
|
23
|
+
import { useComponentWillMount, usePrevious, useScrollToBottom, useTyping, } from './hooks';
|
|
25
24
|
import { InputPanel } from './input-panel';
|
|
25
|
+
import { DarkBackgroundMenu, ErrorMessage, ErrorMessageContainer, StyledWebchat, } from './styles';
|
|
26
26
|
import { TriggerButton } from './trigger-button';
|
|
27
27
|
import { useStorageState } from './use-storage-state-hook';
|
|
28
28
|
import { getParsedAction } from './utils';
|
|
29
29
|
import { WebviewContainer } from './webview';
|
|
30
|
-
const StyledWebchat = styled.div `
|
|
31
|
-
position: fixed;
|
|
32
|
-
right: 20px;
|
|
33
|
-
bottom: 20px;
|
|
34
|
-
width: ${props => props.width}px;
|
|
35
|
-
height: ${props => props.height}px;
|
|
36
|
-
margin: auto;
|
|
37
|
-
background-color: ${COLORS.SOLID_WHITE};
|
|
38
|
-
border-radius: 10px;
|
|
39
|
-
box-shadow: ${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
|
|
40
|
-
display: flex;
|
|
41
|
-
flex-direction: column;
|
|
42
|
-
justify-content: space-between;
|
|
43
|
-
overflow: hidden;
|
|
44
|
-
`;
|
|
45
|
-
const ErrorMessageContainer = styled.div `
|
|
46
|
-
position: relative;
|
|
47
|
-
display: flex;
|
|
48
|
-
z-index: 1;
|
|
49
|
-
justify-content: center;
|
|
50
|
-
width: 100%;
|
|
51
|
-
`;
|
|
52
|
-
const ErrorMessage = styled.div `
|
|
53
|
-
position: absolute;
|
|
54
|
-
top: 10px;
|
|
55
|
-
font-size: 14px;
|
|
56
|
-
line-height: 20px;
|
|
57
|
-
padding: 4px 11px;
|
|
58
|
-
display: flex;
|
|
59
|
-
background-color: ${COLORS.ERROR_RED};
|
|
60
|
-
color: ${COLORS.CONCRETE_WHITE};
|
|
61
|
-
border-radius: 5px;
|
|
62
|
-
align-items: center;
|
|
63
|
-
justify-content: center;
|
|
64
|
-
font-family: ${WEBCHAT.DEFAULTS.FONT_FAMILY};
|
|
65
|
-
`;
|
|
66
|
-
const DarkBackgroundMenu = styled.div `
|
|
67
|
-
background: ${COLORS.SOLID_BLACK};
|
|
68
|
-
opacity: 0.3;
|
|
69
|
-
z-index: 1;
|
|
70
|
-
right: 0;
|
|
71
|
-
bottom: 0;
|
|
72
|
-
border-radius: 10px;
|
|
73
|
-
position: absolute;
|
|
74
|
-
width: 100%;
|
|
75
|
-
height: 100%;
|
|
76
|
-
`;
|
|
77
30
|
// eslint-disable-next-line complexity, react/display-name
|
|
78
|
-
|
|
31
|
+
const Webchat = forwardRef((props, ref) => {
|
|
79
32
|
var _a;
|
|
80
|
-
const { addMessage, addMessageComponent, clearMessages, doRenderCustomComponent,
|
|
33
|
+
const { addMessage, addMessageComponent, clearMessages, doRenderCustomComponent, resetUnreadMessages, setCurrentAttachment, setError, setIsInputFocused, setLastMessageVisible, setOnline, toggleCoverComponent, toggleEmojiPicker, togglePersistentMenu, toggleWebchat, updateDevSettings, updateHandoff, updateLastMessageDate, updateLastRoutePath, updateLatestInput, updateMessage, updateReplies, updateSession, updateTheme, updateTyping, updateWebview, removeWebview, removeReplies, webchatState, webchatRef, chatAreaRef, inputPanelRef, headerRef, repliesRef, scrollableMessagesListRef,
|
|
81
34
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
82
35
|
} = props.webchatHooks || useWebchat();
|
|
83
36
|
const firstUpdate = useRef(true);
|
|
@@ -94,7 +47,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
94
47
|
const [botonicState, saveState] = useStorageState(storage, storageKey);
|
|
95
48
|
const host = props.host || document.body;
|
|
96
49
|
const { scrollToBottom } = useScrollToBottom({ host });
|
|
97
|
-
const saveWebchatState = webchatState => {
|
|
50
|
+
const saveWebchatState = (webchatState) => {
|
|
98
51
|
storage &&
|
|
99
52
|
saveState(JSON.parse(stringifyWithRegexs({
|
|
100
53
|
messages: webchatState.messagesJSON,
|
|
@@ -105,19 +58,17 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
105
58
|
themeUpdates: webchatState.themeUpdates,
|
|
106
59
|
})));
|
|
107
60
|
};
|
|
108
|
-
const handleAttachment = event => {
|
|
61
|
+
const handleAttachment = (event) => {
|
|
109
62
|
if (!isAllowedSize(event.target.files[0].size)) {
|
|
110
63
|
throw new Error(`The file is too large. A maximum of ${MAX_ALLOWED_SIZE_MB}MB is allowed.`);
|
|
111
64
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
file: event.target.files[0],
|
|
115
|
-
attachmentType: getMediaType(event.target.files[0].type),
|
|
116
|
-
});
|
|
65
|
+
// TODO: Attach more files?
|
|
66
|
+
setCurrentAttachment(event.target.files[0]);
|
|
117
67
|
};
|
|
118
68
|
useEffect(() => {
|
|
119
|
-
if (webchatState.currentAttachment)
|
|
69
|
+
if (webchatState.currentAttachment) {
|
|
120
70
|
sendAttachment(webchatState.currentAttachment);
|
|
71
|
+
}
|
|
121
72
|
}, [webchatState.currentAttachment]);
|
|
122
73
|
const sendUserInput = (input) => __awaiter(void 0, void 0, void 0, function* () {
|
|
123
74
|
if (props.onUserInput) {
|
|
@@ -125,8 +76,11 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
125
76
|
scrollToBottom();
|
|
126
77
|
props.onUserInput({
|
|
127
78
|
user: webchatState.session.user,
|
|
79
|
+
// TODO: Review if this input.sentBy exists in the frontend
|
|
128
80
|
input: input,
|
|
81
|
+
//@ts-ignore
|
|
129
82
|
session: webchatState.session,
|
|
83
|
+
// TODO: Review why we were passing lastRoutePath, is only for devMode?
|
|
130
84
|
lastRoutePath: webchatState.lastRoutePath,
|
|
131
85
|
});
|
|
132
86
|
}
|
|
@@ -163,9 +117,10 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
163
117
|
if (shouldKeepSessionOnReload({ initialDevSettings, devSettings })) {
|
|
164
118
|
if (messages) {
|
|
165
119
|
messages.forEach(message => {
|
|
120
|
+
var _a, _b, _c;
|
|
166
121
|
addMessage(message);
|
|
167
|
-
const newMessageComponent = msgToBotonic(Object.assign(Object.assign({}, message), { delay: 0, typing: 0 }), (props.theme.message
|
|
168
|
-
|
|
122
|
+
const newMessageComponent = msgToBotonic(Object.assign(Object.assign({}, message), { delay: 0, typing: 0 }), ((_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.customTypes) || ((_c = props.theme) === null || _c === void 0 ? void 0 : _c.customMessageTypes));
|
|
123
|
+
//@ts-ignore
|
|
169
124
|
if (newMessageComponent)
|
|
170
125
|
addMessageComponent(newMessageComponent);
|
|
171
126
|
});
|
|
@@ -181,12 +136,15 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
181
136
|
updateDevSettings(devSettings);
|
|
182
137
|
else if (initialDevSettings)
|
|
183
138
|
updateDevSettings(initialDevSettings);
|
|
184
|
-
if (lastMessageUpdate)
|
|
139
|
+
if (lastMessageUpdate) {
|
|
185
140
|
updateLastMessageDate(lastMessageUpdate);
|
|
186
|
-
|
|
141
|
+
}
|
|
142
|
+
if (themeUpdates !== undefined) {
|
|
187
143
|
updateTheme(merge(props.theme, themeUpdates), themeUpdates);
|
|
188
|
-
|
|
189
|
-
|
|
144
|
+
}
|
|
145
|
+
if (props.onInit) {
|
|
146
|
+
setTimeout(() => props.onInit && props.onInit(), 100);
|
|
147
|
+
}
|
|
190
148
|
}, []);
|
|
191
149
|
useEffect(() => {
|
|
192
150
|
if (!webchatState.isWebchatOpen) {
|
|
@@ -197,8 +155,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
197
155
|
}
|
|
198
156
|
}, [webchatState.isWebchatOpen]);
|
|
199
157
|
useEffect(() => {
|
|
200
|
-
|
|
201
|
-
|
|
158
|
+
const { messagesJSON, session } = webchatState;
|
|
159
|
+
if (onStateChange && typeof onStateChange === 'function' && session.user) {
|
|
160
|
+
onStateChange({ messagesJSON, user: session.user });
|
|
202
161
|
}
|
|
203
162
|
saveWebchatState(webchatState);
|
|
204
163
|
}, [
|
|
@@ -227,11 +186,12 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
227
186
|
const openWebview = (webviewComponent, params) => {
|
|
228
187
|
updateWebview(webviewComponent, params);
|
|
229
188
|
};
|
|
230
|
-
const textareaRef = useRef(
|
|
189
|
+
const textareaRef = useRef();
|
|
231
190
|
const closeWebview = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
|
-
|
|
191
|
+
var _b;
|
|
192
|
+
removeWebview();
|
|
233
193
|
if (userInputEnabled) {
|
|
234
|
-
textareaRef.current.focus();
|
|
194
|
+
(_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.focus();
|
|
235
195
|
}
|
|
236
196
|
if (options === null || options === void 0 ? void 0 : options.payload) {
|
|
237
197
|
yield sendPayload(options.payload);
|
|
@@ -260,12 +220,20 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
260
220
|
return false;
|
|
261
221
|
for (const rule of blockInputs) {
|
|
262
222
|
if (getBlockInputs(rule, input.data)) {
|
|
263
|
-
addMessageComponent(_jsx(Text
|
|
223
|
+
addMessageComponent(_jsx(Text
|
|
224
|
+
// Is necessary to add the id of the input
|
|
225
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
, Object.assign({
|
|
228
|
+
// Is necessary to add the id of the input
|
|
229
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
id: input.id, sentBy: SENDERS.user, blob: false, style: {
|
|
264
232
|
backgroundColor: COLORS.SCORPION_GRAY,
|
|
265
233
|
borderColor: COLORS.SCORPION_GRAY,
|
|
266
234
|
padding: '8px 12px',
|
|
267
235
|
} }, { children: rule.message })));
|
|
268
|
-
|
|
236
|
+
removeReplies();
|
|
269
237
|
return true;
|
|
270
238
|
}
|
|
271
239
|
}
|
|
@@ -293,12 +261,23 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
293
261
|
const messageComponentFromInput = input => {
|
|
294
262
|
let messageComponent = null;
|
|
295
263
|
if (isText(input)) {
|
|
296
|
-
messageComponent = (
|
|
297
|
-
//
|
|
298
|
-
|
|
264
|
+
messageComponent = (_jsx(Text
|
|
265
|
+
// Is necessary to add the id of the input
|
|
266
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
, Object.assign({
|
|
269
|
+
// Is necessary to add the id of the input
|
|
270
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
271
|
+
// @ts-ignore
|
|
272
|
+
id: input.id,
|
|
273
|
+
// Is necessary to add the payload of the input when user clicks a button
|
|
274
|
+
// @ts-ignore
|
|
275
|
+
payload: input.payload, sentBy: SENDERS.user }, { children: input.data })));
|
|
299
276
|
}
|
|
300
277
|
else if (isMedia(input)) {
|
|
301
278
|
const temporaryDisplayUrl = URL.createObjectURL(input.data);
|
|
279
|
+
// TODO: We sould use URL.revokeObjectURL(temporaryDisplayUrl) when the component is unmounted
|
|
280
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL_static#memory_management
|
|
302
281
|
const mediaProps = {
|
|
303
282
|
id: input.id,
|
|
304
283
|
sentBy: SENDERS.user,
|
|
@@ -334,14 +313,14 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
334
313
|
sendUserInput(input);
|
|
335
314
|
updateLatestInput(input);
|
|
336
315
|
isOnline() && updateLastMessageDate(currentDateString());
|
|
337
|
-
|
|
316
|
+
removeReplies();
|
|
338
317
|
togglePersistentMenu(false);
|
|
339
318
|
toggleEmojiPicker(false);
|
|
340
319
|
});
|
|
341
320
|
/* This is the public API this component exposes to its parents
|
|
342
321
|
https://stackoverflow.com/questions/37949981/call-child-method-from-parent
|
|
343
322
|
*/
|
|
344
|
-
const updateSessionWithUser = userToUpdate => updateSession(merge(webchatState.session, { user: userToUpdate }));
|
|
323
|
+
const updateSessionWithUser = (userToUpdate) => updateSession(merge(webchatState.session, { user: userToUpdate }));
|
|
345
324
|
useImperativeHandle(ref, () => ({
|
|
346
325
|
addBotResponse: ({ response, session, lastRoutePath }) => {
|
|
347
326
|
updateTyping(false);
|
|
@@ -366,7 +345,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
366
345
|
updateLastRoutePath(lastRoutePath);
|
|
367
346
|
updateLastMessageDate(currentDateString());
|
|
368
347
|
},
|
|
369
|
-
setTyping: typing => updateTyping(typing),
|
|
348
|
+
setTyping: (typing) => updateTyping(typing),
|
|
370
349
|
addUserMessage: message => sendInput(message),
|
|
371
350
|
updateUser: updateSessionWithUser,
|
|
372
351
|
openWebchat: () => toggleWebchat(true),
|
|
@@ -380,24 +359,22 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
380
359
|
},
|
|
381
360
|
unmountCustomComponent: () => doRenderCustomComponent(false),
|
|
382
361
|
toggleCoverComponent: () => toggleCoverComponent(!webchatState.isCoverComponentOpen),
|
|
383
|
-
openWebviewApi: component => openWebviewT(component),
|
|
384
|
-
setError,
|
|
385
362
|
setOnline,
|
|
386
363
|
getMessages: () => webchatState.messagesJSON,
|
|
387
364
|
isOnline,
|
|
388
365
|
clearMessages: () => {
|
|
389
366
|
clearMessages();
|
|
390
|
-
|
|
367
|
+
removeReplies();
|
|
391
368
|
},
|
|
392
369
|
getLastMessageUpdate: () => webchatState.lastMessageUpdate,
|
|
393
370
|
updateMessageInfo: (msgId, messageInfo) => {
|
|
394
|
-
const messageToUpdate = webchatState.messagesJSON.filter(m => m.id
|
|
371
|
+
const messageToUpdate = webchatState.messagesJSON.filter(m => m.id === msgId)[0];
|
|
395
372
|
const updatedMsg = merge(messageToUpdate, messageInfo);
|
|
396
373
|
if (updatedMsg.ack === 1)
|
|
397
374
|
delete updatedMsg.unsentInput;
|
|
398
375
|
updateMessage(updatedMsg);
|
|
399
376
|
},
|
|
400
|
-
updateWebchatSettings: settings => {
|
|
377
|
+
updateWebchatSettings: (settings) => {
|
|
401
378
|
if (settings.user) {
|
|
402
379
|
updateSessionWithUser(settings.user);
|
|
403
380
|
}
|
|
@@ -405,20 +382,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
405
382
|
updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates);
|
|
406
383
|
updateTyping(false);
|
|
407
384
|
},
|
|
408
|
-
closeWebview: closeWebview,
|
|
385
|
+
closeWebview: (options) => __awaiter(void 0, void 0, void 0, function* () { return closeWebview(options); }),
|
|
409
386
|
}));
|
|
410
387
|
const resolveCase = () => {
|
|
411
388
|
updateHandoff(false);
|
|
412
|
-
updateSession(Object.assign(Object.assign({}, webchatState.session), { _botonic_action:
|
|
389
|
+
updateSession(Object.assign(Object.assign({}, webchatState.session), { _botonic_action: undefined }));
|
|
413
390
|
};
|
|
414
391
|
const prevSession = usePrevious(webchatState.session);
|
|
415
392
|
useEffect(() => {
|
|
416
393
|
// Resume conversation after handoff
|
|
417
|
-
if (prevSession &&
|
|
418
|
-
prevSession._botonic_action &&
|
|
419
|
-
!webchatState.session._botonic_action) {
|
|
394
|
+
if ((prevSession === null || prevSession === void 0 ? void 0 : prevSession._botonic_action) && !webchatState.session._botonic_action) {
|
|
420
395
|
const action = getParsedAction(prevSession._botonic_action);
|
|
421
|
-
if (action
|
|
396
|
+
if (action === null || action === void 0 ? void 0 : action.on_finish)
|
|
422
397
|
sendPayload(action.on_finish);
|
|
423
398
|
}
|
|
424
399
|
}, [webchatState.session._botonic_action]);
|
|
@@ -435,21 +410,20 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
435
410
|
yield sendInput(input);
|
|
436
411
|
});
|
|
437
412
|
const sendAttachment = (attachment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
438
|
-
if (attachment
|
|
439
|
-
const attachmentType = getMediaType(attachment.
|
|
413
|
+
if (attachment) {
|
|
414
|
+
const attachmentType = getMediaType(attachment.type);
|
|
440
415
|
if (!attachmentType)
|
|
441
416
|
return;
|
|
442
417
|
const input = {
|
|
443
418
|
type: attachmentType,
|
|
444
|
-
data: attachment
|
|
419
|
+
data: attachment,
|
|
445
420
|
};
|
|
446
421
|
yield sendInput(input);
|
|
447
|
-
setCurrentAttachment(
|
|
422
|
+
setCurrentAttachment();
|
|
448
423
|
}
|
|
449
424
|
});
|
|
450
425
|
const webviewRequestContext = {
|
|
451
|
-
closeWebview: closeWebview,
|
|
452
|
-
getString: stringId => props.getString(stringId, webchatState.session),
|
|
426
|
+
closeWebview: (options) => __awaiter(void 0, void 0, void 0, function* () { return yield closeWebview(options); }),
|
|
453
427
|
params: webchatState.webviewParams || {},
|
|
454
428
|
session: webchatState.session || {},
|
|
455
429
|
};
|
|
@@ -526,20 +500,23 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
526
500
|
updateReplies,
|
|
527
501
|
updateUser: updateSessionWithUser,
|
|
528
502
|
updateWebchatDevSettings: updateWebchatDevSettings,
|
|
529
|
-
webchatState,
|
|
530
503
|
trackEvent: props.onTrackEvent,
|
|
504
|
+
webchatState,
|
|
505
|
+
// TODO: Review if need theme inside Context, already exist innside webchatState
|
|
506
|
+
theme,
|
|
531
507
|
webchatRef,
|
|
532
508
|
chatAreaRef,
|
|
533
509
|
inputPanelRef,
|
|
534
510
|
headerRef,
|
|
511
|
+
repliesRef,
|
|
535
512
|
scrollableMessagesListRef,
|
|
536
513
|
} }, { children: [!webchatState.isWebchatOpen && _jsx(TriggerButton, {}), webchatState.isWebchatOpen && (_jsxs(StyledWebchat, Object.assign({ id: BotonicContainerId.Webchat, ref: webchatRef,
|
|
537
514
|
// TODO: Distinguish between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
|
|
538
|
-
role: ROLES.WEBCHAT, width: webchatState.width, height: webchatState.height, style: Object.assign(Object.assign({}, webchatState.theme.style), mobileStyle) }, { children: [_jsx(WebchatHeader, {
|
|
539
|
-
toggleWebchat(false);
|
|
540
|
-
} }), webchatState.isCoverComponentOpen ? (_jsx(CoverComponent, { component: coverComponent, componentProps: coverComponentProps })) : (_jsxs(_Fragment, { children: [webchatState.error.message && (_jsx(ErrorMessageContainer, { children: _jsx(ErrorMessage, { children: webchatState.error.message }) })), _jsx(ChatArea, {}), webchatState.isPersistentMenuOpen && (_jsx(DarkenBackground, { component: persistentMenu() })), !webchatState.handoff && userInputEnabled && (_jsx(InputPanel, { persistentMenu: props.persistentMenu, enableEmojiPicker: props.enableEmojiPicker, enableAttachments: props.enableAttachments, handleAttachment: handleAttachment, textareaRef: textareaRef, host: host, onUserInput: props.onUserInput })), webchatState.webview && webchatWebview(), webchatState.isCustomComponentRendered &&
|
|
515
|
+
role: ROLES.WEBCHAT, width: webchatState.width, height: webchatState.height, style: Object.assign(Object.assign({}, webchatState.theme.style), mobileStyle) }, { children: [_jsx(WebchatHeader, { ref: headerRef }), webchatState.isCoverComponentOpen ? (_jsx(CoverComponent, { component: coverComponent, componentProps: coverComponentProps })) : (_jsxs(_Fragment, { children: [webchatState.error.message && (_jsx(ErrorMessageContainer, { children: _jsx(ErrorMessage, { children: webchatState.error.message }) })), _jsx(ChatArea, {}), webchatState.isPersistentMenuOpen && (_jsx(DarkenBackground, { component: persistentMenu() })), !webchatState.handoff && userInputEnabled && (_jsx(InputPanel, { persistentMenu: props.persistentMenu, enableEmojiPicker: props.enableEmojiPicker, enableAttachments: props.enableAttachments, handleAttachment: handleAttachment, textareaRef: textareaRef, host: host, onUserInput: props.onUserInput })), webchatState.webview && webchatWebview(), webchatState.isCustomComponentRendered &&
|
|
541
516
|
customComponent &&
|
|
542
517
|
_renderCustomComponent()] }))] })))] })));
|
|
543
518
|
return props.shadowDOM ? (_jsx(StyleSheetManager, Object.assign({ target: host }, { children: WebchatComponent }))) : (WebchatComponent);
|
|
544
519
|
});
|
|
520
|
+
Webchat.displayName = 'Webchat';
|
|
521
|
+
export { Webchat };
|
|
545
522
|
//# sourceMappingURL=webchat.js.map
|