/
ListCheckbox.js
60 lines (53 loc) · 1.71 KB
/
ListCheckbox.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
import React, { PropTypes } from 'react';
import classnames from 'classnames';
import { themr } from 'react-css-themr';
import { LIST } from '../identifiers.js';
import InjectCheckbox from '../checkbox/Checkbox.js';
import InjectListItemContent from './ListItemContent.js';
const factory = (Checkbox, ListItemContent) => {
const ListCheckbox = ({ caption, checked, className, disabled, legend, name, onBlur, onChange, onFocus, theme }) => {
const _className = classnames(theme.item, theme.checkboxItem, {
[theme.disabled]: disabled
}, className);
return (
<li className={_className}>
<Checkbox
checked={checked}
className={theme.checkbox}
disabled={disabled}
label={<ListItemContent caption={caption} legend={legend} />}
name={name}
onBlur={onBlur}
onChange={onChange}
onFocus={onFocus}
/>
</li>
);
};
ListCheckbox.propTypes = {
caption: PropTypes.string.isRequired,
checked: PropTypes.bool,
className: PropTypes.string,
disabled: PropTypes.bool,
legend: PropTypes.string,
name: PropTypes.string,
onBlur: PropTypes.func,
onChange: PropTypes.func,
onFocus: PropTypes.func,
theme: PropTypes.shape({
checkbox: PropTypes.string.isRequired,
checkboxItem: PropTypes.string.isRequired,
disabled: PropTypes.string.isRequired,
item: PropTypes.string.isRequired
})
};
ListCheckbox.defaultProps = {
checked: false,
disabled: false
};
return ListCheckbox;
};
const ListCheckbox = factory(InjectCheckbox, InjectListItemContent);
export default themr(LIST)(ListCheckbox);
export { factory as listCheckboxFactory };
export { ListCheckbox };