@applicaster/zapp-react-native-ui-components 14.0.0-rc.9 → 15.0.0-alpha.2239032089

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 (166) hide show
  1. package/Components/AnimatedInOut/index.tsx +5 -3
  2. package/Components/AudioPlayer/index.tsx +15 -0
  3. package/Components/AudioPlayer/mobile/Layout.tsx +66 -0
  4. package/Components/AudioPlayer/{__tests__/__snapshots__/audioPlayer.test.js.snap → mobile/__tests__/__snapshots__/audioPlayerMobileLayout.test.js.snap} +2 -2
  5. package/Components/AudioPlayer/mobile/__tests__/audioPlayerMobileLayout.test.js +18 -0
  6. package/Components/AudioPlayer/mobile/index.tsx +18 -0
  7. package/Components/AudioPlayer/{Artwork.tsx → tv/Artwork.tsx} +3 -2
  8. package/Components/AudioPlayer/{Channel.tsx → tv/Channel.tsx} +7 -7
  9. package/Components/AudioPlayer/tv/Layout.tsx +168 -0
  10. package/Components/AudioPlayer/{Runtime.tsx → tv/Runtime.tsx} +7 -1
  11. package/Components/AudioPlayer/{Summary.tsx → tv/Summary.tsx} +6 -2
  12. package/Components/AudioPlayer/{Title.tsx → tv/Title.tsx} +6 -2
  13. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/Runtime.test.js.snap +2 -2
  14. package/Components/AudioPlayer/tv/__tests__/__snapshots__/audioPlayer.test.js.snap +164 -0
  15. package/Components/AudioPlayer/tv/__tests__/__snapshots__/channel.test.js.snap +19 -0
  16. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/summary.test.js.snap +1 -2
  17. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/title.test.js.snap +1 -2
  18. package/Components/AudioPlayer/{__tests__ → tv/__tests__}/audioPlayer.test.js +7 -3
  19. package/Components/AudioPlayer/{helpers.tsx → tv/helpers.tsx} +11 -5
  20. package/Components/AudioPlayer/{AudioPlayer.tsx → tv/index.tsx} +17 -58
  21. package/Components/AudioPlayer/types.ts +40 -0
  22. package/Components/BaseFocusable/index.tsx +23 -12
  23. package/Components/Cell/Cell.tsx +91 -64
  24. package/Components/Cell/CellWithFocusable.tsx +3 -0
  25. package/Components/Cell/__tests__/CellWIthFocusable.test.js +3 -2
  26. package/Components/Cell/index.js +7 -3
  27. package/Components/ComponentResolver/index.ts +1 -1
  28. package/Components/FeedLoader/FeedLoader.tsx +7 -16
  29. package/Components/FeedLoader/FeedLoaderHOC.tsx +21 -0
  30. package/Components/FeedLoader/index.js +2 -8
  31. package/Components/Focusable/Focusable.tsx +16 -5
  32. package/Components/Focusable/FocusableTvOS.tsx +10 -6
  33. package/Components/Focusable/FocusableiOS.tsx +2 -2
  34. package/Components/Focusable/Touchable.tsx +5 -3
  35. package/Components/Focusable/__tests__/index.android.test.tsx +3 -0
  36. package/Components/Focusable/index.android.tsx +19 -11
  37. package/Components/Focusable/index.tsx +1 -1
  38. package/Components/FocusableGroup/FocusableTvOS.tsx +6 -1
  39. package/Components/FocusableList/FocusableItem.tsx +4 -3
  40. package/Components/FocusableList/FocusableListItemWrapper.tsx +2 -1
  41. package/Components/FocusableList/hooks/useCellState.android.ts +13 -3
  42. package/Components/FocusableList/index.tsx +20 -9
  43. package/Components/FreezeWithCallback/__tests__/index.test.tsx +67 -43
  44. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +42 -59
  45. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +13 -10
  46. package/Components/HandlePlayable/HandlePlayable.tsx +25 -9
  47. package/Components/HookRenderer/HookRenderer.tsx +5 -1
  48. package/Components/Layout/TV/LayoutBackground.tsx +1 -1
  49. package/Components/Layout/TV/__tests__/index.test.tsx +0 -1
  50. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +6 -2
  51. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -1
  52. package/Components/MasterCell/DefaultComponents/FocusableView/index.tsx +4 -39
  53. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +1 -1
  54. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +1 -1
  55. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +65 -17
  56. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/Image.test.tsx +21 -3
  57. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +6 -3
  58. package/Components/MasterCell/DefaultComponents/Text/index.tsx +26 -6
  59. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +10 -10
  60. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +18 -18
  61. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/index.test.tsx +10 -10
  62. package/Components/MasterCell/elementMapper.tsx +1 -2
  63. package/Components/MasterCell/index.tsx +1 -1
  64. package/Components/MasterCell/utils/behaviorProvider.ts +82 -14
  65. package/Components/MasterCell/utils/index.ts +11 -5
  66. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +13 -18
  67. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +9 -0
  68. package/Components/OfflineHandler/__tests__/index.test.tsx +26 -35
  69. package/Components/PlayerContainer/ErrorDisplay/index.ts +1 -1
  70. package/Components/PlayerContainer/PlayerContainer.tsx +46 -33
  71. package/Components/PlayerContainer/ProgramInfo/index.tsx +1 -1
  72. package/Components/PlayerContainer/index.ts +1 -1
  73. package/Components/PlayerImageBackground/index.tsx +1 -1
  74. package/Components/River/ComponentsMap/ComponentsMap.tsx +49 -43
  75. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapHeightContext.ts +8 -0
  76. package/Components/River/ComponentsMap/ContextProviders/ComponentsMapRefContext.ts +8 -0
  77. package/Components/River/ComponentsMap/hooks/__tests__/useLoadingState.test.ts +378 -0
  78. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +2 -2
  79. package/Components/River/RefreshControl.tsx +11 -17
  80. package/Components/River/RiverItem.tsx +3 -0
  81. package/Components/River/TV/River.tsx +11 -20
  82. package/Components/River/TV/index.tsx +5 -3
  83. package/Components/River/TV/withFocusableGroupForContent.tsx +60 -0
  84. package/Components/River/TV/withPipesV1DataLoader.tsx +43 -0
  85. package/Components/River/TV/withRiverDataLoader.tsx +17 -0
  86. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +2 -0
  87. package/Components/River/__tests__/river.test.js +12 -26
  88. package/Components/River/index.tsx +1 -1
  89. package/Components/Screen/__tests__/Screen.test.tsx +28 -29
  90. package/Components/Screen/__tests__/navigationHandler.test.ts +133 -22
  91. package/Components/Screen/navigationHandler.ts +20 -2
  92. package/Components/ScreenResolver/index.tsx +15 -0
  93. package/Components/ScreenRevealManager/ScreenRevealManager.ts +76 -0
  94. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +107 -0
  95. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +96 -0
  96. package/Components/ScreenRevealManager/index.ts +1 -0
  97. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +79 -0
  98. package/Components/Tabs/TV/Tabs.android.tsx +1 -3
  99. package/Components/Tabs/Tabs.tsx +2 -3
  100. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +13 -0
  101. package/Components/TextInputTv/index.tsx +11 -0
  102. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +34 -0
  103. package/Components/Touchable/__tests__/touchable.test.tsx +12 -17
  104. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +15 -9
  105. package/Components/VideoLive/animationUtils.ts +3 -3
  106. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +6 -10
  107. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.web.tsx +294 -0
  108. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.web.tsx +93 -0
  109. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +73 -29
  110. package/Components/VideoModal/PlayerDetails.tsx +29 -7
  111. package/Components/VideoModal/PlayerWrapper.tsx +26 -142
  112. package/Components/VideoModal/VideoModal.tsx +3 -17
  113. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -5
  114. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -7
  115. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +44 -240
  116. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +9 -1
  117. package/Components/VideoModal/hooks/index.ts +0 -2
  118. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +40 -15
  119. package/Components/VideoModal/hooks/useModalSize.ts +18 -2
  120. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +2 -2
  121. package/Components/VideoModal/hooks/utils/index.ts +4 -0
  122. package/Components/VideoModal/utils.ts +6 -0
  123. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -16
  124. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +84 -24
  125. package/Components/Viewport/VisibilitySensor/VisibilitySensor.tsx +3 -3
  126. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/index.ts +3 -3
  127. package/Contexts/CellFocusedStateContext/index.tsx +27 -0
  128. package/Contexts/ConfigutaionContext/__tests__/ConfigurationProvider.test.tsx +3 -3
  129. package/Contexts/ScreenContext/index.tsx +46 -6
  130. package/Decorators/ConfigurationWrapper/__tests__/withConfigurationProvider.test.tsx +3 -3
  131. package/Decorators/ConfigurationWrapper/withConfigurationProvider.tsx +2 -2
  132. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +221 -209
  133. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +14 -16
  134. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -20
  135. package/Decorators/RiverFeedLoader/index.tsx +22 -4
  136. package/Decorators/RiverFeedLoader/utils/index.ts +0 -18
  137. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +3 -6
  138. package/Decorators/ZappPipesDataConnector/ResolverSelector.tsx +25 -0
  139. package/Decorators/ZappPipesDataConnector/__tests__/NullFeedResolver.test.tsx +78 -0
  140. package/Decorators/ZappPipesDataConnector/__tests__/ResolverSelector.test.tsx +205 -0
  141. package/Decorators/ZappPipesDataConnector/__tests__/StaticFeedResolver.test.tsx +251 -0
  142. package/Decorators/ZappPipesDataConnector/__tests__/UrlFeedResolver.test.tsx +368 -0
  143. package/Decorators/ZappPipesDataConnector/__tests__/utils.test.ts +39 -0
  144. package/Decorators/ZappPipesDataConnector/index.tsx +26 -293
  145. package/Decorators/ZappPipesDataConnector/resolvers/NullFeedResolver.tsx +25 -0
  146. package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +87 -0
  147. package/Decorators/ZappPipesDataConnector/resolvers/UrlFeedResolver.tsx +266 -0
  148. package/Decorators/ZappPipesDataConnector/types.ts +29 -0
  149. package/Decorators/ZappPipesDataConnector/utils/mongoFilter.ts +738 -0
  150. package/Decorators/ZappPipesDataConnector/utils/useFilter.tsx +157 -0
  151. package/events/index.ts +5 -0
  152. package/package.json +5 -10
  153. package/Components/AudioPlayer/AudioPlayerLayout.tsx +0 -202
  154. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +0 -66
  155. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +0 -28
  156. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +0 -26
  157. package/Components/AudioPlayer/index.ts +0 -1
  158. package/Components/River/TV/withTVEventHandler.tsx +0 -27
  159. package/Components/River/__tests__/__snapshots__/river.test.js.snap +0 -27
  160. package/Components/VideoModal/hooks/useBackgroundColor.ts +0 -10
  161. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/Runtime.test.js +0 -0
  162. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/__snapshots__/artWork.test.js.snap +0 -0
  163. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/artWork.test.js +0 -0
  164. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/channel.test.js +0 -0
  165. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/summary.test.js +0 -0
  166. /package/Components/AudioPlayer/{__tests__ → tv/__tests__}/title.test.js +0 -0
