import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/esm/inherits";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

import React, { createElement } from 'react';
import { Select } from './component';
export var SelectContainer =
/*#__PURE__*/
function (_React$Component) {
  _inherits(SelectContainer, _React$Component);

  function SelectContainer(props) {
    var _this;

    _classCallCheck(this, SelectContainer);

    _this = _possibleConstructorReturn(this, _getPrototypeOf(SelectContainer).call(this, props));

    _this.handleChange = function (e) {
      var data = _objectSpread({}, _this.props, {
        value: e.currentTarget.value
      });

      _this.setState({
        value: data.value,
        valid: true
      });

      _this.props.onValidChange(_this.state.valid);

      _this.props.onChange(e, data);
    };

    _this.state = {
      value: '',
      valid: false
    };
    return _this;
  }

  _createClass(SelectContainer, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          id = _this$props.id,
          label = _this$props.label,
          options = _this$props.options,
          placeholder = _this$props.placeholder;
      var value = this.state.value;
      var props = {
        id: id,
        label: label,
        value: value,
        options: options,
        onChange: this.handleChange,
        placeholder: placeholder
      };
      return createElement(Select, props);
    }
  }]);

  return SelectContainer;
}(React.Component);