@seamly/web-ui 18.1.1 → 18.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/lib/index.debug.js +286 -99
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +84 -16
- package/build/dist/lib/index.js +4104 -3887
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +4351 -4084
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +746 -641
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +1 -1
- package/build/dist/lib/utils.js +0 -1
- package/build/dist/lib/utils.min.js +1 -1
- package/build/dist/translations/de-informal.js +0 -1
- package/build/dist/translations/de-informal.min.js +1 -1
- package/build/dist/translations/en.js +0 -1
- package/build/dist/translations/en.min.js +1 -1
- package/build/dist/translations/es-informal.js +0 -1
- package/build/dist/translations/es-informal.min.js +1 -1
- package/build/dist/translations/nl-formal.js +0 -1
- package/build/dist/translations/nl-formal.min.js +1 -1
- package/build/dist/translations/nl-informal.js +0 -1
- package/build/dist/translations/nl-informal.min.js +1 -1
- package/package.json +4 -2
- package/src/javascripts/api/index.js +9 -9
- package/src/javascripts/api/producer.js +8 -8
- package/src/javascripts/config.js +9 -11
- package/src/javascripts/domains/app/actions.js +25 -0
- package/src/javascripts/domains/app/index.js +3 -0
- package/src/javascripts/domains/config/actions.js +6 -0
- package/src/javascripts/domains/config/hooks.js +6 -0
- package/src/javascripts/domains/config/index.js +8 -0
- package/src/javascripts/domains/config/middleware.js +26 -0
- package/src/javascripts/domains/config/reducer.js +74 -0
- package/src/javascripts/domains/config/selectors.js +23 -0
- package/src/javascripts/domains/forms/actions.js +1 -1
- package/src/javascripts/domains/forms/hooks.js +10 -14
- package/src/javascripts/domains/forms/provider.js +4 -6
- package/src/javascripts/domains/forms/selectors.js +3 -3
- package/src/javascripts/domains/i18n/index.js +9 -5
- package/src/javascripts/domains/interrupt/actions.js +6 -0
- package/src/javascripts/domains/interrupt/hooks.js +29 -0
- package/src/javascripts/domains/interrupt/index.js +9 -0
- package/src/javascripts/domains/interrupt/middleware.js +30 -0
- package/src/javascripts/domains/interrupt/reducer.js +22 -0
- package/src/javascripts/domains/interrupt/selectors.js +5 -0
- package/src/javascripts/domains/options/index.js +1 -0
- package/src/javascripts/domains/options/middleware.js +35 -0
- package/src/javascripts/domains/redux/create-redux-store.js +14 -6
- package/src/javascripts/domains/redux/hooks.js +2 -2
- package/src/javascripts/domains/redux/index.js +2 -1
- package/src/javascripts/domains/redux/provider.js +5 -0
- package/src/javascripts/domains/store/index.js +38 -0
- package/src/javascripts/{ui → domains}/store/state-reducer.js +4 -7
- package/src/javascripts/domains/translations/actions.js +3 -3
- package/src/javascripts/domains/translations/components/chat-status.js +6 -12
- package/src/javascripts/domains/translations/components/options-button.js +3 -3
- package/src/javascripts/domains/translations/components/options-dialog/form.js +2 -2
- package/src/javascripts/domains/translations/components/options-dialog/index.js +2 -5
- package/src/javascripts/domains/translations/hooks.js +1 -1
- package/src/javascripts/domains/translations/reducer.js +2 -2
- package/src/javascripts/domains/translations/selectors.js +2 -2
- package/src/javascripts/index.js +17 -5
- package/src/javascripts/lib/css.js +5 -5
- package/src/javascripts/lib/engine/index.js +38 -11
- package/src/javascripts/lib/external-api/index.js +6 -6
- package/src/javascripts/lib/i18n.js +2 -2
- package/src/javascripts/lib/parse-body.js +1 -1
- package/src/javascripts/lib/redux-helpers/index.js +18 -4
- package/src/javascripts/lib/split-url-params.js +2 -2
- package/src/javascripts/lib/store/providers/app-storage.js +1 -1
- package/src/javascripts/lib/store/providers/cookie-storage.js +1 -1
- package/src/javascripts/package/utils.js +0 -1
- package/src/javascripts/style-guide/components/app.js +5 -12
- package/src/javascripts/style-guide/components/links.js +6 -6
- package/src/javascripts/style-guide/components/static-core.js +23 -7
- package/src/javascripts/style-guide/state-helpers/index.js +1 -1
- package/src/javascripts/style-guide/states.js +27 -67
- package/src/javascripts/style-guide/style-guide-engine.js +1 -1
- package/src/javascripts/ui/components/chat-app.js +2 -2
- package/src/javascripts/ui/components/conversation/component-filter.js +2 -2
- package/src/javascripts/ui/components/conversation/conversation.js +2 -2
- package/src/javascripts/ui/components/conversation/event/card-component.js +29 -4
- package/src/javascripts/ui/components/conversation/event/carousel-component/components/pagination.js +2 -2
- package/src/javascripts/ui/components/conversation/event/carousel-component/index.js +4 -3
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +2 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +2 -2
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +11 -6
- package/src/javascripts/ui/components/conversation/event/cta.js +1 -6
- package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +1 -1
- package/src/javascripts/ui/components/conversation/event/event-participant.js +3 -5
- package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js +2 -2
- package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +3 -3
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +3 -3
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -2
- package/src/javascripts/ui/components/conversation/event/upload.js +12 -27
- package/src/javascripts/ui/components/conversation/message-container.js +4 -6
- package/src/javascripts/ui/components/core/seamly-activity-monitor.js +4 -5
- package/src/javascripts/ui/components/core/seamly-core.js +6 -7
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +16 -17
- package/src/javascripts/ui/components/core/seamly-file-upload.js +5 -6
- package/src/javascripts/ui/components/core/seamly-idle-detach-counter.js +2 -6
- package/src/javascripts/ui/components/core/seamly-initializer.js +7 -60
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +10 -10
- package/src/javascripts/ui/components/core/seamly-live-region.js +1 -1
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +1 -1
- package/src/javascripts/ui/components/core/seamly-read-state.js +2 -2
- package/src/javascripts/ui/components/entry/entry-container.js +7 -10
- package/src/javascripts/ui/components/entry/toggle-button.js +24 -10
- package/src/javascripts/ui/components/entry/upload/index.js +4 -11
- package/src/javascripts/ui/components/faq/faq.js +4 -4
- package/src/javascripts/ui/components/form-controls/error.js +22 -0
- package/src/javascripts/ui/components/form-controls/file-input.js +3 -9
- package/src/javascripts/ui/components/form-controls/select.js +1 -1
- package/src/javascripts/ui/components/form-controls/wrapper.js +2 -9
- package/src/javascripts/ui/components/layout/agent-info.js +4 -4
- package/src/javascripts/ui/components/layout/app-frame.js +5 -5
- package/src/javascripts/ui/components/layout/chat-frame.js +3 -5
- package/src/javascripts/ui/components/layout/header.js +4 -18
- package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
- package/src/javascripts/ui/components/options/cobrowsing.js +3 -7
- package/src/javascripts/ui/components/options/options-button.js +9 -13
- package/src/javascripts/ui/components/options/options-frame.js +1 -1
- package/src/javascripts/ui/components/options/transcript/index.js +2 -2
- package/src/javascripts/ui/components/options/transcript/transcript-form.js +1 -1
- package/src/javascripts/ui/components/warnings/cobrowsing-active-frame.js +3 -6
- package/src/javascripts/ui/components/warnings/idle-detach-warning.js +2 -6
- package/src/javascripts/ui/components/widgets/in-out-transition.js +2 -2
- package/src/javascripts/ui/components/widgets/lightbox.js +4 -4
- package/src/javascripts/ui/components/widgets/modal.js +3 -3
- package/src/javascripts/ui/components/widgets/upload-progress.js +2 -13
- package/src/javascripts/ui/hooks/component-helper-hooks.js +4 -15
- package/src/javascripts/ui/hooks/file-upload-hooks.js +3 -3
- package/src/javascripts/ui/hooks/focus-helper-hooks.js +4 -4
- package/src/javascripts/ui/hooks/live-region-hooks.js +2 -2
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +7 -6
- package/src/javascripts/ui/hooks/seamly-hooks.js +3 -9
- package/src/javascripts/ui/hooks/seamly-option-hooks.js +4 -4
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +8 -16
- package/src/javascripts/ui/hooks/use-event-component-mapping.js +1 -1
- package/src/javascripts/ui/hooks/use-seamly-chat.js +1 -0
- package/src/javascripts/ui/hooks/use-seamly-commands.js +27 -49
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +3 -3
- package/src/javascripts/ui/hooks/use-seamly-stored-visibility.js +3 -3
- package/src/javascripts/ui/hooks/use-seamly-visibility.js +3 -3
- package/src/javascripts/ui/hooks/utility-hooks.js +2 -2
- package/src/javascripts/ui/utils/form-utils.js +3 -3
- package/src/javascripts/ui/utils/general-utils.js +17 -11
- package/src/javascripts/ui/utils/seamly-utils.js +15 -83
- package/src/javascripts/ui/utils/validations.js +10 -7
- package/src/stylesheets/5-components/_card.scss +0 -1
- package/src/stylesheets/5-components/_choice-prompt.scss +5 -0
- package/src/stylesheets/5-components/_message.scss +10 -0
- package/src/stylesheets/5-components/_options.scss +3 -2
- package/translations/de-informal.js +0 -2
- package/translations/en.js +0 -2
- package/translations/es-informal.js +0 -2
- package/translations/nl-formal.js +0 -2
- package/translations/nl-informal.js +0 -2
- package/webpack/config.common.js +3 -3
- package/webpack/config.package.js +4 -4
- package/webpack/config.site.js +8 -6
- package/CHANGELOG.md +0 -551
- package/src/javascripts/ui/components/core/seamly-api.js +0 -44
- package/src/javascripts/ui/hooks/use-seamly-interrupt.js +0 -62
- package/src/javascripts/ui/store/index.js +0 -37
|
@@ -13,7 +13,7 @@ import { useI18n } from '../../../../domains/i18n'
|
|
|
13
13
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
14
14
|
import MessageContainer from '../message-container'
|
|
15
15
|
|
|
16
|
-
export const useChoicePrompt = event => {
|
|
16
|
+
export const useChoicePrompt = (event) => {
|
|
17
17
|
const { payload } = event
|
|
18
18
|
const [showOptions, setShowOptions] = useState(false)
|
|
19
19
|
const { sendAction, addMessageBubble, addDivider } = useSeamlyCommands()
|
|
@@ -45,7 +45,7 @@ export const useChoicePrompt = event => {
|
|
|
45
45
|
setShowOptions(payload.id === lastEventId)
|
|
46
46
|
}, [payload, lastEventId])
|
|
47
47
|
|
|
48
|
-
const onChoiceClickHandler = choice => {
|
|
48
|
+
const onChoiceClickHandler = (choice) => {
|
|
49
49
|
if (chooseAgain) {
|
|
50
50
|
addDivider('new_topic')
|
|
51
51
|
}
|
|
@@ -63,7 +63,7 @@ export const useChoicePrompt = event => {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
const onChooseAgainClickHandler = () => {
|
|
66
|
-
setShowOptions(s => !s)
|
|
66
|
+
setShowOptions((s) => !s)
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
return {
|
|
@@ -91,7 +91,7 @@ const ChoicePrompt = ({ event, children, ...props }) => {
|
|
|
91
91
|
|
|
92
92
|
return (
|
|
93
93
|
<>
|
|
94
|
-
{toChildArray(children).map(child => {
|
|
94
|
+
{toChildArray(children).map((child) => {
|
|
95
95
|
child.props = {
|
|
96
96
|
...child.props,
|
|
97
97
|
event: subEvent,
|
|
@@ -126,8 +126,13 @@ const ChoicePrompt = ({ event, children, ...props }) => {
|
|
|
126
126
|
{...props}
|
|
127
127
|
>
|
|
128
128
|
<ul className={className('choice-prompt', 'choice-prompt--many')}>
|
|
129
|
-
{body.choices.map(choice => (
|
|
130
|
-
<li
|
|
129
|
+
{body.choices.map((choice) => (
|
|
130
|
+
<li
|
|
131
|
+
key={choice.id}
|
|
132
|
+
className={className('choice-prompt__item', {
|
|
133
|
+
[`choice-prompt__item--${choice.category}`]: choice.category,
|
|
134
|
+
})}
|
|
135
|
+
>
|
|
131
136
|
<button
|
|
132
137
|
type="button"
|
|
133
138
|
className={className('button', 'button--primary')}
|
|
@@ -3,7 +3,6 @@ import { className } from '../../../../lib/css'
|
|
|
3
3
|
import parseBody from '../../../../lib/parse-body'
|
|
4
4
|
import { useGeneratedId, useSeamlyCommands } from '../../../hooks/seamly-hooks'
|
|
5
5
|
import useEventLinkClickHandler from './hooks/use-event-link-click-handler'
|
|
6
|
-
import useTextRendering from './hooks/use-text-rendering'
|
|
7
6
|
import { actionTypes } from '../../../utils/seamly-utils'
|
|
8
7
|
import MessageContainer from '../message-container'
|
|
9
8
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
@@ -14,10 +13,6 @@ const Cta = ({ event }) => {
|
|
|
14
13
|
const { emitEvent } = useSeamlyCommands()
|
|
15
14
|
|
|
16
15
|
const descriptionId = useGeneratedId()
|
|
17
|
-
const eventBody = useTextRendering({
|
|
18
|
-
text: parseBody(body.description),
|
|
19
|
-
variables: body.variables,
|
|
20
|
-
})
|
|
21
16
|
|
|
22
17
|
const onClickHandler = useCallback(
|
|
23
18
|
() =>
|
|
@@ -36,7 +31,7 @@ const Cta = ({ event }) => {
|
|
|
36
31
|
<div
|
|
37
32
|
className={className('cta__content')}
|
|
38
33
|
id={descriptionId}
|
|
39
|
-
dangerouslySetInnerHTML={{ __html:
|
|
34
|
+
dangerouslySetInnerHTML={{ __html: parseBody(body.description) }}
|
|
40
35
|
onClick={eventClick}
|
|
41
36
|
/>
|
|
42
37
|
<a
|
package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js
CHANGED
|
@@ -10,7 +10,7 @@ const NewTranslationDivider = ({ event }) => {
|
|
|
10
10
|
const { enableTranslations, languages } = useTranslations()
|
|
11
11
|
|
|
12
12
|
const languageName = useMemo(() => {
|
|
13
|
-
return languages?.find(lang => lang.locale === translationLocale)
|
|
13
|
+
return languages?.find((lang) => lang.locale === translationLocale)
|
|
14
14
|
?.nativeName
|
|
15
15
|
}, [languages, translationLocale])
|
|
16
16
|
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useSeamlyConfig,
|
|
3
|
-
useSeamlyParticipant,
|
|
4
|
-
} from '../../../hooks/seamly-hooks'
|
|
1
|
+
import { useSeamlyParticipant } from '../../../hooks/seamly-hooks'
|
|
5
2
|
import { className } from '../../../../lib/css'
|
|
3
|
+
import { useConfig } from '../../../../domains/config'
|
|
6
4
|
|
|
7
5
|
const EventParticipant = ({ eventPayload }) => {
|
|
8
6
|
const { fromClient, participant: participantId } = eventPayload
|
|
9
7
|
const participant = useSeamlyParticipant(participantId) || {}
|
|
10
|
-
const { messages, defaults } =
|
|
8
|
+
const { messages, defaults } = useConfig()
|
|
11
9
|
|
|
12
10
|
const participantName = participant && participant.name
|
|
13
11
|
const { showAvatar, showName } = messages[fromClient ? 'user' : 'agent'] || {}
|
package/src/javascripts/ui/components/conversation/event/hooks/use-event-link-click-handler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { actionTypes } from '../../../../utils/seamly-utils'
|
|
2
2
|
import { useSeamlyCommands } from '../../../../hooks/seamly-hooks'
|
|
3
3
|
|
|
4
|
-
const useEventLinkClickHandler = eventId => {
|
|
4
|
+
const useEventLinkClickHandler = (eventId) => {
|
|
5
5
|
const { sendAction } = useSeamlyCommands()
|
|
6
6
|
|
|
7
|
-
const eventClick = e => {
|
|
7
|
+
const eventClick = (e) => {
|
|
8
8
|
if (e.target && e.target.dataset.linkId) {
|
|
9
9
|
sendAction({
|
|
10
10
|
type: actionTypes.navigate,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { useI18n } from '../../../../../domains/i18n'
|
|
2
|
-
import { useSeamlyConfig } from '../../../../hooks/seamly-hooks'
|
|
3
2
|
import { getRelativeDate } from '../../../../utils/general-utils'
|
|
3
|
+
import { useConfig } from '../../../../../domains/config'
|
|
4
4
|
|
|
5
5
|
const dateFormatOptions = { month: 'long', day: 'numeric', year: 'numeric' }
|
|
6
6
|
const timeFormatOptions = { hour: 'numeric', minute: 'numeric' }
|
|
7
7
|
|
|
8
|
-
export const useFormattedDate = date => {
|
|
8
|
+
export const useFormattedDate = (date) => {
|
|
9
9
|
const { t } = useI18n()
|
|
10
|
-
const config =
|
|
10
|
+
const config = useConfig()
|
|
11
11
|
const locale = config?.context?.locale ?? []
|
|
12
12
|
const eventDate = new Date(date)
|
|
13
13
|
const currentDate = new Date()
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useMemo } from 'preact/hooks'
|
|
2
2
|
import Mustache from 'mustache'
|
|
3
3
|
|
|
4
|
-
Mustache.escape = function(escapeText) {
|
|
4
|
+
Mustache.escape = function (escapeText) {
|
|
5
5
|
return escapeText
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
const parseLinkVariable = variable => {
|
|
8
|
+
const parseLinkVariable = (variable) => {
|
|
9
9
|
return `<a href='${variable.url}' data-link-id='${variable.id}' ${
|
|
10
10
|
variable.newTab ? 'target="_blank"' : ''
|
|
11
11
|
}>${variable.name}</a>`
|
|
@@ -26,7 +26,7 @@ export function parseRichtText(text, variables = {}) {
|
|
|
26
26
|
|
|
27
27
|
// Disable escaping as we'll be generating HTML
|
|
28
28
|
const oldEscape = Mustache.escape
|
|
29
|
-
Mustache.escape = function(escapeText) {
|
|
29
|
+
Mustache.escape = function (escapeText) {
|
|
30
30
|
return escapeText
|
|
31
31
|
}
|
|
32
32
|
const output = Mustache.render(text, view)
|
|
@@ -2,11 +2,11 @@ import { useMemo } from 'preact/hooks'
|
|
|
2
2
|
import Mustache from 'mustache'
|
|
3
3
|
import parseBody from '../../../../lib/parse-body'
|
|
4
4
|
import EventDivider from '../event-divider'
|
|
5
|
-
import { useSeamlyConfig } from '../../../hooks/seamly-hooks'
|
|
6
5
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
6
|
+
import { useConfig } from '../../../../domains/config'
|
|
7
7
|
|
|
8
8
|
const Participant = ({ event }) => {
|
|
9
|
-
const { agentIcon } =
|
|
9
|
+
const { agentIcon } = useConfig().defaults || {}
|
|
10
10
|
|
|
11
11
|
const { participant } = event.payload
|
|
12
12
|
const [introduction] = useTranslatedEventData(event)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { useMemo } from 'preact/hooks'
|
|
1
2
|
import { className } from '../../../../lib/css'
|
|
2
3
|
import Icon from '../../layout/icon'
|
|
3
4
|
import { useI18n } from '../../../../domains/i18n'
|
|
4
|
-
import { microsecondsToMilliseconds } from '../../../utils/general-utils'
|
|
5
5
|
import MessageContainer from '../message-container'
|
|
6
6
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
7
7
|
|
|
@@ -18,40 +18,25 @@ const Upload = ({ event, ...props }) => {
|
|
|
18
18
|
const { t } = useI18n()
|
|
19
19
|
const [body] = useTranslatedEventData(event)
|
|
20
20
|
const { fromClient } = event.payload
|
|
21
|
-
const {
|
|
22
|
-
const deleted =
|
|
23
|
-
url && !!deleteAt && microsecondsToMilliseconds(deleteAt) < Date.now()
|
|
21
|
+
const { filename, url } = body
|
|
24
22
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} else {
|
|
33
|
-
return t('fileUpload.srFileUploadedText', filename)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
23
|
+
const srText = useMemo(
|
|
24
|
+
() =>
|
|
25
|
+
url
|
|
26
|
+
? t('fileUpload.srFileDownloadText', filename)
|
|
27
|
+
: t('fileUpload.srFileUploadedText', filename),
|
|
28
|
+
[url, filename, t],
|
|
29
|
+
)
|
|
36
30
|
|
|
37
31
|
return (
|
|
38
|
-
<MessageContainer
|
|
39
|
-
event={event}
|
|
40
|
-
type="upload"
|
|
41
|
-
modifiers={deleted && 'deleted'}
|
|
42
|
-
info={deleted ? t('fileUpload.fileUnavailableText') : undefined}
|
|
43
|
-
{...props}
|
|
44
|
-
>
|
|
32
|
+
<MessageContainer event={event} type="upload" {...props}>
|
|
45
33
|
<div className={className('download')}>
|
|
46
34
|
<Icon name="download" size="16" />
|
|
47
|
-
<UploadContent
|
|
48
|
-
url={!deleted && url}
|
|
49
|
-
target={!fromClient ? '_blank' : undefined}
|
|
50
|
-
>
|
|
35
|
+
<UploadContent url={url} target={!fromClient ? '_blank' : undefined}>
|
|
51
36
|
<span aria-hidden="true" className={className('file-download')}>
|
|
52
37
|
{filename}
|
|
53
38
|
</span>
|
|
54
|
-
<span className={className('visually-hidden')}>{
|
|
39
|
+
<span className={className('visually-hidden')}>{srText}</span>
|
|
55
40
|
</UploadContent>
|
|
56
41
|
</div>
|
|
57
42
|
</MessageContainer>
|
|
@@ -18,10 +18,8 @@ function MessageContainer({
|
|
|
18
18
|
const classNames = useSeamlyMessageContainerClassNames(event)
|
|
19
19
|
const { t } = useI18n()
|
|
20
20
|
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
-
{ hasTranslation, isTranslated, toggleTranslation, locale },
|
|
24
|
-
] = useTranslatedEventData(event)
|
|
21
|
+
const [, { hasTranslation, isTranslated, toggleTranslation, locale }] =
|
|
22
|
+
useTranslatedEventData(event)
|
|
25
23
|
|
|
26
24
|
if (type) {
|
|
27
25
|
classNames.push('message--type-' + type)
|
|
@@ -29,9 +27,9 @@ function MessageContainer({
|
|
|
29
27
|
if (modifiers) {
|
|
30
28
|
if (typeof modifiers === 'string') {
|
|
31
29
|
// eslint-disable-next-line no-param-reassign
|
|
32
|
-
modifiers = modifiers.split(' ').filter(v => v.length)
|
|
30
|
+
modifiers = modifiers.split(' ').filter((v) => v.length)
|
|
33
31
|
}
|
|
34
|
-
modifiers.forEach(modifier => {
|
|
32
|
+
modifiers.forEach((modifier) => {
|
|
35
33
|
classNames.push('message--' + modifier)
|
|
36
34
|
})
|
|
37
35
|
}
|
|
@@ -5,15 +5,13 @@ import {
|
|
|
5
5
|
useSeamlyIdleDetachCountdown,
|
|
6
6
|
} from '../../hooks/seamly-hooks'
|
|
7
7
|
import { activitySendDelay } from '../../../config'
|
|
8
|
+
import { className } from '../../../lib/css'
|
|
8
9
|
|
|
9
10
|
const SeamlyActivityMonitor = ({ children }) => {
|
|
10
11
|
const prevSendTimestamp = useRef(0)
|
|
11
12
|
const { sendAction } = useSeamlyCommands()
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
isActive,
|
|
15
|
-
stopCountdown,
|
|
16
|
-
} = useSeamlyIdleDetachCountdown()
|
|
13
|
+
const { hasCountdown, isActive, stopCountdown } =
|
|
14
|
+
useSeamlyIdleDetachCountdown()
|
|
17
15
|
|
|
18
16
|
const onActivityHandler = useCallback(() => {
|
|
19
17
|
const timeStamp = new Date().getTime()
|
|
@@ -38,6 +36,7 @@ const SeamlyActivityMonitor = ({ children }) => {
|
|
|
38
36
|
// be fired inside the container on the initial focus event.
|
|
39
37
|
return (
|
|
40
38
|
<div
|
|
39
|
+
className={className('activity-monitor')}
|
|
41
40
|
tabIndex="-1"
|
|
42
41
|
onMouseDown={onActivityHandler}
|
|
43
42
|
onKeyUp={onActivityHandler}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import SeamlyApi from './seamly-api'
|
|
2
1
|
import SeamlyInstanceFunctionsLoader from './seamly-instance-functions-loader'
|
|
3
2
|
import SeamlyReadState from './seamly-read-state'
|
|
4
3
|
import SeamlyNewNotifications from './seamly-new-notifications'
|
|
@@ -8,14 +7,14 @@ import SeamlyActivityMonitor from './seamly-activity-monitor'
|
|
|
8
7
|
import SeamlyInitializer from './seamly-initializer'
|
|
9
8
|
import SeamlyEventSubscriber from './seamly-event-subscriber'
|
|
10
9
|
import SeamlyFileUpload from './seamly-file-upload'
|
|
11
|
-
import { SeamlyEventBusContext } from './seamly-api-context'
|
|
12
|
-
import StoreProvider from '
|
|
10
|
+
import { SeamlyEventBusContext, SeamlyApiContext } from './seamly-api-context'
|
|
11
|
+
import { StoreProvider } from '../../../domains/redux'
|
|
13
12
|
|
|
14
|
-
const SeamlyCore = ({ children, config, eventBus }) => {
|
|
13
|
+
const SeamlyCore = ({ store, children, config, eventBus, api }) => {
|
|
15
14
|
return (
|
|
16
|
-
<StoreProvider
|
|
15
|
+
<StoreProvider store={store}>
|
|
17
16
|
<SeamlyEventBusContext.Provider value={eventBus}>
|
|
18
|
-
<
|
|
17
|
+
<SeamlyApiContext.Provider value={api}>
|
|
19
18
|
<SeamlyLiveRegion>
|
|
20
19
|
<SeamlyInitializer config={config} />
|
|
21
20
|
<SeamlyEventSubscriber eventBus={eventBus} />
|
|
@@ -27,7 +26,7 @@ const SeamlyCore = ({ children, config, eventBus }) => {
|
|
|
27
26
|
<SeamlyFileUpload>{children}</SeamlyFileUpload>
|
|
28
27
|
</SeamlyActivityMonitor>
|
|
29
28
|
</SeamlyLiveRegion>
|
|
30
|
-
</
|
|
29
|
+
</SeamlyApiContext.Provider>
|
|
31
30
|
</SeamlyEventBusContext.Provider>
|
|
32
31
|
</StoreProvider>
|
|
33
32
|
)
|
|
@@ -2,7 +2,6 @@ import { useEffect, useRef } from 'preact/hooks'
|
|
|
2
2
|
import { seamlyActions, featureKeys } from '../../utils/seamly-utils'
|
|
3
3
|
import { useI18n } from '../../../domains/i18n'
|
|
4
4
|
import {
|
|
5
|
-
useSeamlyInterrupt,
|
|
6
5
|
useSeamlyOptions,
|
|
7
6
|
useEvents,
|
|
8
7
|
useSeamlyApiContext,
|
|
@@ -13,6 +12,7 @@ import {
|
|
|
13
12
|
import SeamlyGeneralError from '../../../api/errors/seamly-general-error'
|
|
14
13
|
import SeamlySessionExpiredError from '../../../api/errors/seamly-session-expired-error'
|
|
15
14
|
import SeamlyOfflineError from '../../../api/errors/seamly-offline-error'
|
|
15
|
+
import { Actions as InterruptActions } from '../../../domains/interrupt'
|
|
16
16
|
|
|
17
17
|
const {
|
|
18
18
|
ADD_EVENT,
|
|
@@ -20,7 +20,6 @@ const {
|
|
|
20
20
|
SET_IS_LOADING,
|
|
21
21
|
SET_PARTICIPANT,
|
|
22
22
|
SET_HEADER_SUB_TITLE,
|
|
23
|
-
CLEAR_INTERRUPT,
|
|
24
23
|
SET_ACTIVE_SERVICE,
|
|
25
24
|
INIT_RESUME_CONVERSATION_PROMPT,
|
|
26
25
|
CLEAR_EVENTS,
|
|
@@ -38,14 +37,13 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
38
37
|
const dispatch = useSeamlyDispatchContext()
|
|
39
38
|
const events = useEvents()
|
|
40
39
|
const prevEmittedEventId = useRef(null)
|
|
41
|
-
const { setInterrupt } = useSeamlyInterrupt()
|
|
42
40
|
const { setUserSelectedOption } = useSeamlyOptions()
|
|
43
41
|
const { initCountdown, endCountdown } = useSeamlyIdleDetachCountdown()
|
|
44
42
|
const { emitEvent } = useSeamlyCommands()
|
|
45
43
|
|
|
46
44
|
useEffect(() => {
|
|
47
45
|
if (api.connectionInfo) {
|
|
48
|
-
const updateParticipant = event => {
|
|
46
|
+
const updateParticipant = (event) => {
|
|
49
47
|
const { payload } = event
|
|
50
48
|
|
|
51
49
|
if (!payload || !payload.participant) {
|
|
@@ -73,7 +71,7 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
api.stream().subscribe({
|
|
76
|
-
next: event => {
|
|
74
|
+
next: (event) => {
|
|
77
75
|
const { type, payload } = event
|
|
78
76
|
switch (type) {
|
|
79
77
|
case 'ui':
|
|
@@ -178,19 +176,21 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
178
176
|
case 'error':
|
|
179
177
|
switch (payload.type) {
|
|
180
178
|
case 'find_conversation_erred':
|
|
181
|
-
|
|
179
|
+
dispatch(
|
|
180
|
+
InterruptActions.set(new SeamlySessionExpiredError()),
|
|
181
|
+
)
|
|
182
182
|
break
|
|
183
183
|
case 'seamly_offline':
|
|
184
|
-
|
|
184
|
+
dispatch(InterruptActions.set(new SeamlyOfflineError()))
|
|
185
185
|
dispatch({ type: CLEAR_EVENTS })
|
|
186
186
|
break
|
|
187
187
|
default:
|
|
188
|
-
|
|
188
|
+
dispatch(InterruptActions.set(new SeamlyGeneralError()))
|
|
189
189
|
break
|
|
190
190
|
}
|
|
191
191
|
break
|
|
192
192
|
case 'socket_opened':
|
|
193
|
-
dispatch(
|
|
193
|
+
dispatch(InterruptActions.clear())
|
|
194
194
|
break
|
|
195
195
|
}
|
|
196
196
|
},
|
|
@@ -199,7 +199,7 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
199
199
|
api
|
|
200
200
|
.stream()
|
|
201
201
|
.filter(
|
|
202
|
-
e =>
|
|
202
|
+
(e) =>
|
|
203
203
|
e.type === 'message' &&
|
|
204
204
|
EMITTABLE_MESSAGE_TYPES.includes(e.payload.type),
|
|
205
205
|
)
|
|
@@ -220,7 +220,6 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
220
220
|
api,
|
|
221
221
|
eventBus,
|
|
222
222
|
t,
|
|
223
|
-
setInterrupt,
|
|
224
223
|
setUserSelectedOption,
|
|
225
224
|
initCountdown,
|
|
226
225
|
endCountdown,
|
|
@@ -231,9 +230,9 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
231
230
|
const subscribe = () => {
|
|
232
231
|
return api
|
|
233
232
|
.stream()
|
|
234
|
-
.filter(e => e.type === 'sync')
|
|
233
|
+
.filter((e) => e.type === 'sync')
|
|
235
234
|
.subscribe({
|
|
236
|
-
next: event => {
|
|
235
|
+
next: (event) => {
|
|
237
236
|
const { payload } = event
|
|
238
237
|
|
|
239
238
|
const lastEvent = events[events.length - 1]
|
|
@@ -245,7 +244,7 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
245
244
|
|
|
246
245
|
api
|
|
247
246
|
.getConversation()
|
|
248
|
-
.then(history => {
|
|
247
|
+
.then((history) => {
|
|
249
248
|
if (!history) {
|
|
250
249
|
return
|
|
251
250
|
}
|
|
@@ -255,8 +254,8 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
255
254
|
history,
|
|
256
255
|
})
|
|
257
256
|
})
|
|
258
|
-
.catch(error => {
|
|
259
|
-
|
|
257
|
+
.catch((error) => {
|
|
258
|
+
dispatch(InterruptActions.set(error))
|
|
260
259
|
})
|
|
261
260
|
},
|
|
262
261
|
})
|
|
@@ -270,7 +269,7 @@ const SeamlyEventSubscriber = ({ eventBus }) => {
|
|
|
270
269
|
}
|
|
271
270
|
|
|
272
271
|
return () => {}
|
|
273
|
-
}, [api, events, dispatch
|
|
272
|
+
}, [api, events, dispatch])
|
|
274
273
|
|
|
275
274
|
return null
|
|
276
275
|
}
|
|
@@ -21,20 +21,20 @@ const SeamlyFileUpload = ({ children }) => {
|
|
|
21
21
|
const api = useSeamlyApiContext()
|
|
22
22
|
const { addUploadBubble } = useSeamlyCommands()
|
|
23
23
|
|
|
24
|
-
const onUploadFileHandler = file => {
|
|
24
|
+
const onUploadFileHandler = (file) => {
|
|
25
25
|
const fileId = randomId()
|
|
26
26
|
|
|
27
27
|
const uploadHandle = api.uploadFile(
|
|
28
28
|
file,
|
|
29
|
-
p => {
|
|
29
|
+
(p) => {
|
|
30
30
|
dispatch({ type: SET_UPLOAD_PROGRESS, fileId, progress: Math.ceil(p) })
|
|
31
31
|
},
|
|
32
|
-
result => {
|
|
32
|
+
(result) => {
|
|
33
33
|
const {
|
|
34
34
|
id,
|
|
35
35
|
transactionId,
|
|
36
36
|
occurredAt,
|
|
37
|
-
body: { contentType,
|
|
37
|
+
body: { contentType, filename, filesize, url },
|
|
38
38
|
} = result.body
|
|
39
39
|
dispatch({ type: SET_UPLOAD_COMPLETE, fileId })
|
|
40
40
|
addUploadBubble(
|
|
@@ -42,13 +42,12 @@ const SeamlyFileUpload = ({ children }) => {
|
|
|
42
42
|
transactionId,
|
|
43
43
|
occurredAt,
|
|
44
44
|
contentType,
|
|
45
|
-
deleteAt,
|
|
46
45
|
filename,
|
|
47
46
|
filesize,
|
|
48
47
|
url,
|
|
49
48
|
)
|
|
50
49
|
},
|
|
51
|
-
err => {
|
|
50
|
+
(err) => {
|
|
52
51
|
const errorKey = err && err.body ? err.body.error : ''
|
|
53
52
|
let errorText
|
|
54
53
|
|
|
@@ -2,12 +2,8 @@ import useSeamlyIdleDetachCountdown from '../../hooks/use-seamly-idle-detach-cou
|
|
|
2
2
|
import useInterval from '../../hooks/use-interval'
|
|
3
3
|
|
|
4
4
|
const SeamlyIdleDetachCounter = () => {
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
isActive,
|
|
8
|
-
remaining,
|
|
9
|
-
decrementCountdown,
|
|
10
|
-
} = useSeamlyIdleDetachCountdown()
|
|
5
|
+
const { hasCountdown, isActive, remaining, decrementCountdown } =
|
|
6
|
+
useSeamlyIdleDetachCountdown()
|
|
11
7
|
|
|
12
8
|
useInterval(
|
|
13
9
|
() => {
|
|
@@ -1,75 +1,22 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'preact/hooks'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
visibilityStates,
|
|
6
|
-
} from '../../utils/seamly-utils'
|
|
7
|
-
import { useI18n } from '../../../domains/i18n'
|
|
8
|
-
import {
|
|
9
|
-
useSeamlyInterrupt,
|
|
10
|
-
useSeamlyOptions,
|
|
11
|
-
useSeamlyVisibility,
|
|
12
|
-
useSeamlyApiContext,
|
|
13
|
-
useSeamlyDispatchContext,
|
|
14
|
-
} from '../../hooks/seamly-hooks'
|
|
2
|
+
import { visibilityStates } from '../../utils/seamly-utils'
|
|
3
|
+
import { useSeamlyOptions, useSeamlyVisibility } from '../../hooks/seamly-hooks'
|
|
4
|
+
import { useConfig } from '../../../domains/config'
|
|
15
5
|
|
|
16
|
-
const {
|
|
17
|
-
UPDATE_CONFIG,
|
|
18
|
-
SET_INITIAL_STATE,
|
|
19
|
-
SET_SHOW_DISCLAIMER,
|
|
20
|
-
SET_HEADER_SUB_TITLE,
|
|
21
|
-
SET_FEATURES,
|
|
22
|
-
} = seamlyActions
|
|
23
|
-
|
|
24
|
-
const SeamlyInitializer = ({ config }) => {
|
|
25
|
-
const { t } = useI18n()
|
|
26
|
-
const dispatch = useSeamlyDispatchContext()
|
|
27
|
-
const api = useSeamlyApiContext()
|
|
6
|
+
const SeamlyInitializer = () => {
|
|
28
7
|
const { initUserSelectedOptions } = useSeamlyOptions()
|
|
29
|
-
const { setInterrupt } = useSeamlyInterrupt()
|
|
30
8
|
const seamlyInitialized = useRef(false)
|
|
31
9
|
const { setVisibility } = useSeamlyVisibility()
|
|
10
|
+
const config = useConfig()
|
|
32
11
|
|
|
33
12
|
useEffect(() => {
|
|
34
|
-
|
|
35
|
-
const { showDisclaimer } = config
|
|
36
|
-
const { agentName } = config.defaults || {}
|
|
37
|
-
|
|
38
|
-
dispatch({ type: UPDATE_CONFIG, config: seamlyConfig })
|
|
39
|
-
|
|
40
|
-
dispatch({ type: SET_SHOW_DISCLAIMER, showDisclaimer })
|
|
41
|
-
|
|
42
|
-
if (agentName) {
|
|
43
|
-
dispatch({
|
|
44
|
-
type: SET_HEADER_SUB_TITLE,
|
|
45
|
-
title: agentName,
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
}, [dispatch, config])
|
|
49
|
-
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
const initSeamly = async () => {
|
|
13
|
+
if (config.api && !seamlyInitialized.current) {
|
|
52
14
|
seamlyInitialized.current = true
|
|
53
15
|
initUserSelectedOptions()
|
|
54
16
|
|
|
55
17
|
setVisibility(visibilityStates.initialize)
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const { accountConfig = {}, initialState = {} } = await api.getConfig()
|
|
59
|
-
const { features } = accountConfig || {}
|
|
60
|
-
|
|
61
|
-
dispatch({ type: SET_FEATURES, features })
|
|
62
|
-
|
|
63
|
-
dispatch({ type: SET_INITIAL_STATE, initialState })
|
|
64
|
-
} catch (error) {
|
|
65
|
-
setInterrupt(error)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (api.connectionInfo && !seamlyInitialized.current) {
|
|
70
|
-
initSeamly()
|
|
71
18
|
}
|
|
72
|
-
}, [
|
|
19
|
+
}, [initUserSelectedOptions, config, setVisibility])
|
|
73
20
|
|
|
74
21
|
return null
|
|
75
22
|
}
|