@react-native-tvos/virtualized-lists 0.73.7-0 → 0.74.0-0
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 +8 -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>,
|
|
@@ -1164,7 +1165,6 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1164
1165
|
this.context == null &&
|
|
1165
1166
|
this.props.scrollEnabled !== false
|
|
1166
1167
|
) {
|
|
1167
|
-
// TODO (T46547044): use React.warn once 16.9 is sync'd: https://github.com/facebook/react/pull/15170
|
|
1168
1168
|
console.error(
|
|
1169
1169
|
'VirtualizedLists should never be nested inside plain ScrollViews with the same ' +
|
|
1170
1170
|
'orientation because it can break windowing and other functionality - use another ' +
|
|
@@ -1273,8 +1273,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1273
1273
|
_defaultRenderScrollComponent = props => {
|
|
1274
1274
|
const onRefresh = props.onRefresh;
|
|
1275
1275
|
if (this._isNestedWithSameOrientation()) {
|
|
1276
|
-
//
|
|
1277
|
-
|
|
1276
|
+
// Prevent VirtualizedList._onContentSizeChange from being triggered by a bubbling onContentSizeChange event.
|
|
1277
|
+
// This could lead to internal inconsistencies within VirtualizedList.
|
|
1278
|
+
const {onContentSizeChange, ...otherProps} = props;
|
|
1279
|
+
return <View {...otherProps} />;
|
|
1278
1280
|
} else if (onRefresh) {
|
|
1279
1281
|
invariant(
|
|
1280
1282
|
typeof props.refreshing === 'boolean',
|
|
@@ -1329,10 +1331,10 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1329
1331
|
this._updateViewableItems(this.props, this.state.cellsAroundViewport);
|
|
1330
1332
|
};
|
|
1331
1333
|
|
|
1332
|
-
_onCellFocusCapture(cellKey: string) {
|
|
1334
|
+
_onCellFocusCapture = (cellKey: string) => {
|
|
1333
1335
|
this._lastFocusedCellKey = cellKey;
|
|
1334
1336
|
this._updateCellsToRender();
|
|
1335
|
-
}
|
|
1337
|
+
};
|
|
1336
1338
|
|
|
1337
1339
|
_onCellUnmount = (cellKey: string) => {
|
|
1338
1340
|
delete this._cellRefs[cellKey];
|
|
@@ -1576,7 +1578,7 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1576
1578
|
// Next check if the user just scrolled within the start threshold
|
|
1577
1579
|
// and call onStartReached only once for a given content length,
|
|
1578
1580
|
// and only if onEndReached is not being executed
|
|
1579
|
-
|
|
1581
|
+
if (
|
|
1580
1582
|
onStartReached != null &&
|
|
1581
1583
|
this.state.cellsAroundViewport.first === 0 &&
|
|
1582
1584
|
isWithinStartThreshold &&
|
|
@@ -1588,13 +1590,11 @@ class VirtualizedList extends StateSafePureComponent<Props, State> {
|
|
|
1588
1590
|
|
|
1589
1591
|
// If the user scrolls away from the start or end and back again,
|
|
1590
1592
|
// cause onStartReached or onEndReached to be triggered again
|
|
1591
|
-
|
|
1592
|
-
this._sentStartForContentLength =
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
this._sentEndForContentLength =
|
|
1596
|
-
? this._sentEndForContentLength
|
|
1597
|
-
: 0;
|
|
1593
|
+
if (!isWithinStartThreshold) {
|
|
1594
|
+
this._sentStartForContentLength = 0;
|
|
1595
|
+
}
|
|
1596
|
+
if (!isWithinEndThreshold) {
|
|
1597
|
+
this._sentEndForContentLength = 0;
|
|
1598
1598
|
}
|
|
1599
1599
|
}
|
|
1600
1600
|
|
|
@@ -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-0",
|
|
4
4
|
"description": "Virtualized lists for React Native with TV focus engine support.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
"react-test-renderer": "18.2.0"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
+
"@types/react": "^18.2.6",
|
|
31
|
+
"react": "*",
|
|
30
32
|
"react-native": "*"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"@types/react": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
}
|