@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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { randomId } from '../id'
|
|
2
|
+
|
|
1
3
|
export const SLICE_DELIMITER = '/'
|
|
2
4
|
export const DOMAIN_DELIMITER = '//'
|
|
3
5
|
|
|
@@ -10,7 +12,8 @@ export function createAction(
|
|
|
10
12
|
identityReducer = (payload) => ({ payload }),
|
|
11
13
|
) {
|
|
12
14
|
const action = (...params) => ({ type, ...identityReducer(...params) })
|
|
13
|
-
action.toString = () => type
|
|
15
|
+
action.toString = () => String(type)
|
|
16
|
+
action.match = (obj) => obj?.type === String(type)
|
|
14
17
|
return action
|
|
15
18
|
}
|
|
16
19
|
|
|
@@ -32,14 +35,47 @@ export function createActions(baseType, ...args) {
|
|
|
32
35
|
return handlers.map((handler) => create(...handler))
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
export function createThunk(type,
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
})
|
|
40
72
|
}
|
|
41
|
-
|
|
42
|
-
|
|
73
|
+
return Object.assign(thunkCreator, {
|
|
74
|
+
type,
|
|
75
|
+
pending,
|
|
76
|
+
fulfilled,
|
|
77
|
+
rejected,
|
|
78
|
+
})
|
|
43
79
|
}
|
|
44
80
|
|
|
45
81
|
export function createReducer(domain, handlers = {}, defaultState) {
|
|
@@ -3,7 +3,12 @@ export default function store(key) {
|
|
|
3
3
|
|
|
4
4
|
return {
|
|
5
5
|
get() {
|
|
6
|
-
|
|
6
|
+
const candidates = [KEY, KEY.split('.').slice(0, -1).join('.')]
|
|
7
|
+
let val
|
|
8
|
+
do {
|
|
9
|
+
val = sessionStorage.getItem(candidates[0])
|
|
10
|
+
} while (candidates.shift() && !val)
|
|
11
|
+
return JSON.parse(val)
|
|
7
12
|
},
|
|
8
13
|
|
|
9
14
|
set(value) {
|
|
@@ -56,7 +56,7 @@ const SeamlyTestCore = ({ state, translations, children }) => {
|
|
|
56
56
|
},
|
|
57
57
|
})
|
|
58
58
|
newStore.dispatch(ConfigActions.initialize(configSlice || {}))
|
|
59
|
-
newStore.dispatch(I18nActions.
|
|
59
|
+
newStore.dispatch(I18nActions.setLocale.fulfilled('en-GB', translations))
|
|
60
60
|
return newStore
|
|
61
61
|
}, [state, translations])
|
|
62
62
|
|