@seamly/web-ui 18.2.0 → 19.0.0-beta.1
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 +598 -136
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +190 -22
- package/build/dist/lib/index.js +4745 -4468
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +1 -1
- package/build/dist/lib/standalone.js +4839 -4465
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.LICENSE.txt +1 -1
- package/build/dist/lib/style-guide.js +1770 -980
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +1 -1
- package/build/dist/lib/utils.js +0 -1
- package/build/dist/lib/utils.min.js +1 -1
- package/package.json +29 -29
- package/src/javascripts/api/index.js +33 -48
- package/src/javascripts/api/producer.js +9 -12
- package/src/javascripts/config.js +9 -11
- package/src/javascripts/domains/app/actions.js +43 -0
- package/src/javascripts/domains/app/hooks.js +6 -0
- package/src/javascripts/domains/app/index.js +6 -0
- package/src/javascripts/domains/app/reducer.js +16 -0
- package/src/javascripts/domains/app/selectors.js +8 -0
- package/src/javascripts/domains/app/utils.js +4 -0
- package/src/javascripts/domains/config/actions.js +4 -0
- package/src/javascripts/domains/config/hooks.js +6 -0
- package/src/javascripts/domains/config/index.js +8 -0
- package/src/javascripts/domains/config/middleware.js +22 -0
- package/src/javascripts/domains/config/reducer.js +63 -0
- package/src/javascripts/domains/config/selectors.js +23 -0
- package/src/javascripts/domains/config/utils.js +4 -0
- package/src/javascripts/domains/forms/actions.js +2 -4
- package/src/javascripts/domains/forms/hooks.js +10 -14
- package/src/javascripts/domains/forms/provider.js +4 -6
- package/src/javascripts/domains/forms/reducer.js +1 -2
- package/src/javascripts/domains/forms/selectors.js +4 -4
- package/src/javascripts/domains/forms/utils.js +5 -0
- package/src/javascripts/domains/i18n/actions.js +35 -0
- package/src/javascripts/domains/i18n/hooks.js +38 -0
- package/src/javascripts/domains/i18n/index.js +5 -80
- package/src/javascripts/domains/i18n/reducer.js +58 -0
- package/src/javascripts/domains/i18n/selectors.js +15 -0
- package/src/javascripts/domains/i18n/utils.js +9 -0
- package/src/javascripts/domains/interrupt/actions.js +4 -0
- package/src/javascripts/domains/interrupt/hooks.js +29 -0
- package/src/javascripts/domains/interrupt/index.js +9 -0
- package/src/javascripts/domains/interrupt/middleware.js +30 -0
- package/src/javascripts/domains/interrupt/reducer.js +21 -0
- package/src/javascripts/domains/interrupt/selectors.js +6 -0
- package/src/javascripts/domains/interrupt/utils.js +4 -0
- package/src/javascripts/domains/options/index.js +1 -0
- package/src/javascripts/domains/options/middleware.js +35 -0
- package/src/javascripts/domains/redux/create-redux-store.js +14 -6
- package/src/javascripts/domains/redux/hooks.js +3 -2
- package/src/javascripts/domains/redux/index.js +2 -1
- package/src/javascripts/domains/redux/provider.js +5 -0
- package/src/javascripts/domains/store/index.js +44 -0
- package/src/javascripts/{ui → domains}/store/state-reducer.js +4 -7
- package/src/javascripts/domains/translations/actions.js +4 -6
- package/src/javascripts/domains/translations/components/chat-status.js +7 -13
- package/src/javascripts/domains/translations/components/options-button.js +3 -3
- package/src/javascripts/domains/translations/components/options-dialog/form.js +12 -7
- package/src/javascripts/domains/translations/components/options-dialog/index.js +2 -5
- package/src/javascripts/domains/translations/hooks.js +1 -1
- package/src/javascripts/domains/translations/index.js +1 -0
- package/src/javascripts/domains/translations/middleware.js +43 -0
- package/src/javascripts/domains/translations/reducer.js +4 -11
- package/src/javascripts/domains/translations/selectors.js +3 -3
- package/src/javascripts/domains/translations/utils.js +4 -0
- package/src/javascripts/index.js +20 -5
- package/src/javascripts/lib/css.js +5 -5
- package/src/javascripts/lib/engine/index.js +39 -11
- package/src/javascripts/lib/external-api/index.js +6 -6
- package/src/javascripts/lib/mutex.js +30 -0
- package/src/javascripts/lib/parse-body.js +1 -1
- package/src/javascripts/lib/redux-helpers/index.js +25 -8
- package/src/javascripts/lib/split-url-params.js +2 -2
- package/src/javascripts/lib/store/providers/app-storage.js +1 -1
- package/src/javascripts/lib/store/providers/cookie-storage.js +1 -1
- package/src/javascripts/package/utils.js +0 -1
- package/src/javascripts/style-guide/components/app.js +12 -14
- package/src/javascripts/style-guide/components/links.js +6 -6
- package/src/javascripts/style-guide/components/static-core.js +32 -10
- package/src/javascripts/style-guide/state-helpers/index.js +1 -1
- package/src/javascripts/style-guide/states.js +29 -71
- package/src/javascripts/style-guide/style-guide-engine.js +13 -12
- package/src/javascripts/ui/components/chat-app.js +2 -2
- package/src/javascripts/ui/components/conversation/component-filter.js +2 -2
- package/src/javascripts/ui/components/conversation/conversation.js +2 -2
- package/src/javascripts/ui/components/conversation/event/card-component.js +24 -3
- package/src/javascripts/ui/components/conversation/event/carousel-component/components/pagination.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +4 -3
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +2 -2
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +5 -5
- package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +2 -2
- package/src/javascripts/ui/components/conversation/event/event-participant.js +3 -5
- package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js +2 -2
- package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +3 -3
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +3 -3
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -2
- package/src/javascripts/ui/components/conversation/event/upload.js +12 -27
- package/src/javascripts/ui/components/conversation/message-container.js +4 -6
- package/src/javascripts/ui/components/core/seamly-activity-monitor.js +4 -5
- package/src/javascripts/ui/components/core/seamly-core.js +6 -7
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +18 -17
- package/src/javascripts/ui/components/core/seamly-file-upload.js +5 -6
- package/src/javascripts/ui/components/core/seamly-idle-detach-counter.js +2 -6
- package/src/javascripts/ui/components/core/seamly-initializer.js +7 -60
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +10 -16
- package/src/javascripts/ui/components/core/seamly-live-region.js +1 -1
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +5 -6
- package/src/javascripts/ui/components/core/seamly-read-state.js +8 -6
- package/src/javascripts/ui/components/entry/entry-container.js +7 -10
- package/src/javascripts/ui/components/entry/text-entry/hooks.js +6 -4
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +10 -3
- package/src/javascripts/ui/components/entry/toggle-button.js +24 -10
- package/src/javascripts/ui/components/entry/upload/file-upload-form.js +6 -3
- package/src/javascripts/ui/components/entry/upload/index.js +11 -13
- package/src/javascripts/ui/components/faq/faq.js +6 -6
- package/src/javascripts/ui/components/form-controls/error.js +22 -0
- package/src/javascripts/ui/components/form-controls/file-input.js +3 -9
- package/src/javascripts/ui/components/form-controls/select.js +1 -1
- package/src/javascripts/ui/components/form-controls/wrapper.js +2 -9
- package/src/javascripts/ui/components/layout/agent-info.js +4 -4
- package/src/javascripts/ui/components/layout/app-frame.js +15 -12
- package/src/javascripts/ui/components/layout/chat-frame.js +3 -5
- package/src/javascripts/ui/components/layout/header.js +4 -18
- package/src/javascripts/ui/components/layout/interrupt.js +6 -2
- package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
- package/src/javascripts/ui/components/options/cobrowsing.js +3 -7
- package/src/javascripts/ui/components/options/options-button.js +9 -13
- package/src/javascripts/ui/components/options/options-frame.js +1 -1
- package/src/javascripts/ui/components/options/transcript/index.js +2 -2
- package/src/javascripts/ui/components/options/transcript/transcript-form.js +1 -1
- package/src/javascripts/ui/components/warnings/cobrowsing-active-frame.js +3 -6
- package/src/javascripts/ui/components/warnings/idle-detach-warning.js +2 -6
- package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +1 -1
- package/src/javascripts/ui/components/widgets/in-out-transition.js +2 -2
- package/src/javascripts/ui/components/widgets/lightbox.js +4 -4
- package/src/javascripts/ui/components/widgets/modal.js +3 -3
- package/src/javascripts/ui/components/widgets/upload-progress.js +3 -14
- package/src/javascripts/ui/hooks/component-helper-hooks.js +4 -15
- package/src/javascripts/ui/hooks/file-upload-hooks.js +3 -3
- package/src/javascripts/ui/hooks/focus-helper-hooks.js +4 -4
- package/src/javascripts/ui/hooks/live-region-hooks.js +2 -2
- package/src/javascripts/ui/hooks/seamly-api-hooks.js +0 -6
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +22 -25
- package/src/javascripts/ui/hooks/seamly-hooks.js +3 -10
- package/src/javascripts/ui/hooks/seamly-option-hooks.js +4 -4
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +8 -16
- package/src/javascripts/ui/hooks/use-event-component-mapping.js +1 -1
- package/src/javascripts/ui/hooks/use-seamly-chat.js +1 -0
- package/src/javascripts/ui/hooks/use-seamly-commands.js +31 -54
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +3 -3
- package/src/javascripts/ui/hooks/use-seamly-stored-visibility.js +3 -3
- package/src/javascripts/ui/hooks/use-seamly-visibility.js +6 -8
- package/src/javascripts/ui/hooks/use-single-file-upload.js +4 -1
- package/src/javascripts/ui/hooks/utility-hooks.js +2 -2
- package/src/javascripts/ui/utils/form-utils.js +3 -3
- package/src/javascripts/ui/utils/general-utils.js +21 -22
- package/src/javascripts/ui/utils/seamly-utils.js +15 -83
- package/src/javascripts/ui/utils/validations.js +10 -7
- package/src/stylesheets/1-settings/_config.scss +2 -1
- package/src/stylesheets/3-app/_app.scss +3 -4
- package/src/stylesheets/5-components/_card.scss +0 -1
- package/src/stylesheets/5-components/_faq.scss +3 -8
- package/src/stylesheets/5-components/_message.scss +10 -0
- package/src/stylesheets/5-components/_modal.scss +3 -3
- package/src/stylesheets/5-components/_options.scss +3 -2
- package/webpack/config.common.js +3 -3
- package/webpack/config.package.js +4 -22
- package/webpack/config.site.js +8 -6
- package/webpack/defaults.js +0 -3
- package/CHANGELOG.md +0 -561
- package/build/dist/translations/de-informal.js +0 -275
- package/build/dist/translations/de-informal.min.js +0 -1
- package/build/dist/translations/en.js +0 -275
- package/build/dist/translations/en.min.js +0 -1
- package/build/dist/translations/es-informal.js +0 -281
- package/build/dist/translations/es-informal.min.js +0 -1
- package/build/dist/translations/nl-formal.js +0 -275
- package/build/dist/translations/nl-formal.min.js +0 -1
- package/build/dist/translations/nl-informal.js +0 -275
- package/build/dist/translations/nl-informal.min.js +0 -1
- package/src/javascripts/lib/i18n.js +0 -46
- package/src/javascripts/ui/components/core/seamly-api.js +0 -44
- package/src/javascripts/ui/hooks/use-seamly-interrupt.js +0 -62
- package/src/javascripts/ui/store/index.js +0 -37
- package/translations/de-informal.js +0 -237
- package/translations/en.js +0 -234
- package/translations/es-informal.js +0 -243
- package/translations/nl-formal.js +0 -230
- package/translations/nl-informal.js +0 -230
|
@@ -2,7 +2,6 @@ import { useCallback, useContext } from 'preact/hooks'
|
|
|
2
2
|
import {
|
|
3
3
|
useSeamlyApiContext,
|
|
4
4
|
useSeamlyHasConversation,
|
|
5
|
-
useSeamlyHasUserResponded,
|
|
6
5
|
} from './seamly-api-hooks'
|
|
7
6
|
import {
|
|
8
7
|
useSeamlyStateContext,
|
|
@@ -10,17 +9,18 @@ import {
|
|
|
10
9
|
} from './seamly-state-hooks'
|
|
11
10
|
import useSeamlyDispatchContext from './use-seamly-dispatch'
|
|
12
11
|
import { SeamlyEventBusContext } from '../components/core/seamly-api-context'
|
|
13
|
-
import useSeamlyInterrupt from './use-seamly-interrupt'
|
|
14
12
|
import { randomId } from '../../lib/id'
|
|
15
13
|
import { userParticipantId } from '../../config'
|
|
16
14
|
import { sanitizeText } from '../utils/general-utils'
|
|
17
15
|
import { actionTypes, seamlyActions } from '../utils/seamly-utils'
|
|
18
16
|
import { useStableCallback } from './utility-hooks'
|
|
17
|
+
import { Actions as InterruptActions } from '../../domains/interrupt'
|
|
18
|
+
import { useConfig } from '../../domains/config'
|
|
19
|
+
import { useUserHasResponded } from '../../domains/app'
|
|
19
20
|
|
|
20
21
|
const {
|
|
21
22
|
ADD_EVENT,
|
|
22
23
|
CLEAR_EVENTS,
|
|
23
|
-
CLEAR_INTERRUPT,
|
|
24
24
|
SET_IS_LOADING,
|
|
25
25
|
CLEAR_PARTICIPANTS,
|
|
26
26
|
SET_HEADER_SUB_TITLE,
|
|
@@ -33,18 +33,15 @@ const {
|
|
|
33
33
|
|
|
34
34
|
const useSeamlyCommands = () => {
|
|
35
35
|
const api = useSeamlyApiContext()
|
|
36
|
-
const
|
|
36
|
+
const appConfig = useConfig()
|
|
37
37
|
const dispatch = useSeamlyDispatchContext()
|
|
38
38
|
const eventBus = useContext(SeamlyEventBusContext)
|
|
39
|
-
const { setInterrupt } = useSeamlyInterrupt()
|
|
40
39
|
|
|
41
|
-
const hasResponded =
|
|
40
|
+
const hasResponded = useUserHasResponded()
|
|
42
41
|
const hasConversation = useSeamlyHasConversation()
|
|
43
42
|
const { visible: visibility } = useSeamlyStateContext()
|
|
44
43
|
const unreadMessageCount = useSeamlyUnreadCount()
|
|
45
44
|
|
|
46
|
-
const { config: appConfig } = seamlyState
|
|
47
|
-
|
|
48
45
|
const emitEvent = useCallback(
|
|
49
46
|
(...args) => {
|
|
50
47
|
eventBus.emit(...args)
|
|
@@ -78,8 +75,8 @@ const useSeamlyCommands = () => {
|
|
|
78
75
|
])
|
|
79
76
|
|
|
80
77
|
const reset = useCallback(async () => {
|
|
78
|
+
dispatch(InterruptActions.clear())
|
|
81
79
|
dispatch({ type: CLEAR_EVENTS })
|
|
82
|
-
dispatch({ type: CLEAR_INTERRUPT })
|
|
83
80
|
dispatch({
|
|
84
81
|
type: SET_IS_LOADING,
|
|
85
82
|
isLoading: true,
|
|
@@ -99,41 +96,30 @@ const useSeamlyCommands = () => {
|
|
|
99
96
|
})
|
|
100
97
|
|
|
101
98
|
try {
|
|
102
|
-
const {
|
|
103
|
-
const { features } = accountConfig || {}
|
|
99
|
+
const { features } = await api.reset()
|
|
104
100
|
|
|
105
101
|
dispatch({ type: SET_FEATURES, features })
|
|
106
|
-
dispatch({ type: SET_INITIAL_STATE, initialState })
|
|
102
|
+
dispatch({ type: SET_INITIAL_STATE, initialState: {} })
|
|
107
103
|
} catch (error) {
|
|
108
|
-
|
|
104
|
+
dispatch(InterruptActions.set(error))
|
|
109
105
|
}
|
|
110
|
-
}, [api, dispatch, appConfig
|
|
106
|
+
}, [api, dispatch, appConfig])
|
|
111
107
|
|
|
112
108
|
const getMessageBase = useCallback(
|
|
113
|
-
type => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// events array to ensure proper sorting should a history fetch be done
|
|
124
|
-
// prior to receipt of the related ACK.
|
|
125
|
-
occurredAt:
|
|
126
|
-
events.length > 0
|
|
127
|
-
? events[events.length - 1].payload.occurredAt + 1
|
|
128
|
-
: Date.now(),
|
|
129
|
-
meta: {},
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
[seamlyState],
|
|
109
|
+
(type) => ({
|
|
110
|
+
type,
|
|
111
|
+
id: randomId(),
|
|
112
|
+
transactionId: randomId(),
|
|
113
|
+
participant: userParticipantId,
|
|
114
|
+
fromClient: true,
|
|
115
|
+
occurredAt: Date.now() * 1000,
|
|
116
|
+
meta: {},
|
|
117
|
+
}),
|
|
118
|
+
[],
|
|
133
119
|
)
|
|
134
120
|
|
|
135
121
|
const getTextMessageBase = useCallback(
|
|
136
|
-
bodyText => {
|
|
122
|
+
(bodyText) => {
|
|
137
123
|
const base = getMessageBase('text')
|
|
138
124
|
|
|
139
125
|
return {
|
|
@@ -177,7 +163,7 @@ const useSeamlyCommands = () => {
|
|
|
177
163
|
)
|
|
178
164
|
|
|
179
165
|
const addMessageBubble = useCallback(
|
|
180
|
-
text => {
|
|
166
|
+
(text) => {
|
|
181
167
|
dispatch({
|
|
182
168
|
type: ADD_EVENT,
|
|
183
169
|
event: { type: 'message', payload: getTextMessageBase(text) },
|
|
@@ -187,16 +173,7 @@ const useSeamlyCommands = () => {
|
|
|
187
173
|
)
|
|
188
174
|
|
|
189
175
|
const addUploadBubble = useCallback(
|
|
190
|
-
(
|
|
191
|
-
id,
|
|
192
|
-
transactionId,
|
|
193
|
-
occurredAt,
|
|
194
|
-
contentType,
|
|
195
|
-
deleteAt,
|
|
196
|
-
filename,
|
|
197
|
-
filesize,
|
|
198
|
-
url,
|
|
199
|
-
) => {
|
|
176
|
+
(id, transactionId, occurredAt, contentType, filename, filesize, url) => {
|
|
200
177
|
dispatch({
|
|
201
178
|
type: ADD_EVENT,
|
|
202
179
|
event: {
|
|
@@ -209,7 +186,7 @@ const useSeamlyCommands = () => {
|
|
|
209
186
|
fromClient: true,
|
|
210
187
|
occurredAt,
|
|
211
188
|
meta: {},
|
|
212
|
-
body: { contentType,
|
|
189
|
+
body: { contentType, filename, filesize, url },
|
|
213
190
|
},
|
|
214
191
|
},
|
|
215
192
|
})
|
|
@@ -218,7 +195,7 @@ const useSeamlyCommands = () => {
|
|
|
218
195
|
)
|
|
219
196
|
|
|
220
197
|
const addDivider = useCallback(
|
|
221
|
-
subtype => {
|
|
198
|
+
(subtype) => {
|
|
222
199
|
const payload = {
|
|
223
200
|
body: { subtype, type: 'divider' },
|
|
224
201
|
fromClient: false,
|
|
@@ -253,7 +230,7 @@ const useSeamlyCommands = () => {
|
|
|
253
230
|
)
|
|
254
231
|
|
|
255
232
|
const sendAction = useCallback(
|
|
256
|
-
body => {
|
|
233
|
+
(body) => {
|
|
257
234
|
if (!body) {
|
|
258
235
|
return
|
|
259
236
|
}
|
|
@@ -269,7 +246,7 @@ const useSeamlyCommands = () => {
|
|
|
269
246
|
)
|
|
270
247
|
|
|
271
248
|
const sendContext = useCallback(
|
|
272
|
-
context => {
|
|
249
|
+
(context) => {
|
|
273
250
|
api.sendContext(context)
|
|
274
251
|
},
|
|
275
252
|
[api],
|
|
@@ -282,15 +259,15 @@ const useSeamlyCommands = () => {
|
|
|
282
259
|
|
|
283
260
|
return api
|
|
284
261
|
.connect()
|
|
285
|
-
.then(initialState => {
|
|
262
|
+
.then((initialState) => {
|
|
286
263
|
if (initialState) {
|
|
287
264
|
dispatch({ type: SET_INITIAL_STATE, initialState })
|
|
288
265
|
}
|
|
289
266
|
})
|
|
290
|
-
.catch(error => {
|
|
291
|
-
|
|
267
|
+
.catch((error) => {
|
|
268
|
+
dispatch(InterruptActions.set(error))
|
|
292
269
|
})
|
|
293
|
-
}, [api, dispatch
|
|
270
|
+
}, [api, dispatch])
|
|
294
271
|
|
|
295
272
|
return {
|
|
296
273
|
connect,
|
|
@@ -41,7 +41,7 @@ const useSeamlyIdleDetachCountdown = () => {
|
|
|
41
41
|
const { sendAssertive, sendPolite } = useLiveRegion()
|
|
42
42
|
|
|
43
43
|
const sendAssertiveIfOpen = useCallback(
|
|
44
|
-
text => {
|
|
44
|
+
(text) => {
|
|
45
45
|
const { isOpen } = stableState.current
|
|
46
46
|
if (isOpen) {
|
|
47
47
|
sendAssertive(text)
|
|
@@ -51,7 +51,7 @@ const useSeamlyIdleDetachCountdown = () => {
|
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
const sendPoliteIfOpen = useCallback(
|
|
54
|
-
text => {
|
|
54
|
+
(text) => {
|
|
55
55
|
const { isOpen } = stableState.current
|
|
56
56
|
if (isOpen) {
|
|
57
57
|
sendPolite(text)
|
|
@@ -61,7 +61,7 @@ const useSeamlyIdleDetachCountdown = () => {
|
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
const initCountdown = useCallback(
|
|
64
|
-
milliseconds => {
|
|
64
|
+
(milliseconds) => {
|
|
65
65
|
const delaySeconds = millisecondsToSeconds(milliseconds)
|
|
66
66
|
const delayTime = getTimeFromSeconds(delaySeconds)
|
|
67
67
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useCallback } from 'preact/hooks'
|
|
2
|
-
import { useSeamlyConfig } from './seamly-state-hooks'
|
|
3
2
|
import { useSeamlyObjectStore } from './seamly-api-hooks'
|
|
3
|
+
import { useConfig } from '../../domains/config'
|
|
4
4
|
|
|
5
5
|
const useSeamlyStoredVisibility = () => {
|
|
6
|
-
const { layoutMode } =
|
|
6
|
+
const { layoutMode } = useConfig()
|
|
7
7
|
const key = 'visibility'
|
|
8
8
|
const { get, set } = useSeamlyObjectStore()
|
|
9
9
|
|
|
@@ -15,7 +15,7 @@ const useSeamlyStoredVisibility = () => {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const setStoredVisibility = useCallback(
|
|
18
|
-
state => {
|
|
18
|
+
(state) => {
|
|
19
19
|
const saved = get ? get(key) : {}
|
|
20
20
|
set(key, { ...saved, [layoutMode]: state })
|
|
21
21
|
},
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import { useCallback } from 'preact/hooks'
|
|
2
2
|
import {
|
|
3
|
-
useSeamlyConfig,
|
|
4
3
|
useSeamlyStateContext,
|
|
5
4
|
useSeamlyUnreadCount,
|
|
6
5
|
} from './seamly-state-hooks'
|
|
7
6
|
import useSeamlyCommands from './use-seamly-commands'
|
|
8
7
|
import useSeamlyDispatchContext from './use-seamly-dispatch'
|
|
9
|
-
import {
|
|
10
|
-
useSeamlyHasConversation,
|
|
11
|
-
useSeamlyHasUserResponded,
|
|
12
|
-
} from './seamly-api-hooks'
|
|
8
|
+
import { useSeamlyHasConversation } from './seamly-api-hooks'
|
|
13
9
|
import useSeamlyStoredVisibility from './use-seamly-stored-visibility'
|
|
14
10
|
import {
|
|
15
11
|
calculateVisibility,
|
|
16
12
|
seamlyActions,
|
|
17
13
|
visibilityStates,
|
|
18
14
|
} from '../utils/seamly-utils'
|
|
15
|
+
import { useConfig } from '../../domains/config'
|
|
16
|
+
import { useUserHasResponded } from '../../domains/app'
|
|
19
17
|
|
|
20
18
|
const { SET_VISIBILITY } = seamlyActions
|
|
21
19
|
|
|
22
20
|
const useSeamlyVisibility = () => {
|
|
23
|
-
const config =
|
|
21
|
+
const config = useConfig()
|
|
24
22
|
const { layoutMode, visibilityCallback } = config
|
|
25
23
|
const { visible } = useSeamlyStateContext()
|
|
26
24
|
const { emitEvent } = useSeamlyCommands()
|
|
27
25
|
const dispatch = useSeamlyDispatchContext()
|
|
28
26
|
const [storedVisibility, setStoredVisibility] = useSeamlyStoredVisibility()
|
|
29
|
-
const hasResponded =
|
|
27
|
+
const hasResponded = useUserHasResponded()
|
|
30
28
|
const hasConversation = useSeamlyHasConversation()
|
|
31
29
|
const unreadMessageCount = useSeamlyUnreadCount()
|
|
32
30
|
const isVisible = visible ? visible !== visibilityStates.hidden : false
|
|
@@ -38,7 +36,7 @@ const useSeamlyVisibility = () => {
|
|
|
38
36
|
: false
|
|
39
37
|
|
|
40
38
|
const setVisibility = useCallback(
|
|
41
|
-
visibility => {
|
|
39
|
+
(visibility) => {
|
|
42
40
|
const visibilityFn = visibilityCallback || calculateVisibility
|
|
43
41
|
const requestedVisibility = visibilityFn({
|
|
44
42
|
hasConversation,
|
|
@@ -13,6 +13,8 @@ const useSingleFileUpload = (formId, name) => {
|
|
|
13
13
|
// This hook HAS to be used inside the FormBoundary of the file upload.
|
|
14
14
|
const { currentUploads } = useFileUploads()
|
|
15
15
|
|
|
16
|
+
const hasFile = fileList && fileList.length > 0
|
|
17
|
+
|
|
16
18
|
let uploadHandle = null
|
|
17
19
|
let hasServerError = false
|
|
18
20
|
let progress = 0
|
|
@@ -24,7 +26,8 @@ const useSingleFileUpload = (formId, name) => {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
return {
|
|
27
|
-
|
|
29
|
+
hasFile,
|
|
30
|
+
selectedFileName: hasFile ? fileList[0].name : '',
|
|
28
31
|
uploadHandle,
|
|
29
32
|
hasServerError,
|
|
30
33
|
progress,
|
|
@@ -11,7 +11,7 @@ export const useForceUpdate = () => {
|
|
|
11
11
|
// This is an escape hatch mentioned in the React docs:
|
|
12
12
|
// https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate
|
|
13
13
|
/* eslint-disable-next-line no-unused-vars */
|
|
14
|
-
const [ignored, forceUpdate] = useReducer(x => x + 1, 0)
|
|
14
|
+
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0)
|
|
15
15
|
|
|
16
16
|
return useCallback(() => {
|
|
17
17
|
setTimeout(() => {
|
|
@@ -25,7 +25,7 @@ export const useGeneratedId = () => {
|
|
|
25
25
|
return id
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export const useStableCallback = callback => {
|
|
28
|
+
export const useStableCallback = (callback) => {
|
|
29
29
|
const callbackRef = useRef()
|
|
30
30
|
callbackRef.current = callback
|
|
31
31
|
const isFunction = typeof callback === 'function'
|
|
@@ -41,7 +41,7 @@ export const formReducer = (state, action) => {
|
|
|
41
41
|
persistData,
|
|
42
42
|
} = action
|
|
43
43
|
|
|
44
|
-
const setControls = controls => ({
|
|
44
|
+
const setControls = (controls) => ({
|
|
45
45
|
...state,
|
|
46
46
|
[formId]: {
|
|
47
47
|
...state[formId],
|
|
@@ -112,8 +112,8 @@ export const formReducer = (state, action) => {
|
|
|
112
112
|
...state[formId],
|
|
113
113
|
controls: newControlValidities,
|
|
114
114
|
validity: Object.keys(newControlValidities)
|
|
115
|
-
.map(key => newControlValidities[key].validity)
|
|
116
|
-
.every(v => v),
|
|
115
|
+
.map((key) => newControlValidities[key].validity)
|
|
116
|
+
.every((v) => v),
|
|
117
117
|
},
|
|
118
118
|
}
|
|
119
119
|
case SET_STATE:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const debounce = (func, wait) => {
|
|
2
2
|
let timeout
|
|
3
|
-
return function(...args) {
|
|
3
|
+
return function (...args) {
|
|
4
4
|
const context = this
|
|
5
5
|
let isCancelled = false
|
|
6
6
|
clearTimeout(timeout)
|
|
@@ -12,7 +12,7 @@ export const debounce = (func, wait) => {
|
|
|
12
12
|
isCancelled = false
|
|
13
13
|
}, wait)
|
|
14
14
|
|
|
15
|
-
return runInstant => {
|
|
15
|
+
return (runInstant) => {
|
|
16
16
|
isCancelled = true
|
|
17
17
|
if (runInstant) {
|
|
18
18
|
func.apply(context, args)
|
|
@@ -54,7 +54,7 @@ export const closestElement = (el, match) => {
|
|
|
54
54
|
export const createAriaHider = () => {
|
|
55
55
|
const originalValues = []
|
|
56
56
|
const rootNodes = []
|
|
57
|
-
document.querySelectorAll('body > *:not([role="dialog"])').forEach(node => {
|
|
57
|
+
document.querySelectorAll('body > *:not([role="dialog"])').forEach((node) => {
|
|
58
58
|
const attr = node.getAttribute('aria-hidden')
|
|
59
59
|
const alreadyHidden = attr !== null && attr !== 'false'
|
|
60
60
|
if (alreadyHidden) {
|
|
@@ -77,17 +77,17 @@ export const createAriaHider = () => {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
export const propIsTrue = prop => prop === 'true' || prop === true
|
|
80
|
+
export const propIsTrue = (prop) => prop === 'true' || prop === true
|
|
81
81
|
|
|
82
|
-
export const millisecondsToSeconds = milliseconds => {
|
|
82
|
+
export const millisecondsToSeconds = (milliseconds) => {
|
|
83
83
|
return Math.ceil(milliseconds / 1000)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
export const microsecondsToMilliseconds = microseconds => {
|
|
86
|
+
export const microsecondsToMilliseconds = (microseconds) => {
|
|
87
87
|
return Math.ceil(microseconds / 1000)
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export const sanitizeText = text =>
|
|
90
|
+
export const sanitizeText = (text) =>
|
|
91
91
|
text
|
|
92
92
|
.replace(/&/g, '&')
|
|
93
93
|
.replace(/</g, '<')
|
|
@@ -96,7 +96,7 @@ export const sanitizeText = text =>
|
|
|
96
96
|
.replace(/'/g, ''')
|
|
97
97
|
.replace(/\//g, '/')
|
|
98
98
|
|
|
99
|
-
export const getTimeFromSeconds = seconds => {
|
|
99
|
+
export const getTimeFromSeconds = (seconds) => {
|
|
100
100
|
const minutes = Math.floor(seconds / 60)
|
|
101
101
|
const secondsPartial = seconds - minutes * 60
|
|
102
102
|
|
|
@@ -130,7 +130,7 @@ export const getUrlParams = () => {
|
|
|
130
130
|
}, {})
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
export const getUrlSearchString = params => {
|
|
133
|
+
export const getUrlSearchString = (params) => {
|
|
134
134
|
return Object.keys(params).reduce(
|
|
135
135
|
(search, key) =>
|
|
136
136
|
`${search}${search ? '&' : ''}${key}=${encodeURIComponent(params[key])}`,
|
|
@@ -158,9 +158,9 @@ export const keyNames = {
|
|
|
158
158
|
ArrowDown: 'ArrowDown',
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
export const getKey = e => (e.code ? keyNames[e.code] : keyCodes[e.keyCode])
|
|
161
|
+
export const getKey = (e) => (e.code ? keyNames[e.code] : keyCodes[e.keyCode])
|
|
162
162
|
|
|
163
|
-
export const focusElement = el => {
|
|
163
|
+
export const focusElement = (el) => {
|
|
164
164
|
if (el) {
|
|
165
165
|
el.focus()
|
|
166
166
|
}
|
|
@@ -195,15 +195,14 @@ export const getRelativeDate = (date, currentDate) => {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
export const
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return acc
|
|
198
|
+
export const pick = (obj, keys) =>
|
|
199
|
+
keys.reduce((accum, key) => {
|
|
200
|
+
if (key in obj) accum[key] = obj[key]
|
|
201
|
+
return accum
|
|
202
|
+
}, {})
|
|
203
|
+
|
|
204
|
+
export const omit = (obj, keys) =>
|
|
205
|
+
Object.keys(obj).reduce((accum, key) => {
|
|
206
|
+
if (!keys.includes(key)) accum[key] = obj[key]
|
|
207
|
+
return accum
|
|
209
208
|
}, {})
|