text: function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  function _extends() { _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; }; return _extends.apply(this, arguments); }
  
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  import PropTypes from 'prop-types';
  import React from 'react';
  import RadioTile from '../RadioTile';
  import warning from 'warning';
  
  var TileGroup =
  /*#__PURE__*/
  function (_React$Component) {
    _inherits(TileGroup, _React$Component);
  
    function TileGroup() {
      var _ref;
  
      var _temp, _this;
  
      _classCallCheck(this, TileGroup);
  
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
  
      return _possibleConstructorReturn(_this, (_temp = _this = _possibleConstructorReturn(this, (_ref = TileGroup.__proto__ || Object.getPrototypeOf(TileGroup)).call.apply(_ref, [this].concat(args))), Object.defineProperty(_assertThisInitialized(_this), "state", {
        configurable: true,
        enumerable: true,
        writable: true,
        value: {
          selected: null
        }
      }), Object.defineProperty(_assertThisInitialized(_this), "getRadioTiles", {
        configurable: true,
        enumerable: true,
        writable: true,
        value: function value() {
          var childrenArray = React.Children.toArray(_this.props.children);
          var children = childrenArray.map(function (tileRadio) {
            var _tileRadio$props = tileRadio.props,
                value = _tileRadio$props.value,
                other = _objectWithoutProperties(_tileRadio$props, ["value"]);
            /* istanbul ignore if */
  
  
            if (tileRadio.props.hasOwnProperty('checked')) {
              process.env.NODE_ENV !== "production" ? warning(false, "Instead of using the checked property on the RadioTile, set\n            the defaultSelected property or valueSelected property on the TileGroup.") : void 0;
            }
  
            return React.createElement(RadioTile, _extends({}, other, {
              name: _this.props.name,
              key: value,
              value: value,
              onChange: _this.handleChange,
              checked: value === _this.state.selected
            }));
          });
          return children;
        }
      }), Object.defineProperty(_assertThisInitialized(_this), "handleChange", {
        configurable: true,
        enumerable: true,
        writable: true,
        value: function value(newSelection, _value, evt) {
          if (newSelection !== _this.state.selected) {
            _this.setState({
              selected: newSelection
            });
  
            _this.props.onChange(newSelection, _this.props.name, evt);
          }
        }
      }), _temp));
    }
  
    _createClass(TileGroup, [{
      key: "UNSAFE_componentWillMount",
      value: function UNSAFE_componentWillMount() {
        this.setState({
          selected: this.props.valueSelected || this.props.defaultSelected || null
        });
      }
    }, {
      key: "UNSAFE_componentWillReceiveProps",
      value: function UNSAFE_componentWillReceiveProps(nextProps) {
        if (nextProps.hasOwnProperty('valueSelected')) {
          this.setState({
            selected: nextProps.valueSelected
          });
        }
      }
    }, {
      key: "render",
      value: function render() {
        var _props = this.props,
            disabled = _props.disabled,
            className = _props.className;
        return React.createElement("div", {
          className: className,
          disabled: disabled
        }, this.getRadioTiles());
      }
    }]);
  
    return TileGroup;
  }(React.Component);
  
  Object.defineProperty(TileGroup, "propTypes", {
    configurable: true,
    enumerable: true,
    writable: true,
    value: {
      children: PropTypes.node,
      className: PropTypes.string,
      defaultSelected: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
      name: PropTypes.string.isRequired,
      disabled: PropTypes.bool,
      onChange: PropTypes.func,
      valueSelected: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
    }
  });
  Object.defineProperty(TileGroup, "defaultProps", {
    configurable: true,
    enumerable: true,
    writable: true,
    value: {
      onChange:
      /* istanbul ignore next */
      function onChange() {},
      className: 'bx--tile-group'
    }
  });
  export { TileGroup as default };