(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory(require("react"), require("prop-types"));
	else if(typeof define === 'function' && define.amd)
		define(["react", "prop-types"], factory);
	else {
		var a = typeof exports === 'object' ? factory(require("react"), require("prop-types")) : factory(root["React"], root["PropTypes"]);
		for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
	}
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__, __WEBPACK_EXTERNAL_MODULE_1__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, {
/******/ 				configurable: false,
/******/ 				enumerable: true,
/******/ 				get: getter
/******/ 			});
/******/ 		}
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = 1520);
/******/ })
/************************************************************************/
/******/ ({

/***/ 0:
/***/ (function(module, exports) {

module.exports = __WEBPACK_EXTERNAL_MODULE_0__;

/***/ }),

/***/ 1:
/***/ (function(module, exports) {

module.exports = __WEBPACK_EXTERNAL_MODULE_1__;

/***/ }),

/***/ 1002:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _classnames = __webpack_require__(4);

var _classnames2 = _interopRequireDefault(_classnames);

var _react = __webpack_require__(0);

var _react2 = _interopRequireDefault(_react);

var _propTypes = __webpack_require__(1);

var _propTypes2 = _interopRequireDefault(_propTypes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }

var propTypes = {
  /**
    * radio 颜色 样式
    */
  colors: _propTypes2["default"].oneOf(['', 'dark', 'success', 'info', 'warning', 'danger', 'primary']),
  /**
    * radio 大小
    */
  size: _propTypes2["default"].oneOf(['lg', 'sm']),
  /**
    * radio 是否可用
    */
  disabled: _propTypes2["default"].bool,
  /**
    * radio 样式 是否使用红色填充
    */
  inverse: _propTypes2["default"].bool,
  checked: _propTypes2["default"].bool,
  onChange: _propTypes2["default"].func
};

var defaultProps = {
  inverse: false,
  disabled: false,
  clsPrefix: 'u-radio'
};

/**
 * 建立与RadioGroup通信
 */
var contextTypes = {
  radioGroup: _propTypes2["default"].object
};

var Radio = function (_React$Component) {
  _inherits(Radio, _React$Component);

  function Radio(props, context) {
    _classCallCheck(this, Radio);

    var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));

    _this.handleClick = function (event) {
      if (_this.props.disabled) {
        return;
      }
      if (_this.context.radioGroup && _this.context.radioGroup.onChange) {
        _this.context.radioGroup.onChange(_this.props.value);
      } else {
        if (!('checked' in _this.props)) {
          _this.setState({
            checked: !_this.state.checked
          });
        }
        event.target.checked = !_this.state.checked;
        _this.props.onChange && _this.props.onChange(event, !_this.state.checked);
      }
    };

    _this.handleFocus = function (e) {
      if (e.target && e.target.type == 'radio') {
        _this.setState({
          focused: true
        });
      }
    };

    _this.handleBlur = function (e) {
      if (e.target && e.target.type == 'radio') {
        _this.setState({
          focused: false
        });
      }
    };

    var initChecked = typeof props.checked !== 'undefined' ? props.checked : props.defaultChecked;
    _this.state = {
      checked: initChecked,
      focused: false
    };
    return _this;
  }

  Radio.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
    if ('checked' in nextProps) {
      this.setState({
        checked: nextProps.checked
      });
    }
  };

  Radio.prototype.render = function render() {
    var _classes;

    var state = this.state,
        props = this.props,
        context = this.context;
    var checked = state.checked;
    /**
     * 自身的属性
     */

    var inverse = props.inverse,
        disabled = props.disabled,
        colors = props.colors,
        className = props.className,
        children = props.children,
        clsPrefix = props.clsPrefix,
        style = props.style,
        onChange = props.onChange,
        others = _objectWithoutProperties(props, ['inverse', 'disabled', 'colors', 'className', 'children', 'clsPrefix', 'style', 'onChange']);

    var radioGroup = context.radioGroup;

    var radioProps = _extends({}, others);
    // 包裹 radioGroup
    if (radioGroup) {
      radioProps.name = radioGroup.name;
      radioProps.selectedvalue = radioGroup.selectedValue;
      radioProps.size = radioGroup.size;
      radioProps.focusvalue = radioGroup.focusvalue;
    }
    var name = radioProps.name,
        selectedvalue = radioProps.selectedvalue,
        size = radioProps.size,
        focusvalue = radioProps.focusvalue;


    var optional = {};
    /**
     * 若父级selectedValue与本身的value值相同，则改radio被选中
     */
    if (selectedvalue !== undefined) {
      optional.checked = this.props.value === selectedvalue;
    }

    var classes = (_classes = {}, _defineProperty(_classes, clsPrefix + '-focused', this.state.focused), _defineProperty(_classes, 'is-checked', typeof optional.checked !== 'undefined' ? optional.checked : checked), _defineProperty(_classes, 'disabled', disabled), _classes);

    if (colors) {
      classes[clsPrefix + '-' + colors] = true;
    }
    if (size) {
      classes[clsPrefix + '-' + size] = true;
    }
    if (inverse) {
      classes[clsPrefix + '-inverse'] = true;
    }
    if (children == null) {
      classes[clsPrefix + '-noContent'] = true;
    }
    var classNames = (0, _classnames2["default"])(clsPrefix, classes);
    var tabIndex = optional.checked ? 0 : -1;
    if (focusvalue && focusvalue == this.props.value) {
      tabIndex = 0;
    }
    var input = _react2["default"].createElement('input', _extends({}, radioProps, {
      type: 'radio',
      name: name,
      disabled: this.props.disabled,
      tabIndex: tabIndex,
      onFocus: this.handleFocus,
      onBlur: this.handleBlur
    }));
    return _react2["default"].createElement(
      'label',
      { style: style, onClick: this.handleClick, className: (0, _classnames2["default"])(className, classNames) },
      input,
      _react2["default"].createElement(
        'label',
        { className: clsPrefix + '-label' },
        children
      )
    );
  };

  return Radio;
}(_react2["default"].Component);

