@seamly/web-ui 20.0.0-beta.3 → 20.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/lib/components.js +1 -1
- package/build/dist/lib/components.min.js +1 -1
- package/build/dist/lib/deprecated-view.css +1 -0
- package/build/dist/lib/deprecated-view.js +1 -0
- package/build/dist/lib/index.debug.js +80 -57
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +20 -12
- package/build/dist/lib/index.js +14645 -14065
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +5 -0
- package/build/dist/lib/standalone.js +19725 -19707
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +86 -27
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles-default-implementation.css +1 -0
- package/build/dist/lib/styles-default-implementation.js +1 -0
- package/build/dist/lib/styles.css +1 -1
- package/package.json +8 -7
- package/src/javascripts/api/index.js +19 -10
- package/src/javascripts/api/producer.js +5 -3
- package/src/javascripts/domains/translations/components/options-button.js +1 -1
- package/src/javascripts/index.js +2 -2
- package/src/javascripts/lib/engine/index.js +2 -1
- package/src/javascripts/lib/parse-body.js +1 -1
- package/src/javascripts/package/components.js +1 -1
- package/src/javascripts/style-guide/components/view.js +1 -0
- package/src/javascripts/style-guide/states.js +67 -6
- package/src/javascripts/style-guide/style-guide-engine.js +1 -0
- package/src/javascripts/ui/components/app-options/index.js +9 -3
- package/src/javascripts/ui/components/conversation/conversation.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +3 -1
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +12 -3
- package/src/javascripts/ui/components/conversation/event/hooks/use-text-rendering.js +35 -0
- package/src/javascripts/ui/components/conversation/event/participant.js +5 -2
- package/src/javascripts/ui/components/conversation/event/splash.js +2 -1
- package/src/javascripts/ui/components/conversation/event/text.js +2 -1
- package/src/javascripts/ui/components/entry/{toggle-button.js → deprecated-toggle-button.js} +0 -0
- package/src/javascripts/ui/components/entry/entry-container.js +1 -1
- package/src/javascripts/ui/components/layout/chat-frame.js +1 -1
- package/src/javascripts/ui/components/layout/{app-frame.js → chat.js} +10 -41
- package/src/javascripts/ui/components/layout/deprecated-app-frame.js +1 -8
- package/src/javascripts/ui/components/layout/header.js +1 -1
- package/src/javascripts/ui/components/layout/pre-chat-messages.js +2 -8
- package/src/javascripts/ui/components/options/options-button.js +2 -2
- package/src/javascripts/ui/components/suggestions/index.js +2 -3
- package/src/javascripts/ui/components/suggestions/suggestions-list.js +1 -1
- package/src/javascripts/ui/components/view/app-view.js +3 -3
- package/src/javascripts/ui/components/view/deprecated-view.js +2 -2
- package/src/javascripts/ui/components/view/index.js +61 -5
- package/src/javascripts/ui/components/view/inline-view.js +15 -4
- package/src/javascripts/ui/components/view/window-view/index.js +5 -5
- package/src/stylesheets/1-settings/_config.scss +6 -6
- package/src/stylesheets/{3-app/_app.scss → 3-chat/_chat.scss} +22 -35
- package/src/stylesheets/5-components/_chat-status.scss +1 -5
- package/src/stylesheets/5-components/_conversation.scss +3 -3
- package/src/stylesheets/5-components/_disclaimer.scss +2 -6
- package/src/stylesheets/5-components/_interrupt.scss +21 -2
- package/src/stylesheets/5-components/_message-body.scss +23 -1
- package/src/stylesheets/5-components/_message-count.scss +1 -0
- package/src/stylesheets/5-components/_message.scss +4 -0
- package/src/stylesheets/5-components/_modal.scss +2 -2
- package/src/stylesheets/5-components/_options.scss +6 -14
- package/src/stylesheets/5-components/_pre-chat-messages.scss +24 -17
- package/src/stylesheets/5-components/_suggestions.scss +6 -6
- package/src/stylesheets/5-components/_unstarted.scss +22 -36
- package/src/stylesheets/6-default-implementation/_hover.scss +153 -0
- package/src/stylesheets/{6-webui-only → 6-default-implementation}/_scrollbar.scss +1 -1
- package/src/stylesheets/7-deprecated/3-app/_app.scss +8 -8
- package/src/stylesheets/7-deprecated/5-components/_message.scss +1 -1
- package/src/stylesheets/7-deprecated/5-components/_modal.scss +1 -1
- package/src/stylesheets/7-deprecated/5-components/_options.scss +8 -8
- package/src/stylesheets/style-guide.scss +1 -1
- package/src/stylesheets/styles-default-implementation.scss +3 -0
- package/src/stylesheets/styles.scss +8 -9
- package/webpack/config.package.js +9 -1
- package/webpack/defaults.js +3 -6
- package/src/javascripts/ui/components/layout/modal-wrapper.js +0 -0
- package/src/stylesheets/6-webui-only/_hover.scss +0 -151
- package/src/stylesheets/styles-webui-only.scss +0 -3
|
@@ -17,6 +17,7 @@ class SeamlyStyleGuideInstance extends Engine {
|
|
|
17
17
|
const api = new API({
|
|
18
18
|
namespace: this.config.namespace,
|
|
19
19
|
config: this.config.api,
|
|
20
|
+
context: this.config.context,
|
|
20
21
|
})
|
|
21
22
|
api.URLS = {
|
|
22
23
|
translations: `/client/${this.config.api.key}/translations/{version}/{locale}.json`,
|
|
@@ -17,17 +17,23 @@ export default function AppOptions() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<div className={className('
|
|
20
|
+
<div className={className('chat__options')}>
|
|
21
21
|
{isTranslationsAvailable && (
|
|
22
22
|
<div
|
|
23
|
-
className={className(
|
|
23
|
+
className={className(
|
|
24
|
+
'chat__options-item',
|
|
25
|
+
'chat__options-item--left',
|
|
26
|
+
)}
|
|
24
27
|
>
|
|
25
28
|
<TranslationsOptionsButton />
|
|
26
29
|
</div>
|
|
27
30
|
)}
|
|
28
31
|
{allowOptionSelection && (
|
|
29
32
|
<div
|
|
30
|
-
className={className(
|
|
33
|
+
className={className(
|
|
34
|
+
'chat__options-item',
|
|
35
|
+
'chat__options-item--right',
|
|
36
|
+
)}
|
|
31
37
|
>
|
|
32
38
|
<OptionsButton />
|
|
33
39
|
</div>
|
|
@@ -72,7 +72,7 @@ const Conversation = () => {
|
|
|
72
72
|
{t('skiplinkText')}
|
|
73
73
|
</a>
|
|
74
74
|
)}
|
|
75
|
-
<div className={className('
|
|
75
|
+
<div className={className('chat__body')} ref={appBodyContainer}>
|
|
76
76
|
<div className={className('conversation__container')}>
|
|
77
77
|
<PrivacyDisclaimer />
|
|
78
78
|
<ol className={className('conversation')}>
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import MessageContainer from '../../message-container'
|
|
2
2
|
import CarouselComponent from '../carousel-component'
|
|
3
|
+
import { useTranslatedEventData } from '../../../../../domains/translations'
|
|
3
4
|
import CarouselMessageSlide from './components/slide'
|
|
4
5
|
|
|
5
6
|
const getItemKey = (item, idx, prefix = '') => `${prefix}${item.title}:${idx}`
|
|
6
7
|
const getItemLabel = (item) => item.title
|
|
7
8
|
const CarouselMessage = ({ event }) => {
|
|
8
|
-
const
|
|
9
|
+
const [body] = useTranslatedEventData(event)
|
|
10
|
+
const slides = body.cards
|
|
9
11
|
|
|
10
12
|
return (
|
|
11
13
|
<MessageContainer event={event} modifiers={'type-carousel'}>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback } from 'preact/hooks'
|
|
1
|
+
import { useCallback, useState } from 'preact/hooks'
|
|
2
2
|
import { className } from '../../../../lib/css'
|
|
3
3
|
import { actionTypes } from '../../../utils/seamly-utils'
|
|
4
4
|
import { useI18n } from '../../../../domains/i18n'
|
|
@@ -6,6 +6,7 @@ import { useTranslatedEventData } from '../../../../domains/translations'
|
|
|
6
6
|
import MessageContainer from '../message-container'
|
|
7
7
|
import { useSeamlyCommands } from '../../../hooks/seamly-hooks'
|
|
8
8
|
import SuggestionsList from '../../suggestions/suggestions-list'
|
|
9
|
+
import { useConfig } from '../../../../domains/config'
|
|
9
10
|
|
|
10
11
|
export const useSuggestions = (event) => {
|
|
11
12
|
const { payload } = event
|
|
@@ -18,6 +19,8 @@ export const useSuggestions = (event) => {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
const ConversationSuggestions = ({ event, ...props }) => {
|
|
22
|
+
const { userResponded } = useConfig()
|
|
23
|
+
const [isExpanded, setIsExpanded] = useState(true)
|
|
21
24
|
const { t } = useI18n()
|
|
22
25
|
const headingText = t('suggestions.headingText')
|
|
23
26
|
const footerText = t('suggestions.footerText')
|
|
@@ -26,6 +29,8 @@ const ConversationSuggestions = ({ event, ...props }) => {
|
|
|
26
29
|
const handleClick = useCallback(
|
|
27
30
|
({ id, question }) => {
|
|
28
31
|
// @todo Refactor to 'suggestionclick'
|
|
32
|
+
setIsExpanded(false)
|
|
33
|
+
|
|
29
34
|
sendAction({
|
|
30
35
|
type: actionTypes.custom,
|
|
31
36
|
originMessage: payload.id,
|
|
@@ -40,13 +45,17 @@ const ConversationSuggestions = ({ event, ...props }) => {
|
|
|
40
45
|
|
|
41
46
|
addMessageBubble(question)
|
|
42
47
|
},
|
|
43
|
-
[payload, sendAction, addMessageBubble],
|
|
48
|
+
[payload, sendAction, addMessageBubble, setIsExpanded],
|
|
44
49
|
)
|
|
45
50
|
|
|
51
|
+
if (!isExpanded || userResponded) {
|
|
52
|
+
return null
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
return (
|
|
47
56
|
<div className={className('suggestions', 'suggestions--conversation')}>
|
|
48
57
|
{headingText && (
|
|
49
|
-
<
|
|
58
|
+
<p className={className('suggestions__heading')}>{headingText}</p>
|
|
50
59
|
)}
|
|
51
60
|
<MessageContainer
|
|
52
61
|
type="suggestions"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Mustache from 'mustache'
|
|
2
|
+
|
|
3
|
+
Mustache.escape = function (escapeText) {
|
|
4
|
+
return escapeText
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const parseLinkVariable = (variable) => {
|
|
8
|
+
return `<a href='${variable.url}' data-link-id='${variable.id}' ${
|
|
9
|
+
variable.newTab ? 'target="_blank"' : ''
|
|
10
|
+
}>${variable.name}</a>`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function parseRichText(text, variables = {}) {
|
|
14
|
+
const view = {}
|
|
15
|
+
Object.entries(variables).forEach(([key, variable]) => {
|
|
16
|
+
switch (variable.type) {
|
|
17
|
+
case 'link':
|
|
18
|
+
view[key] = parseLinkVariable(variable)
|
|
19
|
+
break
|
|
20
|
+
case 'text':
|
|
21
|
+
view[key] = variable.value
|
|
22
|
+
break
|
|
23
|
+
}
|
|
24
|
+
}, {})
|
|
25
|
+
|
|
26
|
+
// Disable escaping as we'll be generating HTML
|
|
27
|
+
const oldEscape = Mustache.escape
|
|
28
|
+
Mustache.escape = function (escapeText) {
|
|
29
|
+
return escapeText
|
|
30
|
+
}
|
|
31
|
+
const output = Mustache.render(text, view)
|
|
32
|
+
Mustache.escape = oldEscape
|
|
33
|
+
|
|
34
|
+
return output
|
|
35
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMemo } from 'preact/hooks'
|
|
2
|
+
import Mustache from 'mustache'
|
|
2
3
|
import parseBody from '../../../../lib/parse-body'
|
|
3
4
|
import EventDivider from '../event-divider'
|
|
4
5
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
@@ -11,8 +12,10 @@ const Participant = ({ event }) => {
|
|
|
11
12
|
const [introduction] = useTranslatedEventData(event)
|
|
12
13
|
|
|
13
14
|
const intro = useMemo(() => {
|
|
14
|
-
return introduction
|
|
15
|
-
|
|
15
|
+
return introduction
|
|
16
|
+
? Mustache.render(parseBody(introduction), participant)
|
|
17
|
+
: undefined
|
|
18
|
+
}, [introduction, participant])
|
|
16
19
|
|
|
17
20
|
if (!intro) {
|
|
18
21
|
return null
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import parseBody from '../../../../lib/parse-body'
|
|
2
2
|
import useEventLinkClickHandler from './hooks/use-event-link-click-handler'
|
|
3
|
+
import { parseRichText } from './hooks/use-text-rendering'
|
|
3
4
|
import MessageContainer from '../message-container'
|
|
4
5
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
5
6
|
|
|
@@ -16,7 +17,7 @@ const Splash = ({ event, ...props }) => {
|
|
|
16
17
|
{...props}
|
|
17
18
|
bodyProps={{
|
|
18
19
|
dangerouslySetInnerHTML: {
|
|
19
|
-
__html: parseBody(body.text),
|
|
20
|
+
__html: parseRichText(parseBody(body.text), body.variables),
|
|
20
21
|
},
|
|
21
22
|
}}
|
|
22
23
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'preact/hooks'
|
|
2
2
|
import parseBody from '../../../../lib/parse-body'
|
|
3
3
|
import useEventLinkClickHandler from './hooks/use-event-link-click-handler'
|
|
4
|
+
import { parseRichText } from './hooks/use-text-rendering'
|
|
4
5
|
import MessageContainer from '../message-container'
|
|
5
6
|
import { useTranslatedEventData } from '../../../../domains/translations'
|
|
6
7
|
|
|
@@ -13,7 +14,7 @@ const Text = ({ event, ...props }) => {
|
|
|
13
14
|
return {
|
|
14
15
|
bodyProps: {
|
|
15
16
|
dangerouslySetInnerHTML: {
|
|
16
|
-
__html: parseBody(body.text),
|
|
17
|
+
__html: parseRichText(parseBody(body.text), body.variables),
|
|
17
18
|
},
|
|
18
19
|
},
|
|
19
20
|
}
|
package/src/javascripts/ui/components/entry/{toggle-button.js → deprecated-toggle-button.js}
RENAMED
|
File without changes
|
|
@@ -79,7 +79,7 @@ const EntryContainer = () => {
|
|
|
79
79
|
const EntryComponent = entryComponents[renderEntry]
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
|
-
<div className={className('
|
|
82
|
+
<div className={className('chat__entry')} ref={entryContainer}>
|
|
83
83
|
{showCountdown && <IdleDetachWarning />}
|
|
84
84
|
{showResumeConversationPrompt && <ResumeConversationPrompt />}
|
|
85
85
|
<div
|
|
@@ -21,7 +21,7 @@ function ChatFrame({ children, interruptComponent: InterruptComponent }) {
|
|
|
21
21
|
return (
|
|
22
22
|
<>
|
|
23
23
|
<TranslationsChatStatus />
|
|
24
|
-
<div className={className('
|
|
24
|
+
<div className={className('chat__container')}>{getContent()}</div>
|
|
25
25
|
<AppOptions />
|
|
26
26
|
</>
|
|
27
27
|
)
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useCallback, useMemo } from 'preact/hooks'
|
|
2
1
|
import { className } from '../../../lib/css'
|
|
3
2
|
import {
|
|
4
3
|
useSeamlyAppContainerClassNames,
|
|
5
4
|
useSeamlyLayoutMode,
|
|
6
|
-
useSeamlyContainerElement,
|
|
7
5
|
} from '../../hooks/seamly-hooks'
|
|
8
6
|
import { useConfig } from '../../../domains/config'
|
|
9
7
|
import { useUserHasResponded } from '../../../domains/app'
|
|
@@ -11,57 +9,32 @@ import { useI18n } from '../../../domains/i18n'
|
|
|
11
9
|
import { useVisibility, visibilityStates } from '../../../domains/visibility'
|
|
12
10
|
import Suggestions from '../suggestions'
|
|
13
11
|
|
|
14
|
-
const
|
|
15
|
-
children,
|
|
16
|
-
className: givenClassName = '',
|
|
17
|
-
isDeprecated,
|
|
18
|
-
}) => {
|
|
19
|
-
const [, setSeamlyContainerElement] = useSeamlyContainerElement()
|
|
12
|
+
const Chat = ({ children, className: givenClassName = '' }) => {
|
|
20
13
|
const { isOpen, isVisible, setVisibility } = useVisibility()
|
|
21
|
-
const {
|
|
14
|
+
const { namespace, layoutMode } = useConfig()
|
|
22
15
|
const { isInline } = useSeamlyLayoutMode()
|
|
23
16
|
const appContainerClassNames = useSeamlyAppContainerClassNames()
|
|
24
17
|
const userResponded = useUserHasResponded()
|
|
25
|
-
const {
|
|
18
|
+
const { t } = useI18n()
|
|
26
19
|
|
|
27
|
-
const containerElementRef = useCallback(
|
|
28
|
-
(container) => {
|
|
29
|
-
setSeamlyContainerElement(container)
|
|
30
|
-
},
|
|
31
|
-
[setSeamlyContainerElement],
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
const blockLang = useMemo(() => {
|
|
35
|
-
if (locale) {
|
|
36
|
-
const htmlElementLang = document
|
|
37
|
-
.querySelector('html')
|
|
38
|
-
.getAttribute('lang')
|
|
39
|
-
if (htmlElementLang !== locale) {
|
|
40
|
-
return locale
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return undefined
|
|
44
|
-
}, [locale])
|
|
45
|
-
|
|
46
|
-
const baseClassName = isDeprecated ? 'app--deprecated' : 'app'
|
|
47
20
|
const defaultClassNames = [
|
|
48
|
-
|
|
21
|
+
'chat',
|
|
22
|
+
`chat--layout-${layoutMode}`,
|
|
49
23
|
`namespace--${namespace}`,
|
|
50
24
|
]
|
|
51
25
|
|
|
52
26
|
const classNames = [
|
|
53
|
-
baseClassName,
|
|
54
27
|
...defaultClassNames,
|
|
55
28
|
...appContainerClassNames,
|
|
56
29
|
givenClassName,
|
|
57
30
|
]
|
|
58
31
|
|
|
59
32
|
if (!isOpen && layoutMode !== 'app') {
|
|
60
|
-
classNames.push('
|
|
33
|
+
classNames.push('chat--collapsed')
|
|
61
34
|
}
|
|
62
35
|
|
|
63
36
|
if (userResponded) {
|
|
64
|
-
classNames.push('
|
|
37
|
+
classNames.push('chat--user-responded')
|
|
65
38
|
}
|
|
66
39
|
|
|
67
40
|
const onKeyDownHandler = (e) => {
|
|
@@ -76,18 +49,14 @@ const AppFrame = ({
|
|
|
76
49
|
<section
|
|
77
50
|
className={className(classNames)}
|
|
78
51
|
onKeyDown={onKeyDownHandler}
|
|
79
|
-
lang={blockLang}
|
|
80
52
|
tabIndex="-1"
|
|
81
|
-
|
|
82
|
-
style={{ zIndex }}
|
|
83
|
-
data-nosnippet
|
|
84
|
-
aria-label={t('app.srLabel')}
|
|
53
|
+
aria-label={t('chat.srLabel')}
|
|
85
54
|
>
|
|
86
|
-
<div className={className('
|
|
55
|
+
<div className={className('chat-wrapper')}>{children}</div>
|
|
87
56
|
{layoutMode === 'inline' && isOpen && <Suggestions isAside={true} />}
|
|
88
57
|
</section>
|
|
89
58
|
)
|
|
90
59
|
)
|
|
91
60
|
}
|
|
92
61
|
|
|
93
|
-
export default
|
|
62
|
+
export default Chat
|
|
@@ -15,7 +15,7 @@ const DeprecatedAppFrame = ({ children }) => {
|
|
|
15
15
|
const [, setSeamlyContainerElement] = useSeamlyContainerElement()
|
|
16
16
|
const { isOpen, isVisible, setVisibility } = useVisibility()
|
|
17
17
|
const { zIndex, showFaq, layoutMode } = useConfig()
|
|
18
|
-
const {
|
|
18
|
+
const { isInline } = useSeamlyLayoutMode()
|
|
19
19
|
const appContainerClassNames = useSeamlyAppContainerClassNames()
|
|
20
20
|
const userResponded = useUserHasResponded()
|
|
21
21
|
const { locale } = useI18n()
|
|
@@ -58,18 +58,11 @@ const DeprecatedAppFrame = ({ children }) => {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
const onClickHandler = (e) => {
|
|
62
|
-
if (isModal) {
|
|
63
|
-
e.stopPropagation()
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
61
|
return (
|
|
68
62
|
isVisible && (
|
|
69
63
|
<section
|
|
70
64
|
className={className(classNames)}
|
|
71
65
|
onKeyDown={onKeyDownHandler}
|
|
72
|
-
onClick={onClickHandler}
|
|
73
66
|
lang={blockLang}
|
|
74
67
|
tabIndex="-1"
|
|
75
68
|
ref={containerElementRef}
|
|
@@ -10,7 +10,7 @@ const Header = ({ children, onCloseChat }) => {
|
|
|
10
10
|
|
|
11
11
|
const { t } = useI18n()
|
|
12
12
|
return (
|
|
13
|
-
<header className={className('
|
|
13
|
+
<header className={className('chat__header')}>
|
|
14
14
|
{children}
|
|
15
15
|
<div className={className('header-controls')}>
|
|
16
16
|
<button
|
|
@@ -3,9 +3,6 @@ import { useInterrupt } from '../../../domains/interrupt'
|
|
|
3
3
|
import { useConfig } from '../../../domains/config'
|
|
4
4
|
import useEventComponentMapping from '../../hooks/use-event-component-mapping'
|
|
5
5
|
import { useVisibility } from '../../../domains/visibility'
|
|
6
|
-
import InOutTransition, {
|
|
7
|
-
transitionStartStates,
|
|
8
|
-
} from '../widgets/in-out-transition'
|
|
9
6
|
|
|
10
7
|
export default function PreChatMessages() {
|
|
11
8
|
const { preChatEvents, layoutMode } = useConfig()
|
|
@@ -15,10 +12,7 @@ export default function PreChatMessages() {
|
|
|
15
12
|
const isVisible = !(hasInterrupt || !preChatEvents.length || isOpen)
|
|
16
13
|
|
|
17
14
|
return (
|
|
18
|
-
|
|
19
|
-
isActive={isVisible}
|
|
20
|
-
transitionStartState={transitionStartStates.notRendered}
|
|
21
|
-
>
|
|
15
|
+
isVisible && (
|
|
22
16
|
<ul
|
|
23
17
|
className={className(
|
|
24
18
|
'pre-chat-messages',
|
|
@@ -35,7 +29,7 @@ export default function PreChatMessages() {
|
|
|
35
29
|
</li>
|
|
36
30
|
))}
|
|
37
31
|
</ul>
|
|
38
|
-
|
|
32
|
+
)
|
|
39
33
|
)
|
|
40
34
|
}
|
|
41
35
|
|
|
@@ -223,9 +223,9 @@ const OptionsButton = () => {
|
|
|
223
223
|
className={className([
|
|
224
224
|
'button',
|
|
225
225
|
'button--secondary',
|
|
226
|
-
'
|
|
226
|
+
'chat__options__button',
|
|
227
227
|
...(!multiMenu && firstOptionName
|
|
228
|
-
? [`
|
|
228
|
+
? [`chat__options__button--${firstOptionName}`]
|
|
229
229
|
: []),
|
|
230
230
|
...(!multiMenu && !firstOption.available ? ['button--disabled'] : []),
|
|
231
231
|
])}
|
|
@@ -152,13 +152,12 @@ const Suggestions = ({ isAside }) => {
|
|
|
152
152
|
ref={containerRef}
|
|
153
153
|
>
|
|
154
154
|
{headingText && (
|
|
155
|
-
<
|
|
155
|
+
<p id={sectionId} className={className('suggestions__heading')}>
|
|
156
156
|
{headingText}
|
|
157
|
-
</
|
|
157
|
+
</p>
|
|
158
158
|
)}
|
|
159
159
|
{!!renderedSuggestions.length && (
|
|
160
160
|
<SuggestionsList
|
|
161
|
-
hasIcon={true}
|
|
162
161
|
suggestions={renderedSuggestions}
|
|
163
162
|
onClickSuggestion={handleClick}
|
|
164
163
|
/>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Chat from '../layout/chat'
|
|
2
2
|
import Interrupt from '../layout/interrupt'
|
|
3
3
|
import Conversation from '../conversation/conversation'
|
|
4
4
|
import EntryContainer from '../entry/entry-container'
|
|
@@ -9,12 +9,12 @@ const AppView = () => {
|
|
|
9
9
|
useSeamlyChat()
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
|
-
<
|
|
12
|
+
<Chat>
|
|
13
13
|
<ChatFrame interruptComponent={Interrupt}>
|
|
14
14
|
<Conversation />
|
|
15
15
|
<EntryContainer />
|
|
16
16
|
</ChatFrame>
|
|
17
|
-
</
|
|
17
|
+
</Chat>
|
|
18
18
|
)
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -7,11 +7,11 @@ import EntryContainer from '../entry/entry-container'
|
|
|
7
7
|
import Interrupt from '../layout/interrupt'
|
|
8
8
|
import { useSeamlyChat } from '../../hooks/seamly-hooks'
|
|
9
9
|
import { useVisibility } from '../../../domains/visibility'
|
|
10
|
-
import DeprecatedToggleButton from '../entry/toggle-button'
|
|
10
|
+
import DeprecatedToggleButton from '../entry/deprecated-toggle-button'
|
|
11
11
|
|
|
12
12
|
const DeprecatedView = () => {
|
|
13
13
|
const { isVisible } = useVisibility()
|
|
14
|
-
const {
|
|
14
|
+
const { openChat, closeChat } = useSeamlyChat()
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
isVisible && (
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'preact/hooks'
|
|
1
2
|
import { useConfig } from '../../../domains/config'
|
|
2
3
|
import AppView from './app-view'
|
|
3
4
|
import InlineView from './inline-view'
|
|
4
5
|
import WindowView from './window-view'
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { useVisibility } from '../../../domains/visibility'
|
|
7
|
+
import { className } from '../../../lib/css'
|
|
8
|
+
import { useSeamlyAppContainerClassNames } from '../../hooks/component-helper-hooks'
|
|
9
|
+
import { useUserHasResponded } from '../../../domains/app'
|
|
10
|
+
import { useI18n } from '../../../domains/i18n'
|
|
11
|
+
import { useSeamlyContainerElement } from '../../hooks/focus-helper-hooks'
|
|
7
12
|
|
|
8
13
|
const ViewComponentsMap = {
|
|
9
14
|
app: AppView,
|
|
@@ -12,16 +17,67 @@ const ViewComponentsMap = {
|
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
const View = () => {
|
|
15
|
-
const
|
|
16
|
-
const {
|
|
20
|
+
const [, setSeamlyContainerElement] = useSeamlyContainerElement()
|
|
21
|
+
const { namespace, layoutMode, zIndex } = useConfig()
|
|
22
|
+
const { isOpen, isVisible } = useVisibility()
|
|
23
|
+
const appContainerClassNames = useSeamlyAppContainerClassNames()
|
|
24
|
+
const userResponded = useUserHasResponded()
|
|
25
|
+
const { locale } = useI18n()
|
|
17
26
|
const ViewComponent = ViewComponentsMap[layoutMode]
|
|
18
27
|
|
|
28
|
+
const containerElementRef = useCallback(
|
|
29
|
+
(container) => {
|
|
30
|
+
setSeamlyContainerElement(container)
|
|
31
|
+
},
|
|
32
|
+
[setSeamlyContainerElement],
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const blockLang = useMemo(() => {
|
|
36
|
+
if (locale) {
|
|
37
|
+
const htmlElementLang = document
|
|
38
|
+
.querySelector('html')
|
|
39
|
+
.getAttribute('lang')
|
|
40
|
+
if (htmlElementLang !== locale) {
|
|
41
|
+
return locale
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return undefined
|
|
45
|
+
}, [locale])
|
|
46
|
+
|
|
19
47
|
if (!ViewComponent) {
|
|
20
48
|
console.warn('"layoutMode" should be one of "app", "inline" or "window"')
|
|
21
49
|
return null
|
|
22
50
|
}
|
|
23
51
|
|
|
24
|
-
|
|
52
|
+
const defaultClassNames = [
|
|
53
|
+
`app--layout-${layoutMode}`,
|
|
54
|
+
`namespace--${namespace}`,
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
const classNames = ['app', ...defaultClassNames, ...appContainerClassNames]
|
|
58
|
+
|
|
59
|
+
if (!isOpen && layoutMode !== 'app') {
|
|
60
|
+
classNames.push('app--collapsed')
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (userResponded) {
|
|
64
|
+
classNames.push('app--user-responded')
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
isVisible && (
|
|
69
|
+
<div
|
|
70
|
+
className={className(classNames)}
|
|
71
|
+
lang={blockLang}
|
|
72
|
+
tabIndex="-1"
|
|
73
|
+
data-nosnippet
|
|
74
|
+
style={{ zIndex }}
|
|
75
|
+
ref={containerElementRef}
|
|
76
|
+
>
|
|
77
|
+
<ViewComponent />
|
|
78
|
+
</div>
|
|
79
|
+
)
|
|
80
|
+
)
|
|
25
81
|
}
|
|
26
82
|
|
|
27
83
|
export default View
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { className } from '../../../lib/css'
|
|
2
|
-
import
|
|
2
|
+
import Chat from '../layout/chat'
|
|
3
3
|
import Interrupt from '../layout/interrupt'
|
|
4
4
|
import Conversation from '../conversation/conversation'
|
|
5
5
|
import EntryContainer from '../entry/entry-container'
|
|
@@ -11,10 +11,16 @@ import Suggestions from '../suggestions'
|
|
|
11
11
|
import InOutTransition, {
|
|
12
12
|
transitionStartStates,
|
|
13
13
|
} from '../widgets/in-out-transition'
|
|
14
|
+
import { useInterrupt } from '../../../domains/interrupt'
|
|
14
15
|
|
|
15
16
|
const InlineView = () => {
|
|
16
17
|
useSeamlyChat()
|
|
17
18
|
const { isOpen } = useVisibility()
|
|
19
|
+
const { hasInterrupt, meta } = useInterrupt()
|
|
20
|
+
|
|
21
|
+
if (hasInterrupt && !isOpen) {
|
|
22
|
+
return <Interrupt {...meta} />
|
|
23
|
+
}
|
|
18
24
|
|
|
19
25
|
return (
|
|
20
26
|
<>
|
|
@@ -22,7 +28,12 @@ const InlineView = () => {
|
|
|
22
28
|
isActive={!isOpen}
|
|
23
29
|
transitionStartState={transitionStartStates.rendered}
|
|
24
30
|
>
|
|
25
|
-
<div
|
|
31
|
+
<div
|
|
32
|
+
className={className(
|
|
33
|
+
'unstarted-wrapper',
|
|
34
|
+
'unstarted-wrapper--inline',
|
|
35
|
+
)}
|
|
36
|
+
>
|
|
26
37
|
<PreChatMessages />
|
|
27
38
|
<Suggestions />
|
|
28
39
|
</div>
|
|
@@ -31,12 +42,12 @@ const InlineView = () => {
|
|
|
31
42
|
isActive={isOpen}
|
|
32
43
|
transitionStartState={transitionStartStates.rendered}
|
|
33
44
|
>
|
|
34
|
-
<
|
|
45
|
+
<Chat>
|
|
35
46
|
<ChatFrame interruptComponent={Interrupt}>
|
|
36
47
|
{isOpen && <Conversation />}
|
|
37
48
|
<EntryContainer />
|
|
38
49
|
</ChatFrame>
|
|
39
|
-
</
|
|
50
|
+
</Chat>
|
|
40
51
|
</InOutTransition>
|
|
41
52
|
</>
|
|
42
53
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'preact/hooks'
|
|
2
2
|
import { useSeamlyChat } from '../../../hooks/seamly-hooks'
|
|
3
3
|
import { useVisibility } from '../../../../domains/visibility'
|
|
4
|
-
import
|
|
4
|
+
import Chat from '../../layout/chat'
|
|
5
5
|
import ChatFrame from '../../layout/chat-frame'
|
|
6
6
|
import Interrupt from '../../layout/interrupt'
|
|
7
7
|
import Conversation from '../../conversation/conversation'
|
|
@@ -14,7 +14,7 @@ import InOutTransition, {
|
|
|
14
14
|
import PreChatMessages from '../../layout/pre-chat-messages'
|
|
15
15
|
import { useUserHasResponded } from '../../../../domains/app'
|
|
16
16
|
import { className } from '../../../../lib/css'
|
|
17
|
-
import
|
|
17
|
+
import Text from '../../conversation/event/text'
|
|
18
18
|
import { useI18n } from '../../../../domains/i18n'
|
|
19
19
|
|
|
20
20
|
const WindowView = () => {
|
|
@@ -60,20 +60,20 @@ const WindowView = () => {
|
|
|
60
60
|
'unstarted-wrapper--continue',
|
|
61
61
|
)}
|
|
62
62
|
>
|
|
63
|
-
<
|
|
63
|
+
<Text event={continueChatEvent} />
|
|
64
64
|
</div>
|
|
65
65
|
</InOutTransition>
|
|
66
66
|
<InOutTransition
|
|
67
67
|
isActive={isOpen}
|
|
68
68
|
transitionStartState={transitionStartStates.notRendered}
|
|
69
69
|
>
|
|
70
|
-
<
|
|
70
|
+
<Chat>
|
|
71
71
|
{isOpen && <CollapseButton onClick={closeChat} />}
|
|
72
72
|
<ChatFrame interruptComponent={Interrupt}>
|
|
73
73
|
<Conversation />
|
|
74
74
|
<EntryContainer />
|
|
75
75
|
</ChatFrame>
|
|
76
|
-
</
|
|
76
|
+
</Chat>
|
|
77
77
|
</InOutTransition>
|
|
78
78
|
</>
|
|
79
79
|
)
|