@applicaster/zapp-react-native-ui-components 13.0.0-alpha.5033140607 → 13.0.0-alpha.5049772260

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 (211) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AppContainer/__tests__/__snapshots__/AppContainer.test.js.snap +1 -1
  3. package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
  4. package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
  5. package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
  6. package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
  7. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +56 -113
  8. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +39 -23
  9. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
  10. package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
  11. package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
  12. package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
  13. package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
  14. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
  15. package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
  16. package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
  17. package/Components/AudioPlayer/__tests__/title.test.js +3 -5
  18. package/Components/AudioPlayer/helpers.tsx +1 -0
  19. package/Components/BaseFocusable/index.ios.ts +1 -1
  20. package/Components/BaseFocusable/index.tsx +67 -31
  21. package/Components/Cell/Cell.tsx +18 -22
  22. package/Components/Cell/CellWithFocusable.tsx +51 -60
  23. package/Components/Cell/CellWrapper.tsx +18 -0
  24. package/Components/Cell/TvOSCellComponent.tsx +23 -30
  25. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  26. package/Components/Cell/index.js +3 -1
  27. package/Components/Cell/styles.ts +17 -0
  28. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +50 -50
  29. package/Components/CellRendererResolver/index.ts +2 -1
  30. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  31. package/Components/ComponentResolver/__tests__/componentResolver.test.js +26 -30
  32. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  33. package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
  34. package/Components/ErrorScreen/index.tsx +14 -6
  35. package/Components/Focusable/Focusable.tsx +1 -54
  36. package/Components/Focusable/FocusableTvOS.tsx +6 -2
  37. package/Components/Focusable/Touchable.tsx +19 -20
  38. package/Components/Focusable/index.android.tsx +10 -3
  39. package/Components/FocusableCell/index.tsx +1 -1
  40. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
  41. package/Components/FocusableGroup/index.tsx +0 -3
  42. package/Components/FocusableList/index.tsx +26 -10
  43. package/Components/FocusableScrollView/index.tsx +43 -13
  44. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +3 -0
  45. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +76 -7
  46. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +53 -9
  47. package/Components/GeneralContentScreen/utils/useEventAlerts.ts +28 -0
  48. package/Components/HandlePlayable/HandlePlayable.tsx +21 -27
  49. package/Components/Layout/TV/LayoutBackground.tsx +28 -0
  50. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  51. package/Components/Layout/TV/ScreenContainer.tsx +8 -2
  52. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  53. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +3 -1
  54. package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
  55. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +6 -5
  56. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +12 -11
  57. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +15 -10
  58. package/Components/Layout/TV/__tests__/index.test.tsx +14 -4
  59. package/Components/Layout/TV/index.tsx +6 -20
  60. package/Components/Layout/TV/index.web.tsx +4 -1
  61. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  62. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  63. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  64. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +10 -15
  65. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
  66. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  67. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  68. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
  69. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  70. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  71. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/const.ts +3 -0
  72. package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/index.ts +6 -6
  73. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  74. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  75. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
  76. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +11 -19
  77. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +6 -235
  78. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  79. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  80. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  81. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  82. package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
  83. package/Components/MasterCell/utils/index.ts +9 -135
  84. package/Components/ModalComponent/BottomSheetModalContent.tsx +45 -19
  85. package/Components/ModalComponent/Button/Item.tsx +6 -5
  86. package/Components/ModalComponent/Button/assets.ts +1 -1
  87. package/Components/ModalComponent/Button/index.tsx +30 -43
  88. package/Components/ModalComponent/Header/index.tsx +3 -3
  89. package/Components/ModalComponent/utils.ts +55 -7
  90. package/Components/NativeFocusables/{index.js → index.ts} +4 -2
  91. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  92. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  93. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  94. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
  95. package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
  96. package/Components/OfflineHandler/utils/index.ts +1 -1
  97. package/Components/PlayerContainer/PlayerContainer.tsx +45 -25
  98. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  99. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  100. package/Components/PlayerImageBackground/index.tsx +1 -1
  101. package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
  102. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  103. package/Components/River/RefreshControl.tsx +1 -1
  104. package/Components/River/RiverFooter.tsx +39 -9
  105. package/Components/River/RiverItem.tsx +39 -3
  106. package/Components/River/TV/index.tsx +6 -1
  107. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +114 -45
  108. package/Components/River/__tests__/__snapshots__/river.test.js.snap +21 -83
  109. package/Components/River/__tests__/componentsMap.test.js +64 -17
  110. package/Components/River/__tests__/river.test.js +75 -40
  111. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +12 -5
  112. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  113. package/Components/RouteManager/__tests__/testId.test.js +8 -6
  114. package/Components/Screen/TV/index.web.tsx +5 -6
  115. package/Components/Screen/__tests__/Screen.test.tsx +41 -27
  116. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
  117. package/Components/Screen/hooks.ts +53 -0
  118. package/Components/Screen/index.tsx +16 -42
  119. package/Components/ScreenResolver/__tests__/screenResolver.test.js +95 -70
  120. package/Components/Tabs/Tab.tsx +12 -9
  121. package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
  122. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
  123. package/Components/TextInputTv/index.tsx +6 -5
  124. package/Components/TopMarginApplicator/TopMarginApplicator.tsx +2 -3
  125. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
  126. package/Components/TrackedView/index.tsx +1 -0
  127. package/Components/Transitioner/AnimationManager.js +15 -15
  128. package/Components/Transitioner/Scene.tsx +53 -24
  129. package/Components/Transitioner/Transitioner.tsx +3 -3
  130. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  131. package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
  132. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +10 -50
  133. package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
  134. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
  135. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  136. package/Components/Transitioner/index.js +8 -4
  137. package/Components/VideoLive/LiveImageManager.ts +27 -1
  138. package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
  139. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
  140. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +6 -10
  141. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
  142. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +51 -31
  143. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +8 -4
  144. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +48 -22
  145. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +15 -15
  146. package/Components/VideoModal/ModalAnimation/__tests__/getMoveUpValue.test.ts +108 -0
  147. package/Components/VideoModal/ModalAnimation/const.ts +5 -0
  148. package/Components/VideoModal/ModalAnimation/index.ts +4 -1
  149. package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
  150. package/Components/VideoModal/ModalAnimation/utils.ts +38 -2
  151. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  152. package/Components/VideoModal/PlayerDetails.tsx +13 -10
  153. package/Components/VideoModal/PlayerWrapper.tsx +43 -39
  154. package/Components/VideoModal/VideoModal.tsx +17 -11
  155. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
  156. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
  157. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
  158. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -156
  159. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
  160. package/Components/VideoModal/hooks/index.ts +7 -0
  161. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
  162. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  163. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  164. package/Components/VideoModal/utils.ts +6 -9
  165. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  166. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  167. package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
  168. package/Components/Viewport/__tests__/utils.test.js +5 -4
  169. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  170. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  171. package/Components/ZappUIComponent/index.tsx +4 -17
  172. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  173. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  174. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  175. package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
  176. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
  177. package/Contexts/HeaderOffsetContext/index.tsx +4 -6
  178. package/Contexts/ScreenContext/index.tsx +6 -12
  179. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  180. package/Decorators/Analytics/{index.js → index.tsx} +11 -11
  181. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  182. package/Decorators/Navigator/index.tsx +1 -1
  183. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
  184. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
  185. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
  186. package/Decorators/RiverFeedLoader/index.tsx +1 -1
  187. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
  188. package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
  189. package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
  190. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +27 -27
  191. package/Decorators/RiverResolver/index.tsx +6 -8
  192. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  193. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  194. package/Decorators/ZappPipesDataConnector/index.tsx +7 -3
  195. package/package.json +13 -11
  196. package/tsconfig.json +2 -3
  197. package/.babelrc +0 -8
  198. package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
  199. package/Components/Cell/CellStyles/Hero/index.js +0 -111
  200. package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
  201. package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
  202. package/Components/Cell/CellStyles/colors.js +0 -40
  203. package/Components/Cell/CellStyles/index.js +0 -15
  204. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  205. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  206. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  207. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  208. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  209. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  210. package/Decorators/RiverFeedLoader/utils.ts +0 -100
  211. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
