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

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.
@@ -8,6 +8,8 @@ import { isNilOrEmpty } from "../reactUtils/helpers";
8
8
  import { isAndroidTVPlatform } from "../reactUtils";
9
9
  import { noop } from "../functionUtils";
10
10
 
11
+ const EMPTY_GROUP_COMPONENT = "empty_group_component";
12
+
11
13
  export function useFocusManager() {
12
14
  return focusManager;
13
15
  }
@@ -74,6 +76,14 @@ export function useFocusEffect(onFocus, focusWatcher) {
74
76
  }, focusWatcher);
75
77
  }
76
78
 
79
+ export function shouldShowEmptyGroup(component) {
80
+ return (
81
+ component?.ui_components?.filter(
82
+ ({ component_type }) => component_type === EMPTY_GROUP_COMPONENT
83
+ )?.length > 0
84
+ );
85
+ }
86
+
77
87
  export const isFocusable = (component: ZappEntry | ZappUIComponent | any) =>
78
88
  R.tryCatch(
79
89
  R.compose(
@@ -101,15 +111,50 @@ export const useIsFocusable = (props: Props): void => {
101
111
  component.rules.hide_component_if_data_is_empty
102
112
  );
103
113
 
114
+ const isLoadingData = !!zappPipesData?.loading;
115
+
104
116
  const hasNoData =
105
117
  isNilOrEmpty(zappPipesData?.data) ||
106
118
  isNilOrEmpty(zappPipesData?.data?.entry);
107
119
 
120
+ const hasNoUIComponents = isNilOrEmpty(component?.ui_components);
121
+
122
+ const hasDataError = !!zappPipesData?.error;
123
+
124
+ const hasEmptyGroup = shouldShowEmptyGroup(component);
125
+
126
+ const isGallery = component?.component_type === "gallery-qb";
127
+
128
+ const isGroup = component?.component_type === "group-qb";
129
+
130
+ const isHiddenDueToEmptyData =
131
+ !isLoadingData && hasNoData && hideIfDataEmpty && !hasEmptyGroup;
132
+
133
+ const isEmptyGroup = isGroup && hasNoUIComponents;
134
+
135
+ const defaultFocusableLogic =
136
+ componentCellsFocusable &&
137
+ (!hasNoData || !hideIfDataEmpty) &&
138
+ !isEmptyGroup;
139
+
108
140
  React.useEffect(() => {
109
141
  if (isAndroidTVPlatform()) {
110
- setIsFocusable(
111
- componentCellsFocusable && (!hasNoData || !hideIfDataEmpty)
112
- );
142
+ let isFocusableNew = false;
143
+
144
+ if (isGallery) {
145
+ isFocusableNew = true;
146
+ } else if (isFocusable(component)) {
147
+ isFocusableNew = defaultFocusableLogic;
148
+ }
149
+
150
+ setIsFocusable(isFocusableNew);
113
151
  }
114
- }, [setIsFocusable, componentCellsFocusable, hasNoData]);
152
+ }, [
153
+ defaultFocusableLogic,
154
+ isHiddenDueToEmptyData,
155
+ isGallery,
156
+ setIsFocusable,
157
+ hasDataError,
158
+ hasEmptyGroup,
159
+ ]);
115
160
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "12.0.14-rc.1",
3
+ "version": "12.0.15",
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": "12.0.14-rc.1",
31
+ "@applicaster/applicaster-types": "12.0.15",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",