@seamly/web-ui 20.8.1 → 21.0.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/build/dist/lib/deprecated-view.js +1 -1
- package/build/dist/lib/index.debug.js +585 -584
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +110 -110
- package/build/dist/lib/index.js +20269 -26441
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +6 -1
- package/build/dist/lib/standalone.js +27728 -34583
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.LICENSE.txt +1 -1
- package/build/dist/lib/storage.js +6 -15
- package/build/dist/lib/style-guide.js +9660 -8970
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles-default-implementation.js +1 -1
- package/build/dist/lib/styles.js +1 -1
- package/build/dist/lib/utils.js +85 -3
- package/build/dist/lib/utils.min.js +1 -1
- package/package.json +54 -52
- package/src/icons/icon_check-16.svg +14 -0
- package/src/icons/icon_check-32.svg +14 -0
- package/src/javascripts/api/conversation-connector.ts +149 -0
- package/src/javascripts/api/errors/seamly-base-error.js +19 -0
- package/src/javascripts/api/errors/seamly-unavailable-error.js +5 -7
- package/src/javascripts/api/{index.js → index.ts} +163 -116
- package/src/javascripts/config.types.ts +5 -4
- package/src/javascripts/domains/app/actions.ts +47 -46
- package/src/javascripts/domains/app/hooks.js +1 -1
- package/src/javascripts/domains/config/actions.ts +2 -8
- package/src/javascripts/domains/config/hooks.ts +1 -1
- package/src/javascripts/domains/config/selectors.ts +6 -6
- package/src/javascripts/domains/config/slice.ts +3 -3
- package/src/javascripts/domains/errors/index.ts +66 -0
- package/src/javascripts/domains/forms/context.ts +1 -1
- package/src/javascripts/domains/forms/forms.types.ts +3 -3
- package/src/javascripts/domains/forms/hooks.ts +10 -10
- package/src/javascripts/domains/forms/provider.tsx +9 -9
- package/src/javascripts/domains/i18n/actions.ts +11 -5
- package/src/javascripts/domains/i18n/hooks.ts +11 -8
- package/src/javascripts/domains/i18n/selectors.ts +10 -4
- package/src/javascripts/domains/i18n/slice.ts +0 -1
- package/src/javascripts/domains/interrupt/hooks.ts +1 -1
- package/src/javascripts/domains/interrupt/middleware.ts +1 -1
- package/src/javascripts/domains/store/index.ts +1 -1
- package/src/javascripts/domains/store/selectors.ts +16 -0
- package/src/javascripts/domains/store/slice.ts +47 -41
- package/src/javascripts/domains/store/store.types.ts +38 -10
- package/src/javascripts/domains/translations/components/{options-button.js → options-button.tsx} +30 -20
- package/src/javascripts/domains/translations/components/options-dialog/index.tsx +33 -0
- package/src/javascripts/domains/translations/components/options-dialog/translation-option.tsx +37 -0
- package/src/javascripts/domains/translations/components/options-dialog/translation-options.tsx +85 -0
- package/src/javascripts/domains/translations/components/translation-status.tsx +15 -0
- package/src/javascripts/domains/translations/hooks.ts +77 -11
- package/src/javascripts/domains/translations/slice.ts +20 -9
- package/src/javascripts/domains/translations/translations.types.ts +4 -2
- package/src/javascripts/domains/visibility/actions.ts +6 -10
- package/src/javascripts/domains/visibility/hooks.ts +33 -14
- package/src/javascripts/domains/visibility/selectors.ts +3 -2
- package/src/javascripts/domains/visibility/slice.ts +2 -6
- package/src/javascripts/index.ts +19 -21
- package/src/javascripts/lib/engine/{index.js → index.tsx} +25 -7
- package/src/javascripts/lib/url-helpers.ts +112 -0
- package/src/javascripts/package/utils.js +5 -2
- package/src/javascripts/schema.ts +28 -0
- package/src/javascripts/style-guide/components/app.js +16 -12
- package/src/javascripts/style-guide/components/links.js +6 -6
- package/src/javascripts/style-guide/components/static-core.js +6 -3
- package/src/javascripts/style-guide/components/view.js +1 -1
- package/src/javascripts/style-guide/states.js +129 -31
- package/src/javascripts/style-guide/style-guide-engine.js +1 -1
- package/src/javascripts/ui/components/app-options/index.js +25 -6
- package/src/javascripts/ui/components/chat-app.js +1 -1
- package/src/javascripts/ui/components/chat-status/chat-status-action.tsx +30 -0
- package/src/javascripts/ui/components/chat-status/index.tsx +61 -0
- package/src/javascripts/ui/components/conversation/component-filter.js +9 -9
- package/src/javascripts/ui/components/conversation/{conversation.js → conversation.tsx} +32 -41
- package/src/javascripts/ui/components/conversation/event/card-component.js +2 -2
- package/src/javascripts/ui/components/conversation/event/card-message.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +4 -4
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +1 -1
- package/src/javascripts/ui/components/conversation/event/chat-scroll/chat-scroll-context.ts +12 -0
- package/src/javascripts/ui/components/conversation/event/chat-scroll/chat-scroll-provider.tsx +46 -0
- package/src/javascripts/ui/components/conversation/event/chat-scroll/unread-messages-button.tsx +27 -0
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +12 -8
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +6 -6
- package/src/javascripts/ui/components/conversation/event/cta.js +2 -2
- package/src/javascripts/ui/components/conversation/event/divider/index.js +0 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/default.js +1 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +17 -22
- package/src/javascripts/ui/components/conversation/event/divider/variants/time-indicator.js +2 -2
- package/src/javascripts/ui/components/conversation/event/event-participant.js +1 -1
- package/src/javascripts/ui/components/conversation/event/event.tsx +66 -0
- package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js +1 -1
- package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +1 -1
- package/src/javascripts/ui/components/conversation/event/image-lightbox.js +1 -1
- package/src/javascripts/ui/components/conversation/event/image.js +2 -2
- package/src/javascripts/ui/components/conversation/event/splash.js +1 -1
- package/src/javascripts/ui/components/conversation/event/translation.js +1 -1
- package/src/javascripts/ui/components/conversation/event/upload.js +2 -2
- package/src/javascripts/ui/components/conversation/event/video.js +2 -2
- package/src/javascripts/ui/components/conversation/event-divider.js +1 -1
- package/src/javascripts/ui/components/conversation/message-container.js +1 -1
- package/src/javascripts/ui/components/conversation/use-chat-scroll.ts +108 -0
- package/src/javascripts/ui/components/core/{seamly-activity-monitor.js → seamly-activity-monitor.tsx} +12 -5
- package/src/javascripts/ui/components/core/seamly-api-context.ts +7 -0
- package/src/javascripts/ui/components/core/seamly-chat.tsx +8 -0
- package/src/javascripts/ui/components/core/{seamly-core.js → seamly-core.tsx} +27 -14
- package/src/javascripts/ui/components/core/seamly-event-subscriber.ts +340 -0
- package/src/javascripts/ui/components/core/seamly-file-upload.js +2 -2
- package/src/javascripts/ui/components/core/seamly-idle-detach-counter.js +1 -1
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +24 -11
- package/src/javascripts/ui/components/core/seamly-live-region.js +4 -4
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +3 -3
- package/src/javascripts/ui/components/core/seamly-read-state.js +2 -33
- package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +4 -4
- package/src/javascripts/ui/components/entry/entry-container.js +8 -8
- package/src/javascripts/ui/components/entry/text-entry/hooks.js +3 -3
- package/src/javascripts/ui/components/entry/text-entry/index.js +3 -3
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +4 -4
- package/src/javascripts/ui/components/entry/upload/file-upload-form.js +3 -3
- package/src/javascripts/ui/components/entry/upload/index.js +5 -5
- package/src/javascripts/ui/components/entry/upload-toggle.js +6 -6
- package/src/javascripts/ui/components/faq/faq.js +14 -14
- package/src/javascripts/ui/components/form-controls/error.js +2 -2
- package/src/javascripts/ui/components/form-controls/file-input.js +3 -3
- package/src/javascripts/ui/components/layout/agent-info.js +3 -3
- package/src/javascripts/ui/components/layout/chat-frame.js +20 -12
- package/src/javascripts/ui/components/layout/chat.js +5 -5
- package/src/javascripts/ui/components/layout/deprecated-app-frame.js +6 -6
- package/src/javascripts/ui/components/layout/deprecated-chat-frame.js +34 -0
- package/src/javascripts/ui/components/layout/header.js +2 -2
- package/src/javascripts/ui/components/layout/icon.js +11 -9
- package/src/javascripts/ui/components/layout/interrupt.js +7 -5
- package/src/javascripts/ui/components/layout/pre-chat-messages.js +1 -1
- package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
- package/src/javascripts/ui/components/options/options-button.js +5 -5
- package/src/javascripts/ui/components/options/{options-frame.js → options-frame.tsx} +52 -18
- package/src/javascripts/ui/components/options/transcript/index.js +9 -10
- package/src/javascripts/ui/components/options/transcript/transcript-form.js +2 -2
- package/src/javascripts/ui/components/suggestions/index.js +8 -8
- package/src/javascripts/ui/components/suggestions/suggestions-item.js +1 -1
- package/src/javascripts/{domains/translations/components/chat-status.js → ui/components/translation-chat-status/index.tsx} +13 -14
- package/src/javascripts/ui/components/translation-proposal/index.tsx +36 -0
- package/src/javascripts/ui/components/view/app-view.js +2 -7
- package/src/javascripts/ui/components/view/deprecated-view.js +8 -10
- package/src/javascripts/ui/components/view/index.js +6 -6
- package/src/javascripts/ui/components/view/inline-view.js +4 -8
- package/src/javascripts/ui/components/view/window-view/collapse-button.js +2 -2
- package/src/javascripts/ui/components/view/window-view/index.js +11 -17
- package/src/javascripts/ui/components/view/window-view/window-open-button.js +6 -6
- package/src/javascripts/ui/components/warnings/idle-detach-warning.js +3 -3
- package/src/javascripts/ui/components/warnings/prompt.js +1 -1
- package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +4 -4
- package/src/javascripts/ui/components/widgets/in-out-transition.js +20 -18
- package/src/javascripts/ui/components/widgets/lightbox.js +3 -3
- package/src/javascripts/ui/components/widgets/modal.js +2 -2
- package/src/javascripts/ui/components/widgets/upload-progress.js +2 -2
- package/src/javascripts/ui/hooks/file-upload-hooks.js +1 -1
- package/src/javascripts/ui/hooks/focus-helper-hooks.js +1 -1
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +6 -6
- package/src/javascripts/ui/hooks/seamly-hooks.js +11 -10
- package/src/javascripts/ui/hooks/seamly-option-hooks.js +6 -6
- package/src/javascripts/ui/hooks/{seamly-state-hooks.js → seamly-state-hooks.ts} +9 -6
- package/src/javascripts/ui/hooks/use-click-outside.ts +29 -0
- package/src/javascripts/ui/hooks/use-event-component-mapping.js +11 -10
- package/src/javascripts/ui/hooks/use-interval.js +1 -1
- package/src/javascripts/ui/hooks/use-seamly-actions.ts +29 -29
- package/src/javascripts/ui/hooks/use-seamly-chat.js +13 -23
- package/src/javascripts/ui/hooks/use-seamly-commands.js +20 -15
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +8 -8
- package/src/javascripts/ui/hooks/use-seamly-resume-conversation-prompt.js +2 -2
- package/src/javascripts/ui/hooks/use-single-file-upload.js +1 -1
- package/src/javascripts/ui/hooks/utility-hooks.js +1 -1
- package/src/javascripts/ui/utils/general-utils.js +0 -23
- package/src/javascripts/ui/utils/seamly-utils.ts +10 -1
- package/src/javascripts/ui/utils/seamly-utils.types.ts +9 -0
- package/src/stylesheets/1-settings/_config.scss +1 -1
- package/src/stylesheets/3-chat/_chat.scss +23 -5
- package/src/stylesheets/5-components/_chat-status.scss +72 -16
- package/src/stylesheets/5-components/_conversation.scss +35 -1
- package/src/stylesheets/5-components/_disclaimer.scss +0 -5
- package/src/stylesheets/5-components/_options.scss +16 -2
- package/src/stylesheets/5-components/_translation-options.scss +39 -0
- package/src/stylesheets/6-default-implementation/_scrollbar.scss +1 -1
- package/src/stylesheets/7-deprecated/3-app/_app.scss +19 -4
- package/src/stylesheets/7-deprecated/5-components/_chat-status.scss +5 -0
- package/src/stylesheets/7-deprecated/5-components/_options.scss +1 -0
- package/src/stylesheets/7-deprecated/5-components/_translation-options.scss +39 -0
- package/src/stylesheets/deprecated-view.scss +1 -0
- package/src/stylesheets/styles.scss +1 -0
- package/webpack/config.common.js +4 -4
- package/webpack/config.package.js +10 -16
- package/webpack/config.site.js +4 -1
- package/webpack/config.test.js +2 -1
- package/build/dist/lib/deprecated-view.css +0 -1
- package/build/dist/lib/styles-default-implementation.css +0 -1
- package/build/dist/lib/styles.css +0 -1
- package/src/.DS_Store +0 -0
- package/src/javascripts/api/event-producer.js +0 -20
- package/src/javascripts/api/producer.js +0 -136
- package/src/javascripts/domains/errors/index.js +0 -37
- package/src/javascripts/domains/translations/components/options-dialog/form.js +0 -70
- package/src/javascripts/domains/translations/components/options-dialog/index.js +0 -87
- package/src/javascripts/ui/components/chat-status/index.js +0 -38
- package/src/javascripts/ui/components/conversation/event/event.js +0 -36
- package/src/javascripts/ui/components/core/seamly-api-context.js +0 -5
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +0 -279
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { RefObject } from 'preact'
|
|
2
|
+
import {
|
|
3
|
+
MutableRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'preact/hooks'
|
|
9
|
+
import { useSelector } from 'react-redux'
|
|
10
|
+
import { timeout } from 'ui/hooks/focus-helper-hooks'
|
|
11
|
+
import {
|
|
12
|
+
useEvents,
|
|
13
|
+
useLoadedImageEventIds,
|
|
14
|
+
useSeamlyIsLoading,
|
|
15
|
+
} from 'ui/hooks/seamly-state-hooks'
|
|
16
|
+
import { RootState } from 'domains/store'
|
|
17
|
+
import { selectUnreadEventIds } from 'domains/store/selectors'
|
|
18
|
+
import { useVisibility } from 'domains/visibility/hooks'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Threshold defines how close to the bottom user needs to scroll for it to be treated as the bottom of the conversation.
|
|
22
|
+
*/
|
|
23
|
+
const THRESHOLD = 10
|
|
24
|
+
|
|
25
|
+
const useChatScroll = (
|
|
26
|
+
eventRefs: Record<string, RefObject<HTMLElement>>,
|
|
27
|
+
): {
|
|
28
|
+
containerRef: MutableRef<HTMLDivElement>
|
|
29
|
+
unreadIds: string[]
|
|
30
|
+
scrollToRef: () => void
|
|
31
|
+
scrollToBottom: () => void
|
|
32
|
+
} => {
|
|
33
|
+
const containerRef = useRef<HTMLDivElement>()
|
|
34
|
+
const [hasScrolledToBottom, setHasScrolledToBottom] = useState(true)
|
|
35
|
+
const unreadIds = useSelector(selectUnreadEventIds)
|
|
36
|
+
const events = useEvents()
|
|
37
|
+
const isLoading = useSeamlyIsLoading()
|
|
38
|
+
const { isOpen } = useVisibility()
|
|
39
|
+
const loadedImageEventIds = useLoadedImageEventIds()
|
|
40
|
+
const isLastEventFromClient = useSelector(
|
|
41
|
+
(state: RootState) => state.state.isLastEventFromClient,
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
const element = containerRef.current
|
|
46
|
+
const onScroll = () => {
|
|
47
|
+
const { scrollHeight, scrollTop, clientHeight } = element
|
|
48
|
+
const hasScrolledUp =
|
|
49
|
+
Math.abs(scrollHeight - scrollTop - clientHeight) > THRESHOLD
|
|
50
|
+
|
|
51
|
+
setHasScrolledToBottom(!hasScrolledUp)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
element.addEventListener('scroll', onScroll)
|
|
55
|
+
|
|
56
|
+
return () => element.removeEventListener('scroll', onScroll)
|
|
57
|
+
}, [])
|
|
58
|
+
|
|
59
|
+
const scrollToBottom = useCallback(() => {
|
|
60
|
+
requestAnimationFrame(async () => {
|
|
61
|
+
await timeout(30)
|
|
62
|
+
containerRef.current?.scrollTo({
|
|
63
|
+
top: containerRef.current?.scrollHeight,
|
|
64
|
+
left: 0,
|
|
65
|
+
behavior: 'auto',
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
}, [])
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (isLastEventFromClient) {
|
|
72
|
+
scrollToBottom()
|
|
73
|
+
}
|
|
74
|
+
}, [isLastEventFromClient, scrollToBottom])
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (hasScrolledToBottom) {
|
|
78
|
+
scrollToBottom()
|
|
79
|
+
}
|
|
80
|
+
}, [
|
|
81
|
+
hasScrolledToBottom,
|
|
82
|
+
unreadIds,
|
|
83
|
+
events,
|
|
84
|
+
isLoading,
|
|
85
|
+
isOpen,
|
|
86
|
+
loadedImageEventIds,
|
|
87
|
+
scrollToBottom,
|
|
88
|
+
])
|
|
89
|
+
|
|
90
|
+
const scrollToRef = () => {
|
|
91
|
+
const ref = eventRefs[unreadIds?.at(0)]?.current
|
|
92
|
+
// We scroll to the oldest unread event
|
|
93
|
+
containerRef.current?.scrollTo({
|
|
94
|
+
top: ref?.offsetTop,
|
|
95
|
+
behavior: 'auto',
|
|
96
|
+
left: 0,
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
containerRef,
|
|
102
|
+
unreadIds,
|
|
103
|
+
scrollToRef,
|
|
104
|
+
scrollToBottom,
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default useChatScroll
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback, useRef } from 'preact/hooks'
|
|
2
|
+
import { activitySendDelay } from 'config'
|
|
2
3
|
import {
|
|
3
4
|
useSeamlyCommands,
|
|
4
5
|
useSeamlyIdleDetachCountdown,
|
|
5
6
|
} from 'ui/hooks/seamly-hooks'
|
|
6
|
-
import {
|
|
7
|
+
import { actionTypes } from 'ui/utils/seamly-utils'
|
|
8
|
+
import { useVisibility } from 'domains/visibility/hooks'
|
|
7
9
|
import { className } from 'lib/css'
|
|
8
10
|
import SeamlyActivityEventContext from './seamly-activity-event-context'
|
|
9
11
|
|
|
10
12
|
const SeamlyActivityMonitor = ({ children }) => {
|
|
13
|
+
const { isMinimized } = useVisibility()
|
|
11
14
|
const prevSendTimestamp = useRef(0)
|
|
12
15
|
const { sendAction } = useSeamlyCommands()
|
|
13
16
|
const { hasCountdown, isActive, stopCountdown } =
|
|
14
17
|
useSeamlyIdleDetachCountdown()
|
|
15
18
|
|
|
16
19
|
const onActivityHandler = useCallback(() => {
|
|
20
|
+
if (isMinimized) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
const timeStamp = new Date().getTime()
|
|
18
25
|
|
|
19
26
|
const sendActive = () => {
|
|
20
|
-
sendAction({ type:
|
|
27
|
+
sendAction({ type: actionTypes.interactivityUpdate })
|
|
21
28
|
prevSendTimestamp.current = timeStamp
|
|
22
29
|
}
|
|
23
30
|
|
|
@@ -29,7 +36,7 @@ const SeamlyActivityMonitor = ({ children }) => {
|
|
|
29
36
|
if (timeStamp - prevSendTimestamp.current > activitySendDelay) {
|
|
30
37
|
sendActive()
|
|
31
38
|
}
|
|
32
|
-
}, [sendAction, hasCountdown, isActive, stopCountdown])
|
|
39
|
+
}, [sendAction, hasCountdown, isActive, stopCountdown, isMinimized])
|
|
33
40
|
|
|
34
41
|
// It is important to use keyUp here as focus may be set from outside the
|
|
35
42
|
// chat container via keyboard. In this case the keyDown handler would not
|
|
@@ -37,7 +44,7 @@ const SeamlyActivityMonitor = ({ children }) => {
|
|
|
37
44
|
return (
|
|
38
45
|
<div
|
|
39
46
|
className={className('activity-monitor')}
|
|
40
|
-
tabIndex=
|
|
47
|
+
tabIndex={-1}
|
|
41
48
|
onMouseDown={onActivityHandler}
|
|
42
49
|
onKeyUp={onActivityHandler}
|
|
43
50
|
onTouchStart={onActivityHandler}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { API } from 'api'
|
|
2
|
+
import { Events } from 'minivents'
|
|
3
|
+
import { FunctionComponent } from 'preact'
|
|
2
4
|
import { useErrorBoundary } from 'preact/hooks'
|
|
3
5
|
import { Provider } from 'react-redux'
|
|
6
|
+
import SeamlyChat from 'ui/components/core/seamly-chat'
|
|
7
|
+
import { catchError } from 'domains/errors'
|
|
8
|
+
import { Store } from 'domains/store'
|
|
4
9
|
import ComponentFilter from '../conversation/component-filter'
|
|
5
10
|
import SeamlyActivityMonitor from './seamly-activity-monitor'
|
|
6
11
|
import { SeamlyApiContext, SeamlyEventBusContext } from './seamly-api-context'
|
|
@@ -13,25 +18,33 @@ import SeamlyLiveRegion from './seamly-live-region'
|
|
|
13
18
|
import SeamlyNewNotifications from './seamly-new-notifications'
|
|
14
19
|
import SeamlyReadState from './seamly-read-state'
|
|
15
20
|
|
|
16
|
-
const SeamlyCore
|
|
17
|
-
|
|
21
|
+
const SeamlyCore: FunctionComponent<{
|
|
22
|
+
store: Store
|
|
23
|
+
eventBus: Events
|
|
24
|
+
api: API
|
|
25
|
+
}> = ({ store, children, eventBus, api }) => {
|
|
26
|
+
useErrorBoundary((error) => {
|
|
27
|
+
store.dispatch(catchError(error))
|
|
28
|
+
})
|
|
18
29
|
|
|
19
30
|
return (
|
|
20
31
|
<Provider store={store}>
|
|
21
32
|
<SeamlyEventBusContext.Provider value={eventBus}>
|
|
22
33
|
<SeamlyApiContext.Provider value={api}>
|
|
23
34
|
<SeamlyLiveRegion>
|
|
24
|
-
<
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
<SeamlyChat>
|
|
36
|
+
<ComponentFilter>
|
|
37
|
+
<SeamlyInitializer />
|
|
38
|
+
<SeamlyEventSubscriber />
|
|
39
|
+
<SeamlyReadState />
|
|
40
|
+
<SeamlyNewNotifications />
|
|
41
|
+
<SeamlyIdleDetachCounter />
|
|
42
|
+
<SeamlyActivityMonitor>
|
|
43
|
+
<SeamlyInstanceFunctionsLoader />
|
|
44
|
+
<SeamlyFileUpload>{children}</SeamlyFileUpload>
|
|
45
|
+
</SeamlyActivityMonitor>
|
|
46
|
+
</ComponentFilter>
|
|
47
|
+
</SeamlyChat>
|
|
35
48
|
</SeamlyLiveRegion>
|
|
36
49
|
</SeamlyApiContext.Provider>
|
|
37
50
|
</SeamlyEventBusContext.Provider>
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { useContext, useEffect, useRef } from 'preact/hooks'
|
|
2
|
+
import { useDispatch } from 'react-redux'
|
|
3
|
+
import SeamlyGeneralError from 'api/errors/seamly-general-error'
|
|
4
|
+
import SeamlyOfflineError from 'api/errors/seamly-offline-error'
|
|
5
|
+
import SeamlySessionExpiredError from 'api/errors/seamly-session-expired-error'
|
|
6
|
+
import { SeamlyEventBusContext } from 'ui/components/core/seamly-api-context'
|
|
7
|
+
import {
|
|
8
|
+
useEvents,
|
|
9
|
+
useSeamlyApiContext,
|
|
10
|
+
useSeamlyCommands,
|
|
11
|
+
useSeamlyIdleDetachCountdown,
|
|
12
|
+
} from 'ui/hooks/seamly-hooks'
|
|
13
|
+
import { featureKeys } from 'ui/utils/seamly-utils'
|
|
14
|
+
import { setHasResponded } from 'domains/app/slice'
|
|
15
|
+
import { clearInterrupt, setInterrupt } from 'domains/interrupt/slice'
|
|
16
|
+
import {
|
|
17
|
+
ackEvent,
|
|
18
|
+
addEvent,
|
|
19
|
+
clearEvents,
|
|
20
|
+
initResumeConversationPrompt,
|
|
21
|
+
setActiveService,
|
|
22
|
+
setFeatureEnabledState,
|
|
23
|
+
setHeaderSubTitle,
|
|
24
|
+
setHistory,
|
|
25
|
+
setIsLoading,
|
|
26
|
+
setParticipant,
|
|
27
|
+
setServiceDataItem,
|
|
28
|
+
setServiceEntryMetadata,
|
|
29
|
+
} from 'domains/store/slice'
|
|
30
|
+
import type { AckEvent, ChannelEvent } from 'domains/store/store.types'
|
|
31
|
+
import { setTranslationProposalPrompt } from 'domains/translations/slice'
|
|
32
|
+
|
|
33
|
+
const EMITTABLE_MESSAGE_TYPES = ['text', 'choice_prompt', 'image', 'video']
|
|
34
|
+
|
|
35
|
+
const SeamlyEventSubscriber = () => {
|
|
36
|
+
const api = useSeamlyApiContext()
|
|
37
|
+
|
|
38
|
+
const dispatch = useDispatch()
|
|
39
|
+
const events = useEvents()
|
|
40
|
+
const eventBus = useContext(SeamlyEventBusContext)
|
|
41
|
+
const prevEmittedEventId = useRef(null)
|
|
42
|
+
const { initCountdown, endCountdown } = useSeamlyIdleDetachCountdown()
|
|
43
|
+
const { emitEvent } = useSeamlyCommands()
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (api.connectionInfo && api.conversation.socket) {
|
|
47
|
+
const { socket } = api.conversation
|
|
48
|
+
socket.onError((err) => {
|
|
49
|
+
const seamlyOfflineError = new SeamlyOfflineError(err)
|
|
50
|
+
dispatch(
|
|
51
|
+
setInterrupt({
|
|
52
|
+
name: seamlyOfflineError.name,
|
|
53
|
+
message: seamlyOfflineError.message,
|
|
54
|
+
langKey: seamlyOfflineError.langKey,
|
|
55
|
+
originalEvent: seamlyOfflineError.originalEvent,
|
|
56
|
+
originalError: seamlyOfflineError.originalError,
|
|
57
|
+
}),
|
|
58
|
+
)
|
|
59
|
+
dispatch(clearEvents())
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
socket.onOpen(() => {
|
|
63
|
+
dispatch(clearInterrupt())
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}, [api, api.connectionInfo, api.conversation.socket, dispatch])
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (api.connectionInfo && api.conversation.channel) {
|
|
70
|
+
const { channel } = api.conversation
|
|
71
|
+
return () => {
|
|
72
|
+
channel?.leave()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return () => {}
|
|
76
|
+
}, [api, api.connectionInfo, api.conversation])
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
api.conversation.onConnection((connectionState) => {
|
|
80
|
+
if (connectionState === 'join_channel_erred') {
|
|
81
|
+
const seamlyGeneralError = new SeamlyGeneralError()
|
|
82
|
+
dispatch(
|
|
83
|
+
setInterrupt({
|
|
84
|
+
name: seamlyGeneralError.name,
|
|
85
|
+
message: seamlyGeneralError.message,
|
|
86
|
+
langKey: seamlyGeneralError.langKey,
|
|
87
|
+
originalEvent: seamlyGeneralError.originalEvent,
|
|
88
|
+
originalError: seamlyGeneralError.originalError,
|
|
89
|
+
action: seamlyGeneralError.action,
|
|
90
|
+
}),
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
}, [api.conversation, dispatch])
|
|
95
|
+
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (api.connectionInfo && api.conversation.channel) {
|
|
98
|
+
const { channel } = api.conversation
|
|
99
|
+
|
|
100
|
+
const updateParticipant = (event) => {
|
|
101
|
+
const { payload } = event
|
|
102
|
+
|
|
103
|
+
if (!payload || !payload.participant) {
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const { fromClient, participant } = payload
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
!fromClient &&
|
|
111
|
+
typeof participant !== 'string' &&
|
|
112
|
+
participant?.name
|
|
113
|
+
) {
|
|
114
|
+
dispatch(setHeaderSubTitle(participant.name))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
dispatch(
|
|
118
|
+
setParticipant({
|
|
119
|
+
participant,
|
|
120
|
+
fromClient,
|
|
121
|
+
}),
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
if (typeof participant !== 'string' && participant.introduction) {
|
|
125
|
+
dispatch(
|
|
126
|
+
addEvent({
|
|
127
|
+
...event,
|
|
128
|
+
payload: {
|
|
129
|
+
...payload,
|
|
130
|
+
type: 'participant',
|
|
131
|
+
},
|
|
132
|
+
}),
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
channel.onMessage = (type, payload) => {
|
|
138
|
+
const event = { type, payload }
|
|
139
|
+
|
|
140
|
+
switch (type) {
|
|
141
|
+
case 'ui':
|
|
142
|
+
if (payload.state && payload.state.hasOwnProperty('loading')) {
|
|
143
|
+
dispatch(setIsLoading(payload.state.loading))
|
|
144
|
+
}
|
|
145
|
+
switch (payload.type) {
|
|
146
|
+
case 'idle_detach_countdown':
|
|
147
|
+
initCountdown(payload.body.duration)
|
|
148
|
+
break
|
|
149
|
+
case 'idle_detach_countdown_elapsed':
|
|
150
|
+
endCountdown(undefined, true)
|
|
151
|
+
break
|
|
152
|
+
case 'resume_conversation_prompt':
|
|
153
|
+
dispatch(initResumeConversationPrompt())
|
|
154
|
+
break
|
|
155
|
+
case 'translation_proposal':
|
|
156
|
+
dispatch(setTranslationProposalPrompt(payload.body))
|
|
157
|
+
break
|
|
158
|
+
case 'user_first_response':
|
|
159
|
+
dispatch(setHasResponded(true))
|
|
160
|
+
// @ts-ignore
|
|
161
|
+
eventBus.emit('system.userFirstResponse', payload.body)
|
|
162
|
+
break
|
|
163
|
+
}
|
|
164
|
+
break
|
|
165
|
+
case 'message':
|
|
166
|
+
updateParticipant(payload)
|
|
167
|
+
switch (payload.type) {
|
|
168
|
+
case 'text':
|
|
169
|
+
case 'choice_prompt':
|
|
170
|
+
case 'splash':
|
|
171
|
+
case 'image':
|
|
172
|
+
case 'upload':
|
|
173
|
+
case 'video':
|
|
174
|
+
case 'cta':
|
|
175
|
+
case 'custom':
|
|
176
|
+
case 'carousel':
|
|
177
|
+
case 'card':
|
|
178
|
+
if (payload.service && payload.service.serviceSessionId) {
|
|
179
|
+
dispatch(setActiveService(payload.service.serviceSessionId))
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
dispatch(addEvent(event as ChannelEvent))
|
|
183
|
+
break
|
|
184
|
+
}
|
|
185
|
+
break
|
|
186
|
+
case 'participant':
|
|
187
|
+
updateParticipant(event)
|
|
188
|
+
break
|
|
189
|
+
case 'service_data':
|
|
190
|
+
if (payload.persist) {
|
|
191
|
+
dispatch(setServiceDataItem(payload))
|
|
192
|
+
}
|
|
193
|
+
break
|
|
194
|
+
case 'ack':
|
|
195
|
+
dispatch(ackEvent(event as AckEvent))
|
|
196
|
+
break
|
|
197
|
+
case 'system':
|
|
198
|
+
if (payload.type === 'service_changed') {
|
|
199
|
+
const { serviceSettings, ...eventPayload } = payload
|
|
200
|
+
const { entry } = serviceSettings
|
|
201
|
+
const { upload } = entry.options
|
|
202
|
+
|
|
203
|
+
dispatch(
|
|
204
|
+
setFeatureEnabledState({
|
|
205
|
+
key: featureKeys.uploads,
|
|
206
|
+
enabled: !!(upload && upload.enabled),
|
|
207
|
+
}),
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
dispatch(setServiceEntryMetadata(entry))
|
|
211
|
+
if (payload.serviceSessionId) {
|
|
212
|
+
dispatch(setActiveService(payload.serviceSessionId))
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
emitEvent('system.serviceChanged', eventPayload)
|
|
216
|
+
}
|
|
217
|
+
break
|
|
218
|
+
case 'info':
|
|
219
|
+
if (
|
|
220
|
+
payload.type === 'divider' ||
|
|
221
|
+
payload.type === 'text' ||
|
|
222
|
+
payload.type === 'translation'
|
|
223
|
+
) {
|
|
224
|
+
dispatch(addEvent(event as ChannelEvent))
|
|
225
|
+
}
|
|
226
|
+
break
|
|
227
|
+
case 'error':
|
|
228
|
+
switch (payload.type) {
|
|
229
|
+
case 'find_conversation_erred':
|
|
230
|
+
const seamlySessionExpiredError = new SeamlySessionExpiredError(
|
|
231
|
+
event,
|
|
232
|
+
)
|
|
233
|
+
dispatch(
|
|
234
|
+
setInterrupt({
|
|
235
|
+
name: seamlySessionExpiredError.name,
|
|
236
|
+
action: seamlySessionExpiredError.action,
|
|
237
|
+
message: seamlySessionExpiredError.message,
|
|
238
|
+
originalEvent: seamlySessionExpiredError.originalEvent,
|
|
239
|
+
originalError: seamlySessionExpiredError.originalError,
|
|
240
|
+
}),
|
|
241
|
+
)
|
|
242
|
+
break
|
|
243
|
+
case 'conversation_erred':
|
|
244
|
+
const seamlyGeneralError = new SeamlyGeneralError(event)
|
|
245
|
+
dispatch(
|
|
246
|
+
setInterrupt({
|
|
247
|
+
name: seamlyGeneralError.name,
|
|
248
|
+
message: seamlyGeneralError.message,
|
|
249
|
+
langKey: seamlyGeneralError.langKey,
|
|
250
|
+
originalEvent: seamlyGeneralError.originalEvent,
|
|
251
|
+
originalError: seamlyGeneralError.originalError,
|
|
252
|
+
action: seamlyGeneralError.action,
|
|
253
|
+
}),
|
|
254
|
+
)
|
|
255
|
+
break
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
return payload
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}, [
|
|
263
|
+
api,
|
|
264
|
+
api.connectionInfo,
|
|
265
|
+
api.conversation.channel,
|
|
266
|
+
dispatch,
|
|
267
|
+
emitEvent,
|
|
268
|
+
endCountdown,
|
|
269
|
+
eventBus,
|
|
270
|
+
initCountdown,
|
|
271
|
+
])
|
|
272
|
+
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
if (api.connectionInfo && api.conversation.channel) {
|
|
275
|
+
const { channel } = api.conversation
|
|
276
|
+
|
|
277
|
+
channel.on('message', (payload) => {
|
|
278
|
+
if (!EMITTABLE_MESSAGE_TYPES.includes(payload.type)) {
|
|
279
|
+
return payload
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// This check dedupes the sending of messages via
|
|
283
|
+
// the bus if a duplicate connection exists in an
|
|
284
|
+
// error situation.
|
|
285
|
+
if (payload.id !== prevEmittedEventId.current) {
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
eventBus.emit('message', payload)
|
|
288
|
+
}
|
|
289
|
+
prevEmittedEventId.current = payload.id
|
|
290
|
+
return payload
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
}, [api, api.connectionInfo, api.conversation.channel, eventBus])
|
|
294
|
+
|
|
295
|
+
useEffect(() => {
|
|
296
|
+
if (api.connectionInfo && api.conversation.channel) {
|
|
297
|
+
const { channel } = api.conversation
|
|
298
|
+
|
|
299
|
+
const syncChannelRef = channel.on('sync', (payload) => {
|
|
300
|
+
const lastEvent = events[events.length - 1]
|
|
301
|
+
const payloadLastEventId = payload?.lastEvent?.id
|
|
302
|
+
|
|
303
|
+
if (lastEvent && payloadLastEventId === lastEvent.payload.id) {
|
|
304
|
+
return payload
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return api
|
|
308
|
+
.getConversation()
|
|
309
|
+
.then((history) => {
|
|
310
|
+
if (!history) {
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
dispatch(setHistory(history))
|
|
314
|
+
})
|
|
315
|
+
.catch((error) => {
|
|
316
|
+
dispatch(
|
|
317
|
+
setInterrupt({
|
|
318
|
+
name: error?.name,
|
|
319
|
+
message: error?.message,
|
|
320
|
+
langKey: error?.langKey,
|
|
321
|
+
action: error?.action,
|
|
322
|
+
originalEvent: error?.originalEvent,
|
|
323
|
+
originalError: error?.originalError,
|
|
324
|
+
}),
|
|
325
|
+
)
|
|
326
|
+
})
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
return () => {
|
|
330
|
+
channel.off('sync', syncChannelRef)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
return () => undefined
|
|
335
|
+
}, [api, api.connectionInfo, api.conversation.channel, events, dispatch])
|
|
336
|
+
|
|
337
|
+
return null
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export default SeamlyEventSubscriber
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { useDispatch } from 'react-redux'
|
|
2
|
+
import { useSeamlyApiContext, useSeamlyCommands } from 'ui/hooks/seamly-hooks'
|
|
1
3
|
import { useI18n } from 'domains/i18n/hooks'
|
|
2
4
|
import {
|
|
3
5
|
registerUpload,
|
|
@@ -6,8 +8,6 @@ import {
|
|
|
6
8
|
setUploadProgress,
|
|
7
9
|
} from 'domains/store/slice'
|
|
8
10
|
import { randomId } from 'lib/id'
|
|
9
|
-
import { useDispatch } from 'react-redux'
|
|
10
|
-
import { useSeamlyApiContext, useSeamlyCommands } from 'ui/hooks/seamly-hooks'
|
|
11
11
|
import SeamlyFileUploadContext from './seamly-file-upload-context'
|
|
12
12
|
|
|
13
13
|
const SeamlyFileUpload = ({ children }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import useSeamlyIdleDetachCountdown from 'ui/hooks/use-seamly-idle-detach-countdown'
|
|
2
1
|
import useInterval from 'ui/hooks/use-interval'
|
|
2
|
+
import useSeamlyIdleDetachCountdown from 'ui/hooks/use-seamly-idle-detach-countdown'
|
|
3
3
|
|
|
4
4
|
const SeamlyIdleDetachCounter = () => {
|
|
5
5
|
const { hasCountdown, isActive, remaining, decrementCountdown } =
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { useContext, useEffect, useRef } from 'preact/hooks'
|
|
2
|
+
import { useDispatch } from 'react-redux'
|
|
3
|
+
import { userParticipantId } from 'config'
|
|
2
4
|
import {
|
|
3
|
-
useSeamlyCommands,
|
|
4
|
-
useSeamlyUnreadCount,
|
|
5
|
-
useSeamlyLayoutMode,
|
|
6
|
-
useSeamlyConversationUrl,
|
|
7
5
|
useSeamlyActivityEventHandler,
|
|
8
6
|
useSeamlyApiContext,
|
|
7
|
+
useSeamlyCommands,
|
|
8
|
+
useSeamlyConversationUrl,
|
|
9
|
+
useSeamlyLayoutMode,
|
|
10
|
+
useSeamlyUnreadCount,
|
|
9
11
|
} from 'ui/hooks/seamly-hooks'
|
|
10
|
-
import { actionTypes } from 'ui/utils/seamly-utils'
|
|
11
|
-
import { useTranslations } from 'domains/translations/hooks'
|
|
12
|
-
import { useInterrupt } from 'domains/interrupt/hooks'
|
|
12
|
+
import { actionTypes, sourceTypes } from 'ui/utils/seamly-utils'
|
|
13
13
|
import { useConfig } from 'domains/config/hooks'
|
|
14
|
-
import {
|
|
14
|
+
import { updateConfig } from 'domains/config/slice'
|
|
15
|
+
import { useInterrupt } from 'domains/interrupt/hooks'
|
|
16
|
+
import { useTranslations } from 'domains/translations/hooks'
|
|
15
17
|
import { visibilityStates } from 'domains/visibility/constants'
|
|
18
|
+
import { useVisibility } from 'domains/visibility/hooks'
|
|
16
19
|
import { SeamlyEventBusContext } from './seamly-api-context'
|
|
17
20
|
|
|
18
21
|
function useSeamlyInstanceFunction(functionName, fn, deps = []) {
|
|
@@ -35,6 +38,7 @@ function useSeamlyInstanceFunction(functionName, fn, deps = []) {
|
|
|
35
38
|
const SeamlyInstanceFunctionsLoader = () => {
|
|
36
39
|
const config = useConfig()
|
|
37
40
|
const { sendMessage, sendContext, sendAction } = useSeamlyCommands()
|
|
41
|
+
const dispatch = useDispatch()
|
|
38
42
|
const { setVisibility, visible } = useVisibility()
|
|
39
43
|
const currentVisibility = useRef(visible)
|
|
40
44
|
const eventBus = useContext(SeamlyEventBusContext)
|
|
@@ -101,11 +105,20 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
101
105
|
)
|
|
102
106
|
useSeamlyInstanceFunction(
|
|
103
107
|
'setTopic',
|
|
104
|
-
({ name, fallbackMessage }) => {
|
|
108
|
+
({ name, fallbackMessage, userTriggered }) => {
|
|
109
|
+
if (userTriggered) {
|
|
110
|
+
dispatch(updateConfig({ showSuggestions: false }))
|
|
111
|
+
}
|
|
112
|
+
|
|
105
113
|
if (name && fallbackMessage) {
|
|
114
|
+
const participant = userTriggered ? userParticipantId : undefined
|
|
106
115
|
sendAction({
|
|
107
116
|
type: actionTypes.setTopic,
|
|
108
|
-
body: {
|
|
117
|
+
body: {
|
|
118
|
+
name,
|
|
119
|
+
fallbackMessage,
|
|
120
|
+
participant,
|
|
121
|
+
},
|
|
109
122
|
})
|
|
110
123
|
} else {
|
|
111
124
|
console.warn(
|
|
@@ -120,7 +133,7 @@ const SeamlyInstanceFunctionsLoader = () => {
|
|
|
120
133
|
'setTranslation',
|
|
121
134
|
({ enabled, locale }) => {
|
|
122
135
|
if (enabled) {
|
|
123
|
-
enableTranslations(locale)
|
|
136
|
+
enableTranslations(locale, sourceTypes.windowApi)
|
|
124
137
|
} else {
|
|
125
138
|
disableTranslations()
|
|
126
139
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useState,
|
|
3
|
-
useEffect,
|
|
4
|
-
useRef,
|
|
5
2
|
useCallback,
|
|
6
3
|
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
7
|
} from 'preact/hooks'
|
|
8
8
|
import { ariaLiveLevels } from 'ui/utils/seamly-utils'
|
|
9
9
|
import { className } from 'lib/css'
|
|
10
|
-
import { SeamlyLiveRegionContext } from './seamly-live-region-context'
|
|
11
10
|
import { SeamlyEventBusContext } from './seamly-api-context'
|
|
11
|
+
import { SeamlyLiveRegionContext } from './seamly-live-region-context'
|
|
12
12
|
|
|
13
13
|
const SeamlyLiveRegion = ({ children }) => {
|
|
14
14
|
const eventBus = useContext(SeamlyEventBusContext)
|