@applicaster/zapp-react-native-ui-components 13.0.0-alpha.2040752175 → 13.0.0-alpha.2113353282

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__/__snapshots__/AppContainer.test.js.snap +1 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/Runtime.test.js.snap +4 -4
  3. package/Components/AudioPlayer/__tests__/__snapshots__/artWork.test.js.snap +3 -3
  4. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +6 -6
  5. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayerLayout.test.js.snap +7 -7
  6. package/Components/AudioPlayer/__tests__/__snapshots__/channel.test.js.snap +3 -3
  7. package/Components/AudioPlayer/__tests__/__snapshots__/summary.test.js.snap +2 -2
  8. package/Components/AudioPlayer/__tests__/__snapshots__/title.test.js.snap +2 -2
  9. package/Components/BaseFocusable/index.ios.ts +1 -1
  10. package/Components/BaseFocusable/index.tsx +66 -29
  11. package/Components/Cell/Cell.tsx +14 -9
  12. package/Components/Cell/CellWithFocusable.tsx +44 -60
  13. package/Components/Cell/TvOSCellComponent.tsx +3 -8
  14. package/Components/Cell/__tests__/CellWIthFocusable.test.js +13 -6
  15. package/Components/CellRendererResolver/__tests__/__snapshots__/cellRendererResolver.test.js.snap +20 -20
  16. package/Components/CellRendererResolver/__tests__/cellRendererResolver.test.js +5 -3
  17. package/Components/ComponentResolver/__tests__/__snapshots__/componentResolver.test.js.snap +5 -5
  18. package/Components/ComponentResolver/__tests__/componentResolver.test.js +11 -9
  19. package/Components/DisplayState/__tests__/__snapshots__/displayState.test.js.snap +2 -2
  20. package/Components/ErrorScreen/index.tsx +6 -6
  21. package/Components/Focusable/Focusable.tsx +1 -54
  22. package/Components/Focusable/FocusableTvOS.tsx +1 -1
  23. package/Components/Focusable/Touchable.tsx +19 -20
  24. package/Components/FocusableGroup/FocusableTvOS.tsx +34 -83
  25. package/Components/FocusableGroup/index.tsx +1 -3
  26. package/Components/FocusableList/index.tsx +0 -1
  27. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +9 -0
  28. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  29. package/Components/Layout/TV/__tests__/ScreenContainer.test.tsx +1 -0
  30. package/Components/Layout/TV/__tests__/__snapshots__/LayoutContainer.test.tsx.snap +1 -1
  31. package/Components/Layout/TV/__tests__/__snapshots__/NavBarContainer.test.tsx.snap +3 -3
  32. package/Components/Layout/TV/__tests__/__snapshots__/ScreenContainer.test.tsx.snap +9 -9
  33. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  34. package/Components/Layout/TV/__tests__/index.test.tsx +7 -3
  35. package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +66 -0
  36. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +4 -1
  37. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +6 -12
  38. package/Components/MasterCell/DefaultComponents/ImageBorderContainer/__tests__/index.test.ts +93 -0
  39. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +2 -2
  40. package/Components/MasterCell/DefaultComponents/SecondaryImage/__tests__/__snapshots__/Image.test.tsx.snap +3 -3
  41. package/Components/MasterCell/DefaultComponents/SecondaryImage/utils.ts +1 -1
  42. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  43. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/__snapshots__/index.test.tsx.snap +1 -1
  44. package/Components/MasterCell/__tests__/__snapshots__/dataAdapter.test.js.snap +180 -180
  45. package/Components/MasterCell/__tests__/__snapshots__/elementMapper.test.js.snap +7 -7
  46. package/Components/MasterCell/__tests__/__snapshots__/masterCell.test.js.snap +34 -34
  47. package/Components/MasterCell/hooks/useAsyncRendering/MasterCellAsyncRenderManager.ts +2 -2
  48. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +2 -2
  49. package/Components/MasterCell/utils/index.ts +1 -1
  50. package/Components/ModalComponent/Button/index.tsx +6 -6
  51. package/Components/ModalComponent/Header/index.tsx +3 -3
  52. package/Components/NativeFocusables/{index.js → index.ts} +4 -2
  53. package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +2 -2
  54. package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +2 -2
  55. package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +7 -7
  56. package/Components/OfflineHandler/__tests__/index.test.tsx +28 -25
  57. package/Components/PlayerContainer/PlayerContainer.tsx +13 -19
  58. package/Components/PlayerContainer/PlayerContainerContext.tsx +9 -0
  59. package/Components/PlayerContainer/ProgramInfo/index.tsx +2 -2
  60. package/Components/River/ComponentsMap/ComponentsMap.tsx +39 -65
  61. package/Components/River/ComponentsMap/hooks/useLoadingState.ts +78 -51
  62. package/Components/River/RefreshControl.tsx +1 -1
  63. package/Components/River/RiverFooter.tsx +39 -9
  64. package/Components/River/RiverItem.tsx +37 -2
  65. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +114 -45
  66. package/Components/River/__tests__/__snapshots__/river.test.js.snap +12 -12
  67. package/Components/River/__tests__/componentsMap.test.js +64 -17
  68. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -1
  69. package/Components/RouteManager/__tests__/__snapshots__/testId.test.js.snap +1 -1
  70. package/Components/Screen/__tests__/Screen.test.tsx +41 -27
  71. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -4
  72. package/Components/Screen/hooks.ts +56 -0
  73. package/Components/Screen/index.tsx +16 -42
  74. package/Components/ScreenResolver/__tests__/__snapshots__/screenResolver.test.js.snap +2 -2
  75. package/Components/ScreenResolver/__tests__/screenResolver.test.js +31 -27
  76. package/Components/Tabs/Tab.tsx +12 -9
  77. package/Components/TextInputTv/__tests__/TextInputTv.test.js +42 -42
  78. package/Components/TextInputTv/__tests__/__snapshots__/TextInputTv.test.js.snap +7 -0
  79. package/Components/TextInputTv/index.tsx +6 -5
  80. package/Components/Touchable/__tests__/__snapshots__/touchable.test.tsx.snap +2 -2
  81. package/Components/Transitioner/AnimationManager.js +8 -8
  82. package/Components/Transitioner/Scene.tsx +53 -24
  83. package/Components/Transitioner/Transitioner.tsx +3 -3
  84. package/Components/Transitioner/__tests__/__snapshots__/AnimationManager.test.js.snap +26 -26
  85. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +62 -46
  86. package/Components/Transitioner/__tests__/__snapshots__/config.test.js.snap +20 -20
  87. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +4 -4
  88. package/Components/Transitioner/index.js +8 -4
  89. package/Components/VideoLive/LiveImageManager.ts +27 -1
  90. package/Components/VideoLive/PlayerLiveImageComponent.tsx +32 -24
  91. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +63 -8
  92. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +5 -10
  93. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +16 -12
  94. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +5 -1
  95. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +15 -14
  96. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +6 -13
  97. package/Components/VideoModal/ModalAnimation/index.ts +2 -1
  98. package/Components/VideoModal/ModalAnimation/useModalAnimationContext.ts +6 -0
  99. package/Components/VideoModal/ModalAnimation/utils.ts +2 -2
  100. package/Components/VideoModal/OpaqueLayer.tsx +33 -0
  101. package/Components/VideoModal/PlayerDetails.tsx +5 -5
  102. package/Components/VideoModal/PlayerWrapper.tsx +17 -36
  103. package/Components/VideoModal/VideoModal.tsx +14 -23
  104. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +5 -2
  105. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +13 -10
  106. package/Components/VideoModal/__tests__/__snapshots__/PlayerDetails.test.tsx.snap +4 -4
  107. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +66 -156
  108. package/Components/VideoModal/hooks/__tests__/useDelayedPlayerDetails.test.ts +89 -0
  109. package/Components/VideoModal/hooks/index.ts +7 -0
  110. package/Components/VideoModal/hooks/useDelayedPlayerDetails.ts +49 -0
  111. package/Components/VideoModal/hooks/utils/__tests__/showDetails.test.ts +91 -0
  112. package/Components/VideoModal/hooks/utils/index.ts +33 -0
  113. package/Components/VideoModal/utils.ts +3 -5
  114. package/Components/Viewport/ViewportAware/__tests__/__snapshots__/viewportAware.test.js.snap +2 -2
  115. package/Components/Viewport/ViewportTracker/__tests__/__snapshots__/viewportTracker.test.js.snap +1 -1
  116. package/Components/ZappUIComponent/__tests__/__snapshots__/ZappUIComponent.test.js.snap +11 -11
  117. package/Components/default-cell-renderer/__tests__/__snapshots__/defaultCellRenderer.test.tsx.snap +30 -30
  118. package/Contexts/ConfigutaionContext/__tests__/__snapshots__/ConfigurationProvider.test.tsx.snap +1 -1
  119. package/Contexts/ScreenContext/index.tsx +3 -2
  120. package/Decorators/Analytics/{index.js → index.tsx} +11 -11
  121. package/Decorators/Navigator/__tests__/__snapshots__/navigator.test.js.snap +2 -2
  122. package/Decorators/RiverFeedLoader/__tests__/__snapshots__/riverFeedLoader.test.tsx.snap +77 -77
  123. package/Decorators/RiverFeedLoader/__tests__/riverFeedLoader.test.tsx +34 -39
  124. package/Decorators/RiverFeedLoader/__tests__/utils.test.ts +0 -9
  125. package/Decorators/RiverFeedLoader/index.tsx +1 -1
  126. package/Decorators/RiverFeedLoader/utils/getDatasourceUrl.ts +39 -0
  127. package/Decorators/RiverFeedLoader/utils/index.ts +29 -0
  128. package/Decorators/RiverFeedLoader/utils/usePipesContexts.ts +40 -0
  129. package/Decorators/RiverResolver/__tests__/__snapshots__/riverResolver.test.tsx.snap +5 -5
  130. package/Decorators/RiverResolver/__tests__/riverResolver.test.tsx +16 -10
  131. package/Decorators/ZappPipesDataConnector/__tests__/Hero.js +1 -1
  132. package/Decorators/ZappPipesDataConnector/index.tsx +32 -2
  133. package/package.json +12 -6
  134. package/Decorators/RiverFeedLoader/utils.ts +0 -100
