1 | import type * as PropTypes from "prop-types";
|
2 | import { PureComponent } from "react";
|
3 |
|
4 | export type SizedColumnProps = {
|
5 | adjustedWidth: number;
|
6 | columnWidth: number;
|
7 | getColumnWidth: () => number;
|
8 | registerChild: any;
|
9 | };
|
10 |
|
11 | export type ColumnSizerProps = {
|
12 | /**
|
13 | * Function responsible for rendering a virtualized Grid.
|
14 | * This function should implement the following signature:
|
15 | * ({ adjustedWidth, getColumnWidth, registerChild }) => PropTypes.element
|
16 | *
|
17 | * The specified :getColumnWidth function should be passed to the Grid's :columnWidth property.
|
18 | * The :registerChild should be passed to the Grid's :ref property.
|
19 | * The :adjustedWidth property is optional; it reflects the lesser of the overall width or the width of all columns.
|
20 | */
|
21 | children: (props: SizedColumnProps) => React.ReactNode;
|
22 | /** Optional maximum allowed column width */
|
23 | columnMaxWidth?: number | undefined;
|
24 | /** Optional minimum allowed column width */
|
25 | columnMinWidth?: number | undefined;
|
26 | /** Number of columns in Grid or Table child */
|
27 | columnCount?: number | undefined;
|
28 | /** Width of Grid or Table child */
|
29 | width: number;
|
30 | /**
|
31 | * PLEASE NOTE
|
32 | * The [key: string]: any; line is here on purpose
|
33 | * This is due to the need of force re-render of PureComponent
|
34 | * Check the following link if you want to know more
|
35 | * https://github.com/bvaughn/react-virtualized#pass-thru-props
|
36 | */
|
37 | [key: string]: any;
|
38 | };
|
39 | /**
|
40 | * High-order component that auto-calculates column-widths for `Grid` cells.
|
41 | */
|
42 | export class ColumnSizer extends PureComponent<ColumnSizerProps> {
|
43 | static propTypes: {
|
44 | children: PropTypes.Validator<(props: SizedColumnProps) => React.ReactNode>;
|
45 | columnMaxWidth: PropTypes.Requireable<number>;
|
46 | columnMinWidth: PropTypes.Requireable<number>;
|
47 | columnCount: PropTypes.Validator<number>;
|
48 | width: PropTypes.Validator<number>;
|
49 | };
|
50 | }
|
51 |
|
52 | export default ColumnSizer;
|