"use strict"; import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; import _createClass from "@babel/runtime/helpers/esm/createClass"; import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn"; import _isNativeReflectConstruct from "@babel/runtime/helpers/esm/isNativeReflectConstruct"; import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf"; import _inherits from "@babel/runtime/helpers/esm/inherits"; function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } import React from "react"; import classnames from "classnames"; import { clamp } from "./utils/innerSliderUtils"; var getDotCount = function getDotCount(spec) { var dots; if (spec.infinite) { dots = Math.ceil(spec.slideCount / spec.slidesToScroll); } else { dots = Math.ceil((spec.slideCount - spec.slidesToShow) / spec.slidesToScroll) + 1; } return dots; }; export var Dots = /*#__PURE__*/function (_React$PureComponent) { function Dots() { _classCallCheck(this, Dots); return _callSuper(this, Dots, arguments); } _inherits(Dots, _React$PureComponent); return _createClass(Dots, [{ key: "clickHandler", value: function clickHandler(options, e) { // In Autoplay the focus stays on clicked button even after transition // to next slide. That only goes away by click somewhere outside e.preventDefault(); this.props.clickHandler(options); } }, { key: "render", value: function render() { var _this$props = this.props, onMouseEnter = _this$props.onMouseEnter, onMouseOver = _this$props.onMouseOver, onMouseLeave = _this$props.onMouseLeave, infinite = _this$props.infinite, slidesToScroll = _this$props.slidesToScroll, slidesToShow = _this$props.slidesToShow, slideCount = _this$props.slideCount, currentSlide = _this$props.currentSlide; var dotCount = getDotCount({ slideCount: slideCount, slidesToScroll: slidesToScroll, slidesToShow: slidesToShow, infinite: infinite }); var mouseEvents = { onMouseEnter: onMouseEnter, onMouseOver: onMouseOver, onMouseLeave: onMouseLeave }; var dots = []; for (var i = 0; i < dotCount; i++) { var _rightBound = (i + 1) * slidesToScroll - 1; var rightBound = infinite ? _rightBound : clamp(_rightBound, 0, slideCount - 1); var _leftBound = rightBound - (slidesToScroll - 1); var leftBound = infinite ? _leftBound : clamp(_leftBound, 0, slideCount - 1); var className = classnames({ "slick-active": infinite ? currentSlide >= leftBound && currentSlide <= rightBound : currentSlide === leftBound }); var dotOptions = { message: "dots", index: i, slidesToScroll: slidesToScroll, currentSlide: currentSlide }; var onClick = this.clickHandler.bind(this, dotOptions); dots = dots.concat( /*#__PURE__*/React.createElement("li", { key: i, className: className }, /*#__PURE__*/React.cloneElement(this.props.customPaging(i), { onClick: onClick }))); } return /*#__PURE__*/React.cloneElement(this.props.appendDots(dots), _objectSpread({ className: this.props.dotsClass }, mouseEvents)); } }]); }(React.PureComponent);