@botonic/react 0.31.5-alpha.1 → 0.32.0-alpha.0
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/element.js +6 -6
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/handoff.d.ts +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 -127
- package/lib/cjs/components/index.d.ts +7 -1
- package/lib/cjs/components/index.js +14 -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.d.ts +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.d.ts +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.d.ts +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/multichannel/multichannel-button.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +2 -2
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +4 -4
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +12 -11
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-utils.d.ts +9 -15
- package/lib/cjs/components/multichannel/multichannel-utils.js +48 -27
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +7 -7
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/components/multichannel/whatsapp/constants.d.ts +11 -0
- package/lib/cjs/components/multichannel/whatsapp/constants.js +13 -0
- package/lib/cjs/components/multichannel/whatsapp/constants.js.map +1 -0
- package/lib/cjs/components/raw.d.ts +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/text.d.ts +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/components/whatsapp-button-list.js +2 -2
- package/lib/cjs/components/whatsapp-button-list.js.map +1 -1
- package/lib/cjs/components/whatsapp-catalog.d.ts +6 -0
- package/lib/cjs/components/whatsapp-catalog.js +25 -0
- package/lib/cjs/components/whatsapp-catalog.js.map +1 -0
- package/lib/cjs/components/whatsapp-cta-url-button.js +5 -5
- package/lib/cjs/components/whatsapp-cta-url-button.js.map +1 -1
- package/lib/cjs/components/whatsapp-media-carousel.d.ts +46 -0
- package/lib/cjs/components/whatsapp-media-carousel.js +40 -0
- package/lib/cjs/components/whatsapp-media-carousel.js.map +1 -0
- package/lib/cjs/components/whatsapp-product-carousel.d.ts +32 -0
- package/lib/cjs/components/whatsapp-product-carousel.js +34 -0
- package/lib/cjs/components/whatsapp-product-carousel.js.map +1 -0
- package/lib/cjs/components/whatsapp-product-list.d.ts +15 -0
- package/lib/cjs/components/whatsapp-product-list.js +26 -0
- package/lib/cjs/components/whatsapp-product-list.js.map +1 -0
- package/lib/cjs/components/whatsapp-product.d.ts +7 -0
- package/lib/cjs/components/whatsapp-product.js +25 -0
- package/lib/cjs/components/whatsapp-product.js.map +1 -0
- package/lib/cjs/constants.d.ts +0 -6
- package/lib/cjs/constants.js +1 -7
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/contexts.d.ts +3 -4
- package/lib/cjs/contexts.js +2 -76
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.d.ts +7 -0
- package/lib/cjs/dev-app.js +5 -2
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index-types.d.ts +90 -61
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/index.d.ts +1 -1
- 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/react-bot.d.ts +1 -1
- package/lib/cjs/util/error-boundary.d.ts +1 -1
- package/lib/cjs/util/functional.d.ts +3 -0
- package/lib/cjs/util/functional.js +30 -0
- package/lib/cjs/util/functional.js.map +1 -0
- package/lib/cjs/util/react.d.ts +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.d.ts +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/common.d.ts +1 -1
- package/lib/cjs/webchat/components/conditional-animation.d.ts +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.d.ts +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} +4 -1
- package/lib/cjs/webchat/{actions.js → context/actions.js} +4 -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 +86 -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 +76 -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 +21 -20
- package/lib/cjs/webchat/{hooks → context}/use-webchat.js +21 -7
- 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} +4 -0
- package/lib/cjs/webchat/context/webchat-reducer.js.map +1 -0
- package/lib/cjs/webchat/cover-component/index.d.ts +1 -1
- 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-scroll-to-bottom.d.ts +6 -4
- package/lib/cjs/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +16 -16
- 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 +4 -4
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js +6 -6
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +3 -46
- 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 +2 -2
- 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 +2 -2
- 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 +4 -4
- 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/opened-emoji-picker.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/persistent-menu.d.ts +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.d.ts +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 +4 -4
- package/lib/cjs/webchat/input-panel/textarea.js +11 -3
- package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/message-list/index.d.ts +1 -1
- package/lib/cjs/webchat/message-list/index.js +64 -38
- package/lib/cjs/webchat/message-list/index.js.map +1 -1
- package/lib/cjs/webchat/message-list/intro-message.d.ts +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/scroll-button.d.ts +1 -0
- package/lib/cjs/webchat/message-list/styles.js +4 -3
- 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.d.ts +1 -1
- package/lib/cjs/webchat/session-view.js +4 -4
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/styles.d.ts +9 -0
- package/lib/cjs/webchat/styles.js +54 -0
- 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.d.ts +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/typing-indicator/index.d.ts +3 -1
- package/lib/cjs/webchat/typing-indicator/index.js +4 -3
- package/lib/cjs/webchat/typing-indicator/index.js.map +1 -1
- package/lib/cjs/webchat/typing-indicator/styles.d.ts +3 -2
- package/lib/cjs/webchat/typing-indicator/styles.js +6 -3
- package/lib/cjs/webchat/typing-indicator/styles.js.map +1 -1
- package/lib/cjs/webchat/webchat-dev.d.ts +2 -2
- 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 +91 -116
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview/header.d.ts +1 -0
- package/lib/cjs/webchat/webview/header.js +16 -0
- package/lib/cjs/webchat/webview/header.js.map +1 -0
- package/lib/cjs/webchat/webview/index.d.ts +1 -0
- package/lib/cjs/webchat/webview/index.js +49 -0
- package/lib/cjs/webchat/webview/index.js.map +1 -0
- package/lib/cjs/webchat/webview/styles.d.ts +7 -0
- package/lib/cjs/webchat/webview/styles.js +46 -0
- package/lib/cjs/webchat/webview/styles.js.map +1 -0
- package/lib/cjs/webchat-app.d.ts +62 -86
- package/lib/cjs/webchat-app.js +126 -62
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webview-app.js +5 -2
- package/lib/cjs/webview-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/element.js +6 -6
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/handoff.d.ts +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 -127
- package/lib/esm/components/index.d.ts +7 -1
- package/lib/esm/components/index.js +7 -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.d.ts +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.d.ts +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.d.ts +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/multichannel/multichannel-button.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +5 -5
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-reply.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +2 -1
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-utils.d.ts +9 -15
- package/lib/esm/components/multichannel/multichannel-utils.js +40 -24
- package/lib/esm/components/multichannel/multichannel-utils.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +7 -7
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/components/multichannel/whatsapp/constants.d.ts +11 -0
- package/lib/esm/components/multichannel/whatsapp/constants.js +10 -0
- package/lib/esm/components/multichannel/whatsapp/constants.js.map +1 -0
- package/lib/esm/components/raw.d.ts +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/text.d.ts +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/components/whatsapp-button-list.js +1 -1
- package/lib/esm/components/whatsapp-catalog.d.ts +6 -0
- package/lib/esm/components/whatsapp-catalog.js +21 -0
- package/lib/esm/components/whatsapp-catalog.js.map +1 -0
- package/lib/esm/components/whatsapp-cta-url-button.js +1 -1
- package/lib/esm/components/whatsapp-media-carousel.d.ts +46 -0
- package/lib/esm/components/whatsapp-media-carousel.js +36 -0
- package/lib/esm/components/whatsapp-media-carousel.js.map +1 -0
- package/lib/esm/components/whatsapp-product-carousel.d.ts +32 -0
- package/lib/esm/components/whatsapp-product-carousel.js +30 -0
- package/lib/esm/components/whatsapp-product-carousel.js.map +1 -0
- package/lib/esm/components/whatsapp-product-list.d.ts +15 -0
- package/lib/esm/components/whatsapp-product-list.js +22 -0
- package/lib/esm/components/whatsapp-product-list.js.map +1 -0
- package/lib/esm/components/whatsapp-product.d.ts +7 -0
- package/lib/esm/components/whatsapp-product.js +21 -0
- package/lib/esm/components/whatsapp-product.js.map +1 -0
- package/lib/esm/constants.d.ts +0 -6
- package/lib/esm/constants.js +0 -6
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/contexts.d.ts +3 -4
- package/lib/esm/contexts.js +1 -75
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.d.ts +7 -0
- package/lib/esm/dev-app.js +5 -2
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index-types.d.ts +90 -61
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- 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/react-bot.d.ts +1 -1
- package/lib/esm/util/error-boundary.d.ts +1 -1
- package/lib/esm/util/functional.d.ts +3 -0
- package/lib/esm/util/functional.js +26 -0
- package/lib/esm/util/functional.js.map +1 -0
- package/lib/esm/util/react.d.ts +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.d.ts +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/common.d.ts +1 -1
- package/lib/esm/webchat/components/conditional-animation.d.ts +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.d.ts +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} +4 -1
- package/lib/esm/webchat/{actions.js → context/actions.js} +4 -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 +81 -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 +76 -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 +21 -20
- package/lib/esm/webchat/{hooks → context}/use-webchat.js +21 -7
- 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} +4 -0
- package/lib/esm/webchat/context/webchat-reducer.js.map +1 -0
- package/lib/esm/webchat/cover-component/index.d.ts +1 -1
- 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-scroll-to-bottom.d.ts +6 -4
- package/lib/esm/webchat/hooks/use-scroll-to-bottom.js.map +1 -1
- package/lib/esm/webchat/hooks/use-scrollbar-controller.js +16 -16
- 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 +4 -4
- package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -1
- package/lib/esm/webchat/hooks/use-webchat-resizer.js +6 -6
- package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +3 -46
- 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 +2 -2
- 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 +2 -2
- 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 +4 -4
- 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/opened-emoji-picker.d.ts +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.d.ts +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.d.ts +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 +4 -4
- package/lib/esm/webchat/input-panel/textarea.js +11 -3
- package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/message-list/index.d.ts +1 -1
- package/lib/esm/webchat/message-list/index.js +62 -37
- package/lib/esm/webchat/message-list/index.js.map +1 -1
- package/lib/esm/webchat/message-list/intro-message.d.ts +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/scroll-button.d.ts +1 -0
- package/lib/esm/webchat/message-list/styles.js +4 -3
- 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.d.ts +1 -1
- package/lib/esm/webchat/session-view.js +2 -2
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/styles.d.ts +9 -0
- package/lib/esm/webchat/styles.js +50 -0
- 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.d.ts +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/typing-indicator/index.d.ts +3 -1
- package/lib/esm/webchat/typing-indicator/index.js +5 -2
- package/lib/esm/webchat/typing-indicator/index.js.map +1 -1
- package/lib/esm/webchat/typing-indicator/styles.d.ts +3 -2
- package/lib/esm/webchat/typing-indicator/styles.js +5 -2
- package/lib/esm/webchat/typing-indicator/styles.js.map +1 -1
- package/lib/esm/webchat/webchat-dev.d.ts +2 -2
- 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 +87 -112
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview/header.d.ts +1 -0
- package/lib/esm/webchat/webview/header.js +12 -0
- package/lib/esm/webchat/webview/header.js.map +1 -0
- package/lib/esm/webchat/webview/index.d.ts +1 -0
- package/lib/esm/webchat/webview/index.js +45 -0
- package/lib/esm/webchat/webview/index.js.map +1 -0
- package/lib/esm/webchat/webview/styles.d.ts +7 -0
- package/lib/esm/webchat/webview/styles.js +42 -0
- package/lib/esm/webchat/webview/styles.js.map +1 -0
- package/lib/esm/webchat-app.d.ts +62 -86
- package/lib/esm/webchat-app.js +127 -63
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webview-app.js +5 -2
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +21 -18
- 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/element.jsx +4 -11
- package/src/components/handoff.jsx +1 -1
- package/src/components/{image.jsx → image.tsx} +10 -4
- package/src/components/index-types.ts +25 -114
- package/src/components/index.ts +22 -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/multichannel/multichannel-button.jsx +1 -1
- package/src/components/multichannel/multichannel-carousel.jsx +7 -5
- package/src/components/multichannel/multichannel-text.jsx +4 -2
- package/src/components/multichannel/multichannel-utils.js +45 -27
- package/src/components/multichannel/multichannel.jsx +12 -7
- package/src/components/multichannel/whatsapp/constants.ts +10 -0
- 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/components/whatsapp-button-list.tsx +1 -1
- package/src/components/whatsapp-catalog.tsx +42 -0
- package/src/components/whatsapp-cta-url-button.tsx +1 -1
- package/src/components/whatsapp-media-carousel.tsx +104 -0
- package/src/components/whatsapp-product-carousel.tsx +83 -0
- package/src/components/whatsapp-product-list.tsx +56 -0
- package/src/components/whatsapp-product.tsx +44 -0
- package/src/constants.js +0 -7
- package/src/contexts.tsx +5 -80
- package/src/dev-app.jsx +5 -5
- package/src/index-types.ts +101 -70
- package/src/index.ts +1 -5
- package/src/msg-to-botonic.jsx +5 -9
- package/src/util/functional.ts +31 -0
- 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} +4 -0
- package/src/webchat/context/index.tsx +84 -0
- package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
- package/src/webchat/context/types.ts +86 -0
- package/src/webchat/{hooks → context}/use-webchat.ts +73 -15
- package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +5 -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-scroll-to-bottom.ts +8 -2
- package/src/webchat/hooks/use-scrollbar-controller.ts +22 -17
- package/src/webchat/hooks/use-typing.ts +1 -1
- package/src/webchat/hooks/use-webchat-dimensions.ts +4 -4
- package/src/webchat/hooks/use-webchat-resizer.ts +6 -6
- package/src/webchat/index-types.ts +3 -52
- 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 +18 -5
- package/src/webchat/message-list/index.tsx +78 -49
- package/src/webchat/message-list/intro-message.tsx +1 -1
- package/src/webchat/message-list/styles.ts +4 -3
- 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 +2 -2
- package/src/webchat/styles.ts +59 -0
- package/src/webchat/theme/types.ts +119 -0
- package/src/webchat/trigger-button/index.tsx +1 -1
- package/src/webchat/typing-indicator/index.tsx +20 -12
- package/src/webchat/typing-indicator/styles.ts +7 -3
- package/src/webchat/webchat-dev.jsx +1 -1
- package/src/webchat/{webchat.jsx → webchat.tsx} +118 -144
- package/src/webchat/webview/header.tsx +22 -0
- package/src/webchat/webview/index.tsx +80 -0
- package/src/webchat/webview/styles.ts +48 -0
- package/src/webchat-app.tsx +522 -0
- package/src/webview-app.tsx +6 -4
- 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/webview.d.ts +0 -2
- package/lib/cjs/webchat/webview.js +0 -75
- package/lib/cjs/webchat/webview.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/webview.d.ts +0 -2
- package/lib/esm/webchat/webview.js +0 -70
- package/lib/esm/webchat/webview.js.map +0 -1
- package/src/webchat/header.jsx +0 -149
- package/src/webchat/replies.jsx +0 -64
- package/src/webchat/webview.jsx +0 -105
- package/src/webchat-app.jsx +0 -389
|
@@ -12,15 +12,22 @@ import React, {
|
|
|
12
12
|
useRef,
|
|
13
13
|
useState,
|
|
14
14
|
} from 'react'
|
|
15
|
-
import
|
|
15
|
+
import { StyleSheetManager } from 'styled-components'
|
|
16
16
|
import { v7 as uuidv7 } from 'uuid'
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
Audio,
|
|
20
|
+
Document,
|
|
21
|
+
Handoff,
|
|
22
|
+
Image,
|
|
23
|
+
normalizeWebchatSettings,
|
|
24
|
+
Text,
|
|
25
|
+
Video,
|
|
26
|
+
WebchatSettingsProps,
|
|
27
|
+
} from '../components'
|
|
21
28
|
import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../constants'
|
|
22
|
-
import {
|
|
23
|
-
import { SENDERS } from '../index-types'
|
|
29
|
+
import { CloseWebviewOptions } from '../contexts'
|
|
30
|
+
import { SENDERS, WebchatProps, WebchatRef } from '../index-types'
|
|
24
31
|
import {
|
|
25
32
|
getMediaType,
|
|
26
33
|
isAllowedSize,
|
|
@@ -44,6 +51,7 @@ import {
|
|
|
44
51
|
import { ChatArea } from './chat-area'
|
|
45
52
|
import { OpenedPersistentMenu } from './components/opened-persistent-menu'
|
|
46
53
|
import { BotonicContainerId } from './constants'
|
|
54
|
+
import { useWebchat, WebchatContext, WebchatState } from './context'
|
|
47
55
|
import { CoverComponent } from './cover-component'
|
|
48
56
|
import { WebchatHeader } from './header'
|
|
49
57
|
import {
|
|
@@ -51,76 +59,30 @@ import {
|
|
|
51
59
|
usePrevious,
|
|
52
60
|
useScrollToBottom,
|
|
53
61
|
useTyping,
|
|
54
|
-
useWebchat,
|
|
55
62
|
} from './hooks'
|
|
56
63
|
import { InputPanel } from './input-panel'
|
|
64
|
+
import {
|
|
65
|
+
DarkBackgroundMenu,
|
|
66
|
+
ErrorMessage,
|
|
67
|
+
ErrorMessageContainer,
|
|
68
|
+
StyledWebchat,
|
|
69
|
+
} from './styles'
|
|
57
70
|
import { TriggerButton } from './trigger-button'
|
|
58
71
|
import { useStorageState } from './use-storage-state-hook'
|
|
59
72
|
import { getParsedAction } from './utils'
|
|
60
|
-
import { WebviewContainer } from './webview'
|
|
61
|
-
|
|
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
|
-
`
|
|
73
|
+
import { WebviewContainer } from './webview/index'
|
|
112
74
|
|
|
113
75
|
// eslint-disable-next-line complexity, react/display-name
|
|
114
|
-
|
|
76
|
+
const Webchat = forwardRef<WebchatRef | null, WebchatProps>((props, ref) => {
|
|
115
77
|
const {
|
|
116
78
|
addMessage,
|
|
117
79
|
addMessageComponent,
|
|
118
80
|
clearMessages,
|
|
119
81
|
doRenderCustomComponent,
|
|
120
|
-
openWebviewT,
|
|
121
82
|
resetUnreadMessages,
|
|
122
83
|
setCurrentAttachment,
|
|
123
84
|
setError,
|
|
85
|
+
setIsInputFocused,
|
|
124
86
|
setLastMessageVisible,
|
|
125
87
|
setOnline,
|
|
126
88
|
toggleCoverComponent,
|
|
@@ -138,15 +100,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
138
100
|
updateTheme,
|
|
139
101
|
updateTyping,
|
|
140
102
|
updateWebview,
|
|
103
|
+
removeWebview,
|
|
104
|
+
removeReplies,
|
|
141
105
|
webchatState,
|
|
142
|
-
|
|
106
|
+
webchatContainerRef,
|
|
143
107
|
chatAreaRef,
|
|
144
108
|
inputPanelRef,
|
|
145
109
|
headerRef,
|
|
110
|
+
repliesRef,
|
|
146
111
|
scrollableMessagesListRef,
|
|
147
|
-
|
|
148
112
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
149
113
|
} = props.webchatHooks || useWebchat()
|
|
114
|
+
|
|
150
115
|
const firstUpdate = useRef(true)
|
|
151
116
|
const isOnline = () => webchatState.online
|
|
152
117
|
const currentDateString = () => new Date().toISOString()
|
|
@@ -167,7 +132,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
167
132
|
|
|
168
133
|
const { scrollToBottom } = useScrollToBottom({ host })
|
|
169
134
|
|
|
170
|
-
const saveWebchatState = webchatState => {
|
|
135
|
+
const saveWebchatState = (webchatState: WebchatState) => {
|
|
171
136
|
storage &&
|
|
172
137
|
saveState(
|
|
173
138
|
JSON.parse(
|
|
@@ -183,32 +148,34 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
183
148
|
)
|
|
184
149
|
}
|
|
185
150
|
|
|
186
|
-
const handleAttachment = event => {
|
|
151
|
+
const handleAttachment = (event: any) => {
|
|
187
152
|
if (!isAllowedSize(event.target.files[0].size)) {
|
|
188
153
|
throw new Error(
|
|
189
154
|
`The file is too large. A maximum of ${MAX_ALLOWED_SIZE_MB}MB is allowed.`
|
|
190
155
|
)
|
|
191
156
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
attachmentType: getMediaType(event.target.files[0].type),
|
|
196
|
-
})
|
|
157
|
+
|
|
158
|
+
// TODO: Attach more files?
|
|
159
|
+
setCurrentAttachment(event.target.files[0])
|
|
197
160
|
}
|
|
198
161
|
|
|
199
162
|
useEffect(() => {
|
|
200
|
-
if (webchatState.currentAttachment)
|
|
163
|
+
if (webchatState.currentAttachment) {
|
|
201
164
|
sendAttachment(webchatState.currentAttachment)
|
|
165
|
+
}
|
|
202
166
|
}, [webchatState.currentAttachment])
|
|
203
167
|
|
|
204
|
-
const sendUserInput = async input => {
|
|
168
|
+
const sendUserInput = async (input: any) => {
|
|
205
169
|
if (props.onUserInput) {
|
|
206
170
|
resetUnreadMessages()
|
|
207
|
-
scrollToBottom(
|
|
171
|
+
scrollToBottom()
|
|
208
172
|
props.onUserInput({
|
|
209
173
|
user: webchatState.session.user,
|
|
174
|
+
// TODO: Review if this input.sentBy exists in the frontend
|
|
210
175
|
input: input,
|
|
176
|
+
//@ts-ignore
|
|
211
177
|
session: webchatState.session,
|
|
178
|
+
// TODO: Review why we were passing lastRoutePath, is only for devMode?
|
|
212
179
|
lastRoutePath: webchatState.lastRoutePath,
|
|
213
180
|
})
|
|
214
181
|
}
|
|
@@ -260,9 +227,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
260
227
|
addMessage(message)
|
|
261
228
|
const newMessageComponent = msgToBotonic(
|
|
262
229
|
{ ...message, delay: 0, typing: 0 },
|
|
263
|
-
|
|
264
|
-
props.theme.customMessageTypes
|
|
230
|
+
props.theme?.message?.customTypes || props.theme?.customMessageTypes
|
|
265
231
|
)
|
|
232
|
+
//@ts-ignore
|
|
266
233
|
if (newMessageComponent) addMessageComponent(newMessageComponent)
|
|
267
234
|
})
|
|
268
235
|
}
|
|
@@ -271,10 +238,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
271
238
|
} else updateSession(merge(initialSession, session))
|
|
272
239
|
if (devSettings) updateDevSettings(devSettings)
|
|
273
240
|
else if (initialDevSettings) updateDevSettings(initialDevSettings)
|
|
274
|
-
|
|
275
|
-
if (
|
|
241
|
+
|
|
242
|
+
if (lastMessageUpdate) {
|
|
243
|
+
updateLastMessageDate(lastMessageUpdate)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (themeUpdates !== undefined) {
|
|
276
247
|
updateTheme(merge(props.theme, themeUpdates), themeUpdates)
|
|
277
|
-
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (props.onInit) {
|
|
251
|
+
setTimeout(() => props.onInit && props.onInit(), 100)
|
|
252
|
+
}
|
|
278
253
|
}, [])
|
|
279
254
|
|
|
280
255
|
useEffect(() => {
|
|
@@ -287,8 +262,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
287
262
|
}, [webchatState.isWebchatOpen])
|
|
288
263
|
|
|
289
264
|
useEffect(() => {
|
|
290
|
-
|
|
291
|
-
|
|
265
|
+
const { messagesJSON, session } = webchatState
|
|
266
|
+
if (onStateChange && typeof onStateChange === 'function' && session.user) {
|
|
267
|
+
onStateChange({ messagesJSON, user: session.user })
|
|
292
268
|
}
|
|
293
269
|
saveWebchatState(webchatState)
|
|
294
270
|
}, [
|
|
@@ -321,12 +297,12 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
321
297
|
updateWebview(webviewComponent, params)
|
|
322
298
|
}
|
|
323
299
|
|
|
324
|
-
const textareaRef = useRef(
|
|
300
|
+
const textareaRef = useRef<HTMLTextAreaElement | undefined>()
|
|
325
301
|
|
|
326
|
-
const closeWebview = async options => {
|
|
327
|
-
|
|
302
|
+
const closeWebview = async (options?: CloseWebviewOptions) => {
|
|
303
|
+
removeWebview()
|
|
328
304
|
if (userInputEnabled) {
|
|
329
|
-
textareaRef.current
|
|
305
|
+
textareaRef.current?.focus()
|
|
330
306
|
}
|
|
331
307
|
if (options?.payload) {
|
|
332
308
|
await sendPayload(options.payload)
|
|
@@ -342,8 +318,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
342
318
|
)
|
|
343
319
|
|
|
344
320
|
const darkBackgroundMenu = getThemeProperty(
|
|
345
|
-
WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu
|
|
346
|
-
false
|
|
321
|
+
WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu
|
|
347
322
|
)
|
|
348
323
|
|
|
349
324
|
const getBlockInputs = (rule, inputData) => {
|
|
@@ -368,6 +343,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
368
343
|
if (getBlockInputs(rule, input.data)) {
|
|
369
344
|
addMessageComponent(
|
|
370
345
|
<Text
|
|
346
|
+
// Is necessary to add the id of the input
|
|
347
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
348
|
+
// @ts-ignore
|
|
371
349
|
id={input.id}
|
|
372
350
|
sentBy={SENDERS.user}
|
|
373
351
|
blob={false}
|
|
@@ -380,7 +358,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
380
358
|
{rule.message}
|
|
381
359
|
</Text>
|
|
382
360
|
)
|
|
383
|
-
|
|
361
|
+
removeReplies()
|
|
384
362
|
return true
|
|
385
363
|
}
|
|
386
364
|
}
|
|
@@ -421,16 +399,32 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
421
399
|
}, [])
|
|
422
400
|
|
|
423
401
|
const messageComponentFromInput = input => {
|
|
424
|
-
let messageComponent = null
|
|
402
|
+
let messageComponent: any = null
|
|
425
403
|
if (isText(input)) {
|
|
426
404
|
messageComponent = (
|
|
427
|
-
<Text
|
|
405
|
+
<Text
|
|
406
|
+
// Is necessary to add the id of the input
|
|
407
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
408
|
+
// @ts-ignore
|
|
409
|
+
id={input.id}
|
|
410
|
+
// Is necessary to add the payload of the input when user clicks a button
|
|
411
|
+
// @ts-ignore
|
|
412
|
+
payload={input.payload}
|
|
413
|
+
sentBy={SENDERS.user}
|
|
414
|
+
>
|
|
428
415
|
{input.data}
|
|
429
416
|
</Text>
|
|
430
417
|
)
|
|
431
418
|
} else if (isMedia(input)) {
|
|
432
419
|
const temporaryDisplayUrl = URL.createObjectURL(input.data)
|
|
433
|
-
|
|
420
|
+
// TODO: We sould use URL.revokeObjectURL(temporaryDisplayUrl) when the component is unmounted
|
|
421
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL_static#memory_management
|
|
422
|
+
const mediaProps: {
|
|
423
|
+
id: string
|
|
424
|
+
sentBy: SENDERS
|
|
425
|
+
src: string
|
|
426
|
+
input?: any
|
|
427
|
+
} = {
|
|
434
428
|
id: input.id,
|
|
435
429
|
sentBy: SENDERS.user,
|
|
436
430
|
src: temporaryDisplayUrl,
|
|
@@ -446,7 +440,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
446
440
|
return messageComponent
|
|
447
441
|
}
|
|
448
442
|
|
|
449
|
-
const sendInput = async input => {
|
|
443
|
+
const sendInput = async (input: any) => {
|
|
450
444
|
if (!input || Object.keys(input).length == 0) return
|
|
451
445
|
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)
|
|
452
446
|
if (isText(input) && checkBlockInput(input)) return
|
|
@@ -457,7 +451,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
457
451
|
sendUserInput(input)
|
|
458
452
|
updateLatestInput(input)
|
|
459
453
|
isOnline() && updateLastMessageDate(currentDateString())
|
|
460
|
-
|
|
454
|
+
removeReplies()
|
|
461
455
|
togglePersistentMenu(false)
|
|
462
456
|
toggleEmojiPicker(false)
|
|
463
457
|
}
|
|
@@ -466,7 +460,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
466
460
|
https://stackoverflow.com/questions/37949981/call-child-method-from-parent
|
|
467
461
|
*/
|
|
468
462
|
|
|
469
|
-
const updateSessionWithUser = userToUpdate =>
|
|
463
|
+
const updateSessionWithUser = (userToUpdate: any) =>
|
|
470
464
|
updateSession(merge(webchatState.session, { user: userToUpdate }))
|
|
471
465
|
|
|
472
466
|
useImperativeHandle(ref, () => ({
|
|
@@ -499,7 +493,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
499
493
|
|
|
500
494
|
updateLastMessageDate(currentDateString())
|
|
501
495
|
},
|
|
502
|
-
setTyping: typing => updateTyping(typing),
|
|
496
|
+
setTyping: (typing: boolean) => updateTyping(typing),
|
|
503
497
|
addUserMessage: message => sendInput(message),
|
|
504
498
|
updateUser: updateSessionWithUser,
|
|
505
499
|
openWebchat: () => toggleWebchat(true),
|
|
@@ -514,25 +508,23 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
514
508
|
unmountCustomComponent: () => doRenderCustomComponent(false),
|
|
515
509
|
toggleCoverComponent: () =>
|
|
516
510
|
toggleCoverComponent(!webchatState.isCoverComponentOpen),
|
|
517
|
-
openWebviewApi: component => openWebviewT(component),
|
|
518
|
-
setError,
|
|
519
511
|
setOnline,
|
|
520
512
|
getMessages: () => webchatState.messagesJSON,
|
|
521
513
|
isOnline,
|
|
522
514
|
clearMessages: () => {
|
|
523
515
|
clearMessages()
|
|
524
|
-
|
|
516
|
+
removeReplies()
|
|
525
517
|
},
|
|
526
518
|
getLastMessageUpdate: () => webchatState.lastMessageUpdate,
|
|
527
|
-
updateMessageInfo: (msgId, messageInfo) => {
|
|
519
|
+
updateMessageInfo: (msgId: string, messageInfo: any) => {
|
|
528
520
|
const messageToUpdate = webchatState.messagesJSON.filter(
|
|
529
|
-
m => m.id
|
|
521
|
+
m => m.id === msgId
|
|
530
522
|
)[0]
|
|
531
523
|
const updatedMsg = merge(messageToUpdate, messageInfo)
|
|
532
524
|
if (updatedMsg.ack === 1) delete updatedMsg.unsentInput
|
|
533
525
|
updateMessage(updatedMsg)
|
|
534
526
|
},
|
|
535
|
-
updateWebchatSettings: settings => {
|
|
527
|
+
updateWebchatSettings: (settings: WebchatSettingsProps) => {
|
|
536
528
|
if (settings.user) {
|
|
537
529
|
updateSessionWithUser(settings.user)
|
|
538
530
|
}
|
|
@@ -540,59 +532,49 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
540
532
|
updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates)
|
|
541
533
|
updateTyping(false)
|
|
542
534
|
},
|
|
543
|
-
closeWebview:
|
|
535
|
+
closeWebview: async (options?: CloseWebviewOptions) =>
|
|
536
|
+
closeWebview(options),
|
|
544
537
|
}))
|
|
545
538
|
|
|
546
539
|
const resolveCase = () => {
|
|
547
540
|
updateHandoff(false)
|
|
548
|
-
updateSession({ ...webchatState.session, _botonic_action:
|
|
541
|
+
updateSession({ ...webchatState.session, _botonic_action: undefined })
|
|
549
542
|
}
|
|
550
543
|
|
|
551
544
|
const prevSession = usePrevious(webchatState.session)
|
|
552
545
|
useEffect(() => {
|
|
553
546
|
// Resume conversation after handoff
|
|
554
|
-
if (
|
|
555
|
-
prevSession &&
|
|
556
|
-
prevSession._botonic_action &&
|
|
557
|
-
!webchatState.session._botonic_action
|
|
558
|
-
) {
|
|
547
|
+
if (prevSession?._botonic_action && !webchatState.session._botonic_action) {
|
|
559
548
|
const action = getParsedAction(prevSession._botonic_action)
|
|
560
|
-
if (action
|
|
549
|
+
if (action?.on_finish) sendPayload(action.on_finish)
|
|
561
550
|
}
|
|
562
551
|
}, [webchatState.session._botonic_action])
|
|
563
552
|
|
|
564
|
-
const sendText = async (text, payload) => {
|
|
553
|
+
const sendText = async (text: string, payload?: string) => {
|
|
565
554
|
if (!text) return
|
|
566
555
|
const input = { type: INPUT.TEXT, data: text, payload }
|
|
567
556
|
await sendInput(input)
|
|
568
557
|
}
|
|
569
558
|
|
|
570
|
-
const sendPayload = async payload => {
|
|
559
|
+
const sendPayload = async (payload: string) => {
|
|
571
560
|
if (!payload) return
|
|
572
561
|
const input = { type: INPUT.POSTBACK, payload }
|
|
573
562
|
await sendInput(input)
|
|
574
563
|
}
|
|
575
564
|
|
|
576
|
-
const sendAttachment = async attachment => {
|
|
577
|
-
if (attachment
|
|
578
|
-
const attachmentType = getMediaType(attachment.
|
|
565
|
+
const sendAttachment = async (attachment: File) => {
|
|
566
|
+
if (attachment) {
|
|
567
|
+
const attachmentType = getMediaType(attachment.type)
|
|
579
568
|
if (!attachmentType) return
|
|
580
569
|
const input = {
|
|
581
570
|
type: attachmentType,
|
|
582
|
-
data: attachment
|
|
571
|
+
data: attachment,
|
|
583
572
|
}
|
|
584
573
|
await sendInput(input)
|
|
585
|
-
setCurrentAttachment(
|
|
574
|
+
setCurrentAttachment()
|
|
586
575
|
}
|
|
587
576
|
}
|
|
588
577
|
|
|
589
|
-
const webviewRequestContext = {
|
|
590
|
-
closeWebview: closeWebview,
|
|
591
|
-
getString: stringId => props.getString(stringId, webchatState.session),
|
|
592
|
-
params: webchatState.webviewParams || {},
|
|
593
|
-
session: webchatState.session || {},
|
|
594
|
-
}
|
|
595
|
-
|
|
596
578
|
useEffect(() => {
|
|
597
579
|
if (firstUpdate.current) {
|
|
598
580
|
firstUpdate.current = false
|
|
@@ -618,17 +600,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
618
600
|
|
|
619
601
|
const userInputEnabled = isUserInputEnabled()
|
|
620
602
|
|
|
621
|
-
|
|
622
|
-
<WebviewRequestContext.Provider value={webviewRequestContext}>
|
|
623
|
-
<WebviewContainer
|
|
624
|
-
style={{
|
|
625
|
-
...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewStyle),
|
|
626
|
-
...mobileStyle,
|
|
627
|
-
}}
|
|
628
|
-
webview={webchatState.webview}
|
|
629
|
-
/>
|
|
630
|
-
</WebviewRequestContext.Provider>
|
|
631
|
-
)
|
|
603
|
+
// TODO: Create a default theme that include mobileStyle
|
|
632
604
|
let mobileStyle = {}
|
|
633
605
|
if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
|
|
634
606
|
mobileStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
|
|
@@ -679,9 +651,11 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
679
651
|
value={{
|
|
680
652
|
addMessage,
|
|
681
653
|
getThemeProperty,
|
|
654
|
+
closeWebview,
|
|
682
655
|
openWebview,
|
|
683
656
|
resolveCase,
|
|
684
657
|
resetUnreadMessages,
|
|
658
|
+
setIsInputFocused,
|
|
685
659
|
setLastMessageVisible,
|
|
686
660
|
sendAttachment,
|
|
687
661
|
sendInput,
|
|
@@ -696,12 +670,15 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
696
670
|
updateReplies,
|
|
697
671
|
updateUser: updateSessionWithUser,
|
|
698
672
|
updateWebchatDevSettings: updateWebchatDevSettings,
|
|
699
|
-
webchatState,
|
|
700
673
|
trackEvent: props.onTrackEvent,
|
|
701
|
-
|
|
674
|
+
webchatState,
|
|
675
|
+
// TODO: Review if need theme inside Context, already exist inside webchatState
|
|
676
|
+
theme,
|
|
677
|
+
webchatContainerRef,
|
|
702
678
|
chatAreaRef,
|
|
703
679
|
inputPanelRef,
|
|
704
680
|
headerRef,
|
|
681
|
+
repliesRef,
|
|
705
682
|
scrollableMessagesListRef,
|
|
706
683
|
}}
|
|
707
684
|
>
|
|
@@ -710,7 +687,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
710
687
|
{webchatState.isWebchatOpen && (
|
|
711
688
|
<StyledWebchat
|
|
712
689
|
id={BotonicContainerId.Webchat}
|
|
713
|
-
ref={
|
|
690
|
+
ref={webchatContainerRef}
|
|
714
691
|
// TODO: Distinguish between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
|
|
715
692
|
role={ROLES.WEBCHAT}
|
|
716
693
|
width={webchatState.width}
|
|
@@ -720,13 +697,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
720
697
|
...mobileStyle,
|
|
721
698
|
}}
|
|
722
699
|
>
|
|
723
|
-
<WebchatHeader
|
|
724
|
-
id={BotonicContainerId.Header}
|
|
725
|
-
ref={headerRef}
|
|
726
|
-
onCloseClick={() => {
|
|
727
|
-
toggleWebchat(false)
|
|
728
|
-
}}
|
|
729
|
-
/>
|
|
700
|
+
<WebchatHeader ref={headerRef} />
|
|
730
701
|
|
|
731
702
|
{webchatState.isCoverComponentOpen ? (
|
|
732
703
|
<CoverComponent
|
|
@@ -759,7 +730,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
759
730
|
/>
|
|
760
731
|
)}
|
|
761
732
|
|
|
762
|
-
{webchatState.webview &&
|
|
733
|
+
{webchatState.webview && <WebviewContainer />}
|
|
763
734
|
|
|
764
735
|
{webchatState.isCustomComponentRendered &&
|
|
765
736
|
customComponent &&
|
|
@@ -777,3 +748,6 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
777
748
|
WebchatComponent
|
|
778
749
|
)
|
|
779
750
|
})
|
|
751
|
+
|
|
752
|
+
Webchat.displayName = 'Webchat'
|
|
753
|
+
export { Webchat }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React, { useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { ROLES, WEBCHAT } from '../../constants'
|
|
4
|
+
import { WebviewRequestContext } from '../../contexts'
|
|
5
|
+
import { WebchatContext } from '../context'
|
|
6
|
+
import { StyledCloseHeader, StyledWebviewHeader } from './styles'
|
|
7
|
+
|
|
8
|
+
export const WebviewHeader = () => {
|
|
9
|
+
const { closeWebview } = useContext(WebviewRequestContext)
|
|
10
|
+
const { getThemeProperty } = useContext(WebchatContext)
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<StyledWebviewHeader
|
|
14
|
+
role={ROLES.WEBVIEW_HEADER}
|
|
15
|
+
style={{
|
|
16
|
+
...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewHeaderStyle),
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
<StyledCloseHeader onClick={() => closeWebview()}>✕</StyledCloseHeader>
|
|
20
|
+
</StyledWebviewHeader>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { isMobile, Session as CoreSession } from '@botonic/core'
|
|
2
|
+
import React, { useContext, useEffect } from 'react'
|
|
3
|
+
|
|
4
|
+
import { ROLES, WEBCHAT } from '../../constants'
|
|
5
|
+
import { CloseWebviewOptions, WebviewRequestContext } from '../../contexts'
|
|
6
|
+
import { WebchatContext } from '../context'
|
|
7
|
+
import { WebviewHeader } from './header'
|
|
8
|
+
import {
|
|
9
|
+
StyledFrame,
|
|
10
|
+
StyledFrameAsDiv,
|
|
11
|
+
StyledWebview,
|
|
12
|
+
StyledWebviewContent,
|
|
13
|
+
} from './styles'
|
|
14
|
+
|
|
15
|
+
export const WebviewContainer = () => {
|
|
16
|
+
const { closeWebview, getThemeProperty, webchatState } =
|
|
17
|
+
useContext(WebchatContext)
|
|
18
|
+
|
|
19
|
+
const webviewRequestContext = {
|
|
20
|
+
closeWebview: async (options?: CloseWebviewOptions) =>
|
|
21
|
+
await closeWebview(options),
|
|
22
|
+
params: webchatState.webviewParams || ({} as Record<string, any>),
|
|
23
|
+
session: webchatState.session || ({} as Partial<CoreSession>),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// TODO: Remove this code and use theme or webchatState.theme from the context,
|
|
27
|
+
// this code is duplicated from webchat.tsx
|
|
28
|
+
let mobileStyle = {}
|
|
29
|
+
if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
|
|
30
|
+
mobileStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
|
|
31
|
+
width: '100%',
|
|
32
|
+
height: '100%',
|
|
33
|
+
right: 0,
|
|
34
|
+
bottom: 0,
|
|
35
|
+
borderRadius: 0,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Webview = webchatState.webview as string | React.ComponentType
|
|
40
|
+
|
|
41
|
+
const close = async (e: any) => {
|
|
42
|
+
if (e.data === 'botonicCloseWebview') {
|
|
43
|
+
console.log('Received close message from webview')
|
|
44
|
+
await closeWebview()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
window.addEventListener('message', close, false)
|
|
50
|
+
|
|
51
|
+
return () => window.removeEventListener('message', close, false)
|
|
52
|
+
}, [])
|
|
53
|
+
|
|
54
|
+
// TODO: Review how to split the logic of rendering a webview in local development and production
|
|
55
|
+
// In local development, Webview is a component. In production it is the URL of the webview
|
|
56
|
+
const isUrlToWebview = typeof Webview === 'string'
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<StyledWebview
|
|
60
|
+
role={ROLES.WEBVIEW}
|
|
61
|
+
style={{
|
|
62
|
+
...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewStyle),
|
|
63
|
+
...mobileStyle,
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
<WebviewHeader />
|
|
67
|
+
<StyledWebviewContent>
|
|
68
|
+
{isUrlToWebview ? (
|
|
69
|
+
<StyledFrame src={Webview} />
|
|
70
|
+
) : (
|
|
71
|
+
<WebviewRequestContext.Provider value={webviewRequestContext}>
|
|
72
|
+
<StyledFrameAsDiv>
|
|
73
|
+
<Webview />
|
|
74
|
+
</StyledFrameAsDiv>
|
|
75
|
+
</WebviewRequestContext.Provider>
|
|
76
|
+
)}
|
|
77
|
+
</StyledWebviewContent>
|
|
78
|
+
</StyledWebview>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
import { COLORS, WEBCHAT } from '../../constants'
|
|
4
|
+
|
|
5
|
+
export const StyledWebview = styled.div`
|
|
6
|
+
position: absolute;
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
width: 100%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
background-color: ${COLORS.SOLID_WHITE};
|
|
13
|
+
z-index: 2;
|
|
14
|
+
border-radius: ${WEBCHAT.DEFAULTS.BORDER_RADIUS_TOP_CORNERS};
|
|
15
|
+
`
|
|
16
|
+
|
|
17
|
+
export const StyledWebviewHeader = styled.div`
|
|
18
|
+
flex: none;
|
|
19
|
+
text-align: right;
|
|
20
|
+
background-color: ${COLORS.WILD_SAND_WHITE};
|
|
21
|
+
border-top: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_2};
|
|
22
|
+
border-bottom: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_2};
|
|
23
|
+
border-radius: ${WEBCHAT.DEFAULTS.BORDER_RADIUS_TOP_CORNERS};
|
|
24
|
+
`
|
|
25
|
+
export const StyledCloseHeader = styled.div`
|
|
26
|
+
display: inline-block;
|
|
27
|
+
padding: 8px 12px;
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
export const StyledWebviewContent = styled.div`
|
|
32
|
+
flex: 1;
|
|
33
|
+
overflow: auto;
|
|
34
|
+
`
|
|
35
|
+
|
|
36
|
+
export const FrameStyles = `
|
|
37
|
+
border-style: none;
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 100%;
|
|
40
|
+
`
|
|
41
|
+
|
|
42
|
+
export const StyledFrame = styled.iframe`
|
|
43
|
+
${FrameStyles}
|
|
44
|
+
`
|
|
45
|
+
|
|
46
|
+
export const StyledFrameAsDiv = styled.div`
|
|
47
|
+
${FrameStyles}
|
|
48
|
+
`
|