@@ -1,19 +1,18 @@
1
1
  import React, { Dispatch, useEffect, useState } from "react";
2
- import {
3
- act,
4
- create,
5
- ReactTestRenderer,
6
- ReactTestRendererJSON,
7
- } from "react-test-renderer";
2
+ import { act, render } from "@testing-library/react-native";
3
+ import { View } from "react-native";
8
4
  import { FreezeWithCallback } from "../index";
9
5
 
10
- const SimpleContent = () => <div />;
6
+ const SimpleContent = () => <View testID="simple-content" />;
11
7
 
12
8
  interface InnerProps {
13
9
  value: number;
14
10
  }
11
+
15
12
  // eslint-disable-next-line unused-imports/no-unused-vars
16
- const Inner = ({ value }: InnerProps) => <div />;
13
+ const Inner = ({ value }: InnerProps) => (
14
+ <View testID="inner-component" data-value={value} />
15
+ );
17
16
 
18
17
  interface TestSubscriber {
19
18
  renderCount: number;
@@ -51,24 +50,20 @@ const Container = ({ freeze, children }: ContainerProps) => (
51
50
  );
52
51
 
53
52
  function setupTest(initialFreeze: boolean = false) {
54
- let testRenderer: ReactTestRenderer | undefined;
55
53
  const [Subscriber, subscriberState] = createSubscriberComponent();
56
54
 
57
- act(() => {
58
- testRenderer = create(
59
- <Container freeze={initialFreeze}>
60
- <Subscriber />
61
- </Container>
62
- );
63
- });
55
+ const renderResult = render(
56
+ <Container freeze={initialFreeze}>
57
+ <Subscriber />
58
+ </Container>
59
+ );
64
60
 
65
61
  return {
66
- testRenderer,
67
- testInstance: testRenderer?.root,
62
+ renderResult,
68
63
  subscriberState,
69
64
  updateFreeze: (freeze: boolean) => {
70
65
  act(() =>
71
- testRenderer?.update(
66
+ renderResult.rerender(
72
67
  <Container freeze={freeze}>
73
68
  <Subscriber />
74
69
  </Container>
@@ -80,91 +75,120 @@ function setupTest(initialFreeze: boolean = false) {
80
75
 
81
76
  describe("FreezeWithCallback", () => {
82
77
  test("Renders stuff not frozen", () => {
83
- const testRenderer = create(
78
+ const { getByTestId } = render(
84
79
  <Container freeze={false}>
85
80
  <SimpleContent />
86
81
  </Container>
87
82
  );
88
83
 
89
- expect(testRenderer.root.findByType(SimpleContent)).toBeTruthy();
84
+ expect(getByTestId("simple-content")).toBeTruthy();
90
85
  });
91
86
 
92
87
  test("Does not render stuff when frozen", () => {
93
- const testRenderer = create(
88
+ const { queryByTestId } = render(
94
89
  <Container freeze>
95
90
  <SimpleContent />
96
91
  </Container>
97
92
  );
98
93
 
99
- expect(testRenderer.root.findAllByType(SimpleContent)).toHaveLength(0);
94
+ expect(queryByTestId("simple-content")).toBe(null);
100
95
  });
101
96
 
102
97
  test("Stuff is gone after freeze", () => {
103
- const testRenderer = create(
98
+ const { toJSON, getByTestId, rerender } = render(
104
99
  <Container freeze={false}>
105
100
  <SimpleContent />
106
101
  </Container>
107
102
  );
108
103
 
109
- expect(testRenderer.root.findByType(SimpleContent)).toBeTruthy();
104
+ expect(getByTestId("simple-content")).toBeTruthy();
110
105
 
111
106
  act(() =>
112
- testRenderer.update(
107
+ rerender(
113
108
  <Container freeze>
114
109
  <SimpleContent />
115
110
  </Container>
116
111
  )
117
112
  );
118
113
 
119
- expect(testRenderer.toJSON()).toBe(null);
114
+ expect(toJSON()).toBe(null);
120
115
  });
121
116
 
122
117
  test("Updates work when not frozen", () => {
123
- const { testInstance, subscriberState } = setupTest();
118
+ const { renderResult, subscriberState } = setupTest();
119
+
120
+ expect(
121
+ renderResult.getByTestId("inner-component").props["data-value"]
122
+ ).toEqual(0);
124
123
 
125
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
126
124
  act(() => subscriberState.subscription(1));
127
- expect(testInstance?.findByType(Inner).props.value).toEqual(1);
125
+
126
+ expect(
127
+ renderResult.getByTestId("inner-component").props["data-value"]
128
+ ).toEqual(1);
129
+
128
130
  expect(subscriberState.renderCount).toBe(2);
129
131
  });
130
132
 
131
133
  test("Updates does not propagate when frozen", () => {
132
- const { testInstance, subscriberState, updateFreeze } = setupTest();
134
+ const { renderResult, subscriberState, updateFreeze } = setupTest();
135
+
136
+ expect(
137
+ renderResult.getByTestId("inner-component").props["data-value"]
138
+ ).toEqual(0);
133
139
 
134
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
135
140
  updateFreeze(true);
136
141
  act(() => subscriberState.subscription(1));
137
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
142
+
143
+ expect(
144
+ renderResult.getByTestId("inner-component").props["data-value"]
145
+ ).toEqual(0);
146
+
138
147
  expect(subscriberState.renderCount).toBe(1);
139
148
  });
140
149
 
141
150
  test("State persists after defrost", () => {
142
- const { testInstance, subscriberState, updateFreeze, testRenderer } =
143
- setupTest();
151
+ const { renderResult, subscriberState, updateFreeze } = setupTest();
152
+
153
+ expect(
154
+ renderResult.getByTestId("inner-component").props["data-value"]
155
+ ).toEqual(0);
144
156
 
145
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
146
157
  act(() => subscriberState.subscription(1));
147
- expect(testInstance?.findByType(Inner).props.value).toEqual(1);
158
+
159
+ expect(
160
+ renderResult.getByTestId("inner-component").props["data-value"]
161
+ ).toEqual(1);
148
162
 
149
163
  updateFreeze(true);
150
- expect(testRenderer?.toJSON()).toBe(null);
164
+ expect(renderResult.toJSON()).toBe(null);
151
165
 
152
166
  updateFreeze(false);
153
- expect((testRenderer?.toJSON() as ReactTestRendererJSON).type).toBe("div");
154
- expect(testInstance?.findByType(Inner).props.value).toEqual(1);
167
+ expect(renderResult.getByTestId("inner-component")).toBeTruthy();
168
+
169
+ expect(
170
+ renderResult.getByTestId("inner-component").props["data-value"]
171
+ ).toEqual(1);
155
172
  });
156
173
 
157
174
  test("Update propagate after defrost", () => {
158
- const { testInstance, subscriberState, updateFreeze } = setupTest();
175
+ const { renderResult, subscriberState, updateFreeze } = setupTest();
159
176
 
160
177
  updateFreeze(true);
161
178
  act(() => subscriberState.subscription(1));
162
179
  act(() => subscriberState.subscription(2));
163
180
  act(() => subscriberState.subscription(3));
164
- expect(testInstance?.findByType(Inner).props.value).toEqual(0);
181
+
182
+ expect(
183
+ renderResult.getByTestId("inner-component").props["data-value"]
184
+ ).toEqual(0);
165
185
 
166
186
  updateFreeze(false);
167
- expect(testInstance?.findByType(Inner).props.value).toEqual(3);
187
+
188
+ expect(
189
+ renderResult.getByTestId("inner-component").props["data-value"]
190
+ ).toEqual(3);
191
+
168
192
  expect(subscriberState.renderCount).toBe(2);
169
193
  });
170
194
  });
@@ -8,13 +8,10 @@ import {
8
8
  useCurationAPI,
9
9
  } from "../useCurationAPI";
10
10
  import * as redux from "react-redux";
11
- import * as layoutPresets from "@applicaster/zapp-react-native-redux/hooks/useLayoutPresets";
12
- import * as pipesFeeds from "@applicaster/zapp-react-native-redux/hooks/useZappPipesFeeds";
13
11
  import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
14
12
  import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
15
13
 
16
- import { Provider } from "react-redux";
17
- import configureStore from "redux-mock-store";
14
+ import { WrappedWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
18
15
 
19
16
  jest.mock(
20
17
  "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
@@ -42,19 +39,20 @@ const mainStackNavigator = {
42
39
  },
43
40
  };
44
41
 
45
- const store = configureStore()({});
46
-
47
- const wrapper = ({ children }) => (
48
- <Provider store={store}>
49
- <NavigationContext.Provider
50
- value={{ ...mainStackNavigator, currentRoute: homeStack.route }}
51
- >
52
- <PathnameContext.Provider value={homeStack.route}>
53
- {children}
54
- </PathnameContext.Provider>
55
- </NavigationContext.Provider>
56
- </Provider>
57
- );
42
+ const getWrapper =
43
+ (store) =>
44
+ // eslint-disable-next-line react/display-name, react/prop-types
45
+ ({ children }) => (
46
+ <WrappedWithProviders store={store}>
47
+ <NavigationContext.Provider
48
+ value={{ ...mainStackNavigator, currentRoute: homeStack.route }}
49
+ >
50
+ <PathnameContext.Provider value={homeStack.route}>
51
+ {children}
52
+ </PathnameContext.Provider>
53
+ </NavigationContext.Provider>
54
+ </WrappedWithProviders>
55
+ );
58
56
 
59
57
  describe("getTransformedPreset should return the passed components if smartComponents is empty", () => {
60
58
  describe("getTransformedPreset function", () => {
@@ -312,19 +310,10 @@ describe("getTransformedPreset should return the passed components if smartCompo
312
310
  { id: "02", component_type: "not_smart_another" },
313
311
  ];
314
312
 
315
- // mock the hooks
316
- const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
317
- mockUseZappPipesFeeds.mockReturnValue({});
318
-
319
- const mockUseLayoutPresets = jest.spyOn(
320
- layoutPresets,
321
- "useLayoutPresets"
322
- );
323
-
324
- mockUseLayoutPresets.mockReturnValue({});
325
-
326
313
  const { result } = renderHook(() => useCurationAPI(mockComponents), {
327
- wrapper,
314
+ wrapper: getWrapper({
315
+ zappPipes: {},
316
+ }),
328
317
  });
329
318
 
330
319
  // if there are no smart components, it should return the original array
@@ -366,18 +355,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
366
355
  "http://curation": { loading: false, data: { entry: mockPresetEntry } },
367
356
  };
368
357
 
369
- const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
370
- mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
371
-
372
- const mockUseLayoutPresets = jest.spyOn(
373
- layoutPresets,
374
- "useLayoutPresets"
375
- );
376
-
377
- mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
378
-
379
358
  const { result } = renderHook(() => useCurationAPI(mockComponents), {
380
- wrapper,
359
+ wrapper: getWrapper({
360
+ zappPipes: mockFeeds,
361
+ presetsMapping: {
362
+ presets_mappings: {
363
+ ...mockLayoutPresets,
364
+ },
365
+ },
366
+ }),
381
367
  });
382
368
 
383
369
  expect(result.current).toEqual(mockTransformedComponents);
@@ -437,19 +423,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
437
423
  },
438
424
  };
439
425
 
440
- // mock the hooks
441
- const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
442
- mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
443
-
444
- const mockUseLayoutPresets = jest.spyOn(
445
- layoutPresets,
446
- "useLayoutPresets"
447
- );
448
-
449
- mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
450
-
451
426
  const { result } = renderHook(() => useCurationAPI(mockComponents), {
452
- wrapper,
427
+ wrapper: getWrapper({
428
+ zappPipes: mockFeeds,
429
+ presetsMapping: {
430
+ presets_mappings: {
431
+ ...mockLayoutPresets,
432
+ },
433
+ },
434
+ }),
453
435
  });
454
436
 
455
437
  expect(result.current).toEqual(mockTransformedComponents);
@@ -495,14 +477,15 @@ describe("getTransformedPreset should return the passed components if smartCompo
495
477
  "http://curation": { loading: false, data: { entry: mockPresetEntry } },
496
478
  };
497
479
 
498
- // mock the hooks
499
- const mockUseZappPipesFeeds = jest.spyOn(pipesFeeds, "useZappPipesFeeds");
500
- mockUseZappPipesFeeds.mockReturnValue(mockFeeds);
501
- const mockUseLayoutPresets = jest.spyOn(layoutPresets, "useLayoutPresets");
502
- mockUseLayoutPresets.mockReturnValue(mockLayoutPresets);
503
-
504
480
  const { result } = renderHook(() => useCurationAPI(mockComponents), {
505
- wrapper,
481
+ wrapper: getWrapper({
482
+ zappPipes: mockFeeds,
483
+ presetsMapping: {
484
+ presets_mappings: {
485
+ ...mockLayoutPresets,
486
+ },
487
+ },
488
+ }),
506
489
  });
507
490
 
508
491
  expect(result.current).toEqual(mockTransformedComponents);
@@ -1,17 +1,16 @@
1
1
  import { all, equals, path, prop, isEmpty, pluck, values } from "ramda";
2
2
 
3
3
  import { useEffect, useMemo } from "react";
4
- import { useDispatch } from "react-redux";
5
4
 
6
5
  import {
7
6
  useLayoutPresets,
8
- useZappPipesFeeds,
9
- } from "@applicaster/zapp-react-native-redux/hooks";
10
- import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
7
+ useZappPipesFeed,
8
+ } from "@applicaster/zapp-react-native-redux";
11
9
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
12
10
  import { Categories } from "./logger";
13
11
  import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
14
12
  import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
13
+
15
14
  import {
16
15
  ZappPipesEntryContext,
17
16
  ZappPipesScreenContext,
@@ -24,9 +23,13 @@ import {
24
23
  } from "@applicaster/zapp-react-native-utils/reactHooks/feed/useInflatedUrl";
25
24
 
26
25
  import { produce } from "immer";
26
+ import { useLoadPipesDataDispatch } from "@applicaster/zapp-react-native-utils/reactHooks";
27
27
  // types reference
28
28
 
29
- declare type CurationEntry = { preset_name: string; feed_url: string };
29
+ declare interface CurationEntry {
30
+ preset_name: string;
31
+ feed_url: string;
32
+ }
30
33
 
31
34
  type Feeds = Record<string, ZappPipesData>;
32
35
 
@@ -122,8 +125,6 @@ export const getFinalComponents = (
122
125
  export const useCurationAPI = (
123
126
  components: Array<ZappUIComponent>
124
127
  ): ZappUIComponent[] => {
125
- const dispatch = useDispatch();
126
-
127
128
  const smartComponents = useMemo(
128
129
  () => components?.filter?.(isSmartComponent) ?? [],
129
130
  [components]
@@ -159,19 +160,21 @@ export const useCurationAPI = (
159
160
 
160
161
  const urls = useMemo<string[]>(() => Object.values(urlsMap), [urlsMap]);
161
162
 
163
+ const loadPipesDataDispatcher = useLoadPipesDataDispatch();
164
+
162
165
  useEffect(() => {
163
166
  urls.forEach((url, index) => {
164
167
  if (url) {
165
- dispatch(loadPipesData(url, { clearCache: false }));
168
+ loadPipesDataDispatcher(url, { clearCache: false });
166
169
  } else {
167
170
  logger.log_error("Curation url is empty", {
168
171
  componentId: smartComponents?.[index]?.id,
169
172
  });
170
173
  }
171
174
  });
172
- }, [urls]);
175
+ }, [urls, loadPipesDataDispatcher]);
173
176
 
174
- const feeds = useZappPipesFeeds(urls);
177
+ const feeds = useZappPipesFeed(urls);
175
178
  const layoutPresets = useLayoutPresets();
176
179
 
177
180
  const enrichedComponents = useMemo(() => {
@@ -7,12 +7,15 @@ import {
7
7
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
8
8
  import {
9
9
  useDimensions,
10
+ useIsTablet as isTablet,
10
11
  useNavigation,
11
12
  } from "@applicaster/zapp-react-native-utils/reactHooks";
12
13
 
13
14
  import { BufferAnimation } from "../PlayerContainer/BufferAnimation";
14
15
  import { PlayerContainer } from "../PlayerContainer";
15
16
  import { useModalSize } from "../VideoModal/hooks";
17
+ import { ViewStyle } from "react-native";
18
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
16
19
 
17
20
  type Props = {
18
21
  item: ZappEntry;
@@ -83,6 +86,13 @@ type PlayableComponent = {
83
86
  Component: React.ComponentType<any>;
84
87
  };
85
88
 
89
+ const dimensionsContext: "window" | "screen" = platformSelect({
90
+ android_tv: "window",
91
+ amazon: "window",
92
+ // eslint-disable-next-line react-hooks/rules-of-hooks
93
+ default: isTablet() ? "window" : "screen", // on tablet, window represents correct values, on phone it's not as the screen could be rotated
94
+ });
95
+
86
96
  export function HandlePlayable({
87
97
  item,
88
98
  isModal,
@@ -135,19 +145,25 @@ export function HandlePlayable({
135
145
  });
136
146
  }, [casting]);
137
147
 
138
- const { width: screenWidth, height: screenHeight } = useDimensions("window");
148
+ const { width: screenWidth, height: screenHeight } =
149
+ useDimensions(dimensionsContext);
139
150
 
140
151
  const modalSize = useModalSize();
141
152
 
142
153
  const style = React.useMemo(
143
- () => ({
144
- width: isModal ? modalSize.width : mode === "PIP" ? "100%" : screenWidth,
145
- height: isModal
146
- ? modalSize.height
147
- : mode === "PIP"
148
- ? "100%"
149
- : screenHeight,
150
- }),
154
+ () =>
155
+ ({
156
+ width: isModal
157
+ ? modalSize.width
158
+ : mode === "PIP"
159
+ ? "100%"
160
+ : screenWidth,
161
+ height: isModal
162
+ ? modalSize.height
163
+ : mode === "PIP"
164
+ ? "100%"
165
+ : screenHeight,
166
+ }) as ViewStyle,
151
167
  [screenWidth, screenHeight, modalSize, isModal, mode]
152
168
  );
153
169
 
@@ -6,17 +6,20 @@ import {
6
6
  } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
7
7
  import { useHookAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils/helpers/hooks";
8
8
  import { useSetNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks";
9
+ import { PresentationType } from "../ScreenResolver";
9
10
 
10
11
  type Props = {
11
12
  focused?: boolean;
12
13
  parentFocus?: ParentFocus;
13
14
  screenData: HookPluginProps;
15
+ callback: hookCallback;
14
16
  };
15
17
 
16
18
  export const HookRenderer = (props: Props) => {
17
19
  const {
18
20
  focused,
19
- screenData: { callback, payload, hookPlugin },
21
+ screenData: { payload, hookPlugin },
22
+ callback,
20
23
  } = props;
21
24
 
22
25
  const { setVisible: showNavBar } = useSetNavbarState();
@@ -60,6 +63,7 @@ export const HookRenderer = (props: Props) => {
60
63
  hookPlugin,
61
64
  focused,
62
65
  parentFocus,
66
+ presentationType: PresentationType.Hook,
63
67
  }}
64
68
  />
65
69
  );
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks/usePickFromState";
2
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
3
3
  import { getBackgroundImageUrl } from "../utils";
4
4
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
5
 
@@ -7,7 +7,6 @@ import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/
7
7
  import configureStore from "redux-mock-store";
8
8
  import Layout from "../index.web";
9
9
 
10
- // mock useTheme to provide app_background_color
11
10
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
12
11
  useTheme: () => ({
13
12
  app_background_color: "#000000",
@@ -23,6 +23,7 @@ type Props = {
23
23
  style: ViewStyle;
24
24
  testID?: string;
25
25
  accessibilityLabel?: string;
26
+ accessibilityHint?: string;
26
27
  cellUUID?: string;
27
28
  extraProps?: Record<string, any>;
28
29
  };
@@ -48,7 +49,9 @@ function getAssetValue(asset, flavour, fallbackAsset = null) {
48
49
  return asset.src || fallbackAsset;
49
50
  }
50
51
 
51
- export function ActionButton(props: Props) {
52
+ export const ActionButton = React.memo(function ActionButtonComponent(
53
+ props: Props
54
+ ) {
52
55
  const { item, action, asset, flavour = "flavour_1", cellUUID } = props;
53
56
  const actionContext = useActions(action?.identifier);
54
57
 
@@ -98,6 +101,7 @@ export function ActionButton(props: Props) {
98
101
  onPress={onPress}
99
102
  testID={props?.testID || `${item?.id}`}
100
103
  accessibilityLabel={props?.accessibilityLabel || `${item?.id}`}
104
+ accessibilityHint={props?.accessibilityHint}
101
105
  accessible={!!(props?.testID || props?.accessibilityLabel)}
102
106
  style={props?.style}
103
107
  >
@@ -118,4 +122,4 @@ export function ActionButton(props: Props) {
118
122
  )}
119
123
  </TouchableOpacity>
120
124
  );
121
- }
125
+ });
@@ -4,7 +4,7 @@ import * as R from "ramda";
4
4
  import { TouchableOpacity } from "react-native";
5
5
  // import { SvgUri } from "react-native-svg";
6
6
 
7
- import { connectToStore } from "@applicaster/zapp-react-native-redux";
7
+ import { connectToStore } from "@applicaster/zapp-react-native-redux/utils/connectToStore";
8
8
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
9
9
 
10
10
  import Image from "./Image";
@@ -2,10 +2,8 @@ import React, { useMemo } from "react";
2
2
  import { ImageStyle } from "react-native";
3
3
  import { Focusable } from "@applicaster/zapp-react-native-ui-components/Components/Focusable";
4
4
  import { useActions } from "@applicaster/zapp-react-native-utils/reactHooks/actions";
5
- import * as R from "ramda";
6
5
  import { getXray } from "@applicaster/zapp-react-native-utils/logger";
7
6
  import { toBooleanWithDefaultFalse } from "@applicaster/zapp-react-native-utils/booleanUtils";
8
- import { useAccessibilityManager } from "@applicaster/zapp-react-native-utils/appUtils/accessibilityManager/hooks";
9
7
 
10
8
  const { Logger } = getXray();
11
9
 
@@ -45,11 +43,6 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
45
43
 
46
44
  const actionContext = useActions(pluginIdentifier);
47
45
 
48
- const accessibilityManager = useAccessibilityManager({});
49
-
50
- const { ttsLabel = "" } =
51
- actionContext?.initialEntryState(item)?.getAccessibility?.(item) || {};
52
-
53
46
  const onPress = (event) => {
54
47
  event?.preventDefault?.();
55
48
 
@@ -67,39 +60,11 @@ export function FocusableView({ style, children, item, ...otherProps }: Props) {
67
60
  const handleFocus = (focusable) => {
68
61
  const focusedButtonId = getFocusedButtonId(focusable);
69
62
 
70
- wrapperRef?.current?.measure((x, y, width, height, pageX, pageY) => {
71
- const top = pageY;
72
- const bottom = top + height;
73
- const left = pageX;
74
- const right = left + width;
75
-
76
- const boundingRect = {
77
- x,
78
- y,
79
- pageX,
80
- pageY,
81
- width,
82
- height,
83
- top,
84
- bottom,
85
- left,
86
- right,
87
- };
88
-
89
- otherProps?.onToggleFocus?.({
90
- focusable: {
91
- getRect: R.always(boundingRect),
92
- },
93
- focusedButtonId,
94
- mouse: focusable.mouse,
95
- });
63
+ otherProps?.onToggleFocus?.({
64
+ focusable: wrapperRef.current,
65
+ focusedButtonId,
66
+ mouse: focusable.mouse,
96
67
  });
97
-
98
- if (ttsLabel) {
99
- accessibilityManager.readText({
100
- text: ttsLabel,
101
- });
102
- }
103
68
  };
104
69
 
105
70
  const handleBlur = (_focusable, _direction) => {
@@ -20,7 +20,7 @@ const withAppliedDimensions = (style: Style) => (source: Source) => ({
20
20
  });
21
21
 
22
22
  export const withDimensionsHOC = (Component) => {
23
- return function WithDimensions(props: { style: any }) {
23
+ return function WithDimensions(props: Record<string, unknown>) {
24
24
  const theme = useTheme<BaseThemePropertiesMobile>();
25
25
 
26
26
  const useDownScalingImages = toBooleanWithDefaultFalse(
@@ -13,7 +13,7 @@ export const ImageContainer = (props: Props) => {
13
13
  const isActive = useIsScreenActive();
14
14
 
15
15
  const Component =
16
- isVideoPreviewEnabled(props) && isActive ? LiveImage : PureImage;
16
+ isVideoPreviewEnabled(props as Props) && isActive ? LiveImage : PureImage;
17
17
 
18
18
  return <Component {...props} />;
19
19
  };