@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/index-types.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
BotContext,
|
|
2
3
|
BotRequest as CoreBotRequest,
|
|
3
4
|
Input as CoreInput,
|
|
4
5
|
InputType as CoreInputType,
|
|
5
|
-
Plugin as CorePlugin,
|
|
6
6
|
Route as CoreRoute,
|
|
7
7
|
Routes as CoreRoutes,
|
|
8
|
+
ServerConfig,
|
|
8
9
|
Session as CoreSession,
|
|
9
10
|
SessionUser as CoreSessionUser,
|
|
10
11
|
} from '@botonic/core'
|
|
@@ -13,14 +14,16 @@ import React from 'react'
|
|
|
13
14
|
import {
|
|
14
15
|
BlockInputOption,
|
|
15
16
|
ButtonProps,
|
|
16
|
-
CoverComponentOptions,
|
|
17
|
-
PersistentMenuTheme,
|
|
18
17
|
ReplyProps,
|
|
19
|
-
ThemeProps,
|
|
20
18
|
WebchatSettingsProps,
|
|
21
|
-
|
|
22
|
-
} from './
|
|
23
|
-
import {
|
|
19
|
+
} from './components'
|
|
20
|
+
import { CloseWebviewOptions } from './contexts'
|
|
21
|
+
import { UseWebchat } from './webchat/context/use-webchat'
|
|
22
|
+
import {
|
|
23
|
+
CoverComponentOptions,
|
|
24
|
+
PersistentMenuOptionsTheme,
|
|
25
|
+
WebchatTheme,
|
|
26
|
+
} from './webchat/theme/types'
|
|
24
27
|
import { WebchatApp } from './webchat-app'
|
|
25
28
|
|
|
26
29
|
/**
|
|
@@ -35,62 +38,97 @@ export interface Route extends CoreRoute {
|
|
|
35
38
|
}
|
|
36
39
|
export type Routes = CoreRoutes<Route>
|
|
37
40
|
|
|
38
|
-
// Parameters of the actions
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
// Parameters of the actions in botonicInit method
|
|
42
|
+
// the ActionRequest is provided by the context of the core-bot
|
|
43
|
+
export type ActionRequest = BotContext
|
|
44
|
+
|
|
45
|
+
export interface WebchatRef {
|
|
46
|
+
addBotResponse: ({
|
|
47
|
+
response,
|
|
48
|
+
session,
|
|
49
|
+
lastRoutePath,
|
|
50
|
+
}: AddBotResponseArgs) => void
|
|
51
|
+
setTyping: (typing: boolean) => void
|
|
52
|
+
addUserMessage: (message: any) => Promise<void>
|
|
53
|
+
updateUser: (userToUpdate: any) => void
|
|
54
|
+
openWebchat: () => void
|
|
55
|
+
closeWebchat: () => void
|
|
56
|
+
toggleWebchat: () => void
|
|
57
|
+
openCoverComponent: () => void
|
|
58
|
+
closeCoverComponent: () => void
|
|
59
|
+
toggleCoverComponent: () => void
|
|
60
|
+
renderCustomComponent: (customComponent: any) => void
|
|
61
|
+
unmountCustomComponent: () => void
|
|
62
|
+
isOnline: () => boolean
|
|
63
|
+
setOnline: (online: boolean) => void
|
|
64
|
+
getMessages: () => { id: string; ack: number; unsentInput: CoreInput }[] // TODO: define MessagesJSON
|
|
65
|
+
clearMessages: () => void
|
|
66
|
+
getLastMessageUpdate: () => string | undefined
|
|
67
|
+
updateMessageInfo: (msgId: string, messageInfo: any) => void
|
|
68
|
+
updateWebchatSettings: (settings: WebchatSettingsProps) => void
|
|
69
|
+
closeWebview: (options?: CloseWebviewOptions) => Promise<void>
|
|
52
70
|
}
|
|
53
71
|
|
|
54
|
-
|
|
55
|
-
|
|
72
|
+
interface AddBotResponseArgs {
|
|
73
|
+
response: any
|
|
74
|
+
session?: any
|
|
75
|
+
lastRoutePath?: any
|
|
56
76
|
}
|
|
57
77
|
|
|
58
78
|
export interface WebchatArgs {
|
|
59
|
-
|
|
79
|
+
theme?: Partial<WebchatTheme>
|
|
80
|
+
persistentMenu?: PersistentMenuOptionsTheme
|
|
60
81
|
coverComponent?: CoverComponentOptions
|
|
61
|
-
|
|
62
|
-
defaultTyping?: number
|
|
63
|
-
enableAnimations?: boolean
|
|
64
|
-
enableAttachments?: boolean
|
|
82
|
+
blockInputs?: BlockInputOption[]
|
|
65
83
|
enableEmojiPicker?: boolean
|
|
84
|
+
enableAttachments?: boolean
|
|
66
85
|
enableUserInput?: boolean
|
|
67
|
-
|
|
86
|
+
enableAnimations?: boolean
|
|
68
87
|
hostId?: string
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
shadowDOM?: boolean | (() => boolean)
|
|
89
|
+
defaultDelay?: number
|
|
90
|
+
defaultTyping?: number
|
|
91
|
+
storage?: Storage | null
|
|
92
|
+
storageKey?: string
|
|
71
93
|
onInit?: (app: WebchatApp, args: any) => void
|
|
72
|
-
onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
73
94
|
onOpen?: (app: WebchatApp, args: any) => void
|
|
74
|
-
|
|
95
|
+
onClose?: (app: WebchatApp, args: any) => void
|
|
96
|
+
onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
75
97
|
onTrackEvent?: TrackEventFunction
|
|
76
|
-
|
|
98
|
+
onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
|
|
99
|
+
appId?: string
|
|
100
|
+
visibility?: boolean | (() => boolean) | 'dynamic'
|
|
101
|
+
server?: ServerConfig
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface WebchatProps {
|
|
105
|
+
webchatHooks?: UseWebchat
|
|
106
|
+
initialSession?: any
|
|
107
|
+
initialDevSettings?: any
|
|
108
|
+
onStateChange: (args: OnStateChangeArgs) => void
|
|
109
|
+
|
|
110
|
+
shadowDOM?: any
|
|
111
|
+
theme?: WebchatTheme
|
|
77
112
|
storage?: Storage | null
|
|
78
|
-
storageKey?:
|
|
79
|
-
|
|
113
|
+
storageKey?: string | (() => string)
|
|
114
|
+
defaultDelay?: number
|
|
115
|
+
defaultTyping?: number
|
|
116
|
+
onInit?: (args?: any) => void
|
|
117
|
+
onOpen?: (args?: any) => void
|
|
118
|
+
onClose?: (args?: any) => void
|
|
119
|
+
onUserInput(args: OnUserInputArgs): Promise<void>
|
|
120
|
+
onTrackEvent?: TrackEventFunction
|
|
121
|
+
host?: any
|
|
122
|
+
server?: ServerConfig
|
|
80
123
|
}
|
|
81
124
|
|
|
82
|
-
type EventArgs = { [key: string]: any }
|
|
83
|
-
type TrackEventFunction = (
|
|
125
|
+
export type EventArgs = { [key: string]: any }
|
|
126
|
+
export type TrackEventFunction = (
|
|
84
127
|
request: ActionRequest,
|
|
85
128
|
eventName: string,
|
|
86
129
|
args?: EventArgs
|
|
87
130
|
) => Promise<void>
|
|
88
131
|
|
|
89
|
-
export interface WebchatAppArgs {
|
|
90
|
-
appId?: string
|
|
91
|
-
visibility?: () => boolean
|
|
92
|
-
}
|
|
93
|
-
|
|
94
132
|
export enum SENDERS {
|
|
95
133
|
bot = 'bot',
|
|
96
134
|
user = 'user',
|
|
@@ -106,19 +144,19 @@ export interface WebchatMessage {
|
|
|
106
144
|
ack: 0 | 1
|
|
107
145
|
blob: boolean
|
|
108
146
|
buttons: ButtonProps[]
|
|
109
|
-
children: any
|
|
110
|
-
data: any
|
|
147
|
+
children: any // messageJSON don't have children prop
|
|
148
|
+
data: any // if message.type === 'text' => message.data = {text: string}
|
|
111
149
|
delay: number
|
|
112
150
|
display: boolean
|
|
113
|
-
enabletimestamps
|
|
151
|
+
enabletimestamps?: boolean
|
|
114
152
|
id: string
|
|
115
|
-
imagestyle
|
|
153
|
+
imagestyle?: any
|
|
116
154
|
isUnread: boolean
|
|
117
155
|
json: any
|
|
118
|
-
markdown: boolean
|
|
156
|
+
markdown: boolean // 0 | 1
|
|
119
157
|
replies: ReplyProps[]
|
|
120
158
|
sentBy: SENDERS
|
|
121
|
-
style
|
|
159
|
+
style?: any
|
|
122
160
|
timestamp: string
|
|
123
161
|
type: CoreInputType
|
|
124
162
|
typing: number
|
|
@@ -128,7 +166,7 @@ export interface OnUserInputArgs {
|
|
|
128
166
|
input: CoreInput
|
|
129
167
|
lastRoutePath?: string
|
|
130
168
|
session?: CoreSession
|
|
131
|
-
user
|
|
169
|
+
user?: CoreSessionUser
|
|
132
170
|
}
|
|
133
171
|
|
|
134
172
|
export interface OnStateChangeArgs {
|
|
@@ -142,42 +180,20 @@ export interface MessageInfo {
|
|
|
142
180
|
type: 'update_webchat_settings' | 'sender_action'
|
|
143
181
|
}
|
|
144
182
|
|
|
145
|
-
export
|
|
146
|
-
|
|
183
|
+
export type Event = ConnectionChangeEvent | UpdateMessageInfoEvent
|
|
184
|
+
|
|
185
|
+
interface ConnectionChangeEvent {
|
|
186
|
+
action: 'connectionChange'
|
|
187
|
+
online: boolean
|
|
147
188
|
isError?: boolean
|
|
148
189
|
message?: MessageInfo
|
|
149
190
|
}
|
|
150
191
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
addMessage: (message: WebchatMessage) => void
|
|
156
|
-
closeWebview: () => Promise<void>
|
|
157
|
-
getThemeProperty: (property: string, defaultValue?: any) => any
|
|
158
|
-
openWebview: (webviewComponent: Webview, params?: any) => void
|
|
159
|
-
resetUnreadMessages: () => void
|
|
160
|
-
resolveCase: () => void
|
|
161
|
-
sendAttachment: (attachment: File) => Promise<void>
|
|
162
|
-
sendInput: (input: ClientInput) => Promise<void>
|
|
163
|
-
sendPayload: (payload: string) => Promise<void>
|
|
164
|
-
sendText: (text: string, payload?: string) => Promise<void>
|
|
165
|
-
setLastMessageVisible: (isLastMessageVisible: boolean) => void
|
|
166
|
-
theme: ThemeProps
|
|
167
|
-
toggleWebchat: (toggle: boolean) => void
|
|
168
|
-
toggleEmojiPicker: (toggle: boolean) => void
|
|
169
|
-
togglePersistentMenu: (toggle: boolean) => void
|
|
170
|
-
updateLatestInput: (input: ClientInput) => void
|
|
171
|
-
updateMessage: (message: WebchatMessage) => void
|
|
172
|
-
updateReplies: (replies: boolean) => void
|
|
173
|
-
updateUser: (user: Partial<CoreSessionUser>) => void
|
|
174
|
-
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
175
|
-
webchatState: WebchatState
|
|
176
|
-
trackEvent: TrackEventFunction
|
|
177
|
-
webchatRef: React.MutableRefObject<HTMLDivElement | null>
|
|
178
|
-
chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
|
|
179
|
-
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
180
|
-
headerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
181
|
-
scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
|
|
182
|
-
repliesRef: React.MutableRefObject<HTMLDivElement | null>
|
|
192
|
+
interface UpdateMessageInfoEvent {
|
|
193
|
+
action: 'update_message_info'
|
|
194
|
+
message: MessageInfo
|
|
195
|
+
isError?: boolean
|
|
183
196
|
}
|
|
197
|
+
|
|
198
|
+
export { CaseEventQueuePositionChangedInput } from '@botonic/core'
|
|
199
|
+
export { WebchatTheme }
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
|
|
2
2
|
export * from './components'
|
|
3
|
-
export {
|
|
4
|
-
RequestContext,
|
|
5
|
-
WebchatContext,
|
|
6
|
-
WebviewRequestContext,
|
|
7
|
-
} from './contexts'
|
|
3
|
+
export { RequestContext, WebviewRequestContext } from './contexts'
|
|
8
4
|
export { DevApp } from './dev-app'
|
|
9
5
|
export * from './index-types'
|
|
10
6
|
export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
|
package/src/msg-to-botonic.jsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
3
|
import { Audio } from './components/audio'
|
|
4
|
-
import { Button } from './components/button'
|
|
4
|
+
import { Button } from './components/button/index'
|
|
5
5
|
import { ButtonsDisabler } from './components/buttons-disabler'
|
|
6
6
|
import { Carousel } from './components/carousel'
|
|
7
7
|
import { Document } from './components/document'
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
* @param customMessageTypes {{customTypeName}[]?}
|
|
33
33
|
* @return {React.ReactNode}
|
|
34
34
|
*/
|
|
35
|
-
export function msgToBotonic(msg, customMessageTypes) {
|
|
35
|
+
export function msgToBotonic(msg, customMessageTypes = []) {
|
|
36
36
|
delete msg.display
|
|
37
37
|
if (isCustom(msg)) {
|
|
38
38
|
try {
|
|
@@ -56,28 +56,28 @@ export function msgToBotonic(msg, customMessageTypes) {
|
|
|
56
56
|
<Image
|
|
57
57
|
key={msg.key}
|
|
58
58
|
{...msg}
|
|
59
|
-
src={msg.data.image
|
|
59
|
+
src={msg.data.image !== undefined ? msg.data.image : msg.data}
|
|
60
60
|
/>
|
|
61
61
|
)
|
|
62
62
|
} else if (isVideo(msg)) {
|
|
63
63
|
return (
|
|
64
64
|
<Video
|
|
65
65
|
{...msg}
|
|
66
|
-
src={msg.data.video
|
|
66
|
+
src={msg.data.video !== undefined ? msg.data.video : msg.data}
|
|
67
67
|
/>
|
|
68
68
|
)
|
|
69
69
|
} else if (isAudio(msg)) {
|
|
70
70
|
return (
|
|
71
71
|
<Audio
|
|
72
72
|
{...msg}
|
|
73
|
-
src={msg.data.audio
|
|
73
|
+
src={msg.data.audio !== undefined ? msg.data.audio : msg.data}
|
|
74
74
|
/>
|
|
75
75
|
)
|
|
76
76
|
} else if (isDocument(msg)) {
|
|
77
77
|
return (
|
|
78
78
|
<Document
|
|
79
79
|
{...msg}
|
|
80
|
-
src={msg.data.document
|
|
80
|
+
src={msg.data.document !== undefined ? msg.data.document : msg.data}
|
|
81
81
|
/>
|
|
82
82
|
)
|
|
83
83
|
} else if (isLocation(msg)) {
|
|
@@ -99,10 +99,6 @@ export function msgToBotonic(msg, customMessageTypes) {
|
|
|
99
99
|
return null
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function rndStr() {
|
|
103
|
-
return Math.random().toString()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
102
|
/**
|
|
107
103
|
* @param msgs {object|object[]}
|
|
108
104
|
* @param customMessageTypes {{customTypeName}[]?}
|
|
@@ -133,7 +129,7 @@ function textToBotonic(msg) {
|
|
|
133
129
|
return (
|
|
134
130
|
<Text {...msg} key={msg.key}>
|
|
135
131
|
{txt}
|
|
136
|
-
{
|
|
132
|
+
{parseQuickReplies(msg)}
|
|
137
133
|
</Text>
|
|
138
134
|
)
|
|
139
135
|
if (msg.buttons && msg.buttons.length)
|
|
@@ -186,7 +182,7 @@ function buttonsParse(buttons) {
|
|
|
186
182
|
})
|
|
187
183
|
}
|
|
188
184
|
|
|
189
|
-
function
|
|
185
|
+
function parseQuickReplies(msg) {
|
|
190
186
|
let replies = null
|
|
191
187
|
if (msg.replies) {
|
|
192
188
|
replies = msg.replies.map((el, i) => {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CoreBot } from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { Text } from './components/text'
|
|
5
|
+
import { RequestContext } from './contexts'
|
|
6
|
+
import { ActionRequest } from './index-types'
|
|
7
|
+
|
|
8
|
+
type ActionComponentType<P = any> = React.ComponentType<P> & {
|
|
9
|
+
botonicInit?: (request: ActionRequest) => Promise<P>
|
|
10
|
+
contextType?: React.Context<typeof RequestContext>
|
|
11
|
+
render: (props: P) => JSX.Element
|
|
12
|
+
}
|
|
13
|
+
interface RenderReactActionsArgs {
|
|
14
|
+
request: ActionRequest
|
|
15
|
+
actions: ActionComponentType[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class ReactBot extends CoreBot {
|
|
19
|
+
constructor(options: any) {
|
|
20
|
+
super({
|
|
21
|
+
defaultRoutes: [
|
|
22
|
+
{
|
|
23
|
+
path: '404',
|
|
24
|
+
action: () => <Text>I don't understand you</Text>, // eslint-disable-line
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
renderer: (args: RenderReactActionsArgs) => this.renderReactActions(args),
|
|
28
|
+
...options,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async renderReactActions({ request, actions }: RenderReactActionsArgs) {
|
|
33
|
+
const renderedActions: JSX.Element[] = []
|
|
34
|
+
|
|
35
|
+
for (const Action of actions) {
|
|
36
|
+
if (Action) {
|
|
37
|
+
const props = Action.botonicInit
|
|
38
|
+
? await Action.botonicInit(request)
|
|
39
|
+
: {}
|
|
40
|
+
const renderedAction: JSX.Element = (
|
|
41
|
+
<RequestContext.Provider value={request}>
|
|
42
|
+
<Action {...props} />
|
|
43
|
+
</RequestContext.Provider>
|
|
44
|
+
)
|
|
45
|
+
renderedActions.push(renderedAction)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return renderedActions
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
export const timeZoneToCountryCode: Record<string, string> = {
|
|
3
|
+
'Africa/Abidjan': 'CI',
|
|
4
|
+
'Africa/Accra': 'GH',
|
|
5
|
+
'Africa/Addis_Ababa': 'ET',
|
|
6
|
+
'Africa/Algiers': 'DZ',
|
|
7
|
+
'Africa/Asmara': 'ER',
|
|
8
|
+
'Africa/Bamako': 'ML',
|
|
9
|
+
'Africa/Bangui': 'CF',
|
|
10
|
+
'Africa/Banjul': 'GM',
|
|
11
|
+
'Africa/Bissau': 'GW',
|
|
12
|
+
'Africa/Blantyre': 'MW',
|
|
13
|
+
'Africa/Brazzaville': 'CG',
|
|
14
|
+
'Africa/Bujumbura': 'BI',
|
|
15
|
+
'Africa/Cairo': 'EG',
|
|
16
|
+
'Africa/Casablanca': 'MA',
|
|
17
|
+
'Africa/Ceuta': 'ES',
|
|
18
|
+
'Africa/Conakry': 'GN',
|
|
19
|
+
'Africa/Dakar': 'SN',
|
|
20
|
+
'Africa/Dar_es_Salaam': 'TZ',
|
|
21
|
+
'Africa/Djibouti': 'DJ',
|
|
22
|
+
'Africa/Douala': 'CM',
|
|
23
|
+
'Africa/El_Aaiun': 'EH',
|
|
24
|
+
'Africa/Freetown': 'SL',
|
|
25
|
+
'Africa/Gaborone': 'BW',
|
|
26
|
+
'Africa/Harare': 'ZW',
|
|
27
|
+
'Africa/Johannesburg': 'ZA',
|
|
28
|
+
'Africa/Juba': 'SS',
|
|
29
|
+
'Africa/Kampala': 'UG',
|
|
30
|
+
'Africa/Khartoum': 'SD',
|
|
31
|
+
'Africa/Kigali': 'RW',
|
|
32
|
+
'Africa/Kinshasa': 'CD',
|
|
33
|
+
'Africa/Lagos': 'NG',
|
|
34
|
+
'Africa/Libreville': 'GA',
|
|
35
|
+
'Africa/Lome': 'TG',
|
|
36
|
+
'Africa/Luanda': 'AO',
|
|
37
|
+
'Africa/Lubumbashi': 'CD',
|
|
38
|
+
'Africa/Lusaka': 'ZM',
|
|
39
|
+
'Africa/Malabo': 'GQ',
|
|
40
|
+
'Africa/Maputo': 'MZ',
|
|
41
|
+
'Africa/Maseru': 'LS',
|
|
42
|
+
'Africa/Mbabane': 'SZ',
|
|
43
|
+
'Africa/Mogadishu': 'SO',
|
|
44
|
+
'Africa/Monrovia': 'LR',
|
|
45
|
+
'Africa/Nairobi': 'KE',
|
|
46
|
+
'Africa/Ndjamena': 'TD',
|
|
47
|
+
'Africa/Niamey': 'NE',
|
|
48
|
+
'Africa/Nouakchott': 'MR',
|
|
49
|
+
'Africa/Ouagadougou': 'BF',
|
|
50
|
+
'Africa/Porto-Novo': 'BJ',
|
|
51
|
+
'Africa/Sao_Tome': 'ST',
|
|
52
|
+
'Africa/Tripoli': 'LY',
|
|
53
|
+
'Africa/Tunis': 'TN',
|
|
54
|
+
'Africa/Windhoek': 'NA',
|
|
55
|
+
'America/Argentina/Buenos_Aires': 'AR',
|
|
56
|
+
'America/Bogota': 'CO',
|
|
57
|
+
'America/Caracas': 'VE',
|
|
58
|
+
'America/Chicago': 'US',
|
|
59
|
+
'America/Denver': 'US',
|
|
60
|
+
'America/Guatemala': 'GT',
|
|
61
|
+
'America/Halifax': 'CA',
|
|
62
|
+
'America/La_Paz': 'BO',
|
|
63
|
+
'America/Lima': 'PE',
|
|
64
|
+
'America/Los_Angeles': 'US',
|
|
65
|
+
'America/Mexico_City': 'MX',
|
|
66
|
+
'America/Montevideo': 'UY',
|
|
67
|
+
'America/New_York': 'US',
|
|
68
|
+
'America/Phoenix': 'US',
|
|
69
|
+
'America/Santiago': 'CL',
|
|
70
|
+
'America/Sao_Paulo': 'BR',
|
|
71
|
+
'America/Toronto': 'CA',
|
|
72
|
+
'Asia/Bangkok': 'TH',
|
|
73
|
+
'Asia/Colombo': 'LK',
|
|
74
|
+
'Asia/Dubai': 'AE',
|
|
75
|
+
'Asia/Hong_Kong': 'HK',
|
|
76
|
+
'Asia/Jakarta': 'ID',
|
|
77
|
+
'Asia/Kolkata': 'IN',
|
|
78
|
+
'Asia/Manila': 'PH',
|
|
79
|
+
'Asia/Seoul': 'KR',
|
|
80
|
+
'Asia/Shanghai': 'CN',
|
|
81
|
+
'Asia/Singapore': 'SG',
|
|
82
|
+
'Asia/Taipei': 'TW',
|
|
83
|
+
'Asia/Tokyo': 'JP',
|
|
84
|
+
'Australia/Brisbane': 'AU',
|
|
85
|
+
'Australia/Melbourne': 'AU',
|
|
86
|
+
'Australia/Perth': 'AU',
|
|
87
|
+
'Australia/Sydney': 'AU',
|
|
88
|
+
'Europe/Amsterdam': 'NL',
|
|
89
|
+
'Europe/Berlin': 'DE',
|
|
90
|
+
'Europe/Brussels': 'BE',
|
|
91
|
+
'Europe/Bucharest': 'RO',
|
|
92
|
+
'Europe/Copenhagen': 'DK',
|
|
93
|
+
'Europe/Helsinki': 'FI',
|
|
94
|
+
'Europe/Lisbon': 'PT',
|
|
95
|
+
'Europe/London': 'GB',
|
|
96
|
+
'Europe/Madrid': 'ES',
|
|
97
|
+
'Europe/Oslo': 'NO',
|
|
98
|
+
'Europe/Paris': 'FR',
|
|
99
|
+
'Europe/Prague': 'CZ',
|
|
100
|
+
'Europe/Rome': 'IT',
|
|
101
|
+
'Europe/Stockholm': 'SE',
|
|
102
|
+
'Europe/Warsaw': 'PL',
|
|
103
|
+
'Pacific/Auckland': 'NZ',
|
|
104
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function camelCaseToSnake(str: string): string {
|
|
2
|
+
return str
|
|
3
|
+
.replace(/([a-z])([A-Z])/g, '$1_$2')
|
|
4
|
+
.replace(/([A-Za-z])(\d)/g, '$1_$2')
|
|
5
|
+
.replace(/(\d)([A-Za-z])/g, '$1_$2')
|
|
6
|
+
.toLowerCase()
|
|
7
|
+
}
|
|
8
|
+
type Input = Record<string, any> | Record<string, any>[] | undefined
|
|
9
|
+
|
|
10
|
+
export function toSnakeCaseKeys(input: Input): Input {
|
|
11
|
+
if (Array.isArray(input)) {
|
|
12
|
+
return input.map(item => toSnakeCaseKeys(item))
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (typeof input === 'object' && input !== null) {
|
|
16
|
+
const result = Object.keys(input).reduce((acc, key) => {
|
|
17
|
+
const snakeKey = camelCaseToSnake(key)
|
|
18
|
+
const value = input[key]
|
|
19
|
+
acc[snakeKey] =
|
|
20
|
+
typeof value === 'object' && value !== null
|
|
21
|
+
? toSnakeCaseKeys(value)
|
|
22
|
+
: value
|
|
23
|
+
|
|
24
|
+
return acc
|
|
25
|
+
}, {})
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return input
|
|
31
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import merge from 'lodash.merge'
|
|
2
|
+
import UAParser from 'ua-parser-js'
|
|
3
|
+
import { v7 as uuidv7 } from 'uuid'
|
|
4
|
+
|
|
5
|
+
import { WEBCHAT } from '../constants'
|
|
6
|
+
import { timeZoneToCountryCode } from '../time-zone-to-country-code'
|
|
7
|
+
import { ClientUser } from '../webchat/context/types'
|
|
8
|
+
import { WebchatTheme } from '../webchat/theme/types'
|
|
9
|
+
import { getProperty } from './objects'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns the value of a property defined in bot's theme based on WEBCHAT.CUSTOM_PROPERTIES dictionary.
|
|
13
|
+
* It gives preference to nested defined properties (e.g.: header.style) over plain properties (e.g.: headerStyle).
|
|
14
|
+
* If property doesn't exist, returns the defaultValue.
|
|
15
|
+
*/
|
|
16
|
+
export const _getThemeProperty =
|
|
17
|
+
(theme: WebchatTheme) => (property: string, defaultValue?: any) => {
|
|
18
|
+
for (const [key, value] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
|
|
19
|
+
if (value === property) {
|
|
20
|
+
const nestedProperty = getProperty(theme, value)
|
|
21
|
+
if (nestedProperty !== undefined) return nestedProperty
|
|
22
|
+
const plainProperty = getProperty(theme, key)
|
|
23
|
+
if (plainProperty !== undefined) return plainProperty
|
|
24
|
+
return defaultValue
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return undefined
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const createUser = (): {
|
|
31
|
+
id: string
|
|
32
|
+
name: string
|
|
33
|
+
} => {
|
|
34
|
+
const parser = new UAParser()
|
|
35
|
+
const ua = parser.getResult()
|
|
36
|
+
let name = `${ua.os.name} ${ua.browser.name}`
|
|
37
|
+
if (ua.device && ua.device.type) name = `${ua.device.type} ${name}`
|
|
38
|
+
return {
|
|
39
|
+
id: uuidv7(),
|
|
40
|
+
name,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const initSession = (
|
|
44
|
+
session: any
|
|
45
|
+
): { user: { id: string; name: string } } => {
|
|
46
|
+
if (!session) session = {}
|
|
47
|
+
const hasUserId = session?.user?.id !== undefined
|
|
48
|
+
if (!session.user || Object.keys(session.user).length === 0 || !hasUserId)
|
|
49
|
+
session.user = !hasUserId ? merge(session.user, createUser()) : createUser()
|
|
50
|
+
return session
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function updateUserLocaleAndCountry(user: Partial<ClientUser>) {
|
|
54
|
+
user.locale = getLocale(user)
|
|
55
|
+
user.country = getCountry(user)
|
|
56
|
+
user.system_locale = getSystemLocale(user)
|
|
57
|
+
|
|
58
|
+
return user
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getLocale(user: Partial<ClientUser>) {
|
|
62
|
+
if (user.locale) {
|
|
63
|
+
return user.locale
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return user.extra_data?.language
|
|
67
|
+
? (user.extra_data?.language as string)
|
|
68
|
+
: navigator.language
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function getCountry(user: Partial<ClientUser>) {
|
|
72
|
+
if (user.country) {
|
|
73
|
+
return user.country
|
|
74
|
+
}
|
|
75
|
+
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
76
|
+
const userCountry = timeZoneToCountryCode[timeZone]
|
|
77
|
+
|
|
78
|
+
return user.extra_data?.country
|
|
79
|
+
? (user.extra_data?.country as string)
|
|
80
|
+
: userCountry
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getSystemLocale(user: Partial<ClientUser>) {
|
|
84
|
+
if (user.system_locale) {
|
|
85
|
+
return user.system_locale
|
|
86
|
+
}
|
|
87
|
+
return getLocale(user)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export const shouldKeepSessionOnReload = ({
|
|
91
|
+
initialDevSettings,
|
|
92
|
+
devSettings,
|
|
93
|
+
}) => !initialDevSettings || (devSettings && devSettings.keepSessionOnReload)
|
|
94
|
+
|
|
95
|
+
//TODO: Review param serverConfig if is of type ServerConfig this never have errorMessage
|
|
96
|
+
export const getServerErrorMessage = serverConfig => {
|
|
97
|
+
if (!serverConfig || !serverConfig.errorMessage) return 'Connection issues'
|
|
98
|
+
if (typeof serverConfig.errorMessage === 'function') {
|
|
99
|
+
return serverConfig.errorMessage()
|
|
100
|
+
}
|
|
101
|
+
return serverConfig.errorMessage
|
|
102
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebchatContext } from '../../contexts'
|
|
4
3
|
import { BotonicContainerId } from '../constants'
|
|
4
|
+
import { WebchatContext } from '../context'
|
|
5
5
|
import { useWebchatDimensions } from '../hooks'
|
|
6
6
|
import { WebchatMessageList } from '../message-list'
|
|
7
7
|
import { WebchatReplies } from '../replies'
|
|
@@ -27,9 +27,7 @@ export const ChatArea = () => {
|
|
|
27
27
|
height={chatAreaHeight}
|
|
28
28
|
>
|
|
29
29
|
<WebchatMessageList />
|
|
30
|
-
{replies &&
|
|
31
|
-
<WebchatReplies replies={replies} />
|
|
32
|
-
)}
|
|
30
|
+
{replies && replies.length > 0 && <WebchatReplies />}
|
|
33
31
|
</StyledChatArea>
|
|
34
32
|
)
|
|
35
33
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import { WEBCHAT } from '../../constants'
|
|
4
|
-
import { WebchatContext } from '../../contexts'
|
|
5
4
|
import { Scale } from '../../shared/styles'
|
|
6
5
|
import { ConditionalWrapper } from '../../util/react'
|
|
6
|
+
import { WebchatContext } from '../context'
|
|
7
7
|
|
|
8
8
|
export const ConditionalAnimation = props => {
|
|
9
9
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
10
10
|
|
|
11
11
|
const animationsEnabled = getThemeProperty(
|
|
12
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
13
|
-
props.enableAnimations !== undefined ? props.enableAnimations : true
|
|
12
|
+
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
14
13
|
)
|
|
14
|
+
|
|
15
15
|
return (
|
|
16
16
|
<ConditionalWrapper
|
|
17
17
|
condition={animationsEnabled}
|