@gem-sdk/components 2.0.0-dev.622 → 2.0.0-dev.624
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 +12 -6
- package/dist/cjs/collection/components/collection-paginator/common/styles.js +3 -4
- package/dist/cjs/collection/components/collection-paginator/components/CollectionPaginator.liquid.js +2 -1
- package/dist/cjs/collection/setting/collection-paginator/configs/settings.js +2 -3
- package/dist/cjs/index.js +34 -32
- package/dist/cjs/index.liquid.js +16 -10
- package/dist/cjs/next.js +3 -1
- package/dist/cjs/product/components/ProductImagesV3/common/common.js +360 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getAttr.js +192 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getBorderActiveCss.js +26 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getClasses.js +94 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getStyle.js +303 -0
- package/dist/cjs/product/components/ProductImagesV3/common/hoverAction.js +95 -0
- package/dist/cjs/product/components/ProductImagesV3/common/productFeaturedImage.js +59 -0
- package/dist/cjs/product/components/ProductImagesV3/common/productGallery.js +266 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/MediaIcon.js +63 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +36 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +109 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +139 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +100 -0
- package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +77 -0
- package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +300 -0
- package/dist/cjs/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +44 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +83 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +182 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +30 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +239 -0
- package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +28 -0
- package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +144 -0
- package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesAttr.js +14 -0
- package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesClassName.js +54 -0
- package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesStyles.js +53 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +55 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +41 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +134 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +203 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +87 -0
- package/dist/cjs/product/components/ProductImagesV3/index.js +291 -0
- package/dist/cjs/product/components/ProductImagesV3/index.liquid.js +153 -0
- package/dist/cjs/product/index.js +6 -4
- package/dist/cjs/product/next.js +4 -0
- package/dist/cjs/product/setting/product-image-v3/ProductFeatureImage.js +252 -0
- package/dist/cjs/product/setting/product-image-v3/ProductGalleryImage.js +251 -0
- package/dist/cjs/product/setting/product-image-v3/ProductImages.js +74 -0
- package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +388 -0
- package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +518 -0
- package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/index.js +336 -0
- package/dist/cjs/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +118 -0
- package/dist/cjs/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +119 -0
- package/dist/cjs/product/setting/product-image-v3/configs/uiV1.js +237 -0
- package/dist/cjs/product/setting/product-image-v3/configs/uiV2.js +491 -0
- package/dist/cjs/setting.js +97 -95
- package/dist/cjs/swiper-carousel/arrow/Arrow.js +52 -0
- package/dist/cjs/swiper-carousel/arrow/Arrow.liquid.js +46 -0
- package/dist/cjs/swiper-carousel/arrow/common/common.js +119 -0
- package/dist/cjs/swiper-carousel/arrow/common/getClass.js +50 -0
- package/dist/cjs/swiper-carousel/arrow/common/getStyle.js +84 -0
- package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.js +34 -0
- package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.liquid.js +38 -0
- package/dist/cjs/swiper-carousel/carousel-item/common/getClass.js +29 -0
- package/dist/cjs/swiper-carousel/carousel-item/common/getStyle.js +79 -0
- package/dist/cjs/swiper-carousel/carousel-item/hook/useCarouseItem.js +22 -0
- package/dist/cjs/swiper-carousel/components/common/carousel.js +98 -0
- package/dist/cjs/swiper-carousel/components/const/index.js +5 -0
- package/dist/cjs/swiper-carousel/components/hooks/useTrackPreviewPause.js +34 -0
- package/dist/cjs/swiper-carousel/components/plugins/AnimationPlugin.js +42 -0
- package/dist/cjs/swiper-carousel/components/plugins/AutoPlayPlugin.js +105 -0
- package/dist/cjs/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +15 -0
- package/dist/cjs/swiper-carousel/components/plugins/MutationPlugin.js +45 -0
- package/dist/cjs/swiper-carousel/dots/Dots.js +51 -0
- package/dist/cjs/swiper-carousel/dots/Dots.liquid.js +26 -0
- package/dist/cjs/swiper-carousel/dots/common/common.js +28 -0
- package/dist/cjs/swiper-carousel/dots/common/getClass.js +40 -0
- package/dist/cjs/swiper-carousel/dots/common/getStyle.js +33 -0
- package/dist/cjs/swiper-carousel/dots/hook/useDotsSetting.js +21 -0
- package/dist/cjs/swiper-carousel/index.js +17 -0
- package/dist/cjs/swiper-carousel/next.js +22 -0
- package/dist/cjs/swiper-carousel/root/Swiper.js +128 -0
- package/dist/cjs/swiper-carousel/root/Swiper.liquid.js +104 -0
- package/dist/cjs/swiper-carousel/root/common/getAttr.js +25 -0
- package/dist/cjs/swiper-carousel/root/common/getClass.js +135 -0
- package/dist/cjs/swiper-carousel/root/common/getData.js +56 -0
- package/dist/cjs/swiper-carousel/root/common/getStyle.js +64 -0
- package/dist/cjs/swiper-carousel/root/hook/useCarousel.js +482 -0
- package/dist/cjs/swiper-carousel/setting/Swiper.js +42 -0
- package/dist/cjs/swiper-carousel/setting/SwiperItem.js +40 -0
- package/dist/cjs/swiper-carousel/setting/configs/presets.js +87 -0
- package/dist/cjs/swiper-carousel/setting/configs/settingV2.js +819 -0
- package/dist/cjs/swiper-carousel/setting/configs/uiV2.js +718 -0
- package/dist/esm/builder.js +6 -0
- package/dist/esm/collection/components/collection-paginator/common/styles.js +3 -4
- package/dist/esm/collection/components/collection-paginator/components/CollectionPaginator.liquid.js +2 -1
- package/dist/esm/collection/setting/collection-paginator/configs/settings.js +2 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.liquid.js +3 -0
- package/dist/esm/next.js +3 -1
- package/dist/esm/product/components/ProductImagesV3/common/common.js +344 -0
- package/dist/esm/product/components/ProductImagesV3/common/getAttr.js +189 -0
- package/dist/esm/product/components/ProductImagesV3/common/getBorderActiveCss.js +24 -0
- package/dist/esm/product/components/ProductImagesV3/common/getClasses.js +83 -0
- package/dist/esm/product/components/ProductImagesV3/common/getStyle.js +292 -0
- package/dist/esm/product/components/ProductImagesV3/common/hoverAction.js +92 -0
- package/dist/esm/product/components/ProductImagesV3/common/productFeaturedImage.js +53 -0
- package/dist/esm/product/components/ProductImagesV3/common/productGallery.js +251 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/MediaIcon.js +59 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +32 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +105 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +135 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +96 -0
- package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +73 -0
- package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +296 -0
- package/dist/esm/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +40 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +79 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +178 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +26 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +235 -0
- package/dist/esm/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +24 -0
- package/dist/esm/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +140 -0
- package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesAttr.js +12 -0
- package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesClassName.js +52 -0
- package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesStyles.js +51 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +53 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +39 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +132 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +201 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +85 -0
- package/dist/esm/product/components/ProductImagesV3/index.js +287 -0
- package/dist/esm/product/components/ProductImagesV3/index.liquid.js +149 -0
- package/dist/esm/product/index.js +26 -24
- package/dist/esm/product/next.js +4 -0
- package/dist/esm/product/setting/product-image-v3/ProductFeatureImage.js +248 -0
- package/dist/esm/product/setting/product-image-v3/ProductGalleryImage.js +248 -0
- package/dist/esm/product/setting/product-image-v3/ProductImages.js +70 -0
- package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +384 -0
- package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +515 -0
- package/dist/esm/product/setting/product-image-v3/configs/setting-v2/index.js +334 -0
- package/dist/esm/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +116 -0
- package/dist/esm/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +117 -0
- package/dist/esm/product/setting/product-image-v3/configs/uiV1.js +235 -0
- package/dist/esm/product/setting/product-image-v3/configs/uiV2.js +489 -0
- package/dist/esm/setting.js +2 -0
- package/dist/esm/swiper-carousel/arrow/Arrow.js +48 -0
- package/dist/esm/swiper-carousel/arrow/Arrow.liquid.js +42 -0
- package/dist/esm/swiper-carousel/arrow/common/common.js +111 -0
- package/dist/esm/swiper-carousel/arrow/common/getClass.js +48 -0
- package/dist/esm/swiper-carousel/arrow/common/getStyle.js +82 -0
- package/dist/esm/swiper-carousel/carousel-item/SwiperItem.js +30 -0
- package/dist/esm/swiper-carousel/carousel-item/SwiperItem.liquid.js +34 -0
- package/dist/esm/swiper-carousel/carousel-item/common/getClass.js +27 -0
- package/dist/esm/swiper-carousel/carousel-item/common/getStyle.js +77 -0
- package/dist/esm/swiper-carousel/carousel-item/hook/useCarouseItem.js +20 -0
- package/dist/esm/swiper-carousel/components/common/carousel.js +93 -0
- package/dist/esm/swiper-carousel/components/const/index.js +3 -0
- package/dist/esm/swiper-carousel/components/hooks/useTrackPreviewPause.js +30 -0
- package/dist/esm/swiper-carousel/components/plugins/AnimationPlugin.js +35 -0
- package/dist/esm/swiper-carousel/components/plugins/AutoPlayPlugin.js +103 -0
- package/dist/esm/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +13 -0
- package/dist/esm/swiper-carousel/components/plugins/MutationPlugin.js +43 -0
- package/dist/esm/swiper-carousel/dots/Dots.js +47 -0
- package/dist/esm/swiper-carousel/dots/Dots.liquid.js +22 -0
- package/dist/esm/swiper-carousel/dots/common/common.js +26 -0
- package/dist/esm/swiper-carousel/dots/common/getClass.js +38 -0
- package/dist/esm/swiper-carousel/dots/common/getStyle.js +31 -0
- package/dist/esm/swiper-carousel/dots/hook/useDotsSetting.js +19 -0
- package/dist/esm/swiper-carousel/index.js +15 -0
- package/dist/esm/swiper-carousel/next.js +18 -0
- package/dist/esm/swiper-carousel/root/Swiper.js +124 -0
- package/dist/esm/swiper-carousel/root/Swiper.liquid.js +100 -0
- package/dist/esm/swiper-carousel/root/common/getAttr.js +23 -0
- package/dist/esm/swiper-carousel/root/common/getClass.js +133 -0
- package/dist/esm/swiper-carousel/root/common/getData.js +54 -0
- package/dist/esm/swiper-carousel/root/common/getStyle.js +62 -0
- package/dist/esm/swiper-carousel/root/hook/useCarousel.js +480 -0
- package/dist/esm/swiper-carousel/setting/Swiper.js +38 -0
- package/dist/esm/swiper-carousel/setting/SwiperItem.js +36 -0
- package/dist/esm/swiper-carousel/setting/configs/presets.js +85 -0
- package/dist/esm/swiper-carousel/setting/configs/settingV2.js +815 -0
- package/dist/esm/swiper-carousel/setting/configs/uiV2.js +713 -0
- package/dist/types/index.d.ts +551 -116
- package/package.json +2 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createClass } from '@gem-sdk/system';
|
|
2
|
+
import { getWrapperClasses, getGalleryWrapperClasses, getGalleryGridWrapperClasses, getFtImageWithGalleryClasses, getImageGalleryWrapperClasses, getFeaturedImageCarouselClasses, getFeaturedImageGalleryClasses, getFeaturedImageClasses, getGalleryItemClasses, getFeaturedCarouselItemClasses } from '../common/getClasses.js';
|
|
3
|
+
import { checkAddOverFlowClass, setDefaultWhenUndefineSetting } from '../common/common.js';
|
|
4
|
+
|
|
5
|
+
const getProductImagesClassName = (props)=>{
|
|
6
|
+
const { setting, style } = props;
|
|
7
|
+
const productImagesProps = setDefaultWhenUndefineSetting(props);
|
|
8
|
+
const { builderProps, advanced } = productImagesProps;
|
|
9
|
+
const extraClass = advanced?.cssClass;
|
|
10
|
+
const wrapperClasses = createClass(getWrapperClasses({
|
|
11
|
+
extraClass: `${builderProps?.uid} ${extraClass ?? ''} `,
|
|
12
|
+
isAddOverFlowClass: checkAddOverFlowClass(style)
|
|
13
|
+
}));
|
|
14
|
+
const productImagesGalleryClasses = createClass(getGalleryWrapperClasses({}));
|
|
15
|
+
const galleryGridWrapperClasses = createClass(getGalleryGridWrapperClasses({}));
|
|
16
|
+
const galleryItemClasses = (className)=>createClass(getGalleryItemClasses({
|
|
17
|
+
extraClass: `${className ?? ''}`
|
|
18
|
+
}));
|
|
19
|
+
const ftImageGalleryClasses = createClass(getFtImageWithGalleryClasses({
|
|
20
|
+
extraClass: `gp-product-images-feature--${builderProps?.uid}`
|
|
21
|
+
}));
|
|
22
|
+
const imageGalleryWrapperClasses = createClass(getImageGalleryWrapperClasses({
|
|
23
|
+
extraClass: `gp-product-images-gallery-${builderProps?.uid}`
|
|
24
|
+
}));
|
|
25
|
+
const featuredImageCarouselClasses = createClass(getFeaturedImageCarouselClasses({
|
|
26
|
+
extraClass: `gp-product-images-gallery-${builderProps?.uid}`
|
|
27
|
+
}));
|
|
28
|
+
const featuredImageGalleryClasses = createClass(getFeaturedImageGalleryClasses({
|
|
29
|
+
settings: setting
|
|
30
|
+
}));
|
|
31
|
+
const featureImageOnlyOneImageClasses = createClass(getFeaturedImageClasses({
|
|
32
|
+
setting,
|
|
33
|
+
extraClass: `gp-flex gp-relative gp-product-images-gallery-${builderProps?.uid} gp-overflow-hidden gp-flex gp-w-full gp-items-center gp-justify-center `
|
|
34
|
+
}));
|
|
35
|
+
const featuredCarouselItemClasses = (className)=>createClass(getFeaturedCarouselItemClasses({
|
|
36
|
+
extraClass: `${className ?? ''}`
|
|
37
|
+
}));
|
|
38
|
+
return {
|
|
39
|
+
wrapperClasses,
|
|
40
|
+
productImagesGalleryClasses,
|
|
41
|
+
galleryGridWrapperClasses,
|
|
42
|
+
galleryItemClasses,
|
|
43
|
+
ftImageGalleryClasses,
|
|
44
|
+
imageGalleryWrapperClasses,
|
|
45
|
+
featuredImageCarouselClasses,
|
|
46
|
+
featuredImageGalleryClasses,
|
|
47
|
+
featureImageOnlyOneImageClasses,
|
|
48
|
+
featuredCarouselItemClasses
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { getProductImagesClassName };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { createStyle } from '@gem-sdk/system';
|
|
2
|
+
import { getWrapContainerStyle, getFeatureImageStyle, getFeaturedImageOnlyOneImageStyle, getGalleryImageStyle, getFeaturedImageCarouselStyle, getFeatureImageCarouselItemStyle, getGalleryGridStyle, getGalleryGridItemStyle, getGalleryCarouselStyle, getGalleryCarouselItemStyle } from '../common/getStyle.js';
|
|
3
|
+
|
|
4
|
+
const getProductImagesStyles = (settings, options)=>{
|
|
5
|
+
const wrapContainerStyle = createStyle(getWrapContainerStyle(settings));
|
|
6
|
+
const wrapContainerStyleOnlyOneImage = createStyle(getWrapContainerStyle(settings, true));
|
|
7
|
+
const wrapperFeaturedImageStyle = createStyle(getWrapContainerStyle(settings, options?.gallery && options?.gallery?.length < 2));
|
|
8
|
+
const featureImageStyle = createStyle(getFeatureImageStyle(settings, {
|
|
9
|
+
enableOrder: true,
|
|
10
|
+
enableDisplay: true
|
|
11
|
+
}));
|
|
12
|
+
const featureImageOnlyOneImageStyle = createStyle(getFeaturedImageOnlyOneImageStyle({
|
|
13
|
+
settings,
|
|
14
|
+
options: {
|
|
15
|
+
enableRadius: true,
|
|
16
|
+
enableHeight: true
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
const galleryImageStyle = createStyle(getGalleryImageStyle(settings, options?.featureImageHeight));
|
|
20
|
+
const featuredImageCarouselStyle = createStyle(getFeaturedImageCarouselStyle(settings));
|
|
21
|
+
const featureImageCarouselItemStyle = createStyle({
|
|
22
|
+
...getFeatureImageCarouselItemStyle(settings)
|
|
23
|
+
});
|
|
24
|
+
const featureImageCarouselOnlyOneImageStyle = createStyle({
|
|
25
|
+
...getFeatureImageCarouselItemStyle(settings),
|
|
26
|
+
...{
|
|
27
|
+
width: '{{productImageWidth}}px'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const galleryGridStyles = createStyle(getGalleryGridStyle(settings));
|
|
31
|
+
const galleryGridItemStyles = createStyle(getGalleryGridItemStyle(settings));
|
|
32
|
+
const galleryCarouselStyle = createStyle(getGalleryCarouselStyle(settings));
|
|
33
|
+
const galleryCarouselItemStyle = createStyle(getGalleryCarouselItemStyle(settings));
|
|
34
|
+
return {
|
|
35
|
+
wrapContainerStyle,
|
|
36
|
+
wrapContainerStyleOnlyOneImage,
|
|
37
|
+
wrapperFeaturedImageStyle,
|
|
38
|
+
featureImageStyle,
|
|
39
|
+
featureImageOnlyOneImageStyle,
|
|
40
|
+
galleryImageStyle,
|
|
41
|
+
featuredImageCarouselStyle,
|
|
42
|
+
featureImageCarouselItemStyle,
|
|
43
|
+
featureImageCarouselOnlyOneImageStyle,
|
|
44
|
+
galleryGridStyles,
|
|
45
|
+
galleryGridItemStyles,
|
|
46
|
+
galleryCarouselStyle,
|
|
47
|
+
galleryCarouselItemStyle
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { getProductImagesStyles };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useCurrentDevice, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { getTypeWidthDevice } from '../common/common.js';
|
|
4
|
+
|
|
5
|
+
const useFeatureImageWithGallery = (props)=>{
|
|
6
|
+
const { setting, styles } = props;
|
|
7
|
+
const settings = {
|
|
8
|
+
...setting,
|
|
9
|
+
...styles
|
|
10
|
+
};
|
|
11
|
+
const currentDevice = useCurrentDevice();
|
|
12
|
+
const timeout = useRef(null);
|
|
13
|
+
const featureWrapperImage = useRef(null);
|
|
14
|
+
const [onClickFeatureArrow, setOnClickFeatureArrow] = useState('');
|
|
15
|
+
const [featureImageHeight, setFeatureImageHeight] = useState(100);
|
|
16
|
+
const [activeIndexFromFeatureImage, setActiveIndexFromFeatureImage] = useState();
|
|
17
|
+
const position = getResponsiveValueByScreen(settings?.position, currentDevice);
|
|
18
|
+
const isShowCarousel = getTypeWidthDevice(settings?.type)[currentDevice] === 'slider' || [
|
|
19
|
+
'left',
|
|
20
|
+
'right',
|
|
21
|
+
'inside-left',
|
|
22
|
+
'inside-right'
|
|
23
|
+
].includes(position);
|
|
24
|
+
const onHandleLoadedFeatureImage = (status, timeOut = 200)=>{
|
|
25
|
+
if (status) {
|
|
26
|
+
if (timeout.current) clearTimeout(timeout.current);
|
|
27
|
+
timeout.current = setTimeout(()=>setFeatureImageHeight(featureWrapperImage?.current?.offsetHeight || 200), timeOut);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
useEffect(()=>{
|
|
31
|
+
const element = featureWrapperImage?.current;
|
|
32
|
+
if (!element) return;
|
|
33
|
+
const observer = new ResizeObserver(()=>{
|
|
34
|
+
setFeatureImageHeight(element.offsetHeight || 200);
|
|
35
|
+
});
|
|
36
|
+
observer.observe(element);
|
|
37
|
+
return ()=>{
|
|
38
|
+
observer.disconnect();
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
isShowCarousel,
|
|
43
|
+
featureImageHeight,
|
|
44
|
+
featureWrapperImage,
|
|
45
|
+
onClickFeatureArrow,
|
|
46
|
+
activeIndexFromFeatureImage,
|
|
47
|
+
setOnClickFeatureArrow,
|
|
48
|
+
onHandleLoadedFeatureImage,
|
|
49
|
+
setActiveIndexFromFeatureImage
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { useFeatureImageWithGallery };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useCurrentVariant } from '@gem-sdk/core';
|
|
2
|
+
import { useCallback, useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const useFilterImagesByVariant = ({ productImages, displayByVariant, variantSelect })=>{
|
|
5
|
+
const currentVariant = useCurrentVariant();
|
|
6
|
+
const getSelectedVariantOptionValue = useCallback(()=>{
|
|
7
|
+
const selectedVariantOptions = currentVariant?.selectedOptions ?? [];
|
|
8
|
+
const variantOption = selectedVariantOptions.find((item)=>item.name === variantSelect);
|
|
9
|
+
return variantOption?.value?.toLowerCase() ?? '';
|
|
10
|
+
}, [
|
|
11
|
+
currentVariant?.selectedOptions,
|
|
12
|
+
variantSelect
|
|
13
|
+
]);
|
|
14
|
+
const filteredProductImages = useMemo(()=>{
|
|
15
|
+
if (!displayByVariant || !variantSelect || !productImages) {
|
|
16
|
+
return productImages;
|
|
17
|
+
}
|
|
18
|
+
const selectedValue = getSelectedVariantOptionValue();
|
|
19
|
+
if (!selectedValue) {
|
|
20
|
+
return productImages;
|
|
21
|
+
}
|
|
22
|
+
const filteredImages = productImages.filter((image)=>{
|
|
23
|
+
const imageAlt = (image.alt || '').toLowerCase();
|
|
24
|
+
return imageAlt.includes(selectedValue);
|
|
25
|
+
});
|
|
26
|
+
return filteredImages.length > 0 ? filteredImages : productImages;
|
|
27
|
+
}, [
|
|
28
|
+
displayByVariant,
|
|
29
|
+
variantSelect,
|
|
30
|
+
productImages,
|
|
31
|
+
getSelectedVariantOptionValue
|
|
32
|
+
]);
|
|
33
|
+
return {
|
|
34
|
+
filteredProductImages,
|
|
35
|
+
selectedVariantValue: getSelectedVariantOptionValue()
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { useFilterImagesByVariant };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useCurrentDevice, useFeaturedImageGlobal, useEditorMode, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
3
|
+
import { useFilterImagesByVariant } from './useFilterImagesByVariant.js';
|
|
4
|
+
import { handleSetSrcForProductImageList } from '../../../../image/helpers/getSrcSet.js';
|
|
5
|
+
import { getShapeByLayout, checkDisplayGalleryByWidth } from '../common/productGallery.js';
|
|
6
|
+
|
|
7
|
+
const useGalleryCarousel = (props)=>{
|
|
8
|
+
const { builderPropUID, productImages, onHandleClick, activeIndexFormFeatureImage, onClickFeatureArrow, builderPropsClass, arrow, priorityFeatureImage, ...setting } = props;
|
|
9
|
+
const currentDevice = useCurrentDevice();
|
|
10
|
+
const featuredImageGlobal = useFeaturedImageGlobal();
|
|
11
|
+
const [hasClickFeatureArrow, setHasClickFeatureArrow] = useState(onClickFeatureArrow || '');
|
|
12
|
+
const mode = useEditorMode();
|
|
13
|
+
const [moveToIdx, setMoveToIdx] = useState(0);
|
|
14
|
+
const { filteredProductImages } = useFilterImagesByVariant({
|
|
15
|
+
productImages,
|
|
16
|
+
displayByVariant: setting?.displayByVariant,
|
|
17
|
+
variantSelect: setting?.variantSelect
|
|
18
|
+
});
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
setHasClickFeatureArrow(onClickFeatureArrow || '');
|
|
21
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
22
|
+
}, [
|
|
23
|
+
onClickFeatureArrow
|
|
24
|
+
]);
|
|
25
|
+
useEffect(()=>{
|
|
26
|
+
if (hasClickFeatureArrow) {
|
|
27
|
+
setMoveToIdx(activeIndexFormFeatureImage || 0);
|
|
28
|
+
setHasClickFeatureArrow('');
|
|
29
|
+
}
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
}, [
|
|
32
|
+
activeIndexFormFeatureImage
|
|
33
|
+
]);
|
|
34
|
+
useEffect(()=>{
|
|
35
|
+
if (priorityFeatureImage) {
|
|
36
|
+
const indexPriorityFeatureImage = filteredProductImages?.findIndex((item)=>item.id === priorityFeatureImage.id) || 0;
|
|
37
|
+
setMoveToIdx(indexPriorityFeatureImage);
|
|
38
|
+
setHasClickFeatureArrow('');
|
|
39
|
+
}
|
|
40
|
+
}, [
|
|
41
|
+
priorityFeatureImage,
|
|
42
|
+
filteredProductImages
|
|
43
|
+
]);
|
|
44
|
+
useEffect(()=>{
|
|
45
|
+
const index = filteredProductImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
46
|
+
setMoveToIdx(index || 0);
|
|
47
|
+
setHasClickFeatureArrow('');
|
|
48
|
+
}, [
|
|
49
|
+
featuredImageGlobal,
|
|
50
|
+
filteredProductImages
|
|
51
|
+
]);
|
|
52
|
+
const shapeByLayout = useMemo(()=>{
|
|
53
|
+
return getShapeByLayout({
|
|
54
|
+
shape: setting.shape,
|
|
55
|
+
shapeForBottom: setting.shapeForBottom,
|
|
56
|
+
shapeFor1Col: setting.shapeFor1Col,
|
|
57
|
+
shapeFor2Col: setting.shapeFor2Col,
|
|
58
|
+
shapeForFtOnly: setting.shapeForFtOnly,
|
|
59
|
+
shapeForInsideBottom: setting.shapeForInsideBottom,
|
|
60
|
+
shapeForInside: setting.shapeForInside
|
|
61
|
+
}, setting.position);
|
|
62
|
+
}, [
|
|
63
|
+
setting.shape,
|
|
64
|
+
setting.shapeForBottom,
|
|
65
|
+
setting.shapeFor1Col,
|
|
66
|
+
setting.shapeFor2Col,
|
|
67
|
+
setting.shapeForFtOnly,
|
|
68
|
+
setting.position,
|
|
69
|
+
setting.shapeForInsideBottom,
|
|
70
|
+
setting.shapeForInside
|
|
71
|
+
]);
|
|
72
|
+
const handleSetSrc = useCallback(()=>{
|
|
73
|
+
handleSetSrcForProductImageList({
|
|
74
|
+
builderPropUID,
|
|
75
|
+
shapeByLayout,
|
|
76
|
+
qualityType: setting.qualityType,
|
|
77
|
+
qualityPercent: setting.qualityPercent
|
|
78
|
+
});
|
|
79
|
+
}, [
|
|
80
|
+
shapeByLayout,
|
|
81
|
+
setting.qualityPercent,
|
|
82
|
+
setting.qualityType,
|
|
83
|
+
builderPropUID
|
|
84
|
+
]);
|
|
85
|
+
useEffect(()=>{
|
|
86
|
+
if (mode === 'edit') return;
|
|
87
|
+
const $galleryImageGrid = document?.querySelector(`.gem-slider-item-${builderPropUID} .product-list-image`);
|
|
88
|
+
if (!$galleryImageGrid) return;
|
|
89
|
+
handleSetSrc();
|
|
90
|
+
const observer = new ResizeObserver(()=>{
|
|
91
|
+
handleSetSrc();
|
|
92
|
+
});
|
|
93
|
+
observer?.observe($galleryImageGrid, {});
|
|
94
|
+
return ()=>{
|
|
95
|
+
observer?.disconnect();
|
|
96
|
+
};
|
|
97
|
+
}, [
|
|
98
|
+
handleSetSrc,
|
|
99
|
+
builderPropUID,
|
|
100
|
+
mode
|
|
101
|
+
]);
|
|
102
|
+
const enableOpenLightBox = getResponsiveValueByScreen(setting.clickOpenLightBox, currentDevice);
|
|
103
|
+
const isDisplay = useMemo(()=>{
|
|
104
|
+
const isDisplayByWidth = checkDisplayGalleryByWidth({
|
|
105
|
+
shapeByLayout
|
|
106
|
+
});
|
|
107
|
+
return getResponsiveValueByScreen(isDisplayByWidth, currentDevice);
|
|
108
|
+
}, [
|
|
109
|
+
shapeByLayout,
|
|
110
|
+
currentDevice
|
|
111
|
+
]);
|
|
112
|
+
const isEnableBorderActive = useMemo(()=>{
|
|
113
|
+
return setting?.borderActive?.border !== 'none';
|
|
114
|
+
}, [
|
|
115
|
+
setting?.borderActive?.border
|
|
116
|
+
]);
|
|
117
|
+
const isShowButtonLightbox = getResponsiveValueByScreen(setting?.clickOpenLightBox, currentDevice);
|
|
118
|
+
const handleClickCarouselItem = (imageId)=>{
|
|
119
|
+
onHandleClick && onHandleClick(imageId || '', enableOpenLightBox);
|
|
120
|
+
};
|
|
121
|
+
return {
|
|
122
|
+
moveToIdx,
|
|
123
|
+
isDisplay,
|
|
124
|
+
shapeByLayout,
|
|
125
|
+
isEnableBorderActive,
|
|
126
|
+
isShowButtonLightbox,
|
|
127
|
+
filteredProductImages,
|
|
128
|
+
handleClickCarouselItem
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { useGalleryCarousel };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { useFeaturedImageGlobal, useCurrentDevice, useInteraction, useEditorMode, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { createRef, useMemo, useCallback, useEffect } from 'react';
|
|
3
|
+
import { handleSetSrcForFeatureProductImage } from '../../../../image/helpers/getSrcSet.js';
|
|
4
|
+
import { getAspectRatio } from '../common/common.js';
|
|
5
|
+
import { checkRenderFeaturedCarousel } from '../common/productFeaturedImage.js';
|
|
6
|
+
import { useFilterImagesByVariant } from './useFilterImagesByVariant.js';
|
|
7
|
+
|
|
8
|
+
const useProductFeaturedImageCarousel = (props)=>{
|
|
9
|
+
const { productImages, imgRef, onHandleClick, onClickArrow, onHandleLoaded, onHandleUpdateActiveIndex, builderPropUID, builderPropsClass, children, parentUid, ...setting } = props;
|
|
10
|
+
const featuredImageGlobal = useFeaturedImageGlobal();
|
|
11
|
+
const currentDevice = useCurrentDevice();
|
|
12
|
+
const carouselRef = createRef();
|
|
13
|
+
const { onListener, ref } = useInteraction();
|
|
14
|
+
let delayTimeout;
|
|
15
|
+
const mode = useEditorMode();
|
|
16
|
+
const { filteredProductImages } = useFilterImagesByVariant({
|
|
17
|
+
productImages,
|
|
18
|
+
displayByVariant: setting?.displayByVariant,
|
|
19
|
+
variantSelect: setting?.variantSelect
|
|
20
|
+
});
|
|
21
|
+
const imageActiveIndex = useMemo(()=>{
|
|
22
|
+
const index = filteredProductImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
23
|
+
return index;
|
|
24
|
+
}, [
|
|
25
|
+
filteredProductImages,
|
|
26
|
+
featuredImageGlobal
|
|
27
|
+
]);
|
|
28
|
+
const isRenderFeatureCarousel = useMemo(()=>checkRenderFeaturedCarousel(setting), [
|
|
29
|
+
setting
|
|
30
|
+
]);
|
|
31
|
+
const imageActive = useMemo(()=>{
|
|
32
|
+
if (filteredProductImages?.length) return featuredImageGlobal || filteredProductImages?.[0];
|
|
33
|
+
}, [
|
|
34
|
+
filteredProductImages,
|
|
35
|
+
featuredImageGlobal
|
|
36
|
+
]);
|
|
37
|
+
const enableOpenLightBox = useMemo(()=>{
|
|
38
|
+
return getResponsiveValueByScreen(setting.ftClickOpenLightBox, currentDevice) === 'popup';
|
|
39
|
+
}, [
|
|
40
|
+
setting.ftClickOpenLightBox,
|
|
41
|
+
currentDevice
|
|
42
|
+
]);
|
|
43
|
+
const indexHover = useMemo(()=>{
|
|
44
|
+
if (!setting?.otherImage) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
if (filteredProductImages && setting.otherImage >= filteredProductImages.length - 1) {
|
|
48
|
+
return filteredProductImages.length - 1;
|
|
49
|
+
}
|
|
50
|
+
if (filteredProductImages && setting.otherImage === -1) {
|
|
51
|
+
return filteredProductImages.length - 1;
|
|
52
|
+
}
|
|
53
|
+
return setting.otherImage;
|
|
54
|
+
}, [
|
|
55
|
+
setting?.otherImage,
|
|
56
|
+
filteredProductImages
|
|
57
|
+
]);
|
|
58
|
+
const imageShowWhenHover = useMemo(()=>{
|
|
59
|
+
return setting?.hoverEffect === 'other' ? filteredProductImages?.[indexHover] : filteredProductImages?.find((item)=>item.id === featuredImageGlobal?.id) || filteredProductImages?.[0];
|
|
60
|
+
}, [
|
|
61
|
+
featuredImageGlobal?.id,
|
|
62
|
+
indexHover,
|
|
63
|
+
filteredProductImages,
|
|
64
|
+
setting?.hoverEffect
|
|
65
|
+
]);
|
|
66
|
+
const genRandomKey = function() {
|
|
67
|
+
return Math.random().toString(36).substr(2, 5);
|
|
68
|
+
};
|
|
69
|
+
const emitUpdateActiveIndex = (index)=>{
|
|
70
|
+
delayTimeout && clearTimeout(delayTimeout);
|
|
71
|
+
delayTimeout = setTimeout(()=>onHandleUpdateActiveIndex && onHandleUpdateActiveIndex(index), 500);
|
|
72
|
+
};
|
|
73
|
+
const getDefaultAspectRatio = (image)=>{
|
|
74
|
+
let result = '1/1';
|
|
75
|
+
let ratio = 0;
|
|
76
|
+
if (image) {
|
|
77
|
+
if (image.width && image.height) {
|
|
78
|
+
result = `${image.width}/${image.height}`;
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
filteredProductImages?.forEach((item)=>{
|
|
82
|
+
if (item.width && item.height) {
|
|
83
|
+
const r = item.height / item.width;
|
|
84
|
+
if (r > ratio) {
|
|
85
|
+
ratio = r;
|
|
86
|
+
result = `${item.width}/${item.height}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
93
|
+
const getAspectRatioFinal = (image)=>{
|
|
94
|
+
const result = getAspectRatio(setting.ftShape);
|
|
95
|
+
const defaultRatio = getDefaultAspectRatio(image);
|
|
96
|
+
return {
|
|
97
|
+
desktop: result.desktop ?? defaultRatio,
|
|
98
|
+
tablet: result.tablet ?? defaultRatio,
|
|
99
|
+
mobile: result.mobile ?? defaultRatio
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const handleSetSrc = useCallback(()=>{
|
|
103
|
+
handleSetSrcForFeatureProductImage({
|
|
104
|
+
builderPropUID,
|
|
105
|
+
ftShape: setting.ftShape,
|
|
106
|
+
qualityType: setting.qualityType,
|
|
107
|
+
qualityPercent: setting.qualityPercent
|
|
108
|
+
});
|
|
109
|
+
}, [
|
|
110
|
+
setting.ftShape,
|
|
111
|
+
setting.qualityPercent,
|
|
112
|
+
setting.qualityType,
|
|
113
|
+
builderPropUID
|
|
114
|
+
]);
|
|
115
|
+
const onListenerInteraction = ()=>{
|
|
116
|
+
const eventName = 'gp:change-image-step';
|
|
117
|
+
const selector = `[data-id="${builderPropUID}"]`;
|
|
118
|
+
onListener({
|
|
119
|
+
event: eventName,
|
|
120
|
+
selector
|
|
121
|
+
}, (params)=>{
|
|
122
|
+
const element = (ref.current || document).querySelector(selector);
|
|
123
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
124
|
+
carouselRef?.current?.moveToSlideInteraction({
|
|
125
|
+
element,
|
|
126
|
+
data,
|
|
127
|
+
isRollback,
|
|
128
|
+
key: uniqueStorageKey
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
onListener({
|
|
132
|
+
event: 'gp:change-next-slide',
|
|
133
|
+
selector
|
|
134
|
+
}, (params)=>{
|
|
135
|
+
const element = (ref.current || document).querySelector(selector);
|
|
136
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
137
|
+
carouselRef?.current?.nextSlideInteraction({
|
|
138
|
+
element,
|
|
139
|
+
data,
|
|
140
|
+
isRollback,
|
|
141
|
+
key: uniqueStorageKey
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
onListener({
|
|
145
|
+
event: 'gp:change-previous-slide',
|
|
146
|
+
selector
|
|
147
|
+
}, (params)=>{
|
|
148
|
+
const element = (ref.current || document).querySelector(selector);
|
|
149
|
+
const { data, isRollback, uniqueStorageKey } = params || {};
|
|
150
|
+
carouselRef?.current?.previousSlideInteraction({
|
|
151
|
+
element,
|
|
152
|
+
data,
|
|
153
|
+
isRollback,
|
|
154
|
+
key: uniqueStorageKey
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
useEffect(()=>{
|
|
159
|
+
if (mode === 'edit') return;
|
|
160
|
+
const $featuredImage = document?.querySelector(`.gem-slider-item-${builderPropUID} .featured-image-only`);
|
|
161
|
+
if (!$featuredImage) return;
|
|
162
|
+
handleSetSrc();
|
|
163
|
+
const observer = new ResizeObserver(()=>{
|
|
164
|
+
handleSetSrc();
|
|
165
|
+
});
|
|
166
|
+
observer?.observe($featuredImage, {});
|
|
167
|
+
return ()=>{
|
|
168
|
+
observer?.disconnect();
|
|
169
|
+
};
|
|
170
|
+
}, [
|
|
171
|
+
handleSetSrc,
|
|
172
|
+
builderPropUID,
|
|
173
|
+
mode
|
|
174
|
+
]);
|
|
175
|
+
useEffect(()=>{
|
|
176
|
+
onListenerInteraction();
|
|
177
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
178
|
+
}, []);
|
|
179
|
+
useEffect(()=>{
|
|
180
|
+
if (!isRenderFeatureCarousel) {
|
|
181
|
+
onHandleLoaded && onHandleLoaded(true, 0);
|
|
182
|
+
}
|
|
183
|
+
}, [
|
|
184
|
+
isRenderFeatureCarousel,
|
|
185
|
+
onHandleLoaded
|
|
186
|
+
]);
|
|
187
|
+
return {
|
|
188
|
+
ref,
|
|
189
|
+
imageActive,
|
|
190
|
+
imageActiveIndex,
|
|
191
|
+
imageShowWhenHover,
|
|
192
|
+
enableOpenLightBox,
|
|
193
|
+
filteredProductImages,
|
|
194
|
+
isRenderFeatureCarousel,
|
|
195
|
+
genRandomKey,
|
|
196
|
+
getAspectRatioFinal,
|
|
197
|
+
emitUpdateActiveIndex
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export { useProductFeaturedImageCarousel };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useCurrentDevice, useFeaturedImageGlobal, useEditorMode, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { handleSetSrcForProductImageList } from '../../../../image/helpers/getSrcSet.js';
|
|
4
|
+
import { getShapeByLayout, checkDisplayGalleryByWidth } from '../common/productGallery.js';
|
|
5
|
+
import { useFilterImagesByVariant } from './useFilterImagesByVariant.js';
|
|
6
|
+
|
|
7
|
+
const useProductGalleryGrid = (props)=>{
|
|
8
|
+
const { builderPropUID, productImages, activeIndexFormFeatureImage, children, isHiddenInteraction, ...setting } = props;
|
|
9
|
+
const currentDevice = useCurrentDevice();
|
|
10
|
+
const featuredImageGlobal = useFeaturedImageGlobal();
|
|
11
|
+
const [imageActiveIndex, setImageActiveIndex] = useState(0);
|
|
12
|
+
const mode = useEditorMode();
|
|
13
|
+
const { filteredProductImages } = useFilterImagesByVariant({
|
|
14
|
+
productImages,
|
|
15
|
+
displayByVariant: setting?.displayByVariant,
|
|
16
|
+
variantSelect: setting?.variantSelect
|
|
17
|
+
});
|
|
18
|
+
const shapeByLayout = getShapeByLayout({
|
|
19
|
+
shape: setting.shape,
|
|
20
|
+
shapeForBottom: setting.shapeForBottom,
|
|
21
|
+
shapeFor1Col: setting.shapeFor1Col,
|
|
22
|
+
shapeFor2Col: setting.shapeFor2Col,
|
|
23
|
+
shapeForFtOnly: setting.shapeForFtOnly,
|
|
24
|
+
shapeForInsideBottom: setting.shapeForInsideBottom,
|
|
25
|
+
shapeForInside: setting.shapeForInside
|
|
26
|
+
}, setting.position);
|
|
27
|
+
const enableOpenLightBox = getResponsiveValueByScreen(setting.clickOpenLightBox, currentDevice);
|
|
28
|
+
const isDisplayByWidth = checkDisplayGalleryByWidth({
|
|
29
|
+
shapeByLayout
|
|
30
|
+
});
|
|
31
|
+
const isDisplay = getResponsiveValueByScreen(isDisplayByWidth, currentDevice);
|
|
32
|
+
const isEnableBorderActive = setting?.borderActive?.border !== 'none';
|
|
33
|
+
const handleSetSrc = useCallback(()=>{
|
|
34
|
+
handleSetSrcForProductImageList({
|
|
35
|
+
builderPropUID,
|
|
36
|
+
shapeByLayout,
|
|
37
|
+
qualityType: setting.qualityType,
|
|
38
|
+
qualityPercent: setting.qualityPercent
|
|
39
|
+
});
|
|
40
|
+
}, [
|
|
41
|
+
shapeByLayout,
|
|
42
|
+
setting.qualityPercent,
|
|
43
|
+
setting.qualityType,
|
|
44
|
+
builderPropUID
|
|
45
|
+
]);
|
|
46
|
+
useEffect(()=>{
|
|
47
|
+
setImageActiveIndex(activeIndexFormFeatureImage || 0);
|
|
48
|
+
}, [
|
|
49
|
+
activeIndexFormFeatureImage
|
|
50
|
+
]);
|
|
51
|
+
useEffect(()=>{
|
|
52
|
+
const index = filteredProductImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
53
|
+
setImageActiveIndex(index && index > 0 ? index : 0);
|
|
54
|
+
}, [
|
|
55
|
+
featuredImageGlobal,
|
|
56
|
+
filteredProductImages
|
|
57
|
+
]);
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
if (mode === 'edit') return;
|
|
60
|
+
const $galleryImageGrid = document?.querySelector('.grid-gallery');
|
|
61
|
+
if (!$galleryImageGrid) return;
|
|
62
|
+
handleSetSrc();
|
|
63
|
+
const observer = new ResizeObserver(()=>{
|
|
64
|
+
handleSetSrc();
|
|
65
|
+
});
|
|
66
|
+
observer?.observe($galleryImageGrid, {});
|
|
67
|
+
return ()=>{
|
|
68
|
+
observer?.disconnect();
|
|
69
|
+
};
|
|
70
|
+
}, [
|
|
71
|
+
handleSetSrc,
|
|
72
|
+
builderPropUID,
|
|
73
|
+
mode
|
|
74
|
+
]);
|
|
75
|
+
return {
|
|
76
|
+
isDisplay,
|
|
77
|
+
shapeByLayout,
|
|
78
|
+
imageActiveIndex,
|
|
79
|
+
enableOpenLightBox,
|
|
80
|
+
isEnableBorderActive,
|
|
81
|
+
filteredProductImages
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { useProductGalleryGrid };
|