@applicaster/zapp-react-native-utils 13.0.0-alpha.1400045041 → 13.0.0-alpha.1411904511
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 +0 -1
- package/appUtils/focusManager/__tests__/focusManager.test.js +0 -82
- package/appUtils/focusManager/__tests__/index.test.ts +0 -1
- package/appUtils/focusManager/index.ts +3 -16
- package/appUtils/focusManager/utils/index.ts +0 -14
- package/appUtils/focusManagerAux/index.ts +2 -2
- package/appUtils/keyCodes/index.ts +11 -7
- package/appUtils/playerManager/index.ts +1 -1
- package/manifestUtils/sharedConfiguration/screenPicker/stylesFields.js +1 -1
- package/package.json +2 -2
- package/reactHooks/app/useAppState.ts +2 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { focusManager } from "../index.ts";
|
|
2
2
|
import { focusManager as focusManagerIOS } from "../index.ios.ts";
|
|
3
|
-
import { findFirstFocusableItem } from "../utils";
|
|
4
3
|
|
|
5
4
|
describe("focusManagerIOS", () => {
|
|
6
5
|
it("should be defined", () => {
|
|
@@ -9,67 +8,6 @@ describe("focusManagerIOS", () => {
|
|
|
9
8
|
});
|
|
10
9
|
});
|
|
11
10
|
|
|
12
|
-
const focusableTree = {
|
|
13
|
-
root: {
|
|
14
|
-
children: [
|
|
15
|
-
{
|
|
16
|
-
children: [
|
|
17
|
-
{
|
|
18
|
-
children: [
|
|
19
|
-
{
|
|
20
|
-
children: [],
|
|
21
|
-
component: {
|
|
22
|
-
isGroup: true,
|
|
23
|
-
},
|
|
24
|
-
id: "route/1/1",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
children: [],
|
|
28
|
-
component: {
|
|
29
|
-
isGroup: true,
|
|
30
|
-
},
|
|
31
|
-
id: "route/1/2",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
component: {
|
|
35
|
-
isGroup: true,
|
|
36
|
-
},
|
|
37
|
-
id: "route/1",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
children: [
|
|
41
|
-
{
|
|
42
|
-
children: [],
|
|
43
|
-
component: {
|
|
44
|
-
isGroup: true,
|
|
45
|
-
},
|
|
46
|
-
id: "route/2/1",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
children: [],
|
|
50
|
-
component: {
|
|
51
|
-
isGroup: false,
|
|
52
|
-
},
|
|
53
|
-
id: "route/2/2",
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
component: {
|
|
57
|
-
isGroup: true,
|
|
58
|
-
},
|
|
59
|
-
id: "route/2",
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
component: {
|
|
63
|
-
isGroup: true,
|
|
64
|
-
},
|
|
65
|
-
id: "/river/1234",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
component: null,
|
|
69
|
-
id: "root",
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
|
|
73
11
|
describe("focusManager", () => {
|
|
74
12
|
it("should be defined", () => {
|
|
75
13
|
expect(focusManager).toBeDefined();
|
|
@@ -107,24 +45,4 @@ describe("focusManager", () => {
|
|
|
107
45
|
it("placeholder test", () => {
|
|
108
46
|
expect(true).toBe(true);
|
|
109
47
|
});
|
|
110
|
-
|
|
111
|
-
it("findFirstFocusableItem returns focusableItem", () => {
|
|
112
|
-
const expectedItemId =
|
|
113
|
-
focusableTree.root.children[0].children[1].children[1].id;
|
|
114
|
-
|
|
115
|
-
const focusableItem = findFirstFocusableItem(focusableTree.root.children);
|
|
116
|
-
|
|
117
|
-
expect(
|
|
118
|
-
focusableItem !== undefined && expectedItemId === focusableItem.id
|
|
119
|
-
).toBe(true);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("findFirstFocusableItem does not return focusableItem", () => {
|
|
123
|
-
focusableTree.root.children[0].children[1].children[1].component.isGroup =
|
|
124
|
-
true;
|
|
125
|
-
|
|
126
|
-
const focusableItem = findFirstFocusableItem(focusableTree.root.children);
|
|
127
|
-
|
|
128
|
-
expect(focusableItem === undefined).toBe(true);
|
|
129
|
-
});
|
|
130
48
|
});
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
import { subscriber } from "../../functionUtils";
|
|
14
14
|
import { coreLogger } from "../../logger";
|
|
15
15
|
import { ACTION } from "./utils/enums";
|
|
16
|
-
import { findFirstFocusableItem } from "./utils";
|
|
17
16
|
|
|
18
17
|
const logger = coreLogger.addSubsystem("focusManager");
|
|
19
18
|
|
|
@@ -493,29 +492,20 @@ export const focusManager = (function () {
|
|
|
493
492
|
return haveSameParentBeforeRoot(currentFocusNode, R.last(routes));
|
|
494
493
|
}
|
|
495
494
|
|
|
496
|
-
function
|
|
495
|
+
function recoverFocus() {
|
|
497
496
|
if (!isCurrentFocusOnTheTopScreen()) {
|
|
498
|
-
// We've failed to set focused node on the new screen => run focus
|
|
497
|
+
// We've failed to set focused node on the new screen => run focus recovery
|
|
499
498
|
setInitialFocus();
|
|
500
499
|
}
|
|
501
500
|
}
|
|
502
501
|
|
|
503
|
-
/**
|
|
504
|
-
* sets the focus on first focusable item
|
|
505
|
-
* @public
|
|
506
|
-
*/
|
|
507
|
-
function recoverFocus() {
|
|
508
|
-
const focusableItem = findFirstFocusableItem(focusableTree.root.children);
|
|
509
|
-
focusableItem && setFocus(focusableItem.id);
|
|
510
|
-
}
|
|
511
|
-
|
|
512
502
|
/**
|
|
513
503
|
* moves the focus in a provided direction
|
|
514
504
|
* @public
|
|
515
505
|
* @param {Object} direction of the scroll
|
|
516
506
|
*/
|
|
517
507
|
function moveFocus(direction) {
|
|
518
|
-
if (!isCurrentFocusOnTheTopScreen()
|
|
508
|
+
if (!isCurrentFocusOnTheTopScreen()) {
|
|
519
509
|
// We are opening new screen. We need to ignore movement of focus.
|
|
520
510
|
return false;
|
|
521
511
|
}
|
|
@@ -538,8 +528,6 @@ export const focusManager = (function () {
|
|
|
538
528
|
} else {
|
|
539
529
|
currentFocusNode.component.failedLostFocus(currentFocusNode, direction);
|
|
540
530
|
}
|
|
541
|
-
} else {
|
|
542
|
-
recoverFocus();
|
|
543
531
|
}
|
|
544
532
|
}
|
|
545
533
|
|
|
@@ -584,6 +572,5 @@ export const focusManager = (function () {
|
|
|
584
572
|
isGroupItemFocused,
|
|
585
573
|
recoverFocus,
|
|
586
574
|
isCurrentFocusOnTheTopScreen,
|
|
587
|
-
resetFocus,
|
|
588
575
|
};
|
|
589
576
|
})();
|
|
@@ -98,17 +98,3 @@ export const waitForContent = (focusableTree) => {
|
|
|
98
98
|
conditionFn: contentHasAnyChildren,
|
|
99
99
|
});
|
|
100
100
|
};
|
|
101
|
-
|
|
102
|
-
export const findFirstFocusableItem = (items) => {
|
|
103
|
-
for (const item of items) {
|
|
104
|
-
if (!item.component.isGroup) {
|
|
105
|
-
return item;
|
|
106
|
-
} else {
|
|
107
|
-
if (item.children) {
|
|
108
|
-
const focusableItem = findFirstFocusableItem(item.children);
|
|
109
|
-
|
|
110
|
-
if (focusableItem) return focusableItem;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
@@ -54,7 +54,7 @@ export async function setFocusOnContent(currentRoute: string) {
|
|
|
54
54
|
// For doing it we have to wait registration of first focusable node into focusableTree
|
|
55
55
|
// we wait until content node starts having children
|
|
56
56
|
|
|
57
|
-
const { setInitialFocus, focusableTree
|
|
57
|
+
const { setInitialFocus, focusableTree } = focusManager;
|
|
58
58
|
|
|
59
59
|
try {
|
|
60
60
|
await waitForActiveScreen(currentRoute, focusableTree);
|
|
@@ -71,6 +71,6 @@ export async function setFocusOnContent(currentRoute: string) {
|
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
} catch (error) {
|
|
74
|
-
|
|
74
|
+
setFocusOnContent(currentRoute);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as R from "ramda";
|
|
2
|
-
|
|
3
1
|
// more keys can be added here. Simply make sure
|
|
4
2
|
// the key matches the code value
|
|
5
3
|
|
|
@@ -34,12 +32,18 @@ export function keyCode(key) {
|
|
|
34
32
|
keyCode(keyEvent).matchesAny("Enter", "Backspace", KEYS.ArrowLeft, ...)
|
|
35
33
|
*/
|
|
36
34
|
|
|
37
|
-
const matches =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
const matches = (compareKey) => {
|
|
36
|
+
// If compareKey is a string, look it up in KEYS object
|
|
37
|
+
const keyToCompare =
|
|
38
|
+
typeof compareKey === "string" ? KEYS[compareKey] : compareKey;
|
|
39
|
+
|
|
40
|
+
// Compare either code or keyCode properties
|
|
41
|
+
return (
|
|
42
|
+
keyToCompare?.code === key.code || keyToCompare?.keyCode === key.keyCode
|
|
43
|
+
);
|
|
44
|
+
};
|
|
41
45
|
|
|
42
|
-
const matchesAny = (...args) =>
|
|
46
|
+
const matchesAny = (...args) => args.some(matches);
|
|
43
47
|
|
|
44
48
|
const direction = () =>
|
|
45
49
|
matchesAny(...ARROW_KEYS) ? directionHelper(key) : null;
|
|
@@ -452,7 +452,7 @@ export class PlayerManager {
|
|
|
452
452
|
if (this.castingReceiver) {
|
|
453
453
|
this.castingReceiver.closeNativePlayer();
|
|
454
454
|
} else {
|
|
455
|
-
this.getActivePlayer()
|
|
455
|
+
this.getActivePlayer()?.closeNativePlayer();
|
|
456
456
|
this.invokeHandler("close");
|
|
457
457
|
}
|
|
458
458
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "13.0.0-alpha.
|
|
3
|
+
"version": "13.0.0-alpha.1411904511",
|
|
4
4
|
"description": "Applicaster Zapp React Native utilities package",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "13.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "13.0.0-alpha.1411904511",
|
|
32
32
|
"buffer": "^5.2.1",
|
|
33
33
|
"camelize": "^1.0.0",
|
|
34
34
|
"dayjs": "^1.11.10",
|
|
@@ -14,10 +14,10 @@ export function useAppState(returnIsActive) {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
React.useEffect(() => {
|
|
17
|
-
AppState.addEventListener("change", setAppState);
|
|
17
|
+
const unsubscribe = AppState.addEventListener("change", setAppState);
|
|
18
18
|
|
|
19
19
|
return () => {
|
|
20
|
-
|
|
20
|
+
unsubscribe.remove();
|
|
21
21
|
};
|
|
22
22
|
}, []);
|
|
23
23
|
|