@applicaster/zapp-react-native-utils 15.0.0-rc.55 → 15.0.0-rc.57
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.
|
@@ -194,9 +194,9 @@ export const focusManager = (function () {
|
|
|
194
194
|
registerItem(id, component);
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
const
|
|
197
|
+
const groupId = component?.props?.groupId;
|
|
198
198
|
|
|
199
|
-
emitRegistered({ id,
|
|
199
|
+
emitRegistered({ id, groupId, isGroup });
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
function unregister(id, { group = false } = {}) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReplaySubject, Subject } from "rxjs";
|
|
2
|
-
import { filter, switchMap, take } from "rxjs/operators";
|
|
2
|
+
import { filter, switchMap, take, map } from "rxjs/operators";
|
|
3
3
|
import { BUTTON_PREFIX } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const";
|
|
4
4
|
import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager/index.ios";
|
|
5
5
|
|
|
@@ -11,13 +11,23 @@ type RegistrationEvent = {
|
|
|
11
11
|
|
|
12
12
|
let focusableViewRegistrationSubject$ = new Subject<{
|
|
13
13
|
id: FocusableID;
|
|
14
|
-
|
|
14
|
+
groupId: FocusableID;
|
|
15
15
|
}>();
|
|
16
16
|
|
|
17
17
|
let focusableGroupRegistrationSubject$ = new ReplaySubject<{
|
|
18
18
|
id: FocusableID;
|
|
19
19
|
}>();
|
|
20
20
|
|
|
21
|
+
let focusableNativeViewRegistrationSubject$ = new Subject<{
|
|
22
|
+
id: FocusableID;
|
|
23
|
+
groupId: FocusableID;
|
|
24
|
+
}>();
|
|
25
|
+
|
|
26
|
+
let focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
|
|
27
|
+
id: FocusableID;
|
|
28
|
+
groupId: FocusableID;
|
|
29
|
+
}>();
|
|
30
|
+
|
|
21
31
|
const isFocusableButton = (id: Option<FocusableID>): boolean =>
|
|
22
32
|
id && id.includes?.(BUTTON_PREFIX);
|
|
23
33
|
|
|
@@ -41,35 +51,90 @@ export const resetFocusableRegistration = () => {
|
|
|
41
51
|
focusableGroupRegistrationSubject$.complete();
|
|
42
52
|
}
|
|
43
53
|
|
|
54
|
+
if (!focusableNativeViewRegistrationSubject$.closed) {
|
|
55
|
+
focusableNativeViewRegistrationSubject$.complete();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!focusableNativeGroupRegistrationSubject$.closed) {
|
|
59
|
+
focusableNativeGroupRegistrationSubject$.complete();
|
|
60
|
+
}
|
|
61
|
+
|
|
44
62
|
focusableViewRegistrationSubject$ = new Subject<{
|
|
45
63
|
id: FocusableID;
|
|
46
|
-
|
|
64
|
+
groupId: FocusableID;
|
|
47
65
|
}>();
|
|
48
66
|
|
|
49
67
|
focusableGroupRegistrationSubject$ = new ReplaySubject<{
|
|
50
68
|
id: FocusableID;
|
|
51
69
|
}>();
|
|
70
|
+
|
|
71
|
+
focusableNativeViewRegistrationSubject$ = new Subject<{
|
|
72
|
+
id: FocusableID;
|
|
73
|
+
groupId: FocusableID;
|
|
74
|
+
}>();
|
|
75
|
+
|
|
76
|
+
focusableNativeGroupRegistrationSubject$ = new ReplaySubject<{
|
|
77
|
+
id: FocusableID;
|
|
78
|
+
groupId: FocusableID;
|
|
79
|
+
}>();
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const focusableNativeViewRegistration = ({ focusableView, focusableGroup }) => {
|
|
83
|
+
return focusableNativeViewRegistrationSubject$.pipe(
|
|
84
|
+
filter(
|
|
85
|
+
(focusableNativeView) => focusableNativeView.id === focusableView.id
|
|
86
|
+
),
|
|
87
|
+
take(1),
|
|
88
|
+
switchMap((focusableNativeView) =>
|
|
89
|
+
// start waiting registration of its parent FocusableNativeGroup
|
|
90
|
+
focusableNativeGroupRegistrationSubject$.pipe(
|
|
91
|
+
filter(
|
|
92
|
+
(focusableNativeGroup) =>
|
|
93
|
+
focusableNativeGroup.id === focusableNativeView.groupId
|
|
94
|
+
),
|
|
95
|
+
take(1),
|
|
96
|
+
map((focusableNativeGroup) => ({
|
|
97
|
+
focusableNativeGroup,
|
|
98
|
+
focusableNativeView,
|
|
99
|
+
focusableView,
|
|
100
|
+
focusableGroup,
|
|
101
|
+
}))
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
);
|
|
52
105
|
};
|
|
53
106
|
|
|
54
107
|
export const firstFocusableViewRegistrationFactory = () =>
|
|
55
108
|
focusableViewRegistrationSubject$.pipe(
|
|
56
109
|
take(1), // we care about only first FocusableView registration
|
|
57
|
-
switchMap((
|
|
58
|
-
// start waiting registration of its parent
|
|
110
|
+
switchMap((focusableView) =>
|
|
111
|
+
// start waiting registration of its parent FocusableGroup
|
|
59
112
|
focusableGroupRegistrationSubject$.pipe(
|
|
60
|
-
filter((
|
|
113
|
+
filter((focusableGroup) => focusableGroup.id === focusableView.groupId),
|
|
114
|
+
take(1),
|
|
115
|
+
map((focusableGroup) => ({
|
|
116
|
+
focusableView,
|
|
117
|
+
focusableGroup,
|
|
118
|
+
}))
|
|
61
119
|
)
|
|
62
120
|
),
|
|
63
|
-
|
|
121
|
+
// start waiting registration for FocusableNativeView and its parent FocusableNativeGroup
|
|
122
|
+
switchMap(({ focusableView, focusableGroup }) =>
|
|
123
|
+
focusableNativeViewRegistration({
|
|
124
|
+
focusableView,
|
|
125
|
+
focusableGroup,
|
|
126
|
+
})
|
|
127
|
+
)
|
|
64
128
|
);
|
|
65
129
|
|
|
130
|
+
// registration on RN level(into RN focusManager)
|
|
66
131
|
export const emitRegistered = ({
|
|
67
132
|
id,
|
|
68
|
-
|
|
133
|
+
groupId,
|
|
69
134
|
isGroup,
|
|
70
135
|
}: {
|
|
71
136
|
id: Option<FocusableID>;
|
|
72
|
-
|
|
137
|
+
groupId: Option<FocusableID>;
|
|
73
138
|
isGroup: boolean;
|
|
74
139
|
}): void => {
|
|
75
140
|
if (isFocusableButton(id)) {
|
|
@@ -80,13 +145,33 @@ export const emitRegistered = ({
|
|
|
80
145
|
focusableGroupRegistrationSubject$.next({ id });
|
|
81
146
|
}
|
|
82
147
|
|
|
83
|
-
if (!isGroup && id &&
|
|
84
|
-
focusableViewRegistrationSubject$.next({ id,
|
|
148
|
+
if (!isGroup && id && groupId) {
|
|
149
|
+
focusableViewRegistrationSubject$.next({ id, groupId });
|
|
85
150
|
}
|
|
86
151
|
};
|
|
87
152
|
|
|
153
|
+
// unregistration on RN level(into RN focusManager)
|
|
88
154
|
export const emitUnregistered = (id: Option<FocusableID>): void => {
|
|
89
155
|
if (isFocusableButton(id)) {
|
|
90
156
|
registeredSubject$.next({ id, registered: false });
|
|
91
157
|
}
|
|
92
158
|
};
|
|
159
|
+
|
|
160
|
+
// registration focusableNativeView and focusableNativeGroup
|
|
161
|
+
export const emitNativeRegistered = ({
|
|
162
|
+
id,
|
|
163
|
+
groupId,
|
|
164
|
+
isGroup,
|
|
165
|
+
}: {
|
|
166
|
+
id: Option<FocusableID>;
|
|
167
|
+
groupId: Option<FocusableID>;
|
|
168
|
+
isGroup: boolean;
|
|
169
|
+
}): void => {
|
|
170
|
+
if (!isGroup && id && groupId) {
|
|
171
|
+
focusableNativeViewRegistrationSubject$.next({ id, groupId });
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (isGroup && id && groupId) {
|
|
175
|
+
focusableNativeGroupRegistrationSubject$.next({ id, groupId });
|
|
176
|
+
}
|
|
177
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-utils",
|
|
3
|
-
"version": "15.0.0-rc.
|
|
3
|
+
"version": "15.0.0-rc.57",
|
|
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": "15.0.0-rc.
|
|
30
|
+
"@applicaster/applicaster-types": "15.0.0-rc.57",
|
|
31
31
|
"buffer": "^5.2.1",
|
|
32
32
|
"camelize": "^1.0.0",
|
|
33
33
|
"dayjs": "^1.11.10",
|