@applicaster/zapp-react-native-ui-components 13.0.0-alpha.3528549047 → 13.0.0-alpha.3546196593

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 (145) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AudioPlayer/AudioPlayer.tsx +7 -0
  3. package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
  5. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
  6. package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
  7. package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
  8. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
  9. package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
  10. package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
  11. package/Components/AudioPlayer/__tests__/title.test.js +3 -5
  12. package/Components/AudioPlayer/helpers.tsx +1 -0
  13. package/Components/BaseFocusable/index.ios.ts +1 -1
  14. package/Components/BaseFocusable/index.tsx +2 -3
  15. package/Components/Cell/Cell.tsx +11 -16
  16. package/Components/Cell/CellWithFocusable.tsx +48 -59
  17. package/Components/Cell/CellWrapper.ts +5 -0
  18. package/Components/Cell/TvOSCellComponent.tsx +20 -22
  19. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  20. package/Components/Cell/index.js +3 -1
  21. package/Components/Cell/styles.ts +17 -0
  22. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
  23. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  24. package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
  25. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  26. package/Components/ErrorScreen/index.tsx +14 -6
  27. package/Components/Focusable/Focusable.tsx +1 -0
  28. package/Components/Focusable/FocusableTvOS.tsx +5 -1
  29. package/Components/Focusable/Touchable.tsx +19 -20
  30. package/Components/Focusable/index.android.tsx +10 -3
  31. package/Components/FocusableCell/index.tsx +1 -1
  32. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -86
  33. package/Components/FocusableGroup/index.tsx +0 -3
  34. package/Components/FocusableList/index.tsx +26 -9
  35. package/Components/FocusableScrollView/index.tsx +43 -13
  36. package/Components/HandlePlayable/HandlePlayable.tsx +14 -27
  37. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  38. package/Components/Layout/TV/ScreenContainer.tsx +8 -1
  39. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  40. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
  41. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
  42. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
  43. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  44. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  45. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  46. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +9 -14
  47. package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +11 -7
  48. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  49. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  50. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  51. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  52. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  53. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
  54. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
  55. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  56. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  57. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  58. package/Components/MasterCell/utils/behaviorProvider.ts +136 -0
  59. package/Components/MasterCell/utils/index.ts +9 -135
  60. package/Components/ModalComponent/Button/assets.ts +1 -1
  61. package/Components/ModalComponent/Button/index.tsx +6 -6
  62. package/Components/ModalComponent/Header/index.tsx +3 -3
  63. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  64. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  65. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  66. package/Components/OfflineHandler/utils/index.ts +1 -1
  67. package/Components/PlayerContainer/PlayerContainer.tsx +17 -13
  68. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  69. package/Components/PlayerImageBackground/index.tsx +1 -1
  70. package/Components/River/ComponentsMap/ComponentsMap.tsx +42 -65
  71. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  72. package/Components/River/RiverFooter.tsx +39 -9
  73. package/Components/River/RiverItem.tsx +37 -2
  74. package/Components/River/TV/index.tsx +6 -1
  75. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
  76. package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
  77. package/Components/River/__tests__/componentsMap.test.js +3 -4
  78. package/Components/River/__tests__/river.test.js +75 -40
  79. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
  80. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  81. package/Components/RouteManager/__tests__/testId.test.js +8 -6
  82. package/Components/Screen/TV/index.web.tsx +5 -6
  83. package/Components/Screen/hooks.ts +53 -0
  84. package/Components/Screen/index.tsx +16 -42
  85. package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
  86. package/Components/Tabs/Tab.tsx +11 -9
  87. package/Components/TextInputTv/index.tsx +4 -3
  88. package/Components/TrackedView/index.tsx +1 -0
  89. package/Components/Transitioner/AnimationManager.js +15 -15
  90. package/Components/Transitioner/Scene.tsx +53 -24
  91. package/Components/Transitioner/Transitioner.tsx +3 -3
  92. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  93. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
  94. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
  95. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  96. package/Components/Transitioner/index.js +8 -4
  97. package/Components/VideoLive/LiveImageManager.ts +27 -1
  98. package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
  99. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
  100. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -5
  101. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +1 -1
  102. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +44 -30
  103. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +3 -3
  104. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +31 -17
  105. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +4 -5
  106. package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
  107. package/Components/VideoModal/PlayerDetails.tsx +9 -6
  108. package/Components/VideoModal/PlayerWrapper.tsx +2 -2
  109. package/Components/VideoModal/VideoModal.tsx +2 -2
  110. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  111. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  112. package/Components/Viewport/__tests__/utils.test.js +5 -4
  113. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  114. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  115. package/Components/ZappUIComponent/index.tsx +11 -17
  116. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  117. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  118. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  119. package/Contexts/FocusableGroupContext/withFocusableContext.tsx +4 -10
  120. package/Contexts/HeaderOffsetContext/index.tsx +4 -6
  121. package/Contexts/ScreenContext/index.tsx +6 -12
  122. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  123. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  124. package/Decorators/Navigator/index.tsx +1 -1
  125. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
  126. package/Decorators/RiverResolver/index.tsx +6 -8
  127. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  128. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  129. package/Decorators/ZappPipesDataConnector/index.tsx +4 -30
  130. package/package.json +7 -11
  131. package/tsconfig.json +2 -3
  132. package/.babelrc +0 -8
  133. package/Components/Cell/CellStyles/FallbackCellStyle/index.js +0 -157
  134. package/Components/Cell/CellStyles/Hero/index.js +0 -111
  135. package/Components/Cell/CellStyles/ScreenSelector/index.js +0 -68
  136. package/Components/Cell/CellStyles/cellStylesResolver.ts +0 -19
  137. package/Components/Cell/CellStyles/colors.js +0 -40
  138. package/Components/Cell/CellStyles/index.js +0 -15
  139. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  140. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  141. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  142. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  143. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  144. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  145. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
