@gem-sdk/core 1.23.0-staging.26 → 1.23.0-staging.261

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 (66) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +77 -16
  2. package/dist/cjs/components/ComponentWrapper.js +2 -1
  3. package/dist/cjs/components/ComponentWrapperPreview.js +29 -2
  4. package/dist/cjs/components/Render.liquid.js +59 -6
  5. package/dist/cjs/components/constant.js +7 -2
  6. package/dist/cjs/components/resize/Spacing.js +92 -7
  7. package/dist/cjs/components/theme-section/CreateThemeSection.js +4 -5
  8. package/dist/cjs/components/theme-section/ThemeSectionStatus.js +1 -1
  9. package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +5 -4
  10. package/dist/cjs/contexts/BuilderPreviewContext.js +12 -9
  11. package/dist/cjs/contexts/PageContext.js +44 -0
  12. package/dist/cjs/helpers/animations.js +213 -0
  13. package/dist/cjs/helpers/background.js +108 -5
  14. package/dist/cjs/helpers/compose-advance-style.js +17 -7
  15. package/dist/cjs/helpers/icon-list.js +61 -0
  16. package/dist/cjs/helpers/is-empty-children.js +1 -1
  17. package/dist/cjs/helpers/make-style.js +9 -1
  18. package/dist/cjs/helpers/product.js +4 -1
  19. package/dist/cjs/helpers/queries/get-collection.js +7 -1
  20. package/dist/cjs/helpers/size.js +148 -0
  21. package/dist/cjs/helpers/typography.js +10 -9
  22. package/dist/cjs/helpers/variant.js +4 -1
  23. package/dist/cjs/hooks/animation/useAnimationActions.js +39 -0
  24. package/dist/cjs/hooks/animation/useAnimationConfig.js +29 -0
  25. package/dist/cjs/hooks/animation/useAnimationPreview.js +31 -0
  26. package/dist/cjs/hooks/animation/useAnimationTarget.js +120 -0
  27. package/dist/cjs/hooks/animation/useApplyAnimation.js +87 -0
  28. package/dist/cjs/hooks/useAnimations.js +26 -0
  29. package/dist/cjs/hooks/useProduct.js +13 -3
  30. package/dist/cjs/index.js +48 -0
  31. package/dist/cjs/types/animations.js +47 -0
  32. package/dist/cjs/web-components/src/helpers/styles/constant.js +9 -0
  33. package/dist/esm/components/ComponentToolbarPreview.js +77 -16
  34. package/dist/esm/components/ComponentWrapper.js +2 -1
  35. package/dist/esm/components/ComponentWrapperPreview.js +31 -4
  36. package/dist/esm/components/Render.liquid.js +59 -6
  37. package/dist/esm/components/constant.js +7 -3
  38. package/dist/esm/components/resize/Spacing.js +93 -8
  39. package/dist/esm/components/theme-section/CreateThemeSection.js +4 -5
  40. package/dist/esm/components/theme-section/ThemeSectionStatus.js +1 -1
  41. package/dist/esm/components/theme-section/ThemeSectionTooltip.js +5 -4
  42. package/dist/esm/contexts/BuilderPreviewContext.js +12 -9
  43. package/dist/esm/contexts/PageContext.js +41 -0
  44. package/dist/esm/helpers/animations.js +211 -0
  45. package/dist/esm/helpers/background.js +104 -6
  46. package/dist/esm/helpers/compose-advance-style.js +17 -7
  47. package/dist/esm/helpers/icon-list.js +58 -0
  48. package/dist/esm/helpers/is-empty-children.js +2 -2
  49. package/dist/esm/helpers/make-style.js +9 -2
  50. package/dist/esm/helpers/product.js +4 -1
  51. package/dist/esm/helpers/queries/get-collection.js +7 -1
  52. package/dist/esm/helpers/size.js +141 -1
  53. package/dist/esm/helpers/typography.js +10 -9
  54. package/dist/esm/helpers/variant.js +4 -1
  55. package/dist/esm/hooks/animation/useAnimationActions.js +37 -0
  56. package/dist/esm/hooks/animation/useAnimationConfig.js +27 -0
  57. package/dist/esm/hooks/animation/useAnimationPreview.js +29 -0
  58. package/dist/esm/hooks/animation/useAnimationTarget.js +118 -0
  59. package/dist/esm/hooks/animation/useApplyAnimation.js +83 -0
  60. package/dist/esm/hooks/useAnimations.js +24 -0
  61. package/dist/esm/hooks/useProduct.js +13 -3
  62. package/dist/esm/index.js +7 -3
  63. package/dist/esm/types/animations.js +47 -0
  64. package/dist/esm/web-components/src/helpers/styles/constant.js +7 -0
  65. package/dist/types/index.d.ts +324 -38
  66. package/package.json +2 -2
