"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_rcCheckbox=require("rc-checkbox"),_rcCheckbox2=_interopRequireDefault(_rcCheckbox),_shallowequal=require("shallowequal"),_shallowequal2=_interopRequireDefault(_shallowequal);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r.default=e,r}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var __rest=function(e,r){var t={};for(var l in e)Object.prototype.hasOwnProperty.call(e,l)&&r.indexOf(l)<0&&(t[l]=e[l]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(l=Object.getOwnPropertySymbols(e);a<l.length;a++)r.indexOf(l[a])<0&&(t[l[a]]=e[l[a]])}return t},Checkbox=function(e){function t(){(0,_classCallCheck3.default)(this,t);var r=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return r.saveCheckbox=function(e){r.rcCheckbox=e},r}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"shouldComponentUpdate",value:function(e,r,t){return!(0,_shallowequal2.default)(this.props,e)||!(0,_shallowequal2.default)(this.state,r)||!(0,_shallowequal2.default)(this.context.checkboxGroup,t.checkboxGroup)}},{key:"focus",value:function(){this.rcCheckbox.focus()}},{key:"blur",value:function(){this.rcCheckbox.blur()}},{key:"render",value:function(){var e=this.props,r=this.context,t=e.prefixCls,l=e.className,a=e.children,s=e.indeterminate,o=e.style,n=e.onMouseEnter,u=e.onMouseLeave,i=__rest(e,["prefixCls","className","children","indeterminate","style","onMouseEnter","onMouseLeave"]),c=r.checkboxGroup,p=(0,_extends3.default)({},i);c&&(p.onChange=function(){return c.toggleOption({label:a,value:e.value})},p.checked=-1!==c.value.indexOf(e.value),p.disabled=e.disabled||c.disabled);var _=(0,_classnames2.default)(l,(0,_defineProperty3.default)({},t+"-wrapper",!0)),f=(0,_classnames2.default)((0,_defineProperty3.default)({},t+"-indeterminate",s));return React.createElement("label",{className:_,style:o,onMouseEnter:n,onMouseLeave:u},React.createElement(_rcCheckbox2.default,(0,_extends3.default)({},p,{prefixCls:t,className:f,ref:this.saveCheckbox})),void 0!==a?React.createElement("span",null,a):null)}}]),t}(React.Component);(exports.default=Checkbox).defaultProps={prefixCls:"dt-checkbox",indeterminate:!1},Checkbox.contextTypes={checkboxGroup:PropTypes.any},module.exports=exports.default;