@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.
Files changed (174) hide show
  1. package/dist/cjs/builder.js +12 -6
  2. package/dist/cjs/index.js +34 -32
  3. package/dist/cjs/index.liquid.js +16 -10
  4. package/dist/cjs/next.js +3 -1
  5. package/dist/cjs/product/components/ProductImagesV3/common/common.js +360 -0
  6. package/dist/cjs/product/components/ProductImagesV3/common/getAttr.js +192 -0
  7. package/dist/cjs/product/components/ProductImagesV3/common/getBorderActiveCss.js +26 -0
  8. package/dist/cjs/product/components/ProductImagesV3/common/getClasses.js +94 -0
  9. package/dist/cjs/product/components/ProductImagesV3/common/getStyle.js +303 -0
  10. package/dist/cjs/product/components/ProductImagesV3/common/hoverAction.js +95 -0
  11. package/dist/cjs/product/components/ProductImagesV3/common/productFeaturedImage.js +59 -0
  12. package/dist/cjs/product/components/ProductImagesV3/common/productGallery.js +266 -0
  13. package/dist/cjs/product/components/ProductImagesV3/components/child/MediaIcon.js +63 -0
  14. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +36 -0
  15. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +109 -0
  16. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +139 -0
  17. package/dist/cjs/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +100 -0
  18. package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +77 -0
  19. package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +300 -0
  20. package/dist/cjs/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +44 -0
  21. package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +83 -0
  22. package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +182 -0
  23. package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +30 -0
  24. package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +239 -0
  25. package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +28 -0
  26. package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +144 -0
  27. package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesAttr.js +14 -0
  28. package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesClassName.js +54 -0
  29. package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesStyles.js +53 -0
  30. package/dist/cjs/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +55 -0
  31. package/dist/cjs/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +41 -0
  32. package/dist/cjs/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +134 -0
  33. package/dist/cjs/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +203 -0
  34. package/dist/cjs/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +87 -0
  35. package/dist/cjs/product/components/ProductImagesV3/index.js +291 -0
  36. package/dist/cjs/product/components/ProductImagesV3/index.liquid.js +153 -0
  37. package/dist/cjs/product/index.js +6 -4
  38. package/dist/cjs/product/next.js +4 -0
  39. package/dist/cjs/product/setting/product-image-v3/ProductFeatureImage.js +252 -0
  40. package/dist/cjs/product/setting/product-image-v3/ProductGalleryImage.js +251 -0
  41. package/dist/cjs/product/setting/product-image-v3/ProductImages.js +74 -0
  42. package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +388 -0
  43. package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +518 -0
  44. package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/index.js +336 -0
  45. package/dist/cjs/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +118 -0
  46. package/dist/cjs/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +119 -0
  47. package/dist/cjs/product/setting/product-image-v3/configs/uiV1.js +237 -0
  48. package/dist/cjs/product/setting/product-image-v3/configs/uiV2.js +491 -0
  49. package/dist/cjs/setting.js +97 -95
  50. package/dist/cjs/swiper-carousel/arrow/Arrow.js +52 -0
  51. package/dist/cjs/swiper-carousel/arrow/Arrow.liquid.js +46 -0
  52. package/dist/cjs/swiper-carousel/arrow/common/common.js +119 -0
  53. package/dist/cjs/swiper-carousel/arrow/common/getClass.js +50 -0
  54. package/dist/cjs/swiper-carousel/arrow/common/getStyle.js +84 -0
  55. package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.js +34 -0
  56. package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.liquid.js +38 -0
  57. package/dist/cjs/swiper-carousel/carousel-item/common/getClass.js +29 -0
  58. package/dist/cjs/swiper-carousel/carousel-item/common/getStyle.js +79 -0
  59. package/dist/cjs/swiper-carousel/carousel-item/hook/useCarouseItem.js +22 -0
  60. package/dist/cjs/swiper-carousel/components/common/carousel.js +98 -0
  61. package/dist/cjs/swiper-carousel/components/const/index.js +5 -0
  62. package/dist/cjs/swiper-carousel/components/hooks/useTrackPreviewPause.js +34 -0
  63. package/dist/cjs/swiper-carousel/components/plugins/AnimationPlugin.js +42 -0
  64. package/dist/cjs/swiper-carousel/components/plugins/AutoPlayPlugin.js +105 -0
  65. package/dist/cjs/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +15 -0
  66. package/dist/cjs/swiper-carousel/components/plugins/MutationPlugin.js +45 -0
  67. package/dist/cjs/swiper-carousel/dots/Dots.js +51 -0
  68. package/dist/cjs/swiper-carousel/dots/Dots.liquid.js +26 -0
  69. package/dist/cjs/swiper-carousel/dots/common/common.js +28 -0
  70. package/dist/cjs/swiper-carousel/dots/common/getClass.js +40 -0
  71. package/dist/cjs/swiper-carousel/dots/common/getStyle.js +33 -0
  72. package/dist/cjs/swiper-carousel/dots/hook/useDotsSetting.js +21 -0
  73. package/dist/cjs/swiper-carousel/index.js +17 -0
  74. package/dist/cjs/swiper-carousel/next.js +22 -0
  75. package/dist/cjs/swiper-carousel/root/Swiper.js +128 -0
  76. package/dist/cjs/swiper-carousel/root/Swiper.liquid.js +104 -0
  77. package/dist/cjs/swiper-carousel/root/common/getAttr.js +25 -0
  78. package/dist/cjs/swiper-carousel/root/common/getClass.js +135 -0
  79. package/dist/cjs/swiper-carousel/root/common/getData.js +56 -0
  80. package/dist/cjs/swiper-carousel/root/common/getStyle.js +64 -0
  81. package/dist/cjs/swiper-carousel/root/hook/useCarousel.js +482 -0
  82. package/dist/cjs/swiper-carousel/setting/Swiper.js +42 -0
  83. package/dist/cjs/swiper-carousel/setting/SwiperItem.js +40 -0
  84. package/dist/cjs/swiper-carousel/setting/configs/presets.js +87 -0
  85. package/dist/cjs/swiper-carousel/setting/configs/settingV2.js +819 -0
  86. package/dist/cjs/swiper-carousel/setting/configs/uiV2.js +718 -0
  87. package/dist/esm/builder.js +6 -0
  88. package/dist/esm/index.js +1 -0
  89. package/dist/esm/index.liquid.js +3 -0
  90. package/dist/esm/next.js +3 -1
  91. package/dist/esm/product/components/ProductImagesV3/common/common.js +344 -0
  92. package/dist/esm/product/components/ProductImagesV3/common/getAttr.js +189 -0
  93. package/dist/esm/product/components/ProductImagesV3/common/getBorderActiveCss.js +24 -0
  94. package/dist/esm/product/components/ProductImagesV3/common/getClasses.js +83 -0
  95. package/dist/esm/product/components/ProductImagesV3/common/getStyle.js +292 -0
  96. package/dist/esm/product/components/ProductImagesV3/common/hoverAction.js +92 -0
  97. package/dist/esm/product/components/ProductImagesV3/common/productFeaturedImage.js +53 -0
  98. package/dist/esm/product/components/ProductImagesV3/common/productGallery.js +251 -0
  99. package/dist/esm/product/components/ProductImagesV3/components/child/MediaIcon.js +59 -0
  100. package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +32 -0
  101. package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +105 -0
  102. package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +135 -0
  103. package/dist/esm/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +96 -0
  104. package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +73 -0
  105. package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +296 -0
  106. package/dist/esm/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +40 -0
  107. package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +79 -0
  108. package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +178 -0
  109. package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +26 -0
  110. package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +235 -0
  111. package/dist/esm/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +24 -0
  112. package/dist/esm/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +140 -0
  113. package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesAttr.js +12 -0
  114. package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesClassName.js +52 -0
  115. package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesStyles.js +51 -0
  116. package/dist/esm/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +53 -0
  117. package/dist/esm/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +39 -0
  118. package/dist/esm/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +132 -0
  119. package/dist/esm/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +201 -0
  120. package/dist/esm/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +85 -0
  121. package/dist/esm/product/components/ProductImagesV3/index.js +287 -0
  122. package/dist/esm/product/components/ProductImagesV3/index.liquid.js +149 -0
  123. package/dist/esm/product/index.js +26 -24
  124. package/dist/esm/product/next.js +4 -0
  125. package/dist/esm/product/setting/product-image-v3/ProductFeatureImage.js +248 -0
  126. package/dist/esm/product/setting/product-image-v3/ProductGalleryImage.js +248 -0
  127. package/dist/esm/product/setting/product-image-v3/ProductImages.js +70 -0
  128. package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +384 -0
  129. package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +515 -0
  130. package/dist/esm/product/setting/product-image-v3/configs/setting-v2/index.js +334 -0
  131. package/dist/esm/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +116 -0
  132. package/dist/esm/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +117 -0
  133. package/dist/esm/product/setting/product-image-v3/configs/uiV1.js +235 -0
  134. package/dist/esm/product/setting/product-image-v3/configs/uiV2.js +489 -0
  135. package/dist/esm/setting.js +2 -0
  136. package/dist/esm/swiper-carousel/arrow/Arrow.js +48 -0
  137. package/dist/esm/swiper-carousel/arrow/Arrow.liquid.js +42 -0
  138. package/dist/esm/swiper-carousel/arrow/common/common.js +111 -0
  139. package/dist/esm/swiper-carousel/arrow/common/getClass.js +48 -0
  140. package/dist/esm/swiper-carousel/arrow/common/getStyle.js +82 -0
  141. package/dist/esm/swiper-carousel/carousel-item/SwiperItem.js +30 -0
  142. package/dist/esm/swiper-carousel/carousel-item/SwiperItem.liquid.js +34 -0
  143. package/dist/esm/swiper-carousel/carousel-item/common/getClass.js +27 -0
  144. package/dist/esm/swiper-carousel/carousel-item/common/getStyle.js +77 -0
  145. package/dist/esm/swiper-carousel/carousel-item/hook/useCarouseItem.js +20 -0
  146. package/dist/esm/swiper-carousel/components/common/carousel.js +93 -0
  147. package/dist/esm/swiper-carousel/components/const/index.js +3 -0
  148. package/dist/esm/swiper-carousel/components/hooks/useTrackPreviewPause.js +30 -0
  149. package/dist/esm/swiper-carousel/components/plugins/AnimationPlugin.js +35 -0
  150. package/dist/esm/swiper-carousel/components/plugins/AutoPlayPlugin.js +103 -0
  151. package/dist/esm/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +13 -0
  152. package/dist/esm/swiper-carousel/components/plugins/MutationPlugin.js +43 -0
  153. package/dist/esm/swiper-carousel/dots/Dots.js +47 -0
  154. package/dist/esm/swiper-carousel/dots/Dots.liquid.js +22 -0
  155. package/dist/esm/swiper-carousel/dots/common/common.js +26 -0
  156. package/dist/esm/swiper-carousel/dots/common/getClass.js +38 -0
  157. package/dist/esm/swiper-carousel/dots/common/getStyle.js +31 -0
  158. package/dist/esm/swiper-carousel/dots/hook/useDotsSetting.js +19 -0
  159. package/dist/esm/swiper-carousel/index.js +15 -0
  160. package/dist/esm/swiper-carousel/next.js +18 -0
  161. package/dist/esm/swiper-carousel/root/Swiper.js +124 -0
  162. package/dist/esm/swiper-carousel/root/Swiper.liquid.js +100 -0
  163. package/dist/esm/swiper-carousel/root/common/getAttr.js +23 -0
  164. package/dist/esm/swiper-carousel/root/common/getClass.js +133 -0
  165. package/dist/esm/swiper-carousel/root/common/getData.js +54 -0
  166. package/dist/esm/swiper-carousel/root/common/getStyle.js +62 -0
  167. package/dist/esm/swiper-carousel/root/hook/useCarousel.js +480 -0
  168. package/dist/esm/swiper-carousel/setting/Swiper.js +38 -0
  169. package/dist/esm/swiper-carousel/setting/SwiperItem.js +36 -0
  170. package/dist/esm/swiper-carousel/setting/configs/presets.js +85 -0
  171. package/dist/esm/swiper-carousel/setting/configs/settingV2.js +815 -0
  172. package/dist/esm/swiper-carousel/setting/configs/uiV2.js +713 -0
  173. package/dist/types/index.d.ts +551 -116
  174. package/package.json +2 -2
