@applicaster/zapp-react-native-ui-components 16.0.0-alpha.9225550512 → 16.0.0-alpha.9338540010

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 (111) hide show
  1. package/Components/AudioPlayer/tv/__tests__/audioPlayer.test.js +19 -0
  2. package/Components/AudioPlayer/tv/__tests__/index.test.tsx +120 -0
  3. package/Components/AudioPlayer/tv/index.tsx +5 -1
  4. package/Components/Cell/Cell.tsx +3 -6
  5. package/Components/Cell/TvOSCellComponent.tsx +0 -1
  6. package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +15 -0
  7. package/Components/GeneralContentScreen/hookAdapter/__tests__/skipExpression.test.ts +294 -0
  8. package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +64 -0
  9. package/Components/GeneralContentScreen/hookAdapter/skipExpression.ts +252 -0
  10. package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +18 -0
  11. package/Components/LinkHandler/LinkHandler.tsx +2 -7
  12. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +5 -1
  13. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/ActionButtonController.tsx +19 -4
  14. package/Components/MasterCell/DefaultComponents/ActionButtonsCore/components/__tests__/ActionButtonController.test.tsx +43 -1
  15. package/Components/MasterCell/DefaultComponents/Button.tsx +1 -0
  16. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
  17. package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
  18. package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
  19. package/Components/MasterCell/DefaultComponents/LiveImage/executePreloadHooks.ts +2 -4
  20. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +14 -6
  21. package/Components/MasterCell/DefaultComponents/Toggle.tsx +36 -14
  22. package/Components/MasterCell/DefaultComponents/__tests__/Toggle.test.tsx +167 -0
  23. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +1 -1
  24. package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +4 -2
  25. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/__tests__/factory.test.ts +32 -0
  26. package/Components/MasterCell/__tests__/masterCell.test.js +60 -0
  27. package/Components/MasterCell/index.tsx +28 -4
  28. package/Components/MasterCell/utils/__tests__/withoutFocusedState.test.js +20 -0
  29. package/Components/MasterCell/utils/index.ts +18 -0
  30. package/Components/ModalComponent/ActionsBottomSheet/ActionButton.tsx +56 -0
  31. package/Components/ModalComponent/ActionsBottomSheet/__tests__/openActionsBottomSheet.test.ts +38 -0
  32. package/Components/ModalComponent/ActionsBottomSheet/boundActionButton.tsx +24 -0
  33. package/Components/ModalComponent/ActionsBottomSheet/index.ts +9 -0
  34. package/Components/ModalComponent/ActionsBottomSheet/openActionsBottomSheet.ts +61 -0
  35. package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +87 -97
  36. package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +87 -126
  37. package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +140 -83
  38. package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +274 -124
  39. package/Components/ModalComponent/AudioPlayer/Components/NowPlayingHeaderSection.tsx +205 -0
  40. package/Components/ModalComponent/AudioPlayer/Components/__tests__/Item.test.tsx +164 -0
  41. package/Components/ModalComponent/AudioPlayer/Components/__tests__/NowPlayingHeaderSection.test.tsx +36 -0
  42. package/Components/ModalComponent/AudioPlayer/Components/index.ts +3 -3
  43. package/Components/ModalComponent/AudioPlayer/utils/__tests__/mergeStyles.test.ts +433 -0
  44. package/Components/ModalComponent/AudioPlayer/utils/mergeStyles.ts +563 -0
  45. package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
  46. package/Components/ModalComponent/BottomSheetModalContent.tsx +440 -66
  47. package/Components/ModalComponent/Button/index.tsx +5 -3
  48. package/Components/ModalComponent/Header/CloseButton.tsx +12 -0
  49. package/Components/ModalComponent/Header/__tests__/CloseButton.test.tsx +72 -0
  50. package/Components/ModalComponent/Header/index.tsx +20 -7
  51. package/Components/ModalComponent/Header/utils.ts +1 -1
  52. package/Components/ModalComponent/ModalBlocksStyleContext.tsx +10 -0
  53. package/Components/ModalComponent/SortableList.tsx +156 -0
  54. package/Components/ModalComponent/SortableList.web.tsx +34 -0
  55. package/Components/ModalComponent/TextInputContent.tsx +135 -0
  56. package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
  57. package/Components/ModalComponent/__tests__/BottomSheetModalContent.test.tsx +343 -0
  58. package/Components/ModalComponent/__tests__/SortableList.web.test.tsx +16 -0
  59. package/Components/ModalComponent/__tests__/TextInputContent.test.tsx +169 -0
  60. package/Components/ModalComponent/__tests__/showTextInput.test.ts +120 -0
  61. package/Components/ModalComponent/index.tsx +18 -9
  62. package/Components/ModalComponent/presets/__tests__/getCell.test.ts +90 -0
  63. package/Components/ModalComponent/presets/dynamicCollectionCell.tsx +78 -0
  64. package/Components/ModalComponent/presets/index.ts +27 -0
  65. package/Components/ModalComponent/presets/selectableCell.tsx +28 -0
  66. package/Components/ModalComponent/presets/standardCell.tsx +41 -0
  67. package/Components/ModalComponent/presets/types.ts +35 -0
  68. package/Components/ModalComponent/showTextInput.ts +54 -0
  69. package/Components/ModalComponent/utils.ts +82 -21
  70. package/Components/OfflineHandler/__tests__/index.test.tsx +109 -0
  71. package/Components/OfflineHandler/hooks.ts +0 -12
  72. package/Components/OfflineHandler/index.tsx +42 -4
  73. package/Components/PlayerContainer/PlayerContainer.tsx +19 -8
  74. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -4
  75. package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +66 -13
  76. package/Components/River/ComponentsMap/ComponentsMap.tsx +89 -60
  77. package/Components/River/River.tsx +4 -0
  78. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +140 -75
  79. package/Components/River/__tests__/componentsMap.test.js +8 -3
  80. package/Components/River/__tests__/resultCallback.test.tsx +47 -0
  81. package/Components/Screen/__tests__/Screen.test.tsx +24 -0
  82. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +2 -0
  83. package/Components/Screen/index.tsx +5 -0
  84. package/Components/Screen/navigationHandler.ts +8 -8
  85. package/Components/ScreenRevealManager/ScreenRevealManager.ts +18 -2
  86. package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +36 -0
  87. package/Components/ScreenRevealManager/__tests__/withScreenRevealManager.test.tsx +56 -0
  88. package/Components/ScreenRevealManager/withScreenRevealManager.tsx +21 -4
  89. package/Components/Transitioner/AnimationManager.js +1 -1
  90. package/Components/Transitioner/Scene.tsx +4 -3
  91. package/Components/Transitioner/Transitioner.tsx +71 -33
  92. package/Components/Transitioner/__tests__/transitioner.test.js +372 -3
  93. package/Components/VideoLive/LiveImageManager.ts +9 -3
  94. package/Components/VideoLive/__tests__/LiveImageManager.test.ts +59 -0
  95. package/Components/VideoModal/PlayerWrapper.tsx +4 -1
  96. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
  97. package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +58 -0
  98. package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +16 -0
  99. package/Components/VideoModal/playerWrapperStyle.ts +21 -3
  100. package/Components/VideoModal/playerWrapperUtils.ts +7 -1
  101. package/Contexts/ModalNavigationContext/__tests__/index.test.tsx +15 -0
  102. package/Contexts/ModalNavigationContext/index.tsx +2 -2
  103. package/Decorators/ZappPipesDataConnector/__tests__/screenToolbox.test.ts +347 -0
  104. package/Decorators/ZappPipesDataConnector/__tests__/screenToolboxUnavailable.test.ts +53 -0
  105. package/Decorators/ZappPipesDataConnector/index.tsx +19 -4
  106. package/Decorators/ZappPipesDataConnector/screenToolbox.ts +384 -0
  107. package/Hooks/useEntryActionsExpander.ts +63 -0
  108. package/assets/empty-Info.png +0 -0
  109. package/package.json +6 -5
  110. package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +0 -332
  111. /package/Decorators/ZappPipesDataConnector/__tests__/{Hero.js → Hero.tsx} +0 -0