@@ -17,6 +17,14 @@ var Resize = require('./resize/Resize.js');
17
17
  require('../helpers/convert.js');
18
18
 
19
19
  const SECTION_LIMIT = 25;
20
+ const notVisible = (el)=>{
21
+ const overflow = getComputedStyle(el).overflow;
22
+ return overflow !== 'visible';
23
+ };
24
+ const isSection = (el)=>{
25
+ const tag = el.getAttribute('data-component-tag');
26
+ return tag === 'Section';
27
+ };
20
28
  const ComponentToolbarPreview = ({ ...props })=>{
21
29
  const isThemeSection = props.isThemeSection;
22
30
  const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
@@ -27,13 +35,32 @@ const ComponentToolbarPreview = ({ ...props })=>{
27
35
  const [isShowParent, setIsShowParent] = react.useState(false);
28
36
  const [isShowParentRevert, setIsShowParentRevert] = react.useState(false);
29
37
  const [parents, setParents] = react.useState([]);
38
+ const isOverToolbarPosition = (el, parent)=>{
39
+ const parentLenght = parents.length;
40
+ const rect = el.getBoundingClientRect();
41
+ const rectP = parent.getBoundingClientRect();
42
+ // 36px = toolbar active height + 4 spaces
43
+ return rect.top - rectP.top < parentLenght * 36;
44
+ };
45
+ const findOverflowParent = (element, initEl)=>{
46
+ const thisEl = element;
47
+ const origEl = initEl || thisEl;
48
+ if (!thisEl) return;
49
+ if (isSection(thisEl)) return;
50
+ if (notVisible(thisEl) && isOverToolbarPosition(initEl, thisEl)) return thisEl;
51
+ if (thisEl.parentElement) {
52
+ return findOverflowParent(thisEl.parentElement, origEl);
53
+ } else {
54
+ return;
55
+ }
56
+ };
30
57
  // Get parents
31
58
  const onActiveComponent = react.useCallback((e)=>{
32
59
  const detail = e.detail;
33
60
  if (detail?.componentUid == props.uid) {
34
61
  const currentParents = getParents(props.uid).filter((parent)=>{
35
62
  if (parent.uid === 'ROOT') return false;
36
- if (parent.tag === 'Section') return false;
63
+ if (parent.tag === 'Section' && isThemeSectionEditor) return false;
37
64
  if (parent.editorConfigs?.toolbar?.hide) return false;
38
65
  if (parent.editorConfigs?.component?.noSetting) return false;
39
66
  return true;
@@ -46,7 +73,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
46
73
  }, [
47
74
  setParents,
48
75
  getParents,
49
- props.uid
76
+ props.uid,
77
+ isThemeSectionEditor
50
78
  ]);
51
79
  react.useEffect(()=>{
52
80
  window.addEventListener('editor:active-component', onActiveComponent);
@@ -84,11 +112,16 @@ const ComponentToolbarPreview = ({ ...props })=>{
84
112
  setIsShowParentRevert(false);
85
113
  setIsShowParent(false);
86
114
  } else {
87
- const rect = $toolbar.getBoundingClientRect();
88
- if (rect.top < parents.length * 24) {
115
+ const $parentOverflow = findOverflowParent($toolbar, $toolbar);
116
+ if ($parentOverflow) {
89
117
  setIsShowParentRevert(true);
90
118
  } else {
91
- setIsShowParentRevert(false);
119
+ const rect = $toolbar.getBoundingClientRect();
120
+ if (rect.top < parents.length * 36) {
121
+ setIsShowParentRevert(true);
122
+ } else {
123
+ setIsShowParentRevert(false);
124
+ }
92
125
  }
93
126
  setIsShowParent(true);
94
127
  }
@@ -129,6 +162,17 @@ const ComponentToolbarPreview = ({ ...props })=>{
129
162
  window.dispatchEvent(event);
130
163
  return false;
131
164
  };
165
+ const toolbarName = ()=>{
166
+ const tag = props.tag;
167
+ if (tag === 'IconListV2') {
168
+ return 'Item list';
169
+ }
170
+ if (tag === 'IconList') {
171
+ return 'Advanced list';
172
+ }
173
+ const name = props.customLabel || props.label;
174
+ return name;
175
+ };
132
176
  const onZoomOut = (e)=>{
133
177
  e.preventDefault();
134
178
  e.stopPropagation();
@@ -168,6 +212,13 @@ const ComponentToolbarPreview = ({ ...props })=>{
168
212
  }
169
213
  return false;
170
214
  };
215
+ const getSectionName = ()=>{
216
+ const checkRenamedSection = props.name && props.name === `Section ${props.uid}`;
217
+ if (getSectionNumber() >= SECTION_LIMIT - 5) {
218
+ return `${checkRenamedSection ? 'Section' : props?.name} ${getIndexSection() + 1}/${SECTION_LIMIT}`;
219
+ }
220
+ return checkRenamedSection ? `Section ${getIndexSection() + 1}` : props?.name;
221
+ };
171
222
  return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
172
223
  children: [
173
224
  !(props.tag == 'Section' && isThemeSectionEditor) && /*#__PURE__*/ jsxRuntime.jsxs("div", {
@@ -218,10 +269,10 @@ const ComponentToolbarPreview = ({ ...props })=>{
218
269
  }),
219
270
  props.tag == 'Section' ? /*#__PURE__*/ jsxRuntime.jsx("div", {
220
271
  "data-toolbar-name": true,
221
- children: isThemeSection ? props.name : `Section ${getIndexSection() + 1}${getSectionNumber() >= SECTION_LIMIT - 5 ? `/${SECTION_LIMIT}` : ''}`
272
+ children: getSectionName()
222
273
  }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
223
274
  "data-toolbar-name": true,
224
- children: props.customLabel || props.label
275
+ children: toolbarName()
225
276
  }),
226
277
  props.tag !== 'Section' && parents.length > 0 && /*#__PURE__*/ jsxRuntime.jsx("div", {
227
278
  "data-toolbar-icon-parent": true,
@@ -239,12 +290,21 @@ const ComponentToolbarPreview = ({ ...props })=>{
239
290
  })
240
291
  ]
241
292
  }),
242
- isShowParent && parents.map((parent, index)=>/*#__PURE__*/ jsxRuntime.jsxs("div", {
293
+ isShowParent && parents.map((parent, index)=>{
294
+ // Update count columns of Row
295
+ const parentLength = parent?.childrens?.length ?? 0;
296
+ let parent_label = parent.label;
297
+ if (parent.label === 'Row') {
298
+ parent_label = parentLength <= 1 ? parent.label + ' ' + parentLength + ' col' : parent.label + ' ' + parentLength + ' cols';
299
+ }
300
+ return /*#__PURE__*/ jsxRuntime.jsxs("div", {
243
301
  "data-toolbar-parent": true,
244
302
  "data-parent-uid": parent.uid,
245
303
  "data-toolbar-theme-section": isThemeSectionEditor,
304
+ "data-toolbar-parent-revert": isShowParentRevert,
246
305
  style: {
247
- top: !isShowParentRevert ? `${-24 * (index + 1) + index}px` : `${31 + 24 * index - index}px`
306
+ top: !isShowParentRevert ? `${-36 * (index + 1)}px` // 32 height + 4 spacing
307
+ : `${36 * (index + 1)}px`
248
308
  },
249
309
  children: [
250
310
  /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -284,11 +344,12 @@ const ComponentToolbarPreview = ({ ...props })=>{
284
344
  }),
285
345
  /*#__PURE__*/ jsxRuntime.jsx("div", {
286
346
  "data-toolbar-name": true,
287
- children: parent.label
347
+ children: parent_label
288
348
  })
289
349
  ]
290
- }, parent.uid)),
291
- editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
350
+ }, parent.uid);
351
+ }),
352
+ props.tag === 'Section' && !props.isThemeSection && editingPageType !== 'STATIC' && getIndexSection() < SECTION_LIMIT && /*#__PURE__*/ jsxRuntime.jsx(CreateThemeSection.CreateThemeSection, {
292
353
  ...props
293
354
  }),
294
355
  props.tag == 'Sticky' && /*#__PURE__*/ jsxRuntime.jsx("div", {
@@ -375,8 +436,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
375
436
  viewBox: "0 0 16 16",
376
437
  fill: "none",
377
438
  children: /*#__PURE__*/ jsxRuntime.jsx("path", {
378
- d: "M8.5 1.5C8.5 1.22386 8.27614 1 8 1C7.72386 1 7.5 1.22386 7.5 1.5V7.5H1.5C1.22386 7.5 1 7.72386 1 8C1 8.27614 1.22386 8.5 1.5 8.5H7.5V14.5C7.5 14.7761 7.72386 15 8 15C8.27614 15 8.5 14.7761 8.5 14.5V8.5H14.5C14.7761 8.5 15 8.27614 15 8C15 7.72386 14.7761 7.5 14.5 7.5H8.5V1.5Z",
379
- fill: "currentColor"
439
+ d: "M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",
440
+ fill: "#212121"
380
441
  })
381
442
  })
382
443
  }),
@@ -395,8 +456,8 @@ const ComponentToolbarPreview = ({ ...props })=>{
395
456
  viewBox: "0 0 16 16",
396
457
  fill: "none",
397
458
  children: /*#__PURE__*/ jsxRuntime.jsx("path", {
398
- d: "M8.5 1.5C8.5 1.22386 8.27614 1 8 1C7.72386 1 7.5 1.22386 7.5 1.5V7.5H1.5C1.22386 7.5 1 7.72386 1 8C1 8.27614 1.22386 8.5 1.5 8.5H7.5V14.5C7.5 14.7761 7.72386 15 8 15C8.27614 15 8.5 14.7761 8.5 14.5V8.5H14.5C14.7761 8.5 15 8.27614 15 8C15 7.72386 14.7761 7.5 14.5 7.5H8.5V1.5Z",
399
- fill: "currentColor"
459
+ d: "M8.45 3.95C8.45 3.70147 8.24853 3.5 8 3.5C7.75147 3.5 7.55 3.70147 7.55 3.95V7.55H3.95C3.70147 7.55 3.5 7.75147 3.5 8C3.5 8.24853 3.70147 8.45 3.95 8.45H7.55V12.05C7.55 12.2985 7.75147 12.5 8 12.5C8.24853 12.5 8.45 12.2985 8.45 12.05V8.45H12.05C12.2985 8.45 12.5 8.24853 12.5 8C12.5 7.75147 12.2985 7.55 12.05 7.55H8.45V3.95Z",
460
+ fill: "#212121"
400
461
  })
401
462
  })
402
463
  })
@@ -20,6 +20,7 @@ const ComponentWrapper = ({ children, ...props })=>{
20
20
  advanced: advanced
21
21
  }),
