@applicaster/zapp-react-native-ui-components 14.0.0-alpha.1308901965 → 14.0.0-alpha.1310732876

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 (105) 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/BaseFocusable/index.tsx +23 -12
  5. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  6. package/Components/Cell/index.js +1 -1
  7. package/Components/ComponentResolver/index.ts +1 -1
  8. package/Components/FeedLoader/FeedLoader.tsx +6 -15
  9. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  10. package/Components/FeedLoader/index.js +2 -8
  11. package/Components/Focusable/Focusable.tsx +5 -3
  12. package/Components/Focusable/FocusableTvOS.tsx +3 -3
  13. package/Components/Focusable/FocusableiOS.tsx +2 -2
  14. package/Components/Focusable/index.tsx +1 -1
  15. package/Components/FocusableList/index.tsx +4 -0
  16. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  17. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
  18. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +13 -10
  19. package/Components/HandlePlayable/HandlePlayable.tsx +25 -9
  20. package/Components/Layout/TV/LayoutBackground.tsx +1 -1
  21. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  22. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  23. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
  24. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -27
  25. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
  26. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
  27. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  28. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  29. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  30. package/Components/MasterCell/elementMapper.tsx +1 -2
  31. package/Components/MasterCell/utils/behaviorProvider.ts +2 -2
  32. package/Components/MasterCell/utils/index.ts +1 -15
  33. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
  34. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
  35. package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
  36. package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
  37. package/Components/PlayerContainer/PlayerContainer.tsx +41 -28
  38. package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
  39. package/Components/PlayerContainer/index.ts +1 -1
  40. package/Components/River/ComponentsMap/ComponentsMap.tsx +0 -1
  41. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
  42. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
  43. package/Components/River/RefreshControl.tsx +11 -17
  44. package/Components/River/TV/River.tsx +2 -17
  45. package/Components/River/TV/index.tsx +3 -1
  46. package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
  47. package/Components/River/TV/withRiverDataLoader.tsx +17 -0
  48. package/Components/River/TV/withTVEventHandler.tsx +1 -1
  49. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  50. package/Components/River/__tests__/river.test.js +12 -26
  51. package/Components/River/index.tsx +1 -1
  52. package/Components/Screen/__tests__/Screen.test.tsx +28 -29
  53. package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
  54. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
  55. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
  56. package/Components/ScreenRevealManager/index.ts +1 -0
  57. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +79 -0
  58. package/Components/Tabs/TV/Tabs.android.tsx +0 -2
  59. package/Components/Tabs/Tabs.tsx +2 -3
  60. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
  61. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  62. package/Components/Transitioner/Scene.tsx +0 -1
  63. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
  64. package/Components/VideoLive/animationUtils.ts +3 -3
  65. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +3 -9
  66. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +32 -8
  67. package/Components/VideoModal/PlayerDetails.tsx +24 -2
  68. package/Components/VideoModal/PlayerWrapper.tsx +26 -142
  69. package/Components/VideoModal/VideoModal.tsx +3 -17
  70. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  71. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
  72. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
  73. package/Components/VideoModal/hooks/index.ts +0 -2
  74. package/Components/VideoModal/hooks/useModalSize.ts +18 -2
  75. package/Components/VideoModal/utils.ts +6 -0
  76. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
  77. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
  78. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  79. package/Contexts/ScreenContext/index.tsx +46 -6
  80. package/Contexts/ScreenDataContext/index.tsx +0 -2
  81. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  82. package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
  83. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  84. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  85. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  86. package/Decorators/RiverFeedLoader/index.tsx +21 -9
  87. package/Decorators/RiverFeedLoader/utils/index.ts +0 -23
  88. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
  89. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
  90. package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
  91. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
  92. package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
  93. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
  94. package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
  95. package/Decorators/ZappPipesDataConnector/index.tsx +27 -312
  96. package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
  97. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
  98. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
  99. package/Decorators/ZappPipesDataConnector/types.ts +29 -0
  100. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
  101. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
  102. package/events/index.ts +1 -0
  103. package/package.json +5 -10
  104. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
  105. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
@@ -192,20 +192,6 @@ export const getFocusedButtonId = (focusable) => {
192
192
  });
193
193
  };
194
194
 
