@botonic/react 0.22.0-alpha.1 → 0.22.0-beta.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/botonic-tester.js +4 -6
- package/lib/cjs/botonic-tester.js.map +1 -1
- package/lib/cjs/components/audio.js +3 -7
- package/lib/cjs/components/audio.js.map +1 -1
- package/lib/cjs/components/button.js +7 -18
- package/lib/cjs/components/button.js.map +1 -1
- package/lib/cjs/components/carousel.d.ts +1 -1
- package/lib/cjs/components/carousel.js +6 -19
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/components/custom-message.d.ts +3 -34
- package/lib/cjs/components/custom-message.js +4 -10
- package/lib/cjs/components/custom-message.js.map +1 -1
- package/lib/cjs/components/document.js +3 -6
- package/lib/cjs/components/document.js.map +1 -1
- package/lib/cjs/components/element.js +3 -2
- package/lib/cjs/components/element.js.map +1 -1
- package/lib/cjs/components/handoff.js +3 -7
- package/lib/cjs/components/handoff.js.map +1 -1
- package/lib/cjs/components/image.js +3 -7
- package/lib/cjs/components/image.js.map +1 -1
- package/lib/cjs/components/index-types.d.ts +174 -0
- package/lib/cjs/components/index-types.js +17 -0
- package/lib/cjs/components/index-types.js.map +1 -0
- package/lib/cjs/components/index.d.ts +22 -20
- package/lib/cjs/components/index.js +4 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/components/location.js +3 -9
- package/lib/cjs/components/location.js.map +1 -1
- package/lib/cjs/components/message-template.js +2 -3
- package/lib/cjs/components/message-template.js.map +1 -1
- package/lib/cjs/components/message.js +9 -27
- package/lib/cjs/components/message.js.map +1 -1
- package/lib/cjs/components/multichannel/index-types.d.ts +45 -0
- package/lib/cjs/components/multichannel/index-types.js +3 -0
- package/lib/cjs/components/multichannel/index-types.js.map +1 -0
- package/lib/cjs/components/multichannel/index.d.ts +11 -6
- package/lib/cjs/components/multichannel/index.js +2 -0
- package/lib/cjs/components/multichannel/index.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-button.js +4 -5
- package/lib/cjs/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-carousel.js +3 -20
- package/lib/cjs/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-context.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-reply.js +2 -1
- package/lib/cjs/components/multichannel/multichannel-reply.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/cjs/components/multichannel/multichannel-text.js +10 -25
- package/lib/cjs/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/cjs/components/multichannel/multichannel.js +16 -28
- package/lib/cjs/components/multichannel/multichannel.js.map +1 -1
- package/lib/cjs/components/pic.js +3 -2
- package/lib/cjs/components/pic.js.map +1 -1
- package/lib/cjs/components/raw.js +3 -12
- package/lib/cjs/components/raw.js.map +1 -1
- package/lib/cjs/components/reply.js +5 -8
- package/lib/cjs/components/reply.js.map +1 -1
- package/lib/cjs/components/share-button.js +2 -3
- package/lib/cjs/components/share-button.js.map +1 -1
- package/lib/cjs/components/subtitle.js +3 -4
- package/lib/cjs/components/subtitle.js.map +1 -1
- package/lib/cjs/components/text.js +3 -6
- package/lib/cjs/components/text.js.map +1 -1
- package/lib/cjs/components/timestamps.js +2 -5
- package/lib/cjs/components/timestamps.js.map +1 -1
- package/lib/cjs/components/title.js +3 -2
- package/lib/cjs/components/title.js.map +1 -1
- package/lib/cjs/components/video.js +3 -6
- package/lib/cjs/components/video.js.map +1 -1
- package/lib/cjs/components/webchat-settings.js +2 -1
- package/lib/cjs/components/webchat-settings.js.map +1 -1
- package/lib/cjs/components/whatsapp-template.js +3 -4
- package/lib/cjs/components/whatsapp-template.js.map +1 -1
- package/lib/cjs/contexts.d.ts +2 -3
- package/lib/cjs/contexts.js +3 -4
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/dev-app.d.ts +2 -2
- package/lib/cjs/dev-app.js +2 -1
- package/lib/cjs/dev-app.js.map +1 -1
- package/lib/cjs/index-types.d.ts +96 -0
- package/lib/cjs/index-types.js +12 -0
- package/lib/cjs/index-types.js.map +1 -0
- package/lib/cjs/index.d.ts +7 -10
- package/lib/cjs/index.js +6 -10
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/message-utils.d.ts +1 -1
- package/lib/cjs/msg-to-botonic.d.ts +1 -1
- package/lib/cjs/msg-to-botonic.js +24 -46
- package/lib/cjs/msg-to-botonic.js.map +1 -1
- package/lib/cjs/node-app.d.ts +1 -1
- package/lib/cjs/react-bot.d.ts +1 -1
- package/lib/cjs/react-bot.js +3 -4
- package/lib/cjs/react-bot.js.map +1 -1
- package/lib/cjs/util/error-boundary.d.ts +6 -39
- package/lib/cjs/util/error-boundary.js +17 -30
- package/lib/cjs/util/error-boundary.js.map +1 -1
- package/lib/cjs/util/webchat.js.map +1 -1
- package/lib/cjs/webchat/components/attachment.js +7 -10
- package/lib/cjs/webchat/components/attachment.js.map +1 -1
- package/lib/cjs/webchat/components/common.js +2 -1
- package/lib/cjs/webchat/components/common.js.map +1 -1
- package/lib/cjs/webchat/components/conditional-animation.js +2 -3
- package/lib/cjs/webchat/components/conditional-animation.js.map +1 -1
- package/lib/cjs/webchat/components/emoji-picker.js +3 -12
- package/lib/cjs/webchat/components/emoji-picker.js.map +1 -1
- package/lib/cjs/webchat/components/persistent-menu.js +5 -19
- package/lib/cjs/webchat/components/persistent-menu.js.map +1 -1
- package/lib/cjs/webchat/components/send-button.js +2 -7
- package/lib/cjs/webchat/components/send-button.js.map +1 -1
- package/lib/cjs/webchat/components/typing-indicator.js +2 -5
- package/lib/cjs/webchat/components/typing-indicator.js.map +1 -1
- package/lib/cjs/webchat/devices/device-adapter.d.ts +2 -2
- package/lib/cjs/webchat/header.js +4 -14
- package/lib/cjs/webchat/header.js.map +1 -1
- package/lib/cjs/webchat/hooks.js +2 -1
- package/lib/cjs/webchat/hooks.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +55 -0
- package/lib/cjs/webchat/index-types.js +3 -0
- package/lib/cjs/webchat/index-types.js.map +1 -0
- package/lib/cjs/webchat/index.d.ts +4 -6
- package/lib/cjs/webchat/index.js +3 -3
- package/lib/cjs/webchat/index.js.map +1 -1
- package/lib/cjs/webchat/message-list.js +5 -12
- package/lib/cjs/webchat/message-list.js.map +1 -1
- package/lib/cjs/webchat/replies.js +2 -5
- package/lib/cjs/webchat/replies.js.map +1 -1
- package/lib/cjs/webchat/session-view.js +7 -30
- package/lib/cjs/webchat/session-view.js.map +1 -1
- package/lib/cjs/webchat/use-storage-state-hook.js +12 -2
- package/lib/cjs/webchat/use-storage-state-hook.js.map +1 -1
- package/lib/cjs/webchat/webchat-dev.d.ts +1 -1
- package/lib/cjs/webchat/webchat-dev.js +6 -10
- package/lib/cjs/webchat/webchat-dev.js.map +1 -1
- package/lib/cjs/webchat/webchat.d.ts +1 -1
- package/lib/cjs/webchat/webchat.js +43 -86
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.js +5 -13
- package/lib/cjs/webchat/webview.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +2 -2
- package/lib/cjs/webchat-app.js +2 -1
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webview-app.js +12 -13
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/botonic-tester.js +4 -6
- package/lib/esm/botonic-tester.js.map +1 -1
- package/lib/esm/components/audio.js +3 -7
- package/lib/esm/components/audio.js.map +1 -1
- package/lib/esm/components/button.js +7 -18
- package/lib/esm/components/button.js.map +1 -1
- package/lib/esm/components/carousel.d.ts +2 -1
- package/lib/esm/components/carousel.js +6 -19
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/components/custom-message.d.ts +3 -34
- package/lib/esm/components/custom-message.js +4 -10
- package/lib/esm/components/custom-message.js.map +1 -1
- package/lib/esm/components/document.js +3 -6
- package/lib/esm/components/document.js.map +1 -1
- package/lib/esm/components/element.js +3 -2
- package/lib/esm/components/element.js.map +1 -1
- package/lib/esm/components/handoff.js +3 -7
- package/lib/esm/components/handoff.js.map +1 -1
- package/lib/esm/components/image.js +3 -7
- package/lib/esm/components/image.js.map +1 -1
- package/lib/esm/components/index-types.d.ts +174 -0
- package/lib/esm/components/index-types.js +16 -0
- package/lib/esm/components/index-types.js.map +1 -0
- package/lib/esm/components/index.d.ts +22 -19
- package/lib/esm/components/index.js +2 -0
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/components/location.js +3 -9
- package/lib/esm/components/location.js.map +1 -1
- package/lib/esm/components/message-template.js +2 -3
- package/lib/esm/components/message-template.js.map +1 -1
- package/lib/esm/components/message.js +9 -27
- package/lib/esm/components/message.js.map +1 -1
- package/lib/esm/components/multichannel/index-types.d.ts +45 -0
- package/lib/esm/components/multichannel/index-types.js +2 -0
- package/lib/esm/components/multichannel/index-types.js.map +1 -0
- package/lib/esm/components/multichannel/index.d.ts +11 -6
- package/lib/esm/components/multichannel/index.js +1 -0
- package/lib/esm/components/multichannel/index.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-button.js +4 -5
- package/lib/esm/components/multichannel/multichannel-button.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-carousel.js +3 -20
- package/lib/esm/components/multichannel/multichannel-carousel.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-context.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-reply.js +2 -1
- package/lib/esm/components/multichannel/multichannel-reply.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel-text.d.ts +1 -1
- package/lib/esm/components/multichannel/multichannel-text.js +10 -25
- package/lib/esm/components/multichannel/multichannel-text.js.map +1 -1
- package/lib/esm/components/multichannel/multichannel.js +11 -23
- package/lib/esm/components/multichannel/multichannel.js.map +1 -1
- package/lib/esm/components/pic.js +3 -2
- package/lib/esm/components/pic.js.map +1 -1
- package/lib/esm/components/raw.js +3 -12
- package/lib/esm/components/raw.js.map +1 -1
- package/lib/esm/components/reply.js +5 -8
- package/lib/esm/components/reply.js.map +1 -1
- package/lib/esm/components/share-button.js +2 -3
- package/lib/esm/components/share-button.js.map +1 -1
- package/lib/esm/components/subtitle.js +3 -4
- package/lib/esm/components/subtitle.js.map +1 -1
- package/lib/esm/components/text.js +3 -6
- package/lib/esm/components/text.js.map +1 -1
- package/lib/esm/components/timestamps.js +2 -5
- package/lib/esm/components/timestamps.js.map +1 -1
- package/lib/esm/components/title.js +3 -2
- package/lib/esm/components/title.js.map +1 -1
- package/lib/esm/components/video.js +3 -6
- package/lib/esm/components/video.js.map +1 -1
- package/lib/esm/components/webchat-settings.js +2 -1
- package/lib/esm/components/webchat-settings.js.map +1 -1
- package/lib/esm/components/whatsapp-template.js +3 -4
- package/lib/esm/components/whatsapp-template.js.map +1 -1
- package/lib/esm/contexts.d.ts +2 -3
- package/lib/esm/contexts.js +3 -3
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/dev-app.d.ts +2 -2
- package/lib/esm/dev-app.js +2 -1
- package/lib/esm/dev-app.js.map +1 -1
- package/lib/esm/index-types.d.ts +96 -0
- package/lib/esm/index-types.js +9 -0
- package/lib/esm/index-types.js.map +1 -0
- package/lib/esm/index.d.ts +7 -9
- package/lib/esm/index.js +5 -4
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/message-utils.d.ts +2 -1
- package/lib/esm/msg-to-botonic.d.ts +1 -1
- package/lib/esm/msg-to-botonic.js +23 -45
- package/lib/esm/msg-to-botonic.js.map +1 -1
- package/lib/esm/node-app.d.ts +4 -4
- package/lib/esm/react-bot.d.ts +2 -1
- package/lib/esm/react-bot.js +3 -4
- package/lib/esm/react-bot.js.map +1 -1
- package/lib/esm/util/error-boundary.d.ts +6 -39
- package/lib/esm/util/error-boundary.js +17 -30
- package/lib/esm/util/error-boundary.js.map +1 -1
- package/lib/esm/util/webchat.js.map +1 -1
- package/lib/esm/webchat/components/attachment.js +8 -11
- package/lib/esm/webchat/components/attachment.js.map +1 -1
- package/lib/esm/webchat/components/common.js +2 -1
- package/lib/esm/webchat/components/common.js.map +1 -1
- package/lib/esm/webchat/components/conditional-animation.js +2 -3
- package/lib/esm/webchat/components/conditional-animation.js.map +1 -1
- package/lib/esm/webchat/components/emoji-picker.js +3 -12
- package/lib/esm/webchat/components/emoji-picker.js.map +1 -1
- package/lib/esm/webchat/components/persistent-menu.js +5 -19
- package/lib/esm/webchat/components/persistent-menu.js.map +1 -1
- package/lib/esm/webchat/components/send-button.js +2 -7
- package/lib/esm/webchat/components/send-button.js.map +1 -1
- package/lib/esm/webchat/components/typing-indicator.js +2 -5
- package/lib/esm/webchat/components/typing-indicator.js.map +1 -1
- package/lib/esm/webchat/devices/device-adapter.d.ts +2 -2
- package/lib/esm/webchat/header.js +4 -14
- package/lib/esm/webchat/header.js.map +1 -1
- package/lib/esm/webchat/hooks.js +2 -1
- package/lib/esm/webchat/hooks.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +55 -0
- package/lib/esm/webchat/index-types.js +2 -0
- package/lib/esm/webchat/index-types.js.map +1 -0
- package/lib/esm/webchat/index.d.ts +4 -6
- package/lib/esm/webchat/index.js +2 -3
- package/lib/esm/webchat/index.js.map +1 -1
- package/lib/esm/webchat/message-list.js +5 -12
- package/lib/esm/webchat/message-list.js.map +1 -1
- package/lib/esm/webchat/replies.js +2 -5
- package/lib/esm/webchat/replies.js.map +1 -1
- package/lib/esm/webchat/session-view.js +7 -30
- package/lib/esm/webchat/session-view.js.map +1 -1
- package/lib/esm/webchat/use-storage-state-hook.js +12 -2
- package/lib/esm/webchat/use-storage-state-hook.js.map +1 -1
- package/lib/esm/webchat/webchat-dev.d.ts +1 -1
- package/lib/esm/webchat/webchat-dev.js +6 -10
- package/lib/esm/webchat/webchat-dev.js.map +1 -1
- package/lib/esm/webchat/webchat.d.ts +1 -1
- package/lib/esm/webchat/webchat.js +43 -86
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.js +5 -13
- package/lib/esm/webchat/webview.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +5 -4
- package/lib/esm/webchat-app.js +2 -1
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webview-app.js +5 -6
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +21 -15
- package/src/components/{index.d.ts → index-types.ts} +22 -43
- package/src/components/{index.js → index.ts} +2 -0
- package/src/components/message.jsx +4 -11
- package/src/components/multichannel/{index.d.ts → index-types.ts} +1 -10
- package/src/components/multichannel/{index.js → index.ts} +2 -0
- package/src/components/multichannel/multichannel-text.jsx +2 -5
- package/src/contexts.jsx +3 -3
- package/src/index-types.ts +190 -0
- package/src/{index.js → index.ts} +5 -4
- package/src/msg-to-botonic.jsx +11 -11
- package/src/util/error-boundary.jsx +15 -30
- package/src/util/webchat.js +12 -13
- package/src/webchat/components/attachment.jsx +10 -2
- package/src/webchat/components/emoji-picker.jsx +7 -1
- package/src/webchat/hooks.js +2 -1
- package/src/webchat/{index.d.ts → index-types.ts} +5 -10
- package/src/webchat/{index.js → index.ts} +3 -3
- package/src/webchat/use-storage-state-hook.js +13 -2
- package/src/webchat/webchat.jsx +5 -7
- package/src/webview-app.tsx +1 -1
- package/src/index.d.ts +0 -238
package/package.json
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/react",
|
|
3
|
-
"version": "0.22.0-
|
|
3
|
+
"version": "0.22.0-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Build Chatbots using React",
|
|
6
6
|
"main": "./lib/cjs",
|
|
7
7
|
"module": "./lib/esm",
|
|
8
8
|
"types": "./lib/cjs/index.d.ts",
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "
|
|
10
|
+
"test:no-coverage": "./node_modules/.bin/jest --env=jsdom",
|
|
11
|
+
"test": "./node_modules/.bin/jest --env=jsdom --coverage",
|
|
11
12
|
"cloc": "../../scripts/qa/cloc-package.sh .",
|
|
12
13
|
"prepublishOnly": "npm run clean; npm run build; npm run copy-files;",
|
|
13
14
|
"prepare": "node ../../preinstall.js;",
|
|
14
|
-
"clean": "
|
|
15
|
+
"clean": "rm -rf ./lib/",
|
|
15
16
|
"copy-files": "copyfiles -u 1 src/**/*.svg src/**/*.png src/**/*.scss src/**/*.html lib/esm/; copyfiles -u 1 src/**/*.svg src/**/*.png src/**/*.scss src/**/*.html lib/cjs/;",
|
|
16
|
-
"build": "
|
|
17
|
+
"build": "./node_modules/.bin/tsc -p tsconfig.json && ./node_modules/.bin/tsc -p tsconfig.esm.json",
|
|
17
18
|
"build:watch": "npm run build -- --watch",
|
|
18
|
-
"
|
|
19
|
+
"prettier": "../../node_modules/.bin/prettier --no-error-on-unmatched-pattern --write '**/*.md' '**/*.css' '.*.js' '*.js{,on}'",
|
|
20
|
+
"lint": "npm run prettier; npm run lint_core -- --fix",
|
|
19
21
|
"lint_ci": "npm run lint_core",
|
|
20
|
-
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet '.*.js' '*.js' 'src/**/*.js*' 'src/**/*.d.ts'
|
|
22
|
+
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet '.*.js' '*.js' 'src/**/*.js*' 'src/**/*.d.ts' --fix"
|
|
21
23
|
},
|
|
22
24
|
"sideEffects": [
|
|
23
25
|
"*.scss",
|
|
@@ -35,14 +37,14 @@
|
|
|
35
37
|
"dependencies": {
|
|
36
38
|
"@botonic/core": "0.22.0-alpha.0",
|
|
37
39
|
"axios": "^1.4.0",
|
|
38
|
-
"emoji-picker-react": "^
|
|
40
|
+
"emoji-picker-react": "^4.4.9",
|
|
39
41
|
"framer-motion": "^3.1.1",
|
|
40
42
|
"he": "^1.2.0",
|
|
41
43
|
"lodash.merge": "^4.6.2",
|
|
42
44
|
"markdown-it": "^12.0.6",
|
|
43
45
|
"qrcode.react": "^1.0.1",
|
|
44
|
-
"react": "^
|
|
45
|
-
"react-dom": "^
|
|
46
|
+
"react": "^17.0.0",
|
|
47
|
+
"react-dom": "^17.0.0",
|
|
46
48
|
"react-frame-component": "^4.1.3",
|
|
47
49
|
"react-json-tree": "^0.15.0",
|
|
48
50
|
"react-reveal": "^1.2.2",
|
|
@@ -57,21 +59,25 @@
|
|
|
57
59
|
"uuid": "^8.3.2"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@babel/cli": "^7.21.
|
|
61
|
-
"@babel/core": "^7.21.
|
|
62
|
+
"@babel/cli": "^7.21.5",
|
|
63
|
+
"@babel/core": "^7.21.8",
|
|
62
64
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
63
65
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
64
66
|
"@babel/plugin-transform-runtime": "^7.21.4",
|
|
65
|
-
"@babel/preset-env": "^7.21.
|
|
67
|
+
"@babel/preset-env": "^7.21.5",
|
|
66
68
|
"@babel/preset-react": "^7.18.6",
|
|
67
69
|
"@testing-library/react": "^12.0.0",
|
|
68
|
-
"@testing-library/react-hooks": "^
|
|
70
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
71
|
+
"@types/jest": "^29.5.1",
|
|
72
|
+
"@types/parse5": "^7.0.0",
|
|
69
73
|
"@types/react": "17.0.27",
|
|
70
74
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
71
75
|
"copyfiles": "^2.4.1",
|
|
72
76
|
"identity-obj-proxy": "^3.0.0",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
77
|
+
"jest": "^29.5.0",
|
|
78
|
+
"jest-environment-jsdom": "^29.5.0",
|
|
79
|
+
"react-test-renderer": "^17.0.0",
|
|
80
|
+
"ts-jest": "^29.1.0",
|
|
75
81
|
"typescript": "^5.0.4"
|
|
76
82
|
},
|
|
77
83
|
"engines": {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ErrorInfo } from 'react'
|
|
1
|
+
import React, { ErrorInfo } from 'react'
|
|
3
2
|
|
|
4
|
-
import { CoverComponentProps } from '../webchat'
|
|
3
|
+
import { CoverComponentProps } from '../webchat/index-types'
|
|
5
4
|
|
|
6
5
|
export type MessageType =
|
|
7
6
|
| 'audio'
|
|
@@ -26,18 +25,10 @@ export interface MessageProps {
|
|
|
26
25
|
typing?: number
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export const Audio: React.FunctionComponent<MessageProps>
|
|
30
|
-
export const Document: React.FunctionComponent<MessageProps>
|
|
31
|
-
|
|
32
|
-
export const Message: React.FunctionComponent<MessageProps>
|
|
33
|
-
export type Message = React.FunctionComponent<MessageProps>
|
|
34
|
-
export const Video: React.FunctionComponent<MessageProps>
|
|
35
|
-
|
|
36
28
|
export interface TextProps extends MessageProps {
|
|
37
29
|
// converts markdown syntax to HTML
|
|
38
30
|
markdown?: boolean
|
|
39
31
|
}
|
|
40
|
-
export const Text: React.FunctionComponent<TextProps>
|
|
41
32
|
|
|
42
33
|
export interface Webview {
|
|
43
34
|
name: string
|
|
@@ -56,23 +47,16 @@ export interface ButtonProps {
|
|
|
56
47
|
disabledstyle?: boolean
|
|
57
48
|
}
|
|
58
49
|
|
|
59
|
-
export const Button: React.FunctionComponent<ButtonProps>
|
|
60
|
-
|
|
61
50
|
export interface ReplyProps {
|
|
62
51
|
path?: string
|
|
63
52
|
payload?: string
|
|
64
53
|
children: string
|
|
65
54
|
}
|
|
66
|
-
export const Reply: React.FunctionComponent<ReplyProps>
|
|
67
|
-
export type Reply = React.FunctionComponent<ReplyProps>
|
|
68
55
|
|
|
69
56
|
export interface PicProps {
|
|
70
57
|
src: string
|
|
71
58
|
}
|
|
72
59
|
|
|
73
|
-
export const Carousel: React.FunctionComponent<MessageProps>
|
|
74
|
-
export const Image: React.FunctionComponent<ImageProps>
|
|
75
|
-
export const Pic: React.FunctionComponent<PicProps>
|
|
76
60
|
export type ImageProps = PicProps
|
|
77
61
|
|
|
78
62
|
export interface TitleProps {
|
|
@@ -80,17 +64,14 @@ export interface TitleProps {
|
|
|
80
64
|
style: string
|
|
81
65
|
}
|
|
82
66
|
|
|
83
|
-
export const Element: React.FunctionComponent<MessageProps>
|
|
84
|
-
export const Subtitle: React.FunctionComponent<SubtitleProps>
|
|
85
|
-
export const Title: React.FunctionComponent<TitleProps>
|
|
86
67
|
export type SubtitleProps = TitleProps
|
|
87
68
|
|
|
88
|
-
type CustomProp = { custom?: React.ComponentType }
|
|
89
|
-
type EnableProp = { enable?: boolean }
|
|
90
|
-
type ImageProp = { image?: string } // https URL or imported Image asset
|
|
91
|
-
type PersistentMenuCloseOption = { closeLabel: string }
|
|
92
|
-
type PersistentMenuOption = { label: string } & ButtonProps
|
|
93
|
-
type StyleProp = { style?: any }
|
|
69
|
+
export type CustomProp = { custom?: React.ComponentType }
|
|
70
|
+
export type EnableProp = { enable?: boolean }
|
|
71
|
+
export type ImageProp = { image?: string } // https URL or imported Image asset
|
|
72
|
+
export type PersistentMenuCloseOption = { closeLabel: string }
|
|
73
|
+
export type PersistentMenuOption = { label: string } & ButtonProps
|
|
74
|
+
export type StyleProp = { style?: any }
|
|
94
75
|
|
|
95
76
|
export type PersistentMenuTheme = (
|
|
96
77
|
| PersistentMenuCloseOption
|
|
@@ -202,27 +183,25 @@ export interface WebchatSettingsProps {
|
|
|
202
183
|
persistentMenu?: PersistentMenuTheme
|
|
203
184
|
theme?: ThemeProps
|
|
204
185
|
}
|
|
205
|
-
export const WebchatSettings: React.FunctionComponent<WebchatSettingsProps>
|
|
206
186
|
|
|
207
187
|
export type WrappedComponent<Props> = React.FunctionComponent<Props> & {
|
|
208
188
|
customTypeName: string
|
|
209
189
|
}
|
|
210
190
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
export function createErrorBoundary<Props>(_?: {
|
|
216
|
-
errorComponent: React.ComponentType
|
|
217
|
-
}): ErrorBoundary<Props>
|
|
191
|
+
// TODO: Reuse types to be typed in respective functions
|
|
192
|
+
// export class ErrorBoundary<Props> extends React.Component<Props> {
|
|
193
|
+
// componentDidCatch(error: Error, errorInfo: ErrorInfo): void
|
|
194
|
+
// }
|
|
218
195
|
|
|
219
|
-
export function
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
defaultProps?: Record<string, unknown>
|
|
223
|
-
errorBoundary?: ErrorBoundary<Props>
|
|
224
|
-
}): WrappedComponent<Props>
|
|
196
|
+
// export function createErrorBoundary<Props>(_?: {
|
|
197
|
+
// errorComponent: React.ComponentType
|
|
198
|
+
// }): ErrorBoundary<Props>
|
|
225
199
|
|
|
226
|
-
export function
|
|
200
|
+
// export function customMessage<Props>(_: {
|
|
201
|
+
// name: string
|
|
202
|
+
// component: React.ComponentType<Props>
|
|
203
|
+
// defaultProps?: Record<string, unknown>
|
|
204
|
+
// errorBoundary?: ErrorBoundary<Props>
|
|
205
|
+
// }): WrappedComponent<Props>
|
|
227
206
|
|
|
228
|
-
export
|
|
207
|
+
// export function getDisplayName(component: React.ComponentType): string
|
|
@@ -5,7 +5,9 @@ export { customMessage } from './custom-message'
|
|
|
5
5
|
export { Document } from './document'
|
|
6
6
|
export { Element } from './element'
|
|
7
7
|
export { Image } from './image'
|
|
8
|
+
export * from './index-types'
|
|
8
9
|
export { Location } from './location'
|
|
10
|
+
export { Message } from './message'
|
|
9
11
|
export { MessageTemplate } from './message-template'
|
|
10
12
|
export * from './multichannel'
|
|
11
13
|
export { Pic } from './pic'
|
|
@@ -85,12 +85,8 @@ export const Message = props => {
|
|
|
85
85
|
const isFromUser = from === SENDERS.user
|
|
86
86
|
const isFromBot = from === SENDERS.bot
|
|
87
87
|
const markdown = props.markdown
|
|
88
|
-
const {
|
|
89
|
-
|
|
90
|
-
addMessage,
|
|
91
|
-
updateReplies,
|
|
92
|
-
getThemeProperty,
|
|
93
|
-
} = useContext(WebchatContext)
|
|
88
|
+
const { webchatState, addMessage, updateReplies, getThemeProperty } =
|
|
89
|
+
useContext(WebchatContext)
|
|
94
90
|
const [state, setState] = useState({
|
|
95
91
|
id: props.id || uuidv4(),
|
|
96
92
|
})
|
|
@@ -114,11 +110,8 @@ export const Message = props => {
|
|
|
114
110
|
typeof e === 'string' ? renderLinks(e) : e
|
|
115
111
|
)
|
|
116
112
|
|
|
117
|
-
const {
|
|
118
|
-
|
|
119
|
-
getFormattedTimestamp,
|
|
120
|
-
timestampStyle,
|
|
121
|
-
} = resolveMessageTimestamps(getThemeProperty, enabletimestamps)
|
|
113
|
+
const { timestampsEnabled, getFormattedTimestamp, timestampStyle } =
|
|
114
|
+
resolveMessageTimestamps(getThemeProperty, enabletimestamps)
|
|
122
115
|
|
|
123
116
|
const getEnvAck = () => {
|
|
124
117
|
if (isDev) return 1
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
type IndexMode = 'number' | 'letter' | undefined //undefined means no index
|
|
1
|
+
export type IndexMode = 'number' | 'letter' | undefined //undefined means no index
|
|
4
2
|
|
|
5
3
|
export interface MultichannelViewOptions {
|
|
6
4
|
boldIndex?: boolean
|
|
@@ -23,8 +21,6 @@ export interface MultichannelTextProps extends MultichannelViewOptions {
|
|
|
23
21
|
buttonsTextSeparator?: string
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
export const MultichannelText: React.FunctionComponent<MultichannelTextProps>
|
|
27
|
-
|
|
28
24
|
// Carousel
|
|
29
25
|
export interface MultichannelCarouselProps extends MultichannelViewOptions {
|
|
30
26
|
enableURL?: boolean
|
|
@@ -33,7 +29,6 @@ export interface MultichannelCarouselProps extends MultichannelViewOptions {
|
|
|
33
29
|
showSubtitle?: boolean
|
|
34
30
|
buttonsAsText?: boolean
|
|
35
31
|
}
|
|
36
|
-
export const MultichannelCarousel: React.FunctionComponent<MultichannelCarouselProps>
|
|
37
32
|
|
|
38
33
|
// Button
|
|
39
34
|
export interface MultichannelButtonProps {
|
|
@@ -44,10 +39,8 @@ export interface MultichannelButtonProps {
|
|
|
44
39
|
webview?: string
|
|
45
40
|
asText?: boolean
|
|
46
41
|
}
|
|
47
|
-
export const MultichannelButton: React.FunctionComponent<MultichannelButtonProps>
|
|
48
42
|
|
|
49
43
|
// Reply
|
|
50
|
-
export const MultichannelReply: React.FunctionComponent<MultichannelButtonProps>
|
|
51
44
|
|
|
52
45
|
export interface MultichannelProps extends MultichannelViewOptions {
|
|
53
46
|
firstIndex?: number | string
|
|
@@ -61,5 +54,3 @@ export interface MultichannelProps extends MultichannelViewOptions {
|
|
|
61
54
|
**/
|
|
62
55
|
messageSeparator?: string
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
export const Multichannel: React.FunctionComponent<MultichannelProps>
|
|
@@ -194,11 +194,8 @@ export const MultichannelText = props => {
|
|
|
194
194
|
if (isFacebook(requestContext)) {
|
|
195
195
|
const text = getText(props.children)
|
|
196
196
|
const multichannelFacebook = new MultichannelFacebook()
|
|
197
|
-
const {
|
|
198
|
-
|
|
199
|
-
propsLastText,
|
|
200
|
-
propsWithoutChildren,
|
|
201
|
-
} = multichannelFacebook.convertText(props, text[0])
|
|
197
|
+
const { texts, propsLastText, propsWithoutChildren } =
|
|
198
|
+
multichannelFacebook.convertText(props, text[0])
|
|
202
199
|
return (
|
|
203
200
|
<>
|
|
204
201
|
{texts &&
|
package/src/contexts.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext } from 'react'
|
|
2
2
|
|
|
3
3
|
import { webchatInitialState } from './webchat/hooks'
|
|
4
4
|
|
|
5
|
-
export const RequestContext =
|
|
5
|
+
export const RequestContext = createContext({
|
|
6
6
|
getString: () => '',
|
|
7
7
|
setLocale: () => '',
|
|
8
8
|
session: {},
|
|
@@ -12,7 +12,7 @@ export const RequestContext = React.createContext({
|
|
|
12
12
|
defaultTyping: 0,
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
export const WebchatContext =
|
|
15
|
+
export const WebchatContext = createContext({
|
|
16
16
|
sendText: text => {},
|
|
17
17
|
sendAttachment: attachment => {},
|
|
18
18
|
sendPayload: payload => {},
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import * as core from '@botonic/core'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ButtonProps,
|
|
6
|
+
ReplyProps,
|
|
7
|
+
ThemeProps,
|
|
8
|
+
WebchatSettingsProps,
|
|
9
|
+
Webview,
|
|
10
|
+
} from './components/index-types'
|
|
11
|
+
import { WebchatState } from './webchat'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* See @botonic/core's Response for the description of the Response's semantics*/
|
|
15
|
+
export interface BotResponse extends core.BotRequest {
|
|
16
|
+
response: [React.ReactNode]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Route extends core.Route {
|
|
20
|
+
action?: React.ComponentType<any>
|
|
21
|
+
retryAction?: React.ComponentType<any>
|
|
22
|
+
}
|
|
23
|
+
export type Routes = core.Routes<Route>
|
|
24
|
+
|
|
25
|
+
// Parameters of the actions' botonicInit method
|
|
26
|
+
export interface ActionRequest {
|
|
27
|
+
defaultDelay: number
|
|
28
|
+
defaultTyping: number
|
|
29
|
+
input: core.Input
|
|
30
|
+
lastRoutePath: string
|
|
31
|
+
params: { [key: string]: string }
|
|
32
|
+
plugins: { [id: string]: core.Plugin }
|
|
33
|
+
session: core.Session
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RequestContextInterface extends ActionRequest {
|
|
37
|
+
getString: (stringId: string) => string
|
|
38
|
+
setLocale: (locale: string) => string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type RequestContext = React.Context<RequestContextInterface>
|
|
42
|
+
|
|
43
|
+
export interface CustomMessageType {
|
|
44
|
+
customTypeName: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// TODO: Reuse types to be reused in respective components
|
|
48
|
+
// export class WebchatApp {
|
|
49
|
+
// constructor(options: WebchatAppArgs)
|
|
50
|
+
// addBotMessage(message: WebchatMessage): void
|
|
51
|
+
// addBotText(text: string): void
|
|
52
|
+
// addUserMessage(message: WebchatMessage): void
|
|
53
|
+
// addUserPayload(payload: string): void
|
|
54
|
+
// addUserText(text: string): void
|
|
55
|
+
// clearMessages(): void
|
|
56
|
+
// close(): void
|
|
57
|
+
// closeCoverComponent(): void
|
|
58
|
+
// destroy(): void
|
|
59
|
+
// getComponent(
|
|
60
|
+
// host: HTMLElement,
|
|
61
|
+
// optionsAtRuntime?: WebchatAppArgs
|
|
62
|
+
// ): React.ForwardRefExoticComponent<any>
|
|
63
|
+
// getLastMessageUpdate(): string
|
|
64
|
+
// getMessages(): WebchatMessage[]
|
|
65
|
+
// getVisibility(): Promise<boolean>
|
|
66
|
+
// isWebchatVisible({ appId: string }): Promise<boolean>
|
|
67
|
+
// onCloseWebchat(args: any): void
|
|
68
|
+
// onInitWebchat(args: any): void
|
|
69
|
+
// onOpenWebchat(args: any): void
|
|
70
|
+
// onServiceEvent(event: Event): void
|
|
71
|
+
// onStateChange(args: OnStateChangeArgs): void
|
|
72
|
+
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
73
|
+
// open(): void
|
|
74
|
+
// openCoverComponent(): void
|
|
75
|
+
// render(dest?: HTMLElement, optionsAtRuntime?: WebchatAppArgs): void
|
|
76
|
+
// resendUnsentInputs(): Promise<void>
|
|
77
|
+
// resolveWebchatVisibility(optionsAtRuntime: {
|
|
78
|
+
// appId: string
|
|
79
|
+
// visibility: () => boolean
|
|
80
|
+
// }): Promise<boolean>
|
|
81
|
+
// setTyping(enable: boolean): void
|
|
82
|
+
// toggle(): void
|
|
83
|
+
// toggleCoverComponent(): void
|
|
84
|
+
// updateMessageInfo(msgId: string, messageInfo: MessageInfo): void
|
|
85
|
+
// updateLastMessageDate(date: string): void
|
|
86
|
+
// updateUser(user: Partial<core.SessionUser>): void
|
|
87
|
+
// updateWebchatSettings(settings: WebchatSettingsProps): void
|
|
88
|
+
// renderCustomComponent(customComponent: React.ReactNode): void
|
|
89
|
+
// unmountCustomComponent(): void
|
|
90
|
+
// }
|
|
91
|
+
|
|
92
|
+
// export interface WebchatArgs {
|
|
93
|
+
// blockInputs?: BlockInputOption[]
|
|
94
|
+
// coverComponent?: CoverComponentOptions
|
|
95
|
+
// defaultDelay?: number
|
|
96
|
+
// defaultTyping?: number
|
|
97
|
+
// enableAnimations?: boolean
|
|
98
|
+
// enableAttachments?: boolean
|
|
99
|
+
// enableEmojiPicker?: boolean
|
|
100
|
+
// enableUserInput?: boolean
|
|
101
|
+
// shadowDOM?: boolean | (() => boolean)
|
|
102
|
+
// hostId?: string
|
|
103
|
+
// getString?: (stringId: string, session: core.Session) => string
|
|
104
|
+
// onClose?: (app: WebchatApp, args: any) => void
|
|
105
|
+
// onInit?: (app: WebchatApp, args: any) => void
|
|
106
|
+
// onMessage?: (app: WebchatApp, message: WebchatMessage) => void
|
|
107
|
+
// onOpen?: (app: WebchatApp, args: any) => void
|
|
108
|
+
// onConnectionChange?: (app: WebchatApp, isOnline: boolean) => void
|
|
109
|
+
// persistentMenu?: PersistentMenuTheme
|
|
110
|
+
// storage?: Storage | null
|
|
111
|
+
// storageKey?: any
|
|
112
|
+
// theme?: ThemeProps
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
// export interface WebchatAppArgs extends WebchatArgs {
|
|
116
|
+
export interface WebchatAppArgs {
|
|
117
|
+
appId?: string
|
|
118
|
+
visibility?: () => boolean
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface WebchatMessage {
|
|
122
|
+
ack: 0 | 1
|
|
123
|
+
buttons: ButtonProps[]
|
|
124
|
+
data: any
|
|
125
|
+
delay: number
|
|
126
|
+
display: boolean
|
|
127
|
+
from: 'user' | 'bot'
|
|
128
|
+
id: string
|
|
129
|
+
markdown: boolean
|
|
130
|
+
replies: ReplyProps[]
|
|
131
|
+
timestamp: string
|
|
132
|
+
type: core.InputType
|
|
133
|
+
typing: number
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface OnUserInputArgs {
|
|
137
|
+
input: core.Input
|
|
138
|
+
lastRoutePath?: string
|
|
139
|
+
session?: core.Session
|
|
140
|
+
user: core.SessionUser
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface OnStateChangeArgs {
|
|
144
|
+
messagesJSON: WebchatMessage[]
|
|
145
|
+
user: core.SessionUser
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export interface MessageInfo {
|
|
149
|
+
data: any | 'typing_on'
|
|
150
|
+
id: string
|
|
151
|
+
type: 'update_webchat_settings' | 'sender_action'
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface Event {
|
|
155
|
+
action?: 'update_message_info'
|
|
156
|
+
isError?: boolean
|
|
157
|
+
message?: MessageInfo
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface WebchatContextProps {
|
|
161
|
+
sendText: (text: string, payload?: string) => void
|
|
162
|
+
sendAttachment: (attachment: File) => void
|
|
163
|
+
sendPayload: (payload: string) => void
|
|
164
|
+
sendInput: (input: core.Input) => void
|
|
165
|
+
openWebview: (webviewComponent: Webview) => void
|
|
166
|
+
addMessage: (message: WebchatMessage) => void
|
|
167
|
+
updateMessage: (message: WebchatMessage) => void
|
|
168
|
+
updateReplies: (replies: boolean) => void
|
|
169
|
+
updateLatestInput: (input: core.Input) => void
|
|
170
|
+
closeWebview: () => void
|
|
171
|
+
toggleWebchat: () => void
|
|
172
|
+
getThemeProperty: (property: string, defaultValue?: string) => any
|
|
173
|
+
resolveCase: () => void
|
|
174
|
+
theme: ThemeProps
|
|
175
|
+
webchatState: WebchatState
|
|
176
|
+
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
177
|
+
updateUser: (user: Partial<core.SessionUser>) => void
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type WebchatContext = React.Context<WebchatContextProps>
|
|
181
|
+
|
|
182
|
+
// export class DevApp extends WebchatApp {
|
|
183
|
+
// constructor(args: WebchatAppArgs)
|
|
184
|
+
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
185
|
+
// render(dest: HTMLElement, optionsAtRuntime: WebchatAppArgs): void
|
|
186
|
+
// }
|
|
187
|
+
|
|
188
|
+
export * from './components'
|
|
189
|
+
export * from './util'
|
|
190
|
+
export * from './webchat'
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { BotonicInputTester, BotonicOutputTester } from './botonic-tester'
|
|
2
|
-
export * from './components'
|
|
3
|
-
export { RequestContext, WebchatContext } from './contexts'
|
|
2
|
+
// export * from './components'
|
|
3
|
+
// export { RequestContext, WebchatContext } from './contexts'
|
|
4
4
|
export { DevApp } from './dev-app'
|
|
5
|
+
export * from './index-types'
|
|
5
6
|
export { msgsToBotonic, msgToBotonic } from './msg-to-botonic'
|
|
6
7
|
export { NodeApp } from './node-app'
|
|
7
|
-
export { staticAsset } from './util/environment'
|
|
8
|
-
export { getBotonicApp, Webchat } from './webchat/index
|
|
8
|
+
// export { staticAsset } from './util/environment'
|
|
9
|
+
// export { getBotonicApp, Webchat } from './webchat/index'
|
|
9
10
|
export { WebchatApp } from './webchat-app'
|
|
10
11
|
export { WebviewApp } from './webview-app'
|
package/src/msg-to-botonic.jsx
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
isAudio,
|
|
5
|
-
isButtonMessage,
|
|
6
|
-
isCarousel,
|
|
7
|
-
isCustom,
|
|
8
|
-
isDocument,
|
|
9
|
-
isImage,
|
|
10
|
-
isLocation,
|
|
11
|
-
isText,
|
|
12
|
-
isVideo,
|
|
13
|
-
} from './message-utils'
|
|
14
3
|
import { Audio } from './components/audio'
|
|
15
4
|
import { Button } from './components/button'
|
|
16
5
|
import { ButtonsDisabler } from './components/buttons-disabler'
|
|
@@ -25,6 +14,17 @@ import { Subtitle } from './components/subtitle'
|
|
|
25
14
|
import { Text } from './components/text'
|
|
26
15
|
import { Title } from './components/title'
|
|
27
16
|
import { Video } from './components/video'
|
|
17
|
+
import {
|
|
18
|
+
isAudio,
|
|
19
|
+
isButtonMessage,
|
|
20
|
+
isCarousel,
|
|
21
|
+
isCustom,
|
|
22
|
+
isDocument,
|
|
23
|
+
isImage,
|
|
24
|
+
isLocation,
|
|
25
|
+
isText,
|
|
26
|
+
isVideo,
|
|
27
|
+
} from './message-utils'
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
*
|
|
@@ -1,48 +1,33 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
import { isNode } from '@botonic/core'
|
|
2
|
-
import React from 'react'
|
|
3
|
+
import React, { useState } from 'react'
|
|
3
4
|
|
|
4
5
|
import { Text } from '../components/text'
|
|
5
6
|
|
|
6
|
-
/**
|
|
7
|
-
* Replaces crashed children with the provided fallback component.
|
|
8
|
-
* https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html
|
|
9
|
-
* See alternative at https://stackoverflow.com/a/60255291/145289
|
|
10
|
-
*/
|
|
11
7
|
export const createErrorBoundary = ({
|
|
12
|
-
errorComponent =
|
|
8
|
+
errorComponent = ({ errorMessage }) => (
|
|
9
|
+
<Text>The message cannot be displayed</Text>
|
|
10
|
+
),
|
|
13
11
|
} = {}) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
super(props)
|
|
17
|
-
this.state = { error: null }
|
|
18
|
-
}
|
|
12
|
+
const ErrorBoundary = ({ children }) => {
|
|
13
|
+
const [error, setError] = useState(null)
|
|
19
14
|
|
|
20
|
-
|
|
21
|
-
* @param error the exception which was trown
|
|
22
|
-
* @param errorInfo the stack of component names at the error
|
|
23
|
-
*/
|
|
24
|
-
componentDidCatch(error, errorInfo) {
|
|
25
|
-
// No need to log the error because at least chrome & firefox already show
|
|
26
|
-
// both component and call stacks
|
|
15
|
+
const componentDidCatch = (error, errorInfo) => {
|
|
27
16
|
if (isNode()) {
|
|
28
|
-
// In node, only the component stack is displayed
|
|
29
17
|
console.error(`Failure at:`, error)
|
|
30
18
|
}
|
|
31
19
|
}
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
const getDerivedStateFromError = error => {
|
|
34
22
|
return { error }
|
|
35
23
|
}
|
|
36
24
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} else {
|
|
44
|
-
return this.props.children
|
|
45
|
-
}
|
|
25
|
+
if (error) {
|
|
26
|
+
return errorComponent({
|
|
27
|
+
errorMessage: error.message,
|
|
28
|
+
})
|
|
29
|
+
} else {
|
|
30
|
+
return children
|
|
46
31
|
}
|
|
47
32
|
}
|
|
48
33
|
|
package/src/util/webchat.js
CHANGED
|
@@ -10,21 +10,20 @@ import { getProperty } from './objects'
|
|
|
10
10
|
* It gives preference to nested defined properties (e.g.: header.style) over plain properties (e.g.: headerStyle).
|
|
11
11
|
* If property doesn't exist, returns the defaultValue.
|
|
12
12
|
*/
|
|
13
|
-
export const _getThemeProperty =
|
|
14
|
-
|
|
15
|
-
defaultValue = undefined
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export const _getThemeProperty =
|
|
14
|
+
theme =>
|
|
15
|
+
(property, defaultValue = undefined) => {
|
|
16
|
+
for (const [k, v] of Object.entries(WEBCHAT.CUSTOM_PROPERTIES)) {
|
|
17
|
+
if (v == property) {
|
|
18
|
+
const nestedProperty = getProperty(theme, v)
|
|
19
|
+
if (nestedProperty !== undefined) return nestedProperty
|
|
20
|
+
const plainProperty = getProperty(theme, k)
|
|
21
|
+
if (plainProperty !== undefined) return plainProperty
|
|
22
|
+
return defaultValue
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
|
+
return undefined
|
|
25
26
|
}
|
|
26
|
-
return undefined
|
|
27
|
-
}
|
|
28
27
|
|
|
29
28
|
export const createUser = () => {
|
|
30
29
|
const parser = new UAParser()
|