"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),React=_interopRequireWildcard(require("react")),_classnames=_interopRequireDefault(require("classnames")),_withStyles=_interopRequireDefault(require("../../hoc/withStyles")),_ErrorBoundary=_interopRequireDefault(require("../../hoc/ErrorBoundary")),_styles=_interopRequireDefault(require("./styles")),RadioButton=/*#__PURE__*/function(_React$Component){function RadioButton(props){var _this;return(0,_classCallCheck2.default)(this,RadioButton),_this=(0,_possibleConstructorReturn2.default)(this,(0,_getPrototypeOf2.default)(RadioButton).call(this,props)),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"changeValue",function(value){_this.setState({value:value}),_this.props.onChange&&_this.props.onChange(value)}),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"_select",function(){_this.setState({value:!0}),_this.props.onChange&&_this.props.onChange(_this.state.value)}),(0,_defineProperty2.default)((0,_assertThisInitialized2.default)((0,_assertThisInitialized2.default)(_this)),"_renderRadio",function(){var _this$props=_this.props,classes=_this$props.classes,label=_this$props.label,disabled=_this$props.disabled;return React.createElement("div",{className:(0,_classnames.default)(classes.radioWrapper,{disabled:disabled}),onClick:_this._select},React.createElement("div",{className:(0,_classnames.default)(classes.radioOuterCircle,{selected:_this.state.value})},React.createElement("div",{className:classes.radioInnerCircle})),!!label&&React.createElement("div",{className:classes.radioLabel},label))}),_this.state={value:props.value},_this}return(0,_inherits2.default)(RadioButton,_React$Component),(0,_createClass2.default)(RadioButton,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){var props=this.props;props.value!==prevProps.value&&this.setState({value:props.value})}},{key:"render",value:function render(){var _this$props2=this.props,classes=_this$props2.classes,id=_this$props2.id,componentClass=(0,_classnames.default)(classes.radioComponent);return React.createElement(_ErrorBoundary.default,null,React.createElement("div",{className:componentClass,id:id},this._renderRadio()))}}]),RadioButton}(React.Component);(0,_defineProperty2.default)(RadioButton,"defaultProps",{label:"",id:"",onChange:function onChange(){},disabled:!1,value:!1});var _default=(0,_withStyles.default)(_styles.default)(RadioButton);exports.default=_default;