@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
@@ -12,12 +12,8 @@ const IdleDetachWarning = () => {
12
12
  const sendActivity = useSeamlyActivityEventHandler()
13
13
  const { emitEvent } = useSeamlyCommands()
14
14
 
15
- const {
16
- isActive,
17
- remaining,
18
- timer,
19
- endCountdown,
20
- } = useSeamlyIdleDetachCountdown()
15
+ const { isActive, remaining, timer, endCountdown } =
16
+ useSeamlyIdleDetachCountdown()
21
17
 
22
18
  const continueChat = () => {
23
19
  sendActivity()
@@ -20,7 +20,7 @@ const ResumeConversationPrompt = () => {
20
20
  return (
21
21
  <Prompt
22
22
  baseClassName="prompt"
23
- title={t('resumeConversationPrompt.title', currentAgentName)}
23
+ title={t('resumeConversationPrompt.title', { name: currentAgentName })}
24
24
  >
25
25
  <div className={className('prompt__options')}>
26
26
  <button
@@ -99,11 +99,11 @@ const InOutTransition = ({
99
99
 
100
100
  return (
101
101
  renderChildren &&
102
- toChildArray(children).map(child => {
102
+ toChildArray(children).map((child) => {
103
103
  const { className: childClassName = '' } = child.props
104
104
  const cleanClasses = childClassName
105
105
  .split(' ')
106
- .filter(cl => !transitionClassesArray.includes(cl))
106
+ .filter((cl) => !transitionClassesArray.includes(cl))
107
107
 
108
108
  return cloneElement(child, {
109
109
  className: [...cleanClasses, ...activeTransitionClasses].join(' '),
@@ -4,13 +4,13 @@ import { useI18n } from '../../../domains/i18n'
4
4
  import {
5
5
  useSeamlyActivityEventHandler,
6
6
  useSeamlyAppContainerClassNames,
7
- useSeamlyConfig,
8
7
  } from '../../hooks/seamly-hooks'
9
8
  import { className } from '../../../lib/css'
10
9
  import Icon from '../layout/icon'
10
+ import { useConfig } from '../../../domains/config'
11
11
 
12
12
  const Lightbox = ({ url, description, onClose: onCloseHandler }) => {
13
- const { zIndex } = useSeamlyConfig()
13
+ const { zIndex } = useConfig()
14
14
  const onActivityHandler = useSeamlyActivityEventHandler()
15
15
  const appContainerClassNames = useSeamlyAppContainerClassNames()
16
16
  const focusContainer = useRef(null)
@@ -18,7 +18,7 @@ const Lightbox = ({ url, description, onClose: onCloseHandler }) => {
18
18
 
19
19
  const classNames = ['modal', ...appContainerClassNames]
20
20
 
21
- const onFrameClickHandler = e => {
21
+ const onFrameClickHandler = (e) => {
22
22
  e.stopPropagation()
23
23
  }
24
24
 
@@ -28,7 +28,7 @@ const Lightbox = ({ url, description, onClose: onCloseHandler }) => {
28
28
 
29
29
  const style = zIndex ? { zIndex: zIndex + 1 } : undefined
30
30
 
31
- const getModalContent = onClose => (
31
+ const getModalContent = (onClose) => (
32
32
  <div
33
33
  className={className(classNames)}
34
34
  onClick={onFloatClickHandler}
@@ -42,7 +42,7 @@ const Modal = ({
42
42
 
43
43
  useEffect(() => {
44
44
  if (containerIsSet) {
45
- modalContainer.current.addEventListener('keydown', event => {
45
+ modalContainer.current.addEventListener('keydown', (event) => {
46
46
  if ((event.code && event.code === 'Escape') || event.keyCode === 27) {
47
47
  onClose()
48
48
  }
@@ -93,12 +93,12 @@ const Modal = ({
93
93
  return typeof children === 'function'
94
94
  ? children({
95
95
  onClose,
96
- modalRenderFn: els =>
96
+ modalRenderFn: (els) =>
97
97
  modalContainer.current && render(els, modalContainer.current),
98
98
  })
99
99
  : modalContainer.current &&
100
100
  render(
101
- toChildArray(children).map(child => {
101
+ toChildArray(children).map((child) => {
102
102
  child.props = { ...child.props, onClose }
103
103
  return child
104
104
  }),
@@ -1,7 +1,7 @@
1
1
  import { className } from '../../../lib/css'
2
2
  import { useFileUploads } from '../../hooks/seamly-hooks'
3
3
  import { useI18n } from '../../../domains/i18n'
4
- import Icon from '../layout/icon'
4
+ import Error from '../form-controls/error'
5
5
 
6
6
  const UploadProgress = () => {
7
7
  const { t } = useI18n()
@@ -19,24 +19,13 @@ const UploadProgress = () => {
19
19
  className={className('progress__text--percentage')}
20
20
  >{`${progress}%`}</span>
21
21
  </div>
22
- <div
23
- className={className('error')}
24
- aria-live="assertive"
25
- aria-atomic="true"
26
- >
27
- {error && (
28
- <span>
29
- <Icon name="error" size="16" />
30
- {error}
31
- </span>
32
- )}
33
- </div>
22
+ <Error error={error} />
34
23
  <progress
35
24
  className={className('progress__bar')}
36
25
  role="progressbar"
37
26
  aria-valuemin="0"
38
27
  aria-valuemax="100"
39
- aria-label={t('fileUpload.srProgressLabel', name)}
28
+ aria-label={t('fileUpload.srProgressLabel', { fileName: name })}
40
29
  max="100"
41
30
  aria-valuenow={progress}
42
31
  value={progress}
@@ -1,23 +1,12 @@
1
- import { useSeamlyConfig, useSeamlyStateContext } from './seamly-state-hooks'
1
+ import { useSeamlyStateContext } from './seamly-state-hooks'
2
2
  import { useElementFocusingById } from './focus-helper-hooks'
3
+ import { useConfig } from '../../domains/config'
3
4
 
4
5
  export const useSeamlyAppContainerClassNames = () => {
5
- const config = useSeamlyConfig()
6
- const { appContainerClassNames } = config
7
-
8
- if (!appContainerClassNames) {
9
- return []
10
- }
11
-
12
- switch (typeof config.appContainerClassNames) {
13
- case 'function':
14
- return config.appContainerClassNames(config)
15
- default:
16
- return config.appContainerClassNames
17
- }
6
+ return useConfig().appContainerClassNames
18
7
  }
19
8
 
20
- export const useSeamlyMessageContainerClassNames = event => {
9
+ export const useSeamlyMessageContainerClassNames = (event) => {
21
10
  const { fromClient } = event.payload
22
11
  const classNames = ['message']
23
12
 
@@ -52,7 +52,7 @@ export const useFileUploads = () => {
52
52
  const upload = useSeamlyFileUploadContext()
53
53
 
54
54
  const uploadFile = useCallback(
55
- file => {
55
+ (file) => {
56
56
  upload(file)
57
57
  },
58
58
  [upload],
@@ -66,7 +66,7 @@ export const useFileUploads = () => {
66
66
  uploadFile,
67
67
  clearUploads,
68
68
  currentUploads,
69
- isUploading: currentUploads.some(file => file.uploading),
70
- isComplete: currentUploads.every(file => file.complete),
69
+ isUploading: currentUploads.some((file) => file.uploading),
70
+ isComplete: currentUploads.every((file) => file.complete),
71
71
  }
72
72
  }
@@ -9,7 +9,7 @@ import { seamlyActions } from '../utils/seamly-utils'
9
9
 
10
10
  const { SET_SEAMLY_CONTAINER_ELEMENT } = seamlyActions
11
11
 
12
- const focusWithRaf = el => {
12
+ const focusWithRaf = (el) => {
13
13
  requestAnimationFrame(() => {
14
14
  requestAnimationFrame(() => {
15
15
  const focusEl = typeof el === 'string' ? document.getElementById(el) : el
@@ -24,7 +24,7 @@ export const useSeamlyContainerElement = () => {
24
24
  const dispatch = useSeamlyDispatchContext()
25
25
 
26
26
  const setSeamlyContainerElement = useCallback(
27
- element => {
27
+ (element) => {
28
28
  dispatch({ type: SET_SEAMLY_CONTAINER_ELEMENT, element })
29
29
  },
30
30
  [dispatch],
@@ -33,7 +33,7 @@ export const useSeamlyContainerElement = () => {
33
33
  return [seamlyContainerElement, setSeamlyContainerElement]
34
34
  }
35
35
 
36
- export const useElementFocusingById = elementId =>
36
+ export const useElementFocusingById = (elementId) =>
37
37
  useCallback(() => {
38
38
  focusWithRaf(elementId)
39
39
  }, [elementId])
@@ -49,7 +49,7 @@ export const useFocusIfSeamlyContainedFocus = () => {
49
49
 
50
50
  containerElementRef.current = seamlyContainerElement
51
51
 
52
- return useCallback(elementToFocus => {
52
+ return useCallback((elementToFocus) => {
53
53
  const focusFn = () => {
54
54
  focusWithRaf(elementToFocus)
55
55
  }
@@ -8,7 +8,7 @@ export const useSeamlyLiveRegionContext = () =>
8
8
  export const useLiveRegion = () => {
9
9
  const sendMessage = useSeamlyLiveRegionContext()
10
10
  const sendPolite = useCallback(
11
- messageText => {
11
+ (messageText) => {
12
12
  sendMessage({
13
13
  ariaLive: ariaLiveLevels.polite,
14
14
  messageText,
@@ -17,7 +17,7 @@ export const useLiveRegion = () => {
17
17
  [sendMessage],
18
18
  )
19
19
  const sendAssertive = useCallback(
20
- messageText => {
20
+ (messageText) => {
21
21
  sendMessage({
22
22
  ariaLive: ariaLiveLevels.assertive,
23
23
  messageText,
@@ -22,9 +22,3 @@ export const useSeamlyHasConversation = () => {
22
22
  const url = useSeamlyConversationUrl()
23
23
  return !!url
24
24
  }
25
-
26
- export const useSeamlyHasUserResponded = () => {
27
- const { get } = useSeamlyObjectStore()
28
-
29
- return get ? !!get('userResponded') : false
30
- }
@@ -1,9 +1,10 @@
1
1
  import { useRef, useCallback, useEffect } from 'preact/hooks'
2
2
  import { seamlyActions, actionTypes } from '../utils/seamly-utils'
3
- import { useSeamlyStateContext, useSeamlyConfig } from './seamly-state-hooks'
3
+ import { useSeamlyStateContext } from './seamly-state-hooks'
4
4
  import useSeamlyDispatchContext from './use-seamly-dispatch'
5
5
  import { useSeamlyOptions } from './seamly-option-hooks'
6
6
  import useSeamlyCommands from './use-seamly-commands'
7
+ import { typingTimeout } from '../../config'
7
8
 
8
9
  const {
9
10
  SET_BLOCK_AUTO_ENTRY_SWITCH,
@@ -13,19 +14,18 @@ const {
13
14
 
14
15
  export const useSeamlyTyping = () => {
15
16
  const { sendAction } = useSeamlyCommands()
16
- const { typing: typingConfig } = useSeamlyConfig()
17
17
  const { features } = useSeamlyOptions()
18
18
  const { typingPeekahead } = features || {}
19
- const typingTimeout = useRef(null)
20
- const sendEndTypingTimeout = useRef(null)
19
+ const typingTimerId = useRef(null)
20
+ const sendEndTypingTimerId = useRef(null)
21
21
  const isTyping = useRef(false)
22
- const typingInterval = useRef(null)
22
+ const typingIntervalId = useRef(null)
23
23
 
24
24
  useEffect(() => {
25
25
  return () => {
26
- clearInterval(typingInterval.current)
27
- clearTimeout(typingTimeout.current)
28
- clearTimeout(sendEndTypingTimeout.current)
26
+ clearInterval(typingIntervalId.current)
27
+ clearTimeout(typingTimerId.current)
28
+ clearTimeout(sendEndTypingTimerId.current)
29
29
  }
30
30
  }, [])
31
31
 
@@ -43,37 +43,34 @@ export const useSeamlyTyping = () => {
43
43
  })
44
44
  }
45
45
 
46
- return e => {
46
+ return (e) => {
47
47
  if ((e.code && e.code === 'Enter') || e.keyCode === 13) {
48
48
  return
49
49
  }
50
- if (!typingConfig) {
51
- return
52
- }
53
50
 
54
51
  isTyping.current = true
55
- if (!typingInterval.current) {
52
+ if (!typingIntervalId.current) {
56
53
  sendTypingState(true, e.target.value)
57
- typingInterval.current = setInterval(() => {
54
+ typingIntervalId.current = setInterval(() => {
58
55
  if (!isTyping.current) {
59
- clearInterval(typingInterval.current)
60
- typingInterval.current = null
56
+ clearInterval(typingIntervalId.current)
57
+ typingIntervalId.current = null
61
58
  } else if (typingPeekahead && typingPeekahead.enabled) {
62
59
  sendTypingState(true, e.target.value)
63
60
  }
64
- }, typingConfig.timeout)
61
+ }, typingTimeout)
65
62
  }
66
63
 
67
- clearTimeout(typingTimeout.current)
68
- clearTimeout(sendEndTypingTimeout.current)
64
+ clearTimeout(typingTimerId.current)
65
+ clearTimeout(sendEndTypingTimerId.current)
69
66
 
70
- typingTimeout.current = setTimeout(() => {
67
+ typingTimerId.current = setTimeout(() => {
71
68
  isTyping.current = false
72
69
  }, 300)
73
70
 
74
- sendEndTypingTimeout.current = setTimeout(() => {
71
+ sendEndTypingTimerId.current = setTimeout(() => {
75
72
  sendTypingState(false, e.target.value)
76
- }, typingConfig.timeout)
73
+ }, typingTimeout)
77
74
  }
78
75
  }
79
76
 
@@ -91,21 +88,21 @@ export const useSeamlyEntry = () => {
91
88
  const activeEntryOptions = entryOptions[activeEntry] || {}
92
89
 
93
90
  const setBlockAutoEntrySwitch = useCallback(
94
- value => {
91
+ (value) => {
95
92
  dispatch({ type: SET_BLOCK_AUTO_ENTRY_SWITCH, value })
96
93
  },
97
94
  [dispatch],
98
95
  )
99
96
 
100
97
  const setActiveEntryType = useCallback(
101
- entryType => {
98
+ (entryType) => {
102
99
  dispatch({ type: SET_ACTIVE_ENTRY_TYPE, entryType })
103
100
  },
104
101
  [dispatch],
105
102
  )
106
103
 
107
104
  const setUserEntryType = useCallback(
108
- entryType => {
105
+ (entryType) => {
109
106
  dispatch({ type: SET_USER_ENTRY_TYPE, entryType })
110
107
  },
111
108
  [dispatch],
@@ -9,8 +9,6 @@ export {
9
9
  useLastMessageEventId,
10
10
  useEntryTextLimit,
11
11
  useSeamlyCurrentAgent,
12
- useSeamlyConfig,
13
- useSeamlyDisclaimerState,
14
12
  useEvents,
15
13
  useSeamlyHeaderData,
16
14
  useSeamlyIsHistoryLoaded,
@@ -26,7 +24,6 @@ export {
26
24
  export {
27
25
  useSeamlyApiContext,
28
26
  useSeamlyConversationUrl,
29
- useSeamlyHasUserResponded,
30
27
  } from './seamly-api-hooks'
31
28
  export { default as useSeamlyDispatchContext } from './use-seamly-dispatch'
32
29
  export {
@@ -35,7 +32,6 @@ export {
35
32
  useCobrowsingContainer,
36
33
  } from './component-helper-hooks'
37
34
  export { useSeamlyOptions, useOptionButton } from './seamly-option-hooks'
38
- export { default as useSeamlyInterrupt } from './use-seamly-interrupt'
39
35
  export { useFileUploadMeta, useFileUploads } from './file-upload-hooks'
40
36
  export { default as useSeamlyCommands } from './use-seamly-commands'
41
37
  export { useLiveRegion, useSeamlyLiveRegionContext } from './live-region-hooks'
@@ -68,12 +64,9 @@ export const useSeamlyEventStream = (nextFn, filterFn) => {
68
64
  useEffect(() => {
69
65
  if (api.stream) {
70
66
  if (filterFn) {
71
- api
72
- .stream()
73
- .filter(filterFn)
74
- .subscribe({
75
- next: nextFn,
76
- })
67
+ api.stream().filter(filterFn).subscribe({
68
+ next: nextFn,
69
+ })
77
70
  } else {
78
71
  api.stream().subscribe({
79
72
  next: nextFn,
@@ -24,10 +24,10 @@ export const useSeamlyOptions = () => {
24
24
  const optionsObj = { cobrowsing, sendTranscript }
25
25
 
26
26
  const menuOptions = Object.keys(optionsObj)
27
- .filter(key => {
27
+ .filter((key) => {
28
28
  return optionsObj[key]
29
29
  })
30
- .map(option => ({
30
+ .map((option) => ({
31
31
  name: option,
32
32
  title: t(`options.${option}.menuTitle`),
33
33
  available: optionsObj[option].enabled,
@@ -44,7 +44,7 @@ export const useSeamlyOptions = () => {
44
44
  }, [get, dispatch])
45
45
 
46
46
  const setUserSelectedOptions = useCallback(
47
- optionValues => {
47
+ (optionValues) => {
48
48
  dispatch({ type: SET_USER_SELECTED_OPTIONS, options: optionValues })
49
49
  set('options', optionValues)
50
50
  },
@@ -63,7 +63,7 @@ export const useSeamlyOptions = () => {
63
63
  [dispatch, get, set],
64
64
  )
65
65
 
66
- const showOption = optionName => {
66
+ const showOption = (optionName) => {
67
67
  dispatch({ type: SHOW_OPTION, optionName })
68
68
  }
69
69
 
@@ -1,19 +1,14 @@
1
1
  import { createSelector } from 'reselect'
2
2
  import { useSelector } from '../../domains/redux'
3
3
  import { microsecondsToMilliseconds } from '../utils/general-utils'
4
+ import { Selectors as ConfigSelectors, useConfig } from '../../domains/config'
4
5
 
5
- export const selectState = state => state.state
6
+ export const selectState = (state) => state.state
6
7
  export const useSeamlyStateContext = () => useSelector(selectState)
7
8
 
8
- export const selectConfig = createSelector(
9
- selectState,
10
- ({ config }) => config || {},
11
- )
12
- export const useSeamlyConfig = () => useSelector(selectConfig)
13
-
14
9
  export const selectEvents = createSelector(
15
10
  selectState,
16
- selectConfig,
11
+ ConfigSelectors.selectConfig,
17
12
  ({ events }, config) => {
18
13
  const { enabled, threshold } = config?.messages?.timeIndicator ?? {}
19
14
  if (!enabled) {
@@ -53,13 +48,13 @@ export const useSeamlyUnreadCount = () => useSeamlyStateContext().unreadEvents
53
48
 
54
49
  export const useSkiplink = () => useSeamlyStateContext().skiplinkTargetId
55
50
 
56
- export const useSeamlyParticipant = participantId =>
51
+ export const useSeamlyParticipant = (participantId) =>
57
52
  useSeamlyStateContext().participantInfo.participants[participantId]
58
53
 
59
54
  export const useSeamlyServiceInfo = () => useSeamlyStateContext().serviceInfo
60
55
 
61
- const selectLastMessageEventId = createSelector(selectEvents, events => {
62
- const filteredEvents = events.filter(event => event.type === 'message')
56
+ const selectLastMessageEventId = createSelector(selectEvents, (events) => {
57
+ const filteredEvents = events.filter((event) => event.type === 'message')
63
58
  return filteredEvents[filteredEvents.length - 1]?.payload.id
64
59
  })
65
60
  export const useLastMessageEventId = () => useSelector(selectLastMessageEventId)
@@ -67,16 +62,13 @@ export const useLastMessageEventId = () => useSelector(selectLastMessageEventId)
67
62
  export const useSeamlyIsHistoryLoaded = () =>
68
63
  useSeamlyStateContext().historyLoaded
69
64
 
70
- export const useSeamlyDisclaimerState = () =>
71
- useSeamlyStateContext().showDisclaimer
72
-
73
65
  export const useSeamlyCurrentAgent = () => {
74
66
  const { participants, currentAgent } = useSeamlyStateContext().participantInfo
75
67
 
76
68
  return currentAgent ? participants[currentAgent] : null
77
69
  }
78
70
 
79
- export const useSeamlyServiceData = key =>
71
+ export const useSeamlyServiceData = (key) =>
80
72
  useSeamlyStateContext().serviceData[key]
81
73
 
82
74
  export const useEntryTextLimit = () => {
@@ -95,7 +87,7 @@ export const useEntryTextLimit = () => {
95
87
  }
96
88
 
97
89
  export const useSeamlyLayoutMode = () => {
98
- const { layoutMode } = useSeamlyConfig()
90
+ const { layoutMode } = useConfig()
99
91
 
100
92
  return {
101
93
  isInline: layoutMode === 'inline',
@@ -2,7 +2,7 @@ import { useContext } from 'preact/hooks'
2
2
  import ComponentContext from '../components/conversation/component-context'
3
3
  import { payloadTypes } from '../utils/seamly-utils'
4
4
 
5
- const useEventComponentMapping = event => {
5
+ const useEventComponentMapping = (event) => {
6
6
  const components = useContext(ComponentContext)
7
7
 
8
8
  let SubComponent = null
@@ -88,6 +88,7 @@ const useSeamlyChat = () => {
88
88
  // they had been connected before.
89
89
  // We also keep track of whether connect was called before to avoid
90
90
  // multiple in-flight connection processes.
91
+
91
92
  if (
92
93
  (!isOpen && !hasConversation) ||
93
94
  connectCalled.current ||