@seamly/web-ui 19.1.3 → 20.0.0-beta.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/components.js +2 -1
- package/build/dist/lib/components.min.js +1 -1
- package/build/dist/lib/index.debug.js +188 -111
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +48 -20
- package/build/dist/lib/index.js +11764 -11970
- 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 +7131 -7333
- 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 +2117 -2007
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +1 -1
- package/package.json +1 -2
- package/src/.DS_Store +0 -0
- package/src/icons/icon_file-32.svg +1 -1
- package/src/javascripts/api/index.js +48 -37
- 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/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 +7 -2
- 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 +4 -4
- package/src/javascripts/style-guide/components/static-core.js +9 -3
- package/src/javascripts/style-guide/components/view.js +0 -1
- package/src/javascripts/style-guide/states.js +468 -348
- 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/deprecated-app-frame.js +86 -0
- 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 +32 -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 +19 -9
- 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 +34 -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 +284 -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.common.js +7 -1
- package/webpack/config.site.js +4 -0
- package/webpack/config.test.js +1 -0
- package/webpack/defaults.js +5 -0
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +0 -35
- 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
|
@@ -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,16 @@ 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
|
+
|
|
132
|
+
// Used by: StyleGuide
|
|
133
|
+
export { default as View } from './ui/components/view'
|
|
131
134
|
|
|
132
135
|
// Used by: Client
|
|
136
|
+
export { default as DeprecatedView } from './ui/components/view/deprecated-view'
|
|
137
|
+
|
|
133
138
|
// Used by: StyleGuide
|
|
134
|
-
export { default as
|
|
139
|
+
export { default as ComponentFilter } from './ui/components/conversation/component-filter'
|
|
135
140
|
|
|
136
141
|
// Used by: Client
|
|
137
142
|
// 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
|
}
|
|
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'preact/hooks'
|
|
|
2
2
|
import { getUrlParams, getUrlSearchString, randomId } from '@seamly/web-ui'
|
|
3
3
|
import StyleGuideView from './view'
|
|
4
4
|
import StyleGuideLinks from './links'
|
|
5
|
-
import { getStateObj } from '../states'
|
|
5
|
+
import { getStateObj, getDeprecatedStateObj } from '../states'
|
|
6
6
|
|
|
7
7
|
const StyleGuideApp = ({
|
|
8
8
|
config,
|
|
@@ -15,10 +15,10 @@ const StyleGuideApp = ({
|
|
|
15
15
|
const [showStyleGuide, setShowStyleGuide] = useState(true)
|
|
16
16
|
const [headingId] = useState(randomId())
|
|
17
17
|
const { stateUpdateCallback, customMessageEventBodies } = styleGuideConfig
|
|
18
|
-
|
|
18
|
+
const stateObjFunc = config.isDeprecated ? getDeprecatedStateObj : getStateObj
|
|
19
19
|
const [mainState] = useState(() => {
|
|
20
|
-
const mainStateObj =
|
|
21
|
-
styleGuideConfig.showLayoutModes || ['inline', 'window'
|
|
20
|
+
const mainStateObj = stateObjFunc(
|
|
21
|
+
styleGuideConfig.showLayoutModes || ['inline', 'window'],
|
|
22
22
|
customMessageEventBodies,
|
|
23
23
|
)
|
|
24
24
|
return Object.keys(mainStateObj).reduce(
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SeamlyApiContext,
|
|
7
7
|
SeamlyLiveRegionContext,
|
|
8
8
|
StoreProvider,
|
|
9
|
+
ComponentFilter,
|
|
9
10
|
createReduxStore,
|
|
10
11
|
} from '@seamly/web-ui'
|
|
11
12
|
import stateReducer from '../../domains/store/state-reducer'
|
|
@@ -40,7 +41,7 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
40
41
|
const {
|
|
41
42
|
translations: translationsSlice,
|
|
42
43
|
interrupt: interruptSlice,
|
|
43
|
-
config: configSlice,
|
|
44
|
+
config: configSlice = {},
|
|
44
45
|
visibility: visibilitySlice,
|
|
45
46
|
...restState
|
|
46
47
|
} = state || {}
|
|
@@ -68,7 +69,12 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
68
69
|
}),
|
|
69
70
|
],
|
|
70
71
|
})
|
|
71
|
-
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
|
+
}
|
|
72
78
|
newStore.dispatch(I18nActions.setLocale.fulfilled('en-GB', translations))
|
|
73
79
|
return newStore
|
|
74
80
|
}, [state, translations])
|
|
@@ -79,7 +85,7 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
79
85
|
<SeamlyEventBusContext.Provider value={eventBusRef.current}>
|
|
80
86
|
<SeamlyLiveRegionContext.Provider value={liveMsgRef.current}>
|
|
81
87
|
<SeamlyApiContext.Provider value={bareApi}>
|
|
82
|
-
{children}
|
|
88
|
+
<ComponentFilter>{children}</ComponentFilter>
|
|
83
89
|
</SeamlyApiContext.Provider>
|
|
84
90
|
</SeamlyLiveRegionContext.Provider>
|
|
85
91
|
</SeamlyEventBusContext.Provider>
|
|
@@ -7,7 +7,6 @@ const StyleGuideView = ({ state, customComponents = {}, translations }) => {
|
|
|
7
7
|
const { config } = state || {}
|
|
8
8
|
const { layoutMode } = config || {}
|
|
9
9
|
const CustomView = customComponents[layoutMode]
|
|
10
|
-
|
|
11
10
|
// This ensures that the style guide view is completely
|
|
12
11
|
// reconstructed for each state to avoid artifacts from previous
|
|
13
12
|
// renders showing up.
|