@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
|
@@ -6,6 +6,5 @@ export { useScrollToBottom } from './use-scroll-to-bottom'
|
|
|
6
6
|
export { useScrollbarController } from './use-scrollbar-controller'
|
|
7
7
|
export { useTyping } from './use-typing'
|
|
8
8
|
export { useVirtualKeyboardDetection } from './use-virtual-keyboard-detection'
|
|
9
|
-
export { useWebchat, webchatInitialState } from './use-webchat'
|
|
10
9
|
export { useWebchatDimensions } from './use-webchat-dimensions'
|
|
11
10
|
export { useWebchatResizer } from './use-webchat-resizer'
|
|
@@ -3,11 +3,17 @@ import {
|
|
|
3
3
|
getWebchatElement,
|
|
4
4
|
} from '../../util/dom'
|
|
5
5
|
|
|
6
|
+
interface UseScrollToBottom {
|
|
7
|
+
host: any
|
|
8
|
+
behavior?: ScrollBehavior
|
|
9
|
+
timeout?: number
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
export const useScrollToBottom = ({
|
|
7
13
|
host,
|
|
8
14
|
behavior = 'smooth',
|
|
9
15
|
timeout = 200,
|
|
10
|
-
}) => {
|
|
16
|
+
}: UseScrollToBottom) => {
|
|
11
17
|
const scrollToBottom = () => {
|
|
12
18
|
const webchatElement = getWebchatElement(host)
|
|
13
19
|
if (!webchatElement) return
|
|
@@ -17,7 +23,7 @@ export const useScrollToBottom = ({
|
|
|
17
23
|
setTimeout(() => {
|
|
18
24
|
scrollableMessagesListElement.scrollTo({
|
|
19
25
|
top: scrollableMessagesListElement.scrollHeight,
|
|
20
|
-
behavior: behavior
|
|
26
|
+
behavior: behavior,
|
|
21
27
|
})
|
|
22
28
|
}, timeout)
|
|
23
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext, useEffect } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebchatContext } from '../../
|
|
3
|
+
import { WebchatContext } from '../../webchat/context'
|
|
4
4
|
import { DEVICES, isMobileDevice } from '../devices'
|
|
5
5
|
|
|
6
6
|
// TODO: Investigate why when we have some messages, scroll actions are not disabled properly
|
|
@@ -25,12 +25,16 @@ const stopAtScrollLimit = element => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export const useScrollbarController = (currentDevice, host) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
28
|
+
const {
|
|
29
|
+
webchatContainerRef,
|
|
30
|
+
chatAreaRef,
|
|
31
|
+
repliesRef,
|
|
32
|
+
scrollableMessagesListRef,
|
|
33
|
+
} = useContext(WebchatContext)
|
|
30
34
|
|
|
31
35
|
const hasScrollbar = () => {
|
|
32
36
|
if (chatAreaRef.current && scrollableMessagesListRef.current) {
|
|
33
|
-
if (!repliesRef) {
|
|
37
|
+
if (!repliesRef?.current) {
|
|
34
38
|
return (
|
|
35
39
|
scrollableMessagesListRef.current?.scrollHeight >
|
|
36
40
|
chatAreaRef.current?.clientHeight
|
|
@@ -70,25 +74,25 @@ export const useScrollbarController = (currentDevice, host) => {
|
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
const toggleOnTouchMoveEvents = () => {
|
|
73
|
-
if (
|
|
77
|
+
if (webchatContainerRef.current && scrollableMessagesListRef.current) {
|
|
74
78
|
if (hasScrollbar()) {
|
|
75
79
|
scrollableMessagesListRef.current.style.touchAction = 'auto'
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
webchatContainerRef.current.style.touchAction = 'auto'
|
|
81
|
+
webchatContainerRef.current.ontouchmove = null
|
|
82
|
+
webchatContainerRef.current.ontouchstart = null
|
|
79
83
|
return
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
scrollableMessagesListRef.current.style.touchAction = 'none'
|
|
83
|
-
|
|
87
|
+
webchatContainerRef.current.style.touchAction = 'none'
|
|
84
88
|
}
|
|
85
|
-
if (
|
|
86
|
-
|
|
89
|
+
if (webchatContainerRef.current) {
|
|
90
|
+
webchatContainerRef.current.ontouchstart = e => {
|
|
87
91
|
if (e.target === e.currentTarget) {
|
|
88
92
|
e.preventDefault()
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
|
-
|
|
95
|
+
webchatContainerRef.current.ontouchmove = e => {
|
|
92
96
|
if (e.target === e.currentTarget) {
|
|
93
97
|
e.preventDefault()
|
|
94
98
|
}
|
|
@@ -122,22 +126,23 @@ export const useScrollbarController = (currentDevice, host) => {
|
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
const handleScrollEvents = () => {
|
|
125
|
-
if (
|
|
129
|
+
if (webchatContainerRef.current) {
|
|
126
130
|
if (isMobileDevice()) {
|
|
127
131
|
if (currentDevice !== DEVICES.MOBILE.IPHONE) return
|
|
128
132
|
|
|
129
133
|
limitScrollBoundaries()
|
|
130
134
|
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
webchatContainerRef.current.ontouchstart = handleOnTouchMoveEvents
|
|
136
|
+
webchatContainerRef.current.ontouchmove = handleOnTouchMoveEvents
|
|
133
137
|
} else {
|
|
134
|
-
|
|
138
|
+
webchatContainerRef.current.onmouseover = e =>
|
|
139
|
+
handleOnMouseOverEvents(e)
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
useEffect(() => {
|
|
140
|
-
const webchat =
|
|
145
|
+
const webchat = webchatContainerRef.current
|
|
141
146
|
|
|
142
147
|
handleScrollEvents()
|
|
143
148
|
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useCallback, useContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebchatContext } from '../../
|
|
3
|
+
import { WebchatContext } from '../../webchat/context'
|
|
4
4
|
|
|
5
5
|
export const useWebchatDimensions = () => {
|
|
6
6
|
const {
|
|
7
|
-
|
|
7
|
+
webchatContainerRef,
|
|
8
8
|
headerRef,
|
|
9
9
|
inputPanelRef,
|
|
10
10
|
webchatState: { isWebchatOpen },
|
|
11
11
|
} = useContext(WebchatContext)
|
|
12
12
|
|
|
13
13
|
const calculateResizedPercentualWebchatHeight = useCallback(() => {
|
|
14
|
-
const webchatElement =
|
|
14
|
+
const webchatElement = webchatContainerRef.current
|
|
15
15
|
if (!isWebchatOpen || !webchatElement) return 0
|
|
16
16
|
const webchatHeight = webchatElement.clientHeight || 0
|
|
17
17
|
const keyboardOffset =
|
|
@@ -24,7 +24,7 @@ export const useWebchatDimensions = () => {
|
|
|
24
24
|
}, [isWebchatOpen])
|
|
25
25
|
|
|
26
26
|
const calculateResizedPxChatAreaHeight = useCallback(() => {
|
|
27
|
-
const webchatElement =
|
|
27
|
+
const webchatElement = webchatContainerRef.current
|
|
28
28
|
const headerElement = headerRef.current
|
|
29
29
|
const inputPanelElement = inputPanelRef.current
|
|
30
30
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { useContext } from 'react'
|
|
2
2
|
|
|
3
|
-
import { WebchatContext } from '../../
|
|
3
|
+
import { WebchatContext } from '../../webchat/context'
|
|
4
4
|
import { useWebchatDimensions } from './use-webchat-dimensions'
|
|
5
5
|
|
|
6
6
|
export const useWebchatResizer = () => {
|
|
7
|
-
const {
|
|
7
|
+
const { webchatContainerRef, chatAreaRef, inputPanelRef, headerRef } =
|
|
8
8
|
useContext(WebchatContext)
|
|
9
9
|
|
|
10
10
|
const {
|
|
@@ -14,24 +14,24 @@ export const useWebchatResizer = () => {
|
|
|
14
14
|
|
|
15
15
|
const handleKeyboardShown = () => {
|
|
16
16
|
if (
|
|
17
|
-
|
|
17
|
+
webchatContainerRef.current &&
|
|
18
18
|
chatAreaRef.current &&
|
|
19
19
|
headerRef.current &&
|
|
20
20
|
inputPanelRef.current
|
|
21
21
|
) {
|
|
22
|
-
|
|
22
|
+
webchatContainerRef.current.style.height = `${calculateResizedPercentualWebchatHeight()}%`
|
|
23
23
|
chatAreaRef.current.style.height = `${calculateResizedPxChatAreaHeight()}px`
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const handleKeyboardHidden = () => {
|
|
28
28
|
if (
|
|
29
|
-
|
|
29
|
+
webchatContainerRef.current &&
|
|
30
30
|
chatAreaRef.current &&
|
|
31
31
|
inputPanelRef.current &&
|
|
32
32
|
headerRef.current
|
|
33
33
|
) {
|
|
34
|
-
|
|
34
|
+
webchatContainerRef.current.style.height = '100%'
|
|
35
35
|
chatAreaRef.current.style.height = `${calculateResizedPxChatAreaHeight()}px`
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,69 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { RefObject } from 'react'
|
|
1
|
+
import { WebchatArgs } from '../index-types'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface WebchatStateTheme {
|
|
7
|
-
headerTitle: string
|
|
8
|
-
brandColor: string
|
|
9
|
-
brandImage: string
|
|
10
|
-
triggerButtonImage: undefined
|
|
11
|
-
textPlaceholder: string
|
|
12
|
-
style: {
|
|
13
|
-
fontFamily: string
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ErrorMessage {
|
|
18
|
-
message?: string
|
|
19
|
-
}
|
|
20
|
-
export interface DevSettings {
|
|
21
|
-
keepSessionOnReload?: boolean
|
|
22
|
-
showSessionView?: boolean
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface WebchatState {
|
|
26
|
-
width: number
|
|
27
|
-
height: number
|
|
28
|
-
messagesJSON: any[]
|
|
29
|
-
messagesComponents: any[]
|
|
30
|
-
replies: any[]
|
|
31
|
-
latestInput: Partial<CoreInput>
|
|
32
|
-
typing: boolean
|
|
33
|
-
webview: Webview | null
|
|
34
|
-
webviewParams: null
|
|
35
|
-
session: Partial<CoreSession>
|
|
36
|
-
lastRoutePath: string | null
|
|
37
|
-
handoff: boolean
|
|
38
|
-
theme: WebchatStateTheme
|
|
39
|
-
themeUpdates: Partial<WebchatStateTheme>
|
|
40
|
-
error: ErrorMessage
|
|
41
|
-
online: boolean
|
|
42
|
-
devSettings: DevSettings
|
|
43
|
-
isWebchatOpen: boolean
|
|
44
|
-
isEmojiPickerOpen: boolean
|
|
45
|
-
isPersistentMenuOpen: boolean
|
|
46
|
-
isCoverComponentOpen: boolean
|
|
47
|
-
isCustomComponentRendered: boolean
|
|
48
|
-
lastMessageUpdate?: string
|
|
49
|
-
currentAttachment?: File
|
|
50
|
-
numUnreadMessages: number
|
|
51
|
-
isLastMessageVisible: boolean
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// export interface WebchatProps extends WebchatArgs {
|
|
55
|
-
export interface WebchatProps {
|
|
56
|
-
ref: RefObject<any>
|
|
57
|
-
onConnectionRegained?: () => Promise<void>
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export interface WebchatDevProps extends WebchatProps {
|
|
3
|
+
export interface WebchatDevProps extends WebchatArgs {
|
|
61
4
|
initialDevSettings?: {
|
|
62
5
|
keepSessionOnReload?: boolean
|
|
63
6
|
showSessionView?: boolean
|
|
64
7
|
}
|
|
65
8
|
}
|
|
66
|
-
|
|
67
|
-
export interface CoverComponentProps {
|
|
68
|
-
closeComponent: () => void
|
|
69
|
-
}
|
package/src/webchat/index.ts
CHANGED
|
@@ -1,38 +1,27 @@
|
|
|
1
1
|
import React, { useContext, useRef } from 'react'
|
|
2
2
|
|
|
3
3
|
import AttachmentIcon from '../../assets/attachment-icon.svg'
|
|
4
|
-
import { ROLES
|
|
5
|
-
import { WebchatContext } from '../../
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
|
+
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
9
9
|
interface AttachmentProps {
|
|
10
10
|
accept: string
|
|
11
|
-
enableAttachments: boolean
|
|
12
11
|
onChange: (event: any) => void
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export const Attachment = ({
|
|
16
|
-
|
|
17
|
-
enableAttachments,
|
|
18
|
-
onChange,
|
|
19
|
-
}: AttachmentProps) => {
|
|
20
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
14
|
+
export const Attachment = ({ accept, onChange }: AttachmentProps) => {
|
|
15
|
+
const { webchatState } = useContext(WebchatContext)
|
|
21
16
|
|
|
22
17
|
const fileInputRef = useRef<HTMLInputElement | null>(null)
|
|
23
18
|
|
|
24
|
-
const CustomAttachments =
|
|
25
|
-
WEBCHAT.CUSTOM_PROPERTIES.customAttachments,
|
|
26
|
-
undefined
|
|
27
|
-
)
|
|
19
|
+
const CustomAttachments = webchatState.theme.userInput?.attachments?.custom
|
|
28
20
|
|
|
29
21
|
const isAttachmentsEnabled = () => {
|
|
30
22
|
const hasCustomAttachments = !!CustomAttachments
|
|
31
23
|
return (
|
|
32
|
-
|
|
33
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableAttachments,
|
|
34
|
-
enableAttachments
|
|
35
|
-
) ?? hasCustomAttachments
|
|
24
|
+
webchatState.theme.userInput?.attachments?.enable ?? hasCustomAttachments
|
|
36
25
|
)
|
|
37
26
|
}
|
|
38
27
|
const attachmentsEnabled = isAttachmentsEnabled()
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import LogoEmoji from '../../assets/emojiButton.svg'
|
|
4
|
-
import { ROLES
|
|
5
|
-
import { WebchatContext } from '../../
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
|
+
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
9
9
|
interface EmojiPickerProps {
|
|
10
|
-
enableEmojiPicker: boolean
|
|
11
10
|
onClick: () => void
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export const EmojiPicker = ({
|
|
15
|
-
|
|
16
|
-
onClick,
|
|
17
|
-
}: EmojiPickerProps) => {
|
|
18
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
13
|
+
export const EmojiPicker = ({ onClick }: EmojiPickerProps) => {
|
|
14
|
+
const { webchatState } = useContext(WebchatContext)
|
|
19
15
|
|
|
20
|
-
const CustomEmojiPicker =
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.customEmojiPicker,
|
|
22
|
-
undefined
|
|
23
|
-
)
|
|
16
|
+
const CustomEmojiPicker = webchatState.theme.userInput?.emojiPicker?.custom
|
|
24
17
|
|
|
25
18
|
const isEmojiPickerEnabled = () => {
|
|
26
19
|
const hasCustomEmojiPicker = !!CustomEmojiPicker
|
|
27
20
|
return (
|
|
28
|
-
|
|
29
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableEmojiPicker,
|
|
30
|
-
enableEmojiPicker
|
|
31
|
-
) ?? hasCustomEmojiPicker
|
|
21
|
+
webchatState.theme.userInput?.emojiPicker?.enable ?? hasCustomEmojiPicker
|
|
32
22
|
)
|
|
33
23
|
}
|
|
34
24
|
const emojiPickerEnabled = isEmojiPickerEnabled()
|
|
@@ -3,8 +3,8 @@ import React, { useContext } from 'react'
|
|
|
3
3
|
import { v7 as uuidv7 } from 'uuid'
|
|
4
4
|
|
|
5
5
|
import { WEBCHAT } from '../../constants'
|
|
6
|
-
import { WebchatContext } from '../../contexts'
|
|
7
6
|
import { getFullMimeWhitelist } from '../../message-utils'
|
|
7
|
+
import { WebchatContext } from '../../webchat/context'
|
|
8
8
|
import { BotonicContainerId } from '../constants'
|
|
9
9
|
import { Attachment } from './attachment'
|
|
10
10
|
import { EmojiPicker } from './emoji-picker'
|
|
@@ -15,19 +15,13 @@ import { UserInputContainer } from './styles'
|
|
|
15
15
|
import { Textarea } from './textarea'
|
|
16
16
|
|
|
17
17
|
interface InputPanelProps {
|
|
18
|
-
persistentMenu: any
|
|
19
|
-
enableEmojiPicker: boolean
|
|
20
|
-
enableAttachments: boolean
|
|
21
18
|
handleAttachment: (event: any) => void
|
|
22
|
-
textareaRef: React.MutableRefObject<HTMLTextAreaElement>
|
|
19
|
+
textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
|
|
23
20
|
host: HTMLElement
|
|
24
21
|
onUserInput?: (event: any) => Promise<void>
|
|
25
22
|
}
|
|
26
23
|
|
|
27
24
|
export const InputPanel = ({
|
|
28
|
-
persistentMenu,
|
|
29
|
-
enableEmojiPicker,
|
|
30
|
-
enableAttachments,
|
|
31
25
|
handleAttachment,
|
|
32
26
|
textareaRef,
|
|
33
27
|
host,
|
|
@@ -43,6 +37,8 @@ export const InputPanel = ({
|
|
|
43
37
|
} = useContext(WebchatContext)
|
|
44
38
|
|
|
45
39
|
const handleSelectedEmoji = event => {
|
|
40
|
+
if (!textareaRef.current) return
|
|
41
|
+
|
|
46
42
|
textareaRef.current.value += event.emoji
|
|
47
43
|
textareaRef.current.focus()
|
|
48
44
|
}
|
|
@@ -56,7 +52,9 @@ export const InputPanel = ({
|
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
const sendTextAreaText = async () => {
|
|
59
|
-
|
|
55
|
+
if (!textareaRef.current) return
|
|
56
|
+
|
|
57
|
+
await sendText(textareaRef.current?.value)
|
|
60
58
|
textareaRef.current.value = ''
|
|
61
59
|
}
|
|
62
60
|
|
|
@@ -92,23 +90,18 @@ export const InputPanel = ({
|
|
|
92
90
|
/>
|
|
93
91
|
)}
|
|
94
92
|
|
|
95
|
-
<PersistentMenu onClick={handleMenu}
|
|
93
|
+
<PersistentMenu onClick={handleMenu} />
|
|
96
94
|
|
|
97
95
|
<Textarea
|
|
98
96
|
host={host}
|
|
99
|
-
persistentMenu={persistentMenu}
|
|
100
97
|
textareaRef={textareaRef}
|
|
101
98
|
sendChatEvent={sendChatEvent}
|
|
102
99
|
sendTextAreaText={sendTextAreaText}
|
|
103
100
|
/>
|
|
104
101
|
|
|
105
|
-
<EmojiPicker
|
|
106
|
-
enableEmojiPicker={enableEmojiPicker}
|
|
107
|
-
onClick={handleEmojiClick}
|
|
108
|
-
/>
|
|
102
|
+
<EmojiPicker onClick={handleEmojiClick} />
|
|
109
103
|
|
|
110
104
|
<Attachment
|
|
111
|
-
enableAttachments={enableAttachments}
|
|
112
105
|
onChange={handleAttachment}
|
|
113
106
|
accept={getFullMimeWhitelist().join(',')}
|
|
114
107
|
/>
|
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import LogoMenu from '../../assets/menuButton.svg'
|
|
4
|
-
import { ROLES
|
|
5
|
-
import { WebchatContext } from '../../
|
|
4
|
+
import { ROLES } from '../../constants'
|
|
5
|
+
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
9
9
|
interface PersistentMenuProps {
|
|
10
|
-
persistentMenu: any
|
|
11
10
|
onClick: () => void
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export const PersistentMenu = ({
|
|
15
|
-
|
|
16
|
-
persistentMenu,
|
|
17
|
-
}: PersistentMenuProps) => {
|
|
18
|
-
const { getThemeProperty } = useContext(WebchatContext)
|
|
13
|
+
export const PersistentMenu = ({ onClick }: PersistentMenuProps) => {
|
|
14
|
+
const { webchatState } = useContext(WebchatContext)
|
|
19
15
|
|
|
20
|
-
const persistentMenuOptions =
|
|
21
|
-
WEBCHAT.CUSTOM_PROPERTIES.persistentMenu,
|
|
22
|
-
persistentMenu
|
|
23
|
-
)
|
|
16
|
+
const persistentMenuOptions = webchatState.theme.userInput?.persistentMenu
|
|
24
17
|
|
|
25
|
-
const CustomMenuButton =
|
|
26
|
-
WEBCHAT.CUSTOM_PROPERTIES.customMenuButton,
|
|
27
|
-
undefined
|
|
28
|
-
)
|
|
18
|
+
const CustomMenuButton = webchatState.theme.userInput?.menuButton?.custom
|
|
29
19
|
|
|
30
20
|
return (
|
|
31
21
|
<>
|
|
@@ -2,7 +2,7 @@ import React, { useContext } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import SendButtonIcon from '../../assets/send-button.svg'
|
|
4
4
|
import { ROLES, WEBCHAT } from '../../constants'
|
|
5
|
-
import { WebchatContext } from '../../
|
|
5
|
+
import { WebchatContext } from '../../webchat/context'
|
|
6
6
|
import { Icon } from '../components/common'
|
|
7
7
|
import { ConditionalAnimation } from '../components/conditional-animation'
|
|
8
8
|
|
|
@@ -11,17 +11,11 @@ interface SendButtonProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export const SendButton = ({ onClick }: SendButtonProps) => {
|
|
14
|
-
const {
|
|
14
|
+
const { webchatState } = useContext(WebchatContext)
|
|
15
15
|
|
|
16
|
-
const sendButtonEnabled =
|
|
17
|
-
WEBCHAT.CUSTOM_PROPERTIES.enableSendButton,
|
|
18
|
-
true
|
|
19
|
-
)
|
|
16
|
+
const sendButtonEnabled = webchatState.theme.userInput?.sendButton?.enable
|
|
20
17
|
|
|
21
|
-
const CustomSendButton =
|
|
22
|
-
WEBCHAT.CUSTOM_PROPERTIES.customSendButton,
|
|
23
|
-
undefined
|
|
24
|
-
)
|
|
18
|
+
const CustomSendButton = webchatState.theme.userInput?.sendButton?.custom
|
|
25
19
|
|
|
26
20
|
return (
|
|
27
21
|
<>
|
|
@@ -1,39 +1,37 @@
|
|
|
1
1
|
import React, { useContext } from 'react'
|
|
2
2
|
import TextareaAutosize from 'react-textarea-autosize'
|
|
3
3
|
|
|
4
|
-
import { PersistentMenuTheme } from '../../components/index-types'
|
|
5
4
|
import { WEBCHAT } from '../../constants'
|
|
6
|
-
import { WebchatContext } from '../../contexts'
|
|
7
5
|
import { Typing } from '../../index-types'
|
|
6
|
+
import { WebchatContext } from '../../webchat/context'
|
|
8
7
|
import { useDeviceAdapter } from '../hooks'
|
|
9
8
|
import { TextAreaContainer } from './styles'
|
|
10
9
|
|
|
11
10
|
interface TextareaProps {
|
|
12
11
|
host: HTMLElement
|
|
13
|
-
|
|
14
|
-
textareaRef: React.MutableRefObject<HTMLTextAreaElement>
|
|
12
|
+
textareaRef: React.MutableRefObject<HTMLTextAreaElement | undefined>
|
|
15
13
|
sendChatEvent: (event: string) => Promise<void>
|
|
16
14
|
sendTextAreaText: () => Promise<void>
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
export const Textarea = ({
|
|
20
18
|
host,
|
|
21
|
-
persistentMenu,
|
|
22
19
|
textareaRef,
|
|
23
20
|
sendChatEvent,
|
|
24
21
|
sendTextAreaText,
|
|
25
22
|
}: TextareaProps) => {
|
|
26
|
-
const {
|
|
23
|
+
const { webchatState, setIsInputFocused } = useContext(WebchatContext)
|
|
27
24
|
|
|
28
25
|
useDeviceAdapter(host, webchatState.isWebchatOpen)
|
|
29
26
|
|
|
30
27
|
let isTyping = false
|
|
31
28
|
let typingTimeout
|
|
32
29
|
|
|
33
|
-
const persistentMenuOptions =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const persistentMenuOptions = webchatState.theme.userInput?.persistentMenu
|
|
31
|
+
|
|
32
|
+
const placeholder = webchatState.theme.userInput?.box?.placeholder
|
|
33
|
+
|
|
34
|
+
const userInputBoxStyle = webchatState.theme.userInput?.box?.style
|
|
37
35
|
|
|
38
36
|
const onKeyDown = event => {
|
|
39
37
|
if (event.keyCode === 13 && event.shiftKey === false) {
|
|
@@ -44,6 +42,8 @@ export const Textarea = ({
|
|
|
44
42
|
}
|
|
45
43
|
|
|
46
44
|
const onKeyUp = () => {
|
|
45
|
+
if (!textareaRef.current) return
|
|
46
|
+
|
|
47
47
|
if (textareaRef.current.value === '') {
|
|
48
48
|
stopTyping()
|
|
49
49
|
return
|
|
@@ -71,18 +71,25 @@ export const Textarea = ({
|
|
|
71
71
|
sendChatEvent(Typing.Off)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
const handleFocus = () => {
|
|
75
|
+
setIsInputFocused(true)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const handleBlur = () => {
|
|
79
|
+
setIsInputFocused(false)
|
|
80
|
+
}
|
|
81
|
+
|
|
74
82
|
return (
|
|
75
83
|
<TextAreaContainer>
|
|
76
84
|
<TextareaAutosize
|
|
77
85
|
ref={(ref: HTMLTextAreaElement) => (textareaRef.current = ref)}
|
|
86
|
+
onFocus={handleFocus}
|
|
87
|
+
onBlur={handleBlur}
|
|
78
88
|
name='text'
|
|
79
89
|
maxRows={4}
|
|
80
90
|
wrap='soft'
|
|
81
91
|
maxLength={1000}
|
|
82
|
-
placeholder={
|
|
83
|
-
WEBCHAT.CUSTOM_PROPERTIES.textPlaceholder,
|
|
84
|
-
WEBCHAT.DEFAULTS.PLACEHOLDER
|
|
85
|
-
)}
|
|
92
|
+
placeholder={placeholder}
|
|
86
93
|
autoFocus={false}
|
|
87
94
|
onKeyDown={e => onKeyDown(e)}
|
|
88
95
|
onKeyUp={onKeyUp}
|
|
@@ -98,7 +105,7 @@ export const Textarea = ({
|
|
|
98
105
|
padding: 10,
|
|
99
106
|
paddingLeft: persistentMenuOptions ? 0 : 10,
|
|
100
107
|
fontFamily: 'inherit',
|
|
101
|
-
...
|
|
108
|
+
...userInputBoxStyle,
|
|
102
109
|
}}
|
|
103
110
|
/>
|
|
104
111
|
</TextAreaContainer>
|