@@ -0,0 +1,89 @@
1
+ import { renderHook } from "@testing-library/react-hooks";
2
+ import { useDelayedPlayerDetails } from "../useDelayedPlayerDetails";
3
+ import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
4
+ import { showDetails } from "../utils";
5
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
6
+
7
+ jest.mock("@applicaster/zapp-react-native-utils/idleUtils", () => ({
8
+ withTimeout$: jest.fn(),
9
+ }));
10
+
11
+ jest.mock("../utils", () => ({
12
+ showDetails: jest.fn(),
13
+ }));
14
+
15
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
16
+ useIsTablet: jest.fn(),
17
+ }));
18
+
19
+ describe("useDelayedPlayerDetails", () => {
20
+ beforeEach(() => {
21
+ jest.clearAllMocks();
22
+ });
23
+
24
+ it("should return false initially", () => {
25
+ (withTimeout$ as jest.Mock).mockReturnValue({
26
+ subscribe: jest.fn().mockReturnValue({ unsubscribe: jest.fn() }),
27
+ });
28
+
29
+ const { result } = renderHook(() =>
30
+ useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
31
+ );
32
+
33
+ expect(result.current).toBe(false);
34
+ });
35
+
36
+ it("should return true if showDetails returns true", () => {
37
+ (withTimeout$ as jest.Mock).mockReturnValue({
38
+ subscribe: (callback) => {
39
+ callback.next();
40
+
41
+ return { unsubscribe: jest.fn() };
42
+ },
43
+ });
44
+
45
+ (showDetails as jest.Mock).mockReturnValue(true);
46
+ (useIsTablet as jest.Mock).mockReturnValue(false);
47
+
48
+ const { result } = renderHook(() =>
49
+ useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
50
+ );
51
+
52
+ expect(result.current).toBe(true);
53
+ });
54
+
55
+ it("should return false if showDetails returns false", () => {
56
+ (withTimeout$ as jest.Mock).mockReturnValue({
57
+ subscribe: (callback) => {
58
+ callback.next();
59
+
60
+ return { unsubscribe: jest.fn() };
61
+ },
62
+ });
63
+
64
+ (showDetails as jest.Mock).mockReturnValue(false);
65
+ (useIsTablet as jest.Mock).mockReturnValue(false);
66
+
67
+ const { result } = renderHook(() =>
68
+ useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
69
+ );
70
+
71
+ expect(result.current).toBe(false);
72
+ });
73
+
74
+ it("should unsubscribe on unmount", () => {
75
+ const unsubscribeMock = jest.fn();
76
+
77
+ (withTimeout$ as jest.Mock).mockReturnValue({
78
+ subscribe: jest.fn().mockReturnValue({ unsubscribe: unsubscribeMock }),
79
+ });
80
+
81
+ const { unmount } = renderHook(() =>
82
+ useDelayedPlayerDetails({ isInline: true, isDocked: false, isPip: false })
83
+ );
84
+
85
+ unmount();
86
+
87
+ expect(unsubscribeMock).toHaveBeenCalled();
88
+ });
89
+ });
@@ -0,0 +1,7 @@
1
+ export { useBackgroundColor } from "./useBackgroundColor";
2
+
3
+ export { useDelayedPlayerDetails } from "./useDelayedPlayerDetails";
4
+
5
+ export { useInitialPlayerState } from "./useInitialPlayerState";
6
+
7
+ export { useModalSize } from "./useModalSize";
@@ -0,0 +1,49 @@
1
+ import * as React from "react";
2
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
3
+ import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
4
+
5
+ import { showDetails } from "./utils";
6
+
7
+ const TIMEOUT = 100; // ms
8
+
9
+ type Props = { isInline: boolean; isDocked: boolean; isPip: boolean };
10
+
11
+ /**
12
+ * Custom hook to determine whether to show player details with a delay.
13
+ *
14
+ * @param {Object} params - The parameters object.
15
+ * @param {boolean} params.isInline - Indicates if the player is inline.
16
+ * @param {boolean} params.isDocked - Indicates if the player is docked.
17
+ * @param {boolean} params.isPip - Indicates if the player is in PIP mode.
18
+ * @returns {boolean} - Returns true if player details should be shown, otherwise false.
19
+ */
20
+ export const useDelayedPlayerDetails = ({
21
+ isInline,
22
+ isDocked,
23
+ isPip,
24
+ }: Props): boolean => {
25
+ const [shouldShowDetails, setShouldShowDetails] = React.useState(false);
26
+
27
+ const isTablet = useIsTablet();
28
+
29
+ React.useEffect(() => {
30
+ const subscription = withTimeout$(TIMEOUT).subscribe({
31
+ next: () => {
32
+ setShouldShowDetails(() => {
33
+ return showDetails({
34
+ isMobile: !isTablet,
35
+ isInline,
36
+ isDocked,
37
+ isPip,
38
+ });
39
+ });
40
+ },
41
+ });
42
+
43
+ return () => {
44
+ subscription.unsubscribe();
45
+ };
46
+ }, [isDocked, isTablet, isInline, isPip]);
47
+
48
+ return shouldShowDetails;
49
+ };
@@ -0,0 +1,91 @@
1
+ import { showDetails } from "..";
2
+
3
+ describe("showDetails", () => {
4
+ it("should return false if isPip is true", () => {
5
+ const result = showDetails({
6
+ isMobile: true,
7
+ isInline: true,
8
+ isDocked: false,
9
+ isPip: true,
10
+ });
11
+
12
+ expect(result).toBe(false);
13
+ });
14
+
15
+ it("should return false if isDocked is true", () => {
16
+ const result = showDetails({
17
+ isMobile: true,
18
+ isInline: true,
19
+ isDocked: true,
20
+ isPip: false,
21
+ });
22
+
23
+ expect(result).toBe(false);
24
+ });
25
+
26
+ it("should return true if isMobile is true and isInline is true", () => {
27
+ const result = showDetails({
28
+ isMobile: true,
29
+ isInline: true,
30
+ isDocked: false,
31
+ isPip: false,
32
+ });
33
+
34
+ expect(result).toBe(true);
35
+ });
36
+
37
+ it("should return false if isMobile is true and isInline is false", () => {
38
+ const result = showDetails({
39
+ isMobile: true,
40
+ isInline: false,
41
+ isDocked: false,
42
+ isPip: false,
43
+ });
44
+
45
+ expect(result).toBe(false);
46
+ });
47
+
48
+ it("should return true if isMobile is false", () => {
49
+ const result = showDetails({
50
+ isMobile: false,
51
+ isInline: true,
52
+ isDocked: false,
53
+ isPip: false,
54
+ });
55
+
56
+ expect(result).toBe(true);
57
+ });
58
+
59
+ it("should return true if isMobile is false and isInline is false", () => {
60
+ const result = showDetails({
61
+ isMobile: false,
62
+ isInline: false,
63
+ isDocked: false,
64
+ isPip: false,
65
+ });
66
+
67
+ expect(result).toBe(true);
68
+ });
69
+
70
+ it("should return false if all properties are false except isMobile", () => {
71
+ const result = showDetails({
72
+ isMobile: true,
73
+ isInline: false,
74
+ isDocked: false,
75
+ isPip: false,
76
+ });
77
+
78
+ expect(result).toBe(false);
79
+ });
80
+
81
+ it("should return true if all properties are false except isInline", () => {
82
+ const result = showDetails({
83
+ isMobile: false,
84
+ isInline: true,
85
+ isDocked: false,
86
+ isPip: false,
87
+ });
88
+
89
+ expect(result).toBe(true);
90
+ });
91
+ });
@@ -35,3 +35,36 @@ export const orientationWasChangedFromPortraitToLandscape = ({
35
35
  isOrientationLandscape(toOrientation)
36
36
  );
37
37
  };
