@gem-sdk/components 2.0.0-dev.727 → 2.0.0-dev.728
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/dist/cjs/builder.js +2 -2
- package/dist/cjs/carousel/carousel-item/CarouselItem.js +2 -1
- package/dist/cjs/carousel/index.js +3 -3
- package/dist/cjs/carousel/root/CarouselWithSwiper.js +129 -0
- package/dist/cjs/carousel/root/CustomSwiper.js +65 -0
- package/dist/cjs/carousel/root/hook/useCarouselWithSwiper.js +331 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/product/components/ProductImages/ProductGalleryCarousel.js +2 -2
- package/dist/cjs/product/components/ProductImages/ProductImagesLightBox.js +2 -2
- package/dist/cjs/product/components/ProductImagesV2/components/child/ProductFeaturedImageCarousel.js +2 -2
- package/dist/cjs/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.js +2 -2
- package/dist/cjs/product/components/ProductImagesV2/components/lightbox/ProductImagesLightBox.js +2 -2
- package/dist/cjs/product/components/ProductList/ProductListCarouselLayout.js +2 -2
- package/dist/cjs/product/index.js +1 -1
- package/dist/esm/builder.js +2 -2
- package/dist/esm/carousel/carousel-item/CarouselItem.js +2 -1
- package/dist/esm/carousel/index.js +1 -1
- package/dist/esm/carousel/root/CarouselWithSwiper.js +125 -0
- package/dist/esm/carousel/root/CustomSwiper.js +62 -0
- package/dist/esm/carousel/root/hook/useCarouselWithSwiper.js +329 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/product/components/ProductImages/ProductGalleryCarousel.js +2 -2
- package/dist/esm/product/components/ProductImages/ProductImagesLightBox.js +2 -2
- package/dist/esm/product/components/ProductImagesV2/components/child/ProductFeaturedImageCarousel.js +2 -2
- package/dist/esm/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.js +2 -2
- package/dist/esm/product/components/ProductImagesV2/components/lightbox/ProductImagesLightBox.js +2 -2
- package/dist/esm/product/components/ProductList/ProductListCarouselLayout.js +2 -2
- package/dist/esm/product/index.js +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/builder.js
CHANGED
|
@@ -136,7 +136,7 @@ var ArticleReadMore = require('./article/components/ArticleReadMore.js');
|
|
|
136
136
|
var HeroBanner = require('./banner/components/HeroBanner.js');
|
|
137
137
|
var Breadcrumb = require('./breadcrumb/components/Breadcrumb.js');
|
|
138
138
|
var Button = require('./button/components/Button.js');
|
|
139
|
-
var
|
|
139
|
+
var CarouselWithSwiper = require('./carousel/root/CarouselWithSwiper.js');
|
|
140
140
|
var CarouselItem = require('./carousel/carousel-item/CarouselItem.js');
|
|
141
141
|
var Cart = require('./cart/components/Cart.js');
|
|
142
142
|
var CartList = require('./cart/components/CartList.js');
|
|
@@ -282,7 +282,7 @@ var builder = {
|
|
|
282
282
|
HeroBanner: HeroBanner.default,
|
|
283
283
|
Breadcrumb: Breadcrumb.default,
|
|
284
284
|
Button: Button.default,
|
|
285
|
-
Carousel:
|
|
285
|
+
Carousel: CarouselWithSwiper.default,
|
|
286
286
|
CarouselItem: CarouselItem.default,
|
|
287
287
|
Cart: Cart.default,
|
|
288
288
|
CartList: CartList.default,
|
|
@@ -9,13 +9,14 @@ var ChildrenDroppable = require('../../grid/components/ChildrenDroppable.js');
|
|
|
9
9
|
var getStyle = require('./common/getStyle.js');
|
|
10
10
|
var getClass = require('./common/getClass.js');
|
|
11
11
|
var useCarouseItem = require('./hook/useCarouseItem.js');
|
|
12
|
+
var CustomSwiper = require('../root/CustomSwiper.js');
|
|
12
13
|
|
|
13
14
|
const CarouselItem = (props)=>{
|
|
14
15
|
const { children, builderAttrs } = props;
|
|
15
16
|
const { handleClick, handleMouseMove, handleMouseOut } = useCarouseItem.useCarouselItem(props);
|
|
16
17
|
const { carouselItemStyle, carouselItemInnerStyle } = getStyle.getStyle(props);
|
|
17
18
|
const { carouselItemClass, carouselItemInnerClass } = getClass.getClass(props);
|
|
18
|
-
return /*#__PURE__*/ jsxRuntime.jsx(
|
|
19
|
+
return /*#__PURE__*/ jsxRuntime.jsx(CustomSwiper.SwiperSlide, {
|
|
19
20
|
...builderAttrs,
|
|
20
21
|
"aria-hidden": true,
|
|
21
22
|
className: carouselItemClass,
|
|
@@ -4,13 +4,13 @@ require('react/jsx-runtime');
|
|
|
4
4
|
require('@gem-sdk/core');
|
|
5
5
|
require('react');
|
|
6
6
|
require('@gem-sdk/system');
|
|
7
|
-
require('
|
|
7
|
+
require('swiper/element/bundle');
|
|
8
8
|
require('next/link');
|
|
9
|
-
var Carousel
|
|
9
|
+
var Carousel = require('./setting/Carousel.js');
|
|
10
10
|
var CarouselItem$1 = require('./setting/CarouselItem.js');
|
|
11
11
|
|
|
12
12
|
const carouselSetting = {
|
|
13
|
-
Carousel: Carousel
|
|
13
|
+
Carousel: Carousel.default,
|
|
14
14
|
CarouselItem: CarouselItem$1.default
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var core = require('@gem-sdk/core');
|
|
8
|
+
var React = require('react');
|
|
9
|
+
var common = require('../arrow/common/common.js');
|
|
10
|
+
var getClass = require('./common/getClass.js');
|
|
11
|
+
var getStyle = require('./common/getStyle.js');
|
|
12
|
+
var getAttr = require('./common/getAttr.js');
|
|
13
|
+
var getData = require('./common/getData.js');
|
|
14
|
+
var CustomSwiper = require('./CustomSwiper.js');
|
|
15
|
+
var Arrow = require('../arrow/Arrow.js');
|
|
16
|
+
var useCarouselWithSwiper = require('./hook/useCarouselWithSwiper.js');
|
|
17
|
+
var Dots = require('../dots/Dots.js');
|
|
18
|
+
|
|
19
|
+
const CarouselWithSwiper = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
20
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, elmRef } = props;
|
|
21
|
+
const setting = common.mappingNavigationCarousel(props.setting);
|
|
22
|
+
const renderData = {
|
|
23
|
+
...props,
|
|
24
|
+
setting
|
|
25
|
+
};
|
|
26
|
+
const [swiperInstance, setSwiperInstance] = React.useState(null);
|
|
27
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
28
|
+
const { isInfinity, localRef, sliderSettings, totalSlideItem, currentSlide, isRenderDots, showNavigation, handleDotClick, getItemsPerPage, handleNextAndPrevSlide, dispatchEventSelectSlide, getNumberOfFullWidthShow } = useCarouselWithSwiper.useCarouselWithSwiper(renderData, ref, swiperInstance);
|
|
29
|
+
const { loopConfig, arrowShowConfig } = getData.getData(renderData);
|
|
30
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass.getClass(renderData);
|
|
31
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle } = getStyle.getStyle(renderData);
|
|
32
|
+
const { rootAttrRender, sliderAttr } = getAttr.getAttr(renderData);
|
|
33
|
+
const currentDevice = core.useCurrentDevice();
|
|
34
|
+
const enabledSneakPeak = setting?.sneakPeak?.[currentDevice];
|
|
35
|
+
const renderArrow = (position)=>{
|
|
36
|
+
const isNext = position === 'next';
|
|
37
|
+
const slidesPerView = getItemsPerPage();
|
|
38
|
+
const isDisable = isNext ? !isInfinity && currentSlide >= totalSlideItem - Math.floor(slidesPerView) : !isInfinity && currentSlide === 0;
|
|
39
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Arrow.default, {
|
|
40
|
+
uid: builderProps?.uid,
|
|
41
|
+
custom: setting?.arrowCustom ?? '',
|
|
42
|
+
showArrow: arrowShowConfig,
|
|
43
|
+
arrowButtonSize: arrowButtonSize || {},
|
|
44
|
+
arrowIconSize: arrowIconSize || {},
|
|
45
|
+
arrowBackgroundColor: arrowBackgroundColor || '',
|
|
46
|
+
arrowCustomColor: arrowCustomColor,
|
|
47
|
+
gapToEachSize: arrowGapToEachSide,
|
|
48
|
+
showWhenHover: showWhenHover,
|
|
49
|
+
arrowBorder: arrowBorder || {},
|
|
50
|
+
arrowCorner: roundedArrow || {},
|
|
51
|
+
arrowShadow: arrowShadow || {},
|
|
52
|
+
onClick: (e)=>{
|
|
53
|
+
e.stopPropagation();
|
|
54
|
+
handleNextAndPrevSlide(position);
|
|
55
|
+
},
|
|
56
|
+
left: !isNext,
|
|
57
|
+
disabled: isDisable,
|
|
58
|
+
vertical: setting?.vertical,
|
|
59
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
60
|
+
rootId: props?.parentClass
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
64
|
+
ref: elmRef,
|
|
65
|
+
...rootAttrRender,
|
|
66
|
+
className: rootClassRender,
|
|
67
|
+
style: rootStyleRender,
|
|
68
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
69
|
+
ref: localRef,
|
|
70
|
+
...builderAttrs,
|
|
71
|
+
className: wrapperClassRender,
|
|
72
|
+
style: wrapperStyleRender,
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
75
|
+
className: wrapperInnerClass,
|
|
76
|
+
style: wrapperInnerStyle,
|
|
77
|
+
children: [
|
|
78
|
+
showNavigation && renderArrow('prev'),
|
|
79
|
+
/*#__PURE__*/ jsxRuntime.jsx(CustomSwiper.Swiper, {
|
|
80
|
+
...sliderAttr,
|
|
81
|
+
...sliderSettings,
|
|
82
|
+
sliderClass: sliderClass,
|
|
83
|
+
onSwiperReady: (swiper)=>{
|
|
84
|
+
setSwiperInstance(swiper);
|
|
85
|
+
},
|
|
86
|
+
children: core.isEmptyChildren(children) ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
87
|
+
children: "No Slider"
|
|
88
|
+
}) : React.Children.map(core.filterToolbarPreview(children), (child)=>{
|
|
89
|
+
if (/*#__PURE__*/ React.isValidElement(child)) {
|
|
90
|
+
return /*#__PURE__*/ jsxRuntime.jsx(child.type, {
|
|
91
|
+
...child.props,
|
|
92
|
+
parentSettings: setting,
|
|
93
|
+
parentStyle: styles,
|
|
94
|
+
background: setting?.background,
|
|
95
|
+
parentUid: builderProps?.uid,
|
|
96
|
+
dispatchEventSelectSlide: dispatchEventSelectSlide
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
})
|
|
101
|
+
}),
|
|
102
|
+
showNavigation && renderArrow('next')
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
isRenderDots && /*#__PURE__*/ jsxRuntime.jsx(Dots.default, {
|
|
106
|
+
dotStyle: setting?.dotStyle,
|
|
107
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
108
|
+
vertical: setting?.vertical,
|
|
109
|
+
showDots: setting?.dot,
|
|
110
|
+
slideItemsPerPage: getItemsPerPage(),
|
|
111
|
+
enabledSneakPeak: enabledSneakPeak,
|
|
112
|
+
dotColor: setting?.dotColor,
|
|
113
|
+
dotActiveColor: setting?.dotActiveColor,
|
|
114
|
+
dotSize: setting?.dotSize,
|
|
115
|
+
sneakPeakType: setting?.sneakPeakType,
|
|
116
|
+
totalSlideItem: totalSlideItem,
|
|
117
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne,
|
|
118
|
+
currentSlide: currentSlide,
|
|
119
|
+
loop: loopConfig,
|
|
120
|
+
numberOfFullWidthShow: getNumberOfFullWidthShow(currentDevice),
|
|
121
|
+
onHandleClick: handleDotClick
|
|
122
|
+
}),
|
|
123
|
+
core.filterToolbarPreview(children, true)
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
exports.default = CarouselWithSwiper;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var bundle = require('swiper/element/bundle');
|
|
6
|
+
|
|
7
|
+
function Swiper(props) {
|
|
8
|
+
const swiperRef = React.useRef(null);
|
|
9
|
+
const { children, onSwiperReady, sliderClass, ...otherProps } = props;
|
|
10
|
+
const pauseOnMouseEnter = typeof props.autoplay === 'object' && props.autoplay !== null ? props.autoplay.pauseOnMouseEnter : undefined;
|
|
11
|
+
React.useEffect(()=>{
|
|
12
|
+
bundle.register();
|
|
13
|
+
Object.assign(swiperRef.current, otherProps);
|
|
14
|
+
swiperRef.current.initialize();
|
|
15
|
+
const instance = swiperRef.current.swiper;
|
|
16
|
+
onSwiperReady?.(instance);
|
|
17
|
+
}, [
|
|
18
|
+
otherProps,
|
|
19
|
+
onSwiperReady
|
|
20
|
+
]);
|
|
21
|
+
React.useEffect(()=>{
|
|
22
|
+
if (swiperRef.current?.swiper) {
|
|
23
|
+
const swiperInstance = swiperRef.current.swiper;
|
|
24
|
+
swiperInstance.params.spaceBetween = props.spaceBetween ?? swiperInstance.params.spaceBetween;
|
|
25
|
+
swiperInstance.params.slidesPerView = props.slidesPerView ?? swiperInstance.params.slidesPerView;
|
|
26
|
+
swiperInstance.update();
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
props.spaceBetween,
|
|
30
|
+
props.slidesPerView
|
|
31
|
+
]);
|
|
32
|
+
React.useEffect(()=>{
|
|
33
|
+
if (swiperRef.current?.swiper) {
|
|
34
|
+
const swiperInstance = swiperRef.current.swiper;
|
|
35
|
+
swiperInstance.destroy(true, true);
|
|
36
|
+
swiperRef.current.loop = props.loop;
|
|
37
|
+
swiperRef.current.centeredSlides = props.centeredSlides;
|
|
38
|
+
swiperRef.current.dir = props.dir;
|
|
39
|
+
swiperRef.current.initialize();
|
|
40
|
+
onSwiperReady?.(swiperRef.current.swiper);
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
props.dir,
|
|
44
|
+
props.loop,
|
|
45
|
+
props.centeredSlides,
|
|
46
|
+
pauseOnMouseEnter
|
|
47
|
+
]);
|
|
48
|
+
return /*#__PURE__*/ jsxRuntime.jsx("swiper-container", {
|
|
49
|
+
init: false,
|
|
50
|
+
className: sliderClass,
|
|
51
|
+
ref: swiperRef,
|
|
52
|
+
children: children
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function SwiperSlide(props) {
|
|
56
|
+
const { children, className, ...rest } = props;
|
|
57
|
+
return /*#__PURE__*/ jsxRuntime.jsx("swiper-slide", {
|
|
58
|
+
...rest,
|
|
59
|
+
className: className,
|
|
60
|
+
children: children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
exports.Swiper = Swiper;
|
|
65
|
+
exports.SwiperSlide = SwiperSlide;
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var core = require('@gem-sdk/core');
|
|
5
|
+
var useTrackPreviewPause = require('../../components/hooks/useTrackPreviewPause.js');
|
|
6
|
+
|
|
7
|
+
const useCarouselWithSwiper = (props, ref, swiperInstance)=>{
|
|
8
|
+
const { builderProps, moveToIdx, styles, setting, isHiddenArrowWhenDisabled = true, elmRef, onClickArrow, onHandleChangeSlideByInteraction } = props;
|
|
9
|
+
const { loop, navigationEnable = {
|
|
10
|
+
desktop: true
|
|
11
|
+
}, navigationStyle } = setting ?? {};
|
|
12
|
+
const [totalSlideItem, setTotalSlideItem] = React.useState(0);
|
|
13
|
+
const [currentSlide, setCurrentSlide] = React.useState(setting?.defaultCurrentSlider ?? 0);
|
|
14
|
+
const isInfinity = React.useMemo(()=>{
|
|
15
|
+
return core.getResponsiveValueByScreen(loop, 'desktop', false);
|
|
16
|
+
}, [
|
|
17
|
+
loop
|
|
18
|
+
]);
|
|
19
|
+
const { isFirstPreviewClicked } = useTrackPreviewPause.default(setting?.runPreview);
|
|
20
|
+
// const { sliderSelector } = getData(props);
|
|
21
|
+
const localRef = React.useRef();
|
|
22
|
+
// const isRunningAnimation = useRef(false);
|
|
23
|
+
const previousIndex = React.useRef(moveToIdx ?? 0);
|
|
24
|
+
const isRenderDots = React.useMemo(()=>!!totalSlideItem && swiperInstance && core.getResponsiveValueByScreen(setting?.dot), [
|
|
25
|
+
swiperInstance,
|
|
26
|
+
setting?.dot,
|
|
27
|
+
totalSlideItem
|
|
28
|
+
]);
|
|
29
|
+
let delayTimeout;
|
|
30
|
+
const currentDevice = core.useCurrentDevice();
|
|
31
|
+
const mode = core.useEditorMode();
|
|
32
|
+
const { onListener, saveToElementInteractionData, getInteractionPreviousData, trigger } = core.useInteraction();
|
|
33
|
+
const getItemNumberFromOldData = React.useCallback(()=>{
|
|
34
|
+
if (!setting?.slidesToShow) return null;
|
|
35
|
+
const result = {};
|
|
36
|
+
core.DEVICES.forEach((device)=>{
|
|
37
|
+
const value = core.getResponsiveValueByScreen(setting?.slidesToShow, device);
|
|
38
|
+
result[device] = value ? value === 'auto' ? 4 : Math.floor(value) : 0;
|
|
39
|
+
});
|
|
40
|
+
return result;
|
|
41
|
+
}, [
|
|
42
|
+
setting?.slidesToShow
|
|
43
|
+
]);
|
|
44
|
+
const getSlideToShowFromOldData = React.useCallback(()=>{
|
|
45
|
+
if (!setting?.slidesToShow) return null;
|
|
46
|
+
const result = {};
|
|
47
|
+
core.DEVICES.forEach((device)=>{
|
|
48
|
+
const value = core.getResponsiveValueByScreen(setting?.slidesToShow, device);
|
|
49
|
+
result[device] = value ? value === 'auto' ? 4 : value : 0;
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
}, [
|
|
53
|
+
setting?.slidesToShow
|
|
54
|
+
]);
|
|
55
|
+
const showNavigation = React.useMemo(()=>{
|
|
56
|
+
const navigationEnableByDevice = core.getResponsiveValueByScreen(navigationEnable, currentDevice);
|
|
57
|
+
const navigationStyleByDevice = core.getResponsiveValueByScreen(navigationStyle, currentDevice);
|
|
58
|
+
return swiperInstance && navigationEnableByDevice && navigationStyleByDevice !== 'none';
|
|
59
|
+
}, [
|
|
60
|
+
swiperInstance,
|
|
61
|
+
navigationEnable,
|
|
62
|
+
navigationStyle,
|
|
63
|
+
currentDevice
|
|
64
|
+
]);
|
|
65
|
+
const slidesToShow = React.useMemo(()=>{
|
|
66
|
+
const oldData = getSlideToShowFromOldData();
|
|
67
|
+
if (oldData) {
|
|
68
|
+
return oldData;
|
|
69
|
+
}
|
|
70
|
+
const result = {};
|
|
71
|
+
core.DEVICES.forEach((device)=>{
|
|
72
|
+
const enableSneakPeak = core.getResponsiveValueByScreen(setting?.sneakPeak, device);
|
|
73
|
+
const offset = enableSneakPeak ? core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? core.getResponsiveValueByScreen(setting?.sneakPeakOffsetCenter, device) ?? 0 : core.getResponsiveValueByScreen(setting?.sneakPeakOffsetForward, device) ?? 0 : 0;
|
|
74
|
+
const rx = core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? -2 : -1;
|
|
75
|
+
const itemNumberByDevice = core.getResponsiveValueByScreen(setting?.itemNumber, device);
|
|
76
|
+
result[device] = typeof itemNumberByDevice === 'number' ? itemNumberByDevice + offset / 100 * rx : 'auto';
|
|
77
|
+
});
|
|
78
|
+
return result;
|
|
79
|
+
}, [
|
|
80
|
+
getSlideToShowFromOldData,
|
|
81
|
+
setting?.itemNumber,
|
|
82
|
+
setting?.sneakPeak,
|
|
83
|
+
setting?.sneakPeakOffsetCenter,
|
|
84
|
+
setting?.sneakPeakOffsetForward,
|
|
85
|
+
setting?.sneakPeakType
|
|
86
|
+
]);
|
|
87
|
+
const itemNumber = React.useMemo(()=>{
|
|
88
|
+
const oldData = getItemNumberFromOldData();
|
|
89
|
+
return oldData || setting?.itemNumber;
|
|
90
|
+
}, [
|
|
91
|
+
getItemNumberFromOldData,
|
|
92
|
+
setting?.itemNumber
|
|
93
|
+
]);
|
|
94
|
+
const getNumberOfFullWidthShow = React.useCallback((device)=>{
|
|
95
|
+
const sneakPeekTypeByNumber = core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? 2 : 1;
|
|
96
|
+
return typeof core.getResponsiveValueByScreen(itemNumber, device, 4) === 'number' ? core.getResponsiveValueByScreen(itemNumber, device, 4) - sneakPeekTypeByNumber : undefined;
|
|
97
|
+
}, [
|
|
98
|
+
setting?.sneakPeakType,
|
|
99
|
+
itemNumber
|
|
100
|
+
]);
|
|
101
|
+
const getItemsPerPage = ()=>{
|
|
102
|
+
const items = core.getResponsiveValueByScreen(slidesToShow, currentDevice, 1) === 'auto' ? 1 : core.getResponsiveValueByScreen(slidesToShow, currentDevice, 1);
|
|
103
|
+
return items ?? 1;
|
|
104
|
+
};
|
|
105
|
+
const getIndexSlideItemBy = (pageIdx)=>{
|
|
106
|
+
let indexPage = pageIdx * getItemsPerPage();
|
|
107
|
+
if (indexPage >= totalSlideItem - getItemsPerPage()) {
|
|
108
|
+
indexPage = totalSlideItem - getItemsPerPage();
|
|
109
|
+
}
|
|
110
|
+
return indexPage;
|
|
111
|
+
};
|
|
112
|
+
const getAllowTouchMove = (screen)=>{
|
|
113
|
+
const value = mode === 'edit' ? {
|
|
114
|
+
[screen]: false
|
|
115
|
+
} : setting?.enableDrag;
|
|
116
|
+
return core.getResponsiveValueByScreen(value, screen);
|
|
117
|
+
};
|
|
118
|
+
const handleDotClick = (idx, isLoop)=>{
|
|
119
|
+
const index = setting?.sneakPeak?.[currentDevice] ? idx : isLoop ? idx : getIndexSlideItemBy(idx);
|
|
120
|
+
swiperInstance?.slideToLoop(index);
|
|
121
|
+
previousIndex.current = index;
|
|
122
|
+
};
|
|
123
|
+
React.useImperativeHandle(ref, ()=>({
|
|
124
|
+
nextSlideInteraction,
|
|
125
|
+
previousSlideInteraction,
|
|
126
|
+
moveToSlideInteraction
|
|
127
|
+
}));
|
|
128
|
+
const dispatchEventSelectSlide = (index)=>{
|
|
129
|
+
trigger({
|
|
130
|
+
event: 'gp:rollback:select-slide',
|
|
131
|
+
selector: `[data-id="${builderProps?.uid}"]`,
|
|
132
|
+
element: elmRef?.current
|
|
133
|
+
});
|
|
134
|
+
trigger({
|
|
135
|
+
event: 'gp:select-slide',
|
|
136
|
+
selector: `[data-id="${builderProps?.uid}"]`,
|
|
137
|
+
data: index,
|
|
138
|
+
element: elmRef?.current
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
const moveToIdxInteraction = (idx)=>{
|
|
142
|
+
swiperInstance?.slideTo(idx);
|
|
143
|
+
onHandleChangeSlideByInteraction && onHandleChangeSlideByInteraction(idx);
|
|
144
|
+
};
|
|
145
|
+
const handleDirectionalSlide = (params, direction)=>{
|
|
146
|
+
const { key, data, isRollback, element } = params;
|
|
147
|
+
const currentIndex = Math.max(swiperInstance?.activeIndex ?? 0, 0);
|
|
148
|
+
if (isRollback && data === undefined) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (isRollback) {
|
|
152
|
+
if (direction === 'specific') {
|
|
153
|
+
const { previousData } = getInteractionPreviousData(element, key);
|
|
154
|
+
moveToIdxInteraction(Number(previousData));
|
|
155
|
+
} else {
|
|
156
|
+
// For next/previous, move in opposite direction during rollback
|
|
157
|
+
const newIndex = direction === 'next' ? currentIndex - 1 : currentIndex + 1;
|
|
158
|
+
moveToIdxInteraction(newIndex);
|
|
159
|
+
}
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
// Save current state and move to new position
|
|
163
|
+
const indexToSave = direction === 'specific' ? Math.max(previousIndex.current, 0) : currentIndex;
|
|
164
|
+
saveToElementInteractionData(element, key, indexToSave.toString());
|
|
165
|
+
const targetIndex = direction === 'specific' ? Number(data) : direction === 'next' ? currentIndex + 1 : currentIndex - 1;
|
|
166
|
+
moveToIdxInteraction(targetIndex);
|
|
167
|
+
};
|
|
168
|
+
const nextSlideInteraction = (params)=>{
|
|
169
|
+
handleDirectionalSlide(params, 'next');
|
|
170
|
+
};
|
|
171
|
+
const previousSlideInteraction = (params)=>{
|
|
172
|
+
handleDirectionalSlide(params, 'previous');
|
|
173
|
+
};
|
|
174
|
+
const moveToSlideInteraction = (params)=>{
|
|
175
|
+
handleDirectionalSlide(params, 'specific');
|
|
176
|
+
};
|
|
177
|
+
const sliderSettings = {
|
|
178
|
+
speed: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
|
|
179
|
+
dir: setting?.rtl ? 'rtl' : 'ltr',
|
|
180
|
+
slidesPerView: getItemsPerPage(),
|
|
181
|
+
spaceBetween: core.getResponsiveValueByScreen(styles?.spacing, currentDevice),
|
|
182
|
+
loop: core.getResponsiveValueByScreen(loop, currentDevice, false),
|
|
183
|
+
breakpoints: {
|
|
184
|
+
0: {
|
|
185
|
+
allowTouchMove: getAllowTouchMove('mobile'),
|
|
186
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'mobile') === 'center'
|
|
187
|
+
},
|
|
188
|
+
768: {
|
|
189
|
+
allowTouchMove: getAllowTouchMove('tablet'),
|
|
190
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'tablet') === 'center'
|
|
191
|
+
},
|
|
192
|
+
1025: {
|
|
193
|
+
allowTouchMove: getAllowTouchMove('desktop'),
|
|
194
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'desktop') === 'center'
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, currentDevice) === 'center',
|
|
198
|
+
autoplay: {
|
|
199
|
+
delay: (setting?.autoplayTimeout ?? 1) * 1000,
|
|
200
|
+
pauseOnMouseEnter: setting?.pauseOnHover
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
React.useEffect(()=>{
|
|
204
|
+
const selector = `[data-id="${builderProps?.uid}"]`;
|
|
205
|
+
onListener({
|
|
206
|
+
event: 'gp:change-next-slide',
|
|
207
|
+
selector,
|
|
208
|
+
elementRef: localRef
|
|
209
|
+
}, (params)=>{
|
|
210
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
211
|
+
nextSlideInteraction({
|
|
212
|
+
element: localRef.current,
|
|
213
|
+
data,
|
|
214
|
+
isRollback,
|
|
215
|
+
key: uniqueStorageKey
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
onListener({
|
|
219
|
+
event: 'gp:change-previous-slide',
|
|
220
|
+
selector,
|
|
221
|
+
elementRef: localRef
|
|
222
|
+
}, (params)=>{
|
|
223
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
224
|
+
previousSlideInteraction({
|
|
225
|
+
element: localRef.current,
|
|
226
|
+
data,
|
|
227
|
+
isRollback,
|
|
228
|
+
key: uniqueStorageKey
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
onListener({
|
|
232
|
+
event: 'gp:change-image-step',
|
|
233
|
+
selector,
|
|
234
|
+
elementRef: localRef
|
|
235
|
+
}, (params)=>{
|
|
236
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
237
|
+
moveToSlideInteraction({
|
|
238
|
+
element: localRef.current,
|
|
239
|
+
data,
|
|
240
|
+
isRollback,
|
|
241
|
+
key: uniqueStorageKey
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
onListener({
|
|
245
|
+
event: 'gp:change-index-slide',
|
|
246
|
+
selector
|
|
247
|
+
}, (params)=>{
|
|
248
|
+
const element = document.querySelector(selector);
|
|
249
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
250
|
+
moveToSlideInteraction({
|
|
251
|
+
element,
|
|
252
|
+
data,
|
|
253
|
+
isRollback,
|
|
254
|
+
key: uniqueStorageKey
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
}, []);
|
|
258
|
+
const handleNextAndPrevSlide = (action)=>{
|
|
259
|
+
action === 'next' ? swiperInstance?.slideNext() : swiperInstance?.slidePrev();
|
|
260
|
+
if (onClickArrow) {
|
|
261
|
+
delayTimeout && clearTimeout(delayTimeout);
|
|
262
|
+
delayTimeout = setTimeout(()=>onClickArrow && onClickArrow(), 500);
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
React.useEffect(()=>{
|
|
266
|
+
if (typeof moveToIdx == 'number') {
|
|
267
|
+
previousIndex.current = moveToIdx;
|
|
268
|
+
swiperInstance?.slideTo(moveToIdx);
|
|
269
|
+
}
|
|
270
|
+
}, [
|
|
271
|
+
swiperInstance,
|
|
272
|
+
moveToIdx,
|
|
273
|
+
isHiddenArrowWhenDisabled
|
|
274
|
+
]);
|
|
275
|
+
React.useEffect(()=>{
|
|
276
|
+
if (!swiperInstance) return;
|
|
277
|
+
const updateState = ()=>{
|
|
278
|
+
const { realIndex, slides } = swiperInstance;
|
|
279
|
+
setCurrentSlide(realIndex);
|
|
280
|
+
setTotalSlideItem(slides?.length);
|
|
281
|
+
};
|
|
282
|
+
updateState();
|
|
283
|
+
swiperInstance.on('slideChange', updateState);
|
|
284
|
+
return ()=>{
|
|
285
|
+
swiperInstance?.off('slideChange', updateState);
|
|
286
|
+
};
|
|
287
|
+
}, [
|
|
288
|
+
swiperInstance
|
|
289
|
+
]);
|
|
290
|
+
React.useEffect(()=>{
|
|
291
|
+
if (swiperInstance?.wrapperEl) {
|
|
292
|
+
swiperInstance.wrapperEl.style.transitionTimingFunction = setting?.animationMode ?? 'ease';
|
|
293
|
+
}
|
|
294
|
+
}, [
|
|
295
|
+
swiperInstance,
|
|
296
|
+
setting?.animationMode
|
|
297
|
+
]);
|
|
298
|
+
React.useEffect(()=>{
|
|
299
|
+
if (!swiperInstance) return;
|
|
300
|
+
if (swiperInstance.autoplay) {
|
|
301
|
+
const shouldRunAutoplay = mode === 'edit' ? isFirstPreviewClicked ? setting?.runPreview && setting?.autoplay : false : setting?.autoplay;
|
|
302
|
+
if (shouldRunAutoplay) {
|
|
303
|
+
swiperInstance.autoplay.start();
|
|
304
|
+
} else {
|
|
305
|
+
swiperInstance.autoplay.stop();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}, [
|
|
309
|
+
swiperInstance,
|
|
310
|
+
setting?.autoplay,
|
|
311
|
+
mode,
|
|
312
|
+
isFirstPreviewClicked,
|
|
313
|
+
setting?.runPreview
|
|
314
|
+
]);
|
|
315
|
+
return {
|
|
316
|
+
isInfinity,
|
|
317
|
+
sliderSettings,
|
|
318
|
+
totalSlideItem,
|
|
319
|
+
currentSlide,
|
|
320
|
+
localRef,
|
|
321
|
+
isRenderDots,
|
|
322
|
+
showNavigation,
|
|
323
|
+
handleDotClick,
|
|
324
|
+
getItemsPerPage,
|
|
325
|
+
handleNextAndPrevSlide,
|
|
326
|
+
dispatchEventSelectSlide,
|
|
327
|
+
getNumberOfFullWidthShow
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
exports.useCarouselWithSwiper = useCarouselWithSwiper;
|
package/dist/cjs/index.js
CHANGED
|
@@ -82,7 +82,7 @@ var ArticleReadMore = require('./article/components/ArticleReadMore.js');
|
|
|
82
82
|
var HeroBanner = require('./banner/components/HeroBanner.js');
|
|
83
83
|
var Breadcrumb = require('./breadcrumb/components/Breadcrumb.js');
|
|
84
84
|
var Button = require('./button/components/Button.js');
|
|
85
|
-
var
|
|
85
|
+
var CarouselWithSwiper = require('./carousel/root/CarouselWithSwiper.js');
|
|
86
86
|
var CarouselItem = require('./carousel/carousel-item/CarouselItem.js');
|
|
87
87
|
var Cart = require('./cart/components/Cart.js');
|
|
88
88
|
var CartList = require('./cart/components/CartList.js');
|
|
@@ -422,7 +422,7 @@ exports.ArticleReadMore = ArticleReadMore.default;
|
|
|
422
422
|
exports.HeroBanner = HeroBanner.default;
|
|
423
423
|
exports.Breadcrumb = Breadcrumb.default;
|
|
424
424
|
exports.Button = Button.default;
|
|
425
|
-
exports.Carousel =
|
|
425
|
+
exports.Carousel = CarouselWithSwiper.default;
|
|
426
426
|
exports.CarouselItem = CarouselItem.default;
|
|
427
427
|
exports.Cart = Cart.default;
|
|
428
428
|
exports.CartList = CartList.default;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var React = require('react');
|
|
8
|
-
var
|
|
8
|
+
var CarouselWithSwiper = require('../../../carousel/root/CarouselWithSwiper.js');
|
|
9
9
|
var CarouselItem = require('../../../carousel/carousel-item/CarouselItem.js');
|
|
10
10
|
var core = require('@gem-sdk/core');
|
|
11
11
|
var common = require('./common/common.js');
|
|
@@ -63,7 +63,7 @@ const ProductGalleryCarousel = ({ builderPropUID, productImages, onHandleClick,
|
|
|
63
63
|
setting?.aspectRatio,
|
|
64
64
|
aspectHeight
|
|
65
65
|
]);
|
|
66
|
-
return /*#__PURE__*/ jsxRuntime.jsx(
|
|
66
|
+
return /*#__PURE__*/ jsxRuntime.jsx(CarouselWithSwiper.default, {
|
|
67
67
|
setting: {
|
|
68
68
|
loop: setting?.loop,
|
|
69
69
|
slidesToShow: slidePerShow,
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var core = require('@gem-sdk/core');
|
|
8
|
-
var
|
|
8
|
+
var CarouselWithSwiper = require('../../../carousel/root/CarouselWithSwiper.js');
|
|
9
9
|
var CarouselItem = require('../../../carousel/carousel-item/CarouselItem.js');
|
|
10
10
|
var NextImage = require('../../../image/components/NextImage.js');
|
|
11
11
|
var Modal = require('../../../modal/components/Modal.js');
|
|
@@ -43,7 +43,7 @@ const ProductImagesLightBox = ({ builderPropUID, productImages, open, imageRatio
|
|
|
43
43
|
onClose: ()=>onHandleClose(),
|
|
44
44
|
disableIframeClickEvent: true,
|
|
45
45
|
contentClass: "mobile:!gp-w-[100%] gp-px-2",
|
|
46
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(
|
|
46
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(CarouselWithSwiper.default, {
|
|
47
47
|
setting: {
|
|
48
48
|
loop: loopControl,
|
|
49
49
|
slidesToShow: {
|
package/dist/cjs/product/components/ProductImagesV2/components/child/ProductFeaturedImageCarousel.js
CHANGED
|
@@ -11,7 +11,7 @@ var getProductImagesClassName = require('../../composables/getProductImagesClass
|
|
|
11
11
|
var getProductImagesAttr = require('../../composables/getProductImagesAttr.js');
|
|
12
12
|
var system = require('@gem-sdk/system');
|
|
13
13
|
var getStyle = require('../../common/getStyle.js');
|
|
14
|
-
var
|
|
14
|
+
var CarouselWithSwiper = require('../../../../../carousel/root/CarouselWithSwiper.js');
|
|
15
15
|
var CarouselItem = require('../../../../../carousel/carousel-item/CarouselItem.js');
|
|
16
16
|
var ProductFeaturedImageOnly = require('./ProductFeaturedImageOnly.js');
|
|
17
17
|
var useProductFeaturedImageCarousel = require('../../hooks/useProductFeaturedImageCarousel.js');
|
|
@@ -36,7 +36,7 @@ const ProductFeaturedImageCarousel = (props)=>{
|
|
|
36
36
|
ref: ref,
|
|
37
37
|
"data-slot": "children",
|
|
38
38
|
className: "product-feature-image",
|
|
39
|
-
children: isRenderFeatureCarousel ? /*#__PURE__*/ jsxRuntime.jsxs(
|
|
39
|
+
children: isRenderFeatureCarousel ? /*#__PURE__*/ jsxRuntime.jsxs(CarouselWithSwiper.default, {
|
|
40
40
|
parentClass: builderPropsClass,
|
|
41
41
|
elmRef: imgRef,
|
|
42
42
|
setting: featuredImageCarouselSettingAttrs,
|
package/dist/cjs/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.js
CHANGED
|
@@ -13,7 +13,7 @@ var productFeaturedImage = require('../../common/productFeaturedImage.js');
|
|
|
13
13
|
var MediaIcon = require('../child/MediaIcon.js');
|
|
14
14
|
var ButtonOpenLightBox = require('../lightbox/ButtonOpenLightBox.js');
|
|
15
15
|
var NextImage = require('../../../../../image/components/NextImage.js');
|
|
16
|
-
var
|
|
16
|
+
var CarouselWithSwiper = require('../../../../../carousel/root/CarouselWithSwiper.js');
|
|
17
17
|
var CarouselItem = require('../../../../../carousel/carousel-item/CarouselItem.js');
|
|
18
18
|
var useGalleryCarousel = require('../../hooks/useGalleryCarousel.js');
|
|
19
19
|
var system = require('@gem-sdk/system');
|
|
@@ -27,7 +27,7 @@ const ProductGalleryCarousel = (props)=>{
|
|
|
27
27
|
const { galleryCarouselStyle, galleryCarouselItemStyle } = getProductImagesStyles.getProductImagesStyles(setting);
|
|
28
28
|
const { moveToIdx, isDisplay, shapeByLayout, isEnableBorderActive, isShowButtonLightbox, filteredProductImages, handleClickCarouselItem } = useGalleryCarousel.useGalleryCarousel(props);
|
|
29
29
|
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
30
|
-
children: isDisplay && /*#__PURE__*/ jsxRuntime.jsx(
|
|
30
|
+
children: isDisplay && /*#__PURE__*/ jsxRuntime.jsx(CarouselWithSwiper.default, {
|
|
31
31
|
parentClass: builderPropsClass,
|
|
32
32
|
rootClass: builderPropsClass,
|
|
33
33
|
setting: galleryCarouselSettingAttrs,
|