@botonic/react 0.36.0-alpha.0 → 0.36.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/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.d.ts → button/index.d.ts} +4 -5
- package/lib/cjs/components/{button.js → button/index.js} +26 -57
- package/lib/cjs/components/button/index.js.map +1 -0
- package/lib/cjs/components/button/styles.d.ts +2 -0
- package/lib/cjs/components/button/styles.js +40 -0
- package/lib/cjs/components/button/styles.js.map +1 -0
- package/lib/cjs/components/buttons-disabler.d.ts +20 -23
- package/lib/cjs/components/buttons-disabler.js +11 -26
- package/lib/cjs/components/buttons-disabler.js.map +1 -1
- package/lib/cjs/components/carousel.d.ts +8 -9
- package/lib/cjs/components/carousel.js +28 -24
- 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.d.ts +7 -3
- package/lib/cjs/components/element.js +12 -12
- 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 +6 -6
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +31 -132
- package/lib/cjs/components/index.d.ts +8 -2
- package/lib/cjs/components/index.js +16 -3
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/message/index.js +9 -8
- 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 +9 -20
- 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 +4 -4
- package/lib/cjs/components/message/message-footer.js.map +1 -1
- package/lib/cjs/components/message/message-image.js +3 -3
- package/lib/cjs/components/message/message-image.js.map +1 -1
- package/lib/cjs/components/message/styles.d.ts +11 -11
- package/lib/cjs/components/message/timestamps.d.ts +1 -1
- package/lib/cjs/components/message/timestamps.js +3 -3
- package/lib/cjs/components/message/timestamps.js.map +1 -1
- package/lib/cjs/components/multichannel/index-types.d.ts +0 -4
- package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +5 -5
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +59 -62
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-context.d.ts +0 -3
- package/lib/cjs/components/multichannel/multichannel-context.js +0 -3
- package/lib/cjs/components/multichannel/multichannel-context.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 +19 -15
- 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/pic.d.ts +8 -5
- package/lib/cjs/components/pic.js +8 -8
- package/lib/cjs/components/pic.js.map +1 -1
- package/lib/cjs/components/raw.d.ts +1 -1
- package/lib/cjs/components/reply.d.ts +7 -6
- package/lib/cjs/components/reply.js +13 -7
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/subtitle.d.ts +9 -5
- package/lib/cjs/components/subtitle.js +6 -7
- package/lib/cjs/components/subtitle.js.map +1 -1
- package/lib/cjs/components/text.d.ts +1 -1
- package/lib/cjs/components/title.d.ts +9 -5
- package/lib/cjs/components/title.js +6 -7
- package/lib/cjs/components/title.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 +18 -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 +6 -6
- 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 +6 -6
- 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 -18
- package/lib/cjs/constants.js +1 -19
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/contexts.d.ts +3 -8
- package/lib/cjs/contexts.js +11 -77
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.d.ts +7 -0
- package/lib/cjs/dev-app.js +8 -13
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index-types.d.ts +85 -77
- 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 +9 -12
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/react-bot.d.ts +16 -6
- package/lib/cjs/react-bot.js +5 -6
- package/lib/cjs/react-bot.js.map +1 -1
- package/lib/cjs/shared/styles.d.ts +2 -2
- package/lib/cjs/time-zone-to-country-code.d.ts +1 -0
- package/lib/cjs/time-zone-to-country-code.js +108 -0
- package/lib/cjs/time-zone-to-country-code.js.map +1 -0
- 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 +19 -6
- package/lib/cjs/util/webchat.js +44 -8
- 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/chat-area/styles.d.ts +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 +3 -3
- 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 +6 -6
- package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/{esm/webchat → cjs/webchat/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 +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 +83 -0
- package/lib/cjs/webchat/context/types.js +3 -0
- package/lib/cjs/webchat/context/types.js.map +1 -0
- package/lib/cjs/webchat/context/use-webchat.d.ts +46 -0
- package/lib/cjs/webchat/{hooks → context}/use-webchat.js +53 -47
- 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 +6 -0
- package/lib/cjs/webchat/cover-component/index.js +21 -0
- package/lib/cjs/webchat/cover-component/index.js.map +1 -0
- 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 +63 -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 +2 -56
- 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 -2
- package/lib/cjs/webchat/input-panel/attachment.js +7 -6
- package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -2
- package/lib/cjs/webchat/input-panel/emoji-picker.js +7 -6
- package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/input-panel/index.d.ts +2 -5
- package/lib/cjs/webchat/input-panel/index.js +10 -5
- 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 -2
- package/lib/cjs/webchat/input-panel/persistent-menu.js +6 -5
- 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 +5 -4
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/cjs/webchat/input-panel/styles.d.ts +3 -3
- package/lib/cjs/webchat/input-panel/textarea.d.ts +2 -4
- package/lib/cjs/webchat/input-panel/textarea.js +16 -6
- 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 +3 -3
- 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.d.ts +5 -5
- 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 +6 -6
- 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 +4 -0
- package/lib/cjs/webchat/styles.js +65 -0
- package/lib/cjs/webchat/styles.js.map +1 -0
- package/lib/cjs/webchat/theme/default-theme.d.ts +2 -0
- package/lib/cjs/webchat/theme/default-theme.js +104 -0
- package/lib/cjs/webchat/theme/default-theme.js.map +1 -0
- package/lib/cjs/webchat/theme/types.d.ts +214 -0
- package/lib/cjs/webchat/theme/types.js +3 -0
- package/lib/cjs/webchat/theme/types.js.map +1 -0
- package/lib/cjs/webchat/tracking.d.ts +10 -0
- package/lib/cjs/webchat/tracking.js +39 -1
- package/lib/cjs/webchat/tracking.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/index.d.ts +1 -0
- package/lib/cjs/webchat/trigger-button/index.js +5 -5
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/cjs/webchat/trigger-button/styles.d.ts +3 -3
- 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 +4 -3
- 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 +3 -3
- 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 +110 -148
- 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 +36 -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 +60 -0
- package/lib/cjs/webchat/webview/styles.js.map +1 -0
- package/lib/cjs/webchat-app.d.ts +95 -86
- package/lib/cjs/webchat-app.js +164 -72
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webview-app.js +54 -12
- 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.d.ts → button/index.d.ts} +4 -5
- package/lib/esm/components/{button.js → button/index.js} +26 -56
- package/lib/esm/components/button/index.js.map +1 -0
- package/lib/esm/components/button/styles.d.ts +2 -0
- package/lib/esm/components/button/styles.js +36 -0
- package/lib/esm/components/button/styles.js.map +1 -0
- package/lib/esm/components/buttons-disabler.d.ts +20 -23
- package/lib/esm/components/buttons-disabler.js +11 -26
- package/lib/esm/components/buttons-disabler.js.map +1 -1
- package/lib/esm/components/carousel.d.ts +8 -9
- package/lib/esm/components/carousel.js +27 -23
- 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.d.ts +7 -3
- package/lib/esm/components/element.js +10 -10
- 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 +5 -5
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +31 -132
- package/lib/esm/components/index.d.ts +8 -2
- package/lib/esm/components/index.js +8 -2
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/message/index.js +7 -6
- 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 +10 -21
- 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 +3 -3
- package/lib/esm/components/message/message-footer.js.map +1 -1
- package/lib/esm/components/message/message-image.js +2 -2
- package/lib/esm/components/message/message-image.js.map +1 -1
- package/lib/esm/components/message/styles.d.ts +11 -11
- package/lib/esm/components/message/timestamps.d.ts +1 -1
- package/lib/esm/components/message/timestamps.js +2 -2
- package/lib/esm/components/message/timestamps.js.map +1 -1
- package/lib/esm/components/multichannel/index-types.d.ts +0 -4
- package/lib/esm/components/multichannel/multichannel-button.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +2 -2
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +62 -65
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-context.d.ts +0 -3
- package/lib/esm/components/multichannel/multichannel-context.js +0 -3
- package/lib/esm/components/multichannel/multichannel-context.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 +9 -5
- 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/pic.d.ts +8 -5
- package/lib/esm/components/pic.js +6 -6
- package/lib/esm/components/pic.js.map +1 -1
- package/lib/esm/components/raw.d.ts +1 -1
- package/lib/esm/components/reply.d.ts +7 -6
- package/lib/esm/components/reply.js +13 -7
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/subtitle.d.ts +9 -5
- package/lib/esm/components/subtitle.js +4 -5
- package/lib/esm/components/subtitle.js.map +1 -1
- package/lib/esm/components/text.d.ts +1 -1
- package/lib/esm/components/title.d.ts +9 -5
- package/lib/esm/components/title.js +4 -5
- package/lib/esm/components/title.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 +18 -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 +6 -6
- package/lib/esm/components/whatsapp-button-list.js.map +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 +3 -3
- package/lib/esm/components/whatsapp-cta-url-button.js.map +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 -18
- package/lib/esm/constants.js +0 -18
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/contexts.d.ts +3 -8
- package/lib/esm/contexts.js +10 -76
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.d.ts +7 -0
- package/lib/esm/dev-app.js +8 -13
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index-types.d.ts +85 -77
- 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 +8 -11
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/react-bot.d.ts +16 -6
- package/lib/esm/react-bot.js +5 -6
- package/lib/esm/react-bot.js.map +1 -1
- package/lib/esm/shared/styles.d.ts +2 -2
- package/lib/esm/time-zone-to-country-code.d.ts +1 -0
- package/lib/esm/time-zone-to-country-code.js +105 -0
- package/lib/esm/time-zone-to-country-code.js.map +1 -0
- 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 +19 -6
- package/lib/esm/util/webchat.js +42 -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/chat-area/styles.d.ts +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 +2 -2
- 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 +3 -3
- package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/{cjs/webchat → esm/webchat/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 +79 -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 +83 -0
- package/lib/esm/webchat/context/types.js +2 -0
- package/lib/esm/webchat/context/types.js.map +1 -0
- package/lib/esm/webchat/context/use-webchat.d.ts +46 -0
- package/lib/esm/webchat/{hooks → context}/use-webchat.js +51 -45
- 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 +6 -0
- package/lib/esm/webchat/cover-component/index.js +17 -0
- package/lib/esm/webchat/cover-component/index.js.map +1 -0
- 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 +59 -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 +2 -56
- 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 -2
- package/lib/esm/webchat/input-panel/attachment.js +8 -7
- package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -2
- package/lib/esm/webchat/input-panel/emoji-picker.js +8 -7
- package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/input-panel/index.d.ts +2 -5
- package/lib/esm/webchat/input-panel/index.js +9 -4
- 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 -2
- package/lib/esm/webchat/input-panel/persistent-menu.js +7 -6
- 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 +6 -5
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/webchat/input-panel/styles.d.ts +3 -3
- package/lib/esm/webchat/input-panel/textarea.d.ts +2 -4
- package/lib/esm/webchat/input-panel/textarea.js +16 -6
- 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 +2 -2
- 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.d.ts +5 -5
- 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 +5 -5
- 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 +4 -0
- package/lib/esm/webchat/styles.js +61 -0
- package/lib/esm/webchat/styles.js.map +1 -0
- package/lib/esm/webchat/theme/default-theme.d.ts +2 -0
- package/lib/esm/webchat/theme/default-theme.js +101 -0
- package/lib/esm/webchat/theme/default-theme.js.map +1 -0
- package/lib/esm/webchat/theme/types.d.ts +214 -0
- package/lib/esm/webchat/theme/types.js +2 -0
- package/lib/esm/webchat/theme/types.js.map +1 -0
- package/lib/esm/webchat/tracking.d.ts +10 -0
- package/lib/esm/webchat/tracking.js +37 -0
- package/lib/esm/webchat/tracking.js.map +1 -1
- package/lib/esm/webchat/trigger-button/index.d.ts +1 -0
- package/lib/esm/webchat/trigger-button/index.js +4 -4
- package/lib/esm/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/webchat/trigger-button/styles.d.ts +3 -3
- 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 +4 -3
- 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 +3 -3
- 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 +110 -148
- 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 +32 -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 +56 -0
- package/lib/esm/webchat/webview/styles.js.map +1 -0
- package/lib/esm/webchat-app.d.ts +95 -86
- package/lib/esm/webchat-app.js +165 -73
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webview-app.js +55 -13
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +23 -18
- package/src/components/{audio.jsx → audio.tsx} +10 -4
- package/src/components/{button.tsx → button/index.tsx} +26 -104
- package/src/components/button/styles.ts +38 -0
- package/src/components/{buttons-disabler.js → buttons-disabler.ts} +35 -39
- package/src/components/{carousel.jsx → carousel.tsx} +60 -36
- 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 → element.tsx} +12 -14
- package/src/components/handoff.jsx +1 -1
- package/src/components/{image.jsx → image.tsx} +13 -6
- package/src/components/index-types.ts +24 -119
- package/src/components/index.ts +23 -2
- package/src/components/message/index.jsx +7 -10
- package/src/components/message/message-feedback.tsx +10 -27
- package/src/components/message/message-footer.tsx +3 -3
- package/src/components/message/message-image.tsx +2 -5
- package/src/components/message/timestamps.tsx +2 -3
- package/src/components/multichannel/index-types.ts +0 -4
- package/src/components/multichannel/multichannel-button.jsx +2 -2
- package/src/components/multichannel/multichannel-carousel.jsx +96 -94
- package/src/components/multichannel/multichannel-context.jsx +0 -3
- package/src/components/multichannel/multichannel-text.jsx +12 -6
- 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/{pic.jsx → pic.tsx} +12 -5
- package/src/components/{reply.jsx → reply.tsx} +12 -12
- package/src/components/{subtitle.jsx → subtitle.tsx} +10 -10
- package/src/components/{title.jsx → title.tsx} +8 -6
- package/src/components/{video.jsx → video.tsx} +3 -2
- package/src/components/webchat-settings.tsx +22 -2
- package/src/components/whatsapp-button-list.tsx +6 -6
- package/src/components/whatsapp-catalog.tsx +42 -0
- package/src/components/whatsapp-cta-url-button.tsx +6 -3
- 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 -19
- package/src/contexts.tsx +14 -87
- package/src/dev-app.jsx +6 -30
- package/src/index-types.ts +100 -84
- package/src/index.ts +1 -5
- package/src/msg-to-botonic.jsx +8 -12
- package/src/react-bot.tsx +51 -0
- package/src/time-zone-to-country-code.ts +104 -0
- package/src/util/functional.ts +31 -0
- package/src/util/webchat.ts +102 -0
- package/src/webchat/chat-area/index.tsx +2 -4
- package/src/webchat/components/conditional-animation.jsx +3 -3
- package/src/webchat/components/opened-persistent-menu.jsx +3 -4
- package/src/webchat/{actions.ts → context/actions.ts} +4 -0
- package/src/webchat/context/index.tsx +82 -0
- package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
- package/src/webchat/context/types.ts +91 -0
- package/src/webchat/{hooks → context}/use-webchat.ts +104 -53
- package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +5 -1
- package/src/webchat/cover-component/index.tsx +31 -0
- package/src/webchat/global.d.ts +3 -0
- package/src/webchat/header/default-header.tsx +64 -0
- package/src/webchat/header/index.tsx +37 -0
- package/src/webchat/header/styles.ts +66 -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 +2 -63
- package/src/webchat/index.ts +1 -0
- package/src/webchat/input-panel/attachment.tsx +6 -17
- package/src/webchat/input-panel/emoji-picker.tsx +6 -16
- package/src/webchat/input-panel/index.tsx +9 -16
- package/src/webchat/input-panel/persistent-menu.tsx +6 -16
- package/src/webchat/input-panel/send-button.tsx +4 -10
- package/src/webchat/input-panel/textarea.tsx +22 -15
- package/src/webchat/message-list/index.tsx +78 -49
- package/src/webchat/message-list/intro-message.tsx +2 -3
- 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 +5 -9
- 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 +65 -0
- package/src/webchat/theme/default-theme.ts +102 -0
- package/src/webchat/theme/theme.d.ts +8 -0
- package/src/webchat/theme/types.ts +206 -0
- package/src/webchat/tracking.ts +59 -0
- package/src/webchat/trigger-button/index.tsx +4 -6
- 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} +191 -243
- package/src/webchat/webview/header.tsx +22 -0
- package/src/webchat/webview/index.tsx +66 -0
- package/src/webchat/webview/styles.ts +62 -0
- package/src/webchat-app.tsx +575 -0
- package/src/webview-app.tsx +60 -16
- package/lib/cjs/components/button.js.map +0 -1
- 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.d.ts +0 -46
- 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/components/button.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.d.ts +0 -46
- 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/react-bot.jsx +0 -38
- package/src/util/webchat.js +0 -57
- 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
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BotonicAction,
|
|
3
|
-
INPUT,
|
|
4
|
-
isMobile,
|
|
5
|
-
params2queryString,
|
|
6
|
-
} from '@botonic/core'
|
|
1
|
+
import { BotonicAction, INPUT, params2queryString } from '@botonic/core'
|
|
7
2
|
import merge from 'lodash.merge'
|
|
8
3
|
import React, {
|
|
9
4
|
forwardRef,
|
|
@@ -12,15 +7,22 @@ import React, {
|
|
|
12
7
|
useRef,
|
|
13
8
|
useState,
|
|
14
9
|
} from 'react'
|
|
15
|
-
import
|
|
10
|
+
import { StyleSheetManager, ThemeProvider } from 'styled-components'
|
|
16
11
|
import { v7 as uuidv7 } from 'uuid'
|
|
17
12
|
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
import {
|
|
14
|
+
Audio,
|
|
15
|
+
Document,
|
|
16
|
+
Handoff,
|
|
17
|
+
Image,
|
|
18
|
+
normalizeWebchatSettings,
|
|
19
|
+
Text,
|
|
20
|
+
Video,
|
|
21
|
+
WebchatSettingsProps,
|
|
22
|
+
} from '../components'
|
|
21
23
|
import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../constants'
|
|
22
|
-
import {
|
|
23
|
-
import { SENDERS } from '../index-types'
|
|
24
|
+
import { CloseWebviewOptions } from '../contexts'
|
|
25
|
+
import { SENDERS, WebchatProps, WebchatRef } from '../index-types'
|
|
24
26
|
import {
|
|
25
27
|
getMediaType,
|
|
26
28
|
isAllowedSize,
|
|
@@ -40,86 +42,44 @@ import {
|
|
|
40
42
|
getServerErrorMessage,
|
|
41
43
|
initSession,
|
|
42
44
|
shouldKeepSessionOnReload,
|
|
45
|
+
updateUserLocaleAndCountry,
|
|
43
46
|
} from '../util/webchat'
|
|
44
47
|
import { ChatArea } from './chat-area'
|
|
45
48
|
import { OpenedPersistentMenu } from './components/opened-persistent-menu'
|
|
46
49
|
import { BotonicContainerId } from './constants'
|
|
50
|
+
import { useWebchat, WebchatContext, WebchatState } from './context'
|
|
51
|
+
import { CoverComponent } from './cover-component'
|
|
47
52
|
import { WebchatHeader } from './header'
|
|
48
53
|
import {
|
|
49
54
|
useComponentWillMount,
|
|
50
55
|
usePrevious,
|
|
51
56
|
useScrollToBottom,
|
|
52
57
|
useTyping,
|
|
53
|
-
useWebchat,
|
|
54
58
|
} from './hooks'
|
|
55
59
|
import { InputPanel } from './input-panel'
|
|
60
|
+
import {
|
|
61
|
+
DarkBackgroundMenu,
|
|
62
|
+
ErrorMessage,
|
|
63
|
+
ErrorMessageContainer,
|
|
64
|
+
StyledWebchat,
|
|
65
|
+
} from './styles'
|
|
66
|
+
import { WebchatTheme } from './theme/types'
|
|
56
67
|
import { TriggerButton } from './trigger-button'
|
|
57
68
|
import { useStorageState } from './use-storage-state-hook'
|
|
58
69
|
import { getParsedAction } from './utils'
|
|
59
|
-
import { WebviewContainer } from './webview'
|
|
60
|
-
|
|
61
|
-
const StyledWebchat = styled.div`
|
|
62
|
-
position: fixed;
|
|
63
|
-
right: 20px;
|
|
64
|
-
bottom: 20px;
|
|
65
|
-
width: ${props => props.width}px;
|
|
66
|
-
height: ${props => props.height}px;
|
|
67
|
-
margin: auto;
|
|
68
|
-
background-color: ${COLORS.SOLID_WHITE};
|
|
69
|
-
border-radius: 10px;
|
|
70
|
-
box-shadow: ${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
|
|
71
|
-
display: flex;
|
|
72
|
-
flex-direction: column;
|
|
73
|
-
justify-content: space-between;
|
|
74
|
-
overflow: hidden;
|
|
75
|
-
`
|
|
76
|
-
|
|
77
|
-
const ErrorMessageContainer = styled.div`
|
|
78
|
-
position: relative;
|
|
79
|
-
display: flex;
|
|
80
|
-
z-index: 1;
|
|
81
|
-
justify-content: center;
|
|
82
|
-
width: 100%;
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
const ErrorMessage = styled.div`
|
|
86
|
-
position: absolute;
|
|
87
|
-
top: 10px;
|
|
88
|
-
font-size: 14px;
|
|
89
|
-
line-height: 20px;
|
|
90
|
-
padding: 4px 11px;
|
|
91
|
-
display: flex;
|
|
92
|
-
background-color: ${COLORS.ERROR_RED};
|
|
93
|
-
color: ${COLORS.CONCRETE_WHITE};
|
|
94
|
-
border-radius: 5px;
|
|
95
|
-
align-items: center;
|
|
96
|
-
justify-content: center;
|
|
97
|
-
font-family: ${WEBCHAT.DEFAULTS.FONT_FAMILY};
|
|
98
|
-
`
|
|
99
|
-
|
|
100
|
-
const DarkBackgroundMenu = styled.div`
|
|
101
|
-
background: ${COLORS.SOLID_BLACK};
|
|
102
|
-
opacity: 0.3;
|
|
103
|
-
z-index: 1;
|
|
104
|
-
right: 0;
|
|
105
|
-
bottom: 0;
|
|
106
|
-
border-radius: 10px;
|
|
107
|
-
position: absolute;
|
|
108
|
-
width: 100%;
|
|
109
|
-
height: 100%;
|
|
110
|
-
`
|
|
70
|
+
import { WebviewContainer } from './webview/index'
|
|
111
71
|
|
|
112
72
|
// eslint-disable-next-line complexity, react/display-name
|
|
113
|
-
|
|
73
|
+
const Webchat = forwardRef<WebchatRef | null, WebchatProps>((props, ref) => {
|
|
114
74
|
const {
|
|
115
75
|
addMessage,
|
|
116
76
|
addMessageComponent,
|
|
117
77
|
clearMessages,
|
|
118
78
|
doRenderCustomComponent,
|
|
119
|
-
openWebviewT,
|
|
120
79
|
resetUnreadMessages,
|
|
121
80
|
setCurrentAttachment,
|
|
122
81
|
setError,
|
|
82
|
+
setIsInputFocused,
|
|
123
83
|
setLastMessageVisible,
|
|
124
84
|
setOnline,
|
|
125
85
|
toggleCoverComponent,
|
|
@@ -137,15 +97,18 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
137
97
|
updateTheme,
|
|
138
98
|
updateTyping,
|
|
139
99
|
updateWebview,
|
|
100
|
+
removeWebview,
|
|
101
|
+
removeReplies,
|
|
140
102
|
webchatState,
|
|
141
|
-
|
|
103
|
+
webchatContainerRef,
|
|
142
104
|
chatAreaRef,
|
|
143
105
|
inputPanelRef,
|
|
144
106
|
headerRef,
|
|
107
|
+
repliesRef,
|
|
145
108
|
scrollableMessagesListRef,
|
|
146
|
-
|
|
147
109
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
148
|
-
} = props.webchatHooks || useWebchat()
|
|
110
|
+
} = props.webchatHooks || useWebchat(props.theme)
|
|
111
|
+
|
|
149
112
|
const firstUpdate = useRef(true)
|
|
150
113
|
const isOnline = () => webchatState.online
|
|
151
114
|
const currentDateString = () => new Date().toISOString()
|
|
@@ -166,7 +129,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
166
129
|
|
|
167
130
|
const { scrollToBottom } = useScrollToBottom({ host })
|
|
168
131
|
|
|
169
|
-
const saveWebchatState = webchatState => {
|
|
132
|
+
const saveWebchatState = (webchatState: WebchatState) => {
|
|
170
133
|
storage &&
|
|
171
134
|
saveState(
|
|
172
135
|
JSON.parse(
|
|
@@ -182,32 +145,34 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
182
145
|
)
|
|
183
146
|
}
|
|
184
147
|
|
|
185
|
-
const handleAttachment = event => {
|
|
148
|
+
const handleAttachment = (event: any) => {
|
|
186
149
|
if (!isAllowedSize(event.target.files[0].size)) {
|
|
187
150
|
throw new Error(
|
|
188
151
|
`The file is too large. A maximum of ${MAX_ALLOWED_SIZE_MB}MB is allowed.`
|
|
189
152
|
)
|
|
190
153
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
attachmentType: getMediaType(event.target.files[0].type),
|
|
195
|
-
})
|
|
154
|
+
|
|
155
|
+
// TODO: Attach more files?
|
|
156
|
+
setCurrentAttachment(event.target.files[0])
|
|
196
157
|
}
|
|
197
158
|
|
|
198
159
|
useEffect(() => {
|
|
199
|
-
if (webchatState.currentAttachment)
|
|
160
|
+
if (webchatState.currentAttachment) {
|
|
200
161
|
sendAttachment(webchatState.currentAttachment)
|
|
162
|
+
}
|
|
201
163
|
}, [webchatState.currentAttachment])
|
|
202
164
|
|
|
203
|
-
const sendUserInput = async input => {
|
|
165
|
+
const sendUserInput = async (input: any) => {
|
|
204
166
|
if (props.onUserInput) {
|
|
205
167
|
resetUnreadMessages()
|
|
206
|
-
scrollToBottom(
|
|
168
|
+
scrollToBottom()
|
|
207
169
|
props.onUserInput({
|
|
208
170
|
user: webchatState.session.user,
|
|
171
|
+
// TODO: Review if this input.sentBy exists in the frontend
|
|
209
172
|
input: input,
|
|
173
|
+
//@ts-ignore
|
|
210
174
|
session: webchatState.session,
|
|
175
|
+
// TODO: Review why we were passing lastRoutePath, is only for devMode?
|
|
211
176
|
lastRoutePath: webchatState.lastRoutePath,
|
|
212
177
|
})
|
|
213
178
|
}
|
|
@@ -259,9 +224,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
259
224
|
addMessage(message)
|
|
260
225
|
const newMessageComponent = msgToBotonic(
|
|
261
226
|
{ ...message, delay: 0, typing: 0 },
|
|
262
|
-
|
|
263
|
-
props.theme.customMessageTypes
|
|
227
|
+
props.theme?.message?.customTypes
|
|
264
228
|
)
|
|
229
|
+
//@ts-ignore
|
|
265
230
|
if (newMessageComponent) addMessageComponent(newMessageComponent)
|
|
266
231
|
})
|
|
267
232
|
}
|
|
@@ -270,10 +235,23 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
270
235
|
} else updateSession(merge(initialSession, session))
|
|
271
236
|
if (devSettings) updateDevSettings(devSettings)
|
|
272
237
|
else if (initialDevSettings) updateDevSettings(initialDevSettings)
|
|
273
|
-
|
|
274
|
-
if (
|
|
238
|
+
|
|
239
|
+
if (lastMessageUpdate) {
|
|
240
|
+
updateLastMessageDate(lastMessageUpdate)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (themeUpdates !== undefined) {
|
|
275
244
|
updateTheme(merge(props.theme, themeUpdates), themeUpdates)
|
|
276
|
-
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (props.onInit) {
|
|
248
|
+
setTimeout(() => {
|
|
249
|
+
if (typeof props.onInit === 'function') {
|
|
250
|
+
props.onInit()
|
|
251
|
+
session.user = updateUserLocaleAndCountry(session.user)
|
|
252
|
+
}
|
|
253
|
+
}, 100)
|
|
254
|
+
}
|
|
277
255
|
}, [])
|
|
278
256
|
|
|
279
257
|
useEffect(() => {
|
|
@@ -286,8 +264,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
286
264
|
}, [webchatState.isWebchatOpen])
|
|
287
265
|
|
|
288
266
|
useEffect(() => {
|
|
289
|
-
|
|
290
|
-
|
|
267
|
+
const { messagesJSON, session } = webchatState
|
|
268
|
+
if (onStateChange && typeof onStateChange === 'function' && session.user) {
|
|
269
|
+
onStateChange({ messagesJSON, user: session.user })
|
|
291
270
|
}
|
|
292
271
|
saveWebchatState(webchatState)
|
|
293
272
|
}, [
|
|
@@ -320,12 +299,12 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
320
299
|
updateWebview(webviewComponent, params)
|
|
321
300
|
}
|
|
322
301
|
|
|
323
|
-
const textareaRef = useRef(
|
|
302
|
+
const textareaRef = useRef<HTMLTextAreaElement | undefined>()
|
|
324
303
|
|
|
325
|
-
const closeWebview = async options => {
|
|
326
|
-
|
|
304
|
+
const closeWebview = async (options?: CloseWebviewOptions) => {
|
|
305
|
+
removeWebview()
|
|
327
306
|
if (userInputEnabled) {
|
|
328
|
-
textareaRef.current
|
|
307
|
+
textareaRef.current?.focus()
|
|
329
308
|
}
|
|
330
309
|
if (options?.payload) {
|
|
331
310
|
await sendPayload(options.payload)
|
|
@@ -336,13 +315,11 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
336
315
|
}
|
|
337
316
|
|
|
338
317
|
const persistentMenuOptions = getThemeProperty(
|
|
339
|
-
WEBCHAT.CUSTOM_PROPERTIES.persistentMenu
|
|
340
|
-
props.persistentMenu
|
|
318
|
+
WEBCHAT.CUSTOM_PROPERTIES.persistentMenu
|
|
341
319
|
)
|
|
342
320
|
|
|
343
321
|
const darkBackgroundMenu = getThemeProperty(
|
|
344
|
-
WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu
|
|
345
|
-
false
|
|
322
|
+
WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu
|
|
346
323
|
)
|
|
347
324
|
|
|
348
325
|
const getBlockInputs = (rule, inputData) => {
|
|
@@ -358,15 +335,15 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
358
335
|
|
|
359
336
|
const checkBlockInput = input => {
|
|
360
337
|
// if is a text we check if it is a serialized RE
|
|
361
|
-
const blockInputs =
|
|
362
|
-
WEBCHAT.CUSTOM_PROPERTIES.blockInputs,
|
|
363
|
-
props.blockInputs
|
|
364
|
-
)
|
|
338
|
+
const blockInputs = webchatState.theme.userInput?.blockInputs
|
|
365
339
|
if (!Array.isArray(blockInputs)) return false
|
|
366
340
|
for (const rule of blockInputs) {
|
|
367
341
|
if (getBlockInputs(rule, input.data)) {
|
|
368
342
|
addMessageComponent(
|
|
369
343
|
<Text
|
|
344
|
+
// Is necessary to add the id of the input
|
|
345
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
346
|
+
// @ts-ignore
|
|
370
347
|
id={input.id}
|
|
371
348
|
sentBy={SENDERS.user}
|
|
372
349
|
blob={false}
|
|
@@ -379,7 +356,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
379
356
|
{rule.message}
|
|
380
357
|
</Text>
|
|
381
358
|
)
|
|
382
|
-
|
|
359
|
+
removeReplies()
|
|
383
360
|
return true
|
|
384
361
|
}
|
|
385
362
|
}
|
|
@@ -400,55 +377,45 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
400
377
|
)
|
|
401
378
|
}
|
|
402
379
|
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
WEBCHAT.CUSTOM_PROPERTIES.coverComponent,
|
|
406
|
-
props.coverComponent &&
|
|
407
|
-
(props.coverComponent.component || props.coverComponent)
|
|
408
|
-
)
|
|
409
|
-
}
|
|
410
|
-
const CoverComponent = getCoverComponent()
|
|
411
|
-
|
|
412
|
-
const closeCoverComponent = () => {
|
|
413
|
-
toggleCoverComponent(false)
|
|
414
|
-
}
|
|
380
|
+
const coverComponent = webchatState.theme.coverComponent
|
|
381
|
+
const coverComponentProps = webchatState.theme.coverComponent?.props
|
|
415
382
|
|
|
416
383
|
useEffect(() => {
|
|
417
|
-
if (!
|
|
384
|
+
if (!coverComponent) return
|
|
418
385
|
if (
|
|
419
386
|
!botonicState ||
|
|
420
|
-
(botonicState.messages && botonicState.messages.length
|
|
387
|
+
(botonicState.messages && botonicState.messages.length === 0)
|
|
421
388
|
)
|
|
422
389
|
toggleCoverComponent(true)
|
|
423
390
|
}, [])
|
|
424
391
|
|
|
425
|
-
const coverComponent = () => {
|
|
426
|
-
const coverComponentProps = getThemeProperty(
|
|
427
|
-
WEBCHAT.CUSTOM_PROPERTIES.coverComponentProps,
|
|
428
|
-
props.coverComponent && props.coverComponent.props
|
|
429
|
-
)
|
|
430
|
-
|
|
431
|
-
if (CoverComponent && webchatState.isCoverComponentOpen)
|
|
432
|
-
return (
|
|
433
|
-
<CoverComponent
|
|
434
|
-
closeComponent={closeCoverComponent}
|
|
435
|
-
{...coverComponentProps}
|
|
436
|
-
/>
|
|
437
|
-
)
|
|
438
|
-
return null
|
|
439
|
-
}
|
|
440
|
-
|
|
441
392
|
const messageComponentFromInput = input => {
|
|
442
|
-
let messageComponent = null
|
|
393
|
+
let messageComponent: any = null
|
|
443
394
|
if (isText(input)) {
|
|
444
395
|
messageComponent = (
|
|
445
|
-
<Text
|
|
396
|
+
<Text
|
|
397
|
+
// Is necessary to add the id of the input
|
|
398
|
+
// to keep the input.id generated in the frontend as id of the message
|
|
399
|
+
// @ts-ignore
|
|
400
|
+
id={input.id}
|
|
401
|
+
// Is necessary to add the payload of the input when user clicks a button
|
|
402
|
+
// @ts-ignore
|
|
403
|
+
payload={input.payload}
|
|
404
|
+
sentBy={SENDERS.user}
|
|
405
|
+
>
|
|
446
406
|
{input.data}
|
|
447
407
|
</Text>
|
|
448
408
|
)
|
|
449
409
|
} else if (isMedia(input)) {
|
|
450
410
|
const temporaryDisplayUrl = URL.createObjectURL(input.data)
|
|
451
|
-
|
|
411
|
+
// TODO: We should use URL.revokeObjectURL(temporaryDisplayUrl) when the component is unmounted
|
|
412
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL_static#memory_management
|
|
413
|
+
const mediaProps: {
|
|
414
|
+
id: string
|
|
415
|
+
sentBy: SENDERS
|
|
416
|
+
src: string
|
|
417
|
+
input?: any
|
|
418
|
+
} = {
|
|
452
419
|
id: input.id,
|
|
453
420
|
sentBy: SENDERS.user,
|
|
454
421
|
src: temporaryDisplayUrl,
|
|
@@ -464,7 +431,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
464
431
|
return messageComponent
|
|
465
432
|
}
|
|
466
433
|
|
|
467
|
-
const sendInput = async input => {
|
|
434
|
+
const sendInput = async (input: any) => {
|
|
468
435
|
if (!input || Object.keys(input).length == 0) return
|
|
469
436
|
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)
|
|
470
437
|
if (isText(input) && checkBlockInput(input)) return
|
|
@@ -475,7 +442,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
475
442
|
sendUserInput(input)
|
|
476
443
|
updateLatestInput(input)
|
|
477
444
|
isOnline() && updateLastMessageDate(currentDateString())
|
|
478
|
-
|
|
445
|
+
removeReplies()
|
|
479
446
|
togglePersistentMenu(false)
|
|
480
447
|
toggleEmojiPicker(false)
|
|
481
448
|
}
|
|
@@ -484,8 +451,10 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
484
451
|
https://stackoverflow.com/questions/37949981/call-child-method-from-parent
|
|
485
452
|
*/
|
|
486
453
|
|
|
487
|
-
const updateSessionWithUser = userToUpdate =>
|
|
454
|
+
const updateSessionWithUser = (userToUpdate: any) => {
|
|
455
|
+
console.log('userToUpdate', userToUpdate)
|
|
488
456
|
updateSession(merge(webchatState.session, { user: userToUpdate }))
|
|
457
|
+
}
|
|
489
458
|
|
|
490
459
|
useImperativeHandle(ref, () => ({
|
|
491
460
|
addBotResponse: ({ response, session, lastRoutePath }) => {
|
|
@@ -517,7 +486,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
517
486
|
|
|
518
487
|
updateLastMessageDate(currentDateString())
|
|
519
488
|
},
|
|
520
|
-
setTyping: typing => updateTyping(typing),
|
|
489
|
+
setTyping: (typing: boolean) => updateTyping(typing),
|
|
521
490
|
addUserMessage: message => sendInput(message),
|
|
522
491
|
updateUser: updateSessionWithUser,
|
|
523
492
|
openWebchat: () => toggleWebchat(true),
|
|
@@ -532,85 +501,76 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
532
501
|
unmountCustomComponent: () => doRenderCustomComponent(false),
|
|
533
502
|
toggleCoverComponent: () =>
|
|
534
503
|
toggleCoverComponent(!webchatState.isCoverComponentOpen),
|
|
535
|
-
openWebviewApi: component => openWebviewT(component),
|
|
536
|
-
setError,
|
|
537
504
|
setOnline,
|
|
538
505
|
getMessages: () => webchatState.messagesJSON,
|
|
539
506
|
isOnline,
|
|
540
507
|
clearMessages: () => {
|
|
541
508
|
clearMessages()
|
|
542
|
-
|
|
509
|
+
removeReplies()
|
|
543
510
|
},
|
|
544
511
|
getLastMessageUpdate: () => webchatState.lastMessageUpdate,
|
|
545
|
-
updateMessageInfo: (msgId, messageInfo) => {
|
|
512
|
+
updateMessageInfo: (msgId: string, messageInfo: any) => {
|
|
546
513
|
const messageToUpdate = webchatState.messagesJSON.filter(
|
|
547
|
-
m => m.id
|
|
514
|
+
m => m.id === msgId
|
|
548
515
|
)[0]
|
|
549
516
|
const updatedMsg = merge(messageToUpdate, messageInfo)
|
|
550
517
|
if (updatedMsg.ack === 1) delete updatedMsg.unsentInput
|
|
551
518
|
updateMessage(updatedMsg)
|
|
552
519
|
},
|
|
553
|
-
updateWebchatSettings: settings => {
|
|
520
|
+
updateWebchatSettings: (settings: WebchatSettingsProps) => {
|
|
554
521
|
if (settings.user) {
|
|
555
522
|
updateSessionWithUser(settings.user)
|
|
556
523
|
}
|
|
557
524
|
const themeUpdates = normalizeWebchatSettings(settings)
|
|
558
|
-
updateTheme(
|
|
525
|
+
updateTheme(
|
|
526
|
+
merge(webchatState.theme, themeUpdates),
|
|
527
|
+
themeUpdates as WebchatTheme
|
|
528
|
+
)
|
|
559
529
|
updateTyping(false)
|
|
560
530
|
},
|
|
561
|
-
closeWebview:
|
|
531
|
+
closeWebview: async (options?: CloseWebviewOptions) =>
|
|
532
|
+
closeWebview(options),
|
|
562
533
|
}))
|
|
563
534
|
|
|
564
535
|
const resolveCase = () => {
|
|
565
536
|
updateHandoff(false)
|
|
566
|
-
updateSession({ ...webchatState.session, _botonic_action:
|
|
537
|
+
updateSession({ ...webchatState.session, _botonic_action: undefined })
|
|
567
538
|
}
|
|
568
539
|
|
|
569
540
|
const prevSession = usePrevious(webchatState.session)
|
|
570
541
|
useEffect(() => {
|
|
571
542
|
// Resume conversation after handoff
|
|
572
|
-
if (
|
|
573
|
-
prevSession &&
|
|
574
|
-
prevSession._botonic_action &&
|
|
575
|
-
!webchatState.session._botonic_action
|
|
576
|
-
) {
|
|
543
|
+
if (prevSession?._botonic_action && !webchatState.session._botonic_action) {
|
|
577
544
|
const action = getParsedAction(prevSession._botonic_action)
|
|
578
|
-
if (action
|
|
545
|
+
if (action?.on_finish) sendPayload(action.on_finish)
|
|
579
546
|
}
|
|
580
547
|
}, [webchatState.session._botonic_action])
|
|
581
548
|
|
|
582
|
-
const sendText = async (text, payload) => {
|
|
549
|
+
const sendText = async (text: string, payload?: string) => {
|
|
583
550
|
if (!text) return
|
|
584
551
|
const input = { type: INPUT.TEXT, data: text, payload }
|
|
585
552
|
await sendInput(input)
|
|
586
553
|
}
|
|
587
554
|
|
|
588
|
-
const sendPayload = async payload => {
|
|
555
|
+
const sendPayload = async (payload: string) => {
|
|
589
556
|
if (!payload) return
|
|
590
557
|
const input = { type: INPUT.POSTBACK, payload }
|
|
591
558
|
await sendInput(input)
|
|
592
559
|
}
|
|
593
560
|
|
|
594
|
-
const sendAttachment = async attachment => {
|
|
595
|
-
if (attachment
|
|
596
|
-
const attachmentType = getMediaType(attachment.
|
|
561
|
+
const sendAttachment = async (attachment: File) => {
|
|
562
|
+
if (attachment) {
|
|
563
|
+
const attachmentType = getMediaType(attachment.type)
|
|
597
564
|
if (!attachmentType) return
|
|
598
565
|
const input = {
|
|
599
566
|
type: attachmentType,
|
|
600
|
-
data: attachment
|
|
567
|
+
data: attachment,
|
|
601
568
|
}
|
|
602
569
|
await sendInput(input)
|
|
603
|
-
setCurrentAttachment(
|
|
570
|
+
setCurrentAttachment()
|
|
604
571
|
}
|
|
605
572
|
}
|
|
606
573
|
|
|
607
|
-
const webviewRequestContext = {
|
|
608
|
-
closeWebview: closeWebview,
|
|
609
|
-
getString: stringId => props.getString(stringId, webchatState.session),
|
|
610
|
-
params: webchatState.webviewParams || {},
|
|
611
|
-
session: webchatState.session || {},
|
|
612
|
-
}
|
|
613
|
-
|
|
614
574
|
useEffect(() => {
|
|
615
575
|
if (firstUpdate.current) {
|
|
616
576
|
firstUpdate.current = false
|
|
@@ -628,36 +588,13 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
628
588
|
|
|
629
589
|
const isUserInputEnabled = () => {
|
|
630
590
|
const isUserInputEnabled = getThemeProperty(
|
|
631
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableUserInput
|
|
632
|
-
props.enableUserInput !== undefined ? props.enableUserInput : true
|
|
591
|
+
WEBCHAT.CUSTOM_PROPERTIES.enableUserInput
|
|
633
592
|
)
|
|
634
593
|
return isUserInputEnabled && !webchatState.isCoverComponentOpen
|
|
635
594
|
}
|
|
636
595
|
|
|
637
596
|
const userInputEnabled = isUserInputEnabled()
|
|
638
597
|
|
|
639
|
-
const webchatWebview = () => (
|
|
640
|
-
<WebviewRequestContext.Provider value={webviewRequestContext}>
|
|
641
|
-
<WebviewContainer
|
|
642
|
-
style={{
|
|
643
|
-
...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewStyle),
|
|
644
|
-
...mobileStyle,
|
|
645
|
-
}}
|
|
646
|
-
webview={webchatState.webview}
|
|
647
|
-
/>
|
|
648
|
-
</WebviewRequestContext.Provider>
|
|
649
|
-
)
|
|
650
|
-
let mobileStyle = {}
|
|
651
|
-
if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
|
|
652
|
-
mobileStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
|
|
653
|
-
width: '100%',
|
|
654
|
-
height: '100%',
|
|
655
|
-
right: 0,
|
|
656
|
-
bottom: 0,
|
|
657
|
-
borderRadius: 0,
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
|
|
661
598
|
useEffect(() => {
|
|
662
599
|
// Prod mode
|
|
663
600
|
saveWebchatState(webchatState)
|
|
@@ -668,7 +605,10 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
668
605
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
669
606
|
useEffect(() => {
|
|
670
607
|
const themeUpdates = normalizeWebchatSettings(settings)
|
|
671
|
-
updateTheme(
|
|
608
|
+
updateTheme(
|
|
609
|
+
merge(webchatState.theme, themeUpdates),
|
|
610
|
+
themeUpdates as WebchatTheme
|
|
611
|
+
)
|
|
672
612
|
}, [webchatState.messagesJSON])
|
|
673
613
|
}
|
|
674
614
|
|
|
@@ -697,9 +637,11 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
697
637
|
value={{
|
|
698
638
|
addMessage,
|
|
699
639
|
getThemeProperty,
|
|
640
|
+
closeWebview,
|
|
700
641
|
openWebview,
|
|
701
642
|
resolveCase,
|
|
702
643
|
resetUnreadMessages,
|
|
644
|
+
setIsInputFocused,
|
|
703
645
|
setLastMessageVisible,
|
|
704
646
|
sendAttachment,
|
|
705
647
|
sendInput,
|
|
@@ -708,75 +650,81 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
708
650
|
toggleWebchat,
|
|
709
651
|
toggleEmojiPicker,
|
|
710
652
|
togglePersistentMenu,
|
|
653
|
+
toggleCoverComponent,
|
|
711
654
|
updateLatestInput,
|
|
712
655
|
updateMessage,
|
|
713
656
|
updateReplies,
|
|
714
657
|
updateUser: updateSessionWithUser,
|
|
715
658
|
updateWebchatDevSettings: updateWebchatDevSettings,
|
|
716
|
-
webchatState,
|
|
717
659
|
trackEvent: props.onTrackEvent,
|
|
718
|
-
|
|
660
|
+
webchatState,
|
|
661
|
+
webchatContainerRef,
|
|
719
662
|
chatAreaRef,
|
|
720
663
|
inputPanelRef,
|
|
721
664
|
headerRef,
|
|
665
|
+
repliesRef,
|
|
722
666
|
scrollableMessagesListRef,
|
|
723
667
|
}}
|
|
724
668
|
>
|
|
725
|
-
{
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
669
|
+
<ThemeProvider theme={webchatState.theme}>
|
|
670
|
+
{!webchatState.isWebchatOpen && <TriggerButton />}
|
|
671
|
+
|
|
672
|
+
{webchatState.isWebchatOpen && (
|
|
673
|
+
<StyledWebchat
|
|
674
|
+
id={BotonicContainerId.Webchat}
|
|
675
|
+
ref={webchatContainerRef}
|
|
676
|
+
// TODO: Distinguish between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
|
|
677
|
+
role={ROLES.WEBCHAT}
|
|
678
|
+
>
|
|
679
|
+
<WebchatHeader ref={headerRef} />
|
|
680
|
+
|
|
681
|
+
{webchatState.isCoverComponentOpen ? (
|
|
682
|
+
<CoverComponent
|
|
683
|
+
component={coverComponent}
|
|
684
|
+
componentProps={coverComponentProps}
|
|
685
|
+
/>
|
|
686
|
+
) : (
|
|
687
|
+
<>
|
|
688
|
+
{webchatState.error.message && (
|
|
689
|
+
<ErrorMessageContainer>
|
|
690
|
+
<ErrorMessage>{webchatState.error.message}</ErrorMessage>
|
|
691
|
+
</ErrorMessageContainer>
|
|
692
|
+
)}
|
|
693
|
+
|
|
694
|
+
<ChatArea />
|
|
695
|
+
|
|
696
|
+
{webchatState.isPersistentMenuOpen && (
|
|
697
|
+
<DarkenBackground component={persistentMenu()} />
|
|
698
|
+
)}
|
|
699
|
+
|
|
700
|
+
{!webchatState.handoff && userInputEnabled && (
|
|
701
|
+
<InputPanel
|
|
702
|
+
handleAttachment={handleAttachment}
|
|
703
|
+
textareaRef={textareaRef}
|
|
704
|
+
host={host}
|
|
705
|
+
onUserInput={props.onUserInput}
|
|
706
|
+
/>
|
|
707
|
+
)}
|
|
708
|
+
|
|
709
|
+
{webchatState.webview && <WebviewContainer />}
|
|
710
|
+
|
|
711
|
+
{webchatState.isCustomComponentRendered &&
|
|
712
|
+
customComponent &&
|
|
713
|
+
_renderCustomComponent()}
|
|
714
|
+
</>
|
|
715
|
+
)}
|
|
716
|
+
</StyledWebchat>
|
|
717
|
+
)}
|
|
718
|
+
</ThemeProvider>
|
|
775
719
|
</WebchatContext.Provider>
|
|
776
720
|
)
|
|
721
|
+
|
|
777
722
|
return props.shadowDOM ? (
|
|
778
723
|
<StyleSheetManager target={host}>{WebchatComponent}</StyleSheetManager>
|
|
779
724
|
) : (
|
|
780
725
|
WebchatComponent
|
|
781
726
|
)
|
|
782
727
|
})
|
|
728
|
+
|
|
729
|
+
Webchat.displayName = 'Webchat'
|
|
730
|
+
export { Webchat }
|