import _defineProperty from"babel-runtime/helpers/defineProperty";import _extends from"babel-runtime/helpers/extends";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";var __rest=this&&this.__rest||function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&(r[o[s]]=e[o[s]])}return r};import*as React from"react";import*as PropTypes from"prop-types";import classNames from"classnames";import RcCheckbox from"rc-checkbox";import shallowEqual from"shallowequal";var Checkbox=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.saveCheckbox=function(t){e.rcCheckbox=t},e}return _inherits(t,e),_createClass(t,[{key:"shouldComponentUpdate",value:function(e,t,r){return!shallowEqual(this.props,e)||!shallowEqual(this.state,t)||!shallowEqual(this.context.checkboxGroup,r.checkboxGroup)}},{key:"focus",value:function(){this.rcCheckbox.focus()}},{key:"blur",value:function(){this.rcCheckbox.blur()}},{key:"render",value:function(){var e=this.props,t=this.context,r=e.prefixCls,o=e.className,s=e.children,a=e.indeterminate,n=e.style,l=e.onMouseEnter,c=e.onMouseLeave,i=__rest(e,["prefixCls","className","children","indeterminate","style","onMouseEnter","onMouseLeave"]),p=t.checkboxGroup,u=_extends({},i);p&&(u.onChange=function(){return p.toggleOption({label:s,value:e.value})},u.checked=-1!==p.value.indexOf(e.value),u.disabled=e.disabled||p.disabled);var h=classNames(o,_defineProperty({},r+"-wrapper",!0)),m=classNames(_defineProperty({},r+"-indeterminate",a));return React.createElement("label",{className:h,style:n,onMouseEnter:l,onMouseLeave:c},React.createElement(RcCheckbox,_extends({},u,{prefixCls:r,className:m,ref:this.saveCheckbox})),void 0!==s?React.createElement("span",null,s):null)}}]),t}(React.Component);export default Checkbox;Checkbox.defaultProps={prefixCls:"dt-checkbox",indeterminate:!1},Checkbox.contextTypes={checkboxGroup:PropTypes.any};