@evlop/commons 1.0.93 → 1.0.94
Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,6 @@ interface ActionObject {
|
|
13
13
|
callback: Function;
|
14
14
|
}
|
15
15
|
declare type Action = ActionObject | Function | any;
|
16
|
-
export declare const useAction: (action: Action) => any;
|
16
|
+
export declare const useAction: (action: Action) => (event: any) => any;
|
17
17
|
export default useAction;
|
18
18
|
//# sourceMappingURL=useAction.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAction.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AAEF,UAAU,YAAY;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED,aAAK,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,GAAG,CAAA;AAE5C,eAAO,MAAM,SAAS,WAAY,MAAM,
|
1
|
+
{"version":3,"file":"useAction.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAction.tsx"],"names":[],"mappings":"AASA;;;;GAIG;AAEF,UAAU,YAAY;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;CACtB;AAED,aAAK,MAAM,GAAG,YAAY,GAAG,QAAQ,GAAG,GAAG,CAAA;AAE5C,eAAO,MAAM,SAAS,WAAY,MAAM,wBAgCvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
@@ -16,7 +16,7 @@ const useAction = (action) => {
|
|
16
16
|
const dispatch = react_redux_1.useDispatch();
|
17
17
|
const scope = useScope_1.useScope();
|
18
18
|
const template = useTemplate_1.default();
|
19
|
-
return react_1.
|
19
|
+
return react_1.useCallback((event) => {
|
20
20
|
let actionToUse = action;
|
21
21
|
while (actionToUse && actionToUse.bindKey) {
|
22
22
|
actionToUse = lodash_1.get(scope, actionToUse.bindKey);
|
@@ -26,25 +26,25 @@ const useAction = (action) => {
|
|
26
26
|
if (actionToUse) {
|
27
27
|
const { link, navigate, push, page, params, dispatch: dispatchAction, route, callback } = actionToUse;
|
28
28
|
if (link)
|
29
|
-
return
|
29
|
+
return navigator.openURL(template(link));
|
30
30
|
if (navigate)
|
31
|
-
return
|
31
|
+
return navigator.navigate(...lodash_1.castArray(JSON.parse(template(JSON.stringify(navigate)))));
|
32
32
|
if (push)
|
33
|
-
return
|
34
|
-
if (page)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
return navigator.push(...lodash_1.castArray(JSON.parse(template(JSON.stringify(navigate)))));
|
34
|
+
if (page) {
|
35
|
+
console.log(page, params);
|
36
|
+
const routeParams = lodash_2.mapValues(params, (paramValue) => template(paramValue.toString()));
|
37
|
+
return navigator.openPage(page, routeParams);
|
38
|
+
}
|
39
|
+
;
|
40
40
|
if (route)
|
41
|
-
return
|
41
|
+
return navigator.openRoute(template(route));
|
42
42
|
if (dispatchAction)
|
43
|
-
return
|
43
|
+
return dispatch(dispatchAction);
|
44
44
|
if (callback)
|
45
|
-
return
|
45
|
+
return callback({ event, navigator, dispatch });
|
46
46
|
}
|
47
|
-
}, [action, navigator, dispatch]);
|
47
|
+
}, [action, navigator, dispatch, template, scope]);
|
48
48
|
};
|
49
49
|
exports.useAction = useAction;
|
50
50
|
exports.default = exports.useAction;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useAction.js","sourceRoot":"","sources":["../../../src/hooks/useAction.tsx"],"names":[],"mappings":";;;;;;AAAA,
|
1
|
+
{"version":3,"file":"useAction.js","sourceRoot":"","sources":["../../../src/hooks/useAction.tsx"],"names":[],"mappings":";;;;;;AAAA,iCAA6C;AAC7C,6CAA0C;AAC1C,mCAAwC;AACxC,iDAA4C;AAC5C,yCAAoC;AACpC,gEAAwC;AACxC,mCAAiC;AAqB1B,MAAM,SAAS,GAAG,CAAC,MAAc,EAAC,EAAE;IAEvC,MAAM,SAAS,GAAG,2BAAY,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,yBAAW,EAAE,CAAC;IAC/B,MAAM,KAAK,GAAG,mBAAQ,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,qBAAW,EAAE,CAAC;IAE/B,OAAO,mBAAW,CAAC,CAAC,KAAK,EAAC,EAAE;QACxB,IAAI,WAAW,GAAG,MAAM,CAAC;QAEzB,OAAO,WAAW,IAAI,WAAW,CAAC,OAAO,EAAC;YACtC,WAAW,GAAG,YAAG,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;SACjD;QAED,IAAG,OAAO,WAAW,KAAK,UAAU;YAAE,OAAO,WAAW,CAAC;QAEzD,IAAG,WAAW,EAAE;YACZ,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,QAAQ,EAAC,GAAG,WAAW,CAAC;YAErG,IAAI,IAAI;gBAAE,OAAO,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YACnD,IAAI,QAAQ;gBAAE,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,kBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,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