22
22
  /*#__PURE__*/ jsxRuntime.jsx(children.type, {
23
+ className: advanced?.cssClass,
23
24
  ...children.props,
24
25
  style,
25
26
  advanced
@@ -35,7 +36,7 @@ const ComponentWrapper = ({ children, ...props })=>{
35
36
  }),
36
37
  /*#__PURE__*/ jsxRuntime.jsx("div", {
37
38
  style: style,
38
- className: `${props.uid}`,
39
+ className: `${props.uid} ${advanced?.cssClass}`,
39
40
  children: children
40
41
  })
41
42
  ]
@@ -8,8 +8,23 @@ var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
8
8
  var constant = require('./constant.js');
9
9
  var RenderCustomCode = require('./RenderCustomCode.js');
10
10
  var ComponentToolbarPreview = require('./ComponentToolbarPreview.js');
11
+ var useApplyAnimation = require('../hooks/animation/useApplyAnimation.js');
11
12
 
12
13
  const ComponentWrapperPreview = ({ children, ...props })=>{
14
+ react.useEffect(()=>{
15
+ const event = new CustomEvent('editor:component:render', {
16
+ bubbles: true,
17
+ detail: {
18
+ componentUid: props.uid
19
+ }
20
+ });
21
+ window.dispatchEvent(event);
22
+ }, [
23
+ props.uid
24
+ ]);
25
+ useApplyAnimation.default({
26
+ props
27
+ });
13
28
  if (props.type === 'section') {
14
29
  return null;
15
30
  }
@@ -23,6 +38,9 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
23
38
  if (editorConfigs.placeholder?.notAppendBeforeAfter) {
24
39
  customProps['data-placeholder-not-append-before-after'] = true;
25
40
  }
41
+ if (editorConfigs.placeholder?.notAppendLeftRight) {
42
+ customProps['data-placeholder-not-append-left-right'] = true;
43
+ }
26
44
  if (editorConfigs.toolbar?.parent) {
27
45
  customProps['data-toolbar-parent'] = true;
28
46
  }
@@ -95,11 +113,20 @@ const ComponentWrapperPreview = ({ children, ...props })=>{
95
113
  advanced: advanced
96
114
  }),