@@ -14,95 +14,125 @@ exports[`componentsMap renders renders components map correctly 1`] = `
14
14
  >
15
15
  <RCTScrollView
16
16
  ListFooterComponent={
17
- <Memo(RiverFooterComponent)
18
- flatListHeight={null}
19
- loadingState={
20
- BehaviorSubject {
21
- "_value": {
22
- "done": false,
23
- "index": -1,
24
- "waitForAllComponents": false,
25
- },
26
- "closed": false,
27
- "currentObservers": null,
28
- "hasError": false,
29
- "isStopped": false,
30
- "observers": [
31
- SafeSubscriber {
32
- "_finalizers": [
33
- Subscription {
34
- "_finalizers": null,
35
- "_parentage": [Circular],
36
- "closed": false,
37
- "initialTeardown": [Function],
38
- },
39
- ],
40
- "_parentage": null,
41
- "closed": false,
42
- "destination": ConsumerObserver {
43
- "partialObserver": {
44
- "complete": undefined,
45
- "error": undefined,
46
- "next": [Function],
47
- },
48
- },
49
- "initialTeardown": undefined,
50
- "isStopped": false,
17
+ <React.Fragment>
18
+ <Memo(RiverFooterComponent)
19
+ flatListHeight={null}
20
+ loadingState={
21
+ BehaviorSubject {
22
+ "_value": {
23
+ "done": false,
24
+ "index": -1,
25
+ "waitForAllComponents": false,
51
26
  },
52
- SafeSubscriber {
53
- "_finalizers": [
54
- Subscription {
55
- "_finalizers": null,
56
- "_parentage": [Circular],
57
- "closed": false,
58
- "initialTeardown": [Function],
59
- },
60
- ],
61
- "_parentage": null,
62
- "closed": false,
63
- "destination": ConsumerObserver {
64
- "partialObserver": {
65
- "complete": undefined,
66
- "error": undefined,
67
- "next": [Function],
27
+ "closed": false,
28
+ "currentObservers": null,
29
+ "hasError": false,
30
+ "isStopped": false,
31
+ "observers": [
32
+ SafeSubscriber {
33
+ "_finalizers": [
34
+ Subscription {
35
+ "_finalizers": null,
36
+ "_parentage": [Circular],
37
+ "closed": false,
38
+ "initialTeardown": [Function],
39
+ },
40
+ ],
41
+ "_parentage": null,
42
+ "closed": false,
43
+ "destination": ConsumerObserver {
44
+ "partialObserver": {
45
+ "complete": undefined,
46
+ "error": undefined,
47
+ "next": [Function],
48
+ },
68
49
  },
50
+ "initialTeardown": undefined,
51
+ "isStopped": false,
69
52
  },
70
- "initialTeardown": undefined,
71
- "isStopped": false,
72
- },
73
- SafeSubscriber {
74
- "_finalizers": [
75
- Subscription {
76
- "_finalizers": null,
77
- "_parentage": [Circular],
78
- "closed": false,
79
- "initialTeardown": [Function],
53
+ SafeSubscriber {
54
+ "_finalizers": [
55
+ Subscription {
56
+ "_finalizers": null,
57
+ "_parentage": [Circular],
58
+ "closed": false,
59
+ "initialTeardown": [Function],
60
+ },
61
+ ],
62
+ "_parentage": null,
63
+ "closed": false,
64
+ "destination": ConsumerObserver {
65
+ "partialObserver": {
66
+ "complete": undefined,
67
+ "error": undefined,
68
+ "next": [Function],
69
+ },
80
70
  },
81
- ],
82
- "_parentage": null,
83
- "closed": false,
84
- "destination": ConsumerObserver {
85
- "partialObserver": {
86
- "complete": undefined,
87
- "error": undefined,
88
- "next": [Function],
71
+ "initialTeardown": undefined,
72
+ "isStopped": false,
73
+ },
74
+ SafeSubscriber {
75
+ "_finalizers": [
76
+ Subscription {
77
+ "_finalizers": null,
78
+ "_parentage": [Circular],
79
+ "closed": false,
80
+ "initialTeardown": [Function],
81
+ },
82
+ ],
83
+ "_parentage": null,
84
+ "closed": false,
85
+ "destination": ConsumerObserver {
86
+ "partialObserver": {
87
+ "complete": undefined,
88
+ "error": undefined,
89
+ "next": [Function],
90
+ },
89
91
  },
92
+ "initialTeardown": undefined,
93
+ "isStopped": false,
90
94
  },
91
- "initialTeardown": undefined,
92
- "isStopped": false,
93
- },
94
- ],
95
- "thrownError": null,
95
+ ],
96
+ "thrownError": null,
97
+ }
98
+ }
99
+ />
100
+ <View
101
+ edges={
102
+ {
103
+ "bottom": "off",
104
+ }
105
+ }
106
+ mode="margin"
107
+ style={
108
+ {
109
+ "height": 0.5,
110
+ "paddingBottom": undefined,
111
+ }
112
+ }
113
+ />
114
+ </React.Fragment>
115
+ }
116
+ ListHeaderComponent={
117
+ <View
118
+ edges={
119
+ {
120
+ "top": "off",
121
+ }
122
+ }
123
+ mode="margin"
124
+ style={
125
+ {
126
+ "height": 0.5,
127
+ "paddingTop": undefined,
96
128
  }
97
129
  }
98
130
  />
99
131
  }
100
132
  contentContainerStyle={
101
133
  {
102
- "paddingBottom": undefined,
103
134
  "paddingLeft": undefined,
104
135
  "paddingRight": undefined,
105
- "paddingTop": undefined,
106
136
  }
107
137
  }
108
138
  data={
@@ -156,6 +186,25 @@ exports[`componentsMap renders renders components map correctly 1`] = `
156
186
  windowSize={12}
