react-toolbox/components/list/ListCheckbox.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2015-10-19 03:38:25 +03:00
import React from 'react';
2016-05-22 20:08:47 +03:00
import classnames from 'classnames';
import { themr } from 'react-css-themr';
2015-10-19 03:38:25 +03:00
import Checkbox from '../checkbox';
import ListItemContent from './ListItemContent';
2015-10-19 03:38:25 +03:00
2016-05-22 20:08:47 +03:00
const ListCheckbox = ({ caption, checked, className, disabled, legend, name, onBlur, onChange, onFocus, theme }) => {
const _className = classnames(theme.item, theme.checkboxItem, {
[theme.disabled]: disabled
}, className);
2015-10-19 03:38:25 +03:00
return (
2016-05-22 20:08:47 +03:00
<li className={_className}>
<Checkbox
2016-05-22 20:08:47 +03:00
checked={checked}
className={theme.checkbox}
disabled={disabled}
label={<ListItemContent caption={caption} legend={legend} />}
name={name}
onBlur={onBlur}
onChange={onChange}
onFocus={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,
2016-05-22 20:08:47 +03:00
onFocus: React.PropTypes.func,
theme: React.PropTypes.shape({
checkbox: React.PropTypes.string.isRequired,
checkboxItem: React.PropTypes.string.isRequired,
disabled: React.PropTypes.string.isRequired,
item: React.PropTypes.string.isRequired
})
};
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
2016-05-22 20:08:47 +03:00
export default themr('ToolboxList')(ListCheckbox);