@applicaster/zapp-react-native-ui-components 14.0.0-alpha.6242515303 → 14.0.0-alpha.6391068513

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.
Files changed (77) hide show
  1. package/Components/AnimatedInOut/index.tsx +5 -3
  2. package/Components/AudioPlayer/mobile/Layout.tsx +1 -1
  3. package/Components/AudioPlayer/tv/helpers.tsx +10 -3
  4. package/Components/Cell/index.js +1 -1
  5. package/Components/ComponentResolver/index.ts +1 -1
  6. package/Components/FeedLoader/index.js +1 -1
  7. package/Components/Focusable/Focusable.tsx +5 -3
  8. package/Components/Focusable/FocusableTvOS.tsx +3 -3
  9. package/Components/Focusable/FocusableiOS.tsx +2 -2
  10. package/Components/Focusable/index.tsx +1 -1
  11. package/Components/FocusableList/index.tsx +4 -0
  12. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
  13. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +12 -8
  14. package/Components/HandlePlayable/HandlePlayable.tsx +14 -8
  15. package/Components/Layout/TV/LayoutBackground.tsx +1 -1
  16. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
  17. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
  18. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
  19. package/Components/MasterCell/elementMapper.tsx +1 -2
  20. package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
  21. package/Components/MasterCell/utils/index.ts +23 -3
  22. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
  23. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
  24. package/Components/OfflineHandler/__tests__/index.test.tsx +20 -22
  25. package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
  26. package/Components/PlayerContainer/PlayerContainer.tsx +41 -28
  27. package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
  28. package/Components/PlayerContainer/index.ts +1 -1
  29. package/Components/River/ComponentsMap/ComponentsMap.tsx +0 -1
  30. package/Components/River/RefreshControl.tsx +6 -4
  31. package/Components/River/TV/River.tsx +2 -17
  32. package/Components/River/TV/index.tsx +3 -1
  33. package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
  34. package/Components/River/TV/withRiverDataLoader.tsx +17 -0
  35. package/Components/River/TV/withTVEventHandler.tsx +1 -1
  36. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  37. package/Components/River/index.tsx +1 -1
  38. package/Components/Screen/__tests__/Screen.test.tsx +23 -12
  39. package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
  40. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
  41. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
  42. package/Components/ScreenRevealManager/index.ts +1 -0
  43. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +79 -0
  44. package/Components/Tabs/TV/Tabs.android.tsx +0 -2
  45. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
  46. package/Components/Transitioner/Scene.tsx +1 -0
  47. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
  48. package/Components/VideoLive/animationUtils.ts +3 -3
  49. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +32 -8
  50. package/Components/VideoModal/PlayerDetails.tsx +24 -2
  51. package/Components/VideoModal/PlayerWrapper.tsx +26 -142
  52. package/Components/VideoModal/VideoModal.tsx +3 -17
  53. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
  54. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
  55. package/Components/VideoModal/hooks/index.ts +0 -2
  56. package/Components/VideoModal/hooks/useModalSize.ts +18 -2
  57. package/Components/VideoModal/utils.ts +6 -0
  58. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
  59. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
  60. package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
  61. package/Decorators/RiverFeedLoader/index.tsx +8 -2
  62. package/Decorators/RiverFeedLoader/utils/index.ts +7 -2
  63. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
  64. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
  65. package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
  66. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
  67. package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
  68. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
  69. package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
  70. package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
  71. package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
  72. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
  73. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +255 -0
  74. package/Decorators/ZappPipesDataConnector/types.ts +29 -0
  75. package/Decorators/ZappPipesDataConnector/utils/index.ts +40 -0
  76. package/package.json +5 -6
  77. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