97
115
  /*#__PURE__*/ jsxRuntime.jsxs("div", {
98
- style: style,
116
+ style: !constant.excludeApplyStyle.includes(props.tag) ? style : {
117
+ '--mb': style?.['--mb'],
118
+ '--mb-tablet': style?.['--mb-tablet'],
119
+ '--mb-mobile': style?.['--mb-mobile']
120
+ },
99
121
  className: `${props.uid} ${props.advanced?.cssClass ? props.advanced?.cssClass : ''}`,
100
122
  ...builderAttrs,
101
123
  children: [
102
- children,
124
+ !constant.excludeApplyStyle.includes(props.tag) && children,
125
+ /*#__PURE__*/ react.isValidElement(children) && constant.excludeApplyStyle.includes(props.tag) && /*#__PURE__*/ jsxRuntime.jsx(children.type, {
126
+ ...children.props,
127
+ style,
128
+ advanced
129
+ }),
103
130
  /*#__PURE__*/ jsxRuntime.jsx(ComponentToolbarPreview.ComponentToolbarPreview, {
104
131
  ...props
105
132
  })
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var makeStyle = require('../helpers/make-style.js');
5
6
  require('react');
6
7
  require('react/jsx-runtime');
7
8
  require('zustand');
@@ -13,7 +14,7 @@ require('../hooks/useCartUI.js');
13
14
  require('react-transition-group');
14
15
  require('@gem-sdk/core');
15
16
  var render = require('../helpers/render.js');
16
- require('../helpers/convert.js');
17
+ var convert = require('../helpers/convert.js');
17
18
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
18
19
  var constant = require('./constant.js');
19
20
 
@@ -24,6 +25,13 @@ const componentTexts = [
24
25
  'Text',
25
26
  'Heading'
26
27
  ];
28
+ const componentIconList = [
29
+ 'IconListV2',
30
+ 'IconList'
31
+ ];
32
+ const componentUsingAdvanced = [
33
+ 'IconList'
34
+ ];
27
35
  const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, ...passProps })=>{
28
36
  const item = builder[uid];
29
37
  const Component = components[item?.tag];
@@ -104,7 +112,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
104
112
  });