Radio.contextTypes = contextTypes;
Radio.propTypes = propTypes;
Radio.defaultProps = defaultProps;

exports["default"] = Radio;
module.exports = exports['default'];

/***/ }),

/***/ 1520:
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(1521);


/***/ }),

/***/ 1521:
/***/ (function(module, exports, __webpack_require__) {

__webpack_require__(1522);
module.exports = __webpack_require__(1523);


/***/ }),

/***/ 1522:
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ }),

/***/ 1523:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _RadioGroup = __webpack_require__(1524);

var _RadioGroup2 = _interopRequireDefault(_RadioGroup);

var _Radio = __webpack_require__(1002);

var _Radio2 = _interopRequireDefault(_Radio);

var _RadioButton = __webpack_require__(1525);

var _RadioButton2 = _interopRequireDefault(_RadioButton);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

_Radio2["default"].RadioGroup = _RadioGroup2["default"];
_Radio2["default"].RadioButton = _RadioButton2["default"];

exports["default"] = _Radio2["default"];
module.exports = exports['default'];

/***/ }),

/***/ 1524:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = __webpack_require__(0);

var _react2 = _interopRequireDefault(_react);

var _classnames = __webpack_require__(4);

var _classnames2 = _interopRequireDefault(_classnames);

var _propTypes = __webpack_require__(1);

var _propTypes2 = _interopRequireDefault(_propTypes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }

var propTypes = {
  name: _propTypes2["default"].string,
  /**
   * 默认选中的值
   */
  defaultValue: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].number, _propTypes2["default"].bool]),
  /**
   * 选中的值
   */
  selectedValue: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].number, _propTypes2["default"].bool]),
  /**
   * 选中的值,作用与selectedValue一致，添加value属性是为了配合form表单校验初始化等一起使用
   */
  value: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].number, _propTypes2["default"].bool]),
  /**
  * 暴露给用户，且与子Radio通信的方法
  */
  onChange: _propTypes2["default"].func,
  /**
    * radio 大小
    */
  size: _propTypes2["default"].oneOf(['lg', 'sm']),

  children: _propTypes2["default"].node.isRequired,

  Component: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].func, _propTypes2["default"].object]),
  disabled: _propTypes2["default"].bool
};

var defaultProps = {
  Component: 'div',
  clsPrefix: 'u-radio-group',
  defaultValue: ''
};

/**
 * 与子Radio通信
 */
var childContextTypes = {
  radioGroup: _propTypes2["default"].object
};

