@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,83 @@
1
+ import { getResponsiveValueByScreen } from '@gem-sdk/core';
2
+
3
+ function composeClasses(classList) {
4
+ return classList.split(' ').reduce((acc, item)=>{
5
+ acc[item] = true;
6
+ return acc;
7
+ }, {});
8
+ }
9
+ const getWrapperClasses = ({ extraClass, isAddOverFlowClass = false })=>{
10
+ let classList = 'gp-relative gp-w-full';
11
+ if (extraClass) classList += ` ${extraClass}`;
12
+ if (isAddOverFlowClass) classList += ` gp-overflow-hidden`;
13
+ return composeClasses(classList);
14
+ };
15
+ const getGalleryWrapperClasses = ({ extraClass })=>{
16
+ let classList = 'gallery-wrapper gp-product-images-gallery gp-flex gp-overflow-hidden gp-max-w-full gp-max-h-full data-[only-image=true]:gp-hidden';
17
+ if (extraClass) classList += ` ${extraClass}`;
18
+ return composeClasses(classList);
19
+ };
20
+ const getGalleryGridWrapperClasses = ({ extraClass })=>{
21
+ let classList = 'product-feature-image grid-gallery gp-flex !gp-h-fit gp-w-full gp-flex-wrap scrollbar-track:gp-rounded-2xl scrollbar-thumb:gp-rounded-2xl scrollbar-thumb:gp-bg-gray-400';
22
+ if (extraClass) classList += ` ${extraClass}`;
23
+ return composeClasses(classList);
24
+ };
25
+ const getFtImageWithGalleryClasses = ({ extraClass })=>{
26
+ let classList = 'gp-flex !gp-h-fit gp-relative gp-overflow-hidden';
27
+ if (extraClass) classList += ` ${extraClass}`;
28
+ return composeClasses(classList);
29
+ };
30
+ const getImageGalleryWrapperClasses = ({ extraClass })=>{
31
+ let classList = 'gp-flex gp-h-fit gp-max-w-full';
32
+ if (extraClass) classList += ` ${extraClass}`;
33
+ return composeClasses(classList);
34
+ };
35
+ const getFeaturedImageCarouselClasses = ({ extraClass })=>{
36
+ let classList = '`gp-flex-1 gp-w-full gp-feature-image-carousel';
37
+ if (extraClass) classList += ` ${extraClass}`;
38
+ return composeClasses(classList);
39
+ };
40
+ const getFeaturedImageClasses = ({ setting, extraClass })=>{
41
+ let classList = extraClass ?? '';
42
+ const devices = [
43
+ 'desktop',
44
+ 'tablet',
45
+ 'mobile'
46
+ ];
47
+ devices.forEach((device)=>{
48
+ const navigation = getResponsiveValueByScreen(setting?.ftNavigationPosition, device);
49
+ const suffix = device !== 'desktop' ? `${device}:` : '';
50
+ navigation === 'outside' ? classList += ` ${suffix}gp-px-[16px]` : classList += ` ${suffix}gp-px-0`;
51
+ });
52
+ return composeClasses(classList);
53
+ };
54
+ const getFeaturedImageGalleryClasses = ({ settings, extraClass })=>{
55
+ let classList = extraClass ?? 'gp-flex-1 gp-w-full carousel-gallery';
56
+ const devices = [
57
+ 'desktop',
58
+ 'tablet',
59
+ 'mobile'
60
+ ];
61
+ devices.forEach((device)=>{
62
+ const navigation = getResponsiveValueByScreen(settings?.navigationPosition, device);
63
+ const type = getResponsiveValueByScreen(settings?.type, device);
64
+ const position = getResponsiveValueByScreen(settings?.position, device);
65
+ const suffix = device !== 'desktop' ? `${device}:` : '';
66
+ navigation === 'outside' && type === 'slider' && [
67
+ 'bottom-center'
68
+ ].includes(position || '') ? classList += ` ${suffix}gp-px-[16px]` : classList += ` ${suffix}gp-px-0`;
69
+ });
70
+ return composeClasses(classList);
71
+ };
72
+ const getGalleryItemClasses = ({ extraClass })=>{
73
+ let classList = `gp-image-item gp-flex gp-items-center gp-justify-center gp-group gp-relative gp-overflow-hidden gp-cursor-pointer data-[outline=deactive]:after:!gp-border-transparent data-[outline=deactive]:after:!gp-border-transparent`;
74
+ if (extraClass) classList += ` ${extraClass}`;
75
+ return composeClasses(classList);
76
+ };
77
+ const getFeaturedCarouselItemClasses = ({ extraClass })=>{
78
+ let classList = `gp-group gp-z-0 gp-flex !gp-min-w-full !gp-max-w-full gp-w-full gp-relative gp-items-start gp-justify-center gp-overflow-hidden gp-outline-1 -gp-outline-offset-1 gp-image-item gp-ft-image-item data-[outline=active]:gp-outline`;
79
+ if (extraClass) classList += ` ${extraClass}`;
80
+ return composeClasses(classList);
81
+ };
82
+
83
+ export { getFeaturedCarouselItemClasses, getFeaturedImageCarouselClasses, getFeaturedImageClasses, getFeaturedImageGalleryClasses, getFtImageWithGalleryClasses, getGalleryGridWrapperClasses, getGalleryItemClasses, getGalleryWrapperClasses, getImageGalleryWrapperClasses, getWrapperClasses };
@@ -0,0 +1,292 @@
1
+ import { makeStyleResponsive, makeHeight, getHeightByShapeGlobalSize, makeWidth, composeRadius, getResponsiveValueByScreen, makeStyleWithDefault, getWidthByShapeGlobalSize } from '@gem-sdk/core';
2
+ import { getStyleGridLayout, getStyleGridOrderForFeature, getStyleGridOrderForGallery, getStyleInsideLayout, convertSpacing, getDisplayStyle, convertSpacingForIndisdeLayout } from './common.js';
3
+ import { getShapeByLayout, sizeSettingDefaultForNewLayout, getSettingWidthForGridItem, getSettingMinWidthForCarouselItem, getSettingWidthForCarouselItem, checkDisplayGalleryByWidth } from './productGallery.js';
4
+
5
+ const DEVICES = [
6
+ 'desktop',
7
+ 'mobile',
8
+ 'tablet'
9
+ ];
10
+ function filterTruthyStyles(styles) {
11
+ return Object.fromEntries(Object.entries(styles || {}).filter(([, value])=>!!value));
12
+ }
13
+ const getWrapContainerStyle = (settings, isOnlyOneImage)=>{
14
+ const gridLayout = getStyleGridLayout({
15
+ position: settings.position,
16
+ ratioLayout: settings.ratioLayout,
17
+ ratioLayoutRight: settings.ratioLayoutRight,
18
+ isHiddenGalleryImages: !!isOnlyOneImage
19
+ });
20
+ const layoutOneImage = {
21
+ '--gtc': 'minmax(0, 12fr)'
22
+ };
23
+ const composeStyles = {
24
+ ...isOnlyOneImage ? layoutOneImage : gridLayout,
25
+ ...makeStyleResponsive('gg', settings?.spacing)
26
+ };
27
+ return filterTruthyStyles(composeStyles);
28
+ };
29
+ const getFeatureImageStyle = (settings, { enableOrder, enableDisplay })=>{
30
+ const getStyleFeaturedImageDisplay = ()=>{
31
+ return getDisplayStyle((device)=>![
32
+ 'bottom-center',
33
+ 'left',
34
+ 'right',
35
+ 'only-feature',
36
+ 'inside-bottom',
37
+ 'inside-left',
38
+ 'inside-right'
39
+ ].includes(getResponsiveValueByScreen(settings?.position, device) || ''), 'flex');
40
+ };
41
+ const featureImageOrder = getStyleGridOrderForFeature({
42
+ position: settings?.position
43
+ });
44
+ const composeStyles = {
45
+ ...makeStyleResponsive('jc', settings?.align),
46
+ ...enableOrder && {
47
+ ...featureImageOrder
48
+ },
49
+ ...enableDisplay && {
50
+ ...getStyleFeaturedImageDisplay()
51
+ }
52
+ };
53
+ return filterTruthyStyles(composeStyles);
54
+ };
55
+ const getGalleryImageStyle = (settings, featureImageHeight)=>{
56
+ const galleryImageOrder = getStyleGridOrderForGallery({
57
+ position: settings.position
58
+ });
59
+ const getHeightForGallery = ()=>{
60
+ let result = {};
61
+ const ftImageHeight = featureImageHeight ?? 0;
62
+ DEVICES.forEach((device)=>{
63
+ const position = getResponsiveValueByScreen(settings?.position, device);
64
+ const isHorizontalLayout = [
65
+ 'left',
66
+ 'right'
67
+ ].includes(position);
68
+ const spacingByDevice = getResponsiveValueByScreen(settings?.spacing, device);
69
+ const isHorizontalInsideLayout = [
70
+ 'inside-left',
71
+ 'inside-right'
72
+ ].includes(position);
73
+ const spacingValue = convertSpacingForIndisdeLayout(spacingByDevice);
74
+ const heightInside = `calc(${ftImageHeight}px - ${spacingValue})`;
75
+ result = {
76
+ ...result,
77
+ [device]: isHorizontalLayout ? ftImageHeight + 'px' : isHorizontalInsideLayout ? heightInside : 'auto'
78
+ };
79
+ });
80
+ return result;
81
+ };
82
+ const shapeByLayout = getShapeByLayout({
83
+ shape: settings.shape,
84
+ shapeForBottom: settings.shapeForBottom,
85
+ shapeFor1Col: settings.shapeFor1Col,
86
+ shapeFor2Col: settings.shapeFor2Col,
87
+ shapeForFtOnly: settings.shapeForFtOnly,
88
+ shapeForInsideBottom: settings.shapeForInsideBottom ?? sizeSettingDefaultForNewLayout,
89
+ shapeForInside: settings.shapeForInside ?? sizeSettingDefaultForNewLayout
90
+ }, settings.position);
91
+ const styleInsideLayout = getStyleInsideLayout(settings.position, shapeByLayout, settings?.spacing);
92
+ const composeStyles = {
93
+ ...makeStyleResponsive('h', makeHeight(getHeightForGallery())),
94
+ ...makeStyleResponsive('jc', settings?.align),
95
+ ...galleryImageOrder,
96
+ ...styleInsideLayout
97
+ };
98
+ return filterTruthyStyles(composeStyles);
99
+ };
100
+ const getGalleryGridStyle = (setting, wrapperStyle)=>{
101
+ const shapeByLayout = getShapeByLayout({
102
+ shape: setting.shape,
103
+ shapeForBottom: setting.shapeForBottom,
104
+ shapeFor1Col: setting.shapeFor1Col,
105
+ shapeFor2Col: setting.shapeFor2Col,
106
+ shapeForFtOnly: setting.shapeForFtOnly,
107
+ shapeForInsideBottom: setting.shapeForInsideBottom,
108
+ shapeForInside: setting.shapeForInside
109
+ }, setting.position);
110
+ const getGridDisplay = ()=>{
111
+ const isDisplayGrid = (type, position, device)=>{
112
+ const layout = getResponsiveValueByScreen(position, device);
113
+ const typeDevice = getResponsiveValueByScreen(type, device);
114
+ const isDisplayTypeGrid = typeDevice !== 'slider' && (layout === 'bottom-center' || layout === 'inside-bottom');
115
+ const isDisplayByLayout = [
116
+ 'one-col',
117
+ 'two-col'
118
+ ].includes(layout || '');
119
+ return isDisplayTypeGrid || isDisplayByLayout;
120
+ };
121
+ const isDisplayByWidth = checkDisplayGalleryByWidth({
122
+ shapeByLayout
123
+ });
124
+ const isDisplay = {
125
+ desktop: isDisplayByWidth.desktop && isDisplayGrid(setting.type, setting.position, 'desktop'),
126
+ tablet: isDisplayByWidth.tablet && isDisplayGrid(setting.type, setting.position, 'tablet'),
127
+ mobile: isDisplayByWidth.mobile && isDisplayGrid(setting.type, setting.position, 'mobile')
128
+ };
129
+ return getDisplayStyle((device)=>!isDisplay[device], 'flex');
130
+ };
131
+ const composeStyles = {
132
+ ...getGridDisplay(),
133
+ ...makeStyleResponsive('cg', setting?.itemSpacing),
134
+ ...makeStyleResponsive('rg', setting?.itemSpacing),
135
+ ...makeStyleResponsive('jc', setting?.align),
136
+ ...wrapperStyle
137
+ };
138
+ return filterTruthyStyles(composeStyles);
139
+ };
140
+ const getGalleryGridItemStyle = (setting)=>{
141
+ const shapeByLayout = getShapeByLayout({
142
+ shape: setting.shape,
143
+ shapeForBottom: setting.shapeForBottom,
144
+ shapeFor1Col: setting.shapeFor1Col,
145
+ shapeFor2Col: setting.shapeFor2Col,
146
+ shapeForFtOnly: setting.shapeForFtOnly,
147
+ shapeForInsideBottom: setting.shapeForInsideBottom,
148
+ shapeForInside: setting.shapeForInside
149
+ }, setting.position);
150
+ const getHeightByLayoutForItem = getHeightByShapeGlobalSize(shapeByLayout);
151
+ const getWidthByLayoutForItem = getSettingWidthForGridItem({
152
+ shapeByLayout,
153
+ itemSpacing: setting.itemSpacing
154
+ });
155
+ const composeStyles = {
156
+ 'max-width': '100%',
157
+ 'outline-color': 'var(--g-c-brand, brand)',
158
+ ...makeStyleResponsive('h', makeHeight(getHeightByLayoutForItem)),
159
+ ...makeStyleResponsive('w', makeWidth(getWidthByLayoutForItem)),
160
+ ...composeRadius({
161
+ normal: setting.corner
162
+ })
163
+ };
164
+ return filterTruthyStyles(composeStyles);
165
+ };
166
+ const getFeatureImageCarouselItemStyle = (setting)=>{
167
+ const imageHeightResponsive = getHeightByShapeGlobalSize(setting.ftShape);
168
+ const composeStyles = {
169
+ 'max-width': '100%',
170
+ 'outline-color': 'var(--g-c-brand, brand)',
171
+ ...composeRadius({
172
+ normal: setting?.ftCorner
173
+ }),
174
+ ...makeStyleResponsive('h', makeHeight(imageHeightResponsive)),
175
+ 'min-width': '100%'
176
+ };
177
+ return filterTruthyStyles(composeStyles);
178
+ };
179
+ const getGalleryCarouselStyle = (setting)=>{
180
+ const shapeByLayout = getShapeByLayout({
181
+ shape: setting.shape,
182
+ shapeForBottom: setting.shapeForBottom,
183
+ shapeFor1Col: setting.shapeFor1Col,
184
+ shapeFor2Col: setting.shapeFor2Col,
185
+ shapeForFtOnly: setting.shapeForFtOnly,
186
+ shapeForInsideBottom: setting.shapeForInsideBottom,
187
+ shapeForInside: setting.shapeForInside
188
+ }, setting.position);
189
+ const getWidthByLayoutForCarouselByDevice = (device)=>{
190
+ const layout = getResponsiveValueByScreen(setting?.position, device);
191
+ const isLayoutBottom = layout === 'bottom-center' || layout === 'inside-bottom';
192
+ const isInsideLayout = layout === 'inside-left' || layout === 'inside-right';
193
+ const shapeSetting = getResponsiveValueByScreen(shapeByLayout, device);
194
+ return isLayoutBottom || isInsideLayout || !shapeSetting?.width ? '100%' : shapeSetting.width;
195
+ };
196
+ const composeStyles = {
197
+ spacing: convertSpacing(setting?.itemSpacing),
198
+ sizeSetting: {
199
+ desktop: {
200
+ width: getWidthByLayoutForCarouselByDevice('desktop'),
201
+ height: '100%'
202
+ },
203
+ tablet: {
204
+ width: getWidthByLayoutForCarouselByDevice('tablet'),
205
+ height: '100%'
206
+ },
207
+ mobile: {
208
+ width: getWidthByLayoutForCarouselByDevice('mobile'),
209
+ height: '100%'
210
+ }
211
+ }
212
+ };
213
+ return filterTruthyStyles(composeStyles);
214
+ };
215
+ const getGalleryCarouselItemStyle = (setting)=>{
216
+ const shapeByLayout = getShapeByLayout({
217
+ shape: setting.shape,
218
+ shapeForBottom: setting.shapeForBottom,
219
+ shapeFor1Col: setting.shapeFor1Col,
220
+ shapeFor2Col: setting.shapeFor2Col,
221
+ shapeForFtOnly: setting.shapeForFtOnly,
222
+ shapeForInsideBottom: setting.shapeForInsideBottom,
223
+ shapeForInside: setting.shapeForInside
224
+ }, setting.position);
225
+ const styleMinWidthForItem = makeStyleResponsive('minw', makeWidth(getSettingMinWidthForCarouselItem({
226
+ shapeByLayout,
227
+ position: setting.position,
228
+ spacing: setting.itemSpacing
229
+ })));
230
+ const styleWidthForItem = makeStyleResponsive('w', makeWidth(getSettingWidthForCarouselItem({
231
+ shapeByLayout,
232
+ position: setting.position
233
+ })));
234
+ const styleHeightForItem = makeStyleResponsive('h', makeHeight(getHeightByShapeGlobalSize(shapeByLayout)));
235
+ const composeStyles = {
236
+ 'max-width': '100%',
237
+ 'outline-color': 'var(--g-c-brand, brand)',
238
+ ...styleMinWidthForItem,
239
+ ...styleWidthForItem,
240
+ ...styleHeightForItem,
241
+ ...composeRadius({
242
+ normal: setting.corner
243
+ })
244
+ };
245
+ return filterTruthyStyles(composeStyles);
246
+ };
247
+ const getFeaturedImageCarouselStyle = (setting)=>{
248
+ const imageWidthResponsiveByDevice = (device)=>{
249
+ const shapeSetting = getResponsiveValueByScreen(setting.ftShape, device);
250
+ return shapeSetting?.width ?? '100%';
251
+ };
252
+ const composeStyles = {
253
+ playSpeed: setting?.ftAnimationSpeed,
254
+ sizeSetting: {
255
+ desktop: {
256
+ width: imageWidthResponsiveByDevice('desktop'),
257
+ height: 'auto'
258
+ },
259
+ tablet: {
260
+ width: imageWidthResponsiveByDevice('tablet'),
261
+ height: 'auto'
262
+ },
263
+ mobile: {
264
+ width: imageWidthResponsiveByDevice('mobile'),
265
+ height: 'auto'
266
+ }
267
+ },
268
+ align: {
269
+ desktop: getResponsiveValueByScreen(setting?.align, 'desktop'),
270
+ tablet: getResponsiveValueByScreen(setting?.align, 'tablet'),
271
+ mobile: getResponsiveValueByScreen(setting?.align, 'mobile')
272
+ }
273
+ };
274
+ return filterTruthyStyles(composeStyles);
275
+ };
276
+ const getFeaturedImageOnlyOneImageStyle = ({ setting, options })=>{
277
+ const imageHeightResponsive = getHeightByShapeGlobalSize(setting?.ftShape);
278
+ const composeStyles = {
279
+ ...makeStyleWithDefault('w', getWidthByShapeGlobalSize(setting?.ftShape, false, true), {
280
+ desktop: '--g-ct-w',
281
+ tablet: '--g-ct-w',
282
+ mobile: '--g-ct-w'
283
+ }),
284
+ ...options?.enableRadius && composeRadius({
285
+ normal: setting?.ftCorner
286
+ }),
287
+ ...options?.enableHeight && makeStyleResponsive('h', makeHeight(imageHeightResponsive))
288
+ };
289
+ return filterTruthyStyles(composeStyles);
290
+ };
291
+
292
+ export { getFeatureImageCarouselItemStyle, getFeatureImageStyle, getFeaturedImageCarouselStyle, getFeaturedImageOnlyOneImageStyle, getGalleryCarouselItemStyle, getGalleryCarouselStyle, getGalleryGridItemStyle, getGalleryGridStyle, getGalleryImageStyle, getWrapContainerStyle };
@@ -0,0 +1,92 @@
1
+ import { convertUnitToNumber } from './common.js';
2
+
3
+ const handleMouseMove = (event, setting)=>{
4
+ const isEnableRoomEffect = setting?.hoverEffect === 'zoom' && setting?.zoomType === 'default';
5
+ const isEnableGlassEffect = setting?.hoverEffect === 'zoom' && setting?.zoomType === 'glasses';
6
+ const isEnableShowOtherImage = setting?.hoverEffect === 'other';
7
+ const isEnableHoverEffect = setting?.hoverEffect !== 'none';
8
+ if (!isEnableHoverEffect) return;
9
+ const featureImageDom = event.currentTarget.querySelector('img');
10
+ const featureImageHoverDom = event.currentTarget.querySelector('img.hover-image');
11
+ const zoomLens = event.currentTarget.querySelector('.room-len');
12
+ const imagePosition = featureImageDom?.getBoundingClientRect();
13
+ const slideWidth = featureImageDom?.clientWidth || 0;
14
+ const slideHeight = featureImageDom?.clientHeight || 0;
15
+ const zoom = convertUnitToNumber(setting?.zoom, 0);
16
+ const zoomValue = !zoom || zoom < 100 ? 1 : zoom / 100 || 1;
17
+ const zoomSize = (slideWidth || 1) * (setting?.hoverEffect === 'other' ? 1 : zoomValue);
18
+ const zoomSizeHeight = (slideHeight || 1) * (setting?.hoverEffect === 'other' ? 1 : zoomValue);
19
+ const imageOffsetX = event.clientX - imagePosition?.x;
20
+ const imageOffsetY = event.clientY - imagePosition?.y;
21
+ isEnableShowOtherImage && displayOtherImage({
22
+ featureImageHoverDom
23
+ });
24
+ isEnableRoomEffect && event.clientX >= imagePosition?.x && event.clientX <= imagePosition.right && event.clientY >= imagePosition?.y && event.clientY <= imagePosition.bottom && displayZoomImage({
25
+ featureImageDom,
26
+ featureImageHoverDom,
27
+ zoomSize,
28
+ zoomSizeHeight,
29
+ slideWidth,
30
+ imageOffsetX,
31
+ imageOffsetY,
32
+ isEnableShowOtherImage
33
+ });
34
+ isEnableGlassEffect && displayZoomLen({
35
+ zoomLens,
36
+ zoomSize,
37
+ zoomValue,
38
+ imagePosition,
39
+ slideWidth,
40
+ slideHeight,
41
+ imageOffsetX,
42
+ imageOffsetY
43
+ });
44
+ };
45
+ const displayOtherImage = ({ featureImageHoverDom })=>{
46
+ if (!featureImageHoverDom) return;
47
+ featureImageHoverDom.style.opacity = '1';
48
+ featureImageHoverDom.style.top = '0px';
49
+ featureImageHoverDom.style.left = '0px';
50
+ featureImageHoverDom.style.width = '100%';
51
+ };
52
+ const displayZoomLen = ({ zoomLens, zoomSize, zoomValue, slideWidth, slideHeight, imageOffsetX, imageOffsetY })=>{
53
+ if (!zoomLens) return;
54
+ zoomLens.style.opacity = '1';
55
+ const w = zoomLens.offsetWidth / 2;
56
+ const h = zoomLens.offsetHeight / 2;
57
+ const imageHeight = slideHeight || 1;
58
+ if (imageOffsetX > slideWidth - w / zoomValue) {
59
+ imageOffsetX = slideWidth - w / zoomValue;
60
+ }
61
+ if (imageOffsetX < w / zoomValue) {
62
+ imageOffsetX = w / zoomValue;
63
+ }
64
+ if (imageOffsetY > imageHeight - h / zoomValue) {
65
+ imageOffsetY = imageHeight - h / zoomValue;
66
+ }
67
+ if (imageOffsetY < h / zoomValue) {
68
+ imageOffsetY = h / zoomValue;
69
+ }
70
+ zoomLens.style.top = imageOffsetY - h + 'px';
71
+ zoomLens.style.left = imageOffsetX - w + 'px';
72
+ zoomLens.style.backgroundSize = zoomSize + 'px ' + imageHeight * zoomValue + 'px';
73
+ zoomLens.style.backgroundPosition = `-${imageOffsetX * zoomValue - w}px -${imageOffsetY * zoomValue - h}px`;
74
+ };
75
+ const displayZoomImage = ({ featureImageDom, featureImageHoverDom, zoomSize, zoomSizeHeight, slideWidth, imageOffsetX, imageOffsetY, isEnableShowOtherImage = false })=>{
76
+ if (!featureImageHoverDom) return;
77
+ featureImageHoverDom.style.width = `${zoomSize}px`;
78
+ if (!isEnableShowOtherImage) featureImageHoverDom.style.height = `${zoomSizeHeight}px`;
79
+ featureImageHoverDom.style.opacity = '1';
80
+ const x = imageOffsetX / featureImageDom?.offsetWidth;
81
+ const y = imageOffsetY / featureImageDom?.offsetHeight;
82
+ featureImageHoverDom.style.top = (featureImageDom?.offsetHeight - featureImageHoverDom.offsetHeight) * y + 'px';
83
+ featureImageHoverDom.style.left = (slideWidth - zoomSize) * x + 'px';
84
+ };
85
+ const handleMouseOut = (event)=>{
86
+ const featureImageHoverDom = event.currentTarget.querySelector('img.hover-image');
87
+ const zoomLens = event.currentTarget.querySelector('.room-len');
88
+ featureImageHoverDom && (featureImageHoverDom.style.opacity = '0');
89
+ zoomLens && (zoomLens.style.opacity = '0');
90
+ };
91
+
92
+ export { handleMouseMove, handleMouseOut };
@@ -0,0 +1,53 @@
1
+ import { getResponsiveValueByScreen } from '@gem-sdk/core';
2
+
3
+ const devices = [
4
+ 'desktop',
5
+ 'tablet',
6
+ 'mobile'
7
+ ];
8
+ const isFeatureMedia = (contentType)=>{
9
+ if (!contentType) return false;
10
+ return [
11
+ 'EXTERNAL_VIDEO',
12
+ 'MODEL_3D',
13
+ 'VIDEO'
14
+ ].includes(contentType);
15
+ };
16
+ const getZoomLenClass = ()=>{
17
+ return `!gp-flex gp-absolute gp-opacity-0 gp-h-[150px] gp-w-[150px] gp-cursor-none gp-rounded-full gp-bg-no-repeat gp-shadow-glasses gp-bg-white gp-pointer-events-none`;
18
+ };
19
+ const getZoomImageClass = ()=>{
20
+ return `gp-absolute gp-left-0 gp-top-0 gp-opacity-0 gp-transition-opacity gp-bg-white gp-pointer-events-none`;
21
+ };
22
+ const getDotStyleForOnlyFeaturedImage = (setting)=>{
23
+ let result = {};
24
+ devices.forEach((device)=>{
25
+ const position = getResponsiveValueByScreen(setting.position, device);
26
+ const dotStyle = getResponsiveValueByScreen(setting.dotStyle, device);
27
+ result = {
28
+ ...result,
29
+ [device]: position === 'only-feature' ? dotStyle : 'none'
30
+ };
31
+ });
32
+ return result;
33
+ };
34
+ const checkRenderFeaturedCarousel = (setting)=>{
35
+ const devices = [
36
+ 'desktop',
37
+ 'mobile',
38
+ 'tablet'
39
+ ];
40
+ let isShow = false;
41
+ devices.forEach((device)=>{
42
+ const show = checkShowCarousel(setting, device);
43
+ if (checkShowCarousel(setting, device)) {
44
+ isShow = show;
45
+ }
46
+ });
47
+ return isShow;
48
+ };
49
+ const checkShowCarousel = (setting, device)=>{
50
+ return getResponsiveValueByScreen(setting.position, device) !== 'only-feature' || getResponsiveValueByScreen(setting.ftNavigationPosition, device) !== 'none' || getResponsiveValueByScreen(setting.ftDotStyle, device) !== 'none' || getResponsiveValueByScreen(setting.ftLoop, device) === true || setting.ftDragToScroll === true;
51
+ };
52
+
53
+ export { checkRenderFeaturedCarousel, getDotStyleForOnlyFeaturedImage, getZoomImageClass, getZoomLenClass, isFeatureMedia };