@seamly/web-ui 19.1.2 → 20.0.0-beta.2

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.
Files changed (185) hide show
  1. package/CHANGELOG.md +625 -0
  2. package/build/dist/lib/components.js +2 -1
  3. package/build/dist/lib/components.min.js +1 -1
  4. package/build/dist/lib/index.debug.js +183 -128
  5. package/build/dist/lib/index.debug.min.js +1 -1
  6. package/build/dist/lib/index.debug.min.js.LICENSE.txt +45 -25
  7. package/build/dist/lib/index.js +7292 -7752
  8. package/build/dist/lib/index.min.js +1 -1
  9. package/build/dist/lib/index.min.js.LICENSE.txt +0 -5
  10. package/build/dist/lib/standalone.js +5788 -6255
  11. package/build/dist/lib/standalone.min.js +1 -1
  12. package/build/dist/lib/standalone.min.js.LICENSE.txt +0 -5
  13. package/build/dist/lib/style-guide.js +1935 -1965
  14. package/build/dist/lib/style-guide.min.js +1 -1
  15. package/build/dist/lib/styles.css +1 -1
  16. package/package.json +1 -2
  17. package/src/icons/icon_file-32.svg +1 -1
  18. package/src/javascripts/api/errors/seamly-base-error.js +7 -0
  19. package/src/javascripts/api/index.js +48 -37
  20. package/src/javascripts/api/producer.js +5 -1
  21. package/src/javascripts/config.js +1 -5
  22. package/src/javascripts/domains/app/actions.js +22 -5
  23. package/src/javascripts/domains/config/actions.js +3 -0
  24. package/src/javascripts/domains/config/reducer.js +9 -0
  25. package/src/javascripts/domains/errors/index.js +5 -4
  26. package/src/javascripts/domains/forms/hooks.js +3 -1
  27. package/src/javascripts/domains/forms/provider.js +12 -0
  28. package/src/javascripts/domains/forms/reducer.js +2 -0
  29. package/src/javascripts/domains/i18n/hooks.js +2 -1
  30. package/src/javascripts/domains/i18n/reducer.js +2 -0
  31. package/src/javascripts/domains/interrupt/reducer.js +2 -2
  32. package/src/javascripts/domains/options/middleware.js +15 -31
  33. package/src/javascripts/domains/store/index.js +2 -1
  34. package/src/javascripts/domains/store/state-reducer.js +3 -8
  35. package/src/javascripts/domains/translations/components/options-dialog/form.js +1 -1
  36. package/src/javascripts/domains/translations/components/options-dialog/index.js +15 -1
  37. package/src/javascripts/domains/translations/reducer.js +2 -0
  38. package/src/javascripts/domains/visibility/actions.js +1 -1
  39. package/src/javascripts/domains/visibility/hooks.js +10 -8
  40. package/src/javascripts/domains/visibility/utils.js +1 -2
  41. package/src/javascripts/index.js +7 -2
  42. package/src/javascripts/lib/css.js +7 -1
  43. package/src/javascripts/lib/engine/index.js +4 -3
  44. package/src/javascripts/lib/external-api/index.js +38 -29
  45. package/src/javascripts/package/components.js +2 -1
  46. package/src/javascripts/style-guide/components/app.js +1 -1
  47. package/src/javascripts/style-guide/components/static-core.js +9 -3
  48. package/src/javascripts/style-guide/states.js +203 -298
  49. package/src/javascripts/ui/components/chat-app.js +1 -1
  50. package/src/javascripts/ui/components/conversation/component-filter.js +6 -0
  51. package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +8 -1
  52. package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -3
  53. package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +70 -0
  54. package/src/javascripts/ui/components/conversation/event/participant.js +2 -5
  55. package/src/javascripts/ui/components/conversation/event/splash.js +26 -0
  56. package/src/javascripts/ui/components/conversation/event/text.js +1 -2
  57. package/src/javascripts/ui/components/core/seamly-core.js +12 -9
  58. package/src/javascripts/ui/components/core/seamly-event-subscriber.js +4 -10
  59. package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +1 -8
  60. package/src/javascripts/ui/components/entry/entry-container.js +5 -3
  61. package/src/javascripts/ui/components/entry/text-entry/index.js +7 -1
  62. package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +5 -1
  63. package/src/javascripts/ui/components/entry/toggle-button.js +4 -2
  64. package/src/javascripts/ui/components/entry/upload/file-upload-form.js +1 -1
  65. package/src/javascripts/ui/components/form-controls/error.js +6 -2
  66. package/src/javascripts/ui/components/form-controls/form.js +26 -3
  67. package/src/javascripts/ui/components/layout/app-frame.js +24 -15
  68. package/src/javascripts/ui/components/layout/chat-frame.js +0 -2
  69. package/src/javascripts/ui/components/layout/modal-wrapper.js +0 -80
  70. package/src/javascripts/ui/components/layout/pre-chat-messages.js +45 -0
  71. package/src/javascripts/ui/components/options/options-frame.js +9 -4
  72. package/src/javascripts/ui/components/options/options.js +1 -4
  73. package/src/javascripts/ui/components/options/transcript/index.js +15 -1
  74. package/src/javascripts/ui/components/options/transcript/transcript-form.js +1 -1
  75. package/src/javascripts/ui/components/suggestions/index.js +174 -0
  76. package/src/javascripts/ui/components/suggestions/suggestions-item.js +40 -0
  77. package/src/javascripts/ui/components/suggestions/suggestions-list.js +24 -0
  78. package/src/javascripts/ui/components/view/app-view.js +21 -0
  79. package/src/javascripts/ui/components/view/deprecated-view.js +30 -0
  80. package/src/javascripts/ui/components/view/index.js +27 -0
  81. package/src/javascripts/ui/components/view/inline-view.js +45 -0
  82. package/src/javascripts/ui/components/view/window-view/collapse-button.js +20 -0
  83. package/src/javascripts/ui/components/view/window-view/index.js +82 -0
  84. package/src/javascripts/ui/components/view/window-view/window-open-button.js +68 -0
  85. package/src/javascripts/ui/components/widgets/lightbox.js +7 -2
  86. package/src/javascripts/ui/hooks/component-helper-hooks.js +0 -9
  87. package/src/javascripts/ui/hooks/seamly-hooks.js +0 -1
  88. package/src/javascripts/ui/hooks/seamly-state-hooks.js +28 -4
  89. package/src/javascripts/ui/hooks/use-seamly-chat.js +12 -3
  90. package/src/javascripts/ui/hooks/use-seamly-commands.js +4 -31
  91. package/src/javascripts/ui/utils/seamly-utils.js +2 -14
  92. package/src/stylesheets/1-settings/_animations.scss +0 -6
  93. package/src/stylesheets/1-settings/_config.scss +34 -35
  94. package/src/stylesheets/2-tools/_functions.scss +0 -5
  95. package/src/stylesheets/2-tools/_mixins.scss +4 -16
  96. package/src/stylesheets/3-app/_app.scss +78 -135
  97. package/src/stylesheets/4-base/_a11y.scss +0 -3
  98. package/src/stylesheets/4-base/_elements.scss +0 -11
  99. package/src/stylesheets/4-base/_formelements.scss +4 -14
  100. package/src/stylesheets/5-components/_avatar.scss +2 -44
  101. package/src/stylesheets/5-components/_buttons.scss +6 -45
  102. package/src/stylesheets/5-components/_chat-status.scss +14 -38
  103. package/src/stylesheets/5-components/_choice-prompt.scss +33 -2
  104. package/src/stylesheets/5-components/_collapse-button.scss +16 -0
  105. package/src/stylesheets/5-components/_conversation.scss +26 -2
  106. package/src/stylesheets/5-components/_disclaimer.scss +10 -12
  107. package/src/stylesheets/5-components/_divider.scss +7 -4
  108. package/src/stylesheets/5-components/_error.scss +1 -1
  109. package/src/stylesheets/5-components/_form.scss +9 -0
  110. package/src/stylesheets/5-components/_icon.scss +10 -1
  111. package/src/stylesheets/5-components/_idle.scss +0 -8
  112. package/src/stylesheets/5-components/_input.scss +14 -20
  113. package/src/stylesheets/5-components/_interrupt.scss +0 -2
  114. package/src/stylesheets/5-components/_loader.scss +0 -32
  115. package/src/stylesheets/5-components/_message-author.scss +40 -0
  116. package/src/stylesheets/5-components/_message-body.scss +194 -0
  117. package/src/stylesheets/5-components/_message-card.scss +55 -0
  118. package/src/stylesheets/5-components/_message-carousel.scss +143 -0
  119. package/src/stylesheets/5-components/_message-count.scss +11 -28
  120. package/src/stylesheets/5-components/_message-cta.scss +23 -0
  121. package/src/stylesheets/5-components/_message-info.scss +11 -0
  122. package/src/stylesheets/5-components/_message-translation-info.scss +17 -0
  123. package/src/stylesheets/5-components/_message.scss +13 -364
  124. package/src/stylesheets/5-components/_modal.scss +28 -58
  125. package/src/stylesheets/5-components/_notification.scss +0 -5
  126. package/src/stylesheets/5-components/_options.scss +27 -42
  127. package/src/stylesheets/5-components/_pre-chat-messages.scss +30 -0
  128. package/src/stylesheets/5-components/_prompt.scss +0 -8
  129. package/src/stylesheets/5-components/_skip-link.scss +3 -3
  130. package/src/stylesheets/5-components/_suggestions.scss +96 -0
  131. package/src/stylesheets/5-components/_unstarted.scss +50 -0
  132. package/src/stylesheets/5-components/_upload.scss +26 -28
  133. package/src/stylesheets/5-components/_window-open-button.scss +39 -0
  134. package/src/stylesheets/6-webui-only/_hover.scss +151 -0
  135. package/src/stylesheets/6-webui-only/_scrollbar.scss +31 -0
  136. package/src/stylesheets/7-deprecated/1-settings/_animations.scss +43 -0
  137. package/src/stylesheets/7-deprecated/1-settings/_config.scss +105 -0
  138. package/src/stylesheets/7-deprecated/2-tools/_functions.scss +22 -0
  139. package/src/stylesheets/7-deprecated/2-tools/_mixins.scss +77 -0
  140. package/src/stylesheets/7-deprecated/3-app/_app.scss +214 -0
  141. package/src/stylesheets/7-deprecated/4-base/_a11y.scss +14 -0
  142. package/src/stylesheets/7-deprecated/4-base/_elements.scss +21 -0
  143. package/src/stylesheets/7-deprecated/4-base/_formelements.scss +57 -0
  144. package/src/stylesheets/{5-components → 7-deprecated/5-components}/_agent-info.scss +0 -0
  145. package/src/stylesheets/7-deprecated/5-components/_avatar.scss +64 -0
  146. package/src/stylesheets/7-deprecated/5-components/_buttons.scss +94 -0
  147. package/src/stylesheets/{5-components → 7-deprecated/5-components}/_card.scss +0 -0
  148. package/src/stylesheets/{5-components → 7-deprecated/5-components}/_carousel.scss +0 -0
  149. package/src/stylesheets/7-deprecated/5-components/_character-limit.scss +36 -0
  150. package/src/stylesheets/{5-components/_cobrowsing.scss → 7-deprecated/5-components/_chat-status.scss} +18 -16
  151. package/src/stylesheets/7-deprecated/5-components/_choice-prompt.scss +27 -0
  152. package/src/stylesheets/7-deprecated/5-components/_collapse-button.scss +17 -0
  153. package/src/stylesheets/7-deprecated/5-components/_conversation.scss +44 -0
  154. package/src/stylesheets/7-deprecated/5-components/_disclaimer.scss +36 -0
  155. package/src/stylesheets/7-deprecated/5-components/_divider.scss +91 -0
  156. package/src/stylesheets/7-deprecated/5-components/_error.scss +24 -0
  157. package/src/stylesheets/{5-components → 7-deprecated/5-components}/_faq.scss +8 -3
  158. package/src/stylesheets/{5-components → 7-deprecated/5-components}/_header-controls.scss +0 -0
  159. package/src/stylesheets/7-deprecated/5-components/_icon.scss +4 -0
  160. package/src/stylesheets/7-deprecated/5-components/_idle.scss +61 -0
  161. package/src/stylesheets/7-deprecated/5-components/_input.scss +78 -0
  162. package/src/stylesheets/7-deprecated/5-components/_interrupt.scss +35 -0
  163. package/src/stylesheets/7-deprecated/5-components/_loader.scss +78 -0
  164. package/src/stylesheets/7-deprecated/5-components/_message-count.scss +41 -0
  165. package/src/stylesheets/7-deprecated/5-components/_message.scss +385 -0
  166. package/src/stylesheets/7-deprecated/5-components/_modal.scss +138 -0
  167. package/src/stylesheets/7-deprecated/5-components/_notification.scss +20 -0
  168. package/src/stylesheets/7-deprecated/5-components/_options.scss +286 -0
  169. package/src/stylesheets/7-deprecated/5-components/_prompt.scss +44 -0
  170. package/src/stylesheets/7-deprecated/5-components/_skip-link.scss +21 -0
  171. package/src/stylesheets/{5-components → 7-deprecated/5-components}/_svg-graphic.scss +0 -0
  172. package/src/stylesheets/7-deprecated/5-components/_upload.scss +213 -0
  173. package/src/stylesheets/deprecated-view.scss +64 -0
  174. package/src/stylesheets/styles-webui-only.scss +3 -0
  175. package/src/stylesheets/styles.scss +15 -25
  176. package/webpack/config.site.js +4 -0
  177. package/webpack/defaults.js +5 -0
  178. package/src/.DS_Store +0 -0
  179. package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +0 -35
  180. package/src/javascripts/ui/components/faq/faq.js +0 -162
  181. package/src/javascripts/ui/components/layout/view.js +0 -36
  182. package/src/javascripts/ui/components/options/cobrowsing.js +0 -110
  183. package/src/javascripts/ui/components/warnings/cobrowsing-active-frame.js +0 -29
  184. package/src/javascripts/ui/components/warnings/cobrowsing-active.js +0 -33
  185. package/src/stylesheets/5-components/_modal_mode.scss +0 -108
