@botonic/react 0.30.0-alpha.1 → 0.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/carousel.js +6 -3
- package/lib/cjs/components/carousel.js.map +1 -1
- package/lib/cjs/constants.d.ts +0 -6
- package/lib/cjs/constants.js +0 -6
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/contexts.d.ts +1 -1
- package/lib/cjs/contexts.js +9 -3
- package/lib/cjs/contexts.js.map +1 -1
- package/lib/cjs/index-types.d.ts +7 -1
- package/lib/cjs/index-types.js +0 -5
- package/lib/cjs/index-types.js.map +1 -1
- package/lib/cjs/node-app.d.ts +0 -5
- package/lib/cjs/node-app.js +0 -5
- package/lib/cjs/node-app.js.map +1 -1
- package/lib/cjs/util/dom.d.ts +0 -10
- package/lib/cjs/util/dom.js +3 -29
- package/lib/cjs/util/dom.js.map +1 -1
- package/lib/cjs/webchat/actions.d.ts +0 -1
- package/lib/cjs/webchat/actions.js +0 -1
- package/lib/cjs/webchat/actions.js.map +1 -1
- package/lib/cjs/webchat/constants.d.ts +8 -0
- package/lib/cjs/webchat/constants.js +13 -0
- package/lib/cjs/webchat/constants.js.map +1 -0
- package/lib/cjs/webchat/header.d.ts +2 -2
- package/lib/cjs/webchat/header.js +14 -13
- package/lib/cjs/webchat/header.js.map +1 -1
- package/lib/cjs/webchat/hooks/index.d.ts +6 -0
- package/lib/cjs/webchat/hooks/index.js +13 -1
- package/lib/cjs/webchat/hooks/index.js.map +1 -1
- package/lib/cjs/webchat/hooks/use-device-adapter.d.ts +3 -0
- package/lib/cjs/webchat/hooks/use-device-adapter.js +46 -0
- package/lib/cjs/webchat/hooks/use-device-adapter.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-scroll-to-bottom.d.ts +7 -0
- package/lib/cjs/webchat/hooks/use-scroll-to-bottom.js +26 -0
- package/lib/cjs/webchat/hooks/use-scroll-to-bottom.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.d.ts +6 -0
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.js +140 -0
- package/lib/cjs/webchat/hooks/use-scrollbar-controller.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-virtual-keyboard-detection.d.ts +3 -0
- package/lib/cjs/webchat/hooks/use-virtual-keyboard-detection.js +28 -0
- package/lib/cjs/webchat/hooks/use-virtual-keyboard-detection.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.d.ts +4 -0
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.js +39 -0
- package/lib/cjs/webchat/hooks/use-webchat-dimensions.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-webchat-resizer.d.ts +4 -0
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js +34 -0
- package/lib/cjs/webchat/hooks/use-webchat-resizer.js.map +1 -0
- package/lib/cjs/webchat/hooks/use-webchat.d.ts +6 -1
- package/lib/cjs/webchat/hooks/use-webchat.js +12 -8
- package/lib/cjs/webchat/hooks/use-webchat.js.map +1 -1
- package/lib/cjs/webchat/index-types.d.ts +0 -1
- package/lib/cjs/webchat/message-list/index.js +4 -9
- package/lib/cjs/webchat/message-list/index.js.map +1 -1
- package/lib/cjs/webchat/message-list/scroll-button.js.map +1 -1
- package/lib/cjs/webchat/message-list/styles.d.ts +1 -0
- package/lib/cjs/webchat/message-list/styles.js +10 -1
- package/lib/cjs/webchat/message-list/styles.js.map +1 -1
- package/lib/cjs/webchat/replies.js +8 -4
- package/lib/cjs/webchat/replies.js.map +1 -1
- package/lib/cjs/webchat/typing-indicator/index.d.ts +1 -0
- package/lib/cjs/webchat/typing-indicator/index.js +9 -0
- package/lib/cjs/webchat/typing-indicator/index.js.map +1 -0
- package/lib/cjs/webchat/typing-indicator/styles.d.ts +6 -0
- package/lib/cjs/webchat/typing-indicator/styles.js +47 -0
- package/lib/cjs/webchat/typing-indicator/styles.js.map +1 -0
- package/lib/cjs/webchat/webchat-chat-area/index.d.ts +1 -0
- package/lib/cjs/webchat/webchat-chat-area/index.js +22 -0
- package/lib/cjs/webchat/webchat-chat-area/index.js.map +1 -0
- package/lib/cjs/webchat/webchat-chat-area/styles.d.ts +3 -0
- package/lib/cjs/webchat/webchat-chat-area/styles.js +13 -0
- package/lib/cjs/webchat/webchat-chat-area/styles.js.map +1 -0
- package/lib/cjs/webchat/webchat-input-panel/index.d.ts +2 -3
- package/lib/cjs/webchat/webchat-input-panel/index.js +4 -3
- package/lib/cjs/webchat/webchat-input-panel/index.js.map +1 -1
- package/lib/cjs/webchat/webchat-input-panel/textarea.d.ts +2 -3
- package/lib/cjs/webchat/webchat-input-panel/textarea.js +5 -7
- package/lib/cjs/webchat/webchat-input-panel/textarea.js.map +1 -1
- package/lib/cjs/webchat/webchat-reducer.js +0 -2
- package/lib/cjs/webchat/webchat-reducer.js.map +1 -1
- package/lib/cjs/webchat/webchat.js +18 -18
- package/lib/cjs/webchat/webchat.js.map +1 -1
- package/lib/cjs/webchat/webview.js +13 -22
- package/lib/cjs/webchat/webview.js.map +1 -1
- package/lib/cjs/webchat-app.d.ts +1 -1
- package/lib/cjs/webchat-app.js +3 -1
- package/lib/cjs/webchat-app.js.map +1 -1
- package/lib/cjs/webview-app.js +11 -11
- package/lib/cjs/webview-app.js.map +1 -1
- package/lib/esm/components/carousel.js +6 -3
- package/lib/esm/components/carousel.js.map +1 -1
- package/lib/esm/constants.d.ts +0 -6
- package/lib/esm/constants.js +0 -6
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/contexts.d.ts +1 -1
- package/lib/esm/contexts.js +9 -3
- package/lib/esm/contexts.js.map +1 -1
- package/lib/esm/index-types.d.ts +7 -1
- package/lib/esm/index-types.js +0 -5
- package/lib/esm/index-types.js.map +1 -1
- package/lib/esm/node-app.d.ts +0 -5
- package/lib/esm/node-app.js +0 -5
- package/lib/esm/node-app.js.map +1 -1
- package/lib/esm/util/dom.d.ts +0 -10
- package/lib/esm/util/dom.js +2 -25
- package/lib/esm/util/dom.js.map +1 -1
- package/lib/esm/webchat/actions.d.ts +0 -1
- package/lib/esm/webchat/actions.js +0 -1
- package/lib/esm/webchat/actions.js.map +1 -1
- package/lib/esm/webchat/constants.d.ts +8 -0
- package/lib/esm/webchat/constants.js +10 -0
- package/lib/esm/webchat/constants.js.map +1 -0
- package/lib/esm/webchat/header.d.ts +2 -2
- package/lib/esm/webchat/header.js +14 -12
- package/lib/esm/webchat/header.js.map +1 -1
- package/lib/esm/webchat/hooks/index.d.ts +6 -0
- package/lib/esm/webchat/hooks/index.js +6 -0
- package/lib/esm/webchat/hooks/index.js.map +1 -1
- package/lib/esm/webchat/hooks/use-device-adapter.d.ts +3 -0
- package/lib/esm/webchat/hooks/use-device-adapter.js +42 -0
- package/lib/esm/webchat/hooks/use-device-adapter.js.map +1 -0
- package/lib/esm/webchat/hooks/use-scroll-to-bottom.d.ts +7 -0
- package/lib/esm/webchat/hooks/use-scroll-to-bottom.js +22 -0
- package/lib/esm/webchat/hooks/use-scroll-to-bottom.js.map +1 -0
- package/lib/esm/webchat/hooks/use-scrollbar-controller.d.ts +6 -0
- package/lib/esm/webchat/hooks/use-scrollbar-controller.js +136 -0
- package/lib/esm/webchat/hooks/use-scrollbar-controller.js.map +1 -0
- package/lib/esm/webchat/hooks/use-virtual-keyboard-detection.d.ts +3 -0
- package/lib/esm/webchat/hooks/use-virtual-keyboard-detection.js +24 -0
- package/lib/esm/webchat/hooks/use-virtual-keyboard-detection.js.map +1 -0
- package/lib/esm/webchat/hooks/use-webchat-dimensions.d.ts +4 -0
- package/lib/esm/webchat/hooks/use-webchat-dimensions.js +35 -0
- package/lib/esm/webchat/hooks/use-webchat-dimensions.js.map +1 -0
- package/lib/esm/webchat/hooks/use-webchat-resizer.d.ts +4 -0
- package/lib/esm/webchat/hooks/use-webchat-resizer.js +30 -0
- package/lib/esm/webchat/hooks/use-webchat-resizer.js.map +1 -0
- package/lib/esm/webchat/hooks/use-webchat.d.ts +6 -1
- package/lib/esm/webchat/hooks/use-webchat.js +13 -9
- package/lib/esm/webchat/hooks/use-webchat.js.map +1 -1
- package/lib/esm/webchat/index-types.d.ts +0 -1
- package/lib/esm/webchat/message-list/index.js +6 -11
- package/lib/esm/webchat/message-list/index.js.map +1 -1
- package/lib/esm/webchat/message-list/scroll-button.js.map +1 -1
- package/lib/esm/webchat/message-list/styles.d.ts +1 -0
- package/lib/esm/webchat/message-list/styles.js +9 -0
- package/lib/esm/webchat/message-list/styles.js.map +1 -1
- package/lib/esm/webchat/replies.js +8 -4
- package/lib/esm/webchat/replies.js.map +1 -1
- package/lib/esm/webchat/typing-indicator/index.d.ts +1 -0
- package/lib/esm/webchat/typing-indicator/index.js +5 -0
- package/lib/esm/webchat/typing-indicator/index.js.map +1 -0
- package/lib/esm/webchat/typing-indicator/styles.d.ts +6 -0
- package/lib/esm/webchat/typing-indicator/styles.js +43 -0
- package/lib/esm/webchat/typing-indicator/styles.js.map +1 -0
- package/lib/esm/webchat/webchat-chat-area/index.d.ts +1 -0
- package/lib/esm/webchat/webchat-chat-area/index.js +18 -0
- package/lib/esm/webchat/webchat-chat-area/index.js.map +1 -0
- package/lib/esm/webchat/webchat-chat-area/styles.d.ts +3 -0
- package/lib/esm/webchat/webchat-chat-area/styles.js +9 -0
- package/lib/esm/webchat/webchat-chat-area/styles.js.map +1 -0
- package/lib/esm/webchat/webchat-input-panel/index.d.ts +2 -3
- package/lib/esm/webchat/webchat-input-panel/index.js +4 -3
- package/lib/esm/webchat/webchat-input-panel/index.js.map +1 -1
- package/lib/esm/webchat/webchat-input-panel/textarea.d.ts +2 -3
- package/lib/esm/webchat/webchat-input-panel/textarea.js +5 -7
- package/lib/esm/webchat/webchat-input-panel/textarea.js.map +1 -1
- package/lib/esm/webchat/webchat-reducer.js +0 -2
- package/lib/esm/webchat/webchat-reducer.js.map +1 -1
- package/lib/esm/webchat/webchat.js +19 -19
- package/lib/esm/webchat/webchat.js.map +1 -1
- package/lib/esm/webchat/webview.js +14 -22
- package/lib/esm/webchat/webview.js.map +1 -1
- package/lib/esm/webchat-app.d.ts +1 -1
- package/lib/esm/webchat-app.js +3 -1
- package/lib/esm/webchat-app.js.map +1 -1
- package/lib/esm/webview-app.js +11 -11
- package/lib/esm/webview-app.js.map +1 -1
- package/package.json +3 -6
- package/src/components/carousel.jsx +8 -10
- package/src/constants.js +0 -6
- package/src/contexts.tsx +9 -3
- package/src/index-types.ts +7 -52
- package/src/node-app.jsx +0 -6
- package/src/util/dom.js +2 -35
- package/src/webchat/actions.ts +0 -1
- package/src/webchat/constants.ts +9 -0
- package/src/webchat/header.jsx +31 -20
- package/src/webchat/hooks/index.ts +6 -0
- package/src/webchat/hooks/use-device-adapter.ts +50 -0
- package/src/webchat/hooks/use-scroll-to-bottom.ts +29 -0
- package/src/webchat/hooks/use-scrollbar-controller.ts +159 -0
- package/src/webchat/hooks/use-virtual-keyboard-detection.ts +27 -0
- package/src/webchat/hooks/use-webchat-dimensions.ts +50 -0
- package/src/webchat/hooks/use-webchat-resizer.ts +43 -0
- package/src/webchat/hooks/use-webchat.ts +14 -10
- package/src/webchat/index-types.ts +0 -1
- package/src/webchat/message-list/index.tsx +9 -19
- package/src/webchat/message-list/scroll-button.tsx +1 -3
- package/src/webchat/message-list/styles.ts +10 -0
- package/src/webchat/replies.jsx +13 -11
- package/src/webchat/typing-indicator/index.tsx +16 -0
- package/src/webchat/typing-indicator/styles.ts +50 -0
- package/src/webchat/webchat-chat-area/index.tsx +35 -0
- package/src/webchat/webchat-chat-area/styles.ts +9 -0
- package/src/webchat/webchat-input-panel/index.tsx +7 -4
- package/src/webchat/webchat-input-panel/textarea.tsx +7 -11
- package/src/webchat/webchat-reducer.ts +0 -2
- package/src/webchat/webchat.jsx +27 -20
- package/src/webchat/webview.jsx +14 -23
- package/src/webchat-app.jsx +2 -2
- package/src/webview-app.tsx +16 -11
- package/lib/cjs/webchat/components/styled-scrollbar.d.ts +0 -2
- package/lib/cjs/webchat/components/styled-scrollbar.js +0 -54
- package/lib/cjs/webchat/components/styled-scrollbar.js.map +0 -1
- package/lib/cjs/webchat/components/styled-scrollbar.scss +0 -12
- package/lib/cjs/webchat/components/typing-indicator.d.ts +0 -1
- package/lib/cjs/webchat/components/typing-indicator.js +0 -11
- package/lib/cjs/webchat/components/typing-indicator.js.map +0 -1
- package/lib/cjs/webchat/components/typing-indicator.scss +0 -38
- package/lib/cjs/webchat/devices/device-adapter.d.ts +0 -12
- package/lib/cjs/webchat/devices/device-adapter.js +0 -44
- package/lib/cjs/webchat/devices/device-adapter.js.map +0 -1
- package/lib/cjs/webchat/devices/scrollbar-controller.d.ts +0 -12
- package/lib/cjs/webchat/devices/scrollbar-controller.js +0 -103
- package/lib/cjs/webchat/devices/scrollbar-controller.js.map +0 -1
- package/lib/cjs/webchat/devices/webchat-resizer.d.ts +0 -9
- package/lib/cjs/webchat/devices/webchat-resizer.js +0 -47
- package/lib/cjs/webchat/devices/webchat-resizer.js.map +0 -1
- package/lib/esm/webchat/components/styled-scrollbar.d.ts +0 -2
- package/lib/esm/webchat/components/styled-scrollbar.js +0 -50
- package/lib/esm/webchat/components/styled-scrollbar.js.map +0 -1
- package/lib/esm/webchat/components/styled-scrollbar.scss +0 -12
- package/lib/esm/webchat/components/typing-indicator.d.ts +0 -1
- package/lib/esm/webchat/components/typing-indicator.js +0 -6
- package/lib/esm/webchat/components/typing-indicator.js.map +0 -1
- package/lib/esm/webchat/components/typing-indicator.scss +0 -38
- package/lib/esm/webchat/devices/device-adapter.d.ts +0 -12
- package/lib/esm/webchat/devices/device-adapter.js +0 -40
- package/lib/esm/webchat/devices/device-adapter.js.map +0 -1
- package/lib/esm/webchat/devices/scrollbar-controller.d.ts +0 -12
- package/lib/esm/webchat/devices/scrollbar-controller.js +0 -99
- package/lib/esm/webchat/devices/scrollbar-controller.js.map +0 -1
- package/lib/esm/webchat/devices/webchat-resizer.d.ts +0 -9
- package/lib/esm/webchat/devices/webchat-resizer.js +0 -43
- package/lib/esm/webchat/devices/webchat-resizer.js.map +0 -1
- package/src/webchat/components/styled-scrollbar.jsx +0 -60
- package/src/webchat/components/styled-scrollbar.scss +0 -12
- package/src/webchat/components/typing-indicator.jsx +0 -17
- package/src/webchat/components/typing-indicator.scss +0 -38
- package/src/webchat/devices/device-adapter.js +0 -43
- package/src/webchat/devices/scrollbar-controller.js +0 -107
- package/src/webchat/devices/webchat-resizer.js +0 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webview-app.js","sourceRoot":"","sources":["../../src/webview-app.tsx"],"names":[],"mappings":";;AAAA,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAuB,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvE,MAAM,GAAI,SAAQ,KAAK,CAAC,SAAS;IAC/B,YAAY,KAAK;QACf,KAAK,CAAC,KAAK,CAAC,CAAA;QACZ,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QACzC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;aAClD,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"webview-app.js","sourceRoot":"","sources":["../../src/webview-app.tsx"],"names":[],"mappings":";;AAAA,cAAc;AACd,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACvE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM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IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CACvC,KAAC,KAAK,IAAS,IAAI,EAAE,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,OAAO,IAA/C,CAAC,CAAkD,CAChE,CAAC,IAC6B,CAClC,CAAA;IACH,CAAC;CACF;AAED,MAAM,OAAO,UAAU;IACrB,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,MAAM,CAAC,IAAI;QACT,MAAM,CACJ,KAAC,aAAa,cACZ,KAAC,GAAG,IAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,GAAI,GACzC,EAChB,IAAI,CACL,CAAA;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/react",
|
|
3
|
-
"version": "0.30.0
|
|
3
|
+
"version": "0.30.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Build Chatbots using React",
|
|
6
6
|
"main": "./lib/cjs",
|
|
@@ -20,20 +20,18 @@
|
|
|
20
20
|
"lint_core": "../../node_modules/.bin/eslint_d --cache --quiet '.*.js' '*.js' 'src/**/*.js*' --fix"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@botonic/core": "0.30.0
|
|
23
|
+
"@botonic/core": "^0.30.0",
|
|
24
24
|
"axios": "^1.7.2",
|
|
25
25
|
"emoji-picker-react": "^4.4.9",
|
|
26
26
|
"lodash.merge": "^4.6.2",
|
|
27
27
|
"markdown-it": "^12.0.6",
|
|
28
28
|
"react": "^16.14.0",
|
|
29
29
|
"react-dom": "^16.14.0",
|
|
30
|
-
"react-frame-component": "^4.1.3",
|
|
31
30
|
"react-json-tree": "^0.15.0",
|
|
32
31
|
"react-router-dom": "^5.3.4",
|
|
33
32
|
"react-textarea-autosize": "^8.5.3",
|
|
34
|
-
"simplebar-react": "^2.4.3",
|
|
35
33
|
"styled-components": "^5.3.0",
|
|
36
|
-
"ua-parser-js": "^0.
|
|
34
|
+
"ua-parser-js": "^1.0.39",
|
|
37
35
|
"uuid": "^8.3.2"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
@@ -44,7 +42,6 @@
|
|
|
44
42
|
"@types/jest": "^29.5.1",
|
|
45
43
|
"@types/parse5": "^7.0.0",
|
|
46
44
|
"@types/react": "^16.14.56",
|
|
47
|
-
"@types/react-frame-component": "^4.1.6",
|
|
48
45
|
"@types/styled-components": "^5.1.34",
|
|
49
46
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
50
47
|
"copyfiles": "^2.4.1",
|
|
@@ -7,10 +7,14 @@ import RightArrow from '../assets/rightArrow.svg'
|
|
|
7
7
|
import { COLORS, WEBCHAT } from '../constants'
|
|
8
8
|
import { WebchatContext } from '../contexts'
|
|
9
9
|
import { resolveImage } from '../util/environment'
|
|
10
|
-
import { StyledScrollbar } from '../webchat/components/styled-scrollbar'
|
|
11
10
|
import { ButtonsDisabler } from './buttons-disabler'
|
|
12
11
|
import { Message } from './message'
|
|
13
12
|
|
|
13
|
+
const ScrollableCarousel = styled.div`
|
|
14
|
+
overscroll-behavior: contain;
|
|
15
|
+
-webkit-overflow-scrolling: touch;
|
|
16
|
+
`
|
|
17
|
+
|
|
14
18
|
const StyledCarousel = styled.div`
|
|
15
19
|
padding: 10px 0px;
|
|
16
20
|
display: flex;
|
|
@@ -62,10 +66,6 @@ const serialize = carouselProps => {
|
|
|
62
66
|
export const Carousel = props => {
|
|
63
67
|
const { getThemeProperty } = useContext(WebchatContext)
|
|
64
68
|
let content = props.children
|
|
65
|
-
const scrollbarOptions = {
|
|
66
|
-
...{ enable: true, autoHide: true },
|
|
67
|
-
...getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.scrollbar),
|
|
68
|
-
}
|
|
69
69
|
const [hasLeftArrow, setLeftArrow] = useState(false)
|
|
70
70
|
const [hasRightArrow, setRightArrow] = useState(true)
|
|
71
71
|
const carouselRef = useRef(null)
|
|
@@ -77,6 +77,7 @@ export const Carousel = props => {
|
|
|
77
77
|
WEBCHAT.CUSTOM_PROPERTIES.customCarouselRightArrow,
|
|
78
78
|
undefined
|
|
79
79
|
)
|
|
80
|
+
// TODO: Investigate why when set to false, scroll is enabled via dragging the bar but not hovering the carousel elements
|
|
80
81
|
const carouselArrowsEnabled = getThemeProperty(
|
|
81
82
|
WEBCHAT.CUSTOM_PROPERTIES.enableCarouselArrows,
|
|
82
83
|
true
|
|
@@ -150,10 +151,7 @@ export const Carousel = props => {
|
|
|
150
151
|
|
|
151
152
|
if (isBrowser()) {
|
|
152
153
|
content = (
|
|
153
|
-
<
|
|
154
|
-
scrollbar={scrollbarOptions}
|
|
155
|
-
autoHide={scrollbarOptions.autoHide}
|
|
156
|
-
>
|
|
154
|
+
<ScrollableCarousel>
|
|
157
155
|
<StyledCarousel
|
|
158
156
|
ref={carouselRef}
|
|
159
157
|
carouselArrowsEnabled={carouselArrowsEnabled}
|
|
@@ -161,7 +159,7 @@ export const Carousel = props => {
|
|
|
161
159
|
<StyledItems>{carouselProps.children}</StyledItems>
|
|
162
160
|
{carouselArrowsEnabled && getArrows()}
|
|
163
161
|
</StyledCarousel>
|
|
164
|
-
</
|
|
162
|
+
</ScrollableCarousel>
|
|
165
163
|
)
|
|
166
164
|
}
|
|
167
165
|
|
package/src/constants.js
CHANGED
|
@@ -53,16 +53,10 @@ export const WEBCHAT = {
|
|
|
53
53
|
pointerEvents: 'none',
|
|
54
54
|
},
|
|
55
55
|
},
|
|
56
|
-
SELECTORS: {
|
|
57
|
-
SCROLLABLE_CONTENT: '#botonic-scrollable-content',
|
|
58
|
-
SIMPLEBAR_CONTENT: '.simplebar-content',
|
|
59
|
-
SIMPLEBAR_WRAPPER: '.simplebar-content-wrapper',
|
|
60
|
-
},
|
|
61
56
|
CUSTOM_PROPERTIES: {
|
|
62
57
|
// General
|
|
63
58
|
enableAnimations: 'animations.enable',
|
|
64
59
|
markdownStyle: 'markdownStyle',
|
|
65
|
-
scrollbar: 'scrollbar',
|
|
66
60
|
imagePreviewer: 'imagePreviewer',
|
|
67
61
|
// Mobile
|
|
68
62
|
mobileBreakpoint: 'mobileBreakpoint',
|
package/src/contexts.tsx
CHANGED
|
@@ -26,12 +26,12 @@ export interface CloseWebviewOptions {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const WebviewRequestContext = createContext<{
|
|
29
|
-
closeWebview: (options?: CloseWebviewOptions) =>
|
|
29
|
+
closeWebview: (options?: CloseWebviewOptions) => Promise<void>
|
|
30
30
|
getString: (stringId: string) => string
|
|
31
31
|
params: Record<string, any>
|
|
32
32
|
session: CoreSession
|
|
33
33
|
}>({
|
|
34
|
-
closeWebview: () => undefined,
|
|
34
|
+
closeWebview: async () => undefined,
|
|
35
35
|
getString: () => '',
|
|
36
36
|
params: {} as Record<string, any>,
|
|
37
37
|
session: {} as CoreSession,
|
|
@@ -41,7 +41,7 @@ export const WebchatContext = createContext<WebchatContextProps>({
|
|
|
41
41
|
addMessage: () => {
|
|
42
42
|
return
|
|
43
43
|
},
|
|
44
|
-
closeWebview: () => {
|
|
44
|
+
closeWebview: async () => {
|
|
45
45
|
return
|
|
46
46
|
},
|
|
47
47
|
getThemeProperty: () => {
|
|
@@ -100,4 +100,10 @@ export const WebchatContext = createContext<WebchatContextProps>({
|
|
|
100
100
|
trackEvent: async () => {
|
|
101
101
|
return
|
|
102
102
|
},
|
|
103
|
+
webchatRef: { current: null },
|
|
104
|
+
chatAreaRef: { current: null },
|
|
105
|
+
inputPanelRef: { current: null },
|
|
106
|
+
headerRef: { current: null },
|
|
107
|
+
scrollableMessagesListRef: { current: null },
|
|
108
|
+
repliesRef: { current: null },
|
|
103
109
|
})
|
package/src/index-types.ts
CHANGED
|
@@ -55,51 +55,6 @@ export interface CustomMessageType {
|
|
|
55
55
|
customTypeName: string
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// TODO: Reuse types to be reused in respective components
|
|
59
|
-
// export class WebchatApp {
|
|
60
|
-
// constructor(options: WebchatAppArgs)
|
|
61
|
-
// addBotMessage(message: WebchatMessage): void
|
|
62
|
-
// addBotText(text: string): void
|
|
63
|
-
// addUserMessage(message: WebchatMessage): void
|
|
64
|
-
// addUserPayload(payload: string): void
|
|
65
|
-
// addUserText(text: string): void
|
|
66
|
-
// clearMessages(): void
|
|
67
|
-
// close(): void
|
|
68
|
-
// closeCoverComponent(): void
|
|
69
|
-
// destroy(): void
|
|
70
|
-
// getComponent(
|
|
71
|
-
// host: HTMLElement,
|
|
72
|
-
// optionsAtRuntime?: WebchatAppArgs
|
|
73
|
-
// ): React.ForwardRefExoticComponent<any>
|
|
74
|
-
// getLastMessageUpdate(): string
|
|
75
|
-
// getMessages(): WebchatMessage[]
|
|
76
|
-
// getVisibility(): Promise<boolean>
|
|
77
|
-
// isWebchatVisible({ appId: string }): Promise<boolean>
|
|
78
|
-
// onCloseWebchat(args: any): void
|
|
79
|
-
// onInitWebchat(args: any): void
|
|
80
|
-
// onOpenWebchat(args: any): void
|
|
81
|
-
// onServiceEvent(event: Event): void
|
|
82
|
-
// onStateChange(args: OnStateChangeArgs): void
|
|
83
|
-
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
84
|
-
// open(): void
|
|
85
|
-
// openCoverComponent(): void
|
|
86
|
-
// render(dest?: HTMLElement, optionsAtRuntime?: WebchatAppArgs): void
|
|
87
|
-
// resendUnsentInputs(): Promise<void>
|
|
88
|
-
// resolveWebchatVisibility(optionsAtRuntime: {
|
|
89
|
-
// appId: string
|
|
90
|
-
// visibility: () => boolean
|
|
91
|
-
// }): Promise<boolean>
|
|
92
|
-
// setTyping(enable: boolean): void
|
|
93
|
-
// toggle(): void
|
|
94
|
-
// toggleCoverComponent(): void
|
|
95
|
-
// updateMessageInfo(msgId: string, messageInfo: MessageInfo): void
|
|
96
|
-
// updateLastMessageDate(date: string): void
|
|
97
|
-
// updateUser(user: Partial<CoreSessionUser>): void
|
|
98
|
-
// updateWebchatSettings(settings: WebchatSettingsProps): void
|
|
99
|
-
// renderCustomComponent(customComponent: React.ReactNode): void
|
|
100
|
-
// unmountCustomComponent(): void
|
|
101
|
-
// }
|
|
102
|
-
|
|
103
58
|
export interface WebchatArgs {
|
|
104
59
|
blockInputs?: BlockInputOption[]
|
|
105
60
|
coverComponent?: CoverComponentOptions
|
|
@@ -195,7 +150,7 @@ export interface Event {
|
|
|
195
150
|
|
|
196
151
|
export interface WebchatContextProps {
|
|
197
152
|
addMessage: (message: WebchatMessage) => void
|
|
198
|
-
closeWebview: () => void
|
|
153
|
+
closeWebview: () => Promise<void>
|
|
199
154
|
getThemeProperty: (property: string, defaultValue?: any) => any
|
|
200
155
|
openWebview: (webviewComponent: Webview) => void
|
|
201
156
|
resetUnreadMessages: () => void
|
|
@@ -216,10 +171,10 @@ export interface WebchatContextProps {
|
|
|
216
171
|
updateWebchatDevSettings: (settings: WebchatSettingsProps) => void
|
|
217
172
|
webchatState: WebchatState
|
|
218
173
|
trackEvent: TrackEventFunction
|
|
174
|
+
webchatRef: React.MutableRefObject<HTMLDivElement | null>
|
|
175
|
+
chatAreaRef: React.MutableRefObject<HTMLDivElement | null>
|
|
176
|
+
inputPanelRef: React.MutableRefObject<HTMLDivElement | null>
|
|
177
|
+
headerRef: React.MutableRefObject<HTMLDivElement | null>
|
|
178
|
+
scrollableMessagesListRef: React.MutableRefObject<HTMLDivElement | null>
|
|
179
|
+
repliesRef: React.MutableRefObject<HTMLDivElement | null>
|
|
219
180
|
}
|
|
220
|
-
|
|
221
|
-
// export class DevApp extends WebchatApp {
|
|
222
|
-
// constructor(args: WebchatAppArgs)
|
|
223
|
-
// onUserInput(args: OnUserInputArgs): Promise<void>
|
|
224
|
-
// render(dest: HTMLElement, optionsAtRuntime: WebchatAppArgs): void
|
|
225
|
-
// }
|
package/src/node-app.jsx
CHANGED
package/src/util/dom.js
CHANGED
|
@@ -1,40 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export const getScrollableContent = webchatElement => {
|
|
4
|
-
return webchatElement.querySelector(WEBCHAT.SELECTORS.SCROLLABLE_CONTENT)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const getScrollableArea = webchatElement => {
|
|
8
|
-
const getArea = area => {
|
|
9
|
-
const botonicScrollableContent = getScrollableContent(webchatElement)
|
|
10
|
-
const scrollableArea =
|
|
11
|
-
botonicScrollableContent && botonicScrollableContent.querySelector(area)
|
|
12
|
-
return scrollableArea
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
full: getArea(WEBCHAT.SELECTORS.SIMPLEBAR_CONTENT),
|
|
16
|
-
visible: getArea(WEBCHAT.SELECTORS.SIMPLEBAR_WRAPPER),
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const scrollToBottom = ({
|
|
21
|
-
timeout = 200,
|
|
22
|
-
behavior = 'smooth',
|
|
23
|
-
host,
|
|
24
|
-
} = {}) => {
|
|
25
|
-
const webchatElement = getWebchatElement(host)
|
|
26
|
-
if (!webchatElement) return
|
|
27
|
-
const frame = getScrollableArea(webchatElement).visible
|
|
28
|
-
if (frame) {
|
|
29
|
-
setTimeout(
|
|
30
|
-
() => frame.scrollTo({ top: frame.scrollHeight, behavior: behavior }),
|
|
31
|
-
timeout
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
1
|
+
import { BotonicContainerId } from '../webchat/constants'
|
|
35
2
|
|
|
36
3
|
export const getWebchatElement = host =>
|
|
37
|
-
host && host.querySelector(`#${
|
|
4
|
+
host && host.querySelector(`#${BotonicContainerId.Webchat}`)
|
|
38
5
|
|
|
39
6
|
// https://stackoverflow.com/questions/9457891/how-to-detect-if-domcontentloaded-was-fired
|
|
40
7
|
export const onDOMLoaded = callback => {
|
package/src/webchat/actions.ts
CHANGED
|
@@ -14,7 +14,6 @@ export enum WebchatAction {
|
|
|
14
14
|
TOGGLE_WEBCHAT = 'toggleWebchat',
|
|
15
15
|
UPDATE_DEV_SETTINGS = 'updateDevSettings',
|
|
16
16
|
UPDATE_HANDOFF = 'updateHandoff',
|
|
17
|
-
UPDATE_JWT = 'updateJwt',
|
|
18
17
|
UPDATE_LAST_MESSAGE_DATE = 'updateLastMessageDate',
|
|
19
18
|
UPDATE_LAST_ROUTE_PATH = 'updateLastRoutePath',
|
|
20
19
|
UPDATE_LATEST_INPUT = 'updateLatestInput',
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Convert to an enum when all the files using these values are migrated to ts{x}
|
|
2
|
+
export const BotonicContainerId = {
|
|
3
|
+
Webchat: 'botonic-webchat',
|
|
4
|
+
Header: 'botonic-header',
|
|
5
|
+
ChatArea: 'botonic-chat-area',
|
|
6
|
+
ScrollableMessagesList: 'botonic-scrollable-messages-list',
|
|
7
|
+
RepliesContainer: 'botonic-replies-container',
|
|
8
|
+
InputPanel: 'botonic-input-panel',
|
|
9
|
+
}
|
package/src/webchat/header.jsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useContext } from 'react'
|
|
1
|
+
import React, { forwardRef, useContext } from 'react'
|
|
2
2
|
import styled from 'styled-components'
|
|
3
3
|
|
|
4
4
|
import { COLORS, ROLES, WEBCHAT } from '../constants'
|
|
@@ -6,6 +6,7 @@ import { WebchatContext } from '../contexts'
|
|
|
6
6
|
import { Scale } from '../shared/styles'
|
|
7
7
|
import { resolveImage } from '../util/environment'
|
|
8
8
|
import { ConditionalWrapper } from '../util/react'
|
|
9
|
+
import { BotonicContainerId } from './constants'
|
|
9
10
|
|
|
10
11
|
const Header = styled.div`
|
|
11
12
|
display: flex;
|
|
@@ -14,9 +15,9 @@ const Header = styled.div`
|
|
|
14
15
|
${COLORS.BLEACHED_CEDAR_PURPLE} 0%,
|
|
15
16
|
${props => props.color} 100%
|
|
16
17
|
);
|
|
17
|
-
height: 55px;
|
|
18
18
|
border-radius: ${WEBCHAT.DEFAULTS.BORDER_RADIUS_TOP_CORNERS};
|
|
19
19
|
z-index: 2;
|
|
20
|
+
height: inherit;
|
|
20
21
|
`
|
|
21
22
|
|
|
22
23
|
const ImageContainer = styled.div`
|
|
@@ -107,32 +108,42 @@ export const DefaultHeader = props => {
|
|
|
107
108
|
)
|
|
108
109
|
}
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
const StyledWebchatHeader = styled.div`
|
|
112
|
+
border-radius: 8px 8px 0px 0px;
|
|
113
|
+
box-shadow: ${COLORS.PIGEON_POST_BLUE_ALPHA_0_5} 0px 2px 5px;
|
|
114
|
+
height: 55px;
|
|
115
|
+
flex: none;
|
|
116
|
+
`
|
|
117
|
+
|
|
118
|
+
export const WebchatHeader = forwardRef((props, ref) => {
|
|
111
119
|
const { webchatState, getThemeProperty } = useContext(WebchatContext)
|
|
112
120
|
|
|
113
121
|
const handleCloseWebchat = event => {
|
|
114
122
|
props.onCloseClick(event.target.value)
|
|
115
123
|
}
|
|
124
|
+
|
|
116
125
|
const CustomHeader = getThemeProperty(WEBCHAT.CUSTOM_PROPERTIES.customHeader)
|
|
117
126
|
if (CustomHeader) {
|
|
118
|
-
return
|
|
127
|
+
return (
|
|
128
|
+
<div id={BotonicContainerId.Header} ref={ref}>
|
|
129
|
+
<CustomHeader onCloseClick={handleCloseWebchat} />
|
|
130
|
+
</div>
|
|
131
|
+
)
|
|
119
132
|
}
|
|
133
|
+
|
|
120
134
|
return (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
<StyledWebchatHeader id={BotonicContainerId.Header} ref={ref}>
|
|
136
|
+
<DefaultHeader
|
|
137
|
+
webchatState={webchatState}
|
|
138
|
+
getThemeProperty={getThemeProperty}
|
|
139
|
+
color={getThemeProperty(
|
|
140
|
+
WEBCHAT.CUSTOM_PROPERTIES.brandColor,
|
|
141
|
+
COLORS.BOTONIC_BLUE
|
|
142
|
+
)}
|
|
143
|
+
onCloseClick={handleCloseWebchat}
|
|
144
|
+
/>
|
|
145
|
+
</StyledWebchatHeader>
|
|
130
146
|
)
|
|
131
|
-
}
|
|
147
|
+
})
|
|
132
148
|
|
|
133
|
-
|
|
134
|
-
border-radius: 8px 8px 0px 0px;
|
|
135
|
-
box-shadow: ${COLORS.PIGEON_POST_BLUE_ALPHA_0_5} 0px 2px 5px;
|
|
136
|
-
height: 36px;
|
|
137
|
-
flex: none;
|
|
138
|
-
`
|
|
149
|
+
WebchatHeader.displayName = 'WebchatHeader'
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export { useComponentVisible } from './use-component-visible'
|
|
2
2
|
export { useComponentWillMount } from './use-component-will-mount'
|
|
3
|
+
export { useDeviceAdapter } from './use-device-adapter'
|
|
3
4
|
export { usePrevious } from './use-previous'
|
|
5
|
+
export { useScrollToBottom } from './use-scroll-to-bottom'
|
|
6
|
+
export { useScrollbarController } from './use-scrollbar-controller'
|
|
4
7
|
export { useTyping } from './use-typing'
|
|
8
|
+
export { useVirtualKeyboardDetection } from './use-virtual-keyboard-detection'
|
|
5
9
|
export { useWebchat, webchatInitialState } from './use-webchat'
|
|
10
|
+
export { useWebchatDimensions } from './use-webchat-dimensions'
|
|
11
|
+
export { useWebchatResizer } from './use-webchat-resizer'
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { DEVICES } from '../devices'
|
|
4
|
+
import { useScrollToBottom } from './use-scroll-to-bottom'
|
|
5
|
+
import { useScrollbarController } from './use-scrollbar-controller'
|
|
6
|
+
import { useVirtualKeyboardDetection } from './use-virtual-keyboard-detection'
|
|
7
|
+
import { useWebchatResizer } from './use-webchat-resizer'
|
|
8
|
+
|
|
9
|
+
function getCurrentDevice() {
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
if (navigator.userAgentData) return navigator.userAgentData.platform
|
|
12
|
+
return navigator.platform
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const useDeviceAdapter = (host, isWebchatOpen) => {
|
|
16
|
+
const currentDevice = getCurrentDevice()
|
|
17
|
+
|
|
18
|
+
const { scrollToBottom } = useScrollToBottom({ host })
|
|
19
|
+
|
|
20
|
+
const { isVirtualKeyboardVisible } = useVirtualKeyboardDetection(
|
|
21
|
+
window.innerHeight
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
const { handleKeyboardShown, handleKeyboardHidden } = useWebchatResizer()
|
|
25
|
+
|
|
26
|
+
const { handleScrollEvents } = useScrollbarController(currentDevice, host)
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (currentDevice !== DEVICES.MOBILE.IPHONE) return
|
|
30
|
+
if (isVirtualKeyboardVisible) {
|
|
31
|
+
handleKeyboardShown()
|
|
32
|
+
scrollToBottom()
|
|
33
|
+
} else {
|
|
34
|
+
handleKeyboardHidden()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return
|
|
38
|
+
}, [isVirtualKeyboardVisible])
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (host && isWebchatOpen) {
|
|
42
|
+
if (currentDevice !== DEVICES.MOBILE.IPHONE) return
|
|
43
|
+
handleScrollEvents()
|
|
44
|
+
}
|
|
45
|
+
}, [host, isWebchatOpen, handleScrollEvents])
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
currentDevice,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useContext } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WebchatContext } from '../../contexts'
|
|
4
|
+
import { getWebchatElement } from '../../util/dom'
|
|
5
|
+
|
|
6
|
+
export const useScrollToBottom = ({
|
|
7
|
+
host,
|
|
8
|
+
behavior = 'smooth',
|
|
9
|
+
timeout = 200,
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
webchatState: { isWebchatOpen },
|
|
13
|
+
scrollableMessagesListRef,
|
|
14
|
+
} = useContext(WebchatContext)
|
|
15
|
+
|
|
16
|
+
const scrollToBottom = () => {
|
|
17
|
+
const webchatElement = getWebchatElement(host)
|
|
18
|
+
if (!webchatElement) return
|
|
19
|
+
if (!isWebchatOpen) return
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
scrollableMessagesListRef.current?.scrollTo({
|
|
22
|
+
top: scrollableMessagesListRef.current?.scrollHeight,
|
|
23
|
+
behavior: behavior as ScrollBehavior,
|
|
24
|
+
})
|
|
25
|
+
}, timeout)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { scrollToBottom }
|
|
29
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { useContext, useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
import { WebchatContext } from '../../contexts'
|
|
4
|
+
import { DEVICES, isMobileDevice } from '../devices'
|
|
5
|
+
|
|
6
|
+
// TODO: Investigate why when we have some messages, scroll actions are not disabled properly
|
|
7
|
+
|
|
8
|
+
const debounced = (delay, fn) => {
|
|
9
|
+
let timerId
|
|
10
|
+
return function (...args) {
|
|
11
|
+
if (timerId) {
|
|
12
|
+
clearTimeout(timerId)
|
|
13
|
+
}
|
|
14
|
+
timerId = setTimeout(() => {
|
|
15
|
+
fn(...args)
|
|
16
|
+
timerId = null
|
|
17
|
+
}, delay)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const stopAtScrollLimit = element => {
|
|
22
|
+
if (element.scrollTop === 0) element.scrollTop = 1
|
|
23
|
+
if (element.scrollHeight - element.scrollTop === element.clientHeight)
|
|
24
|
+
element.scrollTop -= 1
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const useScrollbarController = (currentDevice, host) => {
|
|
28
|
+
const { webchatRef, chatAreaRef, repliesRef, scrollableMessagesListRef } =
|
|
29
|
+
useContext(WebchatContext)
|
|
30
|
+
|
|
31
|
+
const hasScrollbar = () => {
|
|
32
|
+
if (chatAreaRef.current && scrollableMessagesListRef.current) {
|
|
33
|
+
if (!repliesRef) {
|
|
34
|
+
return (
|
|
35
|
+
scrollableMessagesListRef.current?.scrollHeight >
|
|
36
|
+
chatAreaRef.current?.clientHeight
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
if (repliesRef.current) {
|
|
40
|
+
return (
|
|
41
|
+
scrollableMessagesListRef.current?.scrollHeight >
|
|
42
|
+
chatAreaRef.current?.clientHeight - repliesRef.current?.clientHeight
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const toggleOnMouseWheelEvents = () => {
|
|
51
|
+
if (scrollableMessagesListRef.current) {
|
|
52
|
+
if (hasScrollbar()) {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
scrollableMessagesListRef.current.onmousewheel = {}
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
scrollableMessagesListRef.current.onmousewheel = e => {
|
|
59
|
+
e.preventDefault()
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const handleOnMouseOverEvents = e => {
|
|
65
|
+
let target = e.currentTarget
|
|
66
|
+
while (target) {
|
|
67
|
+
toggleOnMouseWheelEvents()
|
|
68
|
+
target = target.parentNode
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const toggleOnTouchMoveEvents = () => {
|
|
73
|
+
if (webchatRef.current && scrollableMessagesListRef.current) {
|
|
74
|
+
if (hasScrollbar()) {
|
|
75
|
+
scrollableMessagesListRef.current.style.touchAction = 'auto'
|
|
76
|
+
webchatRef.current.style.touchAction = 'auto'
|
|
77
|
+
webchatRef.current.ontouchmove = null
|
|
78
|
+
webchatRef.current.ontouchstart = null
|
|
79
|
+
return
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
scrollableMessagesListRef.current.style.touchAction = 'none'
|
|
83
|
+
webchatRef.current.style.touchAction = 'none'
|
|
84
|
+
}
|
|
85
|
+
if (webchatRef.current) {
|
|
86
|
+
webchatRef.current.ontouchstart = e => {
|
|
87
|
+
if (e.target === e.currentTarget) {
|
|
88
|
+
e.preventDefault()
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
webchatRef.current.ontouchmove = e => {
|
|
92
|
+
if (e.target === e.currentTarget) {
|
|
93
|
+
e.preventDefault()
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const handleOnTouchMoveEvents = () => {
|
|
100
|
+
toggleOnTouchMoveEvents()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const limitScrollBoundaries = () => {
|
|
104
|
+
if (currentDevice !== DEVICES.MOBILE.IPHONE) return
|
|
105
|
+
const chatArea = chatAreaRef.current
|
|
106
|
+
const dStopAtScrollLimit = debounced(100, stopAtScrollLimit)
|
|
107
|
+
|
|
108
|
+
if (chatArea) {
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
if (window.addEventListener) {
|
|
111
|
+
chatArea.addEventListener(
|
|
112
|
+
'scroll',
|
|
113
|
+
() => dStopAtScrollLimit(chatArea),
|
|
114
|
+
true
|
|
115
|
+
)
|
|
116
|
+
// @ts-ignore
|
|
117
|
+
} else if (window.attachEvent) {
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
chatAreaRef.attachEvent('scroll', () => dStopAtScrollLimit(chatArea))
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const handleScrollEvents = () => {
|
|
125
|
+
if (webchatRef.current) {
|
|
126
|
+
if (isMobileDevice()) {
|
|
127
|
+
if (currentDevice !== DEVICES.MOBILE.IPHONE) return
|
|
128
|
+
|
|
129
|
+
limitScrollBoundaries()
|
|
130
|
+
|
|
131
|
+
webchatRef.current.ontouchstart = handleOnTouchMoveEvents
|
|
132
|
+
webchatRef.current.ontouchmove = handleOnTouchMoveEvents
|
|
133
|
+
} else {
|
|
134
|
+
webchatRef.current.onmouseover = e => handleOnMouseOverEvents(e)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
const webchat = webchatRef.current
|
|
141
|
+
|
|
142
|
+
handleScrollEvents()
|
|
143
|
+
|
|
144
|
+
return () => {
|
|
145
|
+
if (webchat) {
|
|
146
|
+
webchat.onmouseover = null
|
|
147
|
+
webchat.ontouchstart = null
|
|
148
|
+
webchat.ontouchmove = null
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}, [currentDevice, host])
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
handleScrollEvents,
|
|
155
|
+
handleOnTouchMoveEvents,
|
|
156
|
+
handleOnMouseOverEvents,
|
|
157
|
+
hasScrollbar,
|
|
158
|
+
}
|
|
159
|
+
}
|