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

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

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { tagPropType, mapToCssModules } from './Shared/helper.js';
import CLink from './CLink';

//component - CoreUI / CListGroupItem

var CListGroupItem = function CListGroupItem(props) {
  var Tag = props.tag,
      className = props.className,
      cssModule = props.cssModule,
      innerRef = props.innerRef,
      active = props.active,
      disabled = props.disabled,
      action = props.action,
      color = props.color,
      accent = props.accent,
      attributes = _objectWithoutProperties(props, ['tag', 'className', 'cssModule', 'innerRef', 'active', 'disabled', 'action', 'color', 'accent']);

  if (disabled) {
    attributes.onClick = function (e) {
      e.preventDefault();
    };
  }

  //render

  var classes = mapToCssModules(classNames(className, active ? 'active' : false, disabled ? 'disabled' : false, action || attributes.href || attributes.to || Tag == 'button' ? 'list-group-item-action' : false, color ? 'list-group-item-' + color : false, accent ? 'list-group-item-accent-' + accent : false, 'list-group-item'), cssModule);

  if (props.href || props.to) {
    Tag = CLink;
    return React.createElement(Tag, _extends({}, attributes, { className: classes }));
  } else {
    return React.createElement(Tag, _extends({}, attributes, { className: classes, ref: innerRef }));
  }
};

CListGroupItem.propTypes = process.env.NODE_ENV !== "production" ? {
  tag: tagPropType,
  className: PropTypes.any,
  cssModule: PropTypes.object,
  //
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  active: PropTypes.bool,
  disabled: PropTypes.bool,
  color: PropTypes.string,
  accent: PropTypes.string,
  action: PropTypes.bool
} : {};

CListGroupItem.defaultProps = {
  tag: 'li'
};

export default CListGroupItem;