react-toolbox/components/list/ListCheckbox.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-10-19 03:38:25 +03:00
import React from 'react';
2015-11-28 18:04:09 +03:00
import ClassNames from 'classnames';
2015-10-19 03:38:25 +03:00
import Checkbox from '../checkbox';
import ListItemContent from './ListItemContent';
2015-10-19 03:38:25 +03:00
import style from './style';
2015-10-22 11:02:36 +03:00
const ListCheckbox = (props) => {
2015-11-28 18:04:09 +03:00
const className = ClassNames([style.item, style.checkboxItem], {
[style.withLegend]: props.legend,
[style.disabled]: props.disabled
}, props.className);
2015-10-19 03:38:25 +03:00
return (
<li className={className}>
<Checkbox
checked={props.checked}
className={style.checkbox}
disabled={props.disabled}
label={<ListItemContent caption={props.caption} legend={props.legend} />}
name={props.name}
onBlur={props.onBlur}
onChange={props.onChange}
onFocus={props.onFocus}
/>
</li>
);
};
2015-10-19 03:38:25 +03:00
ListCheckbox.propTypes = {
caption: React.PropTypes.string.isRequired,
checked: React.PropTypes.bool,
className: React.PropTypes.string,
disabled: React.PropTypes.bool,
legend: React.PropTypes.string,
name: React.PropTypes.string,
onBlur: React.PropTypes.func,
onChange: React.PropTypes.func,
onFocus: React.PropTypes.func
};
2015-10-19 03:38:25 +03:00
ListCheckbox.defaultProps = {
2015-11-01 12:48:12 +03:00
checked: false,
disabled: false
};
2015-10-19 03:38:25 +03:00
export default ListCheckbox;