@seamly/web-ui 19.0.0-beta.2 → 19.0.0-beta.3
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 +6 -6
- package/build/dist/lib/index.debug.min.js +1 -1
- package/build/dist/lib/index.js +108 -53
- package/build/dist/lib/index.min.js +1 -1
- package/build/dist/lib/standalone.js +141 -62
- package/build/dist/lib/standalone.min.js +1 -1
- package/build/dist/lib/storage.js +8 -1
- package/build/dist/lib/storage.min.js +1 -1
- package/build/dist/lib/style-guide.js +94 -46
- package/build/dist/lib/style-guide.min.js +1 -1
- package/package.json +1 -1
- package/src/javascripts/domains/app/actions.js +19 -20
- package/src/javascripts/domains/i18n/actions.js +9 -24
- package/src/javascripts/domains/i18n/reducer.js +9 -3
- package/src/javascripts/domains/i18n/utils.js +2 -7
- package/src/javascripts/lib/redux-helpers/index.js +44 -8
- package/src/javascripts/lib/store/providers/session-storage.js +6 -1
- package/src/javascripts/style-guide/components/static-core.js +1 -1
|
@@ -246,7 +246,14 @@ function store(key) {
|
|
|
246
246
|
const KEY = 'cvco.' + key;
|
|
247
247
|
return {
|
|
248
248
|
get() {
|
|
249
|
-
|
|
249
|
+
const candidates = [KEY, KEY.split('.').slice(0, -1).join('.')];
|
|
250
|
+
let val;
|
|
251
|
+
|
|
252
|
+
do {
|
|
253
|
+
val = sessionStorage.getItem(candidates[0]);
|
|
254
|
+
} while (candidates.shift() && !val);
|
|
255
|
+
|
|
256
|
+
return JSON.parse(val);
|
|
250
257
|
},
|
|
251
258
|
|
|
252
259
|
set(value) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see storage.min.js.LICENSE.txt */
|
|
2
|
-
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(){return{get:()=>{if(window.hasOwnProperty("SeamlyBridge"))try{return JSON.parse(SeamlyBridge.getData())}catch(e){return console.error("Unexpected or malformed data retrieved from bridge",e),{}}return window.seamlyBridgeData},set:e=>{window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.seamlyBridge&&window.webkit.messageHandlers.seamlyBridge.postMessage(JSON.stringify(e)),window.hasOwnProperty("SeamlyBridge")&&SeamlyBridge.setData(JSON.stringify(e)),window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(JSON.stringify(e))}}}function n(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}e.r(t),e.d(t,{appStorageProvider:()=>r,cookieStorageProvider:()=>i,sessionStorageProvider:()=>
|
|
2
|
+
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(){return{get:()=>{if(window.hasOwnProperty("SeamlyBridge"))try{return JSON.parse(SeamlyBridge.getData())}catch(e){return console.error("Unexpected or malformed data retrieved from bridge",e),{}}return window.seamlyBridgeData},set:e=>{window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.seamlyBridge&&window.webkit.messageHandlers.seamlyBridge.postMessage(JSON.stringify(e)),window.hasOwnProperty("SeamlyBridge")&&SeamlyBridge.setData(JSON.stringify(e)),window.ReactNativeWebView&&window.ReactNativeWebView.postMessage(JSON.stringify(e))}}}function n(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)e[n]=r[n]}return e}e.r(t),e.d(t,{appStorageProvider:()=>r,cookieStorageProvider:()=>i,sessionStorageProvider:()=>s});const o=function e(t,r){function o(e,o,i){if("undefined"!=typeof document){"number"==typeof(i=n({},r,i)).expires&&(i.expires=new Date(Date.now()+864e5*i.expires)),i.expires&&(i.expires=i.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var s="";for(var a in i)i[a]&&(s+="; "+a,!0!==i[a]&&(s+="="+i[a].split(";")[0]));return document.cookie=e+"="+t.write(o,e)+s}}return Object.create({set:o,get:function(e){if("undefined"!=typeof document&&(!arguments.length||e)){for(var r=document.cookie?document.cookie.split("; "):[],n={},o=0;o<r.length;o++){var i=r[o].split("="),s=i.slice(1).join("=");try{var a=decodeURIComponent(i[0]);if(n[a]=t.read(s,a),e===a)break}catch(e){}}return e?n[e]:n}},remove:function(e,t){o(e,"",n({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,n({},this.attributes,t))},withConverter:function(t){return e(n({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(r)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"});function i(e={}){return function(t){const r="cvco."+t;return{get(){const e=o.get(r);return e?JSON.parse(e):null},set(t){t&&o.set(r,JSON.stringify(t),e)}}}}function s(e){const t="cvco."+e;return{get(){const e=[t,t.split(".").slice(0,-1).join(".")];let r;do{r=sessionStorage.getItem(e[0])}while(e.shift()&&!r);return JSON.parse(r)},set(e){e&&sessionStorage.setItem(t,JSON.stringify(e))}}}module.exports=t})();
|
|
@@ -1103,6 +1103,7 @@ function redux_helpers_objectSpread(target) { for (var i = 1; i < arguments.leng
|
|
|
1103
1103
|
|
|
1104
1104
|
function redux_helpers_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; }
|
|
1105
1105
|
|
|
1106
|
+
|
|
1106
1107
|
const SLICE_DELIMITER = '/';
|
|
1107
1108
|
const DOMAIN_DELIMITER = '//';
|
|
1108
1109
|
function prefixType(prefix, fn, delimiter = '/') {
|
|
@@ -1115,7 +1116,9 @@ function createAction(type, identityReducer = payload => ({
|
|
|
1115
1116
|
type
|
|
1116
1117
|
}, identityReducer(...params));
|
|
1117
1118
|
|
|
1118
|
-
action.toString = () => type
|
|
1119
|
+
action.toString = () => String(type);
|
|
1120
|
+
|
|
1121
|
+
action.match = obj => (obj === null || obj === void 0 ? void 0 : obj.type) === String(type);
|
|
1119
1122
|
|
|
1120
1123
|
return action;
|
|
1121
1124
|
}
|
|
@@ -1138,16 +1141,70 @@ function createActions(baseType, ...args) {
|
|
|
1138
1141
|
const create = prefixType(baseType, createAction, SLICE_DELIMITER);
|
|
1139
1142
|
return handlers.map(handler => create(...handler));
|
|
1140
1143
|
}
|
|
1141
|
-
function createThunk(type,
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1144
|
+
function createThunk(type, payloadCreator) {
|
|
1145
|
+
const [pending, fulfilled, rejected] = createActions(type, {
|
|
1146
|
+
pending: (arg, requestId) => ({
|
|
1147
|
+
meta: {
|
|
1148
|
+
arg,
|
|
1149
|
+
requestId,
|
|
1150
|
+
status: 'pending'
|
|
1151
|
+
}
|
|
1152
|
+
}),
|
|
1153
|
+
fulfilled: (arg, payload, requestId) => ({
|
|
1154
|
+
payload,
|
|
1155
|
+
meta: {
|
|
1156
|
+
arg,
|
|
1157
|
+
requestId,
|
|
1158
|
+
status: 'fulfilled'
|
|
1159
|
+
}
|
|
1160
|
+
}),
|
|
1161
|
+
rejected: (arg, error, requestId) => ({
|
|
1162
|
+
error,
|
|
1163
|
+
meta: {
|
|
1164
|
+
arg,
|
|
1165
|
+
requestId,
|
|
1166
|
+
status: 'rejected',
|
|
1167
|
+
error: String(error)
|
|
1168
|
+
}
|
|
1169
|
+
})
|
|
1170
|
+
});
|
|
1171
|
+
|
|
1172
|
+
const thunkCreator = arg => (dispatch, getState, extra) => {
|
|
1173
|
+
const requestId = id_randomId();
|
|
1174
|
+
|
|
1175
|
+
const promise = (async () => {
|
|
1176
|
+
let finalAction;
|
|
1177
|
+
|
|
1178
|
+
try {
|
|
1179
|
+
dispatch(pending(arg, requestId));
|
|
1180
|
+
const prms = payloadCreator(arg, {
|
|
1181
|
+
dispatch,
|
|
1182
|
+
getState,
|
|
1183
|
+
extra
|
|
1184
|
+
});
|
|
1185
|
+
const result = await prms;
|
|
1186
|
+
finalAction = fulfilled(arg, result, requestId);
|
|
1187
|
+
} catch (error) {
|
|
1188
|
+
finalAction = rejected(arg, error, requestId);
|
|
1189
|
+
}
|
|
1147
1190
|
|
|
1148
|
-
|
|
1191
|
+
dispatch(finalAction);
|
|
1192
|
+
return finalAction;
|
|
1193
|
+
})();
|
|
1149
1194
|
|
|
1150
|
-
|
|
1195
|
+
return Object.assign(promise, {
|
|
1196
|
+
type,
|
|
1197
|
+
arg,
|
|
1198
|
+
requestId
|
|
1199
|
+
});
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
return Object.assign(thunkCreator, {
|
|
1203
|
+
type,
|
|
1204
|
+
pending,
|
|
1205
|
+
fulfilled,
|
|
1206
|
+
rejected
|
|
1207
|
+
});
|
|
1151
1208
|
}
|
|
1152
1209
|
function createReducer(domain, handlers = {}, defaultState) {
|
|
1153
1210
|
const reducer = (state, action) => {
|
|
@@ -2255,7 +2312,6 @@ function createMutex() {
|
|
|
2255
2312
|
|
|
2256
2313
|
const {
|
|
2257
2314
|
createAction: i18n_utils_createAction,
|
|
2258
|
-
createActions: i18n_utils_createActions,
|
|
2259
2315
|
createThunk: i18n_utils_createThunk,
|
|
2260
2316
|
createReducer: i18n_utils_createReducer,
|
|
2261
2317
|
selectState: i18n_utils_selectState
|
|
@@ -2274,38 +2330,19 @@ const selectLocale = createSelector(i18n_utils_selectState, state => state.local
|
|
|
2274
2330
|
const setInitialLocale = i18n_utils_createAction('setInitialLocale', locale => ({
|
|
2275
2331
|
locale
|
|
2276
2332
|
}));
|
|
2277
|
-
const [setLocaleStart, setLocaleResolve, setLocaleReject] = i18n_utils_createActions('setLocale', {
|
|
2278
|
-
start: locale => ({
|
|
2279
|
-
locale
|
|
2280
|
-
}),
|
|
2281
|
-
resolve: (locale, translations) => ({
|
|
2282
|
-
locale,
|
|
2283
|
-
translations
|
|
2284
|
-
}),
|
|
2285
|
-
reject: (locale, error) => ({
|
|
2286
|
-
locale,
|
|
2287
|
-
error
|
|
2288
|
-
})
|
|
2289
|
-
});
|
|
2290
2333
|
const mutex = createMutex();
|
|
2291
|
-
const setLocale = i18n_utils_createThunk('setLocale',
|
|
2292
|
-
|
|
2334
|
+
const setLocale = i18n_utils_createThunk('setLocale', async (locale, {
|
|
2335
|
+
getState,
|
|
2336
|
+
extra: {
|
|
2337
|
+
api
|
|
2338
|
+
}
|
|
2293
2339
|
}) => {
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
if (currentLocale === locale) {
|
|
2298
|
-
return;
|
|
2340
|
+
return mutex.runExclusively(() => {
|
|
2341
|
+
if (locale === selectLocale(getState())) {
|
|
2342
|
+
return undefined;
|
|
2299
2343
|
}
|
|
2300
2344
|
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
try {
|
|
2304
|
-
const translations = await api.getTranslations(locale);
|
|
2305
|
-
dispatch(setLocaleResolve(locale, translations));
|
|
2306
|
-
} catch (error) {
|
|
2307
|
-
dispatch(setLocaleReject(locale, error));
|
|
2308
|
-
}
|
|
2345
|
+
return api.getTranslations(locale);
|
|
2309
2346
|
});
|
|
2310
2347
|
});
|
|
2311
2348
|
;// CONCATENATED MODULE: ./node_modules/@ultraq/icu-message-formatter/node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
|
|
@@ -3042,13 +3079,21 @@ const defaultState = {
|
|
|
3042
3079
|
}) => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3043
3080
|
initialLocale: locale
|
|
3044
3081
|
}),
|
|
3045
|
-
[
|
|
3082
|
+
[setLocale.pending]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3046
3083
|
isLoading: true
|
|
3047
3084
|
}),
|
|
3048
|
-
[
|
|
3049
|
-
|
|
3050
|
-
|
|
3085
|
+
[setLocale.fulfilled]: (state, {
|
|
3086
|
+
payload: translations,
|
|
3087
|
+
meta: {
|
|
3088
|
+
arg: locale
|
|
3089
|
+
}
|
|
3051
3090
|
}) => {
|
|
3091
|
+
if (!translations) {
|
|
3092
|
+
return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3093
|
+
isLoading: false
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3052
3097
|
return i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3053
3098
|
isLoading: false,
|
|
3054
3099
|
locale,
|
|
@@ -3057,7 +3102,7 @@ const defaultState = {
|
|
|
3057
3102
|
}), {})
|
|
3058
3103
|
});
|
|
3059
3104
|
},
|
|
3060
|
-
[
|
|
3105
|
+
[setLocale.rejected]: state => i18n_reducer_objectSpread(i18n_reducer_objectSpread({}, state), {}, {
|
|
3061
3106
|
isLoading: false
|
|
3062
3107
|
})
|
|
3063
3108
|
}, defaultState));
|
|
@@ -3501,8 +3546,11 @@ const {
|
|
|
3501
3546
|
const setHasResponded = app_utils_createAction('setHasResponded', hasResponded => ({
|
|
3502
3547
|
hasResponded
|
|
3503
3548
|
}));
|
|
3504
|
-
const actions_initialize = app_utils_createThunk('initialize',
|
|
3505
|
-
|
|
3549
|
+
const actions_initialize = app_utils_createThunk('initialize', async (config, {
|
|
3550
|
+
dispatch,
|
|
3551
|
+
extra: {
|
|
3552
|
+
api
|
|
3553
|
+
}
|
|
3506
3554
|
}) => {
|
|
3507
3555
|
try {
|
|
3508
3556
|
var _config$context;
|
|
@@ -5721,7 +5769,7 @@ const SeamlyTestCore = ({
|
|
|
5721
5769
|
}
|
|
5722
5770
|
});
|
|
5723
5771
|
newStore.dispatch(initialize(configSlice || {}));
|
|
5724
|
-
newStore.dispatch(
|
|
5772
|
+
newStore.dispatch(setLocale.fulfilled('en-GB', translations));
|
|
5725
5773
|
return newStore;
|
|
5726
5774
|
}, [state, translations]);
|
|
5727
5775
|
return state && (0,jsx_runtime_namespaceObject.jsx)(web_ui_namespaceObject.StoreProvider, {
|