flipper-plugin
Version:
Flipper Desktop plugin SDK and components
49 lines • 2.14 kB
TypeScript
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import React, { MutableRefObject } from 'react';
import { useVirtual } from 'react-virtual';
import { DataSourceView } from './DataSource';
export type DataSourceVirtualizer = ReturnType<typeof useVirtual>;
type DataSourceProps<T extends object, C> = {
/**
* The data source to render
*/
dataView: DataSourceView<T, T[keyof T]>;
/**
* Automatically scroll if the user is near the end?
*/
autoScroll?: boolean;
/**
* additional context that will be passed verbatim to the itemRenderer, so that it can be easily memoized
*/
context?: C;
/**
* Takes care of rendering an item
* @param item The item as stored in the dataSource
* @param index The index of the item being rendered. The index represents the offset in the _visible_ items of the dataSource
* @param context The optional context passed into this DataSourceRenderer
*/
itemRenderer(item: T, index: number, context: C): React.ReactElement;
useFixedRowHeight: boolean;
defaultRowHeight: number;
onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
virtualizerRef?: MutableRefObject<DataSourceVirtualizer | undefined>;
onRangeChange?(start: number, end: number, total: number, offset: number): void;
onUpdateAutoScroll?(autoScroll: boolean): void;
emptyRenderer?: null | ((dataView: DataSourceView<T, T[keyof T]>) => React.ReactElement);
};
/**
* This component is UI agnostic, and just takes care of virtualizing the provided dataSource, and render it as efficiently a possibible,
* de priorizing off screen updates etc.
*/
export declare const DataSourceRendererVirtual: <T extends object, C>(props: DataSourceProps<T, C>) => React.ReactElement;
export declare const RedrawContext: React.Context<(() => void) | undefined>;
export declare function useTableRedraw(): (() => void) | undefined;
export {};
//# sourceMappingURL=DataSourceRendererVirtual.d.ts.map