-
Notifications
You must be signed in to change notification settings - Fork 374
/
item.jsx
56 lines (51 loc) · 1.21 KB
/
item.jsx
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
import * as React from 'react';
import * as PropTypes from 'prop-types';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import Checkbox from '@material-ui/core/Checkbox';
import { withStyles } from '@material-ui/core/styles';
const styles = ({
checkbox: {
padding: 0,
},
});
const ItemBase = ({
item: { column, hidden },
disabled, onToggle,
classes,
...restProps
}) => (
<ListItem
key={column.name}
button={!disabled}
component="li"
disabled={disabled}
onClick={!disabled ? onToggle : null}
{...restProps}
>
<Checkbox
checked={!hidden}
tabIndex={-1}
disableRipple
disabled={disabled}
className={classes.checkbox}
/>
<ListItemText primary={column.title || column.name} />
</ListItem>
);
ItemBase.propTypes = {
item: PropTypes.shape({
column: PropTypes.shape({
name: PropTypes.string,
}),
hidden: PropTypes.bool,
}).isRequired,
disabled: PropTypes.bool,
onToggle: PropTypes.func,
classes: PropTypes.object.isRequired,
};
ItemBase.defaultProps = {
onToggle: () => { },
disabled: false,
};
export const Item = withStyles(styles, { name: 'Item' })(ItemBase);