@@ -0,0 +1,482 @@
1
+ 'use strict';
2
+
3
+ var react = require('@gem-sdk/keen-slider/react');
4
+ var AutoPlayPlugin = require('../../components/plugins/AutoPlayPlugin.js');
5
+ var AnimationPlugin = require('../../components/plugins/AnimationPlugin.js');
6
+ var React = require('react');
7
+ var core = require('@gem-sdk/core');
8
+ var MutationPlugin = require('../../components/plugins/MutationPlugin.js');
9
+ var FixSliderMoveBackwards = require('../../components/plugins/FixSliderMoveBackwards.js');
10
+ var useTrackPreviewPause = require('../../components/hooks/useTrackPreviewPause.js');
11
+ var getData = require('../common/getData.js');
12
+
13
+ const useCarousel = (props, ref)=>{
14
+ const { builderProps, moveToIdx, styles, setting, isHiddenArrowWhenDisabled = true, elmRef, onChangeActive, onLoaded, onUpdated, onCreated, onClickArrow, onHandleChangeSlideByInteraction } = props;
15
+ const { loop, navigationEnable = {
16
+ desktop: true
17
+ }, navigationStyle } = setting ?? {};
18
+ const [isInfinity, setIsInfinity] = React.useState(false);
19
+ const [totalSlideItem, setTotalSlideItem] = React.useState(0);
20
+ const [slideMaxIndex, setSlideMaxIndex] = React.useState(0);
21
+ const [currentSlide, setCurrentSlide] = React.useState(setting?.defaultCurrentSlider ?? 0);
22
+ const [loaded, setLoaded] = React.useState(false);
23
+ const [slider, setSlider] = React.useState();
24
+ const { sliderSelector } = getData.getData(props);
25
+ const localRef = React.useRef();
26
+ const isRunningAnimation = React.useRef(false);
27
+ const previousIndex = React.useRef(moveToIdx ?? 0);
28
+ let delayTimeout;
29
+ const currentDevice = core.useCurrentDevice();
30
+ const mode = core.useEditorMode();
31
+ const { isFirstPreviewClicked } = useTrackPreviewPause.default(setting?.runPreview);
32
+ const { onListener, saveToElementInteractionData, getInteractionPreviousData, trigger } = core.useInteraction();
33
+ const getItemNumberFromOldData = React.useCallback(()=>{
34
+ if (!setting?.slidesToShow) return null;
35
+ const result = {};
36
+ core.DEVICES.forEach((device)=>{
37
+ const value = core.getResponsiveValueByScreen(setting?.slidesToShow, device);
38
+ result[device] = value ? value === 'auto' ? 4 : Math.floor(value) : 0;
39
+ });
40
+ return result;
41
+ }, [
42
+ setting?.slidesToShow
43
+ ]);
44
+ const getSlideToShowFromOldData = React.useCallback(()=>{
45
+ if (!setting?.slidesToShow) return null;
46
+ const result = {};
47
+ core.DEVICES.forEach((device)=>{
48
+ const value = core.getResponsiveValueByScreen(setting?.slidesToShow, device);
49
+ result[device] = value ? value === 'auto' ? 4 : value : 0;
50
+ });
51
+ return result;
52
+ }, [
53
+ setting?.slidesToShow
54
+ ]);
55
+ const slidesToShow = React.useMemo(()=>{
56
+ const oldData = getSlideToShowFromOldData();
57
+ if (oldData) {
58
+ return oldData;
59
+ }
60
+ const result = {};
61
+ core.DEVICES.forEach((device)=>{
62
+ const enableSneakPeak = core.getResponsiveValueByScreen(setting?.sneakPeak, device);
63
+ const offset = enableSneakPeak ? core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? core.getResponsiveValueByScreen(setting?.sneakPeakOffsetCenter, device) ?? 0 : core.getResponsiveValueByScreen(setting?.sneakPeakOffsetForward, device) ?? 0 : 0;
64
+ const rx = core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? -2 : -1;
65
+ const itemNumberByDevice = core.getResponsiveValueByScreen(setting?.itemNumber, device);
66
+ result[device] = typeof itemNumberByDevice === 'number' ? itemNumberByDevice + offset / 100 * rx : 'auto';
67
+ });
68
+ return result;
69
+ }, [
70
+ getSlideToShowFromOldData,
71
+ setting?.itemNumber,
72
+ setting?.sneakPeak,
73
+ setting?.sneakPeakOffsetCenter,
74
+ setting?.sneakPeakOffsetForward,
75
+ setting?.sneakPeakType
76
+ ]);
77
+ const itemNumber = React.useMemo(()=>{
78
+ const oldData = getItemNumberFromOldData();
79
+ return oldData || setting?.itemNumber;
80
+ }, [
81
+ getItemNumberFromOldData,
82
+ setting?.itemNumber
83
+ ]);
84
+ const getNumberOfFullWidthShow = React.useCallback((device)=>{
85
+ const sneakPeekTypeByNumber = core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' ? 2 : 1;
86
+ return typeof core.getResponsiveValueByScreen(itemNumber, device, 4) === 'number' ? core.getResponsiveValueByScreen(itemNumber, device, 4) - sneakPeekTypeByNumber : undefined;
87
+ }, [
88
+ setting?.sneakPeakType,
89
+ itemNumber
90
+ ]);
91
+ const getOriginCarousel = React.useMemo(()=>(device)=>{
92
+ const origin = core.getResponsiveValueByScreen(setting?.sneakPeakType, device) === 'center' && core.getResponsiveValueByScreen(setting?.sneakPeak, device) ? 'center' : 'auto';
93
+ return origin;
94
+ }, [
95
+ setting?.sneakPeak,
96
+ setting?.sneakPeakType
97
+ ]);
98
+ const getMaxNavigationWhenSneak = React.useMemo(()=>(device)=>{
99
+ if (getOriginCarousel(device) !== 'center') return {};
100
+ const totalItems = setting?.childItem?.length || 1;
101
+ let itemShow = Number(core.getResponsiveValueByScreen(slidesToShow, device, 1)) || 1 + 1;
102
+ if (setting?.sneakPeak?.[currentDevice]) {
103
+ itemShow = Math.trunc(Number(getNumberOfFullWidthShow(device)));
104
+ }
105
+ const max = totalItems - itemShow;
106
+ const isLoopByDevice = core.getResponsiveValueByScreen(loop, device, false);
107
+ if (isLoopByDevice) return {
108
+ max: undefined
109
+ };
110
+ return {
111
+ max
112
+ };
113
+ }, [
114
+ setting?.childItem,
115
+ slidesToShow,
116
+ getOriginCarousel,
117
+ loop,
118
+ currentDevice,
119
+ setting?.sneakPeak,
120
+ getNumberOfFullWidthShow
121
+ ]);
122
+ const removeInitialCarouselGap = ()=>{
123
+ const sliderElm = document.querySelectorAll(`.${sliderSelector}`);
124
+ if (!sliderElm) return;
125
+ sliderElm.forEach((selector)=>{
126
+ selector?.style.removeProperty('--cg');
127
+ selector?.style.removeProperty('--cg-tablet');
128
+ selector?.style.removeProperty('--cg-mobile');
129
+ selector?.style.removeProperty('--rg');
130
+ selector?.style.removeProperty('--rg-tablet');
131
+ selector?.style.removeProperty('--rg-mobile');
132
+ });
133
+ };
134
+ const [sliderRef, instanceRef] = react.useKeenSlider({
135
+ selector: `.gem-slider-item-${builderProps?.uid}`,
136
+ optionsChanged: (slider)=>{
137
+ if (slider?.track?.details?.maxIdx === Infinity) {
138
+ setIsInfinity(true);
139
+ } else {
140
+ setIsInfinity(false);
141
+ }
142
+ setTotalSlideItem(Math.ceil(slider.slides.length));
143
+ setSlideMaxIndex(slider?.track?.details?.maxIdx);
144
+ },
145
+ defaultAnimation: {
146
+ duration: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
147
+ easing: (t)=>{
148
+ switch(setting?.animationMode){
149
+ case AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN.value:
150
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN.formula(t);
151
+ case AnimationPlugin.CAROUSEL_ANIMATION.EASE_OUT.value:
152
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_OUT.formula(t);
153
+ case AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN_OUT.value:
154
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN_OUT.formula(t);
155
+ default:
156
+ return AnimationPlugin.CAROUSEL_ANIMATION.DEFAULT.formula(t);
157
+ }
158
+ }
159
+ },
160
+ dragSpeed: 2,
161
+ renderMode: 'precision',
162
+ mode: 'snap',
163
+ loop: core.getResponsiveValueByScreen(loop, 'desktop', false),
164
+ vertical: core.getResponsiveValueByScreen(setting?.vertical, 'desktop'),
165
+ rtl: setting?.rtl,
166
+ breakpoints: {
167
+ '(max-width: 9999px)': {
168
+ slides: {
169
+ perView: core.getResponsiveValueByScreen(slidesToShow, 'desktop', 4) ?? 1,
170
+ spacing: core.getResponsiveValueByScreen(styles?.spacing, 'desktop'),
171
+ origin: getOriginCarousel('desktop'),
172
+ numberOfFullWidthShow: getNumberOfFullWidthShow('desktop')
173
+ },
174
+ loop: core.getResponsiveValueByScreen(loop, 'desktop', false),
175
+ vertical: core.getResponsiveValueByScreen(setting?.vertical, 'desktop'),
176
+ drag: core.getResponsiveValueByScreen(mode == 'edit' ? {
177
+ desktop: false
178
+ } : setting?.enableDrag, 'desktop'),
179
+ initial: moveToIdx ?? 0,
180
+ range: getMaxNavigationWhenSneak('desktop')
181
+ },
182
+ '(max-width: 1024px)': {
183
+ slides: {
184
+ perView: core.getResponsiveValueByScreen(slidesToShow, 'tablet', 4),
185
+ spacing: core.getResponsiveValueByScreen(styles?.spacing, 'tablet'),
186
+ origin: getOriginCarousel('tablet'),
187
+ numberOfFullWidthShow: getNumberOfFullWidthShow('tablet')
188
+ },
189
+ loop: core.getResponsiveValueByScreen(loop, 'tablet', false),
190
+ vertical: core.getResponsiveValueByScreen(setting?.vertical, 'tablet'),
191
+ drag: core.getResponsiveValueByScreen(mode == 'edit' ? {
192
+ tablet: false
193
+ } : setting?.enableDrag, 'tablet'),
194
+ initial: moveToIdx || 0,
195
+ range: getMaxNavigationWhenSneak('tablet')
196
+ },
197
+ '(max-width: 767px)': {
198
+ slides: {
199
+ perView: core.getResponsiveValueByScreen(slidesToShow, 'mobile', 4),
200
+ spacing: core.getResponsiveValueByScreen(styles?.spacing, 'mobile'),
201
+ origin: getOriginCarousel('mobile'),
202
+ numberOfFullWidthShow: getNumberOfFullWidthShow('mobile')
203
+ },
204
+ loop: core.getResponsiveValueByScreen(loop, 'mobile', false),
205
+ vertical: core.getResponsiveValueByScreen(setting?.vertical, 'mobile'),
206
+ drag: core.getResponsiveValueByScreen(mode == 'edit' ? {
207
+ mobile: false
208
+ } : setting?.enableDrag, 'mobile'),
209
+ initial: moveToIdx ?? 0,
210
+ range: getMaxNavigationWhenSneak('mobile')
211
+ }
212
+ },
213
+ slideChanged: (slider)=>{
214
+ setCurrentSlide(slider.track.details.rel);
215
+ previousIndex.current = slider.track.details.rel;
216
+ onChangeActive && onChangeActive(slider.track.details.rel);
217
+ },
218
+ created: (slider)=>{
219
+ setLoaded(true);
220
+ setSlider(slider);
221
+ setCurrentSlide(slider.track?.details?.rel ?? 0);
222
+ onCreated && onCreated(slider);
223
+ removeInitialCarouselGap();
224
+ },
225
+ updated: (slider)=>{
226
+ onLoaded && onLoaded(true);
227
+ onUpdated && onUpdated(slider);
228
+ },
229
+ autoplay: {
230
+ delay: (setting?.autoplayTimeout ?? 1) * 1000,
231
+ pauseOnHover: setting?.pauseOnHover,
232
+ enable: mode === 'edit' ? isFirstPreviewClicked ? setting?.runPreview && setting?.autoplay : false : setting?.autoplay
233
+ },
234
+ animation: {
235
+ type: setting?.animationMode,
236
+ speed: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500
237
+ },
238
+ dragStarted: (slider)=>{
239
+ slider.container.style.cursor = 'grabbing';
240
+ },
241
+ dragEnded: (slider)=>{
242
+ slider.container.style.cursor = 'auto';
243
+ },
244
+ animationStarted: (slider)=>{
245
+ // This code used to handle when user click next/prev button constantly
246
+ if (!isRunningAnimation.current) {
247
+ isRunningAnimation.current = true;
248
+ } else {
249
+ slider.options.defaultAnimation = {
250
+ duration: AnimationPlugin.DEFAULT_PLAY_SPEED,
251
+ easing: (t)=>AnimationPlugin.CAROUSEL_ANIMATION.DEFAULT.formula(t)
252
+ };
253
+ }
254
+ },
255
+ animationEnded: (slider)=>{
256
+ isRunningAnimation.current = false;
257
+ slider.options.defaultAnimation = {
258
+ duration: styles?.playSpeed === 0 ? 1 : styles?.playSpeed ?? 500,
259
+ easing (t) {
260
+ switch(setting?.animationMode){
261
+ case AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN.value:
262
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN.formula(t);
263
+ case AnimationPlugin.CAROUSEL_ANIMATION.EASE_OUT.value:
264
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_OUT.formula(t);
265
+ case AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN_OUT.value:
266
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN_OUT.formula(t);
267
+ default:
268
+ return AnimationPlugin.CAROUSEL_ANIMATION.EASE_IN.formula(t);
269
+ }
270
+ }
271
+ };
272
+ }
273
+ }, [
274
+ MutationPlugin.MutationPlugin,
275
+ AutoPlayPlugin.AutoPlayPlugin,
276
+ AnimationPlugin.AnimationPlugin,
277
+ FixSliderMoveBackwards.FixSliderMoveBackwards
278
+ ]);
279
+ const isRenderDots = React.useMemo(()=>loaded && !!totalSlideItem && instanceRef.current && core.getResponsiveValueByScreen(setting?.dot), [
280
+ instanceRef,
281
+ loaded,
282
+ setting?.dot,
283
+ totalSlideItem
284
+ ]);
285
+ const showNavigation = React.useMemo(()=>{
286
+ const navigationEnableByDevice = core.getResponsiveValueByScreen(navigationEnable, currentDevice);
287
+ const navigationStyleByDevice = core.getResponsiveValueByScreen(navigationStyle, currentDevice);
288
+ return loaded && instanceRef.current && navigationEnableByDevice && navigationStyleByDevice !== 'none';
289
+ }, [
290
+ currentDevice,
291
+ instanceRef,
292
+ loaded,
293
+ navigationEnable,
294
+ navigationStyle
295
+ ]);
296
+ const getItemsPerPage = ()=>{
297
+ const items = core.getResponsiveValueByScreen(slidesToShow, currentDevice, 1) === 'auto' ? 1 : core.getResponsiveValueByScreen(slidesToShow, currentDevice, 1);
298
+ return items ?? 1;
299
+ };
300
+ const getIndexSlideItemBy = (pageIdx)=>{
301
+ let indexPage = pageIdx * getItemsPerPage();
302
+ if (indexPage >= totalSlideItem - getItemsPerPage()) {
303
+ indexPage = totalSlideItem - getItemsPerPage();
304
+ }
305
+ return indexPage;
306
+ };
307
+ const handleDotClick = (idx, isLoop)=>{
308
+ const index = setting?.sneakPeak?.[currentDevice] ? idx : isLoop ? idx : getIndexSlideItemBy(idx);
309
+ instanceRef.current?.moveToIdx(index);
310
+ previousIndex.current = index;
311
+ };
312
+ const handleNextAndPrevSlide = (action)=>{
313
+ action === 'next' ? instanceRef.current?.next() : instanceRef.current?.prev();
314
+ if (onClickArrow) {
315
+ delayTimeout && clearTimeout(delayTimeout);
316
+ delayTimeout = setTimeout(()=>onClickArrow && onClickArrow(), 500);
317
+ }
318
+ };
319
+ React.useImperativeHandle(ref, ()=>({
320
+ nextSlideInteraction,
321
+ previousSlideInteraction,
322
+ moveToSlideInteraction
323
+ }));
324
+ const dispatchEventSelectSlide = (index)=>{
325
+ trigger({
326
+ event: 'gp:rollback:select-slide',
327
+ selector: `[data-id="${builderProps?.uid}"]`,
328
+ element: elmRef?.current
329
+ });
330
+ trigger({
331
+ event: 'gp:select-slide',
332
+ selector: `[data-id="${builderProps?.uid}"]`,
333
+ data: index,
334
+ element: elmRef?.current
335
+ });
336
+ };
337
+ const moveToIdxInteraction = (idx)=>{
338
+ instanceRef.current?.moveToIdx(idx);
339
+ onHandleChangeSlideByInteraction && onHandleChangeSlideByInteraction(idx);
340
+ };
341
+ const handleDirectionalSlide = (params, direction)=>{
342
+ const { key, data, isRollback, element } = params;
343
+ const currentIndex = Math.max(instanceRef.current?.track?.details?.rel ?? 0, 0);
344
+ if (isRollback && data === undefined) {
345
+ return;
346
+ }
347
+ if (isRollback) {
348
+ if (direction === 'specific') {
349
+ const { previousData } = getInteractionPreviousData(element, key);
350
+ moveToIdxInteraction(Number(previousData));
351
+ } else {
352
+ // For next/previous, move in opposite direction during rollback
353
+ const newIndex = direction === 'next' ? currentIndex - 1 : currentIndex + 1;
354
+ moveToIdxInteraction(newIndex);
355
+ }
356
+ return;
357
+ }
358
+ // Save current state and move to new position
359
+ const indexToSave = direction === 'specific' ? Math.max(previousIndex.current, 0) : currentIndex;
360
+ saveToElementInteractionData(element, key, indexToSave.toString());
361
+ const targetIndex = direction === 'specific' ? Number(data) : direction === 'next' ? currentIndex + 1 : currentIndex - 1;
362
+ moveToIdxInteraction(targetIndex);
363
+ };
364
+ const nextSlideInteraction = (params)=>{
365
+ handleDirectionalSlide(params, 'next');
366
+ };
367
+ const previousSlideInteraction = (params)=>{
368
+ handleDirectionalSlide(params, 'previous');
369
+ };
370
+ const moveToSlideInteraction = (params)=>{
371
+ handleDirectionalSlide(params, 'specific');
372
+ };
373
+ React.useEffect(()=>{
374
+ const selector = `[data-id="${builderProps?.uid}"]`;
375
+ onListener({
376
+ event: 'gp:change-next-slide',
377
+ selector,
378
+ elementRef: localRef
379
+ }, (params)=>{
380
+ const { data, isRollback, uniqueStorageKey } = params || {};
381
+ nextSlideInteraction({
382
+ element: localRef.current,
383
+ data,
384
+ isRollback,
385
+ key: uniqueStorageKey
386
+ });
387
+ });
388
+ onListener({
389
+ event: 'gp:change-previous-slide',
390
+ selector,
391
+ elementRef: localRef
392
+ }, (params)=>{
393
+ const { data, isRollback, uniqueStorageKey } = params || {};
394
+ previousSlideInteraction({
395
+ element: localRef.current,
396
+ data,
397
+ isRollback,
398
+ key: uniqueStorageKey
399
+ });
400
+ });
401
+ onListener({
402
+ event: 'gp:change-image-step',
403
+ selector,
404
+ elementRef: localRef
405
+ }, (params)=>{
406
+ const { data, isRollback, uniqueStorageKey } = params || {};
407
+ moveToSlideInteraction({
408
+ element: localRef.current,
409
+ data,
410
+ isRollback,
411
+ key: uniqueStorageKey
412
+ });
413
+ });
414
+ onListener({
415
+ event: 'gp:change-index-slide',
416
+ selector
417
+ }, (params)=>{
418
+ const element = document.querySelector(selector);
419
+ const { data, isRollback, uniqueStorageKey } = params || {};
420
+ moveToSlideInteraction({
421
+ element,
422
+ data,
423
+ isRollback,
424
+ key: uniqueStorageKey
425
+ });
426
+ });
427
+ }, []);
428
+ // Update slider when size change
429
+ React.useEffect(()=>{
430
+ instanceRef.current?.update(instanceRef.current?.options);
431
+ }, [
432
+ instanceRef,
433
+ setting
434
+ ]);
435
+ React.useEffect(()=>{
436
+ const moveToIndexListenEvent = (event)=>{
437
+ if (builderProps?.uid !== event?.detail.componentUid) return;
438
+ const maxIndexSlideTo = instanceRef?.current?.track.details.maxIdx;
439
+ let indexFinal = event?.detail.index || 0;
440
+ if (maxIndexSlideTo && indexFinal > maxIndexSlideTo) indexFinal = maxIndexSlideTo;
441
+ instanceRef.current?.moveToIdx(indexFinal);
442
+ previousIndex.current = indexFinal;
443
+ };
444
+ window.addEventListener('move-to-idx', moveToIndexListenEvent);
445
+ return ()=>window.removeEventListener('move-to-idx', moveToIndexListenEvent);
446
+ }, [
447
+ instanceRef,
448
+ builderProps?.uid
449
+ ]);
450
+ // change slider when receive prop move to idx
451
+ React.useEffect(()=>{
452
+ if (typeof moveToIdx == 'number') {
453
+ previousIndex.current = moveToIdx;
454
+ instanceRef?.current?.moveToIdx(moveToIdx);
455
+ }
456
+ }, [
457
+ instanceRef,
458
+ moveToIdx,
459
+ isHiddenArrowWhenDisabled
460
+ ]);
461
+ return {
462
+ isInfinity,
463
+ totalSlideItem,
464
+ slideMaxIndex,
465
+ currentSlide,
466
+ loaded,
467
+ slider,
468
+ previousIndex,
469
+ localRef,
470
+ instanceRef,
471
+ showNavigation,
472
+ isRenderDots,
473
+ sliderRef,
474
+ handleDotClick,
475
+ getItemsPerPage,
476
+ handleNextAndPrevSlide,
477
+ dispatchEventSelectSlide,
478
+ getNumberOfFullWidthShow
479
+ };
480
+ };
481
+
482
+ exports.useCarousel = useCarousel;
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var settingV2 = require('./configs/settingV2.js');
6
+ var uiV2 = require('./configs/uiV2.js');
7
+ var presets = require('./configs/presets.js');
8
+
9
+ const config = {
10
+ tag: 'SwiperCarousel',
11
+ label: 'Swiper Carousel',
12
+ icon: `
13
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
14
+ <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"/>
15
+ </svg>
16
+ `,
17
+ settings: settingV2.CarouselSettingsV2,
18
+ ui: [],
19
+ uiV2: uiV2.SettingUIV2,
20
+ presets: presets.SwiperCarouselPreset,
21
+ editorConfigs: {
22
+ slots: {
23
+ children: false
24
+ },
25
+ placeholder: {
26
+ // notAppendBeforeAfter: true,
27
+ notAppendTags: [
28
+ 'MarqueeItem',
29
+ 'Marquee'
30
+ ]
31
+ }
32
+ },
33
+ locales: {
34
+ editor: {
35
+ en: {
36
+ no_slider: 'No Slider'
37
+ }
38
+ }
39
+ }
40
+ };
41
+
42
+ exports.default = config;
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const config = {
6
+ tag: 'SwiperCarouselItem',
7
+ label: 'Swiper Carousel Item',
8
+ settings: [
9
+ {
10
+ id: 'setting',
11
+ controls: []
12
+ },
13
+ {
14
+ id: 'style',
15
+ controls: []
16
+ }
17
+ ],
18
+ editorConfigs: {
19
+ component: {
20
+ noSetting: true,
21
+ noDelete: true,
22
+ noDuplicate: true,
23
+ noDragDrop: true
24
+ },
25
+ slots: {
26
+ children: true
27
+ },
28
+ sideBar: {
29
+ hide: true
30
+ },
31
+ toolbar: {
32
+ hide: true
33
+ },
34
+ placeholder: {
35
+ notAppendBeforeAfter: true
36
+ }
37
+ }
38
+ };
39
+
40
+ exports.default = config;
@@ -0,0 +1,87 @@
1
+ 'use strict';
2
+
3
+ const SwiperCarouselPreset = [
4
+ {
5
+ id: 'swiper-carousel',
6
+ name: {
7
+ en: 'Swiper Carousel'
8
+ },
9
+ icon: {
10
+ desktop: `
11
+ <svg width="96" height="48" viewBox="0 0 96 48" fill="none" xmlns="http://www.w3.org/2000/svg">
12
+ <rect width="96" height="48" rx="3" fill="#424242"/>
13
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M13.8828 18.1302C14.0391 18.3037 14.0391 18.5851 13.8828 18.7587L10.9657 22L13.8828 25.2413C14.0391 25.4149 14.0391 25.6963 13.8828 25.8698C13.7266 26.0434 13.4734 26.0434 13.3172 25.8698L10.1172 22.3143C9.96095 22.1407 9.96095 21.8593 10.1172 21.6857L13.3172 18.1302C13.4734 17.9566 13.7266 17.9566 13.8828 18.1302Z" fill="#F9F9F9"/>
14
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M82.1172 18.1302C82.2734 17.9566 82.5266 17.9566 82.6828 18.1302L85.8828 21.6857C86.0391 21.8593 86.0391 22.1407 85.8828 22.3143L82.6828 25.8698C82.5266 26.0434 82.2734 26.0434 82.1172 25.8698C81.9609 25.6963 81.9609 25.4149 82.1172 25.2413L85.0343 22L82.1172 18.7587C81.9609 18.5851 81.9609 18.3037 82.1172 18.1302Z" fill="#F9F9F9"/>
15
+ <circle cx="40" cy="38" r="2" fill="#F9F9F9"/>
16
+ <circle cx="48" cy="38" r="2" fill="#757575"/>
17
+ <circle cx="56" cy="38" r="2" fill="#757575"/>
18
+ </svg>
19
+ `
20
+ },
21
+ components: [
22
+ {
23
+ tag: 'SwiperCarousel',
24
+ label: 'Swiper Carousel',
25
+ settings: {
26
+ childItem: [
27
+ 'Item 1',
28
+ 'Item 2',
29
+ 'Item 3',
30
+ 'Item 4',
31
+ 'Item 5'
32
+ ],
33
+ itemNumber: {
34
+ desktop: 1,
35
+ tablet: 1,
36
+ mobile: 1
37
+ }
38
+ },
39
+ styles: {
40
+ sizeSetting: {
41
+ desktop: {
42
+ width: '100%'
43
+ }
44
+ }
45
+ },
46
+ advanced: {
47
+ 'spacing-setting': {
48
+ desktop: {
49
+ margin: {
50
+ bottom: 'var(--g-s-l)'
51
+ }
52
+ }
53
+ }
54
+ },
55
+ childrens: [
56
+ {
57
+ tag: 'SwiperCarouselItem',
58
+ label: 'Swiper Carousel Item',
59
+ childrens: []
60
+ },
61
+ {
62
+ tag: 'SwiperCarouselItem',
63
+ label: 'Swiper Carousel Item',
64
+ childrens: []
65
+ },
66
+ {
67
+ tag: 'SwiperCarouselItem',
68
+ label: 'Swiper Carousel Item',
69
+ childrens: []
70
+ },
71
+ {
72
+ tag: 'SwiperCarouselItem',
73
+ label: 'Swiper Carousel Item',
74
+ childrens: []
75
+ },
76
+ {
77
+ tag: 'SwiperCarouselItem',
78
+ label: 'Swiper Carousel Item',
79
+ childrens: []
80
+ }
81
+ ]
82
+ }
83
+ ]
84
+ }
85
+ ];
86
+
87
+ exports.SwiperCarouselPreset = SwiperCarouselPreset;