var RadioGroup = function (_React$Component) {
  _inherits(RadioGroup, _React$Component);

  function RadioGroup(props, context) {
    _classCallCheck(this, RadioGroup);

    var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));

    _this.getValues = function () {
      var array = [];
      var children = _this.props.children;
      if (!children) {
        console.error('RadioGroup must have child nodes');
        return array;
      }
      if (children.length > 1) {
        children.map(function (item) {
          array.push(item.props.value);
        });
      } else if (children.length === 1) {
        array.push(children[0].props.value);
      } else {
        array.push(children.props.value);
      }
      return array;
    };

    _this.handleChange = function (value) {
      var onChange = _this.props.onChange;

      if (!('selectedValue' in _this.props)) {
        _this.setState({
          selectedValue: value
        });
      }
      onChange && onChange(value);
    };

    var initValue = 'value' in props ? props.value : 'selectedValue' in props ? props.selectedValue : props.defaultValue;
    _this.state = {
      focusvalue: '',
      selectedValue: initValue
    };
    return _this;
  }

  RadioGroup.prototype.componentDidMount = function componentDidMount() {
    var array = this.getValues();
    if (array.indexOf(this.props.selectedValue) == -1) {
      this.setState({
        focusvalue: array[0]
      });
    }
  };

  RadioGroup.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
    var array = this.getValues();
    if (array.indexOf(this.props.selectedValue) == -1 || array.indexOf(this.props.value) == -1) {
      this.setState({
        focusvalue: array[0]
      });
    } else {
      this.setState({
        focusvalue: ''
      });
    }
    if ('selectedValue' in nextProps || 'value' in nextProps) {
      this.setState({
        selectedValue: nextProps.selectedValue !== undefined ? nextProps.selectedValue : nextProps.value
      });
    }
  };

  /**
    * 一旦外层change方法触发本身props发生改变，则调用getChildContext更新与子Radio的通信信息（radioGroup）
    */

  RadioGroup.prototype.getChildContext = function getChildContext() {
    var _props = this.props,
        name = _props.name,
        size = _props.size;
    var selectedValue = this.state.selectedValue;

    var onChange = this.handleChange;
    return {
      radioGroup: {
        name: name, selectedValue: selectedValue, onChange: onChange, size: size, focusvalue: this.state.focusvalue
      }
    };
  };

  RadioGroup.prototype.render = function render() {
    var _props2 = this.props,
        Component = _props2.Component,
        name = _props2.name,
        selectedValue = _props2.selectedValue,
        onChange = _props2.onChange,
        children = _props2.children,
        size = _props2.size,
        clsPrefix = _props2.clsPrefix,
        className = _props2.className,
        focusvalue = _props2.focusvalue,
        disabled = _props2.disabled,
        others = _objectWithoutProperties(_props2, ['Component', 'name', 'selectedValue', 'onChange', 'children', 'size', 'clsPrefix', 'className', 'focusvalue', 'disabled']);

    return _react2["default"].createElement(
      Component,
      _extends({ className: (0, _classnames2["default"])(clsPrefix, className) }, others, { focusvalue: this.state.focusvalue }),
      _react2["default"].Children.map(children, function (child) {
        return _react2["default"].cloneElement(child, {
          disabled: child.props.disabled || disabled
        });
      })
    );
  };

  return RadioGroup;
}(_react2["default"].Component);

RadioGroup.childContextTypes = childContextTypes;
RadioGroup.propTypes = propTypes;
RadioGroup.defaultProps = defaultProps;
exports["default"] = RadioGroup;
module.exports = exports['default'];

/***/ }),

/***/ 1525:
/***/ (function(module, exports, __webpack_require__) {

"use strict";


Object.defineProperty(exports, "__esModule", {
  value: true
});

var _react = __webpack_require__(0);

var _react2 = _interopRequireDefault(_react);

var _Radio = __webpack_require__(1002);

var _Radio2 = _interopRequireDefault(_Radio);

var _propTypes = __webpack_require__(1);

var _propTypes2 = _interopRequireDefault(_propTypes);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }

var propTypes = {
  value: _propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].number]),
  style: _propTypes2["default"].object
};
var defaultProps = {
  clsPrefix: "u-radio-button"
};

var RadioButton = function (_Component) {
  _inherits(RadioButton, _Component);

  function RadioButton() {
    _classCallCheck(this, RadioButton);

    return _possibleConstructorReturn(this, _Component.apply(this, arguments));
  }

  RadioButton.prototype.render = function render() {
    return _react2["default"].createElement(_Radio2["default"], this.props);
  };

  return RadioButton;
}(_react.Component);

RadioButton.propTypes = propTypes;
RadioButton.defaultProps = defaultProps;
exports["default"] = RadioButton;
module.exports = exports['default'];

/***/ }),

/***/ 4:
/***/ (function(module, exports, __webpack_require__) {

var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  Copyright (c) 2017 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/
/* global define */

(function () {
	'use strict';

	var hasOwn = {}.hasOwnProperty;

	function classNames () {
		var classes = [];

		for (var i = 0; i < arguments.length; i++) {
			var arg = arguments[i];
			if (!arg) continue;

			var argType = typeof arg;

			if (argType === 'string' || argType === 'number') {
				classes.push(arg);
			} else if (Array.isArray(arg) && arg.length) {
				var inner = classNames.apply(null, arg);
				if (inner) {
					classes.push(inner);
				}
			} else if (argType === 'object') {
				for (var key in arg) {
					if (hasOwn.call(arg, key) && arg[key]) {
						classes.push(key);
					}
				}
			}
		}

		return classes.join(' ');
	}

	if (typeof module !== 'undefined' && module.exports) {
		classNames.default = classNames;
		module.exports = classNames;
	} else if (true) {
		// register as 'classnames', consistent with npm package name
		!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
			return classNames;
		}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
	} else {
		window.classNames = classNames;
	}
}());


/***/ })

/******/ });
});