@elliemae/pui-app-sdk 5.0.1 → 5.1.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/dist/cjs/api/helpers.js
CHANGED
|
@@ -24,19 +24,15 @@ __export(helpers_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(helpers_exports);
|
|
25
25
|
var import_toolkit = require("@reduxjs/toolkit");
|
|
26
26
|
var import_lodash = require("lodash");
|
|
27
|
-
var import_react = require("react");
|
|
28
27
|
const getApiActionCreator = (api) => (operation) => ({
|
|
29
28
|
[operation]: (0, import_toolkit.createAction)(`${api}/${operation}`),
|
|
30
29
|
[`${operation}Success`]: (0, import_toolkit.createAction)(`${api}/${operation}Success`),
|
|
31
30
|
[`${operation}Error`]: (0, import_toolkit.createAction)(`${api}/${operation}Error`)
|
|
32
31
|
});
|
|
33
|
-
const getSelectField = (stateName) => (fieldName = "", defaultValue) => (state = {}, stateValue = (0, import_lodash.get)(state, stateName)) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
)
|
|
41
|
-
) : (0, import_lodash.get)(stateValue, fieldName, finalDefaultValue);
|
|
42
|
-
};
|
|
32
|
+
const getSelectField = (stateName) => (fieldName = "", defaultValue) => (state = {}, stateValue = (0, import_lodash.get)(state, stateName)) => Array.isArray(fieldName) ? fieldName.map(
|
|
33
|
+
(field, i) => (0, import_lodash.get)(
|
|
34
|
+
stateValue,
|
|
35
|
+
field,
|
|
36
|
+
Array.isArray(defaultValue) ? defaultValue[i] : defaultValue
|
|
37
|
+
)
|
|
38
|
+
) : (0, import_lodash.get)(stateValue, fieldName, defaultValue);
|
package/dist/esm/api/helpers.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { createAction } from "@reduxjs/toolkit";
|
|
2
2
|
import { get } from "lodash";
|
|
3
|
-
import { useMemo } from "react";
|
|
4
3
|
const getApiActionCreator = (api) => (operation) => ({
|
|
5
4
|
[operation]: createAction(`${api}/${operation}`),
|
|
6
5
|
[`${operation}Success`]: createAction(`${api}/${operation}Success`),
|
|
7
6
|
[`${operation}Error`]: createAction(`${api}/${operation}Error`)
|
|
8
7
|
});
|
|
9
|
-
const getSelectField = (stateName) => (fieldName = "", defaultValue) => (state = {}, stateValue = get(state, stateName)) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
) : get(stateValue, fieldName, finalDefaultValue);
|
|
18
|
-
};
|
|
8
|
+
const getSelectField = (stateName) => (fieldName = "", defaultValue) => (state = {}, stateValue = get(state, stateName)) => Array.isArray(fieldName) ? fieldName.map(
|
|
9
|
+
(field, i) => get(
|
|
10
|
+
stateValue,
|
|
11
|
+
field,
|
|
12
|
+
Array.isArray(defaultValue) ? defaultValue[i] : defaultValue
|
|
13
|
+
)
|
|
14
|
+
) : get(stateValue, fieldName, defaultValue);
|
|
19
15
|
export {
|
|
20
16
|
getApiActionCreator,
|
|
21
17
|
getSelectField
|
|
@@ -51,7 +51,10 @@ export declare const getApiActionCreator: (api: string) => (operation: string) =
|
|
|
51
51
|
* import { selectSomeState } from 'slices/some-slice';
|
|
52
52
|
* import { useSelector, shallowEqual } from 'react-redux';
|
|
53
53
|
*
|
|
54
|
-
* export const useSelectSomeState = (fieldName, defaultValue) =>
|
|
54
|
+
* export const useSelectSomeState = (fieldName, defaultValue) => {
|
|
55
|
+
* const finalDefaultValue = useMemo(() => defaultValue, []);
|
|
56
|
+
* useSelector(selectSomeState(fieldName, defaultValue), shallowEqual);
|
|
57
|
+
* }
|
|
55
58
|
*
|
|
56
59
|
* // some-component.js
|
|
57
60
|
* import { useSelectSomeState } from 'custom-hooks/state-selectors.js'
|