react-toolbox/components/list/checkbox.jsx

45 lines
1.2 KiB
React
Raw Normal View History

2015-10-19 03:38:25 +03:00
import React from 'react';
import Checkbox from '../checkbox';
import ListItemContent from './content';
import style from './style';
2015-10-22 11:02:36 +03:00
const ListCheckbox = (props) => {
let className = `${style.item} ${style['checkbox-item']}`;
if (props.legend) className += ` ${style['with-legend']}`;
if (props.disabled) className += ` ${style.disabled}`;
if (props.className) className += ` ${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 = {
disabled: false
};
2015-10-19 03:38:25 +03:00
export default ListCheckbox;