@@ -3,24 +3,24 @@
3
3
  exports[`CellRendererResolver renders correctly 1`] = `
4
4
  <View
5
5
  someProp={
6
- Object {
7
- "cellOptions": Object {},
8
- "cellStyles": Object {
9
- "ABCDE-123456": Object {
10
- "configuration": Object {},
6
+ {
7
+ "cellOptions": {},
8
+ "cellStyles": {
9
+ "ABCDE-123456": {
10
+ "configuration": {},
11
11
  "plugin_identifier": "custom_renderer_plugin",
12
12
  },
13
- "FGHIJ-123456": Object {
14
- "configuration": Object {},
13
+ "FGHIJ-123456": {
14
+ "configuration": {},
15
15
  "plugin_identifier": "unknown_plugin",
16
16
  },
17
17
  },
18
- "component": Object {
19
- "styles": Object {
18
+ "component": {
19
+ "styles": {
20
20
  "cell_plugin_configuration_id": "ABCDE-123456",
21
21
  },
22
22
  },
23
- "styles": Object {},
23
+ "styles": {},
24
24
  }
25
25
  }
26
26
  />
@@ -29,24 +29,24 @@ exports[`CellRendererResolver renders correctly 1`] = `
29
29
  exports[`CellRendererResolver with a default renderer plugin renders correctly 1`] = `
30
30
  <View
31
31
  someProp={
32
- Object {
33
- "cellOptions": Object {},
34
- "cellStyles": Object {
35
- "ABCDE-123456": Object {
36
- "configuration": Object {},
32
+ {
33
+ "cellOptions": {},
34
+ "cellStyles": {
35
+ "ABCDE-123456": {
36
+ "configuration": {},
37
37
  "plugin_identifier": "custom_renderer_plugin",
38
38
  },
39
- "FGHIJ-123456": Object {
40
- "configuration": Object {},
39
+ "FGHIJ-123456": {
40
+ "configuration": {},
41
41
  "plugin_identifier": "unknown_plugin",
42
42
  },
43
43
  },
44
- "component": Object {
45
- "styles": Object {
44
+ "component": {
45
+ "styles": {
46
46
  "cell_plugin_configuration_id": "ABCDE-123456",
47
47
  },
48
48
  },
49
- "styles": Object {},
49
+ "styles": {},
50
50
  }
51
51
  }
52
52
  />
@@ -2,9 +2,11 @@ import * as React from "react";
2
2
  import { View } from "react-native";
3
3
  import { shallow } from "enzyme";
4
4
 
5
- jest.mock("../../default-cell-renderer", () =>
6
- jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />)
7
- );
5
+ jest.mock("../../default-cell-renderer", () => {
6
+ const View = jest.requireActual("react-native").View;
7
+
8
+ return jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />);
9
+ });
8
10
 
9
11
  const { CellRendererResolver } = require("../index");
10
12
 
@@ -5,22 +5,22 @@ exports[`ComponentResolver renders correctly 1`] = `
5
5
  value={null}
