@itcase/ui 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/SelectContainer-e2544642.js +7717 -0
- package/dist/components/Accordion.js +249 -0
- package/dist/components/Avatar.js +94 -0
- package/dist/components/Background.js +90 -0
- package/dist/components/Breadcrumbs.js +239 -0
- package/dist/components/Button.js +215 -0
- package/dist/components/Caption.js +65 -0
- package/dist/components/Card.js +112 -0
- package/dist/components/Cell.js +180 -0
- package/dist/components/Checkbox.js +68 -0
- package/dist/components/Chips.js +135 -0
- package/dist/components/ContextMenu.js +149 -0
- package/dist/components/CookiesWarning.js +133 -0
- package/dist/components/Counter.js +99 -0
- package/dist/components/Divider.js +73 -0
- package/dist/components/Dropdown.js +139 -0
- package/dist/components/Emoji.js +124 -0
- package/dist/components/Fader.js +66 -0
- package/dist/components/Flex.js +264 -0
- package/dist/components/FormField.js +289 -0
- package/dist/components/Grid.js +329 -0
- package/dist/components/Group.js +132 -0
- package/dist/components/Icon.js +184 -0
- package/dist/components/Image.js +143 -0
- package/dist/components/Input.js +94 -0
- package/dist/components/Label.js +125 -0
- package/dist/components/LanguageSelector.js +86 -0
- package/dist/components/Link.js +172 -0
- package/dist/components/List.js +143 -0
- package/dist/components/Loader.js +66 -0
- package/dist/components/Logo.js +55 -0
- package/dist/components/Menu.js +86 -0
- package/dist/components/MenuItem.js +209 -0
- package/dist/components/Modal.js +69 -0
- package/dist/components/Notification.js +131 -0
- package/dist/components/Pagination.js +93 -0
- package/dist/components/Popup.js +254 -0
- package/dist/components/Profile.js +99 -0
- package/dist/components/RadioButton.js +71 -0
- package/dist/components/RangeSlider.js +2086 -0
- package/dist/components/Scrollbar.js +3872 -0
- package/dist/components/Search.js +260 -0
- package/dist/components/Segmented.js +77 -0
- package/dist/components/Select.js +49 -0
- package/dist/components/SiteMenu.js +137 -0
- package/dist/components/Swiper.js +927 -0
- package/dist/components/Switch.js +29 -0
- package/dist/components/Text.js +121 -0
- package/dist/components/Textarea.js +90 -0
- package/dist/components/Tile.js +252 -0
- package/dist/components/Title.js +146 -0
- package/dist/components/Tooltip.js +115 -0
- package/dist/components/Video.js +74 -0
- package/dist/components/Wrapper.js +119 -0
- package/dist/constants/componentProps/align.js +5 -0
- package/dist/constants/componentProps/alignDirection.js +5 -0
- package/dist/constants/componentProps/borderColor.js +5 -0
- package/dist/constants/componentProps/borderType.js +5 -0
- package/dist/constants/componentProps/captionPosition.js +5 -0
- package/dist/constants/componentProps/direction.js +5 -0
- package/dist/constants/componentProps/emojiSize.js +5 -0
- package/dist/constants/componentProps/fill.js +5 -0
- package/dist/constants/componentProps/fillGradient.js +5 -0
- package/dist/constants/componentProps/fillType.js +5 -0
- package/dist/constants/componentProps/flexAlign.js +5 -0
- package/dist/constants/componentProps/flexJustifyContent.js +5 -0
- package/dist/constants/componentProps/flexWrap.js +5 -0
- package/dist/constants/componentProps/gridAlign.js +5 -0
- package/dist/constants/componentProps/gridAlignSelf.js +5 -0
- package/dist/constants/componentProps/gridJustifyItems.js +5 -0
- package/dist/constants/componentProps/gridJustifySelf.js +5 -0
- package/dist/constants/componentProps/horizontalContentAlign.js +5 -0
- package/dist/constants/componentProps/horizontalResizeMode.js +5 -0
- package/dist/constants/componentProps/iconSize.js +5 -0
- package/dist/constants/componentProps/position.js +5 -0
- package/dist/constants/componentProps/resizeMode.js +5 -0
- package/dist/constants/componentProps/shape.js +5 -0
- package/dist/constants/componentProps/size.js +5 -0
- package/dist/constants/componentProps/stacking.js +5 -0
- package/dist/constants/componentProps/strokeColor.js +5 -0
- package/dist/constants/componentProps/textAlign.js +5 -0
- package/dist/constants/componentProps/textColor.js +5 -0
- package/dist/constants/componentProps/textColorActive.js +5 -0
- package/dist/constants/componentProps/textColorHover.js +5 -0
- package/dist/constants/componentProps/textGradient.js +5 -0
- package/dist/constants/componentProps/textStyle.js +5 -0
- package/dist/constants/componentProps/textTag.js +5 -0
- package/dist/constants/componentProps/textWeight.js +5 -0
- package/dist/constants/componentProps/titleSize.js +5 -0
- package/dist/constants/componentProps/type.js +5 -0
- package/dist/constants/componentProps/underline.js +5 -0
- package/dist/constants/componentProps/verticalContentAlign.js +5 -0
- package/dist/constants/componentProps/verticalResizeMode.js +5 -0
- package/dist/constants/componentProps/width.js +5 -0
- package/dist/constants/componentProps/wrap.js +5 -0
- package/dist/constants.js +87 -0
- package/dist/context/Notifications.js +121 -0
- package/dist/context/UIContext.js +59 -0
- package/dist/css/components/Accordion/Accordion.css +65 -0
- package/dist/css/components/Avatar/Avatar.css +28 -0
- package/dist/css/components/Background/Background.css +11 -0
- package/dist/css/components/Button/Button.css +362 -0
- package/dist/css/components/Caption/Caption.css +22 -0
- package/dist/css/components/Card/Card.css +19 -0
- package/dist/css/components/Cell/Cell.css +89 -0
- package/dist/css/components/Cell/css/__wrapper/cell__wrapper.css +7 -0
- package/dist/css/components/Cell/css/__wrapper/cell__wrapper_shape.css +15 -0
- package/dist/css/components/Checkbox/Checkbox.css +97 -0
- package/dist/css/components/Chips/Chips.css +47 -0
- package/dist/css/components/ContextMenu/ContextMenu.css +43 -0
- package/dist/css/components/ContextMenu/css/__item/context-menu__item.css +10 -0
- package/dist/css/components/CookiesWarning/CookiesWarning.css +37 -0
- package/dist/css/components/Counter/Counter.css +55 -0
- package/dist/css/components/Divider/Divider.css +78 -0
- package/dist/css/components/Dropdown/Dropdown.css +58 -0
- package/dist/css/components/Emoji/Emoji.css +104 -0
- package/dist/css/components/Emoji/css/__icon/emoji__icon-shape.css +12 -0
- package/dist/css/components/Emoji/css/__icon/emoji__icon.css +5 -0
- package/dist/css/components/Fader/Fader.css +55 -0
- package/dist/css/components/Flex/Flex.css +179 -0
- package/dist/css/components/Flex/css/__item/flex__item.css +5 -0
- package/dist/css/components/Flex/css/__item/flex__item_align.css +15 -0
- package/dist/css/components/Flex/css/__item/flex__item_direction.css +17 -0
- package/dist/css/components/Flex/css/__item/flex__item_grow.css +9 -0
- package/dist/css/components/Flex/css/__item/flex__item_justify-content.css +9 -0
- package/dist/css/components/Flex/css/__item/flex__item_shape.css +12 -0
- package/dist/css/components/Flex/css/__item/flex__item_wrap.css +9 -0
- package/dist/css/components/Grid/Grid.css +208 -0
- package/dist/css/components/Grid/css/__item/grid__item.css +4 -0
- package/dist/css/components/Grid/css/__item/grid__item_align-self.css +9 -0
- package/dist/css/components/Grid/css/__item/grid__item_column.css +17 -0
- package/dist/css/components/Grid/css/__item/grid__item_justify-self.css +9 -0
- package/dist/css/components/Grid/css/__item/grid__item_row.css +17 -0
- package/dist/css/components/Group/Group.css +106 -0
- package/dist/css/components/Icon/Icon.css +149 -0
- package/dist/css/components/Image/Image.css +106 -0
- package/dist/css/components/Input/Input.css +41 -0
- package/dist/css/components/Label/Label.css +33 -0
- package/dist/css/components/Link/Link.css +10 -0
- package/dist/css/components/List/List.css +112 -0
- package/dist/css/components/Loader/Loader.css +42 -0
- package/dist/css/components/Logo/Logo.css +17 -0
- package/dist/css/components/Menu/Menu.css +56 -0
- package/dist/css/components/MenuItem/MenuItem.css +56 -0
- package/dist/css/components/Notification/Notification.css +18 -0
- package/dist/css/components/Pagination/Pagination.css +80 -0
- package/dist/css/components/Pagination/css/__item/pagination__item.css +31 -0
- package/dist/css/components/Pagination/css/__item/pagination__item_state_active.css +16 -0
- package/dist/css/components/Pagination/css/__item/pagination__item_state_disabled.css +19 -0
- package/dist/css/components/Popup/Popup.css +49 -0
- package/dist/css/components/Profile/Profile.css +19 -0
- package/dist/css/components/RadioButton/RadioButton.css +98 -0
- package/dist/css/components/RangeSlider/RangeSlider.css +396 -0
- package/dist/css/components/Scrollbar/Scrollbar.css +2 -0
- package/dist/css/components/Search/Search.css +113 -0
- package/dist/css/components/Search/css/search-input/search-input.css +81 -0
- package/dist/css/components/Search/css/search-input/search-input_shape.css +8 -0
- package/dist/css/components/Search/css/search-result/search-result.css +6 -0
- package/dist/css/components/Search/css/search-result/search-result_shape.css +8 -0
- package/dist/css/components/Select/Select.css +236 -0
- package/dist/css/components/Select/css/__control/select__control.css +11 -0
- package/dist/css/components/Select/css/__control/select__control_fill.css +15 -0
- package/dist/css/components/Select/css/__control/select__control_shape.css +12 -0
- package/dist/css/components/Select/css/__indicators/select__indicators.css +18 -0
- package/dist/css/components/Select/css/__input-container/select__input-container.css +24 -0
- package/dist/css/components/Select/css/__menu/select__menu-notice.css +7 -0
- package/dist/css/components/Select/css/__menu/select__menu.css +36 -0
- package/dist/css/components/Select/css/__option/select__option.css +56 -0
- package/dist/css/components/Select/css/__single-value/select__single-value.css +5 -0
- package/dist/css/components/Select/css/__value-container/select__value-container.css +12 -0
- package/dist/css/components/SiteMenu/SiteMenu.css +37 -0
- package/dist/css/components/Swiper/Swiper.css +839 -0
- package/dist/css/components/Switch/Switch.css +53 -0
- package/dist/css/components/Text/Text.css +33 -0
- package/dist/css/components/Textarea/Textarea.css +40 -0
- package/dist/css/components/Tile/Tile.css +23 -0
- package/dist/css/components/Title/Title.css +71 -0
- package/dist/css/components/Tooltip/Tooltip.css +4 -0
- package/dist/css/components/Video/Video.css +37 -0
- package/dist/css/components/Wrapper/Wrapper.css +36 -0
- package/dist/css/styles/align/align_horizontal-reverse.css +50 -0
- package/dist/css/styles/align/align_horizontal.css +67 -0
- package/dist/css/styles/align/align_vertical-reverse.css +49 -0
- package/dist/css/styles/align/align_vertical.css +64 -0
- package/dist/css/styles/border/border.css +13 -0
- package/dist/css/styles/border-color/border-color.css +28 -0
- package/dist/css/styles/caret-color/caret-color.css +13 -0
- package/dist/css/styles/constraints/constraints.css +59 -0
- package/dist/css/styles/cursor/cursor.css +9 -0
- package/dist/css/styles/direction/direction.css +10 -0
- package/dist/css/styles/elevation/elevation.css +7 -0
- package/dist/css/styles/elevation/elevation_hover.css +11 -0
- package/dist/css/styles/fill/fill.css +28 -0
- package/dist/css/styles/fill/fill_active.css +22 -0
- package/dist/css/styles/fill/fill_active_hover.css +24 -0
- package/dist/css/styles/fill/fill_disabled.css +22 -0
- package/dist/css/styles/fill/fill_hover.css +34 -0
- package/dist/css/styles/fill-gradient/fill-gradient.css +15 -0
- package/dist/css/styles/height/height.css +9 -0
- package/dist/css/styles/hover/hover-fill-color.css +13 -0
- package/dist/css/styles/hover/hover-item-color.css +15 -0
- package/dist/css/styles/hover/hover-text-color.css +15 -0
- package/dist/css/styles/mediaqueries.css +66 -0
- package/dist/css/styles/mixin_elevation.css +33 -0
- package/dist/css/styles/mixin_fill-gradient.css +23 -0
- package/dist/css/styles/mixin_global.css +54 -0
- package/dist/css/styles/opacity/opacity.css +7 -0
- package/dist/css/styles/placeholder-text-color/placeholder-text-color.css +15 -0
- package/dist/css/styles/position/position.css +14 -0
- package/dist/css/styles/resize-horizontal/resize-horizontal.css +12 -0
- package/dist/css/styles/resize-vertical/resize-vertical.css +10 -0
- package/dist/css/styles/shape/shape.css +8 -0
- package/dist/css/styles/text-align/text-align.css +7 -0
- package/dist/css/styles/text-color/text-color.css +13 -0
- package/dist/css/styles/text-color/text-color_active.css +15 -0
- package/dist/css/styles/text-color/text-color_hover.css +17 -0
- package/dist/css/styles/text-color-hover/text-color-hover.css +15 -0
- package/dist/css/styles/text-decoration/text-decoration.css +9 -0
- package/dist/css/styles/text-gradient/text-gradient.css +24 -0
- package/dist/css/styles/text-style/text-style.css +9 -0
- package/dist/css/styles/text-truncate/text-truncate.css +7 -0
- package/dist/css/styles/text-weight/text-weight.css +40 -0
- package/dist/css/styles/width/width.css +9 -0
- package/dist/css/styles/word-wrap/word-wrap.css +8 -0
- package/dist/hooks/styleAttributes.js +33 -0
- package/dist/hooks/useDeviceTargetClass.js +60 -0
- package/dist/hooks/useMediaQueries.js +134 -0
- package/dist/hooks/useStyles.js +16 -0
- package/dist/index-f1505c84.js +86 -0
- package/dist/objectWithoutProperties-ea190611.js +188 -0
- package/dist/useStyles-77c3b520.js +153 -0
- package/package.json +123 -0
|
@@ -0,0 +1,927 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var PropTypes = require('prop-types');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var Swiper$2 = require('swiper');
|
|
7
|
+
var fill = require('../constants/componentProps/fill.js');
|
|
8
|
+
var shape = require('../constants/componentProps/shape.js');
|
|
9
|
+
var index = require('./Title.js');
|
|
10
|
+
var useDeviceTargetClass = require('../hooks/useDeviceTargetClass.js');
|
|
11
|
+
require('../constants/componentProps/textAlign.js');
|
|
12
|
+
require('../constants/componentProps/textColor.js');
|
|
13
|
+
require('../constants/componentProps/textGradient.js');
|
|
14
|
+
require('../constants/componentProps/textStyle.js');
|
|
15
|
+
require('../constants/componentProps/textWeight.js');
|
|
16
|
+
require('../constants/componentProps/titleSize.js');
|
|
17
|
+
require('../constants/componentProps/type.js');
|
|
18
|
+
require('../constants/componentProps/wrap.js');
|
|
19
|
+
require('../useStyles-77c3b520.js');
|
|
20
|
+
require('lodash/camelCase');
|
|
21
|
+
require('lodash/maxBy');
|
|
22
|
+
require('lodash/upperFirst');
|
|
23
|
+
require('../hooks/styleAttributes.js');
|
|
24
|
+
require('../context/UIContext.js');
|
|
25
|
+
require('../hooks/useMediaQueries.js');
|
|
26
|
+
require('react-responsive');
|
|
27
|
+
require('lodash/castArray');
|
|
28
|
+
|
|
29
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
30
|
+
|
|
31
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
32
|
+
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
33
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
34
|
+
var Swiper__default = /*#__PURE__*/_interopDefault(Swiper$2);
|
|
35
|
+
|
|
36
|
+
function isObject(o) {
|
|
37
|
+
return typeof o === 'object' && o !== null && o.constructor && Object.prototype.toString.call(o).slice(8, -1) === 'Object';
|
|
38
|
+
}
|
|
39
|
+
function extend(target, src) {
|
|
40
|
+
const noExtend = ['__proto__', 'constructor', 'prototype'];
|
|
41
|
+
Object.keys(src).filter(key => noExtend.indexOf(key) < 0).forEach(key => {
|
|
42
|
+
if (typeof target[key] === 'undefined') target[key] = src[key];else if (isObject(src[key]) && isObject(target[key]) && Object.keys(src[key]).length > 0) {
|
|
43
|
+
if (src[key].__swiper__) target[key] = src[key];else extend(target[key], src[key]);
|
|
44
|
+
} else {
|
|
45
|
+
target[key] = src[key];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function needsNavigation(params = {}) {
|
|
50
|
+
return params.navigation && typeof params.navigation.nextEl === 'undefined' && typeof params.navigation.prevEl === 'undefined';
|
|
51
|
+
}
|
|
52
|
+
function needsPagination(params = {}) {
|
|
53
|
+
return params.pagination && typeof params.pagination.el === 'undefined';
|
|
54
|
+
}
|
|
55
|
+
function needsScrollbar(params = {}) {
|
|
56
|
+
return params.scrollbar && typeof params.scrollbar.el === 'undefined';
|
|
57
|
+
}
|
|
58
|
+
function uniqueClasses(classNames = '') {
|
|
59
|
+
const classes = classNames.split(' ').map(c => c.trim()).filter(c => !!c);
|
|
60
|
+
const unique = [];
|
|
61
|
+
classes.forEach(c => {
|
|
62
|
+
if (unique.indexOf(c) < 0) unique.push(c);
|
|
63
|
+
});
|
|
64
|
+
return unique.join(' ');
|
|
65
|
+
}
|
|
66
|
+
function wrapperClass(className = '') {
|
|
67
|
+
if (!className) return 'swiper-wrapper';
|
|
68
|
+
if (!className.includes('swiper-wrapper')) return `swiper-wrapper ${className}`;
|
|
69
|
+
return className;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* underscore in name -> watch for changes */
|
|
73
|
+
const paramsList = ['eventsPrefix', 'injectStyles', 'injectStylesUrls', 'modules', 'init', '_direction', 'oneWayMovement', 'touchEventsTarget', 'initialSlide', '_speed', 'cssMode', 'updateOnWindowResize', 'resizeObserver', 'nested', 'focusableElements', '_enabled', '_width', '_height', 'preventInteractionOnTransition', 'userAgent', 'url', '_edgeSwipeDetection', '_edgeSwipeThreshold', '_freeMode', '_autoHeight', 'setWrapperSize', 'virtualTranslate', '_effect', 'breakpoints', '_spaceBetween', '_slidesPerView', 'maxBackfaceHiddenSlides', '_grid', '_slidesPerGroup', '_slidesPerGroupSkip', '_slidesPerGroupAuto', '_centeredSlides', '_centeredSlidesBounds', '_slidesOffsetBefore', '_slidesOffsetAfter', 'normalizeSlideIndex', '_centerInsufficientSlides', '_watchOverflow', 'roundLengths', 'touchRatio', 'touchAngle', 'simulateTouch', '_shortSwipes', '_longSwipes', 'longSwipesRatio', 'longSwipesMs', '_followFinger', 'allowTouchMove', '_threshold', 'touchMoveStopPropagation', 'touchStartPreventDefault', 'touchStartForcePreventDefault', 'touchReleaseOnEdges', 'uniqueNavElements', '_resistance', '_resistanceRatio', '_watchSlidesProgress', '_grabCursor', 'preventClicks', 'preventClicksPropagation', '_slideToClickedSlide', '_loop', 'loopedSlides', 'loopPreventsSliding', '_rewind', '_allowSlidePrev', '_allowSlideNext', '_swipeHandler', '_noSwiping', 'noSwipingClass', 'noSwipingSelector', 'passiveListeners', 'containerModifierClass', 'slideClass', 'slideActiveClass', 'slideVisibleClass', 'slideNextClass', 'slidePrevClass', 'wrapperClass', 'lazyPreloaderClass', 'lazyPreloadPrevNext', 'runCallbacksOnInit', 'observer', 'observeParents', 'observeSlideChildren',
|
|
74
|
+
// modules
|
|
75
|
+
'a11y', '_autoplay', '_controller', 'coverflowEffect', 'cubeEffect', 'fadeEffect', 'flipEffect', 'creativeEffect', 'cardsEffect', 'hashNavigation', 'history', 'keyboard', 'mousewheel', '_navigation', '_pagination', 'parallax', '_scrollbar', '_thumbs', 'virtual', 'zoom', 'control'];
|
|
76
|
+
|
|
77
|
+
function getParams(obj = {}, splitEvents = true) {
|
|
78
|
+
const params = {
|
|
79
|
+
on: {}
|
|
80
|
+
};
|
|
81
|
+
const events = {};
|
|
82
|
+
const passedParams = {};
|
|
83
|
+
extend(params, Swiper__default.default.defaults);
|
|
84
|
+
extend(params, Swiper__default.default.extendedDefaults);
|
|
85
|
+
params._emitClasses = true;
|
|
86
|
+
params.init = false;
|
|
87
|
+
const rest = {};
|
|
88
|
+
const allowedParams = paramsList.map(key => key.replace(/_/, ''));
|
|
89
|
+
const plainObj = Object.assign({}, obj);
|
|
90
|
+
Object.keys(plainObj).forEach(key => {
|
|
91
|
+
if (typeof obj[key] === 'undefined') return;
|
|
92
|
+
if (allowedParams.indexOf(key) >= 0) {
|
|
93
|
+
if (isObject(obj[key])) {
|
|
94
|
+
params[key] = {};
|
|
95
|
+
passedParams[key] = {};
|
|
96
|
+
extend(params[key], obj[key]);
|
|
97
|
+
extend(passedParams[key], obj[key]);
|
|
98
|
+
} else {
|
|
99
|
+
params[key] = obj[key];
|
|
100
|
+
passedParams[key] = obj[key];
|
|
101
|
+
}
|
|
102
|
+
} else if (key.search(/on[A-Z]/) === 0 && typeof obj[key] === 'function') {
|
|
103
|
+
if (splitEvents) {
|
|
104
|
+
events[`${key[2].toLowerCase()}${key.substr(3)}`] = obj[key];
|
|
105
|
+
} else {
|
|
106
|
+
params.on[`${key[2].toLowerCase()}${key.substr(3)}`] = obj[key];
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
rest[key] = obj[key];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
['navigation', 'pagination', 'scrollbar'].forEach(key => {
|
|
113
|
+
if (params[key] === true) params[key] = {};
|
|
114
|
+
if (params[key] === false) delete params[key];
|
|
115
|
+
});
|
|
116
|
+
return {
|
|
117
|
+
params,
|
|
118
|
+
passedParams,
|
|
119
|
+
rest,
|
|
120
|
+
events
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function mountSwiper({
|
|
125
|
+
el,
|
|
126
|
+
nextEl,
|
|
127
|
+
prevEl,
|
|
128
|
+
paginationEl,
|
|
129
|
+
scrollbarEl,
|
|
130
|
+
swiper
|
|
131
|
+
}, swiperParams) {
|
|
132
|
+
if (needsNavigation(swiperParams) && nextEl && prevEl) {
|
|
133
|
+
swiper.params.navigation.nextEl = nextEl;
|
|
134
|
+
swiper.originalParams.navigation.nextEl = nextEl;
|
|
135
|
+
swiper.params.navigation.prevEl = prevEl;
|
|
136
|
+
swiper.originalParams.navigation.prevEl = prevEl;
|
|
137
|
+
}
|
|
138
|
+
if (needsPagination(swiperParams) && paginationEl) {
|
|
139
|
+
swiper.params.pagination.el = paginationEl;
|
|
140
|
+
swiper.originalParams.pagination.el = paginationEl;
|
|
141
|
+
}
|
|
142
|
+
if (needsScrollbar(swiperParams) && scrollbarEl) {
|
|
143
|
+
swiper.params.scrollbar.el = scrollbarEl;
|
|
144
|
+
swiper.originalParams.scrollbar.el = scrollbarEl;
|
|
145
|
+
}
|
|
146
|
+
swiper.init(el);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function getChangedParams(swiperParams, oldParams, children, oldChildren, getKey) {
|
|
150
|
+
const keys = [];
|
|
151
|
+
if (!oldParams) return keys;
|
|
152
|
+
const addKey = key => {
|
|
153
|
+
if (keys.indexOf(key) < 0) keys.push(key);
|
|
154
|
+
};
|
|
155
|
+
if (children && oldChildren) {
|
|
156
|
+
const oldChildrenKeys = oldChildren.map(getKey);
|
|
157
|
+
const childrenKeys = children.map(getKey);
|
|
158
|
+
if (oldChildrenKeys.join('') !== childrenKeys.join('')) addKey('children');
|
|
159
|
+
if (oldChildren.length !== children.length) addKey('children');
|
|
160
|
+
}
|
|
161
|
+
const watchParams = paramsList.filter(key => key[0] === '_').map(key => key.replace(/_/, ''));
|
|
162
|
+
watchParams.forEach(key => {
|
|
163
|
+
if (key in swiperParams && key in oldParams) {
|
|
164
|
+
if (isObject(swiperParams[key]) && isObject(oldParams[key])) {
|
|
165
|
+
const newKeys = Object.keys(swiperParams[key]);
|
|
166
|
+
const oldKeys = Object.keys(oldParams[key]);
|
|
167
|
+
if (newKeys.length !== oldKeys.length) {
|
|
168
|
+
addKey(key);
|
|
169
|
+
} else {
|
|
170
|
+
newKeys.forEach(newKey => {
|
|
171
|
+
if (swiperParams[key][newKey] !== oldParams[key][newKey]) {
|
|
172
|
+
addKey(key);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
oldKeys.forEach(oldKey => {
|
|
176
|
+
if (swiperParams[key][oldKey] !== oldParams[key][oldKey]) addKey(key);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
} else if (swiperParams[key] !== oldParams[key]) {
|
|
180
|
+
addKey(key);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return keys;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function isChildSwiperSlide(child) {
|
|
188
|
+
return child.type && child.type.displayName && child.type.displayName.includes('SwiperSlide');
|
|
189
|
+
}
|
|
190
|
+
function processChildren(c) {
|
|
191
|
+
const slides = [];
|
|
192
|
+
React__default.default.Children.toArray(c).forEach(child => {
|
|
193
|
+
if (isChildSwiperSlide(child)) {
|
|
194
|
+
slides.push(child);
|
|
195
|
+
} else if (child.props && child.props.children) {
|
|
196
|
+
processChildren(child.props.children).forEach(slide => slides.push(slide));
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return slides;
|
|
200
|
+
}
|
|
201
|
+
function getChildren(c) {
|
|
202
|
+
const slides = [];
|
|
203
|
+
const slots = {
|
|
204
|
+
'container-start': [],
|
|
205
|
+
'container-end': [],
|
|
206
|
+
'wrapper-start': [],
|
|
207
|
+
'wrapper-end': []
|
|
208
|
+
};
|
|
209
|
+
React__default.default.Children.toArray(c).forEach(child => {
|
|
210
|
+
if (isChildSwiperSlide(child)) {
|
|
211
|
+
slides.push(child);
|
|
212
|
+
} else if (child.props && child.props.slot && slots[child.props.slot]) {
|
|
213
|
+
slots[child.props.slot].push(child);
|
|
214
|
+
} else if (child.props && child.props.children) {
|
|
215
|
+
const foundSlides = processChildren(child.props.children);
|
|
216
|
+
if (foundSlides.length > 0) {
|
|
217
|
+
foundSlides.forEach(slide => slides.push(slide));
|
|
218
|
+
} else {
|
|
219
|
+
slots['container-end'].push(child);
|
|
220
|
+
}
|
|
221
|
+
} else {
|
|
222
|
+
slots['container-end'].push(child);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
return {
|
|
226
|
+
slides,
|
|
227
|
+
slots
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function updateSwiper({
|
|
232
|
+
swiper,
|
|
233
|
+
slides,
|
|
234
|
+
passedParams,
|
|
235
|
+
changedParams,
|
|
236
|
+
nextEl,
|
|
237
|
+
prevEl,
|
|
238
|
+
scrollbarEl,
|
|
239
|
+
paginationEl
|
|
240
|
+
}) {
|
|
241
|
+
const updateParams = changedParams.filter(key => key !== 'children' && key !== 'direction' && key !== 'wrapperClass');
|
|
242
|
+
const {
|
|
243
|
+
params: currentParams,
|
|
244
|
+
pagination,
|
|
245
|
+
navigation,
|
|
246
|
+
scrollbar,
|
|
247
|
+
virtual,
|
|
248
|
+
thumbs
|
|
249
|
+
} = swiper;
|
|
250
|
+
let needThumbsInit;
|
|
251
|
+
let needControllerInit;
|
|
252
|
+
let needPaginationInit;
|
|
253
|
+
let needScrollbarInit;
|
|
254
|
+
let needNavigationInit;
|
|
255
|
+
let loopNeedDestroy;
|
|
256
|
+
let loopNeedEnable;
|
|
257
|
+
let loopNeedReloop;
|
|
258
|
+
if (changedParams.includes('thumbs') && passedParams.thumbs && passedParams.thumbs.swiper && currentParams.thumbs && !currentParams.thumbs.swiper) {
|
|
259
|
+
needThumbsInit = true;
|
|
260
|
+
}
|
|
261
|
+
if (changedParams.includes('controller') && passedParams.controller && passedParams.controller.control && currentParams.controller && !currentParams.controller.control) {
|
|
262
|
+
needControllerInit = true;
|
|
263
|
+
}
|
|
264
|
+
if (changedParams.includes('pagination') && passedParams.pagination && (passedParams.pagination.el || paginationEl) && (currentParams.pagination || currentParams.pagination === false) && pagination && !pagination.el) {
|
|
265
|
+
needPaginationInit = true;
|
|
266
|
+
}
|
|
267
|
+
if (changedParams.includes('scrollbar') && passedParams.scrollbar && (passedParams.scrollbar.el || scrollbarEl) && (currentParams.scrollbar || currentParams.scrollbar === false) && scrollbar && !scrollbar.el) {
|
|
268
|
+
needScrollbarInit = true;
|
|
269
|
+
}
|
|
270
|
+
if (changedParams.includes('navigation') && passedParams.navigation && (passedParams.navigation.prevEl || prevEl) && (passedParams.navigation.nextEl || nextEl) && (currentParams.navigation || currentParams.navigation === false) && navigation && !navigation.prevEl && !navigation.nextEl) {
|
|
271
|
+
needNavigationInit = true;
|
|
272
|
+
}
|
|
273
|
+
const destroyModule = mod => {
|
|
274
|
+
if (!swiper[mod]) return;
|
|
275
|
+
swiper[mod].destroy();
|
|
276
|
+
if (mod === 'navigation') {
|
|
277
|
+
if (swiper.isElement) {
|
|
278
|
+
swiper[mod].prevEl.remove();
|
|
279
|
+
swiper[mod].nextEl.remove();
|
|
280
|
+
}
|
|
281
|
+
currentParams[mod].prevEl = undefined;
|
|
282
|
+
currentParams[mod].nextEl = undefined;
|
|
283
|
+
swiper[mod].prevEl = undefined;
|
|
284
|
+
swiper[mod].nextEl = undefined;
|
|
285
|
+
} else {
|
|
286
|
+
if (swiper.isElement) {
|
|
287
|
+
swiper[mod].el.remove();
|
|
288
|
+
}
|
|
289
|
+
currentParams[mod].el = undefined;
|
|
290
|
+
swiper[mod].el = undefined;
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
if (changedParams.includes('loop') && swiper.isElement) {
|
|
294
|
+
if (currentParams.loop && !passedParams.loop) {
|
|
295
|
+
loopNeedDestroy = true;
|
|
296
|
+
} else if (!currentParams.loop && passedParams.loop) {
|
|
297
|
+
loopNeedEnable = true;
|
|
298
|
+
} else {
|
|
299
|
+
loopNeedReloop = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
updateParams.forEach(key => {
|
|
303
|
+
if (isObject(currentParams[key]) && isObject(passedParams[key])) {
|
|
304
|
+
extend(currentParams[key], passedParams[key]);
|
|
305
|
+
} else {
|
|
306
|
+
const newValue = passedParams[key];
|
|
307
|
+
if ((newValue === true || newValue === false) && (key === 'navigation' || key === 'pagination' || key === 'scrollbar')) {
|
|
308
|
+
if (newValue === false) {
|
|
309
|
+
destroyModule(key);
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
currentParams[key] = passedParams[key];
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
if (updateParams.includes('controller') && !needControllerInit && swiper.controller && swiper.controller.control && currentParams.controller && currentParams.controller.control) {
|
|
317
|
+
swiper.controller.control = currentParams.controller.control;
|
|
318
|
+
}
|
|
319
|
+
if (changedParams.includes('children') && slides && virtual && currentParams.virtual.enabled) {
|
|
320
|
+
virtual.slides = slides;
|
|
321
|
+
virtual.update(true);
|
|
322
|
+
}
|
|
323
|
+
if (changedParams.includes('children') && slides && currentParams.loop) {
|
|
324
|
+
loopNeedReloop = true;
|
|
325
|
+
}
|
|
326
|
+
if (needThumbsInit) {
|
|
327
|
+
const initialized = thumbs.init();
|
|
328
|
+
if (initialized) thumbs.update(true);
|
|
329
|
+
}
|
|
330
|
+
if (needControllerInit) {
|
|
331
|
+
swiper.controller.control = currentParams.controller.control;
|
|
332
|
+
}
|
|
333
|
+
if (needPaginationInit) {
|
|
334
|
+
if (swiper.isElement && (!paginationEl || typeof paginationEl === 'string')) {
|
|
335
|
+
paginationEl = document.createElement('div');
|
|
336
|
+
paginationEl.classList.add('swiper-pagination');
|
|
337
|
+
swiper.el.shadowEl.appendChild(paginationEl);
|
|
338
|
+
}
|
|
339
|
+
if (paginationEl) currentParams.pagination.el = paginationEl;
|
|
340
|
+
pagination.init();
|
|
341
|
+
pagination.render();
|
|
342
|
+
pagination.update();
|
|
343
|
+
}
|
|
344
|
+
if (needScrollbarInit) {
|
|
345
|
+
if (swiper.isElement && (!scrollbarEl || typeof scrollbarEl === 'string')) {
|
|
346
|
+
scrollbarEl = document.createElement('div');
|
|
347
|
+
scrollbarEl.classList.add('swiper-scrollbar');
|
|
348
|
+
swiper.el.shadowEl.appendChild(scrollbarEl);
|
|
349
|
+
}
|
|
350
|
+
if (scrollbarEl) currentParams.scrollbar.el = scrollbarEl;
|
|
351
|
+
scrollbar.init();
|
|
352
|
+
scrollbar.updateSize();
|
|
353
|
+
scrollbar.setTranslate();
|
|
354
|
+
}
|
|
355
|
+
if (needNavigationInit) {
|
|
356
|
+
if (swiper.isElement) {
|
|
357
|
+
if (!nextEl || typeof nextEl === 'string') {
|
|
358
|
+
nextEl = document.createElement('div');
|
|
359
|
+
nextEl.classList.add('swiper-button-next');
|
|
360
|
+
swiper.el.shadowEl.appendChild(nextEl);
|
|
361
|
+
}
|
|
362
|
+
if (!prevEl || typeof prevEl === 'string') {
|
|
363
|
+
prevEl = document.createElement('div');
|
|
364
|
+
prevEl.classList.add('swiper-button-prev');
|
|
365
|
+
swiper.el.shadowEl.appendChild(prevEl);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (nextEl) currentParams.navigation.nextEl = nextEl;
|
|
369
|
+
if (prevEl) currentParams.navigation.prevEl = prevEl;
|
|
370
|
+
navigation.init();
|
|
371
|
+
navigation.update();
|
|
372
|
+
}
|
|
373
|
+
if (changedParams.includes('allowSlideNext')) {
|
|
374
|
+
swiper.allowSlideNext = passedParams.allowSlideNext;
|
|
375
|
+
}
|
|
376
|
+
if (changedParams.includes('allowSlidePrev')) {
|
|
377
|
+
swiper.allowSlidePrev = passedParams.allowSlidePrev;
|
|
378
|
+
}
|
|
379
|
+
if (changedParams.includes('direction')) {
|
|
380
|
+
swiper.changeDirection(passedParams.direction, false);
|
|
381
|
+
}
|
|
382
|
+
if (loopNeedDestroy || loopNeedReloop) {
|
|
383
|
+
swiper.loopDestroy();
|
|
384
|
+
}
|
|
385
|
+
if (loopNeedEnable || loopNeedReloop) {
|
|
386
|
+
swiper.loopCreate();
|
|
387
|
+
}
|
|
388
|
+
swiper.update();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function renderVirtual(swiper, slides, virtualData) {
|
|
392
|
+
if (!virtualData) return null;
|
|
393
|
+
const getSlideIndex = index => {
|
|
394
|
+
let slideIndex = index;
|
|
395
|
+
if (index < 0) {
|
|
396
|
+
slideIndex = slides.length + index;
|
|
397
|
+
} else if (slideIndex >= slides.length) {
|
|
398
|
+
// eslint-disable-next-line
|
|
399
|
+
slideIndex = slideIndex - slides.length;
|
|
400
|
+
}
|
|
401
|
+
return slideIndex;
|
|
402
|
+
};
|
|
403
|
+
const style = swiper.isHorizontal() ? {
|
|
404
|
+
[swiper.rtlTranslate ? 'right' : 'left']: `${virtualData.offset}px`
|
|
405
|
+
} : {
|
|
406
|
+
top: `${virtualData.offset}px`
|
|
407
|
+
};
|
|
408
|
+
const {
|
|
409
|
+
from,
|
|
410
|
+
to
|
|
411
|
+
} = virtualData;
|
|
412
|
+
const loopFrom = swiper.params.loop ? -slides.length : 0;
|
|
413
|
+
const loopTo = swiper.params.loop ? slides.length * 2 : slides.length;
|
|
414
|
+
const slidesToRender = [];
|
|
415
|
+
for (let i = loopFrom; i < loopTo; i += 1) {
|
|
416
|
+
if (i >= from && i <= to) {
|
|
417
|
+
slidesToRender.push(slides[getSlideIndex(i)]);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return slidesToRender.map((child, index) => {
|
|
421
|
+
return /*#__PURE__*/React__default.default.cloneElement(child, {
|
|
422
|
+
swiper,
|
|
423
|
+
style,
|
|
424
|
+
key: `slide-${index}`
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const updateOnVirtualData = swiper => {
|
|
430
|
+
if (!swiper || swiper.destroyed || !swiper.params.virtual || swiper.params.virtual && !swiper.params.virtual.enabled) return;
|
|
431
|
+
swiper.updateSlides();
|
|
432
|
+
swiper.updateProgress();
|
|
433
|
+
swiper.updateSlidesClasses();
|
|
434
|
+
if (swiper.parallax && swiper.params.parallax && swiper.params.parallax.enabled) {
|
|
435
|
+
swiper.parallax.setTranslate();
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
|
|
439
|
+
function useIsomorphicLayoutEffect(callback, deps) {
|
|
440
|
+
// eslint-disable-next-line
|
|
441
|
+
if (typeof window === 'undefined') return React.useEffect(callback, deps);
|
|
442
|
+
return React.useLayoutEffect(callback, deps);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const SwiperSlideContext = /*#__PURE__*/React.createContext(null);
|
|
446
|
+
const SwiperContext = /*#__PURE__*/React.createContext(null);
|
|
447
|
+
|
|
448
|
+
function _extends$1() { _extends$1 = Object.assign ? Object.assign.bind() : 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$1.apply(this, arguments); }
|
|
449
|
+
const Swiper$1 = /*#__PURE__*/React.forwardRef(function (_temp, externalElRef) {
|
|
450
|
+
let {
|
|
451
|
+
className,
|
|
452
|
+
tag: Tag = 'div',
|
|
453
|
+
wrapperTag: WrapperTag = 'div',
|
|
454
|
+
children,
|
|
455
|
+
onSwiper,
|
|
456
|
+
...rest
|
|
457
|
+
} = _temp === void 0 ? {} : _temp;
|
|
458
|
+
let eventsAssigned = false;
|
|
459
|
+
const [containerClasses, setContainerClasses] = React.useState('swiper');
|
|
460
|
+
const [virtualData, setVirtualData] = React.useState(null);
|
|
461
|
+
const [breakpointChanged, setBreakpointChanged] = React.useState(false);
|
|
462
|
+
const initializedRef = React.useRef(false);
|
|
463
|
+
const swiperElRef = React.useRef(null);
|
|
464
|
+
const swiperRef = React.useRef(null);
|
|
465
|
+
const oldPassedParamsRef = React.useRef(null);
|
|
466
|
+
const oldSlides = React.useRef(null);
|
|
467
|
+
const nextElRef = React.useRef(null);
|
|
468
|
+
const prevElRef = React.useRef(null);
|
|
469
|
+
const paginationElRef = React.useRef(null);
|
|
470
|
+
const scrollbarElRef = React.useRef(null);
|
|
471
|
+
const {
|
|
472
|
+
params: swiperParams,
|
|
473
|
+
passedParams,
|
|
474
|
+
rest: restProps,
|
|
475
|
+
events
|
|
476
|
+
} = getParams(rest);
|
|
477
|
+
const {
|
|
478
|
+
slides,
|
|
479
|
+
slots
|
|
480
|
+
} = getChildren(children);
|
|
481
|
+
const onBeforeBreakpoint = () => {
|
|
482
|
+
setBreakpointChanged(!breakpointChanged);
|
|
483
|
+
};
|
|
484
|
+
Object.assign(swiperParams.on, {
|
|
485
|
+
_containerClasses(swiper, classes) {
|
|
486
|
+
setContainerClasses(classes);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
const initSwiper = () => {
|
|
490
|
+
// init swiper
|
|
491
|
+
Object.assign(swiperParams.on, events);
|
|
492
|
+
eventsAssigned = true;
|
|
493
|
+
const passParams = {
|
|
494
|
+
...swiperParams
|
|
495
|
+
};
|
|
496
|
+
delete passParams.wrapperClass;
|
|
497
|
+
swiperRef.current = new Swiper__default.default(passParams);
|
|
498
|
+
if (swiperRef.current.virtual && swiperRef.current.params.virtual.enabled) {
|
|
499
|
+
swiperRef.current.virtual.slides = slides;
|
|
500
|
+
const extendWith = {
|
|
501
|
+
cache: false,
|
|
502
|
+
slides,
|
|
503
|
+
renderExternal: setVirtualData,
|
|
504
|
+
renderExternalUpdate: false
|
|
505
|
+
};
|
|
506
|
+
extend(swiperRef.current.params.virtual, extendWith);
|
|
507
|
+
extend(swiperRef.current.originalParams.virtual, extendWith);
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
if (!swiperElRef.current) {
|
|
511
|
+
initSwiper();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Listen for breakpoints change
|
|
515
|
+
if (swiperRef.current) {
|
|
516
|
+
swiperRef.current.on('_beforeBreakpoint', onBeforeBreakpoint);
|
|
517
|
+
}
|
|
518
|
+
const attachEvents = () => {
|
|
519
|
+
if (eventsAssigned || !events || !swiperRef.current) return;
|
|
520
|
+
Object.keys(events).forEach(eventName => {
|
|
521
|
+
swiperRef.current.on(eventName, events[eventName]);
|
|
522
|
+
});
|
|
523
|
+
};
|
|
524
|
+
const detachEvents = () => {
|
|
525
|
+
if (!events || !swiperRef.current) return;
|
|
526
|
+
Object.keys(events).forEach(eventName => {
|
|
527
|
+
swiperRef.current.off(eventName, events[eventName]);
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
React.useEffect(() => {
|
|
531
|
+
return () => {
|
|
532
|
+
if (swiperRef.current) swiperRef.current.off('_beforeBreakpoint', onBeforeBreakpoint);
|
|
533
|
+
};
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
// set initialized flag
|
|
537
|
+
React.useEffect(() => {
|
|
538
|
+
if (!initializedRef.current && swiperRef.current) {
|
|
539
|
+
swiperRef.current.emitSlidesClasses();
|
|
540
|
+
initializedRef.current = true;
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// mount swiper
|
|
545
|
+
useIsomorphicLayoutEffect(() => {
|
|
546
|
+
if (externalElRef) {
|
|
547
|
+
externalElRef.current = swiperElRef.current;
|
|
548
|
+
}
|
|
549
|
+
if (!swiperElRef.current) return;
|
|
550
|
+
if (swiperRef.current.destroyed) {
|
|
551
|
+
initSwiper();
|
|
552
|
+
}
|
|
553
|
+
mountSwiper({
|
|
554
|
+
el: swiperElRef.current,
|
|
555
|
+
nextEl: nextElRef.current,
|
|
556
|
+
prevEl: prevElRef.current,
|
|
557
|
+
paginationEl: paginationElRef.current,
|
|
558
|
+
scrollbarEl: scrollbarElRef.current,
|
|
559
|
+
swiper: swiperRef.current
|
|
560
|
+
}, swiperParams);
|
|
561
|
+
if (onSwiper) onSwiper(swiperRef.current);
|
|
562
|
+
// eslint-disable-next-line
|
|
563
|
+
return () => {
|
|
564
|
+
if (swiperRef.current && !swiperRef.current.destroyed) {
|
|
565
|
+
swiperRef.current.destroy(true, false);
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
}, []);
|
|
569
|
+
|
|
570
|
+
// watch for params change
|
|
571
|
+
useIsomorphicLayoutEffect(() => {
|
|
572
|
+
attachEvents();
|
|
573
|
+
const changedParams = getChangedParams(passedParams, oldPassedParamsRef.current, slides, oldSlides.current, c => c.key);
|
|
574
|
+
oldPassedParamsRef.current = passedParams;
|
|
575
|
+
oldSlides.current = slides;
|
|
576
|
+
if (changedParams.length && swiperRef.current && !swiperRef.current.destroyed) {
|
|
577
|
+
updateSwiper({
|
|
578
|
+
swiper: swiperRef.current,
|
|
579
|
+
slides,
|
|
580
|
+
passedParams,
|
|
581
|
+
changedParams,
|
|
582
|
+
nextEl: nextElRef.current,
|
|
583
|
+
prevEl: prevElRef.current,
|
|
584
|
+
scrollbarEl: scrollbarElRef.current,
|
|
585
|
+
paginationEl: paginationElRef.current
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
return () => {
|
|
589
|
+
detachEvents();
|
|
590
|
+
};
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
// update on virtual update
|
|
594
|
+
useIsomorphicLayoutEffect(() => {
|
|
595
|
+
updateOnVirtualData(swiperRef.current);
|
|
596
|
+
}, [virtualData]);
|
|
597
|
+
|
|
598
|
+
// bypass swiper instance to slides
|
|
599
|
+
function renderSlides() {
|
|
600
|
+
if (swiperParams.virtual) {
|
|
601
|
+
return renderVirtual(swiperRef.current, slides, virtualData);
|
|
602
|
+
}
|
|
603
|
+
return slides.map((child, index) => {
|
|
604
|
+
return /*#__PURE__*/React__default.default.cloneElement(child, {
|
|
605
|
+
swiper: swiperRef.current,
|
|
606
|
+
swiperSlideIndex: index
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
return /*#__PURE__*/React__default.default.createElement(Tag, _extends$1({
|
|
611
|
+
ref: swiperElRef,
|
|
612
|
+
className: uniqueClasses(`${containerClasses}${className ? ` ${className}` : ''}`)
|
|
613
|
+
}, restProps), /*#__PURE__*/React__default.default.createElement(SwiperContext.Provider, {
|
|
614
|
+
value: swiperRef.current
|
|
615
|
+
}, slots['container-start'], /*#__PURE__*/React__default.default.createElement(WrapperTag, {
|
|
616
|
+
className: wrapperClass(swiperParams.wrapperClass)
|
|
617
|
+
}, slots['wrapper-start'], renderSlides(), slots['wrapper-end']), needsNavigation(swiperParams) && /*#__PURE__*/React__default.default.createElement(React__default.default.Fragment, null, /*#__PURE__*/React__default.default.createElement("div", {
|
|
618
|
+
ref: prevElRef,
|
|
619
|
+
className: "swiper-button-prev"
|
|
620
|
+
}), /*#__PURE__*/React__default.default.createElement("div", {
|
|
621
|
+
ref: nextElRef,
|
|
622
|
+
className: "swiper-button-next"
|
|
623
|
+
})), needsScrollbar(swiperParams) && /*#__PURE__*/React__default.default.createElement("div", {
|
|
624
|
+
ref: scrollbarElRef,
|
|
625
|
+
className: "swiper-scrollbar"
|
|
626
|
+
}), needsPagination(swiperParams) && /*#__PURE__*/React__default.default.createElement("div", {
|
|
627
|
+
ref: paginationElRef,
|
|
628
|
+
className: "swiper-pagination"
|
|
629
|
+
}), slots['container-end']));
|
|
630
|
+
});
|
|
631
|
+
Swiper$1.displayName = 'Swiper';
|
|
632
|
+
|
|
633
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
634
|
+
const SwiperSlide = /*#__PURE__*/React.forwardRef(function (_temp, externalRef) {
|
|
635
|
+
let {
|
|
636
|
+
tag: Tag = 'div',
|
|
637
|
+
children,
|
|
638
|
+
className = '',
|
|
639
|
+
swiper,
|
|
640
|
+
zoom,
|
|
641
|
+
lazy,
|
|
642
|
+
virtualIndex,
|
|
643
|
+
swiperSlideIndex,
|
|
644
|
+
...rest
|
|
645
|
+
} = _temp === void 0 ? {} : _temp;
|
|
646
|
+
const slideElRef = React.useRef(null);
|
|
647
|
+
const [slideClasses, setSlideClasses] = React.useState('swiper-slide');
|
|
648
|
+
const [lazyLoaded, setLazyLoaded] = React.useState(false);
|
|
649
|
+
function updateClasses(_s, el, classNames) {
|
|
650
|
+
if (el === slideElRef.current) {
|
|
651
|
+
setSlideClasses(classNames);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
useIsomorphicLayoutEffect(() => {
|
|
655
|
+
if (typeof swiperSlideIndex !== 'undefined') {
|
|
656
|
+
slideElRef.current.swiperSlideIndex = swiperSlideIndex;
|
|
657
|
+
}
|
|
658
|
+
if (externalRef) {
|
|
659
|
+
externalRef.current = slideElRef.current;
|
|
660
|
+
}
|
|
661
|
+
if (!slideElRef.current || !swiper) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
if (swiper.destroyed) {
|
|
665
|
+
if (slideClasses !== 'swiper-slide') {
|
|
666
|
+
setSlideClasses('swiper-slide');
|
|
667
|
+
}
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
swiper.on('_slideClass', updateClasses);
|
|
671
|
+
// eslint-disable-next-line
|
|
672
|
+
return () => {
|
|
673
|
+
if (!swiper) return;
|
|
674
|
+
swiper.off('_slideClass', updateClasses);
|
|
675
|
+
};
|
|
676
|
+
});
|
|
677
|
+
useIsomorphicLayoutEffect(() => {
|
|
678
|
+
if (swiper && slideElRef.current && !swiper.destroyed) {
|
|
679
|
+
setSlideClasses(swiper.getSlideClasses(slideElRef.current));
|
|
680
|
+
}
|
|
681
|
+
}, [swiper]);
|
|
682
|
+
const slideData = {
|
|
683
|
+
isActive: slideClasses.indexOf('swiper-slide-active') >= 0,
|
|
684
|
+
isVisible: slideClasses.indexOf('swiper-slide-visible') >= 0,
|
|
685
|
+
isPrev: slideClasses.indexOf('swiper-slide-prev') >= 0,
|
|
686
|
+
isNext: slideClasses.indexOf('swiper-slide-next') >= 0
|
|
687
|
+
};
|
|
688
|
+
const renderChildren = () => {
|
|
689
|
+
return typeof children === 'function' ? children(slideData) : children;
|
|
690
|
+
};
|
|
691
|
+
const onLoad = () => {
|
|
692
|
+
setLazyLoaded(true);
|
|
693
|
+
};
|
|
694
|
+
return /*#__PURE__*/React__default.default.createElement(Tag, _extends({
|
|
695
|
+
ref: slideElRef,
|
|
696
|
+
className: uniqueClasses(`${slideClasses}${className ? ` ${className}` : ''}`),
|
|
697
|
+
"data-swiper-slide-index": virtualIndex,
|
|
698
|
+
onLoad: onLoad
|
|
699
|
+
}, rest), zoom && /*#__PURE__*/React__default.default.createElement(SwiperSlideContext.Provider, {
|
|
700
|
+
value: slideData
|
|
701
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
702
|
+
className: "swiper-zoom-container",
|
|
703
|
+
"data-swiper-zoom": typeof zoom === 'number' ? zoom : undefined
|
|
704
|
+
}, renderChildren(), lazy && !lazyLoaded && /*#__PURE__*/React__default.default.createElement("div", {
|
|
705
|
+
className: "swiper-lazy-preloader"
|
|
706
|
+
}))), !zoom && /*#__PURE__*/React__default.default.createElement(SwiperSlideContext.Provider, {
|
|
707
|
+
value: slideData
|
|
708
|
+
}, renderChildren(), lazy && !lazyLoaded && /*#__PURE__*/React__default.default.createElement("div", {
|
|
709
|
+
className: "swiper-lazy-preloader"
|
|
710
|
+
})));
|
|
711
|
+
});
|
|
712
|
+
SwiperSlide.displayName = 'SwiperSlide';
|
|
713
|
+
|
|
714
|
+
function Swiper(props) {
|
|
715
|
+
var activeSlideIndex = props.activeSlideIndex,
|
|
716
|
+
allowTouchMove = props.allowTouchMove,
|
|
717
|
+
autoHeight = props.autoHeight,
|
|
718
|
+
breakpoints = props.breakpoints,
|
|
719
|
+
children = props.children,
|
|
720
|
+
className = props.className,
|
|
721
|
+
direction = props.direction;
|
|
722
|
+
props.disabledButtonClass;
|
|
723
|
+
var forwardedRef = props.forwardedRef,
|
|
724
|
+
freeMode = props.freeMode,
|
|
725
|
+
id = props.id,
|
|
726
|
+
isChangeOnClickSlide = props.isChangeOnClickSlide,
|
|
727
|
+
isInit = props.isInit,
|
|
728
|
+
isNavigation = props.isNavigation,
|
|
729
|
+
isPagination = props.isPagination,
|
|
730
|
+
isScrollbar = props.isScrollbar,
|
|
731
|
+
items = props.items,
|
|
732
|
+
loop = props.loop,
|
|
733
|
+
modules = props.modules,
|
|
734
|
+
mousewheel = props.mousewheel,
|
|
735
|
+
nextButton = props.nextButton,
|
|
736
|
+
normalizeSlideIndex = props.normalizeSlideIndex,
|
|
737
|
+
prevButton = props.prevButton,
|
|
738
|
+
set = props.set,
|
|
739
|
+
setNextBtnDisabled = props.setNextBtnDisabled,
|
|
740
|
+
setPrevBtnDisabled = props.setPrevBtnDisabled,
|
|
741
|
+
slidesPerView = props.slidesPerView,
|
|
742
|
+
spaceBetween = props.spaceBetween,
|
|
743
|
+
speed = props.speed,
|
|
744
|
+
swiperClass = props.swiperClass,
|
|
745
|
+
title = props.title,
|
|
746
|
+
titleSize = props.titleSize,
|
|
747
|
+
titleTextColor = props.titleTextColor,
|
|
748
|
+
titleWeight = props.titleWeight,
|
|
749
|
+
onSlideNextTransitionEnd = props.onSlideNextTransitionEnd,
|
|
750
|
+
onSlidePrevTransitionEnd = props.onSlidePrevTransitionEnd,
|
|
751
|
+
onSwiper = props.onSwiper,
|
|
752
|
+
onUpdate = props.onUpdate;
|
|
753
|
+
var swiperRef = React.useRef();
|
|
754
|
+
var _useSwiperRef = useSwiperRef(),
|
|
755
|
+
nextEl = _useSwiperRef[0],
|
|
756
|
+
nextRef = _useSwiperRef[1];
|
|
757
|
+
var _useSwiperRef2 = useSwiperRef(),
|
|
758
|
+
prevEl = _useSwiperRef2[0],
|
|
759
|
+
prevRef = _useSwiperRef2[1];
|
|
760
|
+
var isLoop = loop != null ? loop : true;
|
|
761
|
+
React.useImperativeHandle(forwardedRef, function () {
|
|
762
|
+
return swiperRef.current;
|
|
763
|
+
}, []);
|
|
764
|
+
var onInitSwiper = React.useCallback(function (swiper) {
|
|
765
|
+
// Set "disabled" state to navigation buttons on init
|
|
766
|
+
if (!isLoop && setPrevBtnDisabled && setNextBtnDisabled) {
|
|
767
|
+
setPrevBtnDisabled(swiper.isBeginning);
|
|
768
|
+
setNextBtnDisabled(swiper.isEnd);
|
|
769
|
+
}
|
|
770
|
+
}, [isLoop, setPrevBtnDisabled, setNextBtnDisabled]);
|
|
771
|
+
var onSlideChange = React.useCallback(function (swiper) {
|
|
772
|
+
// Some things with clickedIndex
|
|
773
|
+
if (isChangeOnClickSlide) {
|
|
774
|
+
swiper.activeIndex = swiper.clickedIndex || activeSlideIndex;
|
|
775
|
+
}
|
|
776
|
+
}, [isChangeOnClickSlide, activeSlideIndex]);
|
|
777
|
+
var onTransitionStart = React.useCallback(function (swiper) {
|
|
778
|
+
// Set "disabled" state to navigation buttons, when slider move
|
|
779
|
+
if (!isLoop && setPrevBtnDisabled && setNextBtnDisabled) {
|
|
780
|
+
setPrevBtnDisabled(swiper.isBeginning);
|
|
781
|
+
setNextBtnDisabled(swiper.isEnd);
|
|
782
|
+
}
|
|
783
|
+
}, [isLoop, setPrevBtnDisabled, setNextBtnDisabled]);
|
|
784
|
+
React.useEffect(function () {
|
|
785
|
+
var _swiperRef$current;
|
|
786
|
+
var swiperInstance = (_swiperRef$current = swiperRef.current) == null ? void 0 : _swiperRef$current.swiper;
|
|
787
|
+
swiperInstance == null ? void 0 : swiperInstance.updateActiveIndex(activeSlideIndex);
|
|
788
|
+
swiperInstance == null ? void 0 : swiperInstance.updateSlidesClasses();
|
|
789
|
+
}, [activeSlideIndex]);
|
|
790
|
+
var fillClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
791
|
+
prefix: 'fill_',
|
|
792
|
+
propsKey: 'fill'
|
|
793
|
+
});
|
|
794
|
+
var shapeClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
795
|
+
prefix: 'swiper_shape_',
|
|
796
|
+
propsKey: 'shape'
|
|
797
|
+
});
|
|
798
|
+
var alignDirectionClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
799
|
+
prefix: 'align_',
|
|
800
|
+
propsKey: 'alignDirection'
|
|
801
|
+
});
|
|
802
|
+
var alignClass = useDeviceTargetClass.useDeviceTargetClass(props, {
|
|
803
|
+
prefix: 'align_',
|
|
804
|
+
propsKey: 'align'
|
|
805
|
+
});
|
|
806
|
+
return /*#__PURE__*/React__default.default.createElement("div", {
|
|
807
|
+
className: clsx__default.default('swiper-block', slidesPerView === 'auto' && 'swiper-block_type_auto', fillClass, shapeClass, className, set && "swiper-block_set_" + set),
|
|
808
|
+
id: id
|
|
809
|
+
}, (title || prevButton && nextButton) && /*#__PURE__*/React__default.default.createElement("div", {
|
|
810
|
+
className: "swiper-block__wrapper"
|
|
811
|
+
}, title && /*#__PURE__*/React__default.default.createElement(index.Title, {
|
|
812
|
+
className: "swiper-block__title",
|
|
813
|
+
size: titleSize,
|
|
814
|
+
textColor: titleTextColor,
|
|
815
|
+
textWeight: titleWeight
|
|
816
|
+
}, title), prevButton && nextButton && /*#__PURE__*/React__default.default.createElement("div", {
|
|
817
|
+
className: "swiper-block__navigation"
|
|
818
|
+
}, /*#__PURE__*/React__default.default.createElement("div", {
|
|
819
|
+
className: "swiper-block__prev swiper-button",
|
|
820
|
+
ref: prevRef
|
|
821
|
+
}, prevButton), /*#__PURE__*/React__default.default.createElement("div", {
|
|
822
|
+
className: "swiper-block__next swiper-button",
|
|
823
|
+
ref: nextRef
|
|
824
|
+
}, nextButton))), /*#__PURE__*/React__default.default.createElement(Swiper$1, {
|
|
825
|
+
allowTouchMove: allowTouchMove,
|
|
826
|
+
autoHeight: autoHeight != null ? autoHeight : false,
|
|
827
|
+
breakpoints: breakpoints,
|
|
828
|
+
className: clsx__default.default('swiper-block__swiper', swiperClass),
|
|
829
|
+
direction: direction,
|
|
830
|
+
freeMode: freeMode,
|
|
831
|
+
init: isInit != null ? isInit : true,
|
|
832
|
+
loop: isLoop,
|
|
833
|
+
modules: modules,
|
|
834
|
+
mousewheel: mousewheel,
|
|
835
|
+
navigation: isNavigation ? {
|
|
836
|
+
prevEl: prevEl,
|
|
837
|
+
nextEl: nextEl
|
|
838
|
+
} : false,
|
|
839
|
+
normalizeSlideIndex: normalizeSlideIndex,
|
|
840
|
+
pagination: isPagination,
|
|
841
|
+
ref: swiperRef,
|
|
842
|
+
scrollbar: isScrollbar,
|
|
843
|
+
slidesPerView: slidesPerView,
|
|
844
|
+
spaceBetween: spaceBetween,
|
|
845
|
+
speed: speed != null ? speed : 500,
|
|
846
|
+
onInit: onInitSwiper,
|
|
847
|
+
onSlideChange: onSlideChange,
|
|
848
|
+
onSlideNextTransitionEnd: onSlideNextTransitionEnd,
|
|
849
|
+
onSlidePrevTransitionEnd: onSlidePrevTransitionEnd,
|
|
850
|
+
onSwiper: onSwiper,
|
|
851
|
+
onUpdate: onUpdate,
|
|
852
|
+
onTransitionStart: onTransitionStart
|
|
853
|
+
}, children || (items == null ? void 0 : items.map(function (item, i) {
|
|
854
|
+
return /*#__PURE__*/React__default.default.createElement(SwiperSlide, {
|
|
855
|
+
className: clsx__default.default(alignDirectionClass, alignClass),
|
|
856
|
+
key: "swiper-slide_" + i
|
|
857
|
+
}, item);
|
|
858
|
+
}))));
|
|
859
|
+
}
|
|
860
|
+
Swiper.propTypes = {
|
|
861
|
+
activeSlideIndex: PropTypes__default.default.number,
|
|
862
|
+
allowTouchMove: PropTypes__default.default.bool,
|
|
863
|
+
autoHeight: PropTypes__default.default.bool,
|
|
864
|
+
breakpoints: PropTypes__default.default.object,
|
|
865
|
+
children: PropTypes__default.default.any,
|
|
866
|
+
className: PropTypes__default.default.string,
|
|
867
|
+
direction: PropTypes__default.default.string,
|
|
868
|
+
disabledButtonClass: PropTypes__default.default.string,
|
|
869
|
+
fill: PropTypes__default.default.oneOf(fill.default),
|
|
870
|
+
fillDesktop: PropTypes__default.default.oneOf(fill.default),
|
|
871
|
+
fillMobile: PropTypes__default.default.oneOf(fill.default),
|
|
872
|
+
fillTablet: PropTypes__default.default.oneOf(fill.default),
|
|
873
|
+
forwardedRef: PropTypes__default.default.any,
|
|
874
|
+
freeMode: PropTypes__default.default.bool,
|
|
875
|
+
id: PropTypes__default.default.oneOfType([PropTypes__default.default.string, PropTypes__default.default.number]),
|
|
876
|
+
isChangeOnClickSlide: PropTypes__default.default.bool,
|
|
877
|
+
isInit: PropTypes__default.default.bool,
|
|
878
|
+
isNavigation: PropTypes__default.default.bool,
|
|
879
|
+
isPagination: PropTypes__default.default.bool,
|
|
880
|
+
isScrollbar: PropTypes__default.default.bool,
|
|
881
|
+
items: PropTypes__default.default.array,
|
|
882
|
+
loop: PropTypes__default.default.bool,
|
|
883
|
+
modules: PropTypes__default.default.arrayOf(PropTypes__default.default.func),
|
|
884
|
+
mousewheel: PropTypes__default.default.bool,
|
|
885
|
+
nextButton: PropTypes__default.default.any,
|
|
886
|
+
normalizeSlideIndex: PropTypes__default.default.bool,
|
|
887
|
+
prevButton: PropTypes__default.default.any,
|
|
888
|
+
set: PropTypes__default.default.string,
|
|
889
|
+
setNextBtnDisabled: PropTypes__default.default.func,
|
|
890
|
+
setPrevBtnDisabled: PropTypes__default.default.func,
|
|
891
|
+
shape: PropTypes__default.default.oneOf(shape.default),
|
|
892
|
+
shapeDesktop: PropTypes__default.default.oneOf(shape.default),
|
|
893
|
+
shapeMobile: PropTypes__default.default.oneOf(shape.default),
|
|
894
|
+
shapeTablet: PropTypes__default.default.oneOf(shape.default),
|
|
895
|
+
slidesPerView: PropTypes__default.default.number,
|
|
896
|
+
spaceBetween: PropTypes__default.default.number,
|
|
897
|
+
speed: PropTypes__default.default.number,
|
|
898
|
+
swiperClass: PropTypes__default.default.string,
|
|
899
|
+
title: PropTypes__default.default.string,
|
|
900
|
+
titleSize: PropTypes__default.default.string,
|
|
901
|
+
titleTextColor: PropTypes__default.default.string,
|
|
902
|
+
titleWeight: PropTypes__default.default.string,
|
|
903
|
+
onSlideNextTransitionEnd: PropTypes__default.default.func,
|
|
904
|
+
onSlidePrevTransitionEnd: PropTypes__default.default.func,
|
|
905
|
+
onSwiper: PropTypes__default.default.func,
|
|
906
|
+
onUpdate: PropTypes__default.default.func
|
|
907
|
+
};
|
|
908
|
+
Swiper.defaultProps = {
|
|
909
|
+
activeSlideIndex: 0,
|
|
910
|
+
disabledButtonClass: 'swiper-button-disabled'
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
// https://github.com/nolimits4web/swiper/issues/3855#issuecomment-1050694342
|
|
914
|
+
var useSwiperRef = function useSwiperRef() {
|
|
915
|
+
var _useState = React.useState(null),
|
|
916
|
+
wrapper = _useState[0],
|
|
917
|
+
setWrapper = _useState[1];
|
|
918
|
+
var ref = React.useRef(null);
|
|
919
|
+
React.useEffect(function () {
|
|
920
|
+
if (ref.current) {
|
|
921
|
+
setWrapper(ref.current);
|
|
922
|
+
}
|
|
923
|
+
}, []);
|
|
924
|
+
return [wrapper, ref];
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
exports.Swiper = Swiper;
|