@applicaster/zapp-react-native-utils 13.0.21-rc.1 → 13.0.21

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.
@@ -188,9 +188,15 @@ export const focusManager = (function () {
188
188
  function register({ id, component }) {
189
189
  const { isGroup = false } = component;
190
190
 
191
- emitRegistered(id);
191
+ if (isGroup) {
192
+ registerGroup(id, component);
193
+ } else {
194
+ registerItem(id, component);
195
+ }
196
+
197
+ const parentId = component?.props?.groupId;
192
198
 
193
- return isGroup ? registerGroup(id, component) : registerItem(id, component);
199
+ emitRegistered({ id, parentId, isGroup });
194
200
  }
195
201
 
196
202
  function unregister(id, { group = false } = {}) {
@@ -1,5 +1,5 @@
1
- import { ReplaySubject } from "rxjs";
2
- import { filter } from "rxjs/operators";
1
+ import { ReplaySubject, Subject } from "rxjs";
2
+ import { filter, first, switchMap } 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
 
@@ -22,10 +22,54 @@ export const focusableButtonsRegistration$ = (focusableGroupId: string) =>
22
22
  )
23
23
  );
24
24
 
25
- export const emitRegistered = (id: Option<FocusableID>): void => {
25
+ const focusableViewRegistrationSubject$ = new Subject<{
26
+ id: FocusableID;
27
+ parentId: FocusableID;
28
+ }>();
29
+
30
+ let focusableGroupRegistrationSubject$ = new ReplaySubject<{
31
+ id: FocusableID;
32
+ }>();
33
+
34
+ export const resetFocusableGroupRegistration = () => {
35
+ // complete the old subject so subscribers are notified and resources are freed
36
+ focusableGroupRegistrationSubject$.complete();
37
+
38
+ focusableGroupRegistrationSubject$ = new ReplaySubject<{
39
+ id: FocusableID;
40
+ }>();
41
+ };
42
+
43
+ export const firstFocusableViewRegistration$ =
44
+ focusableViewRegistrationSubject$.pipe(
45
+ first(), // we care about only first FocusableView registration
46
+ switchMap(({ parentId }) =>
47
+ // start waiting registration of its parent
48
+ focusableGroupRegistrationSubject$.pipe(
49
+ filter(({ id }) => id === parentId)
50
+ )
51
+ ),
52
+ first()
53
+ );
54
+
55
+ export const emitRegistered = ({
56
+ id,
57
+ parentId,
58
+ isGroup,
59
+ }: {
60
+ id: Option<FocusableID>;
61
+ parentId: Option<FocusableID>;
62
+ isGroup: boolean;
63
+ }): void => {
26
64
  if (isFocusableButton(id)) {
27
65
  registeredSubject$.next({ id, registered: true });
28
66
  }
67
+
68
+ if (!isGroup) {
69
+ focusableViewRegistrationSubject$.next({ id, parentId });
70
+ } else {
71
+ focusableGroupRegistrationSubject$.next({ id });
72
+ }
29
73
  };
30
74
 
31
75
  export const emitUnregistered = (id: Option<FocusableID>): void => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.21-rc.1",
3
+ "version": "13.0.21",
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.21-rc.1",
30
+ "@applicaster/applicaster-types": "13.0.21",
31
31
  "buffer": "^5.2.1",
32
32
  "camelize": "^1.0.0",
33
33
  "dayjs": "^1.11.10",