@@ -4,26 +4,26 @@ import { Animated, View } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
 
6
6
  import {
7
- useModalAnimationContext,
8
7
  PlayerAnimationStateEnum,
8
+ useModalAnimationContext,
9
9
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
10
10
 
11
11
  import {
12
+ useDimensions,
12
13
  useGetBottomTabBarHeight,
13
14
  useNavigation,
14
- useDimensions,
15
15
  } from "@applicaster/zapp-react-native-utils/reactHooks";
16
16
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
17
17
  import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
18
18
  import { useAppState } from "@applicaster/zapp-react-native-utils/reactHooks/app";
19
19
 
20
20
  import {
21
- gestureListenerHelper,
22
- getAnimationStyle,
21
+ AUDIO_PLAYER_HORIZONTAL_PADDING,
22
+ ComponentAnimationType,
23
23
  defaultAspectRatioWidth,
24
+ gestureListenerHelper,
24
25
  getAnimationDefaultValue,
25
- ComponentAnimationType,
26
- AUDIO_PLAYER_HORIZONTAL_PADDING,
26
+ getAnimationStyle,
27
27
  } from "./utils";
28
28
 
29
29
  type Props = {
@@ -100,10 +100,11 @@ export const AnimationView = ({
100
100
  const moveUpValue = additionalData.saveArea
101
101
  ? -insets.top + (isAudioItem ? 0 : progressBarHeight)
102
102
  : isTablet
103
- ? isTabletLandscape && (!isAudioItem || (isAudioItem && inlineAudioPlayer))
104
- ? -tabletLandscapePlayerTopPosition + progressBarHeight
105
- : -130
106
- : -50 + progressBarHeight;
103
+ ? isTabletLandscape &&
104
+ (!isAudioItem || (isAudioItem && inlineAudioPlayer))
105
+ ? -tabletLandscapePlayerTopPosition + progressBarHeight
106
+ : -130
107
+ : -50 + progressBarHeight;
107
108
 
108
109
  const moveComponentHorizontalValue = additionalData.moveValue
109
110
  ? isRTL
@@ -227,6 +228,8 @@ export const AnimationView = ({
227
228
  isAudioItem,
228
229
  moveUpValue,
229
230
  moveComponentHorizontalValue,
231
+ isRTL,
232
+ inlineAudioPlayer,
230
233
  ]
231
234
  );
232
235
 
@@ -245,7 +248,7 @@ export const AnimationView = ({
245
248
  default:
246
249
  return getAnimationValue(
247
250
  animationType,
248
- PlayerAnimationStateEnum.maximaze
251
+ PlayerAnimationStateEnum.maximize
249
252
  ).toValue;
250
253
  }
251
254
  }, [defaultValue, videoModalState]);
@@ -277,6 +280,11 @@ export const AnimationView = ({
277
280
  moveUpValue,
278
281
  moveComponentHorizontalValue,
279
282
  videoModalMode,
283
+ isAudioItem,
284
+ isTablet,
285
+ isTabletLandscape,
286
+ isRTL,
287
+ inlineAudioPlayer,
280
288
  ]
281
289
  );
282
290
 
@@ -305,7 +313,7 @@ export const AnimationView = ({
305
313
  }
306
314
 
307
315
  if (
308
- videoModalMode === "MAXIMIZED" &&
316
+ (videoModalMode === "MAXIMIZED" || videoModalMode === "MINIMIZED") &&
309
317
  defaultValue.x !== screenWidth &&
310
318
  width &&
311
319
  height
@@ -331,7 +339,13 @@ export const AnimationView = ({
331
339
  animatedValue.setValue(value);
332
340
  }
333
341
  }
334
- }, [videoModalState]);
342
+ }, [
343
+ animatedValue,
344
+ animationType,
345
+ getAnimationValue,
346
+ playerAnimationState,
347
+ videoModalState,
348
+ ]);
335
349
 
336
350
  React.useEffect(() => {
337
351
  if (
@@ -343,7 +357,7 @@ export const AnimationView = ({
343
357
  animatedValue,
344
358
  getAnimationValue(animationType, playerAnimationState)
345
359
  ).start();
346
- } else if (playerAnimationState === PlayerAnimationStateEnum.maximaze) {
360
+ } else if (playerAnimationState === PlayerAnimationStateEnum.maximize) {
347
361
  animatedValue.setValue(defaultValue);
348
362
  }
349
363
  }, [playerAnimationState, startComponentsAnimation, defaultValue]);
@@ -404,7 +418,7 @@ export const AnimationView = ({
404
418
 
405
419
  return (
406
420
  <Animated.View
407
- onLayout={additionalData.useLayoutMeasure && measureView}
421
+ onLayout={additionalData.useLayoutMeasure ? measureView : undefined}
408
422
  ref={animationComponentRef}
409
423
  style={[
410
424
  ...preparedStyles,
@@ -434,8 +448,8 @@ export const AnimationComponent = (props: Props) => {
434
448
  const Component = useAnimation
435
449
  ? AnimationView
436
450
  : style
437
- ? View
438
- : React.Fragment;
451
+ ? View
452
+ : React.Fragment;
439
453
 
440
454
  if (
441
455
  additionalData.extraAnimation &&
@@ -14,12 +14,12 @@ import { useConfiguration } from "../utils";
14
14
 
15
15
  export enum PlayerAnimationStateEnum {
16
16
  minimize = "minimize",
17
- maximaze = "maximaze",
17
+ maximize = "maximize",
18
18
  drag_player = "drag_player",
19
19
  drag_scroll = "drag_scroll",
20
20
  }
21
21
 
22
- type PlayerAnimationStateT = number | PlayerAnimationStateEnum | null;
22
+ export type PlayerAnimationStateT = number | PlayerAnimationStateEnum | null;
23
23
 
24
24
  export type ModalAnimationContextT = {
25
25
  isActiveGesture: boolean;
@@ -118,11 +118,10 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
118
118
  If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
119
119
  Because of this we need to minus bottom SafeArea offset.
120
120
  */
121
+
121
122
  const minValue =
122
123
  height -
123
- minimisedHeight -
124
- (bottomTabBarHeight || bottomSafeArea) -
125
- progressBarHeight;
124
+ (minimisedHeight + bottomTabBarHeight + progressBarHeight + bottomSafeArea);
126
125
 
127
126
  const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
128
127
  // Last snap state which will helps us to make smooth responder to scrollview animation
@@ -108,8 +108,8 @@ export const calculateAnimationValue = (animationType, dragPosition, data) => {
108
108
  : { forWidth: 3, forHeight: 3 }
109
109
  : { forWidth: 2, forHeight: 2 }
110
110
  : isTabletLandscape
111
- ? { forWidth: 8, forHeight: 6.5 }
112
- : { forWidth: 3.5, forHeight: 2 };
111
+ ? { forWidth: 8, forHeight: 6.5 }
112
+ : { forWidth: 3.5, forHeight: 2 };
113
113
 
114
114
  const minWidth =
115
115
  isAudioItem && !inlineAudioPlayer ? minimisedHeight : minimisedWidth;
@@ -1,10 +1,11 @@
1
1
  import React, { useEffect, useRef } from "react";
2
2
  import {
3
- StyleProp,
4
- ViewStyle,
5
3
  Animated,
6
- Easing,
7
4
  Dimensions,
5
+ Easing,
6
+ StyleProp,
7
+ ViewStyle,
8
+ StyleSheet,
8
9
  } from "react-native";
9
10
  import { useTargetScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
10
11
  import { ComponentsMap } from "@applicaster/zapp-react-native-ui-components/Components/River/ComponentsMap";
@@ -90,17 +91,19 @@ export const PlayerDetails = ({
90
91
  {
91
92
  // workaround for avoid wrong text-height after going back to portrait rotation
92
93
  // we don't see this view in landscape mode, so we are able to use fixed width from portrait mode
93
- width: isTablet ? undefined : SCREEN_WIDTH,
94
+ width: isTablet
95
+ ? undefined
96
+ : (StyleSheet.flatten(style)?.width ?? SCREEN_WIDTH),
94
97
  },
95
98
  ]}
96
99
  >
97
- {screenData && (
100
+ {screenData ? (
98
101
  <ComponentsMap
99
102
  riverId={screenData.id}
100
103
  feed={screenData?.data?.source}
101
104
  riverComponents={screenData.ui_components}
102
105
  />
103
- )}
106
+ ) : null}
104
107
  </Animated.View>
105
108
  );
106
109
  };
@@ -227,7 +227,7 @@ const PlayerWrapperComponent = (props: Props) => {
227
227
  </View>
228
228
 
229
229
  <AnimatedScrollModal>
230
- {isShowPlayerDetails && (
230
+ {isShowPlayerDetails ? (
231
231
  <AnimationComponent
232
232
  animationType={ComponentAnimationType.componentFade}
233
233
  style={defaultStyles.flex}
@@ -240,7 +240,7 @@ const PlayerWrapperComponent = (props: Props) => {
240
240
  isTablet={isTablet}
241
241
  />
242
242
  </AnimationComponent>
243
- )}
243
+ ) : null}
244
244
  </AnimatedScrollModal>
245
245
  </AnimationComponent>
246
246
  </WrapperView>
@@ -137,14 +137,14 @@ const VideoModalComponent = () => {
137
137
  styles.container,
138
138
  {
139
139
  backgroundColor,
140
+ width: modalSize.width,
141
+ height: modalSize.height,
140
142
  },
141
143
  ]}
142
144
  >
143
145
  <HandlePlayable
144
146
  item={item}
145
147
  isModal={mode !== "PIP"}
146
- modalHeight={modalSize.height}
147
- modalWidth={modalSize.width}
148
148
  mode={mode}
149
149
  />
150
150
  </AnimatedPlayerModalWrapper>
@@ -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": [],
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": [],
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}
@@ -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,13 +8,14 @@ import {
10
8
 
11
9
  import { Placeholder } from "./Placeholder";
12
10
  import { useInitialLoading } from "./hooks";
13
- import { useFocusable } from "../Focusable/index.android";
11
+ import { useIsFocusable } from "@applicaster/zapp-react-native-utils/focusManager";
14
12
 
15
13
  type ReactComponent = React.ComponentType<any>;
16
14
 
17
15
  type Options = {
18
16
  skipOnLoadFinished?: boolean;
19
17
  allowsEmptyDataSource?: boolean;
18
+ alwaysFocusable?: boolean;
20
19
  };
21
20
 
22
21
  type ZappUIComponentType = {
@@ -127,7 +126,6 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
127
126
  props;
128
127
 
129
128
  const parent = useUIComponentContext();
130
- const { setIsFocusable } = useFocusable();
131
129
 
132
130
  const isLoading = toBooleanWithDefaultFalse(zappPipesData?.loading);
133
131
  const isInitialLoading = useInitialLoading(isLoading);
@@ -140,29 +138,25 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
140
138
  options?.allowsEmptyDataSource
141
139
  );
142
140
 
141
+ const alwaysFocusable = toBooleanWithDefaultFalse(options?.alwaysFocusable);
142
+
143
143
  const componentProps = React.useMemo(
144
- () => ({ ...props, parent }),
144
+ () => ({
145
+ ...props,
146
+ forceFocusable: alwaysFocusable,
147
+ parent,
148
+ }),
145
149
  [props, parent]
146
150
  );
147
151
 
152
+ useIsFocusable(componentProps);
153
+
148
154
  React.useEffect(() => {
149
155
  if (!skipOnLoadFinished && !isLoading) {
150
156
  onLoadFinished();
151
157
  }
152
158
  }, [isLoading]);
153
159
 
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
160
  if (isDataSourceEmpty(props) && allowsEmptyDataSource) {
167
161
  return RenderComponent(Component, componentProps);
168
162
  }
@@ -1,10 +1,10 @@
1
1
  import * as React from "react";
2
2
  import { Platform } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
3
+ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
5
4
 
6
5
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
7
6
  useRoute: jest.fn(() => ({ screenData: { id: "test" } })),
7
+ useIsScreenActive: jest.fn(() => true),
8
8
  }));
9
9
 
10
10
  jest.mock("@applicaster/zapp-react-native-utils/screenState", () => ({
@@ -26,8 +26,16 @@ const cell_styles = "style";
26
26
  const configuration = { component, styles, cell_styles } as const;
27
27
 
28
28
  describe("DefaultCellRenderer", () => {
29
+ beforeEach(() => {
30
+ Platform.OS = "ios"; // Reset to default
31
+ });
32
+
33
+ afterEach(() => {
34
+ jest.clearAllMocks();
35
+ });
36
+
29
37
  it("is a function", () => {
30
- expect(DefaultCellRenderer).toBeFunction();
38
+ expect(typeof DefaultCellRenderer).toBe("function");
31
39
  });
32
40
 
33
41
  it("returns an error if component is missing in configuration", () => {
@@ -36,28 +44,23 @@ describe("DefaultCellRenderer", () => {
36
44
  );
37
45
  });
38
46
 
39
- it("returns a react component and it renders correctly", () => {
47
+ it("renders correctly", () => {
40
48
  const CellRenderer = DefaultCellRenderer(configuration);
41
- const wrapper = shallow(<CellRenderer store={null} />);
42
-
43
- expect(shallowToJson(wrapper)).toMatchSnapshot();
49
+ const result = renderWithProviders(<CellRenderer store={null} />);
50
+ expect(result).toBeTruthy();
44
51
  });
45
52
 
46
- it("returns a react component for LG TVs", () => {
53
+ it("renders correctly for LG TVs", () => {
47
54
  Platform.OS = "lg_tv";
48
-
49
55
  const CellRenderer = DefaultCellRenderer(configuration);
50
- const wrapper = shallow(<CellRenderer store={null} />);
51
-
52
- expect(shallowToJson(wrapper)).toMatchSnapshot();
56
+ const result = renderWithProviders(<CellRenderer store={null} />);
57
+ expect(result).toBeTruthy();
53
58
  });
54
59
 
55
- it("returns a react component for Samsung TVs", () => {
60
+ it("renders correctly for Samsung TVs", () => {
56
61
  Platform.OS = "samsung_tv";
57
-
58
62
  const CellRenderer = DefaultCellRenderer(configuration);
59
- const wrapper = shallow(<CellRenderer store={null} />);
60
-
61
- expect(shallowToJson(wrapper)).toMatchSnapshot();
63
+ const result = renderWithProviders(<CellRenderer store={null} />);
64
+ expect(result).toBeTruthy();
62
65
  });
63
66
  });