@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.
Files changed (194) hide show
  1. package/build/dist/lib/index.debug.js +598 -136
  2. package/build/dist/lib/index.debug.min.js +1 -1
  3. package/build/dist/lib/index.debug.min.js.LICENSE.txt +190 -22
  4. package/build/dist/lib/index.js +4745 -4468
  5. package/build/dist/lib/index.min.js +1 -1
  6. package/build/dist/lib/index.min.js.LICENSE.txt +1 -1
  7. package/build/dist/lib/standalone.js +4839 -4465
  8. package/build/dist/lib/standalone.min.js +1 -1
  9. package/build/dist/lib/standalone.min.js.LICENSE.txt +1 -1
  10. package/build/dist/lib/style-guide.js +1770 -980
  11. package/build/dist/lib/style-guide.min.js +1 -1
  12. package/build/dist/lib/styles.css +1 -1
  13. package/build/dist/lib/utils.js +0 -1
  14. package/build/dist/lib/utils.min.js +1 -1
  15. package/package.json +29 -29
  16. package/src/javascripts/api/index.js +33 -48
  17. package/src/javascripts/api/producer.js +9 -12
  18. package/src/javascripts/config.js +9 -11
  19. package/src/javascripts/domains/app/actions.js +43 -0
  20. package/src/javascripts/domains/app/hooks.js +6 -0
  21. package/src/javascripts/domains/app/index.js +6 -0
  22. package/src/javascripts/domains/app/reducer.js +16 -0
  23. package/src/javascripts/domains/app/selectors.js +8 -0
  24. package/src/javascripts/domains/app/utils.js +4 -0
  25. package/src/javascripts/domains/config/actions.js +4 -0
  26. package/src/javascripts/domains/config/hooks.js +6 -0
  27. package/src/javascripts/domains/config/index.js +8 -0
  28. package/src/javascripts/domains/config/middleware.js +22 -0
  29. package/src/javascripts/domains/config/reducer.js +63 -0
  30. package/src/javascripts/domains/config/selectors.js +23 -0
  31. package/src/javascripts/domains/config/utils.js +4 -0
  32. package/src/javascripts/domains/forms/actions.js +2 -4
  33. package/src/javascripts/domains/forms/hooks.js +10 -14
  34. package/src/javascripts/domains/forms/provider.js +4 -6
  35. package/src/javascripts/domains/forms/reducer.js +1 -2
  36. package/src/javascripts/domains/forms/selectors.js +4 -4
  37. package/src/javascripts/domains/forms/utils.js +5 -0
  38. package/src/javascripts/domains/i18n/actions.js +35 -0
  39. package/src/javascripts/domains/i18n/hooks.js +38 -0
  40. package/src/javascripts/domains/i18n/index.js +5 -80
  41. package/src/javascripts/domains/i18n/reducer.js +58 -0
  42. package/src/javascripts/domains/i18n/selectors.js +15 -0
  43. package/src/javascripts/domains/i18n/utils.js +9 -0
  44. package/src/javascripts/domains/interrupt/actions.js +4 -0
  45. package/src/javascripts/domains/interrupt/hooks.js +29 -0
  46. package/src/javascripts/domains/interrupt/index.js +9 -0
  47. package/src/javascripts/domains/interrupt/middleware.js +30 -0
  48. package/src/javascripts/domains/interrupt/reducer.js +21 -0
  49. package/src/javascripts/domains/interrupt/selectors.js +6 -0
  50. package/src/javascripts/domains/interrupt/utils.js +4 -0
  51. package/src/javascripts/domains/options/index.js +1 -0
  52. package/src/javascripts/domains/options/middleware.js +35 -0
  53. package/src/javascripts/domains/redux/create-redux-store.js +14 -6
  54. package/src/javascripts/domains/redux/hooks.js +3 -2
  55. package/src/javascripts/domains/redux/index.js +2 -1
  56. package/src/javascripts/domains/redux/provider.js +5 -0
  57. package/src/javascripts/domains/store/index.js +44 -0
  58. package/src/javascripts/{ui → domains}/store/state-reducer.js +4 -7
  59. package/src/javascripts/domains/translations/actions.js +4 -6
  60. package/src/javascripts/domains/translations/components/chat-status.js +7 -13
  61. package/src/javascripts/domains/translations/components/options-button.js +3 -3
  62. package/src/javascripts/domains/translations/components/options-dialog/form.js +12 -7
  63. package/src/javascripts/domains/translations/components/options-dialog/index.js +2 -5
  64. package/src/javascripts/domains/translations/hooks.js +1 -1
  65. package/src/javascripts/domains/translations/index.js +1 -0
  66. package/src/javascripts/domains/translations/middleware.js +43 -0
  67. package/src/javascripts/domains/translations/reducer.js +4 -11
  68. package/src/javascripts/domains/translations/selectors.js +3 -3
  69. package/src/javascripts/domains/translations/utils.js +4 -0
  70. package/src/javascripts/index.js +20 -5
  71. package/src/javascripts/lib/css.js +5 -5
  72. package/src/javascripts/lib/engine/index.js +39 -11
  73. package/src/javascripts/lib/external-api/index.js +6 -6
  74. package/src/javascripts/lib/mutex.js +30 -0
  75. package/src/javascripts/lib/parse-body.js +1 -1
  76. package/src/javascripts/lib/redux-helpers/index.js +25 -8
  77. package/src/javascripts/lib/split-url-params.js +2 -2
  78. package/src/javascripts/lib/store/providers/app-storage.js +1 -1
  79. package/src/javascripts/lib/store/providers/cookie-storage.js +1 -1
  80. package/src/javascripts/package/utils.js +0 -1
  81. package/src/javascripts/style-guide/components/app.js +12 -14
  82. package/src/javascripts/style-guide/components/links.js +6 -6
  83. package/src/javascripts/style-guide/components/static-core.js +32 -10
  84. package/src/javascripts/style-guide/state-helpers/index.js +1 -1
  85. package/src/javascripts/style-guide/states.js +29 -71
  86. package/src/javascripts/style-guide/style-guide-engine.js +13 -12
  87. package/src/javascripts/ui/components/chat-app.js +2 -2
  88. package/src/javascripts/ui/components/conversation/component-filter.js +2 -2
  89. package/src/javascripts/ui/components/conversation/conversation.js +2 -2
  90. package/src/javascripts/ui/components/conversation/event/card-component.js +24 -3
  91. package/src/javascripts/ui/components/conversation/event/carousel-component/components/pagination.js +2 -2
  92. package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +4 -3
  93. package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -1
  94. package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +2 -2
  95. package/src/javascripts/ui/components/conversation/event/choice-prompt.js +5 -5
  96. package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +2 -2
  97. package/src/javascripts/ui/components/conversation/event/event-participant.js +3 -5
  98. package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js +2 -2
  99. package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +3 -3
  100. package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +3 -3
  101. package/src/javascripts/ui/components/conversation/event/participant.js +2 -2
  102. package/src/javascripts/ui/components/conversation/event/upload.js +12 -27
  103. package/src/javascripts/ui/components/conversation/message-container.js +4 -6
  104. package/src/javascripts/ui/components/core/seamly-activity-monitor.js +4 -5
  105. package/src/javascripts/ui/components/core/seamly-core.js +6 -7
  106. package/src/javascripts/ui/components/core/seamly-event-subscriber.js +18 -17
  107. package/src/javascripts/ui/components/core/seamly-file-upload.js +5 -6
  108. package/src/javascripts/ui/components/core/seamly-idle-detach-counter.js +2 -6
  109. package/src/javascripts/ui/components/core/seamly-initializer.js +7 -60
  110. package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +10 -16
  111. package/src/javascripts/ui/components/core/seamly-live-region.js +1 -1
  112. package/src/javascripts/ui/components/core/seamly-new-notifications.js +5 -6
  113. package/src/javascripts/ui/components/core/seamly-read-state.js +8 -6
  114. package/src/javascripts/ui/components/entry/entry-container.js +7 -10
  115. package/src/javascripts/ui/components/entry/text-entry/hooks.js +6 -4
  116. package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +10 -3
  117. package/src/javascripts/ui/components/entry/toggle-button.js +24 -10
  118. package/src/javascripts/ui/components/entry/upload/file-upload-form.js +6 -3
  119. package/src/javascripts/ui/components/entry/upload/index.js +11 -13
  120. package/src/javascripts/ui/components/faq/faq.js +6 -6
  121. package/src/javascripts/ui/components/form-controls/error.js +22 -0
  122. package/src/javascripts/ui/components/form-controls/file-input.js +3 -9
  123. package/src/javascripts/ui/components/form-controls/select.js +1 -1
  124. package/src/javascripts/ui/components/form-controls/wrapper.js +2 -9
  125. package/src/javascripts/ui/components/layout/agent-info.js +4 -4
  126. package/src/javascripts/ui/components/layout/app-frame.js +15 -12
  127. package/src/javascripts/ui/components/layout/chat-frame.js +3 -5
  128. package/src/javascripts/ui/components/layout/header.js +4 -18
  129. package/src/javascripts/ui/components/layout/interrupt.js +6 -2
  130. package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
  131. package/src/javascripts/ui/components/options/cobrowsing.js +3 -7
  132. package/src/javascripts/ui/components/options/options-button.js +9 -13
  133. package/src/javascripts/ui/components/options/options-frame.js +1 -1
  134. package/src/javascripts/ui/components/options/transcript/index.js +2 -2
  135. package/src/javascripts/ui/components/options/transcript/transcript-form.js +1 -1
  136. package/src/javascripts/ui/components/warnings/cobrowsing-active-frame.js +3 -6
  137. package/src/javascripts/ui/components/warnings/idle-detach-warning.js +2 -6
  138. package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +1 -1
  139. package/src/javascripts/ui/components/widgets/in-out-transition.js +2 -2
  140. package/src/javascripts/ui/components/widgets/lightbox.js +4 -4
  141. package/src/javascripts/ui/components/widgets/modal.js +3 -3
  142. package/src/javascripts/ui/components/widgets/upload-progress.js +3 -14
  143. package/src/javascripts/ui/hooks/component-helper-hooks.js +4 -15
  144. package/src/javascripts/ui/hooks/file-upload-hooks.js +3 -3
  145. package/src/javascripts/ui/hooks/focus-helper-hooks.js +4 -4
  146. package/src/javascripts/ui/hooks/live-region-hooks.js +2 -2
  147. package/src/javascripts/ui/hooks/seamly-api-hooks.js +0 -6
  148. package/src/javascripts/ui/hooks/seamly-entry-hooks.js +22 -25
  149. package/src/javascripts/ui/hooks/seamly-hooks.js +3 -10
  150. package/src/javascripts/ui/hooks/seamly-option-hooks.js +4 -4
  151. package/src/javascripts/ui/hooks/seamly-state-hooks.js +8 -16
  152. package/src/javascripts/ui/hooks/use-event-component-mapping.js +1 -1
  153. package/src/javascripts/ui/hooks/use-seamly-chat.js +1 -0
  154. package/src/javascripts/ui/hooks/use-seamly-commands.js +31 -54
  155. package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +3 -3
  156. package/src/javascripts/ui/hooks/use-seamly-stored-visibility.js +3 -3
  157. package/src/javascripts/ui/hooks/use-seamly-visibility.js +6 -8
  158. package/src/javascripts/ui/hooks/use-single-file-upload.js +4 -1
  159. package/src/javascripts/ui/hooks/utility-hooks.js +2 -2
  160. package/src/javascripts/ui/utils/form-utils.js +3 -3
  161. package/src/javascripts/ui/utils/general-utils.js +21 -22
  162. package/src/javascripts/ui/utils/seamly-utils.js +15 -83
  163. package/src/javascripts/ui/utils/validations.js +10 -7
  164. package/src/stylesheets/1-settings/_config.scss +2 -1
  165. package/src/stylesheets/3-app/_app.scss +3 -4
  166. package/src/stylesheets/5-components/_card.scss +0 -1
  167. package/src/stylesheets/5-components/_faq.scss +3 -8
  168. package/src/stylesheets/5-components/_message.scss +10 -0
  169. package/src/stylesheets/5-components/_modal.scss +3 -3
  170. package/src/stylesheets/5-components/_options.scss +3 -2
  171. package/webpack/config.common.js +3 -3
  172. package/webpack/config.package.js +4 -22
  173. package/webpack/config.site.js +8 -6
  174. package/webpack/defaults.js +0 -3
  175. package/CHANGELOG.md +0 -561
  176. package/build/dist/translations/de-informal.js +0 -275
  177. package/build/dist/translations/de-informal.min.js +0 -1
  178. package/build/dist/translations/en.js +0 -275
  179. package/build/dist/translations/en.min.js +0 -1
  180. package/build/dist/translations/es-informal.js +0 -281
  181. package/build/dist/translations/es-informal.min.js +0 -1
  182. package/build/dist/translations/nl-formal.js +0 -275
  183. package/build/dist/translations/nl-formal.min.js +0 -1
  184. package/build/dist/translations/nl-informal.js +0 -275
  185. package/build/dist/translations/nl-informal.min.js +0 -1
  186. package/src/javascripts/lib/i18n.js +0 -46
  187. package/src/javascripts/ui/components/core/seamly-api.js +0 -44
  188. package/src/javascripts/ui/hooks/use-seamly-interrupt.js +0 -62
  189. package/src/javascripts/ui/store/index.js +0 -37
  190. package/translations/de-informal.js +0 -237
  191. package/translations/en.js +0 -234
  192. package/translations/es-informal.js +0 -243
  193. package/translations/nl-formal.js +0 -230
  194. package/translations/nl-informal.js +0 -230
