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 { mapToCssModules } from './Shared/helper.js';

//component - CoreUI / CCarouselIndicators

var CCarouselIndicators = function CCarouselIndicators(props) {
  var className = props.className,
      cssModule = props.cssModule,
      innerRef = props.innerRef,
      items = props.items,
      activeIndex = props.activeIndex,
      onClickHandler = props.onClickHandler,
      itemProps = props.itemProps,
      attributes = _objectWithoutProperties(props, ['className', 'cssModule', 'innerRef', 'items', 'activeIndex', 'onClickHandler', 'itemProps']);

  //render

  var listClasses = mapToCssModules(classNames(className, 'carousel-indicators'), cssModule);

  var indicators = items.map(function (item, idx) {
    var indicatorClasses = mapToCssModules(classNames({ 'active': activeIndex === idx }), cssModule);
    return React.createElement('li', _extends({
      key: '' + (item.key || Object.values(item).join('')),
      onClick: function onClick(e) {
        e.preventDefault();
        onClickHandler(idx);
      },
      className: indicatorClasses
    }, itemProps));
  });

  return React.createElement(
    'ol',
    _extends({}, attributes, { className: listClasses, ref: innerRef }),
    indicators
  );
};

CCarouselIndicators.propTypes = process.env.NODE_ENV !== "production" ? {
  className: PropTypes.string,
  cssModule: PropTypes.object,
  //
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  items: PropTypes.array.isRequired,
  activeIndex: PropTypes.number.isRequired,
  onClickHandler: PropTypes.func.isRequired,
  itemProps: PropTypes.object
} : {};

export default CCarouselIndicators;