@botonic/react 0.31.5-alpha.1 → 0.32.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
package/src/webchat/webview.jsx
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect } from 'react'
|
|
2
|
-
import styled from 'styled-components'
|
|
3
|
-
|
|
4
|
-
import { COLORS, ROLES, WEBCHAT } from '../constants'
|
|
5
|
-
import { WebchatContext, WebviewRequestContext } from '../contexts'
|
|
6
|
-
|
|
7
|
-
const StyledWebview = styled.div`
|
|
8
|
-
position: absolute;
|
|
9
|
-
display: flex;
|
|
10
|
-
flex-direction: column;
|
|
11
|
-
bottom: 0;
|
|
12
|
-
width: 100%;
|
|
13
|
-
height: 100%;
|
|
14
|
-
background-color: ${COLORS.SOLID_WHITE};
|
|
15
|
-
z-index: 2;
|
|
16
|
-
border-radius: ${WEBCHAT.DEFAULTS.BORDER_RADIUS_TOP_CORNERS};
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
const StyledWebviewHeader = styled.div`
|
|
20
|
-
text-align: right;
|
|
21
|
-
background-color: ${COLORS.WILD_SAND_WHITE};
|
|
22
|
-
border-top: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_2};
|
|
23
|
-
border-bottom: 1px solid ${COLORS.SOLID_BLACK_ALPHA_0_2};
|
|
24
|
-
border-radius: ${WEBCHAT.DEFAULTS.BORDER_RADIUS_TOP_CORNERS};
|
|
25
|
-
`
|
|
26
|
-
const StyledCloseHeader = styled.div`
|
|
27
|
-
display: inline-block;
|
|
28
|
-
padding: 8px 12px;
|
|
29
|
-
cursor: pointer;
|
|
30
|
-
`
|
|
31
|
-
|
|
32
|
-
const StyledWebviewContent = styled.div`
|
|
33
|
-
flex: 1;
|
|
34
|
-
overflow: auto;
|
|
35
|
-
`
|
|
36
|
-
|
|
37
|
-
const FrameStyles = `
|
|
38
|
-
border-style: none;
|
|
39
|
-
width: 100%;
|
|
40
|
-
height: 100%;
|
|
41
|
-
`
|
|
42
|
-
|
|
43
|
-
const StyledFrame = styled.iframe`
|
|
44
|
-
${FrameStyles}
|
|
45
|
-
`
|
|
46
|
-
|
|
47
|
-
const StyledFrameAsDiv = styled.div`
|
|
48
|
-
${FrameStyles}
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
export const WebviewHeader = () => {
|
|
52
|
-
const { closeWebview } = useContext(WebviewRequestContext)
|
|
53
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
54
|
-
return (
|
|
55
|
-
<StyledWebviewHeader
|
|
56
|
-
role={ROLES.WEBVIEW_HEADER}
|
|
57
|
-
style={{
|
|
58
|
-
...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewHeaderStyle),
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
<StyledCloseHeader onClick={closeWebview}>✕</StyledCloseHeader>
|
|
62
|
-
</StyledWebviewHeader>
|
|
63
|
-
)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const WebviewContainer = props => {
|
|
67
|
-
const { webchatState } = useContext(WebchatContext)
|
|
68
|
-
const { closeWebview } = useContext(WebviewRequestContext)
|
|
69
|
-
const Webview = webchatState.webview
|
|
70
|
-
|
|
71
|
-
const close = async e => {
|
|
72
|
-
if (e.data === 'botonicCloseWebview') {
|
|
73
|
-
await closeWebview()
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (window.addEventListener) {
|
|
79
|
-
window.addEventListener('message', close, false)
|
|
80
|
-
} else if (window.attachEvent) {
|
|
81
|
-
// ie8
|
|
82
|
-
window.attachEvent('onmessage', close)
|
|
83
|
-
}
|
|
84
|
-
}, [])
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<StyledWebview
|
|
88
|
-
role={ROLES.WEBVIEW}
|
|
89
|
-
style={{
|
|
90
|
-
...props.style,
|
|
91
|
-
}}
|
|
92
|
-
>
|
|
93
|
-
<WebviewHeader style={{ flex: 'none' }} />
|
|
94
|
-
<StyledWebviewContent>
|
|
95
|
-
{typeof Webview === 'string' ? (
|
|
96
|
-
<StyledFrame src={Webview} />
|
|
97
|
-
) : (
|
|
98
|
-
<StyledFrameAsDiv>
|
|
99
|
-
<Webview />
|
|
100
|
-
</StyledFrameAsDiv>
|
|
101
|
-
)}
|
|
102
|
-
</StyledWebviewContent>
|
|
103
|
-
</StyledWebview>
|
|
104
|
-
)
|
|
105
|
-
}
|
package/src/webchat-app.jsx
DELETED
|
@@ -1,389 +0,0 @@
|
|
|
1
|
-
import { HubtypeService, INPUT } from '@botonic/core'
|
|
2
|
-
import merge from 'lodash.merge'
|
|
3
|
-
import React, { createRef } from 'react'
|
|
4
|
-
import { render, unmountComponentAtNode } from 'react-dom'
|
|
5
|
-
|
|
6
|
-
import { WEBCHAT } from './constants'
|
|
7
|
-
import { SENDERS, Typing } from './index-types'
|
|
8
|
-
import { msgToBotonic } from './msg-to-botonic'
|
|
9
|
-
import { isShadowDOMSupported, onDOMLoaded } from './util/dom'
|
|
10
|
-
import { Webchat } from './webchat/webchat'
|
|
11
|
-
|
|
12
|
-
export class WebchatApp {
|
|
13
|
-
constructor({
|
|
14
|
-
theme = {},
|
|
15
|
-
persistentMenu,
|
|
16
|
-
coverComponent,
|
|
17
|
-
blockInputs,
|
|
18
|
-
enableEmojiPicker,
|
|
19
|
-
enableAttachments,
|
|
20
|
-
enableUserInput,
|
|
21
|
-
enableAnimations,
|
|
22
|
-
hostId,
|
|
23
|
-
shadowDOM,
|
|
24
|
-
defaultDelay,
|
|
25
|
-
defaultTyping,
|
|
26
|
-
storage,
|
|
27
|
-
storageKey,
|
|
28
|
-
onInit,
|
|
29
|
-
onOpen,
|
|
30
|
-
onClose,
|
|
31
|
-
onMessage,
|
|
32
|
-
onTrackEvent,
|
|
33
|
-
onConnectionChange,
|
|
34
|
-
appId,
|
|
35
|
-
visibility,
|
|
36
|
-
server,
|
|
37
|
-
}) {
|
|
38
|
-
this.theme = theme
|
|
39
|
-
this.persistentMenu = persistentMenu
|
|
40
|
-
this.coverComponent = coverComponent
|
|
41
|
-
this.blockInputs = blockInputs
|
|
42
|
-
this.enableEmojiPicker = enableEmojiPicker
|
|
43
|
-
this.enableAttachments = enableAttachments
|
|
44
|
-
this.enableUserInput = enableUserInput
|
|
45
|
-
this.enableAnimations = enableAnimations
|
|
46
|
-
this.shadowDOM = Boolean(
|
|
47
|
-
typeof shadowDOM === 'function' ? shadowDOM() : shadowDOM
|
|
48
|
-
)
|
|
49
|
-
if (this.shadowDOM && !isShadowDOMSupported()) {
|
|
50
|
-
console.warn('[botonic] ShadowDOM not supported on this browser')
|
|
51
|
-
this.shadowDOM = false
|
|
52
|
-
}
|
|
53
|
-
this.hostId = hostId || WEBCHAT.DEFAULTS.HOST_ID
|
|
54
|
-
this.defaultDelay = defaultDelay
|
|
55
|
-
this.defaultTyping = defaultTyping
|
|
56
|
-
this.storage = storage === undefined ? localStorage : storage
|
|
57
|
-
this.storageKey = storageKey || WEBCHAT.DEFAULTS.STORAGE_KEY
|
|
58
|
-
this.onInit = onInit
|
|
59
|
-
this.onOpen = onOpen
|
|
60
|
-
this.onClose = onClose
|
|
61
|
-
this.onMessage = onMessage
|
|
62
|
-
this.onTrackEvent = onTrackEvent
|
|
63
|
-
this.onConnectionChange = onConnectionChange
|
|
64
|
-
this.visibility = visibility
|
|
65
|
-
this.server = server
|
|
66
|
-
this.webchatRef = createRef()
|
|
67
|
-
this.appId = appId
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
createRootElement(host) {
|
|
71
|
-
// Create root element <div id='root'> if not exists
|
|
72
|
-
// Create shadowDOM to root element if needed
|
|
73
|
-
if (host) {
|
|
74
|
-
if (host.id && this.hostId) {
|
|
75
|
-
if (host.id != this.hostId) {
|
|
76
|
-
console.warn(
|
|
77
|
-
`[botonic] Host ID "${host.id}" don't match 'hostId' option: ${this.hostId}. Using value: ${host.id}.`
|
|
78
|
-
)
|
|
79
|
-
this.hostId = host.id
|
|
80
|
-
}
|
|
81
|
-
} else if (host.id) this.hostId = host.id
|
|
82
|
-
else if (this.hostId) host.id = this.hostId
|
|
83
|
-
} else {
|
|
84
|
-
host = document.getElementById(this.hostId)
|
|
85
|
-
}
|
|
86
|
-
if (!host) {
|
|
87
|
-
host = document.createElement('div')
|
|
88
|
-
host.id = this.hostId
|
|
89
|
-
if (document.body.firstChild)
|
|
90
|
-
document.body.insertBefore(host, document.body.firstChild)
|
|
91
|
-
else document.body.appendChild(host)
|
|
92
|
-
}
|
|
93
|
-
this.host = this.shadowDOM ? host.attachShadow({ mode: 'open' }) : host
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
getReactMountNode(node) {
|
|
97
|
-
if (!node) node = this.host
|
|
98
|
-
return node.shadowRoot ? node.shadowRoot : node
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
onInitWebchat(...args) {
|
|
102
|
-
this.onInit && this.onInit(this, ...args)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
onOpenWebchat(...args) {
|
|
106
|
-
this.onOpen && this.onOpen(this, ...args)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
onCloseWebchat(...args) {
|
|
110
|
-
this.onClose && this.onClose(this, ...args)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async onUserInput({ user, input }) {
|
|
114
|
-
this.onMessage &&
|
|
115
|
-
this.onMessage(this, {
|
|
116
|
-
sentBy: SENDERS.user,
|
|
117
|
-
message: input,
|
|
118
|
-
isUnread: false,
|
|
119
|
-
})
|
|
120
|
-
return this.hubtypeService.postMessage(user, input)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
async onConnectionRegained() {
|
|
124
|
-
return this.hubtypeService.onConnectionRegained()
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
onStateChange({ session: { user }, messagesJSON }) {
|
|
128
|
-
const lastMessage = messagesJSON[messagesJSON.length - 1]
|
|
129
|
-
const lastMessageId = lastMessage && lastMessage.id
|
|
130
|
-
const lastMessageUpdateDate = this.getLastMessageUpdate()
|
|
131
|
-
if (this.hubtypeService) {
|
|
132
|
-
this.hubtypeService.lastMessageId = lastMessageId
|
|
133
|
-
this.hubtypeService.lastMessageUpdateDate = lastMessageUpdateDate
|
|
134
|
-
} else if (!this.hubtypeService && user) {
|
|
135
|
-
this.hubtypeService = new HubtypeService({
|
|
136
|
-
appId: this.appId,
|
|
137
|
-
user,
|
|
138
|
-
lastMessageId,
|
|
139
|
-
lastMessageUpdateDate,
|
|
140
|
-
onEvent: event => this.onServiceEvent(event),
|
|
141
|
-
unsentInputs: () =>
|
|
142
|
-
this.webchatRef.current
|
|
143
|
-
.getMessages()
|
|
144
|
-
.filter(msg => msg.ack === 0 && msg.unsentInput),
|
|
145
|
-
server: this.server,
|
|
146
|
-
})
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
onServiceEvent(event) {
|
|
151
|
-
if (event.action === 'connectionChange') {
|
|
152
|
-
this.onConnectionChange && this.onConnectionChange(this, event.online)
|
|
153
|
-
this.webchatRef.current.setOnline(event.online)
|
|
154
|
-
} else if (event.action === 'update_message_info') {
|
|
155
|
-
this.updateMessageInfo(event.message.id, event.message)
|
|
156
|
-
} else if (event.message?.type === 'update_webchat_settings') {
|
|
157
|
-
this.updateWebchatSettings(event.message.data)
|
|
158
|
-
} else if (event.message?.type === 'sender_action') {
|
|
159
|
-
this.setTyping(event.message.data === Typing.On)
|
|
160
|
-
} else {
|
|
161
|
-
this.onMessage &&
|
|
162
|
-
this.onMessage(this, { sentBy: SENDERS.bot, message: event.message })
|
|
163
|
-
this.addBotMessage(event.message)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
updateUser(user) {
|
|
168
|
-
this.webchatRef.current.updateUser(user)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
addBotMessage(message) {
|
|
172
|
-
message.ack = 0
|
|
173
|
-
message.isUnread = true
|
|
174
|
-
message.sentBy = message.sent_by?.split('message_sent_by_')[1]
|
|
175
|
-
delete message.sent_by
|
|
176
|
-
const response = msgToBotonic(
|
|
177
|
-
message,
|
|
178
|
-
this.theme.message?.customTypes || this.theme.customMessageTypes
|
|
179
|
-
)
|
|
180
|
-
|
|
181
|
-
this.webchatRef.current.addBotResponse({
|
|
182
|
-
response,
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
addBotText(text) {
|
|
187
|
-
this.addBotMessage({ type: INPUT.TEXT, data: text })
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
addUserMessage(message) {
|
|
191
|
-
this.webchatRef.current.addUserMessage(message)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
addUserText(text) {
|
|
195
|
-
this.addUserMessage({ type: INPUT.TEXT, data: text })
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
addUserPayload(payload) {
|
|
199
|
-
this.addUserMessage({ type: INPUT.POSTBACK, payload })
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
setTyping(typing) {
|
|
203
|
-
this.webchatRef.current.setTyping(typing)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
open() {
|
|
207
|
-
this.webchatRef.current.openWebchat()
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
close() {
|
|
211
|
-
this.webchatRef.current.closeWebchat()
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async closeWebview() {
|
|
215
|
-
await this.webchatRef.current.closeWebview()
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
toggle() {
|
|
219
|
-
this.webchatRef.current.toggleWebchat()
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
openCoverComponent() {
|
|
223
|
-
this.webchatRef.current.openCoverComponent()
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
closeCoverComponent() {
|
|
227
|
-
this.webchatRef.current.closeCoverComponent()
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
renderCustomComponent(_customComponent) {
|
|
231
|
-
this.webchatRef.current.renderCustomComponent(_customComponent)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
unmountCustomComponent() {
|
|
235
|
-
this.webchatRef.current.unmountCustomComponent()
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
toggleCoverComponent() {
|
|
239
|
-
this.webchatRef.current.toggleCoverComponent()
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
getMessages() {
|
|
243
|
-
return this.webchatRef.current.getMessages()
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
clearMessages() {
|
|
247
|
-
this.webchatRef.current.clearMessages()
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
async getVisibility() {
|
|
251
|
-
return this.resolveWebchatVisibility({
|
|
252
|
-
appId: this.appId,
|
|
253
|
-
visibility: this.visibility,
|
|
254
|
-
})
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
getLastMessageUpdate() {
|
|
258
|
-
return this.webchatRef.current.getLastMessageUpdate()
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
updateMessageInfo(msgId, messageInfo) {
|
|
262
|
-
return this.webchatRef.current.updateMessageInfo(msgId, messageInfo)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
updateWebchatSettings(settings) {
|
|
266
|
-
return this.webchatRef.current.updateWebchatSettings(settings)
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
// eslint-disable-next-line complexity
|
|
270
|
-
getComponent(host, optionsAtRuntime = {}) {
|
|
271
|
-
let {
|
|
272
|
-
theme = {},
|
|
273
|
-
persistentMenu,
|
|
274
|
-
coverComponent,
|
|
275
|
-
blockInputs,
|
|
276
|
-
enableAttachments,
|
|
277
|
-
enableUserInput,
|
|
278
|
-
enableAnimations,
|
|
279
|
-
enableEmojiPicker,
|
|
280
|
-
defaultDelay,
|
|
281
|
-
defaultTyping,
|
|
282
|
-
storage,
|
|
283
|
-
storageKey,
|
|
284
|
-
onInit,
|
|
285
|
-
onOpen,
|
|
286
|
-
onClose,
|
|
287
|
-
onMessage,
|
|
288
|
-
onConnectionChange,
|
|
289
|
-
onTrackEvent,
|
|
290
|
-
appId,
|
|
291
|
-
visibility,
|
|
292
|
-
server,
|
|
293
|
-
hostId,
|
|
294
|
-
...webchatOptions
|
|
295
|
-
} = optionsAtRuntime
|
|
296
|
-
theme = merge(this.theme, theme)
|
|
297
|
-
persistentMenu = persistentMenu || this.persistentMenu
|
|
298
|
-
coverComponent = coverComponent || this.coverComponent
|
|
299
|
-
blockInputs = blockInputs || this.blockInputs
|
|
300
|
-
enableEmojiPicker = enableEmojiPicker || this.enableEmojiPicker
|
|
301
|
-
enableAttachments = enableAttachments || this.enableAttachments
|
|
302
|
-
enableUserInput = enableUserInput || this.enableUserInput
|
|
303
|
-
enableAnimations = enableAnimations || this.enableAnimations
|
|
304
|
-
defaultDelay = defaultDelay || this.defaultDelay
|
|
305
|
-
defaultTyping = defaultTyping || this.defaultTyping
|
|
306
|
-
server = server || this.server
|
|
307
|
-
this.storage = storage || this.storage
|
|
308
|
-
this.storageKey = storageKey || this.storageKey
|
|
309
|
-
this.onInit = onInit || this.onInit
|
|
310
|
-
this.onOpen = onOpen || this.onOpen
|
|
311
|
-
this.onClose = onClose || this.onClose
|
|
312
|
-
this.onMessage = onMessage || this.onMessage
|
|
313
|
-
this.onTrackEvent = onTrackEvent || this.onTrackEvent
|
|
314
|
-
this.onConnectionChange = onConnectionChange || this.onConnectionChange
|
|
315
|
-
this.visibility = visibility || this.visibility
|
|
316
|
-
this.appId = appId || this.appId
|
|
317
|
-
this.hostId = hostId || this.hostId
|
|
318
|
-
this.createRootElement(host)
|
|
319
|
-
return (
|
|
320
|
-
<Webchat
|
|
321
|
-
{...webchatOptions}
|
|
322
|
-
ref={this.webchatRef}
|
|
323
|
-
host={this.host}
|
|
324
|
-
shadowDOM={this.shadowDOM}
|
|
325
|
-
theme={theme}
|
|
326
|
-
persistentMenu={persistentMenu}
|
|
327
|
-
coverComponent={coverComponent}
|
|
328
|
-
blockInputs={blockInputs}
|
|
329
|
-
enableEmojiPicker={enableEmojiPicker}
|
|
330
|
-
enableAttachments={enableAttachments}
|
|
331
|
-
enableUserInput={enableUserInput}
|
|
332
|
-
enableAnimations={enableAnimations}
|
|
333
|
-
storage={this.storage}
|
|
334
|
-
storageKey={this.storageKey}
|
|
335
|
-
defaultDelay={defaultDelay}
|
|
336
|
-
defaultTyping={defaultTyping}
|
|
337
|
-
onInit={(...args) => this.onInitWebchat(...args)}
|
|
338
|
-
onOpen={(...args) => this.onOpenWebchat(...args)}
|
|
339
|
-
onClose={(...args) => this.onCloseWebchat(...args)}
|
|
340
|
-
onUserInput={(...args) => this.onUserInput(...args)}
|
|
341
|
-
onStateChange={webchatState => this.onStateChange(webchatState)}
|
|
342
|
-
onTrackEvent={(...args) => this.onTrackEvent(...args)}
|
|
343
|
-
server={server}
|
|
344
|
-
/>
|
|
345
|
-
)
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
async isWebchatVisible({ appId }) {
|
|
349
|
-
try {
|
|
350
|
-
const { status } = await HubtypeService.getWebchatVisibility({
|
|
351
|
-
appId,
|
|
352
|
-
})
|
|
353
|
-
return status === 200
|
|
354
|
-
} catch (e) {
|
|
355
|
-
return false
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
isOnline() {
|
|
360
|
-
return this.webchatRef.current.isOnline()
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
async resolveWebchatVisibility(optionsAtRuntime) {
|
|
364
|
-
let { appId, visibility } = optionsAtRuntime
|
|
365
|
-
visibility = visibility || this.visibility
|
|
366
|
-
if (visibility === undefined || visibility === true) return true
|
|
367
|
-
if (typeof visibility === 'function' && visibility()) return true
|
|
368
|
-
if (visibility === 'dynamic' && (await this.isWebchatVisible({ appId })))
|
|
369
|
-
return true
|
|
370
|
-
return false
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
destroy() {
|
|
374
|
-
if (this.hubtypeService) this.hubtypeService.destroyPusher()
|
|
375
|
-
unmountComponentAtNode(this.host)
|
|
376
|
-
if (this.storage) this.storage.removeItem(this.storageKey)
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
async render(dest, optionsAtRuntime = {}) {
|
|
380
|
-
onDOMLoaded(async () => {
|
|
381
|
-
const isVisible = await this.resolveWebchatVisibility(optionsAtRuntime)
|
|
382
|
-
if (isVisible)
|
|
383
|
-
render(
|
|
384
|
-
this.getComponent(dest, optionsAtRuntime),
|
|
385
|
-
this.getReactMountNode(dest)
|
|
386
|
-
)
|
|
387
|
-
})
|
|
388
|
-
}
|
|
389
|
-
}
|