@seamly/web-ui 20.3.0 → 20.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/lib/index.debug.js +26 -26
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.js +53 -106
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +7 -3
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/style-guide.js +36 -78
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/javascripts/index.js +1 -0
- package/src/javascripts/ui/components/view/index.js +2 -2
- package/CHANGELOG.md +0 -729
|
@@ -2986,7 +2986,7 @@ function createAction(type, identityReducer = payload => ({
|
|
|
2986
2986
|
|
|
2987
2987
|
action.toString = () => String(type);
|
|
2988
2988
|
|
|
2989
|
-
action.match = obj =>
|
|
2989
|
+
action.match = obj => obj?.type === String(type);
|
|
2990
2990
|
|
|
2991
2991
|
return action;
|
|
2992
2992
|
}
|
|
@@ -3076,7 +3076,7 @@ function createThunk(type, payloadCreator) {
|
|
|
3076
3076
|
}
|
|
3077
3077
|
function createReducer(domain, handlers = {}, defaultState) {
|
|
3078
3078
|
const reducer = (state = defaultState, action) => {
|
|
3079
|
-
const typeReducer = handlers
|
|
3079
|
+
const typeReducer = handlers?.[action?.type];
|
|
3080
3080
|
return typeReducer ? typeReducer(state, action) : state;
|
|
3081
3081
|
};
|
|
3082
3082
|
|
|
@@ -3507,7 +3507,7 @@ function selectors_defineProperty(obj, key, value) { if (key in obj) { Object.de
|
|
|
3507
3507
|
|
|
3508
3508
|
const selectConfig = createSelector(selectState, config => {
|
|
3509
3509
|
let newConfig = selectors_objectSpread({
|
|
3510
|
-
visible:
|
|
3510
|
+
visible: config?.layoutMode === 'inline' ? constants_visibilityStates.open : constants_visibilityStates.minimized,
|
|
3511
3511
|
appContainerClassNames: config.appContainerClassNames || []
|
|
3512
3512
|
}, config);
|
|
3513
3513
|
|
|
@@ -3599,8 +3599,6 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
3599
3599
|
useLayoutEffect(() => {
|
|
3600
3600
|
// we subscribe to the store changes
|
|
3601
3601
|
return store.subscribe(() => {
|
|
3602
|
-
var _selectorRef$current;
|
|
3603
|
-
|
|
3604
3602
|
const newState = store.getState(); // prevent recalculating if the state hasn't changed
|
|
3605
3603
|
// if the selector changed, it was already handled synchronously
|
|
3606
3604
|
|
|
@@ -3609,7 +3607,7 @@ function hooks_useSelector(selector, deps = []) {
|
|
|
3609
3607
|
} // calculate the new value based on selector+state
|
|
3610
3608
|
|
|
3611
3609
|
|
|
3612
|
-
const newValue =
|
|
3610
|
+
const newValue = selectorRef.current?.(store.getState()); // only if the value changed we update. this saves heaps of re-rendering
|
|
3613
3611
|
|
|
3614
3612
|
if (newValue !== valueRef.current) {
|
|
3615
3613
|
valueRef.current = newValue;
|
|
@@ -3672,9 +3670,7 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
3672
3670
|
events,
|
|
3673
3671
|
serviceData
|
|
3674
3672
|
}, config, userHasResponded) => {
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
if (userHasResponded || config.layoutMode === 'inline' || !serviceData.suggestion || !((_serviceData$suggesti = serviceData.suggestion) !== null && _serviceData$suggesti !== void 0 && _serviceData$suggesti.body.length)) {
|
|
3673
|
+
if (userHasResponded || config.layoutMode === 'inline' || !serviceData.suggestion || !serviceData.suggestion?.body.length) {
|
|
3678
3674
|
return events;
|
|
3679
3675
|
}
|
|
3680
3676
|
|
|
@@ -3685,12 +3681,10 @@ const selectEventsWithSuggestion = createSelector(seamly_state_hooks_selectState
|
|
|
3685
3681
|
return [...events, suggestionsEvent];
|
|
3686
3682
|
});
|
|
3687
3683
|
const selectEvents = createSelector(selectEventsWithSuggestion, selectConfig, (events, config) => {
|
|
3688
|
-
var _config$messages;
|
|
3689
|
-
|
|
3690
3684
|
const {
|
|
3691
3685
|
enabled,
|
|
3692
3686
|
threshold
|
|
3693
|
-
} =
|
|
3687
|
+
} = config?.messages?.timeIndicator ?? {};
|
|
3694
3688
|
|
|
3695
3689
|
if (!enabled) {
|
|
3696
3690
|
return events;
|
|
@@ -3723,10 +3717,8 @@ const seamly_state_hooks_useSkiplink = () => seamly_state_hooks_useSeamlyStateCo
|
|
|
3723
3717
|
const useSeamlyParticipant = participantId => seamly_state_hooks_useSeamlyStateContext().participantInfo.participants[participantId];
|
|
3724
3718
|
const useSeamlyServiceInfo = () => seamly_state_hooks_useSeamlyStateContext().serviceInfo;
|
|
3725
3719
|
const selectLastMessageEventId = createSelector(selectEvents, events => {
|
|
3726
|
-
var _filteredEvents;
|
|
3727
|
-
|
|
3728
3720
|
const filteredEvents = events.filter(event => event.type === 'message');
|
|
3729
|
-
return
|
|
3721
|
+
return filteredEvents[filteredEvents.length - 1]?.payload.id;
|
|
3730
3722
|
});
|
|
3731
3723
|
const useLastMessageEventId = () => useSelector(selectLastMessageEventId);
|
|
3732
3724
|
const useSeamlyIsHistoryLoaded = () => seamly_state_hooks_useSeamlyStateContext().historyLoaded;
|
|
@@ -3883,13 +3875,11 @@ const actions_initialize = visibility_utils_createThunk('initialize', async (loc
|
|
|
3883
3875
|
api
|
|
3884
3876
|
}
|
|
3885
3877
|
}) => {
|
|
3886
|
-
var _api$store$get;
|
|
3887
|
-
|
|
3888
3878
|
// initialize stored visibility
|
|
3889
3879
|
const {
|
|
3890
3880
|
layoutMode
|
|
3891
3881
|
} = selectConfig(getState());
|
|
3892
|
-
const storedVisibility =
|
|
3882
|
+
const storedVisibility = api.store.get(StoreKey)?.[layoutMode];
|
|
3893
3883
|
|
|
3894
3884
|
if (storedVisibility) {
|
|
3895
3885
|
dispatch(setFromStorage(storedVisibility));
|
|
@@ -3927,13 +3917,13 @@ class SeamlyBaseError extends Error {
|
|
|
3927
3917
|
|
|
3928
3918
|
this.originalError = originalError;
|
|
3929
3919
|
|
|
3930
|
-
if (originalError
|
|
3920
|
+
if (originalError?.payload) {
|
|
3931
3921
|
this.originalEvent = originalError;
|
|
3932
3922
|
this.originalError = originalError.payload.error;
|
|
3933
3923
|
this.message = `Event of type ${originalError.payload.type} encountered`;
|
|
3934
3924
|
}
|
|
3935
3925
|
|
|
3936
|
-
if (originalError
|
|
3926
|
+
if (originalError?.error) {
|
|
3937
3927
|
this.originalError = originalError.error;
|
|
3938
3928
|
}
|
|
3939
3929
|
}
|
|
@@ -3982,10 +3972,8 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
3982
3972
|
config
|
|
3983
3973
|
}
|
|
3984
3974
|
}) => {
|
|
3985
|
-
var _config$context;
|
|
3986
|
-
|
|
3987
3975
|
dispatch(initialize(config));
|
|
3988
|
-
let locale = config
|
|
3976
|
+
let locale = config?.context?.locale;
|
|
3989
3977
|
|
|
3990
3978
|
try {
|
|
3991
3979
|
const {
|
|
@@ -4012,7 +4000,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4012
4000
|
startChatIcon
|
|
4013
4001
|
}));
|
|
4014
4002
|
|
|
4015
|
-
if (agentParticipant
|
|
4003
|
+
if (agentParticipant?.name) {
|
|
4016
4004
|
dispatch({
|
|
4017
4005
|
type: seamly_utils_seamlyActions.SET_HEADER_SUB_TITLE,
|
|
4018
4006
|
title: agentParticipant.name
|
|
@@ -4024,22 +4012,18 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4024
4012
|
|
|
4025
4013
|
try {
|
|
4026
4014
|
if (api.hasConversation()) {
|
|
4027
|
-
var _initialState$transla;
|
|
4028
|
-
|
|
4029
4015
|
const initialState = await api.getConversationIntitialState();
|
|
4030
4016
|
dispatch({
|
|
4031
4017
|
type: seamly_utils_seamlyActions.SET_INITIAL_STATE,
|
|
4032
4018
|
initialState
|
|
4033
4019
|
});
|
|
4034
|
-
locale =
|
|
4020
|
+
locale = initialState.translation?.locale || locale;
|
|
4035
4021
|
|
|
4036
4022
|
if ('userResponded' in initialState) {
|
|
4037
4023
|
dispatch(setHasResponded(initialState.userResponded));
|
|
4038
4024
|
}
|
|
4039
4025
|
} else {
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
if (config !== null && config !== void 0 && (_config$context2 = config.context) !== null && _config$context2 !== void 0 && _config$context2.topic) {
|
|
4026
|
+
if (config?.context?.topic) {
|
|
4043
4027
|
api.send('action', {
|
|
4044
4028
|
type: seamly_utils_actionTypes.setTopic,
|
|
4045
4029
|
body: {
|
|
@@ -4051,7 +4035,7 @@ const app_actions_initialize = app_utils_createThunk('initialize', async (_, {
|
|
|
4051
4035
|
});
|
|
4052
4036
|
}
|
|
4053
4037
|
|
|
4054
|
-
if (config
|
|
4038
|
+
if (config?.context?.translationLocale) {
|
|
4055
4039
|
locale = config.context.translationLocale;
|
|
4056
4040
|
api.send('action', {
|
|
4057
4041
|
type: seamly_utils_actionTypes.setTranslation,
|
|
@@ -4158,9 +4142,7 @@ function utils_validate(values, schema = {}) {
|
|
|
4158
4142
|
validations = [validations];
|
|
4159
4143
|
}
|
|
4160
4144
|
|
|
4161
|
-
for (let i = 0; i <
|
|
4162
|
-
var _validations;
|
|
4163
|
-
|
|
4145
|
+
for (let i = 0; i < validations?.length ?? 0; i++) {
|
|
4164
4146
|
if (!validations[i].fn(values[key], validations[i].compareValue)) {
|
|
4165
4147
|
errors[key] = validations[i].errorText;
|
|
4166
4148
|
break;
|
|
@@ -4220,7 +4202,7 @@ const getPropSelector = (propName, orDefault) => (_, props) => props[propName] |
|
|
|
4220
4202
|
|
|
4221
4203
|
const getState = forms_utils_selectState;
|
|
4222
4204
|
const selectors_getFormById = createSelector(getState, getPropSelector('formId'), (forms, formId) => forms[formId]);
|
|
4223
|
-
const getFormControlsByFormId = createSelector(selectors_getFormById, form =>
|
|
4205
|
+
const getFormControlsByFormId = createSelector(selectors_getFormById, form => form?.controls || {});
|
|
4224
4206
|
const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId, controls => {
|
|
4225
4207
|
const valuesObj = {};
|
|
4226
4208
|
Object.entries(controls).forEach(([key, {
|
|
@@ -4230,16 +4212,8 @@ const selectors_getFormValuesByFormId = createSelector(getFormControlsByFormId,
|
|
|
4230
4212
|
});
|
|
4231
4213
|
return valuesObj;
|
|
4232
4214
|
});
|
|
4233
|
-
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) =>
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
return (_controls$name = controls[name]) === null || _controls$name === void 0 ? void 0 : _controls$name.value;
|
|
4237
|
-
});
|
|
4238
|
-
const selectors_getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => {
|
|
4239
|
-
var _controls$name2;
|
|
4240
|
-
|
|
4241
|
-
return (_controls$name2 = controls[name]) === null || _controls$name2 === void 0 ? void 0 : _controls$name2.touched;
|
|
4242
|
-
});
|
|
4215
|
+
const selectors_getControlValueByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => controls[name]?.value);
|
|
4216
|
+
const selectors_getControlTouchedByName = createSelector(getFormControlsByFormId, getPropSelector('name'), (controls, name) => controls[name]?.touched);
|
|
4243
4217
|
;// CONCATENATED MODULE: ./src/javascripts/domains/forms/context.js
|
|
4244
4218
|
|
|
4245
4219
|
const context_FormContext = (0,external_preact_namespaceObject.createContext)({});
|
|
@@ -4299,7 +4273,7 @@ function hooks_useFormControl(name) {
|
|
|
4299
4273
|
formId,
|
|
4300
4274
|
name
|
|
4301
4275
|
}, [formId, name]);
|
|
4302
|
-
const error = errors
|
|
4276
|
+
const error = errors?.[name];
|
|
4303
4277
|
const isValid = !error;
|
|
4304
4278
|
useEffect(() => {
|
|
4305
4279
|
// Make sure the form is registered
|
|
@@ -4400,11 +4374,9 @@ function provider_FormProvider(_ref) {
|
|
|
4400
4374
|
});
|
|
4401
4375
|
}, [setExternalErrors]);
|
|
4402
4376
|
const handleSubmit = useCallback(e => {
|
|
4403
|
-
var _e$submitter;
|
|
4404
|
-
|
|
4405
4377
|
e.preventDefault(); // If the submitter is set to being aria-disabled, block the submit action
|
|
4406
4378
|
|
|
4407
|
-
const ariaDisabled =
|
|
4379
|
+
const ariaDisabled = e.submitter?.ariaDisabled === 'true';
|
|
4408
4380
|
setIsSubmitted(!ariaDisabled);
|
|
4409
4381
|
|
|
4410
4382
|
if (!ariaDisabled && validationIsValid) {
|
|
@@ -4471,9 +4443,7 @@ const initialControlState = {
|
|
|
4471
4443
|
};
|
|
4472
4444
|
|
|
4473
4445
|
function updateFormControl(state, formId, name, controlState) {
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
const currentControlState = ((_state$formId = state[formId]) === null || _state$formId === void 0 ? void 0 : _state$formId.controls[name]) || initialControlState;
|
|
4446
|
+
const currentControlState = state[formId]?.controls[name] || initialControlState;
|
|
4477
4447
|
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
|
|
4478
4448
|
[formId]: reducer_objectSpread(reducer_objectSpread({}, state[formId]), {}, {
|
|
4479
4449
|
controls: reducer_objectSpread(reducer_objectSpread({}, state[formId].controls), {}, {
|
|
@@ -4501,11 +4471,9 @@ function updateFormControl(state, formId, name, controlState) {
|
|
|
4501
4471
|
[deregisterForm]: (state, {
|
|
4502
4472
|
formId
|
|
4503
4473
|
}) => {
|
|
4504
|
-
var _newState$formId;
|
|
4505
|
-
|
|
4506
4474
|
const newState = reducer_objectSpread({}, state);
|
|
4507
4475
|
|
|
4508
|
-
if (!
|
|
4476
|
+
if (!newState[formId]?.persistData) {
|
|
4509
4477
|
delete newState[formId];
|
|
4510
4478
|
}
|
|
4511
4479
|
|
|
@@ -6825,21 +6793,19 @@ function hooks_useTranslations() {
|
|
|
6825
6793
|
function useTranslatedEventData({
|
|
6826
6794
|
payload
|
|
6827
6795
|
} = {}) {
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
const payloadId = payload === null || payload === void 0 ? void 0 : payload.id;
|
|
6796
|
+
const payloadId = payload?.id;
|
|
6831
6797
|
let body;
|
|
6832
6798
|
let translatedBody;
|
|
6833
6799
|
|
|
6834
|
-
switch (payload
|
|
6800
|
+
switch (payload?.type) {
|
|
6835
6801
|
case 'participant':
|
|
6836
6802
|
body = payload.participant.introduction;
|
|
6837
6803
|
translatedBody = payload.participant.translatedIntroduction;
|
|
6838
6804
|
break;
|
|
6839
6805
|
|
|
6840
6806
|
default:
|
|
6841
|
-
body = payload
|
|
6842
|
-
translatedBody = payload
|
|
6807
|
+
body = payload?.body;
|
|
6808
|
+
translatedBody = payload?.translatedBody;
|
|
6843
6809
|
}
|
|
6844
6810
|
|
|
6845
6811
|
const hasTranslation = !!translatedBody;
|
|
@@ -6854,12 +6820,12 @@ function useTranslatedEventData({
|
|
|
6854
6820
|
dispatch(Actions.enableEvent(payloadId));
|
|
6855
6821
|
}
|
|
6856
6822
|
}, [isTranslated, payloadId, dispatch]);
|
|
6857
|
-
return [hasTranslation && isTranslated ?
|
|
6823
|
+
return [hasTranslation && isTranslated ? translatedBody?.data : body, {
|
|
6858
6824
|
hasTranslation,
|
|
6859
6825
|
isTranslated: isTranslated && hasTranslation,
|
|
6860
6826
|
toggleTranslation,
|
|
6861
|
-
translatedBy:
|
|
6862
|
-
locale:
|
|
6827
|
+
translatedBy: translatedBody?.translatedBy,
|
|
6828
|
+
locale: translatedBody?.locale
|
|
6863
6829
|
}];
|
|
6864
6830
|
}
|
|
6865
6831
|
function hooks_useTranslationsContainer() {
|
|
@@ -6874,11 +6840,7 @@ function hooks_useLocaleNativeName(locale) {
|
|
|
6874
6840
|
const {
|
|
6875
6841
|
languages
|
|
6876
6842
|
} = hooks_useTranslations();
|
|
6877
|
-
return useMemo(() =>
|
|
6878
|
-
var _languages$find;
|
|
6879
|
-
|
|
6880
|
-
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;
|
|
6881
|
-
}, [locale, languages]);
|
|
6843
|
+
return useMemo(() => languages?.find(lang => lang.locale === locale)?.nativeName, [locale, languages]);
|
|
6882
6844
|
}
|
|
6883
6845
|
;// CONCATENATED MODULE: ./src/javascripts/domains/translations/middleware.js
|
|
6884
6846
|
|
|
@@ -6889,20 +6851,18 @@ function middleware_createMiddleware() {
|
|
|
6889
6851
|
dispatch,
|
|
6890
6852
|
getState
|
|
6891
6853
|
}) => next => action => {
|
|
6892
|
-
var _action$history, _action$history$trans, _action$initialState, _action$initialState$, _action$event, _action$event$payload, _action$event$payload2;
|
|
6893
|
-
|
|
6894
6854
|
const result = next(action);
|
|
6895
6855
|
|
|
6896
6856
|
switch (action.type) {
|
|
6897
6857
|
case String(seamlyActions.SET_HISTORY):
|
|
6898
|
-
if (
|
|
6858
|
+
if (action.history?.translation?.enabled) {
|
|
6899
6859
|
dispatch(Actions.enable(action.history.translation.locale));
|
|
6900
6860
|
}
|
|
6901
6861
|
|
|
6902
6862
|
break;
|
|
6903
6863
|
|
|
6904
6864
|
case String(seamlyActions.SET_INITIAL_STATE):
|
|
6905
|
-
if (
|
|
6865
|
+
if (action.initialState?.translation?.enabled) {
|
|
6906
6866
|
dispatch(Actions.enable(action.initialState.translation.locale));
|
|
6907
6867
|
dispatch(I18nActions.setLocale(action.locale));
|
|
6908
6868
|
}
|
|
@@ -6910,7 +6870,7 @@ function middleware_createMiddleware() {
|
|
|
6910
6870
|
break;
|
|
6911
6871
|
|
|
6912
6872
|
case String(seamlyActions.ADD_EVENT):
|
|
6913
|
-
if (action.event.type === 'info' &&
|
|
6873
|
+
if (action.event.type === 'info' && action.event?.payload?.body?.subtype === 'new_translation' && action.event.payload.body.translationEnabled) {
|
|
6914
6874
|
dispatch(I18nActions.setLocale(action.event.payload.body.translationLocale));
|
|
6915
6875
|
}
|
|
6916
6876
|
|
|
@@ -6947,9 +6907,7 @@ const translations_reducer_initialState = {
|
|
|
6947
6907
|
};
|
|
6948
6908
|
/* harmony default export */ const translations_reducer = (translations_utils_createReducer({
|
|
6949
6909
|
[seamly_utils_seamlyActions.SET_FEATURES]: (state, action) => {
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
const feature = action === null || action === void 0 ? void 0 : (_action$features = action.features) === null || _action$features === void 0 ? void 0 : _action$features.translation;
|
|
6910
|
+
const feature = action?.features?.translation;
|
|
6953
6911
|
|
|
6954
6912
|
if (!feature) {
|
|
6955
6913
|
return state;
|
|
@@ -8347,7 +8305,7 @@ const StyleGuideApp = ({
|
|
|
8347
8305
|
showFaq
|
|
8348
8306
|
}),
|
|
8349
8307
|
headerTitles: app_objectSpread(app_objectSpread({}, bareState.headerTitles), {}, {
|
|
8350
|
-
subTitle:
|
|
8308
|
+
subTitle: agent?.name || bareState.headerTitles.subTitle
|
|
8351
8309
|
})
|
|
8352
8310
|
});
|
|
8353
8311
|
|