@seamly/web-ui 19.1.1 → 20.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/CHANGELOG.md +625 -0
- package/build/dist/lib/components.js +2 -1
- package/build/dist/lib/components.min.js +1 -1
- package/build/dist/lib/index.debug.js +183 -128
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +45 -25
- package/build/dist/lib/index.js +7290 -7753
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +0 -5
- package/build/dist/lib/standalone.js +5785 -6255
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.LICENSE.txt +0 -5
- package/build/dist/lib/style-guide.js +10834 -4971
- package/build/dist/lib/style-guide.min.js +2 -1
- package/build/dist/lib/style-guide.min.js.LICENSE.txt +9 -0
- package/build/dist/lib/styles.css +1 -1
- package/package.json +1 -2
- package/src/icons/icon_file-32.svg +1 -1
- package/src/javascripts/api/errors/seamly-base-error.js +7 -0
- package/src/javascripts/api/index.js +48 -37
- package/src/javascripts/api/producer.js +5 -1
- package/src/javascripts/config.js +1 -5
- package/src/javascripts/domains/app/actions.js +22 -5
- package/src/javascripts/domains/config/actions.js +3 -0
- package/src/javascripts/domains/config/reducer.js +9 -0
- package/src/javascripts/domains/errors/index.js +5 -4
- package/src/javascripts/domains/forms/hooks.js +3 -1
- package/src/javascripts/domains/forms/provider.js +12 -0
- package/src/javascripts/domains/forms/reducer.js +2 -0
- package/src/javascripts/domains/i18n/hooks.js +2 -1
- package/src/javascripts/domains/i18n/reducer.js +2 -0
- package/src/javascripts/domains/interrupt/reducer.js +2 -2
- package/src/javascripts/domains/options/middleware.js +15 -31
- package/src/javascripts/domains/store/index.js +2 -1
- package/src/javascripts/domains/store/state-reducer.js +3 -8
- package/src/javascripts/domains/translations/components/options-dialog/form.js +1 -1
- package/src/javascripts/domains/translations/components/options-dialog/index.js +15 -1
- package/src/javascripts/domains/translations/reducer.js +2 -0
- package/src/javascripts/domains/visibility/actions.js +1 -1
- package/src/javascripts/domains/visibility/hooks.js +10 -8
- package/src/javascripts/domains/visibility/utils.js +1 -2
- package/src/javascripts/index.js +5 -3
- package/src/javascripts/lib/css.js +7 -1
- package/src/javascripts/lib/engine/index.js +4 -3
- package/src/javascripts/lib/external-api/index.js +38 -29
- package/src/javascripts/package/components.js +2 -1
- package/src/javascripts/style-guide/components/app.js +1 -1
- package/src/javascripts/style-guide/components/static-core.js +18 -4
- package/src/javascripts/style-guide/states.js +203 -298
- package/src/javascripts/ui/components/chat-app.js +1 -1
- package/src/javascripts/ui/components/conversation/component-filter.js +6 -0
- package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +8 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -3
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +70 -0
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -5
- package/src/javascripts/ui/components/conversation/event/splash.js +26 -0
- package/src/javascripts/ui/components/conversation/event/text.js +1 -2
- package/src/javascripts/ui/components/core/seamly-core.js +12 -9
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +4 -10
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +1 -8
- package/src/javascripts/ui/components/entry/entry-container.js +5 -3
- package/src/javascripts/ui/components/entry/text-entry/index.js +7 -1
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +5 -1
- package/src/javascripts/ui/components/entry/toggle-button.js +4 -2
- package/src/javascripts/ui/components/entry/upload/file-upload-form.js +1 -1
- package/src/javascripts/ui/components/form-controls/error.js +6 -2
- package/src/javascripts/ui/components/form-controls/form.js +26 -3
- package/src/javascripts/ui/components/layout/app-frame.js +24 -15
- package/src/javascripts/ui/components/layout/chat-frame.js +0 -2
- package/src/javascripts/ui/components/layout/modal-wrapper.js +0 -80
- package/src/javascripts/ui/components/layout/pre-chat-messages.js +45 -0
- package/src/javascripts/ui/components/options/options-frame.js +9 -4
- package/src/javascripts/ui/components/options/options.js +1 -4
- package/src/javascripts/ui/components/options/transcript/index.js +15 -1
- package/src/javascripts/ui/components/options/transcript/transcript-form.js +1 -1
- package/src/javascripts/ui/components/suggestions/index.js +174 -0
- package/src/javascripts/ui/components/suggestions/suggestions-item.js +40 -0
- package/src/javascripts/ui/components/suggestions/suggestions-list.js +24 -0
- package/src/javascripts/ui/components/view/app-view.js +21 -0
- package/src/javascripts/ui/components/view/deprecated-view.js +30 -0
- package/src/javascripts/ui/components/view/index.js +27 -0
- package/src/javascripts/ui/components/view/inline-view.js +45 -0
- package/src/javascripts/ui/components/view/window-view/collapse-button.js +20 -0
- package/src/javascripts/ui/components/view/window-view/index.js +82 -0
- package/src/javascripts/ui/components/view/window-view/window-open-button.js +68 -0
- package/src/javascripts/ui/components/widgets/lightbox.js +7 -2
- package/src/javascripts/ui/hooks/component-helper-hooks.js +0 -9
- package/src/javascripts/ui/hooks/seamly-hooks.js +0 -1
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +28 -4
- package/src/javascripts/ui/hooks/use-seamly-chat.js +12 -3
- package/src/javascripts/ui/hooks/use-seamly-commands.js +4 -31
- package/src/javascripts/ui/utils/seamly-utils.js +2 -14
- package/src/stylesheets/1-settings/_animations.scss +0 -6
- package/src/stylesheets/1-settings/_config.scss +34 -35
- package/src/stylesheets/2-tools/_functions.scss +0 -5
- package/src/stylesheets/2-tools/_mixins.scss +4 -16
- package/src/stylesheets/3-app/_app.scss +78 -135
- package/src/stylesheets/4-base/_a11y.scss +0 -3
- package/src/stylesheets/4-base/_elements.scss +0 -11
- package/src/stylesheets/4-base/_formelements.scss +4 -14
- package/src/stylesheets/5-components/_avatar.scss +2 -44
- package/src/stylesheets/5-components/_buttons.scss +6 -45
- package/src/stylesheets/5-components/_chat-status.scss +14 -38
- package/src/stylesheets/5-components/_choice-prompt.scss +33 -2
- package/src/stylesheets/5-components/_collapse-button.scss +16 -0
- package/src/stylesheets/5-components/_conversation.scss +26 -2
- package/src/stylesheets/5-components/_disclaimer.scss +10 -12
- package/src/stylesheets/5-components/_divider.scss +7 -4
- package/src/stylesheets/5-components/_error.scss +1 -1
- package/src/stylesheets/5-components/_form.scss +9 -0
- package/src/stylesheets/5-components/_icon.scss +10 -1
- package/src/stylesheets/5-components/_idle.scss +0 -8
- package/src/stylesheets/5-components/_input.scss +14 -20
- package/src/stylesheets/5-components/_interrupt.scss +0 -2
- package/src/stylesheets/5-components/_loader.scss +0 -32
- package/src/stylesheets/5-components/_message-author.scss +40 -0
- package/src/stylesheets/5-components/_message-body.scss +194 -0
- package/src/stylesheets/5-components/_message-card.scss +55 -0
- package/src/stylesheets/5-components/_message-carousel.scss +143 -0
- package/src/stylesheets/5-components/_message-count.scss +11 -28
- package/src/stylesheets/5-components/_message-cta.scss +23 -0
- package/src/stylesheets/5-components/_message-info.scss +11 -0
- package/src/stylesheets/5-components/_message-translation-info.scss +17 -0
- package/src/stylesheets/5-components/_message.scss +13 -364
- package/src/stylesheets/5-components/_modal.scss +28 -58
- package/src/stylesheets/5-components/_notification.scss +0 -5
- package/src/stylesheets/5-components/_options.scss +27 -42
- package/src/stylesheets/5-components/_pre-chat-messages.scss +30 -0
- package/src/stylesheets/5-components/_prompt.scss +0 -8
- package/src/stylesheets/5-components/_skip-link.scss +3 -3
- package/src/stylesheets/5-components/_suggestions.scss +96 -0
- package/src/stylesheets/5-components/_unstarted.scss +50 -0
- package/src/stylesheets/5-components/_upload.scss +26 -28
- package/src/stylesheets/5-components/_window-open-button.scss +39 -0
- package/src/stylesheets/6-webui-only/_hover.scss +151 -0
- package/src/stylesheets/6-webui-only/_scrollbar.scss +31 -0
- package/src/stylesheets/7-deprecated/1-settings/_animations.scss +43 -0
- package/src/stylesheets/7-deprecated/1-settings/_config.scss +105 -0
- package/src/stylesheets/7-deprecated/2-tools/_functions.scss +22 -0
- package/src/stylesheets/7-deprecated/2-tools/_mixins.scss +77 -0
- package/src/stylesheets/7-deprecated/3-app/_app.scss +214 -0
- package/src/stylesheets/7-deprecated/4-base/_a11y.scss +14 -0
- package/src/stylesheets/7-deprecated/4-base/_elements.scss +21 -0
- package/src/stylesheets/7-deprecated/4-base/_formelements.scss +57 -0
- package/src/stylesheets/{5-components → 7-deprecated/5-components}/_agent-info.scss +0 -0
- package/src/stylesheets/7-deprecated/5-components/_avatar.scss +64 -0
- package/src/stylesheets/7-deprecated/5-components/_buttons.scss +94 -0
- package/src/stylesheets/{5-components → 7-deprecated/5-components}/_card.scss +0 -0
- package/src/stylesheets/{5-components → 7-deprecated/5-components}/_carousel.scss +0 -0
- package/src/stylesheets/7-deprecated/5-components/_character-limit.scss +36 -0
- package/src/stylesheets/{5-components/_cobrowsing.scss → 7-deprecated/5-components/_chat-status.scss} +18 -16
- package/src/stylesheets/7-deprecated/5-components/_choice-prompt.scss +27 -0
- package/src/stylesheets/7-deprecated/5-components/_collapse-button.scss +17 -0
- package/src/stylesheets/7-deprecated/5-components/_conversation.scss +44 -0
- package/src/stylesheets/7-deprecated/5-components/_disclaimer.scss +36 -0
- package/src/stylesheets/7-deprecated/5-components/_divider.scss +91 -0
- package/src/stylesheets/7-deprecated/5-components/_error.scss +24 -0
- package/src/stylesheets/{5-components → 7-deprecated/5-components}/_faq.scss +8 -3
- package/src/stylesheets/{5-components → 7-deprecated/5-components}/_header-controls.scss +0 -0
- package/src/stylesheets/7-deprecated/5-components/_icon.scss +4 -0
- package/src/stylesheets/7-deprecated/5-components/_idle.scss +61 -0
- package/src/stylesheets/7-deprecated/5-components/_input.scss +78 -0
- package/src/stylesheets/7-deprecated/5-components/_interrupt.scss +35 -0
- package/src/stylesheets/7-deprecated/5-components/_loader.scss +78 -0
- package/src/stylesheets/7-deprecated/5-components/_message-count.scss +41 -0
- package/src/stylesheets/7-deprecated/5-components/_message.scss +385 -0
- package/src/stylesheets/7-deprecated/5-components/_modal.scss +138 -0
- package/src/stylesheets/7-deprecated/5-components/_notification.scss +20 -0
- package/src/stylesheets/7-deprecated/5-components/_options.scss +286 -0
- package/src/stylesheets/7-deprecated/5-components/_prompt.scss +44 -0
- package/src/stylesheets/7-deprecated/5-components/_skip-link.scss +21 -0
- package/src/stylesheets/{5-components → 7-deprecated/5-components}/_svg-graphic.scss +0 -0
- package/src/stylesheets/7-deprecated/5-components/_upload.scss +213 -0
- package/src/stylesheets/deprecated-view.scss +64 -0
- package/src/stylesheets/styles-webui-only.scss +3 -0
- package/src/stylesheets/styles.scss +15 -25
- package/webpack/config.site.js +4 -0
- package/webpack/defaults.js +5 -0
- package/src/.DS_Store +0 -0
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +0 -35
- package/src/javascripts/ui/components/faq/faq.js +0 -162
- package/src/javascripts/ui/components/layout/view.js +0 -36
- package/src/javascripts/ui/components/options/cobrowsing.js +0 -110
- package/src/javascripts/ui/components/warnings/cobrowsing-active-frame.js +0 -29
- package/src/javascripts/ui/components/warnings/cobrowsing-active.js +0 -33
- package/src/stylesheets/5-components/_modal_mode.scss +0 -108
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReducer } from './utils'
|
|
2
2
|
import * as Actions from './actions'
|
|
3
|
-
import
|
|
3
|
+
import * as AppActions from '../app/actions'
|
|
4
4
|
|
|
5
5
|
const initialState = {
|
|
6
6
|
error: undefined,
|
|
@@ -16,7 +16,7 @@ export default createReducer(
|
|
|
16
16
|
[Actions.set]: handleError,
|
|
17
17
|
[AppActions.initialize.rejected]: handleError,
|
|
18
18
|
[Actions.clear]: () => initialState,
|
|
19
|
-
[AppActions.
|
|
19
|
+
[AppActions.initialize.pending]: () => initialState,
|
|
20
20
|
},
|
|
21
21
|
initialState,
|
|
22
22
|
)
|
|
@@ -1,35 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Actions as InterruptActions } from '../interrupt'
|
|
3
|
-
import SeamlyOfflineError from '../../api/errors/seamly-offline-error'
|
|
1
|
+
import { seamlyActions } from '../../ui/utils/seamly-utils'
|
|
4
2
|
|
|
5
3
|
export default function createMiddleware({ api }) {
|
|
6
|
-
return (
|
|
7
|
-
(
|
|
8
|
-
(action)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
option: featureKeys.cobrowsing,
|
|
19
|
-
value: false,
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
break
|
|
23
|
-
case seamlyActions.SET_USER_SELECTED_OPTIONS:
|
|
24
|
-
api.store.set('options', action.options)
|
|
25
|
-
break
|
|
26
|
-
case seamlyActions.SET_USER_SELECTED_OPTION:
|
|
27
|
-
api.store.set('options', {
|
|
28
|
-
...(api.store.get('options') || {}),
|
|
29
|
-
[action.option]: action.value,
|
|
30
|
-
})
|
|
31
|
-
break
|
|
32
|
-
}
|
|
33
|
-
return result
|
|
4
|
+
return () => (next) => (action) => {
|
|
5
|
+
const result = next(action)
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case seamlyActions.SET_USER_SELECTED_OPTIONS:
|
|
8
|
+
api.store.set('options', action.options)
|
|
9
|
+
break
|
|
10
|
+
case seamlyActions.SET_USER_SELECTED_OPTION:
|
|
11
|
+
api.store.set('options', {
|
|
12
|
+
...(api.store.get('options') || {}),
|
|
13
|
+
[action.option]: action.value,
|
|
14
|
+
})
|
|
15
|
+
break
|
|
34
16
|
}
|
|
17
|
+
return result
|
|
18
|
+
}
|
|
35
19
|
}
|
|
@@ -20,7 +20,7 @@ import { createMiddleware as createOptionsMiddleware } from '../options'
|
|
|
20
20
|
import { createMiddleware as createErrorsMiddleware } from '../errors'
|
|
21
21
|
import stateReducer from './state-reducer'
|
|
22
22
|
|
|
23
|
-
export function createStore({ initialState, api, eventBus } = {}) {
|
|
23
|
+
export function createStore({ initialState, api, eventBus, config } = {}) {
|
|
24
24
|
const store = createReduxStore({
|
|
25
25
|
reducers: {
|
|
26
26
|
state: stateReducer,
|
|
@@ -38,6 +38,7 @@ export function createStore({ initialState, api, eventBus } = {}) {
|
|
|
38
38
|
thunkMiddleware.withExtraArgument({
|
|
39
39
|
api,
|
|
40
40
|
eventBus,
|
|
41
|
+
config,
|
|
41
42
|
}),
|
|
42
43
|
createConfigMiddleware(),
|
|
43
44
|
createInterruptMiddleware({ api }),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { randomId } from '../../lib/id'
|
|
4
4
|
import { entryTypes, seamlyStateReducer } from '../../ui/utils/seamly-utils'
|
|
5
|
-
import
|
|
5
|
+
import * as AppActions from '../app/actions'
|
|
6
6
|
|
|
7
7
|
const initialState = {
|
|
8
8
|
events: [],
|
|
@@ -25,7 +25,6 @@ const initialState = {
|
|
|
25
25
|
historyLoaded: false,
|
|
26
26
|
skiplinkTargetId: randomId(),
|
|
27
27
|
optionsButtonId: randomId(),
|
|
28
|
-
cobrowsingContainerId: randomId(),
|
|
29
28
|
headerCollapseButtonId: randomId(),
|
|
30
29
|
serviceData: {},
|
|
31
30
|
options: {
|
|
@@ -48,12 +47,8 @@ const initialState = {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
export default function stateReducer(state = initialState, action) {
|
|
51
|
-
if (action.type === String(AppActions.
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
...initialState,
|
|
55
|
-
visible,
|
|
56
|
-
}
|
|
50
|
+
if (action.type === String(AppActions.initialize.pending)) {
|
|
51
|
+
return initialState
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
return seamlyStateReducer(state, action)
|
|
@@ -29,7 +29,7 @@ function TranslationsOptionsDialogForm({ controlName, descriptionId }) {
|
|
|
29
29
|
}, [t, languages, uiLocale])
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<Form noValidate="true">
|
|
32
|
+
<Form noValidate="true" className={className('options__form')}>
|
|
33
33
|
<p className={className('options__description')} id={descriptionId}>
|
|
34
34
|
{t('translations.settings.description')}
|
|
35
35
|
</p>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo, useRef } from 'preact/hooks'
|
|
1
|
+
import { useCallback, useMemo, useRef, useState } from 'preact/hooks'
|
|
2
2
|
import OptionsFrame from '../../../../ui/components/options/options-frame'
|
|
3
3
|
import { FormProvider } from '../../../forms'
|
|
4
4
|
import TranslationsOptionsDialogForm from './form'
|
|
@@ -12,6 +12,7 @@ export const formName = 'translation-settings'
|
|
|
12
12
|
export const inputName = 'locale'
|
|
13
13
|
|
|
14
14
|
function TranslationsOptionsDialog({ onClose }) {
|
|
15
|
+
const [errorClass, setErrorClass] = useState(undefined)
|
|
15
16
|
const { t } = useI18n()
|
|
16
17
|
|
|
17
18
|
const { isActive, enableTranslations, disableTranslations } =
|
|
@@ -30,6 +31,17 @@ function TranslationsOptionsDialog({ onClose }) {
|
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
const handleError = useCallback(
|
|
35
|
+
({ isValid, isSubmitted }) => {
|
|
36
|
+
if (isSubmitted && !isValid) {
|
|
37
|
+
setErrorClass('options--error')
|
|
38
|
+
} else {
|
|
39
|
+
setErrorClass(undefined)
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
[setErrorClass],
|
|
43
|
+
)
|
|
44
|
+
|
|
33
45
|
// we need a key to fully reset the form when we enable/disable translations
|
|
34
46
|
const formKeyRef = useRef(0)
|
|
35
47
|
const validationSchema = useMemo(() => {
|
|
@@ -45,6 +57,7 @@ function TranslationsOptionsDialog({ onClose }) {
|
|
|
45
57
|
|
|
46
58
|
return (
|
|
47
59
|
<OptionsFrame
|
|
60
|
+
className={errorClass}
|
|
48
61
|
onCancel={onClose}
|
|
49
62
|
formName={formName}
|
|
50
63
|
headingText={t('translations.settings.title')}
|
|
@@ -57,6 +70,7 @@ function TranslationsOptionsDialog({ onClose }) {
|
|
|
57
70
|
formId={formName}
|
|
58
71
|
validationSchema={validationSchema}
|
|
59
72
|
key={formKeyRef.current}
|
|
73
|
+
onError={handleError}
|
|
60
74
|
>
|
|
61
75
|
<TranslationsOptionsDialogForm
|
|
62
76
|
controlName={inputName}
|
|
@@ -2,6 +2,7 @@ import { createReducer } from './utils'
|
|
|
2
2
|
import { seamlyActions } from '../../ui/utils/seamly-utils'
|
|
3
3
|
import { randomId } from '../../lib/id'
|
|
4
4
|
import * as Actions from './actions'
|
|
5
|
+
import * as AppActions from '../app/actions'
|
|
5
6
|
|
|
6
7
|
const initialState = {
|
|
7
8
|
isActive: false,
|
|
@@ -62,6 +63,7 @@ export default createReducer(
|
|
|
62
63
|
originalPayloadIds: [...state.originalPayloadIds, payloadId],
|
|
63
64
|
}
|
|
64
65
|
},
|
|
66
|
+
[AppActions.initialize.pending]: () => initialState,
|
|
65
67
|
},
|
|
66
68
|
initialState,
|
|
67
69
|
)
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useCallback } from 'preact/hooks'
|
|
2
|
-
import { useConfig } from '../config'
|
|
3
2
|
import { useSelector, useStoreDispatch } from '../redux'
|
|
4
3
|
import * as Actions from './actions'
|
|
5
4
|
import * as Selectors from './selectors'
|
|
@@ -9,16 +8,19 @@ export const useVisibility = () => {
|
|
|
9
8
|
const dispatch = useStoreDispatch()
|
|
10
9
|
const visible = useSelector(Selectors.selectVisibility)
|
|
11
10
|
const isVisible = visible ? visible !== visibilityStates.hidden : false
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
? visible === visibilityStates.open ||
|
|
16
|
-
(layoutMode === 'inline' && visible !== visibilityStates.hidden)
|
|
17
|
-
: false
|
|
11
|
+
const isOpen = visible === visibilityStates.open
|
|
12
|
+
const isMinimized = visible === visibilityStates.minimized
|
|
13
|
+
|
|
18
14
|
const setVisibility = useCallback(
|
|
19
15
|
(visibility) => dispatch(Actions.setVisibility(visibility)),
|
|
20
16
|
[dispatch],
|
|
21
17
|
)
|
|
22
18
|
|
|
23
|
-
return {
|
|
19
|
+
return {
|
|
20
|
+
isVisible,
|
|
21
|
+
isOpen,
|
|
22
|
+
isMinimized,
|
|
23
|
+
visible,
|
|
24
|
+
setVisibility,
|
|
25
|
+
}
|
|
24
26
|
}
|
|
@@ -30,8 +30,7 @@ export const calculateVisibility = ({
|
|
|
30
30
|
: visibilityStates.hidden
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const baseVisibility =
|
|
34
|
-
layoutMode === 'inline' ? visibilityStates.open : visibilityStates.minimized
|
|
33
|
+
const baseVisibility = visibilityStates.minimized
|
|
35
34
|
|
|
36
35
|
return (
|
|
37
36
|
requestedVisibility ||
|
package/src/javascripts/index.js
CHANGED
|
@@ -127,11 +127,13 @@ export {
|
|
|
127
127
|
export { default as Text } from './ui/components/conversation/event/text'
|
|
128
128
|
|
|
129
129
|
// Used by: Client
|
|
130
|
-
export { default as
|
|
130
|
+
export { default as DeprecatedToggleButton } from './ui/components/entry/toggle-button'
|
|
131
131
|
|
|
132
|
-
// Used by: Client
|
|
133
132
|
// Used by: StyleGuide
|
|
134
|
-
export { default as View } from './ui/components/
|
|
133
|
+
export { default as View } from './ui/components/view'
|
|
134
|
+
|
|
135
|
+
// Used by: Client
|
|
136
|
+
export { default as DeprecatedView } from './ui/components/view/deprecated-view'
|
|
135
137
|
|
|
136
138
|
// Used by: Client
|
|
137
139
|
// Used by: StyleGuide
|
|
@@ -22,5 +22,11 @@ export const className = (...classes) =>
|
|
|
22
22
|
.map((c) => c.split(' '))
|
|
23
23
|
.flat()
|
|
24
24
|
.filter((c) => c.length)
|
|
25
|
-
.map((c) =>
|
|
25
|
+
.map((c) => {
|
|
26
|
+
// This rule makes sure the CSS_NAME is not added yet
|
|
27
|
+
if (c.indexOf(CSS_NAME) > -1) {
|
|
28
|
+
return c
|
|
29
|
+
}
|
|
30
|
+
return [CSS_NAME, c].join('-')
|
|
31
|
+
})
|
|
26
32
|
.join(' ')
|
|
@@ -4,7 +4,7 @@ import ChatApp from '../../ui/components/chat-app'
|
|
|
4
4
|
import SeamlyCore from '../../ui/components/core/seamly-core'
|
|
5
5
|
import { API } from '../../api'
|
|
6
6
|
import { createStore } from '../../domains/store'
|
|
7
|
-
import
|
|
7
|
+
import * as AppActions from '../../domains/app/actions'
|
|
8
8
|
|
|
9
9
|
export default class Engine {
|
|
10
10
|
constructor(config, externalApi) {
|
|
@@ -21,7 +21,7 @@ export default class Engine {
|
|
|
21
21
|
this.api = new API({
|
|
22
22
|
namespace: config.namespace,
|
|
23
23
|
config: config.api,
|
|
24
|
-
|
|
24
|
+
context: config.context,
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
this.eventBus = new Events()
|
|
@@ -52,9 +52,10 @@ export default class Engine {
|
|
|
52
52
|
const store = createStore({
|
|
53
53
|
api: this.api,
|
|
54
54
|
eventBus: this.eventBus,
|
|
55
|
+
config: renderConfig,
|
|
55
56
|
})
|
|
56
57
|
|
|
57
|
-
await store.dispatch(AppActions.initialize(
|
|
58
|
+
await store.dispatch(AppActions.initialize())
|
|
58
59
|
|
|
59
60
|
if (View) {
|
|
60
61
|
render(
|
|
@@ -50,32 +50,29 @@ class ExternalApi {
|
|
|
50
50
|
const userConfig = this.getUserConfig(...actionObj.args)
|
|
51
51
|
const config = this.getCombinedConfig(userConfig)
|
|
52
52
|
// if this.appConfig is a function, it might return an invalid configuration (false, null, undefined)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
const { parentElement, namespace } = config
|
|
58
|
-
Object.values(this._instances).forEach((instance) => {
|
|
59
|
-
if (
|
|
60
|
-
instance.parentElement === parentElement ||
|
|
61
|
-
instance.namespace === namespace
|
|
62
|
-
) {
|
|
63
|
-
this.destroy(instance)
|
|
64
|
-
}
|
|
65
|
-
})
|
|
66
|
-
const instance = this.createInstance(config)
|
|
67
|
-
this._instances[config.namespace] = instance
|
|
68
|
-
instance.render()
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
handleDestroy(actionObj) {
|
|
72
|
-
if (actionObj.instance !== undefined) {
|
|
73
|
-
this.destroy(actionObj.instance)
|
|
53
|
+
const { parentElement, namespace } = config || userConfig
|
|
54
|
+
if (!namespace) {
|
|
55
|
+
this.destroy()
|
|
74
56
|
} else {
|
|
75
57
|
Object.values(this._instances).forEach((instance) => {
|
|
76
|
-
|
|
58
|
+
if (
|
|
59
|
+
instance.parentElement === parentElement ||
|
|
60
|
+
instance.namespace === namespace
|
|
61
|
+
) {
|
|
62
|
+
this.destroy(instance)
|
|
63
|
+
}
|
|
77
64
|
})
|
|
78
65
|
}
|
|
66
|
+
|
|
67
|
+
if (config) {
|
|
68
|
+
const instance = this.createInstance(config)
|
|
69
|
+
this._instances[config.namespace] = instance
|
|
70
|
+
instance.render()
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
handleDestroy(actionObj) {
|
|
75
|
+
this.destroy(actionObj.instance)
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
handleAction(actionObj) {
|
|
@@ -105,13 +102,20 @@ class ExternalApi {
|
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
destroy(instance) {
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
105
|
+
if (!instance) {
|
|
106
|
+
Object.entries(this._instances).forEach(([namespace, _instance]) => {
|
|
107
|
+
_instance.destroy()
|
|
108
|
+
delete this._instances[namespace]
|
|
109
|
+
})
|
|
110
|
+
} else {
|
|
111
|
+
if (typeof instance === 'string') {
|
|
112
|
+
// eslint-disable-next-line no-param-reassign
|
|
113
|
+
instance = this._instances[instance]
|
|
114
|
+
}
|
|
115
|
+
if (instance) {
|
|
116
|
+
instance.destroy()
|
|
117
|
+
delete this._instances[instance.namespace]
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
120
|
}
|
|
117
121
|
|
|
@@ -124,6 +128,10 @@ class ExternalApi {
|
|
|
124
128
|
if (typeof this.appConfig === 'function') {
|
|
125
129
|
return this.appConfig(userConfig)
|
|
126
130
|
}
|
|
131
|
+
const defaults = {
|
|
132
|
+
...this.appConfig.defaults,
|
|
133
|
+
...userConfig.defaults,
|
|
134
|
+
}
|
|
127
135
|
return {
|
|
128
136
|
...this.appConfig,
|
|
129
137
|
...userConfig,
|
|
@@ -131,6 +139,7 @@ class ExternalApi {
|
|
|
131
139
|
...this.appConfig.api,
|
|
132
140
|
...userConfig.api,
|
|
133
141
|
},
|
|
142
|
+
defaults: Object.keys(defaults).length ? defaults : undefined,
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
}
|
|
@@ -18,7 +18,7 @@ const StyleGuideApp = ({
|
|
|
18
18
|
|
|
19
19
|
const [mainState] = useState(() => {
|
|
20
20
|
const mainStateObj = getStateObj(
|
|
21
|
-
styleGuideConfig.showLayoutModes || ['inline', 'window'
|
|
21
|
+
styleGuideConfig.showLayoutModes || ['inline', 'window'],
|
|
22
22
|
customMessageEventBodies,
|
|
23
23
|
)
|
|
24
24
|
return Object.keys(mainStateObj).reduce(
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { useMemo, useRef } from 'preact/hooks'
|
|
2
|
+
import thunkMiddleware from 'redux-thunk'
|
|
3
|
+
|
|
2
4
|
import {
|
|
3
5
|
SeamlyEventBusContext,
|
|
4
6
|
SeamlyApiContext,
|
|
@@ -6,7 +8,6 @@ import {
|
|
|
6
8
|
StoreProvider,
|
|
7
9
|
createReduxStore,
|
|
8
10
|
} from '@seamly/web-ui'
|
|
9
|
-
|
|
10
11
|
import stateReducer from '../../domains/store/state-reducer'
|
|
11
12
|
import { Reducer as formReducer } from '../../domains/forms'
|
|
12
13
|
import { Reducer as translationsReducer } from '../../domains/translations'
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
Actions as ConfigActions,
|
|
22
23
|
} from '../../domains/config'
|
|
23
24
|
import { Reducer as visibilityReducer } from '../../domains/visibility'
|
|
25
|
+
import ComponentFilter from '../../ui/components/conversation/component-filter'
|
|
24
26
|
|
|
25
27
|
const bareApi = {
|
|
26
28
|
send: () => {},
|
|
@@ -28,6 +30,7 @@ const bareApi = {
|
|
|
28
30
|
return Promise.resolve({})
|
|
29
31
|
},
|
|
30
32
|
store: { get: () => {}, set: () => {} },
|
|
33
|
+
hasConversation: () => false,
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
const SeamlyTestCore = ({ state, translations, children }) => {
|
|
@@ -38,7 +41,7 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
38
41
|
const {
|
|
39
42
|
translations: translationsSlice,
|
|
40
43
|
interrupt: interruptSlice,
|
|
41
|
-
config: configSlice,
|
|
44
|
+
config: configSlice = {},
|
|
42
45
|
visibility: visibilitySlice,
|
|
43
46
|
...restState
|
|
44
47
|
} = state || {}
|
|
@@ -59,8 +62,19 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
59
62
|
[String(interruptReducer)]: interruptSlice,
|
|
60
63
|
[String(visibilityReducer)]: visibilitySlice,
|
|
61
64
|
},
|
|
65
|
+
middlewares: [
|
|
66
|
+
thunkMiddleware.withExtraArgument({
|
|
67
|
+
api: bareApi,
|
|
68
|
+
eventBus: eventBusRef.current,
|
|
69
|
+
}),
|
|
70
|
+
],
|
|
62
71
|
})
|
|
63
|
-
newStore.dispatch(ConfigActions.initialize(configSlice
|
|
72
|
+
newStore.dispatch(ConfigActions.initialize(configSlice))
|
|
73
|
+
if (configSlice.preChatEvents) {
|
|
74
|
+
newStore.dispatch(
|
|
75
|
+
ConfigActions.setPreChatEvents(configSlice.preChatEvents),
|
|
76
|
+
)
|
|
77
|
+
}
|
|
64
78
|
newStore.dispatch(I18nActions.setLocale.fulfilled('en-GB', translations))
|
|
65
79
|
return newStore
|
|
66
80
|
}, [state, translations])
|
|
@@ -71,7 +85,7 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
71
85
|
<SeamlyEventBusContext.Provider value={eventBusRef.current}>
|
|
72
86
|
<SeamlyLiveRegionContext.Provider value={liveMsgRef.current}>
|
|
73
87
|
<SeamlyApiContext.Provider value={bareApi}>
|
|
74
|
-
{children}
|
|
88
|
+
<ComponentFilter>{children}</ComponentFilter>
|
|
75
89
|
</SeamlyApiContext.Provider>
|
|
76
90
|
</SeamlyLiveRegionContext.Provider>
|
|
77
91
|
</SeamlyEventBusContext.Provider>
|