@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,64 +0,0 @@
1
- import { makeStyleResponsive, getHeightByShapeGlobalSize, makeStyleWithDefault, getWidthByShapeGlobalSize, getBgByDevice, makeContainerWidthOrHeight, getResponsiveValueByScreen } from '@gem-sdk/core';
2
- import { createStyle } from '@gem-sdk/system';
3
-
4
- const getStyle = (props)=>{
5
- const DEVICES = [
6
- 'mobile',
7
- 'tablet',
8
- 'desktop'
9
- ];
10
- const { styles, setting, style, rootStyles } = props;
11
- const { arrowGapToEachSide = '16' } = setting ?? {};
12
- const styleHeight = makeStyleResponsive('h', getHeightByShapeGlobalSize(styles?.sizeSetting));
13
- const styleWidth = makeStyleWithDefault('w', getWidthByShapeGlobalSize(styles?.sizeSetting, true), {
14
- desktop: '--g-ct-w',
15
- tablet: '--g-ct-w',
16
- mobile: '--g-ct-w'
17
- });
18
- const makeSpacing = ()=>{
19
- let result = {};
20
- DEVICES.forEach((device)=>{
21
- const isVertical = getResponsiveValueByScreen(setting?.vertical, device);
22
- const spacing = getResponsiveValueByScreen(styles?.spacing, device);
23
- const key = isVertical ? `--rg${device !== 'desktop' ? `-${device}` : ''}` : `--cg${device !== 'desktop' ? `-${device}` : ''}`;
24
- result = {
25
- ...result,
26
- [key]: `${spacing ?? 0}px`
27
- };
28
- });
29
- return result;
30
- };
31
- const wrapperStyleRender = createStyle({
32
- ...style,
33
- ...styleHeight,
34
- ...styleWidth,
35
- ...getBgByDevice({
36
- backgroundColor: styles?.backgroundColor,
37
- backgroundImage: styles?.backgroundImage
38
- })
39
- });
40
- const wrapperInnerStyle = createStyle({
41
- ...makeContainerWidthOrHeight({
42
- vertical: setting?.vertical,
43
- dotStyle: setting?.dotStyle
44
- }),
45
- gap: arrowGapToEachSide + 'px'
46
- });
47
- const rootStyleRender = createStyle({
48
- ...makeStyleResponsive('jc', styles?.align),
49
- ...rootStyles
50
- });
51
- const sliderStyle = createStyle({
52
- ...styleWidth,
53
- ...styleHeight,
54
- ...makeSpacing()
55
- });
56
- return {
57
- rootStyleRender,
58
- wrapperStyleRender,
59
- wrapperInnerStyle,
60
- sliderStyle
61
- };
62
- };
63
-
64
- export { getStyle };
@@ -1,480 +0,0 @@
1
- import { useKeenSlider } from '@gem-sdk/keen-slider/react';
2
- import { AutoPlayPlugin } from '../../components/plugins/AutoPlayPlugin.js';
3
- import { CAROUSEL_ANIMATION, DEFAULT_PLAY_SPEED, AnimationPlugin } from '../../components/plugins/AnimationPlugin.js';
4
- import { useState, useRef, useCallback, useMemo, useImperativeHandle, useEffect } from 'react';
5
- import { useCurrentDevice, useEditorMode, useInteraction, DEVICES, getResponsiveValueByScreen } from '@gem-sdk/core';
6
- import { MutationPlugin } from '../../components/plugins/MutationPlugin.js';
7
- import { FixSliderMoveBackwards } from '../../components/plugins/FixSliderMoveBackwards.js';
8
- import useTrackPreviewPause from '../../components/hooks/useTrackPreviewPause.js';
9
- import { getData } from '../common/getData.js';
10
-
11
- const useCarousel = (props, ref)=>{
12
- const { builderProps, moveToIdx, styles, setting, isHiddenArrowWhenDisabled = true, elmRef, onChangeActive, onLoaded, onUpdated, onCreated, onClickArrow, onHandleChangeSlideByInteraction } = props;
13
- const { loop, navigationEnable = {
14
- desktop: true
15
- }, navigationStyle } = setting ?? {};
16
- const [isInfinity, setIsInfinity] = useState(false);
17
- const [totalSlideItem, setTotalSlideItem] = useState(0);
18
- const [slideMaxIndex, setSlideMaxIndex] = useState(0);
19
- const [currentSlide, setCurrentSlide] = useState(setting?.defaultCurrentSlider ?? 0);
20
- const [loaded, setLoaded] = useState(false);
21
- const [slider, setSlider] = useState();
22
- const { sliderSelector } = getData(props);
23
- const localRef = useRef();
24
- const isRunningAnimation = useRef(false);
25
- const previousIndex = useRef(moveToIdx ?? 0);
26
- let delayTimeout;
27
- const currentDevice = useCurrentDevice();
28
- const mode = useEditorMode();
29
- const { isFirstPreviewClicked } = useTrackPreviewPause(setting?.runPreview);
30
- const { onListener, saveToElementInteractionData, getInteractionPreviousData, trigger } = useInteraction();
31
- const getItemNumberFromOldData = useCallback(()=>{
32
- if (!setting?.slidesToShow) return null;
33
- const result = {};
34
- DEVICES.forEach((device)=>{
35
- const value = getResponsiveValueByScreen(setting?.slidesToShow, device);
36
- result[device] = value ? value === 'auto' ? 4 : Math.floor(value) : 0;
37
- });
38
- return result;
39
- }, [
40
- setting?.slidesToShow
41
- ]);
42
- const getSlideToShowFromOldData = useCallback(()=>{
43
- if (!setting?.slidesToShow) return null;
44
- const result = {};
45
- DEVICES.forEach((device)=>{
46
- const value = getResponsiveValueByScreen(setting?.slidesToShow, device);
47
- result[device] = value ? value === 'auto' ? 4 : value : 0;
48
- });
49
- return result;
50
- }, [
51
- setting?.slidesToShow
52
- ]);
53
- const slidesToShow = useMemo(()=>{
54
- const oldData = getSlideToShowFromOldData();
55
- if (oldData) {
56
- return oldData;
57
- }
58
- const result = {};
59
- DEVICES.forEach((device)=>{
60
- const enableSneakPeak = getResponsiveValueByScreen(setting?.sneakPeak, device);
61
- const offset = enableSneakPeak ? getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? getResponsiveValueByScreen(setting?.sneakPeakOffsetCenter, device) ?? 0 : getResponsiveValueByScreen(setting?.sneakPeakOffsetForward, device) ?? 0 : 0;
62
- const rx = getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? -2 : -1;
63
- const itemNumberByDevice = getResponsiveValueByScreen(setting?.itemNumber, device);
64
- result[device] = typeof itemNumberByDevice === 'number' ? itemNumberByDevice + offset / 100 * rx : 'auto';
65
- });
66
- return result;
67
- }, [
68
- getSlideToShowFromOldData,
69
- setting?.itemNumber,
70
- setting?.sneakPeak,
71
- setting?.sneakPeakOffsetCenter,
72
- setting?.sneakPeakOffsetForward,
73
- setting?.sneakPeakType
74
- ]);
75
- const itemNumber = useMemo(()=>{
76
- const oldData = getItemNumberFromOldData();
77
- return oldData || setting?.itemNumber;
78
- }, [
79
- getItemNumberFromOldData,
80
- setting?.itemNumber
81
- ]);
82
- const getNumberOfFullWidthShow = useCallback((device)=>{
83
- const sneakPeekTypeByNumber = getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? 2 : 1;
84
- return typeof getResponsiveValueByScreen(itemNumber, device, 4) === 'number' ? getResponsiveValueByScreen(itemNumber, device, 4) - sneakPeekTypeByNumber : undefined;
85
- }, [
86
- setting?.sneakPeakType,
87
- itemNumber
88
- ]);
89
- const getOriginCarousel = useMemo(()=>(device)=>{
90
- const origin = getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' && getResponsiveValueByScreen(setting?.sneakPeak, device) ? 'center' : 'auto';
91
- return origin;
92
- }, [
93
- setting?.sneakPeak,
94
- setting?.sneakPeakType
95
- ]);
96
- const getMaxNavigationWhenSneak = useMemo(()=>(device)=>{
97
- if (getOriginCarousel(device) !== 'center') return {};
98
- const totalItems = setting?.childItem?.length || 1;
99
- let itemShow = Number(getResponsiveValueByScreen(slidesToShow, device, 1)) || 1 + 1;
100
- if (setting?.sneakPeak?.[currentDevice]) {
101
- itemShow = Math.trunc(Number(getNumberOfFullWidthShow(device)));
102
- }
103
- const max = totalItems - itemShow;
104
- const isLoopByDevice = getResponsiveValueByScreen(loop, device, false);
105
- if (isLoopByDevice) return {
106
- max: undefined
107
- };
108
- return {
109
- max
110
- };
111
- }, [
112
- setting?.childItem,
113
- slidesToShow,
114
- getOriginCarousel,
115
- loop,
116
- currentDevice,
117
- setting?.sneakPeak,
118
- getNumberOfFullWidthShow
119
- ]);
120
- const removeInitialCarouselGap = ()=>{
121
- const sliderElm = document.querySelectorAll(`.${sliderSelector}`);
122
- if (!sliderElm) return;
123
- sliderElm.forEach((selector)=>{
124
- selector?.style.removeProperty('--cg');
125
- selector?.style.removeProperty('--cg-tablet');
126
- selector?.style.removeProperty('--cg-mobile');
127
- selector?.style.removeProperty('--rg');
128
- selector?.style.removeProperty('--rg-tablet');
129
- selector?.style.removeProperty('--rg-mobile');
130
- });
131
- };
132
- const [sliderRef, instanceRef] = useKeenSlider({
133
- selector: `.gem-slider-item-${builderProps?.uid}`,
134
- optionsChanged: (slider)=>{
135
- if (slider?.track?.details?.maxIdx === Infinity) {
136
- setIsInfinity(true);
137
- } else {
138
- setIsInfinity(false);
139
- }
140
- setTotalSlideItem(Math.ceil(slider.slides.length));
141
- setSlideMaxIndex(slider?.track?.details?.maxIdx);
142
- },
143
- defaultAnimation: {
144
- duration: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
145
- easing: (t)=>{
146
- switch(setting?.animationMode){
147
- case CAROUSEL_ANIMATION.EASE_IN.value:
148
- return CAROUSEL_ANIMATION.EASE_IN.formula(t);
149
- case CAROUSEL_ANIMATION.EASE_OUT.value:
150
- return CAROUSEL_ANIMATION.EASE_OUT.formula(t);
151
- case CAROUSEL_ANIMATION.EASE_IN_OUT.value:
152
- return CAROUSEL_ANIMATION.EASE_IN_OUT.formula(t);
153
- default:
154
- return CAROUSEL_ANIMATION.DEFAULT.formula(t);
155
- }
156
- }
157
- },
158
- dragSpeed: 2,
159
- renderMode: 'precision',
160
- mode: 'snap',
161
- loop: getResponsiveValueByScreen(loop, 'desktop', false),
162
- vertical: getResponsiveValueByScreen(setting?.vertical, 'desktop'),
163
- rtl: setting?.rtl,
164
- breakpoints: {
165
- '(max-width: 9999px)': {
166
- slides: {
167
- perView: getResponsiveValueByScreen(slidesToShow, 'desktop', 4) ?? 1,
168
- spacing: getResponsiveValueByScreen(styles?.spacing, 'desktop'),
169
- origin: getOriginCarousel('desktop'),
170
- numberOfFullWidthShow: getNumberOfFullWidthShow('desktop')
171
- },
172
- loop: getResponsiveValueByScreen(loop, 'desktop', false),
173
- vertical: getResponsiveValueByScreen(setting?.vertical, 'desktop'),
174
- drag: getResponsiveValueByScreen(mode == 'edit' ? {
175
- desktop: false
176
- } : setting?.enableDrag, 'desktop'),
177
- initial: moveToIdx ?? 0,
178
- range: getMaxNavigationWhenSneak('desktop')
179
- },
180
- '(max-width: 1024px)': {
181
- slides: {
182
- perView: getResponsiveValueByScreen(slidesToShow, 'tablet', 4),
183
- spacing: getResponsiveValueByScreen(styles?.spacing, 'tablet'),
184
- origin: getOriginCarousel('tablet'),
185
- numberOfFullWidthShow: getNumberOfFullWidthShow('tablet')
186
- },
187
- loop: getResponsiveValueByScreen(loop, 'tablet', false),
188
- vertical: getResponsiveValueByScreen(setting?.vertical, 'tablet'),
189
- drag: getResponsiveValueByScreen(mode == 'edit' ? {
190
- tablet: false
191
- } : setting?.enableDrag, 'tablet'),
192
- initial: moveToIdx || 0,
193
- range: getMaxNavigationWhenSneak('tablet')
194
- },
195
- '(max-width: 767px)': {
196
- slides: {
197
- perView: getResponsiveValueByScreen(slidesToShow, 'mobile', 4),
198
- spacing: getResponsiveValueByScreen(styles?.spacing, 'mobile'),
199
- origin: getOriginCarousel('mobile'),
200
- numberOfFullWidthShow: getNumberOfFullWidthShow('mobile')
201
- },
202
- loop: getResponsiveValueByScreen(loop, 'mobile', false),
203
- vertical: getResponsiveValueByScreen(setting?.vertical, 'mobile'),
204
- drag: getResponsiveValueByScreen(mode == 'edit' ? {
205
- mobile: false
206
- } : setting?.enableDrag, 'mobile'),
207
- initial: moveToIdx ?? 0,
208
- range: getMaxNavigationWhenSneak('mobile')
209
- }
210
- },
211
- slideChanged: (slider)=>{
212
- setCurrentSlide(slider.track.details.rel);
213
- previousIndex.current = slider.track.details.rel;
214
- onChangeActive && onChangeActive(slider.track.details.rel);
215
- },
216
- created: (slider)=>{
217
- setLoaded(true);
218
- setSlider(slider);
219
- setCurrentSlide(slider.track?.details?.rel ?? 0);
220
- onCreated && onCreated(slider);
221
- removeInitialCarouselGap();
222
- },
223
- updated: (slider)=>{
224
- onLoaded && onLoaded(true);
225
- onUpdated && onUpdated(slider);
226
- },
227
- autoplay: {
228
- delay: (setting?.autoplayTimeout ?? 1) * 1000,
229
- pauseOnHover: setting?.pauseOnHover,
230
- enable: mode === 'edit' ? isFirstPreviewClicked ? setting?.runPreview && setting?.autoplay : false : setting?.autoplay
231
- },
232
- animation: {
233
- type: setting?.animationMode,
234
- speed: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500
235
- },
236
- dragStarted: (slider)=>{
237
- slider.container.style.cursor = 'grabbing';
238
- },
239
- dragEnded: (slider)=>{
240
- slider.container.style.cursor = 'auto';
241
- },
242
- animationStarted: (slider)=>{
243
- // This code used to handle when user click next/prev button constantly
244
- if (!isRunningAnimation.current) {
245
- isRunningAnimation.current = true;
246
- } else {
247
- slider.options.defaultAnimation = {
248
- duration: DEFAULT_PLAY_SPEED,
249
- easing: (t)=>CAROUSEL_ANIMATION.DEFAULT.formula(t)
250
- };
251
- }
252
- },
253
- animationEnded: (slider)=>{
254
- isRunningAnimation.current = false;
255
- slider.options.defaultAnimation = {
256
- duration: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
257
- easing (t) {
258
- switch(setting?.animationMode){
259
- case CAROUSEL_ANIMATION.EASE_IN.value:
260
- return CAROUSEL_ANIMATION.EASE_IN.formula(t);
261
- case CAROUSEL_ANIMATION.EASE_OUT.value:
262
- return CAROUSEL_ANIMATION.EASE_OUT.formula(t);
263
- case CAROUSEL_ANIMATION.EASE_IN_OUT.value:
264
- return CAROUSEL_ANIMATION.EASE_IN_OUT.formula(t);
265
- default:
266
- return CAROUSEL_ANIMATION.EASE_IN.formula(t);
267
- }
268
- }
269
- };
270
- }
271
- }, [
272
- MutationPlugin,
273
- AutoPlayPlugin,
274
- AnimationPlugin,
275
- FixSliderMoveBackwards
276
- ]);
277
- const isRenderDots = useMemo(()=>loaded && !!totalSlideItem && instanceRef.current && getResponsiveValueByScreen(setting?.dot), [
278
- instanceRef,
279
- loaded,
280
- setting?.dot,
281
- totalSlideItem
282
- ]);
283
- const showNavigation = useMemo(()=>{
284
- const navigationEnableByDevice = getResponsiveValueByScreen(navigationEnable, currentDevice);
285
- const navigationStyleByDevice = getResponsiveValueByScreen(navigationStyle, currentDevice);
286
- return loaded && instanceRef.current && navigationEnableByDevice && navigationStyleByDevice !== 'none';
287
- }, [
288
- currentDevice,
289
- instanceRef,
290
- loaded,
291
- navigationEnable,
292
- navigationStyle
293
- ]);
294
- const getItemsPerPage = ()=>{
295
- const items = getResponsiveValueByScreen(slidesToShow, currentDevice, 1) === 'auto' ? 1 : getResponsiveValueByScreen(slidesToShow, currentDevice, 1);
296
- return items ?? 1;
297
- };
298
- const getIndexSlideItemBy = (pageIdx)=>{
299
- let indexPage = pageIdx * getItemsPerPage();
300
- if (indexPage >= totalSlideItem - getItemsPerPage()) {
301
- indexPage = totalSlideItem - getItemsPerPage();
302
- }
303
- return indexPage;
304
- };
305
- const handleDotClick = (idx, isLoop)=>{
306
- const index = setting?.sneakPeak?.[currentDevice] ? idx : isLoop ? idx : getIndexSlideItemBy(idx);
307
- instanceRef.current?.moveToIdx(index);
308
- previousIndex.current = index;
309
- };
310
- const handleNextAndPrevSlide = (action)=>{
311
- action === 'next' ? instanceRef.current?.next() : instanceRef.current?.prev();
312
- if (onClickArrow) {
313
- delayTimeout && clearTimeout(delayTimeout);
314
- delayTimeout = setTimeout(()=>onClickArrow && onClickArrow(), 500);
315
- }
316
- };
317
- useImperativeHandle(ref, ()=>({
318
- nextSlideInteraction,
319
- previousSlideInteraction,
320
- moveToSlideInteraction
321
- }));
322
- const dispatchEventSelectSlide = (index)=>{
323
- trigger({
324
- event: 'gp:rollback:select-slide',
325
- selector: `[data-id="${builderProps?.uid}"]`,
326
- element: elmRef?.current
327
- });
328
- trigger({
329
- event: 'gp:select-slide',
330
- selector: `[data-id="${builderProps?.uid}"]`,
331
- data: index,
332
- element: elmRef?.current
333
- });
334
- };
335
- const moveToIdxInteraction = (idx)=>{
336
- instanceRef.current?.moveToIdx(idx);
337
- onHandleChangeSlideByInteraction && onHandleChangeSlideByInteraction(idx);
338
- };
339
- const handleDirectionalSlide = (params, direction)=>{
340
- const { key, data, isRollback, element } = params;
341
- const currentIndex = Math.max(instanceRef.current?.track?.details?.rel ?? 0, 0);
342
- if (isRollback && data === undefined) {
343
- return;
344
- }
345
- if (isRollback) {
346
- if (direction === 'specific') {
347
- const { previousData } = getInteractionPreviousData(element, key);
348
- moveToIdxInteraction(Number(previousData));
349
- } else {
350
- // For next/previous, move in opposite direction during rollback
351
- const newIndex = direction === 'next' ? currentIndex - 1 : currentIndex + 1;
352
- moveToIdxInteraction(newIndex);
353
- }
354
- return;
355
- }
356
- // Save current state and move to new position
357
- const indexToSave = direction === 'specific' ? Math.max(previousIndex.current, 0) : currentIndex;
358
- saveToElementInteractionData(element, key, indexToSave.toString());
359
- const targetIndex = direction === 'specific' ? Number(data) : direction === 'next' ? currentIndex + 1 : currentIndex - 1;
360
- moveToIdxInteraction(targetIndex);
361
- };
362
- const nextSlideInteraction = (params)=>{
363
- handleDirectionalSlide(params, 'next');
364
- };
365
- const previousSlideInteraction = (params)=>{
366
- handleDirectionalSlide(params, 'previous');
367
- };
368
- const moveToSlideInteraction = (params)=>{
369
- handleDirectionalSlide(params, 'specific');
370
- };
371
- useEffect(()=>{
372
- const selector = `[data-id="${builderProps?.uid}"]`;
373
- onListener({
374
- event: 'gp:change-next-slide',
375
- selector,
376
- elementRef: localRef
377
- }, (params)=>{
378
- const { data, isRollback, uniqueStorageKey } = params || {};
379
- nextSlideInteraction({
380
- element: localRef.current,
381
- data,
382
- isRollback,
383
- key: uniqueStorageKey
384
- });
385
- });
386
- onListener({
387
- event: 'gp:change-previous-slide',
388
- selector,
389
- elementRef: localRef
390
- }, (params)=>{
391
- const { data, isRollback, uniqueStorageKey } = params || {};
392
- previousSlideInteraction({
393
- element: localRef.current,
394
- data,
395
- isRollback,
396
- key: uniqueStorageKey
397
- });
398
- });
399
- onListener({
400
- event: 'gp:change-image-step',
401
- selector,
402
- elementRef: localRef
403
- }, (params)=>{
404
- const { data, isRollback, uniqueStorageKey } = params || {};
405
- moveToSlideInteraction({
406
- element: localRef.current,
407
- data,
408
- isRollback,
409
- key: uniqueStorageKey
410
- });
411
- });
412
- onListener({
413
- event: 'gp:change-index-slide',
414
- selector
415
- }, (params)=>{
416
- const element = document.querySelector(selector);
417
- const { data, isRollback, uniqueStorageKey } = params || {};
418
- moveToSlideInteraction({
419
- element,
420
- data,
421
- isRollback,
422
- key: uniqueStorageKey
423
- });
424
- });
425
- }, []);
426
- // Update slider when size change
427
- useEffect(()=>{
428
- instanceRef.current?.update(instanceRef.current?.options);
429
- }, [
430
- instanceRef,
431
- setting
432
- ]);
433
- useEffect(()=>{
434
- const moveToIndexListenEvent = (event)=>{
435
- if (builderProps?.uid !== event?.detail.componentUid) return;
436
- const maxIndexSlideTo = instanceRef?.current?.track.details.maxIdx;
437
- let indexFinal = event?.detail.index || 0;
438
- if (maxIndexSlideTo && indexFinal > maxIndexSlideTo) indexFinal = maxIndexSlideTo;
439
- instanceRef.current?.moveToIdx(indexFinal);
440
- previousIndex.current = indexFinal;
441
- };
442
- window.addEventListener('move-to-idx', moveToIndexListenEvent);
443
- return ()=>window.removeEventListener('move-to-idx', moveToIndexListenEvent);
444
- }, [
445
- instanceRef,
446
- builderProps?.uid
447
- ]);
448
- // change slider when receive prop move to idx
449
- useEffect(()=>{
450
- if (typeof moveToIdx == 'number') {
451
- previousIndex.current = moveToIdx;
452
- instanceRef?.current?.moveToIdx(moveToIdx);
453
- }
454
- }, [
455
- instanceRef,
456
- moveToIdx,
457
- isHiddenArrowWhenDisabled
458
- ]);
459
- return {
460
- isInfinity,
461
- totalSlideItem,
462
- slideMaxIndex,
463
- currentSlide,
464
- loaded,
465
- slider,
466
- previousIndex,
467
- localRef,
468
- instanceRef,
469
- showNavigation,
470
- isRenderDots,
471
- sliderRef,
472
- handleDotClick,
473
- getItemsPerPage,
474
- handleNextAndPrevSlide,
475
- dispatchEventSelectSlide,
476
- getNumberOfFullWidthShow
477
- };
478
- };
479
-
480
- export { useCarousel };
@@ -1,38 +0,0 @@
1
- import { CarouselSettingsV2 } from './configs/settingV2.js';
2
- import { SettingUIV2 } from './configs/uiV2.js';
3
- import { SwiperCarouselPreset } from './configs/presets.js';
4
-
5
- const config = {
6
- tag: 'SwiperCarousel',
7
- label: 'Swiper Carousel',
8
- icon: `
9
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
10
- <path fill-rule="evenodd" clip-rule="evenodd" d="M4.96586 7.25C4.96586 6.14543 5.86129 5.25 6.96586 5.25H17.0346C18.1391 5.25 19.0346 6.14543 19.0346 7.25V16.7484C19.0346 17.853 18.1391 18.7484 17.0346 18.7484H6.96586C5.86129 18.7484 4.96586 17.853 4.96586 16.7484V7.25ZM9.36039 6.25H6.96586C6.41357 6.25 5.96586 6.69772 5.96586 7.25V16.7484C5.96586 17.3007 6.41357 17.7484 6.96586 17.7484H9.36039L9.36039 6.25ZM10.3604 17.7484V6.25H14.1455V17.7484H10.3604ZM15.1455 17.7484H17.0346C17.5869 17.7484 18.0346 17.3007 18.0346 16.7484V7.25C18.0346 6.69771 17.5869 6.25 17.0346 6.25H15.1455V17.7484ZM3.31666 10.5447C3.51708 10.7346 3.52555 11.0511 3.33558 11.2515L2.61349 12.0133L3.33449 12.7691C3.52509 12.969 3.51762 13.2854 3.31781 13.4761C3.118 13.6667 2.8015 13.6592 2.6109 13.4594L1.693 12.4971C1.43561 12.2273 1.43493 11.803 1.69148 11.5324L2.60981 10.5636C2.79978 10.3632 3.11625 10.3547 3.31666 10.5447ZM20.6827 10.5458C20.8825 10.3552 21.199 10.3627 21.3896 10.5625L22.3075 11.5247C22.5649 11.7946 22.5656 12.2188 22.309 12.4894L21.3907 13.4583C21.2007 13.6587 20.8843 13.6672 20.6839 13.4772C20.4834 13.2872 20.475 12.9707 20.6649 12.7703L21.387 12.0085L20.666 11.2527C20.4754 11.0529 20.4829 10.7364 20.6827 10.5458ZM21.5839 12.215C21.5838 12.2149 21.584 12.2151 21.5839 12.215V12.215Z" fill="white"/>
11
- </svg>
12
- `,
13
- settings: CarouselSettingsV2,
14
- ui: [],
15
- uiV2: SettingUIV2,
16
- presets: SwiperCarouselPreset,
17
- editorConfigs: {
18
- slots: {
19
- children: false
20
- },
21
- placeholder: {
22
- // notAppendBeforeAfter: true,
23
- notAppendTags: [
24
- 'MarqueeItem',
25
- 'Marquee'
26
- ]
27
- }
28
- },
29
- locales: {
30
- editor: {
31
- en: {
32
- no_slider: 'No Slider'
33
- }
34
- }
35
- }
36
- };
37
-
38
- export { config as default };
@@ -1,36 +0,0 @@
1
- const config = {
2
- tag: 'SwiperCarouselItem',
3
- label: 'Swiper Carousel Item',
4
- settings: [
5
- {
6
- id: 'setting',
7
- controls: []
8
- },
9
- {
10
- id: 'style',
11
- controls: []
12
- }
13
- ],
14
- editorConfigs: {
15
- component: {
16
- noSetting: true,
17
- noDelete: true,
18
- noDuplicate: true,
19
- noDragDrop: true
20
- },
21
- slots: {
22
- children: true
23
- },
24
- sideBar: {
25
- hide: true
26
- },
27
- toolbar: {
28
- hide: true
29
- },
30
- placeholder: {
31
- notAppendBeforeAfter: true
32
- }
33
- }
34
- };
35
-
36
- export { config as default };