@seamly/web-ui 20.7.0 → 20.8.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/lib/hooks.js +1 -1
- package/build/dist/lib/hooks.min.js +1 -1
- package/build/dist/lib/index.debug.js +945 -790
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +187 -131
- package/build/dist/lib/index.js +24800 -19606
- 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 +32920 -26742
- 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 +8780 -7907
- 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/styles.css +1 -1
- 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 +96 -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 +113 -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} +40 -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 +642 -0
- package/src/javascripts/domains/store/store.types.ts +146 -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.ts +114 -0
- package/src/javascripts/domains/translations/middleware.js +29 -27
- package/src/javascripts/domains/translations/selectors.ts +12 -0
- package/src/javascripts/domains/translations/slice.ts +120 -0
- package/src/javascripts/domains/translations/translations.types.ts +19 -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 +1448 -0
- package/src/javascripts/style-guide/components/app.js +6 -6
- 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 +67 -7
- 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 +11 -7
- package/src/javascripts/ui/components/conversation/event/card-message.js +2 -2
- 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 +2 -2
- package/src/javascripts/ui/components/conversation/event/choice-prompt.js +3 -3
- package/src/javascripts/ui/components/conversation/event/conversation-suggestions.js +19 -15
- package/src/javascripts/ui/components/conversation/event/cta.js +2 -2
- 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 +44 -5
- 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 +6 -8
- package/src/javascripts/ui/components/conversation/event/participant.js +2 -2
- package/src/javascripts/ui/components/conversation/event/splash.js +4 -4
- package/src/javascripts/ui/components/conversation/event/text.js +2 -2
- package/src/javascripts/ui/components/conversation/event/translation.js +3 -3
- package/src/javascripts/ui/components/conversation/event/upload.js +3 -3
- package/src/javascripts/ui/components/conversation/event/video.js +2 -2
- package/src/javascripts/ui/components/conversation/message-container.js +4 -26
- 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 +98 -92
- 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 +9 -7
- 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 +14 -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 +14 -10
- 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 +20 -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/src/stylesheets/5-components/_message-carousel.scss +10 -8
- 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/CHANGELOG.md +0 -791
- 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/hooks.js +0 -103
- package/src/javascripts/domains/translations/index.js +0 -10
- package/src/javascripts/domains/translations/reducer.js +0 -69
- package/src/javascripts/domains/translations/selectors.js +0 -16
- 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
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import StoreContext from './context'
|
|
2
|
-
import StoreProvider from './provider'
|
|
3
|
-
import createReduxStore from './create-redux-store'
|
|
4
|
-
import {
|
|
5
|
-
useStoreContext,
|
|
6
|
-
useSelector,
|
|
7
|
-
useStoreDispatch,
|
|
8
|
-
useSelectorWithProps,
|
|
9
|
-
} from './hooks'
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
createReduxStore,
|
|
13
|
-
useSelector,
|
|
14
|
-
useSelectorWithProps,
|
|
15
|
-
useStoreDispatch,
|
|
16
|
-
useStoreContext,
|
|
17
|
-
StoreContext,
|
|
18
|
-
StoreProvider,
|
|
19
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const arrayContentEquals = (a, b) => {
|
|
2
|
-
if (a === b) {
|
|
3
|
-
return true
|
|
4
|
-
}
|
|
5
|
-
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {
|
|
6
|
-
return false
|
|
7
|
-
}
|
|
8
|
-
return a.every((value, idx) => b[idx] === value)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const getPropSelector = (propName, orDefault) => (_, props) =>
|
|
12
|
-
props[propName] || orDefault
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Reducer as appReducer } from 'domains/app'
|
|
2
|
-
import { Reducer as configReducer } from 'domains/config'
|
|
3
|
-
import { createMiddleware as createErrorsMiddleware } from 'domains/errors'
|
|
4
|
-
import { Reducer as formReducer } from 'domains/forms'
|
|
5
|
-
import { Reducer as i18nReducer } from 'domains/i18n'
|
|
6
|
-
import {
|
|
7
|
-
createMiddleware as createInterruptMiddleware,
|
|
8
|
-
Reducer as interruptReducer,
|
|
9
|
-
} from 'domains/interrupt'
|
|
10
|
-
import { createMiddleware as createOptionsMiddleware } from 'domains/options'
|
|
11
|
-
import { createReduxStore } from 'domains/redux'
|
|
12
|
-
import {
|
|
13
|
-
createMiddleware as createI18nMiddleware,
|
|
14
|
-
Reducer as translationsReducer,
|
|
15
|
-
} from 'domains/translations'
|
|
16
|
-
import { Reducer as visibilityReducer } from 'domains/visibility'
|
|
17
|
-
import thunkMiddleware from 'redux-thunk'
|
|
18
|
-
import stateReducer from './state-reducer'
|
|
19
|
-
|
|
20
|
-
export function createStore({ initialState, api, eventBus, config } = {}) {
|
|
21
|
-
const store = createReduxStore({
|
|
22
|
-
reducers: {
|
|
23
|
-
state: stateReducer,
|
|
24
|
-
[String(appReducer)]: appReducer,
|
|
25
|
-
[String(configReducer)]: configReducer,
|
|
26
|
-
[String(formReducer)]: formReducer,
|
|
27
|
-
[String(translationsReducer)]: translationsReducer,
|
|
28
|
-
[String(i18nReducer)]: i18nReducer,
|
|
29
|
-
[String(interruptReducer)]: interruptReducer,
|
|
30
|
-
[String(visibilityReducer)]: visibilityReducer,
|
|
31
|
-
},
|
|
32
|
-
initialState,
|
|
33
|
-
middlewares: [
|
|
34
|
-
createErrorsMiddleware({ api }),
|
|
35
|
-
thunkMiddleware.withExtraArgument({
|
|
36
|
-
api,
|
|
37
|
-
eventBus,
|
|
38
|
-
config,
|
|
39
|
-
}),
|
|
40
|
-
createInterruptMiddleware({ api }),
|
|
41
|
-
createOptionsMiddleware({ api }),
|
|
42
|
-
createI18nMiddleware,
|
|
43
|
-
],
|
|
44
|
-
})
|
|
45
|
-
return store
|
|
46
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// Legacy state reducer. Do not add new features here but extract/create new reducers as needed
|
|
2
|
-
|
|
3
|
-
import { randomId } from 'lib/id'
|
|
4
|
-
import { entryTypes, seamlyStateReducer } from 'ui/utils/seamly-utils'
|
|
5
|
-
import * as AppActions from 'domains/app/actions'
|
|
6
|
-
|
|
7
|
-
const initialState = {
|
|
8
|
-
events: [],
|
|
9
|
-
initialState: {},
|
|
10
|
-
unreadEvents: 0,
|
|
11
|
-
loadedImageEventIds: [],
|
|
12
|
-
isLoading: false,
|
|
13
|
-
idleDetachCountdown: { hasCountdown: false, isActive: false },
|
|
14
|
-
resumeConversationPrompt: false,
|
|
15
|
-
serviceInfo: {
|
|
16
|
-
activeServiceSessionId: '',
|
|
17
|
-
},
|
|
18
|
-
participantInfo: {
|
|
19
|
-
participants: {},
|
|
20
|
-
currentAgent: '',
|
|
21
|
-
},
|
|
22
|
-
headerTitles: {
|
|
23
|
-
title: null,
|
|
24
|
-
subTitle: '',
|
|
25
|
-
},
|
|
26
|
-
historyLoaded: false,
|
|
27
|
-
skiplinkTargetId: randomId(),
|
|
28
|
-
optionsButtonId: randomId(),
|
|
29
|
-
headerCollapseButtonId: randomId(),
|
|
30
|
-
serviceData: {},
|
|
31
|
-
options: {
|
|
32
|
-
features: {},
|
|
33
|
-
panelActive: false,
|
|
34
|
-
optionActive: '',
|
|
35
|
-
userSelectedOptions: {},
|
|
36
|
-
},
|
|
37
|
-
showFileUpload: false,
|
|
38
|
-
currentUploads: [],
|
|
39
|
-
entryMeta: {
|
|
40
|
-
default: entryTypes.text,
|
|
41
|
-
active: entryTypes.text,
|
|
42
|
-
userSelected: null,
|
|
43
|
-
blockAutoEntrySwitch: false,
|
|
44
|
-
options: {},
|
|
45
|
-
optionsOverride: {},
|
|
46
|
-
},
|
|
47
|
-
seamlyContainerElement: null,
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export default function stateReducer(state = initialState, action) {
|
|
51
|
-
if (action.type === String(AppActions.initialize.pending)) {
|
|
52
|
-
return initialState
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return seamlyStateReducer(state, action)
|
|
56
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { createActions } from './utils'
|
|
2
|
-
|
|
3
|
-
export const [enable, disable] = createActions('translate', {
|
|
4
|
-
enable: (locale) => ({ locale }),
|
|
5
|
-
disable: () => ({}),
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
export const [enableEvent, disableEvent] = createActions('event', {
|
|
9
|
-
enable: (payloadId) => ({ payloadId }),
|
|
10
|
-
disable: (payloadId) => ({ payloadId }),
|
|
11
|
-
})
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'preact/hooks'
|
|
2
|
-
import {
|
|
3
|
-
useElementFocusingById,
|
|
4
|
-
useSeamlyCommands,
|
|
5
|
-
useStableCallback,
|
|
6
|
-
} from 'ui/hooks/seamly-hooks'
|
|
7
|
-
import { actionTypes } from 'ui/utils/seamly-utils'
|
|
8
|
-
import {
|
|
9
|
-
useSelector,
|
|
10
|
-
useSelectorWithProps,
|
|
11
|
-
useStoreDispatch,
|
|
12
|
-
} from 'domains/redux'
|
|
13
|
-
import * as Selectors from './selectors'
|
|
14
|
-
import * as Actions from './actions'
|
|
15
|
-
|
|
16
|
-
export function useTranslations() {
|
|
17
|
-
const { sendAction } = useSeamlyCommands()
|
|
18
|
-
const dispatch = useStoreDispatch()
|
|
19
|
-
const enableTranslations = useStableCallback(
|
|
20
|
-
(locale) => {
|
|
21
|
-
sendAction({
|
|
22
|
-
type: actionTypes.setTranslation,
|
|
23
|
-
body: { enabled: true, locale },
|
|
24
|
-
})
|
|
25
|
-
dispatch(Actions.enable(locale))
|
|
26
|
-
},
|
|
27
|
-
[sendAction, dispatch],
|
|
28
|
-
)
|
|
29
|
-
const disableTranslations = useStableCallback(() => {
|
|
30
|
-
sendAction({ type: actionTypes.setTranslation, body: { enabled: false } })
|
|
31
|
-
dispatch(Actions.disable())
|
|
32
|
-
}, [sendAction, dispatch])
|
|
33
|
-
|
|
34
|
-
const { languages, isActive, isAvailable, currentLocale } = useSelector(
|
|
35
|
-
Selectors.getState,
|
|
36
|
-
[],
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
languages,
|
|
41
|
-
isActive,
|
|
42
|
-
isAvailable,
|
|
43
|
-
currentLocale,
|
|
44
|
-
enableTranslations,
|
|
45
|
-
disableTranslations,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function useTranslatedEventData({ payload } = {}) {
|
|
50
|
-
const payloadId = payload?.id
|
|
51
|
-
let body
|
|
52
|
-
let translatedBody
|
|
53
|
-
switch (payload?.type) {
|
|
54
|
-
case 'participant':
|
|
55
|
-
body = payload.participant.introduction
|
|
56
|
-
translatedBody = payload.participant.translatedIntroduction
|
|
57
|
-
break
|
|
58
|
-
default:
|
|
59
|
-
body = payload?.body
|
|
60
|
-
translatedBody = payload?.translatedBody
|
|
61
|
-
}
|
|
62
|
-
const hasTranslation = !!translatedBody
|
|
63
|
-
const isTranslated = useSelectorWithProps(
|
|
64
|
-
Selectors.getIsPayloadTranslated,
|
|
65
|
-
{ payloadId },
|
|
66
|
-
[payloadId],
|
|
67
|
-
)
|
|
68
|
-
const dispatch = useStoreDispatch()
|
|
69
|
-
|
|
70
|
-
const toggleTranslation = useStableCallback(() => {
|
|
71
|
-
if (isTranslated) {
|
|
72
|
-
dispatch(Actions.disableEvent(payloadId))
|
|
73
|
-
} else {
|
|
74
|
-
dispatch(Actions.enableEvent(payloadId))
|
|
75
|
-
}
|
|
76
|
-
}, [isTranslated, payloadId, dispatch])
|
|
77
|
-
|
|
78
|
-
return [
|
|
79
|
-
hasTranslation && isTranslated ? translatedBody?.data : body,
|
|
80
|
-
{
|
|
81
|
-
hasTranslation,
|
|
82
|
-
isTranslated: isTranslated && hasTranslation,
|
|
83
|
-
toggleTranslation,
|
|
84
|
-
translatedBy: translatedBody?.translatedBy,
|
|
85
|
-
locale: translatedBody?.locale,
|
|
86
|
-
},
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function useTranslationsContainer() {
|
|
91
|
-
const id = useSelector(Selectors.getState, []).containerId
|
|
92
|
-
const focusContainer = useElementFocusingById(id)
|
|
93
|
-
return { id, focusContainer }
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function useLocaleNativeName(locale) {
|
|
97
|
-
const { languages } = useTranslations()
|
|
98
|
-
|
|
99
|
-
return useMemo(
|
|
100
|
-
() => languages?.find((lang) => lang.locale === locale)?.nativeName,
|
|
101
|
-
[locale, languages],
|
|
102
|
-
)
|
|
103
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as Actions from './actions'
|
|
2
|
-
import * as Selectors from './selectors'
|
|
3
|
-
|
|
4
|
-
export * from './hooks'
|
|
5
|
-
export { default as createMiddleware } from './middleware'
|
|
6
|
-
export { default as Reducer } from './reducer'
|
|
7
|
-
export { default as OptionsButton } from './components/options-button'
|
|
8
|
-
export { default as ChatStatus } from './components/chat-status'
|
|
9
|
-
|
|
10
|
-
export { Actions, Selectors }
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { seamlyActions } from 'ui/utils/seamly-utils'
|
|
2
|
-
import { randomId } from 'lib/id'
|
|
3
|
-
import * as AppActions from 'domains/app/actions'
|
|
4
|
-
import * as Actions from './actions'
|
|
5
|
-
import { createReducer } from './utils'
|
|
6
|
-
|
|
7
|
-
const initialState = {
|
|
8
|
-
isActive: false,
|
|
9
|
-
currentLocale: undefined,
|
|
10
|
-
isAvailable: false,
|
|
11
|
-
languages: [],
|
|
12
|
-
originalPayloadIds: [],
|
|
13
|
-
containerId: randomId(),
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default createReducer(
|
|
17
|
-
{
|
|
18
|
-
[seamlyActions.SET_FEATURES]: (state, action) => {
|
|
19
|
-
const feature = action?.features?.translation
|
|
20
|
-
if (!feature) {
|
|
21
|
-
return state
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...state,
|
|
26
|
-
isAvailable: feature.enabled === true,
|
|
27
|
-
languages: feature.languages || [],
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
[seamlyActions.CLEAR_FEATURES]: () => initialState,
|
|
32
|
-
[Actions.enable]: (state, { locale }) => {
|
|
33
|
-
return {
|
|
34
|
-
...state,
|
|
35
|
-
isActive: true,
|
|
36
|
-
currentLocale: locale,
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
[Actions.disable]: (state) => {
|
|
40
|
-
return {
|
|
41
|
-
...state,
|
|
42
|
-
isActive: false,
|
|
43
|
-
currentLocale: undefined,
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
[Actions.enableEvent]: (state, { payloadId }) => {
|
|
47
|
-
if (!state.originalPayloadIds.includes(payloadId)) {
|
|
48
|
-
return state
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
...state,
|
|
52
|
-
originalPayloadIds: state.originalPayloadIds.filter(
|
|
53
|
-
(id) => id !== payloadId,
|
|
54
|
-
),
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
[Actions.disableEvent]: (state, { payloadId }) => {
|
|
58
|
-
if (state.originalPayloadIds.includes(payloadId)) {
|
|
59
|
-
return state
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
...state,
|
|
63
|
-
originalPayloadIds: [...state.originalPayloadIds, payloadId],
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
[AppActions.initialize.pending]: () => initialState,
|
|
67
|
-
},
|
|
68
|
-
initialState,
|
|
69
|
-
)
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createSelector } from 'reselect'
|
|
2
|
-
import { getPropSelector } from 'domains/redux/utils'
|
|
3
|
-
import { selectState } from './utils'
|
|
4
|
-
|
|
5
|
-
export const getState = selectState
|
|
6
|
-
|
|
7
|
-
export const getOriginalPayloadIds = createSelector(
|
|
8
|
-
getState,
|
|
9
|
-
(state) => state.originalPayloadIds,
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
export const getIsPayloadTranslated = createSelector(
|
|
13
|
-
getOriginalPayloadIds,
|
|
14
|
-
getPropSelector('payloadId'),
|
|
15
|
-
(payloadIds, payloadId) => !payloadIds.includes(payloadId),
|
|
16
|
-
)
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as Actions from './actions'
|
|
2
|
-
import * as Selectors from './selectors'
|
|
3
|
-
|
|
4
|
-
export * from './hooks'
|
|
5
|
-
export { visibilityStates } from './constants'
|
|
6
|
-
export { default as Reducer } from './reducer'
|
|
7
|
-
export { calculateVisibility } from './utils'
|
|
8
|
-
export { Actions, Selectors }
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createReducer } from './utils'
|
|
2
|
-
import * as Actions from './actions'
|
|
3
|
-
import { visibilityStates } from './constants'
|
|
4
|
-
|
|
5
|
-
const initialState = {
|
|
6
|
-
visibility: visibilityStates.initialize,
|
|
7
|
-
showInlineView: false,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default createReducer(
|
|
11
|
-
{
|
|
12
|
-
[Actions.setFromStorage]: (state, { visibility }) => ({
|
|
13
|
-
...state,
|
|
14
|
-
visibility,
|
|
15
|
-
}),
|
|
16
|
-
[Actions.setVisibility.fulfilled]: (state, { payload: visibility }) =>
|
|
17
|
-
visibility ? { ...state, visibility } : state,
|
|
18
|
-
[Actions.setShowInlineView]: (state) => ({
|
|
19
|
-
...state,
|
|
20
|
-
showInlineView: true,
|
|
21
|
-
}),
|
|
22
|
-
},
|
|
23
|
-
initialState,
|
|
24
|
-
)
|
package/src/javascripts/index.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import preactDebug from './lib/preact-debug' // eslint-disable-line
|
|
2
|
-
|
|
3
|
-
// Used by: Client
|
|
4
|
-
import initializeExternalApi from './lib/external-api/initialize-api'
|
|
5
|
-
|
|
6
|
-
export default initializeExternalApi
|
|
7
|
-
|
|
8
|
-
// Used by: Client
|
|
9
|
-
export { default as AgentInfo } from './ui/components/layout/agent-info'
|
|
10
|
-
|
|
11
|
-
// Used by: Client
|
|
12
|
-
export { default as Chat } from './ui/components/layout/chat'
|
|
13
|
-
|
|
14
|
-
// Used by: Client
|
|
15
|
-
export { calculateVisibility } from './domains/visibility'
|
|
16
|
-
|
|
17
|
-
// Used by: Client
|
|
18
|
-
export { default as ChatFrame } from './ui/components/layout/chat-frame'
|
|
19
|
-
|
|
20
|
-
// Used by: Client
|
|
21
|
-
export { className } from './lib/css'
|
|
22
|
-
|
|
23
|
-
// Used by: Client
|
|
24
|
-
export { default as Conversation } from './ui/components/conversation/conversation'
|
|
25
|
-
|
|
26
|
-
// Used by: StyleGuide
|
|
27
|
-
export { createReduxStore } from './domains/redux'
|
|
28
|
-
|
|
29
|
-
// Used by: StyleGuide
|
|
30
|
-
export { default as Engine } from './lib/engine'
|
|
31
|
-
|
|
32
|
-
// Used by: Client
|
|
33
|
-
export { default as EntryContainer } from './ui/components/entry/entry-container'
|
|
34
|
-
|
|
35
|
-
// Used by: Demo
|
|
36
|
-
export { default as EventParticipant } from './ui/components/conversation/event/event-participant'
|
|
37
|
-
|
|
38
|
-
// Used by: Client
|
|
39
|
-
export { eventTypes } from './ui/utils/seamly-utils'
|
|
40
|
-
|
|
41
|
-
// Used by: StyleGuide
|
|
42
|
-
export { default as ExternalApi } from './lib/external-api'
|
|
43
|
-
|
|
44
|
-
// Used by: StyleGuide
|
|
45
|
-
export { getUrlParams } from './ui/utils/general-utils'
|
|
46
|
-
|
|
47
|
-
// Used by: StyleGuide
|
|
48
|
-
export { getUrlSearchString } from './ui/utils/general-utils'
|
|
49
|
-
|
|
50
|
-
// Used by: Client
|
|
51
|
-
export { default as Header } from './ui/components/layout/header'
|
|
52
|
-
|
|
53
|
-
// Used by: Client
|
|
54
|
-
export { default as Icon } from './ui/components/layout/icon'
|
|
55
|
-
|
|
56
|
-
// Used by: Client
|
|
57
|
-
export { default as Interrupt } from './ui/components/layout/interrupt'
|
|
58
|
-
|
|
59
|
-
// Used by: Client
|
|
60
|
-
export { default as MessageContainer } from './ui/components/conversation/message-container'
|
|
61
|
-
|
|
62
|
-
// Used by: StyleGuide
|
|
63
|
-
export { randomId } from './lib/id'
|
|
64
|
-
|
|
65
|
-
// Used by: Client
|
|
66
|
-
export { seamlyActions } from './ui/utils/seamly-utils'
|
|
67
|
-
|
|
68
|
-
// Used by: StyleGuide
|
|
69
|
-
export { SeamlyApiContext } from './ui/components/core/seamly-api-context'
|
|
70
|
-
|
|
71
|
-
// Used by: StyleGuide
|
|
72
|
-
export { SeamlyEventBusContext } from './ui/components/core/seamly-api-context'
|
|
73
|
-
|
|
74
|
-
// Used by: StyleGuide
|
|
75
|
-
export { SeamlyLiveRegionContext } from './ui/components/core/seamly-live-region-context'
|
|
76
|
-
|
|
77
|
-
// Used by: StyleGuide
|
|
78
|
-
export { StoreProvider } from './domains/redux'
|
|
79
|
-
|
|
80
|
-
// Used by: Client
|
|
81
|
-
export { useChoicePrompt } from './ui/components/conversation/event/choice-prompt'
|
|
82
|
-
|
|
83
|
-
// Used by: Client
|
|
84
|
-
export { useSeamlyDispatchContext as useDispatch } from './ui/hooks/seamly-hooks'
|
|
85
|
-
|
|
86
|
-
// Used by: Client
|
|
87
|
-
export { useSeamlyChat } from './ui/hooks/seamly-hooks'
|
|
88
|
-
|
|
89
|
-
// Used by: Client
|
|
90
|
-
export { useSeamlyCommands } from './ui/hooks/seamly-hooks'
|
|
91
|
-
|
|
92
|
-
// Used by: Client
|
|
93
|
-
export { useConfig as useSeamlyConfig } from './domains/config'
|
|
94
|
-
|
|
95
|
-
// Used by: Client
|
|
96
|
-
export { useEvents } from './ui/hooks/seamly-hooks'
|
|
97
|
-
|
|
98
|
-
// Used by: Client
|
|
99
|
-
export { useGeneratedId } from './ui/hooks/seamly-hooks'
|
|
100
|
-
|
|
101
|
-
// Used by: Client
|
|
102
|
-
export { useI18n } from './domains/i18n'
|
|
103
|
-
|
|
104
|
-
// Used by: Client
|
|
105
|
-
export { useSeamlyEventStream } from './ui/hooks/seamly-hooks'
|
|
106
|
-
|
|
107
|
-
// Used by: Client
|
|
108
|
-
export { useSeamlyIdleDetachCountdown } from './ui/hooks/seamly-hooks'
|
|
109
|
-
|
|
110
|
-
// Used by: Client
|
|
111
|
-
export { useSeamlyMessageContainerClassNames } from './ui/hooks/seamly-hooks'
|
|
112
|
-
|
|
113
|
-
// Used by: Client
|
|
114
|
-
export { useSeamlyOptions } from './ui/hooks/seamly-hooks'
|
|
115
|
-
|
|
116
|
-
// Used by: Client
|
|
117
|
-
export { useVisibility as useSeamlyVisibility } from './domains/visibility'
|
|
118
|
-
|
|
119
|
-
// Used by: Client
|
|
120
|
-
export {
|
|
121
|
-
useTranslations,
|
|
122
|
-
useTranslatedEventData,
|
|
123
|
-
useTranslationsContainer,
|
|
124
|
-
} from './domains/translations'
|
|
125
|
-
|
|
126
|
-
// Used by: Client
|
|
127
|
-
export { default as Text } from './ui/components/conversation/event/text'
|
|
128
|
-
|
|
129
|
-
// Used by: Client
|
|
130
|
-
export { default as DeprecatedToggleButton } from './ui/components/entry/deprecated-toggle-button'
|
|
131
|
-
|
|
132
|
-
// Used by: StyleGuide
|
|
133
|
-
// Used by: Client (with custom view)
|
|
134
|
-
export { default as View } from './ui/components/view'
|
|
135
|
-
|
|
136
|
-
// Used by: Client
|
|
137
|
-
export { default as DeprecatedView } from './ui/components/view/deprecated-view'
|
|
138
|
-
|
|
139
|
-
// Used by: StyleGuide
|
|
140
|
-
export { default as ComponentFilter } from './ui/components/conversation/component-filter'
|
|
141
|
-
|
|
142
|
-
// Used by: Client
|
|
143
|
-
// Used by: StyleGuide
|
|
144
|
-
export { visibilityStates } from './domains/visibility'
|
|
145
|
-
|
|
146
|
-
// Used by: StyleGuide
|
|
147
|
-
export { API } from './api'
|
|
148
|
-
|
|
149
|
-
// Used by: StyleGuide
|
|
150
|
-
export { default as SeamlyGeneralError } from './api/errors/seamly-general-error'
|
|
151
|
-
|
|
152
|
-
// Used by: StyleGuide
|
|
153
|
-
export { default as SeamlyOfflineError } from './api/errors/seamly-offline-error'
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { randomId } from 'lib/id'
|
|
2
|
-
|
|
3
|
-
export const SLICE_DELIMITER = '/'
|
|
4
|
-
export const DOMAIN_DELIMITER = '//'
|
|
5
|
-
|
|
6
|
-
export function prefixType(prefix, fn, delimiter = '/') {
|
|
7
|
-
return (type, ...args) => fn(prefix + delimiter + type, ...args)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function createAction(
|
|
11
|
-
type,
|
|
12
|
-
identityReducer = (payload) => ({ payload }),
|
|
13
|
-
) {
|
|
14
|
-
const action = (...params) => ({ type, ...identityReducer(...params) })
|
|
15
|
-
action.toString = () => String(type)
|
|
16
|
-
action.match = (obj) => obj?.type === String(type)
|
|
17
|
-
return action
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function createActions(baseType, ...args) {
|
|
21
|
-
const handlers = []
|
|
22
|
-
// eslint-disable-next-line consistent-return
|
|
23
|
-
args.forEach((arg) => {
|
|
24
|
-
const argType = typeof arg
|
|
25
|
-
if (argType === 'string') {
|
|
26
|
-
return handlers.push([arg])
|
|
27
|
-
}
|
|
28
|
-
if (argType !== 'object' || arg instanceof Array) {
|
|
29
|
-
return undefined
|
|
30
|
-
}
|
|
31
|
-
Object.keys(arg).forEach((key) => handlers.push([key, arg[key]]))
|
|
32
|
-
})
|
|
33
|
-
const create = prefixType(baseType, createAction, SLICE_DELIMITER)
|
|
34
|
-
|
|
35
|
-
return handlers.map((handler) => create(...handler))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function createThunk(type, payloadCreator) {
|
|
39
|
-
const [pending, fulfilled, rejected] = createActions(type, {
|
|
40
|
-
pending: (arg, requestId) => ({
|
|
41
|
-
meta: { arg, requestId, status: 'pending' },
|
|
42
|
-
}),
|
|
43
|
-
fulfilled: (arg, payload, requestId) => ({
|
|
44
|
-
payload,
|
|
45
|
-
meta: { arg, requestId, status: 'fulfilled' },
|
|
46
|
-
}),
|
|
47
|
-
rejected: (arg, error, requestId) => ({
|
|
48
|
-
error,
|
|
49
|
-
meta: { arg, requestId, status: 'rejected', error: String(error) },
|
|
50
|
-
}),
|
|
51
|
-
})
|
|
52
|
-
const thunkCreator = (arg) => (dispatch, getState, extra) => {
|
|
53
|
-
const requestId = randomId()
|
|
54
|
-
const promise = (async () => {
|
|
55
|
-
let finalAction
|
|
56
|
-
try {
|
|
57
|
-
dispatch(pending(arg, requestId))
|
|
58
|
-
const prms = payloadCreator(arg, { dispatch, getState, extra })
|
|
59
|
-
const result = await prms
|
|
60
|
-
finalAction = fulfilled(arg, result, requestId)
|
|
61
|
-
} catch (error) {
|
|
62
|
-
finalAction = rejected(arg, error, requestId)
|
|
63
|
-
}
|
|
64
|
-
dispatch(finalAction)
|
|
65
|
-
return finalAction
|
|
66
|
-
})()
|
|
67
|
-
return Object.assign(promise, {
|
|
68
|
-
type,
|
|
69
|
-
arg,
|
|
70
|
-
requestId,
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
return Object.assign(thunkCreator, {
|
|
74
|
-
type,
|
|
75
|
-
pending,
|
|
76
|
-
fulfilled,
|
|
77
|
-
rejected,
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function createReducer(domain, handlers = {}, defaultState) {
|
|
82
|
-
const reducer = (state = defaultState, action) => {
|
|
83
|
-
const typeReducer = handlers?.[action?.type]
|
|
84
|
-
return typeReducer ? typeReducer(state, action) : state
|
|
85
|
-
}
|
|
86
|
-
reducer.toString = () => domain
|
|
87
|
-
return reducer
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function createDomain(domain) {
|
|
91
|
-
return {
|
|
92
|
-
createAction: prefixType(domain, createAction, DOMAIN_DELIMITER),
|
|
93
|
-
createActions: prefixType(domain, createActions, DOMAIN_DELIMITER),
|
|
94
|
-
createThunk: prefixType(domain, createThunk, DOMAIN_DELIMITER),
|
|
95
|
-
createReducer: (handlers, defaultState) =>
|
|
96
|
-
createReducer(domain, handlers, defaultState),
|
|
97
|
-
selectState: (state) => state[domain],
|
|
98
|
-
}
|
|
99
|
-
}
|