1 | import { PureComponent } from "react";
|
2 |
|
3 | export type CellMeasurerCacheInterface = {
|
4 | hasFixedWidth(): boolean;
|
5 | hasFixedHeight(): boolean;
|
6 | has(rowIndex: number, columnIndex: number): boolean;
|
7 | set(rowIndex: number, columnIndex: number, width: number, height: number): void;
|
8 | getHeight(rowIndex: number, columnIndex?: number): number;
|
9 | getWidth(rowIndex: number, columnIndex?: number): number;
|
10 | };
|
11 |
|
12 | export type KeyMapper = (rowIndex: number, columnIndex: number) => any;
|
13 |
|
14 | export type CellMeasurerCacheParams = {
|
15 | defaultHeight?: number | undefined;
|
16 | defaultWidth?: number | undefined;
|
17 | fixedHeight?: boolean | undefined;
|
18 | fixedWidth?: boolean | undefined;
|
19 | minHeight?: number | undefined;
|
20 | minWidth?: number | undefined;
|
21 | keyMapper?: KeyMapper | undefined;
|
22 | };
|
23 | export class CellMeasurerCache implements CellMeasurerCacheInterface {
|
24 | constructor(params?: CellMeasurerCacheParams);
|
25 | clear(rowIndex: number, columnIndex: number): void;
|
26 | clearAll(): void;
|
27 | columnWidth: (params: { index: number }) => number;
|
28 | readonly defaultHeight: number;
|
29 | readonly defaultWidth: number;
|
30 | hasFixedHeight(): boolean;
|
31 | hasFixedWidth(): boolean;
|
32 | getHeight(rowIndex: number, columnIndex: number): number;
|
33 | getWidth(rowIndex: number, columnIndex: number): number;
|
34 | has(rowIndex: number, columnIndex: number): boolean;
|
35 | rowHeight: (params: { index: number }) => number;
|
36 | set(rowIndex: number, columnIndex: number, width: number, height: number): void;
|
37 | }
|
38 |
|
39 | export type CellPosition = {
|
40 | columnIndex: number;
|
41 | rowIndex: number;
|
42 | };
|
43 |
|
44 | export type MeasuredCellParent = {
|
45 | invalidateCellSizeAfterRender?: ((cell: CellPosition) => void) | undefined;
|
46 | recomputeGridSize?: ((cell: CellPosition) => void) | undefined;
|
47 | };
|
48 |
|
49 | export type CellMeasurerChildProps = {
|
50 | measure: () => void;
|
51 | registerChild: (element?: Element | null) => void;
|
52 | };
|
53 |
|
54 | export type CellMeasurerProps = {
|
55 | cache: CellMeasurerCacheInterface;
|
56 | children: ((props: CellMeasurerChildProps) => React.ReactNode) | React.ReactNode;
|
57 | columnIndex?: number | undefined;
|
58 | index?: number | undefined;
|
59 | parent: MeasuredCellParent;
|
60 | rowIndex?: number | undefined;
|
61 | style?: React.CSSProperties | undefined;
|
62 | /**
|
63 | * PLEASE NOTE
|
64 | * The [key: string]: any; line is here on purpose
|
65 | * This is due to the need of force re-render of PureComponent
|
66 | * Check the following link if you want to know more
|
67 | * https://github.com/bvaughn/react-virtualized#pass-thru-props
|
68 | */
|
69 | [key: string]: any;
|
70 | };
|
71 | /**
|
72 | * Wraps a cell and measures its rendered content.
|
73 | * Measurements are stored in a per-cell cache.
|
74 | * Cached-content is not be re-measured.
|
75 | */
|
76 | export class CellMeasurer extends PureComponent<CellMeasurerProps> {}
|
77 |
|
78 | export default CellMeasurer;
|
79 |
|
\ | No newline at end of file |