import "core-js/modules/es6.object.assign";
import "core-js/modules/web.dom.iterable";
import "core-js/modules/es6.array.iterator";
import "core-js/modules/es6.object.keys";

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 _objectWithoutPropertiesLoose(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]; } return target; }

function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }

import React from 'react';
import PropTypes from 'prop-types';
import { uniqueId } from 'lodash';
import { Checkbox, Icon, ListItem, ListItemSection } from "./..";
/**
 * @category containers
 * @component select-option
 * @variations collab-ui-react
 */

var SelectOption =
/*#__PURE__*/
function (_React$Component) {
  _inheritsLoose(SelectOption, _React$Component);

  function SelectOption() {
    var _this;

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

    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
    _this.state = {
      id: _this.props.id || uniqueId('cui-select-option-')
    };
    return _this;
  }

  var _proto = SelectOption.prototype;

  _proto.render = function render() {
    var _this$props = this.props,
        className = _this$props.className,
        isMulti = _this$props.isMulti,
        active = _this$props.active,
        children = _this$props.children,
        label = _this$props.label,
        title = _this$props.title,
        props = _objectWithoutPropertiesLoose(_this$props, ["className", "isMulti", "active", "children", "label", "title"]);

    var id = this.state.id;
    var separateChildren = isMulti ? React.createElement(Checkbox, {
      htmlId: id + "__checkbox",
      label: label,
      checked: active,
      onChange: function onChange() {}
    }) : [React.createElement(ListItemSection, {
      key: "child-0",
      position: "center"
    }, label || children), React.createElement(ListItemSection, {
      key: "child-1",
      position: "right"
    }, active && React.createElement(Icon, {
      color: "blue",
      name: "check_20"
    }))];
    return React.createElement(ListItem, _extends({
      className: "" + (className && " " + className || ''),
      id: id,
      label: label,
      title: title || label
    }, props), separateChildren);
  };

  return SelectOption;
}(React.Component);

SelectOption.displayName = 'SelectOption';
SelectOption.defaultProps = {
  active: false,
  children: null,
  className: '',
  id: '',
  isMulti: false,
  label: '',
  title: '',
  value: ''
};
SelectOption.propTypes = {
  /** SelectOption Boolean that describes active state */
  active: PropTypes.bool,

  /** SelectOption Children */
  children: PropTypes.node,

  /** HTML Class for ListItem */
  className: PropTypes.string,

  /** SelectOption id */
  id: PropTypes.string,

  /** SelectOption Boolean that modifies adds checkboxes */
  isMulti: PropTypes.bool,

  /** SelectOption string alternative to children nodes */
  label: PropTypes.string,

  /** ListItem Title */
  title: PropTypes.string,

  /** Value  */
  value: PropTypes.string
};
export default SelectOption;