@applicaster/zapp-react-native-utils 12.0.14 → 12.0.16-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.
@@ -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",
3
+ "version": "12.0.16-rc.0",
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",
31
+ "@applicaster/applicaster-types": "12.0.16-rc.0",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -5,7 +5,7 @@ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
5
5
  import { useZappPipesFeed } from "@applicaster/zapp-react-native-redux/hooks";
6
6
 
7
7
  import { reactHooksLogger } from "../logger";
8
- import { useIsInitialRender, shouldDispatchData } from "../utils";
8
+ import { shouldDispatchData, useIsInitialRender } from "../utils";
9
9
  import { useInflatedUrl } from "./useInflatedUrl";
10
10
  import { useRoute } from "../navigation";
11
11
 
@@ -55,7 +55,9 @@ export const useFeedLoader = ({
55
55
 
56
56
  const currentFeed = useZappPipesFeed(callableFeedUrl);
57
57
 
58
- const riverId = screenData?.id;
58
+ const riverId =
59
+ (screenData as LegacyNavigationScreenData)?.targetScreen?.id ??
60
+ screenData?.id;
59
61
 
60
62
  const reloadData = React.useCallback<ReloadDataFunction>(
61
63
  (silentRefresh = true, callback) => {
@@ -0,0 +1,39 @@
1
+ import { reactHooksLogger } from "../../logger";
2
+ import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
3
+
4
+ const logger = reactHooksLogger.addSubsystem("useHookModalScreenData");
5
+
6
+ type VariousScreenData = LegacyNavigationScreenData | ZappRiver | ZappEntry;
7
+
8
+ export const useHookModalScreenData = (): VariousScreenData | undefined => {
9
+ const hookModalState = useZappHooksModalState();
10
+
11
+ if (!hookModalState.state?.screenData) {
12
+ return;
13
+ }
14
+
15
+ try {
16
+ const screenData = hookModalState.state.screenData?.payload;
17
+ const hookPlugin = hookModalState.state.screenData.hookPlugin;
18
+
19
+ if (hookPlugin?.screen_id) {
20
+ return {
21
+ ...screenData,
22
+ targetScreen: hookPlugin,
23
+ };
24
+ }
25
+
26
+ return hookModalState.state.screenData?.payload;
27
+ } catch (error) {
28
+ logger.error({
29
+ message: "Hook modal screen data creation failed",
30
+ data: {
31
+ error,
32
+ hookModalState,
33
+ },
34
+ jsOnly: true,
35
+ });
36
+
37
+ return hookModalState.state.screenData?.payload;
38
+ }
39
+ };
@@ -17,7 +17,6 @@ import {
17
17
  QUICK_BRICK_NAVBAR,
18
18
  QUICK_BRICK_CONTENT,
19
19
  } from "@applicaster/quick-brick-core/const";
20
- import { useZappHooksModalState } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal/hooks/useZappHooksModalState";
21
20
  import { ZappHookModalContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
22
21
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
23
22
  import { HookModalContextT } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappHookModalContext";
@@ -36,6 +35,7 @@ import { useNavbarState } from "../screen";
36
35
  import { useNavigation } from "./useNavigation";
37
36
  import { useModalStore } from "../../modalState";
38
37
  import { ScreenDataContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
38
+ import { useHookModalScreenData } from "../hookModal/hooks/useHookModalScreenData";
39
39
 
40
40
  export { useNavigation } from "./useNavigation";
41
41
 
@@ -156,6 +156,7 @@ export const useRoute = (): {
156
156
  } => {
157
157
  const pathname = usePathname() || "";
158
158
  const navigator = useNavigation();
159
+
159
160
  const screenDataContext = legacyScreenData(useContext(ScreenDataContext));
160
161
 
161
162
  const { plugins, contentTypes, rivers } = usePickFromState([
@@ -165,14 +166,13 @@ export const useRoute = (): {
165
166
  ]);
166
167
 
167
168
  const { modalState } = useModalStore();
168
- const hookModalState = useZappHooksModalState();
169
169
 
170
170
  const modalScreenData = modalState.screen;
171
171
 
172
- const hookModalScreenData = hookModalState.state.screenData?.payload;
172
+ const hookModalScreenData = useHookModalScreenData();
173
173
 
174
174
  const videoModalScreenData =
175
- navigator.videoModalState?.item &&
175
+ navigator?.videoModalState?.item &&
176
176
  legacyScreenData(
177
177
  {
178
178
  entry: navigator.videoModalState?.item as ZappEntry,