@gem-sdk/components 2.0.0-dev.370 → 2.0.0-dev.371
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/button/setting/configs/settings.js +0 -14
- package/dist/cjs/carousel/arrow/Arrow.js +52 -0
- package/dist/cjs/carousel/arrow/Arrow.liquid.js +46 -0
- package/dist/cjs/carousel/{components/common/arrow.js → arrow/common/common.js} +13 -11
- package/dist/cjs/carousel/arrow/common/getClass.js +50 -0
- package/dist/cjs/carousel/arrow/common/getStyle.js +84 -0
- package/dist/cjs/carousel/carousel-item/CarouselItem.js +32 -0
- package/dist/cjs/carousel/carousel-item/CarouselItem.liquid.js +38 -0
- package/dist/cjs/carousel/carousel-item/common/getClass.js +29 -0
- package/dist/cjs/carousel/{components/CarouselItem.liquid.js → carousel-item/common/getStyle.js} +30 -47
- package/dist/cjs/carousel/carousel-item/hook/useCarouseItem.js +14 -0
- package/dist/cjs/carousel/components/const/index.js +5 -0
- package/dist/cjs/carousel/dots/Dots.js +51 -0
- package/dist/cjs/carousel/dots/Dots.liquid.js +26 -0
- package/dist/cjs/carousel/dots/common/common.js +46 -0
- package/dist/cjs/carousel/dots/common/getClass.js +40 -0
- package/dist/cjs/carousel/dots/common/getStyle.js +33 -0
- package/dist/cjs/carousel/dots/hook/useDotsSetting.js +21 -0
- package/dist/cjs/carousel/index.js +1 -2
- package/dist/cjs/carousel/next.js +2 -2
- package/dist/cjs/carousel/root/Carousel.js +129 -0
- package/dist/cjs/carousel/root/Carousel.liquid.js +104 -0
- package/dist/cjs/carousel/root/common/getAttr.js +25 -0
- package/dist/cjs/carousel/root/common/getClass.js +135 -0
- package/dist/cjs/carousel/root/common/getData.js +56 -0
- package/dist/cjs/carousel/root/common/getStyle.js +64 -0
- package/dist/cjs/carousel/{components/Carousel.js → root/hook/useCarousel.js} +153 -321
- package/dist/cjs/carousel/setting/Carousel.js +8 -1555
- package/dist/cjs/carousel/setting/configs/presets.js +380 -0
- package/dist/cjs/carousel/setting/configs/settingV2.js +771 -0
- package/dist/cjs/carousel/setting/configs/uiV1.js +434 -0
- package/dist/cjs/carousel/setting/configs/uiV2.js +627 -0
- package/dist/cjs/common/components/NoDataState.js +5 -5
- package/dist/cjs/grid/row/commons/common.js +3 -3
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.liquid.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/ProductImages/liquid/ProductGalleryCarousel.liquid.js +5 -3
- package/dist/cjs/product/components/ProductImagesV2/common/getAttr.js +1 -0
- package/dist/cjs/product/components/ProductImagesV2/common/productFeaturedImage.js +1 -1
- package/dist/cjs/product/components/ProductImagesV2/common/productGallery.js +1 -1
- package/dist/cjs/product/components/ProductImagesV2/components/child/ProductFeaturedImageCarousel.js +5 -5
- package/dist/cjs/product/components/ProductImagesV2/components/feature-gallery/FeatureImageWithGallery.liquid.js +8 -4
- package/dist/cjs/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.js +2 -2
- package/dist/cjs/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.liquid.js +6 -3
- package/dist/cjs/product/components/ProductImagesV2/components/lightbox/ProductImagesLightBox.js +2 -2
- package/dist/cjs/product/components/ProductImagesV2/hooks/useProductFeaturedImageCarousel.js +3 -3
- package/dist/cjs/product/components/ProductList/ProductListCarouselLayout.js +2 -2
- package/dist/cjs/product/components/ProductList/ProductListCarouselLayout.liquid.js +5 -3
- package/dist/cjs/product/components/ProductList/common/index.js +5 -5
- package/dist/cjs/product/components/ProductVariants/common/main/getAttr.js +1 -1
- package/dist/cjs/text/components/Text.js +3 -3
- package/dist/esm/builder.js +2 -2
- package/dist/esm/button/setting/configs/settings.js +0 -14
- package/dist/esm/carousel/arrow/Arrow.js +48 -0
- package/dist/esm/carousel/arrow/Arrow.liquid.js +42 -0
- package/dist/esm/carousel/{components/common/arrow.js → arrow/common/common.js} +12 -10
- package/dist/esm/carousel/arrow/common/getClass.js +48 -0
- package/dist/esm/carousel/arrow/common/getStyle.js +82 -0
- package/dist/esm/carousel/carousel-item/CarouselItem.js +28 -0
- package/dist/esm/carousel/carousel-item/CarouselItem.liquid.js +34 -0
- package/dist/esm/carousel/carousel-item/common/getClass.js +27 -0
- package/dist/esm/carousel/{components/CarouselItem.liquid.js → carousel-item/common/getStyle.js} +31 -46
- package/dist/esm/carousel/carousel-item/hook/useCarouseItem.js +12 -0
- package/dist/esm/carousel/components/const/index.js +3 -0
- package/dist/esm/carousel/dots/Dots.js +47 -0
- package/dist/esm/carousel/dots/Dots.liquid.js +22 -0
- package/dist/esm/carousel/dots/common/common.js +43 -0
- package/dist/esm/carousel/dots/common/getClass.js +38 -0
- package/dist/esm/carousel/dots/common/getStyle.js +31 -0
- package/dist/esm/carousel/dots/hook/useDotsSetting.js +19 -0
- package/dist/esm/carousel/index.js +1 -2
- package/dist/esm/carousel/next.js +2 -2
- package/dist/esm/carousel/root/Carousel.js +125 -0
- package/dist/esm/carousel/root/Carousel.liquid.js +100 -0
- package/dist/esm/carousel/root/common/getAttr.js +23 -0
- package/dist/esm/carousel/root/common/getClass.js +133 -0
- package/dist/esm/carousel/root/common/getData.js +54 -0
- package/dist/esm/carousel/root/common/getStyle.js +62 -0
- package/dist/esm/carousel/{components/Carousel.js → root/hook/useCarousel.js} +150 -316
- package/dist/esm/carousel/setting/Carousel.js +8 -1555
- package/dist/esm/carousel/setting/configs/presets.js +378 -0
- package/dist/esm/carousel/setting/configs/settingV2.js +769 -0
- package/dist/esm/carousel/setting/configs/uiV1.js +432 -0
- package/dist/esm/carousel/setting/configs/uiV2.js +625 -0
- package/dist/esm/common/components/NoDataState.js +6 -6
- package/dist/esm/grid/row/commons/common.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.liquid.js +2 -2
- 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/ProductImages/liquid/ProductGalleryCarousel.liquid.js +5 -3
- package/dist/esm/product/components/ProductImagesV2/common/getAttr.js +1 -0
- package/dist/esm/product/components/ProductImagesV2/common/productFeaturedImage.js +1 -1
- package/dist/esm/product/components/ProductImagesV2/common/productGallery.js +1 -1
- package/dist/esm/product/components/ProductImagesV2/components/child/ProductFeaturedImageCarousel.js +5 -5
- package/dist/esm/product/components/ProductImagesV2/components/feature-gallery/FeatureImageWithGallery.liquid.js +8 -4
- package/dist/esm/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.js +2 -2
- package/dist/esm/product/components/ProductImagesV2/components/gallery-carousel/GalleryCarousel.liquid.js +6 -3
- package/dist/esm/product/components/ProductImagesV2/components/lightbox/ProductImagesLightBox.js +2 -2
- package/dist/esm/product/components/ProductImagesV2/hooks/useProductFeaturedImageCarousel.js +3 -3
- package/dist/esm/product/components/ProductList/ProductListCarouselLayout.js +2 -2
- package/dist/esm/product/components/ProductList/ProductListCarouselLayout.liquid.js +5 -3
- package/dist/esm/product/components/ProductList/common/index.js +3 -3
- package/dist/esm/product/components/ProductVariants/common/main/getAttr.js +1 -1
- package/dist/esm/text/components/Text.js +4 -4
- package/dist/types/index.d.ts +164 -67
- package/package.json +3 -3
- package/dist/cjs/carousel/components/Arrow.js +0 -110
- package/dist/cjs/carousel/components/Arrow.liquid.js +0 -103
- package/dist/cjs/carousel/components/Carousel.liquid.js +0 -256
- package/dist/cjs/carousel/components/CarouselItem.js +0 -88
- package/dist/cjs/carousel/components/Dots.js +0 -69
- package/dist/cjs/carousel/components/Dots.liquid.js +0 -23
- package/dist/cjs/carousel/components/common/dots.js +0 -57
- package/dist/esm/carousel/components/Arrow.js +0 -106
- package/dist/esm/carousel/components/Arrow.liquid.js +0 -99
- package/dist/esm/carousel/components/Carousel.liquid.js +0 -252
- package/dist/esm/carousel/components/CarouselItem.js +0 -84
- package/dist/esm/carousel/components/Dots.js +0 -65
- package/dist/esm/carousel/components/Dots.liquid.js +0 -19
- package/dist/esm/carousel/components/common/dots.js +0 -53
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
|
|
5
|
+
const getData = (props)=>{
|
|
6
|
+
const { hiddenWhenOnlyOne } = props;
|
|
7
|
+
const getDotItems = (isLoop)=>{
|
|
8
|
+
const { enabledSneakPeak, totalSlideItem = 0, numberOfFullWidthShow = 0, slideItemsPerPage = 0 } = props;
|
|
9
|
+
if (enabledSneakPeak) {
|
|
10
|
+
return Array.from({
|
|
11
|
+
length: isLoop ? totalSlideItem : totalSlideItem - numberOfFullWidthShow + 1
|
|
12
|
+
}, (_, i)=>i);
|
|
13
|
+
} else {
|
|
14
|
+
return Array.from({
|
|
15
|
+
length: isLoop ? totalSlideItem : Math.ceil(totalSlideItem / slideItemsPerPage)
|
|
16
|
+
}, (_, i)=>i);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const checkHidden = (totalDots)=>{
|
|
20
|
+
return hiddenWhenOnlyOne && totalDots?.length < 2;
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
checkHidden,
|
|
24
|
+
getDotItems
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const getUpdatedDotStyle = (dot, dotStyle)=>{
|
|
28
|
+
const devices = [
|
|
29
|
+
'desktop',
|
|
30
|
+
'tablet',
|
|
31
|
+
'mobile'
|
|
32
|
+
];
|
|
33
|
+
let result = {};
|
|
34
|
+
devices.forEach((device)=>{
|
|
35
|
+
const dotSetting = core.getResponsiveValueByScreen(dot, device);
|
|
36
|
+
const dotStyleSetting = core.getResponsiveValueByScreen(dotStyle, device);
|
|
37
|
+
result = {
|
|
38
|
+
...result,
|
|
39
|
+
[device]: dotSetting ? dotStyleSetting : 'none'
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.getData = getData;
|
|
46
|
+
exports.getUpdatedDotStyle = getUpdatedDotStyle;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var system = require('@gem-sdk/system');
|
|
5
|
+
var index = require('../../components/const/index.js');
|
|
6
|
+
|
|
7
|
+
const getDotClass = (props)=>{
|
|
8
|
+
const { dotStyle, vertical, className, uniqueComponentId } = props;
|
|
9
|
+
const getDisplayClass = ()=>{
|
|
10
|
+
const devices = [
|
|
11
|
+
'desktop',
|
|
12
|
+
'tablet',
|
|
13
|
+
'mobile'
|
|
14
|
+
];
|
|
15
|
+
const result = {};
|
|
16
|
+
devices.forEach((device)=>{
|
|
17
|
+
const dotStyleSetting = core.getResponsiveValueByScreen(dotStyle, device);
|
|
18
|
+
const verticalSetting = core.getResponsiveValueByScreen(vertical, device);
|
|
19
|
+
const deviceType = device === 'desktop' ? '' : `${device}:`;
|
|
20
|
+
result[`${deviceType}gp-absolute`] = dotStyleSetting === 'inside';
|
|
21
|
+
result[`${deviceType}gp-static`] = dotStyleSetting !== 'inside';
|
|
22
|
+
result[`${deviceType}gp-flex-row ${deviceType}gp-left-0 ${deviceType}gp-right-0`] = !verticalSetting;
|
|
23
|
+
result[`${deviceType}gp-flex-col ${deviceType}gp-ml-2 ${deviceType}gp-w-fit ${deviceType}gp-h-full`] = !!verticalSetting;
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
const dotClass = system.createClass({
|
|
28
|
+
[`${index.DOT_CONTAINER_SELECTOR} ${index.DOT_CONTAINER_SELECTOR}-${uniqueComponentId}`]: true,
|
|
29
|
+
['gp-z-2 gp-flex gp-flex-1 gp-items-center gp-justify-center gp-gap-2 gp-text-center']: true,
|
|
30
|
+
...className && {
|
|
31
|
+
[className]: true
|
|
32
|
+
},
|
|
33
|
+
...getDisplayClass()
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
dotClass
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
exports.getDotClass = getDotClass;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var system = require('@gem-sdk/system');
|
|
4
|
+
var core = require('@gem-sdk/core');
|
|
5
|
+
|
|
6
|
+
const getDotStyle = (props, componentType)=>{
|
|
7
|
+
const { dotStyle: style, dotGapToCarousel, vertical } = props;
|
|
8
|
+
const isReactComp = componentType === 'react';
|
|
9
|
+
const getStyleDisplayDots = ()=>{
|
|
10
|
+
const devices = [
|
|
11
|
+
'desktop',
|
|
12
|
+
'tablet',
|
|
13
|
+
'mobile'
|
|
14
|
+
];
|
|
15
|
+
const result = {};
|
|
16
|
+
devices.forEach((device)=>{
|
|
17
|
+
const dotStyleSetting = core.getResponsiveValueByScreen(style, device);
|
|
18
|
+
const deviceType = device === 'desktop' ? '' : `${device}`;
|
|
19
|
+
result[`d${deviceType.length === 0 ? '' : '-' + deviceType}`] = dotStyleSetting && dotStyleSetting !== 'none' ? 'flex' : 'none';
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
const dotStyleObj = {
|
|
24
|
+
...core.makeDotGapToCarouselStyle(style, dotGapToCarousel, vertical),
|
|
25
|
+
...getStyleDisplayDots()
|
|
26
|
+
};
|
|
27
|
+
const dotStyle = isReactComp ? system.createStyleReact(dotStyleObj) : system.createStyle(dotStyleObj);
|
|
28
|
+
return {
|
|
29
|
+
dotStyle
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.getDotStyle = getDotStyle;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
|
|
5
|
+
const useDotsSetting = (props)=>{
|
|
6
|
+
const { loop, enabledSneakPeak, slideItemsPerPage = 1, currentSlide = 1 } = props;
|
|
7
|
+
const currentDevice = core.useCurrentDevice();
|
|
8
|
+
const isLoop = core.getResponsiveValueByScreen(loop, currentDevice, false);
|
|
9
|
+
const checkIsActive = (idx)=>{
|
|
10
|
+
if (enabledSneakPeak) {
|
|
11
|
+
return idx === currentSlide;
|
|
12
|
+
}
|
|
13
|
+
return idx === (isLoop ? currentSlide : Math.ceil(currentSlide / slideItemsPerPage));
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
isLoop,
|
|
17
|
+
checkIsActive
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.useDotsSetting = useDotsSetting;
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
require('react/jsx-runtime');
|
|
4
4
|
require('@gem-sdk/core');
|
|
5
5
|
require('react');
|
|
6
|
-
require('@gem-sdk/keen-slider/react');
|
|
7
6
|
require('@gem-sdk/system');
|
|
7
|
+
require('@gem-sdk/keen-slider/react');
|
|
8
8
|
require('next/link');
|
|
9
|
-
require('../product/components/ProductVariants/components/variants/index.js');
|
|
10
9
|
var Carousel$1 = require('./setting/Carousel.js');
|
|
11
10
|
var CarouselItem$1 = require('./setting/CarouselItem.js');
|
|
12
11
|
|
|
@@ -8,10 +8,10 @@ require('react/jsx-runtime');
|
|
|
8
8
|
require('react');
|
|
9
9
|
require('@gem-sdk/core');
|
|
10
10
|
|
|
11
|
-
const Carousel = dynamic(()=>Promise.resolve().then(function () { return require('./
|
|
11
|
+
const Carousel = dynamic(()=>Promise.resolve().then(function () { return require('./root/Carousel.js'); }), {
|
|
12
12
|
loading: Loading.default
|
|
13
13
|
});
|
|
14
|
-
const CarouselItem = dynamic(()=>Promise.resolve().then(function () { return require('./
|
|
14
|
+
const CarouselItem = dynamic(()=>Promise.resolve().then(function () { return require('./carousel-item/CarouselItem.js'); }), {
|
|
15
15
|
loading: Loading.default
|
|
16
16
|
});
|
|
17
17
|
var carousel = {
|
|
@@ -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 Dots = require('../dots/Dots.js');
|
|
10
|
+
var Arrow = require('../arrow/Arrow.js');
|
|
11
|
+
var common = require('../arrow/common/common.js');
|
|
12
|
+
var useCarousel = require('./hook/useCarousel.js');
|
|
13
|
+
var getClass = require('./common/getClass.js');
|
|
14
|
+
var getStyle = require('./common/getStyle.js');
|
|
15
|
+
var getAttr = require('./common/getAttr.js');
|
|
16
|
+
var getData = require('./common/getData.js');
|
|
17
|
+
|
|
18
|
+
const Carousel = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
19
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, elmRef } = props;
|
|
20
|
+
const setting = common.mappingNavigationCarousel(props.setting);
|
|
21
|
+
const renderData = {
|
|
22
|
+
...props,
|
|
23
|
+
setting
|
|
24
|
+
};
|
|
25
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
26
|
+
const { totalSlideItem, isInfinity, slider, currentSlide, localRef, showNavigation, isRenderDots, handleDotClick, getItemsPerPage, sliderRef, handleNextAndPrevSlide, dispatchEventSelectSlide, getNumberOfFullWidthShow } = useCarousel.useCarousel(renderData, ref);
|
|
27
|
+
const { loopConfig, arrowShowConfig } = getData.getData(renderData);
|
|
28
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass.getClass(renderData);
|
|
29
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle, sliderStyle } = getStyle.getStyle(renderData);
|
|
30
|
+
const { rootAttrRender, sliderAttr } = getAttr.getAttr(renderData);
|
|
31
|
+
const currentDevice = core.useCurrentDevice();
|
|
32
|
+
const enabledSneakPeak = setting?.sneakPeak?.[currentDevice];
|
|
33
|
+
const renderArrow = (position)=>{
|
|
34
|
+
const isNext = position === 'next';
|
|
35
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Arrow.default, {
|
|
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: !isInfinity && slider?.track?.details?.abs === 0,
|
|
54
|
+
vertical: setting?.vertical,
|
|
55
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
56
|
+
rootId: props?.parentClass
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const renderChildren = ()=>{
|
|
60
|
+
return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
61
|
+
children: core.isEmptyChildren(children) ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
62
|
+
children: "No Slider"
|
|
63
|
+
}) : React.Children.map(core.filterToolbarPreview(children), (child, index)=>{
|
|
64
|
+
if (/*#__PURE__*/ React.isValidElement(child)) {
|
|
65
|
+
return /*#__PURE__*/ jsxRuntime.jsx(child.type, {
|
|
66
|
+
...child.props,
|
|
67
|
+
index: index,
|
|
68
|
+
parentSettings: setting,
|
|
69
|
+
parentStyle: styles,
|
|
70
|
+
background: setting?.background,
|
|
71
|
+
parentUid: builderProps?.uid,
|
|
72
|
+
dispatchEventSelectSlide: dispatchEventSelectSlide
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
80
|
+
ref: elmRef,
|
|
81
|
+
...rootAttrRender,
|
|
82
|
+
className: rootClassRender,
|
|
83
|
+
style: rootStyleRender,
|
|
84
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
85
|
+
ref: localRef,
|
|
86
|
+
...builderAttrs,
|
|
87
|
+
className: wrapperClassRender,
|
|
88
|
+
style: wrapperStyleRender,
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
91
|
+
className: wrapperInnerClass,
|
|
92
|
+
style: wrapperInnerStyle,
|
|
93
|
+
children: [
|
|
94
|
+
showNavigation && renderArrow('prev'),
|
|
95
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
96
|
+
ref: sliderRef,
|
|
97
|
+
...sliderAttr,
|
|
98
|
+
className: sliderClass,
|
|
99
|
+
style: sliderStyle,
|
|
100
|
+
children: renderChildren()
|
|
101
|
+
}),
|
|
102
|
+
showNavigation && renderArrow('next')
|
|
103
|
+
]
|
|
104
|
+
}),
|
|
105
|
+
isRenderDots && /*#__PURE__*/ jsxRuntime.jsx(Dots.default, {
|
|
106
|
+
showDots: setting?.dot,
|
|
107
|
+
dotStyle: setting?.dotStyle,
|
|
108
|
+
totalSlideItem: totalSlideItem,
|
|
109
|
+
slideItemsPerPage: getItemsPerPage(),
|
|
110
|
+
currentSlide: currentSlide,
|
|
111
|
+
enabledSneakPeak: enabledSneakPeak,
|
|
112
|
+
vertical: setting?.vertical,
|
|
113
|
+
loop: loopConfig,
|
|
114
|
+
dotColor: setting?.dotColor,
|
|
115
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
116
|
+
dotSize: setting?.dotSize,
|
|
117
|
+
dotActiveColor: setting?.dotActiveColor,
|
|
118
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne,
|
|
119
|
+
sneakPeakType: setting?.sneakPeakType,
|
|
120
|
+
numberOfFullWidthShow: getNumberOfFullWidthShow(currentDevice),
|
|
121
|
+
onHandleClick: handleDotClick
|
|
122
|
+
}),
|
|
123
|
+
core.filterToolbarPreview(children, true)
|
|
124
|
+
]
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
exports.default = Carousel;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@gem-sdk/core');
|
|
6
|
+
var Arrow_liquid = require('../arrow/Arrow.liquid.js');
|
|
7
|
+
var helpers = require('../../helpers.js');
|
|
8
|
+
var Dots_liquid = require('../dots/Dots.liquid.js');
|
|
9
|
+
var common = require('../arrow/common/common.js');
|
|
10
|
+
var getData = require('./common/getData.js');
|
|
11
|
+
var getClass = require('./common/getClass.js');
|
|
12
|
+
var getStyle = require('./common/getStyle.js');
|
|
13
|
+
var getAttr = require('./common/getAttr.js');
|
|
14
|
+
|
|
15
|
+
const Carousel = (props)=>{
|
|
16
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, rootId, rawChildren, conditionAppendJs } = props;
|
|
17
|
+
const setting = common.mappingNavigationCarousel(props.setting);
|
|
18
|
+
const renderData = {
|
|
19
|
+
...props,
|
|
20
|
+
setting
|
|
21
|
+
};
|
|
22
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
23
|
+
const { uniqueComponentId, loopConfig, arrowShowConfig, stateData } = getData.getData(renderData);
|
|
24
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass.getClass(renderData);
|
|
25
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle, sliderStyle } = getStyle.getStyle(renderData);
|
|
26
|
+
const { rootAttrRender, sliderAttr } = getAttr.getAttr(renderData);
|
|
27
|
+
const renderJS = ()=>{
|
|
28
|
+
return core.RenderIf(core.isLocalEnv, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-carousel-v2.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-carousel-v2.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);
|
|
29
|
+
};
|
|
30
|
+
const renderArrow = (position)=>{
|
|
31
|
+
const isNext = position === 'next';
|
|
32
|
+
return Arrow_liquid.default({
|
|
33
|
+
uid: builderProps?.uid,
|
|
34
|
+
componentId: uniqueComponentId,
|
|
35
|
+
custom: setting?.arrowCustom ?? '',
|
|
36
|
+
showArrow: arrowShowConfig,
|
|
37
|
+
arrowButtonSize: arrowButtonSize || {},
|
|
38
|
+
arrowIconSize: arrowIconSize || {},
|
|
39
|
+
arrowBackgroundColor: arrowBackgroundColor ?? '',
|
|
40
|
+
arrowCustomColor: arrowCustomColor,
|
|
41
|
+
gapToEachSize: arrowGapToEachSide,
|
|
42
|
+
showWhenHover: showWhenHover,
|
|
43
|
+
arrowBorder: arrowBorder || {},
|
|
44
|
+
arrowCorner: roundedArrow || {},
|
|
45
|
+
arrowShadow: arrowShadow || {},
|
|
46
|
+
left: !isNext,
|
|
47
|
+
onClick: (e)=>{
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
},
|
|
50
|
+
vertical: setting?.vertical,
|
|
51
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
52
|
+
rootId: rootId
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const renderChildren = ()=>{
|
|
56
|
+
return core.template`
|
|
57
|
+
${rawChildren?.length ? core.WrapRenderChildren({
|
|
58
|
+
uid: builderProps?.uid ?? '',
|
|
59
|
+
customProps: rawChildren[0]?.customProps
|
|
60
|
+
}, rawChildren.map((child, index)=>{
|
|
61
|
+
if (child) {
|
|
62
|
+
return core.template`${core.RenderChildren({
|
|
63
|
+
...child,
|
|
64
|
+
index,
|
|
65
|
+
parentSettings: setting,
|
|
66
|
+
parentStyle: styles,
|
|
67
|
+
background: setting?.background,
|
|
68
|
+
parentUid: builderProps?.uid
|
|
69
|
+
})}`;
|
|
70
|
+
}
|
|
71
|
+
})) : children ?? `<div>${helpers.getStaticLocale('Carousel', 'no_slider')}</div>`}`;
|
|
72
|
+
};
|
|
73
|
+
return core.template /* liquid */ `
|
|
74
|
+
<gp-carousel gp-data='${stateData}' ${rootAttrRender} style="${rootStyleRender}" class="${rootClassRender}">
|
|
75
|
+
<div
|
|
76
|
+
${builderAttrs}
|
|
77
|
+
class="${wrapperClassRender}"
|
|
78
|
+
style="${wrapperStyleRender}"
|
|
79
|
+
>
|
|
80
|
+
<div class="${wrapperInnerClass}" style="${wrapperInnerStyle}">
|
|
81
|
+
${renderArrow('prev')}
|
|
82
|
+
<div ${sliderAttr} class="${sliderClass}" style="${sliderStyle}">
|
|
83
|
+
${renderChildren()}
|
|
84
|
+
</div>
|
|
85
|
+
${renderArrow('next')}
|
|
86
|
+
</div>
|
|
87
|
+
${Dots_liquid.default({
|
|
88
|
+
loop: loopConfig,
|
|
89
|
+
showDots: setting?.dot,
|
|
90
|
+
dotStyle: setting?.dotStyle,
|
|
91
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
92
|
+
dotSize: setting?.dotSize,
|
|
93
|
+
vertical: setting?.vertical,
|
|
94
|
+
uniqueComponentId: uniqueComponentId,
|
|
95
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne
|
|
96
|
+
})}
|
|
97
|
+
</div>
|
|
98
|
+
</gp-carousel>
|
|
99
|
+
${conditionAppendJs ? `{% if ${conditionAppendJs} %} ${renderJS()} {% endif %}` : renderJS()}
|
|
100
|
+
|
|
101
|
+
`;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
exports.default = Carousel;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var system = require('@gem-sdk/system');
|
|
4
|
+
var getData = require('./getData.js');
|
|
5
|
+
|
|
6
|
+
const getAttr = (props)=>{
|
|
7
|
+
const { rootAttrs, builderProps, rootId } = props;
|
|
8
|
+
const { uniqueComponentId } = getData.getData(props);
|
|
9
|
+
const rootAttrRender = system.createAttr({
|
|
10
|
+
'data-id': `${builderProps?.uid}`,
|
|
11
|
+
id: `gp-root-carousel-${uniqueComponentId}`,
|
|
12
|
+
...rootAttrs
|
|
13
|
+
});
|
|
14
|
+
const sliderAttr = system.createAttr({
|
|
15
|
+
...(builderProps?.uid || rootId) && {
|
|
16
|
+
id: `gp-carousel-${uniqueComponentId}`
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
rootAttrRender,
|
|
21
|
+
sliderAttr
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.getAttr = getAttr;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var system = require('@gem-sdk/system');
|
|
5
|
+
var getData = require('./getData.js');
|
|
6
|
+
|
|
7
|
+
const getClass = (props)=>{
|
|
8
|
+
const DEVICES = [
|
|
9
|
+
'mobile',
|
|
10
|
+
'tablet',
|
|
11
|
+
'desktop'
|
|
12
|
+
];
|
|
13
|
+
const { setting, builderProps, wrapperClass, rootClass, advanced, fullHeight, slidesClass } = props;
|
|
14
|
+
const { sliderSelector } = getData.getData(props);
|
|
15
|
+
const getDisplayOfWrapper = ()=>{
|
|
16
|
+
let result = {};
|
|
17
|
+
DEVICES.forEach((device)=>{
|
|
18
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
19
|
+
result = {
|
|
20
|
+
...result,
|
|
21
|
+
[`${devicePrefix}gp-flex`]: setting?.vertical?.[device],
|
|
22
|
+
[`${devicePrefix}gp-block`]: !setting?.vertical?.[device]
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
const getWrapperInnerHeight = ()=>{
|
|
28
|
+
let result = {};
|
|
29
|
+
DEVICES.forEach((device)=>{
|
|
30
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
31
|
+
result = {
|
|
32
|
+
...result,
|
|
33
|
+
[`${devicePrefix}gp-h-full`]: setting?.vertical?.[device],
|
|
34
|
+
[`${devicePrefix}gp-flex-1`]: setting?.vertical?.[device]
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
const makeFlexColClass = ()=>{
|
|
40
|
+
let result = {};
|
|
41
|
+
DEVICES.forEach((device)=>{
|
|
42
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
43
|
+
result = {
|
|
44
|
+
...result,
|
|
45
|
+
[`${devicePrefix}!gp-flex-col`]: setting?.vertical?.[device],
|
|
46
|
+
[`${devicePrefix}!gp-flex-row`]: !setting?.vertical?.[device]
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
const makeVerticalWrapClass = ()=>{
|
|
52
|
+
let result = {};
|
|
53
|
+
DEVICES.forEach((device)=>{
|
|
54
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
55
|
+
if (setting?.vertical?.[device]) {
|
|
56
|
+
result = {
|
|
57
|
+
...result,
|
|
58
|
+
[`${devicePrefix}!gp-flex-wrap`]: setting?.vertical?.[device]
|
|
59
|
+
};
|
|
60
|
+
} else {
|
|
61
|
+
result = {
|
|
62
|
+
...result,
|
|
63
|
+
[`${devicePrefix}!gp-flex-nowrap`]: !setting?.vertical?.[device]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return result;
|
|
68
|
+
};
|
|
69
|
+
const makeVerticalMinHeightClass = ()=>{
|
|
70
|
+
let result = {};
|
|
71
|
+
DEVICES.forEach((device)=>{
|
|
72
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
73
|
+
if (setting?.vertical?.[device]) {
|
|
74
|
+
result = {
|
|
75
|
+
...result,
|
|
76
|
+
[`${devicePrefix}!gp-min-h-0`]: setting?.vertical?.[device]
|
|
77
|
+
};
|
|
78
|
+
} else {
|
|
79
|
+
result = {
|
|
80
|
+
...result,
|
|
81
|
+
[`${devicePrefix}!gp-min-h-full`]: !setting?.vertical?.[device]
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
87
|
+
const wrapperClassRender = system.createClass({
|
|
88
|
+
...builderProps?.uid && {
|
|
89
|
+
[builderProps.uid]: true
|
|
90
|
+
},
|
|
91
|
+
...wrapperClass && {
|
|
92
|
+
[wrapperClass]: true
|
|
93
|
+
},
|
|
94
|
+
'gp-relative gp-my-0 tablet:gp-px-0 gp-max-w-full mobile:gp-px-0 gp-carousel-wrapper': true,
|
|
95
|
+
'!gp-flex': core.getResponsiveValueByScreen(setting?.vertical, 'desktop'),
|
|
96
|
+
'tablet:!gp-flex': core.getResponsiveValueByScreen(setting?.vertical, 'tablet'),
|
|
97
|
+
'mobile:!gp-flex': core.getResponsiveValueByScreen(setting?.vertical, 'mobile'),
|
|
98
|
+
...getDisplayOfWrapper()
|
|
99
|
+
});
|
|
100
|
+
const wrapperInnerClass = system.createClass({
|
|
101
|
+
'gp-relative gp-flex gp-items-center gp-justify-between': true,
|
|
102
|
+
'!gp-h-full': fullHeight,
|
|
103
|
+
...getWrapperInnerHeight(),
|
|
104
|
+
...makeFlexColClass()
|
|
105
|
+
});
|
|
106
|
+
const rootClassRender = system.createClass({
|
|
107
|
+
'gp-group/carousel gp-w-full gp-flex': true,
|
|
108
|
+
'!gp-flex-col': core.getResponsiveValueByScreen(setting?.vertical, 'desktop'),
|
|
109
|
+
'tablet:!flex-col': core.getResponsiveValueByScreen(setting?.vertical, 'tablet'),
|
|
110
|
+
'mobile:!flex-col': core.getResponsiveValueByScreen(setting?.vertical, 'mobile'),
|
|
111
|
+
...rootClass && {
|
|
112
|
+
[rootClass]: true
|
|
113
|
+
},
|
|
114
|
+
...advanced?.cssClass && {
|
|
115
|
+
[advanced.cssClass]: true
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const sliderClass = system.createClass({
|
|
119
|
+
'gem-slider gp-h-full gp-overflow-hidden gp-select-none': true,
|
|
120
|
+
[sliderSelector]: true,
|
|
121
|
+
...slidesClass && {
|
|
122
|
+
[slidesClass]: true
|
|
123
|
+
},
|
|
124
|
+
...makeVerticalWrapClass(),
|
|
125
|
+
...makeVerticalMinHeightClass()
|
|
126
|
+
});
|
|
127
|
+
return {
|
|
128
|
+
rootClassRender,
|
|
129
|
+
wrapperClassRender,
|
|
130
|
+
wrapperInnerClass,
|
|
131
|
+
sliderClass
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
exports.getClass = getClass;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var system = require('@gem-sdk/system');
|
|
5
|
+
|
|
6
|
+
const getData = (props)=>{
|
|
7
|
+
const DEVICES = [
|
|
8
|
+
'mobile',
|
|
9
|
+
'tablet',
|
|
10
|
+
'desktop'
|
|
11
|
+
];
|
|
12
|
+
const { setting, rootId, builderProps, styles, moveToIdx, isHiddenArrowWhenDisabled } = props;
|
|
13
|
+
const uniqueComponentId = rootId ?? builderProps?.uid;
|
|
14
|
+
const sliderSelector = `gp-carousel-slider-${builderProps?.uid}`;
|
|
15
|
+
const { enableAction = {
|
|
16
|
+
desktop: true
|
|
17
|
+
}, navigationStyle, navigationEnable = {
|
|
18
|
+
desktop: true
|
|
19
|
+
} } = setting ?? {};
|
|
20
|
+
const getLoopSetting = ()=>{
|
|
21
|
+
let result = setting?.loop;
|
|
22
|
+
DEVICES.forEach((device)=>{
|
|
23
|
+
result = {
|
|
24
|
+
...result,
|
|
25
|
+
[device]: core.getResponsiveValueByScreen(enableAction) ? result?.[device] : false
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
const getArrowType = ()=>{
|
|
31
|
+
let result = navigationStyle;
|
|
32
|
+
DEVICES.forEach((device)=>{
|
|
33
|
+
result = {
|
|
34
|
+
...result,
|
|
35
|
+
[device]: core.getResponsiveValueByScreen(navigationEnable, device) ? result?.[device] : 'none'
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
const stateData = system.createStateOrContext({
|
|
41
|
+
id: uniqueComponentId,
|
|
42
|
+
setting,
|
|
43
|
+
styles,
|
|
44
|
+
moveToIdx,
|
|
45
|
+
isHiddenArrowWhenDisabled
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
loopConfig: getLoopSetting(),
|
|
49
|
+
stateData: core.dataStringify(stateData).replaceAll("'", '''),
|
|
50
|
+
uniqueComponentId,
|
|
51
|
+
arrowShowConfig: getArrowType(),
|
|
52
|
+
sliderSelector
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.getData = getData;
|