157
187
  >
158
188
  <View>
189
+ <View
190
+ collapsable={false}
191
+ onLayout={[Function]}
192
+ >
193
+ <View
194
+ edges={
195
+ {
196
+ "top": "off",
197
+ }
198
+ }
199
+ mode="margin"
200
+ style={
201
+ {
202
+ "height": 0.5,
203
+ "paddingTop": undefined,
204
+ }
205
+ }
206
+ />
207
+ </View>
159
208
  <View
160
209
  onFocusCapture={[Function]}
161
210
  onLayout={[Function]}
@@ -164,6 +213,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
164
213
  <View
165
214
  onLayout={[Function]}
166
215
  style={{}}
216
+ testID="component-A1"
167
217
  >
168
218
  <View />
169
219
  </View>
@@ -176,6 +226,7 @@ exports[`componentsMap renders renders components map correctly 1`] = `
176
226
  <View
177
227
  onLayout={[Function]}
178
228
  style={{}}
229
+ testID="component-A2"
179
230
  />
180
231
  </View>
181
232
  <View
@@ -200,6 +251,20 @@ exports[`componentsMap renders renders components map correctly 1`] = `
200
251
  size="large"
201
252
  />
202
253
  </View>
254
+ <View
255
+ edges={
256
+ {
257
+ "bottom": "off",
258
+ }
259
+ }
260
+ mode="margin"
261
+ style={
262
+ {
263
+ "height": 0.5,
264
+ "paddingBottom": undefined,
265
+ }
266
+ }
267
+ />
203
268
  </View>
