@botonic/react 0.36.0-alpha.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/audio.d.ts +8 -7
- package/lib/cjs/components/audio.js +7 -4
- package/lib/cjs/components/audio.js.map +1 -1
- package/lib/cjs/components/{button.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 +10 -11
- package/lib/cjs/contexts.js +15 -78
- 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 +39 -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 +62 -14
- 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 +10 -11
- package/lib/esm/contexts.js +14 -77
- 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 +35 -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 +64 -16
- 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 +26 -91
- 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 +73 -0
- package/src/webchat/webview/styles.ts +62 -0
- package/src/webchat-app.tsx +575 -0
- package/src/webview-app.tsx +75 -20
- package/lib/cjs/components/button.js.map +0 -1
- package/lib/cjs/webchat/actions.js.map +0 -1
- package/lib/cjs/webchat/header.d.ts +0 -3
- package/lib/cjs/webchat/header.js +0 -86
- package/lib/cjs/webchat/header.js.map +0 -1
- package/lib/cjs/webchat/hooks/use-webchat.d.ts +0 -46
- package/lib/cjs/webchat/hooks/use-webchat.js.map +0 -1
- package/lib/cjs/webchat/messages-reducer.js.map +0 -1
- package/lib/cjs/webchat/replies.d.ts +0 -1
- package/lib/cjs/webchat/replies.js +0 -47
- package/lib/cjs/webchat/replies.js.map +0 -1
- package/lib/cjs/webchat/webchat-reducer.js.map +0 -1
- package/lib/cjs/webchat/webview.d.ts +0 -2
- package/lib/cjs/webchat/webview.js +0 -75
- package/lib/cjs/webchat/webview.js.map +0 -1
- package/lib/esm/components/button.js.map +0 -1
- package/lib/esm/webchat/actions.js.map +0 -1
- package/lib/esm/webchat/header.d.ts +0 -3
- package/lib/esm/webchat/header.js +0 -81
- package/lib/esm/webchat/header.js.map +0 -1
- package/lib/esm/webchat/hooks/use-webchat.d.ts +0 -46
- package/lib/esm/webchat/hooks/use-webchat.js.map +0 -1
- package/lib/esm/webchat/messages-reducer.js.map +0 -1
- package/lib/esm/webchat/replies.d.ts +0 -1
- package/lib/esm/webchat/replies.js +0 -42
- package/lib/esm/webchat/replies.js.map +0 -1
- package/lib/esm/webchat/webchat-reducer.js.map +0 -1
- package/lib/esm/webchat/webview.d.ts +0 -2
- package/lib/esm/webchat/webview.js +0 -70
- package/lib/esm/webchat/webview.js.map +0 -1
- package/src/react-bot.jsx +0 -38
- package/src/util/webchat.js +0 -57
- package/src/webchat/header.jsx +0 -149
- package/src/webchat/replies.jsx +0 -64
- package/src/webchat/webview.jsx +0 -105
- package/src/webchat-app.jsx +0 -389
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
|
-
import { Button } from '../../components/button'
|
|
4
|
+
import { Button } from '../../components/button/index'
|
|
5
5
|
import { ROLES, WEBCHAT } from '../../constants'
|
|
6
|
-
import { WebchatContext } from '
|
|
6
|
+
import { WebchatContext } from '../context'
|
|
7
7
|
import { useComponentVisible } from '../hooks'
|
|
8
8
|
|
|
9
9
|
const ButtonsContainer = styled.div`
|
|
@@ -18,8 +18,7 @@ export const OpenedPersistentMenu = ({ onClick, options, borderRadius }) => {
|
|
|
18
18
|
const { ref, isComponentVisible } = useComponentVisible(true, onClick)
|
|
19
19
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
20
20
|
const CustomPersistentMenu = getThemeProperty(
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.customPersistentMenu
|
|
22
|
-
undefined
|
|
21
|
+
WEBCHAT.CUSTOM_PROPERTIES.customPersistentMenu
|
|
23
22
|
)
|
|
24
23
|
let closeLabel = 'Cancel'
|
|
25
24
|
try {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1
2
|
export enum WebchatAction {
|
|
2
3
|
ADD_MESSAGE = 'addMessage',
|
|
3
4
|
ADD_MESSAGE_COMPONENT = 'addMessageComponent',
|
|
@@ -23,4 +24,7 @@ export enum WebchatAction {
|
|
|
23
24
|
UPDATE_THEME = 'updateTheme',
|
|
24
25
|
UPDATE_TYPING = 'updateTyping',
|
|
25
26
|
UPDATE_WEBVIEW = 'updateWebview',
|
|
27
|
+
REMOVE_REPLIES = 'removeReplies',
|
|
28
|
+
REMOVE_WEBVIEW = 'removeWebview',
|
|
29
|
+
SET_IS_INPUT_FOCUSED = 'setIsInputFocused',
|
|
26
30
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WebchatContextProps, WebchatState } from './types'
|
|
4
|
+
|
|
5
|
+
export { WebchatState } from './types'
|
|
6
|
+
export { useWebchat } from './use-webchat'
|
|
7
|
+
|
|
8
|
+
export const WebchatContext = createContext<WebchatContextProps>({
|
|
9
|
+
addMessage: () => {
|
|
10
|
+
return
|
|
11
|
+
},
|
|
12
|
+
getThemeProperty: () => {
|
|
13
|
+
return
|
|
14
|
+
}, // used to retrieve a specific property of the theme defined by the developer in his 'webchat/index.js'
|
|
15
|
+
closeWebview: async () => {
|
|
16
|
+
return
|
|
17
|
+
},
|
|
18
|
+
openWebview: () => {
|
|
19
|
+
return
|
|
20
|
+
},
|
|
21
|
+
resolveCase: () => {
|
|
22
|
+
return
|
|
23
|
+
},
|
|
24
|
+
resetUnreadMessages: () => {
|
|
25
|
+
return
|
|
26
|
+
},
|
|
27
|
+
setIsInputFocused: () => {
|
|
28
|
+
return
|
|
29
|
+
},
|
|
30
|
+
setLastMessageVisible: () => {
|
|
31
|
+
return
|
|
32
|
+
},
|
|
33
|
+
sendAttachment: async () => {
|
|
34
|
+
return
|
|
35
|
+
},
|
|
36
|
+
sendInput: async () => {
|
|
37
|
+
return
|
|
38
|
+
},
|
|
39
|
+
sendPayload: async () => {
|
|
40
|
+
return
|
|
41
|
+
},
|
|
42
|
+
sendText: async () => {
|
|
43
|
+
return
|
|
44
|
+
},
|
|
45
|
+
toggleCoverComponent: () => {
|
|
46
|
+
return
|
|
47
|
+
},
|
|
48
|
+
toggleWebchat: () => {
|
|
49
|
+
return
|
|
50
|
+
},
|
|
51
|
+
toggleEmojiPicker: () => {
|
|
52
|
+
return
|
|
53
|
+
},
|
|
54
|
+
togglePersistentMenu: () => {
|
|
55
|
+
return
|
|
56
|
+
},
|
|
57
|
+
updateLatestInput: () => {
|
|
58
|
+
return
|
|
59
|
+
},
|
|
60
|
+
updateMessage: () => {
|
|
61
|
+
return
|
|
62
|
+
},
|
|
63
|
+
updateReplies: () => {
|
|
64
|
+
return
|
|
65
|
+
},
|
|
66
|
+
updateUser: () => {
|
|
67
|
+
return
|
|
68
|
+
},
|
|
69
|
+
updateWebchatDevSettings: () => {
|
|
70
|
+
return
|
|
71
|
+
},
|
|
72
|
+
webchatState: {} as WebchatState,
|
|
73
|
+
trackEvent: async () => {
|
|
74
|
+
return
|
|
75
|
+
},
|
|
76
|
+
webchatContainerRef: { current: null },
|
|
77
|
+
chatAreaRef: { current: null },
|
|
78
|
+
inputPanelRef: { current: null },
|
|
79
|
+
headerRef: { current: null },
|
|
80
|
+
scrollableMessagesListRef: { current: null },
|
|
81
|
+
repliesRef: { current: null },
|
|
82
|
+
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SENDERS } from '
|
|
1
|
+
import { SENDERS } from '../../index-types'
|
|
2
2
|
import { WebchatAction } from './actions'
|
|
3
|
-
import { WebchatState } from './
|
|
3
|
+
import { WebchatState } from './types'
|
|
4
4
|
|
|
5
5
|
export const messagesReducer = (
|
|
6
6
|
state: WebchatState,
|
|
@@ -15,6 +15,8 @@ export const messagesReducer = (
|
|
|
15
15
|
return updateMessageReducer(state, action)
|
|
16
16
|
case WebchatAction.UPDATE_REPLIES:
|
|
17
17
|
return { ...state, replies: action.payload }
|
|
18
|
+
case WebchatAction.REMOVE_REPLIES:
|
|
19
|
+
return { ...state, replies: undefined }
|
|
18
20
|
case WebchatAction.CLEAR_MESSAGES:
|
|
19
21
|
return {
|
|
20
22
|
...state,
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Input as CoreInput, Session as CoreSession } from '@botonic/core'
|
|
2
|
+
|
|
3
|
+
import { Reply, WebchatSettingsProps, Webview } from '../../components'
|
|
4
|
+
import { CloseWebviewOptions } from '../../contexts'
|
|
5
|
+
import { TrackEventFunction, WebchatMessage } from '../../index-types'
|
|
6
|
+
import { WebchatTheme } from '../theme/types'
|
|
7
|
+
|
|
8
|
+
export interface ErrorMessage {
|
|
9
|
+
message?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DevSettings {
|
|
13
|
+
keepSessionOnReload?: boolean
|
|
14
|
+
showSessionView?: boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface WebchatState {
|
|
18
|
+
messagesJSON: any[]
|
|
19
|
+
messagesComponents: any[]
|
|
20
|
+
replies?: (typeof Reply)[]
|
|
21
|
+
latestInput: Partial<CoreInput>
|
|
22
|
+
typing: boolean
|
|
23
|
+
webview: Webview | null
|
|
24
|
+
webviewParams: null
|
|
25
|
+
session: Partial<CoreSession>
|
|
26
|
+
lastRoutePath?: string
|
|
27
|
+
handoff: boolean
|
|
28
|
+
theme: WebchatTheme
|
|
29
|
+
themeUpdates: Partial<WebchatTheme>
|
|
30
|
+
error: ErrorMessage
|
|
31
|
+
online: boolean
|
|
32
|
+
devSettings: DevSettings
|
|
33
|
+
isWebchatOpen: boolean
|
|
34
|
+
isEmojiPickerOpen: boolean
|
|
35
|
+
isPersistentMenuOpen: boolean
|
|
36
|
+
isCoverComponentOpen: boolean
|
|
37
|
+
isCustomComponentRendered: boolean
|
|
38
|
+
lastMessageUpdate?: string
|
|
39
|
+
currentAttachment?: File
|
|
40
|
+
numUnreadMessages: number
|
|
41
|
+
isLastMessageVisible: boolean
|
|
42
|
+
isInputFocused: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ClientInput: type for sendInput and updateLatestInput function without message_id and bot_interaction_id because backend set this values
|
|
46
|
+
export type ClientInput = Omit<CoreInput, 'message_id' | 'bot_interaction_id'>
|
|
47
|
+
// ClientSession: type for session in frontend when webchat is deployed
|
|
48
|
+
export type ClientSession = {
|
|
49
|
+
user: ClientUser
|
|
50
|
+
}
|
|
51
|
+
// ClientUser: type for user in frontend when webchat is deployed
|
|
52
|
+
export type ClientUser = {
|
|
53
|
+
id: string
|
|
54
|
+
name: string
|
|
55
|
+
locale: string
|
|
56
|
+
country: string
|
|
57
|
+
system_locale?: string
|
|
58
|
+
extra_data?: Record<string, any>
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface WebchatContextProps {
|
|
62
|
+
addMessage: (message: WebchatMessage) => void
|
|
63
|
+
getThemeProperty: (property: string, defaultValue?: any) => any
|
|
64
|
+
closeWebview: (options?: CloseWebviewOptions) => Promise<void>
|
|
65
|
+
openWebview: (webviewComponent: Webview, params?: any) => void
|
|
66
|
+
resetUnreadMessages: () => void
|
|
67
|
+
resolveCase: () => void
|
|
68
|
+
sendAttachment: (attachment: File) => Promise<void>
|
|
69
|
+
sendInput: (input: ClientInput) => Promise<void>
|
|
70
|
+
sendPayload: (payload: string) => Promise<void>
|
|
71
|
+
sendText: (text: string, payload?: string) => Promise<void>
|
|
72
|
+
setIsInputFocused: (isInputFocused: boolean) => void
|
|
73
|
+
setLastMessageVisible: (isLastMessageVisible: boolean) => void
|
|
74
|
+
toggleWebchat: (toggle: boolean) => void
|
|
75
|
+
toggleEmojiPicker: (toggle: boolean) => void
|
|
76
|
+
togglePersistentMenu: (toggle: boolean) => void
|
|
77
|
+
toggleCoverComponent: (toggle: boolean) => void
|
|
78
|
+
updateLatestInput: (input: ClientInput) => void
|
|
79
|
+
updateMessage: (message: WebchatMessage) => void
|
|
80
|
+
updateReplies: (replies: (typeof Reply)[]) => void
|
|
81
|
+
updateUser: (user: ClientUser) => void
|
|
82
|
+
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
83
|
+
trackEvent?: TrackEventFunction
|
|
84
|
+
webchatState: WebchatState
|
|
85
|
+
webchatContainerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
86
|
+
chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
|
|
87
|
+
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
88
|
+
headerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
89
|
+
scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
|
|
90
|
+
repliesRef: React.MutableRefObject<HTMLDivElement | null>
|
|
91
|
+
}
|
|
@@ -1,58 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Session } from '@botonic/core'
|
|
2
2
|
import { useReducer, useRef } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
isCoverComponentOpen: false,
|
|
42
|
-
isCustomComponentRendered: false,
|
|
43
|
-
lastMessageUpdate: undefined,
|
|
44
|
-
currentAttachment: undefined,
|
|
45
|
-
numUnreadMessages: 0,
|
|
46
|
-
isLastMessageVisible: true,
|
|
4
|
+
import { Reply } from '../../components'
|
|
5
|
+
import { Webview } from '../../components/index-types'
|
|
6
|
+
import { WebchatMessage } from '../../index-types'
|
|
7
|
+
import { defaultTheme } from '../theme/default-theme'
|
|
8
|
+
import { WebchatTheme } from '../theme/types'
|
|
9
|
+
import { WebchatAction } from './actions'
|
|
10
|
+
import { ClientInput, DevSettings, ErrorMessage, WebchatState } from './types'
|
|
11
|
+
import { webchatReducer } from './webchat-reducer'
|
|
12
|
+
|
|
13
|
+
function getWebchatInitialState(initialTheme: WebchatTheme): WebchatState {
|
|
14
|
+
return {
|
|
15
|
+
replies: [],
|
|
16
|
+
messagesJSON: [],
|
|
17
|
+
messagesComponents: [],
|
|
18
|
+
latestInput: {},
|
|
19
|
+
typing: false,
|
|
20
|
+
webview: null,
|
|
21
|
+
webviewParams: null,
|
|
22
|
+
session: { user: undefined },
|
|
23
|
+
lastRoutePath: undefined,
|
|
24
|
+
handoff: false,
|
|
25
|
+
theme: initialTheme,
|
|
26
|
+
themeUpdates: {},
|
|
27
|
+
error: {},
|
|
28
|
+
online: true,
|
|
29
|
+
devSettings: { keepSessionOnReload: false },
|
|
30
|
+
isWebchatOpen: false,
|
|
31
|
+
isEmojiPickerOpen: false,
|
|
32
|
+
isPersistentMenuOpen: false,
|
|
33
|
+
isCoverComponentOpen: false,
|
|
34
|
+
isCustomComponentRendered: false,
|
|
35
|
+
lastMessageUpdate: undefined,
|
|
36
|
+
currentAttachment: undefined,
|
|
37
|
+
numUnreadMessages: 0,
|
|
38
|
+
isLastMessageVisible: true,
|
|
39
|
+
isInputFocused: false,
|
|
40
|
+
}
|
|
47
41
|
}
|
|
48
42
|
|
|
49
|
-
export
|
|
43
|
+
export interface UseWebchat {
|
|
44
|
+
addMessage: (message: WebchatMessage) => void
|
|
45
|
+
addMessageComponent: (message: { props: WebchatMessage }) => void
|
|
46
|
+
clearMessages: () => void
|
|
47
|
+
doRenderCustomComponent: (toggle: boolean) => void
|
|
48
|
+
resetUnreadMessages: () => void
|
|
49
|
+
setCurrentAttachment: (attachment?: File) => void
|
|
50
|
+
setError: (error?: ErrorMessage) => void
|
|
51
|
+
setIsInputFocused: (isInputFocused: boolean) => void
|
|
52
|
+
setLastMessageVisible: (isLastMessageVisible: boolean) => void
|
|
53
|
+
setOnline: (online: boolean) => void
|
|
54
|
+
toggleCoverComponent: (toggle: boolean) => void
|
|
55
|
+
toggleEmojiPicker: (toggle: boolean) => void
|
|
56
|
+
togglePersistentMenu: (toggle: boolean) => void
|
|
57
|
+
toggleWebchat: (toggle: boolean) => void
|
|
58
|
+
updateDevSettings: (settings: DevSettings) => void
|
|
59
|
+
updateHandoff: (handoff: boolean) => void
|
|
60
|
+
updateLastMessageDate: (date: string) => void
|
|
61
|
+
updateLastRoutePath: (path: string) => void
|
|
62
|
+
updateLatestInput: (input: ClientInput) => void
|
|
63
|
+
updateMessage: (message: WebchatMessage) => void
|
|
64
|
+
updateReplies: (replies: (typeof Reply)[]) => void
|
|
65
|
+
updateSession: (session: Partial<Session>) => void
|
|
66
|
+
updateTheme: (theme: WebchatTheme, themeUpdates?: WebchatTheme) => void
|
|
67
|
+
updateTyping: (typing: boolean) => void
|
|
68
|
+
updateWebview: (webview: Webview, params: Record<string, string>) => void
|
|
69
|
+
removeReplies: () => void
|
|
70
|
+
removeWebview: () => void
|
|
71
|
+
webchatState: WebchatState
|
|
72
|
+
webchatContainerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
73
|
+
headerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
74
|
+
chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
|
|
75
|
+
scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
|
|
76
|
+
repliesRef: React.MutableRefObject<HTMLDivElement | null>
|
|
77
|
+
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function useWebchat(theme?: WebchatTheme): UseWebchat {
|
|
81
|
+
const initialTheme = theme || defaultTheme
|
|
82
|
+
const webchatInitialState = getWebchatInitialState(initialTheme)
|
|
83
|
+
|
|
50
84
|
const [webchatState, webchatDispatch] = useReducer(
|
|
51
85
|
webchatReducer,
|
|
52
86
|
webchatInitialState
|
|
53
87
|
)
|
|
54
88
|
|
|
55
|
-
const
|
|
89
|
+
const webchatContainerRef = useRef<HTMLDivElement | null>(null)
|
|
56
90
|
const chatAreaRef = useRef<HTMLDivElement | null>(null)
|
|
57
91
|
const inputPanelRef = useRef<HTMLDivElement | null>(null)
|
|
58
92
|
const headerRef = useRef<HTMLDivElement | null>(null)
|
|
@@ -71,9 +105,12 @@ export function useWebchat() {
|
|
|
71
105
|
const updateMessage = (message: WebchatMessage) =>
|
|
72
106
|
webchatDispatch({ type: WebchatAction.UPDATE_MESSAGE, payload: message })
|
|
73
107
|
|
|
74
|
-
const updateReplies = replies =>
|
|
108
|
+
const updateReplies = (replies: (typeof Reply)[]) =>
|
|
75
109
|
webchatDispatch({ type: WebchatAction.UPDATE_REPLIES, payload: replies })
|
|
76
110
|
|
|
111
|
+
const removeReplies = () =>
|
|
112
|
+
webchatDispatch({ type: WebchatAction.REMOVE_REPLIES, payload: [] })
|
|
113
|
+
|
|
77
114
|
const updateLatestInput = (input: ClientInput) =>
|
|
78
115
|
webchatDispatch({ type: WebchatAction.UPDATE_LATEST_INPUT, payload: input })
|
|
79
116
|
|
|
@@ -86,7 +123,12 @@ export function useWebchat() {
|
|
|
86
123
|
payload: { webview, webviewParams: params },
|
|
87
124
|
})
|
|
88
125
|
|
|
89
|
-
const
|
|
126
|
+
const removeWebview = () =>
|
|
127
|
+
webchatDispatch({
|
|
128
|
+
type: WebchatAction.REMOVE_WEBVIEW,
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
const updateSession = (session: Partial<Session>) => {
|
|
90
132
|
webchatDispatch({
|
|
91
133
|
type: WebchatAction.UPDATE_SESSION,
|
|
92
134
|
payload: session,
|
|
@@ -105,7 +147,7 @@ export function useWebchat() {
|
|
|
105
147
|
payload: handoff,
|
|
106
148
|
})
|
|
107
149
|
|
|
108
|
-
const updateTheme = (theme:
|
|
150
|
+
const updateTheme = (theme: WebchatTheme, themeUpdates?: WebchatTheme) => {
|
|
109
151
|
const payload =
|
|
110
152
|
themeUpdates !== undefined ? { theme, themeUpdates } : { theme }
|
|
111
153
|
webchatDispatch({
|
|
@@ -151,7 +193,7 @@ export function useWebchat() {
|
|
|
151
193
|
payload: toggle,
|
|
152
194
|
})
|
|
153
195
|
|
|
154
|
-
const setError = (error
|
|
196
|
+
const setError = (error?: ErrorMessage) =>
|
|
155
197
|
webchatDispatch({
|
|
156
198
|
type: WebchatAction.SET_ERROR,
|
|
157
199
|
payload: error,
|
|
@@ -176,7 +218,7 @@ export function useWebchat() {
|
|
|
176
218
|
})
|
|
177
219
|
}
|
|
178
220
|
|
|
179
|
-
const setCurrentAttachment = (attachment
|
|
221
|
+
const setCurrentAttachment = (attachment?: File) => {
|
|
180
222
|
webchatDispatch({
|
|
181
223
|
type: WebchatAction.SET_CURRENT_ATTACHMENT,
|
|
182
224
|
payload: attachment,
|
|
@@ -196,6 +238,13 @@ export function useWebchat() {
|
|
|
196
238
|
})
|
|
197
239
|
}
|
|
198
240
|
|
|
241
|
+
const setIsInputFocused = (isInputFocused: boolean) => {
|
|
242
|
+
webchatDispatch({
|
|
243
|
+
type: WebchatAction.SET_IS_INPUT_FOCUSED,
|
|
244
|
+
payload: isInputFocused,
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
|
|
199
248
|
return {
|
|
200
249
|
addMessage,
|
|
201
250
|
addMessageComponent,
|
|
@@ -204,6 +253,7 @@ export function useWebchat() {
|
|
|
204
253
|
resetUnreadMessages,
|
|
205
254
|
setCurrentAttachment,
|
|
206
255
|
setError,
|
|
256
|
+
setIsInputFocused,
|
|
207
257
|
setLastMessageVisible,
|
|
208
258
|
setOnline,
|
|
209
259
|
toggleCoverComponent,
|
|
@@ -221,9 +271,10 @@ export function useWebchat() {
|
|
|
221
271
|
updateTheme,
|
|
222
272
|
updateTyping,
|
|
223
273
|
updateWebview,
|
|
224
|
-
|
|
274
|
+
removeReplies,
|
|
275
|
+
removeWebview,
|
|
225
276
|
webchatState,
|
|
226
|
-
|
|
277
|
+
webchatContainerRef,
|
|
227
278
|
headerRef,
|
|
228
279
|
chatAreaRef,
|
|
229
280
|
scrollableMessagesListRef,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebchatAction } from './actions'
|
|
2
|
-
import { WebchatState } from './index-types'
|
|
3
2
|
import { messagesReducer } from './messages-reducer'
|
|
3
|
+
import { WebchatState } from './types'
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line complexity
|
|
6
6
|
export function webchatReducer(
|
|
@@ -10,6 +10,8 @@ export function webchatReducer(
|
|
|
10
10
|
switch (action.type) {
|
|
11
11
|
case WebchatAction.UPDATE_WEBVIEW:
|
|
12
12
|
return { ...state, ...action.payload }
|
|
13
|
+
case WebchatAction.REMOVE_WEBVIEW:
|
|
14
|
+
return { ...state, webview: null, webviewParams: null }
|
|
13
15
|
case WebchatAction.UPDATE_SESSION:
|
|
14
16
|
return { ...state, session: { ...action.payload } }
|
|
15
17
|
case WebchatAction.UPDATE_TYPING:
|
|
@@ -48,6 +50,8 @@ export function webchatReducer(
|
|
|
48
50
|
return { ...state, lastRoutePath: action.payload }
|
|
49
51
|
case WebchatAction.SET_CURRENT_ATTACHMENT:
|
|
50
52
|
return { ...state, currentAttachment: action.payload }
|
|
53
|
+
case WebchatAction.SET_IS_INPUT_FOCUSED:
|
|
54
|
+
return { ...state, isInputFocused: action.payload }
|
|
51
55
|
default:
|
|
52
56
|
return messagesReducer(state, action)
|
|
53
57
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WEBCHAT } from '../../constants'
|
|
4
|
+
import { WebchatContext } from '../context'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
component: any
|
|
8
|
+
componentProps: any
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const CoverComponent = ({ component, componentProps }: Props) => {
|
|
12
|
+
const { getThemeProperty, toggleCoverComponent, webchatState } =
|
|
13
|
+
useContext(WebchatContext)
|
|
14
|
+
|
|
15
|
+
const Cover = component
|
|
16
|
+
|
|
17
|
+
const coverComponentProps = getThemeProperty(
|
|
18
|
+
WEBCHAT.CUSTOM_PROPERTIES.coverComponentProps,
|
|
19
|
+
componentProps
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const closeCoverComponent = () => {
|
|
23
|
+
toggleCoverComponent(false)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!Cover || !webchatState.isCoverComponentOpen) {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return <Cover closeComponent={closeCoverComponent} {...coverComponentProps} />
|
|
31
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { ROLES, WEBCHAT } from '../../constants'
|
|
4
|
+
import { Scale } from '../../shared/styles'
|
|
5
|
+
import { resolveImage } from '../../util/environment'
|
|
6
|
+
import { ConditionalWrapper } from '../../util/react'
|
|
7
|
+
import { WebchatContext } from '../../webchat/context'
|
|
8
|
+
import {
|
|
9
|
+
CloseHeader,
|
|
10
|
+
HeaderContainer,
|
|
11
|
+
ImageContainer,
|
|
12
|
+
Subtitle,
|
|
13
|
+
TextContainer,
|
|
14
|
+
Title,
|
|
15
|
+
} from './styles'
|
|
16
|
+
|
|
17
|
+
export const DefaultHeader = () => {
|
|
18
|
+
const { getThemeProperty, toggleWebchat } = useContext(WebchatContext)
|
|
19
|
+
|
|
20
|
+
const animationsEnabled = getThemeProperty(
|
|
21
|
+
WEBCHAT.CUSTOM_PROPERTIES.enableAnimations
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const headerImage = getThemeProperty(
|
|
25
|
+
WEBCHAT.CUSTOM_PROPERTIES.headerImage,
|
|
26
|
+
getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.brandImage)
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const headerTitle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.headerTitle)
|
|
30
|
+
|
|
31
|
+
const headerSubtitle = getThemeProperty(
|
|
32
|
+
WEBCHAT.CUSTOM_PROPERTIES.headerSubtitle
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const handleCloseWebchat = () => {
|
|
36
|
+
toggleWebchat(false)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const color = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.brandColor)
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<HeaderContainer
|
|
43
|
+
role={ROLES.HEADER}
|
|
44
|
+
color={color}
|
|
45
|
+
style={{ ...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.headerStyle) }}
|
|
46
|
+
>
|
|
47
|
+
{headerImage && (
|
|
48
|
+
<ImageContainer>
|
|
49
|
+
<img src={resolveImage(headerImage)} />
|
|
50
|
+
</ImageContainer>
|
|
51
|
+
)}
|
|
52
|
+
<TextContainer>
|
|
53
|
+
<Title>{headerTitle}</Title>
|
|
54
|
+
{headerSubtitle ? <Subtitle>{headerSubtitle}</Subtitle> : null}
|
|
55
|
+
</TextContainer>
|
|
56
|
+
<ConditionalWrapper
|
|
57
|
+
condition={animationsEnabled}
|
|
58
|
+
wrapper={children => <Scale>{children}</Scale>}
|
|
59
|
+
>
|
|
60
|
+
<CloseHeader onClick={handleCloseWebchat}>⨯</CloseHeader>
|
|
61
|
+
</ConditionalWrapper>
|
|
62
|
+
</HeaderContainer>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { ForwardedRef, forwardRef, useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WEBCHAT } from '../../constants'
|
|
4
|
+
import { WebchatContext } from '../../webchat/context'
|
|
5
|
+
import { BotonicContainerId } from '../constants'
|
|
6
|
+
import { DefaultHeader } from './default-header'
|
|
7
|
+
import { StyledWebchatHeader } from './styles'
|
|
8
|
+
|
|
9
|
+
export const WebchatHeader = forwardRef(
|
|
10
|
+
(_, ref: ForwardedRef<HTMLDivElement>) => {
|
|
11
|
+
const { getThemeProperty, toggleWebchat } = useContext(WebchatContext)
|
|
12
|
+
|
|
13
|
+
const handleCloseWebchat = () => {
|
|
14
|
+
toggleWebchat(false)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const CustomHeader = getThemeProperty(
|
|
18
|
+
WEBCHAT.CUSTOM_PROPERTIES.customHeader
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
if (CustomHeader) {
|
|
22
|
+
return (
|
|
23
|
+
<div id={BotonicContainerId.Header} ref={ref}>
|
|
24
|
+
<CustomHeader onCloseClick={handleCloseWebchat} />
|
|
25
|
+
</div>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<StyledWebchatHeader id={BotonicContainerId.Header} ref={ref}>
|
|
31
|
+
<DefaultHeader />
|
|
32
|
+
</StyledWebchatHeader>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
WebchatHeader.displayName = 'WebchatHeader'
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
|
|
3
|
+
import { COLORS } from '../../constants'
|
|
4
|
+
|
|
5
|
+
export const HeaderContainer = styled.div`
|
|
6
|
+
display: flex;
|
|
7
|
+
background: linear-gradient(
|
|
8
|
+
90deg,
|
|
9
|
+
${COLORS.BLEACHED_CEDAR_PURPLE} 0%,
|
|
10
|
+
${props => props.color} 100%
|
|
11
|
+
);
|
|
12
|
+
border-radius: ${props => props.theme.header?.style?.borderRadius};
|
|
13
|
+
z-index: 2;
|
|
14
|
+
height: inherit;
|
|
15
|
+
|
|
16
|
+
@media (max-width: ${props => props.theme.mobileBreakpoint}px) {
|
|
17
|
+
border-radius: ${props => props.theme.header?.mobileStyle?.borderRadius};
|
|
18
|
+
}
|
|
19
|
+
`
|
|
20
|
+
|
|
21
|
+
export const ImageContainer = styled.div`
|
|
22
|
+
padding: 10px;
|
|
23
|
+
align-items: center;
|
|
24
|
+
|
|
25
|
+
img {
|
|
26
|
+
width: 32px;
|
|
27
|
+
border-radius: 50%;
|
|
28
|
+
}
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
export const TextContainer = styled.div`
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
flex: 1 1 auto;
|
|
36
|
+
`
|
|
37
|
+
|
|
38
|
+
export const Title = styled.div`
|
|
39
|
+
display: flex;
|
|
40
|
+
font-family: inherit;
|
|
41
|
+
font-size: 15px;
|
|
42
|
+
font-weight: bold;
|
|
43
|
+
color: ${COLORS.SOLID_WHITE};
|
|
44
|
+
`
|
|
45
|
+
|
|
46
|
+
export const Subtitle = styled.div`
|
|
47
|
+
display: flex;
|
|
48
|
+
font-family: inherit;
|
|
49
|
+
font-size: 11px;
|
|
50
|
+
color: ${COLORS.SOLID_WHITE};
|
|
51
|
+
`
|
|
52
|
+
|
|
53
|
+
export const CloseHeader = styled.div`
|
|
54
|
+
padding: 0px 16px;
|
|
55
|
+
cursor: pointer;
|
|
56
|
+
color: ${COLORS.SOLID_WHITE};
|
|
57
|
+
font-family: inherit;
|
|
58
|
+
font-size: 36px;
|
|
59
|
+
`
|
|
60
|
+
|
|
61
|
+
export const StyledWebchatHeader = styled.div`
|
|
62
|
+
border-radius: 8px 8px 0px 0px;
|
|
63
|
+
box-shadow: ${COLORS.PIGEON_POST_BLUE_ALPHA_0_5} 0px 2px 5px;
|
|
64
|
+
height: 55px;
|
|
65
|
+
flex: none;
|
|
66
|
+
`
|