@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,82 @@
|
|
|
1
|
+
import { createStyleReact, createStyle } from '@gem-sdk/system';
|
|
2
|
+
import { getResponsiveStyleShadowWithoutState, getPaddingGlobalSize, makeGlobalSizeWidthResponsive, makeGlobalSizeHeightResponsive, makeStyleResponsive, makeStyle, composeCornerCss, composeBorderCss } from '@gem-sdk/core';
|
|
3
|
+
import { getArrowDisplayStyle, getArrowPositionStyle, getResponsiveSetting } from './common.js';
|
|
4
|
+
|
|
5
|
+
const getStyle = (props, type = 'liquid')=>{
|
|
6
|
+
const { uid, vertical, showArrow, gapToEachSize, left, arrowBackgroundColor, arrowButtonSize, rootId, arrowBorder, arrowCorner, arrowCustomColor, arrowIconSize, arrowShadow } = props;
|
|
7
|
+
const arrowShadowStyle = getResponsiveStyleShadowWithoutState(arrowShadow, 'box-shadow', arrowShadow);
|
|
8
|
+
const arrowBorderStyle = getResponsiveSetting(arrowBorder || {});
|
|
9
|
+
const arrowCornerStyle = getResponsiveSetting(arrowCorner || {});
|
|
10
|
+
const buttonPadding = getPaddingGlobalSize(arrowButtonSize);
|
|
11
|
+
const iconSizeResponsive = getResponsiveSetting(arrowIconSize || {});
|
|
12
|
+
const arrowType = getResponsiveSetting(showArrow || {});
|
|
13
|
+
const buttonWidth = makeGlobalSizeWidthResponsive(arrowButtonSize);
|
|
14
|
+
const buttonHeight = makeGlobalSizeHeightResponsive(arrowButtonSize);
|
|
15
|
+
const iconWidth = makeStyleResponsive('w', iconSizeResponsive, 'px');
|
|
16
|
+
const iconHeight = makeStyleResponsive('h', iconSizeResponsive, 'px');
|
|
17
|
+
const display = makeStyleResponsive('d', getArrowDisplayStyle(arrowType));
|
|
18
|
+
const position = makeStyle(getArrowPositionStyle({
|
|
19
|
+
vertical,
|
|
20
|
+
arrowType,
|
|
21
|
+
gapToEachSize: gapToEachSize ?? '',
|
|
22
|
+
left: Boolean(left)
|
|
23
|
+
}));
|
|
24
|
+
const buttonStyleObj = {
|
|
25
|
+
'background-color': arrowBackgroundColor ?? '',
|
|
26
|
+
...display,
|
|
27
|
+
...position,
|
|
28
|
+
...buttonWidth,
|
|
29
|
+
...buttonHeight,
|
|
30
|
+
...buttonPadding,
|
|
31
|
+
...arrowShadowStyle
|
|
32
|
+
};
|
|
33
|
+
const buttonContentStyleObj = {
|
|
34
|
+
...makeStyle({
|
|
35
|
+
c: arrowCustomColor
|
|
36
|
+
}),
|
|
37
|
+
...iconWidth,
|
|
38
|
+
...iconHeight
|
|
39
|
+
};
|
|
40
|
+
const buttonStyle = type === 'react' ? createStyleReact(buttonStyleObj) : createStyle(buttonStyleObj);
|
|
41
|
+
const buttonContentStyle = type === 'react' ? createStyleReact(buttonContentStyleObj) : createStyle(buttonContentStyleObj);
|
|
42
|
+
const innerBorderCss = `
|
|
43
|
+
${rootId ? '.' + rootId : ''}.gp-carousel-arrow-${uid} {
|
|
44
|
+
${composeCornerCss(arrowCornerStyle.desktop)}
|
|
45
|
+
}
|
|
46
|
+
${rootId ? '.' + rootId : ''}.gp-carousel-arrow-${uid}::before {
|
|
47
|
+
content: '';
|
|
48
|
+
height: 100%;
|
|
49
|
+
width: 100%;
|
|
50
|
+
position: absolute;
|
|
51
|
+
pointer-events: none;
|
|
52
|
+
z-index: 10;
|
|
53
|
+
${composeBorderCss(arrowBorderStyle.desktop)}
|
|
54
|
+
${composeCornerCss(arrowCornerStyle.desktop)}
|
|
55
|
+
}
|
|
56
|
+
@media only screen and (max-width: 1024px) and (min-width: 768px) {
|
|
57
|
+
${rootId ? '.' + rootId : ''}.gp-carousel-arrow-${uid} {
|
|
58
|
+
${composeCornerCss(arrowCornerStyle.tablet)}
|
|
59
|
+
}
|
|
60
|
+
${rootId ? '.' + rootId : ''}.gp-carousel-arrow-${uid}::before {
|
|
61
|
+
${composeBorderCss(arrowBorderStyle.tablet)}
|
|
62
|
+
${composeCornerCss(arrowCornerStyle.tablet)}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
@media only screen and (max-width: 768px) {
|
|
66
|
+
${rootId ? '.' + rootId : ''}.gp-carousel-arrow-${uid} {
|
|
67
|
+
${composeCornerCss(arrowCornerStyle.mobile)}
|
|
68
|
+
}
|
|
69
|
+
${rootId ? '.' + rootId : ''}.gp-carousel-arrow-${uid}::before {
|
|
70
|
+
${composeBorderCss(arrowBorderStyle.mobile)}
|
|
71
|
+
${composeCornerCss(arrowCornerStyle.mobile)}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
`;
|
|
75
|
+
return {
|
|
76
|
+
buttonStyle,
|
|
77
|
+
buttonContentStyle,
|
|
78
|
+
innerBorderCss
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { getStyle };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { isEmptyChildren } from '@gem-sdk/core';
|
|
4
|
+
import ChildrenDroppable from '../../grid/components/ChildrenDroppable.js';
|
|
5
|
+
import { getStyle } from './common/getStyle.js';
|
|
6
|
+
import { getClass } from './common/getClass.js';
|
|
7
|
+
import { useCarouselItem } from './hook/useCarouseItem.js';
|
|
8
|
+
|
|
9
|
+
const CarouselItem = (props)=>{
|
|
10
|
+
const { children, builderAttrs } = props;
|
|
11
|
+
const { handleClick } = useCarouselItem(props);
|
|
12
|
+
const { carouselItemStyle, carouselItemInnerStyle } = getStyle(props);
|
|
13
|
+
const { carouselItemClass, carouselItemInnerClass } = getClass(props);
|
|
14
|
+
return /*#__PURE__*/ jsx("div", {
|
|
15
|
+
...builderAttrs,
|
|
16
|
+
className: carouselItemClass,
|
|
17
|
+
style: carouselItemStyle,
|
|
18
|
+
onClick: handleClick,
|
|
19
|
+
"aria-hidden": true,
|
|
20
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
21
|
+
className: carouselItemInnerClass,
|
|
22
|
+
style: carouselItemInnerStyle,
|
|
23
|
+
children: isEmptyChildren(children) ? /*#__PURE__*/ jsx(ChildrenDroppable, {}) : children
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { CarouselItem as default };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { template } from '@gem-sdk/core';
|
|
2
|
+
import { getStyle } from './common/getStyle.js';
|
|
3
|
+
import { getClass } from './common/getClass.js';
|
|
4
|
+
|
|
5
|
+
const CarouselItem = (props)=>{
|
|
6
|
+
const { builderAttrs, index, children } = props;
|
|
7
|
+
const { carouselItemStyle, carouselItemInnerStyle } = getStyle(props);
|
|
8
|
+
const { carouselItemClass, carouselItemInnerClass } = getClass(props);
|
|
9
|
+
return template`
|
|
10
|
+
<div
|
|
11
|
+
${{
|
|
12
|
+
...builderAttrs
|
|
13
|
+
}}
|
|
14
|
+
class="${carouselItemClass}"
|
|
15
|
+
style="${carouselItemStyle}"
|
|
16
|
+
data-index="${index}"
|
|
17
|
+
grid-index="{{forloop.index}}"
|
|
18
|
+
external-id="{{media.external_id}}"
|
|
19
|
+
media-type="{{media.media_type}}"
|
|
20
|
+
media-poster="{{media.preview_image.src}}"
|
|
21
|
+
media-source-url="{{media.sources.first.url}}"
|
|
22
|
+
media-last-source-url="{{mediaSourceUrl}}"
|
|
23
|
+
>
|
|
24
|
+
<div
|
|
25
|
+
class="${carouselItemInnerClass}"
|
|
26
|
+
style="${carouselItemInnerStyle}"
|
|
27
|
+
>
|
|
28
|
+
${children}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { CarouselItem as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createClass } from '@gem-sdk/system';
|
|
2
|
+
|
|
3
|
+
const getClass = (props)=>{
|
|
4
|
+
const { parentId, parentUid, builderProps, className } = props;
|
|
5
|
+
const carouselItemClass = createClass({
|
|
6
|
+
[`gem-slider-item gp-w-full`]: true,
|
|
7
|
+
[`gem-slider-item-${parentId || parentUid}`]: true,
|
|
8
|
+
...parentUid && {
|
|
9
|
+
[`gp-child-item-${parentUid}`]: true
|
|
10
|
+
},
|
|
11
|
+
...builderProps?.uid && {
|
|
12
|
+
[builderProps?.uid]: true
|
|
13
|
+
},
|
|
14
|
+
...className && {
|
|
15
|
+
[className]: true
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const carouselItemInnerClass = createClass({
|
|
19
|
+
'gp-h-full gp-w-full': true
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
carouselItemClass,
|
|
23
|
+
carouselItemInnerClass
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { getClass };
|
package/dist/esm/carousel/{components/CarouselItem.liquid.js → carousel-item/common/getStyle.js}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { makeGlobalSize,
|
|
2
|
-
import { getInitialWidthForCarouselItem, getCarouselSneakPeakTranslate } from '
|
|
1
|
+
import { makeGlobalSize, getStyleBackgroundByDevice, getGradientBgrStyleByDevice, makeStyleResponsive, getStyleShadow, makeStyle, getSingleColorVariable, getRadiusStyleActiveState } from '@gem-sdk/core';
|
|
2
|
+
import { getInitialWidthForCarouselItem, getCarouselSneakPeakTranslate } from '../../components/common/carousel.js';
|
|
3
|
+
import { createStyle } from '@gem-sdk/system';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const getStyle = (props)=>{
|
|
6
|
+
const { style, contentType, parentStyle, parentSettings, background, customStyle, index } = props;
|
|
5
7
|
const itemPadding = makeGlobalSize(parentStyle?.itemPadding);
|
|
6
8
|
const styleByContentType = ()=>{
|
|
7
9
|
const delList = [
|
|
@@ -27,32 +29,9 @@ const CarouselItem = ({ children, builderAttrs, styles, advanced, setting, build
|
|
|
27
29
|
})
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
|
-
const
|
|
31
|
-
value: parentStyle?.carouselShadow,
|
|
32
|
-
styleAppliedFor: 'box-shadow',
|
|
33
|
-
isEnableShadow: parentStyle?.hasActiveShadow
|
|
34
|
-
});
|
|
35
|
-
return template`
|
|
36
|
-
<div
|
|
37
|
-
media-type="{{media.media_type}}"
|
|
38
|
-
media-poster="{{media.preview_image.src}}"
|
|
39
|
-
media-source-url="{{media.sources.first.url}}"
|
|
40
|
-
media-last-source-url="{{mediaSourceUrl}}"
|
|
41
|
-
external-id="{{media.external_id}}"
|
|
42
|
-
grid-index="{{forloop.index}}"
|
|
43
|
-
${{
|
|
44
|
-
...builderAttrs
|
|
45
|
-
}}
|
|
46
|
-
${{
|
|
47
|
-
...passProps
|
|
48
|
-
}}
|
|
49
|
-
style="${{
|
|
32
|
+
const getCarouselItemStyle = {
|
|
50
33
|
...customStyle,
|
|
51
|
-
...
|
|
52
|
-
ignoreBackgroundImage: true,
|
|
53
|
-
ignoreBackgroundImageProperties: true,
|
|
54
|
-
ignoreBgAttachment: true
|
|
55
|
-
}),
|
|
34
|
+
...itemPadding && itemPadding.padding,
|
|
56
35
|
...getInitialWidthForCarouselItem({
|
|
57
36
|
spacing: parentStyle?.spacing,
|
|
58
37
|
slidesToShow: parentSettings?.itemNumber ?? parentSettings?.slidesToShow,
|
|
@@ -62,7 +41,12 @@ const CarouselItem = ({ children, builderAttrs, styles, advanced, setting, build
|
|
|
62
41
|
sneakPeakOffsetForward: parentSettings?.sneakPeakOffsetForward,
|
|
63
42
|
vertical: parentSettings?.vertical
|
|
64
43
|
}),
|
|
65
|
-
...
|
|
44
|
+
...getStyleBackgroundByDevice(background),
|
|
45
|
+
...getGradientBgrStyleByDevice(background, {
|
|
46
|
+
desktop: true,
|
|
47
|
+
tablet: true,
|
|
48
|
+
mobile: true
|
|
49
|
+
}),
|
|
66
50
|
...makeStyleResponsive('ml', getCarouselSneakPeakTranslate({
|
|
67
51
|
index,
|
|
68
52
|
spacing: parentStyle?.spacing,
|
|
@@ -71,22 +55,23 @@ const CarouselItem = ({ children, builderAttrs, styles, advanced, setting, build
|
|
|
71
55
|
sneakPeakType: parentSettings?.sneakPeakType,
|
|
72
56
|
sneakPeakOffsetCenter: parentSettings?.sneakPeakOffsetCenter,
|
|
73
57
|
sneakPeakOffsetForward: parentSettings?.sneakPeakOffsetForward
|
|
74
|
-
}))
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
58
|
+
}))
|
|
59
|
+
};
|
|
60
|
+
const carouselItemInnerStyle = createStyle({
|
|
61
|
+
...getStyleShadow({
|
|
62
|
+
value: parentStyle?.carouselShadow,
|
|
63
|
+
styleAppliedFor: 'box-shadow',
|
|
64
|
+
isEnableShadow: parentStyle?.hasActiveShadow
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
const carouselItemStyle = createStyle({
|
|
68
|
+
...getCarouselItemStyle,
|
|
69
|
+
...styleByContentType()
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
carouselItemStyle,
|
|
73
|
+
carouselItemInnerStyle
|
|
74
|
+
};
|
|
90
75
|
};
|
|
91
76
|
|
|
92
|
-
export {
|
|
77
|
+
export { getStyle };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const useCarouselItem = (props)=>{
|
|
2
|
+
const { onClickItem, dispatchEventSelectSlide, index = 0 } = props;
|
|
3
|
+
const handleClick = (e)=>{
|
|
4
|
+
onClickItem && onClickItem(e);
|
|
5
|
+
dispatchEventSelectSlide && dispatchEventSelectSlide(index);
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
handleClick
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { useCarouselItem };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { makeStyleResponsiveByScreen, getGlobalColorResponsiveStyle, cls } from '@gem-sdk/core';
|
|
4
|
+
import { getData } from './common/common.js';
|
|
5
|
+
import { getDotClass } from './common/getClass.js';
|
|
6
|
+
import { getDotStyle } from './common/getStyle.js';
|
|
7
|
+
import { useDotsSetting } from './hook/useDotsSetting.js';
|
|
8
|
+
import { If } from '@gem-sdk/system';
|
|
9
|
+
|
|
10
|
+
const Dots = (props)=>{
|
|
11
|
+
const { onHandleClick, dotSize, dotActiveColor, dotColor } = props;
|
|
12
|
+
const { isLoop, checkIsActive } = useDotsSetting(props);
|
|
13
|
+
const { checkHidden, getDotItems } = getData(props);
|
|
14
|
+
const dotItems = getDotItems(isLoop);
|
|
15
|
+
const { dotClass } = getDotClass(props);
|
|
16
|
+
const { dotStyle } = getDotStyle(props, 'react');
|
|
17
|
+
const renderDotItems = ()=>{
|
|
18
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
19
|
+
children: dotItems?.map((idx)=>{
|
|
20
|
+
const isActive = checkIsActive(idx);
|
|
21
|
+
return /*#__PURE__*/ jsx("button", {
|
|
22
|
+
"aria-label": "Dot",
|
|
23
|
+
onClick: ()=>{
|
|
24
|
+
onHandleClick && onHandleClick(idx, isLoop);
|
|
25
|
+
},
|
|
26
|
+
style: {
|
|
27
|
+
...makeStyleResponsiveByScreen('w', dotSize, 'px'),
|
|
28
|
+
...isActive ? getGlobalColorResponsiveStyle('bg', dotActiveColor) : getGlobalColorResponsiveStyle('bg', dotColor)
|
|
29
|
+
},
|
|
30
|
+
className: cls('gp-aspect-square gp-w-3 gp-rounded-full gp-shadow-md', {
|
|
31
|
+
'gem-slider-dot-active': isActive,
|
|
32
|
+
'gem-slider-dot-inactive': !isActive
|
|
33
|
+
})
|
|
34
|
+
}, idx);
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
39
|
+
children: If(!checkHidden(dotItems), /*#__PURE__*/ jsx("div", {
|
|
40
|
+
className: dotClass,
|
|
41
|
+
style: dotStyle,
|
|
42
|
+
children: renderDotItems()
|
|
43
|
+
}))
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { Dots as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen, template } from '@gem-sdk/core';
|
|
2
|
+
import { getDotClass } from './common/getClass.js';
|
|
3
|
+
import { getDotStyle } from './common/getStyle.js';
|
|
4
|
+
import { If } from '@gem-sdk/system';
|
|
5
|
+
import { getData } from './common/common.js';
|
|
6
|
+
|
|
7
|
+
const Dots = (props)=>{
|
|
8
|
+
const isLoop = getResponsiveValueByScreen(props.loop, 'desktop', false);
|
|
9
|
+
const { checkHidden, getDotItems } = getData(props);
|
|
10
|
+
const dotItems = getDotItems(isLoop);
|
|
11
|
+
const { dotClass } = getDotClass(props);
|
|
12
|
+
const { dotStyle } = getDotStyle(props);
|
|
13
|
+
return template`
|
|
14
|
+
${If(!checkHidden(dotItems), template`
|
|
15
|
+
<div class="${dotClass}" style="${dotStyle}">
|
|
16
|
+
<!-- item render by js -->
|
|
17
|
+
</div>
|
|
18
|
+
`)}
|
|
19
|
+
`;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { Dots as default };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
|
|
3
|
+
const getData = (props)=>{
|
|
4
|
+
const { hiddenWhenOnlyOne } = props;
|
|
5
|
+
const getDotItems = (isLoop)=>{
|
|
6
|
+
const { enabledSneakPeak, totalSlideItem = 0, numberOfFullWidthShow = 0, slideItemsPerPage = 0 } = props;
|
|
7
|
+
if (enabledSneakPeak) {
|
|
8
|
+
return Array.from({
|
|
9
|
+
length: isLoop ? totalSlideItem : totalSlideItem - numberOfFullWidthShow + 1
|
|
10
|
+
}, (_, i)=>i);
|
|
11
|
+
} else {
|
|
12
|
+
return Array.from({
|
|
13
|
+
length: isLoop ? totalSlideItem : Math.ceil(totalSlideItem / slideItemsPerPage)
|
|
14
|
+
}, (_, i)=>i);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const checkHidden = (totalDots)=>{
|
|
18
|
+
return hiddenWhenOnlyOne && totalDots?.length < 2;
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
checkHidden,
|
|
22
|
+
getDotItems
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const getUpdatedDotStyle = (dot, dotStyle)=>{
|
|
26
|
+
const devices = [
|
|
27
|
+
'desktop',
|
|
28
|
+
'tablet',
|
|
29
|
+
'mobile'
|
|
30
|
+
];
|
|
31
|
+
let result = {};
|
|
32
|
+
devices.forEach((device)=>{
|
|
33
|
+
const dotSetting = getResponsiveValueByScreen(dot, device);
|
|
34
|
+
const dotStyleSetting = getResponsiveValueByScreen(dotStyle, device);
|
|
35
|
+
result = {
|
|
36
|
+
...result,
|
|
37
|
+
[device]: dotSetting ? dotStyleSetting : 'none'
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { getData, getUpdatedDotStyle };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { createClass } from '@gem-sdk/system';
|
|
3
|
+
import { DOT_CONTAINER_SELECTOR } from '../../components/const/index.js';
|
|
4
|
+
|
|
5
|
+
const getDotClass = (props)=>{
|
|
6
|
+
const { dotStyle, vertical, className, uniqueComponentId } = props;
|
|
7
|
+
const getDisplayClass = ()=>{
|
|
8
|
+
const devices = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'tablet',
|
|
11
|
+
'mobile'
|
|
12
|
+
];
|
|
13
|
+
const result = {};
|
|
14
|
+
devices.forEach((device)=>{
|
|
15
|
+
const dotStyleSetting = getResponsiveValueByScreen(dotStyle, device);
|
|
16
|
+
const verticalSetting = getResponsiveValueByScreen(vertical, device);
|
|
17
|
+
const deviceType = device === 'desktop' ? '' : `${device}:`;
|
|
18
|
+
result[`${deviceType}gp-absolute`] = dotStyleSetting === 'inside';
|
|
19
|
+
result[`${deviceType}gp-static`] = dotStyleSetting !== 'inside';
|
|
20
|
+
result[`${deviceType}gp-flex-row ${deviceType}gp-left-0 ${deviceType}gp-right-0`] = !verticalSetting;
|
|
21
|
+
result[`${deviceType}gp-flex-col ${deviceType}gp-ml-2 ${deviceType}gp-w-fit ${deviceType}gp-h-full`] = !!verticalSetting;
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
const dotClass = createClass({
|
|
26
|
+
[`${DOT_CONTAINER_SELECTOR} ${DOT_CONTAINER_SELECTOR}-${uniqueComponentId}`]: true,
|
|
27
|
+
['gp-z-2 gp-flex gp-flex-1 gp-items-center gp-justify-center gp-gap-2 gp-text-center']: true,
|
|
28
|
+
...className && {
|
|
29
|
+
[className]: true
|
|
30
|
+
},
|
|
31
|
+
...getDisplayClass()
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
dotClass
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { getDotClass };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createStyleReact, createStyle } from '@gem-sdk/system';
|
|
2
|
+
import { makeDotGapToCarouselStyle, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
3
|
+
|
|
4
|
+
const getDotStyle = (props, componentType)=>{
|
|
5
|
+
const { dotStyle: style, dotGapToCarousel, vertical } = props;
|
|
6
|
+
const isReactComp = componentType === 'react';
|
|
7
|
+
const getStyleDisplayDots = ()=>{
|
|
8
|
+
const devices = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'tablet',
|
|
11
|
+
'mobile'
|
|
12
|
+
];
|
|
13
|
+
const result = {};
|
|
14
|
+
devices.forEach((device)=>{
|
|
15
|
+
const dotStyleSetting = getResponsiveValueByScreen(style, device);
|
|
16
|
+
const deviceType = device === 'desktop' ? '' : `${device}`;
|
|
17
|
+
result[`d${deviceType.length === 0 ? '' : '-' + deviceType}`] = dotStyleSetting && dotStyleSetting !== 'none' ? 'flex' : 'none';
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
const dotStyleObj = {
|
|
22
|
+
...makeDotGapToCarouselStyle(style, dotGapToCarousel, vertical),
|
|
23
|
+
...getStyleDisplayDots()
|
|
24
|
+
};
|
|
25
|
+
const dotStyle = isReactComp ? createStyleReact(dotStyleObj) : createStyle(dotStyleObj);
|
|
26
|
+
return {
|
|
27
|
+
dotStyle
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { getDotStyle };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCurrentDevice, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
|
|
3
|
+
const useDotsSetting = (props)=>{
|
|
4
|
+
const { loop, enabledSneakPeak, slideItemsPerPage = 1, currentSlide = 1 } = props;
|
|
5
|
+
const currentDevice = useCurrentDevice();
|
|
6
|
+
const isLoop = getResponsiveValueByScreen(loop, currentDevice, false);
|
|
7
|
+
const checkIsActive = (idx)=>{
|
|
8
|
+
if (enabledSneakPeak) {
|
|
9
|
+
return idx === currentSlide;
|
|
10
|
+
}
|
|
11
|
+
return idx === (isLoop ? currentSlide : Math.ceil(currentSlide / slideItemsPerPage));
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
isLoop,
|
|
15
|
+
checkIsActive
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useDotsSetting };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import 'react/jsx-runtime';
|
|
2
2
|
import '@gem-sdk/core';
|
|
3
3
|
import 'react';
|
|
4
|
-
import '@gem-sdk/keen-slider/react';
|
|
5
4
|
import '@gem-sdk/system';
|
|
5
|
+
import '@gem-sdk/keen-slider/react';
|
|
6
6
|
import 'next/link';
|
|
7
|
-
import '../product/components/ProductVariants/components/variants/index.js';
|
|
8
7
|
import config from './setting/Carousel.js';
|
|
9
8
|
import config$1 from './setting/CarouselItem.js';
|
|
10
9
|
|
|
@@ -4,10 +4,10 @@ import 'react/jsx-runtime';
|
|
|
4
4
|
import 'react';
|
|
5
5
|
import '@gem-sdk/core';
|
|
6
6
|
|
|
7
|
-
const Carousel = dynamic(()=>import('./
|
|
7
|
+
const Carousel = dynamic(()=>import('./root/Carousel.js'), {
|
|
8
8
|
loading: Loading
|
|
9
9
|
});
|
|
10
|
-
const CarouselItem = dynamic(()=>import('./
|
|
10
|
+
const CarouselItem = dynamic(()=>import('./carousel-item/CarouselItem.js'), {
|
|
11
11
|
loading: Loading
|
|
12
12
|
});
|
|
13
13
|
var carousel = {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useCurrentDevice, filterToolbarPreview, isEmptyChildren } from '@gem-sdk/core';
|
|
4
|
+
import { forwardRef, Children, isValidElement } from 'react';
|
|
5
|
+
import Dots from '../dots/Dots.js';
|
|
6
|
+
import Arrow from '../arrow/Arrow.js';
|
|
7
|
+
import { mappingNavigationCarousel } from '../arrow/common/common.js';
|
|
8
|
+
import { useCarousel } from './hook/useCarousel.js';
|
|
9
|
+
import { getClass } from './common/getClass.js';
|
|
10
|
+
import { getStyle } from './common/getStyle.js';
|
|
11
|
+
import { getAttr } from './common/getAttr.js';
|
|
12
|
+
import { getData } from './common/getData.js';
|
|
13
|
+
|
|
14
|
+
const Carousel = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
15
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, elmRef } = props;
|
|
16
|
+
const setting = mappingNavigationCarousel(props.setting);
|
|
17
|
+
const renderData = {
|
|
18
|
+
...props,
|
|
19
|
+
setting
|
|
20
|
+
};
|
|
21
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
22
|
+
const { totalSlideItem, isInfinity, slider, currentSlide, localRef, showNavigation, isRenderDots, handleDotClick, getItemsPerPage, sliderRef, handleNextAndPrevSlide, dispatchEventSelectSlide, getNumberOfFullWidthShow } = useCarousel(renderData, ref);
|
|
23
|
+
const { loopConfig, arrowShowConfig } = getData(renderData);
|
|
24
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass(renderData);
|
|
25
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle, sliderStyle } = getStyle(renderData);
|
|
26
|
+
const { rootAttrRender, sliderAttr } = getAttr(renderData);
|
|
27
|
+
const currentDevice = useCurrentDevice();
|
|
28
|
+
const enabledSneakPeak = setting?.sneakPeak?.[currentDevice];
|
|
29
|
+
const renderArrow = (position)=>{
|
|
30
|
+
const isNext = position === 'next';
|
|
31
|
+
return /*#__PURE__*/ jsx(Arrow, {
|
|
32
|
+
uid: builderProps?.uid,
|
|
33
|
+
custom: setting?.arrowCustom ?? '',
|
|
34
|
+
showArrow: arrowShowConfig,
|
|
35
|
+
arrowButtonSize: arrowButtonSize || {},
|
|
36
|
+
arrowIconSize: arrowIconSize || {},
|
|
37
|
+
arrowBackgroundColor: arrowBackgroundColor || '',
|
|
38
|
+
arrowCustomColor: arrowCustomColor,
|
|
39
|
+
gapToEachSize: arrowGapToEachSide,
|
|
40
|
+
showWhenHover: showWhenHover,
|
|
41
|
+
arrowBorder: arrowBorder || {},
|
|
42
|
+
arrowCorner: roundedArrow || {},
|
|
43
|
+
arrowShadow: arrowShadow || {},
|
|
44
|
+
onClick: (e)=>{
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
handleNextAndPrevSlide(position);
|
|
47
|
+
},
|
|
48
|
+
left: !isNext,
|
|
49
|
+
disabled: !isInfinity && slider?.track?.details?.abs === 0,
|
|
50
|
+
vertical: setting?.vertical,
|
|
51
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
52
|
+
rootId: props?.parentClass
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const renderChildren = ()=>{
|
|
56
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
57
|
+
children: isEmptyChildren(children) ? /*#__PURE__*/ jsx("div", {
|
|
58
|
+
children: "No Slider"
|
|
59
|
+
}) : Children.map(filterToolbarPreview(children), (child, index)=>{
|
|
60
|
+
if (/*#__PURE__*/ isValidElement(child)) {
|
|
61
|
+
return /*#__PURE__*/ jsx(child.type, {
|
|
62
|
+
...child.props,
|
|
63
|
+
index: index,
|
|
64
|
+
parentSettings: setting,
|
|
65
|
+
parentStyle: styles,
|
|
66
|
+
background: setting?.background,
|
|
67
|
+
parentUid: builderProps?.uid,
|
|
68
|
+
dispatchEventSelectSlide: dispatchEventSelectSlide
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return /*#__PURE__*/ jsx("div", {
|
|
76
|
+
ref: elmRef,
|
|
77
|
+
...rootAttrRender,
|
|
78
|
+
className: rootClassRender,
|
|
79
|
+
style: rootStyleRender,
|
|
80
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
81
|
+
ref: localRef,
|
|
82
|
+
...builderAttrs,
|
|
83
|
+
className: wrapperClassRender,
|
|
84
|
+
style: wrapperStyleRender,
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsxs("div", {
|
|
87
|
+
className: wrapperInnerClass,
|
|
88
|
+
style: wrapperInnerStyle,
|
|
89
|
+
children: [
|
|
90
|
+
showNavigation && renderArrow('prev'),
|
|
91
|
+
/*#__PURE__*/ jsx("div", {
|
|
92
|
+
ref: sliderRef,
|
|
93
|
+
...sliderAttr,
|
|
94
|
+
className: sliderClass,
|
|
95
|
+
style: sliderStyle,
|
|
96
|
+
children: renderChildren()
|
|
97
|
+
}),
|
|
98
|
+
showNavigation && renderArrow('next')
|
|
99
|
+
]
|
|
100
|
+
}),
|
|
101
|
+
isRenderDots && /*#__PURE__*/ jsx(Dots, {
|
|
102
|
+
showDots: setting?.dot,
|
|
103
|
+
dotStyle: setting?.dotStyle,
|
|
104
|
+
totalSlideItem: totalSlideItem,
|
|
105
|
+
slideItemsPerPage: getItemsPerPage(),
|
|
106
|
+
currentSlide: currentSlide,
|
|
107
|
+
enabledSneakPeak: enabledSneakPeak,
|
|
108
|
+
vertical: setting?.vertical,
|
|
109
|
+
loop: loopConfig,
|
|
110
|
+
dotColor: setting?.dotColor,
|
|
111
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
112
|
+
dotSize: setting?.dotSize,
|
|
113
|
+
dotActiveColor: setting?.dotActiveColor,
|
|
114
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne,
|
|
115
|
+
sneakPeakType: setting?.sneakPeakType,
|
|
116
|
+
numberOfFullWidthShow: getNumberOfFullWidthShow(currentDevice),
|
|
117
|
+
onHandleClick: handleDotClick
|
|
118
|
+
}),
|
|
119
|
+
filterToolbarPreview(children, true)
|
|
120
|
+
]
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export { Carousel as default };
|