2016-05-29 21:59:54 +03:00
|
|
|
import React, { PropTypes } from 'react';
|
2016-05-22 20:08:47 +03:00
|
|
|
import classnames from 'classnames';
|
|
|
|
import { themr } from 'react-css-themr';
|
2016-05-29 21:59:54 +03:00
|
|
|
import { LIST } from '../identifiers.js';
|
|
|
|
import InjectCheckbox from '../checkbox/Checkbox.js';
|
|
|
|
import InjectListItemContent from './ListItemContent.js';
|
2015-10-19 03:38:25 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
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);
|
2015-10-19 03:38:25 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
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>
|
|
|
|
);
|
|
|
|
};
|
2015-10-19 03:38:25 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
ListCheckbox.propTypes = {
|
2016-06-04 00:44:33 +03:00
|
|
|
caption: PropTypes.string,
|
2016-05-29 21:59:54 +03:00
|
|
|
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({
|
2016-06-04 00:44:33 +03:00
|
|
|
checkbox: PropTypes.string,
|
|
|
|
checkboxItem: PropTypes.string,
|
|
|
|
disabled: PropTypes.string,
|
|
|
|
item: PropTypes.string
|
2016-05-29 21:59:54 +03:00
|
|
|
})
|
|
|
|
};
|
2015-10-19 03:38:25 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
ListCheckbox.defaultProps = {
|
|
|
|
checked: false,
|
|
|
|
disabled: false
|
|
|
|
};
|
|
|
|
|
|
|
|
return ListCheckbox;
|
2015-10-20 08:40:51 +03:00
|
|
|
};
|
2015-10-19 03:38:25 +03:00
|
|
|
|
2016-05-29 21:59:54 +03:00
|
|
|
const ListCheckbox = factory(InjectCheckbox, InjectListItemContent);
|
|
|
|
|
|
|
|
export default themr(LIST)(ListCheckbox);
|
|
|
|
export { factory as listCheckboxFactory };
|
|
|
|
export { ListCheckbox };
|