@botonic/react 0.31.0-alpha.3 → 0.31.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/audio.d.ts +8 -7
- package/lib/cjs/components/audio.js +7 -4
- package/lib/cjs/components/audio.js.map +1 -1
- package/lib/cjs/components/button.js +3 -4
- package/lib/cjs/components/button.js.map +1 -1
- package/lib/cjs/components/carousel.js +2 -2
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/custom-message.d.ts +16 -12
- package/lib/cjs/components/custom-message.js +3 -9
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/components/document.d.ts +8 -7
- package/lib/cjs/components/document.js +5 -5
- package/lib/cjs/components/document.js.map +1 -1
- package/lib/cjs/components/handoff.js +2 -2
- package/lib/cjs/components/handoff.js.map +1 -1
- package/lib/cjs/components/image.d.ts +8 -7
- package/lib/cjs/components/image.js +5 -5
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +33 -4
- package/lib/cjs/components/message/index.js +2 -1
- package/lib/cjs/components/message/index.js.map +1 -1
- package/lib/cjs/components/message/message-feedback.js +2 -2
- package/lib/cjs/components/message/message-feedback.js.map +1 -1
- package/lib/cjs/components/message/message-footer.js +2 -2
- package/lib/cjs/components/message/message-footer.js.map +1 -1
- package/lib/cjs/components/message/message-image.js +2 -2
- package/lib/cjs/components/message/message-image.js.map +1 -1
- package/lib/cjs/components/message/timestamps.js +2 -2
- package/lib/cjs/components/message/timestamps.js.map +1 -1
- package/lib/cjs/components/reply.d.ts +7 -6
- package/lib/cjs/components/reply.js +10 -6
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/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 +1 -1
- package/lib/cjs/components/webchat-settings.js +2 -2
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/contexts.d.ts +3 -4
- package/lib/cjs/contexts.js +2 -79
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/index-types.d.ts +87 -55
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +1 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/msg-to-botonic.d.ts +1 -1
- package/lib/cjs/msg-to-botonic.js +5 -8
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/util/webchat.d.ts +17 -6
- package/lib/cjs/util/webchat.js +9 -7
- package/lib/cjs/util/webchat.js.map +1 -1
- package/lib/cjs/webchat/chat-area/index.js +3 -3
- package/lib/cjs/webchat/chat-area/index.js.map +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +2 -2
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/opened-persistent-menu.js +2 -2
- package/lib/cjs/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
- package/lib/cjs/webchat/{actions.js → context/actions.js} +3 -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 +74 -0
- package/lib/cjs/webchat/context/types.js +3 -0
- package/lib/cjs/webchat/context/types.js.map +1 -0
- package/lib/cjs/webchat/{hooks → context}/use-webchat.d.ts +18 -19
- package/lib/cjs/webchat/{hooks → context}/use-webchat.js +10 -5
- 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} +2 -0
- package/lib/cjs/webchat/context/webchat-reducer.js.map +1 -0
- package/lib/cjs/webchat/cover-component/index.js +2 -2
- package/lib/cjs/webchat/cover-component/index.js.map +1 -1
- package/lib/cjs/webchat/header/default-header.d.ts +1 -0
- package/lib/cjs/webchat/header/default-header.js +25 -0
- package/lib/cjs/webchat/header/default-header.js.map +1 -0
- package/lib/cjs/webchat/header/index.d.ts +2 -0
- package/lib/cjs/webchat/header/index.js +23 -0
- package/lib/cjs/webchat/header/index.js.map +1 -0
- package/lib/cjs/webchat/header/styles.d.ts +7 -0
- package/lib/cjs/webchat/header/styles.js +59 -0
- package/lib/cjs/webchat/header/styles.js.map +1 -0
- package/lib/cjs/webchat/hooks/index.d.ts +0 -1
- package/lib/cjs/webchat/hooks/index.js +1 -4
- package/lib/cjs/webchat/hooks/index.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-previous.d.ts +1 -1
- package/lib/cjs/webchat/hooks/use-previous.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +3 -3
- 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 +2 -2
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js +2 -2
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +3 -44
- 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 -1
- package/lib/cjs/webchat/input-panel/attachment.js +2 -2
- package/lib/cjs/webchat/input-panel/attachment.js.map +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/emoji-picker.js +2 -2
- package/lib/cjs/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/input-panel/index.d.ts +3 -3
- package/lib/cjs/webchat/input-panel/index.js +8 -3
- package/lib/cjs/webchat/input-panel/index.js.map +1 -1
- package/lib/cjs/webchat/input-panel/persistent-menu.js +2 -2
- package/lib/cjs/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/input-panel/send-button.js +2 -2
- package/lib/cjs/webchat/input-panel/send-button.js.map +1 -1
- package/lib/cjs/webchat/input-panel/textarea.d.ts +1 -1
- package/lib/cjs/webchat/input-panel/textarea.js +4 -2
- package/lib/cjs/webchat/input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/message-list/index.js +5 -7
- package/lib/cjs/webchat/message-list/index.js.map +1 -1
- package/lib/cjs/webchat/message-list/intro-message.js +2 -2
- package/lib/cjs/webchat/message-list/intro-message.js.map +1 -1
- package/lib/cjs/webchat/message-list/styles.js +1 -0
- package/lib/cjs/webchat/message-list/styles.js.map +1 -1
- package/lib/cjs/webchat/message-list/unread-messages-banner.js +2 -2
- package/lib/cjs/webchat/message-list/unread-messages-banner.js.map +1 -1
- package/lib/cjs/webchat/message-list/use-notifications.js +2 -2
- package/lib/cjs/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/cjs/webchat/replies/index.d.ts +1 -0
- package/lib/cjs/webchat/replies/index.js +32 -0
- package/lib/cjs/webchat/replies/index.js.map +1 -0
- package/lib/cjs/webchat/replies/styles.d.ts +8 -0
- package/lib/cjs/webchat/replies/styles.js +25 -0
- package/lib/cjs/webchat/replies/styles.js.map +1 -0
- package/lib/cjs/webchat/session-view.js +2 -2
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
- package/lib/cjs/webchat/{webchat-typed/styles.js → styles.js} +1 -1
- package/lib/cjs/webchat/styles.js.map +1 -0
- package/lib/cjs/webchat/trigger-button/index.js +2 -2
- package/lib/cjs/webchat/trigger-button/index.js.map +1 -1
- package/lib/cjs/webchat/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 +83 -104
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.js +3 -2
- package/lib/cjs/webchat/webview.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +12 -84
- package/lib/cjs/webchat-app.js +45 -26
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/esm/components/audio.d.ts +8 -7
- package/lib/esm/components/audio.js +7 -4
- package/lib/esm/components/audio.js.map +1 -1
- package/lib/esm/components/button.js +2 -3
- package/lib/esm/components/button.js.map +1 -1
- package/lib/esm/components/carousel.js +1 -1
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/custom-message.d.ts +16 -12
- package/lib/esm/components/custom-message.js +3 -9
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/components/document.d.ts +8 -7
- package/lib/esm/components/document.js +4 -4
- package/lib/esm/components/document.js.map +1 -1
- package/lib/esm/components/handoff.js +1 -1
- package/lib/esm/components/handoff.js.map +1 -1
- package/lib/esm/components/image.d.ts +8 -7
- package/lib/esm/components/image.js +4 -4
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +33 -4
- package/lib/esm/components/message/index.js +2 -1
- package/lib/esm/components/message/index.js.map +1 -1
- package/lib/esm/components/message/message-feedback.js +1 -1
- package/lib/esm/components/message/message-feedback.js.map +1 -1
- package/lib/esm/components/message/message-footer.js +1 -1
- package/lib/esm/components/message/message-footer.js.map +1 -1
- package/lib/esm/components/message/message-image.js +1 -1
- package/lib/esm/components/message/message-image.js.map +1 -1
- package/lib/esm/components/message/timestamps.js +1 -1
- package/lib/esm/components/message/timestamps.js.map +1 -1
- package/lib/esm/components/reply.d.ts +7 -6
- package/lib/esm/components/reply.js +9 -5
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/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 +1 -1
- package/lib/esm/components/webchat-settings.js +1 -1
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/contexts.d.ts +3 -4
- package/lib/esm/contexts.js +1 -78
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/index-types.d.ts +87 -55
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/msg-to-botonic.d.ts +1 -1
- package/lib/esm/msg-to-botonic.js +5 -8
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/util/webchat.d.ts +17 -6
- package/lib/esm/util/webchat.js +9 -7
- package/lib/esm/util/webchat.js.map +1 -1
- package/lib/esm/webchat/chat-area/index.js +2 -2
- package/lib/esm/webchat/chat-area/index.js.map +1 -1
- package/lib/esm/webchat/components/conditional-animation.js +1 -1
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
- package/lib/esm/webchat/components/opened-persistent-menu.js +1 -1
- package/lib/esm/webchat/components/opened-persistent-menu.js.map +1 -1
- package/lib/esm/webchat/{actions.d.ts → context/actions.d.ts} +2 -0
- package/lib/esm/webchat/{actions.js → context/actions.js} +3 -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 +78 -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 +74 -0
- package/lib/esm/webchat/context/types.js +2 -0
- package/lib/esm/webchat/context/types.js.map +1 -0
- package/lib/esm/webchat/{hooks → context}/use-webchat.d.ts +18 -19
- package/lib/esm/webchat/{hooks → context}/use-webchat.js +10 -5
- 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} +2 -0
- package/lib/esm/webchat/context/webchat-reducer.js.map +1 -0
- package/lib/esm/webchat/cover-component/index.js +1 -1
- package/lib/esm/webchat/cover-component/index.js.map +1 -1
- package/lib/esm/webchat/header/default-header.d.ts +1 -0
- package/lib/esm/webchat/header/default-header.js +21 -0
- package/lib/esm/webchat/header/default-header.js.map +1 -0
- package/lib/esm/webchat/header/index.d.ts +2 -0
- package/lib/esm/webchat/header/index.js +20 -0
- package/lib/esm/webchat/header/index.js.map +1 -0
- package/lib/esm/webchat/header/styles.d.ts +7 -0
- package/lib/esm/webchat/header/styles.js +55 -0
- package/lib/esm/webchat/header/styles.js.map +1 -0
- package/lib/esm/webchat/hooks/index.d.ts +0 -1
- package/lib/esm/webchat/hooks/index.js +0 -1
- package/lib/esm/webchat/hooks/index.js.map +1 -1
- package/lib/esm/webchat/hooks/use-previous.d.ts +1 -1
- package/lib/esm/webchat/hooks/use-previous.js.map +1 -1
- package/lib/esm/webchat/hooks/use-scrollbar-controller.js +2 -2
- 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 +1 -1
- package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -1
- package/lib/esm/webchat/hooks/use-webchat-resizer.js +1 -1
- package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +3 -44
- 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 -1
- package/lib/esm/webchat/input-panel/attachment.js +1 -1
- package/lib/esm/webchat/input-panel/attachment.js.map +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.d.ts +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.js +1 -1
- package/lib/esm/webchat/input-panel/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/input-panel/index.d.ts +3 -3
- package/lib/esm/webchat/input-panel/index.js +7 -2
- package/lib/esm/webchat/input-panel/index.js.map +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.js +1 -1
- package/lib/esm/webchat/input-panel/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/input-panel/send-button.js +1 -1
- package/lib/esm/webchat/input-panel/send-button.js.map +1 -1
- package/lib/esm/webchat/input-panel/textarea.d.ts +1 -1
- package/lib/esm/webchat/input-panel/textarea.js +3 -1
- package/lib/esm/webchat/input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/message-list/index.js +4 -6
- package/lib/esm/webchat/message-list/index.js.map +1 -1
- package/lib/esm/webchat/message-list/intro-message.js +1 -1
- package/lib/esm/webchat/message-list/intro-message.js.map +1 -1
- package/lib/esm/webchat/message-list/styles.js +1 -0
- package/lib/esm/webchat/message-list/styles.js.map +1 -1
- package/lib/esm/webchat/message-list/unread-messages-banner.js +1 -1
- package/lib/esm/webchat/message-list/unread-messages-banner.js.map +1 -1
- package/lib/esm/webchat/message-list/use-notifications.js +1 -1
- package/lib/esm/webchat/message-list/use-notifications.js.map +1 -1
- package/lib/esm/webchat/replies/index.d.ts +1 -0
- package/lib/esm/webchat/replies/index.js +28 -0
- package/lib/esm/webchat/replies/index.js.map +1 -0
- package/lib/esm/webchat/replies/styles.d.ts +8 -0
- package/lib/esm/webchat/replies/styles.js +21 -0
- package/lib/esm/webchat/replies/styles.js.map +1 -0
- package/lib/esm/webchat/session-view.js +1 -1
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/{webchat-typed/styles.d.ts → styles.d.ts} +6 -4
- package/lib/esm/webchat/{webchat-typed/styles.js → styles.js} +1 -1
- package/lib/esm/webchat/styles.js.map +1 -0
- package/lib/esm/webchat/trigger-button/index.js +1 -1
- package/lib/esm/webchat/trigger-button/index.js.map +1 -1
- package/lib/esm/webchat/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 +82 -103
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.js +2 -1
- package/lib/esm/webchat/webview.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +12 -84
- package/lib/esm/webchat-app.js +45 -26
- package/lib/esm/webchat-app.js.map +1 -1
- package/package.json +5 -4
- package/src/components/{audio.jsx → audio.tsx} +10 -4
- package/src/components/button.tsx +1 -3
- package/src/components/carousel.jsx +1 -1
- package/src/components/{custom-message.jsx → custom-message.tsx} +19 -7
- package/src/components/{document.jsx → document.tsx} +5 -3
- package/src/components/handoff.jsx +1 -1
- package/src/components/{image.jsx → image.tsx} +10 -4
- package/src/components/index-types.ts +29 -4
- package/src/components/message/index.jsx +2 -1
- package/src/components/message/message-feedback.tsx +1 -1
- package/src/components/message/message-footer.tsx +1 -1
- package/src/components/message/message-image.tsx +1 -1
- package/src/components/message/timestamps.tsx +1 -1
- package/src/components/{reply.jsx → reply.tsx} +10 -4
- package/src/components/{video.jsx → video.tsx} +3 -2
- package/src/components/webchat-settings.tsx +2 -2
- package/src/contexts.tsx +5 -83
- package/src/index-types.ts +92 -59
- package/src/index.ts +2 -6
- package/src/msg-to-botonic.jsx +5 -9
- package/src/util/{webchat.js → webchat.ts} +15 -9
- package/src/webchat/chat-area/index.tsx +2 -4
- package/src/webchat/components/conditional-animation.jsx +1 -1
- package/src/webchat/components/opened-persistent-menu.jsx +1 -1
- package/src/webchat/{actions.ts → context/actions.ts} +3 -0
- package/src/webchat/context/index.tsx +81 -0
- package/src/webchat/{messages-reducer.ts → context/messages-reducer.ts} +4 -2
- package/src/webchat/context/types.ts +88 -0
- package/src/webchat/{hooks → context}/use-webchat.ts +59 -12
- package/src/webchat/{webchat-reducer.ts → context/webchat-reducer.ts} +3 -1
- package/src/webchat/cover-component/index.tsx +1 -1
- package/src/webchat/global.d.ts +3 -0
- package/src/webchat/header/default-header.tsx +75 -0
- package/src/webchat/header/index.tsx +37 -0
- package/src/webchat/header/styles.ts +62 -0
- package/src/webchat/hooks/index.ts +0 -1
- package/src/webchat/hooks/use-previous.ts +1 -1
- package/src/webchat/hooks/use-scrollbar-controller.ts +2 -2
- package/src/webchat/hooks/use-typing.ts +1 -1
- package/src/webchat/hooks/use-webchat-dimensions.ts +1 -1
- package/src/webchat/hooks/use-webchat-resizer.ts +1 -1
- package/src/webchat/index-types.ts +3 -49
- package/src/webchat/index.ts +1 -0
- package/src/webchat/input-panel/attachment.tsx +2 -2
- package/src/webchat/input-panel/emoji-picker.tsx +2 -2
- package/src/webchat/input-panel/index.tsx +9 -5
- package/src/webchat/input-panel/persistent-menu.tsx +1 -1
- package/src/webchat/input-panel/send-button.tsx +1 -1
- package/src/webchat/input-panel/textarea.tsx +4 -2
- package/src/webchat/message-list/index.tsx +4 -6
- package/src/webchat/message-list/intro-message.tsx +1 -1
- package/src/webchat/message-list/styles.ts +1 -0
- package/src/webchat/message-list/unread-messages-banner.tsx +1 -1
- package/src/webchat/message-list/use-notifications.ts +1 -1
- package/src/webchat/replies/index.tsx +47 -0
- package/src/webchat/replies/styles.ts +28 -0
- package/src/webchat/session-view.jsx +1 -1
- package/src/webchat/{webchat-typed/styles.ts → styles.ts} +7 -2
- package/src/webchat/trigger-button/index.tsx +1 -1
- package/src/webchat/webchat-dev.jsx +1 -1
- package/src/webchat/{webchat.jsx → webchat.tsx} +113 -123
- package/src/webchat/webview.jsx +2 -1
- package/src/webchat-app.tsx +79 -102
- package/lib/cjs/webchat/actions.js.map +0 -1
- package/lib/cjs/webchat/header.d.ts +0 -3
- package/lib/cjs/webchat/header.js +0 -86
- package/lib/cjs/webchat/header.js.map +0 -1
- package/lib/cjs/webchat/hooks/use-webchat.js.map +0 -1
- package/lib/cjs/webchat/messages-reducer.js.map +0 -1
- package/lib/cjs/webchat/replies.d.ts +0 -1
- package/lib/cjs/webchat/replies.js +0 -47
- package/lib/cjs/webchat/replies.js.map +0 -1
- package/lib/cjs/webchat/webchat-reducer.js.map +0 -1
- package/lib/cjs/webchat/webchat-typed/styles.js.map +0 -1
- package/lib/cjs/webchat/webchat-typed/webchat-typed.d.ts +0 -0
- package/lib/cjs/webchat/webchat-typed/webchat-typed.js +0 -663
- package/lib/cjs/webchat/webchat-typed/webchat-typed.js.map +0 -1
- package/lib/esm/webchat/actions.js.map +0 -1
- package/lib/esm/webchat/header.d.ts +0 -3
- package/lib/esm/webchat/header.js +0 -81
- package/lib/esm/webchat/header.js.map +0 -1
- package/lib/esm/webchat/hooks/use-webchat.js.map +0 -1
- package/lib/esm/webchat/messages-reducer.js.map +0 -1
- package/lib/esm/webchat/replies.d.ts +0 -1
- package/lib/esm/webchat/replies.js +0 -42
- package/lib/esm/webchat/replies.js.map +0 -1
- package/lib/esm/webchat/webchat-reducer.js.map +0 -1
- package/lib/esm/webchat/webchat-typed/styles.js.map +0 -1
- package/lib/esm/webchat/webchat-typed/webchat-typed.d.ts +0 -0
- package/lib/esm/webchat/webchat-typed/webchat-typed.js +0 -663
- package/lib/esm/webchat/webchat-typed/webchat-typed.js.map +0 -1
- package/src/webchat/header.jsx +0 -149
- package/src/webchat/replies.jsx +0 -64
- package/src/webchat/webchat-typed/webchat-typed.tsx +0 -728
|
@@ -1,728 +0,0 @@
|
|
|
1
|
-
// import {
|
|
2
|
-
// BotonicAction,
|
|
3
|
-
// INPUT,
|
|
4
|
-
// isMobile,
|
|
5
|
-
// params2queryString,
|
|
6
|
-
// } from '@botonic/core'
|
|
7
|
-
// import merge from 'lodash.merge'
|
|
8
|
-
// import React, {
|
|
9
|
-
// forwardRef,
|
|
10
|
-
// useEffect,
|
|
11
|
-
// useImperativeHandle,
|
|
12
|
-
// useRef,
|
|
13
|
-
// useState,
|
|
14
|
-
// } from 'react'
|
|
15
|
-
// import { StyleSheetManager } from 'styled-components'
|
|
16
|
-
// import { v7 as uuidv7 } from 'uuid'
|
|
17
|
-
|
|
18
|
-
// import { Audio, Document, Image, Text, Video } from '../../components'
|
|
19
|
-
// import { Handoff } from '../../components/handoff'
|
|
20
|
-
// import { normalizeWebchatSettings } from '../../components/webchat-settings'
|
|
21
|
-
// import { COLORS, MAX_ALLOWED_SIZE_MB, ROLES, WEBCHAT } from '../../constants'
|
|
22
|
-
// import { WebchatContext, WebviewRequestContext } from '../../contexts'
|
|
23
|
-
// import { SENDERS } from '../../index-types'
|
|
24
|
-
// import {
|
|
25
|
-
// getMediaType,
|
|
26
|
-
// isAllowedSize,
|
|
27
|
-
// isAudio,
|
|
28
|
-
// isDocument,
|
|
29
|
-
// isImage,
|
|
30
|
-
// isMedia,
|
|
31
|
-
// isText,
|
|
32
|
-
// isVideo,
|
|
33
|
-
// readDataURL,
|
|
34
|
-
// } from '../../message-utils'
|
|
35
|
-
// import { msgToBotonic } from '../../msg-to-botonic'
|
|
36
|
-
// import { isDev } from '../../util/environment'
|
|
37
|
-
// import { deserializeRegex, stringifyWithRegexs } from '../../util/regexs'
|
|
38
|
-
// import {
|
|
39
|
-
// _getThemeProperty,
|
|
40
|
-
// getServerErrorMessage,
|
|
41
|
-
// initSession,
|
|
42
|
-
// shouldKeepSessionOnReload,
|
|
43
|
-
// } from '../../util/webchat'
|
|
44
|
-
// import { ChatArea } from '../chat-area'
|
|
45
|
-
// import { OpenedPersistentMenu } from '../components/opened-persistent-menu'
|
|
46
|
-
// import { BotonicContainerId } from '../constants'
|
|
47
|
-
// import { CoverComponent } from '../cover-component'
|
|
48
|
-
// import { WebchatHeader } from '../header'
|
|
49
|
-
// import {
|
|
50
|
-
// useComponentWillMount,
|
|
51
|
-
// usePrevious,
|
|
52
|
-
// useScrollToBottom,
|
|
53
|
-
// useTyping,
|
|
54
|
-
// useWebchat,
|
|
55
|
-
// } from '../hooks'
|
|
56
|
-
// import { InputPanel } from '../input-panel'
|
|
57
|
-
// import { TriggerButton } from '../trigger-button'
|
|
58
|
-
// import { useStorageState } from '../use-storage-state-hook'
|
|
59
|
-
// import { getParsedAction } from '../utils'
|
|
60
|
-
// import { WebviewContainer } from '../webview'
|
|
61
|
-
// import {
|
|
62
|
-
// DarkBackgroundMenu,
|
|
63
|
-
// ErrorMessage,
|
|
64
|
-
// ErrorMessageContainer,
|
|
65
|
-
// StyledWebchat,
|
|
66
|
-
// } from './styles'
|
|
67
|
-
|
|
68
|
-
// // eslint-disable-next-line complexity, react/display-name
|
|
69
|
-
// export const WebchatTyped = forwardRef((props: WebchatTypeProps, ref) => {
|
|
70
|
-
// const {
|
|
71
|
-
// addMessage,
|
|
72
|
-
// addMessageComponent,
|
|
73
|
-
// clearMessages,
|
|
74
|
-
// doRenderCustomComponent,
|
|
75
|
-
// openWebviewT,
|
|
76
|
-
// resetUnreadMessages,
|
|
77
|
-
// setCurrentAttachment,
|
|
78
|
-
// setError,
|
|
79
|
-
// setLastMessageVisible,
|
|
80
|
-
// setOnline,
|
|
81
|
-
// toggleCoverComponent,
|
|
82
|
-
// toggleEmojiPicker,
|
|
83
|
-
// togglePersistentMenu,
|
|
84
|
-
// toggleWebchat,
|
|
85
|
-
// updateDevSettings,
|
|
86
|
-
// updateHandoff,
|
|
87
|
-
// updateLastMessageDate,
|
|
88
|
-
// updateLastRoutePath,
|
|
89
|
-
// updateLatestInput,
|
|
90
|
-
// updateMessage,
|
|
91
|
-
// updateReplies,
|
|
92
|
-
// updateSession,
|
|
93
|
-
// updateTheme,
|
|
94
|
-
// updateTyping,
|
|
95
|
-
// updateWebview,
|
|
96
|
-
// webchatState,
|
|
97
|
-
// webchatRef,
|
|
98
|
-
// chatAreaRef,
|
|
99
|
-
// inputPanelRef,
|
|
100
|
-
// headerRef,
|
|
101
|
-
// scrollableMessagesListRef,
|
|
102
|
-
|
|
103
|
-
// // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
104
|
-
// } = props.webchatHooks || useWebchat()
|
|
105
|
-
// const firstUpdate = useRef(true)
|
|
106
|
-
// const isOnline = () => webchatState.online
|
|
107
|
-
// const currentDateString = () => new Date().toISOString()
|
|
108
|
-
// const theme = merge(webchatState.theme, props.theme)
|
|
109
|
-
// const { initialSession, initialDevSettings, onStateChange } = props
|
|
110
|
-
// const getThemeProperty = _getThemeProperty(theme)
|
|
111
|
-
|
|
112
|
-
// const [customComponent, setCustomComponent] = useState(null)
|
|
113
|
-
// const storage = props.storage
|
|
114
|
-
// const storageKey =
|
|
115
|
-
// typeof props.storageKey === 'function'
|
|
116
|
-
// ? props.storageKey()
|
|
117
|
-
// : props.storageKey
|
|
118
|
-
|
|
119
|
-
// const [botonicState, saveState] = useStorageState(storage, storageKey)
|
|
120
|
-
|
|
121
|
-
// const host = props.host || document.body
|
|
122
|
-
|
|
123
|
-
// const { scrollToBottom } = useScrollToBottom({ host })
|
|
124
|
-
|
|
125
|
-
// const saveWebchatState = webchatState => {
|
|
126
|
-
// storage &&
|
|
127
|
-
// saveState(
|
|
128
|
-
// JSON.parse(
|
|
129
|
-
// stringifyWithRegexs({
|
|
130
|
-
// messages: webchatState.messagesJSON,
|
|
131
|
-
// session: webchatState.session,
|
|
132
|
-
// lastRoutePath: webchatState.lastRoutePath,
|
|
133
|
-
// devSettings: webchatState.devSettings,
|
|
134
|
-
// lastMessageUpdate: webchatState.lastMessageUpdate,
|
|
135
|
-
// themeUpdates: webchatState.themeUpdates,
|
|
136
|
-
// })
|
|
137
|
-
// )
|
|
138
|
-
// )
|
|
139
|
-
// }
|
|
140
|
-
|
|
141
|
-
// const handleAttachment = event => {
|
|
142
|
-
// if (!isAllowedSize(event.target.files[0].size)) {
|
|
143
|
-
// throw new Error(
|
|
144
|
-
// `The file is too large. A maximum of ${MAX_ALLOWED_SIZE_MB}MB is allowed.`
|
|
145
|
-
// )
|
|
146
|
-
// }
|
|
147
|
-
// setCurrentAttachment({
|
|
148
|
-
// fileName: event.target.files[0].name,
|
|
149
|
-
// file: event.target.files[0], // TODO: Attach more files?
|
|
150
|
-
// attachmentType: getMediaType(event.target.files[0].type),
|
|
151
|
-
// })
|
|
152
|
-
// }
|
|
153
|
-
|
|
154
|
-
// useEffect(() => {
|
|
155
|
-
// if (webchatState.currentAttachment)
|
|
156
|
-
// sendAttachment(webchatState.currentAttachment)
|
|
157
|
-
// }, [webchatState.currentAttachment])
|
|
158
|
-
|
|
159
|
-
// const sendUserInput = async input => {
|
|
160
|
-
// if (props.onUserInput) {
|
|
161
|
-
// resetUnreadMessages()
|
|
162
|
-
// scrollToBottom()
|
|
163
|
-
// props.onUserInput({
|
|
164
|
-
// user: webchatState.session.user,
|
|
165
|
-
// input: input,
|
|
166
|
-
// session: webchatState.session,
|
|
167
|
-
// lastRoutePath: webchatState.lastRoutePath,
|
|
168
|
-
// })
|
|
169
|
-
// }
|
|
170
|
-
// }
|
|
171
|
-
|
|
172
|
-
// // Load styles stored in window._botonicInsertStyles by Webpack
|
|
173
|
-
// useComponentWillMount(() => {
|
|
174
|
-
// if (window._botonicInsertStyles && window._botonicInsertStyles.length) {
|
|
175
|
-
// for (const botonicStyle of window._botonicInsertStyles) {
|
|
176
|
-
// // Injecting styles at head is needed even if we use shadowDOM
|
|
177
|
-
// // as some dependencies like simplebar rely on creating ephemeral elements
|
|
178
|
-
// // on document.body and assume styles will be available globally
|
|
179
|
-
// document.head.appendChild(botonicStyle)
|
|
180
|
-
|
|
181
|
-
// // injecting styles in host node too so that shadowDOM works
|
|
182
|
-
// if (props.shadowDOM) host.appendChild(botonicStyle.cloneNode(true))
|
|
183
|
-
// }
|
|
184
|
-
// delete window._botonicInsertStyles
|
|
185
|
-
// }
|
|
186
|
-
|
|
187
|
-
// if (props.shadowDOM) {
|
|
188
|
-
// // emoji-picker-react injects styles in head, so we need to
|
|
189
|
-
// // re-inject them in our host node to make it work with shadowDOM
|
|
190
|
-
// for (const style of document.querySelectorAll('style')) {
|
|
191
|
-
// if (
|
|
192
|
-
// style.textContent &&
|
|
193
|
-
// style.textContent.includes('emoji-picker-react')
|
|
194
|
-
// )
|
|
195
|
-
// host.appendChild(style.cloneNode(true))
|
|
196
|
-
// }
|
|
197
|
-
// }
|
|
198
|
-
// })
|
|
199
|
-
|
|
200
|
-
// // Load initial state from storage
|
|
201
|
-
// useEffect(() => {
|
|
202
|
-
// let {
|
|
203
|
-
// messages,
|
|
204
|
-
// session,
|
|
205
|
-
// lastRoutePath,
|
|
206
|
-
// devSettings,
|
|
207
|
-
// lastMessageUpdate,
|
|
208
|
-
// themeUpdates,
|
|
209
|
-
// } = botonicState || {}
|
|
210
|
-
// session = initSession(session)
|
|
211
|
-
// updateSession(session)
|
|
212
|
-
// if (shouldKeepSessionOnReload({ initialDevSettings, devSettings })) {
|
|
213
|
-
// if (messages) {
|
|
214
|
-
// messages.forEach(message => {
|
|
215
|
-
// addMessage(message)
|
|
216
|
-
// const newMessageComponent = msgToBotonic(
|
|
217
|
-
// { ...message, delay: 0, typing: 0 },
|
|
218
|
-
// (props.theme.message && props.theme.message.customTypes) ||
|
|
219
|
-
// props.theme.customMessageTypes
|
|
220
|
-
// )
|
|
221
|
-
// if (newMessageComponent) addMessageComponent(newMessageComponent)
|
|
222
|
-
// })
|
|
223
|
-
// }
|
|
224
|
-
// if (initialSession) updateSession(merge(initialSession, session))
|
|
225
|
-
// if (lastRoutePath) updateLastRoutePath(lastRoutePath)
|
|
226
|
-
// } else updateSession(merge(initialSession, session))
|
|
227
|
-
// if (devSettings) updateDevSettings(devSettings)
|
|
228
|
-
// else if (initialDevSettings) updateDevSettings(initialDevSettings)
|
|
229
|
-
// if (lastMessageUpdate) updateLastMessageDate(lastMessageUpdate)
|
|
230
|
-
// if (themeUpdates !== undefined)
|
|
231
|
-
// updateTheme(merge(props.theme, themeUpdates), themeUpdates)
|
|
232
|
-
// if (props.onInit) setTimeout(() => props.onInit(), 100)
|
|
233
|
-
// }, [])
|
|
234
|
-
|
|
235
|
-
// useEffect(() => {
|
|
236
|
-
// if (!webchatState.isWebchatOpen) {
|
|
237
|
-
// if (webchatState.isLastMessageVisible) {
|
|
238
|
-
// resetUnreadMessages()
|
|
239
|
-
// }
|
|
240
|
-
// return
|
|
241
|
-
// }
|
|
242
|
-
// }, [webchatState.isWebchatOpen])
|
|
243
|
-
|
|
244
|
-
// useEffect(() => {
|
|
245
|
-
// if (onStateChange && typeof onStateChange === 'function') {
|
|
246
|
-
// onStateChange(webchatState)
|
|
247
|
-
// }
|
|
248
|
-
// saveWebchatState(webchatState)
|
|
249
|
-
// }, [
|
|
250
|
-
// webchatState.messagesJSON,
|
|
251
|
-
// webchatState.session,
|
|
252
|
-
// webchatState.lastRoutePath,
|
|
253
|
-
// webchatState.devSettings,
|
|
254
|
-
// webchatState.lastMessageUpdate,
|
|
255
|
-
// ])
|
|
256
|
-
|
|
257
|
-
// useEffect(() => {
|
|
258
|
-
// if (!webchatState.online) {
|
|
259
|
-
// setError({
|
|
260
|
-
// message: getServerErrorMessage(props.server),
|
|
261
|
-
// })
|
|
262
|
-
// } else {
|
|
263
|
-
// if (!firstUpdate.current) {
|
|
264
|
-
// setError(undefined)
|
|
265
|
-
// }
|
|
266
|
-
// }
|
|
267
|
-
// }, [webchatState.online])
|
|
268
|
-
|
|
269
|
-
// useTyping({ webchatState, updateTyping, updateMessage, host })
|
|
270
|
-
|
|
271
|
-
// useEffect(() => {
|
|
272
|
-
// updateTheme(merge(props.theme, theme, webchatState.themeUpdates))
|
|
273
|
-
// }, [props.theme, webchatState.themeUpdates])
|
|
274
|
-
|
|
275
|
-
// const openWebview = (webviewComponent, params) => {
|
|
276
|
-
// updateWebview(webviewComponent, params)
|
|
277
|
-
// }
|
|
278
|
-
|
|
279
|
-
// const textareaRef = useRef(null)
|
|
280
|
-
|
|
281
|
-
// const closeWebview = async options => {
|
|
282
|
-
// updateWebview()
|
|
283
|
-
// if (userInputEnabled) {
|
|
284
|
-
// textareaRef.current.focus()
|
|
285
|
-
// }
|
|
286
|
-
// if (options?.payload) {
|
|
287
|
-
// await sendPayload(options.payload)
|
|
288
|
-
// } else if (options?.path) {
|
|
289
|
-
// const params = options.params ? params2queryString(options.params) : ''
|
|
290
|
-
// await sendPayload(`__PATH_PAYLOAD__${options.path}?${params}`)
|
|
291
|
-
// }
|
|
292
|
-
// }
|
|
293
|
-
|
|
294
|
-
// const persistentMenuOptions = getThemeProperty(
|
|
295
|
-
// WEBCHAT.CUSTOM_PROPERTIES.persistentMenu,
|
|
296
|
-
// props.persistentMenu
|
|
297
|
-
// )
|
|
298
|
-
|
|
299
|
-
// const darkBackgroundMenu = getThemeProperty(
|
|
300
|
-
// WEBCHAT.CUSTOM_PROPERTIES.darkBackgroundMenu
|
|
301
|
-
// )
|
|
302
|
-
|
|
303
|
-
// const getBlockInputs = (rule, inputData) => {
|
|
304
|
-
// const processedInput = rule.preprocess
|
|
305
|
-
// ? rule.preprocess(inputData)
|
|
306
|
-
// : inputData
|
|
307
|
-
|
|
308
|
-
// return rule.match.some(regex => {
|
|
309
|
-
// if (typeof regex === 'string') regex = deserializeRegex(regex)
|
|
310
|
-
// return regex.test(processedInput)
|
|
311
|
-
// })
|
|
312
|
-
// }
|
|
313
|
-
|
|
314
|
-
// const checkBlockInput = input => {
|
|
315
|
-
// // if is a text we check if it is a serialized RE
|
|
316
|
-
// const blockInputs = getThemeProperty(
|
|
317
|
-
// WEBCHAT.CUSTOM_PROPERTIES.blockInputs,
|
|
318
|
-
// props.blockInputs
|
|
319
|
-
// )
|
|
320
|
-
// if (!Array.isArray(blockInputs)) return false
|
|
321
|
-
// for (const rule of blockInputs) {
|
|
322
|
-
// if (getBlockInputs(rule, input.data)) {
|
|
323
|
-
// addMessageComponent(
|
|
324
|
-
// <Text
|
|
325
|
-
// sentBy={SENDERS.user}
|
|
326
|
-
// blob={false}
|
|
327
|
-
// style={{
|
|
328
|
-
// backgroundColor: COLORS.SCORPION_GRAY,
|
|
329
|
-
// borderColor: COLORS.SCORPION_GRAY,
|
|
330
|
-
// padding: '8px 12px',
|
|
331
|
-
// }}
|
|
332
|
-
// >
|
|
333
|
-
// {rule.message}
|
|
334
|
-
// </Text>
|
|
335
|
-
// )
|
|
336
|
-
// updateReplies(false)
|
|
337
|
-
// return true
|
|
338
|
-
// }
|
|
339
|
-
// }
|
|
340
|
-
// return false
|
|
341
|
-
// }
|
|
342
|
-
|
|
343
|
-
// const closeMenu = () => {
|
|
344
|
-
// togglePersistentMenu(false)
|
|
345
|
-
// }
|
|
346
|
-
|
|
347
|
-
// const persistentMenu = () => {
|
|
348
|
-
// return (
|
|
349
|
-
// <OpenedPersistentMenu
|
|
350
|
-
// onClick={closeMenu}
|
|
351
|
-
// options={persistentMenuOptions}
|
|
352
|
-
// borderRadius={webchatState.theme.style.borderRadius || '10px'}
|
|
353
|
-
// />
|
|
354
|
-
// )
|
|
355
|
-
// }
|
|
356
|
-
|
|
357
|
-
// const getCoverComponent = () => {
|
|
358
|
-
// return getThemeProperty(
|
|
359
|
-
// WEBCHAT.CUSTOM_PROPERTIES.coverComponent,
|
|
360
|
-
// props.coverComponent &&
|
|
361
|
-
// (props.coverComponent.component || props.coverComponent)
|
|
362
|
-
// )
|
|
363
|
-
// }
|
|
364
|
-
// const coverComponent = getCoverComponent()
|
|
365
|
-
// const coverComponentProps = props.coverComponent?.props
|
|
366
|
-
|
|
367
|
-
// useEffect(() => {
|
|
368
|
-
// if (!coverComponent) return
|
|
369
|
-
// if (
|
|
370
|
-
// !botonicState ||
|
|
371
|
-
// (botonicState.messages && botonicState.messages.length === 0)
|
|
372
|
-
// )
|
|
373
|
-
// toggleCoverComponent(true)
|
|
374
|
-
// }, [])
|
|
375
|
-
|
|
376
|
-
// const messageComponentFromInput = input => {
|
|
377
|
-
// let messageComponent: any = null
|
|
378
|
-
// if (isText(input)) {
|
|
379
|
-
// messageComponent = <Text sentBy={SENDERS.user}>{input.data}</Text>
|
|
380
|
-
// } else if (isMedia(input)) {
|
|
381
|
-
// const temporaryDisplayUrl = URL.createObjectURL(input.data)
|
|
382
|
-
// const mediaProps = {
|
|
383
|
-
// id: input.id,
|
|
384
|
-
// sentBy: SENDERS.user,
|
|
385
|
-
// src: temporaryDisplayUrl,
|
|
386
|
-
// }
|
|
387
|
-
// if (isImage(input)) {
|
|
388
|
-
// mediaProps.input = input
|
|
389
|
-
// messageComponent = <Image {...mediaProps} />
|
|
390
|
-
// } else if (isAudio(input)) messageComponent = <Audio {...mediaProps} />
|
|
391
|
-
// else if (isVideo(input)) messageComponent = <Video {...mediaProps} />
|
|
392
|
-
// else if (isDocument(input))
|
|
393
|
-
// messageComponent = <Document {...mediaProps} />
|
|
394
|
-
// }
|
|
395
|
-
// return messageComponent
|
|
396
|
-
// }
|
|
397
|
-
|
|
398
|
-
// const sendInput = async input => {
|
|
399
|
-
// if (!input || Object.keys(input).length == 0) return
|
|
400
|
-
// if (isText(input) && (!input.data || !input.data.trim())) return // in case trim() doesn't work in a browser we can use !/\S/.test(input.data)
|
|
401
|
-
// if (isText(input) && checkBlockInput(input)) return
|
|
402
|
-
// if (!input.id) input.id = uuidv7()
|
|
403
|
-
// const messageComponent = messageComponentFromInput(input)
|
|
404
|
-
// if (messageComponent) addMessageComponent(messageComponent)
|
|
405
|
-
// if (isMedia(input)) input.data = await readDataURL(input.data)
|
|
406
|
-
// sendUserInput(input)
|
|
407
|
-
// updateLatestInput(input)
|
|
408
|
-
// isOnline() && updateLastMessageDate(currentDateString())
|
|
409
|
-
// updateReplies(false)
|
|
410
|
-
// togglePersistentMenu(false)
|
|
411
|
-
// toggleEmojiPicker(false)
|
|
412
|
-
// }
|
|
413
|
-
|
|
414
|
-
// /* This is the public API this component exposes to its parents
|
|
415
|
-
// https://stackoverflow.com/questions/37949981/call-child-method-from-parent
|
|
416
|
-
// */
|
|
417
|
-
|
|
418
|
-
// const updateSessionWithUser = userToUpdate =>
|
|
419
|
-
// updateSession(merge(webchatState.session, { user: userToUpdate }))
|
|
420
|
-
|
|
421
|
-
// useImperativeHandle(ref, () => ({
|
|
422
|
-
// addBotResponse: ({ response, session, lastRoutePath }) => {
|
|
423
|
-
// updateTyping(false)
|
|
424
|
-
|
|
425
|
-
// const isUnread =
|
|
426
|
-
// !webchatState.isLastMessageVisible || webchatState.numUnreadMessages > 0
|
|
427
|
-
|
|
428
|
-
// if (Array.isArray(response)) {
|
|
429
|
-
// response.forEach(r => {
|
|
430
|
-
// addMessageComponent({ ...r, props: { ...r.props, isUnread } })
|
|
431
|
-
// })
|
|
432
|
-
// } else if (response) {
|
|
433
|
-
// addMessageComponent({
|
|
434
|
-
// ...response,
|
|
435
|
-
// props: { ...response.props, isUnread },
|
|
436
|
-
// })
|
|
437
|
-
// }
|
|
438
|
-
|
|
439
|
-
// if (session) {
|
|
440
|
-
// updateSession(merge(session, { user: webchatState.session.user }))
|
|
441
|
-
// const action = session._botonic_action || ''
|
|
442
|
-
// const handoff = action.startsWith(BotonicAction.CreateCase)
|
|
443
|
-
// if (handoff && isDev) addMessageComponent(<Handoff />)
|
|
444
|
-
// updateHandoff(handoff)
|
|
445
|
-
// }
|
|
446
|
-
|
|
447
|
-
// if (lastRoutePath) updateLastRoutePath(lastRoutePath)
|
|
448
|
-
|
|
449
|
-
// updateLastMessageDate(currentDateString())
|
|
450
|
-
// },
|
|
451
|
-
// setTyping: typing => updateTyping(typing),
|
|
452
|
-
// addUserMessage: message => sendInput(message),
|
|
453
|
-
// updateUser: updateSessionWithUser,
|
|
454
|
-
// openWebchat: () => toggleWebchat(true),
|
|
455
|
-
// closeWebchat: () => toggleWebchat(false),
|
|
456
|
-
// toggleWebchat: () => toggleWebchat(!webchatState.isWebchatOpen),
|
|
457
|
-
// openCoverComponent: () => toggleCoverComponent(true),
|
|
458
|
-
// closeCoverComponent: () => toggleCoverComponent(false),
|
|
459
|
-
// renderCustomComponent: _customComponent => {
|
|
460
|
-
// setCustomComponent(_customComponent)
|
|
461
|
-
// doRenderCustomComponent(true)
|
|
462
|
-
// },
|
|
463
|
-
// unmountCustomComponent: () => doRenderCustomComponent(false),
|
|
464
|
-
// toggleCoverComponent: () =>
|
|
465
|
-
// toggleCoverComponent(!webchatState.isCoverComponentOpen),
|
|
466
|
-
// openWebviewApi: component => openWebviewT(component),
|
|
467
|
-
// setError,
|
|
468
|
-
// setOnline,
|
|
469
|
-
// getMessages: () => webchatState.messagesJSON,
|
|
470
|
-
// isOnline,
|
|
471
|
-
// clearMessages: () => {
|
|
472
|
-
// clearMessages()
|
|
473
|
-
// updateReplies(false)
|
|
474
|
-
// },
|
|
475
|
-
// getLastMessageUpdate: () => webchatState.lastMessageUpdate,
|
|
476
|
-
// updateMessageInfo: (msgId, messageInfo) => {
|
|
477
|
-
// const messageToUpdate = webchatState.messagesJSON.filter(
|
|
478
|
-
// m => m.id == msgId
|
|
479
|
-
// )[0]
|
|
480
|
-
// const updatedMsg = merge(messageToUpdate, messageInfo)
|
|
481
|
-
// if (updatedMsg.ack === 1) delete updatedMsg.unsentInput
|
|
482
|
-
// updateMessage(updatedMsg)
|
|
483
|
-
// },
|
|
484
|
-
// updateWebchatSettings: settings => {
|
|
485
|
-
// if (settings.user) {
|
|
486
|
-
// updateSessionWithUser(settings.user)
|
|
487
|
-
// }
|
|
488
|
-
// const themeUpdates = normalizeWebchatSettings(settings)
|
|
489
|
-
// updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates)
|
|
490
|
-
// updateTyping(false)
|
|
491
|
-
// },
|
|
492
|
-
// closeWebview: closeWebview,
|
|
493
|
-
// }))
|
|
494
|
-
|
|
495
|
-
// const resolveCase = () => {
|
|
496
|
-
// updateHandoff(false)
|
|
497
|
-
// updateSession({ ...webchatState.session, _botonic_action: null })
|
|
498
|
-
// }
|
|
499
|
-
|
|
500
|
-
// const prevSession = usePrevious(webchatState.session)
|
|
501
|
-
// useEffect(() => {
|
|
502
|
-
// // Resume conversation after handoff
|
|
503
|
-
// if (
|
|
504
|
-
// prevSession &&
|
|
505
|
-
// prevSession._botonic_action &&
|
|
506
|
-
// !webchatState.session._botonic_action
|
|
507
|
-
// ) {
|
|
508
|
-
// const action = getParsedAction(prevSession._botonic_action)
|
|
509
|
-
// if (action && action.on_finish) sendPayload(action.on_finish)
|
|
510
|
-
// }
|
|
511
|
-
// }, [webchatState.session._botonic_action])
|
|
512
|
-
|
|
513
|
-
// const sendText = async (text, payload) => {
|
|
514
|
-
// if (!text) return
|
|
515
|
-
// const input = { type: INPUT.TEXT, data: text, payload }
|
|
516
|
-
// await sendInput(input)
|
|
517
|
-
// }
|
|
518
|
-
|
|
519
|
-
// const sendPayload = async payload => {
|
|
520
|
-
// if (!payload) return
|
|
521
|
-
// const input = { type: INPUT.POSTBACK, payload }
|
|
522
|
-
// await sendInput(input)
|
|
523
|
-
// }
|
|
524
|
-
|
|
525
|
-
// const sendAttachment = async attachment => {
|
|
526
|
-
// if (attachment.file) {
|
|
527
|
-
// const attachmentType = getMediaType(attachment.file.type)
|
|
528
|
-
// if (!attachmentType) return
|
|
529
|
-
// const input = {
|
|
530
|
-
// type: attachmentType,
|
|
531
|
-
// data: attachment.file,
|
|
532
|
-
// }
|
|
533
|
-
// await sendInput(input)
|
|
534
|
-
// setCurrentAttachment(undefined)
|
|
535
|
-
// }
|
|
536
|
-
// }
|
|
537
|
-
|
|
538
|
-
// const webviewRequestContext = {
|
|
539
|
-
// closeWebview: closeWebview,
|
|
540
|
-
// getString: stringId => props.getString(stringId, webchatState.session),
|
|
541
|
-
// params: webchatState.webviewParams || {},
|
|
542
|
-
// session: webchatState.session || {},
|
|
543
|
-
// }
|
|
544
|
-
|
|
545
|
-
// useEffect(() => {
|
|
546
|
-
// if (firstUpdate.current) {
|
|
547
|
-
// firstUpdate.current = false
|
|
548
|
-
// return
|
|
549
|
-
// }
|
|
550
|
-
|
|
551
|
-
// if (webchatState.isWebchatOpen && props.onOpen) props.onOpen()
|
|
552
|
-
|
|
553
|
-
// if (!webchatState.isWebchatOpen && props.onClose && !firstUpdate.current) {
|
|
554
|
-
// props.onClose()
|
|
555
|
-
// toggleEmojiPicker(false)
|
|
556
|
-
// togglePersistentMenu(false)
|
|
557
|
-
// }
|
|
558
|
-
// }, [webchatState.isWebchatOpen])
|
|
559
|
-
|
|
560
|
-
// const isUserInputEnabled = () => {
|
|
561
|
-
// const isUserInputEnabled = getThemeProperty(
|
|
562
|
-
// WEBCHAT.CUSTOM_PROPERTIES.enableUserInput,
|
|
563
|
-
// props.enableUserInput !== undefined ? props.enableUserInput : true
|
|
564
|
-
// )
|
|
565
|
-
// return isUserInputEnabled && !webchatState.isCoverComponentOpen
|
|
566
|
-
// }
|
|
567
|
-
|
|
568
|
-
// const userInputEnabled = isUserInputEnabled()
|
|
569
|
-
|
|
570
|
-
// const webchatWebview = () => (
|
|
571
|
-
// <WebviewRequestContext.Provider value={webviewRequestContext}>
|
|
572
|
-
// <WebviewContainer
|
|
573
|
-
// style={{
|
|
574
|
-
// ...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.webviewStyle),
|
|
575
|
-
// ...mobileStyle,
|
|
576
|
-
// }}
|
|
577
|
-
// webview={webchatState.webview}
|
|
578
|
-
// />
|
|
579
|
-
// </WebviewRequestContext.Provider>
|
|
580
|
-
// )
|
|
581
|
-
// let mobileStyle = {}
|
|
582
|
-
// if (isMobile(getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileBreakpoint))) {
|
|
583
|
-
// mobileStyle = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.mobileStyle) || {
|
|
584
|
-
// width: '100%',
|
|
585
|
-
// height: '100%',
|
|
586
|
-
// right: 0,
|
|
587
|
-
// bottom: 0,
|
|
588
|
-
// borderRadius: 0,
|
|
589
|
-
// }
|
|
590
|
-
// }
|
|
591
|
-
|
|
592
|
-
// useEffect(() => {
|
|
593
|
-
// // Prod mode
|
|
594
|
-
// saveWebchatState(webchatState)
|
|
595
|
-
// }, [webchatState.themeUpdates])
|
|
596
|
-
|
|
597
|
-
// // Only needed for dev/serve mode
|
|
598
|
-
// const updateWebchatDevSettings = settings => {
|
|
599
|
-
// // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
600
|
-
// useEffect(() => {
|
|
601
|
-
// const themeUpdates = normalizeWebchatSettings(settings)
|
|
602
|
-
// updateTheme(merge(webchatState.theme, themeUpdates), themeUpdates)
|
|
603
|
-
// }, [webchatState.messagesJSON])
|
|
604
|
-
// }
|
|
605
|
-
|
|
606
|
-
// const DarkenBackground = ({ component }) => {
|
|
607
|
-
// return (
|
|
608
|
-
// <div>
|
|
609
|
-
// {darkBackgroundMenu && (
|
|
610
|
-
// <DarkBackgroundMenu
|
|
611
|
-
// style={{
|
|
612
|
-
// borderRadius: webchatState.theme.style.borderRadius,
|
|
613
|
-
// }}
|
|
614
|
-
// />
|
|
615
|
-
// )}
|
|
616
|
-
// {component}
|
|
617
|
-
// </div>
|
|
618
|
-
// )
|
|
619
|
-
// }
|
|
620
|
-
|
|
621
|
-
// const _renderCustomComponent = () => {
|
|
622
|
-
// if (!customComponent) return <></>
|
|
623
|
-
// else return customComponent
|
|
624
|
-
// }
|
|
625
|
-
|
|
626
|
-
// const WebchatComponent = (
|
|
627
|
-
// <WebchatContext.Provider
|
|
628
|
-
// value={{
|
|
629
|
-
// addMessage,
|
|
630
|
-
// getThemeProperty,
|
|
631
|
-
// openWebview,
|
|
632
|
-
// resolveCase,
|
|
633
|
-
// resetUnreadMessages,
|
|
634
|
-
// setLastMessageVisible,
|
|
635
|
-
// sendAttachment,
|
|
636
|
-
// sendInput,
|
|
637
|
-
// sendPayload,
|
|
638
|
-
// sendText,
|
|
639
|
-
// toggleWebchat,
|
|
640
|
-
// toggleEmojiPicker,
|
|
641
|
-
// togglePersistentMenu,
|
|
642
|
-
// toggleCoverComponent,
|
|
643
|
-
// updateLatestInput,
|
|
644
|
-
// updateMessage,
|
|
645
|
-
// updateReplies,
|
|
646
|
-
// updateUser: updateSessionWithUser,
|
|
647
|
-
// updateWebchatDevSettings: updateWebchatDevSettings,
|
|
648
|
-
// webchatState,
|
|
649
|
-
// trackEvent: props.onTrackEvent,
|
|
650
|
-
// webchatRef,
|
|
651
|
-
// chatAreaRef,
|
|
652
|
-
// inputPanelRef,
|
|
653
|
-
// headerRef,
|
|
654
|
-
// scrollableMessagesListRef,
|
|
655
|
-
// }}
|
|
656
|
-
// >
|
|
657
|
-
// {!webchatState.isWebchatOpen && <TriggerButton />}
|
|
658
|
-
|
|
659
|
-
// {webchatState.isWebchatOpen && (
|
|
660
|
-
// <StyledWebchat
|
|
661
|
-
// id={BotonicContainerId.Webchat}
|
|
662
|
-
// ref={webchatRef}
|
|
663
|
-
// // TODO: Distinguish between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
|
|
664
|
-
// role={ROLES.WEBCHAT}
|
|
665
|
-
// width={webchatState.width}
|
|
666
|
-
// height={webchatState.height}
|
|
667
|
-
// style={{
|
|
668
|
-
// ...webchatState.theme.style,
|
|
669
|
-
// ...mobileStyle,
|
|
670
|
-
// }}
|
|
671
|
-
// >
|
|
672
|
-
// <WebchatHeader
|
|
673
|
-
// id={BotonicContainerId.Header}
|
|
674
|
-
// ref={headerRef}
|
|
675
|
-
// onCloseClick={() => {
|
|
676
|
-
// toggleWebchat(false)
|
|
677
|
-
// }}
|
|
678
|
-
// />
|
|
679
|
-
|
|
680
|
-
// {webchatState.isCoverComponentOpen ? (
|
|
681
|
-
// <CoverComponent
|
|
682
|
-
// component={coverComponent}
|
|
683
|
-
// componentProps={coverComponentProps}
|
|
684
|
-
// />
|
|
685
|
-
// ) : (
|
|
686
|
-
// <>
|
|
687
|
-
// {webchatState.error.message && (
|
|
688
|
-
// <ErrorMessageContainer>
|
|
689
|
-
// <ErrorMessage>{webchatState.error.message}</ErrorMessage>
|
|
690
|
-
// </ErrorMessageContainer>
|
|
691
|
-
// )}
|
|
692
|
-
|
|
693
|
-
// <ChatArea />
|
|
694
|
-
|
|
695
|
-
// {webchatState.isPersistentMenuOpen && (
|
|
696
|
-
// <DarkenBackground component={persistentMenu()} />
|
|
697
|
-
// )}
|
|
698
|
-
|
|
699
|
-
// {!webchatState.handoff && userInputEnabled && (
|
|
700
|
-
// <InputPanel
|
|
701
|
-
// persistentMenu={props.persistentMenu}
|
|
702
|
-
// enableEmojiPicker={props.enableEmojiPicker}
|
|
703
|
-
// enableAttachments={props.enableAttachments}
|
|
704
|
-
// handleAttachment={handleAttachment}
|
|
705
|
-
// textareaRef={textareaRef}
|
|
706
|
-
// host={host}
|
|
707
|
-
// onUserInput={props.onUserInput}
|
|
708
|
-
// />
|
|
709
|
-
// )}
|
|
710
|
-
|
|
711
|
-
// {webchatState.webview && webchatWebview()}
|
|
712
|
-
|
|
713
|
-
// {webchatState.isCustomComponentRendered &&
|
|
714
|
-
// customComponent &&
|
|
715
|
-
// _renderCustomComponent()}
|
|
716
|
-
// </>
|
|
717
|
-
// )}
|
|
718
|
-
// </StyledWebchat>
|
|
719
|
-
// )}
|
|
720
|
-
// </WebchatContext.Provider>
|
|
721
|
-
// )
|
|
722
|
-
|
|
723
|
-
// return props.shadowDOM ? (
|
|
724
|
-
// <StyleSheetManager target={host}>{WebchatComponent}</StyleSheetManager>
|
|
725
|
-
// ) : (
|
|
726
|
-
// WebchatComponent
|
|
727
|
-
// )
|
|
728
|
-
// })
|