@gem-sdk/components 2.0.0-dev.692 → 2.0.0-dev.694

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.
Files changed (218) hide show
  1. package/dist/cjs/accordion/setting/configs/uiV2.js +1 -0
  2. package/dist/cjs/article/setting/configs/ArticleReadMore/settings.js +2 -0
  3. package/dist/cjs/breadcrumb/setting/configs/settings.js +1 -0
  4. package/dist/cjs/builder.js +6 -12
  5. package/dist/cjs/button/setting/configs/settings.js +1 -0
  6. package/dist/cjs/carousel/setting/configs/settingV2.js +3 -0
  7. package/dist/cjs/collection/setting/collection-banner/configs/settings.js +2 -2
  8. package/dist/cjs/countdown-timer/setting/configs/settings.js +2 -0
  9. package/dist/cjs/form/setting/submit-button/configs/settings.js +1 -0
  10. package/dist/cjs/grid/row/setting/configs/settings.js +5 -0
  11. package/dist/cjs/grid/section/setting/configs/settings.js +3 -0
  12. package/dist/cjs/icon-list/setting/configs/settings.js +2 -0
  13. package/dist/cjs/icon-list-hoz/setting/configs/settings.js +1 -0
  14. package/dist/cjs/index.js +32 -34
  15. package/dist/cjs/index.liquid.js +10 -16
  16. package/dist/cjs/marquee/setting/configs/settingsV2.js +1 -0
  17. package/dist/cjs/next.js +1 -3
  18. package/dist/cjs/product/components/ProductBundle/setting/uiV2.js +1 -0
  19. package/dist/cjs/product/components/ProductImagesV2/common/common.js +2 -1
  20. package/dist/cjs/product/index.js +4 -6
  21. package/dist/cjs/product/next.js +0 -4
  22. package/dist/cjs/product/setting/product/configs/settings.js +3 -0
  23. package/dist/cjs/product/setting/product-image-v2/configs/setting-v2/index.js +1 -0
  24. package/dist/cjs/product/setting/product-variant/configs/settings.js +2 -0
  25. package/dist/cjs/product/setting/product-view-more/configs/settings.js +1 -0
  26. package/dist/cjs/setting.js +76 -78
  27. package/dist/cjs/third-party/components/Bogos/BogosSampleContent.js +2 -1
  28. package/dist/cjs/third-party/components/Bogos.liquid.js +2 -0
  29. package/dist/cjs/third-party/setting/Bogos/index.js +5 -1
  30. package/dist/esm/accordion/setting/configs/uiV2.js +1 -0
  31. package/dist/esm/article/setting/configs/ArticleReadMore/settings.js +2 -0
  32. package/dist/esm/breadcrumb/setting/configs/settings.js +1 -0
  33. package/dist/esm/builder.js +0 -6
  34. package/dist/esm/button/setting/configs/settings.js +1 -0
  35. package/dist/esm/carousel/setting/configs/settingV2.js +3 -0
  36. package/dist/esm/collection/setting/collection-banner/configs/settings.js +2 -2
  37. package/dist/esm/countdown-timer/setting/configs/settings.js +2 -0
  38. package/dist/esm/form/setting/submit-button/configs/settings.js +1 -0
  39. package/dist/esm/grid/row/setting/configs/settings.js +5 -0
  40. package/dist/esm/grid/section/setting/configs/settings.js +3 -0
  41. package/dist/esm/icon-list/setting/configs/settings.js +2 -0
  42. package/dist/esm/icon-list-hoz/setting/configs/settings.js +1 -0
  43. package/dist/esm/index.js +0 -1
  44. package/dist/esm/index.liquid.js +0 -3
  45. package/dist/esm/marquee/setting/configs/settingsV2.js +1 -0
  46. package/dist/esm/next.js +1 -3
  47. package/dist/esm/product/components/ProductBundle/setting/uiV2.js +1 -0
  48. package/dist/esm/product/components/ProductImagesV2/common/common.js +2 -1
  49. package/dist/esm/product/index.js +24 -26
  50. package/dist/esm/product/next.js +0 -4
  51. package/dist/esm/product/setting/product/configs/settings.js +3 -0
  52. package/dist/esm/product/setting/product-image-v2/configs/setting-v2/index.js +1 -0
  53. package/dist/esm/product/setting/product-variant/configs/settings.js +2 -0
  54. package/dist/esm/product/setting/product-view-more/configs/settings.js +1 -0
  55. package/dist/esm/setting.js +0 -2
  56. package/dist/esm/third-party/components/Bogos/BogosSampleContent.js +2 -1
  57. package/dist/esm/third-party/components/Bogos.liquid.js +2 -0
  58. package/dist/esm/third-party/setting/Bogos/index.js +5 -1
  59. package/dist/types/index.d.ts +116 -551
  60. package/package.json +2 -2
  61. package/dist/cjs/product/components/ProductImagesV3/common/common.js +0 -360
  62. package/dist/cjs/product/components/ProductImagesV3/common/getAttr.js +0 -192
  63. package/dist/cjs/product/components/ProductImagesV3/common/getBorderActiveCss.js +0 -26
  64. package/dist/cjs/product/components/ProductImagesV3/common/getClasses.js +0 -94
  65. package/dist/cjs/product/components/ProductImagesV3/common/getStyle.js +0 -303
  66. package/dist/cjs/product/components/ProductImagesV3/common/hoverAction.js +0 -95
  67. package/dist/cjs/product/components/ProductImagesV3/common/productFeaturedImage.js +0 -59
  68. package/dist/cjs/product/components/ProductImagesV3/common/productGallery.js +0 -266
  69. package/dist/cjs/product/components/ProductImagesV3/components/child/MediaIcon.js +0 -63
  70. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +0 -36
  71. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +0 -109
  72. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +0 -139
  73. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +0 -100
  74. package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +0 -77
  75. package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +0 -300
  76. package/dist/cjs/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +0 -44
  77. package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +0 -83
  78. package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +0 -182
  79. package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +0 -30
  80. package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +0 -239
  81. package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +0 -28
  82. package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +0 -144
  83. package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesAttr.js +0 -14
  84. package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesClassName.js +0 -54
  85. package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesStyles.js +0 -53
  86. package/dist/cjs/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +0 -55
  87. package/dist/cjs/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +0 -41
  88. package/dist/cjs/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +0 -134
  89. package/dist/cjs/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +0 -203
  90. package/dist/cjs/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +0 -87
  91. package/dist/cjs/product/components/ProductImagesV3/index.js +0 -291
  92. package/dist/cjs/product/components/ProductImagesV3/index.liquid.js +0 -153
  93. package/dist/cjs/product/setting/product-image-v3/ProductFeatureImage.js +0 -252
  94. package/dist/cjs/product/setting/product-image-v3/ProductGalleryImage.js +0 -251
  95. package/dist/cjs/product/setting/product-image-v3/ProductImages.js +0 -74
  96. package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +0 -388
  97. package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +0 -518
  98. package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/index.js +0 -336
  99. package/dist/cjs/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +0 -118
  100. package/dist/cjs/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +0 -119
  101. package/dist/cjs/product/setting/product-image-v3/configs/uiV1.js +0 -237
  102. package/dist/cjs/product/setting/product-image-v3/configs/uiV2.js +0 -491
  103. package/dist/cjs/swiper-carousel/arrow/Arrow.js +0 -52
  104. package/dist/cjs/swiper-carousel/arrow/Arrow.liquid.js +0 -46
  105. package/dist/cjs/swiper-carousel/arrow/common/common.js +0 -119
  106. package/dist/cjs/swiper-carousel/arrow/common/getClass.js +0 -50
  107. package/dist/cjs/swiper-carousel/arrow/common/getStyle.js +0 -84
  108. package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.js +0 -34
  109. package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.liquid.js +0 -38
  110. package/dist/cjs/swiper-carousel/carousel-item/common/getClass.js +0 -29
  111. package/dist/cjs/swiper-carousel/carousel-item/common/getStyle.js +0 -79
  112. package/dist/cjs/swiper-carousel/carousel-item/hook/useCarouseItem.js +0 -22
  113. package/dist/cjs/swiper-carousel/components/common/carousel.js +0 -98
  114. package/dist/cjs/swiper-carousel/components/const/index.js +0 -5
  115. package/dist/cjs/swiper-carousel/components/hooks/useTrackPreviewPause.js +0 -34
  116. package/dist/cjs/swiper-carousel/components/plugins/AnimationPlugin.js +0 -42
  117. package/dist/cjs/swiper-carousel/components/plugins/AutoPlayPlugin.js +0 -105
  118. package/dist/cjs/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +0 -15
  119. package/dist/cjs/swiper-carousel/components/plugins/MutationPlugin.js +0 -45
  120. package/dist/cjs/swiper-carousel/dots/Dots.js +0 -51
  121. package/dist/cjs/swiper-carousel/dots/Dots.liquid.js +0 -26
  122. package/dist/cjs/swiper-carousel/dots/common/common.js +0 -28
  123. package/dist/cjs/swiper-carousel/dots/common/getClass.js +0 -40
  124. package/dist/cjs/swiper-carousel/dots/common/getStyle.js +0 -33
  125. package/dist/cjs/swiper-carousel/dots/hook/useDotsSetting.js +0 -21
  126. package/dist/cjs/swiper-carousel/index.js +0 -17
  127. package/dist/cjs/swiper-carousel/next.js +0 -22
  128. package/dist/cjs/swiper-carousel/root/Swiper.js +0 -128
  129. package/dist/cjs/swiper-carousel/root/Swiper.liquid.js +0 -104
  130. package/dist/cjs/swiper-carousel/root/common/getAttr.js +0 -25
  131. package/dist/cjs/swiper-carousel/root/common/getClass.js +0 -135
  132. package/dist/cjs/swiper-carousel/root/common/getData.js +0 -56
  133. package/dist/cjs/swiper-carousel/root/common/getStyle.js +0 -66
  134. package/dist/cjs/swiper-carousel/root/hook/useCarousel.js +0 -482
  135. package/dist/cjs/swiper-carousel/setting/Swiper.js +0 -42
  136. package/dist/cjs/swiper-carousel/setting/SwiperItem.js +0 -40
  137. package/dist/cjs/swiper-carousel/setting/configs/presets.js +0 -87
  138. package/dist/cjs/swiper-carousel/setting/configs/settingV2.js +0 -819
  139. package/dist/cjs/swiper-carousel/setting/configs/uiV2.js +0 -718
  140. package/dist/esm/product/components/ProductImagesV3/common/common.js +0 -344
  141. package/dist/esm/product/components/ProductImagesV3/common/getAttr.js +0 -189
  142. package/dist/esm/product/components/ProductImagesV3/common/getBorderActiveCss.js +0 -24
  143. package/dist/esm/product/components/ProductImagesV3/common/getClasses.js +0 -83
  144. package/dist/esm/product/components/ProductImagesV3/common/getStyle.js +0 -292
  145. package/dist/esm/product/components/ProductImagesV3/common/hoverAction.js +0 -92
  146. package/dist/esm/product/components/ProductImagesV3/common/productFeaturedImage.js +0 -53
  147. package/dist/esm/product/components/ProductImagesV3/common/productGallery.js +0 -251
  148. package/dist/esm/product/components/ProductImagesV3/components/child/MediaIcon.js +0 -59
  149. package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +0 -32
  150. package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +0 -105
  151. package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +0 -135
  152. package/dist/esm/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +0 -96
  153. package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +0 -73
  154. package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +0 -296
  155. package/dist/esm/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +0 -40
  156. package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +0 -79
  157. package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +0 -178
  158. package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +0 -26
  159. package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +0 -235
  160. package/dist/esm/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +0 -24
  161. package/dist/esm/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +0 -140
  162. package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesAttr.js +0 -12
  163. package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesClassName.js +0 -52
  164. package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesStyles.js +0 -51
  165. package/dist/esm/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +0 -53
  166. package/dist/esm/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +0 -39
  167. package/dist/esm/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +0 -132
  168. package/dist/esm/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +0 -201
  169. package/dist/esm/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +0 -85
  170. package/dist/esm/product/components/ProductImagesV3/index.js +0 -287
  171. package/dist/esm/product/components/ProductImagesV3/index.liquid.js +0 -149
  172. package/dist/esm/product/setting/product-image-v3/ProductFeatureImage.js +0 -248
  173. package/dist/esm/product/setting/product-image-v3/ProductGalleryImage.js +0 -248
  174. package/dist/esm/product/setting/product-image-v3/ProductImages.js +0 -70
  175. package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +0 -384
  176. package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +0 -515
  177. package/dist/esm/product/setting/product-image-v3/configs/setting-v2/index.js +0 -334
  178. package/dist/esm/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +0 -116
  179. package/dist/esm/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +0 -117
  180. package/dist/esm/product/setting/product-image-v3/configs/uiV1.js +0 -235
  181. package/dist/esm/product/setting/product-image-v3/configs/uiV2.js +0 -489
  182. package/dist/esm/swiper-carousel/arrow/Arrow.js +0 -48
  183. package/dist/esm/swiper-carousel/arrow/Arrow.liquid.js +0 -42
  184. package/dist/esm/swiper-carousel/arrow/common/common.js +0 -111
  185. package/dist/esm/swiper-carousel/arrow/common/getClass.js +0 -48
  186. package/dist/esm/swiper-carousel/arrow/common/getStyle.js +0 -82
  187. package/dist/esm/swiper-carousel/carousel-item/SwiperItem.js +0 -30
  188. package/dist/esm/swiper-carousel/carousel-item/SwiperItem.liquid.js +0 -34
  189. package/dist/esm/swiper-carousel/carousel-item/common/getClass.js +0 -27
  190. package/dist/esm/swiper-carousel/carousel-item/common/getStyle.js +0 -77
  191. package/dist/esm/swiper-carousel/carousel-item/hook/useCarouseItem.js +0 -20
  192. package/dist/esm/swiper-carousel/components/common/carousel.js +0 -93
  193. package/dist/esm/swiper-carousel/components/const/index.js +0 -3
  194. package/dist/esm/swiper-carousel/components/hooks/useTrackPreviewPause.js +0 -30
  195. package/dist/esm/swiper-carousel/components/plugins/AnimationPlugin.js +0 -35
  196. package/dist/esm/swiper-carousel/components/plugins/AutoPlayPlugin.js +0 -103
  197. package/dist/esm/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +0 -13
  198. package/dist/esm/swiper-carousel/components/plugins/MutationPlugin.js +0 -43
  199. package/dist/esm/swiper-carousel/dots/Dots.js +0 -47
  200. package/dist/esm/swiper-carousel/dots/Dots.liquid.js +0 -22
  201. package/dist/esm/swiper-carousel/dots/common/common.js +0 -26
  202. package/dist/esm/swiper-carousel/dots/common/getClass.js +0 -38
  203. package/dist/esm/swiper-carousel/dots/common/getStyle.js +0 -31
  204. package/dist/esm/swiper-carousel/dots/hook/useDotsSetting.js +0 -19
  205. package/dist/esm/swiper-carousel/index.js +0 -15
  206. package/dist/esm/swiper-carousel/next.js +0 -18
  207. package/dist/esm/swiper-carousel/root/Swiper.js +0 -124
  208. package/dist/esm/swiper-carousel/root/Swiper.liquid.js +0 -100
  209. package/dist/esm/swiper-carousel/root/common/getAttr.js +0 -23
  210. package/dist/esm/swiper-carousel/root/common/getClass.js +0 -133
  211. package/dist/esm/swiper-carousel/root/common/getData.js +0 -54
  212. package/dist/esm/swiper-carousel/root/common/getStyle.js +0 -64
  213. package/dist/esm/swiper-carousel/root/hook/useCarousel.js +0 -480
  214. package/dist/esm/swiper-carousel/setting/Swiper.js +0 -38
  215. package/dist/esm/swiper-carousel/setting/SwiperItem.js +0 -36
  216. package/dist/esm/swiper-carousel/setting/configs/presets.js +0 -85
  217. package/dist/esm/swiper-carousel/setting/configs/settingV2.js +0 -815
  218. package/dist/esm/swiper-carousel/setting/configs/uiV2.js +0 -713
@@ -1,132 +0,0 @@
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 };
@@ -1,201 +0,0 @@
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 };
@@ -1,85 +0,0 @@
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 };