@@ -0,0 +1,255 @@
1
+ /// <reference types="@applicaster/applicaster-types" />
2
+ /// <reference types="@applicaster/zapp-react-native-ui-components" />
3
+ import React, { useEffect, useMemo } from "react";
4
+ import * as R from "ramda";
5
+ import { Platform } from "react-native";
6
+ import Url from "url";
7
+ import { favoritesListener } from "@applicaster/zapp-react-native-bridge/Favorites";
8
+ import {
9
+ getInflatedDataSourceUrl,
10
+ getSearchContext,
11
+ useFeedLoader,
12
+ useFeedRefresh,
13
+ useRoute,
14
+ } from "@applicaster/zapp-react-native-utils/reactHooks";
15
+
16
+ import { ComponentDataSourceContext, ZappPipesDataProps } from "../types";
17
+ import { isVerticalListOrGrid, subscribeForKeyChanges } from "../utils";
18
+ import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
19
+
20
+ const FAVORITES_TYPE = "FAVOURITES";
21
+
22
+ function getDataSourceUrl({
23
+ component,
24
+ feedUrl,
25
+ screenData,
26
+ entryContext,
27
+ searchContext,
28
+ screenContext,
29
+ }): { dataSourceUrl: string | null; type: string | null } {
30
+ if (feedUrl) {
31
+ return { dataSourceUrl: feedUrl, type: null };
32
+ }
33
+
34
+ if (component.data) {
35
+ const {
36
+ data: { source, type, mapping },
37
+ } = component;
38
+
39
+ if (type === FAVORITES_TYPE) {
40
+ return { dataSourceUrl: source || FAVORITES_TYPE, type };
41
+ }
42
+
43
+ if (source) {
44
+ if (type === "APPLICASTER_COLLECTION" && !R.includes("://", source)) {
45
+ return {
46
+ dataSourceUrl: `applicaster://fetchData?type=${type}&collectionId=${source}`,
47
+ type,
48
+ };
49
+ }
50
+
51
+ if (type === "APPLICASTER_CATEGORY" && !R.includes("://", source)) {
52
+ return {
53
+ dataSourceUrl: `applicaster://fetchData?type=${type}&categoryId=${source}&platform=${Platform.OS}`,
54
+ type,
55
+ };
56
+ }
57
+
58
+ if (mapping) {
59
+ const contexts = {
60
+ entry: entryContext,
61
+ screen: screenContext || screenData,
62
+ search: getSearchContext(searchContext, mapping),
63
+ };
64
+
65
+ const dataSourceUrl = getInflatedDataSourceUrl({
66
+ source,
67
+ mapping,
68
+ contexts,
69
+ });
70
+
71
+ if (!dataSourceUrl) {
72
+ return { dataSourceUrl: null, type: null };
73
+ }
74
+
75
+ return { dataSourceUrl, type };
76
+ }
77
+
78
+ return { dataSourceUrl: source, type };
79
+ }
80
+ }
81
+
82
+ return { dataSourceUrl: null, type: null };
83
+ }
84
+
85
+ function getMethodAndParams(component) {
86
+ const method: "get" | "post" = R.pathOr("get", ["data", "method"], component);
87
+
88
+ const bodyParams: Record<string, unknown> = R.pathOr(
89
+ {},
90
+ ["data", "bodyParams"],
91
+ component
92
+ );
93
+
94
+ return {
95
+ method,
96
+ bodyParams,
97
+ };
98
+ }
99
+
100
+ function getListenerFromPlugin(
101
+ dataSourceUrl: string,
102
+ plugins: QuickBrickPlugin[]
103
+ ): AddDataSourceListener | void {
104
+ const url = Url.parse(dataSourceUrl, false);
105
+
106
+ const addListener = R.compose(
107
+ R.path(["module", "addDataSourceListener"]),
108
+ R.find(R.propEq("identifier", url.host))
109
+ )(plugins);
110
+
111
+ return addListener;
112
+ }
113
+
114
+ function applyItemLimit(zappPipesData, component) {
115
+ if (!zappPipesData || !zappPipesData.data) {
116
+ return zappPipesData;
117
+ }
118
+
119
+ const { data } = zappPipesData;
120
+
121
+ const {
122
+ rules: { item_limit },
123
+ } = component;
124
+
125
+ if (item_limit && data.entry && data.entry.length) {
126
+ return {
127
+ ...zappPipesData,
128
+ data: {
129
+ ...data,
130
+ entry: R.slice(
131
+ 0,
132
+ Math.min(Number(item_limit), R.length(data.entry)),
133
+ data.entry
134
+ ),
135
+ },
136
+ };
137
+ }
138
+
139
+ return zappPipesData;
140
+ }
141
+
142
+ type UrlFeedResolverProps = ComponentDataSourceContext & {
143
+ children: (dataProps: ZappPipesDataProps) => React.ReactNode;
144
+ };
145
+
146
+ export function UrlFeedResolver({
147
+ children,
148
+ component,
149
+ feedUrl,
150
+ isLast,
151
+ entryContext,
152
+ screenContext,
153
+ searchContext,
154
+ screenData,
155
+ plugins,
156
+ }: UrlFeedResolverProps) {
157
+ const { dataSourceUrl, type } = useMemo(
158
+ () =>
159
+ getDataSourceUrl({
160
+ component,
161
+ feedUrl,
162
+ screenData,
163
+ entryContext,
164
+ searchContext,
165
+ screenContext,
166
+ }),
167
+ [
168
+ component?.id,
169
+ feedUrl,
170
+ entryContext,
171
+ searchContext,
172
+ screenContext,
173
+ screenData?.id,
174
+ ]
175
+ );
176
+
177
+ const shouldClearCache = useMemo(
178
+ () => Boolean(component?.rules?.clear_cache_on_reload),
179
+ [component?.id]
180
+ );
181
+
182
+ const pipesOptions = useMemo(
183
+ () => ({
184
+ clearCache: type === FAVORITES_TYPE,
185
+ loadLocalFavorites: type === FAVORITES_TYPE,
186
+ silentRefresh: !shouldClearCache,
187
+ ...getMethodAndParams(component),
188
+ }),
189
+ [type, shouldClearCache, component]
190
+ );
191
+
192
+ const { reloadData, loadNext, error, loading, url, data } = useFeedLoader({
193
+ feedUrl: dataSourceUrl ?? "",
194
+ pipesOptions,
195
+ });
196
+
197
+ const { pathname } = useRoute();
198
+ const screenStateStore = useScreenStateStore();
199
+
200
+ // Setup listeners for data source URL
201
+ useEffect(() => {
202
+ if (!reloadData) {
203
+ return;
204
+ }
205
+
206
+ if (dataSourceUrl?.includes("pipesv2://")) {
207
+ const addListener = getListenerFromPlugin(dataSourceUrl, plugins);
208
+
209
+ if (addListener) {
210
+ return addListener(reloadData);
211
+ }
212
+ } else {
213
+ return subscribeForKeyChanges({
214
+ dataSourceUrl,
215
+ pathname,
216
+ screenStateStore,
217
+ reloadData,
218
+ });
219
+ }
220
+ }, [dataSourceUrl, reloadData, pathname, screenStateStore]);
221
+
222
+ // Setup favorites listener
223
+ useEffect(() => {
224
+ if (type === FAVORITES_TYPE && reloadData) {
225
+ favoritesListener.on("FAVORITES_CHANGED", reloadData);
226
+
227
+ return () => {
228
+ favoritesListener.removeHandler("FAVORITES_CHANGED", reloadData);
229
+ };
230
+ }
231
+ }, [type, reloadData]);
232
+
233
+ // Apply feed refresh hook
234
+ useFeedRefresh({
235
+ reloadData,
236
+ component,
237
+ });
238
+
239
+ const loadNextData = useMemo(
240
+ () => (!isLast && isVerticalListOrGrid(component) ? undefined : loadNext),
241
+ [isLast, component, loadNext]
242
+ );
243
+
244
+ const zappPipesDataProps = useMemo(() => {
245
+ const pipeData = { url, loading, data, error };
246
+
247
+ return {
248
+ zappPipesData: applyItemLimit(pipeData, component),
249
+ reloadData,
250
+ loadNextData,
251
+ };
252
+ }, [url, loading, data, error, component, reloadData, loadNextData]);
253
+
254
+ return <>{children(zappPipesDataProps)}</>;
255
+ }
@@ -0,0 +1,29 @@
1
+ import { ReloadDataFunction } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useFeedLoader";
2
+
3
+ export type ZappPipesData = {
4
+ url: string;
5
+ loading: boolean;
6
+ data: ZappFeed;
7
+ error?: Error;
8
+ };
9
+
10
+ export type ComponentDataSourceContext = {
11
+ component: ZappUIComponent;
12
+ feedUrl?: string;
13
+ riverId: string;
14
+ getStaticComponentFeed?: GeneralContentScreenProps["getStaticComponentFeed"];
15
+ componentIndex?: number;
16
+ isScreenWrappedInContainer?: boolean;
17
+ isLast?: boolean;
18
+ entryContext?: Record<string, any>;
19
+ screenContext?: Record<string, any>;
20
+ searchContext?: string;
21
+ screenData?: any;
22
+ plugins?: QuickBrickPlugin[];
23
+ };
24
+
25
+ export type ZappPipesDataProps = {
26
+ zappPipesData: ZappPipesData;
27
+ reloadData?: ReloadDataFunction;
28
+ loadNextData?: () => void;
29
+ };
@@ -1,5 +1,45 @@
1
+ import {
2
+ subscribeForUrlContextKeyChanges,
3
+ subscribeForUrlScreenKeyChanges,
4
+ } from "@applicaster/zapp-pipes-v2-client";
5
+
1
6
  const isVerticalList = (component) => component?.component_type === "list-qb";
