@gem-sdk/components 2.0.0-dev.728 → 2.0.0-dev.729
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/carousel/index.js +1 -1
- package/dist/cjs/carousel/root/CarouselWithSwiper.js +5 -3
- package/dist/cjs/carousel/root/CustomSwiper.js +20 -26
- package/dist/cjs/carousel/root/hook/useCarouselWithSwiper.js +36 -24
- package/dist/cjs/product/index.js +1 -1
- package/dist/esm/carousel/index.js +1 -1
- package/dist/esm/carousel/root/CarouselWithSwiper.js +6 -4
- package/dist/esm/carousel/root/CustomSwiper.js +19 -25
- package/dist/esm/carousel/root/hook/useCarouselWithSwiper.js +36 -24
- package/dist/esm/product/index.js +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ require('react/jsx-runtime');
|
|
|
4
4
|
require('@gem-sdk/core');
|
|
5
5
|
require('react');
|
|
6
6
|
require('@gem-sdk/system');
|
|
7
|
-
require('swiper/element
|
|
7
|
+
require('swiper/element');
|
|
8
8
|
require('next/link');
|
|
9
9
|
var Carousel = require('./setting/Carousel.js');
|
|
10
10
|
var CarouselItem$1 = require('./setting/CarouselItem.js');
|
|
@@ -60,6 +60,9 @@ const CarouselWithSwiper = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
60
60
|
rootId: props?.parentClass
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
|
+
const handleSliderReady = React.useCallback((swiper)=>{
|
|
64
|
+
setSwiperInstance(swiper);
|
|
65
|
+
}, []);
|
|
63
66
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
64
67
|
ref: elmRef,
|
|
65
68
|
...rootAttrRender,
|
|
@@ -80,9 +83,8 @@ const CarouselWithSwiper = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
|
80
83
|
...sliderAttr,
|
|
81
84
|
...sliderSettings,
|
|
82
85
|
sliderClass: sliderClass,
|
|
83
|
-
onSwiperReady:
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
+
onSwiperReady: handleSliderReady,
|
|
87
|
+
totalSlides: totalSlideItem,
|
|
86
88
|
children: core.isEmptyChildren(children) ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
87
89
|
children: "No Slider"
|
|
88
90
|
}) : React.Children.map(core.filterToolbarPreview(children), (child)=>{
|
|
@@ -2,48 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var
|
|
5
|
+
var element = require('swiper/element');
|
|
6
6
|
|
|
7
7
|
function Swiper(props) {
|
|
8
8
|
const swiperRef = React.useRef(null);
|
|
9
|
-
const { children, onSwiperReady, sliderClass, ...
|
|
9
|
+
const { children, totalSlides, onSwiperReady, sliderClass, ...sliderSetting } = props;
|
|
10
10
|
const pauseOnMouseEnter = typeof props.autoplay === 'object' && props.autoplay !== null ? props.autoplay.pauseOnMouseEnter : undefined;
|
|
11
11
|
React.useEffect(()=>{
|
|
12
|
-
|
|
13
|
-
Object.assign(swiperRef.current,
|
|
12
|
+
element.register();
|
|
13
|
+
Object.assign(swiperRef.current, sliderSetting);
|
|
14
14
|
swiperRef.current.initialize();
|
|
15
15
|
const instance = swiperRef.current.swiper;
|
|
16
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
|
-
]);
|
|
17
|
+
}, []);
|
|
32
18
|
React.useEffect(()=>{
|
|
33
19
|
if (swiperRef.current?.swiper) {
|
|
34
20
|
const swiperInstance = swiperRef.current.swiper;
|
|
35
21
|
swiperInstance.destroy(true, true);
|
|
36
|
-
swiperRef.current
|
|
37
|
-
swiperRef.current.centeredSlides = props.centeredSlides;
|
|
38
|
-
swiperRef.current.dir = props.dir;
|
|
22
|
+
Object.assign(swiperRef.current, sliderSetting);
|
|
39
23
|
swiperRef.current.initialize();
|
|
40
24
|
onSwiperReady?.(swiperRef.current.swiper);
|
|
41
25
|
}
|
|
42
26
|
}, [
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
sliderSetting.dir,
|
|
28
|
+
sliderSetting.loop,
|
|
29
|
+
pauseOnMouseEnter,
|
|
30
|
+
sliderSetting.slidesPerView,
|
|
31
|
+
onSwiperReady,
|
|
32
|
+
totalSlides
|
|
33
|
+
]);
|
|
34
|
+
React.useEffect(()=>{
|
|
35
|
+
const swiperInstance = swiperRef.current?.swiper;
|
|
36
|
+
if (!swiperInstance) return;
|
|
37
|
+
Object.assign(swiperInstance.params, sliderSetting);
|
|
38
|
+
swiperInstance.update();
|
|
39
|
+
}, [
|
|
40
|
+
sliderSetting
|
|
47
41
|
]);
|
|
48
42
|
return /*#__PURE__*/ jsxRuntime.jsx("swiper-container", {
|
|
49
43
|
init: false,
|
|
@@ -174,32 +174,44 @@ const useCarouselWithSwiper = (props, ref, swiperInstance)=>{
|
|
|
174
174
|
const moveToSlideInteraction = (params)=>{
|
|
175
175
|
handleDirectionalSlide(params, 'specific');
|
|
176
176
|
};
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
const slidesPerView = getItemsPerPage();
|
|
178
|
+
const sliderSettings = React.useMemo(()=>{
|
|
179
|
+
return {
|
|
180
|
+
speed: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
|
|
181
|
+
dir: setting?.rtl ? 'rtl' : 'ltr',
|
|
182
|
+
slidesPerView,
|
|
183
|
+
spaceBetween: core.getResponsiveValueByScreen(styles?.spacing, currentDevice),
|
|
184
|
+
loop: core.getResponsiveValueByScreen(loop, currentDevice, false),
|
|
185
|
+
breakpoints: {
|
|
186
|
+
0: {
|
|
187
|
+
allowTouchMove: getAllowTouchMove('mobile'),
|
|
188
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'mobile') === 'center'
|
|
189
|
+
},
|
|
190
|
+
768: {
|
|
191
|
+
allowTouchMove: getAllowTouchMove('tablet'),
|
|
192
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'tablet') === 'center'
|
|
193
|
+
},
|
|
194
|
+
1025: {
|
|
195
|
+
allowTouchMove: getAllowTouchMove('desktop'),
|
|
196
|
+
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'desktop') === 'center'
|
|
197
|
+
}
|
|
187
198
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
},
|
|
192
|
-
1025: {
|
|
193
|
-
allowTouchMove: getAllowTouchMove('desktop'),
|
|
194
|
-
centeredSlides: core.getResponsiveValueByScreen(setting?.sneakPeakType, 'desktop') === 'center'
|
|
199
|
+
autoplay: {
|
|
200
|
+
delay: (setting?.autoplayTimeout ?? 1) * 1000,
|
|
201
|
+
pauseOnMouseEnter: setting?.pauseOnHover
|
|
195
202
|
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
+
};
|
|
204
|
+
}, [
|
|
205
|
+
styles?.playSpeed,
|
|
206
|
+
setting?.rtl,
|
|
207
|
+
styles?.spacing,
|
|
208
|
+
currentDevice,
|
|
209
|
+
loop,
|
|
210
|
+
slidesPerView,
|
|
211
|
+
setting?.sneakPeakType,
|
|
212
|
+
setting?.pauseOnHover,
|
|
213
|
+
setting?.autoplayTimeout
|
|
214
|
+
]);
|
|
203
215
|
React.useEffect(()=>{
|
|
204
216
|
const selector = `[data-id="${builderProps?.uid}"]`;
|
|
205
217
|
onListener({
|
|
@@ -11,7 +11,7 @@ require('../notification/components/Notice.js');
|
|
|
11
11
|
require('./components/ProductButton/common/types.js');
|
|
12
12
|
require('./components/ProductVariants/components/variants/index.js');
|
|
13
13
|
require('next/image');
|
|
14
|
-
require('swiper/element
|
|
14
|
+
require('swiper/element');
|
|
15
15
|
require('react-dom');
|
|
16
16
|
require('../modal/components/confirm.js');
|
|
17
17
|
require('../video/components/Video.js');
|
|
@@ -2,7 +2,7 @@ import 'react/jsx-runtime';
|
|
|
2
2
|
import '@gem-sdk/core';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@gem-sdk/system';
|
|
5
|
-
import 'swiper/element
|
|
5
|
+
import 'swiper/element';
|
|
6
6
|
import 'next/link';
|
|
7
7
|
import config from './setting/Carousel.js';
|
|
8
8
|
import config$1 from './setting/CarouselItem.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import { useCurrentDevice, isEmptyChildren, filterToolbarPreview } from '@gem-sdk/core';
|
|
4
|
-
import { forwardRef, useState, Children, isValidElement } from 'react';
|
|
4
|
+
import { forwardRef, useState, useCallback, Children, isValidElement } from 'react';
|
|
5
5
|
import { mappingNavigationCarousel } from '../arrow/common/common.js';
|
|
6
6
|
import { getClass } from './common/getClass.js';
|
|
7
7
|
import { getStyle } from './common/getStyle.js';
|
|
@@ -56,6 +56,9 @@ const CarouselWithSwiper = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
56
56
|
rootId: props?.parentClass
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
|
+
const handleSliderReady = useCallback((swiper)=>{
|
|
60
|
+
setSwiperInstance(swiper);
|
|
61
|
+
}, []);
|
|
59
62
|
return /*#__PURE__*/ jsx("div", {
|
|
60
63
|
ref: elmRef,
|
|
61
64
|
...rootAttrRender,
|
|
@@ -76,9 +79,8 @@ const CarouselWithSwiper = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
|
76
79
|
...sliderAttr,
|
|
77
80
|
...sliderSettings,
|
|
78
81
|
sliderClass: sliderClass,
|
|
79
|
-
onSwiperReady:
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
+
onSwiperReady: handleSliderReady,
|
|
83
|
+
totalSlides: totalSlideItem,
|
|
82
84
|
children: isEmptyChildren(children) ? /*#__PURE__*/ jsx("div", {
|
|
83
85
|
children: "No Slider"
|
|
84
86
|
}) : Children.map(filterToolbarPreview(children), (child)=>{
|
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useRef, useEffect } from 'react';
|
|
3
|
-
import { register } from 'swiper/element
|
|
3
|
+
import { register } from 'swiper/element';
|
|
4
4
|
|
|
5
5
|
function Swiper(props) {
|
|
6
6
|
const swiperRef = useRef(null);
|
|
7
|
-
const { children, onSwiperReady, sliderClass, ...
|
|
7
|
+
const { children, totalSlides, onSwiperReady, sliderClass, ...sliderSetting } = props;
|
|
8
8
|
const pauseOnMouseEnter = typeof props.autoplay === 'object' && props.autoplay !== null ? props.autoplay.pauseOnMouseEnter : undefined;
|
|
9
9
|
useEffect(()=>{
|
|
10
10
|
register();
|
|
11
|
-
Object.assign(swiperRef.current,
|
|
11
|
+
Object.assign(swiperRef.current, sliderSetting);
|
|
12
12
|
swiperRef.current.initialize();
|
|
13
13
|
const instance = swiperRef.current.swiper;
|
|
14
14
|
onSwiperReady?.(instance);
|
|
15
|
-
}, [
|
|
16
|
-
otherProps,
|
|
17
|
-
onSwiperReady
|
|
18
|
-
]);
|
|
19
|
-
useEffect(()=>{
|
|
20
|
-
if (swiperRef.current?.swiper) {
|
|
21
|
-
const swiperInstance = swiperRef.current.swiper;
|
|
22
|
-
swiperInstance.params.spaceBetween = props.spaceBetween ?? swiperInstance.params.spaceBetween;
|
|
23
|
-
swiperInstance.params.slidesPerView = props.slidesPerView ?? swiperInstance.params.slidesPerView;
|
|
24
|
-
swiperInstance.update();
|
|
25
|
-
}
|
|
26
|
-
}, [
|
|
27
|
-
props.spaceBetween,
|
|
28
|
-
props.slidesPerView
|
|
29
|
-
]);
|
|
15
|
+
}, []);
|
|
30
16
|
useEffect(()=>{
|
|
31
17
|
if (swiperRef.current?.swiper) {
|
|
32
18
|
const swiperInstance = swiperRef.current.swiper;
|
|
33
19
|
swiperInstance.destroy(true, true);
|
|
34
|
-
swiperRef.current
|
|
35
|
-
swiperRef.current.centeredSlides = props.centeredSlides;
|
|
36
|
-
swiperRef.current.dir = props.dir;
|
|
20
|
+
Object.assign(swiperRef.current, sliderSetting);
|
|
37
21
|
swiperRef.current.initialize();
|
|
38
22
|
onSwiperReady?.(swiperRef.current.swiper);
|
|
39
23
|
}
|
|
40
24
|
}, [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
sliderSetting.dir,
|
|
26
|
+
sliderSetting.loop,
|
|
27
|
+
pauseOnMouseEnter,
|
|
28
|
+
sliderSetting.slidesPerView,
|
|
29
|
+
onSwiperReady,
|
|
30
|
+
totalSlides
|
|
31
|
+
]);
|
|
32
|
+
useEffect(()=>{
|
|
33
|
+
const swiperInstance = swiperRef.current?.swiper;
|
|
34
|
+
if (!swiperInstance) return;
|
|
35
|
+
Object.assign(swiperInstance.params, sliderSetting);
|
|
36
|
+
swiperInstance.update();
|
|
37
|
+
}, [
|
|
38
|
+
sliderSetting
|
|
45
39
|
]);
|
|
46
40
|
return /*#__PURE__*/ jsx("swiper-container", {
|
|
47
41
|
init: false,
|
|
@@ -172,32 +172,44 @@ const useCarouselWithSwiper = (props, ref, swiperInstance)=>{
|
|
|
172
172
|
const moveToSlideInteraction = (params)=>{
|
|
173
173
|
handleDirectionalSlide(params, 'specific');
|
|
174
174
|
};
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
+
}
|
|
185
196
|
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
},
|
|
190
|
-
1025: {
|
|
191
|
-
allowTouchMove: getAllowTouchMove('desktop'),
|
|
192
|
-
centeredSlides: getResponsiveValueByScreen(setting?.sneakPeakType, 'desktop') === 'center'
|
|
197
|
+
autoplay: {
|
|
198
|
+
delay: (setting?.autoplayTimeout ?? 1) * 1000,
|
|
199
|
+
pauseOnMouseEnter: setting?.pauseOnHover
|
|
193
200
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
+
]);
|
|
201
213
|
useEffect(()=>{
|
|
202
214
|
const selector = `[data-id="${builderProps?.uid}"]`;
|
|
203
215
|
onListener({
|
|
@@ -9,7 +9,7 @@ import '../notification/components/Notice.js';
|
|
|
9
9
|
import './components/ProductButton/common/types.js';
|
|
10
10
|
import './components/ProductVariants/components/variants/index.js';
|
|
11
11
|
import 'next/image';
|
|
12
|
-
import 'swiper/element
|
|
12
|
+
import 'swiper/element';
|
|
13
13
|
import 'react-dom';
|
|
14
14
|
import '../modal/components/confirm.js';
|
|
15
15
|
import '../video/components/Video.js';
|