@gem-sdk/components 2.0.0-dev.622 → 2.0.0-dev.623
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/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/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
package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var core = require('@gem-sdk/core');
|
|
8
|
+
var Carousel = require('../../../../../carousel/root/Carousel.js');
|
|
9
|
+
var CarouselItem = require('../../../../../carousel/carousel-item/CarouselItem.js');
|
|
10
|
+
var NextImage = require('../../../../../image/components/NextImage.js');
|
|
11
|
+
var Modal = require('../../../../../modal/components/Modal.js');
|
|
12
|
+
require('../../../../../modal/components/confirm.js');
|
|
13
|
+
var React = require('react');
|
|
14
|
+
var productFeaturedImage = require('../../common/productFeaturedImage.js');
|
|
15
|
+
var ProductFeatureVideo = require('../child/ProductFeatureVideo.js');
|
|
16
|
+
var MediaIcon = require('../child/MediaIcon.js');
|
|
17
|
+
|
|
18
|
+
const ProductImagesLightBox = ({ builderPropUID, productImages, open, imageRatio, onHandleClose })=>{
|
|
19
|
+
const featuredImageGlobal = core.useFeaturedImageGlobal();
|
|
20
|
+
const imageActiveIndex = React.useMemo(()=>{
|
|
21
|
+
const index = productImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
22
|
+
return index && index > 0 ? index : 0;
|
|
23
|
+
}, [
|
|
24
|
+
productImages,
|
|
25
|
+
featuredImageGlobal
|
|
26
|
+
]);
|
|
27
|
+
const showControl = {
|
|
28
|
+
desktop: productImages && productImages.length > 1,
|
|
29
|
+
mobile: productImages && productImages?.length > 1,
|
|
30
|
+
tablet: productImages && productImages?.length > 1
|
|
31
|
+
};
|
|
32
|
+
const loopControl = {
|
|
33
|
+
desktop: false,
|
|
34
|
+
mobile: false,
|
|
35
|
+
tablet: false
|
|
36
|
+
};
|
|
37
|
+
const mode = core.useEditorMode();
|
|
38
|
+
const isRenderVideo = (image)=>mode !== 'edit' && [
|
|
39
|
+
'VIDEO',
|
|
40
|
+
'EXTERNAL_VIDEO'
|
|
41
|
+
].includes(image?.contentType || '');
|
|
42
|
+
return /*#__PURE__*/ jsxRuntime.jsx(Modal.default, {
|
|
43
|
+
setting: {
|
|
44
|
+
open: open
|
|
45
|
+
},
|
|
46
|
+
styles: {
|
|
47
|
+
width: '80%'
|
|
48
|
+
},
|
|
49
|
+
closeOnClickOutside: true,
|
|
50
|
+
onClose: ()=>onHandleClose(),
|
|
51
|
+
disableIframeClickEvent: true,
|
|
52
|
+
contentClass: "mobile:!gp-w-[100%] gp-px-2 gp-pb-10",
|
|
53
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(Carousel.default, {
|
|
54
|
+
setting: {
|
|
55
|
+
loop: loopControl,
|
|
56
|
+
slidesToShow: {
|
|
57
|
+
desktop: 1,
|
|
58
|
+
tablet: 1,
|
|
59
|
+
mobile: 1
|
|
60
|
+
},
|
|
61
|
+
defaultCurrentSlider: imageActiveIndex,
|
|
62
|
+
dot: {
|
|
63
|
+
desktop: true,
|
|
64
|
+
mobile: true,
|
|
65
|
+
tablet: true
|
|
66
|
+
},
|
|
67
|
+
dotStyle: {
|
|
68
|
+
desktop: 'outside',
|
|
69
|
+
mobile: 'outside',
|
|
70
|
+
tablet: 'outside'
|
|
71
|
+
},
|
|
72
|
+
dotColor: {
|
|
73
|
+
desktop: '#E2E2E2',
|
|
74
|
+
mobile: '#E2E2E2',
|
|
75
|
+
tablet: '#E2E2E2'
|
|
76
|
+
},
|
|
77
|
+
dotActiveColor: {
|
|
78
|
+
desktop: '#121212',
|
|
79
|
+
mobile: '#121212',
|
|
80
|
+
tablet: '#121212'
|
|
81
|
+
},
|
|
82
|
+
controlOverContent: {
|
|
83
|
+
desktop: true,
|
|
84
|
+
mobile: true,
|
|
85
|
+
tablet: true
|
|
86
|
+
},
|
|
87
|
+
arrow: showControl,
|
|
88
|
+
dotSize: {
|
|
89
|
+
desktop: 12
|
|
90
|
+
},
|
|
91
|
+
dotGapToCarousel: {
|
|
92
|
+
desktop: 12
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
styles: {
|
|
96
|
+
sizeSetting: {
|
|
97
|
+
desktop: {
|
|
98
|
+
height: '80vh'
|
|
99
|
+
},
|
|
100
|
+
tablet: {
|
|
101
|
+
height: '80vh'
|
|
102
|
+
},
|
|
103
|
+
mobile: {
|
|
104
|
+
height: '60vh'
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
moveToIdx: imageActiveIndex,
|
|
109
|
+
hiddenDotWhenOnlyOne: true,
|
|
110
|
+
isHiddenArrowWhenDisabled: true,
|
|
111
|
+
builderProps: {
|
|
112
|
+
uid: builderPropUID
|
|
113
|
+
},
|
|
114
|
+
fullHeight: true,
|
|
115
|
+
children: productImages?.map((image)=>/*#__PURE__*/ jsxRuntime.jsx(CarouselItem.default, {
|
|
116
|
+
className: `gem-slider-item gem-slider-item-${builderPropUID} gp-flex gp-items-center gp-justify-center gp-px-4`,
|
|
117
|
+
children: !isRenderVideo(image) ? /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ jsxRuntime.jsx(NextImage.default, {
|
|
120
|
+
src: productFeaturedImage.isFeatureMedia(image?.contentType) ? image?.previewImage : image?.src,
|
|
121
|
+
width: image?.width,
|
|
122
|
+
height: image?.height,
|
|
123
|
+
alt: image?.alt,
|
|
124
|
+
"content-type": image?.contentType,
|
|
125
|
+
setting: {
|
|
126
|
+
aspectRatio: imageRatio
|
|
127
|
+
},
|
|
128
|
+
className: core.cls('gp-h-full gp-w-full gp-object-contain')
|
|
129
|
+
}, image?.id),
|
|
130
|
+
/*#__PURE__*/ jsxRuntime.jsx(MediaIcon.default, {
|
|
131
|
+
contentType: image?.contentType ?? ''
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
}) : /*#__PURE__*/ jsxRuntime.jsx(ProductFeatureVideo.default, {
|
|
135
|
+
type: image?.contentType,
|
|
136
|
+
url: image.src ?? '',
|
|
137
|
+
aspectRatio: imageRatio
|
|
138
|
+
})
|
|
139
|
+
}, image?.id))
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
exports.default = ProductImagesLightBox;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var getAttr = require('../common/getAttr.js');
|
|
4
|
+
|
|
5
|
+
const getProductImagesAttr = (settings)=>{
|
|
6
|
+
const galleryCarouselSettingAttrs = getAttr.getGalleryCarouselSettingAttr(settings);
|
|
7
|
+
const featuredImageCarouselSettingAttrs = getAttr.getFeaturedCarouselSettingAttr(settings);
|
|
8
|
+
return {
|
|
9
|
+
galleryCarouselSettingAttrs,
|
|
10
|
+
featuredImageCarouselSettingAttrs
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.getProductImagesAttr = getProductImagesAttr;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var system = require('@gem-sdk/system');
|
|
4
|
+
var getClasses = require('../common/getClasses.js');
|
|
5
|
+
var common = require('../common/common.js');
|
|
6
|
+
|
|
7
|
+
const getProductImagesClassName = (props)=>{
|
|
8
|
+
const { setting, style } = props;
|
|
9
|
+
const productImagesProps = common.setDefaultWhenUndefineSetting(props);
|
|
10
|
+
const { builderProps, advanced } = productImagesProps;
|
|
11
|
+
const extraClass = advanced?.cssClass;
|
|
12
|
+
const wrapperClasses = system.createClass(getClasses.getWrapperClasses({
|
|
13
|
+
extraClass: `${builderProps?.uid} ${extraClass ?? ''} `,
|
|
14
|
+
isAddOverFlowClass: common.checkAddOverFlowClass(style)
|
|
15
|
+
}));
|
|
16
|
+
const productImagesGalleryClasses = system.createClass(getClasses.getGalleryWrapperClasses({}));
|
|
17
|
+
const galleryGridWrapperClasses = system.createClass(getClasses.getGalleryGridWrapperClasses({}));
|
|
18
|
+
const galleryItemClasses = (className)=>system.createClass(getClasses.getGalleryItemClasses({
|
|
19
|
+
extraClass: `${className ?? ''}`
|
|
20
|
+
}));
|
|
21
|
+
const ftImageGalleryClasses = system.createClass(getClasses.getFtImageWithGalleryClasses({
|
|
22
|
+
extraClass: `gp-product-images-feature--${builderProps?.uid}`
|
|
23
|
+
}));
|
|
24
|
+
const imageGalleryWrapperClasses = system.createClass(getClasses.getImageGalleryWrapperClasses({
|
|
25
|
+
extraClass: `gp-product-images-gallery-${builderProps?.uid}`
|
|
26
|
+
}));
|
|
27
|
+
const featuredImageCarouselClasses = system.createClass(getClasses.getFeaturedImageCarouselClasses({
|
|
28
|
+
extraClass: `gp-product-images-gallery-${builderProps?.uid}`
|
|
29
|
+
}));
|
|
30
|
+
const featuredImageGalleryClasses = system.createClass(getClasses.getFeaturedImageGalleryClasses({
|
|
31
|
+
settings: setting
|
|
32
|
+
}));
|
|
33
|
+
const featureImageOnlyOneImageClasses = system.createClass(getClasses.getFeaturedImageClasses({
|
|
34
|
+
setting,
|
|
35
|
+
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 `
|
|
36
|
+
}));
|
|
37
|
+
const featuredCarouselItemClasses = (className)=>system.createClass(getClasses.getFeaturedCarouselItemClasses({
|
|
38
|
+
extraClass: `${className ?? ''}`
|
|
39
|
+
}));
|
|
40
|
+
return {
|
|
41
|
+
wrapperClasses,
|
|
42
|
+
productImagesGalleryClasses,
|
|
43
|
+
galleryGridWrapperClasses,
|
|
44
|
+
galleryItemClasses,
|
|
45
|
+
ftImageGalleryClasses,
|
|
46
|
+
imageGalleryWrapperClasses,
|
|
47
|
+
featuredImageCarouselClasses,
|
|
48
|
+
featuredImageGalleryClasses,
|
|
49
|
+
featureImageOnlyOneImageClasses,
|
|
50
|
+
featuredCarouselItemClasses
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
exports.getProductImagesClassName = getProductImagesClassName;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var system = require('@gem-sdk/system');
|
|
4
|
+
var getStyle = require('../common/getStyle.js');
|
|
5
|
+
|
|
6
|
+
const getProductImagesStyles = (settings, options)=>{
|
|
7
|
+
const wrapContainerStyle = system.createStyle(getStyle.getWrapContainerStyle(settings));
|
|
8
|
+
const wrapContainerStyleOnlyOneImage = system.createStyle(getStyle.getWrapContainerStyle(settings, true));
|
|
9
|
+
const wrapperFeaturedImageStyle = system.createStyle(getStyle.getWrapContainerStyle(settings, options?.gallery && options?.gallery?.length < 2));
|
|
10
|
+
const featureImageStyle = system.createStyle(getStyle.getFeatureImageStyle(settings, {
|
|
11
|
+
enableOrder: true,
|
|
12
|
+
enableDisplay: true
|
|
13
|
+
}));
|
|
14
|
+
const featureImageOnlyOneImageStyle = system.createStyle(getStyle.getFeaturedImageOnlyOneImageStyle({
|
|
15
|
+
settings,
|
|
16
|
+
options: {
|
|
17
|
+
enableRadius: true,
|
|
18
|
+
enableHeight: true
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
const galleryImageStyle = system.createStyle(getStyle.getGalleryImageStyle(settings, options?.featureImageHeight));
|
|
22
|
+
const featuredImageCarouselStyle = system.createStyle(getStyle.getFeaturedImageCarouselStyle(settings));
|
|
23
|
+
const featureImageCarouselItemStyle = system.createStyle({
|
|
24
|
+
...getStyle.getFeatureImageCarouselItemStyle(settings)
|
|
25
|
+
});
|
|
26
|
+
const featureImageCarouselOnlyOneImageStyle = system.createStyle({
|
|
27
|
+
...getStyle.getFeatureImageCarouselItemStyle(settings),
|
|
28
|
+
...{
|
|
29
|
+
width: '{{productImageWidth}}px'
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const galleryGridStyles = system.createStyle(getStyle.getGalleryGridStyle(settings));
|
|
33
|
+
const galleryGridItemStyles = system.createStyle(getStyle.getGalleryGridItemStyle(settings));
|
|
34
|
+
const galleryCarouselStyle = system.createStyle(getStyle.getGalleryCarouselStyle(settings));
|
|
35
|
+
const galleryCarouselItemStyle = system.createStyle(getStyle.getGalleryCarouselItemStyle(settings));
|
|
36
|
+
return {
|
|
37
|
+
wrapContainerStyle,
|
|
38
|
+
wrapContainerStyleOnlyOneImage,
|
|
39
|
+
wrapperFeaturedImageStyle,
|
|
40
|
+
featureImageStyle,
|
|
41
|
+
featureImageOnlyOneImageStyle,
|
|
42
|
+
galleryImageStyle,
|
|
43
|
+
featuredImageCarouselStyle,
|
|
44
|
+
featureImageCarouselItemStyle,
|
|
45
|
+
featureImageCarouselOnlyOneImageStyle,
|
|
46
|
+
galleryGridStyles,
|
|
47
|
+
galleryGridItemStyles,
|
|
48
|
+
galleryCarouselStyle,
|
|
49
|
+
galleryCarouselItemStyle
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
exports.getProductImagesStyles = getProductImagesStyles;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var common = require('../common/common.js');
|
|
6
|
+
|
|
7
|
+
const useFeatureImageWithGallery = (props)=>{
|
|
8
|
+
const { setting, styles } = props;
|
|
9
|
+
const settings = {
|
|
10
|
+
...setting,
|
|
11
|
+
...styles
|
|
12
|
+
};
|
|
13
|
+
const currentDevice = core.useCurrentDevice();
|
|
14
|
+
const timeout = React.useRef(null);
|
|
15
|
+
const featureWrapperImage = React.useRef(null);
|
|
16
|
+
const [onClickFeatureArrow, setOnClickFeatureArrow] = React.useState('');
|
|
17
|
+
const [featureImageHeight, setFeatureImageHeight] = React.useState(100);
|
|
18
|
+
const [activeIndexFromFeatureImage, setActiveIndexFromFeatureImage] = React.useState();
|
|
19
|
+
const position = core.getResponsiveValueByScreen(settings?.position, currentDevice);
|
|
20
|
+
const isShowCarousel = common.getTypeWidthDevice(settings?.type)[currentDevice] === 'slider' || [
|
|
21
|
+
'left',
|
|
22
|
+
'right',
|
|
23
|
+
'inside-left',
|
|
24
|
+
'inside-right'
|
|
25
|
+
].includes(position);
|
|
26
|
+
const onHandleLoadedFeatureImage = (status, timeOut = 200)=>{
|
|
27
|
+
if (status) {
|
|
28
|
+
if (timeout.current) clearTimeout(timeout.current);
|
|
29
|
+
timeout.current = setTimeout(()=>setFeatureImageHeight(featureWrapperImage?.current?.offsetHeight || 200), timeOut);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
React.useEffect(()=>{
|
|
33
|
+
const element = featureWrapperImage?.current;
|
|
34
|
+
if (!element) return;
|
|
35
|
+
const observer = new ResizeObserver(()=>{
|
|
36
|
+
setFeatureImageHeight(element.offsetHeight || 200);
|
|
37
|
+
});
|
|
38
|
+
observer.observe(element);
|
|
39
|
+
return ()=>{
|
|
40
|
+
observer.disconnect();
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
isShowCarousel,
|
|
45
|
+
featureImageHeight,
|
|
46
|
+
featureWrapperImage,
|
|
47
|
+
onClickFeatureArrow,
|
|
48
|
+
activeIndexFromFeatureImage,
|
|
49
|
+
setOnClickFeatureArrow,
|
|
50
|
+
onHandleLoadedFeatureImage,
|
|
51
|
+
setActiveIndexFromFeatureImage
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.useFeatureImageWithGallery = useFeatureImageWithGallery;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
const useFilterImagesByVariant = ({ productImages, displayByVariant, variantSelect })=>{
|
|
7
|
+
const currentVariant = core.useCurrentVariant();
|
|
8
|
+
const getSelectedVariantOptionValue = React.useCallback(()=>{
|
|
9
|
+
const selectedVariantOptions = currentVariant?.selectedOptions ?? [];
|
|
10
|
+
const variantOption = selectedVariantOptions.find((item)=>item.name === variantSelect);
|
|
11
|
+
return variantOption?.value?.toLowerCase() ?? '';
|
|
12
|
+
}, [
|
|
13
|
+
currentVariant?.selectedOptions,
|
|
14
|
+
variantSelect
|
|
15
|
+
]);
|
|
16
|
+
const filteredProductImages = React.useMemo(()=>{
|
|
17
|
+
if (!displayByVariant || !variantSelect || !productImages) {
|
|
18
|
+
return productImages;
|
|
19
|
+
}
|
|
20
|
+
const selectedValue = getSelectedVariantOptionValue();
|
|
21
|
+
if (!selectedValue) {
|
|
22
|
+
return productImages;
|
|
23
|
+
}
|
|
24
|
+
const filteredImages = productImages.filter((image)=>{
|
|
25
|
+
const imageAlt = (image.alt || '').toLowerCase();
|
|
26
|
+
return imageAlt.includes(selectedValue);
|
|
27
|
+
});
|
|
28
|
+
return filteredImages.length > 0 ? filteredImages : productImages;
|
|
29
|
+
}, [
|
|
30
|
+
displayByVariant,
|
|
31
|
+
variantSelect,
|
|
32
|
+
productImages,
|
|
33
|
+
getSelectedVariantOptionValue
|
|
34
|
+
]);
|
|
35
|
+
return {
|
|
36
|
+
filteredProductImages,
|
|
37
|
+
selectedVariantValue: getSelectedVariantOptionValue()
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.useFilterImagesByVariant = useFilterImagesByVariant;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var useFilterImagesByVariant = require('./useFilterImagesByVariant.js');
|
|
6
|
+
var getSrcSet = require('../../../../image/helpers/getSrcSet.js');
|
|
7
|
+
var productGallery = require('../common/productGallery.js');
|
|
8
|
+
|
|
9
|
+
const useGalleryCarousel = (props)=>{
|
|
10
|
+
const { builderPropUID, productImages, onHandleClick, activeIndexFormFeatureImage, onClickFeatureArrow, builderPropsClass, arrow, priorityFeatureImage, ...setting } = props;
|
|
11
|
+
const currentDevice = core.useCurrentDevice();
|
|
12
|
+
const featuredImageGlobal = core.useFeaturedImageGlobal();
|
|
13
|
+
const [hasClickFeatureArrow, setHasClickFeatureArrow] = React.useState(onClickFeatureArrow || '');
|
|
14
|
+
const mode = core.useEditorMode();
|
|
15
|
+
const [moveToIdx, setMoveToIdx] = React.useState(0);
|
|
16
|
+
const { filteredProductImages } = useFilterImagesByVariant.useFilterImagesByVariant({
|
|
17
|
+
productImages,
|
|
18
|
+
displayByVariant: setting?.displayByVariant,
|
|
19
|
+
variantSelect: setting?.variantSelect
|
|
20
|
+
});
|
|
21
|
+
React.useEffect(()=>{
|
|
22
|
+
setHasClickFeatureArrow(onClickFeatureArrow || '');
|
|
23
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
|
+
}, [
|
|
25
|
+
onClickFeatureArrow
|
|
26
|
+
]);
|
|
27
|
+
React.useEffect(()=>{
|
|
28
|
+
if (hasClickFeatureArrow) {
|
|
29
|
+
setMoveToIdx(activeIndexFormFeatureImage || 0);
|
|
30
|
+
setHasClickFeatureArrow('');
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33
|
+
}, [
|
|
34
|
+
activeIndexFormFeatureImage
|
|
35
|
+
]);
|
|
36
|
+
React.useEffect(()=>{
|
|
37
|
+
if (priorityFeatureImage) {
|
|
38
|
+
const indexPriorityFeatureImage = filteredProductImages?.findIndex((item)=>item.id === priorityFeatureImage.id) || 0;
|
|
39
|
+
setMoveToIdx(indexPriorityFeatureImage);
|
|
40
|
+
setHasClickFeatureArrow('');
|
|
41
|
+
}
|
|
42
|
+
}, [
|
|
43
|
+
priorityFeatureImage,
|
|
44
|
+
filteredProductImages
|
|
45
|
+
]);
|
|
46
|
+
React.useEffect(()=>{
|
|
47
|
+
const index = filteredProductImages?.findIndex((item)=>item.id === featuredImageGlobal?.id);
|
|
48
|
+
setMoveToIdx(index || 0);
|
|
49
|
+
setHasClickFeatureArrow('');
|
|
50
|
+
}, [
|
|
51
|
+
featuredImageGlobal,
|
|
52
|
+
filteredProductImages
|
|
53
|
+
]);
|
|
54
|
+
const shapeByLayout = React.useMemo(()=>{
|
|
55
|
+
return productGallery.getShapeByLayout({
|
|
56
|
+
shape: setting.shape,
|
|
57
|
+
shapeForBottom: setting.shapeForBottom,
|
|
58
|
+
shapeFor1Col: setting.shapeFor1Col,
|
|
59
|
+
shapeFor2Col: setting.shapeFor2Col,
|
|
60
|
+
shapeForFtOnly: setting.shapeForFtOnly,
|
|
61
|
+
shapeForInsideBottom: setting.shapeForInsideBottom,
|
|
62
|
+
shapeForInside: setting.shapeForInside
|
|
63
|
+
}, setting.position);
|
|
64
|
+
}, [
|
|
65
|
+
setting.shape,
|
|
66
|
+
setting.shapeForBottom,
|
|
67
|
+
setting.shapeFor1Col,
|
|
68
|
+
setting.shapeFor2Col,
|
|
69
|
+
setting.shapeForFtOnly,
|
|
70
|
+
setting.position,
|
|
71
|
+
setting.shapeForInsideBottom,
|
|
72
|
+
setting.shapeForInside
|
|
73
|
+
]);
|
|
74
|
+
const handleSetSrc = React.useCallback(()=>{
|
|
75
|
+
getSrcSet.handleSetSrcForProductImageList({
|
|
76
|
+
builderPropUID,
|
|
77
|
+
shapeByLayout,
|
|
78
|
+
qualityType: setting.qualityType,
|
|
79
|
+
qualityPercent: setting.qualityPercent
|
|
80
|
+
});
|
|
81
|
+
}, [
|
|
82
|
+
shapeByLayout,
|
|
83
|
+
setting.qualityPercent,
|
|
84
|
+
setting.qualityType,
|
|
85
|
+
builderPropUID
|
|
86
|
+
]);
|
|
87
|
+
React.useEffect(()=>{
|
|
88
|
+
if (mode === 'edit') return;
|
|
89
|
+
const $galleryImageGrid = document?.querySelector(`.gem-slider-item-${builderPropUID} .product-list-image`);
|
|
90
|
+
if (!$galleryImageGrid) return;
|
|
91
|
+
handleSetSrc();
|
|
92
|
+
const observer = new ResizeObserver(()=>{
|
|
93
|
+
handleSetSrc();
|
|
94
|
+
});
|
|
95
|
+
observer?.observe($galleryImageGrid, {});
|
|
96
|
+
return ()=>{
|
|
97
|
+
observer?.disconnect();
|
|
98
|
+
};
|
|
99
|
+
}, [
|
|
100
|
+
handleSetSrc,
|
|
101
|
+
builderPropUID,
|
|
102
|
+
mode
|
|
103
|
+
]);
|
|
104
|
+
const enableOpenLightBox = core.getResponsiveValueByScreen(setting.clickOpenLightBox, currentDevice);
|
|
105
|
+
const isDisplay = React.useMemo(()=>{
|
|
106
|
+
const isDisplayByWidth = productGallery.checkDisplayGalleryByWidth({
|
|
107
|
+
shapeByLayout
|
|
108
|
+
});
|
|
109
|
+
return core.getResponsiveValueByScreen(isDisplayByWidth, currentDevice);
|
|
110
|
+
}, [
|
|
111
|
+
shapeByLayout,
|
|
112
|
+
currentDevice
|
|
113
|
+
]);
|
|
114
|
+
const isEnableBorderActive = React.useMemo(()=>{
|
|
115
|
+
return setting?.borderActive?.border !== 'none';
|
|
116
|
+
}, [
|
|
117
|
+
setting?.borderActive?.border
|
|
118
|
+
]);
|
|
119
|
+
const isShowButtonLightbox = core.getResponsiveValueByScreen(setting?.clickOpenLightBox, currentDevice);
|
|
120
|
+
const handleClickCarouselItem = (imageId)=>{
|
|
121
|
+
onHandleClick && onHandleClick(imageId || '', enableOpenLightBox);
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
moveToIdx,
|
|
125
|
+
isDisplay,
|
|
126
|
+
shapeByLayout,
|
|
127
|
+
isEnableBorderActive,
|
|
128
|
+
isShowButtonLightbox,
|
|
129
|
+
filteredProductImages,
|
|
130
|
+
handleClickCarouselItem
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
exports.useGalleryCarousel = useGalleryCarousel;
|