2015-12-24 15:03:06 +08:00
|
|
|
import RcCheckbox from 'rc-checkbox';
|
2015-07-23 22:23:11 +08:00
|
|
|
import React from 'react';
|
2016-03-28 23:21:47 +08:00
|
|
|
import CheckboxGroup from './Group';
|
2016-02-17 18:02:33 +08:00
|
|
|
import classNames from 'classnames';
|
2016-06-16 22:06:06 +08:00
|
|
|
import PureRenderMixin from 'react-addons-pure-render-mixin';
|
2016-06-22 13:18:43 +08:00
|
|
|
import splitObject from '../_util/splitObject';
|
2016-03-18 10:31:25 +08:00
|
|
|
export default class Checkbox extends React.Component {
|
2016-03-28 23:21:47 +08:00
|
|
|
static Group = CheckboxGroup;
|
|
|
|
static defaultProps = {
|
2016-05-11 09:32:33 +08:00
|
|
|
prefixCls: 'ant-checkbox',
|
2016-03-28 23:21:47 +08:00
|
|
|
}
|
2016-06-07 17:54:06 +08:00
|
|
|
shouldComponentUpdate(...args) {
|
|
|
|
return PureRenderMixin.shouldComponentUpdate.apply(this, args);
|
|
|
|
}
|
2015-08-18 14:03:44 +08:00
|
|
|
render() {
|
2016-06-22 13:18:43 +08:00
|
|
|
const [{ prefixCls, style, children, className },restProps] = splitObject(this.props, ['prefixCls', 'style', 'children', 'className']);
|
2016-02-17 18:02:33 +08:00
|
|
|
const classString = classNames({
|
|
|
|
[className]: !!className,
|
|
|
|
[`${prefixCls}-wrapper`]: true,
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<label className={classString} style={style}>
|
|
|
|
<RcCheckbox {...restProps} prefixCls={prefixCls} children={null} />
|
2016-05-23 17:37:31 +08:00
|
|
|
{children !== undefined ? <span>{children}</span> : null}
|
2016-02-17 18:02:33 +08:00
|
|
|
</label>
|
|
|
|
);
|
2015-07-15 16:01:24 +08:00
|
|
|
}
|
2016-03-18 10:31:25 +08:00
|
|
|
}
|