2
7
  const isGrid = (component) => component?.component_type === "grid-qb";
3
8
 
4
9
  export const isVerticalListOrGrid = (component) =>
5
10
  isVerticalList(component) || isGrid(component);
11
+
12
+ export const subscribeForKeyChanges = ({
13
+ dataSourceUrl,
14
+ pathname,
15
+ screenStateStore,
16
+ reloadData,
17
+ }) => {
18
+ const subscriptions = [];
19
+
20
+ if (dataSourceUrl) {
21
+ subscriptions.push(
22
+ subscribeForUrlContextKeyChanges(dataSourceUrl, {}, reloadData)
23
+ );
24
+ }
25
+
26
+ if (dataSourceUrl && pathname && screenStateStore) {
27
+ subscriptions.push(
28
+ subscribeForUrlScreenKeyChanges(
29
+ dataSourceUrl,
30
+ pathname,
31
+ screenStateStore,
32
+ {},
33
+ reloadData
34
+ )
35
+ );
36
+ }
37
+
38
+ return () => {
39
+ subscriptions.forEach((unsubscribe) => {
40
+ if (typeof unsubscribe === "function") {
41
+ unsubscribe();
42
+ }
43
+ });
44
+ };
45
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.0-alpha.6242515303",
3
+ "version": "14.0.0-alpha.6391068513",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "14.0.0-alpha.6242515303",
32
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.6242515303",
33
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.6242515303",
34
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.6242515303",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.6391068513",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.6391068513",
33
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.6391068513",
34
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.6391068513",
35
35
  "promise": "^8.3.0",
36
36
  "url": "^0.11.0",
37
37
  "uuid": "^3.3.2"
@@ -42,7 +42,6 @@
42
42
  "immer": "*",
43
43
  "react": "*",
44
44
  "react-native": "*",
45
- "react-native-safe-area-context": "*",
46
45
  "react-native-svg": "*",
47
46
  "uglify-js": "*",
48
47
  "validate-color": "*",
@@ -1,10 +0,0 @@
1
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
2
- import { useConfiguration } from "../utils";
3
-
4
- export const useBackgroundColor = (): string => {
5
- const { modal_background_color: modalBackgroundColor } = useConfiguration();
6
-
7
- const theme = useTheme<BaseThemePropertiesMobile>();
8
-
9
- return modalBackgroundColor || theme?.status_background_color;
10
- };