@applicaster/zapp-react-native-ui-components 12.0.0-alpha.4400210593 → 12.0.0-alpha.4462655310

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 (80) hide show
  1. package/Components/BaseFocusable/index.tsx +1 -1
  2. package/Components/Cell/Cell.tsx +5 -5
  3. package/Components/Cell/CellWithFocusable.tsx +17 -5
  4. package/Components/FocusableGroup/index.tsx +1 -0
  5. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  6. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  7. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  8. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  9. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  10. package/Components/Layout/TV/__tests__/index.test.tsx +19 -75
  11. package/Components/Layout/TV/index.tsx +12 -11
  12. package/Components/Layout/TV/index.web.tsx +33 -0
  13. package/Components/Layout/index.tsx +15 -11
  14. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  15. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +88 -112
  16. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  17. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  18. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  19. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -1
  20. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  21. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  22. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  23. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  24. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  25. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  26. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  27. package/Components/MasterCell/utils/index.ts +33 -35
  28. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  29. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  30. package/Components/Navigator/StackNavigator.tsx +48 -0
  31. package/Components/Navigator/index.ts +1 -0
  32. package/Components/PlayerContainer/PlayerContainer.tsx +23 -3
  33. package/Components/PlayerImageBackground/index.tsx +34 -8
  34. package/Components/River/ComponentsMap/ComponentsMap.tsx +92 -22
  35. package/Components/River/RefreshControl.tsx +55 -1
  36. package/Components/River/TV/River.tsx +0 -23
  37. package/Components/River/__tests__/componentsMap.test.js +6 -0
  38. package/Components/RouteManager/index.tsx +2 -2
  39. package/Components/Screen/TV/hooks/index.ts +3 -0
  40. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  41. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  42. package/Components/Screen/TV/index.web.tsx +179 -0
  43. package/Components/Screen/__tests__/Screen.test.tsx +3 -0
  44. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  45. package/Components/Screen/index.tsx +64 -25
  46. package/Components/ScreenResolver/index.tsx +3 -1
  47. package/Components/Transitioner/Scene.tsx +24 -19
  48. package/Components/Transitioner/Transitioner.tsx +21 -28
  49. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  50. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  51. package/Components/VideoLive/LiveImageManager.ts +18 -1
  52. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +20 -5
  53. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  54. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  55. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +352 -0
  56. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +158 -0
  57. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +461 -0
  58. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  59. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  60. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  61. package/Components/VideoModal/PlayerDetails.tsx +3 -3
  62. package/Components/VideoModal/PlayerWrapper.tsx +77 -47
  63. package/Components/VideoModal/VideoModal.tsx +23 -40
  64. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -1
  65. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +151 -119
  66. package/Components/VideoModal/utils.ts +8 -5
  67. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  68. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  69. package/Components/Viewport/utils.js +1 -1
  70. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  71. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  72. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  73. package/Contexts/ScreenContext/index.tsx +94 -25
  74. package/Contexts/ScreenDataContext/index.tsx +20 -0
  75. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  76. package/events/index.ts +1 -0
  77. package/package.json +5 -5
  78. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  79. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  80. /package/Contexts/{index.js → index.ts} +0 -0
@@ -23,9 +23,6 @@ exports[`PlayerWrapper renders inline 1`] = `
23
23
  }
24
24
  style={
25
25
  Array [
26
- Object {
27
- "flexDirection": "column",
28
- },
29
26
  Object {
30
27
  "backgroundColor": "transparent",
31
28
  },
@@ -38,44 +35,45 @@ exports[`PlayerWrapper renders inline 1`] = `
38
35
  }
39
36
  >
40
37
  <View
