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 / CCarouselControl

var CCarouselControl = function CCarouselControl(props) {
  var className = props.className,
      cssModule = props.cssModule,
      innerRef = props.innerRef,
      direction = props.direction,
      onClickHandler = props.onClickHandler,
      directionText = props.directionText,
      attributes = _objectWithoutProperties(props, ['className', 'cssModule', 'innerRef', 'direction', 'onClickHandler', 'directionText']);

  var onClick = function onClick(e) {
    e.preventDefault();
    onClickHandler();
  };

  //render

  var anchorClasses = mapToCssModules(classNames(className, 'carousel-control-' + direction), cssModule);

  var iconClasses = mapToCssModules(classNames('carousel-control-' + direction + '-icon'), cssModule);

  var screenReaderClasses = mapToCssModules(classNames('sr-only'), cssModule);

  return React.createElement(
    'a',
    _extends({}, attributes, {
      className: anchorClasses,
      role: 'button',
      tabIndex: '0',
      onClick: onClick,
      ref: innerRef
    }),
    React.createElement('span', { className: iconClasses, 'aria-hidden': 'true' }),
    React.createElement(
      'span',
      { className: screenReaderClasses },
      directionText || direction
    )
  );
};

CCarouselControl.propTypes = process.env.NODE_ENV !== "production" ? {
  className: PropTypes.string,
  cssModule: PropTypes.object,
  //
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  direction: PropTypes.oneOf(['prev', 'next']).isRequired,
  onClickHandler: PropTypes.func.isRequired,
  directionText: PropTypes.string
} : {};

export default CCarouselControl;