import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var _excluded = ["len", "smallImgList", "activeIndex", "imgWidth", "arrowStyle", "smallImgWidth", "handleClick", "display"];

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

/**
 * dots.jsx
 *
 * @Author: bjzhuwei
 * @Date: 2017/8/18 22:52
 */
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
/**
 * @ignore
 * */

var Dots = /*#__PURE__*/function (_React$PureComponent) {
  _inherits(Dots, _React$PureComponent);

  var _super = _createSuper(Dots);

  function Dots() {
    _classCallCheck(this, Dots);

    return _super.apply(this, arguments);
  }

  _createClass(Dots, [{
    key: "render",
    value: function render() {
      var _this = this;

      var _this$props = this.props,
          len = _this$props.len,
          smallImgList = _this$props.smallImgList,
          activeIndex = _this$props.activeIndex,
          imgWidth = _this$props.imgWidth,
          arrowStyle = _this$props.arrowStyle,
          smallImgWidth = _this$props.smallImgWidth,
          handleClick = _this$props.handleClick,
          display = _this$props.display,
          other = _objectWithoutProperties(_this$props, _excluded);

      var smallImgContainerWidth = len * (smallImgWidth + 2 || 60);
      var imgInnerStyle = {};

      if (smallImgContainerWidth > imgWidth) {
        smallImgContainerWidth = imgWidth;
        imgInnerStyle.overflowY = 'scroll';
      }

      imgInnerStyle.width = "".concat(smallImgContainerWidth, "px");
      return /*#__PURE__*/React.createElement("div", {
        className: "dots-index-container",
        style: {
          width: "".concat(imgWidth, "px")
        }
      }, len !== 1 && display ? /*#__PURE__*/React.createElement("div", _extends({
        className: classNames('dots', 'inner-bottom'),
        ref: function ref(e) {
          return _this.dots = e;
        },
        style: arrowStyle
      }, other), /*#__PURE__*/React.createElement("div", {
        className: "inner"
      }, /*#__PURE__*/React.createElement("div", {
        className: "dots-list"
      }, smallImgList.map(function (item, index) {
        var currentIndex = index + 1;
        var className = activeIndex === currentIndex ? 'on dot-item dot-btn' : 'dot-item dot-btn';
        return /*#__PURE__*/React.createElement("span", {
          key: currentIndex,
          className: className,
          onClick: function onClick() {
            return handleClick(currentIndex);
          }
        });
      })))) : null);
    }
  }]);

  return Dots;
}(React.PureComponent);

_defineProperty(Dots, "propTypes", {
  type: PropTypes.string,
  len: PropTypes.number,
  imgList: PropTypes.array,
  activeIndex: PropTypes.number,
  handleClick: PropTypes.func,
  hover: PropTypes.bool
});

export default Dots;