@exodus/ui-config 2.0.0 → 3.0.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/index.js +7 -3
- package/package.json +10 -6
- package/utils.js +14 -0
package/index.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { createStorageAtomFactory } from '@exodus/atoms'
|
|
2
|
+
|
|
2
3
|
import createUiConfigApiDefinition from './api'
|
|
3
4
|
import createUiConfigPluginDefinition from './plugin'
|
|
5
|
+
import { getAtomId } from './utils'
|
|
6
|
+
|
|
7
|
+
export { getConfigReduxEvents, getEventReduxMap } from './utils'
|
|
4
8
|
|
|
5
9
|
const createUiConfigFeatureDefinition = ({ config }) => {
|
|
6
|
-
const
|
|
7
|
-
const configAtomMap = Object.fromEntries(
|
|
10
|
+
const configValues = Object.values(config)
|
|
11
|
+
const configAtomMap = Object.fromEntries(configValues.map(({ id }) => [id, getAtomId(id)]))
|
|
8
12
|
const atomConfigMap = Object.fromEntries(
|
|
9
13
|
Object.keys(configAtomMap).map((configId) => [configAtomMap[configId], configId])
|
|
10
14
|
)
|
|
11
|
-
const atoms =
|
|
15
|
+
const atoms = configValues.map(({ id }) => ({
|
|
12
16
|
definition: {
|
|
13
17
|
id: configAtomMap[id],
|
|
14
18
|
type: 'atom',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ui-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Helper for storing various UI-specific settings/config.",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -17,19 +17,23 @@
|
|
|
17
17
|
"README.md",
|
|
18
18
|
"utils.js",
|
|
19
19
|
"plugin",
|
|
20
|
-
"api"
|
|
20
|
+
"api",
|
|
21
|
+
"utils"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
23
24
|
"lint": "eslint . --ignore-path ../../.gitignore",
|
|
24
|
-
"lint:fix": "yarn lint --fix"
|
|
25
|
+
"lint:fix": "yarn lint --fix",
|
|
26
|
+
"test": "jest"
|
|
25
27
|
},
|
|
26
28
|
"dependencies": {
|
|
27
|
-
"@exodus/atoms": "^5.
|
|
29
|
+
"@exodus/atoms": "^5.6.0",
|
|
28
30
|
"@exodus/basic-utils": "^2.1.0",
|
|
31
|
+
"@exodus/formatting": "^1.1.1",
|
|
29
32
|
"lodash": "^4.17.21"
|
|
30
33
|
},
|
|
31
34
|
"devDependencies": {
|
|
32
|
-
"eslint": "^8.44.0"
|
|
35
|
+
"eslint": "^8.44.0",
|
|
36
|
+
"jest": "^29.1.2"
|
|
33
37
|
},
|
|
34
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "0840a06d2b117adb4895d978418394cdf5a1a128"
|
|
35
39
|
}
|
package/utils.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toUpperSnakeCase } from '@exodus/formatting'
|
|
2
|
+
|
|
3
|
+
export const getAtomId = (id) => `${id}ConfigAtom`
|
|
4
|
+
|
|
5
|
+
const toReduxEvent = (type) => `EVENT_${toUpperSnakeCase(type.replace(/configatom$/i, ''))}_CONFIG`
|
|
6
|
+
const getConfigReduxEventName = (id) => toReduxEvent(getAtomId(id))
|
|
7
|
+
|
|
8
|
+
export const getEventReduxMap = (config) =>
|
|
9
|
+
Object.fromEntries(
|
|
10
|
+
Object.values(config).map(({ id }) => [getAtomId(id), getConfigReduxEventName(id)])
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
export const getConfigReduxEvents = (config) =>
|
|
14
|
+
new Map(Object.values(config).map(({ id }) => [getConfigReduxEventName(id), id]))
|