105
113
  });
106
114
  } else {
107
- liquid = render.template`<div style="${style}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
115
+ liquid = render.template`<div style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
108
116
  ${render.RenderIf(item?.childrens?.length, ()=>{
109
117
  return Component({
110
118
  builderProps: {
@@ -114,6 +122,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
114
122
  styles: item.styles,
115
123
  setting: item.settings,
116
124
  advanced: {
125
+ ...componentUsingAdvanced.includes(item.tag) ? item?.advanced : {},
117
126
  cssClass: item?.advanced?.cssClass
118
127
  },
119
128
  pageContext,
@@ -153,6 +162,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
153
162
  },
154
163
  pageContext,
155
164
  isText: componentTexts.includes(item.tag) ? true : null,
165
+ style: componentIconList.includes(item.tag) ? style : null,
156
166
  ...passProps
157
167
  });
158
168
  })}
@@ -161,6 +171,7 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
161
171
  const { cssCode, jsCode } = RenderCustomCode(item);
162
172
  if (cssCode) liquid += cssCode;
163
173
  if (jsCode) liquid += jsCode;
174
+ liquid = appendAnimation(item, liquid);
164
175
  return {
165
176
  liquid,
166
177
  extraFiles: customProps.extraFiles
@@ -190,13 +201,55 @@ const RenderCustomCode = (item)=>{
190
201
  jsCode
191
202
  };
192
203
  };
204
+ const appendAnimation = (props, liquid)=>{
205
+ const { advanced, tag } = props;
206
+ const { animation } = advanced ?? {};
207
+ const enableAnimation = animation?.desktop?.enabled || animation?.tablet?.enabled || animation?.mobile?.enabled;
208
+ if (!enableAnimation || !animation?.desktop?.triggerConfig) return liquid;
209
+ const getAnimationType = (settings, type)=>{
210
+ return settings?.triggerConfig?.[type]?.animation ?? 'none';
211
+ };
212
+ const getSettingsByDevice = (device)=>{
213
+ if (device === 'desktop') return animation?.desktop;
214
+ else if (device === 'tablet') return animation?.tablet ?? animation?.desktop;
215
+ else if (device === 'mobile') return animation?.mobile ?? animation?.tablet ?? animation?.desktop;
216
+ return animation?.desktop;
217
+ };
218
+ const getInitOpacity = (device)=>+!(getSettingsByDevice(device)?.enabled && ![
219
+ 'shake',
220
+ 'none'
221
+ ].includes(getAnimationType(getSettingsByDevice(device), 'appear')));
222
+ const opacityObject = {
223
+ desktop: getInitOpacity('desktop'),
224
+ tablet: getInitOpacity('tablet'),
225
+ mobile: getInitOpacity('mobile')
226
+ };
227
+ const inheritParentStyle = {
228
+ all: tag === 'Section' ? '' : 'inherit'
229
+ };
230
+ return render.template`
231
+ ${render.RenderIf(convert.isLocalEnv, `<script src="{{ 'gp-animation.js' | asset_url }}" defer="defer"></script>`, `<script src="${convert.baseAssetURL}/assets/gp-animation.js" defer="defer"></script>`)}
232
+ <gp-animation
233
+ gp-data='${JSON.stringify({
234
+ config: animation,
235
+ tag
236
+ })}'
237
+ style="${{
238
+ ...inheritParentStyle
239
+ }}"
240
+ >
241
+ <div style="${{
242
+ ...makeStyle.makeStyleResponsive('op', opacityObject)
243
+ }}">${liquid}</div>
244
+ </gp-animation>
245
+ `;
246
+ };
193
247
  const RenderChildren = (props)=>{
194
248
  const data = Render(props);
195
249
  // Append to prop parent
196
250
  for(const key in data.extraFiles){
197
251
  if (Object.prototype.hasOwnProperty.call(data.extraFiles, key)) {
198
- const value = data.extraFiles[key];
199
- props.customProps.extraFiles[key] = value;
252
+ props.customProps.extraFiles[key] = data.extraFiles[key];
200
253
  }
201
254
  }
202
255
  // Fix limit 256kb
@@ -205,7 +258,7 @@ const RenderChildren = (props)=>{
205
258
  if (Math.ceil(size / 1024) >= 180) {
206
259
  const fileName = `gp-section-snippet-${props.uid}`;
207
260
  props.customProps.extraFiles[fileName] = data.liquid;
208
- return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
261
+ return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
209
262
  }
210
263
  return data.liquid;
211
264
  };
@@ -222,7 +275,7 @@ const WrapRenderChildren = ({ uid, customProps }, codes)=>{
222
275
  if (Math.ceil(size / 1024) >= 180) {
223
276
  const fileName = `gp-section-snippet-${uid + i}`;
224
277
  customProps.extraFiles[fileName] = code;
225
- liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
278
+ liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant, form: form %}`;
226
279
  } else {
227
280
  liquid += code;
228
281
  }
@@ -20,7 +20,6 @@ const disableWrap = [
20
20
  'Header',
21
21
  'HeroBanner',
22
22
  'Icon',
23
- 'IconList',
24
23
  'HTMLCode',
25
24
  'IconListHoz',
26
25
  'IconListItem',
@@ -35,7 +34,8 @@ const disableWrap = [
35
34
  'Product',
36
35
  'ProductImages',
37
36
  'ProductImagesV2',
38
- 'Sticky'
37
+ 'Sticky',
38
+ 'Heading'
39
39
  ];
40
40
  const customRenderChildren = [
41
41
  'Accordion',
@@ -44,6 +44,11 @@ const customRenderChildren = [
44
44
  'IconList',
45
45
  'Tabs'
46
46
  ];
47
+ const excludeApplyStyle = [
48
+ 'IconListV2',
49
+ 'IconList'
50
+ ];
47
51
 
48
52
  exports.customRenderChildren = customRenderChildren;
49
53
  exports.disableWrap = disableWrap;
54
+ exports.excludeApplyStyle = excludeApplyStyle;
@@ -92,26 +92,111 @@ function Spacing(props) {
92
92
  document.removeEventListener('mouseup', onMouseUpDocument);
93
93
  };
94
94
  const onMouseDown = (event)=>{
95
- event.preventDefault();
96
- event.stopPropagation();
97
95
  if ($bottomDrag.current) {
98
96
  const style = getComputedStyle($bottomDrag.current);
99
97
  startY.current = event.clientY;
100
98
  marginBottom.current = parseFloat(style.top);
101
99
  startDrag();
102
100
  }
103
- return false;
104
101
  };
105
- const onMouseUp = (event)=>{
106
- event.preventDefault();
107
- event.stopPropagation();
102
+ const onMouseUp = ()=>{
108
103
  endDrag();
109
- return false;
110
104
  };
105
+ const getChildrenByAttrSelector = ($el, attrSelector)=>{
106
+ const childLen = $el.children.length;
107
+ if (childLen) {
108
+ for(let i = 0; i < childLen; i++){
109
+ const children = $el.children[i];
110
+ if (children) {
111
+ const is = children.getAttribute(attrSelector);
112
+ if (is) {
113
+ return children;
114
+ }
115
+ }
116
+ }
117
+ }
118
+ };
119
+ const onUpdateMarginBottom = react.useCallback((e)=>{
120
+ if (isDragging.current) return;
121
+ const detail = e.detail;
122
+ const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
123
+ const toolbar = $component && getChildrenByAttrSelector($component, 'data-toolbar');
124
+ const isActive = toolbar && toolbar.getAttribute('data-toolbar-active');
125
+ if (isActive && detail?.marginBottom !== undefined && detail?.marginBottom != null) {
126
+ const currentValue = parseInt(detail?.marginBottom);
127
+ const newValue = `${currentValue}px`;
128
+ if ($bottomDrag.current && $bottomBg.current) {
129
+ if (currentValue < 0) {
130
+ $bottomBg.current.style.display = 'none';
131
+ $bottomDrag.current.style.display = 'none';
132
+ } else {
133
+ $bottomBg.current.style.display = 'block';
134
+ $bottomDrag.current.style.display = 'block';
135
+ $bottomBg.current.style.height = newValue;
136
+ $bottomDrag.current.style.top = newValue;
137
+ $component.style.marginBottom = newValue;
138
+ }
139
+ }
140
+ }
141
+ }, []);
142
+ const isPopup = (el)=>{
143
+ const tag = el.getAttribute('data-component-tag');
144
+ return tag === 'Dialog';
145
+ };
146
+ const isSticky = (el)=>{
147
+ const tag = el.getAttribute('data-component-tag');
148
+ return tag === 'Sticky';
149
+ };
150
+ const setPositionSpacing = react.useCallback((paddingLeft)=>{
151
+ const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
152
+ if ($component) {
153
+ if (isPopup($component) || isSticky($component)) return;
154
+ const toolbar = $component && getChildrenByAttrSelector($component, 'data-toolbar');
155
+ const isActive = toolbar && toolbar.getAttribute('data-toolbar-active');
156
+ if (isActive && paddingLeft) {
157
+ const currentValue = isNaN(parseInt(paddingLeft)) ? 0 : Math.max(parseInt(paddingLeft), 0);
158
+ const newValue = `-${currentValue}px`;
159
+ const translateCss = `translate(-${currentValue}px, -100%)`;
160
+ if ($bottomDrag.current && $bottomBg.current) {
161
+ $bottomBg.current.style.left = newValue;
162
+ $bottomDrag.current.style.transform = translateCss;
163
+ }
164
+ }
165
+ }
166
+ }, []);
167
+ const onUpdatePaddingLeft = react.useCallback((e)=>{
168
+ if (isDragging.current) return;
169
+ const detail = e.detail;
170
+ if (detail?.paddingLeft) {
171
+ setPositionSpacing(detail.paddingLeft);
172
+ }
173
+ }, [
174
+ setPositionSpacing
175
+ ]);
176
+ react.useEffect(()=>{
177
+ const $component = $bottomDrag.current?.closest('[data-toolbar-wrap]');
178
+ if ($component) {
179
+ const style = getComputedStyle($component);
180
+ const paddingLeft = style.paddingLeft;
181
+ setPositionSpacing(paddingLeft);
182
+ }
183
+ });
184
+ react.useEffect(()=>{
185
+ window.addEventListener('editor:toolbar:update-margin-bottom', onUpdateMarginBottom);
186
+ window.addEventListener('editor:toolbar:update-padding-left', onUpdatePaddingLeft);
187
+ return ()=>{
188
+ window.removeEventListener('editor:toolbar:update-margin-bottom', onUpdateMarginBottom);
189
+ window.removeEventListener('editor:toolbar:update-padding-left', onUpdatePaddingLeft);
190
+ };
191
+ }, [
192
+ onUpdateMarginBottom,
193
+ onUpdatePaddingLeft
194
+ ]);
111
195
  return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
112
196
  children: props.tag !== 'Section' && /*#__PURE__*/ jsxRuntime.jsx("div", {
113
197
  "data-spacing": true,
114
198
  "data-spacing-theme-section": isThemeSectionEditor,
199
+ className: "absolute w-full bottom-0",
115
200
  children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
116
201
  "data-spacing-margin-bottom": true,
117
202
  children: [
@@ -15,15 +15,14 @@ require('../../helpers/convert.js');
15
15
  const SHOW_TOOLTIP_TIMEOUT = 600;
16
16
  const NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP = 1;
17
17
  const LIMIT_PLANS = [
18
+ 'starter',
18
19
  'trial',
19
20
  'trial2022'
20
21
  ];
21
22
  const CreateThemeSection = ({ ...props })=>{
22
- const isThemeSection = props.isThemeSection;
23
23
  const shopPlan = ShopContext.useShopStore((s)=>s.plan);
24
24
  const createThemeSectionCount = ShopContext.useShopStore((s)=>s.createThemeSectionCount);
25
25
  const isLimit = LIMIT_PLANS.includes(shopPlan ?? '');
26
- const isRenderCreateThemeSection = props.tag === 'Section' && !isThemeSection;
27
26
  const isRenderTooltip = isLimit || createThemeSectionCount === undefined || createThemeSectionCount < NUMBER_OF_THEME_SECTION_CREATED_TO_SHOW_TOOLTIP;
28
27
  const timeoutRef = react.useRef();
29
28
  const [isShowTooltip, setIsShowTooltip] = react.useState(false);
@@ -71,11 +70,11 @@ const CreateThemeSection = ({ ...props })=>{
71
70
  onMouseEnter: showTooltip,
72
71
  onMouseLeave: hideTooltip,
73
72
  children: [
74
- isRenderCreateThemeSection && isRenderTooltip && /*#__PURE__*/ jsxRuntime.jsx("div", {
73
+ isRenderTooltip && /*#__PURE__*/ jsxRuntime.jsx("div", {
75
74
  "data-toolbar-create-theme-section": true,
76
75
  children: "You can create reusable sections"
77
76
  }),
78
- isRenderCreateThemeSection && /*#__PURE__*/ jsxRuntime.jsx("div", {
77
+ /*#__PURE__*/ jsxRuntime.jsx("div", {
79
78
  "data-toolbar-active-create-theme-section-wrapper": true,
80
79
  children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
81
80
  "data-toolbar-active-create-theme-section": true,
@@ -105,7 +104,7 @@ const CreateThemeSection = ({ ...props })=>{
105
104
  ]
106
105
  }),
107
106
  /*#__PURE__*/ jsxRuntime.jsx("p", {
108
- children: "Create Theme section"
107
+ children: "Create Theme Section"
109
108
  })
110
109
  ]
111
110
  })
@@ -26,7 +26,7 @@ const ThemeSectionStatus = ({ ...props })=>{
26
26
  }),
27
27
  /*#__PURE__*/ jsxRuntime.jsx("span", {
28
28
  "data-theme-section-status-text": true,
29
- children: "Need to republish. Go to global edit to publish it"
29
+ children: "Need to republish. Go to global edit and publish this section"
30
30
  })
31
31
  ]
32
32
  })
@@ -29,8 +29,9 @@ const transitions = {
29
29
  };
30
30
  const ThemeSectionTooltip = ({ isShow, isLimit, isRender, children, onMouseEnter, onMouseLeave, onActions })=>{
31
31
  const nodeRef = react.useRef(null);
32
+ const actionBtnLabel = isLimit ? 'Upgrade to create Theme Section' : 'Create Theme Section';
32
33
  const openHelpCenter = ()=>{
33
- const url = 'index';
34
+ const url = 'https://help.gempages.net/articles/theme-section';
34
35
  window.open(url, '_blank');
35
36
  };
36
37
  return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {
@@ -65,7 +66,7 @@ const ThemeSectionTooltip = ({ isShow, isLimit, isRender, children, onMouseEnter
65
66
  children: [
66
67
  /*#__PURE__*/ jsxRuntime.jsx("div", {
67
68
  className: "theme-section-tooltip__body-title",
68
- children: "Create once, use everywhere with Theme section"
69
+ children: "Create once, use everywhere with Theme Section"
69
70
  }),
70
71
  /*#__PURE__*/ jsxRuntime.jsx("div", {
71
72
  className: "theme-section-tooltip__body-desc",
@@ -80,13 +81,13 @@ const ThemeSectionTooltip = ({ isShow, isLimit, isRender, children, onMouseEnter
80
81
  children: [
81
82
  /*#__PURE__*/ jsxRuntime.jsx("button", {
82
83
  onClick: (e)=>onActions(e),
83
- children: isLimit ? 'Upgrade to create Theme section' : 'Create Theme section'
84
+ children: actionBtnLabel
84
85
  }),
85
86
  isLimit && /*#__PURE__*/ jsxRuntime.jsx("div", {
86
87
  onClick: openHelpCenter,
87
88
  "aria-hidden": true,
88
89
  className: "theme-section-tooltip__action-learn-more",
89
- children: "Learn more about Theme section"
90
+ children: "Learn more about Theme Section"
90
91
  })
91
92
  ]
92
93
  })