204
269
  </View>
205
270
  </RCTScrollView>
@@ -11,9 +11,14 @@ jest.mock(
11
11
  () => () => null
12
12
  );
13
13
 
14
- jest.mock("react-native-safe-area-context", () => ({
15
- useSafeAreaInsets: () => ({ top: 50 }),
16
- }));
14
+ jest.mock("react-native-safe-area-context", () => {
15
+ const { View } = jest.requireActual("react-native");
16
+
17
+ return {
18
+ SafeAreaView: View,
19
+ useSafeAreaInsets: () => ({ top: 50 }),
20
+ };
21
+ });
17
22
 
18
23
  jest.mock("react-native", () => {
19
24
  const RN = jest.genMockFromModule("react-native");
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+
4
+ import { RiverComponent } from "../River";
5
+
6
+ const mockResolverProps: any[] = [];
7
+
8
+ jest.mock("../../ScreenResolver", () => ({
9
+ ScreenResolver: (props: any) => {
10
+ mockResolverProps.push(props);
11
+
12
+ return null;
13
+ },
14
+ }));
15
+
16
+ const river = { id: "river-parent-lock", type: "parent_lock" } as any;
17
+
18
+ const baseProps = {
19
+ river,
20
+ screenData: {},
21
+ groupId: "group-1",
22
+ scrollViewExtraProps: {},
23
+ setIsScreenWrappedInContainer: jest.fn(),
24
+ screenContext: { navBar: { setTitle: jest.fn(), setSummary: jest.fn() } },
25
+ } as any;
26
+
27
+ const resolved = () => mockResolverProps[mockResolverProps.length - 1];
28
+
29
+ describe("RiverComponent", () => {
30
+ beforeEach(() => {
31
+ mockResolverProps.length = 0;
32
+ });
33
+
34
+ it("forwards resultCallback to the screen it resolves", () => {
35
+ const resultCallback = jest.fn();
36
+
37
+ render(<RiverComponent {...baseProps} resultCallback={resultCallback} />);
38
+
39
+ expect(resolved().resultCallback).toBe(resultCallback);
40
+ });
41
+
42
+ it("resolves the screen without a resultCallback when none was given", () => {
43
+ render(<RiverComponent {...baseProps} />);
44
+
45
+ expect(resolved().resultCallback).toBeUndefined();
46
+ });
47
+ });
@@ -141,6 +141,10 @@ const {
141
141
  useGetScreenOrientation,
142
142
  } = require("@applicaster/zapp-react-native-utils/appUtils/orientationHelper");
143
143
 
144
+ const {
145
+ useIsScreenActive,
146
+ } = require("@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive");
147
+
144
148
  const navigator = {};
145
149
  const navBarProps = { nav_items: [] };
146
150
  const screenData = {};
@@ -195,4 +199,24 @@ describe("<Screen Component />", () => {
195
199
  expect(toJSON()).toMatchSnapshot();
196
200
  });
197
201
  });