41
- style={
42
- Array [
43
- Object {
44
- "alignSelf": "center",
45
- "position": "relative",
46
- "zIndex": 200,
47
- },
48
- Object {
49
- "aspectRatio": 1.7777777777777777,
50
- "height": undefined,
51
- "width": "100%",
52
- },
53
- Object {},
54
- Object {},
55
- ]
56
- }
57
- testID="test-player-container"
58
- />
59
- <View
60
- configuration={
38
+ additionalData={
61
39
  Object {
62
- "tablet_landscape_player_container_background_color": "red",
63
- "tablet_landscape_sidebar_width": "35%",
40
+ "saveArea": true,
64
41
  }
65
42
  }
66
- entry={
67
- Object {
68
- "id": "test",
69
- }
70
- }
71
- isTabletLandscape={false}
43
+ animationType="moveUpComponent"
72
44
  style={
73
45
  Object {
74
- "flex": 1,
75
- "paddingTop": 20,
46
+ "flexDirection": "column",
76
47
  }
77
48
  }
78
- />
49
+ >
50
+ <View
51
+ style={
52
+ Array [
53
+ Object {
54
+ "alignSelf": "center",
55
+ "position": "relative",
56
+ "zIndex": 200,
57
+ },
58
+ Object {
59
+ "aspectRatio": 1.7777777777777777,
60
+ "height": undefined,
61
+ "width": "100%",
62
+ },
63
+ Object {},
64
+ Object {},
65
+ ]
66
+ }
67
+ testID="test-player-container"
68
+ />
69
+ <View
70
+ style={
71
+ Object {
72
+ "flex": 1,
73
+ }
74
+ }
75
+ />
76
+ </View>
79
77
  </RNCSafeAreaView>
80
78
  </RNCSafeAreaProvider>
81
79
  `;
@@ -95,22 +93,19 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
95
93
  <RNCSafeAreaView
96
94
  edges={
97
95
  Object {
98
- "bottom": "additive",
96
+ "bottom": "off",
99
97
  "left": "off",
100
98
  "right": "off",
101
- "top": "off",
99
+ "top": "additive",
102
100
  }
103
101
  }
104
102
  style={
105
103
  Array [
106
- Object {
107
- "flexDirection": "column",
108
- },
109
104
  Object {
110
105
  "backgroundColor": "transparent",
111
106
  },
112
107
  Object {
113
- "height": 50,
108
+ "height": undefined,
114
109
  "width": 300,
115
110
  },
116
111
  Object {},
@@ -118,32 +113,45 @@ exports[`PlayerWrapper renders inline and docked 1`] = `
118
113
  }
119
114
  >
120
115
  <View
