@applicaster/zapp-react-native-ui-components 12.0.0-rc.4 → 12.0.0-rc.41
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.
- package/Components/AnimatedInOut/index.tsx +18 -10
- package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
- package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
- package/Components/AudioPlayer/helpers.tsx +1 -0
- package/Components/Cell/Cell.tsx +2 -2
- package/Components/Cell/CellWithFocusable.tsx +21 -14
- package/Components/Cell/TvOSCellComponent.tsx +2 -2
- package/Components/ErrorScreen/index.tsx +1 -1
- package/Components/FocusableCell/index.tsx +7 -7
- package/Components/FocusableList/FocusableChild.ts +24 -14
- package/Components/FocusableList/FocusableItem.tsx +1 -1
- package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
- package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
- package/Components/FocusableList/index.tsx +26 -25
- package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
- package/Components/HandlePlayable/HandlePlayable.tsx +1 -1
- package/Components/HookRenderer/index.tsx +1 -6
- package/Components/Image/Image.android.tsx +11 -2
- package/Components/Image/Image.tsx +18 -2
- package/Components/Image/utils/index.ts +39 -0
- package/Components/Layout/TV/__tests__/index.test.tsx +1 -34
- package/Components/Layout/TV/index.tsx +20 -36
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +0 -1
- package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +3 -1
- package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
- package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
- package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +8 -10
- package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
- package/Components/ModalComponent/Button/Item.tsx +82 -0
- package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
- package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
- package/Components/ModalComponent/Button/assets.ts +4 -0
- package/Components/ModalComponent/Button/index.tsx +111 -0
- package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
- package/Components/ModalComponent/Header/Title.tsx +70 -0
- package/Components/ModalComponent/Header/assets.ts +4 -0
- package/Components/ModalComponent/Header/index.tsx +71 -0
- package/Components/ModalComponent/Header/utils.ts +79 -0
- package/Components/ModalComponent/index.tsx +38 -0
- package/Components/ModalComponent/utils.ts +126 -0
- package/Components/PlayerContainer/ErrorDisplay/ErrorDisplay.tsx +4 -7
- package/Components/PlayerContainer/PlayerContainer.tsx +52 -28
- package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +25 -0
- package/Components/River/River.tsx +8 -5
- package/Components/River/TV/River.tsx +2 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
- package/Components/River/__tests__/componentsMap.test.js +1 -0
- package/Components/River/useScreenConfiguration.ts +5 -6
- package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
- package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
- package/Components/RouteManager/index.tsx +5 -3
- package/Components/Screen/__tests__/Screen.test.tsx +48 -36
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +20 -6
- package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
- package/Components/Screen/index.tsx +91 -43
- package/Components/Screen/navigationHandler.ts +0 -82
- package/Components/Screen/orientationHandler.ts +1 -1
- package/Components/ScreenResolver/index.tsx +1 -1
- package/Components/Tabs/TV/styles.ts +1 -1
- package/Components/TrackedView/index.tsx +6 -3
- package/Components/VideoLive/LiveImageManager.ts +42 -13
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +81 -72
- package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +30 -3
- package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +22 -27
- package/Components/VideoModal/PlayerDetails.tsx +3 -0
- package/Components/VideoModal/PlayerWrapper.tsx +66 -63
- package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +4 -4
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +202 -162
- package/Components/VideoModal/hooks/useModalSize.ts +13 -4
- package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
- package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
- package/Components/ZappUIComponent/index.tsx +22 -12
- package/Components/index.js +2 -0
- package/Contexts/ScreenContext/index.tsx +1 -4
- package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
- package/Decorators/RiverResolver/index.tsx +0 -4
- package/Decorators/index.tsx +0 -4
- package/package.json +5 -6
|
@@ -1,257 +1,297 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`PlayerWrapper renders inline 1`] = `
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
Object {
|
|
7
|
-
"bottom": "off",
|
|
8
|
-
"left": "off",
|
|
9
|
-
"right": "off",
|
|
10
|
-
"top": "additive",
|
|
11
|
-
}
|
|
12
|
-
}
|
|
4
|
+
<RNCSafeAreaProvider
|
|
5
|
+
onInsetsChange={[Function]}
|
|
13
6
|
style={
|
|
14
7
|
Array [
|
|
15
8
|
Object {
|
|
16
|
-
"
|
|
17
|
-
},
|
|
18
|
-
Object {
|
|
19
|
-
"backgroundColor": "transparent",
|
|
20
|
-
},
|
|
21
|
-
Object {
|
|
22
|
-
"height": 800,
|
|
23
|
-
"width": 300,
|
|
9
|
+
"flex": 1,
|
|
24
10
|
},
|
|
25
|
-
|
|
11
|
+
undefined,
|
|
26
12
|
]
|
|
27
13
|
}
|
|
28
14
|
>
|
|
29
|
-
<
|
|
15
|
+
<RNCSafeAreaView
|
|
16
|
+
edges={
|
|
17
|
+
Object {
|
|
18
|
+
"bottom": "off",
|
|
19
|
+
"left": "off",
|
|
20
|
+
"right": "off",
|
|
21
|
+
"top": "additive",
|
|
22
|
+
}
|
|
23
|
+
}
|
|
30
24
|
style={
|
|
31
25
|
Array [
|
|
32
26
|
Object {
|
|
33
|
-
"
|
|
34
|
-
"position": "relative",
|
|
35
|
-
"zIndex": 200,
|
|
27
|
+
"flexDirection": "column",
|
|
36
28
|
},
|
|
37
29
|
Object {
|
|
38
|
-
"
|
|
39
|
-
"width": 300,
|
|
30
|
+
"backgroundColor": "transparent",
|
|
40
31
|
},
|
|
41
|
-
Object {},
|
|
42
32
|
Object {
|
|
43
|
-
"height":
|
|
33
|
+
"height": 800,
|
|
34
|
+
"width": 300,
|
|
44
35
|
},
|
|
45
36
|
Object {},
|
|
46
37
|
]
|
|
47
38
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
39
|
+
>
|
|
40
|
+
<View
|
|
41
|
+
style={
|
|
42
|
+
Array [
|
|
43
|
+
Object {
|
|
44
|
+
"alignSelf": "center",
|
|
45
|
+
"position": "relative",
|
|
46
|
+
"zIndex": 200,
|
|
47
|
+
},
|
|
48
|
+
Object {
|
|
49
|
+
"aspectRatio": 1.7777777777777777,
|
|
50
|
+
"height": undefined,
|
|
51
|
+
"width": "100%",
|
|
52
|
+
},
|
|
53
|
+
Object {},
|
|
54
|
+
Object {},
|
|
55
|
+
]
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
testID="test-player-container"
|
|
58
|
+
/>
|
|
59
|
+
<View
|
|
60
|
+
configuration={
|
|
61
|
+
Object {
|
|
62
|
+
"tablet_landscape_player_container_background_color": "red",
|
|
63
|
+
"tablet_landscape_sidebar_width": "35%",
|
|
64
|
+
}
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"flex": 1,
|
|
66
|
-
"paddingTop": 20,
|
|
66
|
+
entry={
|
|
67
|
+
Object {
|
|
68
|
+
"id": "test",
|
|
69
|
+
}
|
|
67
70
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
isTabletLandscape={false}
|
|
72
|
+
style={
|
|
73
|
+
Object {
|
|
74
|
+
"flex": 1,
|
|
75
|
+
"paddingTop": 20,
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/>
|
|
79
|
+
</RNCSafeAreaView>
|
|
80
|
+
</RNCSafeAreaProvider>
|
|
71
81
|
`;
|
|
72
82
|
|
|
73
83
|
exports[`PlayerWrapper renders inline and docked 1`] = `
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
Object {
|
|
77
|
-
"bottom": "additive",
|
|
78
|
-
"left": "off",
|
|
79
|
-
"right": "off",
|
|
80
|
-
"top": "off",
|
|
81
|
-
}
|
|
82
|
-
}
|
|
84
|
+
<RNCSafeAreaProvider
|
|
85
|
+
onInsetsChange={[Function]}
|
|
83
86
|
style={
|
|
84
87
|
Array [
|
|
85
88
|
Object {
|
|
86
|
-
"
|
|
87
|
-
},
|
|
88
|
-
Object {
|
|
89
|
-
"backgroundColor": "transparent",
|
|
90
|
-
},
|
|
91
|
-
Object {
|
|
92
|
-
"height": 50,
|
|
93
|
-
"width": 300,
|
|
89
|
+
"flex": 1,
|
|
94
90
|
},
|
|
95
|
-
|
|
91
|
+
undefined,
|
|
96
92
|
]
|
|
97
93
|
}
|
|
98
94
|
>
|
|
99
|
-
<
|
|
95
|
+
<RNCSafeAreaView
|
|
96
|
+
edges={
|
|
97
|
+
Object {
|
|
98
|
+
"bottom": "additive",
|
|
99
|
+
"left": "off",
|
|
100
|
+
"right": "off",
|
|
101
|
+
"top": "off",
|
|
102
|
+
}
|
|
103
|
+
}
|
|
100
104
|
style={
|
|
101
105
|
Array [
|
|
102
106
|
Object {
|
|
103
|
-
"
|
|
104
|
-
"position": "relative",
|
|
105
|
-
"zIndex": 200,
|
|
107
|
+
"flexDirection": "column",
|
|
106
108
|
},
|
|
107
109
|
Object {
|
|
108
|
-
"
|
|
109
|
-
"width": 300,
|
|
110
|
+
"backgroundColor": "transparent",
|
|
110
111
|
},
|
|
111
|
-
Object {},
|
|
112
112
|
Object {
|
|
113
113
|
"height": 50,
|
|
114
|
+
"width": 300,
|
|
114
115
|
},
|
|
115
116
|
Object {},
|
|
116
117
|
]
|
|
117
118
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
>
|
|
120
|
+
<View
|
|
121
|
+
style={
|
|
122
|
+
Array [
|
|
123
|
+
Object {
|
|
124
|
+
"alignSelf": "center",
|
|
125
|
+
"position": "relative",
|
|
126
|
+
"zIndex": 200,
|
|
127
|
+
},
|
|
128
|
+
Object {
|
|
129
|
+
"aspectRatio": undefined,
|
|
130
|
+
"height": 50,
|
|
131
|
+
"width": "100%",
|
|
132
|
+
},
|
|
133
|
+
Object {},
|
|
134
|
+
Object {},
|
|
135
|
+
]
|
|
125
136
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
testID="test-player-container"
|
|
138
|
+
/>
|
|
139
|
+
<View
|
|
140
|
+
style={
|
|
141
|
+
Object {
|
|
142
|
+
"flex": 1,
|
|
143
|
+
"paddingTop": 20,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/>
|
|
147
|
+
</RNCSafeAreaView>
|
|
148
|
+
</RNCSafeAreaProvider>
|
|
129
149
|
`;
|
|
130
150
|
|
|
131
151
|
exports[`PlayerWrapper renders inline on tablet in landscape orientation 1`] = `
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
Object {
|
|
135
|
-
"bottom": "off",
|
|
136
|
-
"left": "off",
|
|
137
|
-
"right": "off",
|
|
138
|
-
"top": "additive",
|
|
139
|
-
}
|
|
140
|
-
}
|
|
152
|
+
<RNCSafeAreaProvider
|
|
153
|
+
onInsetsChange={[Function]}
|
|
141
154
|
style={
|
|
142
155
|
Array [
|
|
143
156
|
Object {
|
|
144
|
-
"
|
|
145
|
-
},
|
|
146
|
-
Object {
|
|
147
|
-
"backgroundColor": "red",
|
|
148
|
-
},
|
|
149
|
-
Object {
|
|
150
|
-
"height": 800,
|
|
151
|
-
"width": 300,
|
|
157
|
+
"flex": 1,
|
|
152
158
|
},
|
|
153
|
-
|
|
159
|
+
undefined,
|
|
154
160
|
]
|
|
155
161
|
}
|
|
156
162
|
>
|
|
157
|
-
<
|
|
163
|
+
<RNCSafeAreaView
|
|
164
|
+
edges={
|
|
165
|
+
Object {
|
|
166
|
+
"bottom": "off",
|
|
167
|
+
"left": "off",
|
|
168
|
+
"right": "off",
|
|
169
|
+
"top": "additive",
|
|
170
|
+
}
|
|
171
|
+
}
|
|
158
172
|
style={
|
|
159
173
|
Array [
|
|
160
174
|
Object {
|
|
161
|
-
"
|
|
162
|
-
"position": "relative",
|
|
163
|
-
"zIndex": 200,
|
|
175
|
+
"flexDirection": "row",
|
|
164
176
|
},
|
|
165
177
|
Object {
|
|
166
|
-
"
|
|
167
|
-
"width": 195,
|
|
178
|
+
"backgroundColor": "red",
|
|
168
179
|
},
|
|
169
|
-
Object {},
|
|
170
180
|
Object {
|
|
171
|
-
"height":
|
|
181
|
+
"height": 800,
|
|
182
|
+
"width": 300,
|
|
172
183
|
},
|
|
173
184
|
Object {},
|
|
174
185
|
]
|
|
175
186
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
187
|
+
>
|
|
188
|
+
<View
|
|
189
|
+
style={
|
|
190
|
+
Array [
|
|
191
|
+
Object {
|
|
192
|
+
"alignSelf": "center",
|
|
193
|
+
"position": "relative",
|
|
194
|
+
"zIndex": 200,
|
|
195
|
+
},
|
|
196
|
+
Object {
|
|
197
|
+
"aspectRatio": 1.7777777777777777,
|
|
198
|
+
"height": undefined,
|
|
199
|
+
"width": 195,
|
|
200
|
+
},
|
|
201
|
+
Object {},
|
|
202
|
+
Object {},
|
|
203
|
+
]
|
|
183
204
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
205
|
+
testID="test-player-container"
|
|
206
|
+
/>
|
|
207
|
+
<View
|
|
208
|
+
configuration={
|
|
209
|
+
Object {
|
|
210
|
+
"tablet_landscape_player_container_background_color": "red",
|
|
211
|
+
"tablet_landscape_sidebar_width": "35%",
|
|
212
|
+
}
|
|
188
213
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
"flex": 1,
|
|
194
|
-
"paddingTop": 20,
|
|
214
|
+
entry={
|
|
215
|
+
Object {
|
|
216
|
+
"id": "test",
|
|
217
|
+
}
|
|
195
218
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
219
|
+
isTabletLandscape={true}
|
|
220
|
+
style={
|
|
221
|
+
Object {
|
|
222
|
+
"flex": 1,
|
|
223
|
+
"paddingTop": 20,
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/>
|
|
227
|
+
</RNCSafeAreaView>
|
|
228
|
+
</RNCSafeAreaProvider>
|
|
199
229
|
`;
|
|
200
230
|
|
|
201
231
|
exports[`PlayerWrapper renders properly 1`] = `
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
Object {
|
|
205
|
-
"bottom": "off",
|
|
206
|
-
"left": "off",
|
|
207
|
-
"right": "off",
|
|
208
|
-
"top": "additive",
|
|
209
|
-
}
|
|
210
|
-
}
|
|
232
|
+
<RNCSafeAreaProvider
|
|
233
|
+
onInsetsChange={[Function]}
|
|
211
234
|
style={
|
|
212
235
|
Array [
|
|
213
236
|
Object {
|
|
214
|
-
"
|
|
215
|
-
},
|
|
216
|
-
Object {
|
|
217
|
-
"backgroundColor": "transparent",
|
|
218
|
-
},
|
|
219
|
-
Object {
|
|
220
|
-
"height": 800,
|
|
221
|
-
"width": 300,
|
|
237
|
+
"flex": 1,
|
|
222
238
|
},
|
|
223
|
-
|
|
239
|
+
undefined,
|
|
224
240
|
]
|
|
225
241
|
}
|
|
226
242
|
>
|
|
227
|
-
<
|
|
243
|
+
<RNCSafeAreaView
|
|
244
|
+
edges={
|
|
245
|
+
Object {
|
|
246
|
+
"bottom": "off",
|
|
247
|
+
"left": "off",
|
|
248
|
+
"right": "off",
|
|
249
|
+
"top": "additive",
|
|
250
|
+
}
|
|
251
|
+
}
|
|
228
252
|
style={
|
|
229
253
|
Array [
|
|
230
254
|
Object {
|
|
231
|
-
"
|
|
232
|
-
"position": "relative",
|
|
233
|
-
"zIndex": 200,
|
|
255
|
+
"flexDirection": "column",
|
|
234
256
|
},
|
|
235
257
|
Object {
|
|
236
|
-
"
|
|
237
|
-
"width": 300,
|
|
258
|
+
"backgroundColor": "transparent",
|
|
238
259
|
},
|
|
239
|
-
Object {},
|
|
240
260
|
Object {
|
|
241
261
|
"height": 800,
|
|
262
|
+
"width": 300,
|
|
242
263
|
},
|
|
243
264
|
Object {},
|
|
244
265
|
]
|
|
245
266
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
267
|
+
>
|
|
268
|
+
<View
|
|
269
|
+
style={
|
|
270
|
+
Array [
|
|
271
|
+
Object {
|
|
272
|
+
"alignSelf": "center",
|
|
273
|
+
"position": "relative",
|
|
274
|
+
"zIndex": 200,
|
|
275
|
+
},
|
|
276
|
+
Object {
|
|
277
|
+
"aspectRatio": 1.7786666666666666,
|
|
278
|
+
"height": undefined,
|
|
279
|
+
"width": "100%",
|
|
280
|
+
},
|
|
281
|
+
Object {},
|
|
282
|
+
Object {},
|
|
283
|
+
]
|
|
253
284
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
285
|
+
testID="test-player-container"
|
|
286
|
+
/>
|
|
287
|
+
<View
|
|
288
|
+
style={
|
|
289
|
+
Object {
|
|
290
|
+
"flex": 1,
|
|
291
|
+
"paddingTop": 20,
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
/>
|
|
295
|
+
</RNCSafeAreaView>
|
|
296
|
+
</RNCSafeAreaProvider>
|
|
257
297
|
`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { Dimensions } from "react-native";
|
|
3
3
|
import { useIsTabletLandscape } from "@applicaster/zapp-react-native-utils/reactHooks/device/useMemoizedIsTablet";
|
|
4
4
|
import {
|
|
@@ -39,13 +39,22 @@ export const useModalSize = (): Size => {
|
|
|
39
39
|
MODAL_SIZE_FOR_PORTRAIT
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
const setNewModalSize = (
|
|
43
|
-
setModalSize(
|
|
42
|
+
const setNewModalSize = React.useCallback((newSize, log) => {
|
|
43
|
+
setModalSize((oldSize) => {
|
|
44
|
+
if (
|
|
45
|
+
oldSize.height === newSize.height &&
|
|
46
|
+
oldSize.width === newSize.width
|
|
47
|
+
) {
|
|
48
|
+
return oldSize;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return newSize;
|
|
52
|
+
});
|
|
44
53
|
|
|
45
54
|
logger.debug({
|
|
46
55
|
message: log,
|
|
47
56
|
});
|
|
48
|
-
};
|
|
57
|
+
}, []);
|
|
49
58
|
|
|
50
59
|
const isTabletLandscape = useIsTabletLandscape();
|
|
51
60
|
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { shallow } from "enzyme";
|
|
6
|
+
import { create, act } from "react-test-renderer";
|
|
7
|
+
import { shallowToJson } from "enzyme-to-json";
|
|
8
|
+
|
|
9
|
+
import { ViewportEvents } from "../../ViewportEvents";
|
|
10
|
+
|
|
11
|
+
jest.useFakeTimers();
|
|
5
12
|
|
|
13
|
+
jest.mock("react-native/Libraries/ReactNative/UIManager", () => {
|
|
6
14
|
return {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
success(100, 100, 400, 400);
|
|
11
|
-
}),
|
|
12
|
-
},
|
|
13
|
-
findNodeHandle: jest.fn(() => 1234),
|
|
14
|
-
Animated: {
|
|
15
|
-
timing: jest.fn(() => ({ start: jest.fn() })),
|
|
15
|
+
...jest.requireActual("react-native/Libraries/ReactNative/NativeUIManager"),
|
|
16
|
+
measureLayout: (handle, parent, error, success) => {
|
|
17
|
+
success(100, 100, 400, 400);
|
|
16
18
|
},
|
|
17
19
|
};
|
|
18
20
|
});
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
|
|
23
|
+
...jest.requireActual("react-native/Libraries/Renderer/shims/ReactNative"),
|
|
24
|
+
findNodeHandle: () => 1234,
|
|
25
|
+
}));
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
import TestRenderer from "react-test-renderer";
|
|
24
|
-
import { act } from "@testing-library/react-hooks";
|
|
25
|
-
import { shallowToJson } from "enzyme-to-json";
|
|
27
|
+
const ReactNative = require("react-native");
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
const { Animated, ScrollView } = ReactNative;
|
|
30
|
+
|
|
31
|
+
Animated.timing = jest.fn(() => ({ start: jest.fn() }));
|
|
28
32
|
|
|
29
33
|
const viewportEventsManager = new ViewportEvents(true);
|
|
30
34
|
|
|
31
|
-
const {
|
|
32
|
-
const { ViewportAware } = require("../index");
|
|
35
|
+
const { ViewportAware } = require("../");
|
|
33
36
|
const { ViewportTracker } = require("../../ViewportTracker");
|
|
34
37
|
|
|
35
38
|
const TestComponent = (props) => {
|
|
@@ -116,7 +119,7 @@ describe("<ViewportAware />", () => {
|
|
|
116
119
|
});
|
|
117
120
|
|
|
118
121
|
it("invokes the onViewportEnter function when entering the viewport", () => {
|
|
119
|
-
const wrapper =
|
|
122
|
+
const wrapper = create(
|
|
120
123
|
getWrapper(() => (
|
|
121
124
|
<TestComponent
|
|
122
125
|
preTriggerRatio={0.1}
|
|
@@ -134,6 +137,8 @@ describe("<ViewportAware />", () => {
|
|
|
134
137
|
width: 1920,
|
|
135
138
|
height: 1080,
|
|
136
139
|
});
|
|
140
|
+
|
|
141
|
+
jest.runAllTimers();
|
|
137
142
|
});
|
|
138
143
|
|
|
139
144
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
@@ -151,7 +156,7 @@ describe("<ViewportAware />", () => {
|
|
|
151
156
|
});
|
|
152
157
|
|
|
153
158
|
it("invokes the onViewportLeave function when leaving the viewport", () => {
|
|
154
|
-
const wrapper =
|
|
159
|
+
const wrapper = create(
|
|
155
160
|
getWrapper(() => (
|
|
156
161
|
<TestComponent
|
|
157
162
|
preTriggerRatio={0.1}
|
|
@@ -5,11 +5,10 @@ import { ViewportEvents } from "../../ViewportEvents";
|
|
|
5
5
|
|
|
6
6
|
const TestComponent = () => <ScrollView />;
|
|
7
7
|
|
|
8
|
-
jest.mock("react-native", () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
8
|
+
jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
|
|
9
|
+
...jest.requireActual("react-native/Libraries/Renderer/shims/ReactNative"),
|
|
10
|
+
findNodeHandle: () => 1234,
|
|
11
|
+
}));
|
|
13
12
|
|
|
14
13
|
const viewportEventsManager = new ViewportEvents(true);
|
|
15
14
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { Placeholder } from "./Placeholder";
|
|
12
12
|
import { useInitialLoading } from "./hooks";
|
|
13
|
-
import {
|
|
13
|
+
import { useFocusable } from "../Focusable/index.android";
|
|
14
14
|
|
|
15
15
|
type ReactComponent = React.ComponentType<any>;
|
|
16
16
|
|
|
@@ -26,13 +26,23 @@ type ZappUIComponentType = {
|
|
|
26
26
|
options?: Options;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
type RenderComponentProps = any;
|
|
30
|
+
|
|
31
|
+
const RenderComponent = (
|
|
32
|
+
Component: ReactComponent | undefined,
|
|
33
|
+
args: RenderComponentProps
|
|
34
|
+
) => {
|
|
35
|
+
const { component, parent } = args;
|
|
32
36
|
|
|
37
|
+
const contextValue = React.useMemo(
|
|
38
|
+
() => ({ ...component, parent }),
|
|
39
|
+
[component, parent]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (Component) {
|
|
33
43
|
return (
|
|
34
|
-
<UIComponentContext.Provider value={
|
|
35
|
-
<Component {...
|
|
44
|
+
<UIComponentContext.Provider value={contextValue}>
|
|
45
|
+
<Component {...args} />
|
|
36
46
|
</UIComponentContext.Provider>
|
|
37
47
|
);
|
|
38
48
|
}
|
|
@@ -117,7 +127,7 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
|
|
|
117
127
|
props;
|
|
118
128
|
|
|
119
129
|
const parent = useUIComponentContext();
|
|
120
|
-
const { setIsFocusable } =
|
|
130
|
+
const { setIsFocusable } = useFocusable();
|
|
121
131
|
|
|
122
132
|
const isLoading = toBooleanWithDefaultFalse(zappPipesData?.loading);
|
|
123
133
|
const isInitialLoading = useInitialLoading(isLoading);
|
|
@@ -154,11 +164,11 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
|
|
|
154
164
|
}, [props.component?.rules?.component_cells_focusable]);
|
|
155
165
|
|
|
156
166
|
if (isDataSourceEmpty(props) && allowsEmptyDataSource) {
|
|
157
|
-
return
|
|
167
|
+
return RenderComponent(Component, componentProps);
|
|
158
168
|
}
|
|
159
169
|
|
|
160
|
-
if (isLoading && !zappPipesData
|
|
161
|
-
return
|
|
170
|
+
if (isLoading && !zappPipesData?.data && isInitialLoading) {
|
|
171
|
+
return RenderComponent(LoadingComponent || Placeholder, componentProps);
|
|
162
172
|
}
|
|
163
173
|
|
|
164
174
|
if (zappPipesData?.error) {
|
|
@@ -167,9 +177,9 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
|
|
|
167
177
|
index: componentIndex,
|
|
168
178
|
});
|
|
169
179
|
|
|
170
|
-
return
|
|
180
|
+
return RenderComponent(ErrorComponent, componentProps);
|
|
171
181
|
}
|
|
172
182
|
|
|
173
|
-
return
|
|
183
|
+
return RenderComponent(Component, componentProps);
|
|
174
184
|
};
|
|
175
185
|
}
|
package/Components/index.js
CHANGED