volleyball-dev-frontend/node_modules/react-responsive-carousel/lib/js/components/Carousel/index.js
2025-06-02 16:42:16 +00:00

830 lines
31 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactEasySwipe = _interopRequireDefault(require("react-easy-swipe"));
var _cssClasses = _interopRequireDefault(require("../../cssClasses"));
var _Thumbs = _interopRequireDefault(require("../Thumbs"));
var _document = _interopRequireDefault(require("../../shims/document"));
var _window = _interopRequireDefault(require("../../shims/window"));
var _utils = require("./utils");
var _animations = require("./animations");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() { _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; }; return _extends.apply(this, arguments); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Carousel = /*#__PURE__*/function (_React$Component) {
_inherits(Carousel, _React$Component);
var _super = _createSuper(Carousel);
// @ts-ignore
function Carousel(props) {
var _this;
_classCallCheck(this, Carousel);
_this = _super.call(this, props);
_defineProperty(_assertThisInitialized(_this), "thumbsRef", void 0);
_defineProperty(_assertThisInitialized(_this), "carouselWrapperRef", void 0);
_defineProperty(_assertThisInitialized(_this), "listRef", void 0);
_defineProperty(_assertThisInitialized(_this), "itemsRef", void 0);
_defineProperty(_assertThisInitialized(_this), "timer", void 0);
_defineProperty(_assertThisInitialized(_this), "animationHandler", void 0);
_defineProperty(_assertThisInitialized(_this), "setThumbsRef", function (node) {
_this.thumbsRef = node;
});
_defineProperty(_assertThisInitialized(_this), "setCarouselWrapperRef", function (node) {
_this.carouselWrapperRef = node;
});
_defineProperty(_assertThisInitialized(_this), "setListRef", function (node) {
_this.listRef = node;
});
_defineProperty(_assertThisInitialized(_this), "setItemsRef", function (node, index) {
if (!_this.itemsRef) {
_this.itemsRef = [];
}
_this.itemsRef[index] = node;
});
_defineProperty(_assertThisInitialized(_this), "autoPlay", function () {
if (_react.Children.count(_this.props.children) <= 1) {
return;
}
_this.clearAutoPlay();
if (!_this.props.autoPlay) {
return;
}
_this.timer = setTimeout(function () {
_this.increment();
}, _this.props.interval);
});
_defineProperty(_assertThisInitialized(_this), "clearAutoPlay", function () {
if (_this.timer) clearTimeout(_this.timer);
});
_defineProperty(_assertThisInitialized(_this), "resetAutoPlay", function () {
_this.clearAutoPlay();
_this.autoPlay();
});
_defineProperty(_assertThisInitialized(_this), "stopOnHover", function () {
_this.setState({
isMouseEntered: true
}, _this.clearAutoPlay);
});
_defineProperty(_assertThisInitialized(_this), "startOnLeave", function () {
_this.setState({
isMouseEntered: false
}, _this.autoPlay);
});
_defineProperty(_assertThisInitialized(_this), "isFocusWithinTheCarousel", function () {
if (!_this.carouselWrapperRef) {
return false;
}
if ((0, _document.default)().activeElement === _this.carouselWrapperRef || _this.carouselWrapperRef.contains((0, _document.default)().activeElement)) {
return true;
}
return false;
});
_defineProperty(_assertThisInitialized(_this), "navigateWithKeyboard", function (e) {
if (!_this.isFocusWithinTheCarousel()) {
return;
}
var axis = _this.props.axis;
var isHorizontal = axis === 'horizontal';
var keyNames = {
ArrowUp: 38,
ArrowRight: 39,
ArrowDown: 40,
ArrowLeft: 37
};
var nextKey = isHorizontal ? keyNames.ArrowRight : keyNames.ArrowDown;
var prevKey = isHorizontal ? keyNames.ArrowLeft : keyNames.ArrowUp;
if (nextKey === e.keyCode) {
_this.increment();
} else if (prevKey === e.keyCode) {
_this.decrement();
}
});
_defineProperty(_assertThisInitialized(_this), "updateSizes", function () {
if (!_this.state.initialized || !_this.itemsRef || _this.itemsRef.length === 0) {
return;
}
var isHorizontal = _this.props.axis === 'horizontal';
var firstItem = _this.itemsRef[0];
if (!firstItem) {
return;
}
var itemSize = isHorizontal ? firstItem.clientWidth : firstItem.clientHeight;
_this.setState({
itemSize: itemSize
});
if (_this.thumbsRef) {
_this.thumbsRef.updateSizes();
}
});
_defineProperty(_assertThisInitialized(_this), "setMountState", function () {
_this.setState({
hasMount: true
});
_this.updateSizes();
});
_defineProperty(_assertThisInitialized(_this), "handleClickItem", function (index, item) {
if (_react.Children.count(_this.props.children) === 0) {
return;
}
if (_this.state.cancelClick) {
_this.setState({
cancelClick: false
});
return;
}
_this.props.onClickItem(index, item);
if (index !== _this.state.selectedItem) {
_this.setState({
selectedItem: index
});
}
});
_defineProperty(_assertThisInitialized(_this), "handleOnChange", function (index, item) {
if (_react.Children.count(_this.props.children) <= 1) {
return;
}
_this.props.onChange(index, item);
});
_defineProperty(_assertThisInitialized(_this), "handleClickThumb", function (index, item) {
_this.props.onClickThumb(index, item);
_this.moveTo(index);
});
_defineProperty(_assertThisInitialized(_this), "onSwipeStart", function (event) {
_this.setState({
swiping: true
});
_this.props.onSwipeStart(event);
});
_defineProperty(_assertThisInitialized(_this), "onSwipeEnd", function (event) {
_this.setState({
swiping: false,
cancelClick: false,
swipeMovementStarted: false
});
_this.props.onSwipeEnd(event);
_this.clearAutoPlay();
if (_this.state.autoPlay) {
_this.autoPlay();
}
});
_defineProperty(_assertThisInitialized(_this), "onSwipeMove", function (delta, event) {
_this.props.onSwipeMove(event);
var animationHandlerResponse = _this.props.swipeAnimationHandler(delta, _this.props, _this.state, _this.setState.bind(_assertThisInitialized(_this)));
_this.setState(_objectSpread({}, animationHandlerResponse)); // If we have not moved, we should have an empty object returned
// Return false to allow scrolling when not swiping
return !!Object.keys(animationHandlerResponse).length;
});
_defineProperty(_assertThisInitialized(_this), "decrement", function () {
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
_this.moveTo(_this.state.selectedItem - (typeof positions === 'number' ? positions : 1));
});
_defineProperty(_assertThisInitialized(_this), "increment", function () {
var positions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
_this.moveTo(_this.state.selectedItem + (typeof positions === 'number' ? positions : 1));
});
_defineProperty(_assertThisInitialized(_this), "moveTo", function (position) {
if (typeof position !== 'number') {
return;
}
var lastPosition = _react.Children.count(_this.props.children) - 1;
if (position < 0) {
position = _this.props.infiniteLoop ? lastPosition : 0;
}
if (position > lastPosition) {
position = _this.props.infiniteLoop ? 0 : lastPosition;
}
_this.selectItem({
// if it's not a slider, we don't need to set position here
selectedItem: position
}); // don't reset auto play when stop on hover is enabled, doing so will trigger a call to auto play more than once
// and will result in the interval function not being cleared correctly.
if (_this.state.autoPlay && _this.state.isMouseEntered === false) {
_this.resetAutoPlay();
}
});
_defineProperty(_assertThisInitialized(_this), "onClickNext", function () {
_this.increment(1);
});
_defineProperty(_assertThisInitialized(_this), "onClickPrev", function () {
_this.decrement(1);
});
_defineProperty(_assertThisInitialized(_this), "onSwipeForward", function () {
_this.increment(1);
if (_this.props.emulateTouch) {
_this.setState({
cancelClick: true
});
}
});
_defineProperty(_assertThisInitialized(_this), "onSwipeBackwards", function () {
_this.decrement(1);
if (_this.props.emulateTouch) {
_this.setState({
cancelClick: true
});
}
});
_defineProperty(_assertThisInitialized(_this), "changeItem", function (newIndex) {
return function (e) {
if (!(0, _utils.isKeyboardEvent)(e) || e.key === 'Enter') {
_this.moveTo(newIndex);
}
};
});
_defineProperty(_assertThisInitialized(_this), "selectItem", function (state) {
// Merge in the new state while updating updating previous item
_this.setState(_objectSpread({
previousItem: _this.state.selectedItem
}, state), function () {
// Run animation handler and update styles based on it
_this.setState(_this.animationHandler(_this.props, _this.state));
});
_this.handleOnChange(state.selectedItem, _react.Children.toArray(_this.props.children)[state.selectedItem]);
});
_defineProperty(_assertThisInitialized(_this), "getInitialImage", function () {
var selectedItem = _this.props.selectedItem;
var item = _this.itemsRef && _this.itemsRef[selectedItem];
var images = item && item.getElementsByTagName('img') || [];
return images[0];
});
_defineProperty(_assertThisInitialized(_this), "getVariableItemHeight", function (position) {
var item = _this.itemsRef && _this.itemsRef[position];
if (_this.state.hasMount && item && item.children.length) {
var slideImages = item.children[0].getElementsByTagName('img') || [];
if (slideImages.length > 0) {
var image = slideImages[0];
if (!image.complete) {
// if the image is still loading, the size won't be available so we trigger a new render after it's done
var onImageLoad = function onImageLoad() {
_this.forceUpdate();
image.removeEventListener('load', onImageLoad);
};
image.addEventListener('load', onImageLoad);
}
} // try to get img first, if img not there find first display tag
var displayItem = slideImages[0] || item.children[0];
var height = displayItem.clientHeight;
return height > 0 ? height : null;
}
return null;
});
var initState = {
initialized: false,
previousItem: props.selectedItem,
selectedItem: props.selectedItem,
hasMount: false,
isMouseEntered: false,
autoPlay: props.autoPlay,
swiping: false,
swipeMovementStarted: false,
cancelClick: false,
itemSize: 1,
itemListStyle: {},
slideStyle: {},
selectedStyle: {},
prevStyle: {}
};
_this.animationHandler = typeof props.animationHandler === 'function' && props.animationHandler || props.animationHandler === 'fade' && _animations.fadeAnimationHandler || _animations.slideAnimationHandler;
_this.state = _objectSpread(_objectSpread({}, initState), _this.animationHandler(props, initState));
return _this;
}
_createClass(Carousel, [{
key: "componentDidMount",
value: function componentDidMount() {
if (!this.props.children) {
return;
}
this.setupCarousel();
}
}, {
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps, prevState) {
if (!prevProps.children && this.props.children && !this.state.initialized) {
this.setupCarousel();
}
if (!prevProps.autoFocus && this.props.autoFocus) {
this.forceFocus();
}
if (prevState.swiping && !this.state.swiping) {
// We stopped swiping, ensure we are heading to the new/current slide and not stuck
this.setState(_objectSpread({}, this.props.stopSwipingHandler(this.props, this.state)));
}
if (prevProps.selectedItem !== this.props.selectedItem || prevProps.centerMode !== this.props.centerMode) {
this.updateSizes();
this.moveTo(this.props.selectedItem);
}
if (prevProps.autoPlay !== this.props.autoPlay) {
if (this.props.autoPlay) {
this.setupAutoPlay();
} else {
this.destroyAutoPlay();
}
this.setState({
autoPlay: this.props.autoPlay
});
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
this.destroyCarousel();
}
}, {
key: "setupCarousel",
value: function setupCarousel() {
var _this2 = this;
this.bindEvents();
if (this.state.autoPlay && _react.Children.count(this.props.children) > 1) {
this.setupAutoPlay();
}
if (this.props.autoFocus) {
this.forceFocus();
}
this.setState({
initialized: true
}, function () {
var initialImage = _this2.getInitialImage();
if (initialImage && !initialImage.complete) {
// if it's a carousel of images, we set the mount state after the first image is loaded
initialImage.addEventListener('load', _this2.setMountState);
} else {
_this2.setMountState();
}
});
}
}, {
key: "destroyCarousel",
value: function destroyCarousel() {
if (this.state.initialized) {
this.unbindEvents();
this.destroyAutoPlay();
}
}
}, {
key: "setupAutoPlay",
value: function setupAutoPlay() {
this.autoPlay();
var carouselWrapper = this.carouselWrapperRef;
if (this.props.stopOnHover && carouselWrapper) {
carouselWrapper.addEventListener('mouseenter', this.stopOnHover);
carouselWrapper.addEventListener('mouseleave', this.startOnLeave);
}
}
}, {
key: "destroyAutoPlay",
value: function destroyAutoPlay() {
this.clearAutoPlay();
var carouselWrapper = this.carouselWrapperRef;
if (this.props.stopOnHover && carouselWrapper) {
carouselWrapper.removeEventListener('mouseenter', this.stopOnHover);
carouselWrapper.removeEventListener('mouseleave', this.startOnLeave);
}
}
}, {
key: "bindEvents",
value: function bindEvents() {
// as the widths are calculated, we need to resize
// the carousel when the window is resized
(0, _window.default)().addEventListener('resize', this.updateSizes); // issue #2 - image loading smaller
(0, _window.default)().addEventListener('DOMContentLoaded', this.updateSizes);
if (this.props.useKeyboardArrows) {
(0, _document.default)().addEventListener('keydown', this.navigateWithKeyboard);
}
}
}, {
key: "unbindEvents",
value: function unbindEvents() {
// removing listeners
(0, _window.default)().removeEventListener('resize', this.updateSizes);
(0, _window.default)().removeEventListener('DOMContentLoaded', this.updateSizes);
var initialImage = this.getInitialImage();
if (initialImage) {
initialImage.removeEventListener('load', this.setMountState);
}
if (this.props.useKeyboardArrows) {
(0, _document.default)().removeEventListener('keydown', this.navigateWithKeyboard);
}
}
}, {
key: "forceFocus",
value: function forceFocus() {
var _this$carouselWrapper;
(_this$carouselWrapper = this.carouselWrapperRef) === null || _this$carouselWrapper === void 0 ? void 0 : _this$carouselWrapper.focus();
}
}, {
key: "renderItems",
value: function renderItems(isClone) {
var _this3 = this;
if (!this.props.children) {
return [];
}
return _react.Children.map(this.props.children, function (item, index) {
var isSelected = index === _this3.state.selectedItem;
var isPrevious = index === _this3.state.previousItem;
var style = isSelected && _this3.state.selectedStyle || isPrevious && _this3.state.prevStyle || _this3.state.slideStyle || {};
if (_this3.props.centerMode && _this3.props.axis === 'horizontal') {
style = _objectSpread(_objectSpread({}, style), {}, {
minWidth: _this3.props.centerSlidePercentage + '%'
});
}
if (_this3.state.swiping && _this3.state.swipeMovementStarted) {
style = _objectSpread(_objectSpread({}, style), {}, {
pointerEvents: 'none'
});
}
var slideProps = {
ref: function ref(e) {
return _this3.setItemsRef(e, index);
},
key: 'itemKey' + index + (isClone ? 'clone' : ''),
className: _cssClasses.default.ITEM(true, index === _this3.state.selectedItem, index === _this3.state.previousItem),
onClick: _this3.handleClickItem.bind(_this3, index, item),
style: style
};
return /*#__PURE__*/_react.default.createElement("li", slideProps, _this3.props.renderItem(item, {
isSelected: index === _this3.state.selectedItem,
isPrevious: index === _this3.state.previousItem
}));
});
}
}, {
key: "renderControls",
value: function renderControls() {
var _this4 = this;
var _this$props = this.props,
showIndicators = _this$props.showIndicators,
labels = _this$props.labels,
renderIndicator = _this$props.renderIndicator,
children = _this$props.children;
if (!showIndicators) {
return null;
}
return /*#__PURE__*/_react.default.createElement("ul", {
className: "control-dots"
}, _react.Children.map(children, function (_, index) {
return renderIndicator && renderIndicator(_this4.changeItem(index), index === _this4.state.selectedItem, index, labels.item);
}));
}
}, {
key: "renderStatus",
value: function renderStatus() {
if (!this.props.showStatus) {
return null;
}
return /*#__PURE__*/_react.default.createElement("p", {
className: "carousel-status"
}, this.props.statusFormatter(this.state.selectedItem + 1, _react.Children.count(this.props.children)));
}
}, {
key: "renderThumbs",
value: function renderThumbs() {
if (!this.props.showThumbs || !this.props.children || _react.Children.count(this.props.children) === 0) {
return null;
}
return /*#__PURE__*/_react.default.createElement(_Thumbs.default, {
ref: this.setThumbsRef,
onSelectItem: this.handleClickThumb,
selectedItem: this.state.selectedItem,
transitionTime: this.props.transitionTime,
thumbWidth: this.props.thumbWidth,
labels: this.props.labels,
emulateTouch: this.props.emulateTouch
}, this.props.renderThumbs(this.props.children));
}
}, {
key: "render",
value: function render() {
var _this5 = this;
if (!this.props.children || _react.Children.count(this.props.children) === 0) {
return null;
}
var isSwipeable = this.props.swipeable && _react.Children.count(this.props.children) > 1;
var isHorizontal = this.props.axis === 'horizontal';
var canShowArrows = this.props.showArrows && _react.Children.count(this.props.children) > 1; // show left arrow?
var hasPrev = canShowArrows && (this.state.selectedItem > 0 || this.props.infiniteLoop) || false; // show right arrow
var hasNext = canShowArrows && (this.state.selectedItem < _react.Children.count(this.props.children) - 1 || this.props.infiniteLoop) || false;
var itemsClone = this.renderItems(true);
var firstClone = itemsClone.shift();
var lastClone = itemsClone.pop();
var swiperProps = {
className: _cssClasses.default.SLIDER(true, this.state.swiping),
onSwipeMove: this.onSwipeMove,
onSwipeStart: this.onSwipeStart,
onSwipeEnd: this.onSwipeEnd,
style: this.state.itemListStyle,
tolerance: this.props.swipeScrollTolerance
};
var containerStyles = {};
if (isHorizontal) {
swiperProps.onSwipeLeft = this.onSwipeForward;
swiperProps.onSwipeRight = this.onSwipeBackwards;
if (this.props.dynamicHeight) {
var itemHeight = this.getVariableItemHeight(this.state.selectedItem); // swiperProps.style.height = itemHeight || 'auto';
containerStyles.height = itemHeight || 'auto';
}
} else {
swiperProps.onSwipeUp = this.props.verticalSwipe === 'natural' ? this.onSwipeBackwards : this.onSwipeForward;
swiperProps.onSwipeDown = this.props.verticalSwipe === 'natural' ? this.onSwipeForward : this.onSwipeBackwards;
swiperProps.style = _objectSpread(_objectSpread({}, swiperProps.style), {}, {
height: this.state.itemSize
});
containerStyles.height = this.state.itemSize;
}
return /*#__PURE__*/_react.default.createElement("div", {
"aria-label": this.props.ariaLabel,
className: _cssClasses.default.ROOT(this.props.className),
ref: this.setCarouselWrapperRef,
tabIndex: this.props.useKeyboardArrows ? 0 : undefined
}, /*#__PURE__*/_react.default.createElement("div", {
className: _cssClasses.default.CAROUSEL(true),
style: {
width: this.props.width
}
}, this.renderControls(), this.props.renderArrowPrev(this.onClickPrev, hasPrev, this.props.labels.leftArrow), /*#__PURE__*/_react.default.createElement("div", {
className: _cssClasses.default.WRAPPER(true, this.props.axis),
style: containerStyles
}, isSwipeable ? /*#__PURE__*/_react.default.createElement(_reactEasySwipe.default, _extends({
tagName: "ul",
innerRef: this.setListRef
}, swiperProps, {
allowMouseEvents: this.props.emulateTouch
}), this.props.infiniteLoop && lastClone, this.renderItems(), this.props.infiniteLoop && firstClone) : /*#__PURE__*/_react.default.createElement("ul", {
className: _cssClasses.default.SLIDER(true, this.state.swiping),
ref: function ref(node) {
return _this5.setListRef(node);
},
style: this.state.itemListStyle || {}
}, this.props.infiniteLoop && lastClone, this.renderItems(), this.props.infiniteLoop && firstClone)), this.props.renderArrowNext(this.onClickNext, hasNext, this.props.labels.rightArrow), this.renderStatus()), this.renderThumbs());
}
}]);
return Carousel;
}(_react.default.Component);
exports.default = Carousel;
_defineProperty(Carousel, "displayName", 'Carousel');
_defineProperty(Carousel, "defaultProps", {
ariaLabel: undefined,
axis: 'horizontal',
centerSlidePercentage: 80,
interval: 3000,
labels: {
leftArrow: 'previous slide / item',
rightArrow: 'next slide / item',
item: 'slide item'
},
onClickItem: _utils.noop,
onClickThumb: _utils.noop,
onChange: _utils.noop,
onSwipeStart: function onSwipeStart() {},
onSwipeEnd: function onSwipeEnd() {},
onSwipeMove: function onSwipeMove() {
return false;
},
preventMovementUntilSwipeScrollTolerance: false,
renderArrowPrev: function renderArrowPrev(onClickHandler, hasPrev, label) {
return /*#__PURE__*/_react.default.createElement("button", {
type: "button",
"aria-label": label,
className: _cssClasses.default.ARROW_PREV(!hasPrev),
onClick: onClickHandler
});
},
renderArrowNext: function renderArrowNext(onClickHandler, hasNext, label) {
return /*#__PURE__*/_react.default.createElement("button", {
type: "button",
"aria-label": label,
className: _cssClasses.default.ARROW_NEXT(!hasNext),
onClick: onClickHandler
});
},
renderIndicator: function renderIndicator(onClickHandler, isSelected, index, label) {
return /*#__PURE__*/_react.default.createElement("li", {
className: _cssClasses.default.DOT(isSelected),
onClick: onClickHandler,
onKeyDown: onClickHandler,
value: index,
key: index,
role: "button",
tabIndex: 0,
"aria-label": "".concat(label, " ").concat(index + 1)
});
},
renderItem: function renderItem(item) {
return item;
},
renderThumbs: function renderThumbs(children) {
var images = _react.Children.map(children, function (item) {
var img = item; // if the item is not an image, try to find the first image in the item's children.
if (item.type !== 'img') {
img = _react.Children.toArray(item.props.children).find(function (children) {
return children.type === 'img';
});
}
if (!img) {
return undefined;
}
return img;
});
if (images.filter(function (image) {
return image;
}).length === 0) {
console.warn("No images found! Can't build the thumb list without images. If you don't need thumbs, set showThumbs={false} in the Carousel. Note that it's not possible to get images rendered inside custom components. More info at https://github.com/leandrowd/react-responsive-carousel/blob/master/TROUBLESHOOTING.md");
return [];
}
return images;
},
statusFormatter: _utils.defaultStatusFormatter,
selectedItem: 0,
showArrows: true,
showIndicators: true,
showStatus: true,
showThumbs: true,
stopOnHover: true,
swipeScrollTolerance: 5,
swipeable: true,
transitionTime: 350,
verticalSwipe: 'standard',
width: '100%',
animationHandler: 'slide',
swipeAnimationHandler: _animations.slideSwipeAnimationHandler,
stopSwipingHandler: _animations.slideStopSwipingHandler
});