6
6
  >
7
7
  <Memo(ComponentResolver)
8
- cellStyles={Object {}}
8
+ cellStyles={{}}
9
9
  component={
10
- Object {
10
+ {
11
11
  "component_type": "some_component",
12
12
  }
13
13
  }
14
14
  components={
15
- Object {
15
+ {
16
16
  "SomeComponent": [MockFunction],
17
17
  }
18
18
  }
19
19
  decorators={[MockFunction]}
20
20
  dispatch={[Function]}
21
- plugins={Array []}
21
+ plugins={[]}
22
22
  store={
23
- Object {
23
+ {
24
24
  "clearActions": [Function],
25
25
  "dispatch": [Function],
26
26
  "getActions": [Function],
@@ -4,19 +4,21 @@ import { shallow } from "enzyme";
4
4
  import { shallowToJson } from "enzyme-to-json";
5
5
  import configureStore from "redux-mock-store";
6
6
 
7
- const logger = {
7
+ const mockLogger = {
8
8
  warning: jest.fn(),
9
9
  };
10
10
 
11
11
  jest.mock("../../../Helpers/logger", () => ({
12
12
  componentsLogger: {
13
- addSubsystem: jest.fn(() => logger),
13
+ addSubsystem: jest.fn(() => mockLogger),
14
14
  },
15
15
  }));
16
16
 
17
- jest.mock("../../default-cell-renderer", () =>
18
- jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />)
19
- );
17
+ jest.mock("../../default-cell-renderer", () => {
18
+ const View = jest.requireActual("react-native").View;
19
+
20
+ return jest.fn((prop) => <View whoAmI="default renderer" someProp={prop} />);
21
+ });
20
22
 
21
23
  const mock_rtl_flag = false;
22
24
 
@@ -48,7 +50,7 @@ function clearAllMocks() {
48
50
  SomeComponent.mockClear();
49
51
  decorators.mockClear();
50
52
  renderFunction.mockClear();
51
- logger.warning.mockClear();
53
+ mockLogger.warning.mockClear();
52
54
  }
53
55
 
54
56
  describe("ComponentResolver", () => {
@@ -104,16 +106,16 @@ describe("ComponentResolverComponent", () => {
104
106
  expect(shallowToJson(wrapper)).toMatchSnapshot();
105
107
  expect(wrapper.isEmptyRender()).toBe(true);
106
108
 
107
- expect(logger.warning).toHaveBeenCalledTimes(2);
109
+ expect(mockLogger.warning).toHaveBeenCalledTimes(2);
108
110
 
109
- expect(logger.warning).toHaveBeenNthCalledWith(
111
+ expect(mockLogger.warning).toHaveBeenNthCalledWith(
110
112
  1,
111
113
  expect.objectContaining({
112
114
  message: "Could not resolve cell builder plugin",
113
115
  })
114
116
  );
115
117
 
116
- expect(logger.warning).toHaveBeenNthCalledWith(
118
+ expect(mockLogger.warning).toHaveBeenNthCalledWith(
117
119
  2,
118
120
  expect.objectContaining({
119
121
  message: warningMessage,
@@ -1,7 +1,7 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`DISPLAY_STATES matches the snapshot 1`] = `
4
- Object {
4
+ {
5
5
  "CONTENT": "CONTENT",
6
6
  "CONTROLS": "CONTROLS",
7
7
  "DISCOVERY": "DISCOVERY",
@@ -9,7 +9,7 @@ Object {
9
9
  `;
10
10
 
11
11
  exports[`DisplayStateContext has the correct properties 1`] = `
12
- Object {
12
+ {
13
13
  "Consumer": [MockFunction],
14
14
  "Provider": [MockFunction],
15
15
  "withConsumer": [MockFunction],
@@ -1,13 +1,13 @@
1
1
  import React, { useMemo } from "react";
2
2
  import * as R from "ramda";
3
3
  import {
4
- View,
4
+ ImageStyle,
5
5
  StyleSheet,
6
6
  Text,
7
- ViewStyle,
8
- TextStyle,
9
- ImageStyle,
10
7
  TextProps,
8
+ TextStyle,
9
+ View,
10
+ ViewStyle,
11
11
  } from "react-native";
12
12
  import { defaultAsset } from "./defaultAsset";
13
13
  import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
@@ -150,13 +150,13 @@ export function ErrorScreen(props: Props) {
150
150
  return (
151
151
  <View style={[baseStyles.container, styles.screen]}>
152
152
  <View style={[baseStyles.container, styles.component]}>
153
- {assetEnabled && (
153
+ {assetEnabled ? (
154
154
  <Image
155
155
  fadeDuration={0}
156
156
  source={{ uri: asset }}
157
157
  style={styles.asset}
158
158
  />
159
- )}
159
+ ) : null}
160
160
  <Text style={styles.title} {...titleProps}>
161
161
  {title}
162
162
  </Text>
@@ -1,5 +1,5 @@
1
+ /* eslint-disable react/no-unknown-property */
1
2
  import * as React from "react";
2
- import * as R from "ramda";
3
3
 
4
4
  import { BaseFocusable } from "../BaseFocusable";
5
5
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils/focusManager";
@@ -42,8 +42,6 @@ class Focusable extends BaseFocusable<Props> {
42
42
  this.resetLongPressTimeout = this.resetLongPressTimeout.bind(this);
43
43
  this.longPress = this.longPress.bind(this);
44
44
  this.press = this.press.bind(this);
45
- this.focus = this.focus.bind(this);
46
- this.blur = this.blur.bind(this);
47
45
  }
48
46
 
49
47
  /**
@@ -55,37 +53,6 @@ class Focusable extends BaseFocusable<Props> {
55
53
  return this.preferredFocus();
56
54
  }
57
55
 
58
- /**
59
- * Sets the focus on this item. Will trigger sequentially a sequence of
60
- * functions (willReceiveFocus, focus, hasReceivedFocus). If these functions (defined in the Focusable
61
- * Item underlying component) return promises, execution will wait before it proceeds to the next. This
62
- * is useful for triggering sequential operations that specifically require to fully run before or after
63
- * focus is actually set on that item.
64
- * @param {string} scrollDirection string representation of the direction of the navigation which landed
65
- * to this item being focused
66
- */
67
- setFocus(scrollDirection) {
68
- const focusMethods = [
69
- this.willReceiveFocus,
70
- this.focus,
71
- this.hasReceivedFocus,
72
- ];
73
-
74
- const self = this;
75
-
76
- return R.reduce(
77
- (sequence, method) => {
78
- return sequence
79
- .then(() => method.apply(self, [scrollDirection]))
80
- .catch((e) => {
81
- throw e;
82
- });
83
- },
84
- Promise.resolve(),
85
- focusMethods
86
- );
87
- }
88
-
89
56
  startLongPressTimeout() {
90
57
  this.longPressTimeout = setTimeout(() => {
91
58
  this.longPress(null);
@@ -102,26 +69,6 @@ class Focusable extends BaseFocusable<Props> {
102
69
  }
103
70
  }
104
71
 
105
- /**
106
- * will invoke the underlying component's focus method
107
- * @param {Object} scrollDirection
108
- * @returns {Promise}
109
- */
110
- focus(scrollDirection) {
111
- return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
112
- }
113
-
114
- /**
115
- * will invoke the underlying component's blur method
116
- * @param {Object} scrollDirection
117
- * @returns {Promise}
118
- */
119
- blur(
120
- scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
121
- ) {
122
- return this.onBlur(this, scrollDirection);
123
- }
124
-
125
72
  /**
126
73
  * will invoke the underlying component's press method
127
74
  * @param {Object} keyEvent
@@ -90,7 +90,7 @@ export class Focusable extends BaseFocusable<Props> {
90
90
  onBlur(nativeEvent);
91
91
  }
92
92
 
93
- setFocus(direction, callback) {
93
+ setFocus(_direction, callback) {
94
94
  const focusMethods = [
95
95
  { method: this.willReceiveFocus },
96
96
  { method: this.focus, args: [callback] },
@@ -1,25 +1,24 @@
1
1
  import * as React from "react";
2
2
 
3
- type Props =
4
- | {
5
- id: string;
6
- children: React.ReactNode;
7
- onPress?: (ref: FocusManager.TouchableRef) => void;
8
- onPressIn?: (ref: FocusManager.TouchableRef) => void;
9
- onPressOut?: (ref: FocusManager.TouchableRef) => void;
10
- onLongPress?: (ref: FocusManager.TouchableRef) => void;
11
- onFocus?: (
12
- ref: FocusManager.TouchableRef,
13
- options: FocusManager.Android.CallbackOptions
14
- ) => void;
15
- onBlur?: (
16
- ref: FocusManager.TouchableRef,
17
- options: FocusManager.Android.CallbackOptions
18
- ) => void;
19
-
20
- disableFocus?: boolean;
21
- blockFocus?: boolean;
22
- } & Partial<ParentFocus>;
3
+ type Props = {
4
+ id: string;
5
+ children: React.ReactNode;
6
+ onPress?: (ref: FocusManager.TouchableRef) => void;
7
+ onPressIn?: (ref: FocusManager.TouchableRef) => void;
8
+ onPressOut?: (ref: FocusManager.TouchableRef) => void;
9
+ onLongPress?: (ref: FocusManager.TouchableRef) => void;
10
+ onFocus?: (
11
+ ref: FocusManager.TouchableRef,
12
+ options: FocusManager.Android.CallbackOptions
13
+ ) => void;
14
+ onBlur?: (
15
+ ref: FocusManager.TouchableRef,
16
+ options: FocusManager.Android.CallbackOptions
17
+ ) => void;
18
+
19
+ disableFocus?: boolean;
20
+ blockFocus?: boolean;
21
+ } & Partial<ParentFocus>;
23
22
 
24
23
  export class Touchable extends React.Component<Props> {
25
24
  onPress(focusableRef: FocusManager.TouchableRef): void {
@@ -1,17 +1,31 @@
1
1
  import * as React from "react";
2
2
  import { FocusableGroupNative } from "@applicaster/zapp-react-native-ui-components/Components/NativeFocusables";
3
3
  import { BaseFocusable } from "@applicaster/zapp-react-native-ui-components/Components/BaseFocusable";
4
-
5
- function noop() {}
4
+ import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
5
+
6
+ const { log_verbose } = createLogger({
7
+ subsystem: "General",
8
+ category: "FocusableGroup",
9
+ });
10
+
11
+ type FocusableGroupNativeEvent = {
12
+ nativeEvent: {
13
+ focusHeading: FocusManager.Direction;
14
+ groupId: string;
15
+ isActive: boolean;
16
+ isFocusDisabled: boolean;
17
+ isFocusingByUser: boolean;
18
+ itemId: string;
19
+ target: number;
20
+ };
21
+ };
6
22
 
7
23
  type Props = {
8
24
  id: string;
9
25
  children: (arg1: boolean) => React.ComponentType<any>;
10
- onWillUpdateFocus: (nativeEvent: any) => void;
11
- onDidUpdateFocus: (nativeEvent: any) => void;
12
26
  isFocusDisabled: boolean;
13
27
  initialItemId: string;
14
- resetFocusToInitialValue: boolean;
28
+ isPreferredFocusDisabled: boolean;
15
29
  focusGroupRef: React.Component;
16
30
  shouldUsePreferredFocus: boolean;
17
31
  groupId: string;
@@ -21,86 +35,27 @@ type Props = {
21
35
  };
22
36
 
23
37
  export class FocusableGroup extends BaseFocusable<Props> {
24
- focusableGroupNativeRef: React.Component | null;
25
- constructor(props) {
26
- super(props);
27
- this.focusableGroupNativeRef = null;
28
-
29
- this.state = {
30
- isActive: false,
31
- };
32
-
33
- this.onWillUpdateFocus = this.onWillUpdateFocus.bind(this);
34
- this.onDidUpdateFocus = this.onDidUpdateFocus.bind(this);
35
- this.isGroup = true;
36
-
37
- this.shouldUsePreferredFocus = this.shouldUsePreferredFocus.bind(this);
38
- this.measureView = this.measureView.bind(this);
39
- }
40
-
41
- connectedScreenId() {
42
- const {
43
- screenData: { screenId, parentScreenId },
44
- } = this.props;
45
-
46
- if (screenId) {
47
- return null;
48
- }
49
-
50
- return parentScreenId ? `${parentScreenId}-${screenId}` : screenId;
51
- }
52
-
53
- /**
54
- * tells whether the group should give focus to a preferred item when it gains focus from another
55
- * group
56
- * @returns {boolean}
57
- */
58
- shouldUsePreferredFocus() {
59
- return this.props.shouldUsePreferredFocus || false;
60
- }
61
-
62
- /**
63
- * indicates whether the underlying component should claim preferred focus
64
- * when navigating into the group of this item
65
- * @returns {boolean}
66
- */
67
- isPreferredFocus() {
68
- return this.props.preferredFocus || false;
69
- }
70
-
71
- onWillUpdateFocus({ nativeEvent }) {
72
- const { isActive } = nativeEvent;
73
- this.setState({ isActive });
74
- const { onWillUpdateFocus = noop } = this.props;
75
- onWillUpdateFocus(nativeEvent);
76
- }
77
-
78
- onDidUpdateFocus({ nativeEvent }) {
79
- const { onDidUpdateFocus = noop } = this.props;
80
- onDidUpdateFocus(nativeEvent);
81
- }
82
-
83
- setFocusDisabled(isFocusDisabled) {
84
- if (this.ref) {
85
- this.ref.current.setNativeProps({
86
- isFocusDisabled,
87
- });
88
- }
89
- }
90
-
91
38
  render() {
92
39
  const {
93
40
  children,
94
41
  id,
95
42
  isFocusDisabled,
96
43
  initialItemId,
97
- resetFocusToInitialValue,
98
- style,
44
+ isPreferredFocusDisabled,
45
+ style = {},
99
46
  groupId,
100
47
  ...otherProps
101
48
  } = this.props;
102
49
 
103
- const focusableStyles = style || {};
50
+ const onGroupFocus = ({ nativeEvent }: FocusableGroupNativeEvent) => {
51
+ log_verbose("FOCUSABLE_GROUP: onGroupFocus", { nativeEvent });
52
+ this.onFocus(this.ref, nativeEvent.focusHeading);
53
+ };
54
+
55
+ const onGroupBlur = ({ nativeEvent }: FocusableGroupNativeEvent) => {
56
+ log_verbose("FOCUSABLE_GROUP: onGroupBlur", { nativeEvent });
57
+ this.onBlur(this.ref, nativeEvent.focusHeading);
58
+ };
104
59
 
105
60
  return (
106
61
  <FocusableGroupNative
@@ -109,15 +64,11 @@ export class FocusableGroup extends BaseFocusable<Props> {
109
64
  ref={this.ref}
110
65
  isFocusDisabled={isFocusDisabled}
111
66
  initialItemId={initialItemId}
112
- resetFocusToInitialValue={resetFocusToInitialValue}
113
- onLayout={this.measureView}
114
- onViewFocus={this.onFocus}
115
- onViewPress={this.onPress}
116
- onViewBlur={this.onBlur}
117
- style={focusableStyles}
67
+ isPreferredFocusDisabled={isPreferredFocusDisabled}
68
+ onGroupFocus={onGroupFocus}
69
+ onGroupBlur={onGroupBlur}
70
+ style={style}
118
71
  {...otherProps}
119
- onWillUpdateFocus={this.onWillUpdateFocus}
120
- onDidUpdateFocus={this.onDidUpdateFocus}
121
72
  >
122
73
  {children}
123
74
  </FocusableGroupNative>
@@ -16,12 +16,10 @@ type Props = {
16
16
  prioritiseFocusOn?: number;
17
17
  groupId?: string;
18
18
  hasTVPreferredFocus?: boolean;
19
- resetFocusToInitialValue?: boolean;
19
+ isPreferredFocusDisabled?: boolean;
20
20
  onFocus?: () => void;
21
21
  onBlur?: () => void;
22
- onWillUpdateFocus?: (event?: any) => void;
23
22
  willReceiveFocus?: (event?: any) => void;
24
- onDidUpdateFocus?: (event?: any) => void;
25
23
  hasLostFocus?: any;
26
24
  nextFocusUp?: any;
27
25
  nextFocusDown?: any;
@@ -87,7 +87,6 @@ function FocusableListComponent<ItemT>(props: Props<ItemT>, ref) {
87
87
  initialFocusDirection = "down",
88
88
  data = [],
89
89
  // eslint-disable-next-line unused-imports/no-unused-vars
90
- onAllComponentsLoaded, // TODO: re-implement it
91
90
  omitPropsPropagation = [],
92
91
  } = props;
93
92
 
@@ -16,6 +16,15 @@ import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Co
16
16
  import { Provider } from "react-redux";
17
17
  import configureStore from "redux-mock-store";
18
18
 
19
+ jest.mock(
20
+ "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute",
21
+ () => ({
22
+ useRoute: jest.fn().mockReturnValue({
23
+ pathname: "/home",
24
+ }),
25
+ })
26
+ );
27
+
19
28
  const homeStack = {
20
29
  route: "/home",
21
30
  state: {
@@ -9,7 +9,7 @@ import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
9
9
  import { isEmptyOrNil } from "@applicaster/zapp-react-native-utils/cellUtils";
10
10
  import { Categories } from "./logger";
11
11
  import { createLogger } from "@applicaster/zapp-react-native-utils/logger";
12
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
12
+ import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useRoute";
13
13
  import {
14
14
  ZappPipesEntryContext,
15
15
  ZappPipesScreenContext,
@@ -39,6 +39,7 @@ jest.mock(
39
39
  );
40
40
 
41
41
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
42
+ ...jest.requireActual<any>("@applicaster/zapp-react-native-utils/theme"),
42
43
  useTheme: () => ({}),
43
44
  }));
44
45
 
@@ -3,7 +3,7 @@
3
3
  exports[`LayoutContainer renders 1`] = `
4
4
  <View
5
5
  style={
6
- Object {
6
+ {
7
7
  "flex": 1,
8
8
  "height": 1080,
9
9
  "width": 1920,
@@ -3,14 +3,14 @@
3
3
  exports[`NavBarContainer renders 1`] = `
4
4
  <View
5
5
  style={
6
- Array [
7
- Object {
6
+ [
7
+ {
8
8
  "position": "absolute",
9
9
  "top": 0,
10
10
  "width": 1920,
11
11
  "zIndex": 10,
12
12
  },
13
- Object {
13
+ {
14
14
  "maxHeight": 10,
15
15
  },
16
16
  ]
@@ -4,8 +4,8 @@ exports[`ScreenContainer renders 1`] = `
4
4
  <RNCSafeAreaProvider
5
5
  onInsetsChange={[Function]}
6
6
  style={
7
- Array [
8
- Object {
7
+ [
8
+ {
9
9
  "flex": 1,
10
10
  },
11
11
  undefined,
@@ -14,14 +14,14 @@ exports[`ScreenContainer renders 1`] = `
14
14
  >
15
15
  <View
16
16
  style={
17
- Array [
18
- Object {
17
+ [
18
+ {
19
19
  "position": "absolute",
20
20
  "top": 0,
21
21
  "width": 1920,
22
22
  "zIndex": 10,
23
23
  },
24
- Object {
24
+ {
25
25
  "maxHeight": 10,
26
26
  },
27
27
  ]
@@ -30,7 +30,7 @@ exports[`ScreenContainer renders 1`] = `
30
30
  >
31
31
  <View
32
32
  isVisible={true}
33
- menuPlugin={Object {}}
33
+ menuPlugin={{}}
34
34
  navigationProps={null}
35
35
  />
36
36
  </View>
@@ -38,13 +38,13 @@ exports[`ScreenContainer renders 1`] = `
38
38
  `;
39
39
 
40
40
  exports[`ScreenContainer sets margins provided by the theme 1`] = `
41
- Array [
42
- Object {
41
+ [
42
+ {
43
43
  "flex": 1,
44
44
  "height": "100%",
45
45
  "width": "100%",
46
46
  },
47
- Object {
47
+ {
48
48
  "backgroundColor": "transparent",
49
49
  "marginBottom": 10,
50
50
  "paddingBottom": 0,
@@ -8,7 +8,7 @@ exports[`Layout TV renders 1`] = `
8
8
  >
9
9
  <View
10
10
  Components={
11
- Object {
11
+ {
12
12
  "Background": [Function],
13
13
  "NavBar": [Function],
14
14
  }