@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
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
|
-
}
|