@gem-sdk/components 2.0.0-dev.255 → 2.0.0-dev.258

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 (102) hide show
  1. package/dist/cjs/banner/components/HeroBannerItem.js +2 -2
  2. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +1 -1
  3. package/dist/cjs/builder.js +3 -3
  4. package/dist/cjs/cart/components/CartList.js +2 -2
  5. package/dist/cjs/collection/components/CollectionBanner.js +2 -1
  6. package/dist/cjs/collection/components/CollectionBanner.liquid.js +2 -1
  7. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +1 -1
  8. package/dist/cjs/grid/col/Col.js +29 -0
  9. package/dist/cjs/grid/col/Col.liquid.js +25 -0
  10. package/dist/cjs/grid/col/common/getAttr.js +15 -0
  11. package/dist/cjs/grid/col/common/getClass.js +25 -0
  12. package/dist/cjs/grid/{components/Col.liquid.js → col/common/getStyles.js} +22 -16
  13. package/dist/cjs/grid/next.js +3 -3
  14. package/dist/cjs/grid/{components → row}/Row.js +44 -55
  15. package/dist/cjs/grid/row/Row.liquid.js +122 -0
  16. package/dist/cjs/grid/row/commons/common.js +35 -0
  17. package/dist/cjs/grid/row/commons/getAttr.js +20 -0
  18. package/dist/cjs/grid/row/commons/getClass.js +44 -0
  19. package/dist/cjs/grid/row/commons/getData.js +17 -0
  20. package/dist/cjs/grid/row/commons/getStyle.js +102 -0
  21. package/dist/cjs/grid/{components → row/commons}/helpers.js +4 -4
  22. package/dist/cjs/grid/row/hooks/useRowSetting.js +78 -0
  23. package/dist/cjs/grid/{setting/row → row/setting}/configs/uiV2.js +1 -1
  24. package/dist/cjs/grid/{components → section}/Section.js +1 -1
  25. package/dist/cjs/grid/{components → section}/Section.liquid.js +1 -1
  26. package/dist/cjs/grid/{setting → section/setting}/Section.js +4 -4
  27. package/dist/cjs/grid/setting/index.js +3 -3
  28. package/dist/cjs/index.js +3 -3
  29. package/dist/cjs/index.liquid.js +3 -3
  30. package/dist/cjs/post-purchase/callout-banner/components/CalloutBox.js +1 -1
  31. package/dist/cjs/post-purchase/product/components/ProductOffer.js +3 -2
  32. package/dist/cjs/post-purchase/product/settings/product-quantity/configs/uiV2.js +5 -2
  33. package/dist/cjs/product/components/Product.js +2 -1
  34. package/dist/cjs/product/components/Product.liquid.js +2 -1
  35. package/dist/cjs/product/components/ProductList.js +1 -1
  36. package/dist/cjs/product/components/ProductList.liquid.js +1 -1
  37. package/dist/cjs/product/components/ProductQuickView/ProductQuickView.js +2 -2
  38. package/dist/cjs/sticky/components/Sticky.js +1 -1
  39. package/dist/esm/banner/components/HeroBannerItem.js +2 -2
  40. package/dist/esm/banner/components/HeroBannerItem.liquid.js +1 -1
  41. package/dist/esm/builder.js +3 -3
  42. package/dist/esm/cart/components/CartList.js +2 -2
  43. package/dist/esm/collection/components/CollectionBanner.js +2 -1
  44. package/dist/esm/collection/components/CollectionBanner.liquid.js +2 -1
  45. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +1 -1
  46. package/dist/esm/grid/col/Col.js +25 -0
  47. package/dist/esm/grid/col/Col.liquid.js +21 -0
  48. package/dist/esm/grid/col/common/getAttr.js +13 -0
  49. package/dist/esm/grid/col/common/getClass.js +23 -0
  50. package/dist/esm/grid/{components/Col.liquid.js → col/common/getStyles.js} +23 -15
  51. package/dist/esm/grid/next.js +3 -3
  52. package/dist/esm/grid/{components → row}/Row.js +41 -52
  53. package/dist/esm/grid/row/Row.liquid.js +118 -0
  54. package/dist/esm/grid/row/commons/common.js +31 -0
  55. package/dist/esm/grid/row/commons/getAttr.js +18 -0
  56. package/dist/esm/grid/row/commons/getClass.js +42 -0
  57. package/dist/esm/grid/row/commons/getData.js +15 -0
  58. package/dist/esm/grid/row/commons/getStyle.js +100 -0
  59. package/dist/esm/grid/{components → row/commons}/helpers.js +4 -4
  60. package/dist/esm/grid/row/hooks/useRowSetting.js +76 -0
  61. package/dist/esm/grid/{setting/row → row/setting}/configs/uiV2.js +1 -1
  62. package/dist/esm/grid/{components → section}/Section.js +1 -1
  63. package/dist/esm/grid/{components → section}/Section.liquid.js +1 -1
  64. package/dist/esm/grid/{setting → section/setting}/Section.js +4 -4
  65. package/dist/esm/grid/setting/index.js +3 -3
  66. package/dist/esm/index.js +3 -3
  67. package/dist/esm/index.liquid.js +3 -3
  68. package/dist/esm/post-purchase/callout-banner/components/CalloutBox.js +1 -1
  69. package/dist/esm/post-purchase/product/components/ProductOffer.js +3 -2
  70. package/dist/esm/post-purchase/product/settings/product-quantity/configs/uiV2.js +5 -2
  71. package/dist/esm/product/components/Product.js +2 -1
  72. package/dist/esm/product/components/Product.liquid.js +2 -1
  73. package/dist/esm/product/components/ProductList.js +1 -1
  74. package/dist/esm/product/components/ProductList.liquid.js +1 -1
  75. package/dist/esm/product/components/ProductQuickView/ProductQuickView.js +2 -2
  76. package/dist/esm/sticky/components/Sticky.js +1 -1
  77. package/dist/types/index.d.ts +23 -38
  78. package/package.json +2 -2
  79. package/dist/cjs/grid/components/Col.js +0 -44
  80. package/dist/cjs/grid/components/Row.liquid.js +0 -141
  81. package/dist/cjs/grid/hooks/useRowStyles.js +0 -153
  82. package/dist/esm/grid/components/Col.js +0 -40
  83. package/dist/esm/grid/components/Row.liquid.js +0 -137
  84. package/dist/esm/grid/hooks/useRowStyles.js +0 -151
  85. /package/dist/cjs/grid/{setting → col/setting}/Col.js +0 -0
  86. /package/dist/cjs/grid/{hooks → row/commons}/getInnerRadius.js +0 -0
  87. /package/dist/cjs/grid/{setting/row → row/setting}/Row.js +0 -0
  88. /package/dist/cjs/grid/{setting/row → row/setting}/configs/presets.js +0 -0
  89. /package/dist/cjs/grid/{setting/row → row/setting}/configs/settings.js +0 -0
  90. /package/dist/cjs/grid/{setting/row → row/setting}/configs/uiV1.js +0 -0
  91. /package/dist/cjs/grid/{setting/section → section/setting}/configs/settings.js +0 -0
  92. /package/dist/cjs/grid/{setting/section → section/setting}/configs/uiV1.js +0 -0
  93. /package/dist/cjs/grid/{setting/section → section/setting}/configs/uiV2.js +0 -0
  94. /package/dist/esm/grid/{setting → col/setting}/Col.js +0 -0
  95. /package/dist/esm/grid/{hooks → row/commons}/getInnerRadius.js +0 -0
  96. /package/dist/esm/grid/{setting/row → row/setting}/Row.js +0 -0
  97. /package/dist/esm/grid/{setting/row → row/setting}/configs/presets.js +0 -0
  98. /package/dist/esm/grid/{setting/row → row/setting}/configs/settings.js +0 -0
  99. /package/dist/esm/grid/{setting/row → row/setting}/configs/uiV1.js +0 -0
  100. /package/dist/esm/grid/{setting/section → section/setting}/configs/settings.js +0 -0
  101. /package/dist/esm/grid/{setting/section → section/setting}/configs/uiV1.js +0 -0
  102. /package/dist/esm/grid/{setting/section → section/setting}/configs/uiV2.js +0 -0