121
- style={
122
- Array [
123
- Object {
124
- "alignSelf": "center",
125
- "position": "relative",
126
- "zIndex": 200,
127
- },
128
- Object {
129
- "aspectRatio": undefined,
130
- "height": 50,
131
- "width": "100%",
132
- },
133
- Object {},
134
- Object {},
135
- ]
116
+ additionalData={
117
+ Object {
118
+ "saveArea": true,
119
+ }
136
120
  }
137
- testID="test-player-container"
138
- />
139
- <View
121
+ animationType="moveUpComponent"
140
122
  style={
141
123
  Object {
142
- "flex": 1,
143
- "paddingTop": 20,
124
+ "flexDirection": "column",
144
125
  }
145
126
  }
146
- />
127
+ >
128
+ <View
129
+ style={
130
+ Array [
131
+ Object {
132
+ "alignSelf": "center",
133
+ "position": "relative",
134
+ "zIndex": 200,
135
+ },
136
+ Object {
137
+ "aspectRatio": undefined,
138
+ "height": undefined,
139
+ "width": "100%",
140
+ },
141
+ Object {},
142
+ Object {},
143
+ ]
144
+ }
145
+ testID="test-player-container"
146
+ />
147
+ <View
148
+ style={
149
+ Object {
150
+ "flex": 1,
151
+ }
152
+ }
153
+ />
154
+ </View>
147
155
  </RNCSafeAreaView>
148
156
  </RNCSafeAreaProvider>
149
157
  `;
@@ -171,9 +179,6 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
171
179
  }
172
180
  style={
173
181
  Array [
174
- Object {
175
- "flexDirection": "row",
176
- },
177
182
  Object {
178
183
  "backgroundColor": "red",
179
184
  },
@@ -186,44 +191,61 @@ exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
186
191
  }
187
192
  >
188
193
  <View
189
- style={
190
- Array [
191
- Object {
192
- "alignSelf": "center",
193
- "position": "relative",
194
- "zIndex": 200,
195
- },
196
- Object {
197
- "aspectRatio": 1.7777777777777777,
198
- "height": undefined,
199
- "width": 195,
200
- },
201
- Object {},
202
- Object {},
203
- ]
204
- }
205
- testID="test-player-container"
206
- />
207
- <View
208
- configuration={
209
- Object {
210
- "tablet_landscape_player_container_background_color": "red",
211
- "tablet_landscape_sidebar_width": "35%",
212
- }
213
- }
214
- entry={
194
+ additionalData={
215
195
  Object {
216
- "id": "test",
196
+ "saveArea": true,
217
197
  }
218
198
  }
219
- isTabletLandscape={true}
199
+ animationType="moveUpComponent"
220
200
  style={
221
201
  Object {
222
- "flex": 1,
223
- "paddingTop": 20,
202
+ "flexDirection": "row",
224
203
  }
225
204
  }
226
- />
205
+ >
206
+ <View
207
+ style={
208
+ Array [
209
+ Object {
210
+ "alignSelf": "center",
211
+ "position": "relative",
212
+ "zIndex": 200,
213
+ },
214
+ Object {
215
+ "aspectRatio": 1.7777777777777777,
216
+ "height": undefined,
217
+ "width": 195,
218
+ },
219
+ Object {},
220
+ Object {},
221
+ ]
222
+ }
223
+ testID="test-player-container"
224
+ >
225
+ <View
226
+ additionalData={
227
+ Object {
228
+ "disableAnimatedComponent": false,
229
+ "resetAnimationValue": undefined,
230
+ "useLayoutMeasure": true,
231
+ }
232
+ }
233
+ animationType="moveUpComponent"
234
+ style={
235
+ Object {
236
+ "flex": 1,
237
+ }
238
+ }
239
+ />
240
+ </View>
241
+ <View
242
+ style={
243
+ Object {
244
+ "flex": 1,
245
+ }
246
+ }
247
+ />
248
+ </View>
227
249
  </RNCSafeAreaView>
228
250
  </RNCSafeAreaProvider>
229
251
  `;
@@ -251,9 +273,6 @@ exports[`PlayerWrapper renders properly 1`] = `
251
273
  }
252
274
  style={
253
275
  Array [
254
- Object {
255
- "flexDirection": "column",
256
- },
257
276
  Object {
258
277
  "backgroundColor": "transparent",
259
278
  },
@@ -266,32 +285,45 @@ exports[`PlayerWrapper renders properly 1`] = `
266
285
  }
267
286
  >
268
287
  <View