@@ -1,18 +1,29 @@
1
1
  import { render, h } from 'preact'
2
2
  import Events from 'minivents'
3
-
4
3
  import ChatApp from '../../ui/components/chat-app'
5
4
  import SeamlyCore from '../../ui/components/core/seamly-core'
5
+ import { API } from '../../api'
6
+ import { createStore } from '../../domains/store'
7
+ import { Actions as AppActions } from '../../domains/app'
6
8
 
7
9
  export default class Engine {
8
10
  constructor(config, externalApi) {
9
- const { customComponents, parentElement, showFaq, ...restConfig } = config
10
- this.config = { ...restConfig, showFaq: showFaq !== false }
11
- this.namespace = config.namespace || ''
11
+ const { namespace = '', parentElement, showFaq, ...restConfig } = config
12
+ this.config = {
13
+ ...restConfig,
14
+ showFaq: showFaq !== false,
15
+ namespace,
16
+ }
17
+ this.namespace = namespace
12
18
  this.parentElement = parentElement
13
- this.customComponents = customComponents
14
19
  this.externalApi = externalApi
15
20
 
21
+ this.api = new API({
22
+ namespace: config.namespace,
23
+ config: config.api,
24
+ locale: config?.context?.locale,
25
+ })
26
+
16
27
  this.eventBus = new Events()
17
28
  this.functions = {}
18
29
  this.registerFunctions({
@@ -28,8 +39,8 @@ export default class Engine {
28
39
  )
29
40
  }
30
41
 
31
- render() {
32
- const { view: View, ...restComponents } = this.customComponents || {}
42
+ async render() {
43
+ const { view: View, ...restComponents } = this.config.customComponents || {}
33
44
 
34
45
  const renderConfig = {
35
46
  ...this.config,
@@ -38,16 +49,32 @@ export default class Engine {
38
49
  : undefined,
39
50
  }
40
51
 
52
+ const store = createStore({
53
+ api: this.api,
54
+ })
55
+
56
+ await store.dispatch(AppActions.initialize(renderConfig))
57
+
41
58
  if (View) {
42
59
  render(
43
- <SeamlyCore config={renderConfig} eventBus={this.eventBus}>
60
+ <SeamlyCore
61
+ config={renderConfig}
62
+ eventBus={this.eventBus}
63
+ store={store}
64
+ api={this.api}
65
+ >
44
66
  <View />
45
67
  </SeamlyCore>,
46
68
  this.parentElement,
47
69
  )
48
70
  } else {
49
71
  render(
50
- <ChatApp config={renderConfig} eventBus={this.eventBus} />,
72
+ <ChatApp
73
+ config={renderConfig}
74
+ eventBus={this.eventBus}
75
+ store={store}
76
+ api={this.api}
77
+ />,
51
78
  this.parentElement,
52
79
  )
53
80
  }
@@ -56,6 +83,7 @@ export default class Engine {
56
83
  destroy() {
57
84
  render(null, this.parentElement)
58
85
  this.eventBus.off()
86
+ this.api.disconnect()
59
87
  delete this.functions
60
88
  }
61
89
 
@@ -74,7 +102,7 @@ export default class Engine {
74
102
  unregisterFunction(functionName, fn) {
75
103
  const functions = this.functions[functionName]
76
104
  if (functions && functions.length) {
77
- this.functions[functionName] = functions.filter(fn2 => fn2 !== fn)
105
+ this.functions[functionName] = functions.filter((fn2) => fn2 !== fn)
78
106
  }
79
107
  }
80
108
 
@@ -83,7 +111,7 @@ export default class Engine {
83
111
  if (!functions || !functions.length) {
84
112
  return false
85
113
  }
86
- functions.forEach(fn => {
114
+ functions.forEach((fn) => {
87
115
  try {
88
116
  fn(...args)
89
117
  } catch (e) {
@@ -1,8 +1,8 @@
1
1
  import Engine from '../engine'
2
2
 
3
- const isActionObject = actionObj =>
3
+ const isActionObject = (actionObj) =>
4
4
  typeof actionObj === 'object' && 'action' in actionObj
5
- const fixActionObjectArgs = actionObj => ({
5
+ const fixActionObjectArgs = (actionObj) => ({
6
6
  ...actionObj,
7
7
  args: Array.isArray(actionObj.args) ? actionObj.args : [actionObj.args],
8
8
  })
@@ -29,7 +29,7 @@ class ExternalApi {
29
29
  handleActions() {
30
30
  const actions = this._waitingActions
31
31
  this._waitingActions = []
32
- actions.forEach(actionObj => {
32
+ actions.forEach((actionObj) => {
33
33
  switch (actionObj.action) {
34
34
  case 'init':
35
35
  this.handleInit(actionObj)
@@ -55,7 +55,7 @@ class ExternalApi {
55
55
  return
56
56
  }
57
57
  const { parentElement, namespace } = config
58
- Object.values(this._instances).forEach(instance => {
58
+ Object.values(this._instances).forEach((instance) => {
59
59
  if (
60
60
  instance.parentElement === parentElement ||
61
61
  instance.namespace === namespace
@@ -72,7 +72,7 @@ class ExternalApi {
72
72
  if (actionObj.instance !== undefined) {
73
73
  this.destroy(actionObj.instance)
74
74
  } else {
75
- Object.values(this._instances).forEach(instance => {
75
+ Object.values(this._instances).forEach((instance) => {
76
76
  this.destroy(instance)
77
77
  })
78
78
  }
@@ -90,7 +90,7 @@ class ExternalApi {
90
90
 
91
91
  // results will be an array containing the results of wether an instance has
92
92
  // handled the action or not
93
- const results = instances.map(instance => {
93
+ const results = instances.map((instance) => {
94
94
  return !namespace || instance.namespace === namespace
95
95
  ? instance.execFunction(action, ...args)
96
96
  : false
@@ -0,0 +1,30 @@
1
+ export default function createMutex() {
2
+ let isRunning = false
3
+ const tasks = []
4
+
5
+ const next = async () => {
6
+ if (!isRunning) {
7
+ while (tasks.length) {
8
+ const task = tasks.shift()
9
+ isRunning = true
10
+ // eslint-disable-next-line no-await-in-loop
11
+ await task().catch(() => {})
12
+ isRunning = false
13
+ }
14
+ }
15
+ }
16
+ const runExclusively = async (task) => {
17
+ const prms = new Promise((resolve, reject) => {
18
+ tasks.push(async () => {
19
+ try {
20
+ resolve(await task())
21
+ } catch (e) {
22
+ reject(e)
23
+ }
24
+ })
25
+ })
26
+ next()
27
+ return prms
28
+ }
29
+ return { next, runExclusively }
30
+ }
@@ -1,6 +1,6 @@
1
1
  import marked from 'marked'
2
2
 
3
- export default body => {
3
+ export default (body) => {
4
4
  try {
5
5
  return marked(body)
6
6
  } catch (e) {
@@ -5,7 +5,10 @@ export function prefixType(prefix, fn, delimiter = '/') {
5
5
  return (type, ...args) => fn(prefix + delimiter + type, ...args)
6
6
  }
7
7
 
8
- export function createAction(type, identityReducer = payload => ({ payload })) {
8
+ export function createAction(
9
+ type,
10
+ identityReducer = (payload) => ({ payload }),
11
+ ) {
9
12
  const action = (...params) => ({ type, ...identityReducer(...params) })
10
13
  action.toString = () => type.toString()
11
14
  return action
@@ -14,7 +17,7 @@ export function createAction(type, identityReducer = payload => ({ payload })) {
14
17
  export function createActions(baseType, ...args) {
15
18
  const handlers = []
16
19
  // eslint-disable-next-line consistent-return
17
- args.forEach(arg => {
20
+ args.forEach((arg) => {
18
21
  const argType = typeof arg
19
22
  if (argType === 'string') {
20
23
  return handlers.push([arg])
@@ -22,18 +25,21 @@ export function createActions(baseType, ...args) {
22
25
  if (argType !== 'object' || arg instanceof Array) {
23
26
  return undefined
24
27
  }
25
- Object.keys(arg).forEach(key => handlers.push([key, arg[key]]))
28
+ Object.keys(arg).forEach((key) => handlers.push([key, arg[key]]))
26
29
  })
27
30
  const create = prefixType(baseType, createAction, SLICE_DELIMITER)
28
31
 
29
- return handlers.map(handler => create(...handler))
32
+ return handlers.map((handler) => create(...handler))
30
33
  }
31
34
 
32
- export function createDomain(domain) {
33
- return {
34
- createAction: prefixType(domain, createAction, DOMAIN_DELIMITER),
35
- createActions: prefixType(domain, createActions, DOMAIN_DELIMITER),
35
+ export function createThunk(type, thunkCreator) {
36
+ const fn = (...args) => {
37
+ const thunk = thunkCreator(...args)
38
+ thunk.type = type
39
+ return thunk
36
40
  }
41
+ fn.toString = () => type
42
+ return fn
37
43
  }
38
44
 
39
45
  export function createReducer(domain, handlers = {}, defaultState) {
@@ -48,3 +54,14 @@ export function createReducer(domain, handlers = {}, defaultState) {
48
54
  reducer.toString = () => domain
49
55
  return reducer
50
56
  }
57
+
58
+ export function createDomain(domain) {
59
+ return {
60
+ createAction: prefixType(domain, createAction, DOMAIN_DELIMITER),
61
+ createActions: prefixType(domain, createActions, DOMAIN_DELIMITER),
62
+ createThunk: prefixType(domain, createThunk, DOMAIN_DELIMITER),
63
+ createReducer: (handlers, defaultState) =>
64
+ createReducer(domain, handlers, defaultState),
65
+ selectState: (state) => state[domain],
66
+ }
67
+ }
@@ -1,4 +1,4 @@
1
- const splitUrlParams = url => {
1
+ const splitUrlParams = (url) => {
2
2
  const searchIndex = url.indexOf('?')
3
3
 
4
4
  if (searchIndex < 0) {
@@ -9,7 +9,7 @@ const splitUrlParams = url => {
9
9
  const params = url
10
10
  .slice(searchIndex + 1)
11
11
  .split('&')
12
- .reduce(function(acc, hash) {
12
+ .reduce(function (acc, hash) {
13
13
  const [key, val] = hash.split('=')
14
14
  return {
15
15
  ...acc,
@@ -16,7 +16,7 @@ export default function appStore() {
16
16
  }
17
17
  return window.seamlyBridgeData
18
18
  },
19
- set: newData => {
19
+ set: (newData) => {
20
20
  // iOS
21
21
  if (
22
22
  window.webkit &&
@@ -1,7 +1,7 @@
1
1
  import cookies from 'js-cookie'
2
2
 
3
3
  export default function cookieStore(attributes = {}) {
4
- return function(key) {
4
+ return function (key) {
5
5
  const KEY = 'cvco.' + key
6
6
 
7
7
  return {
@@ -4,7 +4,6 @@ export {
4
4
  Engine,
5
5
  eventTypes,
6
6
  ExternalApi,
7
- getSeamlyConfig,
8
7
  getUrlParams,
9
8
  getUrlSearchString,
10
9
  randomId,
@@ -1,15 +1,15 @@
1
1
  import { useCallback, useEffect, useState } from 'preact/hooks'
2
- import {
3
- getSeamlyConfig,
4
- getUrlParams,
5
- getUrlSearchString,
6
- randomId,
7
- } from '@seamly/web-ui'
2
+ import { getUrlParams, getUrlSearchString, randomId } from '@seamly/web-ui'
8
3
  import StyleGuideView from './view'
9
4
  import StyleGuideLinks from './links'
10
5
  import { getStateObj } from '../states'
11
6
 
12
- const StyleGuideApp = ({ config, styleGuideConfig, headingLevel = 2 }) => {
7
+ const StyleGuideApp = ({
8
+ config,
9
+ styleGuideConfig,
10
+ translations,
11
+ headingLevel = 2,
12
+ }) => {
13
13
  const [staticState, setStaticState] = useState(null)
14
14
  const [selectedStateDescription, setSelectedStateDescription] = useState('')
15
15
  const [showStyleGuide, setShowStyleGuide] = useState(true)
@@ -34,7 +34,7 @@ const StyleGuideApp = ({ config, styleGuideConfig, headingLevel = 2 }) => {
34
34
  })
35
35
 
36
36
  const updateState = useCallback(
37
- state => {
37
+ (state) => {
38
38
  if (stateUpdateCallback) {
39
39
  setStaticState(stateUpdateCallback(state))
40
40
  } else {
@@ -46,7 +46,7 @@ const StyleGuideApp = ({ config, styleGuideConfig, headingLevel = 2 }) => {
46
46
 
47
47
  const getState = useCallback(
48
48
  (layoutMode, feature) => {
49
- const { showDisclaimer, defaults } = config
49
+ const { defaults } = config
50
50
  const { headingText } = mainState[feature]
51
51
  setSelectedStateDescription(headingText)
52
52
  const bareState = mainState[feature][layoutMode]
@@ -57,13 +57,11 @@ const StyleGuideApp = ({ config, styleGuideConfig, headingLevel = 2 }) => {
57
57
  ...bareState,
58
58
  config: {
59
59
  ...bareState.config,
60
- ...getSeamlyConfig(config),
60
+ ...config,
61
61
  layoutMode: bareState.config.layoutMode,
62
62
  ...(overrideMessages ? { messages: overrideMessages } : {}),
63
63
  showFaq,
64
64
  },
65
- showDisclaimer:
66
- showDisclaimer != null ? showDisclaimer : bareState.showDisclaimer,
67
65
  headerTitles: {
68
66
  ...bareState.headerTitles,
69
67
  subTitle: agentName || bareState.headerTitles.subTitle,
@@ -82,7 +80,7 @@ const StyleGuideApp = ({ config, styleGuideConfig, headingLevel = 2 }) => {
82
80
  const overlay = document.querySelector('[aria-modal="true"]')
83
81
  if (overlay) {
84
82
  overlay.addEventListener('click', () => {
85
- setStaticState(s => ({
83
+ setStaticState((s) => ({
86
84
  ...s,
87
85
  visible: 'minimized',
88
86
  }))
@@ -145,7 +143,7 @@ const StyleGuideApp = ({ config, styleGuideConfig, headingLevel = 2 }) => {
145
143
  {showStyleGuide && (
146
144
  <StyleGuideView
147
145
  customComponents={styleGuideConfig.customComponents}
148
- translations={config.translations}
146
+ translations={translations}
149
147
  state={staticState}
150
148
  />
151
149
  )}
@@ -4,7 +4,7 @@ import { categories } from '../states'
4
4
  const StyleGuideLinks = ({ setSelectedState, states, headingLevel }) => {
5
5
  const CategoryHeading = `h${headingLevel.toString()}`
6
6
  const FeatureHeading = `h${(parseInt(headingLevel, 10) + 1).toString()}`
7
- const onClickHandler = actionObj => {
7
+ const onClickHandler = (actionObj) => {
8
8
  window.history.pushState(
9
9
  null,
10
10
  null,
@@ -18,9 +18,9 @@ const StyleGuideLinks = ({ setSelectedState, states, headingLevel }) => {
18
18
  return (
19
19
  <nav aria-label="Style guide navigation" className="nav--styleguide">
20
20
  <ol className="list--styleguidestates">
21
- {Object.keys(categories).map(category => {
21
+ {Object.keys(categories).map((category) => {
22
22
  const { heading, description } = categories[category]
23
- const features = Object.keys(states).filter(feature => {
23
+ const features = Object.keys(states).filter((feature) => {
24
24
  const { category: featureCategory } = states[feature]
25
25
  return featureCategory === category
26
26
  })
@@ -30,7 +30,7 @@ const StyleGuideLinks = ({ setSelectedState, states, headingLevel }) => {
30
30
  <CategoryHeading>{heading}</CategoryHeading>
31
31
  <span className="category__description">{description}</span>
32
32
  <ol>
33
- {features.map(feature => {
33
+ {features.map((feature) => {
34
34
  const featureState = { ...states[feature] }
35
35
  delete featureState.category
36
36
  const {
@@ -50,7 +50,7 @@ const StyleGuideLinks = ({ setSelectedState, states, headingLevel }) => {
50
50
  </span>
51
51
  )}
52
52
  <ul className="list--styleguidelayouts">
53
- {Object.keys(rest).map(layoutMode => (
53
+ {Object.keys(rest).map((layoutMode) => (
54
54
  <li
55
55
  key={layoutMode}
56
56
  className={
@@ -74,7 +74,7 @@ const StyleGuideLinks = ({ setSelectedState, states, headingLevel }) => {
74
74
  ? 'page'
75
75
  : null
76
76
  }
77
- onClick={e => {
77
+ onClick={(e) => {
78
78
  e.preventDefault()
79
79
  if (layoutMode === 'inline') {
80
80
  setTimeout(() => {
@@ -6,10 +6,19 @@ import {
6
6
  StoreProvider,
7
7
  createReduxStore,
8
8
  } from '@seamly/web-ui'
9
- import stateReducer from '../../ui/store/state-reducer'
9
+ import stateReducer from '../../domains/store/state-reducer'
10
10
  import { Reducer as formReducer } from '../../domains/forms'
11
11
  import { Reducer as translationsReducer } from '../../domains/translations'
12
- import { Reducer as i18nReducer } from '../../domains/i18n'
12
+ import {
13
+ Reducer as i18nReducer,
14
+ Actions as I18nActions,
15
+ } from '../../domains/i18n'
16
+ import { Reducer as interruptReducer } from '../../domains/interrupt'
17
+ import { Reducer as appReducer } from '../../domains/app'
18
+ import {
19
+ Reducer as configReducer,
20
+ Actions as ConfigActions,
21
+ } from '../../domains/config'
13
22
 
14
23
  const bareApi = {
15
24
  send: () => {},
@@ -19,24 +28,37 @@ const bareApi = {
19
28
  store: { get: () => {}, set: () => {} },
20
29
  }
21
30
 
22
- const SeamlyTestCore = ({ state, children }) => {
31
+ const SeamlyTestCore = ({ state, translations, children }) => {
23
32
  const liveMsgRef = useRef(() => {})
24
33
  const eventBusRef = useRef({ emit: () => {} })
34
+
25
35
  const store = useMemo(() => {
26
- const { translations: translationsSlice, ...restState } = state || {}
27
- return createReduxStore(
28
- {
36
+ const {
37
+ translations: translationsSlice,
38
+ interrupt: interruptSlice,
39
+ config: configSlice,
40
+ ...restState
41
+ } = state || {}
42
+ const newStore = createReduxStore({
43
+ reducers: {
29
44
  state: stateReducer,
45
+ [String(appReducer)]: appReducer,
46
+ [String(configReducer)]: configReducer,
30
47
  [String(formReducer)]: formReducer,
31
48
  [String(translationsReducer)]: translationsReducer,
32
49
  [String(i18nReducer)]: i18nReducer,
50
+ [String(interruptReducer)]: interruptReducer,
33
51
  },
34
- {
52
+ initialState: {
35
53
  state: restState,
36
- translations: translationsSlice,
54
+ [String(translationsReducer)]: translationsSlice,
55
+ [String(interruptReducer)]: interruptSlice,
37
56
  },
38
- )
39
- }, [state])
57
+ })
58
+ newStore.dispatch(ConfigActions.initialize(configSlice || {}))
59
+ newStore.dispatch(I18nActions.setLocaleResolve('en-GB', translations))
60
+ return newStore
61
+ }, [state, translations])
40
62
 
41
63
  return (
42
64
  state && (
@@ -42,7 +42,7 @@ export function addTranslationData(event) {
42
42
  ? 'NL - ' + event.payload.body.buttonText
43
43
  : undefined,
44
44
  choices: event.payload.body.choices
45
- ? event.payload.body.choices.map(choice => ({
45
+ ? event.payload.body.choices.map((choice) => ({
46
46
  ...choice,
47
47
  text: 'NL - ' + choice.text,
48
48
  }))