@react-native-tvos/virtualized-lists 0.79.3-0 → 0.80.0-0rc5
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/ListMetricsAggregator.js +1 -1
- package/Lists/VirtualizeUtils.js +2 -3
- package/Lists/VirtualizedList.d.ts +2 -2
- package/Lists/VirtualizedList.js +45 -23
- package/Lists/VirtualizedListCellRenderer.js +4 -3
- package/Lists/VirtualizedListProps.js +9 -8
- package/Lists/VirtualizedSectionList.js +67 -45
- package/index.js +4 -2
- package/package.json +26 -2
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {VirtualizedListProps} from './VirtualizedListProps';
|
|
12
|
-
import type {LayoutRectangle} from 'react-native
|
|
12
|
+
import type {LayoutRectangle} from 'react-native';
|
|
13
13
|
|
|
14
14
|
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
|
|
15
15
|
import invariant from 'invariant';
|
package/Lists/VirtualizeUtils.js
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
import type ListMetricsAggregator
|
|
14
|
-
|
|
15
|
-
} from './ListMetricsAggregator';
|
|
13
|
+
import type ListMetricsAggregator from './ListMetricsAggregator';
|
|
14
|
+
import type {CellMetricProps} from './ListMetricsAggregator';
|
|
16
15
|
|
|
17
16
|
import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags';
|
|
18
17
|
|
|
@@ -131,8 +131,8 @@ export class VirtualizedList<ItemT> extends React.Component<
|
|
|
131
131
|
recordInteraction: () => void;
|
|
132
132
|
|
|
133
133
|
getScrollRef: () =>
|
|
134
|
-
| React.
|
|
135
|
-
| React.
|
|
134
|
+
| React.ComponentRef<typeof ScrollView>
|
|
135
|
+
| React.ComponentRef<typeof View>
|
|
136
136
|
| null;
|
|
137
137
|
|
|
138
138
|
getScrollResponder: () => ScrollResponderMixin | null;
|
package/Lists/VirtualizedList.js
CHANGED
|
@@ -17,12 +17,13 @@ import type {
|
|
|
17
17
|
Separators,
|
|
18
18
|
VirtualizedListProps,
|
|
19
19
|
} from './VirtualizedListProps';
|
|
20
|
-
import type {ScrollResponderType} from 'react-native/Libraries/Components/ScrollView/ScrollView';
|
|
21
|
-
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
22
20
|
import type {
|
|
23
21
|
LayoutChangeEvent,
|
|
24
22
|
ScrollEvent,
|
|
25
|
-
|
|
23
|
+
ScrollResponderType,
|
|
24
|
+
StyleProp,
|
|
25
|
+
ViewStyle,
|
|
26
|
+
} from 'react-native';
|
|
26
27
|
|
|
27
28
|
import clamp from '../Utilities/clamp';
|
|
28
29
|
import infoLog from '../Utilities/infoLog';
|
|
@@ -53,6 +54,7 @@ import {
|
|
|
53
54
|
import invariant from 'invariant';
|
|
54
55
|
import nullthrows from 'nullthrows';
|
|
55
56
|
import * as React from 'react';
|
|
57
|
+
import {cloneElement, isValidElement} from 'react';
|
|
56
58
|
import {
|
|
57
59
|
I18nManager,
|
|
58
60
|
Platform,
|
|
@@ -316,7 +318,7 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
316
318
|
if (this._scrollRef && this._scrollRef.getScrollableNode) {
|
|
317
319
|
return this._scrollRef.getScrollableNode();
|
|
318
320
|
} else {
|
|
319
|
-
return findNodeHandle(this._scrollRef);
|
|
321
|
+
return findNodeHandle<$FlowFixMe>(this._scrollRef);
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
|
|
@@ -770,7 +772,7 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
770
772
|
stickyIndicesFromProps: Set<number>,
|
|
771
773
|
first: number,
|
|
772
774
|
last: number,
|
|
773
|
-
inversionStyle:
|
|
775
|
+
inversionStyle: StyleProp<ViewStyle>,
|
|
774
776
|
) {
|
|
775
777
|
const {
|
|
776
778
|
CellRendererComponent,
|
|
@@ -891,6 +893,30 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
891
893
|
return key;
|
|
892
894
|
}
|
|
893
895
|
|
|
896
|
+
_renderEmptyComponent(
|
|
897
|
+
element: ExactReactElement_DEPRECATED<any>,
|
|
898
|
+
inversionStyle: StyleProp<ViewStyle>,
|
|
899
|
+
): React.Node {
|
|
900
|
+
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
901
|
+
const isFragment = element.type === React.Fragment;
|
|
902
|
+
|
|
903
|
+
if (isFragment) {
|
|
904
|
+
return element;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
return cloneElement(element, {
|
|
908
|
+
onLayout: (event: LayoutChangeEvent) => {
|
|
909
|
+
this._onLayoutEmpty(event);
|
|
910
|
+
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
911
|
+
if (element.props.onLayout) {
|
|
912
|
+
element.props.onLayout(event);
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
916
|
+
style: StyleSheet.compose(inversionStyle, element.props.style),
|
|
917
|
+
});
|
|
918
|
+
}
|
|
919
|
+
|
|
894
920
|
render(): React.Node {
|
|
895
921
|
this._checkProps(this.props);
|
|
896
922
|
const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} =
|
|
@@ -910,7 +936,7 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
910
936
|
if (stickyIndicesFromProps.has(0)) {
|
|
911
937
|
stickyHeaderIndices.push(0);
|
|
912
938
|
}
|
|
913
|
-
const element =
|
|
939
|
+
const element = isValidElement(ListHeaderComponent) ? (
|
|
914
940
|
ListHeaderComponent
|
|
915
941
|
) : (
|
|
916
942
|
// $FlowFixMe[not-a-component]
|
|
@@ -943,7 +969,7 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
943
969
|
// 2a. Add a cell for ListEmptyComponent if applicable
|
|
944
970
|
const itemCount = this.props.getItemCount(data);
|
|
945
971
|
if (itemCount === 0 && ListEmptyComponent) {
|
|
946
|
-
const element: ExactReactElement_DEPRECATED<any> = ((
|
|
972
|
+
const element: ExactReactElement_DEPRECATED<any> = ((isValidElement(
|
|
947
973
|
ListEmptyComponent,
|
|
948
974
|
) ? (
|
|
949
975
|
ListEmptyComponent
|
|
@@ -956,17 +982,7 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
956
982
|
<VirtualizedListCellContextProvider
|
|
957
983
|
cellKey={this._getCellKey() + '-empty'}
|
|
958
984
|
key="$empty">
|
|
959
|
-
{
|
|
960
|
-
onLayout: (event: LayoutChangeEvent) => {
|
|
961
|
-
this._onLayoutEmpty(event);
|
|
962
|
-
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
963
|
-
if (element.props.onLayout) {
|
|
964
|
-
element.props.onLayout(event);
|
|
965
|
-
}
|
|
966
|
-
},
|
|
967
|
-
// $FlowFixMe[prop-missing] React.Element internal inspection
|
|
968
|
-
style: StyleSheet.compose(inversionStyle, element.props.style),
|
|
969
|
-
})}
|
|
985
|
+
{this._renderEmptyComponent(element, inversionStyle)}
|
|
970
986
|
</VirtualizedListCellContextProvider>,
|
|
971
987
|
);
|
|
972
988
|
}
|
|
@@ -1043,7 +1059,7 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
1043
1059
|
|
|
1044
1060
|
// 3. Add cell for ListFooterComponent
|
|
1045
1061
|
if (ListFooterComponent) {
|
|
1046
|
-
const element =
|
|
1062
|
+
const element = isValidElement(ListFooterComponent) ? (
|
|
1047
1063
|
ListFooterComponent
|
|
1048
1064
|
) : (
|
|
1049
1065
|
// $FlowFixMe[not-a-component]
|
|
@@ -1141,11 +1157,14 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
1141
1157
|
trapFocusDown={
|
|
1142
1158
|
!horizontalOrDefault(this.props.horizontal) && this._hasMore
|
|
1143
1159
|
}>
|
|
1144
|
-
{
|
|
1160
|
+
{cloneElement(
|
|
1145
1161
|
(
|
|
1146
1162
|
this.props.renderScrollComponent ||
|
|
1147
1163
|
this._defaultRenderScrollComponent
|
|
1148
|
-
)(
|
|
1164
|
+
)(
|
|
1165
|
+
// $FlowExpectedError[prop-missing] scrollProps is a superset of ScrollViewProps
|
|
1166
|
+
scrollProps,
|
|
1167
|
+
) as ExactReactElement_DEPRECATED<any>,
|
|
1149
1168
|
{
|
|
1150
1169
|
ref: this._captureScrollRef,
|
|
1151
1170
|
},
|
|
@@ -1153,11 +1172,14 @@ class VirtualizedList extends StateSafePureComponent<
|
|
|
1153
1172
|
)}
|
|
1154
1173
|
</TVFocusGuideView>
|
|
1155
1174
|
) : (
|
|
1156
|
-
|
|
1175
|
+
cloneElement(
|
|
1157
1176
|
(
|
|
1158
1177
|
this.props.renderScrollComponent ||
|
|
1159
1178
|
this._defaultRenderScrollComponent
|
|
1160
|
-
)(
|
|
1179
|
+
)(
|
|
1180
|
+
// $FlowExpectedError[prop-missing] scrollProps is a superset of ScrollViewProps
|
|
1181
|
+
scrollProps,
|
|
1182
|
+
) as ExactReactElement_DEPRECATED<any>,
|
|
1161
1183
|
{
|
|
1162
1184
|
ref: this._captureScrollRef,
|
|
1163
1185
|
},
|
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {CellRendererProps, ListRenderItem} from './VirtualizedListProps';
|
|
12
|
-
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
13
12
|
import type {
|
|
14
13
|
FocusEvent,
|
|
15
14
|
LayoutChangeEvent,
|
|
16
|
-
|
|
15
|
+
StyleProp,
|
|
16
|
+
ViewStyle,
|
|
17
|
+
} from 'react-native';
|
|
17
18
|
|
|
18
19
|
import {VirtualizedListCellContextProvider} from './VirtualizedListContext.js';
|
|
19
20
|
import invariant from 'invariant';
|
|
@@ -29,7 +30,7 @@ export type Props<ItemT> = {
|
|
|
29
30
|
cellKey: string,
|
|
30
31
|
horizontal: ?boolean,
|
|
31
32
|
index: number,
|
|
32
|
-
inversionStyle:
|
|
33
|
+
inversionStyle: StyleProp<ViewStyle>,
|
|
33
34
|
item: ItemT,
|
|
34
35
|
onCellLayout?: (
|
|
35
36
|
event: LayoutChangeEvent,
|
|
@@ -13,14 +13,15 @@ import type {
|
|
|
13
13
|
ViewabilityConfigCallbackPair,
|
|
14
14
|
ViewToken,
|
|
15
15
|
} from './ViewabilityHelper';
|
|
16
|
-
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
|
|
17
16
|
import type {
|
|
18
17
|
FocusEvent,
|
|
19
18
|
LayoutChangeEvent,
|
|
20
|
-
|
|
19
|
+
ScrollViewProps,
|
|
20
|
+
StyleProp,
|
|
21
|
+
ViewStyle,
|
|
22
|
+
} from 'react-native';
|
|
21
23
|
|
|
22
24
|
import * as React from 'react';
|
|
23
|
-
import {typeof ScrollView} from 'react-native';
|
|
24
25
|
|
|
25
26
|
export type Item = any;
|
|
26
27
|
|
|
@@ -45,7 +46,7 @@ export type CellRendererProps<ItemT> = $ReadOnly<{
|
|
|
45
46
|
item: ItemT,
|
|
46
47
|
onFocusCapture?: (event: FocusEvent) => void,
|
|
47
48
|
onLayout?: (event: LayoutChangeEvent) => void,
|
|
48
|
-
style:
|
|
49
|
+
style: StyleProp<ViewStyle>,
|
|
49
50
|
}>;
|
|
50
51
|
|
|
51
52
|
export type ListRenderItem<ItemT> = (
|
|
@@ -169,7 +170,7 @@ type OptionalProps = {
|
|
|
169
170
|
/**
|
|
170
171
|
* Styling for internal View for ListFooterComponent
|
|
171
172
|
*/
|
|
172
|
-
ListFooterComponentStyle?:
|
|
173
|
+
ListFooterComponentStyle?: StyleProp<ViewStyle>,
|
|
173
174
|
/**
|
|
174
175
|
* Rendered at the top of all the items. Can be a React Component Class, a render function, or
|
|
175
176
|
* a rendered element.
|
|
@@ -178,7 +179,7 @@ type OptionalProps = {
|
|
|
178
179
|
/**
|
|
179
180
|
* Styling for internal View for ListHeaderComponent
|
|
180
181
|
*/
|
|
181
|
-
ListHeaderComponentStyle?:
|
|
182
|
+
ListHeaderComponentStyle?: StyleProp<ViewStyle>,
|
|
182
183
|
/**
|
|
183
184
|
* The maximum number of items to render in each incremental render batch. The more rendered at
|
|
184
185
|
* once, the better the fill rate, but responsiveness may suffer because rendering content may
|
|
@@ -258,7 +259,7 @@ type OptionalProps = {
|
|
|
258
259
|
/**
|
|
259
260
|
* Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
|
|
260
261
|
*/
|
|
261
|
-
renderScrollComponent?: (props:
|
|
262
|
+
renderScrollComponent?: (props: ScrollViewProps) => React.MixedElement,
|
|
262
263
|
/**
|
|
263
264
|
* Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
|
|
264
265
|
* screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
|
|
@@ -284,7 +285,7 @@ type OptionalProps = {
|
|
|
284
285
|
};
|
|
285
286
|
|
|
286
287
|
export type VirtualizedListProps = {
|
|
287
|
-
...
|
|
288
|
+
...ScrollViewProps,
|
|
288
289
|
...RequiredProps,
|
|
289
290
|
...OptionalProps,
|
|
290
291
|
};
|
|
@@ -9,14 +9,24 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type {ViewToken} from './ViewabilityHelper';
|
|
12
|
+
import type {VirtualizedListProps} from './VirtualizedListProps';
|
|
12
13
|
|
|
13
14
|
import VirtualizedList from './VirtualizedList';
|
|
14
15
|
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
|
|
15
16
|
import invariant from 'invariant';
|
|
16
17
|
import * as React from 'react';
|
|
17
|
-
type Item = any;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
type DefaultSectionT = {
|
|
20
|
+
data: any,
|
|
21
|
+
[key: string]: any,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type SectionData<SectionItemT, SectionT = DefaultSectionT> =
|
|
25
|
+
| ($ReadOnly<SectionBase<SectionItemT, SectionT>> & SectionT)
|
|
26
|
+
| (SectionBase<SectionItemT, SectionT> & SectionT)
|
|
27
|
+
| SectionT;
|
|
28
|
+
|
|
29
|
+
export type SectionBase<SectionItemT, SectionT = DefaultSectionT> = {
|
|
20
30
|
/**
|
|
21
31
|
* The data for rendering items in this section.
|
|
22
32
|
*/
|
|
@@ -30,7 +40,7 @@ export type SectionBase<SectionItemT> = {
|
|
|
30
40
|
renderItem?: ?(info: {
|
|
31
41
|
item: SectionItemT,
|
|
32
42
|
index: number,
|
|
33
|
-
section:
|
|
43
|
+
section: SectionData<SectionItemT, SectionT>,
|
|
34
44
|
separators: {
|
|
35
45
|
highlight: () => void,
|
|
36
46
|
unhighlight: () => void,
|
|
@@ -40,20 +50,20 @@ export type SectionBase<SectionItemT> = {
|
|
|
40
50
|
...
|
|
41
51
|
}) => null | React.MixedElement,
|
|
42
52
|
ItemSeparatorComponent?: ?React.ComponentType<any>,
|
|
43
|
-
keyExtractor?: (item: SectionItemT, index?: ?number) => string,
|
|
53
|
+
keyExtractor?: (item: ?SectionItemT, index?: ?number) => string,
|
|
44
54
|
...
|
|
45
55
|
};
|
|
46
56
|
|
|
47
|
-
type RequiredProps<SectionT
|
|
48
|
-
sections: $ReadOnlyArray<SectionT
|
|
57
|
+
type RequiredProps<ItemT, SectionT = DefaultSectionT> = {
|
|
58
|
+
sections: $ReadOnlyArray<SectionData<ItemT, SectionT>>,
|
|
49
59
|
};
|
|
50
60
|
|
|
51
|
-
type OptionalProps<SectionT
|
|
61
|
+
type OptionalProps<ItemT, SectionT = DefaultSectionT> = {
|
|
52
62
|
/**
|
|
53
63
|
* Default renderer for every item in every section.
|
|
54
64
|
*/
|
|
55
65
|
renderItem?: (info: {
|
|
56
|
-
item:
|
|
66
|
+
item: ItemT,
|
|
57
67
|
index: number,
|
|
58
68
|
section: SectionT,
|
|
59
69
|
separators: {
|
|
@@ -89,19 +99,10 @@ type OptionalProps<SectionT: SectionBase<any>> = {
|
|
|
89
99
|
onEndReached?: ?({distanceFromEnd: number, ...}) => void,
|
|
90
100
|
};
|
|
91
101
|
|
|
92
|
-
type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
...
|
|
96
|
-
...OptionalProps<SectionT>,
|
|
97
|
-
...$Diff<
|
|
98
|
-
VirtualizedListProps,
|
|
99
|
-
{
|
|
100
|
-
renderItem: $PropertyType<VirtualizedListProps, 'renderItem'>,
|
|
101
|
-
data: $PropertyType<VirtualizedListProps, 'data'>,
|
|
102
|
-
...
|
|
103
|
-
},
|
|
104
|
-
>,
|
|
102
|
+
export type VirtualizedSectionListProps<ItemT, SectionT = DefaultSectionT> = {
|
|
103
|
+
...RequiredProps<ItemT, SectionT>,
|
|
104
|
+
...OptionalProps<ItemT, SectionT>,
|
|
105
|
+
...Omit<VirtualizedListProps, 'data' | 'renderItem'>,
|
|
105
106
|
};
|
|
106
107
|
export type ScrollToLocationParamsType = {
|
|
107
108
|
animated?: ?boolean,
|
|
@@ -119,8 +120,12 @@ type State = {childProps: VirtualizedListProps, ...};
|
|
|
119
120
|
* sections when new props are received, which should be plenty fast for up to ~10,000 items.
|
|
120
121
|
*/
|
|
121
122
|
class VirtualizedSectionList<
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
ItemT,
|
|
124
|
+
SectionT: SectionBase<ItemT, DefaultSectionT> = DefaultSectionT,
|
|
125
|
+
> extends React.PureComponent<
|
|
126
|
+
VirtualizedSectionListProps<ItemT, SectionT>,
|
|
127
|
+
State,
|
|
128
|
+
> {
|
|
124
129
|
scrollToLocation(params: ScrollToLocationParamsType) {
|
|
125
130
|
let index = params.itemIndex;
|
|
126
131
|
for (let i = 0; i < params.sectionIndex; i++) {
|
|
@@ -203,10 +208,10 @@ class VirtualizedSectionList<
|
|
|
203
208
|
}
|
|
204
209
|
|
|
205
210
|
_getItem(
|
|
206
|
-
props: VirtualizedSectionListProps<SectionT>,
|
|
207
|
-
sections: ?$ReadOnlyArray<
|
|
211
|
+
props: VirtualizedSectionListProps<ItemT, SectionT>,
|
|
212
|
+
sections: ?$ReadOnlyArray<SectionData<ItemT, SectionT>>,
|
|
208
213
|
index: number,
|
|
209
|
-
): ?
|
|
214
|
+
): ?ItemT {
|
|
210
215
|
if (!sections) {
|
|
211
216
|
return null;
|
|
212
217
|
}
|
|
@@ -219,6 +224,7 @@ class VirtualizedSectionList<
|
|
|
219
224
|
// We intend for there to be overflow by one on both ends of the list.
|
|
220
225
|
// This will be for headers and footers. When returning a header or footer
|
|
221
226
|
// item the section itself is the item.
|
|
227
|
+
// $FlowIgnore[incompatible-return]
|
|
222
228
|
return section;
|
|
223
229
|
} else if (itemIdx < itemCount) {
|
|
224
230
|
// If we are in the bounds of the list's data then return the item.
|
|
@@ -231,23 +237,23 @@ class VirtualizedSectionList<
|
|
|
231
237
|
}
|
|
232
238
|
|
|
233
239
|
// $FlowFixMe[missing-local-annot]
|
|
234
|
-
_keyExtractor = (item:
|
|
240
|
+
_keyExtractor = (item: ItemT, index: number) => {
|
|
235
241
|
const info = this._subExtractor(index);
|
|
236
242
|
return (info && info.key) || String(index);
|
|
237
243
|
};
|
|
238
244
|
|
|
239
245
|
_subExtractor(index: number): ?{
|
|
240
|
-
section: SectionT
|
|
246
|
+
section: SectionData<ItemT, SectionT>,
|
|
241
247
|
// Key of the section or combined key for section + item
|
|
242
248
|
key: string,
|
|
243
249
|
// Relative index within the section
|
|
244
250
|
index: ?number,
|
|
245
251
|
// True if this is the section header
|
|
246
252
|
header?: ?boolean,
|
|
247
|
-
leadingItem?: ?
|
|
248
|
-
leadingSection?: ?SectionT
|
|
249
|
-
trailingItem?: ?
|
|
250
|
-
trailingSection?: ?SectionT
|
|
253
|
+
leadingItem?: ?ItemT,
|
|
254
|
+
leadingSection?: ?SectionData<ItemT, SectionT>,
|
|
255
|
+
trailingItem?: ?ItemT,
|
|
256
|
+
trailingSection?: ?SectionData<ItemT, SectionT>,
|
|
251
257
|
...
|
|
252
258
|
} {
|
|
253
259
|
let itemIndex = index;
|
|
@@ -336,7 +342,7 @@ class VirtualizedSectionList<
|
|
|
336
342
|
_renderItem =
|
|
337
343
|
(listItemCount: number): $FlowFixMe =>
|
|
338
344
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
339
|
-
({item, index}: {item:
|
|
345
|
+
({item, index}: {item: ItemT, index: number, ...}) => {
|
|
340
346
|
const info = this._subExtractor(index);
|
|
341
347
|
if (!info) {
|
|
342
348
|
return null;
|
|
@@ -453,21 +459,21 @@ class VirtualizedSectionList<
|
|
|
453
459
|
};
|
|
454
460
|
}
|
|
455
461
|
|
|
456
|
-
type ItemWithSeparatorCommonProps = $ReadOnly<{
|
|
457
|
-
leadingItem: ?
|
|
462
|
+
type ItemWithSeparatorCommonProps<ItemT> = $ReadOnly<{
|
|
463
|
+
leadingItem: ?ItemT,
|
|
458
464
|
leadingSection: ?Object,
|
|
459
465
|
section: Object,
|
|
460
|
-
trailingItem: ?
|
|
466
|
+
trailingItem: ?ItemT,
|
|
461
467
|
trailingSection: ?Object,
|
|
462
468
|
}>;
|
|
463
469
|
|
|
464
|
-
type ItemWithSeparatorProps = $ReadOnly<{
|
|
465
|
-
...ItemWithSeparatorCommonProps
|
|
470
|
+
type ItemWithSeparatorProps<ItemT> = $ReadOnly<{
|
|
471
|
+
...ItemWithSeparatorCommonProps<ItemT>,
|
|
466
472
|
LeadingSeparatorComponent: ?React.ComponentType<any>,
|
|
467
473
|
SeparatorComponent: ?React.ComponentType<any>,
|
|
468
474
|
cellKey: string,
|
|
469
475
|
index: number,
|
|
470
|
-
item:
|
|
476
|
+
item: ItemT,
|
|
471
477
|
setSelfHighlightCallback: (
|
|
472
478
|
cellKey: string,
|
|
473
479
|
updateFn: ?(boolean) => void,
|
|
@@ -483,7 +489,9 @@ type ItemWithSeparatorProps = $ReadOnly<{
|
|
|
483
489
|
inverted: boolean,
|
|
484
490
|
}>;
|
|
485
491
|
|
|
486
|
-
function ItemWithSeparator(
|
|
492
|
+
function ItemWithSeparator<ItemT>(
|
|
493
|
+
props: ItemWithSeparatorProps<ItemT>,
|
|
494
|
+
): React.Node {
|
|
487
495
|
const {
|
|
488
496
|
LeadingSeparatorComponent,
|
|
489
497
|
// this is the trailing separator and is associated with this item
|
|
@@ -505,14 +513,18 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node {
|
|
|
505
513
|
|
|
506
514
|
const [separatorHighlighted, setSeparatorHighlighted] = React.useState(false);
|
|
507
515
|
|
|
508
|
-
const [leadingSeparatorProps, setLeadingSeparatorProps] = React.useState
|
|
516
|
+
const [leadingSeparatorProps, setLeadingSeparatorProps] = React.useState<
|
|
517
|
+
ItemWithSeparatorCommonProps<ItemT>,
|
|
518
|
+
>({
|
|
509
519
|
leadingItem: props.leadingItem,
|
|
510
520
|
leadingSection: props.leadingSection,
|
|
511
521
|
section: props.section,
|
|
512
522
|
trailingItem: props.item,
|
|
513
523
|
trailingSection: props.trailingSection,
|
|
514
524
|
});
|
|
515
|
-
const [separatorProps, setSeparatorProps] = React.useState
|
|
525
|
+
const [separatorProps, setSeparatorProps] = React.useState<
|
|
526
|
+
ItemWithSeparatorCommonProps<ItemT>,
|
|
527
|
+
>({
|
|
516
528
|
leadingItem: props.item,
|
|
517
529
|
leadingSection: props.leadingSection,
|
|
518
530
|
section: props.section,
|
|
@@ -553,7 +565,7 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node {
|
|
|
553
565
|
},
|
|
554
566
|
updateProps: (
|
|
555
567
|
select: 'leading' | 'trailing',
|
|
556
|
-
newProps: Partial<ItemWithSeparatorCommonProps
|
|
568
|
+
newProps: Partial<ItemWithSeparatorCommonProps<ItemT>>,
|
|
557
569
|
) => {
|
|
558
570
|
if (select === 'leading') {
|
|
559
571
|
if (LeadingSeparatorComponent != null) {
|
|
@@ -598,12 +610,22 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node {
|
|
|
598
610
|
);
|
|
599
611
|
}
|
|
600
612
|
|
|
601
|
-
|
|
613
|
+
const VirtualizedSectionListComponent = VirtualizedSectionList as component<
|
|
614
|
+
ItemT,
|
|
615
|
+
SectionT: SectionBase<ItemT, DefaultSectionT> = DefaultSectionT,
|
|
616
|
+
>(
|
|
602
617
|
ref: React.RefSetter<
|
|
603
618
|
interface {
|
|
604
619
|
getListRef(): ?VirtualizedList,
|
|
605
620
|
scrollToLocation(params: ScrollToLocationParamsType): void,
|
|
606
621
|
},
|
|
607
622
|
>,
|
|
608
|
-
...VirtualizedSectionListProps<
|
|
623
|
+
...VirtualizedSectionListProps<ItemT, SectionT>
|
|
609
624
|
);
|
|
625
|
+
|
|
626
|
+
export default VirtualizedSectionListComponent;
|
|
627
|
+
|
|
628
|
+
export type AnyVirtualizedSectionList = typeof VirtualizedSectionListComponent<
|
|
629
|
+
any,
|
|
630
|
+
any,
|
|
631
|
+
>;
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
import typeof FillRateHelper from './Lists/FillRateHelper';
|
|
14
14
|
import typeof ViewabilityHelper from './Lists/ViewabilityHelper';
|
|
15
15
|
import typeof VirtualizedList from './Lists/VirtualizedList';
|
|
16
|
-
import
|
|
16
|
+
import type {AnyVirtualizedSectionList} from './Lists/VirtualizedSectionList';
|
|
17
17
|
|
|
18
18
|
import {typeof VirtualizedListContextResetter} from './Lists/VirtualizedListContext';
|
|
19
19
|
import {keyExtractor} from './Lists/VirtualizeUtils';
|
|
@@ -29,11 +29,13 @@ export type {
|
|
|
29
29
|
ListRenderItemInfo,
|
|
30
30
|
ListRenderItem,
|
|
31
31
|
Separators,
|
|
32
|
+
VirtualizedListProps,
|
|
32
33
|
} from './Lists/VirtualizedListProps';
|
|
33
34
|
export type {
|
|
34
35
|
VirtualizedSectionListProps,
|
|
35
36
|
ScrollToLocationParamsType,
|
|
36
37
|
SectionBase,
|
|
38
|
+
SectionData,
|
|
37
39
|
} from './Lists/VirtualizedSectionList';
|
|
38
40
|
export type {FillRateInfo} from './Lists/FillRateHelper';
|
|
39
41
|
|
|
@@ -43,7 +45,7 @@ export default {
|
|
|
43
45
|
get VirtualizedList(): VirtualizedList {
|
|
44
46
|
return require('./Lists/VirtualizedList').default;
|
|
45
47
|
},
|
|
46
|
-
get VirtualizedSectionList():
|
|
48
|
+
get VirtualizedSectionList(): AnyVirtualizedSectionList {
|
|
47
49
|
return require('./Lists/VirtualizedSectionList').default;
|
|
48
50
|
},
|
|
49
51
|
get VirtualizedListContextResetter(): VirtualizedListContextResetter {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-tvos/virtualized-lists",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.80.0-0rc5",
|
|
4
4
|
"description": "Virtualized lists for React Native.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -19,12 +19,36 @@
|
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=18"
|
|
21
21
|
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"react-native-strict-api": "./types_generated/index.d.ts",
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"default": "./index.js"
|
|
27
|
+
},
|
|
28
|
+
"./*": {
|
|
29
|
+
"types": null,
|
|
30
|
+
"default": "./*.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"index.js",
|
|
36
|
+
"index.d.ts",
|
|
37
|
+
"Lists",
|
|
38
|
+
"README.md",
|
|
39
|
+
"types_generated",
|
|
40
|
+
"Utilities",
|
|
41
|
+
"!**/__docs__/**",
|
|
42
|
+
"!**/__fixtures__/**",
|
|
43
|
+
"!**/__mocks__/**",
|
|
44
|
+
"!**/__tests__/**"
|
|
45
|
+
],
|
|
22
46
|
"dependencies": {
|
|
23
47
|
"invariant": "^2.2.4",
|
|
24
48
|
"nullthrows": "^1.1.1"
|
|
25
49
|
},
|
|
26
50
|
"devDependencies": {
|
|
27
|
-
"react-test-renderer": "19.
|
|
51
|
+
"react-test-renderer": "19.1.0"
|
|
28
52
|
},
|
|
29
53
|
"peerDependencies": {
|
|
30
54
|
"@types/react": "^19.0.0",
|