@@ -1,7 +1,10 @@
1
- import { getResponsiveValue, getResponsiveValueByScreen, isColumnDirectionExist, template, makeStyleResponsive, cls } from '@gem-sdk/core';
1
+ import { createStyle } from '@gem-sdk/system';
2
+ import { getResponsiveValue, getResponsiveValueByScreen, isColumnDirectionExist, makeStyleResponsive } from '@gem-sdk/core';
2
3
 
3
- const Column = ({ children, className, style, builderAttrs, builderProps, advanced, setting, styles, justifyContent, order, layout, parentTag, ...props })=>{
4
+ const getStyles = (props, isPostPurchase)=>{
5
+ const { styles, justifyContent, order, layout, parentTag, children } = props;
4
6
  const display = getResponsiveValue(layout, 'display');
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
8
  const displayByBreakpointIfChildrenEmpty = {};
6
9
  const DEVICES = [
7
10
  'desktop',
@@ -15,23 +18,28 @@ const Column = ({ children, className, style, builderAttrs, builderProps, advanc
15
18
  for (const device of DEVICES){
16
19
  displayByBreakpointIfChildrenEmpty[device] = getResponsiveValueByScreen(display, device) === 'fit' || !!layout && isColumnDirectionExist(layout, device) || REMOVE_SPACING_COMPONENT_TAG.includes(parentTag || '') ? 'none' : styles?.display?.[device];
17
20
  }
18
- return template`<div
19
- ${{
20
- ...props
21
- }}
22
- style="${{
21
+ const orderRender = ()=>{
22
+ const od = order ?? styles?.order;
23
+ if (isPostPurchase) {
24
+ return {
25
+ desktop: od?.desktop,
26
+ tablet: od?.desktop,
27
+ mobile: od?.desktop
28
+ };
29
+ }
30
+ return od;
31
+ };
32
+ const colStyle = createStyle({
23
33
  ...makeStyleResponsive('cg', styles?.gap),
24
34
  ...makeStyleResponsive('rg', styles?.gap),
25
35
  ...makeStyleResponsive('ai', styles?.alignItem),
26
36
  ...makeStyleResponsive('jc', justifyContent ?? styles?.justifyContent),
27
- ...makeStyleResponsive('o', order ?? styles?.order),
37
+ ...makeStyleResponsive('o', orderRender()),
28
38
  ...makeStyleResponsive('d', children ? styles?.display : displayByBreakpointIfChildrenEmpty)
29
- }}"
30
- class="${cls(className, builderProps?.uid, advanced?.cssClass, 'gp-relative gp-flex gp-flex-col', styles?.fullWidth ? 'gp-w-full' : '')}"
31
- data-same-height-display-contents="${!!setting?.allowSameHeight}"
32
- >
33
- ${children ?? ''}
34
- </div>`;
39
+ });
40
+ return {
41
+ colStyle
42
+ };
35
43
  };
36
44
 
37
- export { Column as default };
45
+ export { getStyles };
@@ -4,16 +4,16 @@ import 'react/jsx-runtime';
4
4
  import 'react';
5
5
  import '@gem-sdk/core';
6
6
 
7
- const Section = dynamic(()=>import('./components/Section.js'), {
7
+ const Section = dynamic(()=>import('./section/Section.js'), {
8
8
  loading: Loading
9
9
  });
10
- const Row = dynamic(()=>import('./components/Row.js'), {
10
+ const Row = dynamic(()=>import('./row/Row.js'), {
11
11
  loading: Loading
12
12
  });
13
13
  const Root = dynamic(()=>import('./components/Root.js'), {
14
14
  loading: Loading
15
15
  });
16
- const Col = dynamic(()=>import('./components/Col.js'), {
16
+ const Col = dynamic(()=>import('./col/Col.js'), {
17
17
  loading: Loading
18
18
  });
19
19
  var grid = {
@@ -1,21 +1,31 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useMemo, Children, isValidElement, createElement } from 'react';
3
- import { useEditorMode, cls, isEmptyChildren, makeStyleResponsive } from '@gem-sdk/core';
4
3
  import Head from 'next/head';
5
- import ChildrenDroppable from './ChildrenDroppable.js';
6
- import { useRowStyles } from '../hooks/useRowStyles.js';
4
+ import ChildrenDroppable from '../components/ChildrenDroppable.js';
7
5
  import HTML5Embed from '../../video/components/HTML5Embed.js';
8
6
  import { getYoutubeVideoId, youtubeVideoRegex } from '../../video/helpers/common.js';
9
7
  import LiteYouTubeEmbed from '../../video/components/LiteYouTubeEmbed.js';
8
+ import { createClass } from '@gem-sdk/system';
9
+ import { getAttr } from './commons/getAttr.js';
10
+ import { getRowStyle } from './commons/getStyle.js';
11
+ import { getClass } from './commons/getClass.js';
12
+ import { checkHasBackgroundVideo } from './commons/common.js';
13
+ import { useRowSettings } from './hooks/useRowSetting.js';
10
14
 
11
15
  const Row = (props)=>{
12
- const { inView, cacheHeightOutViewport, sizeStyles, wrapStyle, radiusStyleInner, otherProps, bgVideoAspectRatioStyle, bgVideo, ref, getStyles, getVerticalAlign } = useRowStyles(props);
13
- const mode = useEditorMode();
14
- const { styles, setting, className, builderAttrs, builderProps, children } = props;
15
- const { isSection, lazy, as: Element = 'div' } = setting ?? {};
16
+ const { styles, setting, children } = props;
17
+ const { isSection, as: Element = 'div' } = setting ?? {};
16
18
  const { background } = styles ?? {};
19
+ const { builderAttrs, cacheHeightOutViewport, bgVideo, isRowEmpty, rowClassEditorOnly, isRenderPlaceholderViewBox, isPostPurchase, ref, postPurchaseVerticalAlign } = useRowSettings(props);
20
+ const { rowStyle, backgroundBoxStyle, embedVideoStyle, sectionStyle } = getRowStyle(props);
21
+ const { rowAttr, sectionAttr } = getAttr(props);
22
+ const { rowClass, backgroundBoxClass, backgroundBoxInnerClass, sectionClass, wrapperYoutubeClasses, iframeYoutubeClasses } = getClass(props);
23
+ const className = createClass({
24
+ [rowClass]: true,
25
+ [rowClassEditorOnly]: true
26
+ });
17
27
  const embed = useMemo(()=>{
18
- if (!bgVideo) return null;
28
+ if (!checkHasBackgroundVideo(background)) return;
19
29
  if (bgVideo?.videoType === 'html5' && !bgVideo.videoHtml5) return null;
20
30
  if (bgVideo?.videoType === 'youtube' && !bgVideo.video) return null;
21
31
  if (bgVideo?.videoType === 'html5' && bgVideo.videoHtml5) {
@@ -26,13 +36,8 @@ const Row = (props)=>{
26
36
  autoplay: true,
27
37
  src: bgVideo.videoHtml5,
28
38
  title: "Video",
29
- style: {
30
- ...bgVideoAspectRatioStyle,
31
- pointerEvents: 'none',
32
- transform: 'translateY(-50%)',
33
- top: '50%'
34
- },
35
- className: "gp-relative"
39
+ className: "gp-relative",
40
+ style: embedVideoStyle
36
41
  });
37
42
  }
38
43
  const youtubeUrl = bgVideo?.video ?? '';
@@ -50,54 +55,43 @@ const Row = (props)=>{
50
55
  noCookie: true,
51
56
  muted: true,
52
57
  lazy: false,
53
- style: {
54
- ...bgVideoAspectRatioStyle,
55
- pointerEvents: 'none',
56
- transform: 'translateY(-50%)',
57
- top: '50%'
58
- },
59
- wrapperClass: "gp-pb-[56.25%] gp-h-full gp-w-full !gp-max-w-none",
60
- iframeClass: "!gp-w-[500%] !gp-ml-[-200%] !gp-h-full !gp-max-w-none gp-scale-[104%]"
58
+ style: embedVideoStyle,
59
+ wrapperClass: wrapperYoutubeClasses,
60
+ iframeClass: iframeYoutubeClasses
61
61
  });
62
62
  }, [
63
63
  bgVideo,
64
- bgVideoAspectRatioStyle
64
+ embedVideoStyle
65
65
  ]);
66
66
  const element = /*#__PURE__*/ jsxs("div", {
67
- ...builderAttrs,
68
- ...otherProps,
69
- id: builderProps?.uid,
70
- "data-id": builderProps?.uidInteraction ?? builderProps?.uid,
71
67
  ref: ref,
72
- style: getStyles(),
73
- className: cls(className, builderProps?.uid, 'gp-mb-0 gp-relative gp-mx-auto gp-grid gp-max-w-full gp-transition-colors gp-duration-200 gp-ease-in-out ', {
74
- 'gp-content-visibility-hidden': mode !== 'edit' && lazy && !inView
75
- }),
68
+ ...builderAttrs,
69
+ ...rowAttr,
70
+ style: rowStyle,
71
+ className: className,
76
72
  children: [
77
73
  !!embed && /*#__PURE__*/ jsx("div", {
78
- className: "gp-absolute gp-overflow-hidden gp-w-full gp-h-full left-0 top-0",
79
- style: {
80
- ...radiusStyleInner
81
- },
74
+ className: backgroundBoxClass,
75
+ style: backgroundBoxStyle,
82
76
  children: /*#__PURE__*/ jsx("div", {
83
- className: cls('gp-background-video gp-relative gp-h-full'),
77
+ className: backgroundBoxInnerClass,
84
78
  children: embed
85
79
  })
86
80
  }),
87
- inView || mode !== 'edit' ? /*#__PURE__*/ jsx(Fragment, {
88
- children: isEmptyChildren(children) ? /*#__PURE__*/ jsx(ChildrenDroppable, {}) : Children.map(children, (el)=>{
81
+ isRenderPlaceholderViewBox ? /*#__PURE__*/ jsx("div", {
82
+ style: {
83
+ height: `${cacheHeightOutViewport}px`
84
+ }
85
+ }) : /*#__PURE__*/ jsx(Fragment, {
86
+ children: isRowEmpty ? /*#__PURE__*/ jsx(ChildrenDroppable, {}) : Children.map(children, (el)=>{
89
87
  if (/*#__PURE__*/ isValidElement(el)) return /*#__PURE__*/ createElement(el.type, {
90
88
  ...el.props,
91
89
  key: el.key,
92
90
  order: setting?.order,
93
- justifyContent: getVerticalAlign()
91
+ justifyContent: isPostPurchase ? postPurchaseVerticalAlign : setting?.verticalAlign
94
92
  });
95
93
  return null;
96
94
  })
97
- }) : /*#__PURE__*/ jsx("div", {
98
- style: {
99
- height: `${cacheHeightOutViewport}px`
100
- }
101
95
  })
102
96
  ]
103
97
  });
@@ -123,14 +117,9 @@ const Row = (props)=>{
123
117
  ]
124
118
  }),
125
119
  isSection ? /*#__PURE__*/ jsx(Element, {
126
- className: "gp-mx-auto gp-max-w-full [&_*]:gp-max-w-full",
127
- "data-same-height-display-contents": !!setting?.allowSameHeight,
128
- style: {
129
- ...wrapStyle,
130
- ...makeStyleResponsive('w', sizeStyles.wrapper),
131
- ...makeStyleResponsive('pl', sizeStyles.padding),
132
- ...makeStyleResponsive('pr', sizeStyles.padding)
133
- },
120
+ ...sectionAttr,
121
+ className: sectionClass,
122
+ style: sectionStyle,
134
123
  children: element
135
124
  }) : element
136
125
  ]
@@ -0,0 +1,118 @@
1
+ import { template, WrapRenderChildren, RenderChildren, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { getSettingPreloadData } from '../../helpers.js';
3
+ import { getResponsiveSetting } from '../../banner/components/common/common.js';
4
+ import HTML5Embed from '../../video/components/HTML5Embed.liquid.js';
5
+ import { getRowStyle } from './commons/getStyle.js';
6
+ import { getClass } from './commons/getClass.js';
7
+ import { getAttr } from './commons/getAttr.js';
8
+ import { createClass, If } from '@gem-sdk/system';
9
+ import { getData } from './commons/getData.js';
10
+ import { checkHasBackgroundVideo, isRenderHtmlVideo, isRenderYoutubeVideo } from './commons/common.js';
11
+ import { getYoutubeVideoId } from '../../video/helpers/common.js';
12
+ import LiteYouTubeEmbed from '../../video/components/LiteYouTubeEmbed.liquid.js';
13
+
14
+ const Row = (props)=>{
15
+ const { styles, setting, rawChildren, builderProps } = props;
16
+ const { isSection } = setting ?? {};
17
+ const { background } = styles ?? {};
18
+ const elementTag = isSection ? 'section' : 'div';
19
+ const { stateData } = getData(props);
20
+ const { rowStyle, backgroundBoxStyle, embedVideoStyle, sectionStyle } = getRowStyle(props);
21
+ const { rowAttr, sectionAttr } = getAttr(props);
22
+ const { rowClass, backgroundBoxClass, backgroundBoxInnerClass, sectionClass, wrapperYoutubeClasses, iframeYoutubeClasses } = getClass(props);
23
+ const className = createClass({
24
+ [rowClass]: true
25
+ });
26
+ const embed = ()=>{
27
+ if (!checkHasBackgroundVideo(background)) return;
28
+ const backgroundResponsive = getResponsiveSetting(background || {});
29
+ if (isRenderHtmlVideo(background)) {
30
+ return HTML5Embed({
31
+ uid: builderProps?.uid,
32
+ muted: true,
33
+ loop: backgroundResponsive.desktop?.loop,
34
+ controls: false,
35
+ autoplay: true,
36
+ src: '',
37
+ title: 'Video',
38
+ className: 'gp-relative',
39
+ style: embedVideoStyle
40
+ });
41
+ }
42
+ if (isRenderYoutubeVideo(background)) {
43
+ const youtubeUrl = backgroundResponsive?.desktop?.video ?? '';
44
+ const videoId = getYoutubeVideoId(youtubeUrl) || '';
45
+ const isLoop = false;
46
+ const params = `&loop=${isLoop}&playlist=${videoId}&showinfo=0&rel=0&fs=0&enablejsapi=1`;
47
+ return LiteYouTubeEmbed({
48
+ uid: builderProps?.uid,
49
+ id: videoId,
50
+ isHeroBanner: true,
51
+ autoplay: true,
52
+ title: 'Video',
53
+ controls: false,
54
+ params: params,
55
+ adNetwork: false,
56
+ noCookie: true,
57
+ muted: true,
58
+ lazy: backgroundResponsive?.desktop?.lazyLoad ?? true,
59
+ preload: true,
60
+ style: embedVideoStyle,
61
+ wrapperClass: wrapperYoutubeClasses,
62
+ iframeClass: iframeYoutubeClasses
63
+ });
64
+ }
65
+ };
66
+ const renderComponentScript = ()=>{
67
+ if (!checkHasBackgroundVideo(background)) return;
68
+ return template`
69
+ ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-row.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-row.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
70
+ `;
71
+ };
72
+ const element = template`
73
+ <gp-row gp-data='${stateData}' ${{
74
+ ...rowAttr
75
+ }} class="${className}" style="${rowStyle}">
76
+ ${If(!!embed(), template /* liquid */ `
77
+ <div class="${backgroundBoxClass}" style="${backgroundBoxStyle}">
78
+ <div class="${backgroundBoxInnerClass}">${embed()}</div>
79
+ </div>
80
+ `)}
81
+
82
+ ${WrapRenderChildren({
83
+ uid: builderProps?.uid || '',
84
+ customProps: rawChildren?.[0].customProps
85
+ }, rawChildren?.map((child)=>{
86
+ if (child) {
87
+ return RenderChildren({
88
+ ...child,
89
+ order: setting?.order,
90
+ layout: setting?.layout,
91
+ justifyContent: setting?.verticalAlign
92
+ });
93
+ }
94
+ }))}
95
+
96
+ ${renderComponentScript()}
97
+ </gp-row>
98
+ `;
99
+ return template`
100
+ ${RenderIf(!!styles?.preloadBgImage, `${RenderIf(!!background?.desktop?.image?.src, `<link rel="preload" href="${background?.desktop?.image?.src}" as="image" />`)}${RenderIf(!!background?.tablet?.image?.src, `<link rel="preload" href="${background?.tablet?.image?.src}" as="image" />`)}${RenderIf(!!background?.mobile?.image?.src, `<link rel="preload" href="${background?.mobile?.image?.src}" as="image" />`)}`)}
101
+
102
+ ${RenderIf(!!isSection, `{% assign locationOrigin = request.origin | append: routes.root_url | split: '/' | join: '/' %}`)}
103
+
104
+ ${If(isSection, template /* liquid */ `
105
+ <${elementTag}
106
+ ${{
107
+ ...sectionAttr
108
+ }}
109
+ class="${sectionClass} ${isSection ? getSettingPreloadData('gps-lazy') : ''}"
110
+ style="${sectionStyle}"
111
+ >
112
+ ${element}
113
+ </${elementTag}>
114
+ `, template /* liquid */ `${element}`)}
115
+ `;
116
+ };
117
+
118
+ export { Row as default };
@@ -0,0 +1,31 @@
1
+ import { getValueByDevice } from '@gem-sdk/core';
2
+ import { getResponsiveSetting } from '../../../carousel/components/common/arrow.js';
3
+
4
+ const checkHasBackgroundVideo = (background)=>{
5
+ const DEVICES = [
6
+ 'desktop',
7
+ 'tablet',
8
+ 'mobile'
9
+ ];
10
+ return DEVICES.some((item)=>{
11
+ const bg = getValueByDevice(background, item);
12
+ if (bg) return bg.videoType === 'html5' && bg.videoHtml5 || bg.videoType === 'youtube' && bg.video;
13
+ return false;
14
+ });
15
+ };
16
+ const isRenderHtmlVideo = (background)=>{
17
+ const backgroundResponsive = getResponsiveSetting(background || {});
18
+ const videoType = backgroundResponsive.desktop?.videoType;
19
+ const videoTypeTablet = backgroundResponsive.tablet?.videoType;
20
+ const videoTypeMobile = backgroundResponsive.mobile?.videoType;
21
+ return videoType == 'html5' || videoTypeTablet == 'html5' || videoTypeMobile == 'html5';
22
+ };
23
+ const isRenderYoutubeVideo = (background)=>{
24
+ const backgroundResponsive = getResponsiveSetting(background || {});
25
+ const videoType = backgroundResponsive.desktop?.videoType;
26
+ const videoTypeTablet = backgroundResponsive.tablet?.videoType;
27
+ const videoTypeMobile = backgroundResponsive.mobile?.videoType;
28
+ return videoType == 'youtube' || videoTypeTablet == 'youtube' || videoTypeMobile == 'youtube';
29
+ };
30
+
31
+ export { checkHasBackgroundVideo, isRenderHtmlVideo, isRenderYoutubeVideo };
@@ -0,0 +1,18 @@
1
+ import { createAttr } from '@gem-sdk/system';
2
+
3
+ const getAttr = (props)=>{
4
+ const { builderProps, setting } = props;
5
+ const rowAttr = createAttr({
6
+ 'data-id': builderProps?.uidInteraction ?? builderProps?.uid ?? '',
7
+ id: builderProps?.uid ?? ''
8
+ });
9
+ const sectionAttr = createAttr({
10
+ 'data-same-height-display-contents': !!setting?.allowSameHeight
11
+ });
12
+ return {
13
+ rowAttr,
14
+ sectionAttr
15
+ };
16
+ };
17
+
18
+ export { getAttr };
@@ -0,0 +1,42 @@
1
+ import { createClass } from '@gem-sdk/system';
2
+
3
+ const getClass = (props)=>{
4
+ const { builderProps, advanced, className } = props;
5
+ const backgroundBoxClass = createClass({
6
+ 'gp-background-video gp-absolute gp-overflow-hidden gp-w-full gp-h-full left-0 top-0': true
7
+ });
8
+ const backgroundBoxInnerClass = createClass({
9
+ 'gp-bg-video gp-relative gp-h-full': true
10
+ });
11
+ const rowClass = createClass({
12
+ ...className && {
13
+ [className]: true
14
+ },
15
+ ...builderProps?.uid && {
16
+ [builderProps.uid]: true
17
+ },
18
+ 'gp-relative gp-mx-auto gp-mb-0 gp-grid gp-max-w-full gp-transition-colors gp-duration-200 gp-ease-in-out [&_*]:gp-max-w-full': true,
19
+ ...advanced?.cssClass && {
20
+ [advanced?.cssClass]: true
21
+ }
22
+ });
23
+ const sectionClass = createClass({
24
+ 'gp-mx-auto gp-max-w-full [&_*]:gp-max-w-full': true
25
+ });
26
+ const wrapperYoutubeClasses = createClass({
27
+ 'gp-pb-[56.25%] gp-h-full gp-w-full !gp-max-w-none': true
28
+ });
29
+ const iframeYoutubeClasses = createClass({
30
+ '!gp-w-[500%] !gp-ml-[-200%] !gp-h-full !gp-max-w-none gp-scale-[104%]': true
31
+ });
32
+ return {
33
+ rowClass,
34
+ backgroundBoxClass,
35
+ backgroundBoxInnerClass,
36
+ sectionClass,
37
+ wrapperYoutubeClasses,
38
+ iframeYoutubeClasses
39
+ };
40
+ };
41
+
42
+ export { getClass };
@@ -0,0 +1,15 @@
1
+ import { createStateOrContext } from '@gem-sdk/system';
2
+ import { dataStringify } from '@gem-sdk/core';
3
+
4
+ const getData = (props)=>{
5
+ const { styles, builderProps } = props;
6
+ const stateData = createStateOrContext({
7
+ background: styles?.background,
8
+ uid: builderProps?.uid
9
+ });
10
+ return {
11
+ stateData: dataStringify(stateData).replaceAll("'", '&#039;')
12
+ };
13
+ };
14
+
15
+ export { getData };
@@ -0,0 +1,100 @@
1
+ 'use client';
2
+ import { makeStyleResponsive, isEmptyChildren, splitStyle, composeGridLayout, makeStyle, getStyleBackgroundByDevice, getGradientBgrStyleByDevice, composeRadius } from '@gem-sdk/core';
3
+ import { getInnerRadiusExcludeBorder } from './getInnerRadius.js';
4
+ import { createStyle } from '@gem-sdk/system';
5
+ import { createStyleObject } from './helpers.js';
6
+
7
+ const getRowStyle = (rowProps)=>{
8
+ const { children, setting, builderProps, styles, style, advanced, isNotFullWidth } = rowProps;
9
+ const { isSection, layout, horizontalAlign, responsive, inlineAlignment } = setting ?? {};
10
+ const { width, columnGap, fullWidth, background, verticalGutter, verticalGutterMobile } = styles ?? {};
11
+ const innerRadius = getInnerRadiusExcludeBorder(advanced?.border, advanced?.rounded);
12
+ const childHasChildren = builderProps?.builderData?.childrens?.length;
13
+ const bgVideoAspectRatioStyle = {
14
+ ...makeStyleResponsive('aspect', {
15
+ desktop: '16/9'
16
+ })
17
+ };
18
+ const isRowEmpty = isEmptyChildren(children) || !childHasChildren;
19
+ const sizeStyles = createStyleObject(width, fullWidth);
20
+ const [wrapStyle, restStyle] = splitStyle([
21
+ 'pos',
22
+ 'top',
23
+ 'left',
24
+ 'bottom',
25
+ 'right',
26
+ 'z'
27
+ ], style);
28
+ const getGlobalStyles = ()=>{
29
+ return {
30
+ ...isSection ? restStyle : style,
31
+ ...makeStyleResponsive('cg', verticalGutter),
32
+ ...makeStyleResponsive('rg', verticalGutterMobile),
33
+ ...layout ? composeGridLayout(layout) : makeStyleResponsive('gtc', responsive),
34
+ ...makeStyleResponsive('w', sizeStyles.content)
35
+ };
36
+ };
37
+ const getPostPurchaseStyle = ()=>{
38
+ return {
39
+ '--mb': '0px',
40
+ '--mt': '0px',
41
+ ...makeStyleResponsive('cg', columnGap),
42
+ ...makeStyle({
43
+ pc: inlineAlignment
44
+ })
45
+ };
46
+ };
47
+ const getRowNormalStyle = (options)=>{
48
+ return {
49
+ ...getStyleBackgroundByDevice(background, options),
50
+ ...getGradientBgrStyleByDevice(background, {
51
+ desktop: true,
52
+ tablet: true,
53
+ mobile: true
54
+ }),
55
+ ...makeStyleResponsive('pc', horizontalAlign)
56
+ };
57
+ };
58
+ const getMarginByWidth = ()=>{
59
+ const isCustomizeMargin = isNotFullWidth && !isRowEmpty;
60
+ if (!isCustomizeMargin) return {};
61
+ return {
62
+ marginLeft: '0px',
63
+ marginRight: '0px'
64
+ };
65
+ };
66
+ const getRadiusStyleInner = ()=>{
67
+ return {
68
+ ...composeRadius(innerRadius)
69
+ };
70
+ };
71
+ const rowStyle = createStyle({
72
+ ...getGlobalStyles(),
73
+ ...getRowNormalStyle(),
74
+ ...getMarginByWidth(),
75
+ ...getPostPurchaseStyle()
76
+ });
77
+ const backgroundBoxStyle = createStyle({
78
+ ...getRadiusStyleInner()
79
+ });
80
+ const embedVideoStyle = createStyle({
81
+ ...bgVideoAspectRatioStyle,
82
+ pointerEvents: 'none',
83
+ transform: 'translateY(-50%)',
84
+ top: '50%'
85
+ });
86
+ const sectionStyle = createStyle({
87
+ ...wrapStyle,
88
+ ...makeStyleResponsive('w', sizeStyles.wrapper),
89
+ ...makeStyleResponsive('pl', sizeStyles.padding),
90
+ ...makeStyleResponsive('pr', sizeStyles.padding)
91
+ });
92
+ return {
93
+ embedVideoStyle,
94
+ backgroundBoxStyle,
95
+ rowStyle,
96
+ sectionStyle
97
+ };
98
+ };
99
+
100
+ export { getRowStyle };
@@ -30,7 +30,7 @@ const getStyleByDevice = (device, fullWidth, width)=>{
30
30
  };
31
31
  } else {
32
32
  return {
33
- contentWidth: `var(--g-ct-w, ${defaultWidth[device]})`,
33
+ contentWidth: undefined,
34
34
  wrapperWidth: `calc(var(--g-ct-w, ${defaultWidth[device]}) + 2 * var(--g-ct-p, 15px))`,
35
35
  wrapperPadding: 'var(--g-ct-p, 15px)'
36
36
  };
@@ -42,9 +42,9 @@ const createStyleObject = (width, fullWidth)=>{
42
42
  const mobileStyle = getStyleByDevice('mobile', fullWidth, width);
43
43
  return {
44
44
  content: {
45
- desktop: desktopStyle.contentWidth || '100%',
46
- tablet: tabletStyle.contentWidth || '100%',
47
- mobile: mobileStyle.contentWidth || '100%'
45
+ desktop: desktopStyle.contentWidth,
46
+ tablet: tabletStyle.contentWidth,
47
+ mobile: mobileStyle.contentWidth
48
48
  },
49
49
  wrapper: {
50
50
  desktop: desktopStyle.wrapperWidth,
@@ -0,0 +1,76 @@
1
+ import { useState, useMemo } from 'react';
2
+ import { useCurrentDevice, useEditorMode, usePageType, getValueByDevice, isEmptyChildren, getResponsiveValue } from '@gem-sdk/core';
3
+ import { createClass } from '@gem-sdk/system';
4
+ import { useInView } from '../../../intersection-observer/useInView.js';
5
+
6
+ const useRowSettings = (rowProps)=>{
7
+ const { setting, styles, children, maxWidthWithEmptyChildren, builderAttrs } = rowProps;
8
+ const { isSection, lazy, layout, blockAlignment } = setting ?? {};
9
+ const { background } = styles ?? {};
10
+ const currentDevice = useCurrentDevice();
11
+ const [cacheHeightOutViewport, setCacheHeightOutViewport] = useState(500);
12
+ const mode = useEditorMode();
13
+ const pageType = usePageType();
14
+ const bgVideo = getValueByDevice(background, currentDevice);
15
+ const isRowEmpty = useMemo(()=>{
16
+ return isEmptyChildren(children);
17
+ }, [
18
+ children
19
+ ]);
20
+ const [ref, inView] = useInView({
21
+ initialInView: !lazy,
22
+ triggerOnce: true,
23
+ skip: !isSection,
24
+ onChange: (inView, node)=>{
25
+ if (mode == 'edit' && !inView && node) {
26
+ const computedStyle = getComputedStyle(node);
27
+ let height = node?.getBoundingClientRect().height;
28
+ height -= parseFloat(computedStyle.paddingTop) + parseFloat(computedStyle.paddingBottom);
29
+ setCacheHeightOutViewport(height ?? 500);
30
+ }
31
+ }
32
+ });
33
+ const isRenderPlaceholderViewBox = useMemo(()=>!inView && mode == 'edit', [
34
+ inView,
35
+ mode
36
+ ]);
37
+ const isVisibilityContent = useMemo(()=>mode !== 'edit' && lazy && !inView, [
38
+ inView,
39
+ lazy,
40
+ mode
41
+ ]);
42
+ const getWidthForEmptyChildren = ()=>{
43
+ const isCustomizeWidth = maxWidthWithEmptyChildren && isRowEmpty && mode === 'edit';
44
+ if (!isCustomizeWidth) return {};
45
+ const display = getResponsiveValue(layout, 'display');
46
+ const displayByDevice = display[currentDevice];
47
+ return {
48
+ width: displayByDevice === 'fit' ? 'fit-content' : '400px'
49
+ };
50
+ };
51
+ const rowClassEditorOnly = createClass({
52
+ ...getWidthForEmptyChildren,
53
+ 'gp-content-visibility-hidden': isVisibilityContent
54
+ });
55
+ const postPurchaseVerticalAlign = ()=>{
56
+ return {
57
+ desktop: blockAlignment,
58
+ tablet: blockAlignment,
59
+ mobile: blockAlignment
60
+ };
61
+ };
62
+ return {
63
+ ref,
64
+ isRowEmpty,
65
+ cacheHeightOutViewport,
66
+ bgVideo,
67
+ rowClassEditorOnly,
68
+ isRenderPlaceholderViewBox,
69
+ builderAttrs,
70
+ children,
71
+ isPostPurchase: pageType === 'POST_PURCHASE',
72
+ postPurchaseVerticalAlign
73
+ };
74
+ };
75
+
76
+ export { useRowSettings };
@@ -27,7 +27,7 @@ const SettingUIV2 = [
27
27
  },
28
28
  {
29
29
  label: {
30
- en: 'Column Spacing'
30
+ en: 'Column spacing'
31
31
  },
32
32
  conditionDisplay: `pageType !== "POST_PURCHASE" && childrens > 1`,
33
33
  controls: [
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import Row from './Row.js';
3
+ import Row from '../row/Row.js';
4
4
  import Loading from '../../common/components/Loading.js';
5
5
  import { useMemo } from 'react';
6
6