UNPKG

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