@applicaster/zapp-react-native-ui-components 13.0.0-alpha.7120331332 → 13.0.0-alpha.7138263059

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 (134) hide show
  1. package/Components/AppContainer/__tests__/AppContainer.test.js +4 -6
  2. package/Components/AudioPlayer/__tests__/Runtime.test.js +5 -8
  3. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +54 -111
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +36 -20
  5. package/Components/AudioPlayer/__tests__/artWork.test.js +3 -5
  6. package/Components/AudioPlayer/__tests__/audioPlayer.test.js +3 -5
  7. package/Components/AudioPlayer/__tests__/audioPlayerLayout.test.js +7 -8
  8. package/Components/AudioPlayer/__tests__/channel.test.js +3 -5
  9. package/Components/AudioPlayer/__tests__/summary.test.js +3 -5
  10. package/Components/AudioPlayer/__tests__/title.test.js +3 -5
  11. package/Components/BaseFocusable/index.ios.ts +1 -1
  12. package/Components/BaseFocusable/index.tsx +67 -31
  13. package/Components/Cell/Cell.tsx +8 -3
  14. package/Components/Cell/CellWithFocusable.tsx +43 -58
  15. package/Components/Cell/TvOSCellComponent.tsx +20 -26
  16. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  17. package/Components/Cell/index.js +3 -1
  18. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +46 -48
  19. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +1 -42
  20. package/Components/ComponentResolver/__tests__/componentResolver.test.js +16 -22
  21. package/Components/ContentScreen/__tests__/contentScreen.test.js +3 -3
  22. package/Components/ErrorScreen/index.tsx +6 -6
  23. package/Components/Focusable/Focusable.tsx +1 -54
  24. package/Components/Focusable/FocusableTvOS.tsx +6 -2
  25. package/Components/Focusable/Touchable.tsx +19 -20
  26. package/Components/Focusable/index.android.tsx +10 -3
  27. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -83
  28. package/Components/FocusableGroup/index.tsx +1 -3
  29. package/Components/FocusableList/index.tsx +26 -10
  30. package/Components/FocusableScrollView/index.tsx +43 -13
  31. package/Components/Layout/TV/NavBarContainer.tsx +19 -23
  32. package/Components/Layout/TV/ScreenContainer.tsx +8 -1
  33. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +5 -0
  34. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +2 -1
  35. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -2
  36. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +3 -2
  37. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -3
  38. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  39. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  40. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
  41. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  42. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  43. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  44. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  45. package/Components/MasterCell/SharedUI/ProgressBar/hooks/useFillInPercent.ts +2 -8
  46. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +4 -12
  47. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +0 -229
  48. package/Components/MasterCell/__tests__/elementMapper.test.js +18 -5
  49. package/Components/MasterCell/__tests__/masterCell.test.js +26 -26
  50. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  51. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  52. package/Components/MasterCell/utils/index.ts +1 -1
  53. package/Components/ModalComponent/Button/index.tsx +6 -6
  54. package/Components/ModalComponent/Header/index.tsx +3 -3
  55. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  56. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  57. package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -5
  58. package/Components/PlayerContainer/PlayerContainer.tsx +11 -15
  59. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  60. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  61. package/Components/PlayerImageBackground/index.tsx +23 -3
  62. package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
  63. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  64. package/Components/River/RiverFooter.tsx +39 -9
  65. package/Components/River/RiverItem.tsx +37 -2
  66. package/Components/River/TV/index.tsx +6 -1
  67. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +100 -31
  68. package/Components/River/__tests__/__snapshots__/river.test.js.snap +20 -82
  69. package/Components/River/__tests__/componentsMap.test.js +17 -5
  70. package/Components/River/__tests__/river.test.js +75 -40
  71. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +11 -4
  72. package/Components/RouteManager/__tests__/routeManager.test.js +29 -14
  73. package/Components/RouteManager/__tests__/testId.test.js +8 -6
  74. package/Components/Screen/hooks.ts +56 -0
  75. package/Components/Screen/index.tsx +16 -42
  76. package/Components/ScreenResolver/__tests__/screenResolver.test.js +91 -70
  77. package/Components/Tabs/Tab.tsx +11 -9
  78. package/Components/TextInputTv/index.tsx +4 -3
  79. package/Components/TrackedView/index.tsx +1 -0
  80. package/Components/Transitioner/AnimationManager.js +8 -8
  81. package/Components/Transitioner/Scene.tsx +53 -24
  82. package/Components/Transitioner/Transitioner.tsx +3 -3
  83. package/Components/Transitioner/__tests__/Scene.test.js +25 -14
  84. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +9 -49
  85. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +2 -2
  86. package/Components/Transitioner/__tests__/transitioner.test.js +13 -4
  87. package/Components/Transitioner/index.js +8 -4
  88. package/Components/VideoLive/LiveImageManager.ts +27 -1
  89. package/Components/VideoLive/PlayerLiveImageComponent.tsx +36 -24
  90. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +51 -1
  91. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +1 -5
  92. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +16 -12
  93. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
  94. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +15 -14
  95. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +2 -3
  96. package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
  97. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  98. package/Components/VideoModal/PlayerDetails.tsx +9 -6
  99. package/Components/VideoModal/PlayerWrapper.tsx +17 -36
  100. package/Components/VideoModal/VideoModal.tsx +14 -23
  101. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -1
  102. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +0 -90
  103. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
  104. package/Components/VideoModal/hooks/index.ts +7 -0
  105. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
  106. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  107. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  108. package/Components/VideoModal/utils.ts +1 -1
  109. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +24 -36
  110. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +12 -18
  111. package/Components/Viewport/__tests__/utils.test.js +5 -4
  112. package/Components/ZappUIComponent/Placeholder.tsx +3 -1
  113. package/Components/ZappUIComponent/__tests__/{ZappUIComponent.test.js → ZappUIComponent.test.tsx} +26 -10
  114. package/Components/ZappUIComponent/index.tsx +3 -16
  115. package/Components/default-cell-renderer/__tests__/defaultCellRenderer.test.tsx +20 -17
  116. package/Components/default-cell-renderer/viewTrees/tv/DefaultCell/__tests__/DefaultCell.test.tsx +15 -11
  117. package/Contexts/ComponentsMapOffsetContext/index.tsx +49 -0
  118. package/Contexts/ScreenContext/index.tsx +3 -2
  119. package/Contexts/ScreenLayoutContext/index.tsx +5 -3
  120. package/Decorators/Navigator/__tests__/navigator.test.js +16 -16
  121. package/Decorators/Navigator/index.tsx +1 -1
  122. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +18 -24
  123. package/Decorators/RiverResolver/index.tsx +1 -1
  124. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  125. package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +29 -22
  126. package/Decorators/ZappPipesDataConnector/index.tsx +31 -1
  127. package/package.json +14 -8
  128. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +0 -53
  129. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +0 -17
  130. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +0 -17
  131. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +0 -91
  132. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +0 -338
  133. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +0 -18
  134. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +0 -28
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { View, Text } from "react-native";
3
- import { shallow } from "enzyme";
4
- import { shallowToJson } from "enzyme-to-json";
3
+ import { render } from "@testing-library/react-native";
4
+ import { AppContainer } from "../index";
5
5
 
