@react-native-tvos/virtualized-lists 0.80.1-0 → 0.81.0-0rc3

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.
@@ -65,6 +65,7 @@ import {
65
65
  View,
66
66
  findNodeHandle,
67
67
  } from 'react-native';
68
+ import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags';
68
69
 
69
70
  export type {ListRenderItemInfo, ListRenderItem, Separators};
70
71
 
@@ -1375,7 +1376,12 @@ class VirtualizedList extends StateSafePureComponent<
1375
1376
 
1376
1377
  _onCellFocusCapture = (cellKey: string) => {
1377
1378
  this._lastFocusedCellKey = cellKey;
1378
- this._updateCellsToRender();
1379
+ if (ReactNativeFeatureFlags.deferFlatListFocusChangeRenderUpdate()) {
1380
+ // Schedule the cells to render update the same way we handle scroll or layout events.
1381
+ this._scheduleCellsToRenderUpdate();
1382
+ } else {
1383
+ this._updateCellsToRender();
1384
+ }
1379
1385
  };
1380
1386
 
1381
1387
  _onCellUnmount = (cellKey: string) => {
@@ -19,6 +19,7 @@ import type {
19
19
  import {VirtualizedListCellContextProvider} from './VirtualizedListContext.js';
20
20
  import invariant from 'invariant';
21
21
  import * as React from 'react';
22
+ import {isValidElement} from 'react';
22
23
  import {StyleSheet, View} from 'react-native';
23
24
 
24
25
  export type Props<ItemT> = {
@@ -193,9 +194,7 @@ export default class CellRenderer<ItemT> extends React.PureComponent<
193
194
 
194
195
  // NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
195
196
  // called explicitly by `ScrollViewStickyHeader`.
196
- const itemSeparator: React.Node = React.isValidElement(
197
- ItemSeparatorComponent,
198
- )
197
+ const itemSeparator: React.Node = isValidElement(ItemSeparatorComponent)
199
198
  ? // $FlowFixMe[incompatible-type]
200
199
  ItemSeparatorComponent
201
200
  : // $FlowFixMe[incompatible-type]
@@ -8,10 +8,10 @@
8
8
  * @format
9
9
  */
10
10
 
11
- import typeof VirtualizedList from './VirtualizedList';
11
+ import typeof VirtualizedListT from './VirtualizedList';
12
12
 
13
13
  import * as React from 'react';
14
- import {useContext, useMemo} from 'react';
14
+ import {createContext, useContext, useMemo} from 'react';
15
15
 
16
16
  type Context = $ReadOnly<{
17
17
  cellKey: ?string,
@@ -26,16 +26,16 @@ type Context = $ReadOnly<{
26
26
  zoomScale: number,
27
27
  },
28
28
  horizontal: ?boolean,
29
- getOutermostParentListRef: () => React.ElementRef<VirtualizedList>,
29
+ getOutermostParentListRef: () => React.ElementRef<VirtualizedListT>,
30
30
  registerAsNestedChild: ({
31
31
  cellKey: string,
32
- ref: React.ElementRef<VirtualizedList>,
32
+ ref: React.ElementRef<VirtualizedListT>,
33
33
  }) => void,
34
- unregisterAsNestedChild: ({ref: React.ElementRef<VirtualizedList>}) => void,
34
+ unregisterAsNestedChild: ({ref: React.ElementRef<VirtualizedListT>}) => void,
35
35
  }>;
36
36
 
37
37
  export const VirtualizedListContext: React.Context<?Context> =
38
- React.createContext(null);
38
+ createContext(null);
39
39
  if (__DEV__) {
40
40
  VirtualizedListContext.displayName = 'VirtualizedListContext';
41
41
  }
@@ -53,7 +53,7 @@ export type ListRenderItem<ItemT> = (
53
53
  info: ListRenderItemInfo<ItemT>,
54
54
  ) => React.Node;
55
55
 
56
- type RequiredProps = {
56
+ type RequiredVirtualizedListProps = {
57
57
  /**
58
58
  * The default accessor functions assume this is an Array<{key: string} | {id: string}> but you can override
59
59
  * getItem, getItemCount, and keyExtractor to handle any type of index-based data.
@@ -68,7 +68,7 @@ type RequiredProps = {
68
68
  */
69
69
  getItemCount: (data: any) => number,
70
70
  };
71
- type OptionalProps = {
71
+ type OptionalVirtualizedListProps = {
72
72
  renderItem?: ?ListRenderItem<Item>,
73
73
  /**
74
74
  * `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
@@ -286,8 +286,8 @@ type OptionalProps = {
286
286
 
287
287
  export type VirtualizedListProps = {
288
288
  ...ScrollViewProps,
289
- ...RequiredProps,
290
- ...OptionalProps,
289
+ ...RequiredVirtualizedListProps,
290
+ ...OptionalVirtualizedListProps,
291
291
  };
292
292
 
293
293
  /**
@@ -15,18 +15,19 @@ import VirtualizedList from './VirtualizedList';
15
15
  import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
16
16
  import invariant from 'invariant';
17
17
  import * as React from 'react';
18
+ import {useEffect, useState} from 'react';
18
19
 
19
- type DefaultSectionT = {
20
+ type DefaultVirtualizedSectionT = {
20
21
  data: any,
21
22
  [key: string]: any,
22
23
  };
23
24
 
24
- export type SectionData<SectionItemT, SectionT = DefaultSectionT> =
25
+ export type SectionData<SectionItemT, SectionT = DefaultVirtualizedSectionT> =
25
26
  | ($ReadOnly<SectionBase<SectionItemT, SectionT>> & SectionT)
26
27
  | (SectionBase<SectionItemT, SectionT> & SectionT)
27
28
  | SectionT;
28
29
 
29
- export type SectionBase<SectionItemT, SectionT = DefaultSectionT> = {
30
+ export type SectionBase<SectionItemT, SectionT = DefaultVirtualizedSectionT> = {
30
31
  /**
31
32
  * The data for rendering items in this section.
32
33
  */
@@ -54,11 +55,17 @@ export type SectionBase<SectionItemT, SectionT = DefaultSectionT> = {
54
55
  ...
55
56
  };
56
57
 
57
- type RequiredProps<ItemT, SectionT = DefaultSectionT> = {
58
+ type RequiredVirtualizedSectionListProps<
59
+ ItemT,
60
+ SectionT = DefaultVirtualizedSectionT,
61
+ > = {
58
62
  sections: $ReadOnlyArray<SectionData<ItemT, SectionT>>,
59
63
  };
60
64
 
61
- type OptionalProps<ItemT, SectionT = DefaultSectionT> = {
65
+ type OptionalVirtualizedSectionListProps<
66
+ ItemT,
67
+ SectionT = DefaultVirtualizedSectionT,
68
+ > = {
62
69
  /**
63
70
  * Default renderer for every item in every section.
64
71
  */
@@ -99,9 +106,12 @@ type OptionalProps<ItemT, SectionT = DefaultSectionT> = {
99
106
  onEndReached?: ?({distanceFromEnd: number, ...}) => void,
100
107
  };
101
108
 
102
- export type VirtualizedSectionListProps<ItemT, SectionT = DefaultSectionT> = {
103
- ...RequiredProps<ItemT, SectionT>,
104
- ...OptionalProps<ItemT, SectionT>,
109
+ export type VirtualizedSectionListProps<
110
+ ItemT,
111
+ SectionT = DefaultVirtualizedSectionT,
112
+ > = {
113
+ ...RequiredVirtualizedSectionListProps<ItemT, SectionT>,
114
+ ...OptionalVirtualizedSectionListProps<ItemT, SectionT>,
105
115
  ...Omit<VirtualizedListProps, 'data' | 'renderItem'>,
106
116
  };
107
117
  export type ScrollToLocationParamsType = {
@@ -121,7 +131,10 @@ type State = {childProps: VirtualizedListProps, ...};
121
131
  */
122
132
  class VirtualizedSectionList<
123
133
  ItemT,
124
- SectionT: SectionBase<ItemT, DefaultSectionT> = DefaultSectionT,
134
+ SectionT: SectionBase<
135
+ ItemT,
136
+ DefaultVirtualizedSectionT,
137
+ > = DefaultVirtualizedSectionT,
125
138
  > extends React.PureComponent<
126
139
  VirtualizedSectionListProps<ItemT, SectionT>,
127
140
  State,
@@ -509,11 +522,11 @@ function ItemWithSeparator<ItemT>(
509
522
  } = props;
510
523
 
511
524
  const [leadingSeparatorHiglighted, setLeadingSeparatorHighlighted] =
512
- React.useState(false);
525
+ useState(false);
513
526
 
514
- const [separatorHighlighted, setSeparatorHighlighted] = React.useState(false);
527
+ const [separatorHighlighted, setSeparatorHighlighted] = useState(false);
515
528
 
516
- const [leadingSeparatorProps, setLeadingSeparatorProps] = React.useState<
529
+ const [leadingSeparatorProps, setLeadingSeparatorProps] = useState<
517
530
  ItemWithSeparatorCommonProps<ItemT>,
518
531
  >({
519
532
  leadingItem: props.leadingItem,
@@ -522,7 +535,7 @@ function ItemWithSeparator<ItemT>(
522
535
  trailingItem: props.item,
523
536
  trailingSection: props.trailingSection,
524
537
  });
525
- const [separatorProps, setSeparatorProps] = React.useState<
538
+ const [separatorProps, setSeparatorProps] = useState<
526
539
  ItemWithSeparatorCommonProps<ItemT>,
527
540
  >({
528
541
  leadingItem: props.item,
@@ -532,7 +545,7 @@ function ItemWithSeparator<ItemT>(
532
545
  trailingSection: props.trailingSection,
533
546
  });
534
547
 
535
- React.useEffect(() => {
548
+ useEffect(() => {
536
549
  setSelfHighlightCallback(cellKey, setSeparatorHighlighted);
537
550
  // $FlowFixMe[incompatible-call]
538
551
  setSelfUpdatePropsCallback(cellKey, setSeparatorProps);
@@ -612,7 +625,10 @@ function ItemWithSeparator<ItemT>(
612
625
 
613
626
  const VirtualizedSectionListComponent = VirtualizedSectionList as component<
614
627
  ItemT,
615
- SectionT: SectionBase<ItemT, DefaultSectionT> = DefaultSectionT,
628
+ SectionT: SectionBase<
629
+ ItemT,
630
+ DefaultVirtualizedSectionT,
631
+ > = DefaultVirtualizedSectionT,
616
632
  >(
617
633
  ref: React.RefSetter<
618
634
  interface {
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
8
7
  * @flow strict
8
+ * @format
9
9
  */
10
10
 
11
11
  'use strict';
@@ -4,8 +4,8 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
8
7
  * @flow strict
8
+ * @format
9
9
  */
10
10
 
11
11
  'use strict';
package/index.js CHANGED
@@ -4,18 +4,18 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * @format
8
7
  * @flow
8
+ * @format
9
9
  */
10
10
 
11
11
  'use strict';
12
12
 
13
- import typeof FillRateHelper from './Lists/FillRateHelper';
14
- import typeof ViewabilityHelper from './Lists/ViewabilityHelper';
15
- import typeof VirtualizedList from './Lists/VirtualizedList';
16
- import type {AnyVirtualizedSectionList} from './Lists/VirtualizedSectionList';
13
+ import typeof FillRateHelperT from './Lists/FillRateHelper';
14
+ import typeof ViewabilityHelperT from './Lists/ViewabilityHelper';
15
+ import typeof VirtualizedListT from './Lists/VirtualizedList';
16
+ import type {AnyVirtualizedSectionList as AnyVirtualizedSectionListT} from './Lists/VirtualizedSectionList';
17
17
 
18
- import {typeof VirtualizedListContextResetter} from './Lists/VirtualizedListContext';
18
+ import {typeof VirtualizedListContextResetter as VirtualizedListContextResetterT} from './Lists/VirtualizedListContext';
19
19
  import {keyExtractor} from './Lists/VirtualizeUtils';
20
20
 
21
21
  export type {
@@ -42,20 +42,20 @@ export type {FillRateInfo} from './Lists/FillRateHelper';
42
42
  export default {
43
43
  keyExtractor,
44
44
 
45
- get VirtualizedList(): VirtualizedList {
45
+ get VirtualizedList(): VirtualizedListT {
46
46
  return require('./Lists/VirtualizedList').default;
47
47
  },
48
- get VirtualizedSectionList(): AnyVirtualizedSectionList {
48
+ get VirtualizedSectionList(): AnyVirtualizedSectionListT {
49
49
  return require('./Lists/VirtualizedSectionList').default;
50
50
  },
51
- get VirtualizedListContextResetter(): VirtualizedListContextResetter {
51
+ get VirtualizedListContextResetter(): VirtualizedListContextResetterT {
52
52
  const VirtualizedListContext = require('./Lists/VirtualizedListContext');
53
53
  return VirtualizedListContext.VirtualizedListContextResetter;
54
54
  },
55
- get ViewabilityHelper(): ViewabilityHelper {
55
+ get ViewabilityHelper(): ViewabilityHelperT {
56
56
  return require('./Lists/ViewabilityHelper').default;
57
57
  },
58
- get FillRateHelper(): FillRateHelper {
58
+ get FillRateHelper(): FillRateHelperT {
59
59
  return require('./Lists/FillRateHelper').default;
60
60
  },
61
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-tvos/virtualized-lists",
3
- "version": "0.80.1-0",
3
+ "version": "0.81.0-0rc3",
4
4
  "description": "Virtualized lists for React Native.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "bugs": "https://github.com/facebook/react-native/issues",
19
19
  "engines": {
20
- "node": ">=18"
20
+ "node": ">= 20.19.4"
21
21
  },
22
22
  "exports": {
23
23
  ".": {
@@ -51,7 +51,7 @@
51
51
  "react-test-renderer": "19.1.0"
52
52
  },
53
53
  "peerDependencies": {
54
- "@types/react": "^19.0.0",
54
+ "@types/react": "^19.1.0",
55
55
  "react": "*",
56
56
  "react-native": "*"
57
57
  },
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<f61be1758ae0ac5c3b456e1351e93910>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/CellRenderMask.js
11
+ */
12
+
13
+ export type CellRegion = {
14
+ first: number;
15
+ last: number;
16
+ isSpacer: boolean;
17
+ };
18
+ export declare class CellRenderMask {
19
+ constructor(numCells: number);
20
+ enumerateRegions(): ReadonlyArray<CellRegion>;
21
+ addCells(cells: {
22
+ first: number;
23
+ last: number;
24
+ }): void;
25
+ numCells(): number;
26
+ equals(other: CellRenderMask): boolean;
27
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<e813b2d289d62a261179b333cb431e6f>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/FillRateHelper.js
11
+ */
12
+
13
+ import type { CellMetricProps } from "./ListMetricsAggregator";
14
+ import ListMetricsAggregator from "./ListMetricsAggregator";
15
+ export type FillRateInfo = Info;
16
+ declare class Info {
17
+ any_blank_count: number;
18
+ any_blank_ms: number;
19
+ any_blank_speed_sum: number;
20
+ mostly_blank_count: number;
21
+ mostly_blank_ms: number;
22
+ pixels_blank: number;
23
+ pixels_sampled: number;
24
+ pixels_scrolled: number;
25
+ total_time_spent: number;
26
+ sample_count: number;
27
+ }
28
+ /**
29
+ * A helper class for detecting when the maximem fill rate of `VirtualizedList` is exceeded.
30
+ * By default the sampling rate is set to zero and this will do nothing. If you want to collect
31
+ * samples (e.g. to log them), make sure to call `FillRateHelper.setSampleRate(0.0-1.0)`.
32
+ *
33
+ * Listeners and sample rate are global for all `VirtualizedList`s - typical usage will combine with
34
+ * `SceneTracker.getActiveScene` to determine the context of the events.
35
+ */
36
+ declare class FillRateHelper {
37
+ static addListener(callback: ($$PARAM_0$$: FillRateInfo) => void): {
38
+ remove: () => void;
39
+ };
40
+ static setSampleRate(sampleRate: number): void;
41
+ static setMinSampleCount(minSampleCount: number): void;
42
+ constructor(listMetrics: ListMetricsAggregator);
43
+ activate(): void;
44
+ deactivateAndFlush(): void;
45
+ computeBlankness(props: Omit<CellMetricProps, keyof {
46
+ initialNumToRender?: number | undefined;
47
+ }> & {
48
+ initialNumToRender?: number | undefined;
49
+ }, cellsAroundViewport: {
50
+ first: number;
51
+ last: number;
52
+ }, scrollMetrics: {
53
+ dOffset: number;
54
+ offset: number;
55
+ velocity: number;
56
+ visibleLength: number;
57
+ }): number;
58
+ enabled(): boolean;
59
+ }
60
+ export default FillRateHelper;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<993b116aaf2c8d4835bce3f9a4c6392f>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/ListMetricsAggregator.js
11
+ */
12
+
13
+ import type { VirtualizedListProps } from "./VirtualizedListProps";
14
+ import type { LayoutRectangle } from "react-native";
15
+ export type CellMetrics = {
16
+ /**
17
+ * Index of the item in the list
18
+ */
19
+ index: number;
20
+ /**
21
+ * Length of the cell along the scrolling axis
22
+ */
23
+ length: number;
24
+ /**
25
+ * Distance between this cell and the start of the list along the scrolling
26
+ * axis
27
+ */
28
+ offset: number;
29
+ /**
30
+ * Whether the cell is last known to be mounted
31
+ */
32
+ isMounted: boolean;
33
+ };
34
+ export type ListOrientation = {
35
+ horizontal: boolean;
36
+ rtl: boolean;
37
+ };
38
+ /**
39
+ * Subset of VirtualizedList props needed to calculate cell metrics
40
+ */
41
+ export type CellMetricProps = {
42
+ data: VirtualizedListProps["data"];
43
+ getItemCount: VirtualizedListProps["getItemCount"];
44
+ getItem: VirtualizedListProps["getItem"];
45
+ getItemLayout?: VirtualizedListProps["getItemLayout"];
46
+ keyExtractor?: VirtualizedListProps["keyExtractor"];
47
+ };
48
+ /**
49
+ * Provides an interface to query information about the metrics of a list and its cells.
50
+ */
51
+ declare class ListMetricsAggregator {
52
+ /**
53
+ * Notify the ListMetricsAggregator that a cell has been laid out.
54
+ *
55
+ * @returns whether the cell layout has changed since last notification
56
+ */
57
+ notifyCellLayout($$PARAM_0$$: {
58
+ cellIndex: number;
59
+ cellKey: string;
60
+ orientation: ListOrientation;
61
+ layout: LayoutRectangle;
62
+ }): boolean;
63
+ /**
64
+ * Notify ListMetricsAggregator that a cell has been unmounted.
65
+ */
66
+ notifyCellUnmounted(cellKey: string): void;
67
+ /**
68
+ * Notify ListMetricsAggregator that the lists content container has been laid out.
69
+ */
70
+ notifyListContentLayout($$PARAM_0$$: {
71
+ orientation: ListOrientation;
72
+ layout: Readonly<{
73
+ width: number;
74
+ height: number;
75
+ }>;
76
+ }): void;
77
+ /**
78
+ * Return the average length of the cells which have been measured
79
+ */
80
+ getAverageCellLength(): number;
81
+ /**
82
+ * Return the highest measured cell index (or 0 if nothing has been measured
83
+ * yet)
84
+ */
85
+ getHighestMeasuredCellIndex(): number;
86
+ /**
87
+ * Returns the exact metrics of a cell if it has already been laid out,
88
+ * otherwise an estimate based on the average length of previously measured
89
+ * cells
90
+ */
91
+ getCellMetricsApprox(index: number, props: CellMetricProps): CellMetrics;
92
+ /**
93
+ * Returns the exact metrics of a cell if it has already been laid out
94
+ */
95
+ getCellMetrics(index: number, props: CellMetricProps): null | undefined | CellMetrics;
96
+ /**
97
+ * Gets an approximate offset to an item at a given index. Supports
98
+ * fractional indices.
99
+ */
100
+ getCellOffsetApprox(index: number, props: CellMetricProps): number;
101
+ /**
102
+ * Returns the length of all ScrollView content along the scrolling axis.
103
+ */
104
+ getContentLength(): number;
105
+ /**
106
+ * Whether a content length has been observed
107
+ */
108
+ hasContentLength(): boolean;
109
+ /**
110
+ * Finds the flow-relative offset (e.g. starting from the left in LTR, but
111
+ * right in RTL) from a layout box.
112
+ */
113
+ flowRelativeOffset(layout: LayoutRectangle, referenceContentLength?: null | undefined | number): number;
114
+ /**
115
+ * Converts a flow-relative offset to a cartesian offset
116
+ */
117
+ cartesianOffset(flowRelativeOffset: number): number;
118
+ }
119
+ export default ListMetricsAggregator;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<fb3d702a36fcffc782ea82ce81cf27bd>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/StateSafePureComponent.js
11
+ */
12
+
13
+ import * as React from "react";
14
+ /**
15
+ * `setState` is called asynchronously, and should not rely on the value of
16
+ * `this.props` or `this.state`:
17
+ * https://react.dev/docs/state-and-lifecycle.html#state-updates-may-be-asynchronous
18
+ *
19
+ * SafePureComponent adds runtime enforcement, to catch cases where these
20
+ * variables are read in a state updater function, instead of the ones passed
21
+ * in.
22
+ */
23
+ declare class StateSafePureComponent<Props, State extends {}> extends React.PureComponent<Props, State> {
24
+ constructor(props: Props);
25
+ setState<K extends keyof State>(partialState: null | undefined | (Pick<State, K> | (($$PARAM_0$$: State, $$PARAM_1$$: Props) => null | undefined | Pick<State, K>)), callback?: () => unknown): void;
26
+ }
27
+ export default StateSafePureComponent;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<c71c6155a6c1167093da67c32c306d07>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/ViewabilityHelper.js
11
+ */
12
+
13
+ import type { CellMetricProps } from "./ListMetricsAggregator";
14
+ import ListMetricsAggregator from "./ListMetricsAggregator";
15
+ export type ViewToken = {
16
+ item: any;
17
+ key: string;
18
+ index: number | undefined;
19
+ isViewable: boolean;
20
+ section?: any;
21
+ };
22
+ export type ViewabilityConfigCallbackPair = {
23
+ viewabilityConfig: ViewabilityConfig;
24
+ onViewableItemsChanged: (info: {
25
+ viewableItems: Array<ViewToken>;
26
+ changed: Array<ViewToken>;
27
+ }) => void;
28
+ };
29
+ export type ViewabilityConfigCallbackPairs = Array<ViewabilityConfigCallbackPair>;
30
+ export type ViewabilityConfig = Readonly<{
31
+ /**
32
+ * Minimum amount of time (in milliseconds) that an item must be physically viewable before the
33
+ * viewability callback will be fired. A high number means that scrolling through content without
34
+ * stopping will not mark the content as viewable.
35
+ */
36
+ minimumViewTime?: number;
37
+ /**
38
+ * Percent of viewport that must be covered for a partially occluded item to count as
39
+ * "viewable", 0-100. Fully visible items are always considered viewable. A value of 0 means
40
+ * that a single pixel in the viewport makes the item viewable, and a value of 100 means that
41
+ * an item must be either entirely visible or cover the entire viewport to count as viewable.
42
+ */
43
+ viewAreaCoveragePercentThreshold?: number;
44
+ /**
45
+ * Similar to `viewAreaPercentThreshold`, but considers the percent of the item that is visible,
46
+ * rather than the fraction of the viewable area it covers.
47
+ */
48
+ itemVisiblePercentThreshold?: number;
49
+ /**
50
+ * Nothing is considered viewable until the user scrolls or `recordInteraction` is called after
51
+ * render.
52
+ */
53
+ waitForInteraction?: boolean;
54
+ }>;
55
+ /**
56
+ * A Utility class for calculating viewable items based on current metrics like scroll position and
57
+ * layout.
58
+ *
59
+ * An item is said to be in a "viewable" state when any of the following
60
+ * is true for longer than `minimumViewTime` milliseconds (after an interaction if `waitForInteraction`
61
+ * is true):
62
+ *
63
+ * - Occupying >= `viewAreaCoveragePercentThreshold` of the view area XOR fraction of the item
64
+ * visible in the view area >= `itemVisiblePercentThreshold`.
65
+ * - Entirely visible on screen
66
+ */
67
+ declare class ViewabilityHelper {
68
+ constructor(config?: ViewabilityConfig);
69
+ /**
70
+ * Cleanup, e.g. on unmount. Clears any pending timers.
71
+ */
72
+ dispose(): void;
73
+ /**
74
+ * Determines which items are viewable based on the current metrics and config.
75
+ */
76
+ computeViewableItems(props: CellMetricProps, scrollOffset: number, viewportHeight: number, listMetrics: ListMetricsAggregator, renderRange?: {
77
+ first: number;
78
+ last: number;
79
+ }): Array<number>;
80
+ /**
81
+ * Figures out which items are viewable and how that has changed from before and calls
82
+ * `onViewableItemsChanged` as appropriate.
83
+ */
84
+ onUpdate(props: CellMetricProps, scrollOffset: number, viewportHeight: number, listMetrics: ListMetricsAggregator, createViewToken: (index: number, isViewable: boolean, props: CellMetricProps) => ViewToken, onViewableItemsChanged: ($$PARAM_0$$: {
85
+ viewableItems: Array<ViewToken>;
86
+ changed: Array<ViewToken>;
87
+ }) => void, renderRange?: {
88
+ first: number;
89
+ last: number;
90
+ }): void;
91
+ /**
92
+ * clean-up cached _viewableIndices to evaluate changed items on next update
93
+ */
94
+ resetViewableIndices(): void;
95
+ /**
96
+ * Records that an interaction has happened even if there has been no scroll.
97
+ */
98
+ recordInteraction(): void;
99
+ }
100
+ export default ViewabilityHelper;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<c677afc34af685572670d7d4065a70dc>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/VirtualizeUtils.js
11
+ */
12
+
13
+ import type ListMetricsAggregator from "./ListMetricsAggregator";
14
+ import type { CellMetricProps } from "./ListMetricsAggregator";
15
+ /**
16
+ * Used to find the indices of the frames that overlap the given offsets. Useful for finding the
17
+ * items that bound different windows of content, such as the visible area or the buffered overscan
18
+ * area.
19
+ */
20
+ export declare function elementsThatOverlapOffsets(offsets: Array<number>, props: CellMetricProps, listMetrics: ListMetricsAggregator, zoomScale?: number): Array<number>;
21
+ /**
22
+ * Computes the number of elements in the `next` range that are new compared to the `prev` range.
23
+ * Handy for calculating how many new items will be rendered when the render window changes so we
24
+ * can restrict the number of new items render at once so that content can appear on the screen
25
+ * faster.
26
+ */
27
+ export declare function newRangeCount(prev: {
28
+ first: number;
29
+ last: number;
30
+ }, next: {
31
+ first: number;
32
+ last: number;
33
+ }): number;
34
+ /**
35
+ * Custom logic for determining which items should be rendered given the current frame and scroll
36
+ * metrics, as well as the previous render state. The algorithm may evolve over time, but generally
37
+ * prioritizes the visible area first, then expands that with overscan regions ahead and behind,
38
+ * biased in the direction of scroll.
39
+ */
40
+ export declare function computeWindowedRenderLimits(props: CellMetricProps, maxToRenderPerBatch: number, windowSize: number, prev: {
41
+ first: number;
42
+ last: number;
43
+ }, listMetrics: ListMetricsAggregator, scrollMetrics: {
44
+ dt: number;
45
+ offset: number;
46
+ velocity: number;
47
+ visibleLength: number;
48
+ zoomScale: number;
49
+ }): {
50
+ first: number;
51
+ last: number;
52
+ };
53
+ export declare function keyExtractor(item: any, index: number): string;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<8997e25a6b501ab434c0037b6347705b>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/VirtualizedList.js
11
+ */
12
+
13
+ import type { Item, ListRenderItem, ListRenderItemInfo, Separators, VirtualizedListProps } from "./VirtualizedListProps";
14
+ import type { ScrollEvent, ScrollResponderType } from "react-native";
15
+ import { CellRenderMask } from "./CellRenderMask";
16
+ import StateSafePureComponent from "./StateSafePureComponent";
17
+ import { VirtualizedListContext } from "./VirtualizedListContext.js";
18
+ import * as React from "react";
19
+ import { ScrollView } from "react-native";
20
+ export type { ListRenderItemInfo, ListRenderItem, Separators };
21
+ type State = {
22
+ renderMask: CellRenderMask;
23
+ cellsAroundViewport: {
24
+ first: number;
25
+ last: number;
26
+ };
27
+ firstVisibleItemKey: string | undefined;
28
+ pendingScrollUpdateCount: number;
29
+ };
30
+ /**
31
+ * Base implementation for the more convenient [`<FlatList>`](https://reactnative.dev/docs/flatlist)
32
+ * and [`<SectionList>`](https://reactnative.dev/docs/sectionlist) components, which are also better
33
+ * documented. In general, this should only really be used if you need more flexibility than
34
+ * `FlatList` provides, e.g. for use with immutable data instead of plain arrays.
35
+ *
36
+ * Virtualization massively improves memory consumption and performance of large lists by
37
+ * maintaining a finite render window of active items and replacing all items outside of the render
38
+ * window with appropriately sized blank space. The window adapts to scrolling behavior, and items
39
+ * are rendered incrementally with low-pri (after any running interactions) if they are far from the
40
+ * visible area, or with hi-pri otherwise to minimize the potential of seeing blank space.
41
+ *
42
+ * Some caveats:
43
+ *
44
+ * - Internal state is not preserved when content scrolls out of the render window. Make sure all
45
+ * your data is captured in the item data or external stores like Flux, Redux, or Relay.
46
+ * - This is a `PureComponent` which means that it will not re-render if `props` remain shallow-
47
+ * equal. Make sure that everything your `renderItem` function depends on is passed as a prop
48
+ * (e.g. `extraData`) that is not `===` after updates, otherwise your UI may not update on
49
+ * changes. This includes the `data` prop and parent component state.
50
+ * - In order to constrain memory and enable smooth scrolling, content is rendered asynchronously
51
+ * offscreen. This means it's possible to scroll faster than the fill rate ands momentarily see
52
+ * blank content. This is a tradeoff that can be adjusted to suit the needs of each application,
53
+ * and we are working on improving it behind the scenes.
54
+ * - By default, the list looks for a `key` or `id` prop on each item and uses that for the React key.
55
+ * Alternatively, you can provide a custom `keyExtractor` prop.
56
+ * - As an effort to remove defaultProps, use helper functions when referencing certain props
57
+ *
58
+ */
59
+ declare class VirtualizedList extends StateSafePureComponent<VirtualizedListProps, State> {
60
+ static contextType: typeof VirtualizedListContext;
61
+ scrollToEnd(params?: null | undefined | {
62
+ animated?: boolean | undefined;
63
+ }): void;
64
+ scrollToIndex(params: {
65
+ animated?: boolean | undefined;
66
+ index: number;
67
+ viewOffset?: number;
68
+ viewPosition?: number;
69
+ }): any;
70
+ scrollToItem(params: {
71
+ animated?: boolean | undefined;
72
+ item: Item;
73
+ viewOffset?: number;
74
+ viewPosition?: number;
75
+ }): void;
76
+ /**
77
+ * Scroll to a specific content pixel offset in the list.
78
+ *
79
+ * Param `offset` expects the offset to scroll to.
80
+ * In case of `horizontal` is true, the offset is the x-value,
81
+ * in any other case the offset is the y-value.
82
+ *
83
+ * Param `animated` (`true` by default) defines whether the list
84
+ * should do an animation while scrolling.
85
+ */
86
+ scrollToOffset(params: {
87
+ animated?: boolean | undefined;
88
+ offset: number;
89
+ }): void;
90
+ recordInteraction(): void;
91
+ flashScrollIndicators(): void;
92
+ /**
93
+ * Provides a handle to the underlying scroll responder.
94
+ * Note that `this._scrollRef` might not be a `ScrollView`, so we
95
+ * need to check that it responds to `getScrollResponder` before calling it.
96
+ */
97
+ getScrollResponder(): null | undefined | ScrollResponderType;
98
+ getScrollableNode(): null | undefined | number;
99
+ getScrollRef(): null | undefined | React.ComponentRef<typeof ScrollView>;
100
+ setNativeProps(props: Object): void;
101
+ hasMore(): boolean;
102
+ state: State;
103
+ constructor(props: VirtualizedListProps);
104
+ componentDidMount(): void;
105
+ componentWillUnmount(): void;
106
+ static getDerivedStateFromProps(newProps: VirtualizedListProps, prevState: State): State;
107
+ render(): React.ReactNode;
108
+ componentDidUpdate(prevProps: VirtualizedListProps): void;
109
+ measureLayoutRelativeToContainingList(): void;
110
+ unstable_onScroll(e: Object): void;
111
+ unstable_onScrollBeginDrag(e: ScrollEvent): void;
112
+ unstable_onScrollEndDrag(e: ScrollEvent): void;
113
+ unstable_onMomentumScrollBegin(e: ScrollEvent): void;
114
+ unstable_onMomentumScrollEnd(e: ScrollEvent): void;
115
+ }
116
+ export default VirtualizedList;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<55bd8debf6bc6068e4368f5b7905b017>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/VirtualizedListContext.js
11
+ */
12
+
13
+ import type $$IMPORT_TYPEOF_1$$ from "./VirtualizedList";
14
+ type VirtualizedListT = typeof $$IMPORT_TYPEOF_1$$;
15
+ import * as React from "react";
16
+ type Context = Readonly<{
17
+ cellKey: string | undefined;
18
+ getScrollMetrics: () => {
19
+ contentLength: number;
20
+ dOffset: number;
21
+ dt: number;
22
+ offset: number;
23
+ timestamp: number;
24
+ velocity: number;
25
+ visibleLength: number;
26
+ zoomScale: number;
27
+ };
28
+ horizontal: boolean | undefined;
29
+ getOutermostParentListRef: () => React.ComponentRef<VirtualizedListT>;
30
+ registerAsNestedChild: ($$PARAM_0$$: {
31
+ cellKey: string;
32
+ ref: React.ComponentRef<VirtualizedListT>;
33
+ }) => void;
34
+ unregisterAsNestedChild: ($$PARAM_0$$: {
35
+ ref: React.ComponentRef<VirtualizedListT>;
36
+ }) => void;
37
+ }>;
38
+ export declare const VirtualizedListContext: React.Context<null | undefined | Context>;
39
+ export declare type VirtualizedListContext = typeof VirtualizedListContext;
40
+ /**
41
+ * Resets the context. Intended for use by portal-like components (e.g. Modal).
42
+ */
43
+ export declare function VirtualizedListContextResetter($$PARAM_0$$: {
44
+ children: React.ReactNode;
45
+ }): React.ReactNode;
46
+ /**
47
+ * Sets the context with memoization. Intended to be used by `VirtualizedList`.
48
+ */
49
+ export declare function VirtualizedListContextProvider($$PARAM_0$$: {
50
+ children: React.ReactNode;
51
+ value: Context;
52
+ }): React.ReactNode;
53
+ /**
54
+ * Sets the `cellKey`. Intended to be used by `VirtualizedList` for each cell.
55
+ */
56
+ export declare function VirtualizedListCellContextProvider($$PARAM_0$$: {
57
+ cellKey: string;
58
+ children: React.ReactNode;
59
+ }): React.ReactNode;
@@ -0,0 +1,275 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<fcf224b18f3315e5b84e224781b4eeb1>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/VirtualizedListProps.js
11
+ */
12
+
13
+ import type { ViewabilityConfig, ViewabilityConfigCallbackPair, ViewToken } from "./ViewabilityHelper";
14
+ import type { FocusEvent, LayoutChangeEvent, ScrollViewProps, StyleProp, ViewStyle } from "react-native";
15
+ import * as React from "react";
16
+ export type Item = any;
17
+ export type Separators = {
18
+ highlight: () => void;
19
+ unhighlight: () => void;
20
+ updateProps: (select: "leading" | "trailing", newProps: Object) => void;
21
+ };
22
+ export type ListRenderItemInfo<ItemT> = {
23
+ item: ItemT;
24
+ index: number;
25
+ separators: Separators;
26
+ };
27
+ export type CellRendererProps<ItemT> = Readonly<{
28
+ cellKey: string;
29
+ children: React.ReactNode;
30
+ index: number;
31
+ item: ItemT;
32
+ onFocusCapture?: (event: FocusEvent) => void;
33
+ onLayout?: (event: LayoutChangeEvent) => void;
34
+ style: StyleProp<ViewStyle>;
35
+ }>;
36
+ export type ListRenderItem<ItemT> = (info: ListRenderItemInfo<ItemT>) => React.ReactNode;
37
+ type RequiredVirtualizedListProps = {
38
+ /**
39
+ * The default accessor functions assume this is an Array<{key: string} | {id: string}> but you can override
40
+ * getItem, getItemCount, and keyExtractor to handle any type of index-based data.
41
+ */
42
+ data?: any;
43
+ /**
44
+ * A generic accessor for extracting an item from any sort of data blob.
45
+ */
46
+ getItem: (data: any, index: number) => Item | undefined;
47
+ /**
48
+ * Determines how many items are in the data blob.
49
+ */
50
+ getItemCount: (data: any) => number;
51
+ };
52
+ type OptionalVirtualizedListProps = {
53
+ renderItem?: ListRenderItem<Item> | undefined;
54
+ /**
55
+ * `debug` will turn on extra logging and visual overlays to aid with debugging both usage and
56
+ * implementation, but with a significant perf hit.
57
+ */
58
+ debug?: boolean | undefined;
59
+ /**
60
+ * DEPRECATED: Virtualization provides significant performance and memory optimizations, but fully
61
+ * unmounts react instances that are outside of the render window. You should only need to disable
62
+ * this for debugging purposes. Defaults to false.
63
+ */
64
+ disableVirtualization?: boolean | undefined;
65
+ /**
66
+ * A marker property for telling the list to re-render (since it implements `PureComponent`). If
67
+ * any of your `renderItem`, Header, Footer, etc. functions depend on anything outside of the
68
+ * `data` prop, stick it here and treat it immutably.
69
+ */
70
+ extraData?: any;
71
+ getItemLayout?: (data: any, index: number) => {
72
+ length: number;
73
+ offset: number;
74
+ index: number;
75
+ };
76
+ horizontal?: boolean | undefined;
77
+ /**
78
+ * How many items to render in the initial batch. This should be enough to fill the screen but not
79
+ * much more. Note these items will never be unmounted as part of the windowed rendering in order
80
+ * to improve perceived performance of scroll-to-top actions.
81
+ */
82
+ initialNumToRender?: number | undefined;
83
+ /**
84
+ * Instead of starting at the top with the first item, start at `initialScrollIndex`. This
85
+ * disables the "scroll to top" optimization that keeps the first `initialNumToRender` items
86
+ * always rendered and immediately renders the items starting at this initial index. Requires
87
+ * `getItemLayout` to be implemented.
88
+ */
89
+ initialScrollIndex?: number | undefined;
90
+ /**
91
+ * Reverses the direction of scroll. Uses scale transforms of -1.
92
+ */
93
+ inverted?: boolean | undefined;
94
+ keyExtractor?: ((item: Item, index: number) => string) | undefined;
95
+ /**
96
+ * CellRendererComponent allows customizing how cells rendered by
97
+ * `renderItem`/`ListItemComponent` are wrapped when placed into the
98
+ * underlying ScrollView. This component must accept event handlers which
99
+ * notify VirtualizedList of changes within the cell.
100
+ */
101
+ CellRendererComponent?: React.ComponentType<CellRendererProps<Item>> | undefined;
102
+ /**
103
+ * Rendered in between each item, but not at the top or bottom. By default, `highlighted` and
104
+ * `leadingItem` props are provided. `renderItem` provides `separators.highlight`/`unhighlight`
105
+ * which will update the `highlighted` prop, but you can also add custom props with
106
+ * `separators.updateProps`.
107
+ */
108
+ ItemSeparatorComponent?: React.ComponentType<any> | undefined;
109
+ /**
110
+ * Takes an item from `data` and renders it into the list. Example usage:
111
+ *
112
+ * <FlatList
113
+ * ItemSeparatorComponent={Platform.OS !== 'android' && ({highlighted}) => (
114
+ * <View style={[style.separator, highlighted && {marginLeft: 0}]} />
115
+ * )}
116
+ * data={[{title: 'Title Text', key: 'item1'}]}
117
+ * ListItemComponent={({item, separators}) => (
118
+ * <TouchableHighlight
119
+ * onPress={() => this._onPress(item)}
120
+ * onShowUnderlay={separators.highlight}
121
+ * onHideUnderlay={separators.unhighlight}>
122
+ * <View style={{backgroundColor: 'white'}}>
123
+ * <Text>{item.title}</Text>
124
+ * </View>
125
+ * </TouchableHighlight>
126
+ * )}
127
+ * />
128
+ *
129
+ * Provides additional metadata like `index` if you need it, as well as a more generic
130
+ * `separators.updateProps` function which let's you set whatever props you want to change the
131
+ * rendering of either the leading separator or trailing separator in case the more common
132
+ * `highlight` and `unhighlight` (which set the `highlighted: boolean` prop) are insufficient for
133
+ * your use-case.
134
+ */
135
+ ListItemComponent?: (React.ComponentType<any> | React.JSX.Element) | undefined;
136
+ /**
137
+ * Rendered when the list is empty. Can be a React Component Class, a render function, or
138
+ * a rendered element.
139
+ */
140
+ ListEmptyComponent?: (React.ComponentType<any> | React.JSX.Element) | undefined;
141
+ /**
142
+ * Rendered at the bottom of all the items. Can be a React Component Class, a render function, or
143
+ * a rendered element.
144
+ */
145
+ ListFooterComponent?: (React.ComponentType<any> | React.JSX.Element) | undefined;
146
+ /**
147
+ * Styling for internal View for ListFooterComponent
148
+ */
149
+ ListFooterComponentStyle?: StyleProp<ViewStyle>;
150
+ /**
151
+ * Rendered at the top of all the items. Can be a React Component Class, a render function, or
152
+ * a rendered element.
153
+ */
154
+ ListHeaderComponent?: (React.ComponentType<any> | React.JSX.Element) | undefined;
155
+ /**
156
+ * Styling for internal View for ListHeaderComponent
157
+ */
158
+ ListHeaderComponentStyle?: StyleProp<ViewStyle>;
159
+ /**
160
+ * The maximum number of items to render in each incremental render batch. The more rendered at
161
+ * once, the better the fill rate, but responsiveness may suffer because rendering content may
162
+ * interfere with responding to button taps or other interactions.
163
+ */
164
+ maxToRenderPerBatch?: number | undefined;
165
+ /**
166
+ * Called once when the scroll position gets within within `onEndReachedThreshold`
167
+ * from the logical end of the list.
168
+ */
169
+ onEndReached?: ((info: {
170
+ distanceFromEnd: number;
171
+ }) => void) | undefined;
172
+ /**
173
+ * How far from the end (in units of visible length of the list) the trailing edge of the
174
+ * list must be from the end of the content to trigger the `onEndReached` callback.
175
+ * Thus, a value of 0.5 will trigger `onEndReached` when the end of the content is
176
+ * within half the visible length of the list.
177
+ */
178
+ onEndReachedThreshold?: number | undefined;
179
+ /**
180
+ * If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make
181
+ * sure to also set the `refreshing` prop correctly.
182
+ */
183
+ onRefresh?: (() => void) | undefined;
184
+ /**
185
+ * Used to handle failures when scrolling to an index that has not been measured yet. Recommended
186
+ * action is to either compute your own offset and `scrollTo` it, or scroll as far as possible and
187
+ * then try again after more items have been rendered.
188
+ */
189
+ onScrollToIndexFailed?: ((info: {
190
+ index: number;
191
+ highestMeasuredFrameIndex: number;
192
+ averageItemLength: number;
193
+ }) => void) | undefined;
194
+ /**
195
+ * Called once when the scroll position gets within within `onStartReachedThreshold`
196
+ * from the logical start of the list.
197
+ */
198
+ onStartReached?: ((info: {
199
+ distanceFromStart: number;
200
+ }) => void) | undefined;
201
+ /**
202
+ * How far from the start (in units of visible length of the list) the leading edge of the
203
+ * list must be from the start of the content to trigger the `onStartReached` callback.
204
+ * Thus, a value of 0.5 will trigger `onStartReached` when the start of the content is
205
+ * within half the visible length of the list.
206
+ */
207
+ onStartReachedThreshold?: number | undefined;
208
+ /**
209
+ * Called when the viewability of rows changes, as defined by the
210
+ * `viewabilityConfig` prop.
211
+ */
212
+ onViewableItemsChanged?: ((info: {
213
+ viewableItems: Array<ViewToken>;
214
+ changed: Array<ViewToken>;
215
+ }) => void) | undefined;
216
+ persistentScrollbar?: boolean | undefined;
217
+ /**
218
+ * Set this when offset is needed for the loading indicator to show correctly.
219
+ */
220
+ progressViewOffset?: number;
221
+ /**
222
+ * A custom refresh control element. When set, it overrides the default
223
+ * <RefreshControl> component built internally. The onRefresh and refreshing
224
+ * props are also ignored. Only works for vertical VirtualizedList.
225
+ */
226
+ refreshControl?: React.JSX.Element | undefined;
227
+ /**
228
+ * Set this true while waiting for new data from a refresh.
229
+ */
230
+ refreshing?: boolean | undefined;
231
+ /**
232
+ * Note: may have bugs (missing content) in some circumstances - use at your own risk.
233
+ *
234
+ * This may improve scroll performance for large lists.
235
+ */
236
+ removeClippedSubviews?: boolean;
237
+ /**
238
+ * Render a custom scroll component, e.g. with a differently styled `RefreshControl`.
239
+ */
240
+ renderScrollComponent?: (props: ScrollViewProps) => React.JSX.Element;
241
+ /**
242
+ * Amount of time between low-pri item render batches, e.g. for rendering items quite a ways off
243
+ * screen. Similar fill rate/responsiveness tradeoff as `maxToRenderPerBatch`.
244
+ */
245
+ updateCellsBatchingPeriod?: number | undefined;
246
+ /**
247
+ * See `ViewabilityHelper` for flow type and further documentation.
248
+ */
249
+ viewabilityConfig?: ViewabilityConfig;
250
+ /**
251
+ * List of ViewabilityConfig/onViewableItemsChanged pairs. A specific onViewableItemsChanged
252
+ * will be called when its corresponding ViewabilityConfig's conditions are met.
253
+ */
254
+ viewabilityConfigCallbackPairs?: Array<ViewabilityConfigCallbackPair>;
255
+ /**
256
+ * Determines the maximum number of items rendered outside of the visible area, in units of
257
+ * visible lengths. So if your list fills the screen, then `windowSize={21}` (the default) will
258
+ * render the visible screen area plus up to 10 screens above and 10 below the viewport. Reducing
259
+ * this number will reduce memory consumption and may improve performance, but will increase the
260
+ * chance that fast scrolling may reveal momentary blank areas of unrendered content.
261
+ */
262
+ windowSize?: number | undefined;
263
+ };
264
+ export type VirtualizedListProps = Omit<ScrollViewProps, keyof RequiredVirtualizedListProps | keyof OptionalVirtualizedListProps | keyof {}> & Omit<RequiredVirtualizedListProps, keyof OptionalVirtualizedListProps | keyof {}> & Omit<OptionalVirtualizedListProps, keyof {}> & {};
265
+ /**
266
+ * Default Props Helper Functions
267
+ * Use the following helper functions for default values
268
+ */
269
+
270
+ export declare function horizontalOrDefault(horizontal: null | undefined | boolean): boolean;
271
+ export declare function initialNumToRenderOrDefault(initialNumToRender: null | undefined | number): number;
272
+ export declare function maxToRenderPerBatchOrDefault(maxToRenderPerBatch: null | undefined | number): number;
273
+ export declare function onStartReachedThresholdOrDefault(onStartReachedThreshold: null | undefined | number): number;
274
+ export declare function onEndReachedThresholdOrDefault(onEndReachedThreshold: null | undefined | number): number;
275
+ export declare function windowSizeOrDefault(windowSize: null | undefined | number): number;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<ecb7038cddedf7d6444387409ad985d5>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/Lists/VirtualizedSectionList.js
11
+ */
12
+
13
+ import type { VirtualizedListProps } from "./VirtualizedListProps";
14
+ import VirtualizedList from "./VirtualizedList";
15
+ import * as React from "react";
16
+ type DefaultVirtualizedSectionT = {
17
+ data: any;
18
+ [key: string]: any;
19
+ };
20
+ export type SectionData<SectionItemT, SectionT = DefaultVirtualizedSectionT> = (Readonly<SectionBase<SectionItemT, SectionT>> & SectionT) | (SectionBase<SectionItemT, SectionT> & SectionT) | SectionT;
21
+ export type SectionBase<SectionItemT, SectionT = DefaultVirtualizedSectionT> = {
22
+ /**
23
+ * The data for rendering items in this section.
24
+ */
25
+ data: ReadonlyArray<SectionItemT>;
26
+ /**
27
+ * Optional key to keep track of section re-ordering. If you don't plan on re-ordering sections,
28
+ * the array index will be used by default.
29
+ */
30
+ key?: string;
31
+ renderItem?: ((info: {
32
+ item: SectionItemT;
33
+ index: number;
34
+ section: SectionData<SectionItemT, SectionT>;
35
+ separators: {
36
+ highlight: () => void;
37
+ unhighlight: () => void;
38
+ updateProps: (select: "leading" | "trailing", newProps: Object) => void;
39
+ };
40
+ }) => null | React.JSX.Element) | undefined;
41
+ ItemSeparatorComponent?: React.ComponentType<any> | undefined;
42
+ keyExtractor?: (item: SectionItemT | undefined, index?: number | undefined) => string;
43
+ };
44
+ type RequiredVirtualizedSectionListProps<ItemT, SectionT = DefaultVirtualizedSectionT> = {
45
+ sections: ReadonlyArray<SectionData<ItemT, SectionT>>;
46
+ };
47
+ type OptionalVirtualizedSectionListProps<ItemT, SectionT = DefaultVirtualizedSectionT> = {
48
+ /**
49
+ * Default renderer for every item in every section.
50
+ */
51
+ renderItem?: (info: {
52
+ item: ItemT;
53
+ index: number;
54
+ section: SectionT;
55
+ separators: {
56
+ highlight: () => void;
57
+ unhighlight: () => void;
58
+ updateProps: (select: "leading" | "trailing", newProps: Object) => void;
59
+ };
60
+ }) => null | React.ReactNode;
61
+ /**
62
+ * Rendered at the top of each section. These stick to the top of the `ScrollView` by default on
63
+ * iOS. See `stickySectionHeadersEnabled`.
64
+ */
65
+ renderSectionHeader?: ((info: {
66
+ section: SectionT;
67
+ }) => null | React.ReactNode) | undefined;
68
+ /**
69
+ * Rendered at the bottom of each section.
70
+ */
71
+ renderSectionFooter?: ((info: {
72
+ section: SectionT;
73
+ }) => null | React.ReactNode) | undefined;
74
+ /**
75
+ * Rendered at the top and bottom of each section (note this is different from
76
+ * `ItemSeparatorComponent` which is only rendered between items). These are intended to separate
77
+ * sections from the headers above and below and typically have the same highlight response as
78
+ * `ItemSeparatorComponent`. Also receives `highlighted`, `[leading/trailing][Item/Separator]`,
79
+ * and any custom props from `separators.updateProps`.
80
+ */
81
+ SectionSeparatorComponent?: React.ComponentType<any> | undefined;
82
+ /**
83
+ * Makes section headers stick to the top of the screen until the next one pushes it off. Only
84
+ * enabled by default on iOS because that is the platform standard there.
85
+ */
86
+ stickySectionHeadersEnabled?: boolean;
87
+ onEndReached?: (($$PARAM_0$$: {
88
+ distanceFromEnd: number;
89
+ }) => void) | undefined;
90
+ };
91
+ export type VirtualizedSectionListProps<ItemT, SectionT = DefaultVirtualizedSectionT> = Omit<RequiredVirtualizedSectionListProps<ItemT, SectionT>, keyof OptionalVirtualizedSectionListProps<ItemT, SectionT> | keyof Omit<VirtualizedListProps, "data" | "renderItem"> | keyof {}> & Omit<OptionalVirtualizedSectionListProps<ItemT, SectionT>, keyof Omit<VirtualizedListProps, "data" | "renderItem"> | keyof {}> & Omit<Omit<VirtualizedListProps, "data" | "renderItem">, keyof {}> & {};
92
+ export type ScrollToLocationParamsType = {
93
+ animated?: boolean | undefined;
94
+ itemIndex: number;
95
+ sectionIndex: number;
96
+ viewOffset?: number;
97
+ viewPosition?: number;
98
+ };
99
+ declare const VirtualizedSectionListComponent: <ItemT, SectionT extends SectionBase<ItemT, DefaultVirtualizedSectionT> = DefaultVirtualizedSectionT>(props: Omit<VirtualizedSectionListProps<ItemT, SectionT>, keyof {
100
+ ref: React.Ref<{
101
+ getListRef(): VirtualizedList | undefined;
102
+ scrollToLocation(params: ScrollToLocationParamsType): void;
103
+ }>;
104
+ }> & {
105
+ ref: React.Ref<{
106
+ getListRef(): VirtualizedList | undefined;
107
+ scrollToLocation(params: ScrollToLocationParamsType): void;
108
+ }>;
109
+ }) => React.ReactNode;
110
+ declare const $$VirtualizedSectionList: typeof VirtualizedSectionListComponent;
111
+ declare type $$VirtualizedSectionList = typeof $$VirtualizedSectionList;
112
+ export default $$VirtualizedSectionList;
113
+ export type AnyVirtualizedSectionList = typeof VirtualizedSectionListComponent;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @generated SignedSource<<7cfaaf81455a1bf0b07801c4ebd5200c>>
8
+ *
9
+ * This file was translated from Flow by scripts/build-types/index.js.
10
+ * Original file: packages/virtualized-lists/index.js
11
+ */
12
+
13
+ import type $$IMPORT_TYPEOF_1$$ from "./Lists/FillRateHelper";
14
+ type FillRateHelperT = typeof $$IMPORT_TYPEOF_1$$;
15
+ import type $$IMPORT_TYPEOF_2$$ from "./Lists/ViewabilityHelper";
16
+ type ViewabilityHelperT = typeof $$IMPORT_TYPEOF_2$$;
17
+ import type $$IMPORT_TYPEOF_3$$ from "./Lists/VirtualizedList";
18
+ type VirtualizedListT = typeof $$IMPORT_TYPEOF_3$$;
19
+ import type { AnyVirtualizedSectionList as AnyVirtualizedSectionListT } from "./Lists/VirtualizedSectionList";
20
+ import { type VirtualizedListContextResetter as $$IMPORT_TYPEOF_4$$ } from "./Lists/VirtualizedListContext";
21
+ type VirtualizedListContextResetterT = typeof $$IMPORT_TYPEOF_4$$;
22
+ import { keyExtractor } from "./Lists/VirtualizeUtils";
23
+ export type { ViewToken, ViewabilityConfig, ViewabilityConfigCallbackPair, ViewabilityConfigCallbackPairs } from "./Lists/ViewabilityHelper";
24
+ export type { CellRendererProps, ListRenderItemInfo, ListRenderItem, Separators, VirtualizedListProps } from "./Lists/VirtualizedListProps";
25
+ export type { VirtualizedSectionListProps, ScrollToLocationParamsType, SectionBase, SectionData } from "./Lists/VirtualizedSectionList";
26
+ export type { FillRateInfo } from "./Lists/FillRateHelper";
27
+ declare const $$index: {
28
+ keyExtractor: typeof keyExtractor;
29
+ get VirtualizedList(): VirtualizedListT;
30
+ get VirtualizedSectionList(): AnyVirtualizedSectionListT;
31
+ get VirtualizedListContextResetter(): VirtualizedListContextResetterT;
32
+ get ViewabilityHelper(): ViewabilityHelperT;
33
+ get FillRateHelper(): FillRateHelperT;
34
+ };
35
+ declare type $$index = typeof $$index;
36
+ export default $$index;