UNPKG

3.06 kBTypeScriptView Raw
1import { PureComponent, Requireable, Validator } from "react";
2import { CellPosition } from "./CellMeasurer";
3import { GridProps } from "./Grid";
4
5export type MultiGridProps = {
6 classNameBottomLeftGrid?: string | undefined;
7 classNameBottomRightGrid?: string | undefined;
8 classNameTopLeftGrid?: string | undefined;
9 classNameTopRightGrid?: string | undefined;
10 enableFixedColumnScroll?: boolean | undefined;
11 enableFixedRowScroll?: boolean | undefined;
12 fixedColumnCount?: number | undefined;
13 fixedRowCount?: number | undefined;
14 style?: React.CSSProperties | undefined;
15 styleBottomLeftGrid?: React.CSSProperties | undefined;
16 styleBottomRightGrid?: React.CSSProperties | undefined;
17 styleTopLeftGrid?: React.CSSProperties | undefined;
18 styleTopRightGrid?: React.CSSProperties | undefined;
19} & GridProps;
20
21export type MultiGridState = {
22 scrollLeft: number;
23 scrollTop: number;
24};
25
26/**
27 * Renders 1, 2, or 4 Grids depending on configuration.
28 * A main (body) Grid will always be rendered.
29 * Optionally, 1-2 Grids for sticky header rows will also be rendered.
30 * If no sticky columns, only 1 sticky header Grid will be rendered.
31 * If sticky columns, 2 sticky header Grids will be rendered.
32 */
33export class MultiGrid extends PureComponent<MultiGridProps, MultiGridState> {
34 static propTypes: {
35 classNameBottomLeftGrid: Validator<string>;
36 classNameBottomRightGrid: Validator<string>;
37 classNameTopLeftGrid: Validator<string>;
38 classNameTopRightGrid: Validator<string>;
39 enableFixedColumnScroll: Validator<boolean>;
40 enableFixedRowScroll: Validator<boolean>;
41 fixedColumnCount: Validator<number>;
42 fixedRowCount: Validator<number>;
43 style: Validator<React.CSSProperties>;
44 styleBottomLeftGrid: Validator<React.CSSProperties>;
45 styleBottomRightGrid: Validator<React.CSSProperties>;
46 styleTopLeftGrid: Validator<React.CSSProperties>;
47 styleTopRightGrid: Validator<React.CSSProperties>;
48 };
49
50 static defaultProps: {
51 classNameBottomLeftGrid: "";
52 classNameBottomRightGrid: "";
53 classNameTopLeftGrid: "";
54 classNameTopRightGrid: "";
55 enableFixedColumnScroll: false;
56 enableFixedRowScroll: false;
57 fixedColumnCount: 0;
58 fixedRowCount: 0;
59 scrollToColumn: -1;
60 scrollToRow: -1;
61 style: {};
62 styleBottomLeftGrid: {};
63 styleBottomRightGrid: {};
64 styleTopLeftGrid: {};
65 styleTopRightGrid: {};
66 };
67
68 forceUpdateGrids(): void;
69
70 /** See Grid#invalidateCellSizeAfterRender */
71 invalidateCellSizeAfterRender(params?: Partial<CellPosition>): void;
72
73 /** See Grid#measureAllCells */
74 measureAllCells(): void;
75
76 /** See Grid#recomputeGridSize */
77 recomputeGridSize(params?: { columnIndex?: number | undefined; rowIndex?: number | undefined }): void;
78 static getDerivedStateFromProps(nextProps: MultiGridProps, prevState: MultiGridState): MultiGridState | null;
79}
80
81export default MultiGrid;