@botonic/react 0.21.6 → 0.21.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/app.d.ts +2 -0
- package/lib/cjs/app.js +10 -0
- package/lib/cjs/app.js.map +1 -0
- package/lib/cjs/botonic-tester.d.ts +18 -0
- package/lib/cjs/botonic-tester.js +70 -0
- package/lib/cjs/botonic-tester.js.map +1 -0
- package/lib/cjs/components/audio.d.ts +8 -0
- package/lib/cjs/components/audio.js +27 -0
- package/lib/cjs/components/audio.js.map +1 -0
- package/lib/cjs/components/button.d.ts +15 -0
- package/lib/cjs/components/button.js +156 -0
- package/lib/cjs/components/button.js.map +1 -0
- package/lib/cjs/components/buttons-disabler.d.ts +24 -0
- package/lib/cjs/components/buttons-disabler.js +88 -0
- package/lib/cjs/components/buttons-disabler.js.map +1 -0
- package/lib/cjs/components/carousel.d.ts +9 -0
- package/lib/cjs/components/carousel.js +120 -0
- package/lib/cjs/components/carousel.js.map +1 -0
- package/lib/cjs/components/components.d.ts +12 -0
- package/lib/{components → cjs/components}/components.js +6 -11
- package/lib/cjs/components/components.js.map +1 -0
- package/lib/cjs/components/custom-message.d.ts +10 -0
- package/lib/cjs/components/custom-message.js +65 -0
- package/lib/cjs/components/custom-message.js.map +1 -0
- package/lib/cjs/components/document.d.ts +8 -0
- package/lib/cjs/components/document.js +50 -0
- package/lib/cjs/components/document.js.map +1 -0
- package/lib/cjs/components/element.d.ts +4 -0
- package/lib/cjs/components/element.js +55 -0
- package/lib/cjs/components/element.js.map +1 -0
- package/lib/cjs/components/handoff.d.ts +1 -0
- package/lib/cjs/components/handoff.js +58 -0
- package/lib/cjs/components/handoff.js.map +1 -0
- package/lib/cjs/components/image.d.ts +8 -0
- package/lib/cjs/components/image.js +42 -0
- package/lib/cjs/components/image.js.map +1 -0
- package/lib/cjs/components/index.d.ts +1 -0
- package/lib/cjs/components/index.js +44 -0
- package/lib/cjs/components/index.js.map +1 -0
- package/lib/cjs/components/location.d.ts +11 -0
- package/lib/cjs/components/location.js +38 -0
- package/lib/cjs/components/location.js.map +1 -0
- package/lib/cjs/components/markdown.d.ts +7 -0
- package/lib/cjs/components/markdown.js +162 -0
- package/lib/cjs/components/markdown.js.map +1 -0
- package/lib/cjs/components/message-template.d.ts +1 -0
- package/lib/cjs/components/message-template.js +15 -0
- package/lib/cjs/components/message-template.js.map +1 -0
- package/lib/cjs/components/message.d.ts +1 -0
- package/lib/cjs/components/message.js +206 -0
- package/lib/cjs/components/message.js.map +1 -0
- package/lib/cjs/components/multichannel/facebook/facebook.d.ts +17 -0
- package/lib/cjs/components/multichannel/facebook/facebook.js +47 -0
- package/lib/cjs/components/multichannel/facebook/facebook.js.map +1 -0
- package/lib/cjs/components/multichannel/index.d.ts +1 -0
- package/lib/cjs/components/multichannel/index.js +14 -0
- package/lib/cjs/components/multichannel/index.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel-button.d.ts +1 -0
- package/lib/cjs/components/multichannel/multichannel-button.js +77 -0
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel-carousel.d.ts +1 -0
- package/lib/cjs/components/multichannel/multichannel-carousel.js +95 -0
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel-context.d.ts +11 -0
- package/lib/cjs/components/multichannel/multichannel-context.js +16 -0
- package/lib/cjs/components/multichannel/multichannel-context.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel-reply.d.ts +1 -0
- package/lib/cjs/components/multichannel/multichannel-reply.js +24 -0
- package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -0
- package/lib/cjs/components/multichannel/multichannel-text.js +147 -0
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel-utils.d.ts +24 -0
- package/lib/cjs/components/multichannel/multichannel-utils.js +83 -0
- package/lib/cjs/components/multichannel/multichannel-utils.js.map +1 -0
- package/lib/cjs/components/multichannel/multichannel.d.ts +1 -0
- package/lib/cjs/components/multichannel/multichannel.js +72 -0
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -0
- package/lib/cjs/components/pic.d.ts +6 -0
- package/lib/cjs/components/pic.js +29 -0
- package/lib/cjs/components/pic.js.map +1 -0
- package/lib/cjs/components/raw.d.ts +9 -0
- package/lib/cjs/components/raw.js +53 -0
- package/lib/cjs/components/raw.js.map +1 -0
- package/lib/cjs/components/reply.d.ts +9 -0
- package/lib/cjs/components/reply.js +57 -0
- package/lib/cjs/components/reply.js.map +1 -0
- package/lib/cjs/components/share-button.d.ts +1 -0
- package/lib/cjs/components/share-button.js +15 -0
- package/lib/cjs/components/share-button.js.map +1 -0
- package/lib/cjs/components/subtitle.d.ts +6 -0
- package/lib/cjs/components/subtitle.js +25 -0
- package/lib/cjs/components/subtitle.js.map +1 -0
- package/lib/cjs/components/text.d.ts +8 -0
- package/lib/cjs/components/text.js +50 -0
- package/lib/cjs/components/text.js.map +1 -0
- package/lib/cjs/components/timestamps.d.ts +10 -0
- package/lib/cjs/components/timestamps.js +54 -0
- package/lib/cjs/components/timestamps.js.map +1 -0
- package/lib/cjs/components/title.d.ts +6 -0
- package/lib/cjs/components/title.js +21 -0
- package/lib/cjs/components/title.js.map +1 -0
- package/lib/cjs/components/video.d.ts +8 -0
- package/lib/cjs/components/video.js +34 -0
- package/lib/cjs/components/video.js.map +1 -0
- package/lib/cjs/components/webchat-settings.d.ts +10 -0
- package/lib/cjs/components/webchat-settings.js +78 -0
- package/lib/cjs/components/webchat-settings.js.map +1 -0
- package/lib/cjs/components/whatsapp-template.d.ts +1 -0
- package/lib/cjs/components/whatsapp-template.js +26 -0
- package/lib/cjs/components/whatsapp-template.js.map +1 -0
- package/lib/cjs/constants.d.ts +168 -0
- package/lib/cjs/constants.js +190 -0
- package/lib/cjs/constants.js.map +1 -0
- package/lib/cjs/contexts.d.ts +69 -0
- package/lib/cjs/contexts.js +38 -0
- package/lib/cjs/contexts.js.map +1 -0
- package/lib/cjs/dev-app.d.ts +34 -0
- package/lib/cjs/dev-app.js +71 -0
- package/lib/cjs/dev-app.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.js +28 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/message-utils.d.ts +18 -0
- package/lib/cjs/message-utils.js +61 -0
- package/lib/cjs/message-utils.js.map +1 -0
- package/lib/cjs/msg-to-botonic.d.ts +18 -0
- package/lib/cjs/msg-to-botonic.js +160 -0
- package/lib/cjs/msg-to-botonic.js.map +1 -0
- package/lib/cjs/node-app.d.ts +11 -0
- package/lib/cjs/node-app.js +25 -0
- package/lib/cjs/node-app.js.map +1 -0
- package/lib/cjs/react-bot.d.ts +8 -0
- package/lib/cjs/react-bot.js +35 -0
- package/lib/cjs/react-bot.js.map +1 -0
- package/lib/cjs/util/dom.d.ts +13 -0
- package/lib/cjs/util/dom.js +55 -0
- package/lib/cjs/util/dom.js.map +1 -0
- package/lib/cjs/util/environment.d.ts +6 -0
- package/lib/cjs/util/environment.js +68 -0
- package/lib/cjs/util/environment.js.map +1 -0
- package/lib/cjs/util/error-boundary.js +47 -0
- package/lib/cjs/util/error-boundary.js.map +1 -0
- package/lib/cjs/util/index.d.ts +0 -0
- package/lib/cjs/util/index.js +2 -0
- package/lib/cjs/util/index.js.map +1 -0
- package/lib/cjs/util/logs.d.ts +2 -0
- package/lib/cjs/util/logs.js +20 -0
- package/lib/cjs/util/logs.js.map +1 -0
- package/lib/cjs/util/objects.d.ts +3 -0
- package/lib/cjs/util/objects.js +44 -0
- package/lib/cjs/util/objects.js.map +1 -0
- package/lib/cjs/util/react.d.ts +12 -0
- package/lib/cjs/util/react.js +42 -0
- package/lib/cjs/util/react.js.map +1 -0
- package/lib/cjs/util/regexs.d.ts +2 -0
- package/lib/cjs/util/regexs.js +23 -0
- package/lib/cjs/util/regexs.js.map +1 -0
- package/lib/cjs/util/webchat.d.ts +11 -0
- package/lib/cjs/util/webchat.js +62 -0
- package/lib/cjs/util/webchat.js.map +1 -0
- package/lib/cjs/webchat/actions.d.ts +23 -0
- package/lib/cjs/webchat/actions.js +27 -0
- package/lib/cjs/webchat/actions.js.map +1 -0
- package/lib/cjs/webchat/components/attachment.d.ts +5 -0
- package/lib/cjs/webchat/components/attachment.js +32 -0
- package/lib/cjs/webchat/components/attachment.js.map +1 -0
- package/lib/cjs/webchat/components/common.d.ts +1 -0
- package/lib/cjs/webchat/components/common.js +13 -0
- package/lib/cjs/webchat/components/common.js.map +1 -0
- package/lib/cjs/webchat/components/conditional-animation.d.ts +1 -0
- package/lib/cjs/webchat/components/conditional-animation.js +18 -0
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -0
- package/lib/cjs/webchat/components/emoji-picker.d.ts +5 -0
- package/lib/cjs/webchat/components/emoji-picker.js +52 -0
- package/lib/cjs/webchat/components/emoji-picker.js.map +1 -0
- package/lib/cjs/webchat/components/persistent-menu.d.ts +10 -0
- package/lib/cjs/webchat/components/persistent-menu.js +59 -0
- package/lib/cjs/webchat/components/persistent-menu.js.map +1 -0
- package/lib/cjs/webchat/components/send-button.d.ts +3 -0
- package/lib/cjs/webchat/components/send-button.js +24 -0
- package/lib/cjs/webchat/components/send-button.js.map +1 -0
- package/lib/cjs/webchat/components/styled-scrollbar.d.ts +1 -0
- package/lib/cjs/webchat/components/styled-scrollbar.js +54 -0
- package/lib/cjs/webchat/components/styled-scrollbar.js.map +1 -0
- package/lib/cjs/webchat/components/typing-indicator.d.ts +1 -0
- package/lib/cjs/webchat/components/typing-indicator.js +14 -0
- package/lib/cjs/webchat/components/typing-indicator.js.map +1 -0
- package/lib/cjs/webchat/devices/device-adapter.d.ts +12 -0
- package/lib/cjs/webchat/devices/device-adapter.js +47 -0
- package/lib/cjs/webchat/devices/device-adapter.js.map +1 -0
- package/lib/cjs/webchat/devices/index.d.ts +11 -0
- package/lib/cjs/webchat/devices/index.js +23 -0
- package/lib/cjs/webchat/devices/index.js.map +1 -0
- package/lib/cjs/webchat/devices/scrollbar-controller.d.ts +12 -0
- package/lib/cjs/webchat/devices/scrollbar-controller.js +103 -0
- package/lib/cjs/webchat/devices/scrollbar-controller.js.map +1 -0
- package/lib/cjs/webchat/devices/webchat-resizer.d.ts +9 -0
- package/lib/cjs/webchat/devices/webchat-resizer.js +47 -0
- package/lib/cjs/webchat/devices/webchat-resizer.js.map +1 -0
- package/lib/cjs/webchat/header.d.ts +3 -0
- package/lib/cjs/webchat/header.js +95 -0
- package/lib/cjs/webchat/header.js.map +1 -0
- package/lib/cjs/webchat/hooks.d.ts +80 -0
- package/lib/cjs/webchat/hooks.js +218 -0
- package/lib/cjs/webchat/hooks.js.map +1 -0
- package/lib/cjs/webchat/index.d.ts +4 -0
- package/lib/cjs/webchat/index.js +17 -0
- package/lib/cjs/webchat/index.js.map +1 -0
- package/lib/cjs/webchat/message-list.d.ts +1 -0
- package/lib/cjs/webchat/message-list.js +46 -0
- package/lib/cjs/webchat/message-list.js.map +1 -0
- package/lib/cjs/webchat/messages-reducer.d.ts +1 -0
- package/lib/cjs/webchat/messages-reducer.js +58 -0
- package/lib/cjs/webchat/messages-reducer.js.map +1 -0
- package/lib/cjs/webchat/replies.d.ts +1 -0
- package/lib/cjs/webchat/replies.js +46 -0
- package/lib/cjs/webchat/replies.js.map +1 -0
- package/lib/cjs/webchat/session-view.d.ts +1 -0
- package/lib/cjs/webchat/session-view.js +124 -0
- package/lib/cjs/webchat/session-view.js.map +1 -0
- package/lib/cjs/webchat/use-storage-state-hook.d.ts +1 -0
- package/lib/cjs/webchat/use-storage-state-hook.js +32 -0
- package/lib/cjs/webchat/use-storage-state-hook.js.map +1 -0
- package/lib/cjs/webchat/webchat-dev.d.ts +7 -0
- package/lib/cjs/webchat/webchat-dev.js +64 -0
- package/lib/cjs/webchat/webchat-dev.js.map +1 -0
- package/lib/cjs/webchat/webchat-reducer.d.ts +1 -0
- package/lib/cjs/webchat/webchat-reducer.js +48 -0
- package/lib/cjs/webchat/webchat-reducer.js.map +1 -0
- package/lib/cjs/webchat/webchat.d.ts +3 -0
- package/lib/cjs/webchat/webchat.js +703 -0
- package/lib/cjs/webchat/webchat.js.map +1 -0
- package/lib/cjs/webchat/webview.d.ts +2 -0
- package/lib/cjs/webchat/webview.js +92 -0
- package/lib/cjs/webchat/webview.js.map +1 -0
- package/lib/cjs/webchat-app.d.ts +99 -0
- package/lib/cjs/webchat-app.js +269 -0
- package/lib/cjs/webchat-app.js.map +1 -0
- package/lib/cjs/webview.d.ts +9 -0
- package/lib/cjs/webview.js +102 -0
- package/lib/cjs/webview.js.map +1 -0
- package/package.json +3 -3
- package/lib/app.js +0 -19
- package/lib/app.js.map +0 -1
- package/lib/assets/attachment-icon.svg +0 -7
- package/lib/assets/audio.svg +0 -4
- package/lib/assets/botonic_react_logo100x100.png +0 -0
- package/lib/assets/document.svg +0 -3
- package/lib/assets/emojiButton.svg +0 -6
- package/lib/assets/image.svg +0 -4
- package/lib/assets/leftArrow.svg +0 -3
- package/lib/assets/menuButton.svg +0 -3
- package/lib/assets/rightArrow.svg +0 -3
- package/lib/assets/send-button.svg +0 -1
- package/lib/assets/video.svg +0 -3
- package/lib/botonic-tester.js +0 -224
- package/lib/botonic-tester.js.map +0 -1
- package/lib/components/audio.js +0 -48
- package/lib/components/audio.js.map +0 -1
- package/lib/components/button.js +0 -224
- package/lib/components/button.js.map +0 -1
- package/lib/components/buttons-disabler.js +0 -133
- package/lib/components/buttons-disabler.js.map +0 -1
- package/lib/components/carousel.js +0 -194
- package/lib/components/carousel.js.map +0 -1
- package/lib/components/components.js.map +0 -1
- package/lib/components/custom-message.js +0 -131
- package/lib/components/custom-message.js.map +0 -1
- package/lib/components/document.js +0 -76
- package/lib/components/document.js.map +0 -1
- package/lib/components/element.js +0 -69
- package/lib/components/element.js.map +0 -1
- package/lib/components/handoff.js +0 -69
- package/lib/components/handoff.js.map +0 -1
- package/lib/components/image.js +0 -91
- package/lib/components/image.js.map +0 -1
- package/lib/components/index.d.ts +0 -228
- package/lib/components/index.js +0 -193
- package/lib/components/index.js.map +0 -1
- package/lib/components/location.js +0 -69
- package/lib/components/location.js.map +0 -1
- package/lib/components/markdown.js +0 -108
- package/lib/components/markdown.js.map +0 -1
- package/lib/components/message-template.js +0 -36
- package/lib/components/message-template.js.map +0 -1
- package/lib/components/message.js +0 -351
- package/lib/components/message.js.map +0 -1
- package/lib/components/multichannel/facebook/facebook.js +0 -96
- package/lib/components/multichannel/facebook/facebook.js.map +0 -1
- package/lib/components/multichannel/index.d.ts +0 -65
- package/lib/components/multichannel/index.js +0 -46
- package/lib/components/multichannel/index.js.map +0 -1
- package/lib/components/multichannel/multichannel-button.js +0 -119
- package/lib/components/multichannel/multichannel-button.js.map +0 -1
- package/lib/components/multichannel/multichannel-carousel.js +0 -143
- package/lib/components/multichannel/multichannel-carousel.js.map +0 -1
- package/lib/components/multichannel/multichannel-context.js +0 -24
- package/lib/components/multichannel/multichannel-context.js.map +0 -1
- package/lib/components/multichannel/multichannel-reply.js +0 -46
- package/lib/components/multichannel/multichannel-reply.js.map +0 -1
- package/lib/components/multichannel/multichannel-text.js +0 -222
- package/lib/components/multichannel/multichannel-text.js.map +0 -1
- package/lib/components/multichannel/multichannel-utils.js +0 -126
- package/lib/components/multichannel/multichannel-utils.js.map +0 -1
- package/lib/components/multichannel/multichannel.js +0 -111
- package/lib/components/multichannel/multichannel.js.map +0 -1
- package/lib/components/pic.js +0 -50
- package/lib/components/pic.js.map +0 -1
- package/lib/components/raw.js +0 -70
- package/lib/components/raw.js.map +0 -1
- package/lib/components/reply.js +0 -107
- package/lib/components/reply.js.map +0 -1
- package/lib/components/share-button.js +0 -36
- package/lib/components/share-button.js.map +0 -1
- package/lib/components/subtitle.js +0 -54
- package/lib/components/subtitle.js.map +0 -1
- package/lib/components/text.js +0 -80
- package/lib/components/text.js.map +0 -1
- package/lib/components/timestamps.js +0 -69
- package/lib/components/timestamps.js.map +0 -1
- package/lib/components/title.js +0 -52
- package/lib/components/title.js.map +0 -1
- package/lib/components/video.js +0 -51
- package/lib/components/video.js.map +0 -1
- package/lib/components/webchat-settings.js +0 -118
- package/lib/components/webchat-settings.js.map +0 -1
- package/lib/components/whatsapp-template.js +0 -53
- package/lib/components/whatsapp-template.js.map +0 -1
- package/lib/constants.js +0 -203
- package/lib/constants.js.map +0 -1
- package/lib/contexts.js +0 -57
- package/lib/contexts.js.map +0 -1
- package/lib/dev-app.js +0 -241
- package/lib/dev-app.js.map +0 -1
- package/lib/index.d.ts +0 -238
- package/lib/index.js +0 -131
- package/lib/index.js.map +0 -1
- package/lib/message-utils.js +0 -149
- package/lib/message-utils.js.map +0 -1
- package/lib/msg-to-botonic.js +0 -199
- package/lib/msg-to-botonic.js.map +0 -1
- package/lib/node-app.js +0 -97
- package/lib/node-app.js.map +0 -1
- package/lib/react-bot.js +0 -167
- package/lib/react-bot.js.map +0 -1
- package/lib/util/dom.js +0 -84
- package/lib/util/dom.js.map +0 -1
- package/lib/util/environment.js +0 -42
- package/lib/util/environment.js.map +0 -1
- package/lib/util/error-boundary.js +0 -105
- package/lib/util/error-boundary.js.map +0 -1
- package/lib/util/index.d.ts +0 -9
- package/lib/util/index.js +0 -2
- package/lib/util/index.js.map +0 -1
- package/lib/util/logs.js +0 -28
- package/lib/util/logs.js.map +0 -1
- package/lib/util/objects.js +0 -60
- package/lib/util/objects.js.map +0 -1
- package/lib/util/react.js +0 -75
- package/lib/util/react.js.map +0 -1
- package/lib/util/regexs.js +0 -31
- package/lib/util/regexs.js.map +0 -1
- package/lib/util/webchat.js +0 -92
- package/lib/util/webchat.js.map +0 -1
- package/lib/webchat/actions.js +0 -53
- package/lib/webchat/actions.js.map +0 -1
- package/lib/webchat/components/attachment.js +0 -68
- package/lib/webchat/components/attachment.js.map +0 -1
- package/lib/webchat/components/common.js +0 -29
- package/lib/webchat/components/common.js.map +0 -1
- package/lib/webchat/components/conditional-animation.js +0 -42
- package/lib/webchat/components/conditional-animation.js.map +0 -1
- package/lib/webchat/components/emoji-picker.js +0 -89
- package/lib/webchat/components/emoji-picker.js.map +0 -1
- package/lib/webchat/components/persistent-menu.js +0 -104
- package/lib/webchat/components/persistent-menu.js.map +0 -1
- package/lib/webchat/components/send-button.js +0 -45
- package/lib/webchat/components/send-button.js.map +0 -1
- package/lib/webchat/components/styled-scrollbar.js +0 -55
- package/lib/webchat/components/styled-scrollbar.js.map +0 -1
- package/lib/webchat/components/styled-scrollbar.scss +0 -12
- package/lib/webchat/components/typing-indicator.js +0 -27
- package/lib/webchat/components/typing-indicator.js.map +0 -1
- package/lib/webchat/components/typing-indicator.scss +0 -38
- package/lib/webchat/devices/device-adapter.js +0 -82
- package/lib/webchat/devices/device-adapter.js.map +0 -1
- package/lib/webchat/devices/index.js +0 -32
- package/lib/webchat/devices/index.js.map +0 -1
- package/lib/webchat/devices/scrollbar-controller.js +0 -152
- package/lib/webchat/devices/scrollbar-controller.js.map +0 -1
- package/lib/webchat/devices/webchat-resizer.js +0 -76
- package/lib/webchat/devices/webchat-resizer.js.map +0 -1
- package/lib/webchat/header.js +0 -116
- package/lib/webchat/header.js.map +0 -1
- package/lib/webchat/hooks.js +0 -359
- package/lib/webchat/hooks.js.map +0 -1
- package/lib/webchat/index.d.ts +0 -62
- package/lib/webchat/index.js +0 -32
- package/lib/webchat/index.js.map +0 -1
- package/lib/webchat/message-list.js +0 -88
- package/lib/webchat/message-list.js.map +0 -1
- package/lib/webchat/messages-reducer.js +0 -93
- package/lib/webchat/messages-reducer.js.map +0 -1
- package/lib/webchat/replies.js +0 -78
- package/lib/webchat/replies.js.map +0 -1
- package/lib/webchat/session-view.js +0 -106
- package/lib/webchat/session-view.js.map +0 -1
- package/lib/webchat/use-storage-state-hook.js +0 -60
- package/lib/webchat/use-storage-state-hook.js.map +0 -1
- package/lib/webchat/webchat-dev.js +0 -109
- package/lib/webchat/webchat-dev.js.map +0 -1
- package/lib/webchat/webchat-reducer.js +0 -108
- package/lib/webchat/webchat-reducer.js.map +0 -1
- package/lib/webchat/webchat.js +0 -1108
- package/lib/webchat/webchat.js.map +0 -1
- package/lib/webchat/webview.js +0 -122
- package/lib/webchat/webview.js.map +0 -1
- package/lib/webchat-app.js +0 -660
- package/lib/webchat-app.js.map +0 -1
- package/lib/webchat.template.html +0 -37
- package/lib/webview.js +0 -231
- package/lib/webview.js.map +0 -1
- package/lib/webview.template.html +0 -39
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.MultichannelFacebook = exports.MAX_CHARACTERS_FACEBOOK = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
|
-
var MAX_CHARACTERS_FACEBOOK = 640;
|
|
21
|
-
exports.MAX_CHARACTERS_FACEBOOK = MAX_CHARACTERS_FACEBOOK;
|
|
22
|
-
|
|
23
|
-
var MultichannelFacebook = /*#__PURE__*/function () {
|
|
24
|
-
function MultichannelFacebook() {
|
|
25
|
-
(0, _classCallCheck2["default"])(this, MultichannelFacebook);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
(0, _createClass2["default"])(MultichannelFacebook, [{
|
|
29
|
-
key: "convertText",
|
|
30
|
-
value: function convertText(props, originalText) {
|
|
31
|
-
if (originalText.length > MAX_CHARACTERS_FACEBOOK) {
|
|
32
|
-
var texts = this.splitText(originalText);
|
|
33
|
-
var lastText = texts.pop();
|
|
34
|
-
|
|
35
|
-
var _this$getNewProps = this.getNewProps(props, lastText),
|
|
36
|
-
propsLastText = _this$getNewProps.propsLastText,
|
|
37
|
-
propsWithoutChildren = _this$getNewProps.propsWithoutChildren;
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
texts: texts,
|
|
41
|
-
propsLastText: propsLastText,
|
|
42
|
-
propsWithoutChildren: propsWithoutChildren
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
propsLastText: props
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}, {
|
|
51
|
-
key: "splitText",
|
|
52
|
-
value: function splitText(originalText) {
|
|
53
|
-
var lines = originalText.split('\n');
|
|
54
|
-
var initialText = lines.shift();
|
|
55
|
-
var texts = [initialText];
|
|
56
|
-
var index = 0;
|
|
57
|
-
lines.forEach(function (currentText) {
|
|
58
|
-
if (texts[index].length + currentText.length > MAX_CHARACTERS_FACEBOOK) {
|
|
59
|
-
index++;
|
|
60
|
-
texts.push(currentText);
|
|
61
|
-
} else {
|
|
62
|
-
texts[index] = texts[index].concat('\n', currentText);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
return texts;
|
|
66
|
-
} // modifies the props to keep the children only for the last text message, this message will be the one with buttons and replies
|
|
67
|
-
|
|
68
|
-
}, {
|
|
69
|
-
key: "getNewProps",
|
|
70
|
-
value: function getNewProps(props, lastText) {
|
|
71
|
-
var propsLastText = _objectSpread({}, props);
|
|
72
|
-
|
|
73
|
-
propsLastText.children = [lastText];
|
|
74
|
-
|
|
75
|
-
if (Array.isArray(props.children)) {
|
|
76
|
-
props.children.filter(function (e) {
|
|
77
|
-
return e.type;
|
|
78
|
-
}).forEach(function (e) {
|
|
79
|
-
return propsLastText.children.push(e);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
var propsWithoutChildren = _objectSpread({}, props);
|
|
84
|
-
|
|
85
|
-
delete propsWithoutChildren.children;
|
|
86
|
-
return {
|
|
87
|
-
propsLastText: propsLastText,
|
|
88
|
-
propsWithoutChildren: propsWithoutChildren
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}]);
|
|
92
|
-
return MultichannelFacebook;
|
|
93
|
-
}();
|
|
94
|
-
|
|
95
|
-
exports.MultichannelFacebook = MultichannelFacebook;
|
|
96
|
-
//# sourceMappingURL=facebook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/multichannel/facebook/facebook.jsx"],"names":["MAX_CHARACTERS_FACEBOOK","MultichannelFacebook","props","originalText","length","texts","splitText","lastText","pop","getNewProps","propsLastText","propsWithoutChildren","lines","split","initialText","shift","index","forEach","currentText","push","concat","children","Array","isArray","filter","e","type"],"mappings":";;;;;;;;;;;;;;;;;;;AAAO,IAAMA,uBAAuB,GAAG,GAAhC;;;IAEMC,oB;AACX,kCAAc;AAAA;AAAE;;;;WAEhB,qBAAYC,KAAZ,EAAmBC,YAAnB,EAAiC;AAC/B,UAAIA,YAAY,CAACC,MAAb,GAAsBJ,uBAA1B,EAAmD;AACjD,YAAMK,KAAK,GAAG,KAAKC,SAAL,CAAeH,YA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C;AACjCnB,QAAAA,KAAK,CAACmB,QAAN,CACGG,MADH,CACU,UAAAC,CAAC;AAAA,iBAAIA,CAAC,CAACC,IAAN;AAAA,SADX,EAEGT,OAFH,CAEW,UAAAQ,CAAC;AAAA,iBAAIf,aAAa,CAACW,QAAd,CAAuBF,IAAvB,CAA4BM,CAA5B,CAAJ;AAAA,SAFZ;AAGD;;AACD,UAAMd,oBAAoB,qBAAQT,KAAR,CAA1B;;AACA,aAAOS,oBAAoB,CAACU,QAA5B;AACA,aAAO;AAAEX,QAAAA,aAAa,EAAbA,aAAF;AAAiBC,QAAAA,oBAAoB,EAApBA;AAAjB,OAAP;AACD","sourcesContent":["export const MAX_CHARACTERS_FACEBOOK = 640\n\nexport class MultichannelFacebook {\n constructor() {}\n\n convertText(props, originalText) {\n if (originalText.length > MAX_CHARACTERS_FACEBOOK) {\n const texts = this.splitText(originalText)\n const lastText = texts.pop()\n const { propsLastText, propsWithoutChildren } = this.getNewProps(\n props,\n lastText\n )\n return { texts, propsLastText, propsWithoutChildren }\n }\n return { propsLastText: props }\n }\n\n splitText(originalText) {\n const lines = originalText.split('\\n')\n const initialText = lines.shift()\n const texts = [initialText]\n let index = 0\n lines.forEach(currentText => {\n if (texts[index].length + currentText.length > MAX_CHARACTERS_FACEBOOK) {\n index++\n texts.push(currentText)\n } else {\n texts[index] = texts[index].concat('\\n', currentText)\n }\n })\n return texts\n }\n\n // modifies the props to keep the children only for the last text message, this message will be the one with buttons and replies\n getNewProps(props, lastText) {\n const propsLastText = { ...props }\n propsLastText.children = [lastText]\n if (Array.isArray(props.children)) {\n props.children\n .filter(e => e.type)\n .forEach(e => propsLastText.children.push(e))\n }\n const propsWithoutChildren = { ...props }\n delete propsWithoutChildren.children\n return { propsLastText, propsWithoutChildren }\n }\n}\n"],"file":"facebook.js"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
|
|
3
|
-
type IndexMode = 'number' | 'letter' | undefined //undefined means no index
|
|
4
|
-
|
|
5
|
-
export interface MultichannelViewOptions {
|
|
6
|
-
boldIndex?: boolean
|
|
7
|
-
indexSeparator?: string // after it, a space will always be added
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface MultichannelContextType extends MultichannelViewOptions {
|
|
11
|
-
currentIndex: number | string // can be letter or number
|
|
12
|
-
/** @see same field at MultichannelProps */
|
|
13
|
-
messageSeparator?: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// Text
|
|
17
|
-
export interface MultichannelTextProps extends MultichannelViewOptions {
|
|
18
|
-
index?: string
|
|
19
|
-
indexMode?: IndexMode
|
|
20
|
-
/** Defaults to no separator between lines*/
|
|
21
|
-
newline?: string
|
|
22
|
-
buttonsAsText?: boolean
|
|
23
|
-
buttonsTextSeparator?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const MultichannelText: React.FunctionComponent<MultichannelTextProps>
|
|
27
|
-
|
|
28
|
-
// Carousel
|
|
29
|
-
export interface MultichannelCarouselProps extends MultichannelViewOptions {
|
|
30
|
-
enableURL?: boolean
|
|
31
|
-
indexMode?: IndexMode
|
|
32
|
-
showTitle?: boolean
|
|
33
|
-
showSubtitle?: boolean
|
|
34
|
-
buttonsAsText?: boolean
|
|
35
|
-
}
|
|
36
|
-
export const MultichannelCarousel: React.FunctionComponent<MultichannelCarouselProps>
|
|
37
|
-
|
|
38
|
-
// Button
|
|
39
|
-
export interface MultichannelButtonProps {
|
|
40
|
-
newline?: string
|
|
41
|
-
path?: string
|
|
42
|
-
payload?: string
|
|
43
|
-
url?: string
|
|
44
|
-
webview?: string
|
|
45
|
-
asText?: boolean
|
|
46
|
-
}
|
|
47
|
-
export const MultichannelButton: React.FunctionComponent<MultichannelButtonProps>
|
|
48
|
-
|
|
49
|
-
// Reply
|
|
50
|
-
export const MultichannelReply: React.FunctionComponent<MultichannelButtonProps>
|
|
51
|
-
|
|
52
|
-
export interface MultichannelProps extends MultichannelViewOptions {
|
|
53
|
-
firstIndex?: number | string
|
|
54
|
-
carousel?: MultichannelCarouselProps
|
|
55
|
-
text?: MultichannelTextProps
|
|
56
|
-
/**
|
|
57
|
-
* If undefined, each component will be served in a different botonic message
|
|
58
|
-
* '' will concatenate in the same line
|
|
59
|
-
* '\n' will split in different lines
|
|
60
|
-
* '\n\n' will separate with an empty line
|
|
61
|
-
**/
|
|
62
|
-
messageSeparator?: string
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const Multichannel: React.FunctionComponent<MultichannelProps>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Multichannel", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _multichannel.Multichannel;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "MultichannelButton", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _multichannelButton.MultichannelButton;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "MultichannelCarousel", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function get() {
|
|
21
|
-
return _multichannelCarousel.MultichannelCarousel;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "MultichannelReply", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _multichannelReply.MultichannelReply;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "MultichannelText", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _multichannelText.MultichannelText;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var _multichannel = require("./multichannel");
|
|
38
|
-
|
|
39
|
-
var _multichannelButton = require("./multichannel-button");
|
|
40
|
-
|
|
41
|
-
var _multichannelCarousel = require("./multichannel-carousel");
|
|
42
|
-
|
|
43
|
-
var _multichannelReply = require("./multichannel-reply");
|
|
44
|
-
|
|
45
|
-
var _multichannelText = require("./multichannel-text");
|
|
46
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/multichannel/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["import { Multichannel } from './multichannel'\nimport { MultichannelButton } from './multichannel-button'\nimport { MultichannelCarousel } from './multichannel-carousel'\nimport { MultichannelReply } from './multichannel-reply'\nimport { MultichannelText } from './multichannel-text'\n\nexport { Multichannel }\nexport { MultichannelText }\nexport { MultichannelButton }\nexport { MultichannelReply }\nexport { MultichannelCarousel }\n"],"file":"index.js"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.MultichannelButton = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _contexts = require("../../contexts");
|
|
13
|
-
|
|
14
|
-
var _button = require("../button");
|
|
15
|
-
|
|
16
|
-
var _multichannelContext = require("./multichannel-context");
|
|
17
|
-
|
|
18
|
-
var _multichannelUtils = require("./multichannel-utils");
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
var MultichannelButton = function MultichannelButton(props) {
|
|
25
|
-
var requestContext = (0, _react.useContext)(_contexts.RequestContext);
|
|
26
|
-
var multichannelContext = (0, _react.useContext)(_multichannelContext.MultichannelContext);
|
|
27
|
-
|
|
28
|
-
var hasUrl = function hasUrl() {
|
|
29
|
-
return Boolean(props.url);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var hasPath = function hasPath() {
|
|
33
|
-
return Boolean(props.path);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
var hasPayload = function hasPayload() {
|
|
37
|
-
return Boolean(props.payload);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var hasPostback = function hasPostback() {
|
|
41
|
-
return hasPath() || hasPayload();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
var hasWebview = function hasWebview() {
|
|
45
|
-
return Boolean(props.webview);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
var getUrl = function getUrl() {
|
|
49
|
-
return props.url;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
var getWebview = function getWebview() {
|
|
53
|
-
return props.webview;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
var increaseCurrentIndex = function increaseCurrentIndex() {
|
|
57
|
-
if (typeof multichannelContext.currentIndex === 'number') {
|
|
58
|
-
multichannelContext.currentIndex += 1;
|
|
59
|
-
} else if (typeof multichannelContext.currentIndex === 'string') {
|
|
60
|
-
var lastChar = multichannelContext.currentIndex.charCodeAt(multichannelContext.currentIndex.length - 1);
|
|
61
|
-
multichannelContext.currentIndex = String.fromCharCode(lastChar + 1);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
var formatIndex = function formatIndex(index) {
|
|
66
|
-
var _multichannelContext$;
|
|
67
|
-
|
|
68
|
-
var boldIndex = (_multichannelContext$ = multichannelContext.boldIndex) !== null && _multichannelContext$ !== void 0 ? _multichannelContext$ : false;
|
|
69
|
-
return boldIndex ? "*".concat(index, "*") : index;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
var getText = function getText() {
|
|
73
|
-
var text = props.children;
|
|
74
|
-
var newline = props.newline || '';
|
|
75
|
-
var separator = multichannelContext.indexSeparator || ' ';
|
|
76
|
-
var index = multichannelContext.currentIndex ? "".concat(formatIndex(multichannelContext.currentIndex + separator), " ") : '';
|
|
77
|
-
|
|
78
|
-
if (hasPostback()) {
|
|
79
|
-
text = newline + "".concat(index).concat(text);
|
|
80
|
-
} else if (hasUrl()) {
|
|
81
|
-
text = newline + "- ".concat(text);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return text;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
var truncateText = function truncateText(text, maxLength) {
|
|
88
|
-
var ellipsis = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '...';
|
|
89
|
-
|
|
90
|
-
if (text.length > maxLength) {
|
|
91
|
-
return text.substring(0, maxLength - ellipsis.length) + ellipsis;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return text;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
if ((0, _multichannelUtils.isWhatsapp)(requestContext)) {
|
|
98
|
-
var _props$asText;
|
|
99
|
-
|
|
100
|
-
var asText = (_props$asText = props.asText) !== null && _props$asText !== void 0 ? _props$asText : true;
|
|
101
|
-
|
|
102
|
-
if (asText) {
|
|
103
|
-
if (hasUrl()) {
|
|
104
|
-
return "".concat(getText(), ": ").concat(getUrl());
|
|
105
|
-
} else if (hasPath() || hasPayload()) {
|
|
106
|
-
var text = getText();
|
|
107
|
-
increaseCurrentIndex();
|
|
108
|
-
return "".concat(text);
|
|
109
|
-
} else if (hasWebview()) return /*#__PURE__*/_react["default"].createElement(_button.Button, props, getText());
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return /*#__PURE__*/_react["default"].createElement(_button.Button, props, truncateText(props.children, _multichannelUtils.WHATSAPP_MAX_BUTTON_CHARS));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return /*#__PURE__*/_react["default"].createElement(_button.Button, props, props.children);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
exports.MultichannelButton = MultichannelButton;
|
|
119
|
-
//# sourceMappingURL=multichannel-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/multichannel/multichannel-button.jsx"],"names":["MultichannelButton","props","requestContext","RequestContext","multichannelContext","MultichannelContext","hasUrl","Boolean","url","hasPath","path","hasPayload","payload","hasPostback","hasWebview","webview","getUrl","getWebview","increaseCurrentIndex","currentIndex","lastChar","charCodeAt","length","String","fromCharCode","formatIndex","index","boldIndex","getText","text","children","newline","separator","indexSeparator","truncateText","maxLength","ellipsis","substring","asText","WHATSAPP_MAX_BUTTON_CHARS"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAEO,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAAAC,KAAK,EAAI;AACzC,MAAMC,cAAc,GAAG,uBAAWC,wBAAX,CAAvB;AACA,MAAMC,mBAAmB,GAAG,uBAAWC,wCAAX,CAA5B;;AAEA,MAAMC,MAAM,GAAG,SAATA,MAAS;AAAA,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AI,GAAGD,OAAO,EAApB;AACAV,QAAAA,oBAAoB;AACpB,yBAAUW,IAAV;AACD,OAJM,MAIA,IAAIf,UAAU,EAAd,EAAkB,oBAAO,gCAAC,cAAD,EAAYb,KAAZ,EAAoB2B,OAAO,EAA3B,CAAP;AAC1B;;AACD,wBACE,gCAAC,cAAD,EAAY3B,KAAZ,EACGiC,YAAY,CAACjC,KAAK,CAAC6B,QAAP,EAAiBS,4CAAjB,CADf,CADF;AAKD;;AACD,sBAAO,gCAAC,cAAD,EAAYtC,KAAZ,EAAoBA,KAAK,CAAC6B,QAA1B,CAAP;AACD,CAzEM","sourcesContent":["import React, { useContext } from 'react'\n\nimport { RequestContext } from '../../contexts'\nimport { Button } from '../button'\nimport { MultichannelContext } from './multichannel-context'\nimport { isWhatsapp, WHATSAPP_MAX_BUTTON_CHARS } from './multichannel-utils'\n\nexport const MultichannelButton = props => {\n const requestContext = useContext(RequestContext)\n const multichannelContext = useContext(MultichannelContext)\n\n const hasUrl = () => Boolean(props.url)\n\n const hasPath = () => Boolean(props.path)\n\n const hasPayload = () => Boolean(props.payload)\n\n const hasPostback = () => hasPath() || hasPayload()\n\n const hasWebview = () => Boolean(props.webview)\n\n const getUrl = () => props.url\n const getWebview = () => props.webview\n\n const increaseCurrentIndex = () => {\n if (typeof multichannelContext.currentIndex === 'number') {\n multichannelContext.currentIndex += 1\n } else if (typeof multichannelContext.currentIndex === 'string') {\n const lastChar = multichannelContext.currentIndex.charCodeAt(\n multichannelContext.currentIndex.length - 1\n )\n multichannelContext.currentIndex = String.fromCharCode(lastChar + 1)\n }\n }\n\n const formatIndex = index => {\n const boldIndex = multichannelContext.boldIndex ?? false\n return boldIndex ? `*${index}*` : index\n }\n\n const getText = () => {\n let text = props.children\n const newline = props.newline || ''\n const separator = multichannelContext.indexSeparator || ' '\n const index = multichannelContext.currentIndex\n ? `${formatIndex(multichannelContext.currentIndex + separator)} `\n : ''\n if (hasPostback()) {\n text = newline + `${index}${text}`\n } else if (hasUrl()) {\n text = newline + `- ${text}`\n }\n return text\n }\n\n const truncateText = (text, maxLength, ellipsis = '...') => {\n if (text.length > maxLength) {\n return text.substring(0, maxLength - ellipsis.length) + ellipsis\n }\n return text\n }\n\n if (isWhatsapp(requestContext)) {\n const asText = props.asText ?? true\n if (asText) {\n if (hasUrl()) {\n return `${getText()}: ${getUrl()}`\n } else if (hasPath() || hasPayload()) {\n const text = getText()\n increaseCurrentIndex()\n return `${text}`\n } else if (hasWebview()) return <Button {...props}>{getText()}</Button>\n }\n return (\n <Button {...props}>\n {truncateText(props.children, WHATSAPP_MAX_BUTTON_CHARS)}\n </Button>\n )\n }\n return <Button {...props}>{props.children}</Button>\n}\n"],"file":"multichannel-button.js"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.MultichannelCarousel = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _contexts = require("../../contexts");
|
|
13
|
-
|
|
14
|
-
var _carousel = require("../carousel");
|
|
15
|
-
|
|
16
|
-
var _multichannelText = require("./multichannel-text");
|
|
17
|
-
|
|
18
|
-
var _multichannelUtils = require("./multichannel-utils");
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
25
|
-
|
|
26
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
-
|
|
28
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
-
|
|
30
|
-
var MultichannelCarousel = function MultichannelCarousel(props) {
|
|
31
|
-
var requestContext = (0, _react.useContext)(_contexts.RequestContext);
|
|
32
|
-
|
|
33
|
-
var getButtons = function getButtons(node) {
|
|
34
|
-
return [].concat((0, _multichannelUtils.getFilteredElements)(node, _multichannelUtils.isMultichannelButton));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
if ((0, _multichannelUtils.isWhatsapp)(requestContext)) {
|
|
38
|
-
var elements = props.children.map(function (e) {
|
|
39
|
-
return e.props.children;
|
|
40
|
-
}).map(function (element, i) {
|
|
41
|
-
var imageProps = undefined;
|
|
42
|
-
var title = undefined;
|
|
43
|
-
var subtitle = undefined;
|
|
44
|
-
var buttons = [];
|
|
45
|
-
|
|
46
|
-
var _iterator = _createForOfIteratorHelper(element),
|
|
47
|
-
_step;
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
51
|
-
var node = _step.value;
|
|
52
|
-
|
|
53
|
-
if ((0, _multichannelUtils.isNodeKind)(node, 'Pic')) {
|
|
54
|
-
imageProps = node.props;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if ((0, _multichannelUtils.isNodeKind)(node, 'Title')) {
|
|
58
|
-
title = node.props.children;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if ((0, _multichannelUtils.isNodeKind)(node, 'Subtitle')) {
|
|
62
|
-
subtitle = node.props.children;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if ((0, _multichannelUtils.isNodeKind)(node, 'MultichannelButton')) {
|
|
66
|
-
buttons.push(node);
|
|
67
|
-
} //TODO support fragment containing an array
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (Array.isArray(node)) {
|
|
71
|
-
buttons.push(getButtons(node));
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} catch (err) {
|
|
75
|
-
_iterator.e(err);
|
|
76
|
-
} finally {
|
|
77
|
-
_iterator.f();
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
var header = '';
|
|
81
|
-
|
|
82
|
-
if (props.showTitle && title) {
|
|
83
|
-
header += "".concat(title ? "*".concat(title, "*") : '');
|
|
84
|
-
|
|
85
|
-
if (title && subtitle) {
|
|
86
|
-
header += ' ';
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (props.showSubtitle && subtitle) {
|
|
91
|
-
header += "_".concat(subtitle, "_");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
/*#__PURE__*/
|
|
96
|
-
// TODO: newkey only for 1 nested button
|
|
97
|
-
_react["default"].createElement(_multichannelText.MultichannelText, {
|
|
98
|
-
key: i,
|
|
99
|
-
newkey: i,
|
|
100
|
-
indexMode: props.indexMode,
|
|
101
|
-
buttonsAsText: props.buttonsAsText
|
|
102
|
-
}, header || null, buttons)
|
|
103
|
-
); // TODO: in the future, this would be the default mode
|
|
104
|
-
// } else {
|
|
105
|
-
// return (
|
|
106
|
-
// <React.Fragment key={i}>
|
|
107
|
-
// <Image
|
|
108
|
-
// src={imageSrc}
|
|
109
|
-
// caption={carouselToCaption(
|
|
110
|
-
// i + 1,
|
|
111
|
-
// title,
|
|
112
|
-
// subtitle,
|
|
113
|
-
// imageSrc,
|
|
114
|
-
// buttonProps
|
|
115
|
-
// )}
|
|
116
|
-
// ></Image>
|
|
117
|
-
// </React.Fragment>
|
|
118
|
-
// )
|
|
119
|
-
// }
|
|
120
|
-
});
|
|
121
|
-
return elements;
|
|
122
|
-
} else {
|
|
123
|
-
return /*#__PURE__*/_react["default"].createElement(_carousel.Carousel, props, props.children);
|
|
124
|
-
}
|
|
125
|
-
}; // const carouselToCaption = (index, title, subtitle, imageSrc, buttonProps) => {
|
|
126
|
-
// let caption = ''
|
|
127
|
-
// let header = `${title ? `*${title}*` : ''}`
|
|
128
|
-
// header += `${subtitle ? ` - _${subtitle}_` : ''}`
|
|
129
|
-
// let buttons = ''
|
|
130
|
-
// if (buttonProps.url) {
|
|
131
|
-
// buttons += ` - ${buttonProps.children}: ${buttonProps.url}`
|
|
132
|
-
// caption = `${header ? `${header}\n` : ''}${buttons}`
|
|
133
|
-
// }
|
|
134
|
-
// if (buttonProps.payload || buttonProps.path) {
|
|
135
|
-
// buttons += `${index}. `
|
|
136
|
-
// caption = `${buttons}${buttonProps.children}`
|
|
137
|
-
// }
|
|
138
|
-
// return caption
|
|
139
|
-
// }
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
exports.MultichannelCarousel = MultichannelCarousel;
|
|
143
|
-
//# sourceMappingURL=multichannel-carousel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/multichannel/multichannel-carousel.jsx"],"names":["MultichannelCarousel","props","requestContext","RequestContext","getButtons","node","concat","isMultichannelButton","elements","children","map","e","element","i","imageProps","undefined","title","subtitle","buttons","push","Array","isArray","header","showTitle","showSubtitle","indexMode","buttonsAsText"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAOO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAuB,CAAAC,KAAK,EAAI;AAC3C,MAAMC,cAAc,GAAG,uBAAWC,wBAAX,CAAvB;;AAEA,MAAMC,UAAU,GAAG,SAAbA,UAAa,CAAAC,IAAI;AAAA,WACrB,GAAGC,MAAH,CAAU,4CAAoBD,IAApB,EAA0BE,uCAA1B,CAAV,CADqB;AAAA,GAAvB;;AAGA,MAAI,mCAAWL,cAAX,CAAJ,EAAgC;AAC9B,QAAMM,QAAQ,GAAGP,KAAK,CAACQ,QAAN,CACdC,GADc,CACV,UAAAC,CAAC;AAAA,aAAIA,CAAC,CAACV,KAAF,CAAQQ,QAAZ;AAAA,KADS,EAEdC,GAFc,CAEV,UAACE,OAAD,EAAUC,CAAV,EAAgB;AACnB,UAAIC,UAAU,GAAGC,SAAjB;AACA,UAA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A,MAAM,EAAEA,CAFV;AAGE,UAAA,SAAS,EAAEZ,KAAK,CAACwB,SAHnB;AAIE,UAAA,aAAa,EAAExB,KAAK,CAACyB;AAJvB,WAMGJ,MAAM,IAAI,IANb,EAOGJ,OAPH;AAFF,QArCmB,CAkDnB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACD,KArEc,CAAjB;AAsEA,WAAOV,QAAP;AACD,GAxED,MAwEO;AACL,wBAAO,gCAAC,kBAAD,EAAcP,KAAd,EAAsBA,KAAK,CAACQ,QAA5B,CAAP;AACD;AACF,CAjFM,C,CAmFP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["import React, { useContext } from 'react'\n\nimport { RequestContext } from '../../contexts'\nimport { Carousel } from '../carousel'\nimport { MultichannelText } from './multichannel-text'\nimport {\n getFilteredElements,\n isMultichannelButton,\n isNodeKind,\n isWhatsapp,\n} from './multichannel-utils'\n\nexport const MultichannelCarousel = props => {\n const requestContext = useContext(RequestContext)\n\n const getButtons = node =>\n [].concat(getFilteredElements(node, isMultichannelButton))\n\n if (isWhatsapp(requestContext)) {\n const elements = props.children\n .map(e => e.props.children)\n .map((element, i) => {\n let imageProps = undefined\n let title = undefined\n let subtitle = undefined\n const buttons = []\n\n for (const node of element) {\n if (isNodeKind(node, 'Pic')) {\n imageProps = node.props\n }\n if (isNodeKind(node, 'Title')) {\n title = node.props.children\n }\n if (isNodeKind(node, 'Subtitle')) {\n subtitle = node.props.children\n }\n\n if (isNodeKind(node, 'MultichannelButton')) {\n buttons.push(node)\n }\n //TODO support fragment containing an array\n if (Array.isArray(node)) {\n buttons.push(getButtons(node))\n }\n }\n\n let header = ''\n if (props.showTitle && title) {\n header += `${title ? `*${title}*` : ''}`\n if (title && subtitle) {\n header += ' '\n }\n }\n if (props.showSubtitle && subtitle) {\n header += `_${subtitle}_`\n }\n\n return (\n // TODO: newkey only for 1 nested button\n <MultichannelText\n key={i}\n newkey={i}\n indexMode={props.indexMode}\n buttonsAsText={props.buttonsAsText}\n >\n {header || null}\n {buttons}\n </MultichannelText>\n )\n\n // TODO: in the future, this would be the default mode\n // } else {\n // return (\n // <React.Fragment key={i}>\n // <Image\n // src={imageSrc}\n // caption={carouselToCaption(\n // i + 1,\n // title,\n // subtitle,\n // imageSrc,\n // buttonProps\n // )}\n // ></Image>\n // </React.Fragment>\n // )\n // }\n })\n return elements\n } else {\n return <Carousel {...props}>{props.children}</Carousel>\n }\n}\n\n// const carouselToCaption = (index, title, subtitle, imageSrc, buttonProps) => {\n// let caption = ''\n// let header = `${title ? `*${title}*` : ''}`\n// header += `${subtitle ? ` - _${subtitle}_` : ''}`\n// let buttons = ''\n// if (buttonProps.url) {\n// buttons += ` - ${buttonProps.children}: ${buttonProps.url}`\n// caption = `${header ? `${header}\\n` : ''}${buttons}`\n// }\n// if (buttonProps.payload || buttonProps.path) {\n// buttons += `${index}. `\n// caption = `${buttons}${buttonProps.children}`\n// }\n// return caption\n// }\n"],"file":"multichannel-carousel.js"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.MultichannelContext = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var MultichannelContext = /*#__PURE__*/_react["default"].createContext({
|
|
13
|
-
boldIndex: true,
|
|
14
|
-
carousel: {
|
|
15
|
-
indexMode: undefined
|
|
16
|
-
},
|
|
17
|
-
text: {
|
|
18
|
-
indexMode: 'letter'
|
|
19
|
-
},
|
|
20
|
-
indexSeparator: '.'
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
exports.MultichannelContext = MultichannelContext;
|
|
24
|
-
//# sourceMappingURL=multichannel-context.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/multichannel/multichannel-context.jsx"],"names":["MultichannelContext","React","createContext","boldIndex","carousel","indexMode","undefined","text","indexSeparator"],"mappings":";;;;;;;;;AAAA;;AAEO,IAAMA,mBAAmB,gBAAGC,kBAAMC,aAAN,CAAoB;AACrDC,EAAAA,SAAS,EAAE,IAD0C;AAErDC,EAAAA,QAAQ,EAAE;AACRC,IAAAA,SAAS,EAAEC;AADH,GAF2C;AAKrDC,EAAAA,IAAI,EAAE;AACJF,IAAAA,SAAS,EAAE;AADP,GAL+C;AAQrDG,EAAAA,cAAc,EAAE;AARqC,CAApB,CAA5B","sourcesContent":["import React from 'react'\n\nexport const MultichannelContext = React.createContext({\n boldIndex: true,\n carousel: {\n indexMode: undefined,\n },\n text: {\n indexMode: 'letter',\n },\n indexSeparator: '.',\n})\n"],"file":"multichannel-context.js"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.MultichannelReply = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _contexts = require("../../contexts");
|
|
13
|
-
|
|
14
|
-
var _reply = require("../reply");
|
|
15
|
-
|
|
16
|
-
var _multichannelUtils = require("./multichannel-utils");
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
var MultichannelReply = function MultichannelReply(props) {
|
|
23
|
-
var requestContext = (0, _react.useContext)(_contexts.RequestContext);
|
|
24
|
-
|
|
25
|
-
var hasPath = function hasPath() {
|
|
26
|
-
return Boolean(props.path);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var hasPayload = function hasPayload() {
|
|
30
|
-
return Boolean(props.payload);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
var getText = function getText() {
|
|
34
|
-
return "".concat(props.children);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
if ((0, _multichannelUtils.isWhatsapp)(requestContext)) {
|
|
38
|
-
if (hasPath() || hasPayload()) return "".concat(getText());
|
|
39
|
-
return null;
|
|
40
|
-
} else {
|
|
41
|
-
return /*#__PURE__*/_react["default"].createElement(_reply.Reply, props, props.children);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
exports.MultichannelReply = MultichannelReply;
|
|
46
|
-
//# sourceMappingURL=multichannel-reply.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/multichannel/multichannel-reply.jsx"],"names":["MultichannelReply","props","requestContext","RequestContext","hasPath","Boolean","path","hasPayload","payload","getText","children"],"mappings":";;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;;;;;AAEO,IAAMA,iBAAiB,GAAG,SAApBA,iBAAoB,CAAAC,KAAK,EAAI;AACxC,MAAMC,cAAc,GAAG,uBAAWC,wBAAX,CAAvB;;AACA,MAAMC,OAAO,GAAG,SAAVA,OAAU;AAAA,WAAMC,OAAO,CAACJ,KAAK,CAACK,IAAP,CAAb;AAAA,GAAhB;;AACA,MAAMC,UAAU,GAAG,SAAbA,UAAa;AAAA,WAAMF,OAAO,CAACJ,KAAK,CAACO,OAAP,CAAb;AAAA,GAAnB;;AACA,MAAMC,OAAO,GAAG,SAAVA,OAAU;AAAA,qBAASR,KAAK,CAACS,QAAf;AAAA,GAAhB;;AAEA,MAAI,mCAAWR,cAAX,CAAJ,EAAgC;AAC9B,QAAIE,OAAO,MAAMG,UAAU,EAA3B,EAA+B,iBAAUE,OAAO,EAAjB;AAC/B,WAAO,IAAP;AACD,GAHD,MAGO;AACL,wBAAO,gCAAC,YAAD,EAAWR,KAAX,EAAmBA,KAAK,CAACS,QAAzB,CAAP;AACD;AACF,CAZM","sourcesContent":["import React, { useContext } from 'react'\n\nimport { RequestContext } from '../../contexts'\nimport { Reply } from '../reply'\nimport { isWhatsapp } from './multichannel-utils'\n\nexport const MultichannelReply = props => {\n const requestContext = useContext(RequestContext)\n const hasPath = () => Boolean(props.path)\n const hasPayload = () => Boolean(props.payload)\n const getText = () => `${props.children}`\n\n if (isWhatsapp(requestContext)) {\n if (hasPath() || hasPayload()) return `${getText()}`\n return null\n } else {\n return <Reply {...props}>{props.children}</Reply>\n }\n}\n"],"file":"multichannel-reply.js"}
|