@seamly/web-ui 19.0.0 → 19.1.3
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/index.debug.js +150 -62
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +40 -8
- package/build/dist/lib/index.js +493 -413
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +581 -432
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +1875 -1791
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/api/errors/seamly-base-error.js +17 -0
- package/src/javascripts/api/errors/seamly-configuration-error.js +4 -6
- package/src/javascripts/api/errors/seamly-general-error.js +4 -6
- package/src/javascripts/api/errors/seamly-offline-error.js +4 -6
- package/src/javascripts/api/errors/seamly-session-expired-error.js +4 -6
- package/src/javascripts/api/errors/seamly-unauthorized-error.js +4 -6
- package/src/javascripts/api/errors/seamly-unavailable-error.js +17 -0
- package/src/javascripts/api/index.js +10 -11
- package/src/javascripts/api/producer.js +5 -1
- package/src/javascripts/domains/app/actions.js +27 -17
- package/src/javascripts/domains/app/index.js +2 -1
- package/src/javascripts/domains/config/reducer.js +1 -0
- package/src/javascripts/domains/config/selectors.js +1 -1
- package/src/javascripts/domains/errors/index.js +33 -0
- package/src/javascripts/domains/i18n/reducer.js +6 -0
- package/src/javascripts/domains/interrupt/middleware.js +2 -0
- package/src/javascripts/domains/interrupt/reducer.js +10 -9
- package/src/javascripts/domains/store/index.js +6 -1
- package/src/javascripts/domains/store/state-reducer.js +10 -6
- package/src/javascripts/domains/visibility/actions.js +73 -0
- package/src/javascripts/domains/visibility/constants.js +8 -0
- package/src/javascripts/domains/visibility/hooks.js +24 -0
- package/src/javascripts/domains/visibility/index.js +8 -0
- package/src/javascripts/domains/visibility/reducer.js +19 -0
- package/src/javascripts/domains/visibility/selectors.js +9 -0
- package/src/javascripts/domains/visibility/utils.js +42 -0
- package/src/javascripts/index.js +3 -12
- package/src/javascripts/lib/engine/index.js +1 -0
- package/src/javascripts/lib/redux-helpers/index.js +1 -5
- package/src/javascripts/style-guide/components/app.js +1 -1
- package/src/javascripts/style-guide/components/static-core.js +13 -0
- package/src/javascripts/style-guide/states.js +48 -21
- package/src/javascripts/ui/components/conversation/conversation.js +2 -2
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +1 -8
- package/src/javascripts/ui/components/conversation/event/text.js +19 -13
- package/src/javascripts/ui/components/core/seamly-core.js +3 -0
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +3 -3
- package/src/javascripts/ui/components/core/seamly-initializer.js +2 -6
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +2 -3
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +2 -2
- package/src/javascripts/ui/components/core/seamly-read-state.js +2 -2
- package/src/javascripts/ui/components/entry/toggle-button.js +2 -2
- package/src/javascripts/ui/components/layout/agent-info.js +2 -2
- package/src/javascripts/ui/components/layout/app-frame.js +2 -3
- package/src/javascripts/ui/components/layout/chat-frame.js +2 -2
- package/src/javascripts/ui/components/layout/modal-wrapper.js +3 -6
- package/src/javascripts/ui/components/layout/view.js +3 -6
- package/src/javascripts/ui/hooks/seamly-hooks.js +0 -2
- package/src/javascripts/ui/hooks/use-seamly-chat.js +3 -5
- package/src/javascripts/ui/hooks/use-seamly-commands.js +7 -29
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +2 -2
- package/src/javascripts/ui/utils/general-utils.js +0 -9
- package/src/javascripts/ui/utils/seamly-utils.js +0 -66
- package/src/.DS_Store +0 -0
- package/src/javascripts/ui/hooks/use-seamly-stored-visibility.js +0 -31
- package/src/javascripts/ui/hooks/use-seamly-visibility.js +0 -98
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
randomId,
|
|
4
4
|
SeamlyOfflineError,
|
|
5
5
|
SeamlyGeneralError,
|
|
6
|
-
SeamlyConfigurationError,
|
|
7
6
|
} from '@seamly/web-ui'
|
|
8
7
|
import { addTranslationData } from './state-helpers'
|
|
9
8
|
|
|
@@ -21,7 +20,9 @@ const baseState = {
|
|
|
21
20
|
isLoading: false,
|
|
22
21
|
idleDetachCountdown: { hasCountdown: false, isActive: false },
|
|
23
22
|
resumeConversationPrompt: false,
|
|
24
|
-
|
|
23
|
+
visibility: {
|
|
24
|
+
visibility: visibilityStates.open,
|
|
25
|
+
},
|
|
25
26
|
serviceInfo: {
|
|
26
27
|
activeServiceSessionId: '',
|
|
27
28
|
},
|
|
@@ -953,13 +954,37 @@ const standardState = {
|
|
|
953
954
|
headingText: 'System messages',
|
|
954
955
|
description: '',
|
|
955
956
|
...baseState,
|
|
957
|
+
config: {
|
|
958
|
+
overrideMessages: {
|
|
959
|
+
timeIndicator: {
|
|
960
|
+
enabled: true,
|
|
961
|
+
threshold: 3600000,
|
|
962
|
+
},
|
|
963
|
+
},
|
|
964
|
+
},
|
|
956
965
|
participantInfo,
|
|
957
966
|
events: [
|
|
967
|
+
{
|
|
968
|
+
type: 'message',
|
|
969
|
+
payload: {
|
|
970
|
+
...shortTextMessage.payload,
|
|
971
|
+
occurredAt: (Date.now() - 86400000 * 5) * 1000,
|
|
972
|
+
id: randomId(),
|
|
973
|
+
body: {
|
|
974
|
+
text: 'Long ago when a dialog started',
|
|
975
|
+
type: 'text',
|
|
976
|
+
variables: {},
|
|
977
|
+
},
|
|
978
|
+
},
|
|
979
|
+
},
|
|
958
980
|
participantMessage,
|
|
959
981
|
participantMessageDefaultIcon,
|
|
960
982
|
newTopicDivider,
|
|
961
|
-
infoMessage,
|
|
962
983
|
transcriptInfoMessage,
|
|
984
|
+
...[newTranslationDividerStart, newTranslationDividerStop].map(
|
|
985
|
+
addTranslationData,
|
|
986
|
+
),
|
|
987
|
+
infoMessage,
|
|
963
988
|
],
|
|
964
989
|
},
|
|
965
990
|
choicePromptMessages: {
|
|
@@ -1142,34 +1167,24 @@ const standardState = {
|
|
|
1142
1167
|
},
|
|
1143
1168
|
],
|
|
1144
1169
|
},
|
|
1145
|
-
|
|
1146
|
-
// Important: This cannot pick up the language files so the text is hard set here.
|
|
1147
|
-
category: categoryKeys.errors,
|
|
1148
|
-
headingText: 'Disconnected interrupt',
|
|
1149
|
-
description: '',
|
|
1150
|
-
...baseState,
|
|
1151
|
-
interrupt: {
|
|
1152
|
-
error: new SeamlyOfflineError(),
|
|
1153
|
-
},
|
|
1154
|
-
},
|
|
1155
|
-
generalErrorInterrupt: {
|
|
1170
|
+
errorWithAction: {
|
|
1156
1171
|
// Important: This cannot pick up the language files so the text is hard set here.
|
|
1157
1172
|
category: categoryKeys.errors,
|
|
1158
|
-
headingText: '
|
|
1173
|
+
headingText: 'Error with a user action',
|
|
1159
1174
|
description: '',
|
|
1160
1175
|
...baseState,
|
|
1161
1176
|
interrupt: {
|
|
1162
1177
|
error: new SeamlyGeneralError(),
|
|
1163
1178
|
},
|
|
1164
1179
|
},
|
|
1165
|
-
|
|
1180
|
+
errorWithoutAction: {
|
|
1166
1181
|
// Important: This cannot pick up the language files so the text is hard set here.
|
|
1167
1182
|
category: categoryKeys.errors,
|
|
1168
|
-
headingText: '
|
|
1183
|
+
headingText: 'Error without a user action',
|
|
1169
1184
|
description: '',
|
|
1170
1185
|
...baseState,
|
|
1171
1186
|
interrupt: {
|
|
1172
|
-
error: new
|
|
1187
|
+
error: new SeamlyOfflineError(),
|
|
1173
1188
|
},
|
|
1174
1189
|
},
|
|
1175
1190
|
privacyDisclaimer: {
|
|
@@ -1694,6 +1709,7 @@ const standardState = {
|
|
|
1694
1709
|
activeServiceSessionId: '3942159e-9878-469e-9120-f44fd6be0f35',
|
|
1695
1710
|
},
|
|
1696
1711
|
events: [
|
|
1712
|
+
newTranslationDividerStart,
|
|
1697
1713
|
infoMessage,
|
|
1698
1714
|
shortTextMessage,
|
|
1699
1715
|
{
|
|
@@ -1722,6 +1738,8 @@ const standardState = {
|
|
|
1722
1738
|
textMesageWithBullets,
|
|
1723
1739
|
choicePromptMessage,
|
|
1724
1740
|
ctaMessage,
|
|
1741
|
+
newTranslationDividerStop,
|
|
1742
|
+
newTranslationDividerStart,
|
|
1725
1743
|
].map(addTranslationData),
|
|
1726
1744
|
translations: {
|
|
1727
1745
|
...translationsSlice,
|
|
@@ -1786,7 +1804,10 @@ export const getStateObj = (layoutModes, customComponentEventBodies) => ({
|
|
|
1786
1804
|
window: {
|
|
1787
1805
|
...baseState,
|
|
1788
1806
|
config: { ...baseState.config, layoutMode: 'window' },
|
|
1789
|
-
|
|
1807
|
+
visibility: {
|
|
1808
|
+
...baseState.visibility,
|
|
1809
|
+
visibility: visibilityStates.minimized,
|
|
1810
|
+
},
|
|
1790
1811
|
},
|
|
1791
1812
|
},
|
|
1792
1813
|
minimizedStarted: {
|
|
@@ -1796,7 +1817,10 @@ export const getStateObj = (layoutModes, customComponentEventBodies) => ({
|
|
|
1796
1817
|
window: {
|
|
1797
1818
|
...baseState,
|
|
1798
1819
|
config: { ...baseState.config, layoutMode: 'window' },
|
|
1799
|
-
|
|
1820
|
+
visibility: {
|
|
1821
|
+
...baseState.visibility,
|
|
1822
|
+
visibility: visibilityStates.minimized,
|
|
1823
|
+
},
|
|
1800
1824
|
participantInfo,
|
|
1801
1825
|
headerTitles,
|
|
1802
1826
|
},
|
|
@@ -1808,7 +1832,10 @@ export const getStateObj = (layoutModes, customComponentEventBodies) => ({
|
|
|
1808
1832
|
window: {
|
|
1809
1833
|
...baseState,
|
|
1810
1834
|
config: { ...baseState.config, layoutMode: 'window' },
|
|
1811
|
-
|
|
1835
|
+
visibility: {
|
|
1836
|
+
...baseState.visibility,
|
|
1837
|
+
visibility: visibilityStates.minimized,
|
|
1838
|
+
},
|
|
1812
1839
|
participantInfo,
|
|
1813
1840
|
headerTitles,
|
|
1814
1841
|
unreadEvents: 12,
|
|
@@ -3,7 +3,6 @@ import { className } from '../../../lib/css'
|
|
|
3
3
|
import { useI18n } from '../../../domains/i18n'
|
|
4
4
|
import {
|
|
5
5
|
useSeamlyIsLoading,
|
|
6
|
-
useSeamlyVisibility,
|
|
7
6
|
useSkiplink,
|
|
8
7
|
useSkiplinkTargetFocusing,
|
|
9
8
|
} from '../../hooks/seamly-hooks'
|
|
@@ -12,13 +11,14 @@ import Event from './event/event'
|
|
|
12
11
|
import Loader from './loader'
|
|
13
12
|
import ComponentFilter from './component-filter'
|
|
14
13
|
import PrivacyDisclaimer from '../layout/privacy-disclaimer'
|
|
14
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
15
15
|
|
|
16
16
|
const Conversation = () => {
|
|
17
17
|
const { t } = useI18n()
|
|
18
18
|
const appBodyContainer = useRef(null)
|
|
19
19
|
const events = useEvents()
|
|
20
20
|
const isLoading = useSeamlyIsLoading()
|
|
21
|
-
const { isOpen } =
|
|
21
|
+
const { isOpen } = useVisibility()
|
|
22
22
|
const skiplinkTargetId = useSkiplink()
|
|
23
23
|
const focusSkiplinkTarget = useSkiplinkTargetFocusing()
|
|
24
24
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useMemo } from 'preact/hooks'
|
|
2
1
|
import Mustache from 'mustache'
|
|
3
2
|
|
|
4
3
|
Mustache.escape = function (escapeText) {
|
|
@@ -11,7 +10,7 @@ const parseLinkVariable = (variable) => {
|
|
|
11
10
|
}>${variable.name}</a>`
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export function
|
|
13
|
+
export function parseRichText(text, variables = {}) {
|
|
15
14
|
const view = {}
|
|
16
15
|
Object.entries(variables).forEach(([key, variable]) => {
|
|
17
16
|
switch (variable.type) {
|
|
@@ -34,9 +33,3 @@ export function parseRichtText(text, variables = {}) {
|
|
|
34
33
|
|
|
35
34
|
return output
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
const useTextRendering = ({ text, variables = {} }) => {
|
|
39
|
-
return useMemo(() => parseRichtText(text, variables), [text, variables])
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default useTextRendering
|
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
import { useMemo } from 'preact/hooks'
|
|
1
2
|
import parseBody from '../../../../lib/parse-body'
|
|
2
3
|
import useEventLinkClickHandler from './hooks/use-event-link-click-handler'
|
|
3
|
-
import
|
|
4
|
+
import { parseRichText } from './hooks/use-text-rendering'
|
|
4
5
|
import MessageContainer from '../message-container'
|
|
5
6
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
6
7
|
|
|
7
8
|
const Text = ({ event, ...props }) => {
|
|
8
|
-
const { payload } = event
|
|
9
|
-
|
|
10
9
|
const [body] = useTranslatedEventData(event)
|
|
11
|
-
const eventClick = useEventLinkClickHandler(payload.id)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
const eventClick = useEventLinkClickHandler(event.payload.id)
|
|
11
|
+
|
|
12
|
+
const containerProps = useMemo(() => {
|
|
13
|
+
if (!event.payload.fromClient) {
|
|
14
|
+
return {
|
|
15
|
+
bodyProps: {
|
|
16
|
+
dangerouslySetInnerHTML: {
|
|
17
|
+
__html: parseRichText(parseBody(body.text), body.variables),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
children: <p>{body.text}</p>,
|
|
24
|
+
}
|
|
25
|
+
}, [body, event])
|
|
16
26
|
return (
|
|
17
27
|
<MessageContainer
|
|
18
28
|
type="text"
|
|
19
29
|
event={event}
|
|
20
30
|
onClick={eventClick}
|
|
21
31
|
{...props}
|
|
22
|
-
|
|
23
|
-
dangerouslySetInnerHTML: {
|
|
24
|
-
__html: eventBody,
|
|
25
|
-
},
|
|
26
|
-
}}
|
|
32
|
+
{...containerProps}
|
|
27
33
|
/>
|
|
28
34
|
)
|
|
29
35
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useErrorBoundary } from 'preact/hooks'
|
|
1
2
|
import SeamlyInstanceFunctionsLoader from './seamly-instance-functions-loader'
|
|
2
3
|
import SeamlyReadState from './seamly-read-state'
|
|
3
4
|
import SeamlyNewNotifications from './seamly-new-notifications'
|
|
@@ -9,8 +10,10 @@ import SeamlyEventSubscriber from './seamly-event-subscriber'
|
|
|
9
10
|
import SeamlyFileUpload from './seamly-file-upload'
|
|
10
11
|
import { SeamlyEventBusContext, SeamlyApiContext } from './seamly-api-context'
|
|
11
12
|
import { StoreProvider } from '../../../domains/redux'
|
|
13
|
+
import { catchError } from '../../../domains/errors'
|
|
12
14
|
|
|
13
15
|
const SeamlyCore = ({ store, children, config, eventBus, api }) => {
|
|
16
|
+
useErrorBoundary((error) => store.dispatch(catchError(error)))
|
|
14
17
|
return (
|
|
15
18
|
<StoreProvider store={store}>
|
|
16
19
|
<SeamlyEventBusContext.Provider value={eventBus}>
|
|
@@ -179,15 +179,15 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
179
179
|
switch (payload.type) {
|
|
180
180
|
case 'find_conversation_erred':
|
|
181
181
|
dispatch(
|
|
182
|
-
InterruptActions.set(new SeamlySessionExpiredError()),
|
|
182
|
+
InterruptActions.set(new SeamlySessionExpiredError(event)),
|
|
183
183
|
)
|
|
184
184
|
break
|
|
185
185
|
case 'seamly_offline':
|
|
186
|
-
dispatch(InterruptActions.set(new SeamlyOfflineError()))
|
|
186
|
+
dispatch(InterruptActions.set(new SeamlyOfflineError(event)))
|
|
187
187
|
dispatch({ type: CLEAR_EVENTS })
|
|
188
188
|
break
|
|
189
189
|
default:
|
|
190
|
-
dispatch(InterruptActions.set(new SeamlyGeneralError()))
|
|
190
|
+
dispatch(InterruptActions.set(new SeamlyGeneralError(event)))
|
|
191
191
|
break
|
|
192
192
|
}
|
|
193
193
|
break
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'preact/hooks'
|
|
2
|
-
import {
|
|
3
|
-
import { useSeamlyOptions, useSeamlyVisibility } from '../../hooks/seamly-hooks'
|
|
2
|
+
import { useSeamlyOptions } from '../../hooks/seamly-hooks'
|
|
4
3
|
import { useConfig } from '../../../domains/config'
|
|
5
4
|
|
|
6
5
|
const SeamlyInitializer = () => {
|
|
7
6
|
const { initUserSelectedOptions } = useSeamlyOptions()
|
|
8
7
|
const seamlyInitialized = useRef(false)
|
|
9
|
-
const { setVisibility } = useSeamlyVisibility()
|
|
10
8
|
const config = useConfig()
|
|
11
9
|
|
|
12
10
|
useEffect(() => {
|
|
13
11
|
if (config.api && !seamlyInitialized.current) {
|
|
14
12
|
seamlyInitialized.current = true
|
|
15
13
|
initUserSelectedOptions()
|
|
16
|
-
|
|
17
|
-
setVisibility(visibilityStates.initialize)
|
|
18
14
|
}
|
|
19
|
-
}, [initUserSelectedOptions, config
|
|
15
|
+
}, [initUserSelectedOptions, config])
|
|
20
16
|
|
|
21
17
|
return null
|
|
22
18
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { useContext, useEffect, useRef } from 'preact/hooks'
|
|
2
2
|
import {
|
|
3
3
|
useSeamlyCommands,
|
|
4
|
-
useSeamlyVisibility,
|
|
5
4
|
useSeamlyUnreadCount,
|
|
6
5
|
useSeamlyLayoutMode,
|
|
7
6
|
useSeamlyConversationUrl,
|
|
8
7
|
useSeamlyActivityEventHandler,
|
|
9
8
|
useSeamlyApiContext,
|
|
10
9
|
} from '../../hooks/seamly-hooks'
|
|
11
|
-
import { visibilityStates } from '../../utils/seamly-utils'
|
|
12
10
|
import { SeamlyEventBusContext } from './seamly-api-context'
|
|
13
11
|
import { useTranslations } from '../../../domains/translations'
|
|
14
12
|
import { useInterrupt } from '../../../domains/interrupt'
|
|
15
13
|
import { useConfig } from '../../../domains/config'
|
|
14
|
+
import { visibilityStates, useVisibility } from '../../../domains/visibility'
|
|
16
15
|
|
|
17
16
|
function useSeamlyInstanceFunction(functionName, fn, deps = []) {
|
|
18
17
|
const eventBus = useContext(SeamlyEventBusContext)
|
|
@@ -34,7 +33,7 @@ function useSeamlyInstanceFunction(functionName, fn, deps = []) {
|
|
|
34
33
|
const SeamlyInstanceFunctionsLoader = () => {
|
|
35
34
|
const config = useConfig()
|
|
36
35
|
const { sendMessage, sendContext, sendAction } = useSeamlyCommands()
|
|
37
|
-
const { setVisibility, visible } =
|
|
36
|
+
const { setVisibility, visible } = useVisibility()
|
|
38
37
|
const currentVisibility = useRef(visible)
|
|
39
38
|
const eventBus = useContext(SeamlyEventBusContext)
|
|
40
39
|
const api = useSeamlyApiContext()
|
|
@@ -3,11 +3,11 @@ import { useI18n } from '../../../domains/i18n'
|
|
|
3
3
|
import {
|
|
4
4
|
useEvents,
|
|
5
5
|
useLiveRegion,
|
|
6
|
-
useSeamlyVisibility,
|
|
7
6
|
useSeamlyIsHistoryLoaded,
|
|
8
7
|
} from '../../hooks/seamly-hooks'
|
|
9
8
|
import { newMessageScreenReaderWait } from '../../../config'
|
|
10
9
|
import { debounce } from '../../utils/general-utils'
|
|
10
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
11
11
|
|
|
12
12
|
const SeamlyNewNotifications = () => {
|
|
13
13
|
const { t } = useI18n()
|
|
@@ -16,7 +16,7 @@ const SeamlyNewNotifications = () => {
|
|
|
16
16
|
const previousServerEventCount = useRef(0)
|
|
17
17
|
const isHistoryLoaded = useSeamlyIsHistoryLoaded()
|
|
18
18
|
const { sendPolite } = useLiveRegion()
|
|
19
|
-
const { isOpen } =
|
|
19
|
+
const { isOpen } = useVisibility()
|
|
20
20
|
const prevIsOpen = useRef(null)
|
|
21
21
|
const debounceFunc = useRef(null)
|
|
22
22
|
|
|
@@ -2,7 +2,6 @@ import { useEffect, useRef, useMemo } from 'preact/hooks'
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
useEvents,
|
|
5
|
-
useSeamlyVisibility,
|
|
6
5
|
useSeamlyCommands,
|
|
7
6
|
useLiveRegion,
|
|
8
7
|
useSeamlyUnreadCount,
|
|
@@ -17,6 +16,7 @@ import {
|
|
|
17
16
|
} from '../../utils/seamly-utils'
|
|
18
17
|
import { debounce } from '../../utils/general-utils'
|
|
19
18
|
import { unreadScreenReaderWait } from '../../../config'
|
|
19
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
20
20
|
|
|
21
21
|
const { SET_EVENTS_READ } = seamlyActions
|
|
22
22
|
|
|
@@ -24,7 +24,7 @@ const SeamlyReadState = () => {
|
|
|
24
24
|
const { t } = useI18n()
|
|
25
25
|
const events = useEvents()
|
|
26
26
|
const dispatch = useSeamlyDispatchContext()
|
|
27
|
-
const { isOpen, isVisible } =
|
|
27
|
+
const { isOpen, isVisible } = useVisibility()
|
|
28
28
|
const { sendAction } = useSeamlyCommands()
|
|
29
29
|
const unreadCount = useSeamlyUnreadCount()
|
|
30
30
|
const { sendPolite } = useLiveRegion()
|
|
@@ -2,7 +2,6 @@ import { useLayoutEffect, useRef } from 'preact/hooks'
|
|
|
2
2
|
import { useI18n } from '../../../domains/i18n'
|
|
3
3
|
import { className } from '../../../lib/css'
|
|
4
4
|
import {
|
|
5
|
-
useSeamlyVisibility,
|
|
6
5
|
useSkiplinkTargetFocusing,
|
|
7
6
|
useFocusIfSeamlyContainedFocus,
|
|
8
7
|
useSeamlyCurrentAgent,
|
|
@@ -11,11 +10,12 @@ import {
|
|
|
11
10
|
useSeamlyStateContext,
|
|
12
11
|
} from '../../hooks/seamly-hooks'
|
|
13
12
|
import { useInterrupt } from '../../../domains/interrupt'
|
|
13
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
14
14
|
|
|
15
15
|
const ToggleButton = ({ onOpenChat }) => {
|
|
16
16
|
const { t } = useI18n()
|
|
17
17
|
const titleId = useGeneratedId()
|
|
18
|
-
const { isOpen } =
|
|
18
|
+
const { isOpen } = useVisibility()
|
|
19
19
|
const prevIsOpen = useRef(null)
|
|
20
20
|
const buttonRef = useRef(null)
|
|
21
21
|
const lastEventRef = useRef()
|
|
@@ -2,19 +2,19 @@ import Icon from './icon'
|
|
|
2
2
|
import {
|
|
3
3
|
useSeamlyHeaderData,
|
|
4
4
|
useSeamlyUnreadCount,
|
|
5
|
-
useSeamlyVisibility,
|
|
6
5
|
useSeamlyCurrentAgent,
|
|
7
6
|
} from '../../hooks/seamly-hooks'
|
|
8
7
|
import { className } from '../../../lib/css'
|
|
9
8
|
import { useI18n } from '../../../domains/i18n'
|
|
10
9
|
import { useInterrupt } from '../../../domains/interrupt'
|
|
11
10
|
import { useConfig } from '../../../domains/config'
|
|
11
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
12
12
|
|
|
13
13
|
const AgentInfo = () => {
|
|
14
14
|
const { t } = useI18n()
|
|
15
15
|
const { title, subTitle } = useSeamlyHeaderData()
|
|
16
16
|
const unreadMessageCount = useSeamlyUnreadCount()
|
|
17
|
-
const { isOpen } =
|
|
17
|
+
const { isOpen } = useVisibility()
|
|
18
18
|
const currentAgent = useSeamlyCurrentAgent()
|
|
19
19
|
const { hasInterrupt } = useInterrupt()
|
|
20
20
|
const { defaults } = useConfig()
|
|
@@ -2,19 +2,18 @@ import { useCallback, useMemo } from 'preact/hooks'
|
|
|
2
2
|
import { className } from '../../../lib/css'
|
|
3
3
|
import {
|
|
4
4
|
useSeamlyAppContainerClassNames,
|
|
5
|
-
useSeamlyVisibility,
|
|
6
5
|
useSeamlyLayoutMode,
|
|
7
6
|
useSeamlyContainerElement,
|
|
8
7
|
} from '../../hooks/seamly-hooks'
|
|
9
8
|
import Faq from '../faq/faq'
|
|
10
|
-
import { visibilityStates } from '../../utils/seamly-utils'
|
|
11
9
|
import { useConfig } from '../../../domains/config'
|
|
12
10
|
import { useUserHasResponded } from '../../../domains/app'
|
|
13
11
|
import { useI18n } from '../../../domains/i18n'
|
|
12
|
+
import { useVisibility, visibilityStates } from '../../../domains/visibility'
|
|
14
13
|
|
|
15
14
|
const AppFrame = ({ children }) => {
|
|
16
15
|
const [, setSeamlyContainerElement] = useSeamlyContainerElement()
|
|
17
|
-
const { isOpen, isVisible, setVisibility } =
|
|
16
|
+
const { isOpen, isVisible, setVisibility } = useVisibility()
|
|
18
17
|
const { zIndex, showFaq } = useConfig()
|
|
19
18
|
const { isModal, isInline } = useSeamlyLayoutMode()
|
|
20
19
|
const appContainerClassNames = useSeamlyAppContainerClassNames()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { className } from '../../../lib/css'
|
|
2
|
-
import { useSeamlyVisibility } from '../../hooks/seamly-hooks'
|
|
3
2
|
import CobrowsingActiveFrame from '../warnings/cobrowsing-active-frame'
|
|
4
3
|
import AppOptions from '../app-options'
|
|
5
4
|
import { ChatStatus as TranslationsChatStatus } from '../../../domains/translations'
|
|
6
5
|
import { useInterrupt } from '../../../domains/interrupt'
|
|
6
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
7
7
|
|
|
8
8
|
function ChatFrame({ children, interruptComponent: InterruptComponent }) {
|
|
9
9
|
const { hasInterrupt, meta } = useInterrupt()
|
|
10
|
-
const { isOpen } =
|
|
10
|
+
const { isOpen } = useVisibility()
|
|
11
11
|
|
|
12
12
|
const getContent = () => {
|
|
13
13
|
if (hasInterrupt) {
|
|
@@ -3,19 +3,16 @@ import { createFocusTrap } from 'focus-trap'
|
|
|
3
3
|
import InOutTransition, {
|
|
4
4
|
transitionStartStates,
|
|
5
5
|
} from '../widgets/in-out-transition'
|
|
6
|
-
import {
|
|
7
|
-
useSeamlyLayoutMode,
|
|
8
|
-
useSeamlyVisibility,
|
|
9
|
-
} from '../../hooks/seamly-hooks'
|
|
6
|
+
import { useSeamlyLayoutMode } from '../../hooks/seamly-hooks'
|
|
10
7
|
import { useI18n } from '../../../domains/i18n'
|
|
11
8
|
import { className } from '../../../lib/css'
|
|
12
9
|
import { createAriaHider } from '../../utils/general-utils'
|
|
13
|
-
import { visibilityStates } from '
|
|
10
|
+
import { useVisibility, visibilityStates } from '../../../domains/visibility'
|
|
14
11
|
|
|
15
12
|
const ModalWrapper = ({ children }) => {
|
|
16
13
|
const { t } = useI18n()
|
|
17
14
|
const { isModal } = useSeamlyLayoutMode()
|
|
18
|
-
const { isOpen, setVisibility } =
|
|
15
|
+
const { isOpen, setVisibility } = useVisibility()
|
|
19
16
|
const container = useRef(null)
|
|
20
17
|
const focusTrap = useRef(null)
|
|
21
18
|
|
|
@@ -7,14 +7,11 @@ import Header from './header'
|
|
|
7
7
|
import Conversation from '../conversation/conversation'
|
|
8
8
|
import EntryContainer from '../entry/entry-container'
|
|
9
9
|
import Interrupt from './interrupt'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
useSeamlyVisibility,
|
|
13
|
-
useSeamlyLayoutMode,
|
|
14
|
-
} from '../../hooks/seamly-hooks'
|
|
10
|
+
import { useSeamlyChat, useSeamlyLayoutMode } from '../../hooks/seamly-hooks'
|
|
11
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
15
12
|
|
|
16
13
|
const View = () => {
|
|
17
|
-
const { isVisible } =
|
|
14
|
+
const { isVisible } = useVisibility()
|
|
18
15
|
const { openChat, closeChat } = useSeamlyChat()
|
|
19
16
|
const { isModal } = useSeamlyLayoutMode()
|
|
20
17
|
|
|
@@ -49,8 +49,6 @@ export {
|
|
|
49
49
|
useSeamlyContainerElement,
|
|
50
50
|
} from './focus-helper-hooks'
|
|
51
51
|
export { default as useSeamlyChat } from './use-seamly-chat'
|
|
52
|
-
export { default as useSeamlyStoredVisibility } from './use-seamly-stored-visibility'
|
|
53
|
-
export { default as useSeamlyVisibility } from './use-seamly-visibility'
|
|
54
52
|
export { default as useSeamlyIdleDetachCountdown } from './use-seamly-idle-detach-countdown'
|
|
55
53
|
export { default as useSeamlyResumeConversationPrompt } from './use-seamly-resume-conversation-prompt'
|
|
56
54
|
|
|
@@ -5,14 +5,14 @@ import { useEvents } from './seamly-state-hooks'
|
|
|
5
5
|
import useSeamlyCommands from './use-seamly-commands'
|
|
6
6
|
import { useSeamlyHasConversation } from './seamly-api-hooks'
|
|
7
7
|
import { useLiveRegion } from './live-region-hooks'
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
8
|
+
import { seamlyActions } from '../utils/seamly-utils'
|
|
9
|
+
import { useVisibility, visibilityStates } from '../../domains/visibility'
|
|
10
10
|
|
|
11
11
|
const { SET_IS_LOADING } = seamlyActions
|
|
12
12
|
|
|
13
13
|
const useSeamlyChat = () => {
|
|
14
14
|
const { t } = useI18n()
|
|
15
|
-
const { isOpen, isVisible,
|
|
15
|
+
const { isOpen, isVisible, setVisibility } = useVisibility()
|
|
16
16
|
const dispatch = useSeamlyDispatchContext()
|
|
17
17
|
const events = useEvents()
|
|
18
18
|
const spinnerTimeout = useRef(null)
|
|
@@ -52,8 +52,6 @@ const useSeamlyChat = () => {
|
|
|
52
52
|
prevIsVisible.current = isVisible
|
|
53
53
|
}, [isOpen, isVisible, sendAssertive, t])
|
|
54
54
|
|
|
55
|
-
useEffect(() => {}, [visible, sendAssertive])
|
|
56
|
-
|
|
57
55
|
useEffect(() => {
|
|
58
56
|
// This delays the start of the loading inidicator we set when we initialise
|
|
59
57
|
// the application. This is done to only avoid BSOD on initial load if DCX is slow.
|
|
@@ -3,32 +3,24 @@ import {
|
|
|
3
3
|
useSeamlyApiContext,
|
|
4
4
|
useSeamlyHasConversation,
|
|
5
5
|
} from './seamly-api-hooks'
|
|
6
|
-
import {
|
|
7
|
-
useSeamlyStateContext,
|
|
8
|
-
useSeamlyUnreadCount,
|
|
9
|
-
} from './seamly-state-hooks'
|
|
6
|
+
import { useSeamlyUnreadCount } from './seamly-state-hooks'
|
|
10
7
|
import useSeamlyDispatchContext from './use-seamly-dispatch'
|
|
11
8
|
import { SeamlyEventBusContext } from '../components/core/seamly-api-context'
|
|
12
9
|
import { randomId } from '../../lib/id'
|
|
13
10
|
import { userParticipantId } from '../../config'
|
|
14
|
-
import { sanitizeText } from '../utils/general-utils'
|
|
15
11
|
import { actionTypes, seamlyActions } from '../utils/seamly-utils'
|
|
16
12
|
import { useStableCallback } from './utility-hooks'
|
|
17
13
|
import { Actions as InterruptActions } from '../../domains/interrupt'
|
|
18
14
|
import { useConfig } from '../../domains/config'
|
|
19
|
-
import { useUserHasResponded } from '../../domains/app'
|
|
15
|
+
import { useUserHasResponded, Actions as AppActions } from '../../domains/app'
|
|
16
|
+
import { useVisibility } from '../../domains/visibility'
|
|
20
17
|
|
|
21
18
|
const {
|
|
22
19
|
ADD_EVENT,
|
|
23
|
-
CLEAR_EVENTS,
|
|
24
20
|
SET_IS_LOADING,
|
|
25
|
-
CLEAR_PARTICIPANTS,
|
|
26
21
|
SET_HEADER_SUB_TITLE,
|
|
27
22
|
SET_INITIAL_STATE,
|
|
28
|
-
CLEAR_FEATURES,
|
|
29
23
|
SET_FEATURES,
|
|
30
|
-
RESET_UPLOAD_STATE,
|
|
31
|
-
RESET_ENTRY_STATE,
|
|
32
24
|
} = seamlyActions
|
|
33
25
|
|
|
34
26
|
const useSeamlyCommands = () => {
|
|
@@ -39,7 +31,7 @@ const useSeamlyCommands = () => {
|
|
|
39
31
|
|
|
40
32
|
const hasResponded = useUserHasResponded()
|
|
41
33
|
const hasConversation = useSeamlyHasConversation()
|
|
42
|
-
const { visible: visibility } =
|
|
34
|
+
const { visible: visibility } = useVisibility()
|
|
43
35
|
const unreadMessageCount = useSeamlyUnreadCount()
|
|
44
36
|
|
|
45
37
|
const emitEvent = useCallback(
|
|
@@ -75,18 +67,13 @@ const useSeamlyCommands = () => {
|
|
|
75
67
|
])
|
|
76
68
|
|
|
77
69
|
const reset = useCallback(async () => {
|
|
70
|
+
dispatch(AppActions.reset())
|
|
78
71
|
dispatch(InterruptActions.clear())
|
|
79
|
-
|
|
72
|
+
|
|
80
73
|
dispatch({
|
|
81
74
|
type: SET_IS_LOADING,
|
|
82
75
|
isLoading: true,
|
|
83
76
|
})
|
|
84
|
-
dispatch({
|
|
85
|
-
type: CLEAR_PARTICIPANTS,
|
|
86
|
-
})
|
|
87
|
-
dispatch({ type: RESET_UPLOAD_STATE })
|
|
88
|
-
dispatch({ type: RESET_ENTRY_STATE })
|
|
89
|
-
dispatch({ type: CLEAR_FEATURES })
|
|
90
77
|
|
|
91
78
|
const { agentName } = appConfig.defaults || {}
|
|
92
79
|
|
|
@@ -143,20 +130,11 @@ const useSeamlyCommands = () => {
|
|
|
143
130
|
...config,
|
|
144
131
|
}
|
|
145
132
|
|
|
146
|
-
const sanitizedText = sanitizeText(body)
|
|
147
|
-
|
|
148
|
-
const sanitizedMessage = {
|
|
149
|
-
...message,
|
|
150
|
-
body: {
|
|
151
|
-
text: sanitizedText,
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
|
|
155
133
|
api.send('message', message)
|
|
156
134
|
emitEvent('message', message)
|
|
157
135
|
dispatch({
|
|
158
136
|
type: ADD_EVENT,
|
|
159
|
-
event: { type: 'message', payload:
|
|
137
|
+
event: { type: 'message', payload: message },
|
|
160
138
|
})
|
|
161
139
|
},
|
|
162
140
|
[api, dispatch, emitEvent, getTextMessageBase],
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '../utils/general-utils'
|
|
11
11
|
import { actionTypes, seamlyActions } from '../utils/seamly-utils'
|
|
12
12
|
import { screenReaderDebounceDelaySeconds } from '../../config'
|
|
13
|
-
import
|
|
13
|
+
import { useVisibility } from '../../domains/visibility'
|
|
14
14
|
|
|
15
15
|
const {
|
|
16
16
|
CLEAR_IDLE_DETACH_COUNTDOWN,
|
|
@@ -24,7 +24,7 @@ const useSeamlyIdleDetachCountdown = () => {
|
|
|
24
24
|
|
|
25
25
|
const { idleDetachCountdown } = useSeamlyStateContext()
|
|
26
26
|
|
|
27
|
-
const { isOpen: isSeamlyOpen } =
|
|
27
|
+
const { isOpen: isSeamlyOpen } = useVisibility()
|
|
28
28
|
|
|
29
29
|
const stableState = useRef({})
|
|
30
30
|
|