202
+
203
+ describe("when the screen is inactive", () => {
204
+ afterEach(() => {
205
+ useIsScreenActive.mockReturnValue(true);
206
+ });
207
+
208
+ it("hides the screen from VoiceOver (iOS) and TalkBack (Android)", () => {
209
+ useIsScreenActive.mockReturnValue(false);
210
+
211
+ const { UNSAFE_root } = renderWithProviders(
212
+ <Screen {...screenProps} />,
213
+ store
214
+ );
215
+
216
+ expect(UNSAFE_root.findByType(View).props).toMatchObject({
217
+ accessibilityElementsHidden: true,
218
+ importantForAccessibility: "no-hide-descendants",
219
+ });
220
+ });
221
+ });
198
222
  });
@@ -13,6 +13,7 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
13
13
  }
14
14
  >
15
15
  <View
16
+ accessibilityElementsHidden={false}
16
17
  importantForAccessibility="yes"
17
18
  style={
18
19
  {
@@ -58,6 +59,7 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
58
59
  }
59
60
  >
60
61
  <View
62
+ accessibilityElementsHidden={false}
61
63
  importantForAccessibility="yes"
62
64
  style={
63
65
  {
@@ -121,6 +121,11 @@ export function Screen(_props: Props) {
121
121
  ref={ref}
122
122
  style={style}
123
123
  importantForAccessibility={!isActive ? "no-hide-descendants" : "yes"}
124
+ // `importantForAccessibility` only affects Android (see RN docs).
125
+ // Without the iOS counterpart below, VoiceOver keeps traversing and
126
+ // focusing elements on an inactive/underlying screen (e.g. Albums In
127
+ // Order) even after a new screen (e.g. an Album) is pushed on top.
128
+ accessibilityElementsHidden={!isActive}
124
129
  >
125
130
  {isReady ? (
126
131
  <>
@@ -18,10 +18,9 @@ function shouldShowNavigation(route, screenData) {
18
18
  return false;
19
19
  }
20
20
 
21
- if (
22
- screenData.type === "qb_search_screen" ||
23
- screenData?.targetScreen?.type === "qb_search_screen"
24
- ) {
21
+ const currentScreenData = screenData?.targetScreen || screenData;
22
+
23
+ if (currentScreenData.type === "qb_search_screen") {
25
24
  return false;
26
25
  }
27
26
 
@@ -31,10 +30,11 @@ function shouldShowNavigation(route, screenData) {
31
30
  return hookPlugin?.showNavBar || hookPlugin?.presentFullScreen !== true;
32
31
  }
33
32
 
34
- if (
35
- screenData?.general?.allow_screen_plugin_presentation ||
36
- screenData?.targetScreen?.general?.allow_screen_plugin_presentation
37
- ) {
33
+ if (currentScreenData?.general?.hide_menu) {
34
+ return false;
35
+ }
36
+
37
+ if (currentScreenData?.general?.allow_screen_plugin_presentation) {
38
38
  return false;
39
39
  }
40
40
 
@@ -42,9 +42,25 @@ export class ScreenRevealManager {
42
42
  private subject$ = new Subject<void>();
43
43
  private subscription: Subscription;
44
44
 
45
- constructor(componentsToRender: ZappUIComponent[], callback: Callback) {
45
+ /**
46
+ * @param initialNumberToLoad how many components to wait for before revealing
47
+ * the screen. Staggering exists so a screen full of network-backed components
48
+ * does not load them all at once. A caller that has nothing to stagger - see
49
+ * `disableIncrementalLoading` on the HOC - passes the full count here so the
50
+ * reveal waits for exactly what gets rendered. Omitted, the count is derived
51
+ * from the components themselves.
52
+ */
53
+ constructor(
54
+ componentsToRender: ZappUIComponent[],
55
+ callback: Callback,
56
+ initialNumberToLoad?: number
57
+ ) {
46
58
  this.numberOfComponentsWaitToLoadBeforePresent =
47
- getNumberOfComponentsWaitToLoadBeforePresent(componentsToRender);
59
+ initialNumberToLoad == null
60
+ ? getNumberOfComponentsWaitToLoadBeforePresent(componentsToRender)
61
+ : // Clamped like the computed path: waiting for components that do not
62
+ // exist would hold the screen behind its overlay until the timeout.
63
+ Math.min(initialNumberToLoad, componentsToRender.length);
48
64
 
49
65
  this.renderingState = makeListOf<ComponentLoadingState>(
50
66
  COMPONENT_LOADING_STATE.UNKNOWN,
@@ -22,6 +22,42 @@ import { makeListOf } from "@applicaster/zapp-react-native-utils/arrayUtils";
22
22
  import { isFirstComponentGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
23
23
  import { withTimeout$ } from "@applicaster/zapp-react-native-utils/idleUtils";
24
24
 
25
+ describe("ScreenRevealManager explicit component count", () => {
26
+ beforeEach(() => {
27
+ (isFirstComponentGallery as jest.Mock).mockReturnValue(false);
28
+
29
+ (makeListOf as jest.Mock).mockImplementation((value, length) =>
30
+ Array(length).fill(value)
31
+ );
32
+
33
+ (withTimeout$ as jest.Mock).mockReturnValue(new Subject());
34
+ });
35
+
36
+ it("waits for the number of components it is given, not the computed default", () => {
37
+ const components = Array(6).fill({}) as any;
38
+
39
+ const manager = new ScreenRevealManager(components, jest.fn(), 6);
40
+
41
+ expect(manager.numberOfComponentsWaitToLoadBeforePresent).toBe(6);
42
+ });
43
+
44
+ it("never waits for more components than it was handed", () => {
45
+ const components = Array(3).fill({}) as any;
46
+
47
+ const manager = new ScreenRevealManager(components, jest.fn(), 10);
48
+
49
+ expect(manager.numberOfComponentsWaitToLoadBeforePresent).toBe(3);
50
+ });
51
+
52
+ it("falls back to the computed default when given no explicit count", () => {
53
+ const components = Array(6).fill({}) as any;
54
+
55
+ const manager = new ScreenRevealManager(components, jest.fn());
56
+
57
+ expect(manager.numberOfComponentsWaitToLoadBeforePresent).toBe(3);
58
+ });
59
+ });
60
+
25
61
  describe("ScreenRevealManager", () => {
26
62
  let mockCallback: jest.Mock;
27
63
  let timeout$: Subject<void>;
@@ -9,6 +9,12 @@ import {
9
9
  TIMEOUT,
10
10
  } from "../withScreenRevealManager";
11
11
 
12
+ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
13
+ useTheme: () => ({ app_background_color: "#000000" }),
14
+ }));
15
+
16
+ jest.mock("../Overlay", () => ({ Overlay: () => null }));
17
+
12
18
  // jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
13
19
 
14
20
  const MockComponent = ({
@@ -37,6 +43,56 @@ const MockComponent = ({
37
43
 
38
44
  const WrappedComponent = withScreenRevealManager(MockComponent);
39
45
 
46
+ describe("withScreenRevealManager disableIncrementalLoading", () => {
47
+ const components = (count: number) =>
48
+ Array(count).fill({ component_type: "grid-qb" });
49
+
50
+ beforeEach(() => {
51
+ jest.clearAllMocks();
52
+ });
53
+
54
+ it("asks for every component at once when incremental loading is disabled", () => {
55
+ render(
56
+ <WrappedComponent
57
+ componentsToRender={components(6)}
58
+ disableIncrementalLoading
59
+ />
60
+ );
61
+
62
+ expect(screen.getByTestId("mock-component").props.initialNumberToLoad).toBe(
63
+ 6
64
+ );
65
+ });
66
+
67
+ it("still tracks the component count after it changes", () => {
68
+ const { rerender } = render(
69
+ <WrappedComponent
70
+ componentsToRender={components(6)}
71
+ disableIncrementalLoading
72
+ />
73
+ );
74
+
75
+ rerender(
76
+ <WrappedComponent
77
+ componentsToRender={components(9)}
78
+ disableIncrementalLoading
79
+ />
80
+ );
81
+
82
+ expect(screen.getByTestId("mock-component").props.initialNumberToLoad).toBe(
83
+ 9
84
+ );
85
+ });
86
+
87
+ it("loads incrementally when the flag is not set", () => {
88
+ render(<WrappedComponent componentsToRender={components(6)} />);
89
+
90
+ expect(screen.getByTestId("mock-component").props.initialNumberToLoad).toBe(
91
+ 3
92
+ );
93
+ });
94
+ });
95
+
40
96
  describe.skip("withScreenRevealManager", () => {
41
97
  beforeEach(() => {
42
98
  jest.clearAllMocks();
@@ -21,11 +21,23 @@ export const SHOWN = 1; // opacity = 1
21
21
  type Props = {
22
22
  componentsToRender: ZappUIComponent[];
23
23
  backgroundColor?: string;
24
+ /**
25
+ * Renders every component at once instead of revealing them a few at a time.
26
+ *
27
+ * For a screen that builds its own components and holds all of them already -
28
+ * a form, say - staggering buys nothing and costs: each rebuild of the list
29
+ * tears it back down to the first few and lets the rest crawl in again.
30
+ *
31
+ * This is a flag rather than a count on purpose. A count would have to be
32
+ * re-read whenever the number of components changes, while "do not stagger"
33
+ * stays true whatever the screen ends up holding.
34
+ */
35
+ disableIncrementalLoading?: boolean;
24
36
  };
25
37
 
26
38
  export const withScreenRevealManager = (Component) => {
27
39
  return function WithScreenRevealManager(props: Props) {
28
- const { componentsToRender } = props;
40
+ const { componentsToRender, disableIncrementalLoading } = props;
29
41
 
30
42
  const [isContentReadyToBeShown, setIsContentReadyToBeShown] =
31
43
  React.useState(false);
@@ -42,7 +54,8 @@ export const withScreenRevealManager = (Component) => {
42
54
  () =>
43
55
  new ScreenRevealManager(
44
56
  componentsToRender,
45
- handleSetIsContentReadyToBeShown
57
+ handleSetIsContentReadyToBeShown,
58
+ disableIncrementalLoading ? componentsToRender.length : undefined
46
59
  )
47
60
  );
48
61
 
@@ -72,7 +85,7 @@ export const withScreenRevealManager = (Component) => {
72
85
 
73
86
  if (isFirstComponentScreenPicker(componentsToRender)) {
74
87
  // for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
75
- return <Component {...props} />;
88
+ return <Component {...props} initialNumberToLoad={1} />;
76
89
  }
77
90
 
78
91
  return (
@@ -80,7 +93,11 @@ export const withScreenRevealManager = (Component) => {
80
93
  <Component
81
94
  {...props}
82
95
  initialNumberToLoad={
83
- managerRef.current.numberOfComponentsWaitToLoadBeforePresent
96
+ // Recomputed on every render, so the count follows the components
97
+ // even though the manager settled its own expectation at mount.
98
+ disableIncrementalLoading
99
+ ? componentsToRender.length
100
+ : managerRef.current.numberOfComponentsWaitToLoadBeforePresent
84
101
  }
85
102
  onLoadFinishedFromScreenRevealManager={
86
103
  managerRef.current.onLoadFinished
@@ -66,7 +66,7 @@ export class AnimationManager {
66
66
  *
67
67
  * @param {object} to contains style to animate and scenes index
68
68
  * @param {string} action push|back
69
- * @param {number} stepsBack number of steps back
69
+ * @param {number} [stepsBack] number of steps back, used by the back action only
70
70
  */
71
71
  stateForAction({ to, scenes }, action, stepsBack) {
72
72
  let rootIndex = to.index;
@@ -17,13 +17,14 @@ const fullWidthDimensions = {
17
17
  type Props = {
18
18
  children: any;
19
19
  style: any;
20
- pointerEvents: ViewProps["pointerEvents"];
21
- overlayStyle: ViewStyle;
22
- animating: boolean;
20
+ pointerEvents?: ViewProps["pointerEvents"];
21
+ overlayStyle?: ViewStyle;
22
+ animating?: boolean;
23
23
  contentStyle: ViewStyle;
24
24
  pathname: string;
25
25
  isActive: boolean;
26
26
  screenData: NavigationScreenData;
27
+ screenUniqueId?: string;
27
28
  };
28
29
 
29
30
  export function CurrentScreenContextProvider({