@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,100 @@
|
|
|
1
|
+
import { template, RenderIf, isLocalEnv, baseAssetURL, WrapRenderChildren, RenderChildren } from '@gem-sdk/core';
|
|
2
|
+
import Arrow from '../arrow/Arrow.liquid.js';
|
|
3
|
+
import { getSettingPreloadData, getStaticLocale } from '../../helpers.js';
|
|
4
|
+
import Dots from '../dots/Dots.liquid.js';
|
|
5
|
+
import { mappingNavigationCarousel } from '../arrow/common/common.js';
|
|
6
|
+
import { getData } from './common/getData.js';
|
|
7
|
+
import { getClass } from './common/getClass.js';
|
|
8
|
+
import { getStyle } from './common/getStyle.js';
|
|
9
|
+
import { getAttr } from './common/getAttr.js';
|
|
10
|
+
|
|
11
|
+
const Carousel = (props)=>{
|
|
12
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, rootId, rawChildren, conditionAppendJs } = props;
|
|
13
|
+
const setting = mappingNavigationCarousel(props.setting);
|
|
14
|
+
const renderData = {
|
|
15
|
+
...props,
|
|
16
|
+
setting
|
|
17
|
+
};
|
|
18
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
19
|
+
const { uniqueComponentId, loopConfig, arrowShowConfig, stateData } = getData(renderData);
|
|
20
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass(renderData);
|
|
21
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle, sliderStyle } = getStyle(renderData);
|
|
22
|
+
const { rootAttrRender, sliderAttr } = getAttr(renderData);
|
|
23
|
+
const renderJS = ()=>{
|
|
24
|
+
return RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-carousel-v2.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-carousel-v2.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);
|
|
25
|
+
};
|
|
26
|
+
const renderArrow = (position)=>{
|
|
27
|
+
const isNext = position === 'next';
|
|
28
|
+
return Arrow({
|
|
29
|
+
uid: builderProps?.uid,
|
|
30
|
+
componentId: uniqueComponentId,
|
|
31
|
+
custom: setting?.arrowCustom ?? '',
|
|
32
|
+
showArrow: arrowShowConfig,
|
|
33
|
+
arrowButtonSize: arrowButtonSize || {},
|
|
34
|
+
arrowIconSize: arrowIconSize || {},
|
|
35
|
+
arrowBackgroundColor: arrowBackgroundColor ?? '',
|
|
36
|
+
arrowCustomColor: arrowCustomColor,
|
|
37
|
+
gapToEachSize: arrowGapToEachSide,
|
|
38
|
+
showWhenHover: showWhenHover,
|
|
39
|
+
arrowBorder: arrowBorder || {},
|
|
40
|
+
arrowCorner: roundedArrow || {},
|
|
41
|
+
arrowShadow: arrowShadow || {},
|
|
42
|
+
left: !isNext,
|
|
43
|
+
onClick: (e)=>{
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
},
|
|
46
|
+
vertical: setting?.vertical,
|
|
47
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
48
|
+
rootId: rootId
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const renderChildren = ()=>{
|
|
52
|
+
return template`
|
|
53
|
+
${rawChildren?.length ? WrapRenderChildren({
|
|
54
|
+
uid: builderProps?.uid ?? '',
|
|
55
|
+
customProps: rawChildren[0]?.customProps
|
|
56
|
+
}, rawChildren.map((child, index)=>{
|
|
57
|
+
if (child) {
|
|
58
|
+
return template`${RenderChildren({
|
|
59
|
+
...child,
|
|
60
|
+
index,
|
|
61
|
+
parentSettings: setting,
|
|
62
|
+
parentStyle: styles,
|
|
63
|
+
background: setting?.background,
|
|
64
|
+
parentUid: builderProps?.uid
|
|
65
|
+
})}`;
|
|
66
|
+
}
|
|
67
|
+
})) : children ?? `<div>${getStaticLocale('Carousel', 'no_slider')}</div>`}`;
|
|
68
|
+
};
|
|
69
|
+
return template /* liquid */ `
|
|
70
|
+
<gp-carousel gp-data='${stateData}' ${rootAttrRender} style="${rootStyleRender}" class="${rootClassRender}">
|
|
71
|
+
<div
|
|
72
|
+
${builderAttrs}
|
|
73
|
+
class="${wrapperClassRender}"
|
|
74
|
+
style="${wrapperStyleRender}"
|
|
75
|
+
>
|
|
76
|
+
<div class="${wrapperInnerClass}" style="${wrapperInnerStyle}">
|
|
77
|
+
${renderArrow('prev')}
|
|
78
|
+
<div ${sliderAttr} class="${sliderClass}" style="${sliderStyle}">
|
|
79
|
+
${renderChildren()}
|
|
80
|
+
</div>
|
|
81
|
+
${renderArrow('next')}
|
|
82
|
+
</div>
|
|
83
|
+
${Dots({
|
|
84
|
+
loop: loopConfig,
|
|
85
|
+
showDots: setting?.dot,
|
|
86
|
+
dotStyle: setting?.dotStyle,
|
|
87
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
88
|
+
dotSize: setting?.dotSize,
|
|
89
|
+
vertical: setting?.vertical,
|
|
90
|
+
uniqueComponentId: uniqueComponentId,
|
|
91
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne
|
|
92
|
+
})}
|
|
93
|
+
</div>
|
|
94
|
+
</gp-carousel>
|
|
95
|
+
${conditionAppendJs ? `{% if ${conditionAppendJs} %} ${renderJS()} {% endif %}` : renderJS()}
|
|
96
|
+
|
|
97
|
+
`;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { Carousel as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createAttr } from '@gem-sdk/system';
|
|
2
|
+
import { getData } from './getData.js';
|
|
3
|
+
|
|
4
|
+
const getAttr = (props)=>{
|
|
5
|
+
const { rootAttrs, builderProps, rootId } = props;
|
|
6
|
+
const { uniqueComponentId } = getData(props);
|
|
7
|
+
const rootAttrRender = createAttr({
|
|
8
|
+
'data-id': `${builderProps?.uid}`,
|
|
9
|
+
id: `gp-root-carousel-${uniqueComponentId}`,
|
|
10
|
+
...rootAttrs
|
|
11
|
+
});
|
|
12
|
+
const sliderAttr = createAttr({
|
|
13
|
+
...(builderProps?.uid || rootId) && {
|
|
14
|
+
id: `gp-carousel-${uniqueComponentId}`
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
rootAttrRender,
|
|
19
|
+
sliderAttr
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { getAttr };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { createClass } from '@gem-sdk/system';
|
|
3
|
+
import { getData } from './getData.js';
|
|
4
|
+
|
|
5
|
+
const getClass = (props)=>{
|
|
6
|
+
const DEVICES = [
|
|
7
|
+
'mobile',
|
|
8
|
+
'tablet',
|
|
9
|
+
'desktop'
|
|
10
|
+
];
|
|
11
|
+
const { setting, builderProps, wrapperClass, rootClass, advanced, fullHeight, slidesClass } = props;
|
|
12
|
+
const { sliderSelector } = getData(props);
|
|
13
|
+
const getDisplayOfWrapper = ()=>{
|
|
14
|
+
let result = {};
|
|
15
|
+
DEVICES.forEach((device)=>{
|
|
16
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
17
|
+
result = {
|
|
18
|
+
...result,
|
|
19
|
+
[`${devicePrefix}gp-flex`]: setting?.vertical?.[device],
|
|
20
|
+
[`${devicePrefix}gp-block`]: !setting?.vertical?.[device]
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
const getWrapperInnerHeight = ()=>{
|
|
26
|
+
let result = {};
|
|
27
|
+
DEVICES.forEach((device)=>{
|
|
28
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
29
|
+
result = {
|
|
30
|
+
...result,
|
|
31
|
+
[`${devicePrefix}gp-h-full`]: setting?.vertical?.[device],
|
|
32
|
+
[`${devicePrefix}gp-flex-1`]: setting?.vertical?.[device]
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
const makeFlexColClass = ()=>{
|
|
38
|
+
let result = {};
|
|
39
|
+
DEVICES.forEach((device)=>{
|
|
40
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
41
|
+
result = {
|
|
42
|
+
...result,
|
|
43
|
+
[`${devicePrefix}!gp-flex-col`]: setting?.vertical?.[device],
|
|
44
|
+
[`${devicePrefix}!gp-flex-row`]: !setting?.vertical?.[device]
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
const makeVerticalWrapClass = ()=>{
|
|
50
|
+
let result = {};
|
|
51
|
+
DEVICES.forEach((device)=>{
|
|
52
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
53
|
+
if (setting?.vertical?.[device]) {
|
|
54
|
+
result = {
|
|
55
|
+
...result,
|
|
56
|
+
[`${devicePrefix}!gp-flex-wrap`]: setting?.vertical?.[device]
|
|
57
|
+
};
|
|
58
|
+
} else {
|
|
59
|
+
result = {
|
|
60
|
+
...result,
|
|
61
|
+
[`${devicePrefix}!gp-flex-nowrap`]: !setting?.vertical?.[device]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return result;
|
|
66
|
+
};
|
|
67
|
+
const makeVerticalMinHeightClass = ()=>{
|
|
68
|
+
let result = {};
|
|
69
|
+
DEVICES.forEach((device)=>{
|
|
70
|
+
const devicePrefix = device === 'desktop' ? '' : `${device}:`;
|
|
71
|
+
if (setting?.vertical?.[device]) {
|
|
72
|
+
result = {
|
|
73
|
+
...result,
|
|
74
|
+
[`${devicePrefix}!gp-min-h-0`]: setting?.vertical?.[device]
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
result = {
|
|
78
|
+
...result,
|
|
79
|
+
[`${devicePrefix}!gp-min-h-full`]: !setting?.vertical?.[device]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return result;
|
|
84
|
+
};
|
|
85
|
+
const wrapperClassRender = createClass({
|
|
86
|
+
...builderProps?.uid && {
|
|
87
|
+
[builderProps.uid]: true
|
|
88
|
+
},
|
|
89
|
+
...wrapperClass && {
|
|
90
|
+
[wrapperClass]: true
|
|
91
|
+
},
|
|
92
|
+
'gp-relative gp-my-0 tablet:gp-px-0 gp-max-w-full mobile:gp-px-0 gp-carousel-wrapper': true,
|
|
93
|
+
'!gp-flex': getResponsiveValueByScreen(setting?.vertical, 'desktop'),
|
|
94
|
+
'tablet:!gp-flex': getResponsiveValueByScreen(setting?.vertical, 'tablet'),
|
|
95
|
+
'mobile:!gp-flex': getResponsiveValueByScreen(setting?.vertical, 'mobile'),
|
|
96
|
+
...getDisplayOfWrapper()
|
|
97
|
+
});
|
|
98
|
+
const wrapperInnerClass = createClass({
|
|
99
|
+
'gp-relative gp-flex gp-items-center gp-justify-between': true,
|
|
100
|
+
'!gp-h-full': fullHeight,
|
|
101
|
+
...getWrapperInnerHeight(),
|
|
102
|
+
...makeFlexColClass()
|
|
103
|
+
});
|
|
104
|
+
const rootClassRender = createClass({
|
|
105
|
+
'gp-group/carousel gp-w-full gp-flex': true,
|
|
106
|
+
'!gp-flex-col': getResponsiveValueByScreen(setting?.vertical, 'desktop'),
|
|
107
|
+
'tablet:!flex-col': getResponsiveValueByScreen(setting?.vertical, 'tablet'),
|
|
108
|
+
'mobile:!flex-col': getResponsiveValueByScreen(setting?.vertical, 'mobile'),
|
|
109
|
+
...rootClass && {
|
|
110
|
+
[rootClass]: true
|
|
111
|
+
},
|
|
112
|
+
...advanced?.cssClass && {
|
|
113
|
+
[advanced.cssClass]: true
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const sliderClass = createClass({
|
|
117
|
+
'gem-slider gp-h-full gp-overflow-hidden gp-select-none': true,
|
|
118
|
+
[sliderSelector]: true,
|
|
119
|
+
...slidesClass && {
|
|
120
|
+
[slidesClass]: true
|
|
121
|
+
},
|
|
122
|
+
...makeVerticalWrapClass(),
|
|
123
|
+
...makeVerticalMinHeightClass()
|
|
124
|
+
});
|
|
125
|
+
return {
|
|
126
|
+
rootClassRender,
|
|
127
|
+
wrapperClassRender,
|
|
128
|
+
wrapperInnerClass,
|
|
129
|
+
sliderClass
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export { getClass };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { dataStringify, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { createStateOrContext } from '@gem-sdk/system';
|
|
3
|
+
|
|
4
|
+
const getData = (props)=>{
|
|
5
|
+
const DEVICES = [
|
|
6
|
+
'mobile',
|
|
7
|
+
'tablet',
|
|
8
|
+
'desktop'
|
|
9
|
+
];
|
|
10
|
+
const { setting, rootId, builderProps, styles, moveToIdx, isHiddenArrowWhenDisabled } = props;
|
|
11
|
+
const uniqueComponentId = rootId ?? builderProps?.uid;
|
|
12
|
+
const sliderSelector = `gp-carousel-slider-${builderProps?.uid}`;
|
|
13
|
+
const { enableAction = {
|
|
14
|
+
desktop: true
|
|
15
|
+
}, navigationStyle, navigationEnable = {
|
|
16
|
+
desktop: true
|
|
17
|
+
} } = setting ?? {};
|
|
18
|
+
const getLoopSetting = ()=>{
|
|
19
|
+
let result = setting?.loop;
|
|
20
|
+
DEVICES.forEach((device)=>{
|
|
21
|
+
result = {
|
|
22
|
+
...result,
|
|
23
|
+
[device]: getResponsiveValueByScreen(enableAction) ? result?.[device] : false
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
const getArrowType = ()=>{
|
|
29
|
+
let result = navigationStyle;
|
|
30
|
+
DEVICES.forEach((device)=>{
|
|
31
|
+
result = {
|
|
32
|
+
...result,
|
|
33
|
+
[device]: getResponsiveValueByScreen(navigationEnable, device) ? result?.[device] : 'none'
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
const stateData = createStateOrContext({
|
|
39
|
+
id: uniqueComponentId,
|
|
40
|
+
setting,
|
|
41
|
+
styles,
|
|
42
|
+
moveToIdx,
|
|
43
|
+
isHiddenArrowWhenDisabled
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
loopConfig: getLoopSetting(),
|
|
47
|
+
stateData: dataStringify(stateData).replaceAll("'", '''),
|
|
48
|
+
uniqueComponentId,
|
|
49
|
+
arrowShowConfig: getArrowType(),
|
|
50
|
+
sliderSelector
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { getData };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { makeStyleResponsive, getHeightByShapeGlobalSize, makeStyleWithDefault, getWidthByShapeGlobalSize, getStyleBackgroundByDevice, makeContainerWidthOrHeight, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { createStyle } from '@gem-sdk/system';
|
|
3
|
+
|
|
4
|
+
const getStyle = (props)=>{
|
|
5
|
+
const DEVICES = [
|
|
6
|
+
'mobile',
|
|
7
|
+
'tablet',
|
|
8
|
+
'desktop'
|
|
9
|
+
];
|
|
10
|
+
const { styles, setting, style, rootStyles } = props;
|
|
11
|
+
const { arrowGapToEachSide = '16' } = setting ?? {};
|
|
12
|
+
const styleHeight = makeStyleResponsive('h', getHeightByShapeGlobalSize(styles?.sizeSetting));
|
|
13
|
+
const styleWidth = makeStyleWithDefault('w', getWidthByShapeGlobalSize(styles?.sizeSetting, true), {
|
|
14
|
+
desktop: '--g-ct-w',
|
|
15
|
+
tablet: '--g-ct-w',
|
|
16
|
+
mobile: '--g-ct-w'
|
|
17
|
+
});
|
|
18
|
+
const makeSpacing = ()=>{
|
|
19
|
+
let result = {};
|
|
20
|
+
DEVICES.forEach((device)=>{
|
|
21
|
+
const isVertical = getResponsiveValueByScreen(setting?.vertical, device);
|
|
22
|
+
const spacing = getResponsiveValueByScreen(styles?.spacing, device);
|
|
23
|
+
const key = isVertical ? `--rg${device !== 'desktop' ? `-${device}` : ''}` : `--cg${device !== 'desktop' ? `-${device}` : ''}`;
|
|
24
|
+
result = {
|
|
25
|
+
...result,
|
|
26
|
+
[key]: `${spacing ?? 0}px`
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
const wrapperStyleRender = createStyle({
|
|
32
|
+
...style,
|
|
33
|
+
...styleHeight,
|
|
34
|
+
...styleWidth,
|
|
35
|
+
...makeStyleResponsive('bgc', styles?.backgroundColor),
|
|
36
|
+
...getStyleBackgroundByDevice(styles?.backgroundImage, {
|
|
37
|
+
ignoreBackgroundColor: true
|
|
38
|
+
})
|
|
39
|
+
});
|
|
40
|
+
const wrapperInnerStyle = createStyle({
|
|
41
|
+
...makeContainerWidthOrHeight({
|
|
42
|
+
vertical: setting?.vertical,
|
|
43
|
+
dotStyle: setting?.dotStyle
|
|
44
|
+
}),
|
|
45
|
+
gap: arrowGapToEachSide + 'px'
|
|
46
|
+
});
|
|
47
|
+
const rootStyleRender = createStyle({
|
|
48
|
+
...makeStyleResponsive('jc', styles?.align),
|
|
49
|
+
...rootStyles
|
|
50
|
+
});
|
|
51
|
+
const sliderStyle = createStyle({
|
|
52
|
+
...makeSpacing()
|
|
53
|
+
});
|
|
54
|
+
return {
|
|
55
|
+
rootStyleRender,
|
|
56
|
+
wrapperStyleRender,
|
|
57
|
+
wrapperInnerStyle,
|
|
58
|
+
sliderStyle
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { getStyle };
|