From d100a7141ec43d5b49f925a31c09dc5ce0973163 Mon Sep 17 00:00:00 2001 From: WrinkleJ <42173477+WrinkleJ@users.noreply.github.com> Date: Fri, 17 Apr 2020 05:25:57 +0300 Subject: [PATCH] react-virtualized: define types for onRowsRendered props in List (#43972) * [react-virtualized] define types for onRowsRendered props in List * rename type onRowsRenderedParams -> RenderedRows * fix type name * reuse existing type * fix OverscanIndices --- types/react-virtualized/dist/es/Grid.d.ts | 9 ++++----- types/react-virtualized/dist/es/InfiniteLoader.d.ts | 2 +- types/react-virtualized/dist/es/List.d.ts | 12 +++++------- types/react-virtualized/dist/es/Masonry.d.ts | 3 ++- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/types/react-virtualized/dist/es/Grid.d.ts b/types/react-virtualized/dist/es/Grid.d.ts index 9c8a8caf1f..e664af9728 100644 --- a/types/react-virtualized/dist/es/Grid.d.ts +++ b/types/react-virtualized/dist/es/Grid.d.ts @@ -2,7 +2,7 @@ import { Validator, Requireable, PureComponent, Component } from 'react'; import { List } from './List'; import { Table } from './Table'; import { CellMeasurerCache, MeasuredCellParent } from './CellMeasurer'; -import { Index, Map, Alignment } from '../../index'; +import { Index, Map, Alignment, OverscanIndexRange } from '../../index'; export type RenderedSection = { columnOverscanStartIndex: number; @@ -70,10 +70,9 @@ export type OverscanIndicesGetterParams = { startIndex: number; stopIndex: number; }; -export type OverscanIndices = { - overscanStartIndex: number; - overscanStopIndex: number; -}; + +export type OverscanIndices = OverscanIndexRange; + export type OverscanIndicesGetter = (params: OverscanIndicesGetterParams) => OverscanIndices; export type ScrollOffset = { diff --git a/types/react-virtualized/dist/es/InfiniteLoader.d.ts b/types/react-virtualized/dist/es/InfiniteLoader.d.ts index 3252a53e27..12c62714ef 100644 --- a/types/react-virtualized/dist/es/InfiniteLoader.d.ts +++ b/types/react-virtualized/dist/es/InfiniteLoader.d.ts @@ -2,7 +2,7 @@ import { PureComponent, Validator, Requireable } from 'react'; import { Index, IndexRange } from '../../index'; export type InfiniteLoaderChildProps = { - onRowsRendered: (params: { startIndex: number; stopIndex: number }) => void; + onRowsRendered: (params: IndexRange) => void; registerChild: (registeredChild: any) => void; }; diff --git a/types/react-virtualized/dist/es/List.d.ts b/types/react-virtualized/dist/es/List.d.ts index ea4be7f6af..8e65a2b5e9 100644 --- a/types/react-virtualized/dist/es/List.d.ts +++ b/types/react-virtualized/dist/es/List.d.ts @@ -1,6 +1,6 @@ import { PureComponent, Validator, Requireable } from 'react'; import { Grid, GridCoreProps, GridCellProps, OverscanIndicesGetter } from './Grid'; -import { Index, IndexRange, Alignment } from '../../index'; +import { Index, IndexRange, OverscanIndexRange, Alignment } from '../../index'; import { CellMeasurerCache, CellPosition } from './CellMeasurer'; import { OnScrollParams } from './ScrollSync'; @@ -9,6 +9,9 @@ export type ListRowProps = Pick React.ReactNode; + +export type RenderedRows = OverscanIndexRange & IndexRange; + export type ListProps = GridCoreProps & { deferredMeasurementCache?: CellMeasurerCache; /** @@ -31,12 +34,7 @@ export type ListProps = GridCoreProps & { * Callback invoked with information about the slice of rows that were just rendered. * ({ startIndex, stopIndex }): void */ - onRowsRendered?: (info: { - overscanStartIndex: number; - overscanStopIndex: number; - startIndex: number; - stopIndex: number; - }) => void; + onRowsRendered?: (info: RenderedRows) => void; /** * Number of rows to render above/below the visible bounds of the list. * These rows can help for smoother scrolling on touch devices. diff --git a/types/react-virtualized/dist/es/Masonry.d.ts b/types/react-virtualized/dist/es/Masonry.d.ts index 113ccffd17..63f8d264a3 100644 --- a/types/react-virtualized/dist/es/Masonry.d.ts +++ b/types/react-virtualized/dist/es/Masonry.d.ts @@ -1,13 +1,14 @@ import { PureComponent, Validator, Requireable } from 'react'; import { CellMeasurerCacheInterface, KeyMapper, MeasuredCellParent } from './CellMeasurer'; import { GridCellRenderer } from './Grid'; +import { IndexRange } from '../../index'; /** * Specifies the number of miliseconds during which to disable pointer events while a scroll is in progress. * This improves performance and makes scrolling smoother. */ export const DEFAULT_SCROLLING_RESET_TIME_INTERVAL = 150; -export type OnCellsRenderedCallback = (params: { startIndex: number; stopIndex: number }) => void; +export type OnCellsRenderedCallback = (params: IndexRange) => void; export type OnScrollCallback = (params: { clientHeight: number; scrollHeight: number; scrollTop: number }) => void;