@gem-sdk/components 2.0.0-dev.621 → 2.0.0-dev.623
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/article/setting/configs/ArticleAuthor/uiV2.js +1 -0
- package/dist/cjs/article/setting/configs/ArticleReadMore/settings.js +0 -1
- package/dist/cjs/article/setting/configs/ArticleReadMore/uiV2.js +1 -0
- package/dist/cjs/banner/setting/presets/heroBanner1Col.js +1 -1
- package/dist/cjs/banner/setting/presets/heroBannerContentLeft.js +2 -4
- package/dist/cjs/banner/setting/presets/heroBannerContentRight.js +2 -5
- package/dist/cjs/banner/setting/presets/heroBannerVideo.js +10 -0
- package/dist/cjs/banner/setting/setting.js +9 -6
- package/dist/cjs/banner/setting/uiV2.js +34 -10
- package/dist/cjs/builder.js +12 -6
- package/dist/cjs/collection/components/collection-banner/components/CollectionBanner.liquid.js +1 -1
- package/dist/cjs/collection/components/collection-paginator/common/index.js +1 -2
- package/dist/cjs/collection/components/collection-paginator/common/styles.js +2 -2
- package/dist/cjs/collection/components/collection-paginator/components/CollectionPaginator.liquid.js +3 -3
- package/dist/cjs/collection/setting/collection-banner/configs/uiV2.js +2 -2
- package/dist/cjs/collection/setting/collection-paginator/configs/settings.js +8 -5
- package/dist/cjs/collection/setting/collection-paginator/configs/uiV2.js +28 -3
- package/dist/cjs/index.js +34 -32
- package/dist/cjs/index.liquid.js +16 -10
- package/dist/cjs/next.js +3 -1
- package/dist/cjs/product/components/ProductImagesV3/common/common.js +360 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getAttr.js +192 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getBorderActiveCss.js +26 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getClasses.js +94 -0
- package/dist/cjs/product/components/ProductImagesV3/common/getStyle.js +303 -0
- package/dist/cjs/product/components/ProductImagesV3/common/hoverAction.js +95 -0
- package/dist/cjs/product/components/ProductImagesV3/common/productFeaturedImage.js +59 -0
- package/dist/cjs/product/components/ProductImagesV3/common/productGallery.js +266 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/MediaIcon.js +63 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +36 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +109 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +139 -0
- package/dist/cjs/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +100 -0
- package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +77 -0
- package/dist/cjs/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +300 -0
- package/dist/cjs/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +44 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +83 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +182 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +30 -0
- package/dist/cjs/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +239 -0
- package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +28 -0
- package/dist/cjs/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +144 -0
- package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesAttr.js +14 -0
- package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesClassName.js +54 -0
- package/dist/cjs/product/components/ProductImagesV3/composables/getProductImagesStyles.js +53 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +55 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +41 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +134 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +203 -0
- package/dist/cjs/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +87 -0
- package/dist/cjs/product/components/ProductImagesV3/index.js +291 -0
- package/dist/cjs/product/components/ProductImagesV3/index.liquid.js +153 -0
- package/dist/cjs/product/index.js +6 -4
- package/dist/cjs/product/next.js +4 -0
- package/dist/cjs/product/setting/product-image-v3/ProductFeatureImage.js +252 -0
- package/dist/cjs/product/setting/product-image-v3/ProductGalleryImage.js +251 -0
- package/dist/cjs/product/setting/product-image-v3/ProductImages.js +74 -0
- package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +388 -0
- package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +518 -0
- package/dist/cjs/product/setting/product-image-v3/configs/setting-v2/index.js +336 -0
- package/dist/cjs/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +118 -0
- package/dist/cjs/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +119 -0
- package/dist/cjs/product/setting/product-image-v3/configs/uiV1.js +237 -0
- package/dist/cjs/product/setting/product-image-v3/configs/uiV2.js +491 -0
- package/dist/cjs/setting.js +97 -95
- package/dist/cjs/swiper-carousel/arrow/Arrow.js +52 -0
- package/dist/cjs/swiper-carousel/arrow/Arrow.liquid.js +46 -0
- package/dist/cjs/swiper-carousel/arrow/common/common.js +119 -0
- package/dist/cjs/swiper-carousel/arrow/common/getClass.js +50 -0
- package/dist/cjs/swiper-carousel/arrow/common/getStyle.js +84 -0
- package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.js +34 -0
- package/dist/cjs/swiper-carousel/carousel-item/SwiperItem.liquid.js +38 -0
- package/dist/cjs/swiper-carousel/carousel-item/common/getClass.js +29 -0
- package/dist/cjs/swiper-carousel/carousel-item/common/getStyle.js +79 -0
- package/dist/cjs/swiper-carousel/carousel-item/hook/useCarouseItem.js +22 -0
- package/dist/cjs/swiper-carousel/components/common/carousel.js +98 -0
- package/dist/cjs/swiper-carousel/components/const/index.js +5 -0
- package/dist/cjs/swiper-carousel/components/hooks/useTrackPreviewPause.js +34 -0
- package/dist/cjs/swiper-carousel/components/plugins/AnimationPlugin.js +42 -0
- package/dist/cjs/swiper-carousel/components/plugins/AutoPlayPlugin.js +105 -0
- package/dist/cjs/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +15 -0
- package/dist/cjs/swiper-carousel/components/plugins/MutationPlugin.js +45 -0
- package/dist/cjs/swiper-carousel/dots/Dots.js +51 -0
- package/dist/cjs/swiper-carousel/dots/Dots.liquid.js +26 -0
- package/dist/cjs/swiper-carousel/dots/common/common.js +28 -0
- package/dist/cjs/swiper-carousel/dots/common/getClass.js +40 -0
- package/dist/cjs/swiper-carousel/dots/common/getStyle.js +33 -0
- package/dist/cjs/swiper-carousel/dots/hook/useDotsSetting.js +21 -0
- package/dist/cjs/swiper-carousel/index.js +17 -0
- package/dist/cjs/swiper-carousel/next.js +22 -0
- package/dist/cjs/swiper-carousel/root/Swiper.js +128 -0
- package/dist/cjs/swiper-carousel/root/Swiper.liquid.js +104 -0
- package/dist/cjs/swiper-carousel/root/common/getAttr.js +25 -0
- package/dist/cjs/swiper-carousel/root/common/getClass.js +135 -0
- package/dist/cjs/swiper-carousel/root/common/getData.js +56 -0
- package/dist/cjs/swiper-carousel/root/common/getStyle.js +64 -0
- package/dist/cjs/swiper-carousel/root/hook/useCarousel.js +482 -0
- package/dist/cjs/swiper-carousel/setting/Swiper.js +42 -0
- package/dist/cjs/swiper-carousel/setting/SwiperItem.js +40 -0
- package/dist/cjs/swiper-carousel/setting/configs/presets.js +87 -0
- package/dist/cjs/swiper-carousel/setting/configs/settingV2.js +819 -0
- package/dist/cjs/swiper-carousel/setting/configs/uiV2.js +718 -0
- package/dist/esm/article/setting/configs/ArticleAuthor/uiV2.js +1 -0
- package/dist/esm/article/setting/configs/ArticleReadMore/settings.js +0 -1
- package/dist/esm/article/setting/configs/ArticleReadMore/uiV2.js +1 -0
- package/dist/esm/banner/setting/presets/heroBanner1Col.js +1 -1
- package/dist/esm/banner/setting/presets/heroBannerContentLeft.js +2 -4
- package/dist/esm/banner/setting/presets/heroBannerContentRight.js +2 -5
- package/dist/esm/banner/setting/presets/heroBannerVideo.js +10 -0
- package/dist/esm/banner/setting/setting.js +9 -6
- package/dist/esm/banner/setting/uiV2.js +34 -10
- package/dist/esm/builder.js +6 -0
- package/dist/esm/collection/components/collection-banner/components/CollectionBanner.liquid.js +1 -1
- package/dist/esm/collection/components/collection-paginator/common/index.js +1 -2
- package/dist/esm/collection/components/collection-paginator/common/styles.js +2 -2
- package/dist/esm/collection/components/collection-paginator/components/CollectionPaginator.liquid.js +3 -3
- package/dist/esm/collection/setting/collection-banner/configs/uiV2.js +2 -2
- package/dist/esm/collection/setting/collection-paginator/configs/settings.js +8 -5
- package/dist/esm/collection/setting/collection-paginator/configs/uiV2.js +28 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.liquid.js +3 -0
- package/dist/esm/next.js +3 -1
- package/dist/esm/product/components/ProductImagesV3/common/common.js +344 -0
- package/dist/esm/product/components/ProductImagesV3/common/getAttr.js +189 -0
- package/dist/esm/product/components/ProductImagesV3/common/getBorderActiveCss.js +24 -0
- package/dist/esm/product/components/ProductImagesV3/common/getClasses.js +83 -0
- package/dist/esm/product/components/ProductImagesV3/common/getStyle.js +292 -0
- package/dist/esm/product/components/ProductImagesV3/common/hoverAction.js +92 -0
- package/dist/esm/product/components/ProductImagesV3/common/productFeaturedImage.js +53 -0
- package/dist/esm/product/components/ProductImagesV3/common/productGallery.js +251 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/MediaIcon.js +59 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeatureVideo.js +32 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageCarousel.js +105 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductFeaturedImageOnly.js +135 -0
- package/dist/esm/product/components/ProductImagesV3/components/child/ProductGalleryGrid.js +96 -0
- package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.js +73 -0
- package/dist/esm/product/components/ProductImagesV3/components/feature-gallery/FeatureImageWithGallery.liquid.js +296 -0
- package/dist/esm/product/components/ProductImagesV3/components/feature-only/OnlyFeatureImage.js +40 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.js +79 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-carousel/GalleryCarousel.liquid.js +178 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.js +26 -0
- package/dist/esm/product/components/ProductImagesV3/components/gallery-grid/GalleryGrid.liquid.js +235 -0
- package/dist/esm/product/components/ProductImagesV3/components/lightbox/ButtonOpenLightBox.js +24 -0
- package/dist/esm/product/components/ProductImagesV3/components/lightbox/ProductImagesLightBox.js +140 -0
- package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesAttr.js +12 -0
- package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesClassName.js +52 -0
- package/dist/esm/product/components/ProductImagesV3/composables/getProductImagesStyles.js +51 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useFeatureImageWithGallery.js +53 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useFilterImagesByVariant.js +39 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useGalleryCarousel.js +132 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useProductFeaturedImageCarousel.js +201 -0
- package/dist/esm/product/components/ProductImagesV3/hooks/useProductGalleryGrid.js +85 -0
- package/dist/esm/product/components/ProductImagesV3/index.js +287 -0
- package/dist/esm/product/components/ProductImagesV3/index.liquid.js +149 -0
- package/dist/esm/product/index.js +26 -24
- package/dist/esm/product/next.js +4 -0
- package/dist/esm/product/setting/product-image-v3/ProductFeatureImage.js +248 -0
- package/dist/esm/product/setting/product-image-v3/ProductGalleryImage.js +248 -0
- package/dist/esm/product/setting/product-image-v3/ProductImages.js +70 -0
- package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductFeatureImage.js +384 -0
- package/dist/esm/product/setting/product-image-v3/configs/setting-v2/ProductGalleryImage.js +515 -0
- package/dist/esm/product/setting/product-image-v3/configs/setting-v2/index.js +334 -0
- package/dist/esm/product/setting/product-image-v3/configs/ui/FeatureNavigation.js +116 -0
- package/dist/esm/product/setting/product-image-v3/configs/ui/ImageListNavigation.js +117 -0
- package/dist/esm/product/setting/product-image-v3/configs/uiV1.js +235 -0
- package/dist/esm/product/setting/product-image-v3/configs/uiV2.js +489 -0
- package/dist/esm/setting.js +2 -0
- package/dist/esm/swiper-carousel/arrow/Arrow.js +48 -0
- package/dist/esm/swiper-carousel/arrow/Arrow.liquid.js +42 -0
- package/dist/esm/swiper-carousel/arrow/common/common.js +111 -0
- package/dist/esm/swiper-carousel/arrow/common/getClass.js +48 -0
- package/dist/esm/swiper-carousel/arrow/common/getStyle.js +82 -0
- package/dist/esm/swiper-carousel/carousel-item/SwiperItem.js +30 -0
- package/dist/esm/swiper-carousel/carousel-item/SwiperItem.liquid.js +34 -0
- package/dist/esm/swiper-carousel/carousel-item/common/getClass.js +27 -0
- package/dist/esm/swiper-carousel/carousel-item/common/getStyle.js +77 -0
- package/dist/esm/swiper-carousel/carousel-item/hook/useCarouseItem.js +20 -0
- package/dist/esm/swiper-carousel/components/common/carousel.js +93 -0
- package/dist/esm/swiper-carousel/components/const/index.js +3 -0
- package/dist/esm/swiper-carousel/components/hooks/useTrackPreviewPause.js +30 -0
- package/dist/esm/swiper-carousel/components/plugins/AnimationPlugin.js +35 -0
- package/dist/esm/swiper-carousel/components/plugins/AutoPlayPlugin.js +103 -0
- package/dist/esm/swiper-carousel/components/plugins/FixSliderMoveBackwards.js +13 -0
- package/dist/esm/swiper-carousel/components/plugins/MutationPlugin.js +43 -0
- package/dist/esm/swiper-carousel/dots/Dots.js +47 -0
- package/dist/esm/swiper-carousel/dots/Dots.liquid.js +22 -0
- package/dist/esm/swiper-carousel/dots/common/common.js +26 -0
- package/dist/esm/swiper-carousel/dots/common/getClass.js +38 -0
- package/dist/esm/swiper-carousel/dots/common/getStyle.js +31 -0
- package/dist/esm/swiper-carousel/dots/hook/useDotsSetting.js +19 -0
- package/dist/esm/swiper-carousel/index.js +15 -0
- package/dist/esm/swiper-carousel/next.js +18 -0
- package/dist/esm/swiper-carousel/root/Swiper.js +124 -0
- package/dist/esm/swiper-carousel/root/Swiper.liquid.js +100 -0
- package/dist/esm/swiper-carousel/root/common/getAttr.js +23 -0
- package/dist/esm/swiper-carousel/root/common/getClass.js +133 -0
- package/dist/esm/swiper-carousel/root/common/getData.js +54 -0
- package/dist/esm/swiper-carousel/root/common/getStyle.js +62 -0
- package/dist/esm/swiper-carousel/root/hook/useCarousel.js +480 -0
- package/dist/esm/swiper-carousel/setting/Swiper.js +38 -0
- package/dist/esm/swiper-carousel/setting/SwiperItem.js +36 -0
- package/dist/esm/swiper-carousel/setting/configs/presets.js +85 -0
- package/dist/esm/swiper-carousel/setting/configs/settingV2.js +815 -0
- package/dist/esm/swiper-carousel/setting/configs/uiV2.js +713 -0
- package/dist/types/index.d.ts +552 -117
- package/package.json +3 -3
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const AutoPlayPlugin = (slider)=>{
|
|
2
|
+
let autoplay = slider.options.autoplay ?? {};
|
|
3
|
+
let timeout;
|
|
4
|
+
let mouseOver = false;
|
|
5
|
+
let inViewport = false;
|
|
6
|
+
let observer = null;
|
|
7
|
+
// Thêm sự kiện cho dot nếu có
|
|
8
|
+
const $dots = slider?.container?.closest('[data-component-type="component"]')?.querySelector('.carousel-dots');
|
|
9
|
+
// Callback của IntersectionObserver
|
|
10
|
+
function handleIntersection(entries) {
|
|
11
|
+
entries.forEach((entry)=>{
|
|
12
|
+
// Với threshold 0, chỉ cần một phần bất kỳ hiển thị sẽ đánh dấu isIntersecting
|
|
13
|
+
inViewport = entry.isIntersecting;
|
|
14
|
+
if (inViewport) {
|
|
15
|
+
nextTimeout();
|
|
16
|
+
} else {
|
|
17
|
+
clearNextTimeout();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function initIntersectionObserver() {
|
|
22
|
+
// Nếu đã có observer hoặc không có container thì không khởi tạo lại
|
|
23
|
+
if (observer || !slider.container) return;
|
|
24
|
+
observer = new IntersectionObserver(handleIntersection, {
|
|
25
|
+
root: null,
|
|
26
|
+
threshold: 0
|
|
27
|
+
});
|
|
28
|
+
observer.observe(slider.container);
|
|
29
|
+
}
|
|
30
|
+
function clearNextTimeout() {
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
}
|
|
33
|
+
function nextTimeout() {
|
|
34
|
+
clearNextTimeout();
|
|
35
|
+
timeout = setTimeout(()=>{
|
|
36
|
+
// Nếu đang hover, autoplay bị tắt hoặc slider không trong viewport thì không chuyển slide
|
|
37
|
+
if (mouseOver || !autoplay.enable || !inViewport) return;
|
|
38
|
+
slider.next();
|
|
39
|
+
}, autoplay.delay ?? 2000);
|
|
40
|
+
}
|
|
41
|
+
function onMouseOver() {
|
|
42
|
+
mouseOver = true;
|
|
43
|
+
clearNextTimeout();
|
|
44
|
+
}
|
|
45
|
+
function onMouseOut() {
|
|
46
|
+
mouseOver = false;
|
|
47
|
+
nextTimeout();
|
|
48
|
+
}
|
|
49
|
+
slider.on('created', ()=>{
|
|
50
|
+
$dots?.addEventListener('mouseover', onMouseOver);
|
|
51
|
+
$dots?.addEventListener('mouseout', onMouseOut);
|
|
52
|
+
// Nếu tùy chọn pauseOnHover bật thì thêm sự kiện hover cho container slider
|
|
53
|
+
if (autoplay.pauseOnHover && slider.container) {
|
|
54
|
+
slider.container.addEventListener('mouseover', onMouseOver);
|
|
55
|
+
slider.container.addEventListener('mouseout', onMouseOut);
|
|
56
|
+
}
|
|
57
|
+
if (autoplay.enable) {
|
|
58
|
+
initIntersectionObserver();
|
|
59
|
+
nextTimeout();
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
slider.on('dragStarted', clearNextTimeout);
|
|
63
|
+
slider.on('animationEnded', nextTimeout);
|
|
64
|
+
slider.on('updated', (newOptions)=>{
|
|
65
|
+
autoplay = newOptions.options?.autoplay ?? {};
|
|
66
|
+
if (autoplay.enable) {
|
|
67
|
+
initIntersectionObserver();
|
|
68
|
+
nextTimeout();
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
slider.on('optionsChanged', (newOptions)=>{
|
|
72
|
+
if (newOptions.options.autoplay?.pauseOnHover !== autoplay.pauseOnHover && slider.container) {
|
|
73
|
+
if (newOptions.options.autoplay?.pauseOnHover) {
|
|
74
|
+
slider.container.addEventListener('mouseover', onMouseOver);
|
|
75
|
+
slider.container.addEventListener('mouseout', onMouseOut);
|
|
76
|
+
} else {
|
|
77
|
+
slider.container.removeEventListener('mouseover', onMouseOver);
|
|
78
|
+
slider.container.removeEventListener('mouseout', onMouseOut);
|
|
79
|
+
mouseOver = false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
autoplay = newOptions.options.autoplay ?? {};
|
|
83
|
+
if (autoplay.enable) {
|
|
84
|
+
initIntersectionObserver();
|
|
85
|
+
nextTimeout();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
slider.on('destroyed', ()=>{
|
|
89
|
+
if (slider.container) {
|
|
90
|
+
slider.container.removeEventListener('mouseover', onMouseOver);
|
|
91
|
+
slider.container.removeEventListener('mouseout', onMouseOut);
|
|
92
|
+
}
|
|
93
|
+
$dots?.removeEventListener('mouseover', onMouseOver);
|
|
94
|
+
$dots?.removeEventListener('mouseout', onMouseOut);
|
|
95
|
+
clearNextTimeout();
|
|
96
|
+
if (observer) {
|
|
97
|
+
observer.disconnect();
|
|
98
|
+
observer = null;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export { AutoPlayPlugin };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//Solution from https://github.com/rcbyr/keen-slider/issues/255
|
|
2
|
+
const FixSliderMoveBackwards = (slider)=>{
|
|
3
|
+
slider.on('animationEnded', (slider)=>{
|
|
4
|
+
const { rel, progress } = slider.track.details;
|
|
5
|
+
if (rel === 0 && progress !== 0) {
|
|
6
|
+
slider.moveToIdx(0, true, {
|
|
7
|
+
duration: 0
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { FixSliderMoveBackwards };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const MutationPlugin = (slider)=>{
|
|
2
|
+
const observer = new MutationObserver((mutations)=>{
|
|
3
|
+
mutations.forEach(()=>{
|
|
4
|
+
slider.update();
|
|
5
|
+
});
|
|
6
|
+
});
|
|
7
|
+
const config = {
|
|
8
|
+
childList: true
|
|
9
|
+
};
|
|
10
|
+
const resizeObserver = new ResizeObserver(function() {
|
|
11
|
+
resetStyleOfSlides(slider);
|
|
12
|
+
slider.update();
|
|
13
|
+
});
|
|
14
|
+
const resetStyleOfSlides = (slider)=>{
|
|
15
|
+
if (slider.options.vertical) {
|
|
16
|
+
removeMinMaxWidthOfSlides(slider);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
removeMinMaxHeightOfSlides(slider);
|
|
20
|
+
};
|
|
21
|
+
const removeMinMaxWidthOfSlides = (slider)=>{
|
|
22
|
+
slider.slides.forEach((slide)=>{
|
|
23
|
+
slide.style.maxWidth = '';
|
|
24
|
+
slide.style.minWidth = '';
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const removeMinMaxHeightOfSlides = (slider)=>{
|
|
28
|
+
slider.slides.forEach((slide)=>{
|
|
29
|
+
slide.style.maxHeight = '';
|
|
30
|
+
slide.style.minHeight = '';
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
slider.on('created', ()=>{
|
|
34
|
+
resizeObserver.observe(slider.container);
|
|
35
|
+
observer.observe(slider.container, config);
|
|
36
|
+
});
|
|
37
|
+
slider.on('destroyed', ()=>{
|
|
38
|
+
resizeObserver.unobserve(slider.container);
|
|
39
|
+
observer.disconnect();
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { MutationPlugin };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { makeStyleResponsiveByScreen, getGlobalColorResponsiveStyle, cls } from '@gem-sdk/core';
|
|
4
|
+
import { getData } from './common/common.js';
|
|
5
|
+
import { getDotClass } from './common/getClass.js';
|
|
6
|
+
import { getDotStyle } from './common/getStyle.js';
|
|
7
|
+
import { useDotsSetting } from './hook/useDotsSetting.js';
|
|
8
|
+
import { If } from '@gem-sdk/system';
|
|
9
|
+
|
|
10
|
+
const Dots = (props)=>{
|
|
11
|
+
const { onHandleClick, dotSize, dotActiveColor, dotColor } = props;
|
|
12
|
+
const { isLoop, checkIsActive } = useDotsSetting(props);
|
|
13
|
+
const { checkHidden, getDotItems } = getData(props);
|
|
14
|
+
const dotItems = getDotItems(isLoop);
|
|
15
|
+
const { dotClass } = getDotClass(props);
|
|
16
|
+
const { dotStyle } = getDotStyle(props, 'react');
|
|
17
|
+
const renderDotItems = ()=>{
|
|
18
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
19
|
+
children: dotItems?.map((idx)=>{
|
|
20
|
+
const isActive = checkIsActive(idx);
|
|
21
|
+
return /*#__PURE__*/ jsx("button", {
|
|
22
|
+
"aria-label": "Dot",
|
|
23
|
+
onClick: ()=>{
|
|
24
|
+
onHandleClick && onHandleClick(idx, isLoop);
|
|
25
|
+
},
|
|
26
|
+
style: {
|
|
27
|
+
...makeStyleResponsiveByScreen('w', dotSize, 'px'),
|
|
28
|
+
...isActive ? getGlobalColorResponsiveStyle('bg', dotActiveColor) : getGlobalColorResponsiveStyle('bg', dotColor)
|
|
29
|
+
},
|
|
30
|
+
className: cls('gp-aspect-square gp-w-3 gp-rounded-full gp-shadow-md', {
|
|
31
|
+
'gem-slider-dot-active': isActive,
|
|
32
|
+
'gem-slider-dot-inactive': !isActive
|
|
33
|
+
})
|
|
34
|
+
}, idx);
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
39
|
+
children: If(!checkHidden(dotItems), /*#__PURE__*/ jsx("div", {
|
|
40
|
+
className: dotClass,
|
|
41
|
+
style: dotStyle,
|
|
42
|
+
children: renderDotItems()
|
|
43
|
+
}))
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { Dots as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen, template } from '@gem-sdk/core';
|
|
2
|
+
import { getDotClass } from './common/getClass.js';
|
|
3
|
+
import { getDotStyle } from './common/getStyle.js';
|
|
4
|
+
import { If } from '@gem-sdk/system';
|
|
5
|
+
import { getData } from './common/common.js';
|
|
6
|
+
|
|
7
|
+
const Dots = (props)=>{
|
|
8
|
+
const isLoop = getResponsiveValueByScreen(props.loop, 'desktop', false);
|
|
9
|
+
const { checkHidden, getDotItems } = getData(props);
|
|
10
|
+
const dotItems = getDotItems(isLoop);
|
|
11
|
+
const { dotClass } = getDotClass(props);
|
|
12
|
+
const { dotStyle } = getDotStyle(props);
|
|
13
|
+
return template`
|
|
14
|
+
${If(!checkHidden(dotItems), template`
|
|
15
|
+
<div class="${dotClass}" style="${dotStyle}">
|
|
16
|
+
<!-- item render by js -->
|
|
17
|
+
</div>
|
|
18
|
+
`)}
|
|
19
|
+
`;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { Dots as default };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '@gem-sdk/core';
|
|
2
|
+
|
|
3
|
+
const getData = (props)=>{
|
|
4
|
+
const { hiddenWhenOnlyOne } = props;
|
|
5
|
+
const getDotItems = (isLoop)=>{
|
|
6
|
+
const { enabledSneakPeak, totalSlideItem = 0, numberOfFullWidthShow = 0, slideItemsPerPage = 0 } = props;
|
|
7
|
+
if (enabledSneakPeak) {
|
|
8
|
+
return Array.from({
|
|
9
|
+
length: isLoop ? totalSlideItem : totalSlideItem - numberOfFullWidthShow + 1
|
|
10
|
+
}, (_, i)=>i);
|
|
11
|
+
} else {
|
|
12
|
+
return Array.from({
|
|
13
|
+
length: isLoop ? totalSlideItem : Math.ceil(totalSlideItem / slideItemsPerPage)
|
|
14
|
+
}, (_, i)=>i);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const checkHidden = (totalDots)=>{
|
|
18
|
+
return hiddenWhenOnlyOne && totalDots?.length < 2;
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
checkHidden,
|
|
22
|
+
getDotItems
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { getData };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
import { createClass } from '@gem-sdk/system';
|
|
3
|
+
import { DOT_CONTAINER_SELECTOR } from '../../components/const/index.js';
|
|
4
|
+
|
|
5
|
+
const getDotClass = (props)=>{
|
|
6
|
+
const { dotStyle, vertical, className, uniqueComponentId } = props;
|
|
7
|
+
const getDisplayClass = ()=>{
|
|
8
|
+
const devices = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'tablet',
|
|
11
|
+
'mobile'
|
|
12
|
+
];
|
|
13
|
+
const result = {};
|
|
14
|
+
devices.forEach((device)=>{
|
|
15
|
+
const dotStyleSetting = getResponsiveValueByScreen(dotStyle, device);
|
|
16
|
+
const verticalSetting = getResponsiveValueByScreen(vertical, device);
|
|
17
|
+
const deviceType = device === 'desktop' ? '' : `${device}:`;
|
|
18
|
+
result[`${deviceType}gp-absolute`] = dotStyleSetting === 'inside';
|
|
19
|
+
result[`${deviceType}gp-static`] = dotStyleSetting !== 'inside';
|
|
20
|
+
result[`${deviceType}gp-flex-row ${deviceType}gp-left-0 ${deviceType}gp-right-0`] = !verticalSetting;
|
|
21
|
+
result[`${deviceType}gp-flex-col ${deviceType}gp-ml-2 ${deviceType}gp-w-fit ${deviceType}gp-h-full`] = !!verticalSetting;
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
const dotClass = createClass({
|
|
26
|
+
[`${DOT_CONTAINER_SELECTOR} ${DOT_CONTAINER_SELECTOR}-${uniqueComponentId}`]: true,
|
|
27
|
+
['gp-z-2 gp-flex gp-flex-1 gp-items-center gp-justify-center gp-gap-2 gp-text-center']: true,
|
|
28
|
+
...className && {
|
|
29
|
+
[className]: true
|
|
30
|
+
},
|
|
31
|
+
...getDisplayClass()
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
dotClass
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { getDotClass };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createStyleReact, createStyle } from '@gem-sdk/system';
|
|
2
|
+
import { makeDotGapToCarouselStyle, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
3
|
+
|
|
4
|
+
const getDotStyle = (props, componentType)=>{
|
|
5
|
+
const { dotStyle: style, dotGapToCarousel, vertical } = props;
|
|
6
|
+
const isReactComp = componentType === 'react';
|
|
7
|
+
const getStyleDisplayDots = ()=>{
|
|
8
|
+
const devices = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'tablet',
|
|
11
|
+
'mobile'
|
|
12
|
+
];
|
|
13
|
+
const result = {};
|
|
14
|
+
devices.forEach((device)=>{
|
|
15
|
+
const dotStyleSetting = getResponsiveValueByScreen(style, device);
|
|
16
|
+
const deviceType = device === 'desktop' ? '' : `${device}`;
|
|
17
|
+
result[`--d${deviceType.length === 0 ? '' : '-' + deviceType}`] = dotStyleSetting && dotStyleSetting !== 'none' ? 'flex' : 'none';
|
|
18
|
+
});
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
const dotStyleObj = {
|
|
22
|
+
...makeDotGapToCarouselStyle(style, dotGapToCarousel, vertical),
|
|
23
|
+
...getStyleDisplayDots()
|
|
24
|
+
};
|
|
25
|
+
const dotStyle = isReactComp ? createStyleReact(dotStyleObj) : createStyle(dotStyleObj);
|
|
26
|
+
return {
|
|
27
|
+
dotStyle
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { getDotStyle };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useCurrentDevice, getResponsiveValueByScreen } from '@gem-sdk/core';
|
|
2
|
+
|
|
3
|
+
const useDotsSetting = (props)=>{
|
|
4
|
+
const { loop, enabledSneakPeak, slideItemsPerPage = 1, currentSlide = 1 } = props;
|
|
5
|
+
const currentDevice = useCurrentDevice();
|
|
6
|
+
const isLoop = getResponsiveValueByScreen(loop, currentDevice, false);
|
|
7
|
+
const checkIsActive = (idx)=>{
|
|
8
|
+
if (enabledSneakPeak) {
|
|
9
|
+
return idx === currentSlide;
|
|
10
|
+
}
|
|
11
|
+
return idx === (isLoop ? currentSlide : Math.ceil(currentSlide / slideItemsPerPage));
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
isLoop,
|
|
15
|
+
checkIsActive
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { useDotsSetting };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import 'react/jsx-runtime';
|
|
2
|
+
import '@gem-sdk/core';
|
|
3
|
+
import 'react';
|
|
4
|
+
import '@gem-sdk/system';
|
|
5
|
+
import '@gem-sdk/keen-slider/react';
|
|
6
|
+
import 'next/link';
|
|
7
|
+
import config from './setting/Swiper.js';
|
|
8
|
+
import config$1 from './setting/SwiperItem.js';
|
|
9
|
+
|
|
10
|
+
const swiperCarouselSetting = {
|
|
11
|
+
SwiperCarousel: config,
|
|
12
|
+
SwiperCarouselItem: config$1
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { swiperCarouselSetting };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import dynamic from 'next/dynamic';
|
|
2
|
+
import Loading from '../common/components/Loading.js';
|
|
3
|
+
import 'react/jsx-runtime';
|
|
4
|
+
import 'react';
|
|
5
|
+
import '@gem-sdk/core';
|
|
6
|
+
|
|
7
|
+
const SwiperCarousel = dynamic(()=>import('./root/Swiper.js'), {
|
|
8
|
+
loading: Loading
|
|
9
|
+
});
|
|
10
|
+
const SwiperCarouselItem = dynamic(()=>import('./carousel-item/SwiperItem.js'), {
|
|
11
|
+
loading: Loading
|
|
12
|
+
});
|
|
13
|
+
var swiperCarousel = {
|
|
14
|
+
SwiperCarousel,
|
|
15
|
+
SwiperCarouselItem
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { swiperCarousel as default };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { useCurrentDevice, filterToolbarPreview, isEmptyChildren } from '@gem-sdk/core';
|
|
4
|
+
import { forwardRef, Children, isValidElement } from 'react';
|
|
5
|
+
import Dots from '../dots/Dots.js';
|
|
6
|
+
import Arrow from '../arrow/Arrow.js';
|
|
7
|
+
import { mappingNavigationCarousel } from '../arrow/common/common.js';
|
|
8
|
+
import { useCarousel } from './hook/useCarousel.js';
|
|
9
|
+
import { getClass } from './common/getClass.js';
|
|
10
|
+
import { getStyle } from './common/getStyle.js';
|
|
11
|
+
import { getAttr } from './common/getAttr.js';
|
|
12
|
+
import { getData } from './common/getData.js';
|
|
13
|
+
|
|
14
|
+
const Carousel = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
15
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, elmRef } = props;
|
|
16
|
+
const setting = mappingNavigationCarousel(props.setting);
|
|
17
|
+
const renderData = {
|
|
18
|
+
...props,
|
|
19
|
+
setting
|
|
20
|
+
};
|
|
21
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
22
|
+
const { totalSlideItem, isInfinity, slider, currentSlide, localRef, showNavigation, isRenderDots, handleDotClick, getItemsPerPage, sliderRef, handleNextAndPrevSlide, dispatchEventSelectSlide, getNumberOfFullWidthShow } = useCarousel(renderData, ref);
|
|
23
|
+
const { loopConfig, arrowShowConfig } = getData(renderData);
|
|
24
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass(renderData);
|
|
25
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle } = getStyle(renderData);
|
|
26
|
+
const { rootAttrRender, sliderAttr } = getAttr(renderData);
|
|
27
|
+
const currentDevice = useCurrentDevice();
|
|
28
|
+
const enabledSneakPeak = setting?.sneakPeak?.[currentDevice];
|
|
29
|
+
const renderArrow = (position)=>{
|
|
30
|
+
const isNext = position === 'next';
|
|
31
|
+
return /*#__PURE__*/ jsx(Arrow, {
|
|
32
|
+
uid: builderProps?.uid,
|
|
33
|
+
custom: setting?.arrowCustom ?? '',
|
|
34
|
+
showArrow: arrowShowConfig,
|
|
35
|
+
arrowButtonSize: arrowButtonSize || {},
|
|
36
|
+
arrowIconSize: arrowIconSize || {},
|
|
37
|
+
arrowBackgroundColor: arrowBackgroundColor || '',
|
|
38
|
+
arrowCustomColor: arrowCustomColor,
|
|
39
|
+
gapToEachSize: arrowGapToEachSide,
|
|
40
|
+
showWhenHover: showWhenHover,
|
|
41
|
+
arrowBorder: arrowBorder || {},
|
|
42
|
+
arrowCorner: roundedArrow || {},
|
|
43
|
+
arrowShadow: arrowShadow || {},
|
|
44
|
+
onClick: (e)=>{
|
|
45
|
+
e.stopPropagation();
|
|
46
|
+
handleNextAndPrevSlide(position);
|
|
47
|
+
},
|
|
48
|
+
left: !isNext,
|
|
49
|
+
disabled: !isInfinity && slider?.track?.details?.abs === 0,
|
|
50
|
+
vertical: setting?.vertical,
|
|
51
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
52
|
+
rootId: props?.parentClass
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const renderChildren = ()=>{
|
|
56
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
57
|
+
children: isEmptyChildren(children) ? /*#__PURE__*/ jsx("div", {
|
|
58
|
+
children: "No Slider"
|
|
59
|
+
}) : Children.map(filterToolbarPreview(children), (child, index)=>{
|
|
60
|
+
if (/*#__PURE__*/ isValidElement(child)) {
|
|
61
|
+
return /*#__PURE__*/ jsx(child.type, {
|
|
62
|
+
...child.props,
|
|
63
|
+
index: index,
|
|
64
|
+
parentSettings: setting,
|
|
65
|
+
parentStyle: styles,
|
|
66
|
+
background: setting?.background,
|
|
67
|
+
parentUid: builderProps?.uid,
|
|
68
|
+
dispatchEventSelectSlide: dispatchEventSelectSlide
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
return /*#__PURE__*/ jsx("div", {
|
|
76
|
+
ref: elmRef,
|
|
77
|
+
...rootAttrRender,
|
|
78
|
+
className: rootClassRender,
|
|
79
|
+
style: rootStyleRender,
|
|
80
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
81
|
+
ref: localRef,
|
|
82
|
+
...builderAttrs,
|
|
83
|
+
className: wrapperClassRender,
|
|
84
|
+
style: wrapperStyleRender,
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ jsxs("div", {
|
|
87
|
+
className: wrapperInnerClass,
|
|
88
|
+
style: wrapperInnerStyle,
|
|
89
|
+
children: [
|
|
90
|
+
showNavigation && renderArrow('prev'),
|
|
91
|
+
/*#__PURE__*/ jsx("div", {
|
|
92
|
+
ref: sliderRef,
|
|
93
|
+
...sliderAttr,
|
|
94
|
+
className: sliderClass,
|
|
95
|
+
children: renderChildren()
|
|
96
|
+
}),
|
|
97
|
+
showNavigation && renderArrow('next')
|
|
98
|
+
]
|
|
99
|
+
}),
|
|
100
|
+
isRenderDots && /*#__PURE__*/ jsx(Dots, {
|
|
101
|
+
showDots: setting?.dot,
|
|
102
|
+
dotStyle: setting?.dotStyle,
|
|
103
|
+
totalSlideItem: totalSlideItem,
|
|
104
|
+
slideItemsPerPage: getItemsPerPage(),
|
|
105
|
+
currentSlide: currentSlide,
|
|
106
|
+
enabledSneakPeak: enabledSneakPeak,
|
|
107
|
+
vertical: setting?.vertical,
|
|
108
|
+
loop: loopConfig,
|
|
109
|
+
dotColor: setting?.dotColor,
|
|
110
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
111
|
+
dotSize: setting?.dotSize,
|
|
112
|
+
dotActiveColor: setting?.dotActiveColor,
|
|
113
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne,
|
|
114
|
+
sneakPeakType: setting?.sneakPeakType,
|
|
115
|
+
numberOfFullWidthShow: getNumberOfFullWidthShow(currentDevice),
|
|
116
|
+
onHandleClick: handleDotClick
|
|
117
|
+
}),
|
|
118
|
+
filterToolbarPreview(children, true)
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
export { Carousel as default };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { template, RenderIf, isLocalEnv, baseAssetURL, WrapRenderChildren, RenderChildren } from '@gem-sdk/core';
|
|
2
|
+
import Arrow from '../arrow/Arrow.liquid.js';
|
|
3
|
+
import { getSettingPreloadData, getStaticLocale } from '../../helpers.js';
|
|
4
|
+
import Dots from '../dots/Dots.liquid.js';
|
|
5
|
+
import { mappingNavigationCarousel } from '../arrow/common/common.js';
|
|
6
|
+
import { getData } from './common/getData.js';
|
|
7
|
+
import { getClass } from './common/getClass.js';
|
|
8
|
+
import { getStyle } from './common/getStyle.js';
|
|
9
|
+
import { getAttr } from './common/getAttr.js';
|
|
10
|
+
|
|
11
|
+
const Carousel = (props)=>{
|
|
12
|
+
const { children, builderAttrs, builderProps, styles, isHiddenArrowWhenDisabled = true, hiddenDotWhenOnlyOne, rootId, rawChildren, conditionAppendJs } = props;
|
|
13
|
+
const setting = mappingNavigationCarousel(props.setting);
|
|
14
|
+
const renderData = {
|
|
15
|
+
...props,
|
|
16
|
+
setting
|
|
17
|
+
};
|
|
18
|
+
const { arrowButtonSize, arrowBackgroundColor, arrowGapToEachSide = '16', roundedArrow, arrowIconSize, arrowCustomColor, arrowBorder, arrowShadow, showWhenHover } = setting ?? {};
|
|
19
|
+
const { uniqueComponentId, loopConfig, arrowShowConfig, stateData } = getData(renderData);
|
|
20
|
+
const { rootClassRender, wrapperClassRender, wrapperInnerClass, sliderClass } = getClass(renderData);
|
|
21
|
+
const { rootStyleRender, wrapperStyleRender, wrapperInnerStyle, sliderStyle } = getStyle(renderData);
|
|
22
|
+
const { rootAttrRender, sliderAttr } = getAttr(renderData);
|
|
23
|
+
const renderJS = ()=>{
|
|
24
|
+
return RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-swiper.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-swiper.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`);
|
|
25
|
+
};
|
|
26
|
+
const renderArrow = (position)=>{
|
|
27
|
+
const isNext = position === 'next';
|
|
28
|
+
return Arrow({
|
|
29
|
+
uid: builderProps?.uid,
|
|
30
|
+
componentId: uniqueComponentId,
|
|
31
|
+
custom: setting?.arrowCustom ?? '',
|
|
32
|
+
showArrow: arrowShowConfig,
|
|
33
|
+
arrowButtonSize: arrowButtonSize || {},
|
|
34
|
+
arrowIconSize: arrowIconSize || {},
|
|
35
|
+
arrowBackgroundColor: arrowBackgroundColor ?? '',
|
|
36
|
+
arrowCustomColor: arrowCustomColor,
|
|
37
|
+
gapToEachSize: arrowGapToEachSide,
|
|
38
|
+
showWhenHover: showWhenHover,
|
|
39
|
+
arrowBorder: arrowBorder || {},
|
|
40
|
+
arrowCorner: roundedArrow || {},
|
|
41
|
+
arrowShadow: arrowShadow || {},
|
|
42
|
+
left: !isNext,
|
|
43
|
+
onClick: (e)=>{
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
},
|
|
46
|
+
vertical: setting?.vertical,
|
|
47
|
+
isHiddenWhenDisabled: isHiddenArrowWhenDisabled,
|
|
48
|
+
rootId: rootId
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
const renderChildren = ()=>{
|
|
52
|
+
return template`
|
|
53
|
+
${rawChildren?.length ? WrapRenderChildren({
|
|
54
|
+
uid: builderProps?.uid ?? '',
|
|
55
|
+
customProps: rawChildren[0]?.customProps
|
|
56
|
+
}, rawChildren.map((child, index)=>{
|
|
57
|
+
if (child) {
|
|
58
|
+
return template`${RenderChildren({
|
|
59
|
+
...child,
|
|
60
|
+
index,
|
|
61
|
+
parentSettings: setting,
|
|
62
|
+
parentStyle: styles,
|
|
63
|
+
background: setting?.background,
|
|
64
|
+
parentUid: builderProps?.uid
|
|
65
|
+
})}`;
|
|
66
|
+
}
|
|
67
|
+
})) : children ?? `<div>${getStaticLocale('Carousel', 'no_slider')}</div>`}`;
|
|
68
|
+
};
|
|
69
|
+
return template /* liquid */ `
|
|
70
|
+
<gp-swiper gp-data='${stateData}' ${rootAttrRender} style="${rootStyleRender}" class="${rootClassRender}">
|
|
71
|
+
<div
|
|
72
|
+
${builderAttrs}
|
|
73
|
+
class="${wrapperClassRender}"
|
|
74
|
+
style="${wrapperStyleRender}"
|
|
75
|
+
>
|
|
76
|
+
<div ${sliderAttr} class="${wrapperInnerClass}" style="${wrapperInnerStyle}">
|
|
77
|
+
${renderArrow('prev')}
|
|
78
|
+
<div class="${sliderClass}" style="${sliderStyle}">
|
|
79
|
+
${renderChildren()}
|
|
80
|
+
</div>
|
|
81
|
+
${renderArrow('next')}
|
|
82
|
+
</div>
|
|
83
|
+
${Dots({
|
|
84
|
+
loop: loopConfig,
|
|
85
|
+
showDots: setting?.dot,
|
|
86
|
+
dotStyle: setting?.dotStyle,
|
|
87
|
+
dotGapToCarousel: setting?.dotGapToCarousel,
|
|
88
|
+
dotSize: setting?.dotSize,
|
|
89
|
+
vertical: setting?.vertical,
|
|
90
|
+
uniqueComponentId: uniqueComponentId,
|
|
91
|
+
hiddenWhenOnlyOne: hiddenDotWhenOnlyOne
|
|
92
|
+
})}
|
|
93
|
+
</div>
|
|
94
|
+
</gp-swiper>
|
|
95
|
+
${conditionAppendJs ? `{% if ${conditionAppendJs} %} ${renderJS()} {% endif %}` : renderJS()}
|
|
96
|
+
|
|
97
|
+
`;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { Carousel as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createAttr } from '@gem-sdk/system';
|
|
2
|
+
import { getData } from './getData.js';
|
|
3
|
+
|
|
4
|
+
const getAttr = (props)=>{
|
|
5
|
+
const { rootAttrs, builderProps, rootId } = props;
|
|
6
|
+
const { uniqueComponentId } = getData(props);
|
|
7
|
+
const rootAttrRender = createAttr({
|
|
8
|
+
'data-id': `${builderProps?.uid}`,
|
|
9
|
+
id: `gp-root-carousel-${uniqueComponentId}`,
|
|
10
|
+
...rootAttrs
|
|
11
|
+
});
|
|
12
|
+
const sliderAttr = createAttr({
|
|
13
|
+
...(builderProps?.uid || rootId) && {
|
|
14
|
+
id: `gp-swiper-${uniqueComponentId}`
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
rootAttrRender,
|
|
19
|
+
sliderAttr
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { getAttr };
|