@seamly/web-ui 20.7.0 → 20.8.0-alpha.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/CHANGELOG.md +212 -16
- package/build/dist/lib/hooks.js +1 -1
- package/build/dist/lib/hooks.min.js +1 -1
- package/build/dist/lib/index.debug.js +939 -784
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +186 -130
- package/build/dist/lib/index.js +24806 -19703
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/index.min.js.LICENSE.txt +38 -4
- package/build/dist/lib/standalone.js +32726 -26838
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/standalone.min.js.LICENSE.txt +39 -0
- package/build/dist/lib/storage.js +2 -2
- package/build/dist/lib/storage.min.js +1 -1
- package/build/dist/lib/style-guide.js +8649 -7863
- package/build/dist/lib/style-guide.min.js +2 -1
- package/build/dist/lib/style-guide.min.js.LICENSE.txt +38 -0
- package/build/dist/lib/utils.js +1 -2
- package/build/dist/lib/utils.min.js +1 -1
- package/package.json +19 -9
- package/src/icons/avatar_agent-32.svg +7 -0
- package/src/icons/avatar_bot-32.svg +6 -1
- package/src/javascripts/api/index.js +1 -1
- package/src/javascripts/{config.js → config.ts} +3 -1
- package/src/javascripts/config.types.ts +95 -0
- package/src/javascripts/domains/app/actions.ts +83 -0
- package/src/javascripts/domains/app/app.types.ts +3 -0
- package/src/javascripts/domains/app/hooks.js +3 -5
- package/src/javascripts/domains/app/selectors.ts +6 -0
- package/src/javascripts/domains/app/slice.ts +30 -0
- package/src/javascripts/domains/config/actions.ts +45 -0
- package/src/javascripts/domains/config/hooks.ts +19 -0
- package/src/javascripts/domains/config/selectors.ts +24 -0
- package/src/javascripts/domains/config/slice.ts +111 -0
- package/src/javascripts/domains/errors/index.js +13 -9
- package/src/javascripts/domains/forms/context.ts +14 -0
- package/src/javascripts/domains/forms/forms.types.ts +24 -0
- package/src/javascripts/domains/forms/{hooks.js → hooks.ts} +23 -26
- package/src/javascripts/domains/forms/{provider.js → provider.tsx} +20 -14
- package/src/javascripts/domains/forms/{selectors.js → selectors.ts} +7 -8
- package/src/javascripts/domains/forms/slice.ts +84 -0
- package/src/javascripts/domains/forms/utils.ts +15 -0
- package/src/javascripts/domains/i18n/actions.ts +24 -0
- package/src/javascripts/domains/i18n/{hooks.js → hooks.ts} +2 -2
- package/src/javascripts/domains/i18n/i18n.types.ts +6 -0
- package/src/javascripts/domains/i18n/selectors.ts +16 -0
- package/src/javascripts/domains/i18n/{reducer.js → slice.ts} +43 -37
- package/src/javascripts/domains/interrupt/{hooks.js → hooks.ts} +2 -2
- package/src/javascripts/domains/interrupt/{middleware.js → middleware.ts} +11 -8
- package/src/javascripts/domains/interrupt/selectors.ts +6 -0
- package/src/javascripts/domains/interrupt/slice.ts +40 -0
- package/src/javascripts/domains/options/middleware.js +9 -6
- package/src/javascripts/domains/redux/redux.types.ts +11 -0
- package/src/javascripts/domains/store/index.ts +53 -0
- package/src/javascripts/domains/store/slice.ts +639 -0
- package/src/javascripts/domains/store/store.types.ts +135 -0
- package/src/javascripts/domains/translations/components/chat-status.js +2 -2
- package/src/javascripts/domains/translations/components/options-button.js +1 -1
- package/src/javascripts/domains/translations/components/options-dialog/form.js +5 -5
- package/src/javascripts/domains/translations/components/options-dialog/index.js +2 -2
- package/src/javascripts/domains/translations/{hooks.js → hooks.ts} +28 -23
- package/src/javascripts/domains/translations/middleware.js +29 -27
- package/src/javascripts/domains/translations/selectors.js +4 -9
- package/src/javascripts/domains/translations/slice.ts +67 -0
- package/src/javascripts/domains/translations/translations.types.ts +12 -0
- package/src/javascripts/domains/visibility/{actions.js → actions.ts} +25 -19
- package/src/javascripts/domains/visibility/{hooks.js → hooks.ts} +13 -10
- package/src/javascripts/domains/visibility/{selectors.js → selectors.ts} +3 -6
- package/src/javascripts/domains/visibility/slice.ts +38 -0
- package/src/javascripts/domains/visibility/utils.js +0 -9
- package/src/javascripts/domains/visibility/visibility.types.ts +6 -0
- package/src/javascripts/index.ts +92 -0
- package/src/javascripts/lib/engine/index.js +15 -11
- package/src/javascripts/lib/external-api/initialize-api.js +1 -1
- package/src/javascripts/lib/id.js +5 -8
- package/src/javascripts/lib/mutex.js +3 -1
- package/src/javascripts/lib/store/providers/cookie-storage.js +1 -1
- package/src/javascripts/lib/store/providers/session-storage.js +1 -1
- package/src/javascripts/package/hooks.js +2 -2
- package/src/javascripts/package/utils.js +0 -1
- package/src/javascripts/schema.ts +1455 -0
- package/src/javascripts/style-guide/components/app.js +4 -4
- package/src/javascripts/style-guide/components/static-core.js +87 -65
- package/src/javascripts/style-guide/components/view.js +4 -4
- package/src/javascripts/style-guide/state-helpers/index.js +5 -5
- package/src/javascripts/style-guide/states.js +6 -4
- package/src/javascripts/style-guide.ts +5 -0
- package/src/javascripts/ui/components/app-options/index.js +2 -4
- package/src/javascripts/ui/components/conversation/component-filter.js +1 -1
- package/src/javascripts/ui/components/conversation/conversation.js +5 -5
- package/src/javascripts/ui/components/conversation/event/card-message.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-component/components/controls.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/components/slide.js +1 -1
- package/src/javascripts/ui/components/conversation/event/carousel-message/index.js +1 -1
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +2 -2
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +11 -14
- package/src/javascripts/ui/components/conversation/event/cta.js +1 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/default.js +1 -1
- package/src/javascripts/ui/components/conversation/event/divider/variants/new-translation.js +5 -2
- package/src/javascripts/ui/components/conversation/event/event-participant.js +2 -2
- package/src/javascripts/ui/components/conversation/event/hooks/use-formatted-date.js +2 -2
- package/src/javascripts/ui/components/conversation/event/image-lightbox.js +1 -1
- package/src/javascripts/ui/components/conversation/event/image.js +5 -7
- package/src/javascripts/ui/components/conversation/event/participant.js +1 -1
- package/src/javascripts/ui/components/conversation/event/splash.js +3 -3
- package/src/javascripts/ui/components/conversation/event/text.js +1 -1
- package/src/javascripts/ui/components/conversation/event/translation.js +2 -2
- package/src/javascripts/ui/components/conversation/event/upload.js +2 -2
- package/src/javascripts/ui/components/conversation/event/video.js +1 -1
- package/src/javascripts/ui/components/conversation/message-container.js +4 -4
- package/src/javascripts/ui/components/core/seamly-api-context.js +1 -1
- package/src/javascripts/ui/components/core/seamly-core.js +15 -14
- package/src/javascripts/ui/components/core/seamly-event-subscriber.js +96 -91
- package/src/javascripts/ui/components/core/seamly-file-upload.js +20 -24
- package/src/javascripts/ui/components/core/seamly-initializer.js +1 -1
- package/src/javascripts/ui/components/core/seamly-instance-functions-loader.js +5 -4
- package/src/javascripts/ui/components/core/seamly-new-notifications.js +2 -2
- package/src/javascripts/ui/components/core/seamly-read-state.js +10 -17
- package/src/javascripts/ui/components/entry/deprecated-toggle-button.js +3 -3
- package/src/javascripts/ui/components/entry/entry-container.js +4 -6
- package/src/javascripts/ui/components/entry/text-entry/hooks.js +3 -3
- package/src/javascripts/ui/components/entry/text-entry/index.js +3 -2
- package/src/javascripts/ui/components/entry/text-entry/text-entry-form.js +6 -10
- package/src/javascripts/ui/components/entry/upload/file-upload-form.js +2 -2
- package/src/javascripts/ui/components/entry/upload/index.js +10 -9
- package/src/javascripts/ui/components/entry/upload-toggle.js +2 -2
- package/src/javascripts/ui/components/faq/faq.js +6 -6
- package/src/javascripts/ui/components/form-controls/file-input.js +1 -1
- package/src/javascripts/ui/components/form-controls/form.js +1 -1
- package/src/javascripts/ui/components/form-controls/input.js +1 -1
- package/src/javascripts/ui/components/form-controls/select.js +1 -1
- package/src/javascripts/ui/components/layout/agent-info.js +4 -4
- package/src/javascripts/ui/components/layout/chat-frame.js +3 -3
- package/src/javascripts/ui/components/layout/chat.js +11 -12
- package/src/javascripts/ui/components/layout/deprecated-app-frame.js +10 -9
- package/src/javascripts/ui/components/layout/header.js +1 -1
- package/src/javascripts/ui/components/layout/interrupt.js +23 -24
- package/src/javascripts/ui/components/layout/pre-chat-messages.js +11 -11
- package/src/javascripts/ui/components/layout/privacy-disclaimer.js +2 -2
- package/src/javascripts/ui/components/options/options-button.js +12 -10
- 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/suggestions/index.js +9 -8
- package/src/javascripts/ui/components/view/deprecated-view.js +19 -16
- package/src/javascripts/ui/components/view/index.js +12 -12
- package/src/javascripts/ui/components/view/inline-view.js +2 -2
- package/src/javascripts/ui/components/view/window-view/collapse-button.js +3 -3
- package/src/javascripts/ui/components/view/window-view/index.js +13 -13
- package/src/javascripts/ui/components/view/window-view/window-open-button.js +13 -13
- package/src/javascripts/ui/components/warnings/idle-detach-warning.js +1 -1
- package/src/javascripts/ui/components/warnings/resume-conversation-prompt.js +1 -1
- package/src/javascripts/ui/components/widgets/lightbox.js +2 -2
- package/src/javascripts/ui/components/widgets/upload-progress.js +1 -1
- package/src/javascripts/ui/hooks/component-helper-hooks.js +1 -1
- package/src/javascripts/ui/hooks/file-upload-hooks.js +4 -6
- package/src/javascripts/ui/hooks/focus-helper-hooks.js +14 -12
- package/src/javascripts/ui/hooks/live-region-hooks.js +2 -0
- package/src/javascripts/ui/hooks/seamly-api-hooks.js +8 -3
- package/src/javascripts/ui/hooks/seamly-entry-hooks.js +28 -25
- package/src/javascripts/ui/hooks/seamly-hooks.js +25 -25
- package/src/javascripts/ui/hooks/seamly-option-hooks.js +17 -19
- package/src/javascripts/ui/hooks/seamly-state-hooks.js +14 -13
- package/src/javascripts/ui/hooks/use-seamly-chat.js +15 -25
- package/src/javascripts/ui/hooks/use-seamly-commands.js +46 -46
- package/src/javascripts/ui/hooks/use-seamly-idle-detach-countdown.js +22 -24
- package/src/javascripts/ui/hooks/use-seamly-resume-conversation-prompt.js +8 -9
- package/src/javascripts/ui/hooks/use-single-file-upload.js +4 -6
- package/src/javascripts/ui/hooks/utility-hooks.js +4 -4
- package/src/javascripts/ui/utils/form-utils.js +0 -145
- package/src/javascripts/ui/utils/general-utils.js +3 -4
- package/src/javascripts/ui/utils/seamly-utils.ts +73 -0
- package/webpack/config.common.js +16 -0
- package/webpack/config.dev.js +1 -0
- package/webpack/config.package.js +26 -5
- package/webpack/defaults.js +7 -2
- package/webpack/parts/babel-loader-browser-plugins.js +1 -0
- package/webpack/parts/dev-server.js +4 -3
- package/src/javascripts/domains/app/actions.js +0 -112
- package/src/javascripts/domains/app/index.js +0 -7
- package/src/javascripts/domains/app/reducer.js +0 -16
- package/src/javascripts/domains/app/selectors.js +0 -8
- package/src/javascripts/domains/app/utils.js +0 -4
- package/src/javascripts/domains/config/actions.js +0 -7
- package/src/javascripts/domains/config/hooks.js +0 -23
- package/src/javascripts/domains/config/index.js +0 -7
- package/src/javascripts/domains/config/reducer.js +0 -79
- package/src/javascripts/domains/config/selectors.js +0 -23
- package/src/javascripts/domains/config/utils.js +0 -4
- package/src/javascripts/domains/forms/actions.js +0 -21
- package/src/javascripts/domains/forms/context.js +0 -6
- package/src/javascripts/domains/forms/index.js +0 -8
- package/src/javascripts/domains/forms/reducer.js +0 -84
- package/src/javascripts/domains/forms/utils.js +0 -20
- package/src/javascripts/domains/i18n/actions.js +0 -20
- package/src/javascripts/domains/i18n/index.js +0 -7
- package/src/javascripts/domains/i18n/selectors.js +0 -15
- package/src/javascripts/domains/i18n/utils.js +0 -4
- package/src/javascripts/domains/interrupt/actions.js +0 -4
- package/src/javascripts/domains/interrupt/index.js +0 -9
- package/src/javascripts/domains/interrupt/reducer.js +0 -22
- package/src/javascripts/domains/interrupt/selectors.js +0 -6
- package/src/javascripts/domains/interrupt/utils.js +0 -4
- package/src/javascripts/domains/options/index.js +0 -1
- package/src/javascripts/domains/redux/context.js +0 -6
- package/src/javascripts/domains/redux/create-redux-store.js +0 -21
- package/src/javascripts/domains/redux/hooks.js +0 -80
- package/src/javascripts/domains/redux/index.js +0 -19
- package/src/javascripts/domains/redux/provider.js +0 -5
- package/src/javascripts/domains/redux/utils.js +0 -12
- package/src/javascripts/domains/store/index.js +0 -46
- package/src/javascripts/domains/store/state-reducer.js +0 -56
- package/src/javascripts/domains/translations/actions.js +0 -11
- package/src/javascripts/domains/translations/index.js +0 -10
- package/src/javascripts/domains/translations/reducer.js +0 -69
- package/src/javascripts/domains/translations/utils.js +0 -4
- package/src/javascripts/domains/visibility/index.js +0 -8
- package/src/javascripts/domains/visibility/reducer.js +0 -24
- package/src/javascripts/index.js +0 -153
- package/src/javascripts/lib/redux-helpers/index.js +0 -99
- package/src/javascripts/style-guide.js +0 -5
- package/src/javascripts/ui/hooks/use-seamly-dispatch.js +0 -3
- package/src/javascripts/ui/utils/seamly-utils.js +0 -832
|
@@ -21,7 +21,6 @@ module.exports = (env = {}, argv = {}, configOverrides = {}) => {
|
|
|
21
21
|
ROOT,
|
|
22
22
|
|
|
23
23
|
BABEL_TRANSPILE_MODULES,
|
|
24
|
-
|
|
25
24
|
BROWSERS,
|
|
26
25
|
} = implConfig
|
|
27
26
|
|
|
@@ -52,11 +51,18 @@ module.exports = (env = {}, argv = {}, configOverrides = {}) => {
|
|
|
52
51
|
],
|
|
53
52
|
resolve: {
|
|
54
53
|
modules: [path.resolve(__dirname, '../src/javascripts'), 'node_modules'],
|
|
54
|
+
alias: {
|
|
55
|
+
react: 'preact/compat',
|
|
56
|
+
'react-dom/test-utils': 'preact/test-utils',
|
|
57
|
+
'react-dom': 'preact/compat', // Must be below test-utils
|
|
58
|
+
'react/jsx-runtime': 'preact/jsx-runtime',
|
|
59
|
+
},
|
|
60
|
+
extensions: ['.ts', '.tsx', '.js'],
|
|
55
61
|
},
|
|
56
62
|
module: {
|
|
57
63
|
rules: [
|
|
58
64
|
{
|
|
59
|
-
test: /\.
|
|
65
|
+
test: /\.(j|t)s$/,
|
|
60
66
|
include: BABEL_TRANSPILE_MODULES.map((moduleName) =>
|
|
61
67
|
path.resolve('node_modules', moduleName),
|
|
62
68
|
),
|
|
@@ -66,20 +72,35 @@ module.exports = (env = {}, argv = {}, configOverrides = {}) => {
|
|
|
66
72
|
},
|
|
67
73
|
},
|
|
68
74
|
{
|
|
69
|
-
test: /\.
|
|
75
|
+
test: /\.(j|t)s$/,
|
|
70
76
|
exclude: /(node_modules|bower_components)/,
|
|
71
77
|
loader: 'babel-loader',
|
|
72
78
|
options: {
|
|
73
79
|
plugins: generateBabelLoaderPluginsPart(env, argv, implConfig),
|
|
74
80
|
},
|
|
75
81
|
},
|
|
82
|
+
{
|
|
83
|
+
test: /\.tsx?$/,
|
|
84
|
+
loader: 'ts-loader',
|
|
85
|
+
exclude: /node_modules|\.d\.ts$/,
|
|
86
|
+
options: {
|
|
87
|
+
compilerOptions: {
|
|
88
|
+
outDir: 'build',
|
|
89
|
+
noEmit: false,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
test: /\.d\.ts$/,
|
|
95
|
+
loader: 'ignore-loader',
|
|
96
|
+
},
|
|
76
97
|
],
|
|
77
98
|
},
|
|
78
99
|
}
|
|
79
100
|
|
|
80
101
|
const packageConfig = webpackMerge(baseConfig, {
|
|
81
102
|
entry: {
|
|
82
|
-
index: path.join(SRC_ROOT, 'javascripts/index.
|
|
103
|
+
index: path.join(SRC_ROOT, 'javascripts/index.ts'),
|
|
83
104
|
},
|
|
84
105
|
})
|
|
85
106
|
|
|
@@ -93,7 +114,7 @@ module.exports = (env = {}, argv = {}, configOverrides = {}) => {
|
|
|
93
114
|
|
|
94
115
|
const styleguideConfig = webpackMerge(baseConfig, {
|
|
95
116
|
entry: {
|
|
96
|
-
'style-guide': path.join(SRC_ROOT, 'javascripts/style-guide.
|
|
117
|
+
'style-guide': path.join(SRC_ROOT, 'javascripts/style-guide.ts'),
|
|
97
118
|
},
|
|
98
119
|
externals: [/^@seamly\/web-ui(\/.*)?/i],
|
|
99
120
|
})
|
package/webpack/defaults.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
1
2
|
const path = require('path')
|
|
2
3
|
|
|
3
4
|
const BABEL_TRANSPILE_MODULES = ['debug', 'superagent', 'phoenix']
|
|
@@ -10,7 +11,7 @@ const PUBLIC_ROOT = path.join(ROOT, 'public')
|
|
|
10
11
|
const PUBLIC_TEST_ROOT = path.join(PUBLIC_ROOT, 'test')
|
|
11
12
|
const PUBLIC_STYLEGUIDE_ROOT = path.join(PUBLIC_ROOT, 'style-guide')
|
|
12
13
|
|
|
13
|
-
const PUBLIC_PATH = process.env
|
|
14
|
+
const PUBLIC_PATH = process.env.PUBLIC_PATH || '/'
|
|
14
15
|
|
|
15
16
|
const ALIASSES = {
|
|
16
17
|
'@seamly/web-ui$': path.resolve(SRC_ROOT, 'javascripts'),
|
|
@@ -40,7 +41,7 @@ const ALIASSES = {
|
|
|
40
41
|
),
|
|
41
42
|
'@seamly/web-ui/style-guide$': path.resolve(
|
|
42
43
|
SRC_ROOT,
|
|
43
|
-
'javascripts/style-guide.
|
|
44
|
+
'javascripts/style-guide.ts',
|
|
44
45
|
),
|
|
45
46
|
'@seamly/web-ui/src/stylesheets/styles.scss': path.resolve(
|
|
46
47
|
SRC_ROOT,
|
|
@@ -55,6 +56,10 @@ const ALIASSES = {
|
|
|
55
56
|
'style-guide.scss',
|
|
56
57
|
),
|
|
57
58
|
lib: path.resolve(SRC_ROOT, 'javascripts/lib/'),
|
|
59
|
+
react: 'preact/compat',
|
|
60
|
+
'react-dom/test-utils': 'preact/test-utils',
|
|
61
|
+
'react-dom': 'preact/compat', // Must be below test-utils
|
|
62
|
+
'react/jsx-runtime': 'preact/jsx-runtime',
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
module.exports = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
1
2
|
const path = require('path')
|
|
2
3
|
|
|
3
4
|
module.exports = (env, argv, { PUBLIC_PATH, SRC_ROOT }) => ({
|
|
@@ -13,9 +14,9 @@ module.exports = (env, argv, { PUBLIC_PATH, SRC_ROOT }) => ({
|
|
|
13
14
|
},
|
|
14
15
|
resolve: {
|
|
15
16
|
alias: {
|
|
16
|
-
api: path.resolve(SRC_ROOT, 'javascripts/api'),
|
|
17
|
-
domains: path.resolve(SRC_ROOT, 'javascripts/domains'),
|
|
18
|
-
ui: path.resolve(SRC_ROOT, 'javascripts/ui'),
|
|
17
|
+
api: path.resolve(SRC_ROOT, 'javascripts/api/'),
|
|
18
|
+
domains: path.resolve(SRC_ROOT, 'javascripts/domains/'),
|
|
19
|
+
ui: path.resolve(SRC_ROOT, 'javascripts/ui/'),
|
|
19
20
|
},
|
|
20
21
|
},
|
|
21
22
|
})
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { actionTypes, seamlyActions } from 'ui/utils/seamly-utils'
|
|
2
|
-
import * as ConfigActions from 'domains/config/actions'
|
|
3
|
-
import * as I18nActions from 'domains/i18n/actions'
|
|
4
|
-
import * as TranslationActions from 'domains/translations/actions'
|
|
5
|
-
import * as VisibilityActions from 'domains/visibility/actions'
|
|
6
|
-
import SeamlyUnavailableError from 'api/errors/seamly-unavailable-error'
|
|
7
|
-
import SeamlySessionExpiredError from 'api/errors/seamly-session-expired-error'
|
|
8
|
-
import * as InterruptActions from 'domains/interrupt/actions'
|
|
9
|
-
import { createAction, createThunk } from './utils'
|
|
10
|
-
|
|
11
|
-
export const setHasResponded = createAction(
|
|
12
|
-
'setHasResponded',
|
|
13
|
-
(hasResponded) => ({ hasResponded }),
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
export const initialize = createThunk(
|
|
17
|
-
'initialize',
|
|
18
|
-
async (_, { dispatch, extra: { api, config } }) => {
|
|
19
|
-
dispatch(ConfigActions.initialize(config))
|
|
20
|
-
let locale = config?.context?.locale
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
const {
|
|
24
|
-
features,
|
|
25
|
-
defaultLocale,
|
|
26
|
-
preChat,
|
|
27
|
-
agentParticipant,
|
|
28
|
-
userParticipant,
|
|
29
|
-
startChatIcon,
|
|
30
|
-
} = await api.getConfig()
|
|
31
|
-
|
|
32
|
-
dispatch({ type: seamlyActions.SET_FEATURES, features })
|
|
33
|
-
locale = locale || defaultLocale
|
|
34
|
-
dispatch(I18nActions.setInitialLocale(locale))
|
|
35
|
-
dispatch(
|
|
36
|
-
ConfigActions.setPreChatEvents(
|
|
37
|
-
preChat.map((payload) => ({ type: 'message', payload })),
|
|
38
|
-
),
|
|
39
|
-
)
|
|
40
|
-
dispatch(
|
|
41
|
-
ConfigActions.update({
|
|
42
|
-
agentParticipant,
|
|
43
|
-
userParticipant,
|
|
44
|
-
startChatIcon,
|
|
45
|
-
}),
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
if (agentParticipant?.name) {
|
|
49
|
-
dispatch({
|
|
50
|
-
type: seamlyActions.SET_HEADER_SUB_TITLE,
|
|
51
|
-
title: agentParticipant.name,
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
} catch (e) {
|
|
55
|
-
throw new SeamlyUnavailableError()
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
if (api.hasConversation()) {
|
|
60
|
-
const initialState = await api.getConversationIntitialState()
|
|
61
|
-
dispatch({ type: seamlyActions.SET_INITIAL_STATE, initialState })
|
|
62
|
-
|
|
63
|
-
locale = initialState.translation?.locale || locale
|
|
64
|
-
|
|
65
|
-
if ('userResponded' in initialState) {
|
|
66
|
-
dispatch(setHasResponded(initialState.userResponded))
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
if (config?.context?.topic) {
|
|
70
|
-
api.send('action', {
|
|
71
|
-
type: actionTypes.setTopic,
|
|
72
|
-
body: {
|
|
73
|
-
name: config.context.topic,
|
|
74
|
-
// Separate fallback message is not needed here. Only an attached service will use this, but none will
|
|
75
|
-
// be attached before the conversation has started (meaning the fallback message will never be shown).
|
|
76
|
-
fallbackMessage: config.context.topic,
|
|
77
|
-
},
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
if (config?.context?.translationLocale) {
|
|
81
|
-
locale = config.context.translationLocale
|
|
82
|
-
api.send('action', {
|
|
83
|
-
type: actionTypes.setTranslation,
|
|
84
|
-
body: { enabled: true, locale },
|
|
85
|
-
})
|
|
86
|
-
dispatch(TranslationActions.enable(locale))
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (e) {
|
|
90
|
-
if (e instanceof SeamlySessionExpiredError) {
|
|
91
|
-
throw e
|
|
92
|
-
}
|
|
93
|
-
throw new SeamlyUnavailableError()
|
|
94
|
-
} finally {
|
|
95
|
-
await dispatch(I18nActions.setLocale(locale))
|
|
96
|
-
dispatch(VisibilityActions.initialize())
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
export const reset = createThunk(
|
|
102
|
-
'reset',
|
|
103
|
-
async (config, { dispatch, extra: { api } }) => {
|
|
104
|
-
try {
|
|
105
|
-
await api.disconnect()
|
|
106
|
-
await api.clearStore()
|
|
107
|
-
dispatch(initialize())
|
|
108
|
-
} catch (error) {
|
|
109
|
-
dispatch(InterruptActions.set(error))
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createReducer } from './utils'
|
|
2
|
-
import * as Actions from './actions'
|
|
3
|
-
|
|
4
|
-
const initialState = {
|
|
5
|
-
userHasResponded: false,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default createReducer(
|
|
9
|
-
{
|
|
10
|
-
[Actions.setHasResponded]: (state, { hasResponded }) => ({
|
|
11
|
-
...state,
|
|
12
|
-
userHasResponded: hasResponded,
|
|
13
|
-
}),
|
|
14
|
-
},
|
|
15
|
-
initialState,
|
|
16
|
-
)
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createAction } from './utils'
|
|
2
|
-
|
|
3
|
-
export const initialize = createAction('initialize', (config) => ({ config }))
|
|
4
|
-
export const update = createAction('update', (config) => ({ config }))
|
|
5
|
-
export const setPreChatEvents = createAction('setPreChatEvents', (events) => ({
|
|
6
|
-
events,
|
|
7
|
-
}))
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { useSelector } from 'domains/redux'
|
|
2
|
-
import * as Selectors from './selectors'
|
|
3
|
-
|
|
4
|
-
export function useConfig() {
|
|
5
|
-
return useSelector(Selectors.selectConfig)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function useParticipants() {
|
|
9
|
-
const { agentParticipant, userParticipant } = useSelector(
|
|
10
|
-
Selectors.selectConfig,
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
return {
|
|
14
|
-
agent: agentParticipant,
|
|
15
|
-
user: userParticipant,
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function useStartChatIcon() {
|
|
20
|
-
const { startChatIcon } = useSelector(Selectors.selectConfig)
|
|
21
|
-
|
|
22
|
-
return startChatIcon
|
|
23
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { defaultConfig } from 'config'
|
|
2
|
-
import { pick } from 'ui/utils/general-utils'
|
|
3
|
-
import * as AppActions from 'domains/app/actions'
|
|
4
|
-
import { createReducer } from './utils'
|
|
5
|
-
import * as Actions from './actions'
|
|
6
|
-
|
|
7
|
-
const initialState = {
|
|
8
|
-
...defaultConfig,
|
|
9
|
-
hideOnNoUserResponse: false,
|
|
10
|
-
connectWhenInView: true,
|
|
11
|
-
showDisclaimer: false,
|
|
12
|
-
showFaq: false,
|
|
13
|
-
customComponents: {},
|
|
14
|
-
defaults: {},
|
|
15
|
-
preChatEvents: [],
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const configKeys = [
|
|
19
|
-
'hideOnNoUserResponse',
|
|
20
|
-
'connectWhenInView',
|
|
21
|
-
'showDisclaimer',
|
|
22
|
-
'showFaq',
|
|
23
|
-
'namespace',
|
|
24
|
-
'customComponents',
|
|
25
|
-
'defaults',
|
|
26
|
-
'layoutMode',
|
|
27
|
-
'api',
|
|
28
|
-
'zIndex',
|
|
29
|
-
'context',
|
|
30
|
-
'appContainerClassNames',
|
|
31
|
-
'messages',
|
|
32
|
-
'visible',
|
|
33
|
-
'visibilityCallback',
|
|
34
|
-
'errorCallback',
|
|
35
|
-
'agentParticipant',
|
|
36
|
-
'userParticipant',
|
|
37
|
-
'startChatIcon',
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
const updateState = (state, { config }) => {
|
|
41
|
-
const { messages, ...partialConfig } = pick(config, configKeys)
|
|
42
|
-
let newState = state
|
|
43
|
-
if (Object.keys(partialConfig).length > 0) {
|
|
44
|
-
newState = {
|
|
45
|
-
...newState,
|
|
46
|
-
...partialConfig,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (messages) {
|
|
50
|
-
newState = {
|
|
51
|
-
...newState,
|
|
52
|
-
messages: {
|
|
53
|
-
...newState.messages,
|
|
54
|
-
...messages,
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return newState
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default createReducer(
|
|
63
|
-
{
|
|
64
|
-
[Actions.initialize]: (state, action) => {
|
|
65
|
-
return updateState(state, action)
|
|
66
|
-
},
|
|
67
|
-
[Actions.update]: (state, action) => {
|
|
68
|
-
return updateState(state, action)
|
|
69
|
-
},
|
|
70
|
-
[AppActions.initialize.pending]: () => initialState,
|
|
71
|
-
[Actions.setPreChatEvents]: (state, { events }) => {
|
|
72
|
-
return {
|
|
73
|
-
...state,
|
|
74
|
-
preChatEvents: events,
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
initialState,
|
|
79
|
-
)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createSelector } from 'reselect'
|
|
2
|
-
import { visibilityStates } from 'domains/visibility/constants'
|
|
3
|
-
import { selectState } from './utils'
|
|
4
|
-
|
|
5
|
-
export const selectConfig = createSelector(selectState, (config) => {
|
|
6
|
-
let newConfig = {
|
|
7
|
-
visible:
|
|
8
|
-
config?.layoutMode === 'inline'
|
|
9
|
-
? visibilityStates.open
|
|
10
|
-
: visibilityStates.minimized,
|
|
11
|
-
appContainerClassNames: config.appContainerClassNames || [],
|
|
12
|
-
...config,
|
|
13
|
-
}
|
|
14
|
-
if (typeof newConfig.appContainerClassNames === 'function') {
|
|
15
|
-
newConfig = {
|
|
16
|
-
...newConfig,
|
|
17
|
-
appContainerClassNames: newConfig.appContainerClassNames(newConfig),
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return newConfig
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
export { selectState }
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { createActions } from './utils'
|
|
2
|
-
|
|
3
|
-
export const [registerForm, deregisterForm] = createActions('form', {
|
|
4
|
-
register: (formId, persistData) => ({ formId, persistData }),
|
|
5
|
-
deregister: (formId) => ({ formId }),
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
export const [
|
|
9
|
-
registerControl,
|
|
10
|
-
deregisterControl,
|
|
11
|
-
updateControlValue,
|
|
12
|
-
updateControlTouched,
|
|
13
|
-
] = createActions('control', {
|
|
14
|
-
register: (formId, name) => ({
|
|
15
|
-
formId,
|
|
16
|
-
name,
|
|
17
|
-
}),
|
|
18
|
-
deregister: (formId, name) => ({ formId, name }),
|
|
19
|
-
updateValue: (formId, name, value) => ({ formId, name, value }),
|
|
20
|
-
updateTouched: (formId, name, touched) => ({ formId, name, touched }),
|
|
21
|
-
})
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import * as AppActions from 'domains/app/actions'
|
|
2
|
-
import { createReducer } from './utils'
|
|
3
|
-
import * as Actions from './actions'
|
|
4
|
-
|
|
5
|
-
const initialState = {}
|
|
6
|
-
|
|
7
|
-
const initialFormState = {
|
|
8
|
-
controls: {},
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const initialControlState = {
|
|
12
|
-
value: '',
|
|
13
|
-
touched: false,
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function updateFormControl(state, formId, name, controlState) {
|
|
17
|
-
const currentControlState =
|
|
18
|
-
state[formId]?.controls[name] || initialControlState
|
|
19
|
-
return {
|
|
20
|
-
...state,
|
|
21
|
-
[formId]: {
|
|
22
|
-
...state[formId],
|
|
23
|
-
controls: {
|
|
24
|
-
...state[formId].controls,
|
|
25
|
-
[name]: {
|
|
26
|
-
...currentControlState,
|
|
27
|
-
...controlState,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default createReducer(
|
|
35
|
-
{
|
|
36
|
-
// Form handlers
|
|
37
|
-
[Actions.registerForm]: (state, { formId, persistData }) => {
|
|
38
|
-
const formState = persistData
|
|
39
|
-
? state[formId] ?? { ...initialFormState, persistData }
|
|
40
|
-
: { ...initialFormState, persistData }
|
|
41
|
-
return {
|
|
42
|
-
...state,
|
|
43
|
-
[formId]: formState,
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
[Actions.deregisterForm]: (state, { formId }) => {
|
|
47
|
-
const newState = { ...state }
|
|
48
|
-
if (!newState[formId]?.persistData) {
|
|
49
|
-
delete newState[formId]
|
|
50
|
-
}
|
|
51
|
-
return newState
|
|
52
|
-
},
|
|
53
|
-
// Form control handlers
|
|
54
|
-
[Actions.registerControl]: (state, { name, formId }) => {
|
|
55
|
-
return updateFormControl(state, formId, name)
|
|
56
|
-
},
|
|
57
|
-
[Actions.deregisterControl]: (state, { formId, name }) => {
|
|
58
|
-
const form = state[formId]
|
|
59
|
-
if (!form) {
|
|
60
|
-
return state
|
|
61
|
-
}
|
|
62
|
-
if (form.persistData) {
|
|
63
|
-
return state
|
|
64
|
-
}
|
|
65
|
-
const controls = { ...form.controls }
|
|
66
|
-
delete controls[name]
|
|
67
|
-
return {
|
|
68
|
-
...state,
|
|
69
|
-
[formId]: {
|
|
70
|
-
...form,
|
|
71
|
-
controls,
|
|
72
|
-
},
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
[Actions.updateControlValue]: (state, { formId, name, value }) => {
|
|
76
|
-
return updateFormControl(state, formId, name, { value })
|
|
77
|
-
},
|
|
78
|
-
[Actions.updateControlTouched]: (state, { formId, name, touched }) => {
|
|
79
|
-
return updateFormControl(state, formId, name, { touched })
|
|
80
|
-
},
|
|
81
|
-
[AppActions.initialize.pending]: () => initialState,
|
|
82
|
-
},
|
|
83
|
-
initialState,
|
|
84
|
-
)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createDomain } from 'lib/redux-helpers'
|
|
2
|
-
|
|
3
|
-
export const { createActions, createReducer, selectState } =
|
|
4
|
-
createDomain('forms')
|
|
5
|
-
|
|
6
|
-
export function validate(values, schema = {}) {
|
|
7
|
-
return Object.entries(schema).reduce((errors, [key, validations]) => {
|
|
8
|
-
if (validations && !Array.isArray(validations)) {
|
|
9
|
-
// eslint-disable-next-line no-param-reassign
|
|
10
|
-
validations = [validations]
|
|
11
|
-
}
|
|
12
|
-
for (let i = 0; i < validations?.length ?? 0; i++) {
|
|
13
|
-
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
14
|
-
errors[key] = validations[i].errorText
|
|
15
|
-
break
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return errors
|
|
19
|
-
}, {})
|
|
20
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import createMutex from 'lib/mutex'
|
|
2
|
-
import { selectLocale } from './selectors'
|
|
3
|
-
import { createAction, createThunk } from './utils'
|
|
4
|
-
|
|
5
|
-
export const setInitialLocale = createAction('setInitialLocale', (locale) => ({
|
|
6
|
-
locale,
|
|
7
|
-
}))
|
|
8
|
-
|
|
9
|
-
const mutex = createMutex()
|
|
10
|
-
export const setLocale = createThunk(
|
|
11
|
-
'setLocale',
|
|
12
|
-
async (locale, { getState, extra: { api } }) => {
|
|
13
|
-
return mutex.runExclusively(() => {
|
|
14
|
-
if (locale === selectLocale(getState())) {
|
|
15
|
-
return undefined
|
|
16
|
-
}
|
|
17
|
-
return api.getTranslations(locale)
|
|
18
|
-
})
|
|
19
|
-
},
|
|
20
|
-
)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createSelector } from 'reselect'
|
|
2
|
-
import { selectState } from './utils'
|
|
3
|
-
|
|
4
|
-
export const selectTranslations = createSelector(
|
|
5
|
-
selectState,
|
|
6
|
-
(state) => state.translations,
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
export const selectInitialLocale = createSelector(
|
|
10
|
-
selectState,
|
|
11
|
-
(state) => state.initialLocale,
|
|
12
|
-
)
|
|
13
|
-
export const selectLocale = createSelector(selectState, (state) => state.locale)
|
|
14
|
-
|
|
15
|
-
export { selectState }
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as AppActions from 'domains/app/actions'
|
|
2
|
-
import { createReducer } from './utils'
|
|
3
|
-
import * as Actions from './actions'
|
|
4
|
-
|
|
5
|
-
const initialState = {
|
|
6
|
-
error: undefined,
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const handleError = (state, { error }) => ({
|
|
10
|
-
...state,
|
|
11
|
-
error,
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
export default createReducer(
|
|
15
|
-
{
|
|
16
|
-
[Actions.set]: handleError,
|
|
17
|
-
[AppActions.initialize.rejected]: handleError,
|
|
18
|
-
[Actions.clear]: () => initialState,
|
|
19
|
-
[AppActions.initialize.pending]: () => initialState,
|
|
20
|
-
},
|
|
21
|
-
initialState,
|
|
22
|
-
)
|