forked from bvaughn/react-virtualized
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColumn.js
82 lines (64 loc) · 2.61 KB
/
Column.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/** @flow */
import PropTypes from 'prop-types'
import { Component } from 'react'
import defaultHeaderRenderer from './defaultHeaderRenderer'
import defaultCellRenderer from './defaultCellRenderer'
import defaultCellDataGetter from './defaultCellDataGetter'
/**
* Describes the header and cell contents of a table column.
*/
export default class Column extends Component {
static propTypes = {
/** Optional aria-label value to set on the column header */
'aria-label': PropTypes.string,
/**
* Callback responsible for returning a cell's data, given its :dataKey
* ({ columnData: any, dataKey: string, rowData: any }): any
*/
cellDataGetter: PropTypes.func,
/**
* Callback responsible for rendering a cell's contents.
* ({ cellData: any, columnData: any, dataKey: string, rowData: any, rowIndex: number }): node
*/
cellRenderer: PropTypes.func,
/** Optional CSS class to apply to cell */
className: PropTypes.string,
/** Optional additional data passed to this column's :cellDataGetter */
columnData: PropTypes.object,
/** Uniquely identifies the row-data attribute correspnding to this cell */
dataKey: PropTypes.any.isRequired,
/** If sort is enabled for the table at large, disable it for this column */
disableSort: PropTypes.bool,
/** Flex grow style; defaults to 0 */
flexGrow: PropTypes.number,
/** Flex shrink style; defaults to 1 */
flexShrink: PropTypes.number,
/** Optional CSS class to apply to this column's header */
headerClassName: PropTypes.string,
/**
* Optional callback responsible for rendering a column header contents.
* ({ columnData: object, dataKey: string, disableSort: boolean, label: string, sortBy: string, sortDirection: string }): PropTypes.node
*/
headerRenderer: PropTypes.func.isRequired,
/** Optional id to set on the column header */
id: PropTypes.string,
/** Header label for this column */
label: PropTypes.string,
/** Maximum width of column; this property will only be used if :flexGrow is > 0. */
maxWidth: PropTypes.number,
/** Minimum width of column. */
minWidth: PropTypes.number,
/** Optional inline style to apply to cell */
style: PropTypes.object,
/** Flex basis (width) for this column; This value can grow or shrink based on :flexGrow and :flexShrink properties. */
width: PropTypes.number.isRequired
};
static defaultProps = {
cellDataGetter: defaultCellDataGetter,
cellRenderer: defaultCellRenderer,
flexGrow: 0,
flexShrink: 1,
headerRenderer: defaultHeaderRenderer,
style: {}
};
}