@applicaster/zapp-react-native-utils 13.0.0-rc.86 → 13.0.0-rc.88
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.
|
@@ -58,6 +58,22 @@ type Props = {
|
|
|
58
58
|
children: React.ReactNode;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
function findParentComponent(
|
|
62
|
+
childId: string,
|
|
63
|
+
parent: ZappRiver | ZappUIComponent
|
|
64
|
+
): ZappRiver | ZappUIComponent | null {
|
|
65
|
+
for (const child of parent.ui_components) {
|
|
66
|
+
if (child.id === childId) return parent;
|
|
67
|
+
|
|
68
|
+
if (child.ui_components) {
|
|
69
|
+
const found = findParentComponent(childId, child);
|
|
70
|
+
if (found) return found;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
61
77
|
const prepareDefaultActions = (actionExecutor) => {
|
|
62
78
|
actionExecutor.registerAction("localStorageSet", async (action) => {
|
|
63
79
|
const namespaces = action.options.content;
|
|
@@ -72,11 +88,13 @@ const prepareDefaultActions = (actionExecutor) => {
|
|
|
72
88
|
async (_action, context) => {
|
|
73
89
|
const dispatch = appStore.getDispatch();
|
|
74
90
|
|
|
75
|
-
|
|
91
|
+
const dataSource =
|
|
92
|
+
context?.component?.data?.source ||
|
|
93
|
+
findParentComponent(context?.component.id, context?.screenData)?.data
|
|
94
|
+
?.source;
|
|
76
95
|
|
|
77
|
-
|
|
96
|
+
log_info(`handleAction: refreshComponent for dataSource:${dataSource}`);
|
|
78
97
|
|
|
79
|
-
// TODO: Later we can pass component ids to do refresh instead of current one
|
|
80
98
|
// TODO: In theory we should wait callback to complete, before completing the action, but now it's not needed
|
|
81
99
|
// TODO: handle focused item removal
|
|
82
100
|
dispatch(
|
|
@@ -256,7 +274,7 @@ export function withActionExecutor(Component) {
|
|
|
256
274
|
useEffect(() => {
|
|
257
275
|
return _actionExecutor.registerAction(
|
|
258
276
|
"navigateToScreen",
|
|
259
|
-
async (action: ActionType,
|
|
277
|
+
async (action: ActionType, context?: Record<string, any>) => {
|
|
260
278
|
const screenType = action.options?.typeMapping;
|
|
261
279
|
|
|
262
280
|
if (!screenType) {
|
|
@@ -283,6 +301,7 @@ export function withActionExecutor(Component) {
|
|
|
283
301
|
return ActionResult.Error;
|
|
284
302
|
}
|
|
285
303
|
|
|
304
|
+
context?.callback?.({ success: false, error: null, abort: true });
|
|
286
305
|
navigator.replace(river);
|
|
287
306
|
|
|
288
307
|
return ActionResult.Success;
|
|
@@ -65,6 +65,10 @@ export class Hook implements HookInterface {
|
|
|
65
65
|
event: (typeof HOOKS_EVENTS)[keyof typeof HOOKS_EVENTS],
|
|
66
66
|
...args
|
|
67
67
|
) {
|
|
68
|
+
if (this.state === hookState(HOOKS_EVENTS.CANCEL)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
68
72
|
this.state = hookState(event);
|
|
69
73
|
this.manager.subscriber.invokeHandler(event, ...args);
|
|
70
74
|
}
|
|
@@ -269,6 +269,7 @@ export function HooksManager({
|
|
|
269
269
|
payload = initialPayload,
|
|
270
270
|
callback: callbackArg,
|
|
271
271
|
cancelled,
|
|
272
|
+
abort,
|
|
272
273
|
}) {
|
|
273
274
|
let callback = callbackArg;
|
|
274
275
|
|
|
@@ -308,6 +309,7 @@ export function HooksManager({
|
|
|
308
309
|
hookPlugin.setStateAndNotify(HOOKS_EVENTS.CANCEL, {
|
|
309
310
|
hookPlugin,
|
|
310
311
|
payload,
|
|
312
|
+
abort,
|
|
311
313
|
});
|
|
312
314
|
|
|
313
315
|
const isHookInHomescreen = payload?.home;
|
package/dateUtils/index.ts
CHANGED
|
@@ -2,10 +2,12 @@ import dayjs from "dayjs";
|
|
|
2
2
|
import utc from "dayjs/plugin/utc";
|
|
3
3
|
import timezone from "dayjs/plugin/timezone";
|
|
4
4
|
import isoWeek from "dayjs/plugin/isoWeek";
|
|
5
|
+
import duration from "dayjs/plugin/duration";
|
|
5
6
|
|
|
6
7
|
// Extend dayjs with plugins
|
|
7
8
|
dayjs.extend(utc);
|
|
8
9
|
dayjs.extend(timezone);
|
|
9
10
|
dayjs.extend(isoWeek);
|
|
11
|
+
dayjs.extend(duration);
|
|
10
12
|
|
|
11
13
|
export { dayjs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-rc.
|
|
3
|
+
"version": "13.0.0-rc.88",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@applicaster/applicaster-types": "13.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.0-rc.88",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|
package/utils/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
### ramda replacement utils
|
|
2
|
+
|
|
3
|
+
See contribution guide below
|
|
4
|
+
|
|
5
|
+
## Reference
|
|
6
|
+
|
|
7
|
+
Prefer non-fp variant as it more performant - if refactoring assumes you need more efforts rewrite ramda sample to lodash and it can be easily replaced with lodash-fp - use lodash-fp.
|
|
8
|
+
|
|
9
|
+
### Ramda alternatives:
|
|
10
|
+
|
|
11
|
+
Custom
|
|
12
|
+
- `splitEvery` => `chunk`
|
|
13
|
+
|
|
14
|
+
From `lodash`
|
|
15
|
+
- `clone` => `clone`
|
|
16
|
+
- `flatten` => `flatten`
|
|
17
|
+
- `times` => `flatten`
|
|
18
|
+
- `drop` => `drop`
|
|
19
|
+
- `length` => `size`
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## Contribution
|
|
23
|
+
|
|
24
|
+
To add new helper function as ramda replacement
|
|
25
|
+
|
|
26
|
+
1. Search for replacement ( you can use lodash or pure JS solution), arguments should match with Ramda definition (for easier transition).
|
|
27
|
+
2. Add new file if needed, add test, update exports in index file. 2.1. Make sure it's well-typed.
|
|
28
|
+
3. If the function can-be reexported from other 3rd party lib - update index.ts to re-export it.
|
|
29
|
+
4. Make sure README is updated and contains reference for newly added function.
|
|
30
|
+
5. You can use AI's help. Use query like 'lodash & lodash/fp equivalent of Ramda's R.clone function' to get an options you can use.
|
package/utils/chunk.ts
ADDED
package/utils/index.ts
ADDED