@applicaster/zapp-react-native-utils 13.0.12 → 13.0.13-rc.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/appUtils/focusManager/__tests__/__snapshots__/focusManager.test.js.snap +1 -0
- package/appUtils/focusManager/index.ios.ts +18 -1
- package/appUtils/focusManagerAux/utils/index.ts +19 -1
- package/appUtils/focusManagerAux/utils/utils.ios.ts +35 -0
- package/navigationUtils/index.ts +19 -16
- package/package.json +2 -2
- package/utils/index.ts +8 -0
|
@@ -64,6 +64,7 @@ exports[`focusManagerIOS should be defined 1`] = `
|
|
|
64
64
|
"getGroupRootById": [Function],
|
|
65
65
|
"getPreferredFocusChild": [Function],
|
|
66
66
|
"invokeHandler": [Function],
|
|
67
|
+
"isChildOf": [Function],
|
|
67
68
|
"isFocusOn": [Function],
|
|
68
69
|
"isGroupItemFocused": [Function],
|
|
69
70
|
"moveFocus": [Function],
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { NativeModules } from "react-native";
|
|
2
2
|
import * as R from "ramda";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
isCurrentFocusOn,
|
|
6
|
+
isChildOf as isChildOfUtils,
|
|
7
|
+
} from "../focusManagerAux/utils";
|
|
5
8
|
import { Tree } from "./treeDataStructure/Tree";
|
|
6
9
|
import { findFocusableNode } from "./treeDataStructure/Utils";
|
|
7
10
|
import { subscriber } from "../../functionUtils";
|
|
8
11
|
import { findChild } from "./utils";
|
|
9
12
|
|
|
13
|
+
import {
|
|
14
|
+
emitRegistered,
|
|
15
|
+
emitUnregistered,
|
|
16
|
+
} from "../focusManagerAux/utils/utils.ios";
|
|
17
|
+
|
|
10
18
|
const { FocusableManagerModule } = NativeModules;
|
|
11
19
|
|
|
12
20
|
/**
|
|
@@ -180,10 +188,14 @@ export const focusManager = (function () {
|
|
|
180
188
|
function register({ id, component }) {
|
|
181
189
|
const { isGroup = false } = component;
|
|
182
190
|
|
|
191
|
+
emitRegistered(id);
|
|
192
|
+
|
|
183
193
|
return isGroup ? registerGroup(id, component) : registerItem(id, component);
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
function unregister(id, { group = false } = {}) {
|
|
197
|
+
emitUnregistered(id);
|
|
198
|
+
|
|
187
199
|
group ? unregisterGroup(id) : unregisterItem(id);
|
|
188
200
|
}
|
|
189
201
|
|
|
@@ -400,6 +412,10 @@ export const focusManager = (function () {
|
|
|
400
412
|
return id && isCurrentFocusOn(id, currentFocusNode);
|
|
401
413
|
}
|
|
402
414
|
|
|
415
|
+
function isChildOf(childId, parentId): boolean {
|
|
416
|
+
return isChildOfUtils(focusableTree, childId, parentId);
|
|
417
|
+
}
|
|
418
|
+
|
|
403
419
|
return {
|
|
404
420
|
on,
|
|
405
421
|
invokeHandler,
|
|
@@ -422,5 +438,6 @@ export const focusManager = (function () {
|
|
|
422
438
|
isGroupItemFocused,
|
|
423
439
|
getPreferredFocusChild,
|
|
424
440
|
isFocusOn,
|
|
441
|
+
isChildOf,
|
|
425
442
|
};
|
|
426
443
|
})();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNotNil } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
|
|
2
|
-
import { find, last, pathOr, startsWith } from "ramda";
|
|
2
|
+
import { find, last, pathOr, startsWith, isNil } from "ramda";
|
|
3
3
|
import {
|
|
4
4
|
QUICK_BRICK_CONTENT,
|
|
5
5
|
QUICK_BRICK_NAVBAR,
|
|
@@ -117,3 +117,21 @@ export const isCurrentFocusOn = (id, node) => {
|
|
|
117
117
|
|
|
118
118
|
return isCurrentFocusOn(id, node.parent);
|
|
119
119
|
};
|
|
120
|
+
|
|
121
|
+
export const isChildOf = (focusableTree, childId, parentId) => {
|
|
122
|
+
if (isNil(childId) || isNil(parentId)) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const childNode = focusableTree.findInTree(childId);
|
|
127
|
+
|
|
128
|
+
if (isNil(childNode)) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (childNode.parent?.id === parentId) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return isChildOf(focusableTree, childNode.parent?.id, parentId);
|
|
137
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ReplaySubject } from "rxjs";
|
|
2
|
+
import { filter } from "rxjs/operators";
|
|
3
|
+
import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
|
|
4
|
+
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
|
|
5
|
+
|
|
6
|
+
type FocusableID = string;
|
|
7
|
+
type RegistrationEvent = {
|
|
8
|
+
id: FocusableID;
|
|
9
|
+
registered: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const isFocusableButton = (id: Option<FocusableID>): boolean =>
|
|
13
|
+
id && id.includes?.(BUTTON_PREFIX);
|
|
14
|
+
|
|
15
|
+
const registeredSubject$ = new ReplaySubject<RegistrationEvent>(1);
|
|
16
|
+
|
|
17
|
+
export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
|
|
18
|
+
registeredSubject$.pipe(
|
|
19
|
+
filter(
|
|
20
|
+
(value) =>
|
|
21
|
+
value.registered && focusManager.isChildOf(value.id, focusableGroupId)
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const emitRegistered = (id: Option<FocusableID>): void => {
|
|
26
|
+
if (isFocusableButton(id)) {
|
|
27
|
+
registeredSubject$.next({ id, registered: true });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const emitUnregistered = (id: Option<FocusableID>): void => {
|
|
32
|
+
if (isFocusableButton(id)) {
|
|
33
|
+
registeredSubject$.next({ id, registered: false });
|
|
34
|
+
}
|
|
35
|
+
};
|
package/navigationUtils/index.ts
CHANGED
|
@@ -604,24 +604,27 @@ export function routeIsPlayerScreen(currentRoute) {
|
|
|
604
604
|
return currentRoute?.includes("/playable");
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
-
export const getNavBarProps =
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
607
|
+
export const getNavBarProps = (
|
|
608
|
+
currentRiver: ZappRiver,
|
|
609
|
+
pathname: string,
|
|
610
|
+
title: string
|
|
611
|
+
) => {
|
|
612
|
+
const props = getNavigationPropsV2({
|
|
613
|
+
currentRiver,
|
|
614
|
+
title,
|
|
615
|
+
category: "nav_bar",
|
|
616
|
+
});
|
|
614
617
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
618
|
+
if (props) {
|
|
619
|
+
return {
|
|
620
|
+
...props,
|
|
621
|
+
id: pathname,
|
|
622
|
+
pathname: pathname,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
622
625
|
|
|
623
|
-
|
|
624
|
-
|
|
626
|
+
return null;
|
|
627
|
+
};
|
|
625
628
|
|
|
626
629
|
export const findMenuPlugin = (
|
|
627
630
|
navigations: ZappNavigation[],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.13-rc.0",
|
|
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.
|
|
30
|
+
"@applicaster/applicaster-types": "13.0.13-rc.0",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|