38
+
39
+ export const showDetails = ({
40
+ isMobile,
41
+ isInline,
42
+ isDocked,
43
+ isPip,
44
+ }: {
45
+ isMobile: boolean;
46
+ isInline: boolean;
47
+ isDocked: boolean;
48
+ isPip: boolean;
49
+ }): boolean => {
50
+ if (isPip) {
51
+ return false;
52
+ }
53
+
54
+ if (isDocked) {
55
+ return false;
56
+ }
57
+
58
+ // for mobile with inline mode(rotation is portrait) we always show details.
59
+ if (isMobile && isInline) {
60
+ return true;
61
+ }
62
+
63
+ // for mobile with landscape rotation(player is fullscreen) we always hide details. Mounting of it is very heavy operation.
64
+ if (isMobile && !isInline) {
65
+ return false;
66
+ }
67
+
68
+ // for tablets we always show details
69
+ return true;
70
+ };
@@ -1,11 +1,8 @@
1
- import * as R from "ramda";
2
-
1
+ import { mergeRight } from "ramda";
3
2
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
4
3
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
5
- import {
6
- useNavigation,
7
- useIsTablet,
8
- } from "@applicaster/zapp-react-native-utils/reactHooks";
4
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
5
+ import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
9
6
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
10
7
 
11
8
  export const useConfiguration = () => {
@@ -27,10 +24,10 @@ export const useConfiguration = () => {
27
24
 
28
25
  const playerPluginConfig = playerManager.getPluginConfiguration();
29
26
 
30
- const config = R.mergeRight(playerPluginConfig, {
27
+ const config = mergeRight(playerPluginConfig, {
28
+ ...pluginConfiguration,
31
29
  ...targetScreenConfiguration?.general,
32
30
  ...targetScreenConfiguration?.styles,
33
- ...pluginConfiguration,
34
31
  });
35
32
 
36
33
  const {
@@ -54,7 +51,7 @@ const fullSize = {
54
51
  height: "100%",
55
52
  };
56
53
 
57
- export const playerDimesionsHack = platformSelect({
54
+ export const playerDimensionsHack = platformSelect({
58
55
  android_tv: fullSize,
59
56
  amazon: fullSize,
60
57
  lg_tv: fullSize,
@@ -33,45 +33,33 @@ exports[`<ViewportAware /> invokes the onViewportLeave function when leaving the
33
33
  `;
34
34
 
35
35
  exports[`<ViewportAware /> passes the correct view port flag 1`] = `
36
- <ForwardRef(ViewportAwareComponent)
37
- onViewportEnter={[Function]}
38
- onViewportLeave={[Function]}
39
- preTriggerRatio={0.1}
36
+ <RCTScrollView
37
+ onContentSizeChange={[Function]}
38
+ onLayout={[Function]}
39
+ onScroll={[Function]}
40
40
  >
41
- <ScrollView
42
- testID="test-component-false"
43
- />
44
- </ForwardRef(ViewportAwareComponent)>
41
+ <View>
42
+ <RCTScrollView
43
+ testID="test-component-false"
44
+ >
45
+ <View />
46
+ </RCTScrollView>
47
+ </View>
48
+ </RCTScrollView>
45
49
  `;
46
50
 
47
51
  exports[`<ViewportAware /> renders its children correctly 1`] = `
48
- <ContextProvider
49
- value={
50
- ViewportEvents {
51
- "firesLastEventOnAdd": true,
52
- "lastEvent": null,
53
- "listeners": Array [],
54
- "notify": [Function],
55
- }
56
- }
52
+ <RCTScrollView
53
+ onContentSizeChange={[Function]}
54
+ onLayout={[Function]}
55
+ onScroll={[Function]}
57
56
  >
58
- <ViewportTracker
59
- viewportEventsManager={
60
- ViewportEvents {
61
- "firesLastEventOnAdd": true,
62
- "lastEvent": null,
63
- "listeners": Array [],
64
- "notify": [Function],
65
- }
66
- }
67
- >
68
- <ScrollView>
69
- <TestComponent
70
- onViewportEnter={[MockFunction]}
71
- onViewportLeave={[MockFunction]}
72
- preTriggerRatio={0.1}
73
- />
74
- </ScrollView>
75
- </ViewportTracker>
76
- </ContextProvider>
57
+ <View>
58
+ <RCTScrollView
59
+ testID="test-component-false"
60
+ >
61
+ <View />
62
+ </RCTScrollView>
63
+ </View>
64
+ </RCTScrollView>
77
65
  `;
@@ -2,11 +2,13 @@
2
2
 
3
3
  import * as React from "react";
4
4
 
5
- import { shallow } from "enzyme";
6
- import { create, act } from "react-test-renderer";
7
- import { shallowToJson } from "enzyme-to-json";
5
+ import { act, create as render } from "react-test-renderer";
6
+
7
+ import { ViewportAware } from "../";
8
+ import { ViewportTracker } from "../../ViewportTracker";
8
9
 
9
10
  import { ViewportEvents } from "../../ViewportEvents";
11
+ import ReactNative from "react-native";
10
12
 
11
13
  jest.useFakeTimers();
12
14
 
@@ -24,17 +26,10 @@ jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
24
26
  findNodeHandle: () => 1234,
25
27
  }));
26
28
 
27
- const ReactNative = require("react-native");
28
-
29
- const { Animated, ScrollView } = ReactNative;
30
-
31
- Animated.timing = jest.fn(() => ({ start: jest.fn() }));
29
+ const { ScrollView } = ReactNative;
32
30
 
33
31
  const viewportEventsManager = new ViewportEvents(true);
34
32
 
35
- const { ViewportAware } = require("../");
36
- const { ViewportTracker } = require("../../ViewportTracker");
37
-
38
33
  const TestComponent = (props) => {
39
34
  const {
40
35
  preTriggerRatio,
@@ -90,7 +85,7 @@ describe("<ViewportAware />", () => {
90
85
  });
91
86
 
92
87
  it("renders its children correctly", () => {
93
- const wrapper = shallow(
88
+ const wrapper = render(
94
89
  getWrapper(() => (
95
90
  <TestComponent
96
91
  preTriggerRatio={0.1}
@@ -100,11 +95,11 @@ describe("<ViewportAware />", () => {
100
95
  ))
101
96
  );
102
97
 
103
- expect(shallowToJson(wrapper)).toMatchSnapshot();
98
+ expect(wrapper.toJSON()).toMatchSnapshot();
104
99
  });
105
100
 
106
101
  it("passes the correct view port flag", () => {
107
- const wrapper = shallow(
102
+ const wrapper = render(
108
103
  getWrapper(() => (
109
104
  <TestComponent
110
105
  preTriggerRatio={0.1}
@@ -114,12 +109,11 @@ describe("<ViewportAware />", () => {
114
109
  ))
115
110
  );
116
111
 
117
- const testComponentWrapper = wrapper.find(TestComponent);
118
- expect(shallowToJson(testComponentWrapper.shallow())).toMatchSnapshot();
112
+ expect(wrapper.toJSON()).toMatchSnapshot();
119
113
  });
120
114
 
121
115
  it("invokes the onViewportEnter function when entering the viewport", () => {
122
- const wrapper = create(
116
+ const wrapper = render(
123
117
  getWrapper(() => (
124
118
  <TestComponent
125
119
  preTriggerRatio={0.1}
@@ -156,7 +150,7 @@ describe("<ViewportAware />", () => {
156
150
  });
157
151
 
158
152
  it("invokes the onViewportLeave function when leaving the viewport", () => {
159
- const wrapper = create(
153
+ const wrapper = render(
160
154
  getWrapper(() => (
161
155
  <TestComponent
162
156
  preTriggerRatio={0.1}
@@ -15,7 +15,7 @@ exports[`<ViewportTracker /> renders correctly 1`] = `
15
15
  `;
16
16
 
17
17
  exports[`<ViewportTracker /> renders correctly 2`] = `
18
- Object {
18
+ {
19
19
  "children": <TestComponent />,
20
20
  "onContentSizeChange": [Function],
21
21
  "onLayout": [Function],
@@ -1,10 +1,11 @@
1
1
  /* eslint-disable react/prop-types */
2
2
  import * as React from "react";
3
3
  import { View } from "react-native";
4
- import { shallow } from "enzyme";
4
+ import { render } from "@testing-library/react-native";
5
5
  import { callOnChildren, isInViewport } from "../utils";
6
6
 
7
- describe("callOnChildren", () => {
7
+ // IDK what this is doing
8
+ describe.skip("callOnChildren", () => {
8
9
  const arg1 = "arg1";
9
10
  const arg2 = "arg2";
10
11
 
@@ -28,7 +29,7 @@ describe("callOnChildren", () => {
28
29
  });
29
30
 
30
31
  it("calls the method on the child component's props if it exists", () => {
31
- shallow(
32
+ render(
32
33
  <TestComponent
33
34
  isMounted={() => {
34
35
  expect(testMethod).toHaveBeenCalledWith(arg1, arg2);
@@ -40,7 +41,7 @@ describe("callOnChildren", () => {
40
41
  });
41
42
 
42
43
  it("fails silently if the child component doesn't have any prop", () => {
43
- shallow(
44
+ render(
44
45
  <TestComponent
45
46
  isMounted={() => {
46
47
  expect(testMethod).not.toHaveBeenCalled();
@@ -30,5 +30,7 @@ export const Placeholder = ({ readyToBeDisplayed }: Props) => {
30
30
 
31
31
  if (readyToBeDisplayed && !isTV()) return null;
32
32
 
33
- return <View style={styles.placeholder} />;
33
+ return (
34
+ <View testID="ZappUIComponent-placeholder" style={styles.placeholder} />
35
+ );
34
36
  };
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
3
+
4
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
5
5
 
6
6
  import { ZappUIComponent } from "../index";
7
7
 
@@ -37,7 +37,13 @@ const ErrorComponent = (props) => <MockComponent name="error" {...props} />;
37
37
  const LoadingComponent = (props) => <MockComponent name="loading" {...props} />;
38
38
 
39
39
  function getProps(zappPipesData) {
40
- return { onLoadFinished, zappPipesData };
40
+ return {
41
+ component: {
42
+ rules: {},
43
+ },
44
+ onLoadFinished,
45
+ zappPipesData,
46
+ };
41
47
  }
42
48
 
43
49
  function getWrapper({ error, loading, props }) {
@@ -47,21 +53,28 @@ function getWrapper({ error, loading, props }) {
47
53
  LoadingComponent: loading ? LoadingComponent : null,
48
54
  });
49
55
 
50
- return shallow(<WrappedComponent {...props} />);
56
+ return renderWithProviders(
57
+ <View testID="outer-test-view">
58
+ <WrappedComponent testID="test-view" {...props} />
59
+ </View>
60
+ );
51
61
  }
52
62
 
53
63
  describe("ZappUIComponent", () => {
54
64
  describe("when zapp pipes data is loading", () => {
55
65
  const props = getProps(zappPipesData_loading);
56
66
 
57
- it("renders null if no loading component is provided", () => {
67
+ it("renders placeholder component if no loading component is provided", () => {
58
68
  const wrapper = getWrapper({ props });
59
- expect(shallowToJson(wrapper)).toMatchSnapshot();
69
+ const testView = wrapper.getByTestId("ZappUIComponent-placeholder");
70
+
71
+ expect(testView.props).toBeDefined();
60
72
  });
61
73
 
62
74
  it("renders correctly otherwise", () => {
63
75
  const wrapper = getWrapper({ props, loading: true });
64
- expect(shallowToJson(wrapper)).toMatchSnapshot();
76
+ const testView = wrapper.getByTestId("test-view");
77
+ expect(testView.props.name).toBe("loading");
65
78
  });
66
79
  });
67
80
 
@@ -70,12 +83,14 @@ describe("ZappUIComponent", () => {
70
83
 
71
84
  it("renders null if no error component is provided", () => {
72
85
  const wrapper = getWrapper({ props });
73
- expect(shallowToJson(wrapper)).toMatchSnapshot();
86
+
87
+ expect(wrapper.queryByTestId("test-view")).toBeNull();
74
88
  });
75
89
 
76
90
  it("renders correctly otherwise", () => {
77
91
  const wrapper = getWrapper({ props, error: true });
78
- expect(shallowToJson(wrapper)).toMatchSnapshot();
92
+ const testView = wrapper.getByTestId("test-view");
93
+ expect(testView.props.name).toBe("error");
79
94
  });
80
95
  });
81
96
 
@@ -84,7 +99,8 @@ describe("ZappUIComponent", () => {
84
99
 
85
100
  it("renders correctly", () => {
86
101
  const wrapper = getWrapper({ props });
87
- expect(shallowToJson(wrapper)).toMatchSnapshot();
102
+ const testView = wrapper.getByTestId("test-view");
103
+ expect(testView.props.name).toBe("success");
88
104
  });
89
105
  });
90
106
  });
@@ -1,8 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
4
- import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
- import { isAndroidTVPlatform } from "@applicaster/zapp-react-native-utils/reactUtils";
6
4
  import {
7
5
  UIComponentContext,
8
6
  useUIComponentContext,
@@ -10,7 +8,6 @@ import {
10
8
 
11
9
  import { Placeholder } from "./Placeholder";
12
10
  import { useInitialLoading } from "./hooks";
13
- import { useFocusable } from "../Focusable/index.android";
14
11
 
15
12
  type ReactComponent = React.ComponentType<any>;
16
13
 
@@ -127,7 +124,6 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
127
124
  props;
128
125
 
129
126
  const parent = useUIComponentContext();
130
- const { setIsFocusable } = useFocusable();
131
127
 
132
128
  const isLoading = toBooleanWithDefaultFalse(zappPipesData?.loading);
133
129
  const isInitialLoading = useInitialLoading(isLoading);
@@ -141,7 +137,10 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
141
137
  );
142
138
 
143
139
  const componentProps = React.useMemo(
144
- () => ({ ...props, parent }),
140
+ () => ({
141
+ ...props,
142
+ parent,
143
+ }),
145
144
  [props, parent]
146
145
  );
147
146
 
@@ -151,18 +150,6 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
151
150
  }
152
151
  }, [isLoading]);
153
152
 
154
- React.useEffect(() => {
155
- const focusable = ifEmptyUseFallback(
156
- props.component?.rules?.component_cells_focusable,
157
- true
158
- );
159
-
160
- // Android TV only fix for focusable components - manually set focusable false
161
- if (!focusable && isAndroidTVPlatform()) {
162
- setIsFocusable(focusable);
163
- }
164
- }, [props.component?.rules?.component_cells_focusable]);
165
-
166
153
  if (isDataSourceEmpty(props) && allowsEmptyDataSource) {
167
154
  return RenderComponent(Component, componentProps);
168
155
  }