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,r){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&r.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)r.indexOf(o[s])<0&&(t[o[s]]=e[o[s]])}return t};import*as React from"react";import*as PropTypes from"prop-types";import RcCheckbox from"rc-checkbox";import classNames from"classnames";import shallowEqual from"shallowequal";var Radio=function(e){function r(){_classCallCheck(this,r);var e=_possibleConstructorReturn(this,(r.__proto__||Object.getPrototypeOf(r)).apply(this,arguments));return e.saveCheckbox=function(r){e.rcCheckbox=r},e}return _inherits(r,e),_createClass(r,[{key:"shouldComponentUpdate",value:function(e,r,t){return!shallowEqual(this.props,e)||!shallowEqual(this.state,r)||!shallowEqual(this.context.radioGroup,t.radioGroup)}},{key:"focus",value:function(){this.rcCheckbox.focus()}},{key:"blur",value:function(){this.rcCheckbox.blur()}},{key:"render",value:function(){var e,r=this.props,t=this.context,o=r.prefixCls,s=r.className,a=r.children,l=r.style,n=__rest(r,["prefixCls","className","children","style"]),i=t.radioGroup,c=_extends({},n);i&&(c.name=i.name,c.onChange=i.onChange,c.checked=r.value===i.value,c.disabled=r.disabled||i.disabled);var p=classNames(s,(_defineProperty(e={},o+"-wrapper",!0),_defineProperty(e,o+"-wrapper-checked",c.checked),_defineProperty(e,o+"-wrapper-disabled",c.disabled),e));return React.createElement("label",{className:p,style:l,onMouseEnter:r.onMouseEnter,onMouseLeave:r.onMouseLeave},React.createElement(RcCheckbox,_extends({},c,{prefixCls:o,ref:this.saveCheckbox})),void 0!==a?React.createElement("span",null,a):null)}}]),r}(React.Component);export default Radio;Radio.defaultProps={prefixCls:"dt-radio",type:"radio"},Radio.contextTypes={radioGroup:PropTypes.any};