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 _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; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

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, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

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; }

import React from 'react';
import { FormSelect, FormSelectOption, FormSelectOptionGroup } from '../index';

var FormSelectInputGrouped =
/*#__PURE__*/
function (_React$Component) {
  _inherits(FormSelectInputGrouped, _React$Component);

  function FormSelectInputGrouped() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, FormSelectInputGrouped);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(FormSelectInputGrouped)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
      value: '2'
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onChange", function (value, event) {
      _this.setState({
        value: value
      });
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "groups", [{
      groupLabel: 'Group1',
      disabled: false,
      options: [{
        value: '1',
        label: 'The First Option',
        disabled: false
      }, {
        value: '2',
        label: 'Second option is selected by default',
        disabled: false
      }]
    }, {
      groupLabel: 'Group2',
      disabled: false,
      options: [{
        value: '3',
        label: 'The Third Option',
        disabled: false
      }, {
        value: '4',
        label: 'The Fourth option',
        disabled: false
      }]
    }, {
      groupLabel: 'Group3',
      disabled: true,
      options: [{
        value: '5',
        label: 'The Fifth Option',
        disabled: false
      }, {
        value: '6',
        label: 'The Sixth option',
        disabled: false
      }]
    }]);

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getOptionLbl", function (option) {
      return option.label;
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getOptionVal", function (option) {
      return option.value;
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getOptionsGroupLbl", function (group) {
      return group && group.groupLabel;
    });

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getGroupOptions", function (group) {
      return group && group.options;
    });

    return _this;
  }

  _createClass(FormSelectInputGrouped, [{
    key: "render",
    value: function render() {
      return React.createElement(FormSelect, {
        value: this.state.value,
        onChange: this.onChange,
        "aria-label": "FormSelect Input"
      }, this.groups.map(function (group, index) {
        return React.createElement(FormSelectOptionGroup, {
          isDisabled: group.disabled,
          key: index,
          label: group.groupLabel
        }, group.options.map(function (option, i) {
          return React.createElement(FormSelectOption, {
            isDisabled: option.disabled,
            key: i,
            value: option.value,
            label: option.label
          });
        }));
      }));
    }
  }]);

  return FormSelectInputGrouped;
}(React.Component);

export default FormSelectInputGrouped;