@seamly/web-ui 20.5.0 → 20.7.0
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 +791 -0
- package/build/dist/lib/index.debug.js +43 -43
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.debug.min.js.LICENSE.txt +4 -4
- package/build/dist/lib/index.js +432 -621
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +349 -766
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +151 -92
- package/build/dist/lib/style-guide.min.js +1 -1
- package/build/dist/lib/styles.css +1 -1
- package/package.json +1 -1
- package/src/javascripts/domains/store/index.js +11 -11
- package/src/javascripts/domains/translations/middleware.js +6 -5
- package/src/javascripts/style-guide/states.js +31 -1
- package/src/javascripts/ui/components/conversation/conversation.js +31 -26
- package/src/javascripts/ui/components/suggestions/index.js +37 -26
- package/src/javascripts/ui/hooks/use-seamly-commands.js +0 -17
- package/src/javascripts/ui/utils/seamly-utils.js +5 -3
- package/src/stylesheets/5-components/_suggestions.scss +3 -3
- package/webpack/parts/dev-server.js +10 -1
- package/src/.DS_Store +0 -0
|
@@ -172,7 +172,8 @@ const baseState = {
|
|
|
172
172
|
},
|
|
173
173
|
currentUploads: []
|
|
174
174
|
};
|
|
175
|
-
const avatar = 'data:image/svg+xml;base64,
|
|
175
|
+
const avatar = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMiAzMiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzIgMzIiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsPSIjNEE0OEMxIiBkPSJNMTAsMTQuOGMtMS4xLDAtMi0wLjktMi0yczAuOS0yLDItMnMyLDAuOSwyLDJTMTEuMSwxNC44LDEwLDE0Ljh6IE0xNS45LDE0LjhjMS4xLDAsMi0wLjksMi0ycy0wLjktMi0yLTIKCXMtMiwwLjktMiwyUzE0LjgsMTQuOCwxNS45LDE0Ljh6IE0yMS44LDEwLjhjLTEuMSwwLTIsMC45LTIsMnMwLjksMiwyLDJzMi0wLjksMi0yUzIyLjksMTAuOCwyMS44LDEwLjh6IE0yMS4zLDE4LjFIMTAuNwoJQzExLjcsMjMuOSwyMC4yLDIzLjksMjEuMywxOC4xeiIvPgo8L3N2Zz4K';
|
|
176
|
+
const transferAvatar = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCAzMiAzMiIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMzIgMzIiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8cGF0aCBmaWxsPSIjNEE0OEMxIiBkPSJNMTAuMSwxNC45Yy0xLjEsMC0yLTAuOS0yLTJzMC45LTIsMi0yczIsMC45LDIsMlMxMS4yLDE0LjksMTAuMSwxNC45eiBNMjEuOSwxMC45Yy0xLjEsMC0yLDAuOS0yLDIKCXMwLjksMiwyLDJzMi0wLjksMi0yUzIzLDEwLjksMjEuOSwxMC45eiBNMjEuNCwxOC4ySDEwLjhDMTEuOCwyNCwyMC4zLDI0LDIxLjQsMTguMnogTTE3LjIsMjUuM2gtMi40Yy0wLjYsMC0xLjIsMC40LTEuNCwxCgljLTUuMS0wLjItOS4yLTQuNC05LjQtOS42YzAuMSwwLDAuMiwwLjEsMC40LDAuMWgwLjFjMC44LDAsMS40LTAuNiwxLjQtMS40di00LjdjMC0wLjgtMC42LTEuNC0xLjQtMS40aDBjLTAuOCwwLTEuNCwwLjYtMS40LDEuNAoJdjIuN3YydjEuMWMwLDUuOSw0LjcsMTAuNiwxMC41LDEwLjhjMC4yLDAuNSwwLjcsMC44LDEuMiwwLjhoMi40YzAuOCwwLDEuNC0wLjYsMS40LTEuNFMxOCwyNS4zLDE3LjIsMjUuM3oiLz4KPC9zdmc+Cg==';
|
|
176
177
|
const participantInfo = {
|
|
177
178
|
participants: {
|
|
178
179
|
agent: {
|
|
@@ -343,6 +344,33 @@ const participantMessage = {
|
|
|
343
344
|
type: 'participant'
|
|
344
345
|
}
|
|
345
346
|
};
|
|
347
|
+
const participantTransferMessage = {
|
|
348
|
+
type: 'participant',
|
|
349
|
+
payload: {
|
|
350
|
+
fromClient: false,
|
|
351
|
+
fromHistory: true,
|
|
352
|
+
id: (0,web_ui_namespaceObject.randomId)(),
|
|
353
|
+
messageStatus: 'received',
|
|
354
|
+
participant: {
|
|
355
|
+
introduction: 'Welcome, you are now chatting with Mrs. Bot 2, give me a minit to read back the chat history.',
|
|
356
|
+
id: 'agent',
|
|
357
|
+
avatar: transferAvatar,
|
|
358
|
+
name: 'Two',
|
|
359
|
+
service: {
|
|
360
|
+
expose: {
|
|
361
|
+
map: {},
|
|
362
|
+
version: 3
|
|
363
|
+
},
|
|
364
|
+
meta: {},
|
|
365
|
+
name: 'new service',
|
|
366
|
+
serviceSessionId: (0,web_ui_namespaceObject.randomId)(),
|
|
367
|
+
settings: {}
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
transactionId: (0,web_ui_namespaceObject.randomId)(),
|
|
371
|
+
type: 'participant'
|
|
372
|
+
}
|
|
373
|
+
};
|
|
346
374
|
const participantMessageDefaultIcon = {
|
|
347
375
|
type: 'participant',
|
|
348
376
|
payload: {
|
|
@@ -1148,7 +1176,7 @@ const standardState = {
|
|
|
1148
1176
|
payload: states_objectSpread(states_objectSpread({}, choicePromptMessage.payload), {}, {
|
|
1149
1177
|
id: `${choicePromptMessage.payload.id}XXX`
|
|
1150
1178
|
})
|
|
1151
|
-
}), longTextMessage, userMessage, textMessageBoldItalicUnderline, userMessageWithLinks, newTopicDivider, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage]
|
|
1179
|
+
}), longTextMessage, participantTransferMessage, userMessage, textMessageBoldItalicUnderline, userMessageWithLinks, newTopicDivider, imageMessage, fileDownloadAgentMessage, deletedFileDownloadAgentMessage, userMessageLong, videoMessage, textMessageWithLinks, textMessageWithLongLink, imageMessageWithLightbox, fileDownloadUserMessage, emptyUrlFileDownloadUserMessage, textMesageWithBullets, choicePromptMessage, ctaMessage]
|
|
1152
1180
|
}),
|
|
1153
1181
|
userMessages: states_objectSpread(states_objectSpread({
|
|
1154
1182
|
category: categoryKeys.messages,
|
|
@@ -1226,7 +1254,7 @@ const standardState = {
|
|
|
1226
1254
|
type: 'text'
|
|
1227
1255
|
}
|
|
1228
1256
|
})
|
|
1229
|
-
}, participantMessage, participantMessageDefaultIcon, newTopicDivider, transcriptInfoMessage, ...[newTranslationDividerStart, newTranslationDividerStop].map(addTranslationData), infoMessage]
|
|
1257
|
+
}, participantMessage, participantMessageDefaultIcon, participantTransferMessage, newTopicDivider, transcriptInfoMessage, ...[newTranslationDividerStart, newTranslationDividerStop].map(addTranslationData), infoMessage]
|
|
1230
1258
|
}),
|
|
1231
1259
|
choicePromptMessages: states_objectSpread(states_objectSpread({
|
|
1232
1260
|
category: categoryKeys.messages,
|
|
@@ -2224,6 +2252,7 @@ function seamly_utils_objectSpread(target) { for (var i = 1; i < arguments.lengt
|
|
|
2224
2252
|
function seamly_utils_defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2225
2253
|
|
|
2226
2254
|
|
|
2255
|
+
|
|
2227
2256
|
const eventTypes = {
|
|
2228
2257
|
info: 'info',
|
|
2229
2258
|
message: 'message',
|
|
@@ -2515,9 +2544,9 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2515
2544
|
|
|
2516
2545
|
|
|
2517
2546
|
if (accountHasUploads && (eventType === eventTypes.message || eventType === eventTypes.participant) && !payload.fromClient) {
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2547
|
+
var _payload$entry;
|
|
2548
|
+
|
|
2549
|
+
const entryType = payload === null || payload === void 0 ? void 0 : (_payload$entry = payload.entry) === null || _payload$entry === void 0 ? void 0 : _payload$entry.type;
|
|
2521
2550
|
newOptions = seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions), {}, {
|
|
2522
2551
|
features: seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions.features), {}, {
|
|
2523
2552
|
uploads: seamly_utils_objectSpread(seamly_utils_objectSpread({}, newOptions.features.uploads), {}, {
|
|
@@ -2547,7 +2576,10 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2547
2576
|
// event optimistically.
|
|
2548
2577
|
payload: seamly_utils_objectSpread(seamly_utils_objectSpread({}, incrementUnread && {
|
|
2549
2578
|
messageStatus: payload.fromClient ? readStates.read : readStates.received
|
|
2550
|
-
}),
|
|
2579
|
+
}), {}, {
|
|
2580
|
+
// We add a randomid to use as key for mapping of Events to avoid rerendering
|
|
2581
|
+
key: id_randomId()
|
|
2582
|
+
}, payload)
|
|
2551
2583
|
})]
|
|
2552
2584
|
});
|
|
2553
2585
|
|
|
@@ -2641,12 +2673,9 @@ const seamlyStateReducer = (state, action) => {
|
|
|
2641
2673
|
const newFeaturesHasUpload = newFeatures.hasOwnProperty(featureKeys.uploads); // Only set uploads if it was initialised by the account config.
|
|
2642
2674
|
|
|
2643
2675
|
if (newFeaturesHasUpload) {
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
const {
|
|
2648
|
-
type: entryType
|
|
2649
|
-
} = lastParticipantEventPayload.entry || {};
|
|
2676
|
+
var _lastParticipantEvent, _lastParticipantEvent2;
|
|
2677
|
+
|
|
2678
|
+
const entryType = lastParticipantEvent === null || lastParticipantEvent === void 0 ? void 0 : (_lastParticipantEvent = lastParticipantEvent.payload) === null || _lastParticipantEvent === void 0 ? void 0 : (_lastParticipantEvent2 = _lastParticipantEvent.entry) === null || _lastParticipantEvent2 === void 0 ? void 0 : _lastParticipantEvent2.type;
|
|
2650
2679
|
newFeatures = seamly_utils_objectSpread(seamly_utils_objectSpread({}, newFeatures), {}, {
|
|
2651
2680
|
uploads: {
|
|
2652
2681
|
enabled: !!(uploads && uploads.enabled),
|
|
@@ -2996,7 +3025,7 @@ function createAction(type, identityReducer = payload => ({
|
|
|
2996
3025
|
|
|
2997
3026
|
action.toString = () => String(type);
|
|
2998
3027
|
|
|
2999
|
-
action.match = obj => obj
|
|
3028
|
+
action.match = obj => (obj === null || obj === void 0 ? void 0 : obj.type) === String(type);
|
|
3000
3029
|
|
|
3001
3030
|
return action;
|
|
3002
3031
|
}
|
|
@@ -3086,7 +3115,7 @@ function createThunk(type, payloadCreator) {
|
|
|
3086
3115
|
}
|
|
3087
3116
|
function createReducer(domain, handlers = {}, defaultState) {
|
|
3088
3117
|
const reducer = (state = defaultState, action) => {
|
|
3089
|
-
const typeReducer = handlers
|
|
3118
|
+
const typeReducer = handlers === null || handlers === void 0 ? void 0 : handlers[action === null || action === void 0 ? void 0 : action.type];
|
|
3090
3119
|
return typeReducer ? typeReducer(state, action) : state;
|
|
3091
3120
|
};
|
|
3092
3121
|
|
|
@@ -3517,7 +3546,7 @@ function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.de
|
|
|
3517
3546
|
|
|
3518
3547
|
const selectConfig = createSelector(selectState, config => {
|
|
3519
3548
|
let newConfig = selectors_objectSpread({
|
|
3520
|
-
visible: config
|
|
3549
|
+
visible: (config === null || config === void 0 ? void 0 : config.layoutMode) === 'inline' ? constants_visibilityStates.open : constants_visibilityStates.minimized,
|
|
3521
3550
|
appContainerClassNames: config.appContainerClassNames || []
|
|
3522
3551
|
}, config);
|
|
3523
3552
|
|
|
@@ -3609,6 +3638,8 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
3609
3638
|
useLayoutEffect(() => {
|
|
3610
3639
|
// we subscribe to the store changes
|
|
3611
3640
|
return store.subscribe(() => {
|
|
3641
|
+
var _selectorRef$current;
|
|
3642
|
+
|
|
3612
3643
|
const newState = store.getState(); // prevent recalculating if the state hasn't changed
|
|
3613
3644
|
// if the selector changed, it was already handled synchronously
|
|
3614
3645
|
|
|
@@ -3617,7 +3648,7 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
3617
3648
|
} // calculate the new value based on selector+state
|
|
3618
3649
|
|
|
3619
3650
|
|
|
3620
|
-
const newValue = selectorRef.current
|
|
3651
|
+
const newValue = (_selectorRef$current = selectorRef.current) === null || _selectorRef$current === void 0 ? void 0 : _selectorRef$current.call(selectorRef, store.getState()); // only if the value changed we update. this saves heaps of re-rendering
|
|
3621
3652
|
|
|
3622
3653
|
if (newValue !== valueRef.current) {
|
|
3623
3654
|
valueRef.current = newValue;
|
|
@@ -3680,7 +3711,9 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
3680
3711
|
events,
|
|
3681
3712
|
serviceData
|
|
3682
3713
|
}, config, userHasResponded) => {
|
|
3683
|
-
|
|
3714
|
+
var _serviceData$suggesti;
|
|
3715
|
+
|
|
3716
|
+
if (userHasResponded || config.layoutMode === 'inline' || !serviceData.suggestion || !((_serviceData$suggesti = serviceData.suggestion) !== null && _serviceData$suggesti !== void 0 && _serviceData$suggesti.body.length)) {
|
|
3684
3717
|
return events;
|
|
3685
3718
|
}
|
|
3686
3719
|
|
|
@@ -3691,10 +3724,12 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
3691
3724
|
return [...events, suggestionsEvent];
|
|
3692
3725
|
});
|
|
3693
3726
|
const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (events, config) => {
|
|
3727
|
+
var _config$messages;
|
|
3728
|
+
|
|
3694
3729
|
const {
|
|
3695
3730
|
enabled,
|
|
3696
3731
|
threshold
|
|
3697
|
-
} = config
|
|
3732
|
+
} = (config === null || config === void 0 ? void 0 : (_config$messages = config.messages) === null || _config$messages === void 0 ? void 0 : _config$messages.timeIndicator) ?? {};
|
|
3698
3733
|
|
|
3699
3734
|
if (!enabled) {
|
|
3700
3735
|
return events;
|
|
@@ -3728,8 +3763,10 @@ const seamly_state_hooks_useSkiplink = () => seamly_state_hooks_useSeamlyStateCo
|
|
|
3728
3763
|
const useSeamlyParticipant = participantId => seamly_state_hooks_useSeamlyStateContext().participantInfo.participants[participantId];
|
|
3729
3764
|
const useSeamlyServiceInfo = () => seamly_state_hooks_useSeamlyStateContext().serviceInfo;
|
|
3730
3765
|
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
3766
|
+
var _filteredEvents;
|
|
3767
|
+
|
|
3731
3768
|
const filteredEvents = events.filter(event => event.type === 'message');
|
|
3732
|
-
return filteredEvents[filteredEvents.length - 1]
|
|
3769
|
+
return (_filteredEvents = filteredEvents[filteredEvents.length - 1]) === null || _filteredEvents === void 0 ? void 0 : _filteredEvents.payload.id;
|
|
3733
3770
|
});
|
|
3734
3771
|
const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
|
|
3735
3772
|
const useSeamlyIsHistoryLoaded = () => seamly_state_hooks_useSeamlyStateContext().historyLoaded;
|
|
@@ -3898,11 +3935,13 @@ const actions_initialize = visibility_utils_createThunk('initialize', async (loc
|
|
|
3898
3935
|
api
|
|
3899
3936
|
}
|
|
3900
3937
|
}) => {
|
|
3938
|
+
var _api$store$get;
|
|
3939
|
+
|
|
3901
3940
|
// initialize stored visibility
|
|
3902
3941
|
const {
|
|
3903
3942
|
layoutMode
|
|
3904
3943
|
} = selectConfig(getState());
|
|
3905
|
-
const storedVisibility = api.store.get(StoreKey)
|
|
3944
|
+
const storedVisibility = (_api$store$get = api.store.get(StoreKey)) === null || _api$store$get === void 0 ? void 0 : _api$store$get[layoutMode];
|
|
3906
3945
|
|
|
3907
3946
|
if (storedVisibility) {
|
|
3908
3947
|
dispatch(setFromStorage(storedVisibility));
|
|
@@ -3940,13 +3979,13 @@ class SeamlyBaseError extends Error {
|
|
|
3940
3979
|
|
|
3941
3980
|
this.originalError = originalError;
|
|
3942
3981
|
|
|
3943
|
-
if (originalError
|
|
3982
|
+
if (originalError !== null && originalError !== void 0 && originalError.payload) {
|
|
3944
3983
|
this.originalEvent = originalError;
|
|
3945
3984
|
this.originalError = originalError.payload.error;
|
|
3946
3985
|
this.message = `Event of type ${originalError.payload.type} encountered`;
|
|
3947
3986
|
}
|
|
3948
3987
|
|
|
3949
|
-
if (originalError
|
|
3988
|
+
if (originalError !== null && originalError !== void 0 && originalError.error) {
|
|
3950
3989
|
this.originalError = originalError.error;
|
|
3951
3990
|
}
|
|
3952
3991
|
}
|
|
@@ -3995,8 +4034,10 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
3995
4034
|
config
|
|
3996
4035
|
}
|
|
3997
4036
|
}) => {
|
|
4037
|
+
var _config$context;
|
|
4038
|
+
|
|
3998
4039
|
dispatch(initialize(config));
|
|
3999
|
-
let locale = config
|
|
4040
|
+
let locale = config === null || config === void 0 ? void 0 : (_config$context = config.context) === null || _config$context === void 0 ? void 0 : _config$context.locale;
|
|
4000
4041
|
|
|
4001
4042
|
try {
|
|
4002
4043
|
const {
|
|
@@ -4023,7 +4064,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4023
4064
|
startChatIcon
|
|
4024
4065
|
}));
|
|
4025
4066
|
|
|
4026
|
-
if (agentParticipant
|
|
4067
|
+
if (agentParticipant !== null && agentParticipant !== void 0 && agentParticipant.name) {
|
|
4027
4068
|
dispatch({
|
|
4028
4069
|
type: seamly_utils_seamlyActions.SET_HEADER_SUB_TITLE,
|
|
4029
4070
|
title: agentParticipant.name
|
|
@@ -4035,18 +4076,22 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4035
4076
|
|
|
4036
4077
|
try {
|
|
4037
4078
|
if (api.hasConversation()) {
|
|
4079
|
+
var _initialState$transla;
|
|
4080
|
+
|
|
4038
4081
|
const initialState = await api.getConversationIntitialState();
|
|
4039
4082
|
dispatch({
|
|
4040
4083
|
type: seamly_utils_seamlyActions.SET_INITIAL_STATE,
|
|
4041
4084
|
initialState
|
|
4042
4085
|
});
|
|
4043
|
-
locale = initialState.translation
|
|
4086
|
+
locale = ((_initialState$transla = initialState.translation) === null || _initialState$transla === void 0 ? void 0 : _initialState$transla.locale) || locale;
|
|
4044
4087
|
|
|
4045
4088
|
if ('userResponded' in initialState) {
|
|
4046
4089
|
dispatch(actions_setHasResponded(initialState.userResponded));
|
|
4047
4090
|
}
|
|
4048
4091
|
} else {
|
|
4049
|
-
|
|
4092
|
+
var _config$context2, _config$context3;
|
|
4093
|
+
|
|
4094
|
+
if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.topic) {
|
|
4050
4095
|
api.send('action', {
|
|
4051
4096
|
type: seamly_utils_actionTypes.setTopic,
|
|
4052
4097
|
body: {
|
|
@@ -4058,7 +4103,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4058
4103
|
});
|
|
4059
4104
|
}
|
|
4060
4105
|
|
|
4061
|
-
if (config
|
|
4106
|
+
if (config !== null && config !== void 0 && (_config$context3 = config.context) !== null && _config$context3 !== void 0 && _config$context3.translationLocale) {
|
|
4062
4107
|
locale = config.context.translationLocale;
|
|
4063
4108
|
api.send('action', {
|
|
4064
4109
|
type: seamly_utils_actionTypes.setTranslation,
|
|
@@ -4166,7 +4211,9 @@ function utils_validate(values, schema = {}) {
|
|
|
4166
4211
|
validations = [validations];
|
|
4167
4212
|
}
|
|
4168
4213
|
|
|
4169
|
-
for (let i = 0; i < validations
|
|
4214
|
+
for (let i = 0; i < ((_validations = validations) === null || _validations === void 0 ? void 0 : _validations.length) ?? 0; i++) {
|
|
4215
|
+
var _validations;
|
|
4216
|
+
|
|
4170
4217
|
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
4171
4218
|
errors[key] = validations[i].errorText;
|
|
4172
4219
|
break;
|
|
@@ -4226,7 +4273,7 @@ const getPropSelector = (propName, orDefault) => (_, props) => props[propName] |
|
|
|
4226
4273
|
|
|
4227
4274
|
const getState = forms_utils_selectState;
|
|
4228
4275
|
const selectors_getFormById = createSelector(getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
4229
|
-
const getFormControlsByFormId = createSelector(selectors_getFormById, form => form
|
|
4276
|
+
const getFormControlsByFormId = createSelector(selectors_getFormById, form => (form === null || form === void 0 ? void 0 : form.controls) || {});
|
|
4230
4277
|
const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
4231
4278
|
const valuesObj = {};
|
|
4232
4279
|
Object.entries(controls).forEach(([key, {
|
|
@@ -4236,8 +4283,16 @@ const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId,
|
|
|
4236
4283
|
});
|
|
4237
4284
|
return valuesObj;
|
|
4238
4285
|
});
|
|
4239
|
-
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) =>
|
|
4240
|
-
|
|
4286
|
+
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
4287
|
+
var _controls$name;
|
|
4288
|
+
|
|
4289
|
+
return (_controls$name = controls[name]) === null || _controls$name === void 0 ? void 0 : _controls$name.value;
|
|
4290
|
+
});
|
|
4291
|
+
const selectors_getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
4292
|
+
var _controls$name2;
|
|
4293
|
+
|
|
4294
|
+
return (_controls$name2 = controls[name]) === null || _controls$name2 === void 0 ? void 0 : _controls$name2.touched;
|
|
4295
|
+
});
|
|
4241
4296
|
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/context.js
|
|
4242
4297
|
|
|
4243
4298
|
const context_FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
@@ -4297,7 +4352,7 @@ function hooks_useFormControl(name) {
|
|
|
4297
4352
|
formId,
|
|
4298
4353
|
name
|
|
4299
4354
|
}, [formId, name]);
|
|
4300
|
-
const error = errors
|
|
4355
|
+
const error = errors === null || errors === void 0 ? void 0 : errors[name];
|
|
4301
4356
|
const isValid = !error;
|
|
4302
4357
|
useEffect(() => {
|
|
4303
4358
|
// Make sure the form is registered
|
|
@@ -4399,9 +4454,11 @@ function provider_FormProvider(_ref) {
|
|
|
4399
4454
|
});
|
|
4400
4455
|
}, [setExternalErrors]);
|
|
4401
4456
|
const handleSubmit = useCallback(e => {
|
|
4457
|
+
var _e$submitter;
|
|
4458
|
+
|
|
4402
4459
|
e.preventDefault(); // If the submitter is set to being aria-disabled, block the submit action
|
|
4403
4460
|
|
|
4404
|
-
const ariaDisabled = e.submitter
|
|
4461
|
+
const ariaDisabled = ((_e$submitter = e.submitter) === null || _e$submitter === void 0 ? void 0 : _e$submitter.ariaDisabled) === 'true';
|
|
4405
4462
|
setIsSubmitted(!ariaDisabled);
|
|
4406
4463
|
|
|
4407
4464
|
if (!ariaDisabled && validationIsValid) {
|
|
@@ -4468,7 +4525,9 @@ const initialControlState = {
|
|
|
4468
4525
|
};
|
|
4469
4526
|
|
|
4470
4527
|
function updateFormControl(state, formId, name, controlState) {
|
|
4471
|
-
|
|
4528
|
+
var _state$formId;
|
|
4529
|
+
|
|
4530
|
+
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
4472
4531
|
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
|
|
4473
4532
|
[formId]: reducer_objectSpread(reducer_objectSpread({}, state[formId]), {}, {
|
|
4474
4533
|
controls: reducer_objectSpread(reducer_objectSpread({}, state[formId].controls), {}, {
|
|
@@ -4496,9 +4555,11 @@ function updateFormControl(state, formId, name, controlState) {
|
|
|
4496
4555
|
[deregisterForm]: (state, {
|
|
4497
4556
|
formId
|
|
4498
4557
|
}) => {
|
|
4558
|
+
var _newState$formId;
|
|
4559
|
+
|
|
4499
4560
|
const newState = reducer_objectSpread({}, state);
|
|
4500
4561
|
|
|
4501
|
-
if (!newState[formId]
|
|
4562
|
+
if (!((_newState$formId = newState[formId]) !== null && _newState$formId !== void 0 && _newState$formId.persistData)) {
|
|
4502
4563
|
delete newState[formId];
|
|
4503
4564
|
}
|
|
4504
4565
|
|
|
@@ -5962,13 +6023,13 @@ const useIntersect = ({
|
|
|
5962
6023
|
}) => {
|
|
5963
6024
|
const [entry, setEntry] = useState(null);
|
|
5964
6025
|
const containerRef = useRef(null);
|
|
5965
|
-
const isVisible = !!entry
|
|
6026
|
+
const isVisible = !!(entry !== null && entry !== void 0 && entry.isIntersecting) || !enabled;
|
|
5966
6027
|
const frozen = isVisible && freezeOnceVisible;
|
|
5967
6028
|
|
|
5968
6029
|
const observerCallback = ([updatedEntry]) => setEntry(updatedEntry);
|
|
5969
6030
|
|
|
5970
6031
|
useEffect(() => {
|
|
5971
|
-
const node = containerRef
|
|
6032
|
+
const node = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
5972
6033
|
const hasIOSupport = !!window.IntersectionObserver;
|
|
5973
6034
|
|
|
5974
6035
|
if (!node && "production" === 'development') {} // Return an arrow function to have a consistent return value
|
|
@@ -6227,20 +6288,6 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
6227
6288
|
}
|
|
6228
6289
|
});
|
|
6229
6290
|
}, [dispatch]);
|
|
6230
|
-
const sendInfo = useCallback(({
|
|
6231
|
-
type,
|
|
6232
|
-
subtype
|
|
6233
|
-
}) => {
|
|
6234
|
-
const info = {
|
|
6235
|
-
type,
|
|
6236
|
-
subtype,
|
|
6237
|
-
id: randomId(),
|
|
6238
|
-
transactionId: randomId(),
|
|
6239
|
-
participant: userParticipantId,
|
|
6240
|
-
fromClient: true
|
|
6241
|
-
};
|
|
6242
|
-
api.send('info', info);
|
|
6243
|
-
}, [api]);
|
|
6244
6291
|
const sendAction = useCallback(body => {
|
|
6245
6292
|
if (!body) {
|
|
6246
6293
|
return;
|
|
@@ -6283,7 +6330,6 @@ const use_seamly_commands_useSeamlyCommands = () => {
|
|
|
6283
6330
|
connect,
|
|
6284
6331
|
start,
|
|
6285
6332
|
sendMessage,
|
|
6286
|
-
sendInfo,
|
|
6287
6333
|
sendAction,
|
|
6288
6334
|
sendContext,
|
|
6289
6335
|
reset,
|
|
@@ -6910,19 +6956,21 @@ function hooks_useTranslations() {
|
|
|
6910
6956
|
function useTranslatedEventData({
|
|
6911
6957
|
payload
|
|
6912
6958
|
} = {}) {
|
|
6913
|
-
|
|
6959
|
+
var _translatedBody, _translatedBody2, _translatedBody3;
|
|
6960
|
+
|
|
6961
|
+
const payloadId = payload === null || payload === void 0 ? void 0 : payload.id;
|
|
6914
6962
|
let body;
|
|
6915
6963
|
let translatedBody;
|
|
6916
6964
|
|
|
6917
|
-
switch (payload
|
|
6965
|
+
switch (payload === null || payload === void 0 ? void 0 : payload.type) {
|
|
6918
6966
|
case 'participant':
|
|
6919
6967
|
body = payload.participant.introduction;
|
|
6920
6968
|
translatedBody = payload.participant.translatedIntroduction;
|
|
6921
6969
|
break;
|
|
6922
6970
|
|
|
6923
6971
|
default:
|
|
6924
|
-
body = payload
|
|
6925
|
-
translatedBody = payload
|
|
6972
|
+
body = payload === null || payload === void 0 ? void 0 : payload.body;
|
|
6973
|
+
translatedBody = payload === null || payload === void 0 ? void 0 : payload.translatedBody;
|
|
6926
6974
|
}
|
|
6927
6975
|
|
|
6928
6976
|
const hasTranslation = !!translatedBody;
|
|
@@ -6937,12 +6985,12 @@ function useTranslatedEventData({
|
|
|
6937
6985
|
dispatch(Actions.enableEvent(payloadId));
|
|
6938
6986
|
}
|
|
6939
6987
|
}, [isTranslated, payloadId, dispatch]);
|
|
6940
|
-
return [hasTranslation && isTranslated ? translatedBody
|
|
6988
|
+
return [hasTranslation && isTranslated ? (_translatedBody = translatedBody) === null || _translatedBody === void 0 ? void 0 : _translatedBody.data : body, {
|
|
6941
6989
|
hasTranslation,
|
|
6942
6990
|
isTranslated: isTranslated && hasTranslation,
|
|
6943
6991
|
toggleTranslation,
|
|
6944
|
-
translatedBy: translatedBody
|
|
6945
|
-
locale: translatedBody
|
|
6992
|
+
translatedBy: (_translatedBody2 = translatedBody) === null || _translatedBody2 === void 0 ? void 0 : _translatedBody2.translatedBy,
|
|
6993
|
+
locale: (_translatedBody3 = translatedBody) === null || _translatedBody3 === void 0 ? void 0 : _translatedBody3.locale
|
|
6946
6994
|
}];
|
|
6947
6995
|
}
|
|
6948
6996
|
function hooks_useTranslationsContainer() {
|
|
@@ -6957,49 +7005,58 @@ function hooks_useLocaleNativeName(locale) {
|
|
|
6957
7005
|
const {
|
|
6958
7006
|
languages
|
|
6959
7007
|
} = hooks_useTranslations();
|
|
6960
|
-
return useMemo(() =>
|
|
7008
|
+
return useMemo(() => {
|
|
7009
|
+
var _languages$find;
|
|
7010
|
+
|
|
7011
|
+
return languages === null || languages === void 0 ? void 0 : (_languages$find = languages.find(lang => lang.locale === locale)) === null || _languages$find === void 0 ? void 0 : _languages$find.nativeName;
|
|
7012
|
+
}, [locale, languages]);
|
|
6961
7013
|
}
|
|
6962
7014
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/middleware.js
|
|
6963
7015
|
|
|
6964
7016
|
|
|
6965
7017
|
|
|
6966
|
-
function middleware_createMiddleware(
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
7018
|
+
function middleware_createMiddleware({
|
|
7019
|
+
dispatch,
|
|
7020
|
+
getState
|
|
7021
|
+
}) {
|
|
7022
|
+
return next => {
|
|
7023
|
+
return action => {
|
|
7024
|
+
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
7025
|
+
|
|
7026
|
+
const result = next(action);
|
|
6972
7027
|
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
7028
|
+
switch (action.type) {
|
|
7029
|
+
case String(seamlyActions.SET_HISTORY):
|
|
7030
|
+
if ((_action$history = action.history) !== null && _action$history !== void 0 && (_action$history$trans = _action$history.translation) !== null && _action$history$trans !== void 0 && _action$history$trans.enabled) {
|
|
7031
|
+
dispatch(Actions.enable(action.history.translation.locale));
|
|
7032
|
+
dispatch(I18nActions.setLocale(action.history.translation.locale));
|
|
7033
|
+
}
|
|
6978
7034
|
|
|
6979
|
-
|
|
7035
|
+
break;
|
|
6980
7036
|
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
7037
|
+
case String(seamlyActions.SET_INITIAL_STATE):
|
|
7038
|
+
if ((_action$initialState = action.initialState) !== null && _action$initialState !== void 0 && (_action$initialState$ = _action$initialState.translation) !== null && _action$initialState$ !== void 0 && _action$initialState$.enabled) {
|
|
7039
|
+
dispatch(Actions.enable(action.initialState.translation.locale));
|
|
7040
|
+
dispatch(I18nActions.setLocale(action.locale));
|
|
7041
|
+
}
|
|
6986
7042
|
|
|
6987
|
-
|
|
7043
|
+
break;
|
|
6988
7044
|
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
7045
|
+
case String(seamlyActions.ADD_EVENT):
|
|
7046
|
+
if (action.event.type === 'info' && ((_action$event = action.event) === null || _action$event === void 0 ? void 0 : (_action$event$payload = _action$event.payload) === null || _action$event$payload === void 0 ? void 0 : (_action$event$payload2 = _action$event$payload.body) === null || _action$event$payload2 === void 0 ? void 0 : _action$event$payload2.subtype) === 'new_translation' && action.event.payload.body.translationEnabled) {
|
|
7047
|
+
dispatch(I18nActions.setLocale(action.event.payload.body.translationLocale));
|
|
7048
|
+
}
|
|
6993
7049
|
|
|
6994
|
-
|
|
7050
|
+
break;
|
|
6995
7051
|
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7052
|
+
case String(Actions.disable):
|
|
7053
|
+
const initialLocale = I18nSelectors.selectInitialLocale(getState());
|
|
7054
|
+
dispatch(I18nActions.setLocale(initialLocale));
|
|
7055
|
+
break;
|
|
7056
|
+
}
|
|
7001
7057
|
|
|
7002
|
-
|
|
7058
|
+
return result;
|
|
7059
|
+
};
|
|
7003
7060
|
};
|
|
7004
7061
|
}
|
|
7005
7062
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/reducer.js
|
|
@@ -7024,7 +7081,9 @@ const translations_reducer_initialState = {
|
|
|
7024
7081
|
};
|
|
7025
7082
|
/* harmony default export */ const translations_reducer = (translations_utils_createReducer({
|
|
7026
7083
|
[seamly_utils_seamlyActions.SET_FEATURES]: (state, action) => {
|
|
7027
|
-
|
|
7084
|
+
var _action$features;
|
|
7085
|
+
|
|
7086
|
+
const feature = action === null || action === void 0 ? void 0 : (_action$features = action.features) === null || _action$features === void 0 ? void 0 : _action$features.translation;
|
|
7028
7087
|
|
|
7029
7088
|
if (!feature) {
|
|
7030
7089
|
return state;
|
|
@@ -8423,7 +8482,7 @@ const StyleGuideApp = ({
|
|
|
8423
8482
|
showFaq
|
|
8424
8483
|
}),
|
|
8425
8484
|
headerTitles: app_objectSpread(app_objectSpread({}, bareState.headerTitles), {}, {
|
|
8426
|
-
subTitle: agent
|
|
8485
|
+
subTitle: (agent === null || agent === void 0 ? void 0 : agent.name) || bareState.headerTitles.subTitle
|
|
8427
8486
|
})
|
|
8428
8487
|
});
|
|
8429
8488
|
|