@@ -1,35 +1,19 @@
1
- import { featureKeys, seamlyActions } from '../../ui/utils/seamly-utils'
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 ({ dispatch }) =>
7
- (next) =>
8
- (action) => {
9
- const result = next(action)
10
-
11
- switch (action.type) {
12
- // This is needed for backwards compatibility. If there's an error,
13
- // Cobrowsing has to be disabled in order to not "re-start" into co-browsing
14
- case String(InterruptActions.set):
15
- if (!(action.error instanceof SeamlyOfflineError)) {
16
- dispatch({
17
- type: seamlyActions.SET_USER_SELECTED_OPTION,
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 { Actions as AppActions } from '../app'
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.reset)) {
52
- const { visible } = state
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,4 +1,4 @@
1
- import { Selectors as ConfigSelectors } from '../config'
1
+ import * as ConfigSelectors from '../config/selectors'
2
2
  import * as AppSelectors from '../app/selectors'
3
3
 
4
4
  import { visibilityStates, StoreKey } from './constants'
@@ -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 { layoutMode } = useConfig()
13
- const isOpen =
14
- visible && layoutMode
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 { isVisible, isOpen, visible, setVisibility }
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 ||
@@ -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 ToggleButton } from './ui/components/entry/toggle-button'
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 View } from './ui/components/layout/view'
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) => [CSS_NAME, c].join('-'))
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 { Actions as AppActions } from '../../domains/app'
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
- locale: config?.context?.locale,
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(renderConfig))
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
- if (!config) {
54
- this.destroy(userConfig.namespace)
55
- return
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
- this.destroy(instance)
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 (typeof instance === 'string') {
109
- // eslint-disable-next-line no-param-reassign
110
- instance = this._instances[instance]
111
- }
112
- if (instance) {
113
- instance.destroy()
114
- delete this._instances[instance.namespace]
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
  }
@@ -9,6 +9,7 @@ export {
9
9
  Icon,
10
10
  MessageContainer,
11
11
  Text,
12
- ToggleButton,
12
+ DeprecatedToggleButton,
13
+ DeprecatedView,
13
14
  View,
14
15
  } from '@seamly/web-ui'
@@ -18,7 +18,7 @@ const StyleGuideApp = ({
18
18
 
19
19
  const [mainState] = useState(() => {
20
20
  const mainStateObj = getStateObj(
21
- styleGuideConfig.showLayoutModes || ['inline', 'window', 'modal'],
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>