@react-native-tvos/virtualized-lists 0.73.6-0 → 0.74.0-0rc0
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/Lists/FillRateHelper.js +1 -0
- package/Lists/ListMetricsAggregator.js +2 -2
- package/Lists/ViewabilityHelper.js +1 -0
- package/Lists/VirtualizedList.d.ts +4 -4
- package/Lists/VirtualizedList.js +39 -39
- package/Lists/VirtualizedListCellRenderer.js +14 -12
- package/Lists/VirtualizedListProps.js +6 -6
- package/Lists/VirtualizedSectionList.js +1 -1
- package/index.js +4 -4
- package/package.json +2 -1
package/Lists/FillRateHelper.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {Layout} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
12
11
|
import type {Props as VirtualizedListProps} from './VirtualizedListProps';
|
|
13
|
-
import {
|
|
12
|
+
import type {Layout} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
14
13
|
|
|
14
|
+
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
|
|
15
15
|
import invariant from 'invariant';
|
|
16
16
|
|
|
17
17
|
export type CellMetrics = {
|
|
@@ -18,8 +18,8 @@ import type {
|
|
|
18
18
|
ScrollView,
|
|
19
19
|
} from 'react-native';
|
|
20
20
|
|
|
21
|
-
export interface ViewToken {
|
|
22
|
-
item:
|
|
21
|
+
export interface ViewToken<ItemT = any> {
|
|
22
|
+
item: ItemT;
|
|
23
23
|
key: string;
|
|
24
24
|
index: number | null;
|
|
25
25
|
isViewable: boolean;
|
|
@@ -330,8 +330,8 @@ export interface VirtualizedListWithoutRenderItemProps<ItemT>
|
|
|
330
330
|
*/
|
|
331
331
|
onViewableItemsChanged?:
|
|
332
332
|
| ((info: {
|
|
333
|
-
viewableItems: Array<ViewToken
|
|
334
|
-
changed: Array<ViewToken
|
|
333
|
+
viewableItems: Array<ViewToken<ItemT>>;
|
|
334
|
+
changed: Array<ViewToken<ItemT>>;
|
|
335
335
|
}) => void)
|
|
336
336
|
| null
|
|
337
337
|
| undefined;
|
package/Lists/VirtualizedList.js
CHANGED
|
@@ -8,12 +8,7 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
12
|
-
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
13
|
-
import type {
|
|
14
|
-
LayoutEvent,
|
|
15
|
-
ScrollEvent,
|
|
16
|
-
} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
11
|
+
import type {CellMetricProps, ListOrientation} from './ListMetricsAggregator';
|
|
17
12
|
import type {ViewToken} from './ViewabilityHelper';
|
|
18
13
|
import type {
|
|
19
14
|
Item,
|
|
@@ -22,18 +17,13 @@ import type {
|
|
|
22
17
|
RenderItemType,
|
|
23
18
|
Separators,
|
|
24
19
|
} from './VirtualizedListProps';
|
|
25
|
-
import type {
|
|
20
|
+
import type {ScrollResponderType} from 'react-native/Libraries/Components/ScrollView/ScrollView';
|
|
21
|
+
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
22
|
+
import type {
|
|
23
|
+
LayoutEvent,
|
|
24
|
+
ScrollEvent,
|
|
25
|
+
} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
26
26
|
|
|
27
|
-
import {
|
|
28
|
-
I18nManager,
|
|
29
|
-
Platform,
|
|
30
|
-
RefreshControl,
|
|
31
|
-
ScrollView,
|
|
32
|
-
View,
|
|
33
|
-
StyleSheet,
|
|
34
|
-
TVFocusGuideView,
|
|
35
|
-
findNodeHandle,
|
|
36
|
-
} from 'react-native';
|
|
37
27
|
import Batchinator from '../Interaction/Batchinator';
|
|
38
28
|
import clamp from '../Utilities/clamp';
|
|
39
29
|
import infoLog from '../Utilities/infoLog';
|
|
@@ -49,6 +39,14 @@ import {
|
|
|
49
39
|
VirtualizedListContext,
|
|
50
40
|
VirtualizedListContextProvider,
|
|
51
41
|
} from './VirtualizedListContext.js';
|
|
42
|
+
import {
|
|
43
|
+
horizontalOrDefault,
|
|
44
|
+
initialNumToRenderOrDefault,
|
|
45
|
+
maxToRenderPerBatchOrDefault,
|
|
46
|
+
onEndReachedThresholdOrDefault,
|
|
47
|
+
onStartReachedThresholdOrDefault,
|
|
48
|
+
windowSizeOrDefault,
|
|
49
|
+
} from './VirtualizedListProps';
|
|
52
50
|
import {
|
|
53
51
|
computeWindowedRenderLimits,
|
|
54
52
|
keyExtractor as defaultKeyExtractor,
|
|
@@ -56,15 +54,16 @@ import {
|
|
|
56
54
|
import invariant from 'invariant';
|
|
57
55
|
import nullthrows from 'nullthrows';
|
|
58
56
|
import * as React from 'react';
|
|
59
|
-
|
|
60
57
|
import {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
I18nManager,
|
|
59
|
+
Platform,
|
|
60
|
+
RefreshControl,
|
|
61
|
+
ScrollView,
|
|
62
|
+
StyleSheet,
|
|
63
|
+
TVFocusGuideView,
|
|
64
|
+
View,
|
|
65
|
+
findNodeHandle,
|
|
66
|
+
} from 'react-native';
|
|
68
67
|
|
|
69
68
|
export type {RenderItemProps, RenderItemType, Separators};
|
|
70
69
|
|
|
@@ -813,7 +812,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
813
812
|
key={key}
|
|
814
813
|
prevCellKey={prevCellKey}
|
|
815
814
|
onUpdateSeparators={this._onUpdateSeparators}
|
|
816
|
-
onCellFocusCapture={
|
|
815
|
+
onCellFocusCapture={this._onCellFocusCapture}
|
|
817
816
|
onUnmount={this._onCellUnmount}
|
|
818
817
|
ref={ref => {
|
|
819
818
|
this._cellRefs[key] = ref;
|
|
@@ -957,10 +956,12 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
957
956
|
{React.cloneElement(element, {
|
|
958
957
|
onLayout: (event: LayoutEvent) => {
|
|
959
958
|
this._onLayoutEmpty(event);
|
|
959
|
+
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
960
960
|
if (element.props.onLayout) {
|
|
961
961
|
element.props.onLayout(event);
|
|
962
962
|
}
|
|
963
963
|
},
|
|
964
|
+
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
964
965
|
style: StyleSheet.compose(inversionStyle, element.props.style),
|
|
965
966
|
})}
|
|
966
967
|
</VirtualizedListCellContextProvider>,
|
|
@@ -1151,7 +1152,6 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1151
1152
|
this.context == null &&
|
|
1152
1153
|
this.props.scrollEnabled !== false
|
|
1153
1154
|
) {
|
|
1154
|
-
// TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170
|
|
1155
1155
|
console.error(
|
|
1156
1156
|
'VirtualizedLists should never be nested inside plain ScrollViews with the same ' +
|
|
1157
1157
|
'orientation because it can break windowing and other functionality - use another ' +
|
|
@@ -1260,8 +1260,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1260
1260
|
_defaultRenderScrollComponent = props => {
|
|
1261
1261
|
const onRefresh = props.onRefresh;
|
|
1262
1262
|
if (this._isNestedWithSameOrientation()) {
|
|
1263
|
-
//
|
|
1264
|
-
|
|
1263
|
+
// Prevent VirtualizedList._onContentSizeChange from being triggered by a bubbling onContentSizeChange event.
|
|
1264
|
+
// This could lead to internal inconsistencies within VirtualizedList.
|
|
1265
|
+
const {onContentSizeChange, ...otherProps} = props;
|
|
1266
|
+
return <View {...otherProps} />;
|
|
1265
1267
|
} else if (onRefresh) {
|
|
1266
1268
|
invariant(
|
|
1267
1269
|
typeof props.refreshing === 'boolean',
|
|
@@ -1316,10 +1318,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1316
1318
|
this._updateViewableItems(this.props, this.state.cellsAroundViewport);
|
|
1317
1319
|
};
|
|
1318
1320
|
|
|
1319
|
-
_onCellFocusCapture(cellKey: string) {
|
|
1321
|
+
_onCellFocusCapture = (cellKey: string) => {
|
|
1320
1322
|
this._lastFocusedCellKey = cellKey;
|
|
1321
1323
|
this._updateCellsToRender();
|
|
1322
|
-
}
|
|
1324
|
+
};
|
|
1323
1325
|
|
|
1324
1326
|
_onCellUnmount = (cellKey: string) => {
|
|
1325
1327
|
delete this._cellRefs[cellKey];
|
|
@@ -1563,7 +1565,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1563
1565
|
// Next check if the user just scrolled within the start threshold
|
|
1564
1566
|
// and call onStartReached only once for a given content length,
|
|
1565
1567
|
// and only if onEndReached is not being executed
|
|
1566
|
-
|
|
1568
|
+
if (
|
|
1567
1569
|
onStartReached != null &&
|
|
1568
1570
|
this.state.cellsAroundViewport.first === 0 &&
|
|
1569
1571
|
isWithinStartThreshold &&
|
|
@@ -1575,13 +1577,11 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1575
1577
|
|
|
1576
1578
|
// If the user scrolls away from the start or end and back again,
|
|
1577
1579
|
// cause onStartReached or onEndReached to be triggered again
|
|
1578
|
-
|
|
1579
|
-
this._sentStartForContentLength =
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
this._sentEndForContentLength =
|
|
1583
|
-
? this._sentEndForContentLength
|
|
1584
|
-
: 0;
|
|
1580
|
+
if (!isWithinStartThreshold) {
|
|
1581
|
+
this._sentStartForContentLength = 0;
|
|
1582
|
+
}
|
|
1583
|
+
if (!isWithinEndThreshold) {
|
|
1584
|
+
this._sentEndForContentLength = 0;
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
1587
|
|
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import type {CellRendererProps, RenderItemType} from './VirtualizedListProps';
|
|
11
12
|
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
12
13
|
import type {
|
|
13
14
|
FocusEvent,
|
|
14
15
|
LayoutEvent,
|
|
15
16
|
} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
16
|
-
import type {CellRendererProps, RenderItemType} from './VirtualizedListProps';
|
|
17
17
|
|
|
18
|
-
import {View, StyleSheet} from 'react-native';
|
|
19
18
|
import {VirtualizedListCellContextProvider} from './VirtualizedListContext.js';
|
|
20
19
|
import invariant from 'invariant';
|
|
21
20
|
import * as React from 'react';
|
|
21
|
+
import {StyleSheet, View} from 'react-native';
|
|
22
22
|
|
|
23
23
|
export type Props<ItemT> = {
|
|
24
24
|
CellRendererComponent?: ?React.ComponentType<CellRendererProps<ItemT>>,
|
|
@@ -32,7 +32,7 @@ export type Props<ItemT> = {
|
|
|
32
32
|
inversionStyle: ViewStyleProp,
|
|
33
33
|
item: ItemT,
|
|
34
34
|
onCellLayout?: (event: LayoutEvent, cellKey: string, index: number) => void,
|
|
35
|
-
onCellFocusCapture?: (
|
|
35
|
+
onCellFocusCapture?: (cellKey: string) => void,
|
|
36
36
|
onUnmount: (cellKey: string) => void,
|
|
37
37
|
onUpdateSeparators: (
|
|
38
38
|
cellKeys: Array<?string>,
|
|
@@ -115,12 +115,15 @@ export default class CellRenderer<ItemT> extends React.Component<
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
_onLayout = (nativeEvent: LayoutEvent): void => {
|
|
118
|
-
this.props.onCellLayout
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
this.props.onCellLayout?.(
|
|
119
|
+
nativeEvent,
|
|
120
|
+
this.props.cellKey,
|
|
121
|
+
this.props.index,
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
_onCellFocusCapture = (e: FocusEvent): void => {
|
|
126
|
+
this.props.onCellFocusCapture?.(this.props.cellKey);
|
|
124
127
|
};
|
|
125
128
|
|
|
126
129
|
_renderElement(
|
|
@@ -174,7 +177,6 @@ export default class CellRenderer<ItemT> extends React.Component<
|
|
|
174
177
|
item,
|
|
175
178
|
index,
|
|
176
179
|
inversionStyle,
|
|
177
|
-
onCellFocusCapture,
|
|
178
180
|
onCellLayout,
|
|
179
181
|
renderItem,
|
|
180
182
|
} = this.props;
|
|
@@ -206,7 +208,7 @@ export default class CellRenderer<ItemT> extends React.Component<
|
|
|
206
208
|
const result = !CellRendererComponent ? (
|
|
207
209
|
<View
|
|
208
210
|
style={cellStyle}
|
|
209
|
-
onFocusCapture={
|
|
211
|
+
onFocusCapture={this._onCellFocusCapture}
|
|
210
212
|
{...(onCellLayout && {onLayout: this._onLayout})}>
|
|
211
213
|
{element}
|
|
212
214
|
{itemSeparator}
|
|
@@ -217,7 +219,7 @@ export default class CellRenderer<ItemT> extends React.Component<
|
|
|
217
219
|
index={index}
|
|
218
220
|
item={item}
|
|
219
221
|
style={cellStyle}
|
|
220
|
-
onFocusCapture={
|
|
222
|
+
onFocusCapture={this._onCellFocusCapture}
|
|
221
223
|
{...(onCellLayout && {onLayout: this._onLayout})}>
|
|
222
224
|
{element}
|
|
223
225
|
{itemSeparator}
|
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {typeof ScrollView} from 'react-native';
|
|
12
|
-
import type {
|
|
13
|
-
FocusEvent,
|
|
14
|
-
LayoutEvent,
|
|
15
|
-
} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
16
|
-
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
17
11
|
import type {
|
|
18
12
|
ViewabilityConfig,
|
|
19
13
|
ViewabilityConfigCallbackPair,
|
|
20
14
|
ViewToken,
|
|
21
15
|
} from './ViewabilityHelper';
|
|
16
|
+
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
17
|
+
import type {
|
|
18
|
+
FocusEvent,
|
|
19
|
+
LayoutEvent,
|
|
20
|
+
} from 'react-native/Libraries/Types/CoreEventTypes';
|
|
22
21
|
|
|
23
22
|
import * as React from 'react';
|
|
23
|
+
import {typeof ScrollView} from 'react-native';
|
|
24
24
|
|
|
25
25
|
export type Item = any;
|
|
26
26
|
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
import type {ViewToken} from './ViewabilityHelper';
|
|
12
12
|
|
|
13
|
-
import {View} from 'react-native';
|
|
14
13
|
import VirtualizedList from './VirtualizedList';
|
|
15
14
|
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
|
|
16
15
|
import invariant from 'invariant';
|
|
17
16
|
import * as React from 'react';
|
|
17
|
+
import {View} from 'react-native';
|
|
18
18
|
|
|
19
19
|
type Item = any;
|
|
20
20
|
|
package/index.js
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
import
|
|
14
|
-
|
|
13
|
+
import typeof FillRateHelper from './Lists/FillRateHelper';
|
|
14
|
+
import typeof ViewabilityHelper from './Lists/ViewabilityHelper';
|
|
15
15
|
import typeof VirtualizedList from './Lists/VirtualizedList';
|
|
16
16
|
import typeof VirtualizedSectionList from './Lists/VirtualizedSectionList';
|
|
17
|
+
|
|
17
18
|
import {typeof VirtualizedListContextResetter} from './Lists/VirtualizedListContext';
|
|
18
|
-
import
|
|
19
|
-
import typeof FillRateHelper from './Lists/FillRateHelper';
|
|
19
|
+
import {keyExtractor} from './Lists/VirtualizeUtils';
|
|
20
20
|
|
|
21
21
|
export type {
|
|
22
22
|
ViewToken,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-tvos/virtualized-lists",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0-0rc0",
|
|
4
4
|
"description": "Virtualized lists for React Native with TV focus engine support.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"react-test-renderer": "18.2.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
+
"react": "*",
|
|
30
31
|
"react-native": "*"
|
|
31
32
|
}
|
|
32
33
|
}
|