195
- export const isSelected = ({
196
- item,
197
- screenRoute,
198
- screenStateStore,
199
- behavior,
200
- }: {
201
- item: ZappEntry;
202
- screenRoute: string;
203
- screenStateStore: ScreenStateStore;
204
- behavior?: Behavior;
205
- }) => {
206
- return isCellSelected({ item, screenRoute, screenStateStore, behavior });
207
- };
208
-
209
195
  export const useCellState = ({
210
196
  item,
211
197
  behavior,
@@ -221,7 +207,7 @@ export const useCellState = ({
221
207
 
222
208
  const _isSelected = useMemo(
223
209
  () =>
224
- isSelected({
210
+ isCellSelected({
225
211
  item,
226
212
  screenRoute: router?.pathname,
227
213
  screenStateStore,
@@ -1,9 +1,12 @@
1
1
  import React from "react";
2
2
  import { Text, Animated } from "react-native";
3
+ import { render } from "@testing-library/react-native";
3
4
 
4
- import renderer from "react-test-renderer";
5
-
6
- jest.useFakeTimers();
5
+ import {
6
+ NotificationView,
7
+ onlinePhrase,
8
+ offlinePhrase,
9
+ } from "../NotificationView";
7
10
 
8
11
  jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
9
12
  usePickFromState: () => ({
@@ -32,39 +35,31 @@ jest.mock("react-native-safe-area-context", () => ({
32
35
 
33
36
  const dismiss = jest.fn();
34
37
 
35
- const {
36
- NotificationView,
37
- onlinePhrase,
38
- offlinePhrase,
39
- } = require("../NotificationView");
40
-
41
38
  describe("NotificationView", () => {
42
39
  it("Show online message when Online", () => {
43
- const component = renderer.create(
44
- <NotificationView online dismiss={dismiss} />
45
- );
40
+ const component = render(<NotificationView online dismiss={dismiss} />);
46
41
 
47
- expect(component.root.findByType(Text).props.children).toBe(onlinePhrase);
42
+ expect(component.UNSAFE_getByType(Text).props.children).toBe(onlinePhrase);
48
43
  });
49
44
 
50
45
  it("Show offline message when Online", () => {
51
- const component = renderer.create(
46
+ const component = render(
52
47
  <NotificationView online={false} dismiss={dismiss} />
53
48
  );
54
49
 
55
- expect(component.root.findByType(Text).props.children).toBe(offlinePhrase);
50
+ expect(component.UNSAFE_getByType(Text).props.children).toBe(offlinePhrase);
56
51
  });
57
52
 
58
53
  it("When hidden is false to true notification is visible", () => {
59
- const component = renderer.create(
54
+ const component = render(
60
55
  <NotificationView online={false} hidden={false} dismiss={dismiss} />
61
56
  );
62
57
 
63
- component.update(
58
+ component.rerender(
64
59
  <NotificationView online={false} hidden={true} dismiss={dismiss} />
65
60
  );
66
61
 
67
- const animatedView = component.root.findByType(Animated.View);
62
+ const animatedView = component.UNSAFE_getByType(Animated.View);
68
63
  const animatedViewStyles = animatedView.props.style;
69
64
 
70
65
  expect(animatedViewStyles.opacity).toBe(1);
@@ -21,6 +21,15 @@ exports[`OfflineHandler renders 1`] = `
21
21
  }
22
22
  >
23
23
  <View
24
+ accessibilityState={
25
+ {
26
+ "busy": undefined,
27
+ "checked": undefined,
28
+ "disabled": undefined,
29
+ "expanded": undefined,
30
+ "selected": undefined,
31
+ }
32
+ }
24
33
  accessible={true}
25
34
  collapsable={false}
26
35
  focusable={true}
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
-
3
- import renderer, { act } from "react-test-renderer";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  jest.useFakeTimers({ legacyFakeTimers: true });
6
5
 
@@ -19,29 +18,27 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/utils", () => {
19
18
  };
20
19
  });
21
20
 
22
- jest.mock(
23
- "@applicaster/zapp-react-native-redux/hooks/usePickFromState",
24
- () => ({
25
- usePickFromState: () => ({
26
- plugins: [
27
- {
28
- name: "offline experience",
29
- identifier: "offline-experience",
30
- type: "general",
31
- module: {
32
- useOfflineExperienceConfiguration: () => ({
33
- configurationFields: {},
34
- localizations: {
35
- offline_toast_message: "No internet connection",
36
- online_toast_message: "You are back online",
37
- },
38
- }),
39
- },
21
+ jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
22
+ ...jest.requireActual("@applicaster/zapp-react-native-redux/hooks"),
23
+ usePickFromState: () => ({
24
+ plugins: [
25
+ {
26
+ name: "offline experience",
27
+ identifier: "offline-experience",
28
+ type: "general",
29
+ module: {
30
+ useOfflineExperienceConfiguration: () => ({
31
+ configurationFields: {},
32
+ localizations: {
33
+ offline_toast_message: "No internet connection",
34
+ online_toast_message: "You are back online",
35
+ },
36
+ }),
40
37
  },
41
- ],
42
- }),
43
- })
44
- );
38
+ },
39
+ ],
40
+ }),
41
+ }));
45
42
 
46
43
  jest.mock("react-native-safe-area-context", () => ({
47
44
  useSafeAreaInsets: () => ({ top: 44 }),
@@ -51,24 +48,18 @@ describe("OfflineHandler", () => {
51
48
  const { OfflineHandler, NotificationView } = require("../");
52
49
 
53
50
  it("renders", () => {
54
- const instance = renderer.create(<OfflineHandler />);
55
- expect(instance.toJSON()).toMatchSnapshot();
51
+ const { toJSON } = render(<OfflineHandler />);
52
+ expect(toJSON()).toMatchSnapshot();
56
53
  });
57
54
 
58
55
  it("renders Notification mode if component was rendered while online", () => {
59
56
  mockConnectionStatus = true;
60
57
 
61
- let instance;
62
-
63
- act(() => {
64
- instance = renderer.create(<OfflineHandler />);
65
- });
58
+ const { rerender, UNSAFE_getByType } = render(<OfflineHandler />);
66
59
 
67
- act(() => {
68
- instance.update(<OfflineHandler />);
69
- });
60
+ rerender(<OfflineHandler />);
70
61
 
71
- const notificationsView = instance.root.findByType(NotificationView);
62
+ const notificationsView = UNSAFE_getByType(NotificationView);
72
63
  expect(notificationsView).toBeDefined();
73
64
  });
74
65
  });
@@ -1,6 +1,6 @@
1
1
  import * as R from "ramda";
2
2
 
3
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
3
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
4
4
 
5
5
  import { ErrorDisplayComponent } from "./ErrorDisplay";
6
6
 
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { useEffect, useReducer } from "react";
3
- // @ts-ignore
4
- import { TVMenuControl, View, ViewStyle } from "react-native";
3
+ import { View, ViewStyle } from "react-native";
5
4
  import * as R from "ramda";
6
5
  import uuid from "uuid/v4";
7
6
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils/playerManager";
@@ -62,6 +61,11 @@ import {
62
61
  useModalAnimationContext,
63
62
  } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
64
63
 
64
+ import {
65
+ PlayerNativeCommandTypes,
66
+ PlayerNativeSendCommand,
67
+ } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/playerNativeCommand";
68
+
65
69
  type Props = {
66
70
  Player: React.ComponentType<any>;
67
71
  PlayerLoadingView?: React.ComponentType<any>; // 👀 we are not receiving this prop
@@ -88,7 +92,7 @@ export const VideoModalMode = {
88
92
  MAXIMIZED: "MAXIMIZED",
89
93
  MINIMIZED: "MINIMIZED",
90
94
  FULLSCREEN: "FULLSCREEN",
91
- };
95
+ } as const;
92
96
 
93
97
  export type PlayNextData = {
94
98
  state: PlayNextState;
@@ -127,7 +131,7 @@ const webStyles = {
127
131
  playerScreen: {
128
132
  flex: 1,
129
133
  height: "100vh",
130
- background: "black",
134
+ backgroundColor: "black",
131
135
  },
132
136
  playerWrapper: {
133
137
  height: "100%",
@@ -145,7 +149,6 @@ const nativeStyles = {
145
149
  },
146
150
  playerScreen: {
147
151
  flex: 1,
148
- backgroundColor: "black",
149
152
  overflow: "hidden",
150
153
  },
151
154
  playerWrapper: {
@@ -260,9 +263,15 @@ const PlayerContainerComponent = (props: Props) => {
260
263
  return;
261
264
  }
262
265
 
266
+ // send command to clear and stop player
267
+ PlayerNativeSendCommand(
268
+ PlayerNativeCommandTypes.clearPlayerData,
269
+ state.playerId
270
+ );
271
+
263
272
  showNavBar(true);
264
273
  navigator.goBack();
265
- }, [isModal, navigator.goBack, showNavBar]);
274
+ }, [isModal, navigator.goBack, state.playerId, showNavBar]);
266
275
 
267
276
  const playEntry = (entry) => navigator.replaceTop(entry, { mode });
268
277
 
@@ -390,13 +399,17 @@ const PlayerContainerComponent = (props: Props) => {
390
399
  }
391
400
  };
392
401
 
393
- const playerRemoteHandler = (event, isLanguageOverlayVisible) => {
394
- const { eventType } = event;
402
+ const playerRemoteHandler = React.useCallback(
403
+ (isLanguageOverlayVisible = false) =>
404
+ (event) => {
405
+ const { eventType } = event;
395
406
 
396
- if (!isLanguageOverlayVisible && eventType === "menu") {
397
- close();
398
- }
399
- };
407
+ if (!isLanguageOverlayVisible && eventType === "menu") {
408
+ close();
409
+ }
410
+ },
411
+ [close]
412
+ );
400
413
 
401
414
  // Effects
402
415
  useEffect(() => {
@@ -509,16 +522,6 @@ const PlayerContainerComponent = (props: Props) => {
509
522
  }
510
523
  }, [isAudioContent]);
511
524
 
512
- // Needs to handle back button on Apple TV
513
- // https://github.com/facebook/react-native/issues/18930
514
- useEffect(() => {
515
- TVMenuControl?.enableTVMenuKey();
516
-
517
- return () => {
518
- TVMenuControl?.disableTVMenuKey();
519
- };
520
- }, []);
521
-
522
525
  useEffect(() => {
523
526
  playerEvent("source_changed", { item });
524
527
 
@@ -565,8 +568,9 @@ const PlayerContainerComponent = (props: Props) => {
565
568
  const isInlineTV = isInlineTVUtil(screenData);
566
569
 
567
570
  const inline =
568
- [VideoModalMode.MAXIMIZED, VideoModalMode.MINIMIZED].includes(mode) ||
569
- isInlineTV;
571
+ [VideoModalMode.MAXIMIZED, VideoModalMode.MINIMIZED].includes(
572
+ mode as any
573
+ ) || isInlineTV;
570
574
 
571
575
  const value = React.useMemo(
572
576
  () => ({ playerId: state.playerId }),
@@ -587,7 +591,11 @@ const PlayerContainerComponent = (props: Props) => {
587
591
  );
588
592
  }
589
593
 
590
- if (screen_background_color && mode !== VideoModalMode.FULLSCREEN) {
594
+ if (
595
+ screen_background_color &&
596
+ mode !== VideoModalMode.FULLSCREEN &&
597
+ isTV()
598
+ ) {
591
599
  updatedStyles.playerScreen.backgroundColor = screen_background_color;
592
600
  }
593
601
 
@@ -617,6 +625,8 @@ const PlayerContainerComponent = (props: Props) => {
617
625
  playNextData,
618
626
  };
619
627
 
628
+ const pointerEventsProp = mode === "MINIMIZED" ? "box-none" : "auto";
629
+
620
630
  return (
621
631
  <PlayerStateContext.Provider value={value}>
622
632
  <PlayerContainerContextProvider
@@ -627,9 +637,9 @@ const PlayerContainerComponent = (props: Props) => {
627
637
  <PlayerContainerContext.Consumer>
628
638
  {(context) => (
629
639
  <TVEventHandlerComponent
630
- tvEventHandler={(_component, event) =>
631
- playerRemoteHandler(event, context.isLanguageOverlayVisible)
632
- }
640
+ tvEventHandler={playerRemoteHandler(
641
+ context.isLanguageOverlayVisible
642
+ )}
633
643
  >
634
644
  <FocusableGroup
635
645
  id={FocusableGroupMainContainerId}
@@ -637,14 +647,17 @@ const PlayerContainerComponent = (props: Props) => {
637
647
  preferredFocus
638
648
  shouldUsePreferredFocus
639
649
  groupId={groupId}
650
+ pointerEvents={pointerEventsProp}
640
651
  >
641
652
  {/* Video player and components */}
642
653
  <View
643
654
  style={styles.playerScreen}
644
655
  testID={"player-screen-container"}
656
+ pointerEvents={pointerEventsProp}
645
657
  >
646
658
  {/* Player container */}
647
659
  <View
660
+ pointerEvents={pointerEventsProp}
648
661
  style={[
649
662
  styles.playerWrapper,
650
663
  // eslint-disable-next-line react-native/no-inline-styles, react-native/no-color-literals
@@ -1,4 +1,4 @@
1
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
1
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
2
2
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
3
3
  import { styleKeys } from "@applicaster/zapp-react-native-utils/styleKeysUtils";
4
4
  import { transformColorCode as fixColorHexCode } from "@applicaster/zapp-react-native-utils/transform";
@@ -1,6 +1,6 @@
1
1
  import * as R from "ramda";
2
2
 
3
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
3
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
4
4
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
5
5
 
6
6
  import { PlayerContainer as PlayerContainerComponent } from "./PlayerContainer";
@@ -286,7 +286,6 @@ function ComponentsMapComponent(props: Props) {
286
286
  initialNumToRender={3}
287
287
  maxToRenderPerBatch={10}
288
288
  windowSize={12}
289
- listKey={riverId}
290
289
  keyExtractor={keyExtractor}
291
290
  renderItem={renderRiverItem}
292
291
  data={riverComponents}