269
- style={
270
- Array [
271
- Object {
272
- "alignSelf": "center",
273
- "position": "relative",
274
- "zIndex": 200,
275
- },
276
- Object {
277
- "aspectRatio": 1.7786666666666666,
278
- "height": undefined,
279
- "width": "100%",
280
- },
281
- Object {},
282
- Object {},
283
- ]
288
+ additionalData={
289
+ Object {
290
+ "saveArea": true,
291
+ }
284
292
  }
285
- testID="test-player-container"
286
- />
287
- <View
293
+ animationType="moveUpComponent"
288
294
  style={
289
295
  Object {
290
- "flex": 1,
291
- "paddingTop": 20,
296
+ "flexDirection": "column",
292
297
  }
293
298
  }
294
- />
299
+ >
300
+ <View
301
+ style={
302
+ Array [
303
+ Object {
304
+ "alignSelf": "center",
305
+ "position": "relative",
306
+ "zIndex": 200,
307
+ },
308
+ Object {
309
+ "aspectRatio": 1.7786666666666666,
310
+ "height": undefined,
311
+ "width": "100%",
312
+ },
313
+ Object {},
314
+ Object {},
315
+ ]
316
+ }
317
+ testID="test-player-container"
318
+ />
319
+ <View
320
+ style={
321
+ Object {
322
+ "flex": 1,
323
+ }
324
+ }
325
+ />
326
+ </View>
295
327
  </RNCSafeAreaView>
296
328
  </RNCSafeAreaProvider>
297
329
  `;
@@ -23,18 +23,21 @@ export const useConfiguration = () => {
23
23
  const targetScreenConfiguration = rivers?.[targetScreenId];
24
24
 
25
25
  const pluginConfiguration =
26
- pluginConfigurations[targetScreenConfiguration.type].configuration_json;
26
+ pluginConfigurations[targetScreenConfiguration?.type]?.configuration_json;
27
27
 
28
28
  const playerPluginConfig = playerManager.getPluginConfiguration();
29
29
 
30
30
  const config = R.mergeRight(playerPluginConfig, {
31
- ...targetScreenConfiguration.general,
32
- ...targetScreenConfiguration.styles,
31
+ ...targetScreenConfiguration?.general,
32
+ ...targetScreenConfiguration?.styles,
33
33
  ...pluginConfiguration,
34
34
  });
35
35
 
36
- const { minimised_height, minimised_height_tablet, modal_background_color } =
37
- config;
36
+ const {
37
+ minimised_height = 0,
38
+ minimised_height_tablet = 0,
39
+ modal_background_color,
40
+ } = config;
38
41
 
39
42
  const minimisedHeight = useIsTablet()
40
43
  ? minimised_height_tablet
@@ -6,23 +6,23 @@ import { callOnChildren } from "../utils";
6
6
 
7
7
  export function ViewportTracker(props) {
8
8
  const viewportEvents = useViewportEventsContext();
9
- const { children } = props;
10
- const [width, setWidth] = React.useState(0);
11
- const [height, setHeight] = React.useState(0);
12
- const [offsetX, setOffsetX] = React.useState(0);
13
- const [offsetY, setOffsetY] = React.useState(0);
14
9
  const [nodeHandle, setNodeHandle] = React.useState(null);
15
10
 
16
- const assignRef = React.useCallback(
17
- (ref) => {
18
- callOnChildren(children, "ref", ref);
19
- setNodeHandle(findNodeHandle(ref));
20
- },
21
- [children]
22
- );
11
+ const childrenRef = React.useRef(props.children);
12
+
13
+ const dimensionsRef = React.useRef({ width: 0, height: 0 });
14
+ const offsetRef = React.useRef({ offsetX: 0, offsetY: 0 });
15
+
16
+ const assignRef = React.useCallback((ref) => {
17
+ childrenRef.current?.ref?.(ref);
18
+ setNodeHandle(findNodeHandle(ref));
19
+ }, []);
23
20
 
24
21
  const onViewportChange = React.useCallback(
25
- (event, shouldMeasureLayout = true) => {
22
+ ({
23
+ event = { ...dimensionsRef.current, ...offsetRef.current },
24
+ shouldMeasureLayout = true,
25
+ } = {}) => {
26
26
  if (nodeHandle && event?.width > 0 && event?.height > 0) {
27
27
  viewportEvents?.notify?.({
28
28
  parentHandle: nodeHandle,
@@ -36,54 +36,45 @@ export function ViewportTracker(props) {
36
36
 
37
37
  const onLayout = React.useCallback(
38
38
  (event) => {
39
- callOnChildren(children, "onLayout", event);
40
- setWidth(event?.nativeEvent?.layout?.width);
41
- setHeight(event?.nativeEvent?.layout?.height);
39
+ callOnChildren(childrenRef.current, "onLayout", event);
40
+ dimensionsRef.current = event?.nativeEvent?.layout;
42
41
 
43
- onViewportChange({
44
- width: event?.nativeEvent?.layout?.width,
45
- height: event?.nativeEvent?.layout?.height,
46
- offsetX,
47
- offsetY,
48
- });
42
+ onViewportChange();
49
43
  },
50
- [offsetX, offsetY, children, onViewportChange]
44
+ [onViewportChange]
51
45
  );
52
46
 
53
47
  const onContentSizeChange = React.useCallback(
54
48
  (contentWidth, contentHeight) => {
55
49
  callOnChildren(
56
- children,
50
+ childrenRef.current,
57
51
  "onContentSizeChange",
58
52
  contentWidth,
59
53
  contentHeight
60
54
  );
61
55
 
62
- onViewportChange({ width, height, offsetX, offsetY });
56
+ onViewportChange();
63
57
  },
64
- [onViewportChange, children, width, height, offsetX, offsetY]
58
+ [onViewportChange]
65
59
  );
66
60
 
67
61
  const onScroll = React.useCallback(
68
62
  (event) => {
69
- callOnChildren(children, "onScroll", event);
70
- setOffsetX(event?.nativeEvent?.contentOffset?.x);
71
- setOffsetY(event?.nativeEvent?.contentOffset?.y);
63
+ callOnChildren(childrenRef.current, "onScroll", event);
64
+ offsetRef.current = event?.nativeEvent?.contentOffset;
72
65
 
73
- onViewportChange(
74
- {
75
- width,
76
- height,
77
- offsetX: event?.nativeEvent?.contentOffset?.x,
78
- offsetY: event?.nativeEvent?.contentOffset?.y,
79
- },
80
- false
81
- );
66
+ onViewportChange({
67
+ shouldMeasureLayout: false,
68
+ });
82
69
  },
83
- [onViewportChange, width, height, children]
70
+ [onViewportChange]
84
71
  );
85
72
 
86
- return React.cloneElement(React.Children.only(children), {
73
+ React.useEffect(() => {
74
+ childrenRef.current = props.children;
75
+ }, [props.children]);
76
+
77
+ return React.cloneElement(React.Children.only(props.children), {
87
78
  ref: assignRef,
88
79
  onLayout,
89
80
  onContentSizeChange,
@@ -6,6 +6,7 @@ import { ViewportEventContext, ViewportEvents } from "../ViewportEvents";
6
6
  type Props = {
7
7
  viewportEventsManager?: any;
8
8
  children: React.ReactNode;
9
+ flatListRef?: any; // this ref is used to bind to children component
9
10
  };
10
11
 
11
12
  export function ViewportTracker(props: Props) {
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
 
3
3
  export function callOnChildren(children, method, ...args) {
4
4
  const childMethod = React.Children.only(children).props[method];
5
- childMethod && childMethod(...args);
5
+ typeof childMethod === "function" && childMethod?.(...args);
6
6
  }
7
7
 
8
8
  export function isInViewport(
@@ -1,4 +1,5 @@
1
1
  import { createContext } from "@applicaster/zapp-react-native-utils/reactUtils/createContext";
2
+ import React from "react";
2
3
 
3
4
  const initialContext = { toggleMenu: {}, closeMenu: {}, openMenu: {} };
4
5
 
@@ -16,3 +17,18 @@ const stateValidator = ({ property }) =>
16
17
  property === "openMenu";
17
18
 
18
19
  export const MenuToggleContext = createContext(initialContext, stateValidator);
20
+
21
+ export type MenuToggleContextType = {
22
+ toggleMenu: any;
23
+ setToggleMenu: () => void;
24
+ openMenu: any;
25
+ setOpenMenu: () => void;
26
+ closeMenu: any;
27
+ setCloseMenu: () => void;
28
+ };
29
+
30
+ export const useMenuToggleContext = () => {
31
+ return React.useContext<MenuToggleContextType>(
32
+ MenuToggleContext.ReactContext
33
+ );
34
+ };
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ScreenContext withScreenContext should return the context 1`] = `null`;
@@ -0,0 +1,27 @@
1
+ import { render } from "@testing-library/react-native";
2
+ import { ScreenContext, ScreenContextProvider, withScreenContext } from "../";
3
+ import React from "react";
4
+
5
+ describe("ScreenContext", () => {
6
+ describe("ScreneContext context", () => {
7
+ it("should return the context", () => {
8
+ expect(ScreenContext).toBeDefined();
9
+ });
10
+ });
11
+
12
+ describe("ScreenContextProvider", () => {
13
+ it("should return the provider", () => {
14
+ expect(ScreenContextProvider).toBeDefined();
15
+ });
16
+ });
17
+
18
+ describe("withScreenContext", () => {
19
+ it("should return the context", () => {
20
+ const Component = () => null;
21
+ const WrappedComponent = withScreenContext(Component);
22
+ const { toJSON } = render(<WrappedComponent />);
23
+
24
+ expect(toJSON()).toMatchSnapshot();
25
+ });
26
+ });
27
+ });