@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
package/src/webchat/webchat.jsx
CHANGED
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
readDataURL,
|
|
34
34
|
} from '../message-utils'
|
|
35
35
|
import { msgToBotonic } from '../msg-to-botonic'
|
|
36
|
-
import { scrollToBottom } from '../util/dom'
|
|
37
36
|
import { isDev } from '../util/environment'
|
|
38
37
|
import { deserializeRegex, stringifyWithRegexs } from '../util/regexs'
|
|
39
38
|
import {
|
|
@@ -43,19 +42,19 @@ import {
|
|
|
43
42
|
shouldKeepSessionOnReload,
|
|
44
43
|
} from '../util/webchat'
|
|
45
44
|
import { OpenedPersistentMenu } from './components/opened-persistent-menu'
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
45
|
+
import { BotonicContainerId } from './constants'
|
|
46
|
+
import { WebchatHeader } from './header'
|
|
48
47
|
import {
|
|
49
48
|
useComponentWillMount,
|
|
50
49
|
usePrevious,
|
|
50
|
+
useScrollToBottom,
|
|
51
51
|
useTyping,
|
|
52
52
|
useWebchat,
|
|
53
53
|
} from './hooks'
|
|
54
|
-
import { WebchatMessageList } from './message-list'
|
|
55
|
-
import { WebchatReplies } from './replies'
|
|
56
54
|
import { TriggerButton } from './trigger-button'
|
|
57
55
|
import { useStorageState } from './use-storage-state-hook'
|
|
58
56
|
import { getParsedAction } from './utils'
|
|
57
|
+
import { WebchatChatArea } from './webchat-chat-area'
|
|
59
58
|
import { WebchatInputPanel } from './webchat-input-panel'
|
|
60
59
|
import { WebviewContainer } from './webview'
|
|
61
60
|
|
|
@@ -71,6 +70,7 @@ const StyledWebchat = styled.div`
|
|
|
71
70
|
box-shadow: ${COLORS.SOLID_BLACK_ALPHA_0_2} 0px 0px 12px;
|
|
72
71
|
display: flex;
|
|
73
72
|
flex-direction: column;
|
|
73
|
+
justify-content: space-between;
|
|
74
74
|
`
|
|
75
75
|
|
|
76
76
|
const ErrorMessageContainer = styled.div`
|
|
@@ -137,6 +137,12 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
137
137
|
updateTyping,
|
|
138
138
|
updateWebview,
|
|
139
139
|
webchatState,
|
|
140
|
+
webchatRef,
|
|
141
|
+
chatAreaRef,
|
|
142
|
+
inputPanelRef,
|
|
143
|
+
headerRef,
|
|
144
|
+
scrollableMessagesListRef,
|
|
145
|
+
|
|
140
146
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
141
147
|
} = props.webchatHooks || useWebchat()
|
|
142
148
|
const firstUpdate = useRef(true)
|
|
@@ -157,7 +163,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
157
163
|
|
|
158
164
|
const host = props.host || document.body
|
|
159
165
|
|
|
160
|
-
const
|
|
166
|
+
const { scrollToBottom } = useScrollToBottom({ host })
|
|
161
167
|
|
|
162
168
|
const saveWebchatState = webchatState => {
|
|
163
169
|
storage &&
|
|
@@ -276,7 +282,6 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
276
282
|
}
|
|
277
283
|
return
|
|
278
284
|
}
|
|
279
|
-
deviceAdapter.init(host)
|
|
280
285
|
}, [webchatState.isWebchatOpen])
|
|
281
286
|
|
|
282
287
|
useEffect(() => {
|
|
@@ -316,16 +321,16 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
316
321
|
|
|
317
322
|
const textareaRef = useRef(null)
|
|
318
323
|
|
|
319
|
-
const closeWebview = options => {
|
|
324
|
+
const closeWebview = async options => {
|
|
320
325
|
updateWebview()
|
|
321
326
|
if (userInputEnabled) {
|
|
322
327
|
textareaRef.current.focus()
|
|
323
328
|
}
|
|
324
329
|
if (options?.payload) {
|
|
325
|
-
sendPayload(options.payload)
|
|
330
|
+
await sendPayload(options.payload)
|
|
326
331
|
} else if (options?.path) {
|
|
327
332
|
const params = options.params ? params2queryString(options.params) : ''
|
|
328
|
-
sendPayload(`__PATH_PAYLOAD__${options.path}?${params}`)
|
|
333
|
+
await sendPayload(`__PATH_PAYLOAD__${options.path}?${params}`)
|
|
329
334
|
}
|
|
330
335
|
}
|
|
331
336
|
|
|
@@ -709,15 +714,21 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
709
714
|
updateWebchatDevSettings: updateWebchatDevSettings,
|
|
710
715
|
webchatState,
|
|
711
716
|
trackEvent: props.onTrackEvent,
|
|
717
|
+
webchatRef,
|
|
718
|
+
chatAreaRef,
|
|
719
|
+
inputPanelRef,
|
|
720
|
+
headerRef,
|
|
721
|
+
scrollableMessagesListRef,
|
|
712
722
|
}}
|
|
713
723
|
>
|
|
714
724
|
{!webchatState.isWebchatOpen && <TriggerButton />}
|
|
715
725
|
|
|
716
726
|
{webchatState.isWebchatOpen && (
|
|
717
727
|
<StyledWebchat
|
|
728
|
+
id={BotonicContainerId.Webchat}
|
|
729
|
+
ref={webchatRef}
|
|
718
730
|
// TODO: Distinguis between multiple instances of webchat, e.g. `${uniqueId}-botonic-webchat`
|
|
719
731
|
role={ROLES.WEBCHAT}
|
|
720
|
-
id={WEBCHAT.DEFAULTS.ID}
|
|
721
732
|
width={webchatState.width}
|
|
722
733
|
height={webchatState.height}
|
|
723
734
|
style={{
|
|
@@ -725,7 +736,9 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
725
736
|
...mobileStyle,
|
|
726
737
|
}}
|
|
727
738
|
>
|
|
728
|
-
<
|
|
739
|
+
<WebchatHeader
|
|
740
|
+
id={BotonicContainerId.Header}
|
|
741
|
+
ref={headerRef}
|
|
729
742
|
onCloseClick={() => {
|
|
730
743
|
toggleWebchat(false)
|
|
731
744
|
}}
|
|
@@ -735,13 +748,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
735
748
|
<ErrorMessage>{webchatState.error.message}</ErrorMessage>
|
|
736
749
|
</ErrorMessageContainer>
|
|
737
750
|
)}
|
|
738
|
-
|
|
739
|
-
<WebchatMessageList />
|
|
740
|
-
|
|
741
|
-
{webchatState.replies &&
|
|
742
|
-
Object.keys(webchatState.replies).length > 0 && (
|
|
743
|
-
<WebchatReplies replies={webchatState.replies} />
|
|
744
|
-
)}
|
|
751
|
+
<WebchatChatArea />
|
|
745
752
|
|
|
746
753
|
{webchatState.isPersistentMenuOpen && (
|
|
747
754
|
<DarkenBackground component={persistentMenu()} />
|
|
@@ -753,7 +760,7 @@ export const Webchat = forwardRef((props, ref) => {
|
|
|
753
760
|
enableAttachments={props.enableAttachments}
|
|
754
761
|
handleAttachment={handleAttachment}
|
|
755
762
|
textareaRef={textareaRef}
|
|
756
|
-
|
|
763
|
+
host={host}
|
|
757
764
|
onUserInput={props.onUserInput}
|
|
758
765
|
/>
|
|
759
766
|
)}
|
package/src/webchat/webview.jsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useContext, useEffect } from 'react'
|
|
2
|
-
import Frame from 'react-frame-component'
|
|
3
2
|
import styled from 'styled-components'
|
|
4
3
|
|
|
5
4
|
import { COLORS, ROLES, WEBCHAT } from '../constants'
|
|
@@ -35,31 +34,19 @@ const StyledWebviewContent = styled.div`
|
|
|
35
34
|
overflow: auto;
|
|
36
35
|
`
|
|
37
36
|
|
|
38
|
-
const
|
|
37
|
+
const FrameStyles = `
|
|
39
38
|
border-style: none;
|
|
40
39
|
width: 100%;
|
|
41
40
|
height: 100%;
|
|
42
41
|
`
|
|
43
42
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Setting the prop "asframe" will render the webview inside an iframe.
|
|
48
|
-
Pros and Cons of this "asframe" mode are:
|
|
49
|
-
Pros: OAuth2 flows can be tested locally with an iframe.
|
|
50
|
-
Cons: We won't be able to visualize correctly css styles in botonic serve (although styles will work in production).
|
|
51
|
-
*/
|
|
43
|
+
const StyledFrame = styled.iframe`
|
|
44
|
+
${FrameStyles}
|
|
45
|
+
`
|
|
52
46
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
height: '100%',
|
|
57
|
-
}
|
|
58
|
-
if (props.asframe) {
|
|
59
|
-
return <Frame style={style}>{props.children}</Frame>
|
|
60
|
-
}
|
|
61
|
-
return <div style={style}>{props.children}</div>
|
|
62
|
-
}
|
|
47
|
+
const StyledFrameAsDiv = styled.div`
|
|
48
|
+
${FrameStyles}
|
|
49
|
+
`
|
|
63
50
|
|
|
64
51
|
export const WebviewHeader = () => {
|
|
65
52
|
const { closeWebview } = useContext(WebviewRequestContext)
|
|
@@ -81,7 +68,11 @@ export const WebviewContainer = props => {
|
|
|
81
68
|
const { closeWebview } = useContext(WebviewRequestContext)
|
|
82
69
|
const Webview = webchatState.webview
|
|
83
70
|
|
|
84
|
-
const close = e =>
|
|
71
|
+
const close = async e => {
|
|
72
|
+
if (e.data === 'botonicCloseWebview') {
|
|
73
|
+
await closeWebview()
|
|
74
|
+
}
|
|
75
|
+
}
|
|
85
76
|
|
|
86
77
|
useEffect(() => {
|
|
87
78
|
if (window.addEventListener) {
|
|
@@ -104,9 +95,9 @@ export const WebviewContainer = props => {
|
|
|
104
95
|
{typeof Webview === 'string' ? (
|
|
105
96
|
<StyledFrame src={Webview} />
|
|
106
97
|
) : (
|
|
107
|
-
<
|
|
98
|
+
<StyledFrameAsDiv>
|
|
108
99
|
<Webview />
|
|
109
|
-
</
|
|
100
|
+
</StyledFrameAsDiv>
|
|
110
101
|
)}
|
|
111
102
|
</StyledWebviewContent>
|
|
112
103
|
</StyledWebview>
|
package/src/webchat-app.jsx
CHANGED
package/src/webview-app.tsx
CHANGED
|
@@ -12,35 +12,40 @@ class App extends React.Component {
|
|
|
12
12
|
super(props)
|
|
13
13
|
const url = new URL(window.location.href)
|
|
14
14
|
const params = Array.from(url.searchParams.entries())
|
|
15
|
-
.filter(([key, value]) => key
|
|
15
|
+
.filter(([key, value]) => key !== 'context')
|
|
16
16
|
.reduce((o, [key, value]) => {
|
|
17
17
|
o[key] = value
|
|
18
18
|
return o
|
|
19
19
|
}, {})
|
|
20
|
-
const
|
|
20
|
+
const urlContext = url.searchParams.get('context')
|
|
21
|
+
const session = JSON.parse(urlContext || '{}')
|
|
21
22
|
this.state = { session, params }
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
async close(options?: CloseWebviewOptions) {
|
|
25
26
|
let payload = options ? options.payload : null
|
|
26
|
-
|
|
27
|
+
|
|
28
|
+
if (options?.path) {
|
|
29
|
+
payload = `__PATH_PAYLOAD__${options.path}`
|
|
30
|
+
}
|
|
31
|
+
|
|
27
32
|
if (payload) {
|
|
28
33
|
if (options?.params) {
|
|
29
34
|
payload = `${payload}?${params2queryString(options.params)}`
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
|
|
37
|
+
const session = this.state.session
|
|
32
38
|
try {
|
|
33
|
-
const baseUrl =
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
data: { payload: payload, chat_id: s.user.id },
|
|
39
|
-
})
|
|
39
|
+
const baseUrl = session._hubtype_api || 'https://api.hubtype.com'
|
|
40
|
+
const url = `${baseUrl}/v1/bots/${session.bot.id}/send_postback/`
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
42
|
+
const data = { payload: payload, chat_id: session.user.id }
|
|
43
|
+
await axios.post(url, data)
|
|
40
44
|
} catch (e) {
|
|
41
45
|
console.log(e)
|
|
42
46
|
}
|
|
43
47
|
}
|
|
48
|
+
|
|
44
49
|
const provider = this.state.session.user.provider
|
|
45
50
|
const impId = this.state.session.user.imp_id
|
|
46
51
|
if (provider === PROVIDER.WHATSAPP) {
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StyledScrollbar = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
require("simplebar/dist/simplebar.css");
|
|
6
|
-
require("./styled-scrollbar.scss");
|
|
7
|
-
const simplebar_react_1 = tslib_1.__importDefault(require("simplebar-react"));
|
|
8
|
-
const styled_components_1 = tslib_1.__importStar(require("styled-components"));
|
|
9
|
-
const constants_1 = require("../../constants");
|
|
10
|
-
exports.StyledScrollbar = (0, styled_components_1.default)(simplebar_react_1.default) `
|
|
11
|
-
${props => props.ismessagescontainer === 'true' &&
|
|
12
|
-
(0, styled_components_1.css) `
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
overflow-y: auto;
|
|
16
|
-
overflow-x: hidden;
|
|
17
|
-
`}
|
|
18
|
-
& .simplebar-scrollbar::before {
|
|
19
|
-
background-color: ${({ scrollbar }) => scrollbar && scrollbar.thumb && scrollbar.thumb.color
|
|
20
|
-
? scrollbar.thumb.color
|
|
21
|
-
: `${constants_1.COLORS.GRAY}`};
|
|
22
|
-
background-image: ${({ scrollbar }) => scrollbar && scrollbar.thumb && scrollbar.thumb.bgcolor
|
|
23
|
-
? scrollbar.thumb.bgcolor
|
|
24
|
-
: `${constants_1.COLORS.GRAY}`};
|
|
25
|
-
border-radius: ${({ scrollbar }) => scrollbar && scrollbar.thumb && scrollbar.thumb.border
|
|
26
|
-
? scrollbar.thumb.border
|
|
27
|
-
: '20px'};
|
|
28
|
-
}
|
|
29
|
-
& .simplebar-track .simplebar-scrollbar.simplebar-visible::before {
|
|
30
|
-
opacity: ${({ scrollbar }) => scrollbar && !scrollbar.enable
|
|
31
|
-
? '0'
|
|
32
|
-
: scrollbar && scrollbar.thumb && scrollbar.thumb.opacity
|
|
33
|
-
? scrollbar.thumb.opacity
|
|
34
|
-
: '0.75'};
|
|
35
|
-
}
|
|
36
|
-
& .simplebar-track {
|
|
37
|
-
background-color: ${({ scrollbar }) => scrollbar &&
|
|
38
|
-
scrollbar.track &&
|
|
39
|
-
scrollbar.track.color &&
|
|
40
|
-
!(scrollbar && !scrollbar.enable)
|
|
41
|
-
? scrollbar.track.color
|
|
42
|
-
: constants_1.COLORS.TRANSPARENT};
|
|
43
|
-
background-image: ${({ scrollbar }) => scrollbar &&
|
|
44
|
-
scrollbar.track &&
|
|
45
|
-
scrollbar.track.bgcolor &&
|
|
46
|
-
!(scrollbar && !scrollbar.enable)
|
|
47
|
-
? scrollbar.track.bgcolor
|
|
48
|
-
: constants_1.COLORS.TRANSPARENT};
|
|
49
|
-
border-radius: ${({ scrollbar }) => scrollbar && scrollbar.track && scrollbar.track.border
|
|
50
|
-
? scrollbar.track.border
|
|
51
|
-
: '20px'};
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
//# sourceMappingURL=styled-scrollbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styled-scrollbar.js","sourceRoot":"","sources":["../../../../src/webchat/components/styled-scrollbar.jsx"],"names":[],"mappings":";;;;AAAA,wCAAqC;AACrC,mCAAgC;AAEhC,8EAAuC;AACvC,+EAA+C;AAE/C,+CAAwC;AAE3B,QAAA,eAAe,GAAG,IAAA,2BAAM,EAAC,yBAAS,CAAC,CAAA;IAC5C,KAAK,CAAC,EAAE,CACR,KAAK,CAAC,mBAAmB,KAAK,MAAM;IACpC,IAAA,uBAAG,EAAA;;;;;KAKF;;wBAEmB,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACpC,SAAS,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK;IACnD,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK;IACvB,CAAC,CAAC,GAAG,kBAAM,CAAC,IAAI,EAAE;wBACF,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACpC,SAAS,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO;IACrD,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO;IACzB,CAAC,CAAC,GAAG,kBAAM,CAAC,IAAI,EAAE;qBACL,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACjC,SAAS,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM;IACpD,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM;IACxB,CAAC,CAAC,MAAM;;;eAGD,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAC3B,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM;IAC5B,CAAC,CAAC,GAAG;IACL,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO;QACvD,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO;QACzB,CAAC,CAAC,MAAM;;;wBAGM,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACpC,SAAS;IACT,SAAS,CAAC,KAAK;IACf,SAAS,CAAC,KAAK,CAAC,KAAK;IACrB,CAAC,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK;IACvB,CAAC,CAAC,kBAAM,CAAC,WAAW;wBACJ,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACpC,SAAS;IACT,SAAS,CAAC,KAAK;IACf,SAAS,CAAC,KAAK,CAAC,OAAO;IACvB,CAAC,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO;IACzB,CAAC,CAAC,kBAAM,CAAC,WAAW;qBACP,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CACjC,SAAS,IAAI,SAAS,CAAC,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,MAAM;IACpD,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM;IACxB,CAAC,CAAC,MAAM;;CAEf,CAAA"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#botonic-scrollable-content
|
|
2
|
-
> div.simplebar-wrapper
|
|
3
|
-
> div.simplebar-mask
|
|
4
|
-
> div
|
|
5
|
-
> div {
|
|
6
|
-
overscroll-behavior: contain; // https://css-tricks.com/almanac/properties/o/overscroll-behavior/
|
|
7
|
-
-webkit-overflow-scrolling: touch;
|
|
8
|
-
::-webkit-scrollbar {
|
|
9
|
-
// https://github.com/Grsmto/simplebar/issues/445#issuecomment-586902814
|
|
10
|
-
display: none;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function TypingIndicator(props: any): JSX.Element;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TypingIndicator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
-
require("./typing-indicator.scss");
|
|
7
|
-
const react_1 = tslib_1.__importDefault(require("react"));
|
|
8
|
-
const constants_1 = require("../../constants");
|
|
9
|
-
const TypingIndicator = props => ((0, jsx_runtime_1.jsxs)("div", Object.assign({ role: constants_1.ROLES.TYPING_INDICATOR, className: 'typing-indicator', style: { backgroundColor: constants_1.COLORS.SEASHELL_WHITE } }, { children: [(0, jsx_runtime_1.jsx)("span", {}), (0, jsx_runtime_1.jsx)("span", {}), (0, jsx_runtime_1.jsx)("span", {})] })));
|
|
10
|
-
exports.TypingIndicator = TypingIndicator;
|
|
11
|
-
//# sourceMappingURL=typing-indicator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typing-indicator.js","sourceRoot":"","sources":["../../../../src/webchat/components/typing-indicator.jsx"],"names":[],"mappings":";;;;;AAAA,mCAAgC;AAEhC,0DAAyB;AAEzB,+CAA+C;AAExC,MAAM,eAAe,GAAG,KAAK,CAAC,EAAE,CAAC,CACtC,+CACE,IAAI,EAAE,iBAAK,CAAC,gBAAgB,EAC5B,SAAS,EAAC,kBAAkB,EAC5B,KAAK,EAAE,EAAE,eAAe,EAAE,kBAAM,CAAC,cAAc,EAAE,iBAEjD,kCAAQ,EACR,kCAAQ,EACR,kCAAQ,KACJ,CACP,CAAA;AAVY,QAAA,eAAe,mBAU3B"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
.typing-indicator {
|
|
2
|
-
will-change: transform;
|
|
3
|
-
width: 44px;
|
|
4
|
-
line-height: 0px;
|
|
5
|
-
border-radius: 20px;
|
|
6
|
-
padding: 8px 2px 8px;
|
|
7
|
-
text-align: center;
|
|
8
|
-
display: block;
|
|
9
|
-
margin: 8px;
|
|
10
|
-
position: relative;
|
|
11
|
-
animation: 2s bulge infinite ease-out;
|
|
12
|
-
span {
|
|
13
|
-
height: 6px;
|
|
14
|
-
width: 6px;
|
|
15
|
-
margin: 0 1px;
|
|
16
|
-
background-color: #9e9ea1;
|
|
17
|
-
display: inline-block;
|
|
18
|
-
border-radius: 50%;
|
|
19
|
-
opacity: 0.4;
|
|
20
|
-
@for $i from 1 through 3 {
|
|
21
|
-
&:nth-of-type(#{$i}) {
|
|
22
|
-
animation: 1s blink infinite ($i * 0.3333s);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@keyframes blink {
|
|
29
|
-
50% {
|
|
30
|
-
opacity: 1;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@keyframes bulge {
|
|
35
|
-
50% {
|
|
36
|
-
transform: scale(1.05);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class DeviceAdapter {
|
|
2
|
-
currentDevice: any;
|
|
3
|
-
init(host: any): void;
|
|
4
|
-
webchatResizer: WebchatResizer | undefined;
|
|
5
|
-
scrollbarController: ScrollbarController | undefined;
|
|
6
|
-
getCurrentDevice(): any;
|
|
7
|
-
onFocus(): void;
|
|
8
|
-
onBlur(): void;
|
|
9
|
-
fontSize(defaultFontSize?: number): number | "initial";
|
|
10
|
-
}
|
|
11
|
-
import { WebchatResizer } from "./webchat-resizer";
|
|
12
|
-
import { ScrollbarController } from "./scrollbar-controller";
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeviceAdapter = void 0;
|
|
4
|
-
const dom_1 = require("../../util/dom");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const scrollbar_controller_1 = require("./scrollbar-controller");
|
|
7
|
-
const webchat_resizer_1 = require("./webchat-resizer");
|
|
8
|
-
class DeviceAdapter {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.currentDevice = this.getCurrentDevice();
|
|
11
|
-
}
|
|
12
|
-
init(host) {
|
|
13
|
-
this.webchatResizer = new webchat_resizer_1.WebchatResizer(this.currentDevice, host);
|
|
14
|
-
this.scrollbarController = new scrollbar_controller_1.ScrollbarController(this.currentDevice, host);
|
|
15
|
-
this.scrollbarController.handleScrollEvents();
|
|
16
|
-
}
|
|
17
|
-
getCurrentDevice() {
|
|
18
|
-
// navigator.platform deprecated. Ref: (https://erikmartinjordan.com/navigator-platform-deprecated-alternative)
|
|
19
|
-
if (navigator.userAgentData)
|
|
20
|
-
return navigator.userAgentData.platform;
|
|
21
|
-
return navigator.platform;
|
|
22
|
-
}
|
|
23
|
-
onFocus() {
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
var _a;
|
|
26
|
-
// Place onFocus logic to be run the last on the queue of asynchronous events to give enough time to init method to be called. Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop#zero_delays
|
|
27
|
-
(_a = this.webchatResizer) === null || _a === void 0 ? void 0 : _a.onFocus(() => this.scrollbarController.handleOnTouchMoveEvents());
|
|
28
|
-
}, 0);
|
|
29
|
-
}
|
|
30
|
-
onBlur() {
|
|
31
|
-
if (this.currentDevice !== _1.DEVICES.MOBILE.IPHONE)
|
|
32
|
-
return;
|
|
33
|
-
this.webchatResizer.onBlur();
|
|
34
|
-
this.scrollbarController.handleOnTouchMoveEvents();
|
|
35
|
-
}
|
|
36
|
-
fontSize(defaultFontSize = 14) {
|
|
37
|
-
if (this.currentDevice !== _1.DEVICES.MOBILE.IPHONE)
|
|
38
|
-
return defaultFontSize;
|
|
39
|
-
// Disabling auto-zoom on input (iPhone devices): https://stackoverflow.com/a/25614477, https://stackoverflow.com/a/6394497
|
|
40
|
-
return 'initial';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.DeviceAdapter = DeviceAdapter;
|
|
44
|
-
//# sourceMappingURL=device-adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"device-adapter.js","sourceRoot":"","sources":["../../../../src/webchat/devices/device-adapter.js"],"names":[],"mappings":";;;AAAA,wCAA+C;AAC/C,wBAA2B;AAC3B,iEAA4D;AAC5D,uDAAkD;AAElD,MAAa,aAAa;IACxB;QACE,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAA;IAC9C,CAAC;IAED,IAAI,CAAC,IAAI;QACP,IAAI,CAAC,cAAc,GAAG,IAAI,gCAAc,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QAClE,IAAI,CAAC,mBAAmB,GAAG,IAAI,0CAAmB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;QAC5E,IAAI,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,CAAA;IAC/C,CAAC;IAED,gBAAgB;QACd,+GAA+G;QAC/G,IAAI,SAAS,CAAC,aAAa;YAAE,OAAO,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAA;QACpE,OAAO,SAAS,CAAC,QAAQ,CAAA;IAC3B,CAAC;IAED,OAAO;QACL,UAAU,CAAC,GAAG,EAAE;;YACd,iNAAiN;YACjN,MAAA,IAAI,CAAC,cAAc,0CAAE,OAAO,CAAC,GAAG,EAAE,CAChC,IAAI,CAAC,mBAAmB,CAAC,uBAAuB,EAAE,CACnD,CAAA;QACH,CAAC,EAAE,CAAC,CAAC,CAAA;IACP,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,CAAC,aAAa,KAAK,UAAO,CAAC,MAAM,CAAC,MAAM;YAAE,OAAM;QACxD,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,CAAA;QAC5B,IAAI,CAAC,mBAAmB,CAAC,uBAAuB,EAAE,CAAA;IACpD,CAAC;IAED,QAAQ,CAAC,eAAe,GAAG,EAAE;QAC3B,IAAI,IAAI,CAAC,aAAa,KAAK,UAAO,CAAC,MAAM,CAAC,MAAM;YAAE,OAAO,eAAe,CAAA;QACxE,2HAA2H;QAC3H,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AArCD,sCAqCC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export class ScrollbarController {
|
|
2
|
-
constructor(currentDevice: any, host: any);
|
|
3
|
-
currentDevice: any;
|
|
4
|
-
webchat: any;
|
|
5
|
-
handleScrollEvents(): void;
|
|
6
|
-
hasScrollbar(): boolean;
|
|
7
|
-
handleOnMouseOverEvents(e: any): void;
|
|
8
|
-
toggleOnMouseWheelEvents(): void;
|
|
9
|
-
handleOnTouchMoveEvents(e: any): void;
|
|
10
|
-
toggleOnTouchMoveEvents(): void;
|
|
11
|
-
limitScrollBoundaries(): void;
|
|
12
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ScrollbarController = void 0;
|
|
4
|
-
const dom_1 = require("../../util/dom");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
const debounced = (delay, fn) => {
|
|
7
|
-
let timerId;
|
|
8
|
-
return function (...args) {
|
|
9
|
-
if (timerId) {
|
|
10
|
-
clearTimeout(timerId);
|
|
11
|
-
}
|
|
12
|
-
timerId = setTimeout(() => {
|
|
13
|
-
fn(...args);
|
|
14
|
-
timerId = null;
|
|
15
|
-
}, delay);
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
const stopAtScrollLimit = element => {
|
|
19
|
-
if (element.scrollTop === 0)
|
|
20
|
-
element.scrollTop = 1;
|
|
21
|
-
if (element.scrollHeight - element.scrollTop === element.clientHeight)
|
|
22
|
-
element.scrollTop -= 1;
|
|
23
|
-
};
|
|
24
|
-
class ScrollbarController {
|
|
25
|
-
constructor(currentDevice, host) {
|
|
26
|
-
this.currentDevice = currentDevice;
|
|
27
|
-
this.webchat = (0, dom_1.getWebchatElement)(host);
|
|
28
|
-
}
|
|
29
|
-
handleScrollEvents() {
|
|
30
|
-
/*
|
|
31
|
-
It handles scroll events for Mobile/Desktop.
|
|
32
|
-
"ontouchmove" is the phone equivalent for "onmouseover"
|
|
33
|
-
*/
|
|
34
|
-
if ((0, _1.isMobileDevice)()) {
|
|
35
|
-
if (this.currentDevice !== _1.DEVICES.MOBILE.IPHONE)
|
|
36
|
-
return;
|
|
37
|
-
this.limitScrollBoundaries();
|
|
38
|
-
this.webchat.ontouchstart = e => {
|
|
39
|
-
this.handleOnTouchMoveEvents(e);
|
|
40
|
-
};
|
|
41
|
-
this.webchat.ontouchmove = e => {
|
|
42
|
-
this.handleOnTouchMoveEvents(e);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
this.webchat.onmouseover = e => this.handleOnMouseOverEvents(e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
hasScrollbar() {
|
|
50
|
-
const scrollableArea = (0, dom_1.getScrollableArea)(this.webchat);
|
|
51
|
-
const isScrollable = scrollableArea.visible.clientHeight - scrollableArea.full.clientHeight < 0;
|
|
52
|
-
return isScrollable;
|
|
53
|
-
}
|
|
54
|
-
handleOnMouseOverEvents(e) {
|
|
55
|
-
let target = e.currentTarget;
|
|
56
|
-
while (target) {
|
|
57
|
-
this.toggleOnMouseWheelEvents();
|
|
58
|
-
target = target.parentNode;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
toggleOnMouseWheelEvents() {
|
|
62
|
-
const scrollableContent = (0, dom_1.getScrollableContent)(this.webchat);
|
|
63
|
-
if (this.hasScrollbar()) {
|
|
64
|
-
scrollableContent.onmousewheel = {};
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
scrollableContent.onmousewheel = e => e.preventDefault();
|
|
68
|
-
}
|
|
69
|
-
handleOnTouchMoveEvents(e) {
|
|
70
|
-
this.toggleOnTouchMoveEvents();
|
|
71
|
-
}
|
|
72
|
-
toggleOnTouchMoveEvents() {
|
|
73
|
-
if (this.hasScrollbar()) {
|
|
74
|
-
this.webchat.ontouchmove = {};
|
|
75
|
-
this.webchat.ontouchstart = {};
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
this.webchat.ontouchmove = e => {
|
|
79
|
-
if (e.target === e.currentTarget)
|
|
80
|
-
e.preventDefault();
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
limitScrollBoundaries() {
|
|
84
|
-
if (this.currentDevice !== _1.DEVICES.MOBILE.IPHONE)
|
|
85
|
-
return;
|
|
86
|
-
/*
|
|
87
|
-
It adds a bounce effect when top or bottom limits of the scrollbar are reached for iOS,
|
|
88
|
-
as an alternative of overscroll-behavior (https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior)
|
|
89
|
-
*/
|
|
90
|
-
const frame = (0, dom_1.getScrollableArea)(this.webchat).visible;
|
|
91
|
-
const dStopAtScrollLimit = debounced(100, stopAtScrollLimit);
|
|
92
|
-
if (frame) {
|
|
93
|
-
if (window.addEventListener) {
|
|
94
|
-
frame.addEventListener('scroll', () => dStopAtScrollLimit(frame), true);
|
|
95
|
-
}
|
|
96
|
-
else if (window.attachEvent) {
|
|
97
|
-
frame.attachEvent('scroll', () => dStopAtScrollLimit(frame));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.ScrollbarController = ScrollbarController;
|
|
103
|
-
//# sourceMappingURL=scrollbar-controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scrollbar-controller.js","sourceRoot":"","sources":["../../../../src/webchat/devices/scrollbar-controller.js"],"names":[],"mappings":"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"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebchatResizer = void 0;
|
|
4
|
-
const dom_1 = require("../../util/dom");
|
|
5
|
-
const _1 = require(".");
|
|
6
|
-
class WebchatResizer {
|
|
7
|
-
constructor(currentDevice, host) {
|
|
8
|
-
this.currentDevice = currentDevice;
|
|
9
|
-
this.host = host;
|
|
10
|
-
this.webchat = (0, dom_1.getWebchatElement)(host);
|
|
11
|
-
}
|
|
12
|
-
onFocus(onKeyboardShownFn) {
|
|
13
|
-
if (this.currentDevice !== _1.DEVICES.MOBILE.IPHONE)
|
|
14
|
-
return;
|
|
15
|
-
/*
|
|
16
|
-
Based on Tip #4 from https://blog.opendigerati.com/the-eccentric-ways-of-ios-safari-with-the-keyboard-b5aa3f34228d,
|
|
17
|
-
taking window.innerHeight as the amount of pixels the virtual keyboard adds
|
|
18
|
-
*/
|
|
19
|
-
const waitUntilKeyboardIsShown = 400;
|
|
20
|
-
const calculateNewWebchatElementHeight = () => {
|
|
21
|
-
const webchatHeight = this.webchat.clientHeight;
|
|
22
|
-
// Some iOS versions keep track of this height with VisualViewport API: https://stackoverflow.com/a/59056851
|
|
23
|
-
const keyboardOffset = (window.visualViewport && window.visualViewport.height) ||
|
|
24
|
-
window.innerHeight;
|
|
25
|
-
let newWebchatPercentualHeight = keyboardOffset / webchatHeight;
|
|
26
|
-
const toTwoDecimal = toRound => Math.round(toRound * 100) / 100;
|
|
27
|
-
newWebchatPercentualHeight =
|
|
28
|
-
toTwoDecimal(newWebchatPercentualHeight) * 100;
|
|
29
|
-
return newWebchatPercentualHeight;
|
|
30
|
-
};
|
|
31
|
-
setTimeout(() => {
|
|
32
|
-
this.setWebchatElementHeight(`${calculateNewWebchatElementHeight()}%`);
|
|
33
|
-
// scrollToBottom(this.host)
|
|
34
|
-
onKeyboardShownFn();
|
|
35
|
-
}, waitUntilKeyboardIsShown);
|
|
36
|
-
}
|
|
37
|
-
onBlur() {
|
|
38
|
-
if (this.currentDevice !== _1.DEVICES.MOBILE.IPHONE)
|
|
39
|
-
return;
|
|
40
|
-
this.setWebchatElementHeight('100%');
|
|
41
|
-
}
|
|
42
|
-
setWebchatElementHeight(newHeight) {
|
|
43
|
-
this.webchat.style.height = newHeight;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.WebchatResizer = WebchatResizer;
|
|
47
|
-
//# sourceMappingURL=webchat-resizer.js.map
|