@gem-sdk/components 2.0.0-dev.742 → 2.0.0-dev.745

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