6
6
  const styles = {
7
7
  iphone: {
@@ -15,11 +15,9 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
15
15
  })),
16
16
  }));
17
17
 
18
- const { AppContainer } = require("../index");
19
-
20
18
  describe("<AppContainer />", () => {
21
19
  it("renders correctly", () => {
22
- const wrapper = shallow(
20
+ const { toJSON } = render(
23
21
  <AppContainer styles={styles}>
24
22
  <View>
25
23
  <Text>I'm an app</Text>
@@ -27,6 +25,6 @@ describe("<AppContainer />", () => {
27
25
  </AppContainer>
28
26
  );
29
27
 
30
- expect(shallowToJson(wrapper)).toMatchSnapshot();
28
+ expect(toJSON()).toMatchSnapshot();
31
29
  });
32
30
  });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { Runtime } from "../Runtime";
6
5
 
@@ -18,14 +17,12 @@ const RuntimeProps = (isRTL) => ({
18
17
 
19
18
  describe("<Runtime />", () => {
20
19
  it("RTL renders correctly", () => {
21
- const wrapper = shallow(<Runtime {...RuntimeProps(true)} />);
22
-
23
- expect(shallowToJson(wrapper)).toMatchSnapshot();
20
+ const { toJSON } = render(<Runtime {...RuntimeProps(true)} />);
21
+ expect(toJSON()).toMatchSnapshot();
24
22
  });
25
23
 
26
24
  it("LTR renders correctly", () => {
27
- const wrapper = shallow(<Runtime {...RuntimeProps(false)} />);
28
-
29
- expect(shallowToJson(wrapper)).toMatchSnapshot();
25
+ const { toJSON } = render(<Runtime {...RuntimeProps(false)} />);
26
+ expect(toJSON()).toMatchSnapshot();
30
27
  });
31
28
  });
@@ -1,123 +1,66 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`<AudioPlayer /> renders correctly 1`] = `
4
- <AudioPlayerLayout
5
- config={
4
+ <View
5
+ pointerEvents="none"
6
+ style={
6
7
  {
7
- "artworkAspectRatio": "1:1",
8
- "audioPlayerBackgroundImageQuery": "",
9
- "backgroundColor": "black",
10
- "backgroundImage": "https://example.com",
11
- "channelIcon": "https://example.com",
12
- "isRTL": true,
13
- "magicBackground": false,
14
- "runTimeFontFamily": undefined,
15
- "runTimeFontSize": undefined,
16
- "summaryColor": "white",
17
- "summaryFontFamily": undefined,
18
- "summaryFontSize": undefined,
19
- "titleColor": "white",
20
- "titleFontFamily": undefined,
21
- "titleFontSize": undefined,
8
+ "backgroundColor": "transparent",
9
+ "overflow": "hidden",
22
10
  }
23
11
  }
24
- style={{}}
25
12
  >
26
- <Channel
27
- config={
13
+ <View
14
+ collapsable={false}
15
+ style={
28
16
  {
29
- "artworkAspectRatio": "1:1",
30
- "audioPlayerBackgroundImageQuery": "",
31
- "backgroundColor": "black",
32
- "backgroundImage": "https://example.com",
33
- "channelIcon": "https://example.com",
34
- "isRTL": true,
35
- "magicBackground": false,
36
- "runTimeFontFamily": undefined,
37
- "runTimeFontSize": undefined,
38
- "summaryColor": "white",
39
- "summaryFontFamily": undefined,
40
- "summaryFontSize": undefined,
41
- "titleColor": "white",
42
- "titleFontFamily": undefined,
43
- "titleFontSize": undefined,
17
+ "backgroundColor": "transparent",
18
+ "opacity": 0,
19
+ "overflow": "hidden",
44
20
  }
45
21
  }
46
- srcImage="https://example.com"
47
- />
48
- <Title
49
- config={
50
- {
51
- "artworkAspectRatio": "1:1",
52
- "audioPlayerBackgroundImageQuery": "",
53
- "backgroundColor": "black",
54
- "backgroundImage": "https://example.com",
55
- "channelIcon": "https://example.com",
56
- "isRTL": true,
57
- "magicBackground": false,
58
- "runTimeFontFamily": undefined,
59
- "runTimeFontSize": undefined,
60
- "summaryColor": "white",
61
- "summaryFontFamily": undefined,
62
- "summaryFontSize": undefined,
63
- "titleColor": "white",
64
- "titleFontFamily": undefined,
65
- "titleFontSize": undefined,
66
- }
67
- }
68
- title="tittle"
69
- />
70
- <Summary
71
- config={
72
- {
73
- "artworkAspectRatio": "1:1",
74
- "audioPlayerBackgroundImageQuery": "",
75
- "backgroundColor": "black",
76
- "backgroundImage": "https://example.com",
77
- "channelIcon": "https://example.com",
78
- "isRTL": true,
79
- "magicBackground": false,
80
- "runTimeFontFamily": undefined,
81
- "runTimeFontSize": undefined,
82
- "summaryColor": "white",
83
- "summaryFontFamily": undefined,
84
- "summaryFontSize": undefined,
85
- "titleColor": "white",
86
- "titleFontFamily": undefined,
87
- "titleFontSize": undefined,
22
+ >
23
+ <View
24
+ accessibilityIgnoresInvertColors={true}
25
+ style={
26
+ {
27
+ "flex": 1,
28
+ }
88
29
  }
89
- }
90
- summary="Summary"
91
- />
92
- <Runtime
93
- audio_player_artwork_aspect_ratio="1:1"
94
- audio_player_background_color="black"
95
- audio_player_background_image="https://example.com"
96
- audio_player_channel_icon="https://example.com"
97
- audio_player_rtl={true}
98
- audio_player_summary_color="white"
99
- audio_player_title_color="white"
100
- config={
101
- {
102
- "artworkAspectRatio": "1:1",
103
- "audioPlayerBackgroundImageQuery": "",
104
- "backgroundColor": "black",
105
- "backgroundImage": "https://example.com",
106
- "channelIcon": "https://example.com",
107
- "isRTL": true,
108
- "magicBackground": false,
109
- "runTimeFontFamily": undefined,
110
- "runTimeFontSize": undefined,
111
- "summaryColor": "white",
112
- "summaryFontFamily": undefined,
113
- "summaryFontSize": undefined,
114
- "titleColor": "white",
115
- "titleFontFamily": undefined,
116
- "titleFontSize": undefined,
117
- }
118
- }
119
- end_time="11:11"
120
- start_time="10:10"
121
- />
122
- </AudioPlayerLayout>
30
+ >
31
+ <Image
32
+ resizeMode="cover"
33
+ source={
34
+ {
35
+ "uri": "https://example.com",
36
+ }
37
+ }
38
+ style={
39
+ [
40
+ {
41
+ "bottom": 0,
42
+ "left": 0,
43
+ "position": "absolute",
44
+ "right": 0,
45
+ "top": 0,
46
+ },
47
+ {
48
+ "height": undefined,
49
+ "width": undefined,
50
+ },
51
+ undefined,
52
+ ]
53
+ }
54
+ />
55
+ <View
56
+ style={
57
+ {
58
+ "backgroundColor": "transparent",
59
+ "overflow": "hidden",
60
+ }
61
+ }
62
+ />
63
+ </View>
64
+ </View>
65
+ </View>
123
66
  `;
@@ -1,6 +1,6 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`<AudioPlayerLayout /> renders correctly 1`] = `
3
+ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
4
4
  <View
5
5
  pointerEvents="none"
6
6
  style={
@@ -10,32 +10,48 @@ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
10
10
  }
11
11
  }
12
12
  >
13
- <ForwardRef(AnimatedComponentWrapper)
13
+ <View
14
+ collapsable={false}
14
15
  style={
15
- [
16
- {
17
- "backgroundColor": "transparent",
18
- "overflow": "hidden",
19
- },
20
- {
21
- "opacity": 0,
22
- },
23
- ]
16
+ {
17
+ "backgroundColor": "transparent",
18
+ "opacity": 0,
19
+ "overflow": "hidden",
20
+ }
24
21
  }
25
22
  >
26
- <ImageBackground
27
- resizeMode="cover"
28
- source={
29
- {
30
- "uri": "https://example.com",
31
- }
32
- }
23
+ <View
24
+ accessibilityIgnoresInvertColors={true}
33
25
  style={
34
26
  {
35
27
  "flex": 1,
36
28
  }
37
29
  }
38
30
  >
31
+ <Image
32
+ resizeMode="cover"
33
+ source={
34
+ {
35
+ "uri": "https://example.com",
36
+ }
37
+ }
38
+ style={
39
+ [
40
+ {
41
+ "bottom": 0,
42
+ "left": 0,
43
+ "position": "absolute",
44
+ "right": 0,
45
+ "top": 0,
46
+ },
47
+ {
48
+ "height": undefined,
49
+ "width": undefined,
50
+ },
51
+ undefined,
52
+ ]
53
+ }
54
+ />
39
55
  <View
40
56
  style={
41
57
  {
@@ -44,7 +60,7 @@ exports[`<AudioPlayerLayout /> renders correctly 1`] = `
44
60
  }
45
61
  }
46
62
  />
47
- </ImageBackground>
48
- </ForwardRef(AnimatedComponentWrapper)>
63
+ </View>
64
+ </View>
49
65
  </View>
50
66
  `;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { Artwork } from "../Artwork";
6
5
 
@@ -16,9 +15,8 @@ const artWorkProps = {
16
15
  };
17
16
 
18
17
  describe("<Artwork />", () => {
19
- const wrapper = shallow(<Artwork {...artWorkProps} />);
20
-
21
18
  it("renders correctly", () => {
22
- expect(shallowToJson(wrapper)).toMatchSnapshot();
19
+ const { toJSON } = render(<Artwork {...artWorkProps} />);
20
+ expect(toJSON()).toMatchSnapshot();
23
21
  });
24
22
  });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { AudioPlayer } from "../AudioPlayer";
6
5
 
@@ -47,9 +46,8 @@ const audioPlayerProps = {
47
46
  };
48
47
 
49
48
  describe("<AudioPlayer />", () => {
50
- const wrapper = shallow(<AudioPlayer {...audioPlayerProps} />);
51
-
52
49
  it("renders correctly", () => {
53
- expect(shallowToJson(wrapper)).toMatchSnapshot();
50
+ const { toJSON } = render(<AudioPlayer {...audioPlayerProps} />);
51
+ expect(toJSON()).toMatchSnapshot();
54
52
  });
55
53
  });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { AudioPlayerLayout } from "../AudioPlayerLayout";
6
5
 
@@ -16,12 +15,12 @@ const audioPlayerLayoutProps = {
16
15
  children: [],
17
16
  };
18
17
 
19
- jest.useFakeTimers();
20
-
21
- describe("<AudioPlayerLayout />", () => {
22
- const wrapper = shallow(<AudioPlayerLayout {...audioPlayerLayoutProps} />);
23
-
18
+ describe("<AudioPlayerLayout />", () => {
24
19
  it("renders correctly", () => {
25
- expect(shallowToJson(wrapper)).toMatchSnapshot();
20
+ const { toJSON } = render(
21
+ <AudioPlayerLayout {...audioPlayerLayoutProps} />
22
+ );
23
+
24
+ expect(toJSON()).toMatchSnapshot();
26
25
  });
27
26
  });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { Channel } from "../Channel";
6
5
 
@@ -16,9 +15,8 @@ const channelProps = {
16
15
  };
17
16
 
18
17
  describe("<Channel />", () => {
19
- const wrapper = shallow(<Channel {...channelProps} />);
20
-
21
18
  it("renders correctly", () => {
22
- expect(shallowToJson(wrapper)).toMatchSnapshot();
19
+ const { toJSON } = render(<Channel {...channelProps} />);
20
+ expect(toJSON()).toMatchSnapshot();
23
21
  });
24
22
  });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { Summary } from "../Summary";
6
5
 
@@ -16,9 +15,8 @@ const summaryProps = {
16
15
  };
17
16
 
18
17
  describe("<Summary />", () => {
19
- const wrapper = shallow(<Summary {...summaryProps} />);
20
-
21
18
  it("renders correctly", () => {
22
- expect(shallowToJson(wrapper)).toMatchSnapshot();
19
+ const { toJSON } = render(<Summary {...summaryProps} />);
20
+ expect(toJSON()).toMatchSnapshot();
23
21
  });
24
22
  });
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
- import { shallow } from "enzyme";
3
- import { shallowToJson } from "enzyme-to-json";
2
+ import { render } from "@testing-library/react-native";
4
3
 
5
4
  import { Title } from "../Title";
6
5
 
@@ -16,9 +15,8 @@ const titleProps = {
16
15
  };
17
16
 
18
17
  describe("<Title />", () => {
19
- const wrapper = shallow(<Title {...titleProps} />);
20
-
21
18
  it("renders correctly", () => {
22
- expect(shallowToJson(wrapper)).toMatchSnapshot();
19
+ const { toJSON } = render(<Title {...titleProps} />);
20
+ expect(toJSON()).toMatchSnapshot();
23
21
  });
24
22
  });
@@ -25,7 +25,7 @@ type Props = {
25
25
  };
26
26
 
27
27
  export class BaseFocusable<
28
- T extends Props = Props
28
+ T extends Props = Props,
29
29
  > extends BaseFocusableInterface<T> {
30
30
  constructor(props) {
31
31
  super(props);
@@ -1,13 +1,12 @@
1
1
  import * as React from "react";
2
+ import * as R from "ramda";
2
3
 
3
4
  import {
4
5
  BaseFocusable as BaseFocusableInterface,
5
6
  BoundingRect,
6
7
  } from "./BaseFocusable.interface";
7
8
 
8
- import { createReactRef } from "@applicaster/zapp-react-native-utils/reactUtils";
9
9
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
10
- import * as FOCUS_EVENTS from "@applicaster/zapp-react-native-utils/appUtils/focusManager/events";
11
10
  import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
12
11
 
13
12
  type ScrollDirection = FocusManager.IOS.Direction | FocusManager.Web.Direction;
@@ -35,7 +34,7 @@ type Props = {
35
34
  };
36
35
 
37
36
  export class BaseFocusable<
38
- T extends Props = Props
37
+ T extends Props = Props,
39
38
  > extends BaseFocusableInterface<T> {
40
39
  constructor(props) {
41
40
  super(props);
@@ -45,7 +44,7 @@ export class BaseFocusable<
45
44
  focused: initialFocus || false,
46
45
  };
47
46
 
48
- this.ref = createReactRef();
47
+ this.ref = React.createRef();
49
48
  }
50
49
 
51
50
  componentDidMount() {
@@ -131,12 +130,6 @@ export class BaseFocusable<
131
130
  willLoseFocus: FocusManager.FocusEventCB = (focusable, scrollDirection) => {
132
131
  const { willLoseFocus = noop } = this.props;
133
132
  willLoseFocus(focusable, scrollDirection);
134
-
135
- focusManager.invokeHandler?.(
136
- FOCUS_EVENTS.WILL_LOSE_FOCUS,
137
- this,
138
- scrollDirection
139
- );
140
133
  };
141
134
 
142
135
  willReceiveFocus: FocusManager.FocusEventCB = (
@@ -145,12 +138,6 @@ export class BaseFocusable<
145
138
  ) => {
146
139
  const { willReceiveFocus = noop } = this.props;
147
140
  willReceiveFocus(focusable, scrollDirection);
148
-
149
- focusManager.invokeHandler?.(
150
- FOCUS_EVENTS.WILL_RECEIVE_FOCUS,
151
- this,
152
- scrollDirection
153
- );
154
141
  };
155
142
 
156
143
  /**
@@ -163,8 +150,6 @@ export class BaseFocusable<
163
150
  const { onFocus = noop } = this.props;
164
151
  this.setFocusedState(true);
165
152
  onFocus(focusable, scrollDirection);
166
-
167
- focusManager.invokeHandler?.(FOCUS_EVENTS.FOCUS, this, scrollDirection);
168
153
  };
169
154
 
170
155
  /**
@@ -179,12 +164,6 @@ export class BaseFocusable<
179
164
  ) => {
180
165
  const { hasReceivedFocus = noop } = this.props;
181
166
  hasReceivedFocus(focusable, scrollDirection);
182
-
183
- focusManager.invokeHandler?.(
184
- FOCUS_EVENTS.HAS_RECEIVED_FOCUS,
185
- this,
186
- scrollDirection
187
- );
188
167
  };
189
168
 
190
169
  /**
@@ -196,12 +175,6 @@ export class BaseFocusable<
196
175
  hasLostFocus: FocusManager.FocusEventCB = (focusable, scrollDirection) => {
197
176
  const { hasLostFocus = noop } = this.props;
198
177
  hasLostFocus(focusable, scrollDirection);
199
-
200
- focusManager.invokeHandler?.(
201
- FOCUS_EVENTS.HAS_LOST_FOCUS,
202
- this,
203
- scrollDirection
204
- );
205
178
  };
206
179
 
207
180
  /**
@@ -228,7 +201,6 @@ export class BaseFocusable<
228
201
  const { onBlur = noop } = this.props;
229
202
  this.setFocusedState(false);
230
203
  onBlur(focusable, scrollDirection);
231
- focusManager.invokeHandler?.(FOCUS_EVENTS.BLUR, this, scrollDirection);
232
204
  };
233
205
 
234
206
  onPress = (keyEvent?: Nullable<React.MouseEvent>) => {
@@ -269,4 +241,68 @@ export class BaseFocusable<
269
241
  this.setState({ focused });
270
242
  }
271
243
  };
244
+
245
+ /**
246
+ * will invoke the underlying component's focus method
247
+ * @param {Object} scrollDirection
248
+ * @returns {Promise}
249
+ */
250
+ focus(_, scrollDirection) {
251
+ return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
252
+ }
253
+
254
+ /**
255
+ * will invoke the underlying component's blur method
256
+ * @param {Object} scrollDirection
257
+ * @returns {Promise}
258
+ */
259
+ blur(
260
+ _,
261
+ scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
262
+ ) {
263
+ return this.onBlur(this, scrollDirection);
264
+ }
265
+
266
+ /**
267
+ * Sets the focus on this item. Will trigger sequentially a sequence of
268
+ * functions (willReceiveFocus, focus, hasReceivedFocus). If these functions (defined in the Focusable
269
+ * Item underlying component) return promises, execution will wait before it proceeds to the next. This
270
+ * is useful for triggering sequential operations that specifically require to fully run before or after
271
+ * focus is actually set on that item.
272
+ * @param {string} scrollDirection string representation of the direction of the navigation which landed
273
+ * to this item being focused
274
+ */
275
+ _executeFocusSequence(methodNames, scrollDirection) {
276
+ return R.reduce(
277
+ (sequence, methodName) => {
278
+ const method = this[methodName]; // Access the method by name
279
+
280
+ if (typeof method !== "function") {
281
+ throw new Error(
282
+ `Method '${methodName}' not found or not a function.`
283
+ );
284
+ }
285
+
286
+ return sequence
287
+ .then(() => method.call(this, scrollDirection))
288
+ .catch((e) => {
289
+ throw e; // Re-throw for consistent error handling
290
+ });
291
+ },
292
+ Promise.resolve(),
293
+ methodNames
294
+ );
295
+ }
296
+
297
+ setFocus(scrollDirection) {
298
+ const focusMethods = ["willReceiveFocus", "focus", "hasReceivedFocus"];
299
+
300
+ return this._executeFocusSequence(focusMethods, scrollDirection);
301
+ }
302
+
303
+ setBlur(scrollDirection) {
304
+ const blurMethods = ["willLoseFocus", "blur", "hasLostFocus"];
305
+
306
+ return this._executeFocusSequence(blurMethods, scrollDirection);
307
+ }
272
308
  }
@@ -61,6 +61,7 @@ type Props = {
61
61
  skipFocusManagerRegistration?: boolean;
62
62
  shouldUpdate: boolean;
63
63
  behavior: Behavior;
64
+ componentsMapOffset: number;
64
65
  };
65
66
 
66
67
  type State = {
@@ -273,10 +274,14 @@ export class CellComponent extends React.Component<Props, State> {
273
274
  if (isFocused) {
274
275
  const accessibilityManager = AccessibilityManager.getInstance();
275
276
 
277
+ const accessibilityTitle =
278
+ item?.extensions?.accessibility?.label || item?.title || "";
279
+
280
+ const accessibilityHint =
281
+ item?.extensions?.accessibility?.hint || "";
282
+
276
283
  accessibilityManager.readText({
277
- text: String(
278
- item.extensions?.accessibility?.label || item.title
279
- ),
284
+ text: `${accessibilityTitle} ${accessibilityHint}`,
280
285
  });
281
286
  }
282
287